ChibiOS  19.1.4
Collaboration diagram for LIS3DSH:

Detailed Description

Macros

#define lis3dshAccelerometerGetAxesNumber(devp)   accelerometerGetAxesNumber(&((devp)->acc_if))
 Return the number of axes of the BaseAccelerometer. More...
 
#define lis3dshAccelerometerReadRaw(devp, axes)   accelerometerReadRaw(&((devp)->acc_if), axes)
 Retrieves raw data from the BaseAccelerometer. More...
 
#define lis3dshAccelerometerReadCooked(devp, axes)   accelerometerReadCooked(&((devp)->acc_if), axes)
 Retrieves cooked data from the BaseAccelerometer. More...
 
#define lis3dshAccelerometerSetBias(devp, bp)   accelerometerSetBias(&((devp)->acc_if), bp)
 Set bias values for the BaseAccelerometer. More...
 
#define lis3dshAccelerometerResetBias(devp)   accelerometerResetBias(&((devp)->acc_if))
 Reset bias values for the BaseAccelerometer. More...
 
#define lis3dshAccelerometerSetSensitivity(devp, sp)   accelerometerSetSensitivity(&((devp)->acc_if), sp)
 Set sensitivity values for the BaseAccelerometer. More...
 
#define lis3dshAccelerometerResetSensitivity(devp)   accelerometerResetSensitivity(&((devp)->acc_if))
 Reset sensitivity values for the BaseAccelerometer. More...
 
#define lis3dshAccelerometerSetFullScale(devp, fs)   (devp)->vmt->acc_set_full_scale(devp, fs)
 Changes the LIS3DSHDriver accelerometer fullscale value. More...
 

Version identification

#define EX_LIS3DSH_VERSION   "1.1.2"
 LIS3DSH driver version string. More...
 
#define EX_LIS3DSH_MAJOR   1
 LIS3DSH driver version major number. More...
 
#define EX_LIS3DSH_MINOR   1
 LIS3DSH driver version minor number. More...
 
#define EX_LIS3DSH_PATCH   2
 LIS3DSH driver version patch number. More...
 
#define LIS3DSH_ACC_NUMBER_OF_AXES   3U
 LIS3DSH accelerometer subsystem characteristics. More...
 

LIS3DSH communication interfaces related bit masks

#define LIS3DSH_DI_MASK   0xFF
 
#define LIS3DSH_DI(n)   (1 << n)
 
#define LIS3DSH_AD_MASK   0x3F
 
#define LIS3DSH_AD(n)   (1 << n)
 
#define LIS3DSH_MS   (1 << 6)
 
#define LIS3DSH_RW   (1 << 7)
 

LIS3DSH register addresses

#define LIS3DSH_AD_OUT_T   0x0C
 
#define LIS3DSH_AD_INFO1   0x0D
 
#define LIS3DSH_AD_INFO2   0x0E
 
#define LIS3DSH_AD_WHO_AM_I   0x0F
 
#define LIS3DSH_AD_OFF_X   0x10
 
#define LIS3DSH_AD_OFF_Y   0x11
 
#define LIS3DSH_AD_OFF_Z   0x12
 
#define LIS3DSH_AD_CS_X   0x13
 
#define LIS3DSH_AD_CS_Y   0x14
 
#define LIS3DSH_AD_CS_Z   0x15
 
#define LIS3DSH_AD_LC_L   0x16
 
#define LIS3DSH_AD_LC_H   0x17
 
#define LIS3DSH_AD_STAT   0x18
 
#define LIS3DSH_AD_PEAK1   0x19
 
#define LIS3DSH_AD_PEAK2   0x1A
 
#define LIS3DSH_AD_VFC_1   0x1B
 
#define LIS3DSH_AD_VFC_2   0x1C
 
#define LIS3DSH_AD_VFC_3   0x1D
 
#define LIS3DSH_AD_VFC_4   0x1E
 
#define LIS3DSH_AD_THRS3   0x1F
 
#define LIS3DSH_AD_CTRL_REG4   0x20
 
