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 MAGNETO6_REG_MAGNETIC_X_MSB 0x00
74 #define MAGNETO6_REG_MAGNETIC_Y_MSB 0x01
75 #define MAGNETO6_REG_MAGNETIC_Z_MSB 0x02
76 #define MAGNETO6_REG_TEMPERATURE_MSB 0x03
77 #define MAGNETO6_REG_MAGNETIC_XY_LSB 0x04
78 #define MAGNETO6_REG_TEMPERATURE_Z_LSB 0x05
79 #define MAGNETO6_REG_DIAG 0x06
80 #define MAGNETO6_REG_CONFIG 0x10
81 #define MAGNETO6_REG_MOD1 0x11
82 #define MAGNETO6_REG_MOD2 0x13
83 #define MAGNETO6_REG_VERSION 0x16
101 #define MAGNETO6_CONFIG_DISABLE_TEMP 0x80
102 #define MAGNETO6_CONFIG_ENABLE_ANGULAR_XY 0x40
103 #define MAGNETO6_CONFIG_TRIGGER_DISABLE 0x00
104 #define MAGNETO6_CONFIG_TRIGGER_MSB 0x10
105 #define MAGNETO6_CONFIG_TRIGGER_REG_READ 0x20
106 #define MAGNETO6_CONFIG_TRIGGER_MASK 0x30
107 #define MAGNETO6_CONFIG_SHORT_RANGE_SENS_EN 0x08
108 #define MAGNETO6_CONFIG_TL_COMP_TC0 0x00
109 #define MAGNETO6_CONFIG_TL_COMP_TC1 0x02
110 #define MAGNETO6_CONFIG_TL_COMP_TC2 0x04
111 #define MAGNETO6_CONFIG_TL_COMP_TC3 0x06
112 #define MAGNETO6_CONFIG_TL_COMP_MASK 0x06
113 #define MAGNETO6_CONFIG_PARITY_BIT 0x01
119 #define MAGNETO6_MOD1_FUSE_PARITY 0x80
120 #define MAGNETO6_MOD1_I2C_ADDR_0 0x00
121 #define MAGNETO6_MOD1_I2C_ADDR_1 0x20
122 #define MAGNETO6_MOD1_I2C_ADDR_2 0x40
123 #define MAGNETO6_MOD1_I2C_ADDR_3 0x60
124 #define MAGNETO6_MOD1_I2C_ADDR_MASK 0x60
125 #define MAGNETO6_MOD1_1BYTE_READ_EN 0x10
126 #define MAGNETO6_MOD1_COLLISION_AVOID 0x08
127 #define MAGNETO6_MOD1_INT_DISABLE 0x04
128 #define MAGNETO6_MOD1_MODE_LOW_POWER 0x00
129 #define MAGNETO6_MOD1_MODE_MASTER 0x01
130 #define MAGNETO6_MOD1_MODE_FAST 0x03
131 #define MAGNETO6_MOD1_MODE_MASK 0x03
137 #define MAGNETO6_MOD2_FUPDATE_SLOW 0x80
138 #define MAGNETO6_MOD2_FACTORY_MASK 0x7F
144 #define MAGNETO6_DIAG_BUS_PARITY 0x80
145 #define MAGNETO6_DIAG_FUSE_PARITY 0x40
146 #define MAGNETO6_DIAG_CFG_PARITY 0x20
147 #define MAGNETO6_DIAG_T_BIT 0x10
148 #define MAGNETO6_DIAG_PD3_FLAG 0x08
149 #define MAGNETO6_DIAG_PD0_FLAG 0x04
150 #define MAGNETO6_DIAG_FRAME_COUNTER_MASK 0x03
156 #define MAGNETO6_VERSION_FACTORY_MASK 0xC0
157 #define MAGNETO6_VERSION_TYPE_MASK 0x30
158 #define MAGNETO6_VERSION_HWV_MASK 0x0F
164 #define MAGNETO6_TEMP_25_DIGIT 1180
165 #define MAGNETO6_TEMP_25 25
166 #define MAGNETO6_TEMP_RES 0.24f
167 #define MAGNETO6_MAGNETIC_RES_MILLI_T 0.13f
173 #define MAGNETO6_I2C_TIMEOUT 100000ul
180 #define MAGNETO6_DEVICE_ADDRESS_0 0x35
181 #define MAGNETO6_DEVICE_ADDRESS_1 0x22
182 #define MAGNETO6_DEVICE_ADDRESS_2 0x78
183 #define MAGNETO6_DEVICE_ADDRESS_3 0x44
201 #define MAGNETO6_MAP_MIKROBUS( cfg, mikrobus ) \
202 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
203 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
204 cfg.ien = MIKROBUS( mikrobus, MIKROBUS_CS ); \
205 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
float temperature
Definition: magneto6.h:219
uint8_t slave_address
Definition: magneto6.h:242
float z_data
Definition: magneto6.h:218
pin_name_t ien
Definition: magneto6.h:255
uint8_t magneto6_get_int_pin(magneto6_t *ctx)
Magneto 6 get int pin function.
err_t magneto6_default_cfg(magneto6_t *ctx)
Magneto 6 default configuration function.
err_t magneto6_read_reg(magneto6_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Magneto 6 read reg function.
void magneto6_cfg_setup(magneto6_cfg_t *cfg)
Magneto 6 configuration object setup function.
pin_name_t scl
Definition: magneto6.h:252
digital_out_t ien
Definition: magneto6.h:230
uint8_t i2c_address
Definition: magneto6.h:258
@ MAGNETO6_OK
Definition: magneto6.h:268
pin_name_t int_pin
Definition: magneto6.h:256
void magneto6_set_ien_pin(magneto6_t *ctx, uint8_t state)
Magneto 6 set ien pin function.
Magneto 6 Click data object.
Definition: magneto6.h:215
pin_name_t sda
Definition: magneto6.h:253
err_t magneto6_read_data(magneto6_t *ctx, magneto6_data_t *data_out)
Magneto 6 read data function.
magneto6_return_value_t
Magneto 6 Click return value data.
Definition: magneto6.h:267
@ MAGNETO6_ERROR
Definition: magneto6.h:269
float y_data
Definition: magneto6.h:217
digital_in_t int_pin
Definition: magneto6.h:233
pin_name_t scl
Definition: magneto6.h:236
uint8_t i2c_started
Definition: magneto6.h:239
Magneto 6 Click configuration object.
Definition: magneto6.h:251
Magneto 6 Click context object.
Definition: magneto6.h:228
float x_data
Definition: magneto6.h:216
err_t magneto6_init(magneto6_t *ctx, magneto6_cfg_t *cfg)
Magneto 6 initialization function.
err_t magneto6_write_reg(magneto6_t *ctx, uint8_t reg, uint8_t data_in)
Magneto 6 write reg function.
pin_name_t sda
Definition: magneto6.h:237