43 #define CHIP_NAME "Analog Devices ADXL345"
44 #define MANUFACTURER_NAME "Analog Devices"
45 #define SUPPLY_VOLTAGE_MIN 2.0f
46 #define SUPPLY_VOLTAGE_MAX 3.6f
47 #define MAX_CURRENT 0.14f
48 #define TEMPERATURE_MIN -40.0f
49 #define TEMPERATURE_MAX 85.0f
50 #define DRIVER_VERSION 2000
55 #define ADXL345_REG_DEVID 0x00
56 #define ADXL345_REG_THRESH_TAP 0x1D
57 #define ADXL345_REG_OFSX 0x1E
58 #define ADXL345_REG_OFSY 0x1F
59 #define ADXL345_REG_OFSZ 0x20
60 #define ADXL345_REG_DUR 0x21
61 #define ADXL345_REG_LATENT 0x22
62 #define ADXL345_REG_WINDOW 0x23
63 #define ADXL345_REG_THRESH_ACT 0x24
64 #define ADXL345_REG_THRESH_INACT 0x25
65 #define ADXL345_REG_TIME_INACT 0x26
66 #define ADXL345_REG_ACT_INACT_CTL 0x27
67 #define ADXL345_REG_THRESH_FF 0x28
68 #define ADXL345_REG_TIME_FF 0x29
69 #define ADXL345_REG_TAP_AXES 0x2A
70 #define ADXL345_REG_ACT_TAP_STATUS 0x2B
71 #define ADXL345_REG_BW_RATE 0x2C
72 #define ADXL345_REG_POWER_CTL 0x2D
73 #define ADXL345_REG_INT_ENABLE 0x2E
74 #define ADXL345_REG_INT_MAP 0x2F
75 #define ADXL345_REG_INT_SOURCE 0x30
76 #define ADXL345_REG_DATA_FORMAT 0x31
77 #define ADXL345_REG_DATAX0 0x32
78 #define ADXL345_REG_DATAX1 0x33
79 #define ADXL345_REG_DATAY0 0x34
80 #define ADXL345_REG_DATAY1 0x35
81 #define ADXL345_REG_DATAZ0 0x36
82 #define ADXL345_REG_DATAZ1 0x37
83 #define ADXL345_REG_FIFO_CTL 0x38
84 #define ADXL345_REG_FIFO_STATUS 0x39
97 static uint8_t a_adxl345_iic_spi_read(
adxl345_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
118 if (handle->
spi_read(reg, buf, len) != 0)
140 static uint8_t a_adxl345_iic_spi_write(
adxl345_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
160 if (handle->
spi_write(reg, buf, len) != 0)
187 handle->
iic_spi = (uint8_t)interface;
229 handle->
iic_addr = (uint8_t)addr_pin;
327 *reg = (uint8_t)(g / 0.0625f);
354 *g = (float)(reg) * 0.0625f;
483 *reg = (int8_t)(g / 0.0156f);
510 *g = (float)(reg) * 0.0156f;
587 *reg = (uint8_t)(us / 625);
614 *us = (uint32_t)((
float)(reg) * 625.0f);
691 *reg = (uint8_t)(ms / 1.25f);
718 *ms = (float)(reg) * 1.25f;
795 *reg = (uint8_t)(ms / 1.25f);
822 *ms = (float)(reg) * 1.25f;
899 *reg = (uint8_t)(g / 0.0625f);
926 *g = (float)(reg) * 0.0625f;
1003 *reg = (uint8_t)(g / 0.0625f);
1030 *g = (float)(reg) * 0.0625f;
1171 prev &= ~(1 << type);
1172 prev |= (enable << type);
1209 prev &= (1 << type);
1247 prev |= (coupled << 7);
1321 prev |= (coupled << 3);
1435 *reg = (uint8_t)(g / 0.0625f);
1462 *g = (float)(reg) * 0.0625f;
1539 *reg = (uint8_t)(ms / 5);
1603 prev &= ~(1 << axis);
1604 prev |= enable << axis;
1641 prev &= (1 << axis);
1679 prev |= enable << 3;
1852 prev &= ~(1 << type);
1853 prev |= enable << type;
1890 prev &= (1 << type);
1928 prev &= ~(1 << type);
1929 prev |= pin << type;
1966 prev &= (1 << type);
2029 prev |= (enable << 7);
2103 prev |= (wire << 6);
2177 prev |= (active_level << 5);
2251 prev |= (enable << 3);
2325 prev |= (enable << 2);
2399 prev |= (range << 0);
2473 prev |= (mode << 6);
2621 prev |= (level & 0x1F);
2658 *level = prev & 0x1F;
2695 *level = prev & 0x3F;
2769 prev |= enable << 5;
2843 prev |= enable << 4;
2917 prev |= enable << 3;
2991 prev |= enable << 2;
3065 prev |= sleep_frequency;
3121 handle->
debug_print(
"adxl345: iic deinit failed.\n");
3134 handle->
debug_print(
"adxl345: spi deinit failed.\n");
3170 handle->
debug_print(
"adxl345: iic_init is null.\n");
3176 handle->
debug_print(
"adxl345: iic_deinit is null.\n");
3182 handle->
debug_print(
"adxl345: iic_read is null.\n");
3188 handle->
debug_print(
"adxl345: iic_write is null.\n");
3194 handle->
debug_print(
"adxl345: spi_init is null.\n");
3200 handle->
debug_print(
"adxl345: spi_deinit is null.\n");
3206 handle->
debug_print(
"adxl345: spi_read is null.\n");
3212 handle->
debug_print(
"adxl345: spi_write is null.\n");
3218 handle->
debug_print(
"adxl345: delay_ms is null.\n");
3224 handle->
debug_print(
"adxl345: receive_callback is null.\n");
3233 handle->
debug_print(
"adxl345: iic init failed.\n");
3242 handle->
debug_print(
"adxl345: spi init failed.\n");
3250 (void)a_adxl345_close(handle);
3257 (void)a_adxl345_close(handle);
3308 res = a_adxl345_close(handle);
3338 uint8_t mode, cnt, i;
3339 uint8_t justify, full_res, range;
3340 uint8_t buf[32 * 6];
3353 handle->
debug_print(
"adxl345: length is zero.\n");
3372 full_res = (prev >> 3) & 0x01;
3373 justify = (prev >> 2) & 0x01;
3374 range = prev & 0x03;
3385 raw[0][0] = (int16_t)(buf[1] << 8) | buf[0];
3386 raw[0][1] = (int16_t)(buf[3] << 8) | buf[2];
3387 raw[0][2] = (int16_t)(buf[5] << 8) | buf[4];
3394 if ((raw[0][0] & (1 << 15)) != 0)
3396 raw[0][0] = ((uint16_t)0xFC << 8) | ((raw[0][0] >> 6) & 0x3FF);
3400 raw[0][0] = (raw[0][0] >> 6) & 0x3FF;
3402 if ((raw[0][1] & (1 << 15)) != 0)
3404 raw[0][1] = ((uint16_t)0xFC << 8) | ((raw[0][1] >> 6) & 0x3FF);
3408 raw[0][1] = (raw[0][1] >> 6) & 0x3FF;
3410 if ((raw[0][2] & (1 << 15)) != 0)
3412 raw[0][2] = ((uint16_t)0xFC << 8) | ((raw[0][2] >> 6) & 0x3FF);
3416 raw[0][2] = (raw[0][2] >> 6) & 0x3FF;
3419 else if (range == 0x01)
3421 if ((raw[0][0] & (1 << 15)) != 0)
3423 raw[0][0] = ((uint16_t)0xF3 << 8) | ((raw[0][0] >> 5) & 0x7FF);
3427 raw[0][0] = (raw[0][0] >> 5) & 0x7FF;
3429 if ((raw[0][1] & (1 << 15)) != 0)
3431 raw[0][1] = ((uint16_t)0xF3 << 8) | ((raw[0][1] >> 5) & 0x7FF);
3435 raw[0][1] = (raw[0][1] >> 5) & 0x7FF;
3437 if ((raw[0][2] & (1 << 15)) != 0)
3439 raw[0][2] = ((uint16_t)0xF3 << 8) | ((raw[0][2] >> 5) & 0x7FF);
3443 raw[0][2] = (raw[0][2] >> 5) & 0x7FF;
3446 else if (range == 0x02)
3448 if ((raw[0][0] & (1 << 15)) != 0)
3450 raw[0][0] = ((uint16_t)0xF0 << 8) | ((raw[0][0] >> 4) & 0xFFF);
3454 raw[0][0] = (raw[0][0] >> 4) & 0xFFF;
3456 if ((raw[0][1] & (1 << 15)) != 0)
3458 raw[0][1] = ((uint16_t)0xF0 << 8) | ((raw[0][1] >> 4) & 0xFFF);
3462 raw[0][1] = (raw[0][1] >> 4) & 0xFFF;
3464 if ((raw[0][2] & (1 << 15)) != 0)
3466 raw[0][2] = ((uint16_t)0xF0 << 8) | ((raw[0][2] >> 4) & 0xFFF);
3470 raw[0][2] = (raw[0][2] >> 4) & 0xFFF;
3475 if ((raw[0][0] & (1 << 15)) != 0)
3477 raw[0][0] = ((uint16_t)0xE0 << 8) | ((raw[0][0] >> 3) & 0x1FFF);
3481 raw[0][0] = (raw[0][0] >> 3) & 0x1FFF;
3483 if ((raw[0][1] & (1 << 15)) != 0)
3485 raw[0][1] = ((uint16_t)0xE0 << 8) | ((raw[0][1] >> 3) & 0x1FFF);
3489 raw[0][1] = (raw[0][1] >> 3) & 0x1FFF;
3491 if ((raw[0][2] & (1 << 15)) != 0)
3493 raw[0][2] = ((uint16_t)0xE0 << 8) | ((raw[0][2] >> 3) & 0x1FFF);
3497 raw[0][2] = (raw[0][2] >> 3) & 0x1FFF;
3501 g[0][0] = (float)(raw[0][0]) * 0.0039f;
3502 g[0][1] = (float)(raw[0][1]) * 0.0039f;
3503 g[0][2] = (float)(raw[0][2]) * 0.0039f;
3509 if ((raw[0][0] & (1 << 15)) != 0)
3511 raw[0][0] = ((uint16_t)0xFC << 8) | ((raw[0][0] >> 6) & 0x3FF);
3515 raw[0][0] = (raw[0][0] >> 6) & 0x3FF;
3517 if ((raw[0][1] & (1 << 15)) != 0)
3519 raw[0][1] = ((uint16_t)0xFC << 8) | ((raw[0][1] >> 6) & 0x3FF);
3523 raw[0][1] = (raw[0][1] >> 6) & 0x3FF;
3525 if ((raw[0][2] & (1 << 15)) != 0)
3527 raw[0][2] = ((uint16_t)0xFC << 8) | ((raw[0][2] >> 6) & 0x3FF);
3531 raw[0][2] = (raw[0][2] >> 6) & 0x3FF;
3536 g[0][0] = (float)(raw[0][0]) * 0.0039f;
3537 g[0][1] = (float)(raw[0][1]) * 0.0039f;
3538 g[0][2] = (float)(raw[0][2]) * 0.0039f;
3540 else if (range == 0x01)
3542 g[0][0] = (float)(raw[0][0]) * 0.0078f;
3543 g[0][1] = (float)(raw[0][1]) * 0.0078f;
3544 g[0][2] = (float)(raw[0][2]) * 0.0078f;
3546 else if (range == 0x02)
3548 g[0][0] = (float)(raw[0][0]) * 0.0156f;
3549 g[0][1] = (float)(raw[0][1]) * 0.0156f;
3550 g[0][2] = (float)(raw[0][2]) * 0.0156f;
3554 g[0][0] = (float)(raw[0][0]) * 0.0312f;
3555 g[0][1] = (float)(raw[0][1]) * 0.0312f;
3556 g[0][2] = (float)(raw[0][2]) * 0.0312f;
3570 *len = ((*len) < cnt) ? (*len) : cnt;
3578 for (i = 0; i < (*len); i++)
3580 raw[i][0] = (int16_t)(buf[1 + i * 6] << 8) | buf[0 + i * 6];
3581 raw[i][1] = (int16_t)(buf[3 + i * 6] << 8) | buf[2 + i * 6];
3582 raw[i][2] = (int16_t)(buf[5 + i * 6] << 8) | buf[4 + i * 6];
3589 if ((raw[i][0] & (1 << 15)) != 0)
3591 raw[i][0] = ((uint16_t)0xFC << 8) | ((raw[i][0] >> 6) & 0x3FF);
3595 raw[i][0] = (raw[i][0] >> 6) & 0x3FF;
3597 if ((raw[i][1] & (1 << 15)) != 0)
3599 raw[i][1] = ((uint16_t)0xFC << 8) | ((raw[i][1] >> 6) & 0x3FF);
3603 raw[i][1] = (raw[i][1] >> 6) & 0x3FF;
3605 if ((raw[i][2] & (1 << 15)) != 0)
3607 raw[i][2] = ((uint16_t)0xFC << 8) | ((raw[i][2] >> 6) & 0x3FF);
3611 raw[i][2] = (raw[i][2] >> 6) & 0x3FF;
3614 else if (range == 0x01)
3616 if ((raw[i][0] & (1 << 15)) != 0)
3618 raw[i][0] = ((uint16_t)0xF3 << 8) | ((raw[i][0] >> 5) & 0x7FF);
3622 raw[i][0] = (raw[i][0] >> 5) & 0x7FF;
3624 if ((raw[i][1] & (1 << 15)) != 0)
3626 raw[i][1] = ((uint16_t)0xF3 << 8) | ((raw[i][1] >> 5) & 0x7FF);
3630 raw[i][1] = (raw[i][1] >> 5) & 0x7FF;
3632 if ((raw[i][2] & (1 << 15)) != 0)
3634 raw[i][2] = ((uint16_t)0xF3 << 8) | ((raw[i][2] >> 5) & 0x7FF);
3638 raw[i][2] = (raw[i][2] >> 5) & 0x7FF;
3641 else if (range == 0x02)
3643 if ((raw[i][0] & (1 << 15)) != 0)
3645 raw[i][0] = ((uint16_t)0xF0 << 8) | ((raw[i][0] >> 4) & 0xFFF);
3649 raw[i][0] = (raw[i][0] >> 4) & 0xFFF;
3651 if ((raw[i][1] & (1 << 15)) != 0)
3653 raw[i][1] = ((uint16_t)0xF0 << 8) | ((raw[i][1] >> 4) & 0xFFF);
3657 raw[i][1] = (raw[i][1] >> 4) & 0xFFF;
3659 if ((raw[i][2] & (1 << 15)) != 0)
3661 raw[i][2] = ((uint16_t)0xF0 << 8) | ((raw[i][2] >> 4) & 0xFFF);
3665 raw[i][2] = (raw[i][2] >> 4) & 0xFFF;
3670 if ((raw[i][0] & (1 << 15)) != 0)
3672 raw[i][0] = ((uint16_t)0xE0 << 8) | ((raw[i][0] >> 3) & 0x1FFF);
3676 raw[i][0] = (raw[i][0] >> 3) & 0x1FFF;
3678 if ((raw[i][1] & (1 << 15)) != 0)
3680 raw[i][1] = ((uint16_t)0xE0 << 8) | ((raw[i][1] >> 3) & 0x1FFF);
3684 raw[i][1] = (raw[i][1] >> 3) & 0x1FFF;
3686 if ((raw[i][2] & (1 << 15)) != 0)
3688 raw[i][2] = ((uint16_t)0xE0 << 8) | ((raw[i][2] >> 3) & 0x1FFF);
3692 raw[i][2] = (raw[i][2] >> 3) & 0x1FFF;
3696 g[i][0] = (float)(raw[i][0])*0.0039f;
3697 g[i][1] = (float)(raw[i][1])*0.0039f;
3698 g[i][2] = (float)(raw[i][2])*0.0039f;
3704 if ((raw[i][0] & (1 << 15)) != 0)
3706 raw[i][0] = ((uint16_t)0xFC << 8) | ((raw[i][0] >> 6) & 0x3FF);
3710 raw[i][0] = (raw[i][0] >> 6) & 0x3FF;
3712 if ((raw[i][1] & (1 << 15)) != 0)
3714 raw[i][1] = ((uint16_t)0xFC << 8) | ((raw[i][1] >> 6) & 0x3FF);
3718 raw[i][1] = (raw[i][1] >> 6) & 0x3FF;
3720 if ((raw[i][2] & (1 << 15)) != 0)
3722 raw[i][2] = ((uint16_t)0xFC << 8) | ((raw[i][2] >> 6) & 0x3FF);
3726 raw[i][2] = (raw[i][2] >> 6) & 0x3FF;
3731 g[i][0] = (float)(raw[i][0]) * 0.0039f;
3732 g[i][1] = (float)(raw[i][1]) * 0.0039f;
3733 g[i][2] = (float)(raw[i][2]) * 0.0039f;
3735 else if (range == 0x01)
3737 g[i][0] = (float)(raw[i][0]) * 0.0078f;
3738 g[i][1] = (float)(raw[i][1]) * 0.0078f;
3739 g[i][2] = (float)(raw[i][2]) * 0.0078f;
3741 else if (range == 0x02)
3743 g[i][0] = (float)(raw[i][0]) * 0.0156f;
3744 g[i][1] = (float)(raw[i][1]) * 0.0156f;
3745 g[i][2] = (float)(raw[i][2]) * 0.0156f;
3749 g[i][0] = (float)(raw[i][0]) * 0.0312f;
3750 g[i][1] = (float)(raw[i][1]) * 0.0312f;
3751 g[i][2] = (float)(raw[i][2]) * 0.0312f;
3874 return a_adxl345_iic_spi_write(handle, reg, buf, len);
3901 return a_adxl345_iic_spi_read(handle, reg, buf, len);
#define ADXL345_REG_THRESH_FF
#define ADXL345_REG_TAP_AXES
#define ADXL345_REG_ACT_TAP_STATUS
#define ADXL345_REG_DEVID
chip register definition
#define ADXL345_REG_THRESH_TAP
#define ADXL345_REG_BW_RATE
#define ADXL345_REG_DATA_FORMAT
#define ADXL345_REG_TIME_FF
#define SUPPLY_VOLTAGE_MAX
#define ADXL345_REG_FIFO_CTL
#define ADXL345_REG_THRESH_INACT
#define ADXL345_REG_INT_MAP
#define ADXL345_REG_LATENT
#define ADXL345_REG_FIFO_STATUS
#define ADXL345_REG_INT_SOURCE
#define ADXL345_REG_POWER_CTL
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define ADXL345_REG_WINDOW
#define ADXL345_REG_TIME_INACT
#define ADXL345_REG_DATAX0
#define CHIP_NAME
chip register definition
#define ADXL345_REG_INT_ENABLE
#define ADXL345_REG_ACT_INACT_CTL
#define ADXL345_REG_THRESH_ACT
driver adxl345 header file
adxl345_interface_t
adxl345 interface enumeration definition
uint8_t adxl345_inaction_time_convert_to_register(adxl345_handle_t *handle, uint8_t s, uint8_t *reg)
convert the inaction time to the register raw data
uint8_t adxl345_get_justify(adxl345_handle_t *handle, adxl345_justify_t *enable)
get the justify status
adxl345_spi_wire_t
adxl345 spi wire enumeration definition
uint8_t adxl345_get_action_coupled(adxl345_handle_t *handle, adxl345_coupled_t *coupled)
get the action coupled
uint8_t adxl345_get_link_activity_inactivity(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the activity and inactivity linking status
uint8_t adxl345_duration_convert_to_register(adxl345_handle_t *handle, uint32_t us, uint8_t *reg)
convert the duration to the register raw data
uint8_t adxl345_inaction_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the inaction threshold to the register raw data
uint8_t adxl345_get_auto_sleep(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the auto sleep status
uint8_t adxl345_set_full_resolution(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the full resolution
uint8_t adxl345_set_inaction_time(adxl345_handle_t *handle, uint8_t t)
set the inaction time
uint8_t adxl345_duration_convert_to_data(adxl345_handle_t *handle, uint8_t reg, uint32_t *us)
convert the register raw data to the duration
adxl345_justify_t
adxl345 justify enumeration definition
uint8_t adxl345_get_tap_threshold(adxl345_handle_t *handle, uint8_t *threshold)
get the tap threshold
uint8_t adxl345_deinit(adxl345_handle_t *handle)
close the chip
uint8_t adxl345_set_inaction_coupled(adxl345_handle_t *handle, adxl345_coupled_t coupled)
set the inaction coupled
uint8_t adxl345_get_tap_axis(adxl345_handle_t *handle, adxl345_tap_axis_t axis, adxl345_bool_t *enable)
get the tap axis status
adxl345_action_inaction_t
adxl345 action inaction enumeration definition
uint8_t adxl345_get_trigger_pin(adxl345_handle_t *handle, adxl345_interrupt_pin_t *pin)
get the trigger pin
uint8_t adxl345_inaction_threshold_convert_to_data(adxl345_handle_t *handle, uint8_t reg, float *g)
convert the register raw data to the inaction threshold
uint8_t adxl345_set_spi_wire(adxl345_handle_t *handle, adxl345_spi_wire_t wire)
set the chip spi wire
uint8_t adxl345_set_measure(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the measure
uint8_t adxl345_set_trigger_pin(adxl345_handle_t *handle, adxl345_interrupt_pin_t pin)
set the trigger pin
uint8_t adxl345_get_full_resolution(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the full resolution status
uint8_t adxl345_irq_handler(adxl345_handle_t *handle)
irq handler
uint8_t adxl345_set_link_activity_inactivity(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the activity and inactivity linking
uint8_t adxl345_get_free_fall_time(adxl345_handle_t *handle, uint8_t *t)
get the free fall time
uint8_t adxl345_free_fall_time_convert_to_data(adxl345_handle_t *handle, uint8_t reg, uint16_t *ms)
convert the register raw data to the free fall time
uint8_t adxl345_get_sleep_frequency(adxl345_handle_t *handle, adxl345_sleep_frequency_t *sleep_frequency)
get the sleep frequency
uint8_t adxl345_get_sleep(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the sleep mode status
uint8_t adxl345_get_mode(adxl345_handle_t *handle, adxl345_mode_t *mode)
get the chip mode
uint8_t adxl345_set_action_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the action threshold
uint8_t adxl345_get_offset(adxl345_handle_t *handle, int8_t *x, int8_t *y, int8_t *z)
get the axis offset
uint8_t adxl345_get_free_fall_threshold(adxl345_handle_t *handle, uint8_t *threshold)
get the free fall threshold
uint8_t adxl345_set_free_fall_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the free fall threshold
uint8_t adxl345_set_sleep(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the sleep mode
uint8_t adxl345_get_interface(adxl345_handle_t *handle, adxl345_interface_t *interface)
get the chip interface
uint8_t adxl345_get_window(adxl345_handle_t *handle, uint8_t *t)
get the window
adxl345_trigger_status_t
adxl345 trigger status enumeration definition
uint8_t adxl345_read(adxl345_handle_t *handle, int16_t(*raw)[3], float(*g)[3], uint16_t *len)
read the data
uint8_t adxl345_get_duration(adxl345_handle_t *handle, uint8_t *t)
get the duration
uint8_t adxl345_action_threshold_convert_to_data(adxl345_handle_t *handle, uint8_t reg, float *g)
convert the register raw data to the action threshold
uint8_t adxl345_get_latent(adxl345_handle_t *handle, uint8_t *t)
get the latent
uint8_t adxl345_set_offset(adxl345_handle_t *handle, int8_t x, int8_t y, int8_t z)
set the axis offset
uint8_t adxl345_set_latent(adxl345_handle_t *handle, uint8_t t)
set the latent
uint8_t adxl345_set_rate(adxl345_handle_t *handle, adxl345_rate_t rate)
set the sampling rate
uint8_t adxl345_set_inaction_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the inaction threshold
uint8_t adxl345_get_inaction_time(adxl345_handle_t *handle, uint8_t *t)
get the inaction time
uint8_t adxl345_set_addr_pin(adxl345_handle_t *handle, adxl345_address_t addr_pin)
set the iic address pin
uint8_t adxl345_get_range(adxl345_handle_t *handle, adxl345_range_t *range)
get the chip range
uint8_t adxl345_set_self_test(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the self test
uint8_t adxl345_tap_threshold_convert_to_data(adxl345_handle_t *handle, uint8_t reg, float *g)
convert the register raw data to the tap threshold
uint8_t adxl345_free_fall_time_convert_to_register(adxl345_handle_t *handle, uint16_t ms, uint8_t *reg)
convert the free fall time to the register raw data
uint8_t adxl345_get_measure(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the measure status
adxl345_range_t
adxl345 range enumeration definition
uint8_t adxl345_get_action_inaction(adxl345_handle_t *handle, adxl345_action_inaction_t type, adxl345_bool_t *enable)
get the action or inaction status
uint8_t adxl345_get_spi_wire(adxl345_handle_t *handle, adxl345_spi_wire_t *wire)
get the chip spi wire
uint8_t adxl345_get_rate(adxl345_handle_t *handle, adxl345_rate_t *rate)
get the sampling rate
uint8_t adxl345_set_action_inaction(adxl345_handle_t *handle, adxl345_action_inaction_t type, adxl345_bool_t enable)
enable or disable the action or inaction
uint8_t adxl345_free_fall_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the free fall threshold to the register raw data
uint8_t adxl345_window_convert_to_register(adxl345_handle_t *handle, float ms, uint8_t *reg)
convert the window time to the register raw data
uint8_t adxl345_get_trigger_status(adxl345_handle_t *handle, adxl345_trigger_status_t *status)
get the trigger status
uint8_t adxl345_set_duration(adxl345_handle_t *handle, uint8_t t)
set the duration
uint8_t adxl345_tap_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the tap threshold to the register raw data
uint8_t adxl345_set_tap_suppress(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the tap suppress
uint8_t adxl345_set_auto_sleep(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the auto sleep
uint8_t adxl345_get_addr_pin(adxl345_handle_t *handle, adxl345_address_t *addr_pin)
get the iic address pin
uint8_t adxl345_set_tap_axis(adxl345_handle_t *handle, adxl345_tap_axis_t axis, adxl345_bool_t enable)
enable or disable the tap axis
adxl345_rate_t
adxl345 rate enumeration definition
uint8_t adxl345_set_free_fall_time(adxl345_handle_t *handle, uint8_t t)
set the free fall time
uint8_t adxl345_get_inaction_coupled(adxl345_handle_t *handle, adxl345_coupled_t *coupled)
get the inaction coupled
uint8_t adxl345_set_window(adxl345_handle_t *handle, uint8_t t)
set the window
uint8_t adxl345_action_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the action threshold to the register raw data
uint8_t adxl345_set_sleep_frequency(adxl345_handle_t *handle, adxl345_sleep_frequency_t sleep_frequency)
set the sleep frequency
adxl345_address_t
adxl345 address enumeration definition
uint8_t adxl345_latent_convert_to_register(adxl345_handle_t *handle, float ms, uint8_t *reg)
convert the latent to the register raw data
adxl345_tap_axis_t
adxl345 tap axis enumeration definition
uint8_t adxl345_offset_convert_to_register(adxl345_handle_t *handle, float g, int8_t *reg)
convert the offset to the register raw data
uint8_t adxl345_init(adxl345_handle_t *handle)
initialize the chip
adxl345_coupled_t
adxl345 coupled enumeration definition
uint8_t adxl345_inaction_time_convert_to_data(adxl345_handle_t *handle, uint8_t reg, uint8_t *s)
convert the register raw data to the inaction time
uint8_t adxl345_window_convert_to_data(adxl345_handle_t *handle, uint8_t reg, float *ms)
convert the register raw data to the window time
uint8_t adxl345_set_action_coupled(adxl345_handle_t *handle, adxl345_coupled_t coupled)
set the action coupled
adxl345_bool_t
adxl345 bool enumeration definition
uint8_t adxl345_get_inaction_threshold(adxl345_handle_t *handle, uint8_t *threshold)
get the inaction threshold
uint8_t adxl345_get_tap_status(adxl345_handle_t *handle, uint8_t *status)
get the tap status
uint8_t adxl345_get_self_test(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the self test status
uint8_t adxl345_set_justify(adxl345_handle_t *handle, adxl345_justify_t enable)
enable or disable the justify
uint8_t adxl345_set_interface(adxl345_handle_t *handle, adxl345_interface_t interface)
set the chip interface
uint8_t adxl345_get_action_threshold(adxl345_handle_t *handle, uint8_t *threshold)
get the action threshold
uint8_t adxl345_set_mode(adxl345_handle_t *handle, adxl345_mode_t mode)
set the chip mode
uint8_t adxl345_latent_convert_to_data(adxl345_handle_t *handle, uint8_t reg, float *ms)
convert the register raw data to the latent
uint8_t adxl345_get_tap_suppress(adxl345_handle_t *handle, adxl345_bool_t *enable)
get the tap suppress status
adxl345_sleep_frequency_t
adxl345 sleep frequency enumeration definition
uint8_t adxl345_offset_convert_to_data(adxl345_handle_t *handle, int8_t reg, float *g)
convert the register raw data to the offset
adxl345_mode_t
adxl345 mode enumeration definition
uint8_t adxl345_info(adxl345_info_t *info)
get chip's information
uint8_t adxl345_set_tap_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the tap threshold
uint8_t adxl345_set_range(adxl345_handle_t *handle, adxl345_range_t range)
set the chip range
uint8_t adxl345_free_fall_threshold_convert_to_data(adxl345_handle_t *handle, uint8_t reg, float *g)
convert the register raw data to the free fall threshold
uint8_t adxl345_get_reg(adxl345_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t adxl345_set_reg(adxl345_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t adxl345_get_watermark(adxl345_handle_t *handle, uint8_t *level)
get the fifo watermark
uint8_t adxl345_get_watermark_level(adxl345_handle_t *handle, uint8_t *level)
get the current fifo watermark level
uint8_t adxl345_set_watermark(adxl345_handle_t *handle, uint8_t level)
set the fifo watermark
adxl345_interrupt_active_level_t
adxl345 interrupt active_level enumeration definition
adxl345_interrupt_pin_t
adxl345 interrupt pin enumeration definition
uint8_t adxl345_get_interrupt_source(adxl345_handle_t *handle, uint8_t *source)
get the interrupt source
uint8_t adxl345_get_interrupt_active_level(adxl345_handle_t *handle, adxl345_interrupt_active_level_t *active_level)
get the interrupt active level
uint8_t adxl345_set_interrupt(adxl345_handle_t *handle, adxl345_interrupt_t type, adxl345_bool_t enable)
enable or disable the interrupt
uint8_t adxl345_get_interrupt(adxl345_handle_t *handle, adxl345_interrupt_t type, adxl345_bool_t *enable)
get the interrupt status
adxl345_interrupt_t
adxl345 interrupt enumeration definition
uint8_t adxl345_set_interrupt_map(adxl345_handle_t *handle, adxl345_interrupt_t type, adxl345_interrupt_pin_t pin)
set the interrupt map
uint8_t adxl345_set_interrupt_active_level(adxl345_handle_t *handle, adxl345_interrupt_active_level_t active_level)
set the interrupt active level
uint8_t adxl345_get_interrupt_map(adxl345_handle_t *handle, adxl345_interrupt_t type, adxl345_interrupt_pin_t *pin)
get the interrupt map
@ ADXL345_INTERRUPT_DATA_READY
@ ADXL345_INTERRUPT_DOUBLE_TAP
@ ADXL345_INTERRUPT_ACTIVITY
@ ADXL345_INTERRUPT_SINGLE_TAP
@ ADXL345_INTERRUPT_INACTIVITY
@ ADXL345_INTERRUPT_WATERMARK
@ ADXL345_INTERRUPT_OVERRUN
@ ADXL345_INTERRUPT_FREE_FALL
adxl345 handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* receive_callback)(uint8_t type)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
adxl345 information structure definition
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v