#define LIS3DSH_AD_CTRL_REG1   0x21
 
#define LIS3DSH_AD_CTRL_REG2   0x22
 
#define LIS3DSH_AD_CTRL_REG3   0x23
 
#define LIS3DSH_AD_CTRL_REG5   0x24
 
#define LIS3DSH_AD_CTRL_REG6   0x25
 
#define LIS3DSH_AD_STATUS   0x27
 
#define LIS3DSH_AD_OUT_X_L   0x28
 
#define LIS3DSH_AD_OUT_X_H   0x29
 
#define LIS3DSH_AD_OUT_Y_L   0x2A
 
#define LIS3DSH_AD_OUT_Y_H   0x2B
 
#define LIS3DSH_AD_OUT_Z_L   0x2C
 
#define LIS3DSH_AD_OUT_Z_H   0x2D
 
#define LIS3DSH_AD_FIFO_CTRL   0x2E
 
#define LIS3DSH_AD_FIFO_SRC   0x2F
 
#define LIS3DSH_AD_ST1_0   0x40
 
#define LIS3DSH_AD_ST1_1   0x41
 
#define LIS3DSH_AD_ST1_2   0x42
 
#define LIS3DSH_AD_ST1_3   0x43
 
#define LIS3DSH_AD_ST1_4   0x44
 
#define LIS3DSH_AD_ST1_5   0x45
 
#define LIS3DSH_AD_ST1_6   0x46
 
#define LIS3DSH_AD_ST1_7   0x47
 
#define LIS3DSH_AD_ST1_8   0x48
 
#define LIS3DSH_AD_ST1_9   0x49
 
#define LIS3DSH_AD_ST1_A   0x4A
 
#define LIS3DSH_AD_ST1_B   0x4B
 
#define LIS3DSH_AD_ST1_C   0x4C
 
#define LIS3DSH_AD_ST1_D   0x4D
 
#define LIS3DSH_AD_ST1_E   0x4E
 
#define LIS3DSH_AD_ST1_F   0x4F
 
#define LIS3DSH_AD_TIM4_1   0x50
 
#define LIS3DSH_AD_TIM3_1   0x51
 
#define LIS3DSH_AD_TIM2_1_L   0x52
 
#define LIS3DSH_AD_TIM2_1_H   0x53
 
#define LIS3DSH_AD_TIM1_1_L   0x54
 
#define LIS3DSH_AD_TIM1_1_H   0x55
 
#define LIS3DSH_AD_THRS2_1   0x56
 
#define LIS3DSH_AD_THRS1_1   0x57
 
#define LIS3DSH_AD_MASK1_B   0x59
 
#define LIS3DSH_AD_MASK1_A   0x5A
 
#define LIS3DSH_AD_SETT1   0x5B
 
#define LIS3DSH_AD_PR1   0x5C
 
#define LIS3DSH_AD_TC1_L   0x5D
 
#define LIS3DSH_AD_TC1_H   0x5E
 
#define LIS3DSH_AD_OUTS1   0x5F
 
#define LIS3DSH_AD_ST2_0   0x60
 
#define LIS3DSH_AD_ST2_1   0x61
 
#define LIS3DSH_AD_ST2_2   0x62
 
#define LIS3DSH_AD_ST2_3   0x63
 
#define LIS3DSH_AD_ST2_4   0x64
 
#define LIS3DSH_AD_ST2_5   0x65
 
#define LIS3DSH_AD_ST2_6   0x66
 
#define LIS3DSH_AD_ST2_7   0x67
 
#define LIS3DSH_AD_ST2_8   0x68
 
#define LIS3DSH_AD_ST2_9   0x69
 
#define LIS3DSH_AD_ST2_A   0x6A
 
#define LIS3DSH_AD_ST2_B   0x6B
 
#define LIS3DSH_AD_ST2_C   0x6C
 
#define LIS3DSH_AD_ST2_D   0x6D
 
#define LIS3DSH_AD_ST2_E   0x6E
 
