ChibiOS  21.6.0
lis3dsh.h File Reference

LIS3DSH MEMS interface module header. More...

#include "ex_accelerometer.h"

Go to the source code of this file.

Data Structures

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

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...
 

Functions

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...
 

LIS3DSH data structures and types

#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...
 
enum  lis3dsh_acc_fs_t {
  LIS3DSH_ACC_FS_2G = 0x00, LIS3DSH_ACC_FS_4G = 0x08, LIS3DSH_ACC_FS_6G = 0x10, LIS3DSH_ACC_FS_8G = 0x18,
  LIS3DSH_ACC_FS_16G = 0x20
}
 LIS3DSH full scale. More...
 
enum  lis3dsh_acc_odr_t {
  LIS3DSH_ACC_ODR_PD = 0x00, LIS3DSH_ACC_ODR_3_125HZ = 0x10, LIS3DSH_ACC_ODR_6_25HZ = 0x20, LIS3DSH_ACC_ODR_12_5HZ = 0x30,
  LIS3DSH_ACC_ODR_25HZ = 0x40, LIS3DSH_ACC_ODR_50HZ = 0x50, LIS3DSH_ACC_ODR_100HZ = 0x60, LIS3DSH_ACC_ODR_400HZ = 0x70,
  LIS3DSH_ACC_ODR_800HZ = 0x80, LIS3DSH_ACC_ODR_1600HZ = 0x90
}
 LIS3DSH output data rate. More...
 
enum  lis3dsh_acc_bw_t { LIS3DSH_ACC_BW_800HZ = 0x00, LIS3DSH_ACC_BW_200HZ = 0x40, LIS3DSH_ACC_BW_400HZ = 0x80, LIS3DSH_ACC_BW_50HZ = 0xC0 }
 LIS3DSH anti-aliasing bandwidth. More...
 
enum  lis3dsh_acc_bdu_t { LIS3DSH_ACC_BDU_CONTINUOUS = 0x00, LIS3DSH_ACC_BDU_BLOCKED = 0x80 }
 LIS3DSH block data update. More...
 
enum  lis3dsh_state_t { LIS3DSH_UNINIT = 0, LIS3DSH_STOP = 1, LIS3DSH_READY = 2 }
 Driver state machine possible states. More...
 
typedef struct LIS3DSHDriver LIS3DSHDriver
 Structure representing a LIS3DSH driver. More...
 

Detailed Description

LIS3DSH MEMS interface module header.

Definition in file lis3dsh.h.