49#if (LSM6DSL_USE_I2C) || defined(__DOXYGEN__)
64 uint8_t* rxbuf,
size_t n) {
83#define lsm6dslI2CWriteRegister(i2cp, sad, txbuf, n) \
84 i2cMasterTransmitTimeout(i2cp, sad, txbuf, n + 1, NULL, 0, \
129 "acc_read_raw(), invalid state");
132 "acc_read_raw(), channel not ready");
134#if LSM6DSL_SHARED_I2C
137 devp->config->i2ccfg);
144#if LSM6DSL_SHARED_I2C
150 tmp = buff[2 * i] + (buff[2 * i + 1] << 8);
151 axes[i] = (int32_t)tmp;
185 "acc_read_cooked(), invalid state");
189 axes[i] = (raw[i] * devp->accsensitivity[i]) - devp->accbias[i];
217 "acc_set_bias(), invalid state");
220 devp->accbias[i] = bp[i];
246 "acc_reset_bias(), invalid state");
276 "acc_set_sensivity(), invalid state");
279 devp->accsensitivity[i] = sp[i];
305 "acc_reset_sensivity(), invalid state");
347 "acc_set_full_scale(), invalid state");
349 "acc_set_full_scale(), channel not ready");
373 (newfs != devp->accfullscale)) {
375 scale = newfs / devp->accfullscale;
376 devp->accfullscale = newfs;
378#if LSM6DSL_SHARED_I2C
381 devp->config->i2ccfg);
386 devp->config->slaveaddress,
389#if LSM6DSL_SHARED_I2C
399#if LSM6DSL_SHARED_I2C
401 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
405 devp->config->slaveaddress, buff, 1);
407#if LSM6DSL_SHARED_I2C
415 devp->accsensitivity[i] *= scale;
416 devp->accbias[i] *= scale;
464 "gyro_read_raw(), invalid state");
467 "gyro_read_raw(), channel not ready");
469#if LSM6DSL_SHARED_I2C
472 devp->config->i2ccfg);
479#if LSM6DSL_SHARED_I2C
485 tmp = buff[2 * i] + (buff[2 * i + 1] << 8);
486 axes[i] = (int32_t)tmp;
520 "gyro_read_cooked(), invalid state");
524 axes[i] = (raw[i] * devp->gyrosensitivity[i]) - devp->gyrobias[i];
554 "gyro_sample_bias(), invalid state");
557 "gyro_sample_bias(), channel not ready");
572 devp->gyrobias[i] *= devp->gyrosensitivity[i];
600 "gyro_set_bias(), invalid state");
603 devp->gyrobias[i] = bp[i];
629 "gyro_reset_bias(), invalid state");
659 "gyro_set_sensivity(), invalid state");
662 devp->gyrosensitivity[i] = sp[i];
688 "gyro_reset_sensivity(), invalid state");
732 "gyro_set_full_scale(), invalid state");
735 "gyro_set_full_scale(), channel not ready");
757 if(newfs != devp->gyrofullscale) {
758 scale = newfs / devp->gyrofullscale;
759 devp->gyrofullscale = newfs;
762#if LSM6DSL_SHARED_I2C
765 devp->config->i2ccfg);
770 devp->config->slaveaddress,
773#if LSM6DSL_SHARED_I2C
783#if LSM6DSL_SHARED_I2C
786 devp->config->i2ccfg);
792#if LSM6DSL_SHARED_I2C
799 devp->gyrosensitivity[i] *= scale;
800 devp->gyrobias[i] *= scale;
863 "lsm6dslStart(), invalid state");
865 devp->config = config;
873#if LSM6DSL_SHARED_I2C
877 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
881#if LSM6DSL_SHARED_I2C
891 cr[1] = devp->config->accodr |
892 devp->config->accfullscale;
896 cr[2] = devp->config->gyroodr |
897 devp->config->gyrofullscale;
902#if LSM6DSL_USE_ADVANCED || defined(__DOXYGEN__)
903 cr[3] |= devp->config->endianness | devp->config->bdu;
909#if LSM6DSL_USE_ADVANCED || defined(__DOXYGEN__)
925#if LSM6DSL_USE_ADVANCED || defined(__DOXYGEN__)
926 cr[6] |= devp->config->acclpmode;
929#if LSM6DSL_USE_ADVANCED || defined(__DOXYGEN__)
931 cr[6] |= devp->config->gyrolpfilter;
941#if LSM6DSL_USE_ADVANCED || defined(__DOXYGEN__)
942 cr[7] |= devp->config->gyrolpmode;
960#if LSM6DSL_SHARED_I2C
962 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
968#if LSM6DSL_SHARED_I2C
976 if(devp->config->accsensitivity == NULL)
979 devp->accsensitivity[i] = devp->config->accsensitivity[i];
985 if(devp->config->accsensitivity == NULL)
988 devp->accsensitivity[i] = devp->config->accsensitivity[i];
994 if(devp->config->accsensitivity == NULL)
997 devp->accsensitivity[i] = devp->config->accsensitivity[i];
1003 if(devp->config->accsensitivity == NULL)
1006 devp->accsensitivity[i] = devp->config->accsensitivity[i];
1014 if(devp->config->accbias != NULL)
1016 devp->accbias[i] = devp->config->accbias[i];
1023 if(devp->config->gyrosensitivity == NULL)
1026 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1032 if(devp->config->gyrosensitivity == NULL)
1035 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1041 if(devp->config->gyrosensitivity == NULL)
1044 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1050 if(devp->config->gyrosensitivity == NULL)
1053 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1059 if(devp->config->gyrosensitivity == NULL)
1062 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1070 if(devp->config->gyrobias != NULL)
1072 devp->gyrobias[i] = devp->config->gyrobias[i];
1096 "lsm6dslStop(), invalid state");
1100#if LSM6DSL_SHARED_I2C
1102 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
1115#if LSM6DSL_SHARED_I2C
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
static const struct BaseAccelerometerVMT vmt_accelerometer
static const struct ADXL317VMT vmt_device
static msg_t acc_set_full_scale(ADXL355Driver *devp, adxl355_acc_fs_t fs)
Changes the ADXL355Driver accelerometer fullscale value.
#define objGetInstance(type, ip)
Returns the instance pointer starting from an interface pointer.
msg_t i2cStart(I2CDriver *i2cp, const I2CConfig *config)
Configures and activates the I2C peripheral.
msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp, i2caddr_t addr, const uint8_t *txbuf, size_t txbytes, uint8_t *rxbuf, size_t rxbytes, sysinterval_t timeout)
Sends data via the I2C bus.
void i2cReleaseBus(I2CDriver *i2cp)
Releases exclusive access to the I2C bus.
void i2cStop(I2CDriver *i2cp)
Deactivates the I2C peripheral.
void i2cAcquireBus(I2CDriver *i2cp)
Gains exclusive access to the I2C bus.
struct hal_i2c_driver I2CDriver
Type of a structure representing an I2C driver.
static const struct BaseGyroscopeVMT vmt_gyroscope
static msg_t gyro_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseGyroscope.
static size_t gyro_get_axes_number(void *ip)
Return the number of axes of the BaseGyroscope.
static msg_t gyro_read_raw(void *ip, int32_t axes[L3GD20_GYRO_NUMBER_OF_AXES])
Retrieves raw data from the BaseGyroscope.
static msg_t gyro_sample_bias(void *ip)
Samples bias values for the BaseGyroscope.
static msg_t gyro_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseGyroscope.
static msg_t gyro_set_bias(void *ip, float *bp)
Set bias values for the BaseGyroscope.
static msg_t gyro_set_full_scale(L3GD20Driver *devp, l3gd20_fs_t fs)
Changes the L3GD20Driver gyroscope fullscale value.
static msg_t gyro_reset_sensivity(void *ip)
Reset sensitivity values for the BaseGyroscope.
static msg_t gyro_reset_bias(void *ip)
Reset bias values for the BaseGyroscope.
#define LSM6DSL_GYRO_SENS_250DPS
void lsm6dslObjectInit(LSM6DSLDriver *devp)
Initializes an instance.
#define LSM6DSL_ACC_SENS_2G
#define lsm6dslI2CWriteRegister(i2cp, sad, txbuf, n)
Writes a value into a register using I2C.
#define LSM6DSL_GYRO_125DPS
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
lsm6dsl_gyro_fs_t
LSM6DSL gyroscope subsystem full scale.
void lsm6dslStart(LSM6DSLDriver *devp, const LSM6DSLConfig *config)
Configures and activates LSM6DSL Complex Driver peripheral.
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
lsm6dsl_acc_fs_t
LSM6DSL accelerometer subsystem full scale.
lsm6dsl_sad_t
Accelerometer and Gyroscope Slave Address.
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
#define LSM6DSL_GYRO_SENS_125DPS
#define LSM6DSL_GYRO_1000DPS
static msg_t acc_set_full_scale(LSM6DSLDriver *devp, lsm6dsl_acc_fs_t fs)
Changes the LSM6DSLDriver accelerometer fullscale value.
#define LSM6DSL_ACC_SENS_16G
#define LSMDSL_CTRL4_C_LPF1_SEL_G
static msg_t gyro_read_raw(void *ip, int32_t axes[LSM6DSL_GYRO_NUMBER_OF_AXES])
Retrieves raw data from the BaseGyroscope.
#define LSM6DSL_ACC_SENS_8G
#define LSM6DSL_GYRO_2000DPS
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
#define LSM6DSL_ACC_NUMBER_OF_AXES
LSM6DSL accelerometer subsystem characteristics.
#define LSMDSL_CTRL1_XL_FS_MASK
#define LSM6DSL_AD_CTRL3_C
msg_t lsm6dslI2CReadRegister(I2CDriver *i2cp, lsm6dsl_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
Reads registers value using I2C.
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
void lsm6dslStop(LSM6DSLDriver *devp)
Deactivates the LSM6DSL Complex Driver peripheral.
#define LSMDSL_CTRL3_C_IF_INC
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
static msg_t gyro_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseGyroscope.
static size_t gyro_get_axes_number(void *ip)
Return the number of axes of the BaseGyroscope.
#define LSM6DSL_GYRO_BIAS_SETTLING_US
Settling time for gyroscope bias removal.
#define LSM6DSL_GYRO_SENS_1000DPS
#define LSM6DSL_GYRO_SENS_2000DPS
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
static msg_t gyro_set_full_scale(LSM6DSLDriver *devp, lsm6dsl_gyro_fs_t fs)
Changes the LSM6DSLDriver gyroscope fullscale value.
static msg_t gyro_sample_bias(void *ip)
Samples bias values for the BaseGyroscope.
#define LSMDSL_CTRL2_G_FS_MASK
static msg_t gyro_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseGyroscope.
#define LSM6DSL_GYRO_NUMBER_OF_AXES
L3GD20 gyroscope system characteristics.
#define LSM6DSL_GYRO_BIAS_ACQ_TIMES
Number of acquisitions for gyroscope bias removal.
#define LSM6DSL_AD_OUTX_L_XL
static msg_t gyro_set_bias(void *ip, float *bp)
Set bias values for the BaseGyroscope.
#define LSM6DSL_ACC_SENS_4G
#define LSM6DSL_GYRO_250DPS
#define LSM6DSL_GYRO_500DPS
#define LSM6DSL_GYRO_BIAS
#define LSM6DSL_GYRO_SENS_500DPS
#define LSM6DSL_AD_OUTX_L_G
static msg_t gyro_reset_sensivity(void *ip)
Reset sensitivity values for the BaseGyroscope.
#define LSM6DSL_AD_CTRL2_G
#define LSM6DSL_AD_CTRL1_XL
static msg_t gyro_reset_bias(void *ip)
Reset bias values for the BaseGyroscope.
@ LSM6DSL_GYRO_FS_1000DPS
@ LSM6DSL_GYRO_FS_2000DPS
@ LSM6DSL_GYRO_LPF_DISABLED
#define osalThreadSleepMicroseconds(usecs)
Delays the invoking thread for the specified number of microseconds.
#define osalDbgAssert(c, remark)
Condition assertion.
#define osalDbgCheck(c)
Function parameters check.
#define osalThreadSleepMilliseconds(msecs)
Delays the invoking thread for the specified number of milliseconds.
#define FALSE
Generic 'false' preprocessor boolean constant.
#define MSG_OK
Normal wakeup message.
#define MSG_RESET
Wakeup caused by a reset condition.
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
LSM6DSL MEMS interface module header.
Base accelerometer class.
const struct BaseAccelerometerVMT * vmt
Virtual Methods Table.
BaseAccelerometer virtual methods table.
const struct BaseGyroscopeVMT * vmt
Virtual Methods Table.
BaseGyroscope virtual methods table.
LSM6DSL configuration structure.
LSM6DSL 6-axis accelerometer/gyroscope class.
BaseGyroscope gyro_if
Base gyroscope interface.
BaseAccelerometer acc_if
Base accelerometer interface.
const struct LSM6DSLVMT * vmt
Virtual Methods Table.
LSM6DSL virtual methods table.