no-OS
adxl38x.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef __ADXL38X_H__
40 #define __ADXL38X_H__
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include <stdbool.h>
47 #include "no_os_i2c.h"
48 #include "no_os_spi.h"
49 
50 /******************************************************************************/
51 /******************************** ADXL38X *************************************/
52 /******************************************************************************/
53 /* Constants and Macros */
54 
55 /* SPI */
56 #define ADXL38X_SPI_READ 0x01
57 #define ADXL38X_SPI_WRITE 0x00
58 
59 /* Register Map fo ADXL38X (Rev H DS)*/
60 #define ADXL38X_DEVID_AD 0x00
61 #define ADXL38X_DEVID_MST 0x01
62 #define ADXL38X_PART_ID 0x02
63 #define ADXL38X_PART_ID_REV_ID 0x03
64 #define ADXL38X_SERIAL_NUMBER_0 0x04
65 #define ADXL38X_SERIAL_NUMBER_1 0x05
66 #define ADXL38X_SERIAL_NUMBER_2 0x06
67 #define ADXL38X_SERIAL_NUMBER_3 0x07
68 #define ADXL38X_SERIAL_NUMBER_4 0x08
69 #define ADXL38X_SERIAL_NUMBER_5 0x09
70 #define ADXL38X_SERIAL_NUMBER_6 0x0A
71 #define ADXL38X_DEV_DELTA_Q_X 0x0B
72 #define ADXL38X_DEV_DELTA_Q_Y 0x0C
73 #define ADXL38X_DEV_DELTA_Q_Z 0x0D
74 #define ADXL38X_DEV_DELTA_F0_X 0x0E
75 #define ADXL38X_DEV_DELTA_F0_Y 0x0F
76 #define ADXL38X_DEV_DELTA_F0_Z 0x10
77 #define ADXL38X_STATUS0 0x11
78 #define ADXL38X_STATUS1 0x12
79 #define ADXL38X_STATUS2 0x13
80 #define ADXL38X_STATUS3 0x14
81 #define ADXL38X_XDATA_H 0x15
82 #define ADXL38X_XDATA_L 0x16
83 #define ADXL38X_YDATA_H 0x17
84 #define ADXL38X_YDATA_L 0x18
85 #define ADXL38X_ZDATA_H 0x19
86 #define ADXL38X_ZDATA_L 0x1A
87 #define ADXL38X_TDATA_H 0x1B
88 #define ADXL38X_TDATA_L 0x1C
89 #define ADXL38X_FIFO_DATA 0x1D
90 #define ADXL38X_FIFO_STATUS0 0x1E
91 #define ADXL38X_FIFO_STATUS1 0x1F
92 #define ADXL38X_MISC0 0x20
93 #define ADXL38X_MISC1 0x21
94 #define ADXL38X_SENS_DSM 0x24
95 #define ADXL38X_CLK_CTRL 0x25
96 #define ADXL38X_OP_MODE 0x26
97 #define ADXL38X_DIG_EN 0x27
98 #define ADXL38X_SAR_I2C 0x28
99 #define ADXL38X_NVM_CTL 0x29
100 #define ADXL38X_REG_RESET 0x2A
101 #define ADXL38X_INT0_MAP0 0x2B
102 #define ADXL38X_INT0_MAP1 0x2C
103 #define ADXL38X_INT1_MAP0 0x2D
104 #define ADXL38X_INT1_MAP1 0x2E
105 #define ADXL38X_TEST_EN 0x2F
106 #define ADXL38X_FIFO_CFG0 0x30
107 #define ADXL38X_FIFO_CFG1 0x31
108 #define ADXL38X_SPT_CFG0 0x32
109 #define ADXL38X_SPT_CFG1 0x33
110 #define ADXL38X_SPT_CFG2 0x34
111 #define ADXL38X_SYNC_CFG 0x35
112 #define ADXL38X_PDM_CFG 0x36
113 #define ADXL38X_ACT_INACT_CTL 0x37
114 #define ADXL38X_SNSR_AXIS_EN 0x38
115 #define ADXL38X_THRESH_ACT_H 0x39
116 #define ADXL38X_THRESH_ACT_L 0x3A
117 #define ADXL38X_TIME_ACT_H 0x3B
118 #define ADXL38X_TIME_ACT_M 0x3C
119 #define ADXL38X_TIME_ACT_L 0x3D
120 #define ADXL38X_THRESH_INACT_H 0x3E
121 #define ADXL38X_THRESH_INACT_L 0x3F
122 #define ADXL38X_TIME_INACT_H 0x40
123 #define ADXL38X_TIME_INACT_M 0x41
124 #define ADXL38X_TIME_INACT_L 0x42
125 #define ADXL38X_TAP_THRESH 0x43
126 #define ADXL38X_TAP_DUR 0x44
127 #define ADXL38X_TAP_LATENT 0x45
128 #define ADXL38X_TAP_WINDOW 0x46
129 #define ADXL38X_TAP_CFG 0x47
130 #define ADXL38X_OR_CFG 0x48
131 #define ADXL38X_TRIG_CFG 0x49
132 #define ADXL38X_X_SAR_OFFSET 0x4A
133 #define ADXL38X_Y_SAR_OFFSET 0x4B
134 #define ADXL38X_Z_SAR_OFFSET 0x4C
135 #define ADXL38X_X_DSM_OFFSET 0x4D
136 #define ADXL38X_Y_DSM_OFFSET 0x4E
137 #define ADXL38X_Z_DSM_OFFSET 0x4F
138 #define ADXL38X_FILTER 0x50
139 #define ADXL38X_USER_TEMP_SENS_0 0x55
140 #define ADXL38X_USER_TEMP_SENS_1 0x56
141 #define ADXL38X_MISO 0x58
142 #define ADXL38X_SOUT0 0x59
143 #define ADXL38X_MCLK 0x5A
144 #define ADXL38X_BCLK 0x5B
145 #define ADXL38X_FSYNC 0x5C
146 #define ADXL38X_INT0 0x5D
147 #define ADXL38X_INT1 0x5E
148 
149 /* Register reset value for ADXL38X */
150 #define ADXL38X_RESET_ZERO 0x00
151 #define ADXL38X_RESET_DEVID_AD 0xAD
152 #define ADXL38X_RESET_DEVID_MST 0x1D
153 #define ADXL38X_RESET_PART_ID 0x17
154 #define ADXL38X_RESET_PART_ID_REV_ID 0xC1
155 #define ADXL38X_RESET_STATUS0 0x80
156 #define ADXL38X_RESET_STATUS2 0x04
157 #define ADXL38X_RESET_INT0_MAP0 0x80
158 #define ADXL38X_RESET_INT1_MAP1 0x80
159 #define ADXL38X_RESET_SPT_CFG1 0x08
160 #define ADXL38X_RESET_SPT_CFG2 0x1A
161 
162 /* Register masks */
163 #define ADXL38X_MASK_RANGE 0xC0
164 #define ADXL38X_MASK_OP_MODE 0x0F
165 #define ADXL38X_MASK_CHEN_DIG_EN 0xF0
166 #define ADXL38X_NEG_ACC_MSK NO_OS_GENMASK(31, 16)
167 #define ADXL38X_SLF_TST_CTRL_MSK 0xE0
168 #define ADXL38X_FIFOCFG_FIFOMODE_MSK 0x30
169 
170 /* Pre-defined codes */
171 #define ADXL38X_RESET_CODE 0x52
172 #define ADXL38X_RESET_STATUS 0x80000400
173 
174 /* Scale Factors */
175 /*
176  * ADXL380
177  * At +/- 4g with 16-bit resolution, scale from datasheet = 133.3ug/LSB.
178  * 1333 * (10^-7)
179  * For +/- 8g range a multiplier with value 2 is used.
180  * For +/-16g range, a multiplier with value 4 is used.
181  */
182 #define ADXL380_ACC_SCALE_FACTOR_GEE_MUL (int64_t) 1333
183 /*
184  * ADXL382
185  * At +/- 15g with 16-bit resolution, scale from datasheet = 500ug/LSB.
186  * 5000 * (10^-7)
187  * For +/- 30g range a multiplier with value 2 is used.
188  * For +/-60g range, a multiplier with value 4 is used.
189  */
190 #define ADXL382_ACC_SCALE_FACTOR_GEE_MUL (int64_t) 5000
191 /* Common denominator for ADXL380 and ADXL382 */
192 #define ADXL38X_ACC_SCALE_FACTOR_GEE_DIV (int32_t) 10000000
193 /*
194  * ADXL380/382 Temperature
195  *
196  * scale is 10.2 LSB/C.
197  * Offset = 550LSB at 25C
198  * offset at 0C = 550 - (10.2 * 25) LSB
199  * offset at 0C = 295 LSB
200  */
201 #define ADXL38X_TEMP_OFFSET (int32_t) 295
202 #define ADXL38X_TEMP_SCALE_NUM (int32_t) 102
203 #define ADXL38X_TEMP_SCALE_DEN (int32_t) 10
204 
205 /* Sensitivity */
206 /*
207  * ADXL380
208  * At +/- 4g with 16-bit resolution, sensitivity from datasheet = 7500LSB/g.
209  * For +/- 8g range a divisor with value 2 is used.
210  * For +/-16g range, a divisor with value 4 is used.
211  */
212 #define ADXL380_ACC_SENSITIVITY (int32_t) 7500
213 /*
214  * ADXL382
215  * At +/- 15g with 16-bit resolution, sensitivity from datasheet = 2000LSB/g.
216  * For +/- 30g range a divisor with value 2 is used.
217  * For +/-60g range, a divisor with value 4 is used.
218  */
219 #define ADXL382_ACC_SENSITIVITY (int32_t) 2000
220 
221 /* Self Test Limits */
222 /* ADXL380 */
223 #define ADXL380_XY_ST_LIMIT_MIN 29
224 #define ADXL380_Z_ST_LIMIT_MIN 27
225 #define ADXL380_XY_ST_LIMIT_MAX 50
226 #define ADXL380_Z_ST_LIMIT_MAX 32
227 /* ADXL382 */
228 #define ADXL382_XY_ST_LIMIT_MIN 31
229 #define ADXL382_Z_ST_LIMIT_MIN 26
230 #define ADXL382_XY_ST_LIMIT_MAX 42
231 #define ADXL382_Z_ST_LIMIT_MAX 34
232 
233 #define ADXL38X_ST_LIMIT_DENOMINATOR 10
234 
235 /******************************************************************************/
236 /*************************** Types Declarations *******************************/
237 /******************************************************************************/
245 };
246 
250 };
251 
263 };
264 
283 };
284 
301 };
302 
312 };
313 
319  int64_t integer;
320  int32_t fractional;
321 };
322 
328 };
329 
335 } ;
336 
341 struct adxl38x_dev {
352 
353  uint8_t comm_buff[320];
354 };
355 
367 };
368 
370  //Status 3
371  uint8_t DATA_READY : 1;
372  uint8_t RESERVED2 : 7;
373  //Status 2
374  uint8_t UV_FLAG : 1;
375  uint8_t UV_FLAG_STICKY : 1;
376  uint8_t RESERVED1 : 1;
377  uint8_t NVM_CRC_ERR : 1;
378  uint8_t NVM_CRC_DONE : 1;
379  uint8_t NVM_ECC_DET : 1;
380  uint8_t RESERVED : 1;
381  uint8_t NVM_ECC_DONE : 1;
382  //Status 1
383  uint8_t SINGLE_TAP : 1;
384  uint8_t DOUBLE_TAP : 1;
385  uint8_t TRIPLE_TAP : 1;
386  uint8_t OVER_RANGE : 1;
387  uint8_t OVER_RANGE_STICKY : 1;
388  uint8_t ACT : 1;
389  uint8_t INACT : 1;
390  uint8_t NVM_IRQ : 1;
391  //Status 0
392  uint8_t PARITY_ERR_STICKY : 1;
393  uint8_t FIFO_FULL : 1;
394  uint8_t FIFO_OVR : 1;
395  uint8_t FIFO_WATERMARK : 1;
396  uint8_t FIFO_READY : 1;
398  uint8_t NVM_DONE : 1;
399  uint8_t NVM_BUSY_STATUS : 1;
400 };
401 
404  uint32_t value;
405 };
406 
407 /******************************************************************************/
408 /************************ Functions Declarations ******************************/
409 /******************************************************************************/
410 
411 int adxl38x_read_device_data(struct adxl38x_dev *dev, uint8_t base_address,
412  uint16_t size, uint8_t *read_data);
413 int adxl38x_write_device_data(struct adxl38x_dev *dev, uint8_t base_address,
414  uint16_t size, uint8_t *write_data);
415 
416 int adxl38x_register_update_bits(struct adxl38x_dev *dev, uint8_t reg_addr,
417  uint8_t mask,
418  uint8_t update_val);
419 
420 int adxl38x_init(struct adxl38x_dev **device,
422 
423 int adxl38x_remove(struct adxl38x_dev *dev);
424 
425 int adxl38x_soft_reset(struct adxl38x_dev *dev);
426 
427 int adxl38x_get_sts_reg(struct adxl38x_dev *dev,
428  union adxl38x_sts_reg_flags *status_flags);
429 
430 int adxl38x_set_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode);
431 
432 int adxl38x_get_op_mode(struct adxl38x_dev *dev, enum adxl38x_op_mode *op_mode);
433 
434 int adxl38x_set_range(struct adxl38x_dev *dev, enum adxl38x_range range_val);
435 
436 int adxl38x_get_range(struct adxl38x_dev *dev, enum adxl38x_range *range_val);
437 
438 int adxl38x_get_deviceID(struct adxl38x_dev *dev,
439  enum adxl38x_id *devID);
440 
441 int adxl38x_set_self_test_registers(struct adxl38x_dev *dev, bool st_mode,
442  bool st_force, bool st_dir);
443 
444 int adxl38x_get_sts_reg(struct adxl38x_dev *dev,
445  union adxl38x_sts_reg_flags *status_flags);
446 
447 int adxl38x_get_raw_xyz(struct adxl38x_dev *dev, uint16_t *raw_x,
448  uint16_t *raw_y, uint16_t *raw_z);
449 
450 int adxl38x_get_temp(struct adxl38x_dev *dev,
451  struct adxl38x_fractional_val *raw_temp);
452 
453 int adxl38x_get_raw_data(struct adxl38x_dev *dev,
454  enum adxl38x_ch_select channels,
455  uint16_t *raw_x, uint16_t *raw_y,
456  uint16_t *raw_z, uint16_t *raw_temp);
457 
458 int adxl38x_get_xyz_gees(struct adxl38x_dev *dev,
459  enum adxl38x_ch_select channels,
460  struct adxl38x_fractional_val *x, struct adxl38x_fractional_val *y,
461  struct adxl38x_fractional_val *z);
462 
463 int adxl38x_selftest(struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode,
464  bool *st_x, bool *st_y, bool *st_z);
465 
466 int adxl38x_accel_set_FIFO( struct adxl38x_dev *dev, uint16_t numSamples,
467  bool externalTrigger, enum adxl38x_fifo_mode fifo_mode,
468  bool chIDEnable, bool readReset);
469 
470 int adxl38x_data_raw_to_gees( struct adxl38x_dev *dev, uint8_t *raw_accel_data,
471  struct adxl38x_fractional_val *data_frac);
472 
473 #endif /* __ADXL38X_H__ */
474 
adxl38x_comm_type
adxl38x_comm_type
Definition: adxl38x.h:247
ADXL38X_RESET_DEVID_MST
#define ADXL38X_RESET_DEVID_MST
Definition: adxl38x.h:152
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:142
ADXL382_RANGE_15G
@ ADXL382_RANGE_15G
Definition: adxl38x.h:258
ADXL38X_RESET_CODE
#define ADXL38X_RESET_CODE
Definition: adxl38x.h:171
ADXL38X_MODE_HP_SERIAL_VLP_OP
@ ADXL38X_MODE_HP_SERIAL_VLP_OP
Definition: adxl38x.h:282
ADXL38X_FIFO_CFG1
#define ADXL38X_FIFO_CFG1
Definition: adxl38x.h:107
ADXL38X_MODE_VLP
@ ADXL38X_MODE_VLP
Definition: adxl38x.h:273
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:364
ADXL38X_I2C_COMM
@ ADXL38X_I2C_COMM
Definition: adxl38x.h:249
_adxl38x_sts_reg_flags::OVER_RANGE
uint8_t OVER_RANGE
Definition: adxl38x.h:386
ADXL38X_DEVID_MST
#define ADXL38X_DEVID_MST
Definition: adxl38x.h:61
adxl38x_sts_reg_flags::fields
struct _adxl38x_sts_reg_flags fields
Definition: adxl38x.h:403
adxl38x_dev::dev_type
enum adxl38x_id dev_type
Definition: adxl38x.h:343
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:100
ADXL38X_MODE_LP_SERIAL_ULP_OP
@ ADXL38X_MODE_LP_SERIAL_ULP_OP
Definition: adxl38x.h:275
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:404
_adxl38x_sts_reg_flags::FIFO_OVR
uint8_t FIFO_OVR
Definition: adxl38x.h:394
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:165
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:58
ADXL38X_MISC0
#define ADXL38X_MISC0
Definition: adxl38x.h:92
_adxl38x_sts_reg_flags::DOUBLE_TAP
uint8_t DOUBLE_TAP
Definition: adxl38x.h:384
ADXL38X_CH_EN_Z
@ ADXL38X_CH_EN_Z
Definition: adxl38x.h:294
_adxl38x_sts_reg_flags::NVM_BUSY_STATUS
uint8_t NVM_BUSY_STATUS
Definition: adxl38x.h:399
ADXL380_ACC_SCALE_FACTOR_GEE_MUL
#define ADXL380_ACC_SCALE_FACTOR_GEE_MUL
Definition: adxl38x.h:182
ADXL382_RANGE_60G
@ ADXL382_RANGE_60G
Definition: adxl38x.h:262
ADXL38X_SLF_TST_CTRL_MSK
#define ADXL38X_SLF_TST_CTRL_MSK
Definition: adxl38x.h:167
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:165
ADXL38X_ACC_SCALE_FACTOR_GEE_DIV
#define ADXL38X_ACC_SCALE_FACTOR_GEE_DIV
Definition: adxl38x.h:192
adxl38x_comm_desc::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adxl38x.h:327
_adxl38x_sts_reg_flags
Definition: adxl38x.h:369
ADXL38X_FIFO_NORMAL
@ ADXL38X_FIFO_NORMAL
Definition: adxl38x.h:309
ADXL38X_MODE_HP_SERIAL_ULP_OP
@ ADXL38X_MODE_HP_SERIAL_ULP_OP
Definition: adxl38x.h:281
ADXL382_Z_ST_LIMIT_MIN
#define ADXL382_Z_ST_LIMIT_MIN
Definition: adxl38x.h:229
adxl38x_dev::com_desc
union adxl38x_comm_desc com_desc
Definition: adxl38x.h:345
_adxl38x_sts_reg_flags::ACT
uint8_t ACT
Definition: adxl38x.h:388
no_os_spi.h
Header file of SPI Interface.
ADXL382_ACC_SENSITIVITY
#define ADXL382_ACC_SENSITIVITY
Definition: adxl38x.h:219
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:672
_adxl38x_sts_reg_flags::NVM_IRQ
uint8_t NVM_IRQ
Definition: adxl38x.h:390
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:963
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:119
ADXL38X_DEVID_AD
#define ADXL38X_DEVID_AD
Definition: adxl38x.h:60
ADXL38X_CH_EN_ZT
@ ADXL38X_CH_EN_ZT
Definition: adxl38x.h:298
ADXL382_XY_ST_LIMIT_MAX
#define ADXL382_XY_ST_LIMIT_MAX
Definition: adxl38x.h:230
ADXL38X_MODE_LP_SERIAL_VLP_OP
@ ADXL38X_MODE_LP_SERIAL_VLP_OP
Definition: adxl38x.h:276
ADXL38X_PART_ID
#define ADXL38X_PART_ID
Definition: adxl38x.h:62
ADXL38X_MODE_RBW
@ ADXL38X_MODE_RBW
Definition: adxl38x.h:277
ADXL38X_STATUS0
#define ADXL38X_STATUS0
Definition: adxl38x.h:77
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:472
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:452
ADXL38X_FIFO_DISABLE
@ ADXL38X_FIFO_DISABLE
Definition: adxl38x.h:308
_adxl38x_sts_reg_flags::NVM_CRC_DONE
uint8_t NVM_CRC_DONE
Definition: adxl38x.h:378
ADXL38X_TEMP_SCALE_DEN
#define ADXL38X_TEMP_SCALE_DEN
Definition: adxl38x.h:203
ADXL38X_SPI_WRITE
#define ADXL38X_SPI_WRITE
Definition: adxl38x.h:57
ADXL38X_MODE_HRT_SND
@ ADXL38X_MODE_HRT_SND
Definition: adxl38x.h:271
ADXL38X_TEMP_SCALE_NUM
#define ADXL38X_TEMP_SCALE_NUM
Definition: adxl38x.h:202
device
Definition: ad9361_util.h:75
adxl372.h
Header file for adxl372 Driver.
_adxl38x_sts_reg_flags::FIFO_READY
uint8_t FIFO_READY
Definition: adxl38x.h:396
_adxl38x_sts_reg_flags::DATA_READY
uint8_t DATA_READY
Definition: adxl38x.h:371
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:902
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:587
ADXL38X_CH_DSB_ALL
@ ADXL38X_CH_DSB_ALL
Definition: adxl38x.h:290
ADXL380_XY_ST_LIMIT_MIN
#define ADXL380_XY_ST_LIMIT_MIN
Definition: adxl38x.h:223
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:672
ADXL38X_FIFO_STREAM
@ ADXL38X_FIFO_STREAM
Definition: adxl38x.h:310
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:60
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:55
adxl38x_get_deviceID
int adxl38x_get_deviceID(struct adxl38x_dev *dev, enum adxl38x_id *devID)
Gets the current device type.
Definition: adxl38x.c:396
_adxl38x_sts_reg_flags::NVM_ECC_DONE
uint8_t NVM_ECC_DONE
Definition: adxl38x.h:381
_adxl38x_sts_reg_flags::RESERVED2
uint8_t RESERVED2
Definition: adxl38x.h:372
ADXL38X_MODE_STDBY
@ ADXL38X_MODE_STDBY
Definition: adxl38x.h:270
adxl38x_dev::op_mode
enum adxl38x_op_mode op_mode
Definition: adxl38x.h:351
ADXL38X_DIG_EN
#define ADXL38X_DIG_EN
Definition: adxl38x.h:97
adxl38x_soft_reset
int adxl38x_soft_reset(struct adxl38x_dev *dev)
Performs a soft reset of the device.
Definition: adxl38x.c:276
adxl38x_dev
ADXL38X Device structure.
Definition: adxl38x.h:341
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:472
adxl38x_get_deviceID
int adxl38x_get_deviceID(struct adxl38x_dev *dev, enum adxl38x_id *devID)
Gets the current device type.
Definition: adxl38x.c:396
ADXL38X_RESET_PART_ID
#define ADXL38X_RESET_PART_ID
Definition: adxl38x.h:153
ADXL38X_MODE_ULP
@ ADXL38X_MODE_ULP
Definition: adxl38x.h:272
adxl38x_dev::range
enum adxl38x_range range
Definition: adxl38x.h:349
adxl38x_comm_desc::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: adxl38x.h:325
ADXL38X_CH_EN_YZ
@ ADXL38X_CH_EN_YZ
Definition: adxl38x.h:295
_adxl38x_sts_reg_flags::RESERVED1
uint8_t RESERVED1
Definition: adxl38x.h:376
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:257
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:902
_adxl38x_sts_reg_flags::UV_FLAG
uint8_t UV_FLAG
Definition: adxl38x.h:374
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
adxl38x_soft_reset
int adxl38x_soft_reset(struct adxl38x_dev *dev)
Performs a soft reset of the device.
Definition: adxl38x.c:276
ADXL38X_RESET_ZERO
#define ADXL38X_RESET_ZERO
Definition: adxl38x.h:150
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:311
ADXL38X_REG_RESET
#define ADXL38X_REG_RESET
Definition: adxl38x.h:100
ADXL38X_CH_EN_XYZT
@ ADXL38X_CH_EN_XYZT
Definition: adxl38x.h:300
ADXL38X_OP_MODE
#define ADXL38X_OP_MODE
Definition: adxl38x.h:96
adxl38x_dev::comm_buff
uint8_t comm_buff[320]
Definition: adxl38x.h:353
no_os_error.h
Error codes definition.
_adxl38x_sts_reg_flags::NVM_CRC_ERR
uint8_t NVM_CRC_ERR
Definition: adxl38x.h:377
ADXL38X_MODE_HP
@ ADXL38X_MODE_HP
Definition: adxl38x.h:280
ADXL38X_TEMP_OFFSET
#define ADXL38X_TEMP_OFFSET
Definition: adxl38x.h:201
ADXL372_REG_WRITE
#define ADXL372_REG_WRITE(x)
Definition: adxl372.h:122
ADXL382_ACC_SCALE_FACTOR_GEE_MUL
#define ADXL382_ACC_SCALE_FACTOR_GEE_MUL
Definition: adxl38x.h:190
ID_ADXL380
@ ID_ADXL380
Definition: adxl38x.h:243
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:75
_adxl38x_sts_reg_flags::UV_FLAG_STICKY
uint8_t UV_FLAG_STICKY
Definition: adxl38x.h:375
adxl38x_ch_select
adxl38x_ch_select
Definition: adxl38x.h:289
ADXL38X_MASK_RANGE
#define ADXL38X_MASK_RANGE
Definition: adxl38x.h:163
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:53
ADXL38X_MODE_RBW_SERIAL_ULP_OP
@ ADXL38X_MODE_RBW_SERIAL_ULP_OP
Definition: adxl38x.h:278
ADXL38X_CH_EN_XY
@ ADXL38X_CH_EN_XY
Definition: adxl38x.h:293
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:53
adxl372_dev
Definition: adxl372.h:368
ADXL382_RANGE_30G
@ ADXL382_RANGE_30G
Definition: adxl38x.h:260
adxl38x_sts_reg_flags
Definition: adxl38x.h:402
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:351
ADXL38X_FIFOCFG_FIFOMODE_MSK
#define ADXL38X_FIFOCFG_FIFOMODE_MSK
Definition: adxl38x.h:168
_adxl38x_sts_reg_flags::OVER_RANGE_STICKY
uint8_t OVER_RANGE_STICKY
Definition: adxl38x.h:387
adxl38x_fractional_val::integer
int64_t integer
Definition: adxl38x.h:319
ADXL38X_SPI_READ
#define ADXL38X_SPI_READ
Definition: adxl38x.h:56
ADXL38X_XDATA_H
#define ADXL38X_XDATA_H
Definition: adxl38x.h:81
ADXL38X_SNSR_AXIS_EN
#define ADXL38X_SNSR_AXIS_EN
Definition: adxl38x.h:114
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:142
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:113
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:372
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:496
ADXL38X_ST_LIMIT_DENOMINATOR
#define ADXL38X_ST_LIMIT_DENOMINATOR
Definition: adxl38x.h:233
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:765
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:327
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
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:537
ADXL38X_YDATA_H
#define ADXL38X_YDATA_H
Definition: adxl38x.h:83
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:82
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:173
adxl38x_id
adxl38x_id
Definition: adxl38x.h:242
ADXL38X_FIFO_CFG0
#define ADXL38X_FIFO_CFG0
Definition: adxl38x.h:106
ADXL380_RANGE_8G
@ ADXL380_RANGE_8G
Definition: adxl38x.h:259
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:107
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:537
adxl38x_fractional_val
Data format in which the values are converted.
Definition: adxl38x.h:318
_adxl38x_sts_reg_flags::RESERVED
uint8_t RESERVED
Definition: adxl38x.h:380
_adxl38x_sts_reg_flags::FIFO_FULL
uint8_t FIFO_FULL
Definition: adxl38x.h:393
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:196
ADXL38X_SPI_COMM
@ ADXL38X_SPI_COMM
Definition: adxl38x.h:248
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:963
no_os_i2c.h
Header file of I2C Interface.
ADXL380_Z_ST_LIMIT_MAX
#define ADXL380_Z_ST_LIMIT_MAX
Definition: adxl38x.h:226
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:372
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:496
ADXL38X_NEG_ACC_MSK
#define ADXL38X_NEG_ACC_MSK
Definition: adxl38x.h:166
ID_ADXL382
@ ID_ADXL382
Definition: adxl38x.h:244
adxl38x_dev::comm_type
enum adxl38x_comm_type comm_type
Definition: adxl38x.h:347
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:304
adxl38x_comm_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: adxl38x.h:334
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:765
adxl38x_comm_init_param::i2c_init
struct no_os_i2c_init_param i2c_init
Definition: adxl38x.h:332
adxl38x_range
ADXL38X Range (OP MODE[7:6]).
ADXL382_Z_ST_LIMIT_MAX
#define ADXL382_Z_ST_LIMIT_MAX
Definition: adxl38x.h:231
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:51
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:75
_adxl38x_sts_reg_flags::TRIPLE_TAP
uint8_t TRIPLE_TAP
Definition: adxl38x.h:385
adxl38x_remove
int adxl38x_remove(struct adxl38x_dev *dev)
Free the resources allocated by the init function.
Definition: adxl38x.c:256
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:304
ADXL38X_RESET_DEVID_AD
#define ADXL38X_RESET_DEVID_AD
Definition: adxl38x.h:151
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:120
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:70
NULL
#define NULL
Definition: wrapper.h:64
_adxl38x_sts_reg_flags::PARITY_ERR_STICKY
uint8_t PARITY_ERR_STICKY
Definition: adxl38x.h:392
ADXL38X_TDATA_H
#define ADXL38X_TDATA_H
Definition: adxl38x.h:87
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:173
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:119
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:587
adxl38x_init_param::dev_type
enum adxl38x_id dev_type
Definition: adxl38x.h:366
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:79
_adxl38x_sts_reg_flags::NVM_DONE
uint8_t NVM_DONE
Definition: adxl38x.h:398
ADXL380_ACC_SENSITIVITY
#define ADXL380_ACC_SENSITIVITY
Definition: adxl38x.h:212
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:122
ADXL38X_CH_EN_YZT
@ ADXL38X_CH_EN_YZT
Definition: adxl38x.h:299
ADXL38X_MODE_RBW_SERIAL_VLP_OP
@ ADXL38X_MODE_RBW_SERIAL_VLP_OP
Definition: adxl38x.h:279
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:113
ADXL38X_CH_EN_X
@ ADXL38X_CH_EN_X
Definition: adxl38x.h:291
adxl38x_fractional_val::fractional
int32_t fractional
Definition: adxl38x.h:320
ADXL38X_CH_EN_T
@ ADXL38X_CH_EN_T
Definition: adxl38x.h:297
adxl372_dev::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: adxl372.h:372
ADXL380_XY_ST_LIMIT_MAX
#define ADXL380_XY_ST_LIMIT_MAX
Definition: adxl38x.h:225
ADXL38X_CH_EN_XYZ
@ ADXL38X_CH_EN_XYZ
Definition: adxl38x.h:296
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:424
adxl38x_remove
int adxl38x_remove(struct adxl38x_dev *dev)
Free the resources allocated by the init function.
Definition: adxl38x.c:256
_adxl38x_sts_reg_flags::FIFO_WATERMARK
uint8_t FIFO_WATERMARK
Definition: adxl38x.h:395
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:103
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:327
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:58
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:389
ADXL382_XY_ST_LIMIT_MIN
#define ADXL382_XY_ST_LIMIT_MIN
Definition: adxl38x.h:228
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:75
ADXL38X_MODE_LP
@ ADXL38X_MODE_LP
Definition: adxl38x.h:274
_adxl38x_sts_reg_flags::EFUSE_BUSY_REGERR_STICKY
uint8_t EFUSE_BUSY_REGERR_STICKY
Definition: adxl38x.h:397
ADXL38X_CH_EN_Y
@ ADXL38X_CH_EN_Y
Definition: adxl38x.h:292
adxl38x_comm_init_param
Definition: adxl38x.h:330
_adxl38x_sts_reg_flags::NVM_ECC_DET
uint8_t NVM_ECC_DET
Definition: adxl38x.h:379
errno.h
Error macro definition for ARM Compiler.
adxl38x_comm_desc
Definition: adxl38x.h:323
adxl38x_init_param
Structure holding the parameters for ADXL38X device initialization.
Definition: adxl38x.h:360
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:351
ADXL38X_ZDATA_H
#define ADXL38X_ZDATA_H
Definition: adxl38x.h:85
ADXL38X_MASK_OP_MODE
#define ADXL38X_MASK_OP_MODE
Definition: adxl38x.h:164
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:424
ADXL380_Z_ST_LIMIT_MIN
#define ADXL380_Z_ST_LIMIT_MIN
Definition: adxl38x.h:224
adxl372_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adxl372.h:370
_adxl38x_sts_reg_flags::SINGLE_TAP
uint8_t SINGLE_TAP
Definition: adxl38x.h:383
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
ADXL38X_MASK_CHEN_DIG_EN
#define ADXL38X_MASK_CHEN_DIG_EN
Definition: adxl38x.h:165
ADXL372_REG_READ
#define ADXL372_REG_READ(x)
Definition: adxl372.h:121
ADXL380_RANGE_16G
@ ADXL380_RANGE_16G
Definition: adxl38x.h:261
adxl38x_init_param::comm_init
union adxl38x_comm_init_param comm_init
Definition: adxl38x.h:362