no-OS
adxl355.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef __ADXL355_H__
40 #define __ADXL355_H__
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include <string.h>
47 #include "no_os_util.h"
48 #include "no_os_i2c.h"
49 #include "no_os_spi.h"
50 
51 /******************************************************************************/
52 /********************** Macros and Constants Definitions **********************/
53 /******************************************************************************/
54 /* SPI commands */
55 #define ADXL355_SPI_READ 0x01
56 #define ADXL355_SPI_WRITE 0x00
57 #define ADXL355_ADDR(x) ((x) & 0xFF)
58 #define GET_ADXL355_TRANSF_LEN(x) (((x) >> 8) & 0x0000FF)
59 #define SET_ADXL355_TRANSF_LEN(x) (((x) << 8) & 0x00FF00)
60 #define GET_ADXL355_RESET_VAL(x) (((x) >> 16) & 0x0000FF)
61 #define SET_ADXL355_RESET_VAL(x) (((x) << 16) & 0xFF0000)
62 
63 /* ADXL355 Register Map */
64 #define ADXL355_DEVID_AD (ADXL355_ADDR(0x00) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0xAD))
65 #define ADXL355_DEVID_MST (ADXL355_ADDR(0x01) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x1D))
66 #define ADXL355_PARTID (ADXL355_ADDR(0x02) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0xED))
67 #define ADXL359_PARTID (ADXL355_ADDR(0x02) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0xE9))
68 #define ADXL355_REVID (ADXL355_ADDR(0x03) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x01))
69 #define ADXL355_STATUS (ADXL355_ADDR(0x04) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
70 #define ADXL355_FIFO_ENTRIES (ADXL355_ADDR(0x05) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
71 #define ADXL355_TEMP (ADXL355_ADDR(0x06) | SET_ADXL355_TRANSF_LEN(2))
72 #define ADXL355_XDATA (ADXL355_ADDR(0x08) | SET_ADXL355_TRANSF_LEN(3))
73 #define ADXL355_YDATA (ADXL355_ADDR(0x0B) | SET_ADXL355_TRANSF_LEN(3))
74 #define ADXL355_ZDATA (ADXL355_ADDR(0x0E) | SET_ADXL355_TRANSF_LEN(3))
75 #define ADXL355_FIFO_DATA (ADXL355_ADDR(0x11) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
76 #define ADXL355_OFFSET_X (ADXL355_ADDR(0x1E) | SET_ADXL355_TRANSF_LEN(2))
77 #define ADXL355_OFFSET_Y (ADXL355_ADDR(0x20) | SET_ADXL355_TRANSF_LEN(2))
78 #define ADXL355_OFFSET_Z (ADXL355_ADDR(0x22) | SET_ADXL355_TRANSF_LEN(2))
79 #define ADXL355_ACT_EN (ADXL355_ADDR(0x24) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
80 #define ADXL355_ACT_THRESH (ADXL355_ADDR(0x25) | SET_ADXL355_TRANSF_LEN(2))
81 #define ADXL355_ACT_CNT (ADXL355_ADDR(0x27) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x01))
82 #define ADXL355_FILTER (ADXL355_ADDR(0x28) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
83 #define ADXL355_FIFO_SAMPLES (ADXL355_ADDR(0x29) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x60))
84 #define ADXL355_INT_MAP (ADXL355_ADDR(0x2A) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
85 #define ADXL355_SYNC (ADXL355_ADDR(0x2B) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
86 #define ADXL355_RANGE (ADXL355_ADDR(0x2C) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x81))
87 #define ADXL355_POWER_CTL (ADXL355_ADDR(0x2D) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x01))
88 #define ADXL355_SELF_TEST (ADXL355_ADDR(0x2E) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
89 #define ADXL355_RESET (ADXL355_ADDR(0x2F) | SET_ADXL355_TRANSF_LEN(1) | SET_ADXL355_RESET_VAL(0x00))
90 
91 #define ADXL355_SHADOW_REGISTER_BASE_ADDR (ADXL355_ADDR(0x50) | SET_ADXL355_TRANSF_LEN(5))
92 #define ADXL355_MAX_FIFO_SAMPLES_VAL 0x60
93 #define ADXL355_SELF_TEST_TRIGGER_VAL 0x03
94 #define ADXL355_RESET_CODE 0x52
95 
96 /*
97  * At +/- 2g with 20-bit resolution, scale is given in datasheet as
98  * 3.9ug/LSB = 0.0000039 * 9.80665 = 0.00003824593 m/s^2.
99  * For +/- 4g range a multiplier with value 2 is used.
100  * For +/-8g range, a multiplier with value 4 is used.
101  */
102 #define ADXL355_ACC_SCALE_FACTOR_MUL (int64_t) 38245
103 #define ADXL355_ACC_SCALE_FACTOR_DIV (int32_t)1000000000
104 
105 /*
106  * At +/- 10g with 20-bit resolution, scale is given in datasheet as
107  * 19.5ug/LSB = 0.0000195 * 9.80665 = 0.00019122967 m/s^2.
108  * For +/- 4g range a multiplier with value 2 is used.
109  * For +/-8g range, a multiplier with value 4 is used.
110  */
111 #define ADXL359_ACC_SCALE_FACTOR_MUL (int64_t) 191229
112 #define ADXL359_ACC_SCALE_FACTOR_DIV (int32_t)1000000000
113 
114 /*
115  * The datasheet defines an intercept of 1885 LSB at 25 degC
116  * and a slope of -9.05 LSB/C. The following formula can be used to find the
117  * temperature:
118  * Temp = ((RAW - 1885)/(-9.05)) + 25 but this doesn't follow the format of
119  * the IIO which is Temp = (RAW + OFFSET) * SCALE. Hence using some rearranging
120  * we get the scale as -0.110497238 and offset as -2111.25
121  */
122 /* OFFSET = ADXL355_TEMP_OFFSET / ADXL355_TEMP_OFFSET_DIV */
123 #define ADXL355_TEMP_OFFSET -211125
124 #define ADXL355_TEMP_OFFSET_DIV 100
125 
126 /* SCALE = ADXL355_TEMP_SCALE_FACTOR / ADXL355_TEMP_SCALE_FACTOR_DIV
127  We want to return the temperature in millidegrees Celsius so instead of
128  0.110497238, we are going to use 110.497238 value for scale
129  */
130 #define ADXL355_TEMP_SCALE_FACTOR -110497238
131 #define ADXL355_TEMP_SCALE_FACTOR_DIV 1000000
132 
133 /*
134  * The datasheet defines an intercept of 1852 LSB at 25 degC
135  * and a slope of -9.05 LSB/C. The following formula can be used to find the
136  * temperature:
137  * Temp = ((RAW - 1852)/(-9.05)) + 25 but this doesn't follow the format of
138  * the IIO which is Temp = (RAW + OFFSET) * SCALE. Hence using some rearranging
139  * we get the scale as -0.110497238 and offset as -2078.25
140  */
141 /* OFFSET = ADXL359_TEMP_OFFSET / ADXL359_TEMP_OFFSET_DIV */
142 #define ADXL359_TEMP_OFFSET -207825
143 #define ADXL359_TEMP_OFFSET_DIV 100
144 
145 /* SCALE = ADXL359_TEMP_SCALE_FACTOR / ADXL359_TEMP_SCALE_FACTOR_DIV
146  We want to return the temperature in millidegrees Celsius so instead of
147  0.110497238, we are going to use 110.497238 value for scale
148  */
149 #define ADXL359_TEMP_SCALE_FACTOR -110497238
150 #define ADXL359_TEMP_SCALE_FACTOR_DIV 1000000
151 
152 #define ADXL355_NEG_ACC_MSK NO_OS_GENMASK(31, 20)
153 #define ADXL355_RANGE_FIELD_MSK NO_OS_GENMASK( 1, 0)
154 #define ADXL355_ODR_LPF_FIELD_MSK NO_OS_GENMASK( 3, 0)
155 #define ADXL355_HPF_FIELD_MSK NO_OS_GENMASK( 6, 4)
156 #define ADXL355_INT_POL_FIELD_MSK NO_OS_BIT(6)
157 
158 /******************************************************************************/
159 /*************************** Types Declarations *******************************/
160 /******************************************************************************/
165 };
166 
176 };
177 
181 };
182 
191 };
192 
205 };
206 
214 };
215 
219 };
220 
226 } ;
227 
239 };
240 
242  uint8_t RDY_EN1 : 1;
243  uint8_t FULL_EN1 : 1;
244  uint8_t OVR_EN1 : 1;
245  uint8_t ACT_EN1 : 1;
246  uint8_t RDY_EN2 : 1;
247  uint8_t FULL_EN2 : 1;
248  uint8_t OVR_EN2 : 1;
249  uint8_t ACT_EN2 : 1;
250 };
251 
254  uint8_t value;
255 };
256 
258  uint8_t DATA_RDY : 1;
259  uint8_t FIFO_FULL : 1;
260  uint8_t FIFO_OVR : 1;
261  uint8_t Activity : 1;
262  uint8_t NVM_BUSY : 1;
263  uint8_t reserved : 3;
264 };
265 
268  uint8_t value;
269 };
270 
272  uint8_t ACT_X : 1;
273  uint8_t ACT_Y : 1;
274  uint8_t ACT_Z : 1;
275  uint8_t reserved : 4;
276 };
277 
280  uint8_t value;
281 };
282 
284  int64_t integer;
285  int32_t fractional;
286 } ;
287 
293 };
294 
299 struct adxl355_dev {
310  uint16_t x_offset;
311  uint16_t y_offset;
312  uint16_t z_offset;
313  uint8_t fifo_samples;
315  uint8_t act_cnt;
316  uint16_t act_thr;
317  uint8_t comm_buff[289];
318 };
319 
320 /******************************************************************************/
321 /************************ Functions Declarations ******************************/
322 /******************************************************************************/
324 int adxl355_init(struct adxl355_dev **device,
326 
328 int adxl355_remove(struct adxl355_dev *dev);
329 
331 int adxl355_set_op_mode(struct adxl355_dev *dev, enum adxl355_op_mode op_mode);
332 
334 int adxl355_get_op_mode(struct adxl355_dev *dev,
335  enum adxl355_op_mode *read_op_mode);
336 
338 int adxl355_soft_reset(struct adxl355_dev *dev);
339 
341 int adxl355_set_self_test(struct adxl355_dev *dev);
342 
344 int adxl355_set_range(struct adxl355_dev *dev, enum adxl355_range range_val);
345 
347 int adxl355_set_odr_lpf(struct adxl355_dev *dev,
348  enum adxl355_odr_lpf odr_lpf_val);
349 
351 int adxl355_set_hpf_corner(struct adxl355_dev *dev,
352  enum adxl355_hpf_corner hpf_corner_val);
353 
355 int adxl355_set_offset(struct adxl355_dev *dev, uint16_t x_offset,
356  uint16_t y_offset, uint16_t z_offset);
357 
359 int adxl355_get_raw_xyz(struct adxl355_dev *dev, uint32_t *raw_x,
360  uint32_t *raw_y, uint32_t *raw_z);
361 
363 int adxl355_get_xyz(struct adxl355_dev *dev, struct adxl355_frac_repr *x,
364  struct adxl355_frac_repr *y, struct adxl355_frac_repr *z);
365 
367 int adxl355_get_raw_temp(struct adxl355_dev *dev, uint16_t *raw_temp);
368 
370 int adxl355_get_temp(struct adxl355_dev *dev, struct adxl355_frac_repr *temp);
371 
373 int adxl355_get_sts_reg(struct adxl355_dev *dev,
374  union adxl355_sts_reg_flags *status_flags);
375 
377 int adxl355_get_nb_of_fifo_entries(struct adxl355_dev *dev, uint8_t *reg_value);
378 
380 int adxl355_set_fifo_samples(struct adxl355_dev *dev, uint8_t reg_value);
381 
383 int adxl355_get_raw_fifo_data(struct adxl355_dev *dev, uint8_t *fifo_entries,
384  uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z);
385 
387 int adxl355_get_fifo_data(struct adxl355_dev *dev, uint8_t *fifo_entries,
388  struct adxl355_frac_repr *x, struct adxl355_frac_repr *y,
389  struct adxl355_frac_repr *z);
390 
392 int adxl355_conf_act_en(struct adxl355_dev *dev,
393  union adxl355_act_en_flags act_config);
394 
396 int adxl355_conf_act_thr(struct adxl355_dev *dev, uint16_t act_thr);
397 
399 int adxl355_set_act_cnt_reg(struct adxl355_dev *dev, uint8_t act_cnt);
400 
402 int adxl355_config_int_pins(struct adxl355_dev *dev,
403  union adxl355_int_mask int_conf);
404 
406 int adxl355_set_int_pol(struct adxl355_dev *dev, enum adxl355_int_pol int_pol);
407 
408 #endif /* __ADXL355_H__ */
adxl355_config_int_pins
int adxl355_config_int_pins(struct adxl355_dev *dev, union adxl355_int_mask int_conf)
Configures the interrupt map for INT1 and INT2 pins.
Definition: adxl355.c:873
ADXL355_FIFO_ENTRIES
#define ADXL355_FIFO_ENTRIES
Definition: adxl355.h:70
adxl355_get_fifo_data
int adxl355_get_fifo_data(struct adxl355_dev *dev, uint8_t *fifo_entries, struct adxl355_frac_repr *x, struct adxl355_frac_repr *y, struct adxl355_frac_repr *z)
Reads fifo data and returns the values converted in m/s^2.
Definition: adxl355.c:773
adxl355_write_device_data
int adxl355_write_device_data(struct adxl355_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data)
Writes to the device.
Definition: adxl355.c:113
_adxl355_act_en_flags::ACT_X
uint8_t ACT_X
Definition: adxl355.h:272
adxl355_init_param
Structure holding the parameters for ADXL355 device initialization.
Definition: adxl355.h:232
adxl355_hpf_corner
adxl355_hpf_corner
Definition: adxl355.h:183
adxl355_get_temp
int adxl355_get_temp(struct adxl355_dev *dev, struct adxl355_frac_repr *temp)
Reads the raw temperature data and converts it to millidegrees Celsius.
Definition: adxl355.c:631
no_os_alloc.h
adxl355_get_raw_temp
int adxl355_get_raw_temp(struct adxl355_dev *dev, uint16_t *raw_temp)
Reads the raw temperature.
Definition: adxl355.c:607
ADXL355_ACC_SCALE_FACTOR_DIV
#define ADXL355_ACC_SCALE_FACTOR_DIV
Definition: adxl355.h:103
adxl355_dev::y_offset
uint16_t y_offset
Definition: adxl355.h:311
_adxl355_int_mask::ACT_EN2
uint8_t ACT_EN2
Definition: adxl355.h:249
ADXL355_ACT_EN
#define ADXL355_ACT_EN
Definition: adxl355.h:79
no_os_div_s64_rem
int64_t no_os_div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
adxl355_get_fifo_data
int adxl355_get_fifo_data(struct adxl355_dev *dev, uint8_t *fifo_entries, struct adxl355_frac_repr *x, struct adxl355_frac_repr *y, struct adxl355_frac_repr *z)
Reads fifo data and returns the values converted in m/s^2.
Definition: adxl355.c:773
ADXL355_FILTER
#define ADXL355_FILTER
Definition: adxl355.h:82
adxl355_int_mask::fields
struct _adxl355_int_mask fields
Definition: adxl355.h:253
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
adxl355_set_odr_lpf
int adxl355_set_odr_lpf(struct adxl355_dev *dev, enum adxl355_odr_lpf odr_lpf_val)
Writes the low-pass filter settings.
Definition: adxl355.c:392
ADXL355_ODR_500HZ
@ ADXL355_ODR_500HZ
Definition: adxl355.h:197
GET_ADXL355_RESET_VAL
#define GET_ADXL355_RESET_VAL(x)
Definition: adxl355.h:60
adxl355_get_raw_fifo_data
int adxl355_get_raw_fifo_data(struct adxl355_dev *dev, uint8_t *fifo_entries, uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z)
Reads fifo data and returns the raw values.
Definition: adxl355.c:731
adxl355_get_raw_temp
int adxl355_get_raw_temp(struct adxl355_dev *dev, uint16_t *raw_temp)
Reads the raw temperature.
Definition: adxl355.c:607
ADXL355_OFFSET_Z
#define ADXL355_OFFSET_Z
Definition: adxl355.h:78
adxl355_get_sts_reg
int adxl355_get_sts_reg(struct adxl355_dev *dev, union adxl355_sts_reg_flags *status_flags)
Reads the status register value.
Definition: adxl355.c:667
NO_OS_GENMASK
#define NO_OS_GENMASK(h, l)
Definition: no_os_util.h:86
adxl355_sts_reg_flags
Definition: adxl355.h:266
adxl355_type
adxl355_type
Definition: adxl355.h:161
ADXL355_INT_MAP
#define ADXL355_INT_MAP
Definition: adxl355.h:84
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
adxl355_dev::act_en
union adxl355_act_en_flags act_en
Definition: adxl355.h:314
ADXL355_HPF_24_7
@ ADXL355_HPF_24_7
Definition: adxl355.h:185
adxl355_set_act_cnt_reg
int adxl355_set_act_cnt_reg(struct adxl355_dev *dev, uint8_t act_cnt)
Writes the activity count register value.
Definition: adxl355.c:854
ADXL355_SELF_TEST_TRIGGER_VAL
#define ADXL355_SELF_TEST_TRIGGER_VAL
Definition: adxl355.h:93
_adxl355_sts_reg_flags::FIFO_FULL
uint8_t FIFO_FULL
Definition: adxl355.h:259
adxl355_soft_reset
int adxl355_soft_reset(struct adxl355_dev *dev)
Performs a soft reset of the device.
Definition: adxl355.c:300
adxl355_dev::z_offset
uint16_t z_offset
Definition: adxl355.h:312
no_os_spi.h
Header file of SPI Interface.
_adxl355_sts_reg_flags::FIFO_OVR
uint8_t FIFO_OVR
Definition: adxl355.h:260
adxl355_conf_act_en
int adxl355_conf_act_en(struct adxl355_dev *dev, union adxl355_act_en_flags act_config)
Configures the activity enable register.
Definition: adxl355.c:809
_adxl355_int_mask::FULL_EN1
uint8_t FULL_EN1
Definition: adxl355.h:243
adxl355_get_raw_xyz
int adxl355_get_raw_xyz(struct adxl355_dev *dev, uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z)
Reads the raw output data.
Definition: adxl355.c:538
adxl355_get_sts_reg
int adxl355_get_sts_reg(struct adxl355_dev *dev, union adxl355_sts_reg_flags *status_flags)
Reads the status register value.
Definition: adxl355.c:667
ADXL355_HPF_FIELD_MSK
#define ADXL355_HPF_FIELD_MSK
Definition: adxl355.h:155
ADXL355_TEMP_OFFSET
#define ADXL355_TEMP_OFFSET
Definition: adxl355.h:123
adxl355_comm_init_param::i2c_init
struct no_os_i2c_init_param i2c_init
Definition: adxl355.h:223
ADXL355_ODR_7_813HZ
@ ADXL355_ODR_7_813HZ
Definition: adxl355.h:203
ADXL355_INT_ACTIVE_LOW
@ ADXL355_INT_ACTIVE_LOW
Definition: adxl355.h:217
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
ADXL355_PARTID
#define ADXL355_PARTID
Definition: adxl355.h:66
adxl355_init_param::comm_init
union adxl355_comm_init_param comm_init
Definition: adxl355.h:234
ADXL355_ODR_2000HZ
@ ADXL355_ODR_2000HZ
Definition: adxl355.h:195
adxl355_get_raw_xyz
int adxl355_get_raw_xyz(struct adxl355_dev *dev, uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z)
Reads the raw output data.
Definition: adxl355.c:538
ADXL355_ODR_250HZ
@ ADXL355_ODR_250HZ
Definition: adxl355.h:198
ADXL355_POWER_CTL
#define ADXL355_POWER_CTL
Definition: adxl355.h:87
no_os_delay.h
Header file of Delay functions.
adxl355_dev::odr_lpf
enum adxl355_odr_lpf odr_lpf
Definition: adxl355.h:307
adxl355_get_nb_of_fifo_entries
int adxl355_get_nb_of_fifo_entries(struct adxl355_dev *dev, uint8_t *reg_value)
Reads the number of FIFO entries register value.
Definition: adxl355.c:690
ADXL355_HPF_0_3862
@ ADXL355_HPF_0_3862
Definition: adxl355.h:188
adxl355_set_self_test
int adxl355_set_self_test(struct adxl355_dev *dev)
Triggers the self-test feature.
Definition: adxl355.c:345
adxl355_op_mode
adxl355_op_mode
Definition: adxl355.h:167
_adxl355_int_mask::RDY_EN1
uint8_t RDY_EN1
Definition: adxl355.h:242
ADXL355_HPF_0_0238
@ ADXL355_HPF_0_0238
Definition: adxl355.h:190
adxl355_act_en_flags::value
uint8_t value
Definition: adxl355.h:280
ADXL355_STATUS
#define ADXL355_STATUS
Definition: adxl355.h:69
adxl355_init_param::comm_type
enum adxl355_comm_type comm_type
Definition: adxl355.h:236
device
Definition: ad9361_util.h:75
adxl355.h
Header file of ADXL355 Driver.
adxl355_soft_reset
int adxl355_soft_reset(struct adxl355_dev *dev)
Performs a soft reset of the device.
Definition: adxl355.c:300
ADXL359_TEMP_SCALE_FACTOR
#define ADXL359_TEMP_SCALE_FACTOR
Definition: adxl355.h:149
ADXL355_SELF_TEST
#define ADXL355_SELF_TEST
Definition: adxl355.h:88
adxl355_remove
int adxl355_remove(struct adxl355_dev *dev)
Free the resources allocated by adxl355_init().
Definition: adxl355.c:236
adxl355_range
adxl355_range
Definition: adxl355.h:207
ADXL355_STDBY_TEMP_ON_DRDY_OFF
@ ADXL355_STDBY_TEMP_ON_DRDY_OFF
Definition: adxl355.h:173
adxl355_get_op_mode
int adxl355_get_op_mode(struct adxl355_dev *dev, enum adxl355_op_mode *read_op_mode)
Gets the current operation mode of the device.
Definition: adxl355.c:279
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
_adxl355_act_en_flags
Definition: adxl355.h:271
_adxl355_sts_reg_flags::Activity
uint8_t Activity
Definition: adxl355.h:261
adxl355_dev::com_desc
union adxl355_comm_desc com_desc
Definition: adxl355.h:303
ADXL355_ODR_4000HZ
@ ADXL355_ODR_4000HZ
Definition: adxl355.h:194
adxl355_frac_repr::integer
int64_t integer
Definition: adxl355.h:284
ADXL359_PARTID
#define ADXL359_PARTID
Definition: adxl355.h:67
adxl355_config_int_pins
int adxl355_config_int_pins(struct adxl355_dev *dev, union adxl355_int_mask int_conf)
Configures the interrupt map for INT1 and INT2 pins.
Definition: adxl355.c:873
ADXL355_ODR_LPF_FIELD_MSK
#define ADXL355_ODR_LPF_FIELD_MSK
Definition: adxl355.h:154
ADXL355_ODR_1000HZ
@ ADXL355_ODR_1000HZ
Definition: adxl355.h:196
_adxl355_int_mask::RDY_EN2
uint8_t RDY_EN2
Definition: adxl355.h:246
GET_ADXL355_TRANSF_LEN
#define GET_ADXL355_TRANSF_LEN(x)
Definition: adxl355.h:58
adxl355_get_xyz
int adxl355_get_xyz(struct adxl355_dev *dev, struct adxl355_frac_repr *x, struct adxl355_frac_repr *y, struct adxl355_frac_repr *z)
Reads the raw output data of each axis and converts it to g.
Definition: adxl355.c:577
adxl355_set_int_pol
int adxl355_set_int_pol(struct adxl355_dev *dev, enum adxl355_int_pol int_pol)
Sets the interrupt polarity.
Definition: adxl355.c:890
adxl355_dev
ADXL355 Device structure.
Definition: adxl355.h:299
adxl355_set_self_test
int adxl355_set_self_test(struct adxl355_dev *dev)
Triggers the self-test feature.
Definition: adxl355.c:345
ADXL355_SHADOW_REGISTER_BASE_ADDR
#define ADXL355_SHADOW_REGISTER_BASE_ADDR
Definition: adxl355.h:91
ADXL355_TEMP
#define ADXL355_TEMP
Definition: adxl355.h:71
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
ADXL355_MEAS_TEMP_OFF_DRDY_ON
@ ADXL355_MEAS_TEMP_OFF_DRDY_ON
Definition: adxl355.h:170
adxl355_set_offset
int adxl355_set_offset(struct adxl355_dev *dev, uint16_t x_offset, uint16_t y_offset, uint16_t z_offset)
Sets an offset value for each axis (Offset Calibration).
Definition: adxl355.c:495
ADXL355_XDATA
#define ADXL355_XDATA
Definition: adxl355.h:72
adxl355_comm_init_param
Definition: adxl355.h:221
adxl355_remove
int adxl355_remove(struct adxl355_dev *dev)
Free the resources allocated by adxl355_init().
Definition: adxl355.c:236
ADXL355_ACT_CNT
#define ADXL355_ACT_CNT
Definition: adxl355.h:81
ADXL359_TEMP_OFFSET_DIV
#define ADXL359_TEMP_OFFSET_DIV
Definition: adxl355.h:143
ADXL355_INT_ACTIVE_HIGH
@ ADXL355_INT_ACTIVE_HIGH
Definition: adxl355.h:218
ADXL355_ZDATA
#define ADXL355_ZDATA
Definition: adxl355.h:74
adxl355_set_offset
int adxl355_set_offset(struct adxl355_dev *dev, uint16_t x_offset, uint16_t y_offset, uint16_t z_offset)
Sets an offset value for each axis (Offset Calibration).
Definition: adxl355.c:495
_adxl355_sts_reg_flags::DATA_RDY
uint8_t DATA_RDY
Definition: adxl355.h:258
ADXL355_FIFO_SAMPLES
#define ADXL355_FIFO_SAMPLES
Definition: adxl355.h:83
adxl355_conf_act_en
int adxl355_conf_act_en(struct adxl355_dev *dev, union adxl355_act_en_flags act_config)
Configures the activity enable register.
Definition: adxl355.c:809
adxl355_comm_desc::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: adxl355.h:290
adxl355_get_xyz
int adxl355_get_xyz(struct adxl355_dev *dev, struct adxl355_frac_repr *x, struct adxl355_frac_repr *y, struct adxl355_frac_repr *z)
Reads the raw output data of each axis and converts it to g.
Definition: adxl355.c:577
_adxl355_int_mask::OVR_EN2
uint8_t OVR_EN2
Definition: adxl355.h:248
ADXL355_ODR_62_5HZ
@ ADXL355_ODR_62_5HZ
Definition: adxl355.h:200
_adxl355_int_mask::ACT_EN1
uint8_t ACT_EN1
Definition: adxl355.h:245
adxl355_dev::act_thr
uint16_t act_thr
Definition: adxl355.h:316
no_os_get_unaligned_be24
uint32_t no_os_get_unaligned_be24(uint8_t *buf)
ADXL355_YDATA
#define ADXL355_YDATA
Definition: adxl355.h:73
_adxl355_int_mask
Definition: adxl355.h:241
adxl355_dev::dev_type
enum adxl355_type dev_type
Definition: adxl355.h:301
ADXL355_ODR_15_625HZ
@ ADXL355_ODR_15_625HZ
Definition: adxl355.h:202
ADXL355_ADDR
#define ADXL355_ADDR(x)
Definition: adxl355.h:57
ADXL355_MEAS_TEMP_OFF_DRDY_OFF
@ ADXL355_MEAS_TEMP_OFF_DRDY_OFF
Definition: adxl355.h:174
adxl355_int_pol
adxl355_int_pol
Definition: adxl355.h:216
_adxl355_act_en_flags::reserved
uint8_t reserved
Definition: adxl355.h:275
ADXL355_RANGE_FIELD_MSK
#define ADXL355_RANGE_FIELD_MSK
Definition: adxl355.h:153
adxl355_get_op_mode
int adxl355_get_op_mode(struct adxl355_dev *dev, enum adxl355_op_mode *op_mode)
Gets the current operation mode of the device.
Definition: adxl355.c:279
ADXL355_STDBY_TEMP_OFF_DRDY_ON
@ ADXL355_STDBY_TEMP_OFF_DRDY_ON
Definition: adxl355.h:171
_adxl355_int_mask::FULL_EN2
uint8_t FULL_EN2
Definition: adxl355.h:247
ADXL355_DEVID_AD
#define ADXL355_DEVID_AD
Definition: adxl355.h:64
_adxl355_act_en_flags::ACT_Z
uint8_t ACT_Z
Definition: adxl355.h:274
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
adxl355_dev::comm_buff
uint8_t comm_buff[289]
Definition: adxl355.h:317
adxl355_dev::fifo_samples
uint8_t fifo_samples
Definition: adxl355.h:313
ADXL359_TEMP_SCALE_FACTOR_DIV
#define ADXL359_TEMP_SCALE_FACTOR_DIV
Definition: adxl355.h:150
ADXL355_RANGE
#define ADXL355_RANGE
Definition: adxl355.h:86
ADXL355_TEMP_OFFSET_DIV
#define ADXL355_TEMP_OFFSET_DIV
Definition: adxl355.h:124
ADXL355_HPF_6_2084
@ ADXL355_HPF_6_2084
Definition: adxl355.h:186
ADXL355_ODR_125HZ
@ ADXL355_ODR_125HZ
Definition: adxl355.h:199
adxl355_dev::act_cnt
uint8_t act_cnt
Definition: adxl355.h:315
_adxl355_act_en_flags::ACT_Y
uint8_t ACT_Y
Definition: adxl355.h:273
ADXL355_DEVID_MST
#define ADXL355_DEVID_MST
Definition: adxl355.h:65
ADXL355_STDBY_TEMP_OFF_DRDY_OFF
@ ADXL355_STDBY_TEMP_OFF_DRDY_OFF
Definition: adxl355.h:175
adxl355_init_param::dev_type
enum adxl355_type dev_type
Definition: adxl355.h:238
adxl355_act_en_flags
Definition: adxl355.h:278
ADXL355_NEG_ACC_MSK
#define ADXL355_NEG_ACC_MSK
Definition: adxl355.h:152
ADXL355_ACC_SCALE_FACTOR_MUL
#define ADXL355_ACC_SCALE_FACTOR_MUL
Definition: adxl355.h:102
adxl355_set_fifo_samples
int adxl355_set_fifo_samples(struct adxl355_dev *dev, uint8_t reg_value)
Sets the number of FIFO samples register value.
Definition: adxl355.c:704
ADXL359_RANGE_40G
@ ADXL359_RANGE_40G
Definition: adxl355.h:213
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:107
adxl355_dev::op_mode
enum adxl355_op_mode op_mode
Definition: adxl355.h:306
adxl355_frac_repr
Definition: adxl355.h:283
adxl355_sts_reg_flags::fields
struct _adxl355_sts_reg_flags fields
Definition: adxl355.h:267
ADXL355_FIFO_DATA
#define ADXL355_FIFO_DATA
Definition: adxl355.h:75
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
adxl355_conf_act_thr
int adxl355_conf_act_thr(struct adxl355_dev *dev, uint16_t act_thr)
Configures the activity threshold registers.
Definition: adxl355.c:832
adxl355_set_int_pol
int adxl355_set_int_pol(struct adxl355_dev *dev, enum adxl355_int_pol int_pol)
Sets the interrupt polarity.
Definition: adxl355.c:890
no_os_i2c.h
Header file of I2C Interface.
ADXL355_I2C_COMM
@ ADXL355_I2C_COMM
Definition: adxl355.h:180
adxl355_set_fifo_samples
int adxl355_set_fifo_samples(struct adxl355_dev *dev, uint8_t reg_value)
Sets the number of FIFO samples register value.
Definition: adxl355.c:704
adxl355_comm_desc
Definition: adxl355.h:288
adxl355_dev::x_offset
uint16_t x_offset
Definition: adxl355.h:310
adxl355_comm_type
adxl355_comm_type
Definition: adxl355.h:178
ADXL355_ODR_3_906HZ
@ ADXL355_ODR_3_906HZ
Definition: adxl355.h:204
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:51
adxl355_conf_act_thr
int adxl355_conf_act_thr(struct adxl355_dev *dev, uint16_t act_thr)
Configures the activity threshold registers.
Definition: adxl355.c:832
adxl355_set_hpf_corner
int adxl355_set_hpf_corner(struct adxl355_dev *dev, enum adxl355_hpf_corner hpf_corner_val)
Writes the high-pass filter settings.
Definition: adxl355.c:443
ADXL359_ACC_SCALE_FACTOR_MUL
#define ADXL359_ACC_SCALE_FACTOR_MUL
Definition: adxl355.h:111
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
adxl355_get_nb_of_fifo_entries
int adxl355_get_nb_of_fifo_entries(struct adxl355_dev *dev, uint8_t *reg_value)
Reads the number of FIFO entries register value.
Definition: adxl355.c:690
adxl355_int_mask::value
uint8_t value
Definition: adxl355.h:254
ADXL355_MAX_FIFO_SAMPLES_VAL
#define ADXL355_MAX_FIFO_SAMPLES_VAL
Definition: adxl355.h:92
_adxl355_sts_reg_flags::NVM_BUSY
uint8_t NVM_BUSY
Definition: adxl355.h:262
ADXL355_RESET
#define ADXL355_RESET
Definition: adxl355.h:89
ADXL355_MEAS_TEMP_ON_DRDY_OFF
@ ADXL355_MEAS_TEMP_ON_DRDY_OFF
Definition: adxl355.h:172
ADXL355_SPI_COMM
@ ADXL355_SPI_COMM
Definition: adxl355.h:179
ADXL355_RANGE_8G
@ ADXL355_RANGE_8G
Definition: adxl355.h:212
adxl355_sts_reg_flags::value
uint8_t value
Definition: adxl355.h:268
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:70
adxl355_set_hpf_corner
int adxl355_set_hpf_corner(struct adxl355_dev *dev, enum adxl355_hpf_corner hpf_corner_val)
Writes the high-pass filter settings.
Definition: adxl355.c:443
ADXL355_STDBY_TEMP_ON_DRDY_ON
@ ADXL355_STDBY_TEMP_ON_DRDY_ON
Definition: adxl355.h:169
ADXL355_OFFSET_X
#define ADXL355_OFFSET_X
Definition: adxl355.h:76
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
ID_ADXL355
@ ID_ADXL355
Definition: adxl355.h:162
ADXL355_MEAS_TEMP_ON_DRDY_ON
@ ADXL355_MEAS_TEMP_ON_DRDY_ON
Definition: adxl355.h:168
adxl355_act_en_flags::fields
struct _adxl355_act_en_flags fields
Definition: adxl355.h:279
ADXL355_HPF_0_0954
@ ADXL355_HPF_0_0954
Definition: adxl355.h:189
ADXL355_TEMP_SCALE_FACTOR_DIV
#define ADXL355_TEMP_SCALE_FACTOR_DIV
Definition: adxl355.h:131
ID_ADXL357
@ ID_ADXL357
Definition: adxl355.h:163
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
ID_ADXL359
@ ID_ADXL359
Definition: adxl355.h:164
adxl355_init
int adxl355_init(struct adxl355_dev **device, struct adxl355_init_param init_param)
Initializes the communication peripheral and checks if the ADXL355 part is present.
Definition: adxl355.c:143
ADXL355_TEMP_SCALE_FACTOR
#define ADXL355_TEMP_SCALE_FACTOR
Definition: adxl355.h:130
adxl355_dev::hpf_corner
enum adxl355_hpf_corner hpf_corner
Definition: adxl355.h:308
adxl355_read_device_data
int adxl355_read_device_data(struct adxl355_dev *dev, uint8_t base_address, uint16_t size, uint8_t *read_data)
Reads from the device.
Definition: adxl355.c:81
adxl355_dev::range
enum adxl355_range range
Definition: adxl355.h:309
adxl355_set_op_mode
int adxl355_set_op_mode(struct adxl355_dev *dev, enum adxl355_op_mode op_mode)
Places the device into the given operation mode.
Definition: adxl355.c:258
adxl355_comm_desc::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adxl355.h:292
adxl355_comm_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: adxl355.h:225
ADXL359_RANGE_10G
@ ADXL359_RANGE_10G
Definition: adxl355.h:209
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
adxl355_init
int adxl355_init(struct adxl355_dev **device, struct adxl355_init_param init_param)
Initializes the communication peripheral and checks if the ADXL355 part is present.
Definition: adxl355.c:143
ADXL355_RANGE_2G
@ ADXL355_RANGE_2G
Definition: adxl355.h:208
_adxl355_int_mask::OVR_EN1
uint8_t OVR_EN1
Definition: adxl355.h:244
adxl355_int_mask
Definition: adxl355.h:252
ADXL359_TEMP_OFFSET
#define ADXL359_TEMP_OFFSET
Definition: adxl355.h:142
_adxl355_sts_reg_flags
Definition: adxl355.h:257
no_os_util.h
Header file of utility functions.
adxl355_get_temp
int adxl355_get_temp(struct adxl355_dev *dev, struct adxl355_frac_repr *temp)
Reads the raw temperature data and converts it to millidegrees Celsius.
Definition: adxl355.c:631
adxl355_set_op_mode
int adxl355_set_op_mode(struct adxl355_dev *dev, enum adxl355_op_mode op_mode)
Places the device into the given operation mode.
Definition: adxl355.c:258
ADXL355_OFFSET_Y
#define ADXL355_OFFSET_Y
Definition: adxl355.h:77
ADXL355_ACT_THRESH
#define ADXL355_ACT_THRESH
Definition: adxl355.h:80
ADXL355_SPI_WRITE
#define ADXL355_SPI_WRITE
Definition: adxl355.h:56
adxl355_set_range
int adxl355_set_range(struct adxl355_dev *dev, enum adxl355_range range_val)
Sets the measurement range register value.
Definition: adxl355.c:361
ADXL355_RESET_CODE
#define ADXL355_RESET_CODE
Definition: adxl355.h:94
adxl355_set_odr_lpf
int adxl355_set_odr_lpf(struct adxl355_dev *dev, enum adxl355_odr_lpf odr_lpf_val)
Writes the low-pass filter settings.
Definition: adxl355.c:392
ADXL355_ODR_31_25HZ
@ ADXL355_ODR_31_25HZ
Definition: adxl355.h:201
ADXL359_RANGE_20G
@ ADXL359_RANGE_20G
Definition: adxl355.h:211
adxl355_get_raw_fifo_data
int adxl355_get_raw_fifo_data(struct adxl355_dev *dev, uint8_t *fifo_entries, uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z)
Reads fifo data and returns the raw values.
Definition: adxl355.c:731
ADXL355_HPF_OFF
@ ADXL355_HPF_OFF
Definition: adxl355.h:184
adxl355_dev::comm_type
enum adxl355_comm_type comm_type
Definition: adxl355.h:305
_adxl355_sts_reg_flags::reserved
uint8_t reserved
Definition: adxl355.h:263
ADXL355_INT_POL_FIELD_MSK
#define ADXL355_INT_POL_FIELD_MSK
Definition: adxl355.h:156
ADXL355_RANGE_4G
@ ADXL355_RANGE_4G
Definition: adxl355.h:210
errno.h
Error macro definition for ARM Compiler.
adxl355_frac_repr::fractional
int32_t fractional
Definition: adxl355.h:285
ADXL355_SPI_READ
#define ADXL355_SPI_READ
Definition: adxl355.h:55
adxl355_set_act_cnt_reg
int adxl355_set_act_cnt_reg(struct adxl355_dev *dev, uint8_t act_cnt)
Writes the activity count register value.
Definition: adxl355.c:854
adxl355_odr_lpf
adxl355_odr_lpf
Definition: adxl355.h:193
adxl355_set_range
int adxl355_set_range(struct adxl355_dev *dev, enum adxl355_range range_val)
Sets the measurement range register value.
Definition: adxl355.c:361
ADXL355_HPF_1_5545
@ ADXL355_HPF_1_5545
Definition: adxl355.h:187
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131