The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.
The ADXL345 is well suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0°.
Several special sensing functions are provided. Activity and inactivity sensing detect the presence or lack of motion and if the acceleration on any axis exceeds a user-set level. Tap sensing detects single and double taps. Free-fall sensing detects if the device is falling. These functions can be mapped to one of two interrupt output pins. An integrated, patent pending 32-level first in, first out (FIFO) buffer can be used to store data to minimize host processor intervention.
Low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at extremely low power dissipation.
The ADXL345 is supplied in a small, thin, 3 mm × 5 mm × 1 mm, 14-lead, plastic package.
The goal of this project (Microcontroller No-OS) is to be able to provide reference projects for lower end processors, which can't run Linux, or aren't running a specific operating system, to help those customers using microcontrollers with ADI parts. Here you can find a generic driver which can be used as a base for any microcontroller platform and also specific drivers for different microcontroller platforms.
The driver contains two parts:
The Communication Driver has a standard interface, so the ADXL345 driver can be used exactly as it is provided.
If the SPI communication is chosen, there are three functions which are called by the ADXL345 driver:
SPI driver architecture
If the I2C communication is chosen, there are three functions which are called by the ADXL345 driver:
I2C driver architecture
The implementation of these three functions depends on the used microcontroller.
The following functions are implemented in this version of ADXL345 driver:
|unsigned char ADXL345_Init(char commProtocol)||Initializes the communication peripheral and checks if the ADXL345 part is present.|
|void ADXL345_SetRegisterValue(unsigned char registerAddress, unsigned char registerValue)||Writes data into a register.|
|unsigned char ADXL345_GetRegisterValue(unsigned char registerAddress)||Reads the value of a register.|
|void ADXL345_SetPowerMode(unsigned char pwrMode)||Places the device into standby/measure mode.|
|void ADXL345_GetXyz(unsigned short* x, unsigned short* y, unsigned short* z)||Reads the output data of each axis.|
|void ADXL345_SetTapDetection(unsigned char tapType, unsigned char tapAxes, unsigned char tapDur, unsigned char tapLatent, unsigned char tapWindow, unsigned char tapThresh, unsigned char tapInt)||Enables/disables the tap detection.|
|void ADXL345_SetActivityDetection(unsigned char actOnOff, unsigned char actAxes, unsigned char actAcDc, unsigned char actThresh, unsigned char actInt)||Enables/disables the activity detection.|
|void ADXL345_SetInactivityDetection(unsigned char inactOnOff, unsigned char inactAxes, unsigned char inactAcDc, unsigned char inactThresh, unsigned char inactTime, unsigned char inactInt)||Enables/disables the inactivity detection.|
|void ADXL345_SetFreeFallDetection(unsigned char ffOnOff, unsigned char ffThresh, unsigned char ffTime, unsigned char ffInt)||Enables/disables the free-fall detection.|
|void ADXL345_SetOffset(unsigned char xOffset, unsigned char yOffset, unsigned char zOffset)||Calibrates the accelerometer.|
This section contains a description of the steps required to run the ADXL345 demonstration project on a Renesas RL78G13 platform.
There are two options:
In this example, the output data of each axis is read and displayed on the Renesas Demonstration Kit for RL78G13 board’s LCD. Were also activated “Single Tap”, “Double Tap” and “Free-Fall” interrupts. When one of them occurs, on the LCD screen appears a corresponding message.
This section presents the steps for developing a software application that will run on the Renesas Demo Kit for RL78G13 for controlling and monitoring the operation of the ADI part.
This section contains a description of the steps required to run the ADXL345 demonstration project on a Renesas RX62N platform.
There are two options:
PmodACL Pin 1 (CS) → YRDKRX62N J8 connector Pin 15 PmodACL Pin 2 (MOSI) → YRDKRX62N J8 connector Pin 19 PmodACL Pin 3 (MISO) → YRDKRX62N J8 connector Pin 22 PmodACL Pin 4 (CLK) → YRDKRX62N J8 connector Pin 20 PmodACL Pin 5 (GND) → YRDKRX62N J8 connector Pin 4 PmodACL Pin 6 (VCC) → YRDKRX62N J8 connector Pin 3
In this example, the output data of each axis is read and displayed on the Renesas Demonstration Kit for RX62N board’s LCD. Were also activated “Single Tap”, “Double Tap” and “Free-Fall” interrupts. When one of them occurs, on the LCD screen appears a corresponding message.
This section presents the steps for developing a software application that will run on the Renesas Demo Kit for RX62N for controlling and monitoring the operation of the ADI part.