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 C3DHALL11_REG_DEVICE_CONFIG_1 0x00
74#define C3DHALL11_REG_DEVICE_CONFIG_2 0x01
75#define C3DHALL11_REG_SENSOR_CONFIG_1 0x02
76#define C3DHALL11_REG_SENSOR_CONFIG_2 0x03
77#define C3DHALL11_REG_X_THR_CONFIG 0x04
78#define C3DHALL11_REG_Y_THR_CONFIG 0x05
79#define C3DHALL11_REG_Z_THR_CONFIG 0x06
80#define C3DHALL11_REG_T_CONFIG 0x07
81#define C3DHALL11_REG_INT_CONFIG_1 0x08
82#define C3DHALL11_REG_MAG_GAIN_CONFIG 0x09
83#define C3DHALL11_REG_MAG_OFFSET_CONFIG_1 0x0A
84#define C3DHALL11_REG_MAG_OFFSET_CONFIG_2 0x0B
85#define C3DHALL11_REG_I2C_ADDRESS 0x0C
86#define C3DHALL11_REG_DEVICE_ID 0x0D
87#define C3DHALL11_REG_MANUFACTURER_ID_LSB 0x0E
88#define C3DHALL11_REG_MANUFACTURER_ID_MSB 0x0F
89#define C3DHALL11_REG_T_MSB_RESULT 0x10
90#define C3DHALL11_REG_T_LSB_RESULT 0x11
91#define C3DHALL11_REG_X_MSB_RESULT 0x12
92#define C3DHALL11_REG_X_LSB_RESULT 0x13
93#define C3DHALL11_REG_Y_MSB_RESULT 0x14
94#define C3DHALL11_REG_Y_LSB_RESULT 0x15
95#define C3DHALL11_REG_Z_MSB_RESULT 0x16
96#define C3DHALL11_REG_Z_LSB_RESULT 0x17
97#define C3DHALL11_REG_CONV_STATUS 0x18
98#define C3DHALL11_REG_ANGLE_RESULT_MSB 0x19
99#define C3DHALL11_REG_ANGLE_RESULT_LSB 0x1A
100#define C3DHALL11_REG_MAGNITUDE_RESULT 0x1B
101#define C3DHALL11_REG_DEVICE_STATUS 0x1C
119#define C3DHALL11_CRC_DISABLE 0x00
120#define C3DHALL11_CRC_ENABLE 0x80
121#define C3DHALL11_CRC_EN_BIT_MASK 0x80
122#define C3DHALL11_MAG_TEMPCO_0 0x00
123#define C3DHALL11_MAG_TEMPCO_0p12 0x20
124#define C3DHALL11_MAG_TEMPCO_0p2 0x60
125#define C3DHALL11_MAG_TEMPCO_BIT_MASK 0x60
126#define C3DHALL11_CONV_AVG_1X 0x00
127#define C3DHALL11_CONV_AVG_2X 0x04
128#define C3DHALL11_CONV_AVG_4X 0x08
129#define C3DHALL11_CONV_AVG_8X 0x0C
130#define C3DHALL11_CONV_AVG_16X 0x10
131#define C3DHALL11_CONV_AVG_32X 0x14
132#define C3DHALL11_CONV_AVG_BIT_MASK 0x1C
133#define C3DHALL11_I2C_RD_STANDARD 0x00
134#define C3DHALL11_I2C_RD_1_BYTE_16BIT 0x01
135#define C3DHALL11_I2C_RD_1_BYTE_8BIT 0x02
136#define C3DHALL11_I2C_RD_BIT_MASK 0x03
142#define C3DHALL11_THR_HYST_2S_COMPLEMENT 0x00
143#define C3DHALL11_THR_HYST_7LSB 0x20
144#define C3DHALL11_THR_HYST_BIT_MASK 0xE0
145#define C3DHALL11_LP_LN_ACTUVE_CURRENT_MODE 0x00
146#define C3DHALL11_LP_LN_NOISE_MODE 0x10
147#define C3DHALL11_LP_LN_BIT_MASK 0x10
148#define C3DHALL11_I2C_GLITCH_FILTER_ON 0x00
149#define C3DHALL11_I2C_GLITCH_FILTER_OFF 0x08
150#define C3DHALL11_I2C_GLITCH_FILTER_BIT_MASK 0x08
151#define C3DHALL11_TRIGGER_MODE_CMD 0x00
152#define C3DHALL11_TRIGGER_MODE_INT 0x04
153#define C3DHALL11_TRIGGER_MODE_BIT_MASK 0x04
154#define C3DHALL11_OPERATING_MODE_STANDBY 0x00
155#define C3DHALL11_OPERATING_MODE_SLEEP 0x01
156#define C3DHALL11_OPERATING_MODE_CONTINUOUS 0x02
157#define C3DHALL11_OPERATING_MODE_WS 0x03
158#define C3DHALL11_OPERATING_MODE_BIT_MASK 0x03
164#define C3DHALL11_MAG_CH_EN_DISABLE 0x00
165#define C3DHALL11_MAG_CH_EN_ENABLE_X 0x10
166#define C3DHALL11_MAG_CH_EN_ENABLE_Y 0x20
167#define C3DHALL11_MAG_CH_EN_ENABLE_XY 0x30
168#define C3DHALL11_MAG_CH_EN_ENABLE_Z 0x40
169#define C3DHALL11_MAG_CH_EN_ENABLE_ZX 0x50
170#define C3DHALL11_MAG_CH_EN_ENABLE_YZ 0x60
171#define C3DHALL11_MAG_CH_EN_ENABLE_XYZ 0x70
172#define C3DHALL11_MAG_CH_EN_ENABLE_XYX 0x80
173#define C3DHALL11_MAG_CH_EN_ENABLE_YXY 0x90
174#define C3DHALL11_MAG_CH_EN_ENABLE_YZY 0xA0
175#define C3DHALL11_MAG_CH_EN_ENABLE_XZX 0xB0
176#define C3DHALL11_MAG_CH_EN_BIT_MASK 0xF0
177#define C3DHALL11_SLEEPTIME_1MS 0x00
178#define C3DHALL11_SLEEPTIME_5MS 0x01
179#define C3DHALL11_SLEEPTIME_10MS 0x02
180#define C3DHALL11_SLEEPTIME_15MS 0x03
181#define C3DHALL11_SLEEPTIME_20MS 0x04
182#define C3DHALL11_SLEEPTIME_30MS 0x05
183#define C3DHALL11_SLEEPTIME_50MS 0x06
184#define C3DHALL11_SLEEPTIME_100MS 0x07
185#define C3DHALL11_SLEEPTIME_500MS 0x08
186#define C3DHALL11_SLEEPTIME_1000MS 0x09
187#define C3DHALL11_SLEEPTIME_2000MS 0x0A
188#define C3DHALL11_SLEEPTIME_5000MS 0x0B
189#define C3DHALL11_SLEEPTIME_20000MS 0x0C
190#define C3DHALL11_SLEEPTIME_BIT_MASK 0x0F
196#define C3DHALL11_THRX_COUNT_1 0x00
197#define C3DHALL11_THRX_COUNT_4 0x40
198#define C3DHALL11_THRX_COUNT_BIT_MASK 0x40
199#define C3DHALL11_MAG_THR_DIR_ABOVE 0x00
200#define C3DHALL11_MAG_THR_DIR_BELOW 0x20
201#define C3DHALL11_MAG_THR_DIR_BIT_MASK 0x20
202#define C3DHALL11_MAG_GAIN_CH_1 0x00
203#define C3DHALL11_MAG_GAIN_CH_2 0x10
204#define C3DHALL11_MAG_GAIN_CH_BIT_MASK 0x10
205#define C3DHALL11_ANGLE_EN_NO_ANGLE 0x00
206#define C3DHALL11_ANGLE_EN_XY_ANGLE 0x04
207#define C3DHALL11_ANGLE_EN_YZ_ANGLE 0x08
208#define C3DHALL11_ANGLE_EN_XZ_ANGLE 0x0C
209#define C3DHALL11_ANGLE_EN_BIT_MASK 0x0C
210#define C3DHALL11_X_Y_RANGE_40mT 0x00
211#define C3DHALL11_X_Y_RANGE_80mT 0x02
212#define C3DHALL11_X_Y_RANGE_BIT_MASK 0x02
213#define C3DHALL11_Z_RANGE_40mT 0x00
214#define C3DHALL11_Z_RANGE_80mT 0x01
215#define C3DHALL11_Z_RANGE_BIT_MASK 0x01
221#define C3DHALL11_T_THR_CONFIG_BIT_MASK 0xFE
222#define C3DHALL11_T_CH_EN_DISABLE 0x00
223#define C3DHALL11_T_CH_EN_ENABLE 0x01
224#define C3DHALL11_T_CH_EN_BIT_MASK 0x01
230#define C3DHALL11_RSLT_INT_NO_ASSERT 0x00
231#define C3DHALL11_RSLT_INT_ASSERT 0x80
232#define C3DHALL11_RSLT_INT_BIT_MASK 0x80
233#define C3DHALL11_THRSLD_INT_NO_ASSERT 0x00
234#define C3DHALL11_THRSLD_INT_ASSERT 0x40
235#define C3DHALL11_THRSLD_INT_BIT_MASK 0x40
236#define C3DHALL11_INT_STATE_LATCHED 0x00
237#define C3DHALL11_INT_STATE_PULSE_10US 0x20
238#define C3DHALL11_INT_STATE_BIT_MASK 0x20
239#define C3DHALL11_INT_MODE_NO_INT 0x00
240#define C3DHALL11_INT_MODE_INT 0x04
241#define C3DHALL11_INT_MODE_INT_WO_I2C_BUSY 0x08
242#define C3DHALL11_INT_MODE_SCL 0x0C
243#define C3DHALL11_INT_MODE_SCL_WO_I2C_BUSY 0x10
244#define C3DHALL11_INT_MODE_BIT_MASK 0x1C
245#define C3DHALL11_MASK_INTB_ENABLE 0x00
246#define C3DHALL11_MASK_INTB_DISABLE 0x01
247#define C3DHALL11_MASK_INTB_BIT_MASK 0x01
253#define C3DHALL11_DEVICE_ID 0x01
254#define C3DHALL11_MANUFACTURER_ID_LSB 0x49
255#define C3DHALL11_MANUFACTURER_ID_MSB 0x54
261#define C3DHALL11_CONV_STATUS_SET_COUNT 0xE0
262#define C3DHALL11_CONV_STATUS_DIAG_STATUS 0x02
263#define C3DHALL11_CONV_STATUS_DATA_READY 0x01
269#define C3DHALL11_DEVICE_STATUS_INTB_RB 0x10
270#define C3DHALL11_DEVICE_STATUS_OSC_ER 0x08
271#define C3DHALL11_DEVICE_STATUS_INT_ER 0x04
272#define C3DHALL11_DEVICE_STATUS_OTP_CRC_ER 0x02
273#define C3DHALL11_DEVICE_STATUS_VCC_UV_ER 0x01
279#define C3DHALL11_TEMP_SENS_T0 25.0
280#define C3DHALL11_TEMP_ADC_T0 17508
281#define C3DHALL11_TEMP_ADC_RESOLUTION 60.1
282#define C3DHALL11_ANGLE_RESOLUTION 16.0
283#define C3DHALL11_XYZ_SENSITIVITY_40mT 820.0
284#define C3DHALL11_XYZ_SENSITIVITY_80mT 410.0
291#define C3DHALL11_DEVICE_ADDRESS 0x35
309#define C3DHALL11_MAP_MIKROBUS( cfg, mikrobus ) \
310 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
311 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
312 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
c3dhall11_return_value_t
3D Hall 11 Click return value data.
Definition c3dhall11.h:370
@ C3DHALL11_OK
Definition c3dhall11.h:371
@ C3DHALL11_ERROR
Definition c3dhall11.h:372
err_t c3dhall11_check_communication(c3dhall11_t *ctx)
3D Hall 11 check communication function.
void c3dhall11_cfg_setup(c3dhall11_cfg_t *cfg)
3D Hall 11 configuration object setup function.
err_t c3dhall11_write_register(c3dhall11_t *ctx, uint8_t reg, uint8_t data_in)
3D Hall 11 write register function.
err_t c3dhall11_generic_read(c3dhall11_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
3D Hall 11 I2C reading function.
err_t c3dhall11_read_data(c3dhall11_t *ctx, c3dhall11_data_t *data_out)
3D Hall 11 read data function.
err_t c3dhall11_default_cfg(c3dhall11_t *ctx)
3D Hall 11 default configuration function.
err_t c3dhall11_read_register(c3dhall11_t *ctx, uint8_t reg, uint8_t *data_out)
3D Hall 11 read register function.
err_t c3dhall11_init(c3dhall11_t *ctx, c3dhall11_cfg_t *cfg)
3D Hall 11 initialization function.
uint8_t c3dhall11_get_int_pin(c3dhall11_t *ctx)
3D Hall 11 get int pin function.
err_t c3dhall11_generic_write(c3dhall11_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
3D Hall 11 I2C writing function.
3D Hall 11 Click configuration object.
Definition c3dhall11.h:354
uint32_t i2c_speed
Definition c3dhall11.h:360
pin_name_t scl
Definition c3dhall11.h:355
pin_name_t int_pin
Definition c3dhall11.h:358
pin_name_t sda
Definition c3dhall11.h:356
uint8_t i2c_address
Definition c3dhall11.h:361
3D Hall 11 Click data object.
Definition c3dhall11.h:322
float z_axis
Definition c3dhall11.h:325
uint8_t magnitude
Definition c3dhall11.h:328
float x_axis
Definition c3dhall11.h:323
float y_axis
Definition c3dhall11.h:324
float angle
Definition c3dhall11.h:326
float temperature
Definition c3dhall11.h:327
3D Hall 11 Click context object.
Definition c3dhall11.h:337
digital_in_t int_pin
Definition c3dhall11.h:339
i2c_master_t i2c
Definition c3dhall11.h:342
uint8_t slave_address
Definition c3dhall11.h:345