Improved EX drivers
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11685 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
e0fcf2b6c7
commit
f2f3035c3c
|
@ -66,23 +66,26 @@
|
|||
* @brief HTS221 hygrometer subsystem characteristics.
|
||||
* @note Sensitivity is expressed as %rH/LSB whereas %rH stand for percentage
|
||||
* of relative humidity.
|
||||
*
|
||||
* @note Bias is expressed as %rH.
|
||||
* @{
|
||||
*/
|
||||
#define HTS221_HYGRO_NUMBER_OF_AXES 1U
|
||||
|
||||
#define HTS221_HYGRO_SENS 0.00390625f
|
||||
#define HTS221_HYGRO_BIAS 0.0f
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief HTS221 thermometer subsystem characteristics.
|
||||
* @note Sensitivity is expressed as °C/LSB.
|
||||
* @note Bias is expressed as °C.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define HTS221_THERMO_NUMBER_OF_AXES 1U
|
||||
|
||||
#define HTS221_THERMO_SENS 0.0015625f
|
||||
#define HTS221_THERMO_BIAS 0.0f
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
|
@ -286,7 +286,7 @@ static msg_t gyro_reset_bias(void *ip) {
|
|||
"gyro_reset_bias(), invalid state");
|
||||
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++)
|
||||
devp->gyrobias[i] = 0.0;
|
||||
devp->gyrobias[i] = L3GD20_GYRO_BIAS;
|
||||
return MSG_OK;
|
||||
}
|
||||
|
||||
|
@ -345,13 +345,13 @@ static msg_t gyro_reset_sensivity(void *ip) {
|
|||
|
||||
if(devp->config->gyrofullscale == L3GD20_FS_250DPS)
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++)
|
||||
devp->gyrosensitivity[i] = L3GD20_SENS_250DPS;
|
||||
devp->gyrosensitivity[i] = L3GD20_GYRO_SENS_250DPS;
|
||||
else if(devp->config->gyrofullscale == L3GD20_FS_500DPS)
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++)
|
||||
devp->gyrosensitivity[i] = L3GD20_SENS_500DPS;
|
||||
devp->gyrosensitivity[i] = L3GD20_GYRO_SENS_500DPS;
|
||||
else if(devp->config->gyrofullscale == L3GD20_FS_2000DPS)
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++)
|
||||
devp->gyrosensitivity[i] = L3GD20_SENS_2000DPS;
|
||||
devp->gyrosensitivity[i] = L3GD20_GYRO_SENS_2000DPS;
|
||||
else {
|
||||
osalDbgAssert(FALSE, "gyro_reset_sensivity(), full scale issue");
|
||||
return MSG_RESET;
|
||||
|
@ -468,14 +468,11 @@ static const struct BaseGyroscopeVMT vmt_gyroscope = {
|
|||
* @init
|
||||
*/
|
||||
void l3gd20ObjectInit(L3GD20Driver *devp) {
|
||||
uint32_t i;
|
||||
|
||||
devp->vmt = &vmt_device;
|
||||
devp->gyro_if.vmt = &vmt_gyroscope;
|
||||
|
||||
devp->config = NULL;
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++)
|
||||
devp->gyrobias[i] = 0.0f;
|
||||
|
||||
devp->state = L3GD20_STOP;
|
||||
}
|
||||
|
||||
|
@ -560,7 +557,7 @@ void l3gd20Start(L3GD20Driver *devp, const L3GD20Config *config) {
|
|||
devp->gyrofullscale = L3GD20_250DPS;
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++) {
|
||||
if (devp->config->gyrosensitivity == NULL)
|
||||
devp->gyrosensitivity[i] = L3GD20_SENS_250DPS;
|
||||
devp->gyrosensitivity[i] = L3GD20_GYRO_SENS_250DPS;
|
||||
else
|
||||
devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
|
||||
}
|
||||
|
@ -569,7 +566,7 @@ void l3gd20Start(L3GD20Driver *devp, const L3GD20Config *config) {
|
|||
devp->gyrofullscale = L3GD20_500DPS;
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++) {
|
||||
if (devp->config->gyrosensitivity == NULL)
|
||||
devp->gyrosensitivity[i] = L3GD20_SENS_500DPS;
|
||||
devp->gyrosensitivity[i] = L3GD20_GYRO_SENS_500DPS;
|
||||
else
|
||||
devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
|
||||
}
|
||||
|
@ -578,19 +575,24 @@ void l3gd20Start(L3GD20Driver *devp, const L3GD20Config *config) {
|
|||
devp->gyrofullscale = L3GD20_2000DPS;
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++) {
|
||||
if (devp->config->gyrosensitivity == NULL)
|
||||
devp->gyrosensitivity[i] = L3GD20_SENS_2000DPS;
|
||||
devp->gyrosensitivity[i] = L3GD20_GYRO_SENS_2000DPS;
|
||||
else
|
||||
devp->gyrosensitivity[i] = devp->config->gyrosensitivity[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
osalDbgAssert(FALSE, "l3gd20Start(), full scale issue");
|
||||
|
||||
|
||||
/* Storing bias information.*/
|
||||
if(devp->config->gyrobias != NULL) {
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++) {
|
||||
devp->gyrobias[i] = devp->config->gyrobias[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < L3GD20_GYRO_NUMBER_OF_AXES; i++)
|
||||
devp->gyrobias[i] = L3GD20_GYRO_BIAS;
|
||||
}
|
||||
|
||||
/* This is the Gyroscope transient recovery time.*/
|
||||
osalThreadSleepMilliseconds(10);
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
* @brief L3GD20 gyroscope system characteristics.
|
||||
* @note Sensitivity is expressed as DPS/LSB whereas DPS stand for Degree
|
||||
* per second [°/s].
|
||||
* @note Bias is expressed as DPS.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -73,9 +74,11 @@
|
|||
#define L3GD20_500DPS 500.0f
|
||||
#define L3GD20_2000DPS 2000.0f
|
||||
|
||||
#define L3GD20_SENS_250DPS 0.00875f
|
||||
#define L3GD20_SENS_500DPS 0.01750f
|
||||
#define L3GD20_SENS_2000DPS 0.07000f
|
||||
#define L3GD20_GYRO_SENS_250DPS 0.00875f
|
||||
#define L3GD20_GYRO_SENS_500DPS 0.01750f
|
||||
#define L3GD20_GYRO_SENS_2000DPS 0.07000f
|
||||
|
||||
#define L3GD20_GYRO_BIAS 0.0f
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
|
@ -254,7 +254,7 @@ static msg_t acc_reset_bias(void *ip) {
|
|||
"acc_reset_bias(), invalid state");
|
||||
|
||||
for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++)
|
||||
devp->accbias[i] = 0.0;
|
||||
devp->accbias[i] = LSM303DLHC_ACC_BIAS;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ static msg_t comp_read_raw(void *ip, int32_t axes[]) {
|
|||
* @brief Retrieves cooked data from the BaseCompass.
|
||||
* @note This data is manipulated according to the formula
|
||||
* cooked = (raw * sensitivity) - bias.
|
||||
* @note Final data is expressed as Ga.
|
||||
* @note Final data is expressed as G.
|
||||
* @note The axes array must be at least the same size of the
|
||||
* BaseCompass axes number.
|
||||
*
|
||||
|
@ -535,7 +535,7 @@ static msg_t comp_read_cooked(void *ip, float axes[]) {
|
|||
|
||||
/**
|
||||
* @brief Set bias values for the BaseCompass.
|
||||
* @note Bias must be expressed as Ga.
|
||||
* @note Bias must be expressed as G.
|
||||
* @note The bias buffer must be at least the same size of the
|
||||
* BaseCompass axes number.
|
||||
*
|
||||
|
@ -588,13 +588,13 @@ static msg_t comp_reset_bias(void *ip) {
|
|||
"comp_reset_bias(), invalid state");
|
||||
|
||||
for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++)
|
||||
devp->compbias[i] = 0.0;
|
||||
devp->compbias[i] = LSM303DLHC_COMP_BIAS;
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sensitivity values for the BaseCompass.
|
||||
* @note Sensitivity must be expressed as Ga/LSB.
|
||||
* @note Sensitivity must be expressed as G/LSB.
|
||||
* @note The sensitivity buffer must be at least the same size of the
|
||||
* BaseCompass axes number.
|
||||
*
|
||||
|
@ -860,11 +860,8 @@ void lsm303dlhcObjectInit(LSM303DLHCDriver *devp) {
|
|||
|
||||
devp->accaxes = LSM303DLHC_ACC_NUMBER_OF_AXES;
|
||||
devp->compaxes = LSM303DLHC_COMP_NUMBER_OF_AXES;
|
||||
|
||||
for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++)
|
||||
devp->accbias[i] = 0.0f;
|
||||
for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++)
|
||||
devp->compbias[i] = 0.0f;
|
||||
|
||||
|
||||
devp->state = LSM303DLHC_STOP;
|
||||
}
|
||||
|
||||
|
@ -976,6 +973,9 @@ void lsm303dlhcStart(LSM303DLHCDriver *devp, const LSM303DLHCConfig *config) {
|
|||
if(devp->config->accbias != NULL)
|
||||
for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++)
|
||||
devp->accbias[i] = devp->config->accbias[i];
|
||||
else
|
||||
for(i = 0; i < LSM303DLHC_ACC_NUMBER_OF_AXES; i++)
|
||||
devp->accbias[i] = LSM303DLHC_ACC_BIAS;
|
||||
|
||||
|
||||
/* Configuring Compass subsystem */
|
||||
|
@ -1131,7 +1131,10 @@ void lsm303dlhcStart(LSM303DLHCDriver *devp, const LSM303DLHCConfig *config) {
|
|||
if(devp->config->compbias != NULL)
|
||||
for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++)
|
||||
devp->compbias[i] = devp->config->compbias[i];
|
||||
|
||||
else
|
||||
for(i = 0; i < LSM303DLHC_COMP_NUMBER_OF_AXES; i++)
|
||||
devp->compbias[i] = LSM303DLHC_COMP_BIAS;
|
||||
|
||||
/* This is the MEMS transient recovery time */
|
||||
osalThreadSleepMilliseconds(5);
|
||||
|
||||
|
|
|
@ -63,7 +63,9 @@
|
|||
|
||||
/**
|
||||
* @brief LSM303DLHC accelerometer subsystem characteristics.
|
||||
* @note Sensitivity is expressed as mG/LSB whereas 1 mG = 0.00980665 m/s^2.
|
||||
* @note Sensitivity is expressed as milli-G/LSB whereas
|
||||
* 1 milli-G = 0.00980665 m/s^2.
|
||||
* @note Bias is expressed as milli-G.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -78,11 +80,14 @@
|
|||
#define LSM303DLHC_ACC_SENS_4G 0.1221f
|
||||
#define LSM303DLHC_ACC_SENS_8G 0.2442f
|
||||
#define LSM303DLHC_ACC_SENS_16G 0.4884f
|
||||
|
||||
#define LSM303DLHC_ACC_BIAS 0.0f
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief LSM303DLHC compass subsystem characteristics.
|
||||
* @note Sensitivity is expressed as GA/LSB whereas GA stands for Gauss.
|
||||
* @note Sensitivity is expressed as G/LSB whereas G stands for Gauss.
|
||||
* @note Bias is expressed as G.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -111,6 +116,8 @@
|
|||
#define LSM303DLHC_COMP_SENS_Z_4P7GA 0.0028169f
|
||||
#define LSM303DLHC_COMP_SENS_Z_5P6GA 0.0033898f
|
||||
#define LSM303DLHC_COMP_SENS_Z_8P1GA 0.0048780f
|
||||
|
||||
#define LSM303DLHC_COMP_BIAS 0.0f
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -795,7 +802,7 @@ struct LSM303DLHCDriver {
|
|||
* @brief Retrieves cooked data from the BaseCompass.
|
||||
* @note This data is manipulated according to the formula
|
||||
* cooked = (raw * sensitivity) - bias.
|
||||
* @note Final data is expressed as Ga.
|
||||
* @note Final data is expressed as G.
|
||||
* @note The axes array must be at least the same size of the
|
||||
* BaseCompass axes number.
|
||||
*
|
||||
|
@ -815,7 +822,7 @@ struct LSM303DLHCDriver {
|
|||
|
||||
/**
|
||||
* @brief Set bias values for the BaseCompass.
|
||||
* @note Bias must be expressed as Ga.
|
||||
* @note Bias must be expressed as G.
|
||||
* @note The bias buffer must be at least the same size of the
|
||||
* BaseCompass axes number.
|
||||
*
|
||||
|
@ -847,7 +854,7 @@ struct LSM303DLHCDriver {
|
|||
|
||||
/**
|
||||
* @brief Set sensitivity values for the BaseCompass.
|
||||
* @note Sensitivity must be expressed as Ga/LSB.
|
||||
* @note Sensitivity must be expressed as G/LSB.
|
||||
* @note The sensitivity buffer must be at least the same size of the
|
||||
* BaseCompass axes number.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue