aboutsummaryrefslogtreecommitdiffstats
path: root/os/ex
diff options
context:
space:
mode:
authorRocco Marco Guglielmi <roccomarco.guglielmi@gmail.com>2018-03-10 13:53:44 +0000
committerRocco Marco Guglielmi <roccomarco.guglielmi@gmail.com>2018-03-10 13:53:44 +0000
commitf2f3035c3c49daa3a62aa7606455da90d350190e (patch)
tree9b7bbf9b90832eb6b3f55450fc525b34566f8605 /os/ex
parente0fcf2b6c7e1c722368934effec0e175bc7925d0 (diff)
downloadChibiOS-f2f3035c3c49daa3a62aa7606455da90d350190e.tar.gz
ChibiOS-f2f3035c3c49daa3a62aa7606455da90d350190e.tar.bz2
ChibiOS-f2f3035c3c49daa3a62aa7606455da90d350190e.zip
Improved EX drivers
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11685 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/ex')
-rw-r--r--os/ex/ST/hts221.h5
-rw-r--r--os/ex/ST/l3gd20.c26
-rw-r--r--os/ex/ST/l3gd20.h9
-rw-r--r--os/ex/ST/lsm303dlhc.c25
-rw-r--r--os/ex/ST/lsm303dlhc.h17
5 files changed, 50 insertions, 32 deletions
diff --git a/os/ex/ST/hts221.h b/os/ex/ST/hts221.h
index 2570a6ed1..893f9f314 100644
--- a/os/ex/ST/hts221.h
+++ b/os/ex/ST/hts221.h
@@ -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
/** @} */
/**
diff --git a/os/ex/ST/l3gd20.c b/os/ex/ST/l3gd20.c
index fcb6dd17d..4313341e6 100644
--- a/os/ex/ST/l3gd20.c
+++ b/os/ex/ST/l3gd20.c
@@ -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);
diff --git a/os/ex/ST/l3gd20.h b/os/ex/ST/l3gd20.h
index 5f17eb91b..c57615040 100644
--- a/os/ex/ST/l3gd20.h
+++ b/os/ex/ST/l3gd20.h
@@ -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
/** @} */
/**
diff --git a/os/ex/ST/lsm303dlhc.c b/os/ex/ST/lsm303dlhc.c
index 64f965607..0a4d9689f 100644
--- a/os/ex/ST/lsm303dlhc.c
+++ b/os/ex/ST/lsm303dlhc.c
@@ -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);
diff --git a/os/ex/ST/lsm303dlhc.h b/os/ex/ST/lsm303dlhc.h
index 51784e24b..0d7fa656e 100644
--- a/os/ex/ST/lsm303dlhc.h
+++ b/os/ex/ST/lsm303dlhc.h
@@ -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.
*