no-OS
adxl38x.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __ADXL38X_H__
34 #define __ADXL38X_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include <stdbool.h>
41 #include "no_os_i2c.h"
42 #include "no_os_spi.h"
43 
44 /******************************************************************************/
45 /******************************** ADXL38X *************************************/
46 /******************************************************************************/
47 /* Constants and Macros */
48 
49 /* SPI */
50 #define ADXL38X_SPI_READ 0x01
51 #define ADXL38X_SPI_WRITE 0x00
52 
53 /* Register Map fo ADXL38X (Rev H DS)*/
54 #define ADXL38X_DEVID_AD 0x00
55 #define ADXL38X_DEVID_MST 0x01
56 #define ADXL38X_PART_ID 0x02
57 #define ADXL38X_PART_ID_REV_ID 0x03
58 #define ADXL38X_SERIAL_NUMBER_0 0x04
59 #define ADXL38X_SERIAL_NUMBER_1 0x05
60 #define ADXL38X_SERIAL_NUMBER_2 0x06
61 #define ADXL38X_SERIAL_NUMBER_3 0x07
62 #define ADXL38X_SERIAL_NUMBER_4 0x08
63 #define ADXL38X_SERIAL_NUMBER_5 0x09
64 #define ADXL38X_SERIAL_NUMBER_6 0x0A
65 #define ADXL38X_DEV_DELTA_Q_X 0x0B
66 #define ADXL38X_DEV_DELTA_Q_Y 0x0C
67 #define ADXL38X_DEV_DELTA_Q_Z 0x0D
68 #define ADXL38X_DEV_DELTA_F0_X 0x0E
69 #define ADXL38X_DEV_DELTA_F0_Y 0x0F
70 #define ADXL38X_DEV_DELTA_F0_Z 0x10
71 #define ADXL38X_STATUS0 0x11
72 #define ADXL38X_STATUS1 0x12
73 #define ADXL38X_STATUS2 0x13
74 #define ADXL38X_STATUS3 0x14
75 #define ADXL38X_XDATA_H 0x15
76 #define ADXL38X_XDATA_L 0x16
77 #define ADXL38X_YDATA_H 0x17
78 #define ADXL38X_YDATA_L 0x18
79 #define ADXL38X_ZDATA_H 0x19
80 #define ADXL38X_ZDATA_L 0x1A
81 #define ADXL38X_TDATA_H 0x1B
82 #define ADXL38X_TDATA_L 0x1C
83 #define ADXL38X_FIFO_DATA 0x1D
84 #define ADXL38X_FIFO_STATUS0 0x1E
85 #define ADXL38X_FIFO_STATUS1 0x1F
86 #define ADXL38X_MISC0 0x20
87 #define ADXL38X_MISC1 0x21
88 #define ADXL38X_SENS_DSM 0x24
89 #define ADXL38X_CLK_CTRL 0x25
90 #define ADXL38X_OP_MODE 0x26
91 #define ADXL38X_DIG_EN 0x27
92 #define ADXL38X_SAR_I2C 0x28
93 #define ADXL38X_NVM_CTL 0x29
94 #define ADXL38X_REG_RESET 0x2A
95 #define ADXL38X_INT0_MAP0 0x2B
96 #define ADXL38X_INT0_MAP1 0x2C
97 #define ADXL38X_INT1_MAP0 0x2D
98 #define ADXL38X_INT1_MAP1 0x2E
99 #define ADXL38X_TEST_EN 0x2F
100 #define ADXL38X_FIFO_CFG0 0x30
101 #define ADXL38X_FIFO_CFG1 0x31
102 #define ADXL38X_SPT_CFG0 0x32
103 #define ADXL38X_SPT_CFG1 0x33
104 #define ADXL38X_SPT_CFG2 0x34
105 #define ADXL38X_SYNC_CFG 0x35
106 #define ADXL38X_PDM_CFG 0x36
107 #define ADXL38X_ACT_INACT_CTL 0x37
108 #define ADXL38X_SNSR_AXIS_EN 0x38
109 #define ADXL38X_THRESH_ACT_H 0x39
110 #define ADXL38X_THRESH_ACT_L 0x3A
111 #define ADXL38X_TIME_ACT_H 0x3B
112 #define ADXL38X_TIME_ACT_M 0x3C
113 #define ADXL38X_TIME_ACT_L 0x3D
114 #define ADXL38X_THRESH_INACT_H 0x3E
115 #define ADXL38X_THRESH_INACT_L 0x3F
116 #define ADXL38X_TIME_INACT_H 0x40
117 #define ADXL38X_TIME_INACT_M 0x41
118 #define ADXL38X_TIME_INACT_L 0x42
119 #define ADXL38X_TAP_THRESH 0x43
120 #define ADXL38X_TAP_DUR 0x44
121 #define ADXL38X_TAP_LATENT 0x45
122 #define ADXL38X_TAP_WINDOW 0x46
123 #define ADXL38X_TAP_CFG 0x47
124 #define ADXL38X_OR_CFG 0x48
125 #define ADXL38X_TRIG_CFG 0x49
126 #define ADXL38X_X_SAR_OFFSET 0x4A
127 #define ADXL38X_Y_SAR_OFFSET 0x4B
128 #define ADXL38X_Z_SAR_OFFSET 0x4C
129 #define ADXL38X_X_DSM_OFFSET 0x4D
130 #define ADXL38X_Y_DSM_OFFSET 0x4E
131 #define ADXL38X_Z_DSM_OFFSET 0x4F
132 #define ADXL38X_FILTER 0x50
133 #define ADXL38X_USER_TEMP_SENS_0 0x55
134 #define ADXL38X_USER_TEMP_SENS_1 0x56
135 #define ADXL38X_MISO 0x58
136 #define ADXL38X_SOUT0 0x59
137 #define ADXL38X_MCLK 0x5A
138 #define ADXL38X_BCLK 0x5B
139 #define ADXL38X_FSYNC 0x5C
140 #define ADXL38X_INT0 0x5D
141 #define ADXL38X_INT1 0x5E
142 
143 /* Register reset value for ADXL38X */
144 #define ADXL38X_RESET_ZERO 0x00
145 #define ADXL38X_RESET_DEVID_AD 0xAD
146 #define ADXL38X_RESET_DEVID_MST 0x1D
147 #define ADXL38X_RESET_PART_ID 0x17
148 #define ADXL38X_RESET_PART_ID_REV_ID 0xC1
149 #define ADXL38X_RESET_STATUS0 0x80
150 #define ADXL38X_RESET_STATUS2 0x04
151 #define ADXL38X_RESET_INT0_MAP0 0x80
152 #define ADXL38X_RESET_INT1_MAP1 0x80
153 #define ADXL38X_RESET_SPT_CFG1 0x08
154 #define ADXL38X_RESET_SPT_CFG2 0x1A
155 
156 /* Register masks */
157 #define ADXL38X_MASK_RANGE 0xC0
158 #define ADXL38X_MASK_OP_MODE 0x0F
159 #define ADXL38X_MASK_CHEN_DIG_EN 0xF0
160 #define ADXL38X_NEG_ACC_MSK NO_OS_GENMASK(31, 16)
161 #define ADXL38X_SLF_TST_CTRL_MSK 0xE0
162 #define ADXL38X_FIFOCFG_FIFOMODE_MSK 0x30
163 
164 /* Pre-defined codes */
165 #define ADXL38X_RESET_CODE 0x52
166 #define ADXL38X_RESET_STATUS 0x80000400
167 
168 /* Scale Factors */
169 /*
170  * ADXL380
171  * At +/- 4g with 16-bit resolution, scale from datasheet = 133.3ug/LSB.
172  * 1333 * (10^-7)
173  * For +/- 8g range a multiplier with value 2 is used.
174  * For +/-16g range, a multiplier with value 4 is used.
175  */
176 #define ADXL380_ACC_SCALE_FACTOR_GEE_MUL (int64_t) 1333
177 /*
178  * ADXL382
179  * At +/- 15g with 16-bit resolution, scale from datasheet = 500ug/LSB.
180  * 5000 * (10^-7)
181  * For +/- 30g range a multiplier with value 2 is used.
182  * For +/-60g range, a multiplier with value 4 is used.
183  */
184 #define ADXL382_ACC_SCALE_FACTOR_GEE_MUL (int64_t) 5000
185 /* Common denominator for ADXL380 and ADXL382 */
186 #define ADXL38X_ACC_SCALE_FACTOR_GEE_DIV (int32_t) 10000000
187 /*
188  * ADXL380/382 Temperature
189  *
190  * scale is 10.2 LSB/C.
191  * Offset = 550LSB at 25C
192  * offset at 0C = 550 - (10.2 * 25) LSB
193  * offset at 0C = 295 LSB
194  */
195 #define ADXL38X_TEMP_OFFSET (int32_t) 295
196 #define ADXL38X_TEMP_SCALE_NUM (int32_t) 102
197 #define ADXL38X_TEMP_SCALE_DEN (int32_t) 10
198 
199 /* Sensitivity */
200 /*
201  * ADXL380
202  * At +/- 4g with 16-bit resolution, sensitivity from datasheet = 7500LSB/g.
203  * For +/- 8g range a divisor with value 2 is used.
204  * For +/-16g range, a divisor with value 4 is used.
205  */
206 #define ADXL380_ACC_SENSITIVITY (int32_t) 7500
207 /*
208  * ADXL382
209  * At +/- 15g with 16-bit resolution, sensitivity from datasheet = 2000LSB/g.
210  * For +/- 30g range a divisor with value 2 is used.
211  * For +/-60g range, a divisor with value 4 is used.
212  */
213 #define ADXL382_ACC_SENSITIVITY (int32_t) 2000
214 
215 /* Self Test Limits */
216 /* ADXL380 */
217 #define ADXL380_XY_ST_LIMIT_MIN 29
218 #define ADXL380_Z_ST_LIMIT_MIN 27
219 #define ADXL380_XY_ST_LIMIT_MAX 50
220 #define ADXL380_Z_ST_LIMIT_MAX 32
221 /* ADXL382 */
222 #define ADXL382_XY_ST_LIMIT_MIN 31
223 #define ADXL382_Z_ST_LIMIT_MIN 26
224 #define ADXL382_XY_ST_LIMIT_MAX 42
225 #define ADXL382_Z_ST_LIMIT_MAX 34
226 
227 #define ADXL38X_ST_LIMIT_DENOMINATOR 10
228 
229 /******************************************************************************/
230 /*************************** Types Declarations *******************************/
231 /******************************************************************************/
239 };
240 
244 };
245 
257 };
258 
277 };
278 
295 };
296 
306 };
307 
313  int64_t integer;
314  int32_t fractional;
315 };
316 
322 };
323 
329 } ;
330 
335 struct adxl38x_dev {
346 
347  uint8_t comm_buff[320];
348 };
349 
361 };
362 
364  //Status 3
365  uint8_t DATA_READY : 1;
366  uint8_t RESERVED2 : 7;
367  //Status 2
368  uint8_t UV_FLAG : 1;
369  uint8_t UV_FLAG_STICKY : 1;
370  uint8_t RESERVED1 : 1;
371  uint8_t NVM_CRC_ERR : 1;
372  uint8_t NVM_CRC_DONE : 1;
373  uint8_t NVM_ECC_DET : 1;
374  uint8_t RESERVED : 1;
375  uint8_t NVM_ECC_DONE : 1;
376  //Status 1
377  uint8_t SINGLE_TAP : 1;
378  uint8_t DOUBLE_TAP : 1;
379  uint8_t TRIPLE_TAP : 1;
380  uint8_t OVER_RANGE : 1;
381  uint8_t OVER_RANGE_STICKY : 1;
382  uint8_t ACT : 1;
383  uint8_t INACT : 1;
384  uint8_t NVM_IRQ : 1;
385  //Status 0
386  uint8_t PARITY_ERR_STICKY : 1;
387  uint8_t FIFO_FULL : 1;
388  uint8_t FIFO_OVR : 1;
389  uint8_t FIFO_WATERMARK : 1;
390  uint8_t FIFO_READY : 1;
392  uint8_t NVM_DONE : 1;
393  uint8_t NVM_BUSY_STATUS : 1;
394 };
395 
398  uint32_t value;
399 };
400 
401 /******************************************************************************/
402 /************************ Functions Declarations ******************************/
403 /******************************************************************************/
404 
405 int adxl38x_read_device_data(struct adxl38x_dev *dev, uint8_t base_address,
406  uint16_t size, uint8_t *read_data);
407 int adxl38x_write_device_data(struct adxl38x_dev *dev, uint8_t base_address,
408  uint16_t size, uint8_t *write_data);
409 
410 int adxl38x_register_update_bits(struct adxl38x_dev *dev, uint8_t reg_addr,
411  uint8_t mask,
412  uint8_t update_val);
413 
414 int adxl38x_init(struct adxl38x_dev **device,
416 
417 int adxl38x_remove(struct adxl38x_dev *dev);
418 
419 int adxl38x_soft_reset(struct adxl38x_dev *dev);
420 
421 int adxl38x_get_sts_reg(struct adxl38x_dev *dev,
422  union adxl38x_sts_reg_flags *status_flags);
423 
424 int adxl38x_set_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode);
425 
426 int adxl38x_get_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode *op_mode);
427 
428 int adxl38x_set_range(struct adxl38x_dev *dev, enum adxl38x_range range_val);
429 
430 int adxl38x_get_range(struct adxl38x_dev *dev, enum adxl38x_range *range_val);
431 
432 int adxl38x_get_deviceID(struct adxl38x_dev *dev,
433  enum adxl38x_id *devID);
434 
435 int adxl38x_set_self_test_registers(struct adxl38x_dev *dev, bool st_mode,
436  bool st_force, bool st_dir);
437 
438 int adxl38x_get_sts_reg(struct adxl38x_dev *dev,
439  union adxl38x_sts_reg_flags *status_flags);
440 
441 int adxl38x_get_raw_xyz(struct adxl38x_dev *dev, uint16_t *raw_x,
442  uint16_t *raw_y, uint16_t *raw_z);
443 
444 int adxl38x_get_temp(struct adxl38x_dev *dev,
445  struct adxl38x_fractional_val *raw_temp);
446 
447 int adxl38x_get_raw_data(struct adxl38x_dev *dev,
448  enum adxl38x_ch_select channels,
449  uint16_t *raw_x, uint16_t *raw_y,
450  uint16_t *raw_z, uint16_t *raw_temp);
451 
452 int adxl38x_get_xyz_gees(struct adxl38x_dev *dev,
453  enum adxl38x_ch_select channels,
454  struct adxl38x_fractional_val *x, struct adxl38x_fractional_val *y,
455  struct adxl38x_fractional_val *z);
456 
457 int adxl38x_selftest(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode,
458  bool *st_x, bool *st_y, bool *st_z);
459 
460 int adxl38x_accel_set_FIFO( struct adxl38x_dev *dev, uint16_t numSamples,
461  bool externalTrigger, enum adxl38x_fifo_mode fifo_mode,
462  bool chIDEnable, bool readReset);
463 
464 int adxl38x_data_raw_to_gees( struct adxl38x_dev *dev, uint8_t *raw_accel_data,
465  struct adxl38x_fractional_val *data_frac);
466 
467 #endif /* __ADXL38X_H__ */
468 
adxl38x_comm_type
adxl38x_comm_type
Definition: adxl38x.h:241
ADXL38X_RESET_DEVID_MST
#define ADXL38X_RESET_DEVID_MST
Definition: adxl38x.h:146
adxl38x_register_update_bits
int adxl38x_register_update_bits(struct adxl38x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t update_val)
Updates register with specified bits using given mask.
Definition: adxl38x.c:136
ADXL382_RANGE_15G
@ ADXL382_RANGE_15G
Definition: adxl38x.h:252
ADXL38X_RESET_CODE
#define ADXL38X_RESET_CODE
Definition: adxl38x.h:165
ADXL38X_MODE_HP_SERIAL_VLP_OP
@ ADXL38X_MODE_HP_SERIAL_VLP_OP
Definition: adxl38x.h:276
ADXL38X_FIFO_CFG1
#define ADXL38X_FIFO_CFG1
Definition: adxl38x.h:101
ADXL38X_MODE_VLP
@ ADXL38X_MODE_VLP
Definition: adxl38x.h:267
adxl38x.h
Header file of ADXL38X Driver.
no_os_alloc.h
adxl38x_init_param::comm_type
enum adxl38x_comm_type comm_type
Definition: adxl38x.h:358
ADXL38X_I2C_COMM
@ ADXL38X_I2C_COMM
Definition: adxl38x.h:243
_adxl38x_sts_reg_flags::OVER_RANGE
uint8_t OVER_RANGE
Definition: adxl38x.h:380
ADXL38X_DEVID_MST
#define ADXL38X_DEVID_MST
Definition: adxl38x.h:55
adxl38x_sts_reg_flags::fields
struct _adxl38x_sts_reg_flags fields
Definition: adxl38x.h:397
adxl38x_dev::dev_type
enum adxl38x_id dev_type
Definition: adxl38x.h:337
adxl372_spi_reg_read_multiple
int32_t adxl372_spi_reg_read_multiple(struct adxl372_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
Definition: adxl372_spi.c:94
ADXL38X_MODE_LP_SERIAL_ULP_OP
@ ADXL38X_MODE_LP_SERIAL_ULP_OP
Definition: adxl38x.h:269
no_os_div_s64_rem
int64_t no_os_div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
adxl38x_sts_reg_flags::value
uint32_t value
Definition: adxl38x.h:398
_adxl38x_sts_reg_flags::FIFO_OVR
uint8_t FIFO_OVR
Definition: adxl38x.h:388
no_os_i2c_write
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
ADXL38X_MISC0
#define ADXL38X_MISC0
Definition: adxl38x.h:86
_adxl38x_sts_reg_flags::DOUBLE_TAP
uint8_t DOUBLE_TAP
Definition: adxl38x.h:378
ADXL38X_CH_EN_Z
@ ADXL38X_CH_EN_Z
Definition: adxl38x.h:288
_adxl38x_sts_reg_flags::NVM_BUSY_STATUS
uint8_t NVM_BUSY_STATUS
Definition: adxl38x.h:393
ADXL380_ACC_SCALE_FACTOR_GEE_MUL
#define ADXL380_ACC_SCALE_FACTOR_GEE_MUL
Definition: adxl38x.h:176
ADXL382_RANGE_60G
@ ADXL382_RANGE_60G
Definition: adxl38x.h:256
ADXL38X_SLF_TST_CTRL_MSK
#define ADXL38X_SLF_TST_CTRL_MSK
Definition: adxl38x.h:161
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
ADXL38X_ACC_SCALE_FACTOR_GEE_DIV
#define ADXL38X_ACC_SCALE_FACTOR_GEE_DIV
Definition: adxl38x.h:186
adxl38x_comm_desc::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adxl38x.h:321
_adxl38x_sts_reg_flags
Definition: adxl38x.h:363
ADXL38X_FIFO_NORMAL
@ ADXL38X_FIFO_NORMAL
Definition: adxl38x.h:303
ADXL38X_MODE_HP_SERIAL_ULP_OP
@ ADXL38X_MODE_HP_SERIAL_ULP_OP
Definition: adxl38x.h:275
ADXL382_Z_ST_LIMIT_MIN
#define ADXL382_Z_ST_LIMIT_MIN
Definition: adxl38x.h:223
adxl38x_dev::com_desc
union adxl38x_comm_desc com_desc
Definition: adxl38x.h:339
_adxl38x_sts_reg_flags::ACT
uint8_t ACT
Definition: adxl38x.h:382
no_os_spi.h
Header file of SPI Interface.
ADXL382_ACC_SENSITIVITY
#define ADXL382_ACC_SENSITIVITY
Definition: adxl38x.h:213
adxl38x_get_xyz_gees
int adxl38x_get_xyz_gees(struct adxl38x_dev *dev, enum adxl38x_ch_select channels, struct adxl38x_fractional_val *x, struct adxl38x_fractional_val *y, struct adxl38x_fractional_val *z)
Reads the raw output data of each axis and converts it to g.
Definition: adxl38x.c:666
_adxl38x_sts_reg_flags::NVM_IRQ
uint8_t NVM_IRQ
Definition: adxl38x.h:384
adxl38x_data_raw_to_gees
int adxl38x_data_raw_to_gees(struct adxl38x_dev *dev, uint8_t *raw_accel_data, struct adxl38x_fractional_val *data_frac)
Function to convert accel data to gees.
Definition: adxl38x.c:957
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
ADXL38X_DEVID_AD
#define ADXL38X_DEVID_AD
Definition: adxl38x.h:54
ADXL38X_CH_EN_ZT
@ ADXL38X_CH_EN_ZT
Definition: adxl38x.h:292
ADXL382_XY_ST_LIMIT_MAX
#define ADXL382_XY_ST_LIMIT_MAX
Definition: adxl38x.h:224
ADXL38X_MODE_LP_SERIAL_VLP_OP
@ ADXL38X_MODE_LP_SERIAL_VLP_OP
Definition: adxl38x.h:270
ADXL38X_PART_ID
#define ADXL38X_PART_ID
Definition: adxl38x.h:56
ADXL38X_MODE_RBW
@ ADXL38X_MODE_RBW
Definition: adxl38x.h:271
ADXL38X_STATUS0
#define ADXL38X_STATUS0
Definition: adxl38x.h:71
adxl38x_get_sts_reg
int adxl38x_get_sts_reg(struct adxl38x_dev *dev, union adxl38x_sts_reg_flags *status_flags)
Reads the status registers.
Definition: adxl38x.c:466
no_os_delay.h
Header file of Delay functions.
adxl38x_clear_self_test_registers
int adxl38x_clear_self_test_registers(struct adxl38x_dev *dev)
Resets the self test registers for the part.
Definition: adxl38x.c:446
ADXL38X_FIFO_DISABLE
@ ADXL38X_FIFO_DISABLE
Definition: adxl38x.h:302
_adxl38x_sts_reg_flags::NVM_CRC_DONE
uint8_t NVM_CRC_DONE
Definition: adxl38x.h:372
ADXL38X_TEMP_SCALE_DEN
#define ADXL38X_TEMP_SCALE_DEN
Definition: adxl38x.h:197
ADXL38X_SPI_WRITE
#define ADXL38X_SPI_WRITE
Definition: adxl38x.h:51
ADXL38X_MODE_HRT_SND
@ ADXL38X_MODE_HRT_SND
Definition: adxl38x.h:265
ADXL38X_TEMP_SCALE_NUM
#define ADXL38X_TEMP_SCALE_NUM
Definition: adxl38x.h:196
device
Definition: ad9361_util.h:69
adxl372.h
Header file for adxl372 Driver.
_adxl38x_sts_reg_flags::FIFO_READY
uint8_t FIFO_READY
Definition: adxl38x.h:390
_adxl38x_sts_reg_flags::DATA_READY
uint8_t DATA_READY
Definition: adxl38x.h:365
adxl38x_accel_set_FIFO
int adxl38x_accel_set_FIFO(struct adxl38x_dev *dev, uint16_t numSamples, bool externalTrigger, enum adxl38x_fifo_mode fifo_mode, bool chIDEnable, bool readReset)
Function to set the paramenters for FIFO mode.
Definition: adxl38x.c:896
adxl38x_op_mode
ADXL38X Operating modes (OP MODE[3:0]).
adxl38x_get_raw_data
int adxl38x_get_raw_data(struct adxl38x_dev *dev, enum adxl38x_ch_select channels, uint16_t *raw_x, uint16_t *raw_y, uint16_t *raw_z, uint16_t *raw_temp)
Reads the raw output data using burst read.
Definition: adxl38x.c:581
ADXL38X_CH_DSB_ALL
@ ADXL38X_CH_DSB_ALL
Definition: adxl38x.h:284
ADXL380_XY_ST_LIMIT_MIN
#define ADXL380_XY_ST_LIMIT_MIN
Definition: adxl38x.h:217
adxl38x_get_xyz_gees
int adxl38x_get_xyz_gees(struct adxl38x_dev *dev, enum adxl38x_ch_select channels, struct adxl38x_fractional_val *x, struct adxl38x_fractional_val *y, struct adxl38x_fractional_val *z)
Reads the raw output data of each axis and converts it to g.
Definition: adxl38x.c:666
ADXL38X_FIFO_STREAM
@ ADXL38X_FIFO_STREAM
Definition: adxl38x.h:304
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
adxl38x_get_deviceID
int adxl38x_get_deviceID(struct adxl38x_dev *dev, enum adxl38x_id *devID)
Gets the current device type.
Definition: adxl38x.c:390
_adxl38x_sts_reg_flags::NVM_ECC_DONE
uint8_t NVM_ECC_DONE
Definition: adxl38x.h:375
_adxl38x_sts_reg_flags::RESERVED2
uint8_t RESERVED2
Definition: adxl38x.h:366
ADXL38X_MODE_STDBY
@ ADXL38X_MODE_STDBY
Definition: adxl38x.h:264
adxl38x_dev::op_mode
enum adxl38x_op_mode op_mode
Definition: adxl38x.h:345
ADXL38X_DIG_EN
#define ADXL38X_DIG_EN
Definition: adxl38x.h:91
adxl38x_soft_reset
int adxl38x_soft_reset(struct adxl38x_dev *dev)
Performs a soft reset of the device.
Definition: adxl38x.c:270
adxl38x_dev
ADXL38X Device structure.
Definition: adxl38x.h:335
adxl38x_get_sts_reg
int adxl38x_get_sts_reg(struct adxl38x_dev *dev, union adxl38x_sts_reg_flags *status_flags)
Reads the status registers.
Definition: adxl38x.c:466
adxl38x_get_deviceID
int adxl38x_get_deviceID(struct adxl38x_dev *dev, enum adxl38x_id *devID)
Gets the current device type.
Definition: adxl38x.c:390
ADXL38X_RESET_PART_ID
#define ADXL38X_RESET_PART_ID
Definition: adxl38x.h:147
ADXL38X_MODE_ULP
@ ADXL38X_MODE_ULP
Definition: adxl38x.h:266
adxl38x_dev::range
enum adxl38x_range range
Definition: adxl38x.h:343
adxl38x_comm_desc::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: adxl38x.h:319
ADXL38X_CH_EN_YZ
@ ADXL38X_CH_EN_YZ
Definition: adxl38x.h:289
_adxl38x_sts_reg_flags::RESERVED1
uint8_t RESERVED1
Definition: adxl38x.h:370
no_os_div_s64
int64_t no_os_div_s64(int64_t dividend, int32_t divisor)
ADXL380_RANGE_4G
@ ADXL380_RANGE_4G
Definition: adxl38x.h:251
adxl38x_accel_set_FIFO
int adxl38x_accel_set_FIFO(struct adxl38x_dev *dev, uint16_t num_samples, bool external_trigger, enum adxl38x_fifo_mode fifo_mode, bool ch_ID_enable, bool read_reset)
Function to set the paramenters for FIFO mode.
Definition: adxl38x.c:896
_adxl38x_sts_reg_flags::UV_FLAG
uint8_t UV_FLAG
Definition: adxl38x.h:368
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
adxl38x_soft_reset
int adxl38x_soft_reset(struct adxl38x_dev *dev)
Performs a soft reset of the device.
Definition: adxl38x.c:270
ADXL38X_RESET_ZERO
#define ADXL38X_RESET_ZERO
Definition: adxl38x.h:144
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
ADXL38X_FIFO_TRIGGER
@ ADXL38X_FIFO_TRIGGER
Definition: adxl38x.h:305
ADXL38X_REG_RESET
#define ADXL38X_REG_RESET
Definition: adxl38x.h:94
ADXL38X_CH_EN_XYZT
@ ADXL38X_CH_EN_XYZT
Definition: adxl38x.h:294
ADXL38X_OP_MODE
#define ADXL38X_OP_MODE
Definition: adxl38x.h:90
adxl38x_dev::comm_buff
uint8_t comm_buff[320]
Definition: adxl38x.h:347
no_os_error.h
Error codes definition.
_adxl38x_sts_reg_flags::NVM_CRC_ERR
uint8_t NVM_CRC_ERR
Definition: adxl38x.h:371
ADXL38X_MODE_HP
@ ADXL38X_MODE_HP
Definition: adxl38x.h:274
ADXL38X_TEMP_OFFSET
#define ADXL38X_TEMP_OFFSET
Definition: adxl38x.h:195
ADXL372_REG_WRITE
#define ADXL372_REG_WRITE(x)
Definition: adxl372.h:116
ADXL382_ACC_SCALE_FACTOR_GEE_MUL
#define ADXL382_ACC_SCALE_FACTOR_GEE_MUL
Definition: adxl38x.h:184
ID_ADXL380
@ ID_ADXL380
Definition: adxl38x.h:237
adxl38x_read_device_data
int adxl38x_read_device_data(struct adxl38x_dev *dev, uint8_t base_address, uint16_t size, uint8_t *read_data)
Reads from the device.
Definition: adxl38x.c:69
_adxl38x_sts_reg_flags::UV_FLAG_STICKY
uint8_t UV_FLAG_STICKY
Definition: adxl38x.h:369
adxl38x_ch_select
adxl38x_ch_select
Definition: adxl38x.h:283
ADXL38X_MASK_RANGE
#define ADXL38X_MASK_RANGE
Definition: adxl38x.h:157
adxl372_i2c_reg_read
int32_t adxl372_i2c_reg_read(struct adxl372_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: adxl372_i2c.c:47
ADXL38X_MODE_RBW_SERIAL_ULP_OP
@ ADXL38X_MODE_RBW_SERIAL_ULP_OP
Definition: adxl38x.h:272
ADXL38X_CH_EN_XY
@ ADXL38X_CH_EN_XY
Definition: adxl38x.h:287
adxl372_spi_reg_read
int32_t adxl372_spi_reg_read(struct adxl372_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: adxl372_spi.c:47
adxl372_dev
Definition: adxl372.h:362
ADXL382_RANGE_30G
@ ADXL382_RANGE_30G
Definition: adxl38x.h:254
adxl38x_sts_reg_flags
Definition: adxl38x.h:396
adxl38x_fifo_mode
ADXL38X FIFO mode (FIFO_CFG1[5:4]).
adxl38x_set_range
int adxl38x_set_range(struct adxl38x_dev *dev, enum adxl38x_range range_val)
Sets the measurement range register value.
Definition: adxl38x.c:345
ADXL38X_FIFOCFG_FIFOMODE_MSK
#define ADXL38X_FIFOCFG_FIFOMODE_MSK
Definition: adxl38x.h:162
_adxl38x_sts_reg_flags::OVER_RANGE_STICKY
uint8_t OVER_RANGE_STICKY
Definition: adxl38x.h:381
adxl38x_fractional_val::integer
int64_t integer
Definition: adxl38x.h:313
ADXL38X_SPI_READ
#define ADXL38X_SPI_READ
Definition: adxl38x.h:50
ADXL38X_XDATA_H
#define ADXL38X_XDATA_H
Definition: adxl38x.h:75
ADXL38X_SNSR_AXIS_EN
#define ADXL38X_SNSR_AXIS_EN
Definition: adxl38x.h:108
adxl38x_register_update_bits
int adxl38x_register_update_bits(struct adxl38x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t update_val)
Updates register with specified bits using given mask.
Definition: adxl38x.c:136
adxl38x_write_device_data
int adxl38x_write_device_data(struct adxl38x_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data)
Writes to the device.
Definition: adxl38x.c:107
adxl38x_get_range
int adxl38x_get_range(struct adxl38x_dev *dev, enum adxl38x_range *range_val)
Gets the current range setting of the device.
Definition: adxl38x.c:366
adxl38x_get_raw_xyz
int adxl38x_get_raw_xyz(struct adxl38x_dev *dev, uint16_t *raw_x, uint16_t *raw_y, uint16_t *raw_z)
Reads the raw output data using continuous read.
Definition: adxl38x.c:490
ADXL38X_ST_LIMIT_DENOMINATOR
#define ADXL38X_ST_LIMIT_DENOMINATOR
Definition: adxl38x.h:227
adxl38x_selftest
int adxl38x_selftest(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode, bool *st_x, bool *st_y, bool *st_z)
Executed Selftest on the sensing axes and returns the outcome of the test.
Definition: adxl38x.c:759
adxl38x_get_op_mode
int adxl38x_get_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode *op_mode)
Gets the current operation mode of the device.
Definition: adxl38x.c:321
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
adxl38x_get_temp
int adxl38x_get_temp(struct adxl38x_dev *dev, struct adxl38x_fractional_val *raw_temp)
Reads the raw temperature data using burst read.
Definition: adxl38x.c:531
ADXL38X_YDATA_H
#define ADXL38X_YDATA_H
Definition: adxl38x.h:77
adxl372_i2c_reg_write
int32_t adxl372_i2c_reg_write(struct adxl372_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: adxl372_i2c.c:76
adxl38x_init
int adxl38x_init(struct adxl38x_dev **device, struct adxl38x_init_param init_param)
Initializes the device and checks for valid peripheral communication.
Definition: adxl38x.c:167
adxl38x_id
adxl38x_id
Definition: adxl38x.h:236
ADXL38X_FIFO_CFG0
#define ADXL38X_FIFO_CFG0
Definition: adxl38x.h:100
ADXL380_RANGE_8G
@ ADXL380_RANGE_8G
Definition: adxl38x.h:253
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
adxl38x_get_temp
int adxl38x_get_temp(struct adxl38x_dev *dev, struct adxl38x_fractional_val *temp_degC)
Reads the raw temperature data using burst read.
Definition: adxl38x.c:531
adxl38x_fractional_val
Data format in which the values are converted.
Definition: adxl38x.h:312
_adxl38x_sts_reg_flags::RESERVED
uint8_t RESERVED
Definition: adxl38x.h:374
_adxl38x_sts_reg_flags::FIFO_FULL
uint8_t FIFO_FULL
Definition: adxl38x.h:387
no_os_i2c_read
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
ADXL38X_SPI_COMM
@ ADXL38X_SPI_COMM
Definition: adxl38x.h:242
adxl38x_data_raw_to_gees
int adxl38x_data_raw_to_gees(struct adxl38x_dev *dev, uint8_t *raw_accel_data, struct adxl38x_fractional_val *data_frac)
Function to convert accel data to gees.
Definition: adxl38x.c:957
no_os_i2c.h
Header file of I2C Interface.
ADXL380_Z_ST_LIMIT_MAX
#define ADXL380_Z_ST_LIMIT_MAX
Definition: adxl38x.h:220
adxl38x_get_range
int adxl38x_get_range(struct adxl38x_dev *dev, enum adxl38x_range *range_val)
Gets the current range setting of the device.
Definition: adxl38x.c:366
adxl38x_get_raw_xyz
int adxl38x_get_raw_xyz(struct adxl38x_dev *dev, uint16_t *raw_x, uint16_t *raw_y, uint16_t *raw_z)
Reads the raw output data using continuous read.
Definition: adxl38x.c:490
ADXL38X_NEG_ACC_MSK
#define ADXL38X_NEG_ACC_MSK
Definition: adxl38x.h:160
ID_ADXL382
@ ID_ADXL382
Definition: adxl38x.h:238
adxl38x_dev::comm_type
enum adxl38x_comm_type comm_type
Definition: adxl38x.h:341
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
adxl38x_set_op_mode
int adxl38x_set_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode)
Places the device into the given operation mode.
Definition: adxl38x.c:298
adxl38x_comm_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: adxl38x.h:328
adxl38x_selftest
int adxl38x_selftest(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode, bool *st_x, bool *st_y, bool *st_z)
Executed Selftest on the sensing axes and returns the outcome of the test.
Definition: adxl38x.c:759
adxl38x_comm_init_param::i2c_init
struct no_os_i2c_init_param i2c_init
Definition: adxl38x.h:326
adxl38x_range
ADXL38X Range (OP MODE[7:6]).
ADXL382_Z_ST_LIMIT_MAX
#define ADXL382_Z_ST_LIMIT_MAX
Definition: adxl38x.h:225
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
_adxl38x_sts_reg_flags::TRIPLE_TAP
uint8_t TRIPLE_TAP
Definition: adxl38x.h:379
adxl38x_remove
int adxl38x_remove(struct adxl38x_dev *dev)
Free the resources allocated by the init function.
Definition: adxl38x.c:250
adxl38x_set_op_mode
int adxl38x_set_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode)
Places the device into the given operation mode.
Definition: adxl38x.c:298
ADXL38X_RESET_DEVID_AD
#define ADXL38X_RESET_DEVID_AD
Definition: adxl38x.h:145
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
NULL
#define NULL
Definition: wrapper.h:64
_adxl38x_sts_reg_flags::PARITY_ERR_STICKY
uint8_t PARITY_ERR_STICKY
Definition: adxl38x.h:386
ADXL38X_TDATA_H
#define ADXL38X_TDATA_H
Definition: adxl38x.h:81
adxl38x_init
int adxl38x_init(struct adxl38x_dev **device, struct adxl38x_init_param init_param)
Initializes the device and checks for valid peripheral communication.
Definition: adxl38x.c:167
no_os_get_unaligned_be32
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
adxl38x_get_raw_data
int adxl38x_get_raw_data(struct adxl38x_dev *dev, enum adxl38x_ch_select channels, uint16_t *raw_x, uint16_t *raw_y, uint16_t *raw_z, uint16_t *raw_temp)
Reads the raw output data using burst read.
Definition: adxl38x.c:581
adxl38x_init_param::dev_type
enum adxl38x_id dev_type
Definition: adxl38x.h:360
adxl372_spi_reg_write
int32_t adxl372_spi_reg_write(struct adxl372_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: adxl372_spi.c:73
_adxl38x_sts_reg_flags::NVM_DONE
uint8_t NVM_DONE
Definition: adxl38x.h:392
ADXL380_ACC_SENSITIVITY
#define ADXL380_ACC_SENSITIVITY
Definition: adxl38x.h:206
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
ADXL38X_CH_EN_YZT
@ ADXL38X_CH_EN_YZT
Definition: adxl38x.h:293
ADXL38X_MODE_RBW_SERIAL_VLP_OP
@ ADXL38X_MODE_RBW_SERIAL_VLP_OP
Definition: adxl38x.h:273
adxl38x_write_device_data
int adxl38x_write_device_data(struct adxl38x_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data)
Writes to the device.
Definition: adxl38x.c:107
ADXL38X_CH_EN_X
@ ADXL38X_CH_EN_X
Definition: adxl38x.h:285
adxl38x_fractional_val::fractional
int32_t fractional
Definition: adxl38x.h:314
ADXL38X_CH_EN_T
@ ADXL38X_CH_EN_T
Definition: adxl38x.h:291
adxl372_dev::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: adxl372.h:366
ADXL380_XY_ST_LIMIT_MAX
#define ADXL380_XY_ST_LIMIT_MAX
Definition: adxl38x.h:219
ADXL38X_CH_EN_XYZ
@ ADXL38X_CH_EN_XYZ
Definition: adxl38x.h:290
adxl38x_set_self_test_registers
int adxl38x_set_self_test_registers(struct adxl38x_dev *dev, bool st_mode, bool st_force, bool st_dir)
Sets the part to execute self-test routine.
Definition: adxl38x.c:418
adxl38x_remove
int adxl38x_remove(struct adxl38x_dev *dev)
Free the resources allocated by the init function.
Definition: adxl38x.c:250
_adxl38x_sts_reg_flags::FIFO_WATERMARK
uint8_t FIFO_WATERMARK
Definition: adxl38x.h:389
adxl372_i2c_reg_read_multiple
int32_t adxl372_i2c_reg_read_multiple(struct adxl372_dev *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count)
Definition: adxl372_i2c.c:97
adxl38x_get_op_mode
int adxl38x_get_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode *op_mode)
Gets the current operation mode of the device.
Definition: adxl38x.c:321
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
no_os_get_unaligned_be16
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
_adxl38x_sts_reg_flags::INACT
uint8_t INACT
Definition: adxl38x.h:383
ADXL382_XY_ST_LIMIT_MIN
#define ADXL382_XY_ST_LIMIT_MIN
Definition: adxl38x.h:222
no_os_util.h
Header file of utility functions.
no_os_sign_extend32
int32_t no_os_sign_extend32(uint32_t value, int index)
adxl38x_read_device_data
int adxl38x_read_device_data(struct adxl38x_dev *dev, uint8_t base_address, uint16_t size, uint8_t *read_data)
Reads from the device.
Definition: adxl38x.c:69
ADXL38X_MODE_LP
@ ADXL38X_MODE_LP
Definition: adxl38x.h:268
_adxl38x_sts_reg_flags::EFUSE_BUSY_REGERR_STICKY
uint8_t EFUSE_BUSY_REGERR_STICKY
Definition: adxl38x.h:391
ADXL38X_CH_EN_Y
@ ADXL38X_CH_EN_Y
Definition: adxl38x.h:286
adxl38x_comm_init_param
Definition: adxl38x.h:324
_adxl38x_sts_reg_flags::NVM_ECC_DET
uint8_t NVM_ECC_DET
Definition: adxl38x.h:373
errno.h
Error macro definition for ARM Compiler.
adxl38x_comm_desc
Definition: adxl38x.h:317
adxl38x_init_param
Structure holding the parameters for ADXL38X device initialization.
Definition: adxl38x.h:354
adxl38x_set_range
int adxl38x_set_range(struct adxl38x_dev *dev, enum adxl38x_range range_val)
Sets the measurement range register value.
Definition: adxl38x.c:345
ADXL38X_ZDATA_H
#define ADXL38X_ZDATA_H
Definition: adxl38x.h:79
ADXL38X_MASK_OP_MODE
#define ADXL38X_MASK_OP_MODE
Definition: adxl38x.h:158
adxl38x_set_self_test_registers
int adxl38x_set_self_test_registers(struct adxl38x_dev *dev, bool st_mode, bool st_force, bool st_dir)
Sets the part to execute self-test routine.
Definition: adxl38x.c:418
ADXL380_Z_ST_LIMIT_MIN
#define ADXL380_Z_ST_LIMIT_MIN
Definition: adxl38x.h:218
adxl372_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adxl372.h:364
_adxl38x_sts_reg_flags::SINGLE_TAP
uint8_t SINGLE_TAP
Definition: adxl38x.h:377
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
ADXL38X_MASK_CHEN_DIG_EN
#define ADXL38X_MASK_CHEN_DIG_EN
Definition: adxl38x.h:159
ADXL372_REG_READ
#define ADXL372_REG_READ(x)
Definition: adxl372.h:115
ADXL380_RANGE_16G
@ ADXL380_RANGE_16G
Definition: adxl38x.h:255
adxl38x_init_param::comm_init
union adxl38x_comm_init_param comm_init
Definition: adxl38x.h:356