#define LIS3DSH_AD_ST2_F   0x6F
 
#define LIS3DSH_AD_TIM4_2   0x70
 
#define LIS3DSH_AD_TIM3_2   0x71
 
#define LIS3DSH_AD_TIM2_2_L   0x72
 
#define LIS3DSH_AD_TIM2_2_H   0x73
 
#define LIS3DSH_AD_TIM1_2_L   0x74
 
#define LIS3DSH_AD_TIM1_2_H   0x75
 
#define LIS3DSH_AD_THRS2_2   0x76
 
#define LIS3DSH_AD_THRS1_2   0x77
 
#define LIS3DSH_AD_DES2   0x78
 
#define LIS3DSH_AD_MASK2_B   0x79
 
#define LIS3DSH_AD_MASK2_A   0x7A
 
#define LIS3DSH_AD_SETT2   0x7B
 
#define LIS3DSH_AD_PR2   0x7C
 
#define LIS3DSH_AD_TC2_L   0x7D
 
#define LIS3DSH_AD_TC2_H   0x7E
 
#define LIS3DSH_AD_OUTS2   0x7F
 

LIS3DSH_CTRL_REG1 register bits definitions

#define LIS3DSH_CTRL_REG1_MASK   0xE9
 
#define LIS3DSH_CTRL_REG1_SM1_EN   (1 << 0)
 
#define LIS3DSH_CTRL_REG1_SM1_PIN   (1 << 3)
 
#define LIS3DSH_CTRL_REG1_HYST0_1   (1 << 5)
 
#define LIS3DSH_CTRL_REG1_HYST1_1   (1 << 6)
 
#define LIS3DSH_CTRL_REG1_HYST2_1   (1 << 7)
 

LIS3DSH_CTRL_REG2 register bits definitions

#define LIS3DSH_CTRL_REG2_MASK   0xE9
 
#define LIS3DSH_CTRL_REG2_SM2_EN   (1 << 0)
 
#define LIS3DSH_CTRL_REG2_SM2_PIN   (1 << 3)
 
#define LIS3DSH_CTRL_REG2_HYST0_2   (1 << 5)
 
#define LIS3DSH_CTRL_REG2_HYST1_2   (1 << 6)
 
#define LIS3DSH_CTRL_REG2_HYST2_2   (1 << 7)
 

LIS3DSH_CTRL_REG3 register bits definitions

#define LIS3DSH_CTRL_REG3_MASK   0xFF
 
#define LIS3DSH_CTRL_REG3_STRT   (1 << 0)
 
#define LIS3DSH_CTRL_REG3_VFILT   (1 << 2)
 
#define LIS3DSH_CTRL_REG3_INT1_EN   (1 << 3)
 
#define LIS3DSH_CTRL_REG3_INT2_EN   (1 << 4)
 
#define LIS3DSH_CTRL_REG3_IEL   (1 << 5)
 
#define LIS3DSH_CTRL_REG3_IEA   (1 << 6)
 
#define LIS3DSH_CTRL_REG3_DR_EN   (1 << 7)
 

LIS3DSH_CTRL_REG4 register bits definitions

#define LIS3DSH_CTRL_REG4_MASK   0xFF
 
#define LIS3DSH_CTRL_REG4_XEN   (1 << 0)
 
#define LIS3DSH_CTRL_REG4_YEN   (1 << 1)
 
#define LIS3DSH_CTRL_REG4_ZEN   (1 << 2)
 
#define LIS3DSH_CTRL_REG4_BDU   (1 << 3)
 
#define LIS3DSH_CTRL_REG4_ODR_0   (1 << 4)
 
#define LIS3DSH_CTRL_REG4_ODR_1   (1 << 5)
 
#define LIS3DSH_CTRL_REG4_ODR_2   (1 << 6)
 
#define LIS3DSH_CTRL_REG4_ODR_3   (1 << 7)
 

LIS3DSH_CTRL_REG5 register bits definitions

#define LIS3DSH_CTRL_REG5_MASK   0xFF
 
