periph 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -12
- package/examples/accelerometer/adxl345/complete.js +52 -0
- package/examples/accelerometer/adxl345/demo.js +34 -0
- package/examples/accelerometer/adxl345/minimal.js +18 -0
- package/examples/accelerometer/adxl362/complete.js +57 -0
- package/examples/accelerometer/adxl362/demo.js +51 -0
- package/examples/accelerometer/adxl362/minimal.js +21 -0
- package/examples/adc_dac/ad7705/complete.js +32 -0
- package/examples/adc_dac/ad7705/demo.js +42 -0
- package/examples/adc_dac/ad7705/minimal.js +16 -0
- package/examples/adc_dac/ad7706/complete.js +35 -0
- package/examples/adc_dac/ad7706/demo.js +44 -0
- package/examples/adc_dac/ad7706/minimal.js +16 -0
- package/examples/adc_dac/hx710a/complete.js +45 -0
- package/examples/adc_dac/hx710a/demo.js +52 -0
- package/examples/adc_dac/hx710a/minimal.js +16 -0
- package/examples/adc_dac/hx710b/complete.js +45 -0
- package/examples/adc_dac/hx710b/demo.js +64 -0
- package/examples/adc_dac/hx710b/minimal.js +16 -0
- package/examples/adc_dac/hx711/complete.js +7 -7
- package/examples/adc_dac/hx711/demo.js +6 -6
- package/examples/adc_dac/hx711/minimal.js +7 -7
- package/examples/adc_dac/mcp4725/complete.js +19 -17
- package/examples/adc_dac/mcp4725/demo.js +5 -5
- package/examples/adc_dac/mcp4725/minimal.js +8 -6
- package/examples/adc_dac/mcp4728/complete.js +24 -22
- package/examples/adc_dac/mcp4728/demo.js +22 -22
- package/examples/adc_dac/mcp4728/minimal.js +8 -6
- package/examples/adc_dac/pcf8591/complete.js +41 -0
- package/examples/adc_dac/pcf8591/demo.js +39 -0
- package/examples/adc_dac/pcf8591/minimal.js +19 -0
- package/examples/comms/mcp2515/complete.js +75 -0
- package/examples/comms/mcp2515/demo.js +66 -0
- package/examples/comms/mcp2515/minimal.js +27 -0
- package/examples/comms/rda5807m/complete.js +55 -0
- package/examples/comms/rda5807m/demo.js +68 -0
- package/examples/comms/rda5807m/minimal.js +15 -0
- package/examples/comms/rfm9x/complete.js +50 -0
- package/examples/comms/rfm9x/demo.js +55 -0
- package/examples/comms/rfm9x/minimal.js +20 -0
- package/examples/display/pcf8576/complete.js +18 -15
- package/examples/display/pcf8576/demo.js +6 -6
- package/examples/display/pcf8576/minimal.js +12 -10
- package/examples/environmental/aht21/complete.js +15 -13
- package/examples/environmental/aht21/demo.js +8 -6
- package/examples/environmental/aht21/minimal.js +5 -5
- package/examples/environmental/bme280/complete.js +23 -20
- package/examples/environmental/bme280/demo.js +14 -14
- package/examples/environmental/bme280/minimal.js +13 -11
- package/examples/environmental/bme680/complete.js +25 -22
- package/examples/environmental/bme680/demo.js +38 -36
- package/examples/environmental/bme680/minimal.js +14 -12
- package/examples/gas/ens160/complete.js +29 -27
- package/examples/gas/ens160/demo.js +39 -37
- package/examples/gas/ens160/minimal.js +17 -15
- package/examples/gnss/neo6/complete.js +49 -0
- package/examples/gnss/neo6/demo.js +54 -0
- package/examples/gnss/neo6/minimal.js +30 -0
- package/examples/gyroscope/l3g4200d/complete.js +56 -0
- package/examples/gyroscope/l3g4200d/demo.js +49 -0
- package/examples/gyroscope/l3g4200d/minimal.js +19 -0
- package/examples/gyroscope/l3gd20h/complete.js +42 -0
- package/examples/gyroscope/l3gd20h/demo.js +29 -0
- package/examples/gyroscope/l3gd20h/minimal.js +13 -0
- package/examples/humidity/dht11/complete.js +22 -0
- package/examples/humidity/dht11/demo.js +38 -0
- package/examples/humidity/dht11/minimal.js +18 -0
- package/examples/imu/mpu6050/complete.js +27 -25
- package/examples/imu/mpu6050/demo.js +29 -26
- package/examples/imu/mpu6050/minimal.js +6 -6
- package/examples/imu/mpu9250/complete.js +65 -0
- package/examples/imu/mpu9250/demo.js +53 -0
- package/examples/imu/mpu9250/minimal.js +21 -0
- package/examples/imu/mpu9255/complete.js +73 -0
- package/examples/imu/mpu9255/demo.js +73 -0
- package/examples/imu/mpu9255/minimal.js +21 -0
- package/examples/io_expander/mcp23017/complete.js +70 -77
- package/examples/io_expander/mcp23017/demo.js +37 -33
- package/examples/io_expander/mcp23017/minimal.js +15 -11
- package/examples/io_expander/pcf8574/complete.js +60 -65
- package/examples/io_expander/pcf8574/demo.js +30 -25
- package/examples/io_expander/pcf8574/minimal.js +15 -11
- package/examples/io_expander/pcf8575/complete.js +24 -20
- package/examples/io_expander/pcf8575/demo.js +27 -23
- package/examples/io_expander/pcf8575/minimal.js +16 -12
- package/examples/io_expander/tpic6b595/complete.js +57 -0
- package/examples/io_expander/tpic6b595/demo.js +75 -0
- package/examples/io_expander/tpic6b595/minimal.js +26 -0
- package/examples/led/apa102/complete.js +72 -0
- package/examples/led/apa102/demo.js +92 -0
- package/examples/led/apa102/minimal.js +21 -0
- package/examples/led/sk6812rgbw/complete.js +42 -40
- package/examples/led/sk6812rgbw/demo.js +16 -16
- package/examples/led/sk6812rgbw/minimal.js +15 -17
- package/examples/led/ws2812b/complete.js +40 -38
- package/examples/led/ws2812b/demo.js +16 -16
- package/examples/led/ws2812b/minimal.js +13 -14
- package/examples/led/ws2814/complete.js +71 -0
- package/examples/led/ws2814/demo.js +82 -0
- package/examples/led/ws2814/minimal.js +23 -0
- package/examples/light/apds-9930/complete.js +46 -0
- package/examples/light/apds-9930/demo.js +31 -0
- package/examples/light/apds-9930/minimal.js +20 -0
- package/examples/light/apds9960/complete.js +45 -43
- package/examples/light/apds9960/demo.js +11 -9
- package/examples/light/apds9960/minimal.js +5 -5
- package/examples/magnetometer/as5600/complete.js +31 -29
- package/examples/magnetometer/as5600/demo.js +35 -33
- package/examples/magnetometer/as5600/minimal.js +7 -7
- package/examples/magnetometer/hmc5883l/complete.js +47 -0
- package/examples/magnetometer/hmc5883l/demo.js +50 -0
- package/examples/magnetometer/hmc5883l/minimal.js +15 -0
- package/examples/memory/24aa02uid/complete.js +23 -21
- package/examples/memory/24aa02uid/demo.js +32 -30
- package/examples/memory/24aa02uid/minimal.js +5 -5
- package/examples/other/mpr121/complete.js +50 -0
- package/examples/other/mpr121/demo.js +30 -0
- package/examples/other/mpr121/minimal.js +17 -0
- package/examples/power/ade7953/complete.js +44 -0
- package/examples/power/ade7953/demo.js +28 -0
- package/examples/power/ade7953/minimal.js +15 -0
- package/examples/power/ina219/complete.js +20 -18
- package/examples/power/ina219/demo.js +15 -13
- package/examples/power/ina219/minimal.js +8 -8
- package/examples/power/ina226/complete.js +24 -22
- package/examples/power/ina226/demo.js +22 -20
- package/examples/power/ina226/minimal.js +5 -5
- package/examples/power/ina3221/complete.js +51 -49
- package/examples/power/ina3221/demo.js +13 -13
- package/examples/power/ina3221/minimal.js +8 -8
- package/examples/pressure/bmp085/complete.js +29 -0
- package/examples/pressure/bmp085/demo.js +34 -0
- package/examples/pressure/bmp085/minimal.js +19 -0
- package/examples/pressure/bmp180/complete.js +20 -17
- package/examples/pressure/bmp180/demo.js +24 -22
- package/examples/pressure/bmp180/minimal.js +13 -11
- package/examples/pressure/bmp280/complete.js +23 -20
- package/examples/pressure/bmp280/demo.js +44 -41
- package/examples/pressure/bmp280/minimal.js +13 -11
- package/examples/pressure/bmp384/complete.js +29 -0
- package/examples/pressure/bmp384/demo.js +40 -0
- package/examples/pressure/bmp384/minimal.js +18 -0
- package/examples/pressure/bmp581/complete.js +34 -0
- package/examples/pressure/bmp581/demo.js +56 -0
- package/examples/pressure/bmp581/minimal.js +19 -0
- package/examples/pressure/lps22df/complete.js +50 -0
- package/examples/pressure/lps22df/demo.js +41 -0
- package/examples/pressure/lps22df/minimal.js +19 -0
- package/examples/pressure/lps28dfw/complete.js +37 -0
- package/examples/pressure/lps28dfw/demo.js +33 -0
- package/examples/pressure/lps28dfw/minimal.js +19 -0
- package/examples/pressure/lps33hw/complete.js +43 -0
- package/examples/pressure/lps33hw/demo.js +43 -0
- package/examples/pressure/lps33hw/minimal.js +19 -0
- package/examples/rfid/mfrc522/complete.js +44 -0
- package/examples/rfid/mfrc522/demo.js +70 -0
- package/examples/rfid/mfrc522/minimal.js +17 -0
- package/package.json +5 -1
- package/src/chips/accelerometer/adxl345.js +482 -0
- package/src/chips/accelerometer/adxl362.js +594 -0
- package/src/chips/adc_dac/ad7705.js +345 -0
- package/src/chips/adc_dac/ad7706.js +331 -0
- package/src/chips/adc_dac/hx710a.js +184 -0
- package/src/chips/adc_dac/hx710b.js +186 -0
- package/src/chips/adc_dac/hx711.js +15 -15
- package/src/chips/adc_dac/mcp4725.js +48 -40
- package/src/chips/adc_dac/mcp4728.js +57 -44
- package/src/chips/adc_dac/pcf8591.js +196 -0
- package/src/chips/comms/mcp2515.js +659 -0
- package/src/chips/comms/rda5807m.js +393 -0
- package/src/chips/comms/rfm9x.js +590 -0
- package/src/chips/display/pcf8576.js +42 -33
- package/src/chips/environmental/aht21.js +52 -37
- package/src/chips/environmental/bme280.js +85 -66
- package/src/chips/environmental/bme680.js +110 -87
- package/src/chips/gas/ens160.js +82 -64
- package/src/chips/gnss/neo6.js +438 -0
- package/src/chips/gyroscope/l3g4200d.js +366 -0
- package/src/chips/gyroscope/l3gd20h.js +314 -0
- package/src/chips/humidity/dht11.js +135 -0
- package/src/chips/imu/mpu6050.js +89 -66
- package/src/chips/imu/mpu9250.js +394 -0
- package/src/chips/imu/mpu9255.js +447 -0
- package/src/chips/io_expander/mcp23017.js +240 -157
- package/src/chips/io_expander/pcf8574.js +149 -124
- package/src/chips/io_expander/pcf8575.js +164 -135
- package/src/chips/io_expander/tpic6b595.js +242 -0
- package/src/chips/led/_NeoPixelRGBBase.js +204 -0
- package/src/chips/led/_NeoPixelRGBWBase.js +218 -0
- package/src/chips/led/apa102.js +236 -0
- package/src/chips/led/sk6812rgbw.js +15 -149
- package/src/chips/led/ws2812b.js +14 -139
- package/src/chips/led/ws2814.js +49 -0
- package/src/chips/light/apds-9930.js +342 -0
- package/src/chips/light/apds9960.js +158 -123
- package/src/chips/magnetometer/as5600.js +102 -82
- package/src/chips/magnetometer/hmc5883l.js +222 -0
- package/src/chips/memory/_24aa02uid.js +32 -29
- package/src/chips/other/mpr121.js +375 -0
- package/src/chips/power/ade7953.js +427 -0
- package/src/chips/power/ina219.js +45 -40
- package/src/chips/power/ina226.js +50 -45
- package/src/chips/power/ina3221.js +95 -76
- package/src/chips/pressure/bmp085.js +251 -0
- package/src/chips/pressure/bmp180.js +54 -37
- package/src/chips/pressure/bmp280.js +72 -53
- package/src/chips/pressure/bmp384.js +410 -0
- package/src/chips/pressure/bmp581.js +489 -0
- package/src/chips/pressure/lps22df.js +341 -0
- package/src/chips/pressure/lps28dfw.js +314 -0
- package/src/chips/pressure/lps33hw.js +255 -0
- package/src/chips/rfid/mfrc522.js +674 -0
- package/src/connection/connection.js +111 -0
- package/src/connection/dhtxx.js +138 -0
- package/src/connection/dhtxx_mock.js +39 -0
- package/src/{transport → connection}/hx711.js +49 -22
- package/src/connection/hx711_mock.js +52 -0
- package/src/{transport → connection}/i2c.js +13 -9
- package/src/connection/i2c_mock.js +91 -0
- package/src/connection/input_pin.js +156 -0
- package/src/connection/neo6_mock.js +45 -0
- package/src/{transport → connection}/neopixel.js +23 -4
- package/src/connection/output_pin.js +41 -0
- package/src/connection/sipo.js +159 -0
- package/src/{transport → connection}/smbus.js +14 -10
- package/src/{transport → connection}/spi.js +12 -8
- package/src/connection/spi_mock.js +151 -0
- package/src/{transport → connection}/uart.js +33 -26
- package/examples/gnss/.gitkeep +0 -0
- package/examples/humidity/.gitkeep +0 -0
- package/src/chips/gnss/.gitkeep +0 -0
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ADXL362 3-axis MEMS accelerometer driver (SPI).
|
|
5
|
+
*
|
|
6
|
+
* The ADXL362 is an ultralow power 3-axis accelerometer with 12-bit
|
|
7
|
+
* output resolution, a 512-sample FIFO, on-chip temperature sensor,
|
|
8
|
+
* autonomous activity/inactivity (motion) detection with two independent
|
|
9
|
+
* interrupt pins, and a wake-up mode that consumes ~270 nA. The
|
|
10
|
+
* ADXL362 is SPI-only — there is no I²C mode.
|
|
11
|
+
*
|
|
12
|
+
* SPI command structure:
|
|
13
|
+
* WRITE register 0x0A + addr + data...
|
|
14
|
+
* READ register 0x0B + addr + data...
|
|
15
|
+
* READ FIFO 0x0D + data...
|
|
16
|
+
*
|
|
17
|
+
* Default configuration baked into Minimal:
|
|
18
|
+
* - ±2 g measurement range
|
|
19
|
+
* - 100 Hz output data rate, ODR/4 antialiasing bandwidth
|
|
20
|
+
* - Normal noise mode (POWER_CTL.LOW_NOISE=00)
|
|
21
|
+
* - Continuous measurement mode (POWER_CTL.MEASURE=10)
|
|
22
|
+
* - FIFO disabled
|
|
23
|
+
* - No interrupts mapped; INT1/INT2 high-impedance
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// SPI command bytes.
|
|
27
|
+
const CMD_WRITE_REG = 0x0A;
|
|
28
|
+
const CMD_READ_REG = 0x0B;
|
|
29
|
+
const CMD_READ_FIFO = 0x0D;
|
|
30
|
+
|
|
31
|
+
// Soft-reset key (ASCII 'R').
|
|
32
|
+
const SOFT_RESET_KEY = 0x52;
|
|
33
|
+
|
|
34
|
+
// Per-range sensitivity (g/LSB), typical. The ±8 g value is intentionally
|
|
35
|
+
// not 4× the ±2 g value (4.255 mg/LSB vs. 1 mg/LSB) per datasheet.
|
|
36
|
+
const SENSITIVITY_G_PER_LSB = [0.001, 0.002, 0.004255];
|
|
37
|
+
|
|
38
|
+
// ODR codes (FILTER_CTL bits 2:0) and their actual rates in Hz. Codes
|
|
39
|
+
// 0x05–0x07 all map to 400 Hz.
|
|
40
|
+
const ODR_CODES = [
|
|
41
|
+
[0x00, 12.5],
|
|
42
|
+
[0x01, 25.0],
|
|
43
|
+
[0x02, 50.0],
|
|
44
|
+
[0x03, 100.0],
|
|
45
|
+
[0x04, 200.0],
|
|
46
|
+
[0x05, 400.0],
|
|
47
|
+
[0x06, 400.0],
|
|
48
|
+
[0x07, 400.0],
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
// Register map (6-bit addresses).
|
|
52
|
+
const REG_DEVID_AD = 0x00;
|
|
53
|
+
const REG_DEVID_MST = 0x01;
|
|
54
|
+
const REG_PARTID = 0x02;
|
|
55
|
+
const REG_XDATA = 0x08;
|
|
56
|
+
const REG_YDATA = 0x09;
|
|
57
|
+
const REG_ZDATA = 0x0A;
|
|
58
|
+
const REG_STATUS = 0x0B;
|
|
59
|
+
const REG_FIFO_ENTRIES_L = 0x0C;
|
|
60
|
+
const REG_FIFO_ENTRIES_H = 0x0D;
|
|
61
|
+
const REG_XDATA_L = 0x0E;
|
|
62
|
+
const REG_XDATA_H = 0x0F;
|
|
63
|
+
const REG_YDATA_L = 0x10;
|
|
64
|
+
const REG_YDATA_H = 0x11;
|
|
65
|
+
const REG_ZDATA_L = 0x12;
|
|
66
|
+
const REG_ZDATA_H = 0x13;
|
|
67
|
+
const REG_TEMP_L = 0x14;
|
|
68
|
+
const REG_TEMP_H = 0x15;
|
|
69
|
+
const REG_SOFT_RESET = 0x1F;
|
|
70
|
+
const REG_THRESH_ACT_L = 0x20;
|
|
71
|
+
const REG_THRESH_ACT_H = 0x21;
|
|
72
|
+
const REG_TIME_ACT = 0x22;
|
|
73
|
+
const REG_THRESH_INACT_L = 0x23;
|
|
74
|
+
const REG_THRESH_INACT_H = 0x24;
|
|
75
|
+
const REG_TIME_INACT_L = 0x25;
|
|
76
|
+
const REG_TIME_INACT_H = 0x26;
|
|
77
|
+
const REG_ACT_INACT_CTL = 0x27;
|
|
78
|
+
const REG_FIFO_CONTROL = 0x28;
|
|
79
|
+
const REG_FIFO_SAMPLES = 0x29;
|
|
80
|
+
const REG_INTMAP1 = 0x2A;
|
|
81
|
+
const REG_INTMAP2 = 0x2B;
|
|
82
|
+
const REG_FILTER_CTL = 0x2C;
|
|
83
|
+
const REG_POWER_CTL = 0x2D;
|
|
84
|
+
const REG_SELF_TEST = 0x2E;
|
|
85
|
+
|
|
86
|
+
const DEVID_AD_VALUE = 0xAD;
|
|
87
|
+
const DEVID_MST_VALUE = 0x1D;
|
|
88
|
+
const PARTID_VALUE = 0xF2;
|
|
89
|
+
|
|
90
|
+
// FILTER_CTL reset value: RANGE=±2 g, HALF_BW=1, ODR=100 Hz.
|
|
91
|
+
const FILTER_CTL_DEFAULT = 0x13;
|
|
92
|
+
// POWER_CTL measurement-mode value: MEASURE=10.
|
|
93
|
+
const POWER_CTL_MEASURE = 0x02;
|
|
94
|
+
|
|
95
|
+
const STATUS_AWAKE = 0x40;
|
|
96
|
+
const STATUS_DATA_READY = 0x01;
|
|
97
|
+
|
|
98
|
+
function _delayMs(ms) {
|
|
99
|
+
return new Promise(r => setTimeout(r, ms));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function _signExtend12(v) {
|
|
103
|
+
v &= 0x0FFF;
|
|
104
|
+
return (v & 0x0800) ? (v - 0x1000) : v;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* ADXL362 minimal driver — read X, Y, Z acceleration in *g*.
|
|
109
|
+
*
|
|
110
|
+
* Performs the chip's full power-up sequence at construction: verifies
|
|
111
|
+
* DEVID_AD=0xAD, DEVID_MST=0x1D, PARTID=0xF2; writes the reset FILTER_CTL
|
|
112
|
+
* and switches POWER_CTL into measurement mode.
|
|
113
|
+
*/
|
|
114
|
+
class ADXL362Minimal {
|
|
115
|
+
/**
|
|
116
|
+
* @param {object} connection - Configured SPI connection bound to the device.
|
|
117
|
+
*/
|
|
118
|
+
constructor(connection) {
|
|
119
|
+
this._connection = connection;
|
|
120
|
+
this._rangeBits = 0x00; // ±2 g default
|
|
121
|
+
this._odrHz = 100.0;
|
|
122
|
+
this._init();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Run the chip's full power-up sequence.
|
|
127
|
+
*
|
|
128
|
+
* Verifies DEVID_AD=0xAD, DEVID_MST=0x1D, PARTID=0xF2; writes the
|
|
129
|
+
* reset FILTER_CTL and switches POWER_CTL into measurement mode.
|
|
130
|
+
*
|
|
131
|
+
* @returns {Promise<void>}
|
|
132
|
+
*/
|
|
133
|
+
async init() {
|
|
134
|
+
await _delayMs(5); // power-up to standby turn-on time
|
|
135
|
+
const ids = await this._readBurst(REG_DEVID_AD, 3);
|
|
136
|
+
if (ids[0] !== DEVID_AD_VALUE) {
|
|
137
|
+
throw new Error(`ADXL362 DEVID_AD: expected 0xAD, got 0x${ids[0].toString(16)}`);
|
|
138
|
+
}
|
|
139
|
+
if (ids[1] !== DEVID_MST_VALUE) {
|
|
140
|
+
throw new Error(`ADXL362 DEVID_MST: expected 0x1D, got 0x${ids[1].toString(16)}`);
|
|
141
|
+
}
|
|
142
|
+
if (ids[2] !== PARTID_VALUE) {
|
|
143
|
+
throw new Error(`ADXL362 PARTID: expected 0xF2, got 0x${ids[2].toString(16)}`);
|
|
144
|
+
}
|
|
145
|
+
await this._writeReg(REG_FILTER_CTL, FILTER_CTL_DEFAULT);
|
|
146
|
+
await this._writeReg(REG_POWER_CTL, POWER_CTL_MEASURE);
|
|
147
|
+
await _delayMs(40); // 4/ODR at 100 Hz
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async _readBurst(reg, n) {
|
|
151
|
+
return this._connection.writeRead(Buffer.from([CMD_READ_REG, reg & 0x3F]), n);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async _readFifo(n) {
|
|
155
|
+
return this._connection.writeRead(Buffer.from([CMD_READ_FIFO]), n);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async _writeReg(reg, value) {
|
|
159
|
+
await this._connection.write(Buffer.from([CMD_WRITE_REG, reg & 0x3F, value & 0xFF]));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async _readReg(reg) {
|
|
163
|
+
const out = await this._readBurst(reg, 1);
|
|
164
|
+
return out[0];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_sensitivity() {
|
|
168
|
+
if (this._rangeBits === 0x40) return SENSITIVITY_G_PER_LSB[1];
|
|
169
|
+
if (this._rangeBits === 0x80 || this._rangeBits === 0xC0) return SENSITIVITY_G_PER_LSB[2];
|
|
170
|
+
return SENSITIVITY_G_PER_LSB[0];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Read 3-axis linear acceleration.
|
|
175
|
+
*
|
|
176
|
+
* Burst-reads the 12-bit XDATA_L/H, YDATA_L/H, ZDATA_L/H sextet so
|
|
177
|
+
* the three samples come from a single measurement.
|
|
178
|
+
*
|
|
179
|
+
* @returns {Promise<{x:number, y:number, z:number}>} Acceleration in *g*.
|
|
180
|
+
*/
|
|
181
|
+
async read() {
|
|
182
|
+
const raw = await this._readBurst(REG_XDATA_L, 6);
|
|
183
|
+
const rx = _signExtend12(((raw[1] & 0x0F) << 8) | raw[0]);
|
|
184
|
+
const ry = _signExtend12(((raw[3] & 0x0F) << 8) | raw[2]);
|
|
185
|
+
const rz = _signExtend12(((raw[5] & 0x0F) << 8) | raw[4]);
|
|
186
|
+
const sens = this._sensitivity();
|
|
187
|
+
return { x: rx * sens, y: ry * sens, z: rz * sens };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Mixin that adds Full-stage functionality on top of `ADXL362Minimal`.
|
|
193
|
+
*
|
|
194
|
+
* Usage: `class ADXL362Full extends _ADXL362FullMixin(ADXL362Minimal) {}`.
|
|
195
|
+
*/
|
|
196
|
+
const _ADXL362FullMixin = (Base) => class extends Base {
|
|
197
|
+
/**
|
|
198
|
+
* Return raw device-ID bytes (DEVID_AD, DEVID_MST, PARTID, REVID).
|
|
199
|
+
* @returns {Promise<{devidAd:number, devidMst:number, partid:number, revid:number}>}
|
|
200
|
+
*/
|
|
201
|
+
async deviceId() {
|
|
202
|
+
const ids = await this._readBurst(REG_DEVID_AD, 4);
|
|
203
|
+
return { devidAd: ids[0], devidMst: ids[1], partid: ids[2], revid: ids[3] };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Soft-reset the chip (writes 0x52 to SOFT_RESET, waits ≥0.5 ms).
|
|
208
|
+
* @returns {Promise<void>}
|
|
209
|
+
*/
|
|
210
|
+
async softReset() {
|
|
211
|
+
await this._writeReg(REG_SOFT_RESET, SOFT_RESET_KEY);
|
|
212
|
+
await _delayMs(1);
|
|
213
|
+
this._rangeBits = 0x00;
|
|
214
|
+
this._odrHz = 100.0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Set the measurement range to ±2/±4/±8 g.
|
|
219
|
+
* @param {number} rangeG - 2, 4, or 8.
|
|
220
|
+
* @returns {Promise<void>}
|
|
221
|
+
*/
|
|
222
|
+
async setRange(rangeG) {
|
|
223
|
+
let code = 0;
|
|
224
|
+
if (rangeG === 2) code = 0x00;
|
|
225
|
+
else if (rangeG === 4) code = 0x40;
|
|
226
|
+
else if (rangeG === 8) code = 0x80;
|
|
227
|
+
else throw new RangeError('rangeG must be one of 2, 4, 8');
|
|
228
|
+
const f = await this._readReg(REG_FILTER_CTL);
|
|
229
|
+
await this._writeReg(REG_FILTER_CTL, (f & 0x3F) | (code & 0xC0));
|
|
230
|
+
this._rangeBits = code;
|
|
231
|
+
if (this._odrHz > 0) {
|
|
232
|
+
await _delayMs(1000.0 / this._odrHz + 1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Set the output data rate to the nearest supported value (12.5–400 Hz).
|
|
238
|
+
* @param {number} odrHz - Requested ODR in Hz.
|
|
239
|
+
* @returns {Promise<void>}
|
|
240
|
+
*/
|
|
241
|
+
async setOdr(odrHz) {
|
|
242
|
+
let bestCode = ODR_CODES[0][0];
|
|
243
|
+
let bestRate = ODR_CODES[0][1];
|
|
244
|
+
let bestDiff = Math.abs(bestRate - odrHz);
|
|
245
|
+
for (const [code, rate] of ODR_CODES) {
|
|
246
|
+
const d = Math.abs(rate - odrHz);
|
|
247
|
+
if (d < bestDiff) {
|
|
248
|
+
bestCode = code; bestRate = rate; bestDiff = d;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const f = await this._readReg(REG_FILTER_CTL);
|
|
252
|
+
await this._writeReg(REG_FILTER_CTL, (f & 0xF8) | (bestCode & 0x07));
|
|
253
|
+
this._odrHz = bestRate;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Set FILTER_CTL.HALF_BW (antialiasing bandwidth = ODR/4 or ODR/2).
|
|
258
|
+
* @param {boolean} enabled
|
|
259
|
+
* @returns {Promise<void>}
|
|
260
|
+
*/
|
|
261
|
+
async setHalfBandwidth(enabled) {
|
|
262
|
+
const f = await this._readReg(REG_FILTER_CTL);
|
|
263
|
+
await this._writeReg(REG_FILTER_CTL, enabled ? (f | 0x10) : (f & ~0x10));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Set POWER_CTL.LOW_NOISE (0=normal, 1=low, 2=ultralow noise).
|
|
268
|
+
* @param {number} mode - 0, 1, or 2.
|
|
269
|
+
* @returns {Promise<void>}
|
|
270
|
+
*/
|
|
271
|
+
async setNoiseMode(mode) {
|
|
272
|
+
if (mode !== 0 && mode !== 1 && mode !== 2) {
|
|
273
|
+
throw new RangeError('mode must be 0 (normal), 1 (low), or 2 (ultralow)');
|
|
274
|
+
}
|
|
275
|
+
const p = await this._readReg(REG_POWER_CTL);
|
|
276
|
+
await this._writeReg(REG_POWER_CTL, (p & 0xCF) | ((mode << 4) & 0x30));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Set POWER_CTL.WAKEUP (270 nA idle mode).
|
|
281
|
+
* @param {boolean} enabled
|
|
282
|
+
* @returns {Promise<void>}
|
|
283
|
+
*/
|
|
284
|
+
async setWakeupMode(enabled) {
|
|
285
|
+
const p = await this._readReg(REG_POWER_CTL);
|
|
286
|
+
await this._writeReg(REG_POWER_CTL, enabled ? (p | 0x08) : (p & ~0x08));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Set POWER_CTL.AUTOSLEEP; effective only in linked/loop mode.
|
|
291
|
+
* @param {boolean} enabled
|
|
292
|
+
* @returns {Promise<void>}
|
|
293
|
+
*/
|
|
294
|
+
async setAutosleep(enabled) {
|
|
295
|
+
const p = await this._readReg(REG_POWER_CTL);
|
|
296
|
+
await this._writeReg(REG_POWER_CTL, enabled ? (p | 0x04) : (p & ~0x04));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Set POWER_CTL.EXT_CLK; INT1 is repurposed as clock input.
|
|
301
|
+
* @param {boolean} enabled
|
|
302
|
+
* @returns {Promise<void>}
|
|
303
|
+
*/
|
|
304
|
+
async setExternalClock(enabled) {
|
|
305
|
+
const p = await this._readReg(REG_POWER_CTL);
|
|
306
|
+
await this._writeReg(REG_POWER_CTL, enabled ? (p | 0x40) : (p & ~0x40));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Set FILTER_CTL.EXT_SAMPLE; INT2 is repurposed as sync trigger input.
|
|
311
|
+
* @param {boolean} enabled
|
|
312
|
+
* @returns {Promise<void>}
|
|
313
|
+
*/
|
|
314
|
+
async setExternalSampleTrigger(enabled) {
|
|
315
|
+
const f = await this._readReg(REG_FILTER_CTL);
|
|
316
|
+
await this._writeReg(REG_FILTER_CTL, enabled ? (f | 0x08) : (f & ~0x08));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Read 3-axis acceleration using the 8-bit XDATA/YDATA/ZDATA registers.
|
|
321
|
+
* @returns {Promise<{x:number, y:number, z:number}>} Acceleration in *g*, ~16-LSB resolution.
|
|
322
|
+
*/
|
|
323
|
+
async read8bit() {
|
|
324
|
+
const raw = await this._readBurst(REG_XDATA, 3);
|
|
325
|
+
const s8 = v => (v & 0x80) ? (v - 256) : v;
|
|
326
|
+
const sens = this._sensitivity() * 16;
|
|
327
|
+
return { x: s8(raw[0]) * sens, y: s8(raw[1]) * sens, z: s8(raw[2]) * sens };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Read the on-chip temperature sensor (typical bias/sensitivity).
|
|
332
|
+
* @returns {Promise<number>} Temperature in °C.
|
|
333
|
+
*/
|
|
334
|
+
async temperature() {
|
|
335
|
+
const raw = await this._readBurst(REG_TEMP_L, 2);
|
|
336
|
+
const raw12 = _signExtend12(((raw[1] & 0x0F) << 8) | raw[0]);
|
|
337
|
+
return 25.0 + (raw12 - 350) * 0.065;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Read the raw STATUS register byte.
|
|
342
|
+
* @returns {Promise<number>}
|
|
343
|
+
*/
|
|
344
|
+
async status() {
|
|
345
|
+
return await this._readReg(REG_STATUS);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Return STATUS.AWAKE.
|
|
350
|
+
* @returns {Promise<boolean>}
|
|
351
|
+
*/
|
|
352
|
+
async awake() {
|
|
353
|
+
return (await this.status()) & STATUS_AWAKE ? true : false;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Return STATUS.DATA_READY.
|
|
358
|
+
* @returns {Promise<boolean>}
|
|
359
|
+
*/
|
|
360
|
+
async dataReady() {
|
|
361
|
+
return (await this.status()) & STATUS_DATA_READY ? true : false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Return the 10-bit FIFO entry count (0–512).
|
|
366
|
+
* @returns {Promise<number>}
|
|
367
|
+
*/
|
|
368
|
+
async fifoEntries() {
|
|
369
|
+
const lo = await this._readReg(REG_FIFO_ENTRIES_L);
|
|
370
|
+
const hi = await this._readReg(REG_FIFO_ENTRIES_H);
|
|
371
|
+
return lo | ((hi & 0x03) << 8);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Configure the FIFO mode, optional temperature storage, and watermark.
|
|
376
|
+
* @param {number} mode - 0=disabled, 1=oldest saved, 2=stream, 3=triggered.
|
|
377
|
+
* @param {boolean} [storeTemp=false]
|
|
378
|
+
* @param {number} [watermark=128] - 9-bit watermark (0–511).
|
|
379
|
+
* @returns {Promise<void>}
|
|
380
|
+
*/
|
|
381
|
+
async configureFifo(mode, storeTemp = false, watermark = 128) {
|
|
382
|
+
if (mode < 0 || mode > 3) throw new RangeError('mode must be 0/1/2/3');
|
|
383
|
+
if (watermark < 0 || watermark > 0x1FF) throw new RangeError('watermark must be 0–511');
|
|
384
|
+
const fc = (mode & 0x03) | (((watermark >> 8) & 0x01) << 3) | (storeTemp ? 0x04 : 0x00);
|
|
385
|
+
await this._writeReg(REG_FIFO_CONTROL, fc);
|
|
386
|
+
await this._writeReg(REG_FIFO_SAMPLES, watermark & 0xFF);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Read all available FIFO entries.
|
|
391
|
+
*
|
|
392
|
+
* Each 16-bit entry's top two bits encode the axis (0=X, 1=Y,
|
|
393
|
+
* 2=Z, 3=temperature); the low 12 bits are signed axis/temperature
|
|
394
|
+
* data, scaled with the current range.
|
|
395
|
+
*
|
|
396
|
+
* @returns {Promise<Array<{axis:number, value:number}>>}
|
|
397
|
+
*/
|
|
398
|
+
async readFifo() {
|
|
399
|
+
const n = await this.fifoEntries();
|
|
400
|
+
if (n === 0) return [];
|
|
401
|
+
const raw = await this._readFifo(n * 2);
|
|
402
|
+
const sens = this._sensitivity();
|
|
403
|
+
const out = [];
|
|
404
|
+
for (let i = 0; i < n; i++) {
|
|
405
|
+
const lo = raw[2 * i];
|
|
406
|
+
const hi = raw[2 * i + 1];
|
|
407
|
+
const raw16 = (hi << 8) | lo;
|
|
408
|
+
const axis = (raw16 >> 14) & 0x03;
|
|
409
|
+
const raw12 = _signExtend12(raw16 & 0x0FFF);
|
|
410
|
+
const value = (axis === 3) ? 25.0 + (raw12 - 350) * 0.065 : raw12 * sens;
|
|
411
|
+
out.push({ axis, value });
|
|
412
|
+
}
|
|
413
|
+
return out;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Set the activity threshold in *g* (clamped to 10-bit range).
|
|
418
|
+
* @param {number} thresholdG
|
|
419
|
+
* @param {boolean} [referenced=false]
|
|
420
|
+
* @returns {Promise<void>}
|
|
421
|
+
*/
|
|
422
|
+
async setActivityThreshold(thresholdG, referenced = false) {
|
|
423
|
+
let raw = Math.round(thresholdG / this._sensitivity());
|
|
424
|
+
if (raw < 0) raw = 0;
|
|
425
|
+
if (raw > 0x3FF) raw = 0x3FF;
|
|
426
|
+
await this._writeReg(REG_THRESH_ACT_L, raw & 0xFF);
|
|
427
|
+
await this._writeReg(REG_THRESH_ACT_H, (raw >> 8) & 0x03);
|
|
428
|
+
const aic = await this._readReg(REG_ACT_INACT_CTL);
|
|
429
|
+
await this._writeReg(REG_ACT_INACT_CTL, referenced ? (aic | 0x02) : (aic & ~0x02));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Set the activity-time filter (0–255 samples).
|
|
434
|
+
* @param {number} samples
|
|
435
|
+
* @returns {Promise<void>}
|
|
436
|
+
*/
|
|
437
|
+
async setActivityTime(samples) {
|
|
438
|
+
if (samples < 0 || samples > 0xFF) throw new RangeError('samples must be 0–255');
|
|
439
|
+
await this._writeReg(REG_TIME_ACT, samples & 0xFF);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Set the inactivity threshold in *g* (clamped to 10-bit range).
|
|
444
|
+
* @param {number} thresholdG
|
|
445
|
+
* @param {boolean} [referenced=false]
|
|
446
|
+
* @returns {Promise<void>}
|
|
447
|
+
*/
|
|
448
|
+
async setInactivityThreshold(thresholdG, referenced = false) {
|
|
449
|
+
let raw = Math.round(thresholdG / this._sensitivity());
|
|
450
|
+
if (raw < 0) raw = 0;
|
|
451
|
+
if (raw > 0x3FF) raw = 0x3FF;
|
|
452
|
+
await this._writeReg(REG_THRESH_INACT_L, raw & 0xFF);
|
|
453
|
+
await this._writeReg(REG_THRESH_INACT_H, (raw >> 8) & 0x03);
|
|
454
|
+
const aic = await this._readReg(REG_ACT_INACT_CTL);
|
|
455
|
+
await this._writeReg(REG_ACT_INACT_CTL, referenced ? (aic | 0x08) : (aic & ~0x08));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Set the inactivity-time filter (0–65535 samples).
|
|
460
|
+
* @param {number} samples
|
|
461
|
+
* @returns {Promise<void>}
|
|
462
|
+
*/
|
|
463
|
+
async setInactivityTime(samples) {
|
|
464
|
+
if (samples < 0 || samples > 0xFFFF) throw new RangeError('samples must be 0–65535');
|
|
465
|
+
await this._writeReg(REG_TIME_INACT_L, samples & 0xFF);
|
|
466
|
+
await this._writeReg(REG_TIME_INACT_H, (samples >> 8) & 0xFF);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Set ACT_INACT_CTL.ACT_EN.
|
|
471
|
+
* @param {boolean} enabled
|
|
472
|
+
* @returns {Promise<void>}
|
|
473
|
+
*/
|
|
474
|
+
async enableActivityDetection(enabled) {
|
|
475
|
+
const aic = await this._readReg(REG_ACT_INACT_CTL);
|
|
476
|
+
await this._writeReg(REG_ACT_INACT_CTL, enabled ? (aic | 0x01) : (aic & ~0x01));
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Set ACT_INACT_CTL.INACT_EN.
|
|
481
|
+
* @param {boolean} enabled
|
|
482
|
+
* @returns {Promise<void>}
|
|
483
|
+
*/
|
|
484
|
+
async enableInactivityDetection(enabled) {
|
|
485
|
+
const aic = await this._readReg(REG_ACT_INACT_CTL);
|
|
486
|
+
await this._writeReg(REG_ACT_INACT_CTL, enabled ? (aic | 0x04) : (aic & ~0x04));
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Set ACT_INACT_CTL.LINKLOOP (0=default, 1=linked, 3=loop).
|
|
491
|
+
* @param {number} mode
|
|
492
|
+
* @returns {Promise<void>}
|
|
493
|
+
*/
|
|
494
|
+
async setLinkLoopMode(mode) {
|
|
495
|
+
if (mode !== 0 && mode !== 1 && mode !== 3) {
|
|
496
|
+
throw new RangeError('mode must be 0 (default), 1 (linked), or 3 (loop)');
|
|
497
|
+
}
|
|
498
|
+
const aic = await this._readReg(REG_ACT_INACT_CTL);
|
|
499
|
+
await this._writeReg(REG_ACT_INACT_CTL, (aic & 0xCF) | ((mode << 4) & 0x30));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
static _INTMAP_BIT(source) {
|
|
503
|
+
switch (source) {
|
|
504
|
+
case 0: return 0x01; // SOURCE_DATA_READY
|
|
505
|
+
case 1: return 0x02; // SOURCE_FIFO_READY
|
|
506
|
+
case 2: return 0x04; // SOURCE_FIFO_WATERMARK
|
|
507
|
+
case 3: return 0x08; // SOURCE_FIFO_OVERRUN
|
|
508
|
+
case 4: return 0x10; // SOURCE_ACT
|
|
509
|
+
case 5: return 0x20; // SOURCE_INACT
|
|
510
|
+
case 6: return 0x40; // SOURCE_AWAKE
|
|
511
|
+
default: throw new RangeError('invalid source');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Map one interrupt source to the named INT pin.
|
|
517
|
+
* @param {number} pin - 1 or 2.
|
|
518
|
+
* @param {number} source - One of SOURCE_* (0–6).
|
|
519
|
+
* @param {boolean} enabled
|
|
520
|
+
* @returns {Promise<void>}
|
|
521
|
+
*/
|
|
522
|
+
async setInterrupt(pin, source, enabled) {
|
|
523
|
+
if (pin !== 1 && pin !== 2) throw new RangeError('pin must be 1 or 2');
|
|
524
|
+
const reg = (pin === 1) ? REG_INTMAP1 : REG_INTMAP2;
|
|
525
|
+
const cur = await this._readReg(reg);
|
|
526
|
+
const bit = this.constructor._INTMAP_BIT(source);
|
|
527
|
+
await this._writeReg(reg, enabled ? (cur | bit) : (cur & ~bit));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Set the active-low polarity for one INT pin.
|
|
532
|
+
* @param {number} pin - 1 or 2.
|
|
533
|
+
* @param {boolean} activeLow
|
|
534
|
+
* @returns {Promise<void>}
|
|
535
|
+
*/
|
|
536
|
+
async setInterruptPolarity(pin, activeLow) {
|
|
537
|
+
if (pin !== 1 && pin !== 2) throw new RangeError('pin must be 1 or 2');
|
|
538
|
+
const reg = (pin === 1) ? REG_INTMAP1 : REG_INTMAP2;
|
|
539
|
+
const cur = await this._readReg(reg);
|
|
540
|
+
await this._writeReg(reg, activeLow ? (cur | 0x80) : (cur & ~0x80));
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Enable or disable the electrostatic self-test force on all axes.
|
|
545
|
+
* @param {boolean} enabled
|
|
546
|
+
* @returns {Promise<void>}
|
|
547
|
+
*/
|
|
548
|
+
async selfTest(enabled) {
|
|
549
|
+
const st = await this._readReg(REG_SELF_TEST);
|
|
550
|
+
await this._writeReg(REG_SELF_TEST, enabled ? (st | 0x01) : (st & ~0x01));
|
|
551
|
+
if (enabled && this._odrHz > 0) {
|
|
552
|
+
await _delayMs(4000.0 / this._odrHz + 1);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* ADXL362 full driver — extends Minimal with the full chip API.
|
|
559
|
+
*/
|
|
560
|
+
class ADXL362Full extends _ADXL362FullMixin(ADXL362Minimal) {
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// Interrupt source constants (used by setInterrupt).
|
|
564
|
+
ADXL362Full.SOURCE_DATA_READY = 0;
|
|
565
|
+
ADXL362Full.SOURCE_FIFO_READY = 1;
|
|
566
|
+
ADXL362Full.SOURCE_FIFO_WATERMARK = 2;
|
|
567
|
+
ADXL362Full.SOURCE_FIFO_OVERRUN = 3;
|
|
568
|
+
ADXL362Full.SOURCE_ACT = 4;
|
|
569
|
+
ADXL362Full.SOURCE_INACT = 5;
|
|
570
|
+
ADXL362Full.SOURCE_AWAKE = 6;
|
|
571
|
+
|
|
572
|
+
// Noise mode constants (POWER_CTL.LOW_NOISE[5:4]).
|
|
573
|
+
ADXL362Full.NOISE_NORMAL = 0;
|
|
574
|
+
ADXL362Full.NOISE_LOW = 1;
|
|
575
|
+
ADXL362Full.NOISE_ULTRALOW = 2;
|
|
576
|
+
|
|
577
|
+
// Link/loop mode constants (ACT_INACT_CTL.LINKLOOP[5:4]).
|
|
578
|
+
ADXL362Full.LINKLOOP_DEFAULT = 0;
|
|
579
|
+
ADXL362Full.LINKLOOP_LINKED = 1;
|
|
580
|
+
ADXL362Full.LINKLOOP_LOOP = 3;
|
|
581
|
+
|
|
582
|
+
// FIFO mode constants (FIFO_CONTROL.FIFO_MODE[1:0]).
|
|
583
|
+
ADXL362Full.FIFO_DISABLED = 0;
|
|
584
|
+
ADXL362Full.FIFO_OLDEST_SAVED = 1;
|
|
585
|
+
ADXL362Full.FIFO_STREAM = 2;
|
|
586
|
+
ADXL362Full.FIFO_TRIGGERED = 3;
|
|
587
|
+
|
|
588
|
+
// FIFO entry-axis constants (top 2 bits of each 16-bit FIFO entry).
|
|
589
|
+
ADXL362Full.AXIS_X = 0;
|
|
590
|
+
ADXL362Full.AXIS_Y = 1;
|
|
591
|
+
ADXL362Full.AXIS_Z = 2;
|
|
592
|
+
ADXL362Full.AXIS_TEMP = 3;
|
|
593
|
+
|
|
594
|
+
module.exports = { ADXL362Minimal, ADXL362Full };
|