Updated LSM6DS0 driver to v 1.0.4 (Fixing Bug #915).

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11447 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Rocco Marco Guglielmi 2018-02-05 11:24:40 +00:00
parent 8c23b103dd
commit 6b491d1eda
2 changed files with 52 additions and 54 deletions

View File

@ -554,28 +554,17 @@ static msg_t gyro_set_full_scale(void *ip, lsm6ds0_gyro_fs_t fs) {
return msg; return msg;
} }
static const struct BaseSensorVMT vmt_basesensor = { static const struct BaseSensorVMT vmt_sensor = {
sens_get_axes_number, sens_read_raw, sens_read_cooked sens_get_axes_number, sens_read_raw, sens_read_cooked
}; };
static const struct BaseGyroscopeVMT vmt_basegyroscope = { static const struct LSM6DS0AccelerometerVMT vmt_accelerometer = {
gyro_get_axes_number, gyro_read_raw, gyro_read_cooked,
gyro_sample_bias, gyro_set_bias, gyro_reset_bias,
gyro_set_sensivity, gyro_reset_sensivity
};
static const struct BaseAccelerometerVMT vmt_baseaccelerometer = {
acc_get_axes_number, acc_read_raw, acc_read_cooked,
acc_set_bias, acc_reset_bias, acc_set_sensivity, acc_reset_sensivity
};
static const struct LSM6DS0ACCVMT vmt_lsm6ds0acc = {
acc_get_axes_number, acc_read_raw, acc_read_cooked, acc_get_axes_number, acc_read_raw, acc_read_cooked,
acc_set_bias, acc_reset_bias, acc_set_sensivity, acc_reset_sensivity, acc_set_bias, acc_reset_bias, acc_set_sensivity, acc_reset_sensivity,
acc_set_full_scale acc_set_full_scale
}; };
static const struct LSM6DS0GYROVMT vmt_lsm6ds0gyro = { static const struct LSM6DS0GyroscopeVMT vmt_gyroscope = {
gyro_get_axes_number, gyro_read_raw, gyro_read_cooked, gyro_get_axes_number, gyro_read_raw, gyro_read_cooked,
gyro_sample_bias, gyro_set_bias, gyro_reset_bias, gyro_sample_bias, gyro_set_bias, gyro_reset_bias,
gyro_set_sensivity, gyro_reset_sensivity, gyro_set_full_scale gyro_set_sensivity, gyro_reset_sensivity, gyro_set_full_scale
@ -594,11 +583,9 @@ static const struct LSM6DS0GYROVMT vmt_lsm6ds0gyro = {
*/ */
void lsm6ds0ObjectInit(LSM6DS0Driver *devp) { void lsm6ds0ObjectInit(LSM6DS0Driver *devp) {
uint32_t i; uint32_t i;
devp->vmt_basesensor = &vmt_basesensor; devp->vmt_sensor = &vmt_sensor;
devp->vmt_baseaccelerometer = &vmt_baseaccelerometer; devp->vmt_accelerometer = &vmt_accelerometer;
devp->vmt_basegyroscope = &vmt_basegyroscope; devp->vmt_gyroscope = &vmt_gyroscope;
devp->vmt_lsm6ds0acc = &vmt_lsm6ds0acc;
devp->vmt_lsm6ds0gyro = &vmt_lsm6ds0gyro;
devp->config = NULL; devp->config = NULL;
for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++) for(i = 0; i < LSM6DS0_ACC_NUMBER_OF_AXES; i++)
devp->accbias[i] = 0.0f; devp->accbias[i] = 0.0f;

View File

@ -43,7 +43,7 @@
/** /**
* @brief LSM6DS0 driver version string. * @brief LSM6DS0 driver version string.
*/ */
#define EX_LSM6DS0_VERSION "1.0.3" #define EX_LSM6DS0_VERSION "1.0.4"
/** /**
* @brief LSM6DS0 driver version major number. * @brief LSM6DS0 driver version major number.
@ -58,7 +58,7 @@
/** /**
* @brief LSM6DS0 driver version patch number. * @brief LSM6DS0 driver version patch number.
*/ */
#define EX_LSM6DS0_PATCH 3 #define EX_LSM6DS0_PATCH 4
/** @} */ /** @} */
/** /**
@ -99,11 +99,11 @@
* @name LSM6DS0 communication interfaces related bit masks * @name LSM6DS0 communication interfaces related bit masks
* @{ * @{
*/ */
#define LSM6DS0_DI_MASK 0xFF /**< Data In mask */ #define LSM6DS0_DI_MASK 0xFF
#define LSM6DS0_DI(n) (1 << n) /**< Data In bit n */ #define LSM6DS0_DI(n) (1 << n)
#define LSM6DS0_AD_MASK 0x7F /**< Address Data mask */ #define LSM6DS0_AD_MASK 0x7F
#define LSM6DS0_AD(n) (1 << n) /**< Address Data bit n */ #define LSM6DS0_AD(n) (1 << n)
#define LSM6DS0_MS (1 << 7) /**< Multiple read write */ #define LSM6DS0_MS (1 << 7)
/** @} */ /** @} */
/** /**
@ -677,33 +677,42 @@ typedef struct {
} LSM6DS0Config; } LSM6DS0Config;
/** /**
* @brief Structure representing a LSM6DS0 driver. * @brief @p LSM6DS0 accelerometer subsystem specific methods.
*/ */
typedef struct LSM6DS0Driver LSM6DS0Driver; #define _lsm6ds0_accelerometer_methods_alone \
/* Change full scale value of LSM6DS0 accelerometer subsystem .*/ \
msg_t (*set_full_scale)(void *instance, lsm6ds0_acc_fs_t fs);
/** /**
* @brief @p LSM6DS0 accelerometer subsystem specific methods. * @brief @p LSM6DS0 accelerometer subsystem specific methods.
*/ */
#define _lsm6ds0_acc_methods \ #define _lsm6ds0_accelerometer_methods \
_base_accelerometer_methods \ _base_accelerometer_methods \
/* Change full scale value of LSM6DS0 accelerometer subsystem .*/ \ _lsm6ds0_accelerometer_methods_alone
msg_t (*set_full_scale)(void *instance, lsm6ds0_acc_fs_t fs);
/** /**
* @brief @p LSM6DS0 gyroscope subsystem specific methods. * @brief @p LSM6DS0 gyroscope subsystem specific methods.
*/ */
#define _lsm6ds0_gyro_methods \ #define _lsm6ds0_gyroscope_methods_alone \
_base_gyroscope_methods \
/* Change full scale value of LSM6DS0 gyroscope subsystem .*/ \ /* Change full scale value of LSM6DS0 gyroscope subsystem .*/ \
msg_t (*set_full_scale)(void *instance, lsm6ds0_gyro_fs_t fs); msg_t (*set_full_scale)(void *instance, lsm6ds0_gyro_fs_t fs);
/**
* @brief @p LSM6DS0 gyroscope subsystem specific methods.
*/
#define _lsm6ds0_gyroscope_methods \
_base_gyroscope_methods \
_lsm6ds0_gyroscope_methods_alone
/** /**
* @extends BaseAccelerometerVMT * @extends BaseAccelerometerVMT
* *
* @brief @p LSM6DS0 accelerometer virtual methods table. * @brief @p LSM6DS0 accelerometer virtual methods table.
*/ */
struct LSM6DS0ACCVMT { struct LSM6DS0AccelerometerVMT {
_lsm6ds0_acc_methods _lsm6ds0_accelerometer_methods
}; };
/** /**
@ -711,16 +720,14 @@ struct LSM6DS0ACCVMT {
* *
* @brief @p LSM6DS0 gyroscope virtual methods table. * @brief @p LSM6DS0 gyroscope virtual methods table.
*/ */
struct LSM6DS0GYROVMT { struct LSM6DS0GyroscopeVMT {
_lsm6ds0_gyro_methods _lsm6ds0_gyroscope_methods
}; };
/** /**
* @brief @p LSM6DS0Driver specific data. * @brief @p LSM6DS0Driver specific data.
*/ */
#define _lsm6ds0_data \ #define _lsm6ds0_data \
_base_accelerometer_data \
_base_gyroscope_data \
/* Driver state.*/ \ /* Driver state.*/ \
lsm6ds0_state_t state; \ lsm6ds0_state_t state; \
/* Current configuration data.*/ \ /* Current configuration data.*/ \
@ -743,17 +750,21 @@ struct LSM6DS0GYROVMT {
*/ */
struct LSM6DS0Driver { struct LSM6DS0Driver {
/** @brief BaseSensor Virtual Methods Table. */ /** @brief BaseSensor Virtual Methods Table. */
const struct BaseSensorVMT *vmt_basesensor; const struct BaseSensorVMT *vmt_sensor;
/** @brief BaseAccelerometer Virtual Methods Table. */ _base_sensor_data
const struct BaseAccelerometerVMT *vmt_baseaccelerometer;
/** @brief BaseGyroscope Virtual Methods Table. */
const struct BaseGyroscopeVMT *vmt_basegyroscope;
/** @brief LSM6DS0 Accelerometer Virtual Methods Table. */ /** @brief LSM6DS0 Accelerometer Virtual Methods Table. */
const struct LSM6DS0ACCVMT *vmt_lsm6ds0acc; const struct LSM6DS0AccelerometerVMT *vmt_accelerometer;
_base_accelerometer_data
/** @brief LSM6DS0 Gyroscope Virtual Methods Table. */ /** @brief LSM6DS0 Gyroscope Virtual Methods Table. */
const struct LSM6DS0GYROVMT *vmt_lsm6ds0gyro; const struct LSM6DS0GyroscopeVMT *vmt_gyroscope;
_base_gyroscope_data
_lsm6ds0_data _lsm6ds0_data
}; };
/**
* @brief Structure representing a LSM6DS0 driver.
*/
typedef struct LSM6DS0Driver LSM6DS0Driver;
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/
@ -763,7 +774,7 @@ struct LSM6DS0Driver {
/** /**
* @brief Change accelerometer fullscale value. * @brief Change accelerometer fullscale value.
* *
* @param[in] ip pointer to a @p BaseAccelerometer class. * @param[in] ip pointer to a @p LSM6DS0Driver class.
* @param[in] fs the new full scale value. * @param[in] fs the new full scale value.
* *
* @return The operation status. * @return The operation status.
@ -772,12 +783,12 @@ struct LSM6DS0Driver {
* @api * @api
*/ */
#define accelerometerSetFullScale(ip, fs) \ #define accelerometerSetFullScale(ip, fs) \
(ip)->vmt_lsm6ds0acc->set_full_scale(ip, fs) (ip)->vmt_accelerometer->set_full_scale(ip, fs)
/** /**
* @brief Change compass fullscale value. * @brief Change compass fullscale value.
* *
* @param[in] ip pointer to a @p BaseGyroscope class. * @param[in] ip pointer to a @p LSM6DS0Driver class.
* @param[in] fs the new full scale value. * @param[in] fs the new full scale value.
* *
* @return The operation status. * @return The operation status.
@ -786,7 +797,7 @@ struct LSM6DS0Driver {
* @api * @api
*/ */
#define gyroscopeSetFullScale(ip, fs) \ #define gyroscopeSetFullScale(ip, fs) \
(ip)->vmt_lsm6ds0gyro->set_full_scale(ip, fs) (ip)->vmt_gyroscope->set_full_scale(ip, fs)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */