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"
48 #include "drv_spi_master.h"
71 #define C6DOFIMU16_REG_ACCEL_DATA_X1_UI 0x00
72 #define C6DOFIMU16_REG_ACCEL_DATA_X0_UI 0x01
73 #define C6DOFIMU16_REG_ACCEL_DATA_Y1_UI 0x02
74 #define C6DOFIMU16_REG_ACCEL_DATA_Y0_UI 0x03
75 #define C6DOFIMU16_REG_ACCEL_DATA_Z1_UI 0x04
76 #define C6DOFIMU16_REG_ACCEL_DATA_Z0_UI 0x05
77 #define C6DOFIMU16_REG_GYRO_DATA_X1_UI 0x06
78 #define C6DOFIMU16_REG_GYRO_DATA_X0_UI 0x07
79 #define C6DOFIMU16_REG_GYRO_DATA_Y1_UI 0x08
80 #define C6DOFIMU16_REG_GYRO_DATA_Y0_UI 0x09
81 #define C6DOFIMU16_REG_GYRO_DATA_Z1_UI 0x0A
82 #define C6DOFIMU16_REG_GYRO_DATA_Z0_UI 0x0B
83 #define C6DOFIMU16_REG_TEMP_DATA1_UI 0x0C
84 #define C6DOFIMU16_REG_TEMP_DATA0_UI 0x0D
85 #define C6DOFIMU16_REG_TMST_FSYNCH 0x0E
86 #define C6DOFIMU16_REG_TMST_FSYNCL 0x0F
87 #define C6DOFIMU16_REG_PWR_MGMNT0 0x10
88 #define C6DOFIMU16_REG_FIFO_COUNT_0 0x12
89 #define C6DOFIMU16_REG_FIFO_COUNT_1 0x13
90 #define C6DOFIMU16_REG_FIFO_DATA 0x14
91 #define C6DOFIMU16_REG_INT1_CONFIG0 0x16
92 #define C6DOFIMU16_REG_INT1_CONFIG1 0x17
93 #define C6DOFIMU16_REG_INT1_CONFIG2 0x18
94 #define C6DOFIMU16_REG_INT1_STATUS0 0x19
95 #define C6DOFIMU16_REG_ACCEL_CONFIG0 0x1B
96 #define C6DOFIMU16_REG_GYRO_CONFIG0 0x1C
97 #define C6DOFIMU16_REG_FIFO_CONFIG0 0x1D
98 #define C6DOFIMU16_REG_FIFO_CONFIG1_0 0x1E
99 #define C6DOFIMU16_REG_FIFO_CONFIG1_1 0x1F
100 #define C6DOFIMU16_REG_FIFO_CONFIG2 0x20
101 #define C6DOFIMU16_REG_FIFO_CONFIG3 0x21
102 #define C6DOFIMU16_REG_FIFO_CONFIG4 0x22
103 #define C6DOFIMU16_REG_DMP_EXT_SEN_ODR_CFG 0x27
104 #define C6DOFIMU16_REG_EDMP_APEX_EN0 0x29
105 #define C6DOFIMU16_REG_EDMP_APEX_EN1 0x2A
106 #define C6DOFIMU16_REG_APEX_BUFFER_MGMT 0x2B
107 #define C6DOFIMU16_REG_INTF_CONFIG0 0x2C
108 #define C6DOFIMU16_REG_INTF_CONFIG1_OVRD 0x2D
109 #define C6DOFIMU16_REG_IOC_PAD_SCENARIO 0x2F
110 #define C6DOFIMU16_REG_IOC_PAD_SCENARIO_AUX_OVRD 0x30
111 #define C6DOFIMU16_REG_IOC_PAD_SCENARIO_OVRD 0x31
112 #define C6DOFIMU16_REG_DRIVE_CONFIG0 0x32
113 #define C6DOFIMU16_REG_DRIVE_CONFIG1 0x33
114 #define C6DOFIMU16_REG_DRIVE_CONFIG2 0x34
115 #define C6DOFIMU16_REG_INT_APEX_CONFIG1 0x3A
116 #define C6DOFIMU16_REG_INT_APEX_STATUS0 0x3B
117 #define C6DOFIMU16_REG_INT_APEX_STATUS1 0x3C
118 #define C6DOFIMU16_REG_INT2_CONFIG0 0x56
119 #define C6DOFIMU16_REG_INT2_CONFIG1 0x57
120 #define C6DOFIMU16_REG_INT2_CONFIG2 0x58
121 #define C6DOFIMU16_REG_INT2_STATUS0 0x59
122 #define C6DOFIMU16_REG_WHO_AM_I 0x72
123 #define C6DOFIMU16_REG_REG_HOST_MSG 0x73
124 #define C6DOFIMU16_REG_IREG_ADDR_15_8 0x7C
125 #define C6DOFIMU16_REG_IREG_ADDR_7_0 0x7D
126 #define C6DOFIMU16_REG_IREG_DATA 0x7E
127 #define C6DOFIMU16_REG_REG_MISC2 0x7F
145 #define C6DOFIMU16_GYRO_MODE_OFF 0x00
146 #define C6DOFIMU16_GYRO_MODE_STANDBY 0x04
147 #define C6DOFIMU16_GYRO_MODE_LOW_POWER 0x08
148 #define C6DOFIMU16_GYRO_MODE_LOW_NOISE 0x0C
149 #define C6DOFIMU16_ACCEL_MODE_OFF 0x00
150 #define C6DOFIMU16_ACCEL_MODE_STANDBY 0x01
151 #define C6DOFIMU16_ACCEL_MODE_LOW_POWER 0x02
152 #define C6DOFIMU16_ACCEL_MODE_LOW_NOISE 0x03
158 #define C6DOFIMU16_GYRO_UI_FS_SEL_MASK 0xF0
159 #define C6DOFIMU16_GYRO_UI_FS_SEL_2000DPS 0x10
160 #define C6DOFIMU16_GYRO_UI_FS_SEL_1000DPS 0x20
161 #define C6DOFIMU16_GYRO_UI_FS_SEL_500DPS 0x30
162 #define C6DOFIMU16_GYRO_UI_FS_SEL_250DPS 0x40
163 #define C6DOFIMU16_GYRO_UI_FS_SEL_125DPS 0x50
164 #define C6DOFIMU16_GYRO_UI_FS_SEL_62_5DPS 0x60
165 #define C6DOFIMU16_GYRO_UI_FS_SEL_31_25DPS 0x70
166 #define C6DOFIMU16_GYRO_UI_FS_SEL_15_625DPS 0x80
172 #define C6DOFIMU16_ACCEL_UI_FS_SEL_MASK 0x70
173 #define C6DOFIMU16_ACCEL_UI_FS_SEL_16g 0x10
174 #define C6DOFIMU16_ACCEL_UI_FS_SEL_8g 0x20
175 #define C6DOFIMU16_ACCEL_UI_FS_SEL_4g 0x30
176 #define C6DOFIMU16_ACCEL_UI_FS_SEL_2g 0x40
182 #define C6DOFIMU16_ACCEL_ODR_6_4_KHZ 0x03
183 #define C6DOFIMU16_ACCEL_ODR_3_2_KHZ 0x04
184 #define C6DOFIMU16_ACCEL_ODR_1_6_KHZ 0x05
185 #define C6DOFIMU16_ACCEL_ODR_800_HZ 0x06
186 #define C6DOFIMU16_ACCEL_ODR_400_HZ 0x07
187 #define C6DOFIMU16_ACCEL_ODR_200_HZ 0x08
188 #define C6DOFIMU16_ACCEL_ODR_100_HZ 0x09
189 #define C6DOFIMU16_ACCEL_ODR_50_HZ 0x0A
190 #define C6DOFIMU16_ACCEL_ODR_25_HZ 0x0B
191 #define C6DOFIMU16_ACCEL_ODR_12_5_HZ 0x0C
192 #define C6DOFIMU16_ACCEL_ODR_6_25_HZ 0x0D
193 #define C6DOFIMU16_ACCEL_ODR_3_125_HZ 0x0E
194 #define C6DOFIMU16_ACCEL_ODR_1_5625_HZ 0x0F
200 #define C6DOFIMU16_GYRO_ODR_6_4_KHZ 0x03
201 #define C6DOFIMU16_GYRO_ODR_3_2_KHZ 0x04
202 #define C6DOFIMU16_GYRO_ODR_1_6_KHZ 0x05
203 #define C6DOFIMU16_GYRO_ODR_800_HZ 0x06
204 #define C6DOFIMU16_GYRO_ODR_400_HZ 0x07
205 #define C6DOFIMU16_GYRO_ODR_200_HZ 0x08
206 #define C6DOFIMU16_GYRO_ODR_100_HZ 0x09
207 #define C6DOFIMU16_GYRO_ODR_50_HZ 0x0A
208 #define C6DOFIMU16_GYRO_ODR_25_HZ 0x0B
209 #define C6DOFIMU16_GYRO_ODR_12_5_HZ 0x0C
210 #define C6DOFIMU16_GYRO_ODR_6_25_HZ 0x0D
211 #define C6DOFIMU16_GYRO_ODR_3_125_HZ 0x0E
212 #define C6DOFIMU16_GYRO_ODR_1_5625_HZ 0x0F
218 #define C6DOFIMU16_SOFTWARE_RESET 0x02
224 #define C6DOFIMU16_DEVICE_ID 0xE5
231 #define C6DOFIMU16_ACCEL_2G_CONV_MUL 16384u
232 #define C6DOFIMU16_ACCEL_4G_CONV_MUL 8192u
233 #define C6DOFIMU16_ACCEL_8G_CONV_MUL 4096u
234 #define C6DOFIMU16_ACCEL_16G_CONV_MUL 2048u
235 #define C6DOFIMU16_GYRO_2000DPS_CONV_MUL 16.4f
236 #define C6DOFIMU16_GYRO_1000DPS_CONV_MUL 32.8f
237 #define C6DOFIMU16_GYRO_500DPS_CONV_MUL 65.5f
238 #define C6DOFIMU16_GYRO_250DPS_CONV_MUL 131.0f
239 #define C6DOFIMU16_GYRO_125DPS_CONV_MUL 262.0f
240 #define C6DOFIMU16_GYRO_62_5DPS_CONV_MUL 524.3f
241 #define C6DOFIMU16_GYRO_31_25DPS_CONV_MUL 1048.6f
242 #define C6DOFIMU16_GYRO_15_625DPS_CONV_MUL 2097.2f
249 #define C6DOFIMU16_DEVICE_ADDRESS_0 0x68
250 #define C6DOFIMU16_DEVICE_ADDRESS_1 0x69
260 #define C6DOFIMU16_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
261 #define C6DOFIMU16_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
279 #define C6DOFIMU16_MAP_MIKROBUS( cfg, mikrobus ) \
280 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
281 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
282 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
283 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
284 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
285 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
286 cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
287 cfg.int2 = MIKROBUS( mikrobus, MIKROBUS_INT )
566 #endif // C6DOFIMU16_H
c6dofimu16_return_value_t
6DOF IMU 16 Click return value data.
Definition: c6dofimu16.h:374
err_t c6dofimu16_reg_write(c6dofimu16_t *ctx, uint8_t reg, uint8_t data_in)
6DOF IMU 16 data writing function.
void c6dofimu16_drv_interface_sel(c6dofimu16_cfg_t *cfg, c6dofimu16_drv_t drv_sel)
6DOF IMU 16 driver interface setup function.
pin_name_t int1
Definition: c6dofimu16.h:343
digital_in_t int2
Definition: c6dofimu16.h:317
uint8_t i2c_address
Definition: c6dofimu16.h:347
uint32_t spi_speed
Definition: c6dofimu16.h:349
struct c6dofimu16_s c6dofimu16_t
6DOF IMU 16 Click context object.
6DOF IMU 16 Click axes data structure.
Definition: c6dofimu16.h:362
6DOF IMU 16 Click context object.
Definition: c6dofimu16.h:315
err_t c6dofimu16_sw_reset(c6dofimu16_t *ctx)
6DOF IMU 16 software reset device function.
This file contains SPI specific macros, functions, etc.
err_t c6dofimu16_get_accel_data(c6dofimu16_t *ctx, c6dofimu16_axis_t *accel_data)
6DOF IMU 16 read accel function.
pin_name_t chip_select
Definition: c6dofimu16.h:323
float y_data
Definition: c6dofimu16.h:364
spi_master_mode_t spi_mode
Definition: c6dofimu16.h:350
err_t(* c6dofimu16_master_io_t)(struct c6dofimu16_s *, uint8_t, uint8_t *, uint8_t)
Definition: c6dofimu16.h:308
6DOF IMU 16 Click configuration object.
Definition: c6dofimu16.h:336
err_t c6dofimu16_init(c6dofimu16_t *ctx, c6dofimu16_cfg_t *cfg)
6DOF IMU 16 initialization function.
i2c_master_t i2c
Definition: c6dofimu16.h:319
spi_master_chip_select_polarity_t cs_polarity
Definition: c6dofimu16.h:351
c6dofimu16_master_io_t read_f
Definition: c6dofimu16.h:327
pin_name_t cs
Definition: c6dofimu16.h:342
err_t c6dofimu16_generic_write(c6dofimu16_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
6DOF IMU 16 data writing function.
pin_name_t mosi
Definition: c6dofimu16.h:340
@ C6DOFIMU16_ERROR
Definition: c6dofimu16.h:376
void c6dofimu16_cfg_setup(c6dofimu16_cfg_t *cfg)
6DOF IMU 16 configuration object setup function.
uint8_t c6dofimu16_get_int1_pin(c6dofimu16_t *ctx)
6DOF IMU 16 get int1 pin function.
@ C6DOFIMU16_DRV_SEL_SPI
Definition: c6dofimu16.h:298
uint32_t i2c_speed
Definition: c6dofimu16.h:346
c6dofimu16_drv_t drv_sel
Definition: c6dofimu16.h:324
spi_master_t spi
Definition: c6dofimu16.h:320
pin_name_t miso
Definition: c6dofimu16.h:339
@ C6DOFIMU16_DRV_SEL_I2C
Definition: c6dofimu16.h:299
pin_name_t sda
Definition: c6dofimu16.h:338
c6dofimu16_drv_t
6DOF IMU 16 Click driver selector.
Definition: c6dofimu16.h:297
err_t c6dofimu16_generic_read(c6dofimu16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
6DOF IMU 16 data reading function.
float x_data
Definition: c6dofimu16.h:363
digital_in_t int1
Definition: c6dofimu16.h:316
err_t c6dofimu16_get_gyro_data(c6dofimu16_t *ctx, c6dofimu16_axis_t *gyro_data)
6DOF IMU 16 read gyro function.
pin_name_t int2
Definition: c6dofimu16.h:344
err_t c6dofimu16_default_cfg(c6dofimu16_t *ctx)
6DOF IMU 16 default configuration function.
float z_data
Definition: c6dofimu16.h:365
@ C6DOFIMU16_OK
Definition: c6dofimu16.h:375
pin_name_t scl
Definition: c6dofimu16.h:337
c6dofimu16_drv_t drv_sel
Definition: c6dofimu16.h:353
uint8_t slave_address
Definition: c6dofimu16.h:322
pin_name_t sck
Definition: c6dofimu16.h:341
err_t c6dofimu16_reg_read(c6dofimu16_t *ctx, uint8_t reg, uint8_t *data_out)
6DOF IMU 16 register data reading function.
uint8_t c6dofimu16_get_int2_pin(c6dofimu16_t *ctx)
6DOF IMU 16 get int2 pin function.
c6dofimu16_master_io_t write_f
Definition: c6dofimu16.h:326