#define LIS3DSH_CTRL_REG5_SIM   (1 << 0)
 
#define LIS3DSH_CTRL_REG5_ST1   (1 << 1)
 
#define LIS3DSH_CTRL_REG5_ST2   (1 << 2)
 
#define LIS3DSH_CTRL_REG5_FS_MASK   0x38
 
#define LIS3DSH_CTRL_REG5_FS0   (1 << 3)
 
#define LIS3DSH_CTRL_REG5_FS1   (1 << 4)
 
#define LIS3DSH_CTRL_REG5_FS2   (1 << 5)
 
#define LIS3DSH_CTRL_REG5_BW1   (1 << 6)
 
#define LIS3DSH_CTRL_REG5_BW2   (1 << 7)
 

LIS3DSH_CTRL_REG6 register bits definitions

#define LIS3DSH_CTRL_REG6_MASK   0xFF
 
#define LIS3DSH_CTRL_REG6_P2_BOOT   (1 << 0)
 
#define LIS3DSH_CTRL_REG6_P1_OVRUN   (1 << 1)
 
#define LIS3DSH_CTRL_REG6_P1_WTM   (1 << 2)
 
#define LIS3DSH_CTRL_REG6_P1_EMPTY   (1 << 3)
 
#define LIS3DSH_CTRL_REG6_ADD_INC   (1 << 4)
 
#define LIS3DSH_CTRL_REG6_WTM_EN   (1 << 5)
 
#define LIS3DSH_CTRL_REG6_FIFO_EN   (1 << 6)
 
#define LIS3DSH_CTRL_REG6_BOOT   (1 << 7)
 

Configuration options

#define LIS3DSH_USE_SPI   TRUE
 LIS3DSH SPI interface switch. More...
 
#define LIS3DSH_SHARED_SPI   FALSE
 LIS3DSH shared SPI switch. More...
 
#define LIS3DSH_USE_I2C   FALSE
 LIS3DSH I2C interface switch. More...
 
#define LIS3DSH_SHARED_I2C   FALSE
 LIS3DSH shared I2C switch. More...
 
#define LIS3DSH_USE_ADVANCED   FALSE
 LIS3DSH advanced configurations switch. More...
 

LIS3DSH data structures and types

Todo:
Add support for LIS3DSH over I2C.
typedef struct LIS3DSHDriver LIS3DSHDriver
 Structure representing a LIS3DSH driver. More...
 
#define _lis3dsh_methods_alone
 LIS3DSH specific methods. More...
 
#define _lis3dsh_methods
 LIS3DSH specific methods with inherited ones. More...
 
#define _lis3dsh_data
 LIS3DSHDriver specific data. More...
 

Data Structures

struct  LIS3DSHConfig
 LIS3DSH configuration structure. More...
 
struct  LIS3DSHVMT
 LIS3DSH virtual methods table. More...
 
struct  LIS3DSHDriver
 LIS3DSH 3-axis accelerometer class. More...
 

Functions

static void lis3dshSPIReadRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
 Reads a generic register value using SPI. More...
 
