![]() |
no-OS
|
Implementation of ADXL345 Driver. More...
Functions | |
| uint8_t | adxl345_get_register_value (struct adxl345_dev *dev, uint8_t register_address) |
| Reads the value of a register. | |
| void | adxl345_set_register_value (struct adxl345_dev *dev, uint8_t register_address, uint8_t register_value) |
| Writes data into a register. | |
| int32_t | adxl345_init (struct adxl345_dev **device, struct adxl345_init_param init_param) |
| Initializes the communication peripheral and checks if the ADXL345 part is present. | |
| int32_t | adxl345_remove (struct adxl345_dev *dev) |
| Free the resources allocated by adxl345_init(). | |
| void | adxl345_set_power_mode (struct adxl345_dev *dev, uint8_t pwr_mode) |
| Places the device into standby/measure mode. | |
| void | adxl345_get_xyz (struct adxl345_dev *dev, int16_t *x, int16_t *y, int16_t *z) |
| Reads the raw output data of each axis. | |
| void | adxl345_get_g_xyz (struct adxl345_dev *dev, float *x, float *y, float *z) |
| Reads the raw output data of each axis and converts it to g. | |
| void | adxl345_set_tap_detection (struct adxl345_dev *dev, uint8_t tap_type, uint8_t tap_axes, uint8_t tap_dur, uint8_t tap_latent, uint8_t tap_window, uint8_t tap_thresh, uint8_t tap_int) |
| Enables/disables the tap detection. | |
| void | adxl345_set_activity_detection (struct adxl345_dev *dev, uint8_t act_on_off, uint8_t act_axes, uint8_t act_ac_dc, uint8_t act_thresh, uint8_t act_int) |
| Enables/disables the activity detection. | |
| void | adxl345_set_inactivity_detection (struct adxl345_dev *dev, uint8_t inact_on_off, uint8_t inact_axes, uint8_t inact_ac_dc, uint8_t inact_thresh, uint8_t inact_time, uint8_t inact_int) |
| Enables/disables the inactivity detection. | |
| void | adxl345_set_free_fall_detection (struct adxl345_dev *dev, uint8_t ff_on_off, uint8_t ff_thresh, uint8_t ff_time, uint8_t ff_int) |
| Enables/disables the free-fall detection. | |
| void | adxl345_set_orientation_detection (struct adxl345_dev *dev, uint8_t orient_int, uint8_t orient_on_off, uint8_t int_3d, enum adxl345_dead_zone_angle dead_zone, enum adxl345_divisor_bandwidth divisor) |
| Enables/disables the orientation detection (only for adxl346). | |
| void | adxl345_set_offset (struct adxl345_dev *dev, uint8_t x_offset, uint8_t y_offset, uint8_t z_offset) |
| Sets an offset value for each axis (Offset Calibration). | |
| void | adxl345_set_range_resolution (struct adxl345_dev *dev, uint8_t g_range, uint8_t full_res) |
| Selects the measurement range. | |
Implementation of ADXL345 Driver.
Copyright 2012(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| void adxl345_get_g_xyz | ( | struct adxl345_dev * | dev, |
| float * | x, | ||
| float * | y, | ||
| float * | z ) |
Reads the raw output data of each axis and converts it to g.
| dev | - The device structure. |
| x | - X-axis's output data. |
| y | - Y-axis's output data. |
| z | - Z-axis's output data. |
| uint8_t adxl345_get_register_value | ( | struct adxl345_dev * | dev, |
| uint8_t | register_address ) |
Reads the value of a register.
| dev | - The device structure. |
| register_address | - Address of the register. |
| void adxl345_get_xyz | ( | struct adxl345_dev * | dev, |
| int16_t * | x, | ||
| int16_t * | y, | ||
| int16_t * | z ) |
Reads the raw output data of each axis.
| dev | - The device structure. |
| x | - X-axis's output data. |
| y | - Y-axis's output data. |
| z | - Z-axis's output data. |
| int32_t adxl345_init | ( | struct adxl345_dev ** | device, |
| struct adxl345_init_param | init_param ) |
Initializes the communication peripheral and checks if the ADXL345 part is present.
| device | - The device structure. |
| init_param | - The structure that contains the device initial parameters. |
| int32_t adxl345_remove | ( | struct adxl345_dev * | dev | ) |
Free the resources allocated by adxl345_init().
| dev | - The device structure. |
| void adxl345_set_activity_detection | ( | struct adxl345_dev * | dev, |
| uint8_t | act_on_off, | ||
| uint8_t | act_axes, | ||
| uint8_t | act_ac_dc, | ||
| uint8_t | act_thresh, | ||
| uint8_t | act_int ) |
Enables/disables the activity detection.
| dev | - The device structure. |
| act_on_off | - Enables/disables the activity detection. Example: 0x0 - disables the activity detection. 0x1 - enables the activity detection. |
| act_axes | - Axes which participate in detecting activity. Example: 0x0 - disables axes participation. ADXL345_ACT_X_EN - enables x-axis participation. ADXL345_ACT_Y_EN - enables y-axis participation. ADXL345_ACT_Z_EN - enables z-axis participation. |
| act_ac_dc | - Selects dc-coupled or ac-coupled operation. Example: 0x0 - dc-coupled operation. ADXL345_ACT_ACDC - ac-coupled operation. |
| act_thresh | - Threshold value for detecting activity. The scale factor is 62.5 mg/LSB. |
| act_int | - Interrupts pin. Example: 0x0 - activity interrupts on INT1 pin. ADXL345_ACTIVITY - activity interrupts on INT2 pin. |
| void adxl345_set_free_fall_detection | ( | struct adxl345_dev * | dev, |
| uint8_t | ff_on_off, | ||
| uint8_t | ff_thresh, | ||
| uint8_t | ff_time, | ||
| uint8_t | ff_int ) |
Enables/disables the free-fall detection.
| dev | - The device structure. |
| ff_on_off | - Enables/disables the free-fall detection. Example: 0x0 - disables the free-fall detection. 0x1 - enables the free-fall detection. |
| ff_thresh | - Threshold value for free-fall detection. The scale factor is 62.5 mg/LSB. |
| ff_time | - Time value for free-fall detection. The scale factor is 5 ms/LSB. |
| ff_int | - Interrupts pin. Example: 0x0 - free-fall interrupts on INT1 pin. ADXL345_FREE_FALL - free-fall interrupts on INT2 pin. |
| void adxl345_set_inactivity_detection | ( | struct adxl345_dev * | dev, |
| uint8_t | inact_on_off, | ||
| uint8_t | inact_axes, | ||
| uint8_t | inact_ac_dc, | ||
| uint8_t | inact_thresh, | ||
| uint8_t | inact_time, | ||
| uint8_t | inact_int ) |
Enables/disables the inactivity detection.
| dev | - The device structure. |
| inact_on_off | - Enables/disables the inactivity detection. Example: 0x0 - disables the inactivity detection. 0x1 - enables the inactivity detection. |
| inact_axes | - Axes which participate in detecting inactivity. Example: 0x0 - disables axes participation. ADXL345_INACT_X_EN - enables x-axis. ADXL345_INACT_Y_EN - enables y-axis. ADXL345_INACT_Z_EN - enables z-axis. |
| inact_ac_dc | - Selects dc-coupled or ac-coupled operation. Example: 0x0 - dc-coupled operation. ADXL345_INACT_ACDC - ac-coupled operation. |
| inact_thresh | - Threshold value for detecting inactivity. The scale factor is 62.5 mg/LSB. |
| inact_time | - Inactivity time. The scale factor is 1 sec/LSB. |
| inact_int | - Interrupts pin. Example: 0x0 - inactivity interrupts on INT1 pin. ADXL345_INACTIVITY - inactivity interrupts on INT2 pin. |
| void adxl345_set_offset | ( | struct adxl345_dev * | dev, |
| uint8_t | x_offset, | ||
| uint8_t | y_offset, | ||
| uint8_t | z_offset ) |
Sets an offset value for each axis (Offset Calibration).
| dev | - The device structure. |
| x_offset | - X-axis's offset. |
| y_offset | - Y-axis's offset. |
| z_offset | - Z-axis's offset. |
| void adxl345_set_orientation_detection | ( | struct adxl345_dev * | dev, |
| uint8_t | orient_int, | ||
| uint8_t | orient_on_off, | ||
| uint8_t | int_3d, | ||
| enum adxl345_dead_zone_angle | dead_zone, | ||
| enum adxl345_divisor_bandwidth | divisor ) |
Enables/disables the orientation detection (only for adxl346).
| dev | - The device structure. |
| orient_int | - Interrupts pin. Example: 0x0 - orientation interrupts on INT1 pin. ADXL345_ORIENTATION - orientation interrupts on INT2 pin. |
| orient_on_off | - Enables/disables the orientation detection. Example: 0x0 - disables the orientation detection. 0x1 - enables the orientation detection. |
| int_3d | - Enables/disables the 3d orientation detection. Example: 0x0 - disables the 3d orientation detection (enables 2d orientation detection). 0x1 - enables the 3d orientation detection (disables 2d orientation detection). |
| dead_zone | - Dead zone angle encoding. |
| divisor | - Bandwidth divisor encoding. |
| void adxl345_set_power_mode | ( | struct adxl345_dev * | dev, |
| uint8_t | pwr_mode ) |
Places the device into standby/measure mode.
| dev | - The device structure. |
| pwr_mode | - Power mode. Example: 0x0 - standby mode. 0x1 - measure mode. |
| void adxl345_set_range_resolution | ( | struct adxl345_dev * | dev, |
| uint8_t | g_range, | ||
| uint8_t | full_res ) |
Selects the measurement range.
| dev | - The device structure. |
| g_range | - Range option. Example: ADXL345_RANGE_PM_2G - +-2 g ADXL345_RANGE_PM_4G - +-4 g ADXL345_RANGE_PM_8G - +-8 g ADXL345_RANGE_PM_16G - +-16 g |
| full_res | - Full resolution option. Example: 0x0 - Disables full resolution. ADXL345_FULL_RES - Enables full resolution. |
| void adxl345_set_register_value | ( | struct adxl345_dev * | dev, |
| uint8_t | register_address, | ||
| uint8_t | register_value ) |
Writes data into a register.
| dev | - The device structure. |
| register_address | - Address of the register. |
| register_value | - Data value to write. |
| void adxl345_set_tap_detection | ( | struct adxl345_dev * | dev, |
| uint8_t | tap_type, | ||
| uint8_t | tap_axes, | ||
| uint8_t | tap_dur, | ||
| uint8_t | tap_latent, | ||
| uint8_t | tap_window, | ||
| uint8_t | tap_thresh, | ||
| uint8_t | tap_int ) |
Enables/disables the tap detection.
| dev | - The device structure. |
| tap_type | - Tap type (none, single, double). Example: 0x0 - disables tap detection. ADXL345_SINGLE_TAP - enables single tap detection. ADXL345_DOUBLE_TAP - enables double tap detection. |
| tap_axes | - Axes which participate in tap detection. Example: 0x0 - disables axes participation. ADXL345_TAP_X_EN - enables x-axis participation. ADXL345_TAP_Y_EN - enables y-axis participation. ADXL345_TAP_Z_EN - enables z-axis participation. |
| tap_dur | - Tap duration. The scale factor is 625us is/LSB. |
| tap_latent | - Tap latency. The scale factor is 1.25 ms/LSB. |
| tap_window | - Tap window. The scale factor is 1.25 ms/LSB. |
| tap_thresh | - Tap threshold. The scale factor is 62.5 mg/LSB. |
| tap_int | - Interrupts pin. Example: 0x0 - interrupts on INT1 pin. ADXL345_SINGLE_TAP - single tap interrupts on INT2 pin. ADXL345_DOUBLE_TAP - double tap interrupts on INT2 pin. |