xyControl
0.1
Quadrotor Flight Controller on AVR Basis
|
Configuring and reading an LSM303DLHC Accelerometer. More...
Files | |
file | acc.h |
LSM303DLHC Accelerometer API Header. | |
file | acc.c |
LSM303DLHC Accelerometer API Implementation. | |
Macros | |
#define | ACCREG_CTRL1 0x20 |
Accelerometer Control Register 1. More... | |
#define | ACCREG_CTRL4 0x23 |
Accelerometer Control Register 4. More... | |
#define | ACCREG_XL 0x28 |
First Accelerometer Output Register. More... | |
Enumerations | |
enum | AccRange { r2G, r4G, r8G, r16G } |
Accelerometer Range options. More... | |
Functions | |
Error | accInit (AccRange r) |
Initialize the Accelerometer. More... | |
Error | accRead (Vector3f *v) |
Read from the Accelerometer. More... | |
Error | accWriteRegister (uint8_t reg, uint8_t val) |
Write an Accelerometer Register. More... | |
Variables | |
AccRange | accRange |
Stored range to scale returned values. More... | |
Configuring and reading an LSM303DLHC Accelerometer.
#define ACCREG_CTRL1 0x20 |
#define ACCREG_CTRL4 0x23 |
#define ACCREG_XL 0x28 |
enum AccRange |
Initialize the Accelerometer.
Call before accRead(). I2C should already be initialized!
r | AccRange to use. |
Definition at line 76 of file acc.c.
References accRange, ACCREG_CTRL1, ACCREG_CTRL4, accWriteRegister(), ARGUMENT_ERROR, r16G, r2G, r4G, r8G, and SUCCESS.
Referenced by orientationInit().
Read from the Accelerometer.
Accelerometer should already be initialized!
v | Vector3f for the read values |
Definition at line 103 of file acc.c.
References ACC_ADDRESS, ACCFILTERFACTOR, accRange, ACCREG_XL, ARGUMENT_ERROR, r16G, r2G, r4G, r8G, SUCCESS, TWI_NO_ANSWER, TWI_READ, TWI_WRITE, TWI_WRITE_ERROR, twiReadAck(), twiReadNak(), twiRepStart(), twiStart(), twiWrite(), Vector3f::x, Vector3f::y, and Vector3f::z.
Referenced by orientationTask().
Error accWriteRegister | ( | uint8_t | reg, |
uint8_t | val | ||
) |
Write an Accelerometer Register.
I2C should aready be initialized!
reg | Register Address |
val | New Value |
Definition at line 62 of file acc.c.
References TWI_NO_ANSWER.
Referenced by accInit().