static void lis3dshSPIWriteRegister (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 (LIS3DSHDriver *devp, lis3dsh_acc_fs_t fs)
 Changes the LIS3DSHDriver accelerometer fullscale value. More...
 
void lis3dshObjectInit (LIS3DSHDriver *devp)
 Initializes an instance. More...
 
void lis3dshStart (LIS3DSHDriver *devp, const LIS3DSHConfig *config)
 Configures and activates LIS3DSH Complex Driver peripheral. More...
 
void lis3dshStop (LIS3DSHDriver *devp)
 Deactivates the LIS3DSH Complex Driver peripheral. More...
 

Macro Definition Documentation

#define EX_LIS3DSH_VERSION   "1.1.2"

LIS3DSH driver version string.

Definition at line 46 of file lis3dsh.h.

#define EX_LIS3DSH_MAJOR   1

LIS3DSH driver version major number.

Definition at line 51 of file lis3dsh.h.

#define EX_LIS3DSH_MINOR   1

LIS3DSH driver version minor number.

Definition at line 56 of file lis3dsh.h.

#define EX_LIS3DSH_PATCH   2

LIS3DSH driver version patch number.

Definition at line 61 of file lis3dsh.h.

#define LIS3DSH_ACC_NUMBER_OF_AXES   3U

LIS3DSH accelerometer subsystem characteristics.

Note
Sensitivity is expressed as milli-G/LSB whereas 1 milli-G = 0.00980665 m/s^2.
Bias is expressed as milli-G.

Definition at line 72 of file lis3dsh.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(), lis3dshObjectInit(), and lis3dshStart().

#define LIS3DSH_USE_SPI   TRUE

LIS3DSH SPI interface switch.

If set to TRUE the support for SPI is included.

Note
The default is TRUE.

Definition at line 303 of file lis3dsh.h.

#define LIS3DSH_SHARED_SPI   FALSE

LIS3DSH shared SPI switch.

If set to TRUE the device acquires SPI bus ownership on each transaction.

Note
The default is FALSE. Requires SPI_USE_MUTUAL_EXCLUSION.

Definition at line 313 of file lis3dsh.h.

#define LIS3DSH_USE_I2C   FALSE

LIS3DSH I2C interface switch.

If set to TRUE the support for I2C is included.

Note
The default is FALSE.

Definition at line 322 of file lis3dsh.h.

#define LIS3DSH_SHARED_I2C   FALSE

LIS3DSH shared I2C switch.

If set to TRUE the device acquires I2C bus ownership on each transaction.

Note
The default is FALSE. Requires I2C_USE_MUTUAL_EXCLUSION.

Definition at line 332 of file lis3dsh.h.

#define LIS3DSH_USE_ADVANCED   FALSE

LIS3DSH advanced configurations switch.

If set to TRUE more configurations are available.

Note
The default is FALSE.

Definition at line 341 of file lis3dsh.h.

#define _lis3dsh_methods_alone
Value:
/* Change full scale value of LIS3DSH accelerometer subsystem.*/ \
static msg_t acc_set_full_scale(LIS302DLDriver *devp, lis302dl_acc_fs_t fs)
Changes the LIS302DLDriver accelerometer fullscale value.
Definition: lis302dl.c:332
lis3dsh_acc_fs_t
LIS3DSH full scale.
Definition: lis3dsh.h:392
LIS3DSH 3-axis accelerometer class.
Definition: lis3dsh.h:541
int32_t msg_t
Definition: chtypes.h:51

LIS3DSH specific methods.

Definition at line 499 of file lis3dsh.h.

#define _lis3dsh_methods
Value:
#define _lis3dsh_methods_alone
LIS3DSH specific methods.
Definition: lis3dsh.h:499

LIS3DSH specific methods with inherited ones.

Definition at line 507 of file lis3dsh.h.

#define _lis3dsh_data
Value:
/* Driver state.*/ \
/* Current configuration data.*/ \
const LIS3DSHConfig *config; \
/* Accelerometer subsystem axes number.*/ \
size_t accaxes; \
/* Accelerometer subsystem current sensitivity.*/ \
float accsensitivity[LIS3DSH_ACC_NUMBER_OF_AXES]; \
/* Accelerometer subsystem current bias .*/ \
float accbias[LIS3DSH_ACC_NUMBER_OF_AXES]; \
/* Accelerometer subsystem current full scale value.*/ \
float accfullscale;
#define LIS3DSH_ACC_NUMBER_OF_AXES
LIS3DSH accelerometer subsystem characteristics.
Definition: lis3dsh.h:72
lis3dsh_state_t
Driver state machine possible states.
Definition: lis3dsh.h:437
#define _base_sensor_data
BaseSensor specific data.
Definition: hal_sensors.h:74
LIS3DSH configuration structure.
Definition: lis3dsh.h:446

LIS3DSHDriver specific data.

Definition at line 523 of file lis3dsh.h.

#define lis3dshAccelerometerGetAxesNumber (   devp)    accelerometerGetAxesNumber(&((devp)->acc_if))

Return the number of axes of the BaseAccelerometer.

Parameters
[in]devppointer to LIS3DSHDriver.
Returns
the number of axes.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 563 of file lis3dsh.h.

#define lis3dshAccelerometerReadRaw (   devp,
  axes 
)    accelerometerReadRaw(&((devp)->acc_if), axes)

