49#if (LSM6DS0_USE_I2C) || defined(__DOXYGEN__)
64 uint8_t* rxbuf,
size_t n) {
83#define lsm6ds0I2CWriteRegister(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 LSM6DS0_SHARED_I2C
137 devp->config->i2ccfg);
144#if LSM6DS0_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 LSM6DS0_SHARED_I2C
381 devp->config->i2ccfg);
386 devp->config->slaveaddress,
389#if LSM6DS0_SHARED_I2C
399#if LSM6DS0_SHARED_I2C
401 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
405 devp->config->slaveaddress, buff, 1);
407#if LSM6DS0_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 LSM6DS0_SHARED_I2C
472 devp->config->i2ccfg);
479#if LSM6DS0_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");
727 "gyro_set_full_scale(), invalid state");
730 "gyro_set_full_scale(), channel not ready");
746 if(newfs != devp->gyrofullscale) {
747 scale = newfs / devp->gyrofullscale;
748 devp->gyrofullscale = newfs;
751#if LSM6DS0_SHARED_I2C
754 devp->config->i2ccfg);
759 devp->config->slaveaddress,
762#if LSM6DS0_SHARED_I2C
772#if LSM6DS0_SHARED_I2C
775 devp->config->i2ccfg);
781#if LSM6DS0_SHARED_I2C
788 devp->gyrosensitivity[i] *= scale;
789 devp->gyrobias[i] *= scale;
852 "lsm6ds0Start(), invalid state");
854 devp->config = config;
862#if LSM6DS0_USE_ADVANCED || defined(__DOXYGEN__)
863 cr[1] |= devp->config->endianness | devp->config->bdu;
867#if LSM6DS0_SHARED_I2C
871 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
875#if LSM6DS0_SHARED_I2C
887#if LSM6DS0_USE_ADVANCED || defined(__DOXYGEN__)
888 cr[1] |= devp->config->accdecmode;
894 cr[2] = devp->config->accodr |
895 devp->config->accfullscale;
899#if LSM6DS0_SHARED_I2C
901 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
907#if LSM6DS0_SHARED_I2C
915 if(devp->config->accsensitivity == NULL)
918 devp->accsensitivity[i] = devp->config->accsensitivity[i];
924 if(devp->config->accsensitivity == NULL)
927 devp->accsensitivity[i] = devp->config->accsensitivity[i];
933 if(devp->config->accsensitivity == NULL)
936 devp->accsensitivity[i] = devp->config->accsensitivity[i];
942 if(devp->config->accsensitivity == NULL)
945 devp->accsensitivity[i] = devp->config->accsensitivity[i];
953 if(devp->config->accbias != NULL)
955 devp->accbias[i] = devp->config->accbias[i];
966 cr[1] = devp->config->gyrofullscale |
967 devp->config->gyroodr;
973#if LSM6DS0_USE_ADVANCED || defined(__DOXYGEN__)
974 cr[2] |= devp->config->gyrooutsel;
981#if LSM6DS0_USE_ADVANCED || defined(__DOXYGEN__)
982 cr[3] |= devp->config->gyrohpfenable |
983 devp->config->gyrolowmodecfg |
984 devp->config->gyrohpcfg;
994#if LSM6DS0_SHARED_I2C
996 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
1002#if LSM6DS0_SHARED_I2C
1013#if LSM6DS0_SHARED_I2C
1015 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
1021#if LSM6DS0_SHARED_I2C
1028 if(devp->config->gyrosensitivity == NULL)
1031 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1037 if(devp->config->gyrosensitivity == NULL)
1040 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1046 if(devp->config->gyrosensitivity == NULL)
1049 devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
1057 if(devp->config->gyrobias != NULL)
1059 devp->gyrobias[i] = devp->config->gyrobias[i];
1083 "lsm6ds0Stop(), invalid state");
1087#if LSM6DS0_SHARED_I2C
1089 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
1105#if LSM6DS0_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 LSM6DS0_ACC_SENS_2G
#define LSM6DS0_CTRL_REG6_XL_FS_MASK
#define LSM6DS0_AD_OUT_X_L_XL
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
#define LSM6DS0_CTRL_REG1_G_FS_MASK
#define LSM6DS0_CTRL_REG9_SLEEP_G
void lsm6ds0Stop(LSM6DS0Driver *devp)
Deactivates the LSM6DS0 Complex Driver peripheral.
#define LSM6DS0_ACC_SENS_16G
static msg_t acc_set_full_scale(LSM6DS0Driver *devp, lsm6ds0_acc_fs_t fs)
Changes the LSM6DS0Driver accelerometer fullscale value.
void lsm6ds0Start(LSM6DS0Driver *devp, const LSM6DS0Config *config)
Configures and activates LSM6DS0 Complex Driver peripheral.
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
#define LSM6DS0_GYRO_BIAS
#define LSM6DS0_CTRL_REG4_ZEN_G
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
#define LSM6DS0_AD_CTRL_REG9
#define LSM6DS0_AD_OUT_X_L_G
#define LSM6DS0_CTRL_REG5_XL_XEN_XL
lsm6ds0_sad_t
Accelerometer and Gyroscope Slave Address.
#define LSM6DS0_ACC_SENS_8G
#define LSM6DS0_GYRO_2000DPS
#define LSM6DS0_GYRO_NUMBER_OF_AXES
L3GD20 gyroscope system characteristics.
#define LSM6DS0_GYRO_500DPS
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
#define LSM6DS0_CTRL_REG4_XEN_G
void lsm6ds0ObjectInit(LSM6DS0Driver *devp)
Initializes an instance.
#define LSM6DS0_GYRO_SENS_2000DPS
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
#define lsm6ds0I2CWriteRegister(i2cp, sad, txbuf, n)
Writes a value into a register using I2C.
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
#define LSM6DS0_AD_CTRL_REG8
static msg_t gyro_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseGyroscope.
#define LSM6DS0_CTRL_REG8_IF_ADD_INC
static size_t gyro_get_axes_number(void *ip)
Return the number of axes of the BaseGyroscope.
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
#define LSM6DS0_AD_CTRL_REG1_G
#define LSM6DS0_CTRL_REG5_XL_ZEN_XL
lsm6ds0_acc_fs_t
LSM6DS0 accelerometer subsystem full scale.
static msg_t gyro_sample_bias(void *ip)
Samples bias values for the BaseGyroscope.
#define LSM6DS0_AD_CTRL_REG6_XL
static msg_t gyro_set_full_scale(LSM6DS0Driver *devp, lsm6ds0_gyro_fs_t fs)
Changes the LSM6DS0Driver gyroscope fullscale value.
static msg_t gyro_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseGyroscope.
#define LSM6DS0_GYRO_BIAS_ACQ_TIMES
Number of acquisitions for gyroscope bias removal.
#define LSM6DS0_GYRO_SENS_245DPS
#define LSM6DS0_CTRL_REG4_YEN_G
#define LSM6DS0_CTRL_REG5_XL_YEN_XL
#define LSM6DS0_ACC_SENS_4G
static msg_t gyro_set_bias(void *ip, float *bp)
Set bias values for the BaseGyroscope.
#define LSM6DS0_GYRO_BIAS_SETTLING_US
Settling time for gyroscope bias removal.
#define LSM6DS0_ACC_NUMBER_OF_AXES
LSM6DS0 accelerometer subsystem characteristics.
lsm6ds0_gyro_fs_t
LSM6DS0 gyroscope subsystem full scale.
#define LSM6DS0_GYRO_SENS_500DPS
#define LSM6DS0_GYRO_245DPS
static msg_t gyro_reset_sensivity(void *ip)
Reset sensitivity values for the BaseGyroscope.
#define LSM6DS0_AD_CTRL_REG5_XL
static msg_t gyro_reset_bias(void *ip)
Reset bias values for the BaseGyroscope.
static msg_t gyro_read_raw(void *ip, int32_t axes[LSM6DS0_GYRO_NUMBER_OF_AXES])
Retrieves raw data from the BaseGyroscope.
msg_t lsm6ds0I2CReadRegister(I2CDriver *i2cp, lsm6ds0_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
Reads registers value using I2C.
@ LSM6DS0_GYRO_FS_2000DPS
#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.
LSM6DS0 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.
LSM6DS0 configuration structure.
LSM6DS0 6-axis accelerometer/gyroscope class.
BaseGyroscope gyro_if
Base gyroscope interface.
const struct LSM6DS0VMT * vmt
Virtual Methods Table.
BaseAccelerometer acc_if
Base accelerometer interface.
LSM6DS0 virtual methods table.