46 #define EX_LIS302DL_VERSION "1.1.0" 51 #define EX_LIS302DL_MAJOR 1 56 #define EX_LIS302DL_MINOR 1 61 #define EX_LIS302DL_PATCH 0 72 #define LIS302DL_ACC_NUMBER_OF_AXES 3U 74 #define LIS302DL_ACC_2G 2.0f 75 #define LIS302DL_ACC_8G 8.0f 77 #define LIS302DL_ACC_SENS_2G 18.0f 78 #define LIS302DL_ACC_SENS_8G 72.0f 80 #define LIS302DL_ACC_BIAS 0.0f 87 #define LIS302DL_DI_MASK 0xFF 88 #define LIS302DL_DI(n) (1 << n) 89 #define LIS302DL_AD_MASK 0x3F 90 #define LIS302DL_AD(n) (1 << n) 91 #define LIS302DL_MS (1 << 6) 92 #define LIS302DL_RW (1 << 7) 99 #define LIS302DL_AD_WHO_AM_I 0x0F 100 #define LIS302DL_AD_CTRL_REG1 0x20 101 #define LIS302DL_AD_CTRL_REG2 0x21 102 #define LIS302DL_AD_CTRL_REG3 0x22 103 #define LIS302DL_AD_HP_FILER_RESET 0x23 104 #define LIS302DL_AD_STATUS_REG 0x27 105 #define LIS302DL_AD_OUT_X 0x29 106 #define LIS302DL_AD_OUT_Y 0x2B 107 #define LIS302DL_AD_OUT_Z 0x2D 108 #define LIS302DL_AD_FF_WU_CFG_1 0x30 109 #define LIS302DL_AD_FF_WU_SRC_1 0x31 110 #define LIS302DL_AD_FF_WU_THS_1 0x32 111 #define LIS302DL_AD_FF_WU_DURATION_1 0x33 112 #define LIS302DL_AD_FF_WU_CFG_2 0x34 113 #define LIS302DL_AD_FF_WU_SRC_2 0x35 114 #define LIS302DL_AD_FF_WU_THS_2 0x36 115 #define LIS302DL_AD_FF_WU_DURATION_2 0x37 116 #define LIS302DL_AD_CLICK_CFG 0x38 117 #define LIS302DL_AD_CLICK_SRC 0x39 118 #define LIS302DL_AD_CLICK_THSY_X 0x3B 119 #define LIS302DL_AD_CLICK_THSZ 0x3C 120 #define LIS302DL_AD_CLICK_TIME_LIMIT 0x3D 121 #define LIS302DL_AD_CLICK_LATENCY 0x3E 122 #define LIS302DL_AD_CLICK_WINDOW 0x3F 129 #define LIS302DL_CTRL_REG1_MASK 0xFF 130 #define LIS302DL_CTRL_REG1_XEN (1 << 0) 131 #define LIS302DL_CTRL_REG1_YEN (1 << 1) 132 #define LIS302DL_CTRL_REG1_ZEN (1 << 2) 133 #define LIS302DL_CTRL_REG1_STM (1 << 3) 134 #define LIS302DL_CTRL_REG1_STP (1 << 4) 135 #define LIS302DL_CTRL_REG1_FS_MASK 0x20 136 #define LIS302DL_CTRL_REG1_FS (1 << 5) 137 #define LIS302DL_CTRL_REG1_PD (1 << 6) 138 #define LIS302DL_CTRL_REG1_DR (1 << 7) 145 #define LIS302DL_CTRL_REG2_MASK 0xDF 146 #define LIS302DL_CTRL_REG2_HPCF1 (1 << 0) 147 #define LIS302DL_CTRL_REG2_HPCF2 (1 << 1) 148 #define LIS302DL_CTRL_REG2_HPFFWU1 (1 << 2) 149 #define LIS302DL_CTRL_REG2_HPFFWU2 (1 << 3) 150 #define LIS302DL_CTRL_REG2_FDS (1 << 4) 151 #define LIS302DL_CTRL_REG2_BOOT (1 << 6) 152 #define LIS302DL_CTRL_REG2_SIM (1 << 7) 159 #define LIS302DL_CTRL_REG3_MASK 0xFF 160 #define LIS302DL_CTRL_REG3_I1CFG0 (1 << 0) 161 #define LIS302DL_CTRL_REG3_I1CFG1 (1 << 1) 162 #define LIS302DL_CTRL_REG3_I1CFG2 (1 << 2) 163 #define LIS302DL_CTRL_REG3_I2CFG0 (1 << 3) 164 #define LIS302DL_CTRL_REG3_I2CFG1 (1 << 4) 165 #define LIS302DL_CTRL_REG3_I2CFG2 (1 << 5) 166 #define LIS302DL_CTRL_REG3_PP_OD (1 << 6) 167 #define LIS302DL_CTRL_REG3_IHL (1 << 7) 183 #if !defined(LIS302DL_USE_SPI) || defined(__DOXYGEN__) 184 #define LIS302DL_USE_SPI TRUE 193 #if !defined(LIS302DL_SHARED_SPI) || defined(__DOXYGEN__) 194 #define LIS302DL_SHARED_SPI FALSE 202 #if !defined(LIS302DL_USE_I2C) || defined(__DOXYGEN__) 203 #define LIS302DL_USE_I2C FALSE 212 #if !defined(LIS302DL_SHARED_I2C) || defined(__DOXYGEN__) 213 #define LIS302DL_SHARED_I2C FALSE 222 #if !defined(LIS302DL_ACC_USE_ADVANCED) || defined(__DOXYGEN__) 223 #define LIS302DL_ACC_USE_ADVANCED FALSE 231 #if !(LIS302DL_USE_SPI ^ LIS302DL_USE_I2C) 232 #error "LIS302DL_USE_SPI and LIS302DL_USE_I2C cannot be both true or both false" 235 #if LIS302DL_USE_SPI && !HAL_USE_SPI 236 #error "LIS302DL_USE_SPI requires HAL_USE_SPI" 239 #if LIS302DL_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION 240 #error "LIS302DL_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION" 243 #if LIS302DL_USE_I2C && !HAL_USE_I2C 244 #error "LIS302DL_USE_I2C requires HAL_USE_I2C" 247 #if LIS302DL_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION 248 #error "LIS302DL_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION" 255 #error "LIS302DL over I2C still not supported" 312 #if (LIS302DL_USE_SPI) || defined(__DOXYGEN__) 322 #if (LIS302DL_USE_I2C) || defined(__DOXYGEN__) 348 #if LIS302DL_USE_ADVANCED || defined(__DOXYGEN__) 359 #define _lis302dl_methods_alone \ 361 msg_t (*set_full_scale)(LIS302DLDriver *devp, lis302dl_acc_fs_t fs); 367 #define _lis302dl_methods \ 368 _base_object_methods \ 369 _lis302dl_methods_alone 383 #define _lis302dl_data \ 385 lis302dl_state_t state; \ 387 const LIS302DLConfig *config; \ 391 float accsensitivity[LIS302DL_ACC_NUMBER_OF_AXES]; \ 393 int32_t accbias[LIS302DL_ACC_NUMBER_OF_AXES]; \ 422 #define lis302dlAccelerometerGetAxesNumber(devp) \ 423 accelerometerGetAxesNumber(&((devp)->acc_if)) 443 #define lis302dlAccelerometerReadRaw(devp, axes) \ 444 accelerometerReadRaw(&((devp)->acc_if), axes) 465 #define lis302dlAccelerometerReadCooked(devp, axes) \ 466 accelerometerReadCooked(&((devp)->acc_if), axes) 482 #define lis302dlAccelerometerSetBias(devp, bp) \ 483 accelerometerSetBias(&((devp)->acc_if), bp) 497 #define lis302dlAccelerometerResetBias(devp) \ 498 accelerometerResetBias(&((devp)->acc_if)) 514 #define lis302dlAccelerometerSetSensitivity(devp, sp) \ 515 accelerometerSetSensitivity(&((devp)->acc_if), sp) 529 #define lis302dlAccelerometerResetSensitivity(devp) \ 530 accelerometerResetSensitivity(&((devp)->acc_if)) 547 #define lis302dlAccelerometerSetFullScale(devp, fs) \ 548 (devp)->vmt->acc_set_full_scale(devp, fs)
void lis302dlStop(LIS302DLDriver *devp)
Deactivates the LIS302DL Complex Driver peripheral.
Type of I2C driver configuration structure.
lis302dl_state_t
Driver state machine possible states.
float * accbias
LIS302DL accelerometer subsystem initial bias.
lis302dl_acc_odr_t
LIS302DL output data rate and bandwidth.
SPIDriver * spip
SPI driver associated to this LIS302DL.
void lis302dlStart(LIS302DLDriver *devp, const LIS302DLConfig *config)
Configures and activates LIS302DL Complex Driver peripheral.
BaseAccelerometer acc_if
Base accelerometer interface.
const struct LIS302DLVMT * vmt
Virtual Methods Table.
float * accsensitivity
LIS302DL accelerometer subsystem initial sensitivity.
Structure representing an I2C driver.
lis302dl_acc_odr_t accoutputdatarate
LIS302DL output data rate selection.
Driver configuration structure.
LIS302DL 3-axis accelerometer class.
lis302dl_acc_fs_t
LIS302DL full scale.
lis302dl_acc_hp_t
LIS302DL high pass filtering.
Generic accelerometer interface header.
LIS302DL configuration structure.
I2CDriver * i2cp
I2C driver associated to this LIS302DL.
const SPIConfig * spicfg
SPI configuration associated to this LIS302DL.
lis302dl_acc_hp_t acchighpass
LIS302DL high pass filtering.
#define _lis302dl_methods
LIS302DL specific methods with inherited ones.
#define _lis302dl_data
LIS302DLDriver specific data.
lis302dl_acc_fs_t accfullscale
LIS302DL accelerometer subsystem initial full scale.
void lis302dlObjectInit(LIS302DLDriver *devp)
Initializes an instance.
const I2CConfig * i2ccfg
I2C configuration associated to this LIS302DL.
Base accelerometer class.
LIS302DL accelerometer virtual methods table.
Structure representing an SPI driver.