Retrieves raw data from the BaseAccelerometer.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS3DSHDriver.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 584 of file lis3dsh.h.

#define lis3dshAccelerometerReadCooked (   devp,
  axes 
)    accelerometerReadCooked(&((devp)->acc_if), axes)

Retrieves cooked data from the BaseAccelerometer.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as milli-G.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS3DSHDriver.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 606 of file lis3dsh.h.

#define lis3dshAccelerometerSetBias (   devp,
  bp 
)    accelerometerSetBias(&((devp)->acc_if), bp)

Set bias values for the BaseAccelerometer.

Note
Bias must be expressed as milli-G.
The bias buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS3DSHDriver.
[in]bpa buffer which contains biases.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 623 of file lis3dsh.h.

#define lis3dshAccelerometerResetBias (   devp)    accelerometerResetBias(&((devp)->acc_if))

Reset bias values for the BaseAccelerometer.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]devppointer to LIS3DSHDriver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 638 of file lis3dsh.h.

#define lis3dshAccelerometerSetSensitivity (   devp,
  sp 
)    accelerometerSetSensitivity(&((devp)->acc_if), sp)

Set sensitivity values for the BaseAccelerometer.

Note
Sensitivity must be expressed as milli-G/LSB.
The sensitivity buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS3DSHDriver.
[in]spa buffer which contains sensitivities.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 655 of file lis3dsh.h.

#define lis3dshAccelerometerResetSensitivity (   devp)    accelerometerResetSensitivity(&((devp)->acc_if))

Reset sensitivity values for the BaseAccelerometer.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]devppointer to LIS3DSHDriver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 670 of file lis3dsh.h.

#define lis3dshAccelerometerSetFullScale (   devp,
  fs 
)    (devp)->vmt->acc_set_full_scale(devp, fs)

Changes the LIS3DSHDriver accelerometer fullscale value.

Note
This function also rescale sensitivities and biases based on previous and next fullscale value.
A recalibration is highly suggested after calling this function.
Parameters
[in]devppointer to LIS3DSHDriver.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 688 of file lis3dsh.h.

Typedef Documentation

typedef struct LIS3DSHDriver LIS3DSHDriver

Structure representing a LIS3DSH driver.

Definition at line 387 of file lis3dsh.h.

Enumeration Type Documentation

LIS3DSH full scale.

Enumerator
LIS3DSH_ACC_FS_2G 

Full scale ±2g.

LIS3DSH_ACC_FS_4G 

Full scale ±4g.

LIS3DSH_ACC_FS_6G 

Full scale ±6g.

LIS3DSH_ACC_FS_8G 

Full scale ±8g.

LIS3DSH_ACC_FS_16G 

Full scale ±16g.

Definition at line 392 of file lis3dsh.h.

LIS3DSH output data rate.

Enumerator
LIS3DSH_ACC_ODR_PD 

ODR 100 Hz.

LIS3DSH_ACC_ODR_3_125HZ 

ODR 3.125 Hz.

LIS3DSH_ACC_ODR_6_25HZ 

ODR 6.25 Hz.

LIS3DSH_ACC_ODR_12_5HZ 

ODR 12.5 Hz.

LIS3DSH_ACC_ODR_25HZ 

ODR 25 Hz.

LIS3DSH_ACC_ODR_50HZ 

ODR 50 Hz.

LIS3DSH_ACC_ODR_100HZ 

ODR 100 Hz.

LIS3DSH_ACC_ODR_400HZ 

ODR 400 Hz.

LIS3DSH_ACC_ODR_800HZ 

ODR 800 Hz.

