Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define COMPASS8_REG_WIA1 0x00
70 #define COMPASS8_REG_WIA2 0x01
71 #define COMPASS8_REG_RSV1 0x02
72 #define COMPASS8_REG_RSV2 0x03
73 #define COMPASS8_REG_ST1 0x10
74 #define COMPASS8_REG_HXH 0x11
75 #define COMPASS8_REG_HXL 0x12
76 #define COMPASS8_REG_HYH 0x13
77 #define COMPASS8_REG_HYL 0x14
78 #define COMPASS8_REG_HZH 0x15
79 #define COMPASS8_REG_HZL 0x16
80 #define COMPASS8_REG_TMPS 0x17
81 #define COMPASS8_REG_ST2 0x18
82 #define COMPASS8_REG_CNTL1 0x30
83 #define COMPASS8_REG_CNTL2 0x31
84 #define COMPASS8_REG_CNTL3 0x32
85 #define COMPASS8_REG_TS1 0x33
86 #define COMPASS8_REG_TS2 0x34
104 #define COMPASS8_ST1_DATA_NORMAL 0x00
105 #define COMPASS8_ST1_DATA_READY 0x01
106 #define COMPASS8_ST1_DOR_NORMAL 0x00
107 #define COMPASS8_ST1_DOR_OVR 0x02
113 #define COMPASS8_CNTL1_WM_STEP_1 0x00
114 #define COMPASS8_CNTL1_WM_STEP_2 0x01
115 #define COMPASS8_CNTL1_WM_STEP_3 0x02
116 #define COMPASS8_CNTL1_ITS_OFF 0x00
117 #define COMPASS8_CNTL1_ITS_LOW 0x20
118 #define COMPASS8_CNTL1_ITS_HIGH 0x40
119 #define COMPASS8_CNTL1_ITS_HIGH1 0x60
125 #define COMPASS8_CNTL2_MODE_PD 0x00
126 #define COMPASS8_CNTL2_MODE_SNGL 0x01
127 #define COMPASS8_CNTL2_MODE_CONT1 0x02
128 #define COMPASS8_CNTL2_MODE_CONT2 0x04
129 #define COMPASS8_CNTL2_MODE_CONT3 0x05
130 #define COMPASS8_CNTL2_MODE_CONT4 0x08
131 #define COMPASS8_CNTL2_MODE_CONT5 0x0E
132 #define COMPASS8_CNTL2_MODE_BITMASK 0x0F
133 #define COMPASS8_CNTL2_MODE_ST 0x10
134 #define COMPASS8_CNTL2_IBIP_DIS 0x00
135 #define COMPASS8_CNTL2_IBIP_EN 0x20
136 #define COMPASS8_CNTL2_SDR_DIS 0x00
137 #define COMPASS8_CNTL2_SDR_EN 0x40
138 #define COMPASS8_CNTL2_FIFO_DIS 0x00
139 #define COMPASS8_CNTL2_FIFO_EN 0x80
145 #define COMPASS8_CNTL3_SRST_NORMAL 0x00
146 #define COMPASS8_CNTL3_SRST_RESET 0x01
152 #define COMPASS8_COMPANY_ID 0x48
153 #define COMPASS8_DEVICE_ID 0x0E
159 #define COMPASS8_MAG_AXIS_SENS 0.125f
166 #define COMPASS8_DEVICE_ADDRESS 0x0E
184 #define COMPASS8_MAP_MIKROBUS( cfg, mikrobus ) \
185 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
186 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
187 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
pin_name_t scl
Definition: compass8.h:215
err_t compass8_sw_reset(compass8_t *ctx)
Compass 8 soft reset function.
err_t compass8_generic_read(compass8_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Compass 8 I2C reading function.
Compass 8 Click configuration object.
Definition: compass8.h:214
err_t compass8_get_device_id(compass8_t *ctx, uint8_t *device_id)
Compass 8 get device ID function.
compass8_return_value_t
Compass 8 Click return value data.
Definition: compass8.h:242
err_t compass8_set_operation_mode(compass8_t *ctx, uint8_t op_mode)
Compass 8 set operation mode function.
void compass8_device_enable(compass8_t *ctx)
Compass 8 device enable function.
@ COMPASS8_ERROR
Definition: compass8.h:244
err_t compass8_get_operation_mode(compass8_t *ctx, uint8_t *op_mode)
Compass 8 get operation mode function.
uint8_t slave_address
Definition: compass8.h:205
float x
Definition: compass8.h:231
uint8_t i2c_address
Definition: compass8.h:221
void compass8_device_disable(compass8_t *ctx)
Compass 8 device disable function.
pin_name_t en
Definition: compass8.h:218
uint32_t i2c_speed
Definition: compass8.h:220
err_t compass8_get_magnetic_data(compass8_t *ctx, compass8_axes_t *axis)
Compass 8 get magnetic data function.
digital_out_t en
Definition: compass8.h:199
float z
Definition: compass8.h:233
err_t compass8_get_raw_data(compass8_t *ctx, int16_t *axis_x, int16_t *axis_y, int16_t *axis_z)
Compass 8 get mag raw data function.
Compass 8 Click axes magnetic flux density data.
Definition: compass8.h:230
void compass8_cfg_setup(compass8_cfg_t *cfg)
Compass 8 configuration object setup function.
i2c_master_t i2c
Definition: compass8.h:202
Compass 8 Click context object.
Definition: compass8.h:197
err_t compass8_init(compass8_t *ctx, compass8_cfg_t *cfg)
Compass 8 initialization function.
@ COMPASS8_OK
Definition: compass8.h:243
float y
Definition: compass8.h:232
err_t compass8_wait_data_ready(compass8_t *ctx)
Compass 8 wait data ready function.
err_t compass8_get_company_id(compass8_t *ctx, uint8_t *company_id)
Compass 8 get company ID function.
pin_name_t sda
Definition: compass8.h:216
err_t compass8_default_cfg(compass8_t *ctx)
Compass 8 default configuration function.
err_t compass8_generic_write(compass8_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Compass 8 I2C writing function.
err_t compass8_set_control(compass8_t *ctx, uint8_t ctrl_reg, uint8_t data_in)
Compass 8 set control function.