Go to the documentation of this file.
39 #ifdef PREINIT_SUPPORTED
43 #ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
73 #define COMPASS8_REG_WIA1 0x00
74 #define COMPASS8_REG_WIA2 0x01
75 #define COMPASS8_REG_RSV1 0x02
76 #define COMPASS8_REG_RSV2 0x03
77 #define COMPASS8_REG_ST1 0x10
78 #define COMPASS8_REG_HXH 0x11
79 #define COMPASS8_REG_HXL 0x12
80 #define COMPASS8_REG_HYH 0x13
81 #define COMPASS8_REG_HYL 0x14
82 #define COMPASS8_REG_HZH 0x15
83 #define COMPASS8_REG_HZL 0x16
84 #define COMPASS8_REG_TMPS 0x17
85 #define COMPASS8_REG_ST2 0x18
86 #define COMPASS8_REG_CNTL1 0x30
87 #define COMPASS8_REG_CNTL2 0x31
88 #define COMPASS8_REG_CNTL3 0x32
89 #define COMPASS8_REG_TS1 0x33
90 #define COMPASS8_REG_TS2 0x34
108 #define COMPASS8_ST1_DATA_NORMAL 0x00
109 #define COMPASS8_ST1_DATA_READY 0x01
110 #define COMPASS8_ST1_DOR_NORMAL 0x00
111 #define COMPASS8_ST1_DOR_OVR 0x02
117 #define COMPASS8_CNTL1_WM_STEP_1 0x00
118 #define COMPASS8_CNTL1_WM_STEP_2 0x01
119 #define COMPASS8_CNTL1_WM_STEP_3 0x02
120 #define COMPASS8_CNTL1_ITS_OFF 0x00
121 #define COMPASS8_CNTL1_ITS_LOW 0x20
122 #define COMPASS8_CNTL1_ITS_HIGH 0x40
123 #define COMPASS8_CNTL1_ITS_HIGH1 0x60
129 #define COMPASS8_CNTL2_MODE_PD 0x00
130 #define COMPASS8_CNTL2_MODE_SNGL 0x01
131 #define COMPASS8_CNTL2_MODE_CONT1 0x02
132 #define COMPASS8_CNTL2_MODE_CONT2 0x04
133 #define COMPASS8_CNTL2_MODE_CONT3 0x05
134 #define COMPASS8_CNTL2_MODE_CONT4 0x08
135 #define COMPASS8_CNTL2_MODE_CONT5 0x0E
136 #define COMPASS8_CNTL2_MODE_BITMASK 0x0F
137 #define COMPASS8_CNTL2_MODE_ST 0x10
138 #define COMPASS8_CNTL2_IBIP_DIS 0x00
139 #define COMPASS8_CNTL2_IBIP_EN 0x20
140 #define COMPASS8_CNTL2_SDR_DIS 0x00
141 #define COMPASS8_CNTL2_SDR_EN 0x40
142 #define COMPASS8_CNTL2_FIFO_DIS 0x00
143 #define COMPASS8_CNTL2_FIFO_EN 0x80
149 #define COMPASS8_CNTL3_SRST_NORMAL 0x00
150 #define COMPASS8_CNTL3_SRST_RESET 0x01
156 #define COMPASS8_COMPANY_ID 0x48
157 #define COMPASS8_DEVICE_ID 0x0E
163 #define COMPASS8_MAG_AXIS_SENS 0.125f
170 #define COMPASS8_DEVICE_ADDRESS 0x0E
188 #define COMPASS8_MAP_MIKROBUS( cfg, mikrobus ) \
189 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
190 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
191 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
pin_name_t scl
Definition: compass8.h:219
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:218
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:246
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:248
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:209
float x
Definition: compass8.h:235
uint8_t i2c_address
Definition: compass8.h:225
void compass8_device_disable(compass8_t *ctx)
Compass 8 device disable function.
pin_name_t en
Definition: compass8.h:222
uint32_t i2c_speed
Definition: compass8.h:224
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:203
float z
Definition: compass8.h:237
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:234
void compass8_cfg_setup(compass8_cfg_t *cfg)
Compass 8 configuration object setup function.
i2c_master_t i2c
Definition: compass8.h:206
Compass 8 Click context object.
Definition: compass8.h:201
err_t compass8_init(compass8_t *ctx, compass8_cfg_t *cfg)
Compass 8 initialization function.
@ COMPASS8_OK
Definition: compass8.h:247
float y
Definition: compass8.h:236
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:220
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.