ChibiOS
0.0.0
|
![]() |
Version identification | |
#define | EX_LIS302DL_VERSION "1.1.0" |
LIS302DL driver version string. More... | |
#define | EX_LIS302DL_MAJOR 1 |
LIS302DL driver version major number. More... | |
#define | EX_LIS302DL_MINOR 1 |
LIS302DL driver version minor number. More... | |
#define | EX_LIS302DL_PATCH 0 |
LIS302DL driver version patch number. More... | |
#define | LIS302DL_ACC_NUMBER_OF_AXES 3U |
LIS302DL accelerometer subsystem characteristics. More... | |
Configuration options | |
#define | LIS302DL_USE_SPI TRUE |
LIS302DL SPI interface switch. More... | |
#define | LIS302DL_SHARED_SPI FALSE |
LIS302DL shared SPI switch. More... | |
#define | LIS302DL_USE_I2C FALSE |
LIS302DL I2C interface switch. More... | |
#define | LIS302DL_SHARED_I2C FALSE |
LIS302DL shared I2C switch. More... | |
#define | LIS302DL_ACC_USE_ADVANCED FALSE |
LIS302DL accelerometer subsystem advanced configurations switch. More... | |
LIS302DL data structures and types | |
| |
typedef struct LIS302DLDriver | LIS302DLDriver |
Structure representing a LIS302DL driver. More... | |
#define | _lis302dl_methods_alone |
LIS302DL specific methods. More... | |
#define | _lis302dl_methods |
LIS302DL specific methods with inherited ones. More... | |
#define | _lis302dl_data |
LIS302DLDriver specific data. More... | |
Data Structures | |
struct | LIS302DLConfig |
LIS302DL configuration structure. More... | |
struct | LIS302DLVMT |
LIS302DL accelerometer virtual methods table. More... | |
struct | LIS302DLDriver |
LIS302DL 3-axis accelerometer class. More... | |
Functions | |
static void | lis302dlSPIReadRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b) |
Reads a generic register value using SPI. More... | |
static void | lis302dlSPIWriteRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b) |
Writes a value into a generic register using SPI. More... | |
static size_t | acc_get_axes_number (void *ip) |
Return the number of axes of the BaseAccelerometer. More... | |
static msg_t | acc_read_raw (void *ip, int32_t axes[]) |
Retrieves raw data from the BaseAccelerometer. More... | |
static msg_t | acc_read_cooked (void *ip, float axes[]) |
Retrieves cooked data from the BaseAccelerometer. More... | |
static msg_t | acc_set_bias (void *ip, float *bp) |
Set bias values for the BaseAccelerometer. More... | |
static msg_t | acc_reset_bias (void *ip) |
Reset bias values for the BaseAccelerometer. More... | |
static msg_t | acc_set_sensivity (void *ip, float *sp) |
Set sensitivity values for the BaseAccelerometer. More... | |
static msg_t | acc_reset_sensivity (void *ip) |
Reset sensitivity values for the BaseAccelerometer. More... | |
static msg_t | acc_set_full_scale (LIS302DLDriver *devp, lis302dl_acc_fs_t fs) |
Changes the LIS302DLDriver accelerometer fullscale value. More... | |
void | lis302dlObjectInit (LIS302DLDriver *devp) |
Initializes an instance. More... | |
void | lis302dlStart (LIS302DLDriver *devp, const LIS302DLConfig *config) |
Configures and activates LIS302DL Complex Driver peripheral. More... | |
void | lis302dlStop (LIS302DLDriver *devp) |
Deactivates the LIS302DL Complex Driver peripheral. More... | |
#define EX_LIS302DL_VERSION "1.1.0" |
LIS302DL driver version string.
Definition at line 46 of file lis302dl.h.
#define EX_LIS302DL_MAJOR 1 |
LIS302DL driver version major number.
Definition at line 51 of file lis302dl.h.
#define EX_LIS302DL_MINOR 1 |
LIS302DL driver version minor number.
Definition at line 56 of file lis302dl.h.
#define EX_LIS302DL_PATCH 0 |
LIS302DL driver version patch number.
Definition at line 61 of file lis302dl.h.
#define LIS302DL_ACC_NUMBER_OF_AXES 3U |
LIS302DL accelerometer subsystem characteristics.
Definition at line 72 of file lis302dl.h.
Referenced by acc_get_axes_number(), acc_read_cooked(), acc_read_raw(), acc_reset_bias(), acc_reset_sensivity(), acc_set_bias(), acc_set_full_scale(), acc_set_sensivity(), lis302dlObjectInit(), and lis302dlStart().
#define LIS302DL_USE_SPI TRUE |
LIS302DL SPI interface switch.
If set to TRUE
the support for SPI is included.
TRUE
. Definition at line 184 of file lis302dl.h.
#define LIS302DL_SHARED_SPI FALSE |
LIS302DL shared SPI switch.
If set to TRUE
the device acquires SPI bus ownership on each transaction.
FALSE
. Requires SPI_USE_MUTUAL_EXCLUSION. Definition at line 194 of file lis302dl.h.
#define LIS302DL_USE_I2C FALSE |
LIS302DL I2C interface switch.
If set to TRUE
the support for I2C is included.
FALSE
. Definition at line 203 of file lis302dl.h.
#define LIS302DL_SHARED_I2C FALSE |
LIS302DL shared I2C switch.
If set to TRUE
the device acquires I2C bus ownership on each transaction.
FALSE
. Requires I2C_USE_MUTUAL_EXCLUSION. Definition at line 213 of file lis302dl.h.
#define LIS302DL_ACC_USE_ADVANCED FALSE |
LIS302DL accelerometer subsystem advanced configurations switch.
If set to TRUE
more configurations are available.
FALSE
. Definition at line 223 of file lis302dl.h.
#define _lis302dl_methods_alone |
LIS302DL
specific methods.
Definition at line 359 of file lis302dl.h.
#define _lis302dl_methods |
LIS302DL
specific methods with inherited ones.
Definition at line 367 of file lis302dl.h.
#define _lis302dl_data |
LIS302DLDriver
specific data.
Definition at line 383 of file lis302dl.h.
#define lis302dlAccelerometerGetAxesNumber | ( | devp | ) | accelerometerGetAxesNumber(&((devp)->acc_if)) |
Return the number of axes of the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
Definition at line 422 of file lis302dl.h.
#define lis302dlAccelerometerReadRaw | ( | devp, | |
axes | |||
) | accelerometerReadRaw(&((devp)->acc_if), axes) |
Retrieves raw data from the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
[out] | axes | a buffer which would be filled with raw data. |
MSG_OK | if the function succeeded. |
MSG_RESET | if one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors() . |
MSG_TIMEOUT | if a timeout occurred before operation end. |
Definition at line 443 of file lis302dl.h.
#define lis302dlAccelerometerReadCooked | ( | devp, | |
axes | |||
) | accelerometerReadCooked(&((devp)->acc_if), axes) |
Retrieves cooked data from the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
[out] | axes | a buffer which would be filled with cooked data. |
MSG_OK | if the function succeeded. |
MSG_RESET | if one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors() . |
MSG_TIMEOUT | if a timeout occurred before operation end. |
Definition at line 465 of file lis302dl.h.
#define lis302dlAccelerometerSetBias | ( | devp, | |
bp | |||
) | accelerometerSetBias(&((devp)->acc_if), bp) |
Set bias values for the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
[in] | bp | a buffer which contains biases. |
MSG_OK | if the function succeeded. |
Definition at line 482 of file lis302dl.h.
#define lis302dlAccelerometerResetBias | ( | devp | ) | accelerometerResetBias(&((devp)->acc_if)) |
Reset bias values for the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
MSG_OK | if the function succeeded. |
Definition at line 497 of file lis302dl.h.
#define lis302dlAccelerometerSetSensitivity | ( | devp, | |
sp | |||
) | accelerometerSetSensitivity(&((devp)->acc_if), sp) |
Set sensitivity values for the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
[in] | sp | a buffer which contains sensitivities. |
MSG_OK | if the function succeeded. |
Definition at line 514 of file lis302dl.h.
#define lis302dlAccelerometerResetSensitivity | ( | devp | ) | accelerometerResetSensitivity(&((devp)->acc_if)) |
Reset sensitivity values for the BaseAccelerometer.
[in] | devp | pointer to LIS302DLDriver . |
MSG_OK | if the function succeeded. |
MSG_RESET | otherwise. |
Definition at line 529 of file lis302dl.h.
#define lis302dlAccelerometerSetFullScale | ( | devp, | |
fs | |||
) | (devp)->vmt->acc_set_full_scale(devp, fs) |
Changes the LIS302DLDriver accelerometer fullscale value.
[in] | devp | pointer to LIS302DLDriver . |
[in] | fs | new fullscale value. |
MSG_OK | if the function succeeded. |
MSG_RESET | otherwise. |
Definition at line 547 of file lis302dl.h.
typedef struct LIS302DLDriver LIS302DLDriver |
Structure representing a LIS302DL driver.
Definition at line 269 of file lis302dl.h.
enum lis302dl_acc_fs_t |
LIS302DL full scale.
Enumerator | |
---|---|
LIS302DL_ACC_FS_2G |
Full scale ±2g. |
LIS302DL_ACC_FS_8G |
Full scale ±8g. |
Definition at line 274 of file lis302dl.h.
enum lis302dl_acc_odr_t |
LIS302DL output data rate and bandwidth.
Enumerator | |
---|---|
LIS302DL_ACC_ODR_100HZ |
ODR 100 Hz. |
LIS302DL_ACC_ODR_400HZ |
ODR 400 Hz. |
Definition at line 282 of file lis302dl.h.
enum lis302dl_acc_hp_t |
LIS302DL high pass filtering.
Definition at line 290 of file lis302dl.h.
enum lis302dl_state_t |
Driver state machine possible states.
Enumerator | |
---|---|
LIS302DL_UNINIT |
Not initialized. |
LIS302DL_STOP |
Stopped. |
LIS302DL_READY |
Ready. |
Definition at line 301 of file lis302dl.h.
|
static |
Reads a generic register value using SPI.
[in] | spip | pointer to the SPI interface |
[in] | reg | starting register address |
[in] | n | number of adjacent registers to write |
[in] | b | pointer to a buffer. |
Definition at line 59 of file lis302dl.c.
References spiReceive(), spiSelect(), spiSend(), and spiUnselect().
Referenced by acc_read_raw(), and acc_set_full_scale().
|
static |
Writes a value into a generic register using SPI.
[in] | spip | pointer to the SPI interface |
[in] | reg | starting register address |
[in] | n | number of adjacent registers to write |
[in] | b | pointer to a buffer of values. |
Definition at line 78 of file lis302dl.c.
References spiSelect(), spiSend(), and spiUnselect().
Referenced by acc_set_full_scale(), lis302dlStart(), and lis302dlStop().
|
static |
Return the number of axes of the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
Definition at line 96 of file lis302dl.c.
References LIS302DL_ACC_NUMBER_OF_AXES.
Referenced by acc_set_full_scale().
|
static |
Retrieves raw data from the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
[out] | axes | a buffer which would be filled with raw data. |
MSG_OK | if the function succeeded. |
MSG_RESET | if one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors() . |
MSG_TIMEOUT | if a timeout occurred before operation end. |
Definition at line 118 of file lis302dl.c.
References LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, lis302dlSPIReadRegister(), MSG_OK, objGetInstance, osalDbgAssert, osalDbgCheck, SPI_READY, spiAcquireBus(), spiReleaseBus(), and spiStart().
Referenced by acc_read_cooked(), and acc_set_full_scale().
|
static |
Retrieves cooked data from the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
[out] | axes | a buffer which would be filled with cooked data. |
MSG_OK | if the function succeeded. |
MSG_RESET | if one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors() . |
MSG_TIMEOUT | if a timeout occurred before operation end. |
Definition at line 171 of file lis302dl.c.
References acc_read_raw(), LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.
Referenced by acc_set_full_scale().
|
static |
Set bias values for the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
[in] | bp | a buffer which contains biases. |
MSG_OK | if the function succeeded. |
Definition at line 204 of file lis302dl.c.
References LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.
Referenced by acc_set_full_scale().
|
static |
Reset bias values for the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
MSG_OK | if the function succeeded. |
Definition at line 233 of file lis302dl.c.
References LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.
Referenced by acc_set_full_scale().
|
static |
Set sensitivity values for the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
[in] | sp | a buffer which contains sensitivities. |
MSG_OK | if the function succeeded. |
Definition at line 263 of file lis302dl.c.
References LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.
Referenced by acc_set_full_scale().
|
static |
Reset sensitivity values for the BaseAccelerometer.
[in] | ip | pointer to BaseAccelerometer interface. |
MSG_OK | if the function succeeded. |
MSG_RESET | otherwise. |
Definition at line 292 of file lis302dl.c.
References FALSE, LIS302DL_ACC_FS_2G, LIS302DL_ACC_FS_8G, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, MSG_OK, MSG_RESET, objGetInstance, osalDbgAssert, and osalDbgCheck.
Referenced by acc_set_full_scale().
|
static |
Changes the LIS302DLDriver accelerometer fullscale value.
[in] | devp | pointer to LIS302DLDriver interface. |
[in] | fs | new fullscale value. |
MSG_OK | if the function succeeded. |
MSG_RESET | otherwise. |
Definition at line 332 of file lis302dl.c.
References acc_get_axes_number(), acc_read_cooked(), acc_read_raw(), acc_reset_bias(), acc_reset_sensivity(), acc_set_bias(), acc_set_sensivity(), LIS302DL_ACC_FS_2G, LIS302DL_ACC_FS_8G, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, lis302dlSPIReadRegister(), lis302dlSPIWriteRegister(), MSG_RESET, osalDbgAssert, osalDbgCheck, SPI_READY, spiAcquireBus(), spiReleaseBus(), and spiStart().
void lis302dlObjectInit | ( | LIS302DLDriver * | devp | ) |
Initializes an instance.
[out] | devp | pointer to the LIS302DLDriver object |
Definition at line 425 of file lis302dl.c.
References LIS302DLDriver::acc_if, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_STOP, BaseAccelerometer::vmt, and LIS302DLDriver::vmt.
void lis302dlStart | ( | LIS302DLDriver * | devp, |
const LIS302DLConfig * | config | ||
) |
Configures and activates LIS302DL Complex Driver peripheral.
[in] | devp | pointer to the LIS302DLDriver object |
[in] | config | pointer to the LIS302DLConfig object |
Definition at line 444 of file lis302dl.c.
References SPIDriver::config, FALSE, LIS302DL_ACC_FS_2G, LIS302DL_ACC_FS_8G, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_READY, LIS302DL_STOP, lis302dlSPIWriteRegister(), osalDbgAssert, osalDbgCheck, osalThreadSleepMilliseconds, spiAcquireBus(), LIS302DLConfig::spip, spiReleaseBus(), and spiStart().
void lis302dlStop | ( | LIS302DLDriver * | devp | ) |
Deactivates the LIS302DL Complex Driver peripheral.
[in] | devp | pointer to the LIS302DLDriver object |
Definition at line 528 of file lis302dl.c.
References LIS302DL_READY, LIS302DL_STOP, lis302dlSPIWriteRegister(), osalDbgAssert, osalDbgCheck, spiAcquireBus(), spiReleaseBus(), spiStart(), and spiStop().