LIS3DSH_ACC_ODR_1600HZ 

ODR 1600 Hz.

Definition at line 403 of file lis3dsh.h.

LIS3DSH anti-aliasing bandwidth.

Enumerator
LIS3DSH_ACC_BW_800HZ 

AA filter BW 800Hz.

LIS3DSH_ACC_BW_200HZ 

AA filter BW 200Hz.

LIS3DSH_ACC_BW_400HZ 

AA filter BW 400Hz.

LIS3DSH_ACC_BW_50HZ 

AA filter BW 50Hz.

Definition at line 419 of file lis3dsh.h.

LIS3DSH block data update.

Enumerator
LIS3DSH_ACC_BDU_CONTINUOUS 

Block data continuously updated.

LIS3DSH_ACC_BDU_BLOCKED 

Block data updated after reading.

Definition at line 429 of file lis3dsh.h.

Driver state machine possible states.

Enumerator
LIS3DSH_UNINIT 

Not initialized.

LIS3DSH_STOP 

Stopped.

LIS3DSH_READY 

Ready.

Definition at line 437 of file lis3dsh.h.

Function Documentation

static void lis3dshSPIReadRegister ( SPIDriver spip,
uint8_t  reg,
size_t  n,
uint8_t *  b 
)
static

Reads a generic register value using SPI.

Precondition
The SPI interface must be initialized and the driver started.
Note
Multiple write/read requires proper settings in CTRL_REG6.
Parameters
[in]spippointer to the SPI interface
[in]regstarting register address
[in]nnumber of adjacent registers to write
[in]bpointer to a buffer.

Definition at line 60 of file lis3dsh.c.

References spiReceive(), spiSelect(), spiSend(), and spiUnselect().

Referenced by acc_read_raw(), and acc_set_full_scale().

Here is the call graph for this function:

static void lis3dshSPIWriteRegister ( SPIDriver spip,
uint8_t  reg,
size_t  n,
uint8_t *  b 
)
static

Writes a value into a generic register using SPI.

Precondition
The SPI interface must be initialized and the driver started.
Note
Multiple write/read requires proper settings in CTRL_REG6.
Parameters
[in]spippointer to the SPI interface
[in]regstarting register address
[in]nnumber of adjacent registers to write
[in]bpointer to a buffer of values.

Definition at line 80 of file lis3dsh.c.

References spiSelect(), spiSend(), and spiUnselect().

Referenced by acc_set_full_scale(), lis3dshStart(), and lis3dshStop().

Here is the call graph for this function:

static size_t acc_get_axes_number ( void *  ip)
static

Return the number of axes of the BaseAccelerometer.

Parameters
[in]ippointer to BaseAccelerometer interface.
Returns
the number of axes.

Definition at line 98 of file lis3dsh.c.

References LIS3DSH_ACC_NUMBER_OF_AXES.

Referenced by acc_set_full_scale().

static msg_t acc_read_raw ( void *  ip,
int32_t  axes[] 
)
static

Retrieves raw data from the BaseAccelerometer.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer interface.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.

Definition at line 120 of file lis3dsh.c.

References LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, lis3dshSPIReadRegister(), MSG_OK, objGetInstance, osalDbgAssert, osalDbgCheck, SPI_READY, spiAcquireBus(), spiReleaseBus(), and spiStart().

Referenced by acc_read_cooked(), and acc_set_full_scale().

Here is the call graph for this function:

static msg_t acc_read_cooked ( void *  ip,
float  axes[] 
)
static

Retrieves cooked data from the BaseAccelerometer.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as milli-G.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer interface.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.

Definition at line 176 of file lis3dsh.c.

References acc_read_raw(), LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_set_full_scale().

Here is the call graph for this function:

static msg_t acc_set_bias ( void *  ip,
float *  bp 
)
static

Set bias values for the BaseAccelerometer.

Note
Bias must be expressed as milli-G.
The bias buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer interface.
[in]bpa buffer which contains biases.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 209 of file lis3dsh.c.

References LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_set_full_scale().

