Contiki 2.5
|
Files | |
file | acc-adxl345.c |
ADXL345 Accelerometer interface implementation | |
file | acc-adxl345.h |
ADXL345 Accelerometer interface definitions | |
Macros | |
#define | ADXL345_CS 2 |
#define | ADXL345_DATA_FORMAT_REG 0x31 |
#define | ADXL345_DATA_FORMAT_DATA 0x00 |
#define | ADXL345_POWER_CTL_REG 0x2D |
#define | ADXL345_POWER_CTL_DATA 0x08 |
#define | ADXL345_BW_RATE_REG 0x2C |
#define | ADXL345_BW_RATE_DATA 0x0A |
Functions | |
int8_t | adxl345_init (void) |
Initialize the ADXL345 Acceleration Sensor. More... | |
uint16_t | adxl345_get_x_acceleration (void) |
This function returns the current measured acceleration at the x-axis of the adxl345. More... | |
uint16_t | adxl345_get_y_acceleration (void) |
This function returns the current measured acceleration at the y-axis of the adxl345. More... | |
uint16_t | adxl345_get_z_acceleration (void) |
This function returns the current measured acceleration at the z-axis of the adxl345. More... | |
acc_data_t | adxl345_get_acceleration (void) |
This function returns the current measured acceleration of all axis (x,y,z) More... | |
void | adxl345_write (uint8_t reg, uint8_t data) |
This function writes data to the given register of the ADXL345. More... | |
uint8_t | adxl345_read (uint8_t reg) |
This function reads from the given register of the ADXL345. More... | |
In previous Projects we evaluated some accelerometer sensors and the digital ADXL345 is the best choice for an sensor node application. All accelerometers have nearly the same performance characteristics, but he ADXL345 is very cheap and has the lowest power consumption.
#define ADXL345_BW_RATE_DATA 0x0A |
ADXL Data Rate and Power Mode Control Register Data:
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
---|---|---|---|---|---|---|---|
0 | 0 | 0 | LOW_POWER | Rate_3 | Rate_2 | Rate_1 | Rate_0 |
Definition at line 192 of file acc-adxl345.h.
Referenced by adxl345_init().
#define ADXL345_BW_RATE_REG 0x2C |
ADXL Data Rate and Power Mode Control Register
Definition at line 164 of file acc-adxl345.h.
Referenced by adxl345_init().
#define ADXL345_CS 2 |
SPI device order. The chip select number where the ADXL345 is connected to the BCD-decimal decoder
Definition at line 93 of file acc-adxl345.h.
Referenced by adxl345_init(), adxl345_read(), and adxl345_write().
#define ADXL345_DATA_FORMAT_DATA 0x00 |
ADXL Data Format Register Data:
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
---|---|---|---|---|---|---|---|
SELF_TEST | SPI | INT_INVERT | 0 | FULL_RES | Justify | Range | Range |
Definition at line 126 of file acc-adxl345.h.
Referenced by adxl345_init().
#define ADXL345_DATA_FORMAT_REG 0x31 |
ADXL Data Format Register
Definition at line 98 of file acc-adxl345.h.
Referenced by adxl345_init().
#define ADXL345_POWER_CTL_DATA 0x08 |
ADXL Power Control Register Data:
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
---|---|---|---|---|---|---|---|
0 | 0 | Link | Auto Sleep | Measure | Sleep | Wakeup | Wakeup |
Definition at line 159 of file acc-adxl345.h.
Referenced by adxl345_init().
#define ADXL345_POWER_CTL_REG 0x2D |
ADXL Power Control Register
Definition at line 131 of file acc-adxl345.h.
Referenced by adxl345_init().
acc_data_t adxl345_get_acceleration | ( | void | ) |
This function returns the current measured acceleration of all axis (x,y,z)
Definition at line 85 of file acc-adxl345.c.
References adxl345_get_x_acceleration(), adxl345_get_y_acceleration(), and adxl345_get_z_acceleration().
uint16_t adxl345_get_x_acceleration | ( | void | ) |
This function returns the current measured acceleration at the x-axis of the adxl345.
Definition at line 60 of file acc-adxl345.c.
References adxl345_read().
Referenced by adxl345_get_acceleration().
uint16_t adxl345_get_y_acceleration | ( | void | ) |
This function returns the current measured acceleration at the y-axis of the adxl345.
Definition at line 69 of file acc-adxl345.c.
References adxl345_read().
Referenced by adxl345_get_acceleration().
uint16_t adxl345_get_z_acceleration | ( | void | ) |
This function returns the current measured acceleration at the z-axis of the adxl345.
Definition at line 77 of file acc-adxl345.c.
References adxl345_read().
Referenced by adxl345_get_acceleration().
int8_t adxl345_init | ( | void | ) |
Initialize the ADXL345 Acceleration Sensor.
The specific sensor settings are provided by
Definition at line 41 of file acc-adxl345.c.
References ADXL345_BW_RATE_DATA, ADXL345_BW_RATE_REG, ADXL345_CS, ADXL345_DATA_FORMAT_DATA, ADXL345_DATA_FORMAT_REG, ADXL345_POWER_CTL_DATA, ADXL345_POWER_CTL_REG, adxl345_read(), adxl345_write(), MSPI_BAUD_MAX, mspi_chip_release(), mspi_init(), and MSPI_MODE_3.
uint8_t adxl345_read | ( | uint8_t | reg | ) |
This function reads from the given register of the ADXL345.
reg | The register address |
Definition at line 101 of file acc-adxl345.c.
References ADXL345_CS, mspi_chip_release(), mspi_chip_select(), and mspi_transceive().
Referenced by adxl345_get_x_acceleration(), adxl345_get_y_acceleration(), adxl345_get_z_acceleration(), and adxl345_init().
void adxl345_write | ( | uint8_t | reg, |
uint8_t | data | ||
) |
This function writes data to the given register of the ADXL345.
reg | The register address |
data | The data value |
Definition at line 93 of file acc-adxl345.c.
References ADXL345_CS, mspi_chip_release(), mspi_chip_select(), and mspi_transceive().
Referenced by adxl345_init().