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"
52 #include "drv_spi_master.h"
75 #define ACCEL31_REG_CHIP_ID 0x00
76 #define ACCEL31_REG_HEALTH_STATUS 0x02
77 #define ACCEL31_REG_CMD_SUSPEND 0x04
78 #define ACCEL31_REG_CONFIG_STATUS 0x10
79 #define ACCEL31_REG_SENSOR_STATUS 0x11
80 #define ACCEL31_REG_INT_STATUS_INT1_0 0x12
81 #define ACCEL31_REG_INT_STATUS_INT1_1 0x13
82 #define ACCEL31_REG_INT_STATUS_INT2_0 0x14
83 #define ACCEL31_REG_INT_STATUS_INT2_1 0x15
84 #define ACCEL31_REG_INT_STATUS_I3C_0 0x16
85 #define ACCEL31_REG_INT_STATUS_I3C_1 0x17
86 #define ACCEL31_REG_ACC_DATA_0 0x18
87 #define ACCEL31_REG_ACC_DATA_1 0x19
88 #define ACCEL31_REG_ACC_DATA_2 0x1A
89 #define ACCEL31_REG_ACC_DATA_3 0x1B
90 #define ACCEL31_REG_ACC_DATA_4 0x1C
91 #define ACCEL31_REG_ACC_DATA_5 0x1D
92 #define ACCEL31_REG_TEMP_DATA 0x1E
93 #define ACCEL31_REG_SENSOR_TIME_0 0x1F
94 #define ACCEL31_REG_SENSOR_TIME_1 0x20
95 #define ACCEL31_REG_SENSOR_TIME_2 0x21
96 #define ACCEL31_REG_FIFO_LEVEL_0 0x22
97 #define ACCEL31_REG_FIFO_LEVEL_1 0x23
98 #define ACCEL31_REG_FIFO_DATA_OUT 0x24
99 #define ACCEL31_REG_AUX_DATA_0 0x2B
100 #define ACCEL31_REG_AUX_DATA_1 0x2C
101 #define ACCEL31_REG_ACC_CONF_0 0x30
102 #define ACCEL31_REG_ACC_CONF_1 0x31
103 #define ACCEL31_REG_ACC_CONF_2 0x32
104 #define ACCEL31_REG_TEMP_CONF 0x33
105 #define ACCEL31_REG_INT1_CONF 0x34
106 #define ACCEL31_REG_INT2_CONF 0x35
107 #define ACCEL31_REG_INT_MAP_0 0x36
108 #define ACCEL31_REG_INT_MAP_1 0x37
109 #define ACCEL31_REG_INT_MAP_2 0x38
110 #define ACCEL31_REG_INT_MAP_3 0x39
111 #define ACCEL31_REG_IF_CONF_0 0x3A
112 #define ACCEL31_REG_IF_CONF_1 0x3B
113 #define ACCEL31_REG_FIFO_CTRL 0x40
114 #define ACCEL31_REG_FIFO_CONF_0 0x41
115 #define ACCEL31_REG_FIFO_CONF_1 0x42
116 #define ACCEL31_REG_FIFO_WM_0 0x43
117 #define ACCEL31_REG_FIFO_WM_1 0x44
118 #define ACCEL31_REG_FEAT_ENG_CONF 0x50
119 #define ACCEL31_REG_FEAT_ENG_STATUS 0x51
120 #define ACCEL31_REG_FEAT_ENG_GP_FLAGS 0x52
121 #define ACCEL31_REG_FEAT_ENG_GPR_CONF 0x53
122 #define ACCEL31_REG_FEAT_ENG_GPR_CTRL 0x54
123 #define ACCEL31_REG_FEAT_ENG_GPR_0 0x55
124 #define ACCEL31_REG_FEAT_ENG_GPR_1 0x56
125 #define ACCEL31_REG_FEAT_ENG_GPR_2 0x57
126 #define ACCEL31_REG_FEATURE_DATA_ADDR 0x5E
127 #define ACCEL31_REG_FEATURE_DATA_TX 0x5F
128 #define ACCEL31_REG_ACC_OFFSET_0 0x70
129 #define ACCEL31_REG_ACC_OFFSET_1 0x71
130 #define ACCEL31_REG_ACC_OFFSET_2 0x72
131 #define ACCEL31_REG_ACC_OFFSET_3 0x73
132 #define ACCEL31_REG_ACC_OFFSET_4 0x74
133 #define ACCEL31_REG_ACC_OFFSET_5 0x75
134 #define ACCEL31_REG_ACC_SELF_TEST 0x76
135 #define ACCEL31_REG_CMD 0x7E
153 #define ACCEL31_CHIP_ID 0xC4
159 #define ACCEL31_CMD_SUSPEND_MODE_NORMAL 0x00
160 #define ACCEL31_CMD_SUSPEND_MODE_SUSPEND 0x01
161 #define ACCEL31_CMD_SUSPEND_MODE_MASK 0x01
167 #define ACCEL31_SENSOR_STATUS_SENSOR_RDY 0x04
168 #define ACCEL31_SENSOR_STATUS_TEMP_RDY 0x02
169 #define ACCEL31_SENSOR_STATUS_ACC_RDY 0x01
175 #define ACCEL31_ACC_CONF_0_SENSOR_DISABLE 0x00
176 #define ACCEL31_ACC_CONF_0_SENSOR_ENABLE 0x0F
177 #define ACCEL31_ACC_CONF_0_SENSOR_WRONG_CFG 0x0E
178 #define ACCEL31_ACC_CONF_0_SENSOR_MASK 0x0F
184 #define ACCEL31_ACC_CONF_1_POWER_MODE_MASK 0x80
185 #define ACCEL31_ACC_CONF_1_ACC_BWP_MASK 0x70
186 #define ACCEL31_ACC_CONF_1_ACC_ODR_MASK 0x0F
192 #define ACCEL31_ACC_CONF_2_ACC_DRDY_MASK 0x80
193 #define ACCEL31_ACC_CONF_2_NOISE_MODE_MASK 0x10
194 #define ACCEL31_ACC_CONF_2_ACC_IIR_MASK 0x0C
195 #define ACCEL31_ACC_CONF_2_ACC_RANGE_MASK 0x03
201 #define ACCEL31_TEMP_CONF_EXT_SEL_MASK 0x10
202 #define ACCEL31_TEMP_CONF_MEAS_SRC_MASK 0x08
203 #define ACCEL31_TEMP_CONF_RATE_MASK 0x07
209 #define ACCEL31_INT2_CONF_LVL_MASK 0x08
210 #define ACCEL31_INT2_CONF_OD_MASK 0x04
211 #define ACCEL31_INT2_CONF_MODE_OUT_DIS 0x00
212 #define ACCEL31_INT2_CONF_MODE_LATCH 0x01
213 #define ACCEL31_INT2_CONF_MODE_PULSE_SHORT 0x02
214 #define ACCEL31_INT2_CONF_MODE_PULSE_LONG 0x03
215 #define ACCEL31_INT2_CONF_MODE_MASK 0x03
221 #define ACCEL31_CMD_SOFT_RESET 0xB6
227 #define ACCEL31_ACCEL_ODR_1_5625_HZ 0
228 #define ACCEL31_ACCEL_ODR_3_125_HZ 1
229 #define ACCEL31_ACCEL_ODR_6_25_HZ 2
230 #define ACCEL31_ACCEL_ODR_12_5_HZ 3
231 #define ACCEL31_ACCEL_ODR_25_HZ 4
232 #define ACCEL31_ACCEL_ODR_50_HZ 5
233 #define ACCEL31_ACCEL_ODR_100_HZ 6
234 #define ACCEL31_ACCEL_ODR_200_HZ 7
235 #define ACCEL31_ACCEL_ODR_400_HZ 8
236 #define ACCEL31_ACCEL_ODR_800_HZ 9
237 #define ACCEL31_ACCEL_ODR_1600_HZ 10
238 #define ACCEL31_ACCEL_ODR_3200_HZ 11
239 #define ACCEL31_ACCEL_ODR_6400_HZ 12
245 #define ACCEL31_ACCEL_FS_2G 0
246 #define ACCEL31_ACCEL_FS_4G 1
247 #define ACCEL31_ACCEL_FS_8G 2
248 #define ACCEL31_ACCEL_FS_16G 3
254 #define ACCEL31_TEMP_ODR_1_5625_HZ 0
255 #define ACCEL31_TEMP_ODR_3_125_HZ 1
256 #define ACCEL31_TEMP_ODR_6_25_HZ 2
257 #define ACCEL31_TEMP_ODR_12_5_HZ 3
258 #define ACCEL31_TEMP_ODR_25_HZ 4
259 #define ACCEL31_TEMP_ODR_50_HZ 5
260 #define ACCEL31_TEMP_ODR_100_HZ 6
261 #define ACCEL31_TEMP_ODR_200_HZ 7
267 #define ACCEL31_ACCEL_SENS_G_PER_LSB 0.000061
268 #define ACCEL31_TEMP_OFFSET 23
275 #define ACCEL31_DEVICE_ADDRESS 0x18
285 #define ACCEL31_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
286 #define ACCEL31_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
304 #define ACCEL31_MAP_MIKROBUS( cfg, mikrobus ) \
305 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
306 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
307 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
308 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
309 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
310 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
311 cfg.int2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
312 cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t accel31_read_regs(accel31_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 31 read regs function.
float accel_sens
Definition: accel31.h:354
err_t(* accel31_master_io_t)(struct accel31_s *, uint8_t, uint8_t *, uint8_t)
Definition: accel31.h:333
err_t accel31_sw_reset(accel31_t *ctx)
Accel 31 sw reset function.
pin_name_t scl
Definition: accel31.h:364
@ ACCEL31_DRV_SEL_SPI
Definition: accel31.h:323
pin_name_t int1
Definition: accel31.h:371
err_t accel31_get_accel_drdy(accel31_t *ctx, uint8_t *drdy)
Accel 31 get accel drdy function.
void accel31_drv_interface_sel(accel31_cfg_t *cfg, accel31_drv_t drv_sel)
Accel 31 driver interface setup function.
This file contains SPI specific macros, functions, etc.
uint32_t spi_speed
Definition: accel31.h:376
err_t accel31_set_accel_odr(accel31_t *ctx, uint8_t odr)
Accel 31 set accel odr function.
accel31_axes_t accel
Definition: accel31.h:402
uint8_t slave_address
Definition: accel31.h:347
accel31_drv_t drv_sel
Definition: accel31.h:349
err_t accel31_get_data(accel31_t *ctx, accel31_data_t *data_out)
Accel 31 get data function.
err_t accel31_set_temp_odr(accel31_t *ctx, uint8_t odr)
Accel 31 set temp odr function.
digital_in_t int2
Definition: accel31.h:341
float y
Definition: accel31.h:391
err_t accel31_default_cfg(accel31_t *ctx)
Accel 31 default configuration function.
struct accel31_s accel31_t
Accel 31 Click context object.
err_t accel31_read_reg(accel31_t *ctx, uint8_t reg, uint8_t *data_out)
Accel 31 read reg function.
err_t accel31_get_accel(accel31_t *ctx, accel31_axes_t *accel)
Accel 31 get accel function.
err_t accel31_write_reg(accel31_t *ctx, uint8_t reg, uint8_t data_in)
Accel 31 write reg function.
int8_t temperature
Definition: accel31.h:403
uint8_t accel31_get_int1_pin(accel31_t *ctx)
Accel 31 get int1 pin function.
uint32_t i2c_speed
Definition: accel31.h:373
Accel 31 Click context object.
Definition: accel31.h:340
err_t accel31_init(accel31_t *ctx, accel31_cfg_t *cfg)
Accel 31 initialization function.
float x
Definition: accel31.h:390
accel31_master_io_t write_f
Definition: accel31.h:351
@ ACCEL31_DATA_NOT_READY
Definition: accel31.h:415
pin_name_t sck
Definition: accel31.h:368
Accel 31 Click configuration object.
Definition: accel31.h:363
err_t accel31_set_accel_fsr(accel31_t *ctx, uint8_t fsr)
Accel 31 set accel fsr function.
@ ACCEL31_DRV_SEL_I2C
Definition: accel31.h:324
uint8_t accel31_get_int2_pin(accel31_t *ctx)
Accel 31 get int2 pin function.
pin_name_t miso
Definition: accel31.h:366
pin_name_t chip_select
Definition: accel31.h:348
uint8_t i2c_address
Definition: accel31.h:374
spi_master_t spi
Definition: accel31.h:345
err_t accel31_check_communication(accel31_t *ctx)
Accel 31 check communication function.
i2c_master_t i2c
Definition: accel31.h:344
pin_name_t int2
Definition: accel31.h:370
pin_name_t sda
Definition: accel31.h:365
spi_master_chip_select_polarity_t cs_polarity
Definition: accel31.h:378
accel31_drv_t
Accel 31 Click driver selector.
Definition: accel31.h:322
@ ACCEL31_ERROR
Definition: accel31.h:414
spi_master_mode_t spi_mode
Definition: accel31.h:377
digital_in_t int1
Definition: accel31.h:342
accel31_master_io_t read_f
Definition: accel31.h:352
accel31_return_value_t
Accel 31 Click return value data.
Definition: accel31.h:412
err_t accel31_get_temp_drdy(accel31_t *ctx, uint8_t *drdy)
Accel 31 get temp drdy function.
pin_name_t cs
Definition: accel31.h:369
err_t accel31_get_temp(accel31_t *ctx, int8_t *temp)
Accel 31 get temp function.
@ ACCEL31_OK
Definition: accel31.h:413
Accel 31 Click axes data structure.
Definition: accel31.h:389
pin_name_t mosi
Definition: accel31.h:367
float z
Definition: accel31.h:392
err_t accel31_write_regs(accel31_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 31 write regs function.
accel31_drv_t drv_sel
Definition: accel31.h:380
Accel 31 Click data structure.
Definition: accel31.h:401
void accel31_cfg_setup(accel31_cfg_t *cfg)
Accel 31 configuration object setup function.