static msg_t acc_reset_bias ( void *  ip)
static

Reset bias values for the BaseAccelerometer.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]ippointer to BaseAccelerometer interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 238 of file lis3dsh.c.

References LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_set_full_scale().

static msg_t acc_set_sensivity ( void *  ip,
float *  sp 
)
static

Set sensitivity values for the BaseAccelerometer.

Note
Sensitivity must be expressed as milli-G/LSB.
The sensitivity buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer interface.
[in]spa buffer which contains sensitivities.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 268 of file lis3dsh.c.

References LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_set_full_scale().

static msg_t acc_reset_sensivity ( void *  ip)
static

Reset sensitivity values for the BaseAccelerometer.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]ippointer to BaseAccelerometer interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 297 of file lis3dsh.c.

References FALSE, LIS3DSH_ACC_FS_16G, LIS3DSH_ACC_FS_2G, LIS3DSH_ACC_FS_4G, LIS3DSH_ACC_FS_6G, LIS3DSH_ACC_FS_8G, LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, MSG_OK, MSG_RESET, objGetInstance, osalDbgAssert, and osalDbgCheck.

Referenced by acc_set_full_scale().

static msg_t acc_set_full_scale ( LIS3DSHDriver devp,
lis3dsh_acc_fs_t  fs 
)
static

Changes the LIS3DSHDriver accelerometer fullscale value.

Note
This function also rescale sensitivities and biases based on previous and next fullscale value.
A recalibration is highly suggested after calling this function.
Parameters
[in]devppointer to LIS3DSHDriver interface.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 346 of file lis3dsh.c.

References acc_get_axes_number(), acc_read_cooked(), acc_read_raw(), acc_reset_bias(), acc_reset_sensivity(), acc_set_bias(), acc_set_sensivity(), LIS3DSH_ACC_FS_16G, LIS3DSH_ACC_FS_2G, LIS3DSH_ACC_FS_4G, LIS3DSH_ACC_FS_6G, LIS3DSH_ACC_FS_8G, LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, lis3dshSPIReadRegister(), lis3dshSPIWriteRegister(), MSG_RESET, osalDbgAssert, osalDbgCheck, SPI_READY, spiAcquireBus(), spiReleaseBus(), and spiStart().

Here is the call graph for this function:

void lis3dshObjectInit ( LIS3DSHDriver devp)

Initializes an instance.

Parameters
[out]devppointer to the LIS3DSHDriver object
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 448 of file lis3dsh.c.

References LIS3DSHDriver::acc_if, LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_STOP, BaseAccelerometer::vmt, and LIS3DSHDriver::vmt.

void lis3dshStart ( LIS3DSHDriver devp,
const LIS3DSHConfig config 
)

Configures and activates LIS3DSH Complex Driver peripheral.

Parameters
[in]devppointer to the LIS3DSHDriver object
[in]configpointer to the LIS3DSHConfig object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 467 of file lis3dsh.c.

References FALSE, LIS3DSH_ACC_FS_16G, LIS3DSH_ACC_FS_2G, LIS3DSH_ACC_FS_4G, LIS3DSH_ACC_FS_6G, LIS3DSH_ACC_FS_8G, LIS3DSH_ACC_NUMBER_OF_AXES, LIS3DSH_READY, LIS3DSH_STOP, lis3dshSPIWriteRegister(), osalDbgAssert, osalDbgCheck, osalThreadSleepMilliseconds, spiAcquireBus(), spiReleaseBus(), and spiStart().

Here is the call graph for this function:

void lis3dshStop ( LIS3DSHDriver devp)

Deactivates the LIS3DSH Complex Driver peripheral.

Parameters
[in]devppointer to the LIS3DSHDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 613 of file lis3dsh.c.

References LIS3DSH_READY, LIS3DSH_STOP, lis3dshSPIWriteRegister(), osalDbgAssert, osalDbgCheck, spiAcquireBus(), spiReleaseBus(), spiStart(), and spiStop().

Here is the call graph for this function: