41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_out.h"
52#include "drv_digital_in.h"
53#include "drv_spi_master.h"
66#define LSM6DSL_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define LSM6DSL_RETVAL uint8_t
80#define LSM6DSL_OK 0x00
81#define LSM6DSL_INIT_ERROR 0xFF
88#define LSM6DSL_FUNC_CFG_ACCESS 0x01
89#define LSM6DSL_SENSOR_SYNC_TIME 0x04
90#define LSM6DSL_SENSOR_RES_RATIO 0x05
91#define LSM6DSL_FIFO_CTRL1 0x06
92#define LSM6DSL_FIFO_CTRL2 0x07
93#define LSM6DSL_FIFO_CTRL3 0x08
94#define LSM6DSL_FIFO_CTRL4 0x09
95#define LSM6DSL_FIFO_CTRL5 0x0A
96#define LSM6DSL_DRDY_PULSE_CFG_G 0x0B
97#define LSM6DSL_INT1_CTRL 0x0D
98#define LSM6DSL_INT2_CTRL 0x0E
99#define LSM6DSL_WHO_AM_I_REG 0x0F
100#define LSM6DSL_CTRL1_XL 0x10
101#define LSM6DSL_CTRL2_G 0x11
102#define LSM6DSL_CTRL3_C 0x12
103#define LSM6DSL_CTRL4_C 0x13
104#define LSM6DSL_CTRL5_C 0x14
105#define LSM6DSL_CTRL6_G 0x15
106#define LSM6DSL_CTRL7_G 0x16
107#define LSM6DSL_CTRL8_XL 0x17
108#define LSM6DSL_CTRL9_XL 0x18
109#define LSM6DSL_CTRL10_C 0x19
110#define LSM6DSL_MASTER_CONFIG 0x1A
111#define LSM6DSL_WAKE_UP_SRC 0x1B
112#define LSM6DSL_TAP_SRC 0x1C
113#define LSM6DSL_D6D_SRC 0x1D
114#define LSM6DSL_STATUS_REG 0x1E
115#define LSM6DSL_OUT_TEMP_L 0x20
116#define LSM6DSL_OUT_TEMP_H 0x21
117#define LSM6DSL_OUTX_L_G 0x22
118#define LSM6DSL_OUTX_H_G 0x23
119#define LSM6DSL_OUTY_L_G 0x24
120#define LSM6DSL_OUTY_H_G 0x25
121#define LSM6DSL_OUTZ_L_G 0x26
122#define LSM6DSL_OUTZ_H_G 0x27
123#define LSM6DSL_OUTX_L_XL 0x28
124#define LSM6DSL_OUTX_H_XL 0x29
125#define LSM6DSL_OUTY_L_XL 0x2A
126#define LSM6DSL_OUTY_H_XL 0x2B
127#define LSM6DSL_OUTZ_L_XL 0x2C
128#define LSM6DSL_OUTZ_H_XL 0x2D
129#define LSM6DSL_SENSORHUB1_REG 0x2E
130#define LSM6DSL_SENSORHUB2_REG 0x2F
131#define LSM6DSL_SENSORHUB3_REG 0x30
132#define LSM6DSL_SENSORHUB4_REG 0x31
133#define LSM6DSL_SENSORHUB5_REG 0x32
134#define LSM6DSL_SENSORHUB6_REG 0x33
135#define LSM6DSL_SENSORHUB7_REG 0x34
136#define LSM6DSL_SENSORHUB8_REG 0x35
137#define LSM6DSL_SENSORHUB9_REG 0x36
138#define LSM6DSL_SENSORHUB10_REG 0x37
139#define LSM6DSL_SENSORHUB11_REG 0x38
140#define LSM6DSL_SENSORHUB12_REG 0x39
141#define LSM6DSL_FIFO_STATUS1 0x3A
142#define LSM6DSL_FIFO_STATUS2 0x3B
143#define LSM6DSL_FIFO_STATUS3 0x3C
144#define LSM6DSL_FIFO_STATUS4 0x3D
145#define LSM6DSL_FIFO_DATA_OUT_L 0x3E
146#define LSM6DSL_FIFO_DATA_OUT_H 0x3F
147#define LSM6DSL_TIMESTAMP0_REG 0x40
148#define LSM6DSL_TIMESTAMP1_REG 0x41
149#define LSM6DSL_TIMESTAMP2_REG 0x42
150#define LSM6DSL_TIMESTAMP_L 0x49
151#define LSM6DSL_TIMESTAMP_H 0x4A
152#define LSM6DSL_STEP_COUNTER_L 0x4B
153#define LSM6DSL_STEP_COUNTER_H 0x4C
154#define LSM6DSL_SENSORHUB13_REG 0x4D
155#define LSM6DSL_SENSORHUB14_REG 0x4E
156#define LSM6DSL_SENSORHUB15_REG 0x4F
157#define LSM6DSL_SENSORHUB16_REG 0x50
158#define LSM6DSL_SENSORHUB17_REG 0x51
159#define LSM6DSL_SENSORHUB18_REG 0x52
160#define LSM6DSL_FUNC_SRC 0x53
161#define LSM6DSL_TAP_CFG1 0x58
162#define LSM6DSL_TAP_THS_6D 0x59
163#define LSM6DSL_INT_DUR2 0x5A
164#define LSM6DSL_WAKE_UP_THS 0x5B
165#define LSM6DSL_WAKE_UP_DUR 0x5C
166#define LSM6DSL_FREE_FALL 0x5D
167#define LSM6DSL_MD1_CFG 0x5E
168#define LSM6DSL_MD2_CFG 0x5F
169#define LSM6DSL_OUT_MAG_RAW_X_L 0x66
170#define LSM6DSL_OUT_MAG_RAW_X_H 0x67
171#define LSM6DSL_OUT_MAG_RAW_Y_L 0x68
172#define LSM6DSL_OUT_MAG_RAW_Y_H 0x69
173#define LSM6DSL_OUT_MAG_RAW_Z_L 0x6A
174#define LSM6DSL_OUT_MAG_RAW_Z_H 0x6B
175#define LSM6DSL_X_OFS_USR 0x73
176#define LSM6DSL_Y_OFS_USR 0x74
177#define LSM6DSL_Z_OFS_USR 0x75
184#define LSM6DSL_SLV0_ADD 0x02
185#define LSM6DSL_SLV0_SUBADD 0x03
186#define LSM6DSL_SLAVE0_CONFIG 0x04
187#define LSM6DSL_SLV1_ADD 0x05
188#define LSM6DSL_SLV1_SUBADD 0x06
189#define LSM6DSL_SLAVE1_CONFIG 0x07
190#define LSM6DSL_SLV2_ADD 0x08
191#define LSM6DSL_SLV2_SUBADD 0x09
192#define LSM6DSL_SLAVE2_CONFIG 0x0A
193#define LSM6DSL_SLV3_ADD 0x0B
194#define LSM6DSL_SLV3_SUBADD 0x0C
195#define LSM6DSL_SLAVE3_CONFIG 0x0D
196#define LSM6DSL_DATAWRITE_SRC_MODE_SUB_SLV0 0x0E
197#define LSM6DSL_CONFIG_PEDO_THS_MIN 0x0F
198#define LSM6DSL_SM_STEP_THS 0x13
199#define LSM6DSL_PEDO_DEB_REG 0x14
200#define LSM6DSL_STEP_COUNT_DELTA 0x15
201#define LSM6DSL_MAG_SI_XX 0x24
202#define LSM6DSL_MAG_SI_XY 0x25
203#define LSM6DSL_MAG_SI_XZ 0x26
204#define LSM6DSL_MAG_SI_YX 0x27
205#define LSM6DSL_MAG_SI_YY 0x28
206#define LSM6DSL_MAG_SI_YZ 0x29
207#define LSM6DSL_MAG_SI_ZX 0x2A
208#define LSM6DSL_MAG_SI_ZY 0x2B
209#define LSM6DSL_MAG_SI_ZZ 0x2C
210#define LSM6DSL_MAG_OFFX_L 0x2D
211#define LSM6DSL_MAG_OFFX_H 0x2E
212#define LSM6DSL_MAG_OFFY_L 0x2F
213#define LSM6DSL_MAG_OFFY_H 0x30
214#define LSM6DSL_MAG_OFFZ_L 0x31
215#define LSM6DSL_MAG_OFFZ_H 0x32
222#define LSM6DSL_CHECK_ID 0x6A
229#define LSM6DSL_DISABLE_MEASUREMENT 0x00
230#define LSM6DSL_ODR_6660_HZ 0xA0
231#define LSM6DSL_ODR_3330_HZ 0x90
232#define LSM6DSL_ODR_1660_HZ 0x80
233#define LSM6DSL_ODR_833_HZ 0x70
234#define LSM6DSL_ODR_416_HZ 0x60
235#define LSM6DSL_ODR_208_HZ 0x50
236#define LSM6DSL_ODR_104_HZ 0x40
237#define LSM6DSL_ODR_52_HZ 0x30
238#define LSM6DSL_ODR_26_HZ 0x20
239#define LSM6DSL_ODR_12_5_HZ 0x10
240#define LSM6DSL_ODR_XL_1_6_HZ 0xB0
247#define LSM6DSL_FULLSCALE_XL_2 0x00
248#define LSM6DSL_FULLSCALE_XL_4 0x04
249#define LSM6DSL_FULLSCALE_XL_8 0x08
250#define LSM6DSL_FULLSCALE_XL_16 0x0C
251#define LSM6DSL_FULLSCALE_G_125 0x02
252#define LSM6DSL_FULLSCALE_G_245 0x00
253#define LSM6DSL_FULLSCALE_G_500 0x04
254#define LSM6DSL_FULLSCALE_G_1000 0x08
255#define LSM6DSL_FULLSCALE_G_2000 0x0C
#define LSM6DSL_RETVAL
Definition lsm6dsl.h:78
void lsm6dsl_sleep_gyro(lsm6dsl_t *ctx)
Set gyroscope sleep mode function.
uint8_t lsm6dsl_check_id(lsm6dsl_t *ctx)
Function check LSM6DSL ID.
float lsm6dsl_get_temperature(lsm6dsl_t *ctx)
void lsm6dsl_default_cfg(lsm6dsl_t *ctx)
Click Default Configuration function.
void lsm6dsl_soft_reset(lsm6dsl_t *ctx)
Set soft reset function.
void lsm6dsl_set_self_test_mode(lsm6dsl_t *ctx, uint8_t gyro_self_test, uint8_t accel_self_test)
Set self-test mode function.
void lsm6dsl_set_gyro_config(lsm6dsl_t *ctx, uint8_t odr_sel, uint8_t full_scale)
Set gyro configuration function.
void lsm6dsl_get_gyro(lsm6dsl_t *ctx, lsm6dsl_gyro_t *gyro, uint8_t full_scale)
Get gyroscope function.
void lsm6dsl_wake_up_gyro(lsm6dsl_t *ctx)
Set gyroscope wake up mode function.
void lsm6dsl_circular_burst_mode(lsm6dsl_t *ctx, uint8_t burst_mode)
Set circular burst mode function.
void lsm6dsl_cfg_setup(lsm6dsl_cfg_t *cfg)
Config Object Initialization function.
LSM6DSL_RETVAL lsm6dsl_init(lsm6dsl_t *ctx, lsm6dsl_cfg_t *cfg)
Initialization function.
void lsm6dsl_write_byte(lsm6dsl_t *ctx, uint8_t reg_address, uint8_t write_data)
Write byte of data function.
uint8_t lsm6dsl_read_byte(lsm6dsl_t *ctx, uint8_t reg_address)
Read byte of data function.
void lsm6dsl_set_accel_config(lsm6dsl_t *ctx, uint8_t odr_sel, uint8_t full_scale)
Set accel configuration function.
void lsm6dsl_get_accel(lsm6dsl_t *ctx, lsm6dsl_accel_t *accel, uint8_t full_scale)
Get acceleration function.
uint16_t lsm6dsl_get_axis(lsm6dsl_t *ctx, uint8_t reg_address_low)
Get axis value function.
void lsm6dsl_generic_transfer(lsm6dsl_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
uint8_t lsm6dsl_get_status_reg(lsm6dsl_t *ctx)
Get status function.
Accel object definition.
Definition lsm6dsl.h:269
float accel_x
Definition lsm6dsl.h:270
float accel_z
Definition lsm6dsl.h:272
float accel_y
Definition lsm6dsl.h:271
Click configuration structure definition.
Definition lsm6dsl.h:309
uint8_t spi_mode
Definition lsm6dsl.h:324
spi_master_chip_select_polarity_t cs_polarity
Definition lsm6dsl.h:325
pin_name_t sck
Definition lsm6dsl.h:314
pin_name_t mosi
Definition lsm6dsl.h:313
uint32_t spi_speed
Definition lsm6dsl.h:323
pin_name_t int_pin
Definition lsm6dsl.h:319
pin_name_t miso
Definition lsm6dsl.h:312
pin_name_t cs
Definition lsm6dsl.h:315
Gyro object definition.
Definition lsm6dsl.h:280
float gyro_x
Definition lsm6dsl.h:281
float gyro_y
Definition lsm6dsl.h:282
float gyro_z
Definition lsm6dsl.h:283
Click ctx object definition.
Definition lsm6dsl.h:291
digital_out_t cs
Definition lsm6dsl.h:292
spi_master_t spi
Definition lsm6dsl.h:300
digital_in_t int_pin
Definition lsm6dsl.h:296
pin_name_t chip_select
Definition lsm6dsl.h:301