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