no-OS
Loading...
Searching...
No Matches
adxl367.h
Go to the documentation of this file.
1/***************************************************************************/
33
34#ifndef __ADXL367_H__
35#define __ADXL367_H__
36
37#include <stdint.h>
38#include <stdbool.h>
39#include "no_os_spi.h"
40#include "no_os_i2c.h"
41
42/* ADXL367 communication commands */
43#define ADXL367_WRITE_REG 0x0A
44#define ADXL367_READ_REG 0x0B
45#define ADXL367_READ_FIFO 0x0D
46#define ADXL367_I2C_READ 0x01
47#define ADXL367_I2C_WRITE 0x00
48
49/* Registers */
50#define ADXL367_REG_DEVID_AD 0x00
51#define ADXL367_REG_DEVID_MST 0x01
52#define ADXL367_REG_PARTID 0x02
53#define ADXL367_REG_REVID 0x03
54#define ADXL367_REG_SERIAL_NUMBER_3 0x04
55#define ADXL367_REG_SERIAL_NUMBER_2 0x05
56#define ADXL367_REG_SERIAL_NUMBER_1 0x06
57#define ADXL367_REG_SERIAL_NUMBER_0 0x07
58#define ADXL367_REG_XDATA 0x08
59#define ADXL367_REG_YDATA 0x09
60#define ADXL367_REG_ZDATA 0x0A
61#define ADXL367_REG_STATUS 0x0B
62#define ADXL367_REG_FIFO_ENTRIES_L 0x0C
63#define ADXL367_REG_FIFO_ENTRIES_H 0x0D
64#define ADXL367_REG_XDATA_H 0x0E
65#define ADXL367_REG_XDATA_L 0x0F
66#define ADXL367_REG_YDATA_H 0x10
67#define ADXL367_REG_YDATA_L 0x11
68#define ADXL367_REG_ZDATA_H 0x12
69#define ADXL367_REG_ZDATA_L 0x13
70#define ADXL367_REG_TEMP_H 0x14
71#define ADXL367_REG_TEMP_L 0x15
72#define ADXL367_REG_EX_ADC_H 0x16
73#define ADXL367_REG_EX_ADC_L 0x17
74#define ADXL367_REG_I2C_FIFO_DATA 0x18
75#define ADXL367_REG_SOFT_RESET 0x1F
76#define ADXL367_REG_THRESH_ACT_H 0x20
77#define ADXL367_REG_THRESH_ACT_L 0x21
78#define ADXL367_REG_TIME_ACT 0x22
79#define ADXL367_REG_THRESH_INACT_H 0x23
80#define ADXL367_REG_THRESH_INACT_L 0x24
81#define ADXL367_REG_TIME_INACT_H 0x25
82#define ADXL367_REG_TIME_INACT_L 0x26
83#define ADXL367_REG_ACT_INACT_CTL 0x27
84#define ADXL367_REG_FIFO_CONTROL 0x28
85#define ADXL367_REG_FIFO_SAMPLES 0x29
86#define ADXL367_REG_INTMAP1_LWR 0x2A
87#define ADXL367_REG_INTMAP2_LWR 0x2B
88#define ADXL367_REG_FILTER_CTL 0x2C
89#define ADXL367_REG_POWER_CTL 0x2D
90#define ADXL367_REG_SELF_TEST 0x2E
91#define ADXL367_REG_TAP_THRESH 0x2F
92#define ADXL367_REG_TAP_DUR 0x30
93#define ADXL367_REG_TAP_LATENT 0x31
94#define ADXL367_REG_TAP_WINDOW 0x32
95#define ADXL367_REG_X_OFFSET 0x33
96#define ADXL367_REG_Y_OFFSET 0x34
97#define ADXL367_REG_Z_OFFSET 0x35
98#define ADXL367_REG_X_SENS 0x36
99#define ADXL367_REG_Y_SENS 0x37
100#define ADXL367_REG_Z_SENS 0x38
101#define ADXL367_REG_TIMER_CTL 0x39
102#define ADXL367_REG_INTMAP1_UPPER 0x3A
103#define ADXL367_REG_INTMAP2_UPPER 0x3B
104#define ADXL367_REG_ADC_CTL 0x3C
105#define ADXL367_REG_TEMP_CTL 0x3D
106#define ADXL367_REG_TEMP_ADC_OV_TH_H 0x3E
107#define ADXL367_REG_TEMP_ADC_OV_TH_L 0x3F
108#define ADXL367_REG_TEMP_ADC_UN_TH_H 0x40
109#define ADXL367_REG_TEMP_ADC_UN_TH_L 0x41
110#define ADXL367_REG_TEMP_ADC_TIMER 0x42
111#define ADXL367_REG_AXIS_MASK 0x43
112#define ADXL367_REG_STATUS_COPY 0x44
113#define ADXL367_REG_STATUS_2 0x45
114#define ADXL367_REG_STATUS_3 0x46
115#define ADXL367_REG_PEDOMETER_STEP_CNT_H 0x47
116#define ADXL367_REG_PEDOMETER_STEP_CNT_L 0x48
117#define ADXL367_REG_PEDOMETER_CTL 0x49
118#define ADXL367_REG_PEDOMETER_THRESH_H 0x4a
119#define ADXL367_REG_PEDOMETER_THRESH_L 0x4b
120#define ADXL367_REG_PEDOMETER_SENS_H 0x4c
121#define ADXL367_REG_PEDOMETER_SENS_L 0x4d
122
123/* ADXL367_REG_STATUS definitions */
124#define ADXL367_STATUS_ERR_USER_REGS NO_OS_BIT(7)
125#define ADXL367_STATUS_AWAKE NO_OS_BIT(6)
126#define ADXL367_STATUS_INACT NO_OS_BIT(5)
127#define ADXL367_STATUS_ACT NO_OS_BIT(4)
128#define ADXL367_STATUS_FIFO_OVERRUN NO_OS_BIT(3)
129#define ADXL367_STATUS_FIFO_WATERMARK NO_OS_BIT(2)
130#define ADXL367_STATUS_FIFO_RDY NO_OS_BIT(1)
131#define ADXL367_STATUS_DATA_RDY NO_OS_BIT(0)
132
133/* ADXL367_REG_THRESH_H mask */
134#define ADXL367_THRESH_H 0x7F
135
136/* ADXL367_REG_THRESH_L mask */
137#define ADXL367_THRESH_L 0xFC
138
139/* ADXL367_REG_ACT_INACT_CTL definitions */
140#define ADXL367_ACT_INACT_CTL_REF_READBACK_MSK NO_OS_GENMASK(7, 6)
141#define ADXL367_ACT_INACT_CTL_LINKLOOP_MSK NO_OS_GENMASK(5, 4)
142#define ADXL367_ACT_INACT_CTL_INACT_EN_MSK NO_OS_GENMASK(3, 2)
143#define ADXL367_ACT_INACT_CTL_ACT_EN_MSK NO_OS_GENMASK(1, 0)
144
145/* ADXL367_ACT_INACT_CTL_INACT_EN(x) options */
146#define ADXL367_NO_INACTIVITY_DETECTION_ENABLED 0x0
147#define ADXL367_INACTIVITY_ENABLE 0x1
148#define ADXL367_NO_INACTIVITY_DETECTION_ENABLED_2 0x2
149#define ADXL367_REFERENCED_INACTIVITY_ENABLE 0x3
150
151/* ADXL367_ACT_INACT_CTL_ACT_EN(x) options */
152#define ADXL367_NO_ACTIVITY_DETECTION 0x0
153#define ADXL367_ACTIVITY_ENABLE 0x1
154#define ADXL367_NO_ACTIVITY_DETECTION_2 0x2
155#define ADXL367_REFERENCED_ACTIVITY_ENABLE 0x3
156
157/* ADXL367_REG_FIFO_CONTROL */
158#define ADXL367_FIFO_CONTROL_FIFO_CHANNEL_MSK NO_OS_GENMASK(6, 3)
159#define ADXL367_FIFO_CONTROL_FIFO_SAMPLES NO_OS_BIT(2)
160#define ADXL367_FIFO_CONTROL_FIFO_MODE_MSK NO_OS_GENMASK(1, 0)
161
162/* ADXL367_FIFO_CONTROL_FIFO_CHANNEL(x) options */
163#define ADXL367_ALL_AXIS 0x0
164#define ADXL367_X_AXIS 0x1
165#define ADXL367_Y_AXIS 0x2
166#define ADXL367_X_AXIS_2 0x3
167#define ADXL367_ALL_AXIS_TEMP 0x4
168#define ADXL367_X_AXIS_TEMP 0x5
169#define ADXL367_Y_AXIS_TEMP 0x6
170#define ADXL367_Z_AXIS_TEMP 0x7
171#define ADXL367_ALL_AXIS_EXT_ADC 0x8
172#define ADXL367_X_AXIS_EXT_ADC 0x9
173#define ADXL367_Y_AXIS_EXT_ADC 0xA
174#define ADXL367_Z_AXIS_EXT_ADC 0xB
175
176/* ADXL367_FIFO_CONTROL_FIFO_MODE(x) options */
177#define ADXL367_FIFO_DISABLE 0
178#define ADXL367_FIFO_OLDEST_SAVED 1
179#define ADXL367_FIFO_STREAM 2
180#define ADXL367_FIFO_TRIGGERED 3
181
182/* ADXL367_REG_INTMAP1_LOWER */
183#define ADXL367_INTMAP1_INT_LOW_INT1 NO_OS_BIT(7)
184#define ADXL367_INTMAP1_AWAKE_INT1 NO_OS_BIT(6)
185#define ADXL367_INTMAP1_INACT_INT1 NO_OS_BIT(5)
186#define ADXL367_INTMAP1_ACT_INT1 NO_OS_BIT(4)
187#define ADXL367_INTMAP1_FIFO_OVERRUN_INT1 NO_OS_BIT(3)
188#define ADXL367_INTMAP1_FIFO_WATERMARK_INT1 NO_OS_BIT(2)
189#define ADXL367_INTMAP1_FIFO_RDY_INT1 NO_OS_BIT(1)
190#define ADXL367_INTMAP1_DATA_RDY_INT1 NO_OS_BIT(0)
191
192/* ADXL367_REG_INTMAP2_LOWER definitions */
193#define ADXL367_INTMAP2_INT_LOW_INT2 NO_OS_BIT(7)
194#define ADXL367_INTMAP2_AWAKE_INT2 NO_OS_BIT(6)
195#define ADXL367_INTMAP2_INACT_INT2 NO_OS_BIT(5)
196#define ADXL367_INTMAP2_ACT_INT2 NO_OS_BIT(4)
197#define ADXL367_INTMAP2_FIFO_OVERRUN_INT2 NO_OS_BIT(3)
198#define ADXL367_INTMAP2_FIFO_WATERMARK_INT2 NO_OS_BIT(2)
199#define ADXL367_INTMAP2_FIFO_RDY_INT2 NO_OS_BIT(1)
200#define ADXL367_INTMAP2_DATA_RDY_INT2 NO_OS_BIT(0)
201
202/* ADXL367_REG_FILTER_CTL definitions */
203#define ADXL367_FILTER_CTL_RANGE_MSK NO_OS_GENMASK(7, 6)
204#define ADXL367_FILTER_I2C_HS NO_OS_BIT(5)
205#define ADXL367_FILTER_CTL_RES NO_OS_BIT(4)
206#define ADXL367_FILTER_CTL_EXT_SAMPLE NO_OS_BIT(3)
207#define ADXL367_FILTER_CTL_ODR_MSK NO_OS_GENMASK(2, 0)
208
209/* ADXL367_FILTER_CTL_RANGE(x) options */
210#define ADXL367_RANGE_2G 0 /* +/-2 g */
211#define ADXL367_RANGE_4G 1 /* +/-4 g */
212#define ADXL367_RANGE_8G 2 /* +/-8 g */
213
214/* ADXL367_REG_POWER_CTL definitions */
215#define ADXL367_POWER_CTL_RES NO_OS_BIT(7)
216#define ADXL367_POWER_CTL_EXT_CLK NO_OS_BIT(6)
217#define ADXL367_POWER_CTL_LOW_NOISE_MSK NO_OS_GENMASK(5, 4)
218#define ADXL367_POWER_CTL_WAKEUP NO_OS_BIT(3)
219#define ADXL367_POWER_CTL_AUTOSLEEP NO_OS_BIT(2)
220#define ADXL367_POWER_CTL_MEASURE_MSK NO_OS_GENMASK(1, 0)
221
222/* ADXL367_POWER_CTL_NOISE(x) options */
223#define ADXL367_NOISE_MODE_NORMAL 0
224#define ADXL367_NOISE_MODE_LOW 1
225#define ADXL367_NOISE_MODE_ULTRALOW 2
226
227/* ADXL367_REG_SELF_TEST */
228#define ADXL367_SELF_TEST_ST_FORCE NO_OS_BIT(1)
229#define ADXL367_SELF_TEST_ST NO_OS_BIT(0)
230
231/* XYZ_AXIS_OFFSET MASK */
232#define ADXL367_XYZ_AXIS_OFFSET_MASK 0x1F
233
234/* ADXL367_REG_INTMAPX_UPPER MASK */
235#define ADXL367_INTMAPX_UPPER_MASK 0xDF
236
237/* ADXL367_REG_ADC_CTL definitions. */
238#define ADXL367_FIFO_8_12BIT_MSK NO_OS_GENMASK(7,6)
239#define ADXL367_ADC_INACT_EN NO_OS_BIT(3)
240#define ADXL367_ADC_ACT_EN NO_OS_BIT(1)
241#define ADXL367_ADC_EN NO_OS_BIT(0)
242
243/* ADXL367_REG_TEMP_CTL definitions. */
244#define ADXL367_NL_COMP_EN NO_OS_BIT(7)
245#define ADXL367_TEMP_INACT_EN NO_OS_BIT(3)
246#define ADXL367_TEMP_ACT_EN NO_OS_BIT(1)
247#define ADXL367_TEMP_EN NO_OS_BIT(0)
248
249/* ADXL367_REG_STATUS_3 definitions. */
250#define ADXL367_PEDOMETER_OVERFLOW_MSK NO_OS_BIT(0)
251
252/* ADXL367_REG_PEDOMETER_CTL definitions. */
253#define ADXL367_PEDOMETER_RESET_STEPMSK NO_OS_BIT(2)
254#define ADXL367_PEDOMETER_RESET_OF_MSK NO_OS_BIT(1)
255#define ADXL367_PEDOMETER_EN_MSK NO_OS_BIT(0)
256
257/* ADXL367 device information */
258#define ADXL367_DEVICE_AD 0xAD
259#define ADXL367_DEVICE_MST 0x1D
260#define ADXL367_PART_ID 0xF7
261
262/* ADXL367 Reset settings */
263#define ADXL367_RESET_KEY 0x52
264
265/* Channel ID for FIFO read */
266#define ADXL367_FIFO_X_ID 0x00
267#define ADXL367_FIFO_Y_ID 0x01
268#define ADXL367_FIFO_Z_ID 0x02
269#define ADXL367_FIFO_TEMP_ADC_ID 0x03
270
271#define ADXL367_ABSOLUTE 0x00
272#define ADXL367_REFERENCED 0x01
273
274/*
275 * At +/- 2g with 14-bit resolution, scale is given in datasheet as
276 * 250ug/LSB = 0.0002500 * 9.80665 = 0.0024516625 m/s^2.
277 * For +/- 4g range a multiplier with value 2 is used.
278 * For +/-8g range, a multiplier with value 4 is used.
279 */
280#define ADXL367_ACC_SCALE_FACTOR_MUL 245166ULL
281#define ADXL367_ACC_SCALE_FACTOR_DIV 1000000000
282
283/*
284 * At 25C, raw value is equal to 165 LSB. Raw value varies with 54LSB/C.
285 * Offset = 25 * ADXL367_TEMP_PER_C - ADXL367_TEMP_25C = 1185.
286 * Temp = (RAW + OFFSET) * SCALE
287 * */
288#define ADXL367_TEMP_OFFSET 1185
289#define ADXL367_TEMP_25C 165
290#define ADXL367_TEMP_SCALE 18518518
291#define ADXL367_TEMP_SCALE_DIV 1000000000
292
293/* Min change = 90mg. Sensitivity = 4LSB / mg */
294#define ADXL367_SELF_TEST_MIN 90 * 100 / 25
295/* Max change = 270mg. Sensitivity = 4LSB / mg */
296#define ADXL367_SELF_TEST_MAX 270 * 100 / 25
297
305};
306
315
324
334
347
358
364 /* All axis. Default mode. */
366 /* X axis. */
368 /* Y axis. */
370 /* Z axis. */
372 /* All axis + temperature. */
374 /* X axis + temperature. */
376 /* Y axis + temperature. */
378 /* Z axis + temperature. */
380 /* All axis + ADC. */
382 /* X axis + ADC. */
384 /* Y axis + ADC. */
386 /* Z axis + ADC. */
388};
389
395 /* Upper 12 bits plus channel ID.*/
397 /* Upper 8 bits, no channel ID. */
399 /* Upper 12 bits, no channel ID. */
401 /* 14 bits plus channel ID. Default mode. */
403};
404
410 uint8_t err_fuse : 1;
411 uint8_t err_user_regs : 1;
412 uint8_t kpalv_timer : 1;
413 uint8_t temp_adc_hi : 1;
414 uint8_t temp_adc_low : 1;
415 uint8_t tap_two : 1;
416 uint8_t tap_one : 1;
417 uint8_t int_low : 1;
418 uint8_t awake : 1;
419 uint8_t inact : 1;
420 uint8_t act : 1;
421 uint8_t fifo_overrun : 1;
422 uint8_t fifo_watermark : 1;
423 uint8_t fifo_ready : 1;
424 uint8_t data_ready : 1;
425};
426
432 int64_t integer;
433 int32_t fractional;
434};
435
464
481
482/* Initializes the device. */
483int adxl367_init(struct adxl367_dev **device,
485
486/* Free the resources allocated by adxl367_init(). */
487int adxl367_remove(struct adxl367_dev *dev);
488
489/* Performs device self-test. */
490int adxl367_self_test(struct adxl367_dev *dev);
491
492/* Writes data into a register. */
494 uint8_t register_value,
495 uint8_t register_address);
496
497/* Performs a burst read of a specified number of registers. */
499 uint8_t *read_data,
500 uint8_t register_address,
501 uint8_t bytes_number);
502
503/* Performs a masked write to a register. */
504int adxl367_reg_write_msk(struct adxl367_dev *dev,
505 uint8_t reg_addr,
506 uint8_t data,
507 uint8_t mask);
508
509/* Resets the device via comm. */
510int adxl367_software_reset(struct adxl367_dev *dev);
511
512/* Places the device into standby/measure mode. */
513int adxl367_set_power_mode(struct adxl367_dev *dev,
514 enum adxl367_op_mode mode);
515
516/* Selects the measurement range. */
517int adxl367_set_range(struct adxl367_dev *dev,
518 enum adxl367_range range);
519
520/* Selects the Output Data Rate of the device. */
522 enum adxl367_odr odr);
523
524/* Sets user defined offset for each axis. */
525int adxl367_set_offset(struct adxl367_dev *dev, uint16_t x_offset,
526 uint16_t y_offset, uint16_t z_offset);
527
528/* Reads the 3-axis raw data from the accelerometer. */
529int adxl367_get_raw_xyz(struct adxl367_dev *dev,
530 int16_t* x,
531 int16_t* y,
532 int16_t* z);
533
534/* Reads the 3-axis raw data from the accelerometer and converts it to g. */
535int adxl367_get_g_xyz(struct adxl367_dev *dev,
536 struct adxl367_fractional_val* x,
537 struct adxl367_fractional_val* y,
538 struct adxl367_fractional_val* z);
539
540/* Enables temperature reading. */
541int adxl367_temp_read_en(struct adxl367_dev *dev, bool enable);
542
543/* Enables adc reading and disables temperature reading. */
544int adxl367_adc_read_en(struct adxl367_dev *dev, bool enable);
545
546/* Reads the raw temperature of the device. */
547int adxl367_read_raw_temp(struct adxl367_dev *dev, int16_t *raw_temp);
548
549/* Reads the temperature of the device. */
551 struct adxl367_fractional_val *temp);
552
553/* Reads ADC data. */
554int adxl367_read_adc(struct adxl367_dev *dev, int16_t *data);
555
556/* Reads the number of FIFO entries register value. */
558 uint16_t *entr_nb);
559
560/* Sets the number of FIFO samples register value. */
562 uint16_t sets_nb);
563
564/* Sets FIFO mode. */
565int adxl367_set_fifo_mode(struct adxl367_dev *dev,
566 enum adxl367_fifo_mode mode);
567
568/* Sets FIFO read mode. */
570 enum adxl367_fifo_read_mode read_mode);
571
572/* Sets FIFO data storage format. */
574 enum adxl367_fifo_format format);
575
576/* Configures FIFO feature. */
577int adxl367_fifo_setup(struct adxl367_dev *dev,
578 enum adxl367_fifo_mode mode,
579 enum adxl367_fifo_format format,
580 uint8_t sets_nb);
581
582/* Reads raw values from FIFO. */
583int adxl367_read_raw_fifo(struct adxl367_dev *dev, int16_t *x, int16_t *y,
584 int16_t *z, int16_t *temp_adc, uint16_t *entries);
585
586/* Reads converted values from FIFO. */
589 struct adxl367_fractional_val *z, struct adxl367_fractional_val *temp_adc,
590 uint16_t *entries);
591
592/* Enables specified events to interrupt pin. */
593int adxl367_int_map(struct adxl367_dev *dev, struct adxl367_int_map *map,
594 uint8_t pin);
595
596/* Configures activity detection. */
598 uint8_t ref_or_abs,
599 uint16_t threshold,
600 uint8_t time);
601
602/* Configures inactivity detection. */
604 uint8_t ref_or_abs,
605 uint16_t threshold,
606 uint16_t time);
607
608/* Enable or disable Z-axis nonlinearity compensation. */
609int adxl367_z_nonlinearity_compensation(struct adxl367_dev *dev, bool enable);
610
611/* Enable or disable activity and inactivity reference readback. */
613 bool inactivity,
614 int16_t* x,
615 int16_t* y,
616 int16_t* z);
617
618/* Enable the step counter feature. */
619int adxl367_pedometer_enable(struct adxl367_dev *dev, bool enable);
620
621/* Read the step counter. */
622int adxl367_pedometer_get_steps(struct adxl367_dev *dev, uint16_t *steps);
623
624/* Reset the step counter. */
625int adxl367_pedometer_reset(struct adxl367_dev *dev);
626
627#endif /* __ADXL367_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int adxl367_pedometer_enable(struct adxl367_dev *dev, bool enable)
Definition adxl367.c:1416
adxl367_fifo_format
Enum for selecting FIFO storage mode.
Definition adxl367.h:363
@ ADXL367_FIFO_FORMAT_Y
Definition adxl367.h:369
@ ADXL367_FIFO_FORMAT_XYZT
Definition adxl367.h:373
@ ADXL367_FIFO_FORMAT_YA
Definition adxl367.h:385
@ ADXL367_FIFO_FORMAT_X
Definition adxl367.h:367
@ ADXL367_FIFO_FORMAT_XA
Definition adxl367.h:383
@ ADXL367_FIFO_FORMAT_XYZA
Definition adxl367.h:381
@ ADXL367_FIFO_FORMAT_ZA
Definition adxl367.h:387
@ ADXL367_FIFO_FORMAT_Z
Definition adxl367.h:371
@ ADXL367_FIFO_FORMAT_ZT
Definition adxl367.h:379
@ ADXL367_FIFO_FORMAT_YT
Definition adxl367.h:377
@ ADXL367_FIFO_FORMAT_XYZ
Definition adxl367.h:365
@ ADXL367_FIFO_FORMAT_XT
Definition adxl367.h:375
int adxl367_set_range(struct adxl367_dev *dev, enum adxl367_range range)
Selects the measurement range.
Definition adxl367.c:469
int adxl367_set_fifo_read_mode(struct adxl367_dev *dev, enum adxl367_fifo_read_mode read_mode)
Sets FIFO read mode.
Definition adxl367.c:916
adxl367_fifo_mode
Enum for selecting FIFO operating mode.
Definition adxl367.h:352
@ ADXL367_FIFO_DISABLED
Definition adxl367.h:353
@ ADXL367_TRIGGERED_MODE
Definition adxl367.h:356
@ ADXL367_STREAM_MODE
Definition adxl367.h:355
@ ADXL367_OLDEST_SAVED
Definition adxl367.h:354
adxl367_range
Enum for selecting range.
Definition adxl367.h:329
@ ADXL367_8G_RANGE
Definition adxl367.h:332
@ ADXL367_2G_RANGE
Definition adxl367.h:330
@ ADXL367_4G_RANGE
Definition adxl367.h:331
int adxl367_set_power_mode(struct adxl367_dev *dev, enum adxl367_op_mode mode)
Places the device into standby/measure mode.
Definition adxl367.c:437
int adxl367_z_nonlinearity_compensation(struct adxl367_dev *dev, bool enable)
Definition adxl367.c:1356
adxl367_odr
Enum for selecting output data rate.
Definition adxl367.h:339
@ ADXL367_ODR_200HZ
Definition adxl367.h:344
@ ADXL367_ODR_12P5HZ
Definition adxl367.h:340
@ ADXL367_ODR_25HZ
Definition adxl367.h:341
@ ADXL367_ODR_50HZ
Definition adxl367.h:342
@ ADXL367_ODR_100HZ
Definition adxl367.h:343
@ ADXL367_ODR_400HZ
Definition adxl367.h:345
int adxl367_fifo_setup(struct adxl367_dev *dev, enum adxl367_fifo_mode mode, enum adxl367_fifo_format format, uint8_t sets_nb)
Configures the FIFO feature. Uses ADXL367_14B_CHID read mode as default.
Definition adxl367.c:1022
int adxl367_self_test(struct adxl367_dev *dev)
Performs self test.
Definition adxl367.c:157
adxl367_comm_type
Enum for communication type.
Definition adxl367.h:311
@ ADXL367_I2C_COMM
Definition adxl367.h:313
@ ADXL367_SPI_COMM
Definition adxl367.h:312
int adxl367_reference_readback(struct adxl367_dev *dev, bool inactivity, int16_t *x, int16_t *y, int16_t *z)
Definition adxl367.c:1369
int adxl367_reg_write_msk(struct adxl367_dev *dev, uint8_t reg_addr, uint8_t data, uint8_t mask)
Performs a masked write to a register.
Definition adxl367.c:372
int adxl367_adc_read_en(struct adxl367_dev *dev, bool enable)
Enables ADC reading. Disables temperature reading.
Definition adxl367.c:686
int adxl367_set_offset(struct adxl367_dev *dev, uint16_t x_offset, uint16_t y_offset, uint16_t z_offset)
Sets offset for each axis.
Definition adxl367.c:527
adxl367_fifo_read_mode
Enum for selecting FIFO reading mode.
Definition adxl367.h:394
@ ADXL367_14B_CHID
Definition adxl367.h:402
@ ADXL367_8B
Definition adxl367.h:398
@ ADXL367_12B
Definition adxl367.h:400
@ ADXL367_12B_CHID
Definition adxl367.h:396
int adxl367_read_temperature(struct adxl367_dev *dev, struct adxl367_fractional_val *temp)
Reads the temperature of the device.
Definition adxl367.c:774
int adxl367_init(struct adxl367_dev **device, struct adxl367_init_param init_param)
Initializes communication with the device and checks if the part is present by reading the device id.
Definition adxl367.c:55
int adxl367_set_fifo_format(struct adxl367_dev *dev, enum adxl367_fifo_format format)
Sets FIFO format.
Definition adxl367.c:953
int adxl367_get_g_xyz(struct adxl367_dev *dev, struct adxl367_fractional_val *x, struct adxl367_fractional_val *y, struct adxl367_fractional_val *z)
Reads the 3-axis raw data from the accelerometer and converts it to g.
Definition adxl367.c:639
int adxl367_pedometer_get_steps(struct adxl367_dev *dev, uint16_t *steps)
Definition adxl367.c:1429
int adxl367_set_register_value(struct adxl367_dev *dev, uint8_t register_value, uint8_t register_address)
Writes data into a register.
Definition adxl367.c:259
int adxl367_setup_inactivity_detection(struct adxl367_dev *dev, uint8_t ref_or_abs, uint16_t threshold, uint16_t time)
Configures inactivity detection.
Definition adxl367.c:1310
int adxl367_software_reset(struct adxl367_dev *dev)
Performs soft-reset.
Definition adxl367.c:395
int adxl367_read_raw_fifo(struct adxl367_dev *dev, int16_t *x, int16_t *y, int16_t *z, int16_t *temp_adc, uint16_t *entries)
Reads all available raw values from FIFO. If, after setting FIFO mode, any of x, y,...
Definition adxl367.c:1059
int adxl367_pedometer_reset(struct adxl367_dev *dev)
Definition adxl367.c:1458
int adxl367_set_output_rate(struct adxl367_dev *dev, enum adxl367_odr odr)
Selects the Output Data Rate of the device.
Definition adxl367.c:500
int adxl367_read_adc(struct adxl367_dev *dev, int16_t *data)
Reads ADC data. If ADXL367_ADC_EN is not set, use adxl367_adc_read_en() first to enable ADC reading.
Definition adxl367.c:796
int adxl367_set_fifo_mode(struct adxl367_dev *dev, enum adxl367_fifo_mode mode)
Sets FIFO mode.
Definition adxl367.c:887
int adxl367_set_fifo_sample_sets_nb(struct adxl367_dev *dev, uint16_t sets_nb)
Sets the number of FIFO sample sets.
Definition adxl367.c:858
adxl367_id
Compatible device specifier, value corresponds to REV_ID register value.
Definition adxl367.h:302
@ ADXL366_ID
Definition adxl367.h:304
@ ADXL367_ID
Definition adxl367.h:303
int adxl367_get_nb_of_fifo_entries(struct adxl367_dev *dev, uint16_t *entr_nb)
Reads the number of FIFO entries.
Definition adxl367.c:834
int adxl367_read_converted_fifo(struct adxl367_dev *dev, struct adxl367_fractional_val *x, struct adxl367_fractional_val *y, struct adxl367_fractional_val *z, struct adxl367_fractional_val *temp_adc, uint16_t *entries)
Reads converted values from FIFO. If, after setting FIFO mode, any of x, y, z, temp or adc aren't sel...
Definition adxl367.c:1147
int adxl367_remove(struct adxl367_dev *dev)
Frees the resources allocated by adxl367_init().
Definition adxl367.c:136
int adxl367_int_map(struct adxl367_dev *dev, struct adxl367_int_map *map, uint8_t pin)
Enables specified events to interrupt pin.
Definition adxl367.c:1202
int adxl367_get_raw_xyz(struct adxl367_dev *dev, int16_t *x, int16_t *y, int16_t *z)
Reads the 3-axis raw data from the accelerometer.
Definition adxl367.c:566
int adxl367_setup_activity_detection(struct adxl367_dev *dev, uint8_t ref_or_abs, uint16_t threshold, uint8_t time)
Configures activity detection.
Definition adxl367.c:1253
int adxl367_read_raw_temp(struct adxl367_dev *dev, int16_t *raw_temp)
Reads the raw temperature of the device. If ADXL367_TEMP_EN is not set, use adxl367_temp_read_en() fi...
Definition adxl367.c:713
int adxl367_temp_read_en(struct adxl367_dev *dev, bool enable)
Enables temperature reading.
Definition adxl367.c:669
adxl367_op_mode
Enum for operating mode.
Definition adxl367.h:320
@ ADXL367_OP_STANDBY
Definition adxl367.h:321
@ ADXL367_OP_MEASURE
Definition adxl367.h:322
int adxl367_get_register_value(struct adxl367_dev *dev, uint8_t *read_data, uint8_t register_address, uint8_t bytes_number)
Performs a burst read of a specified number of registers.
Definition adxl367.c:288
Header file of I2C Interface.
Header file of SPI Interface.
ADXL367 Device structure.
Definition adxl367.h:440
uint16_t x_offset
Definition adxl367.h:460
enum adxl367_fifo_format fifo_format
Definition adxl367.h:456
enum adxl367_comm_type comm_type
Definition adxl367.h:444
uint16_t y_offset
Definition adxl367.h:461
enum adxl367_odr odr
Definition adxl367.h:454
enum adxl367_id id
Definition adxl367.h:442
enum adxl367_op_mode op_mode
Definition adxl367.h:453
uint8_t fifo_buffer[1027]
Definition adxl367.h:459
enum adxl367_fifo_read_mode fifo_read_mode
Definition adxl367.h:457
enum adxl367_fifo_mode fifo_mode
Definition adxl367.h:455
struct no_os_i2c_desc * i2c_desc
Definition adxl367.h:448
uint8_t i2c_slave_address
Definition adxl367.h:450
enum adxl367_range range
Definition adxl367.h:452
struct no_os_spi_desc * spi_desc
Definition adxl367.h:446
uint16_t z_offset
Definition adxl367.h:462
Data format in which the values are converted.
Definition adxl367.h:431
int32_t fractional
Definition adxl367.h:433
int64_t integer
Definition adxl367.h:432
Structure holding the parameters for ADXL367 device initialization.
Definition adxl367.h:469
struct no_os_spi_init_param spi_init
Definition adxl367.h:475
uint8_t i2c_slave_address
Definition adxl367.h:479
enum adxl367_id id
Definition adxl367.h:471
enum adxl367_comm_type comm_type
Definition adxl367.h:473
struct no_os_i2c_init_param i2c_init
Definition adxl367.h:477
Contains bit options from INT registers.
Definition adxl367.h:409
uint8_t temp_adc_hi
Definition adxl367.h:413
uint8_t inact
Definition adxl367.h:419
uint8_t data_ready
Definition adxl367.h:424
uint8_t err_user_regs
Definition adxl367.h:411
uint8_t temp_adc_low
Definition adxl367.h:414
uint8_t act
Definition adxl367.h:420
uint8_t tap_two
Definition adxl367.h:415
uint8_t kpalv_timer
Definition adxl367.h:412
uint8_t fifo_ready
Definition adxl367.h:423
uint8_t awake
Definition adxl367.h:418
uint8_t fifo_watermark
Definition adxl367.h:422
uint8_t int_low
Definition adxl367.h:417
uint8_t fifo_overrun
Definition adxl367.h:421
uint8_t tap_one
Definition adxl367.h:416
uint8_t err_fuse
Definition adxl367.h:410
Definition ad9361_util.h:63
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128