All parts / ADXL345
ADXL345 register map
3-axis MEMS accelerometer with tap, activity and free-fall detection — Analog Devices
30 registers
I2C, SPI
I²C 0x53, 0x1D
8-bit reg addresses
86% bit coverage
not yet human-verified
I²C address conflict. On its default address(es) this part collides with
PCA9685 (0x53). You cannot put them on the same bus without changing a strap pin, using an I²C multiplexer, or moving one to a second bus.
See the full address map.
Get it as a C header
pip install regforge
regforge gen ADXL345 --out ./src --driver --tests
Writes adxl345_regs.h with every address, mask and shift below, a bus-agnostic driver skeleton, and a file of compile-time assertions that make your compiler check the bit arithmetic. No API key needed — this part ships inside the package.
Not yet human-verified. Transcribed and mechanically validated — no overlapping fields, no out-of-range bits, reset values consistent with their fields — but not yet checked line-by-line against the datasheet.
Verifying it is a useful half hour.
Registers
| Addr | Register | Access | Width | Reset | Description |
| 0x00 | DEVID | RO | 8 | 0xE5 | Device ID. Always reads 0xE5. |
| 0x1D | THRESH_TAP | RW | 8 | — | Tap threshold, 62.5 mg per LSB |
| 0x1E | OFSX | RW | 8 | — | X-axis offset, two's complement, 15.6 mg per LSB |
| 0x1F | OFSY | RW | 8 | — | Y-axis offset, two's complement, 15.6 mg per LSB |
| 0x20 | OFSZ | RW | 8 | — | Z-axis offset, two's complement, 15.6 mg per LSB |
| 0x21 | DUR | RW | 8 | — | Maximum tap duration, 625 us per LSB |
| 0x22 | LATENT | RW | 8 | — | Tap latency, 1.25 ms per LSB |
| 0x23 | WINDOW | RW | 8 | — | Double-tap window, 1.25 ms per LSB |
| 0x24 | THRESH_ACT | RW | 8 | — | Activity threshold, 62.5 mg per LSB |
| 0x25 | THRESH_INACT | RW | 8 | — | Inactivity threshold, 62.5 mg per LSB |
| 0x26 | TIME_INACT | RW | 8 | — | Inactivity time, 1 s per LSB |
| 0x27 | ACT_INACT_CTL | RW | 8 | 0x00 | Axis enables for activity and inactivity detection |
| 0x28 | THRESH_FF | RW | 8 | — | Free-fall threshold, 62.5 mg per LSB |
| 0x29 | TIME_FF | RW | 8 | — | Free-fall time, 5 ms per LSB |
| 0x2A | TAP_AXES | RW | 8 | 0x00 | Axis enables for tap detection |
| 0x2B | ACT_TAP_STATUS | RO | 8 | 0x00 | Which axis was involved in the most recent event |
| 0x2C | BW_RATE | RW | 8 | 0x0A | Output data rate and low-power mode |
| 0x2D | POWER_CTL | RW | 8 | 0x00 | Power-saving control. Measure is clear at reset, so the part boots in standby and produces no data until you set it. |
| 0x2E | INT_ENABLE | RW | 8 | 0x00 | Interrupt enables |
| 0x2F | INT_MAP | RW | 8 | 0x00 | Interrupt routing. 0 sends the event to INT1, 1 sends it to INT2. |
| 0x30 | INT_SOURCE | RO | 8 | 0x02 | Which interrupts are asserted. Reading clears most of them. |
| 0x31 | DATA_FORMAT | RW | 8 | 0x00 | Data presentation. FULL_RES changes how the 13-bit result is aligned, which is the usual cause of scaling that looks wrong by a factor of 2. |
| 0x32 | DATAX0 | RO | 8 | — | X-axis measurement, low byte |
| 0x33 | DATAX1 | RO | 8 | — | X-axis measurement, high byte |
| 0x34 | DATAY0 | RO | 8 | — | Y-axis measurement, low byte |
| 0x35 | DATAY1 | RO | 8 | — | Y-axis measurement, high byte |
| 0x36 | DATAZ0 | RO | 8 | — | Z-axis measurement, low byte |
| 0x37 | DATAZ1 | RO | 8 | — | Z-axis measurement, high byte |
| 0x38 | FIFO_CTL | RW | 8 | 0x00 | FIFO mode and watermark |
| 0x39 | FIFO_STATUS | RO | 8 | 0x00 | FIFO fill level |
Bit layouts
Drawn MSB-first, the way the datasheet draws them. [7:5] means shift 5, width 3, mask 0xE0 — this is the notation that costs people a day when they read it backwards.
ACT_INACT_CTL @ 0x27 — 8 fields
ACT_AC_DC[7]
ACT_X_EN[6]
ACT_Y_EN[5]
ACT_Z_EN[4]
INACT_AC_DC[3]
INACT_X_EN[2]
INACT_Y_EN[1]
INACT_Z_EN[0]
| Bits | Field | Access | Mask | Reset | Description |
| [7] | ACT_AC_DC | RW | 0x80 | 0x00 | Activity: 0 = dc-coupled, 1 = ac-coupled |
| [6] | ACT_X_EN | RW | 0x40 | 0x00 | Enable X for activity |
| [5] | ACT_Y_EN | RW | 0x20 | 0x00 | Enable Y for activity |
| [4] | ACT_Z_EN | RW | 0x10 | 0x00 | Enable Z for activity |
| [3] | INACT_AC_DC | RW | 0x08 | 0x00 | Inactivity: 0 = dc-coupled, 1 = ac-coupled |
| [2] | INACT_X_EN | RW | 0x04 | 0x00 | Enable X for inactivity |
| [1] | INACT_Y_EN | RW | 0x02 | 0x00 | Enable Y for inactivity |
| [0] | INACT_Z_EN | RW | 0x01 | 0x00 | Enable Z for inactivity |
TAP_AXES @ 0x2A — 4 fields
—7
—6
—5
—4
SUPPRESS[3]
TAP_X_EN[2]
TAP_Y_EN[1]
TAP_Z_EN[0]
| Bits | Field | Access | Mask | Reset | Description |
| [3] | SUPPRESS | RW | 0x08 | 0x00 | Suppress double tap if a spike occurs during latency |
| [2] | TAP_X_EN | RW | 0x04 | 0x00 | Enable X for tap |
| [1] | TAP_Y_EN | RW | 0x02 | 0x00 | Enable Y for tap |
| [0] | TAP_Z_EN | RW | 0x01 | 0x00 | Enable Z for tap |
ACT_TAP_STATUS @ 0x2B — 7 fields
—7
ACT_X_SRC[6]
ACT_Y_SRC[5]
ACT_Z_SRC[4]
ASLEEP[3]
TAP_X_SRC[2]
TAP_Y_SRC[1]
TAP_Z_SRC[0]
| Bits | Field | Access | Mask | Reset | Description |
| [6] | ACT_X_SRC | RO | 0x40 | 0x00 | X involved in activity |
| [5] | ACT_Y_SRC | RO | 0x20 | 0x00 | Y involved in activity |
| [4] | ACT_Z_SRC | RO | 0x10 | 0x00 | Z involved in activity |
| [3] | ASLEEP | RO | 0x08 | 0x00 | Device is in sleep mode |
| [2] | TAP_X_SRC | RO | 0x04 | 0x00 | X involved in tap |
| [1] | TAP_Y_SRC | RO | 0x02 | 0x00 | Y involved in tap |
| [0] | TAP_Z_SRC | RO | 0x01 | 0x00 | Z involved in tap |
BW_RATE @ 0x2C — 2 fields
—7
—6
—5
LOW_POWER[4]
RATE[3:0]
| Bits | Field | Access | Mask | Reset | Description |
| [4] | LOW_POWER | RW | 0x10 | 0x00 | Reduced power at the cost of higher noise |
| [3:0] | RATE | RW | 0x0F | 0x0A | Output data rate |
BW_RATE.RATE values
| Value | Name | Meaning |
| 0x00 | HZ_0_10 | 0.10 Hz |
| 0x01 | HZ_0_20 | 0.20 Hz |
| 0x02 | HZ_0_39 | 0.39 Hz |
| 0x03 | HZ_0_78 | 0.78 Hz |
| 0x04 | HZ_1_56 | 1.56 Hz |
| 0x05 | HZ_3_13 | 3.13 Hz |
| 0x06 | HZ_6_25 | 6.25 Hz |
| 0x07 | HZ_12_5 | 12.5 Hz |
| 0x08 | HZ_25 | 25 Hz |
| 0x09 | HZ_50 | 50 Hz |
| 0x0A | HZ_100 | 100 Hz (default) |
| 0x0B | HZ_200 | 200 Hz |
| 0x0C | HZ_400 | 400 Hz |
| 0x0D | HZ_800 | 800 Hz |
| 0x0E | HZ_1600 | 1600 Hz |
| 0x0F | HZ_3200 | 3200 Hz |
POWER_CTL @ 0x2D — 5 fields
—7
—6
LINK[5]
AUTO_SLEEP[4]
MEASURE[3]
SLEEP[2]
WAKEUP[1:0]
| Bits | Field | Access | Mask | Reset | Description |
| [5] | LINK | RW | 0x20 | 0x00 | Serially link activity and inactivity detection |
| [4] | AUTO_SLEEP | RW | 0x10 | 0x00 | Enter sleep automatically on inactivity |
| [3] | MEASURE | RW | 0x08 | 0x00 | 0 = standby, 1 = measurement. Set this to start. |
| [2] | SLEEP | RW | 0x04 | 0x00 | Put the part into sleep mode |
| [1:0] | WAKEUP | RW | 0x03 | 0x00 | Reading rate in sleep mode |
POWER_CTL.WAKEUP values
| Value | Name | Meaning |
| 0x00 | HZ_8 | 8 Hz |
| 0x01 | HZ_4 | 4 Hz |
| 0x02 | HZ_2 | 2 Hz |
| 0x03 | HZ_1 | 1 Hz |
INT_ENABLE @ 0x2E — 8 fields
DATA_READY[7]
SINGLE_TAP[6]
DOUBLE_TAP[5]
ACTIVITY[4]
INACTIVITY[3]
FREE_FALL[2]
WATERMARK[1]
OVERRUN[0]
| Bits | Field | Access | Mask | Reset | Description |
| [7] | DATA_READY | RW | 0x80 | 0x00 | Data ready |
| [6] | SINGLE_TAP | RW | 0x40 | 0x00 | Single tap |
| [5] | DOUBLE_TAP | RW | 0x20 | 0x00 | Double tap |
| [4] | ACTIVITY | RW | 0x10 | 0x00 | Activity |
| [3] | INACTIVITY | RW | 0x08 | 0x00 | Inactivity |
| [2] | FREE_FALL | RW | 0x04 | 0x00 | Free fall |
| [1] | WATERMARK | RW | 0x02 | 0x00 | FIFO watermark |
| [0] | OVERRUN | RW | 0x01 | 0x00 | FIFO overrun |
INT_MAP @ 0x2F — 8 fields
DATA_READY[7]
SINGLE_TAP[6]
DOUBLE_TAP[5]
ACTIVITY[4]
INACTIVITY[3]
FREE_FALL[2]
WATERMARK[1]
OVERRUN[0]
| Bits | Field | Access | Mask | Reset | Description |
| [7] | DATA_READY | RW | 0x80 | 0x00 | Route data ready |
| [6] | SINGLE_TAP | RW | 0x40 | 0x00 | Route single tap |
| [5] | DOUBLE_TAP | RW | 0x20 | 0x00 | Route double tap |
| [4] | ACTIVITY | RW | 0x10 | 0x00 | Route activity |
| [3] | INACTIVITY | RW | 0x08 | 0x00 | Route inactivity |
| [2] | FREE_FALL | RW | 0x04 | 0x00 | Route free fall |
| [1] | WATERMARK | RW | 0x02 | 0x00 | Route FIFO watermark |
| [0] | OVERRUN | RW | 0x01 | 0x00 | Route FIFO overrun |
INT_SOURCE @ 0x30 — 8 fields
DATA_READY[7]
SINGLE_TAP[6]
DOUBLE_TAP[5]
ACTIVITY[4]
INACTIVITY[3]
FREE_FALL[2]
WATERMARK[1]
OVERRUN[0]
| Bits | Field | Access | Mask | Reset | Description |
| [7] | DATA_READY | RO | 0x80 | 0x00 | Data ready |
| [6] | SINGLE_TAP | RO | 0x40 | 0x00 | Single tap |
| [5] | DOUBLE_TAP | RO | 0x20 | 0x00 | Double tap |
| [4] | ACTIVITY | RO | 0x10 | 0x00 | Activity |
| [3] | INACTIVITY | RO | 0x08 | 0x00 | Inactivity |
| [2] | FREE_FALL | RO | 0x04 | 0x00 | Free fall |
| [1] | WATERMARK | RO | 0x02 | 0x01 | FIFO watermark |
| [0] | OVERRUN | RO | 0x01 | 0x00 | FIFO overrun |
DATA_FORMAT @ 0x31 — 6 fields
SELF_TEST[7]
SPI[6]
INT_INVERT[5]
—4
FULL_RES[3]
JUSTIFY[2]
RANGE[1:0]
| Bits | Field | Access | Mask | Reset | Description |
| [7] | SELF_TEST | RW | 0x80 | 0x00 | Apply a self-test force to the sensor |
| [6] | SPI | RW | 0x40 | 0x00 | 0 = 4-wire SPI, 1 = 3-wire SPI |
| [5] | INT_INVERT | RW | 0x20 | 0x00 | 0 = interrupts active high, 1 = active low |
| [3] | FULL_RES | RW | 0x08 | 0x00 | 1 = full resolution, 4 mg per LSB at every range. 0 = fixed 10-bit. |
| [2] | JUSTIFY | RW | 0x04 | 0x00 | 1 = left-justified (MSB) mode |
| [1:0] | RANGE | RW | 0x03 | 0x00 | g range |
DATA_FORMAT.RANGE values
| Value | Name | Meaning |
| 0x00 | G_2 | +/-2 g (default) |
| 0x01 | G_4 | +/-4 g |
| 0x02 | G_8 | +/-8 g |
| 0x03 | G_16 | +/-16 g |
FIFO_CTL @ 0x38 — 3 fields
FIFO_MODE[7:6]
TRIGGER[5]
SAMPLES[4:0]
| Bits | Field | Access | Mask | Reset | Description |
| [7:6] | FIFO_MODE | RW | 0xC0 | 0x00 | FIFO mode |
| [5] | TRIGGER | RW | 0x20 | 0x00 | 0 = trigger on INT1, 1 = trigger on INT2 |
| [4:0] | SAMPLES | RW | 0x1F | 0x00 | Watermark sample count |
FIFO_CTL.FIFO_MODE values
| Value | Name | Meaning |
| 0x00 | BYPASS | FIFO bypassed (default) |
| 0x01 | FIFO | Collect until full, then stop |
| 0x02 | STREAM | Keep the most recent 32 samples |
| 0x03 | TRIGGER | Hold samples around a trigger event |
FIFO_STATUS @ 0x39 — 2 fields
FIFO_TRIG[7]
—6
ENTRIES[5:0]
| Bits | Field | Access | Mask | Reset | Description |
| [7] | FIFO_TRIG | RO | 0x80 | 0x00 | A trigger event has occurred |
| [5:0] | ENTRIES | RO | 0x3F | 0x00 | Number of samples in the FIFO |
Generated C header
What regforge gen ADXL345 writes for ACT_INACT_CTL:
/* ------------------------------------------------------------------------ */
/* ACT_INACT_CTL @ 0x27u rw 8-bit reset 0x00u */
/* Axis enables for activity and inactivity detection */
/* ------------------------------------------------------------------------ */
#define ADXL345_ACT_INACT_CTL 0x27u
#define ADXL345_ACT_INACT_CTL_WIDTH 8u
#define ADXL345_ACT_INACT_CTL_RESET 0x00u
/* ACT_AC_DC bits [7] rw reset 0x00u -- Activity: 0 = dc-coupled, 1 = ac-coupled */
#define ADXL345_ACT_INACT_CTL_ACT_AC_DC_SHIFT 7u
#define ADXL345_ACT_INACT_CTL_ACT_AC_DC_WIDTH 1u
#define ADXL345_ACT_INACT_CTL_ACT_AC_DC_MASK 0x80u
#define ADXL345_ACT_INACT_CTL_ACT_AC_DC_GET(reg) (((uint8_t)(reg) & 0x80u) >> 7u)
#define ADXL345_ACT_INACT_CTL_ACT_AC_DC_SET(reg, val) (((uint8_t)(reg) & (uint8_t)~0x80u) | (((uint8_t)(val) << 7u) & 0x80u))
/* ACT_X_EN bits [6] rw reset 0x00u -- Enable X for activity */
#define ADXL345_ACT_INACT_CTL_ACT_X_EN_SHIFT 6u
#define ADXL345_ACT_INACT_CTL_ACT_X_EN_WIDTH 1u
#define ADXL345_ACT_INACT_CTL_ACT_X_EN_MASK 0x40u
#define ADXL345_ACT_INACT_CTL_ACT_X_EN_GET(reg) (((uint8_t)(reg) & 0x40u) >> 6u)
#define ADXL345_ACT_INACT_CTL_ACT_X_EN_SET(reg, val) (((uint8_t)(reg) & (uint8_t)~0x40u) | (((uint8_t)(val) << 6u) & 0x40u))
/* ACT_Y_EN bits [5] rw reset 0x00u -- Enable Y for activity */
#define ADXL345_ACT_INACT_CTL_ACT_Y_EN_SHIFT 5u
#define ADXL345_ACT_INACT_CTL_ACT_Y_EN_WIDTH 1u
#define ADXL345_ACT_INACT_CTL_ACT_Y_EN_MASK 0x20u
#define ADXL345_ACT_INACT_CTL_ACT_Y_EN_GET(reg) (((uint8_t)(reg) & 0x20u) >> 5u)
#define ADXL345_ACT_INACT_CTL_ACT_Y_EN_SET(reg, val) (((uint8_t)(reg) & (uint8_t)~0x20u) | (((uint8_t)(val) << 5u) & 0x20u))
/* ACT_Z_EN bits [4] rw reset 0x00u -- Enable Z for activity */
#define ADXL345_ACT_INACT_CTL_ACT_Z_EN_SHIFT 4u
#define ADXL345_ACT_INACT_CTL_ACT_Z_EN_WIDTH 1u
#define ADXL345_ACT_INACT_CTL_ACT_Z_EN_MASK 0x10u
#define ADXL345_ACT_INACT_CTL_ACT_Z_EN_GET(reg) (((uint8_t)(reg) & 0x10u) >> 4u)
#define ADXL345_ACT_INACT_CTL_ACT_Z_EN_SET(reg, val) (((uint8_t)(reg) & (uint8_t)~0x10u) | (((uint8_t)(val) << 4u) & 0x10u))
/* INACT_AC_DC bits [3] rw reset 0x00u -- Inactivity: 0 = dc-coupled, 1 = ac-coupled */
#define ADXL345_ACT_INACT_CTL_INACT_AC_DC_SHIFT 3u
#define ADXL345_ACT_INACT_CTL_INACT_AC_DC_WIDTH 1u
#define ADXL345_ACT_INACT_CTL_INACT_AC_DC_MASK 0x08u
#define ADXL345_ACT_INACT_CTL_INACT_AC_DC_GET(reg) (((uint8_t)(reg) & 0x08u) >> 3u)
#define ADXL345_ACT_INACT_CTL_INACT_AC_DC_SET(reg, val) (((uint8_t)(reg) & (uint8_t)~0x08u) | (((uint8_t)(val) << 3u) & 0x08u))
Compared with
Related parts
Source
Transcribed from Analog Devices ADXL345 datasheet (hand-transcribed) (hand-transcribed). Hand-authored seed entry, not machine-extracted. Check against Analog Devices ADXL345 datasheet before trusting it, then mark it verified.
Raw JSON · Report an error