diff options
author | Rocco Marco Guglielmi <roccomarco.guglielmi@live.com> | 2016-08-31 17:51:29 +0000 |
---|---|---|
committer | Rocco Marco Guglielmi <roccomarco.guglielmi@live.com> | 2016-08-31 17:51:29 +0000 |
commit | 16eb9bd9a6895dc9b5b812f46e9477039c018ec1 (patch) | |
tree | 62d4150c56093569950e7435741023843159f56e /os/ex | |
parent | f3e61d2cde6739acb39cfd85ebaceb2c77bd7cd2 (diff) | |
download | ChibiOS-16eb9bd9a6895dc9b5b812f46e9477039c018ec1.tar.gz ChibiOS-16eb9bd9a6895dc9b5b812f46e9477039c018ec1.tar.bz2 ChibiOS-16eb9bd9a6895dc9b5b812f46e9477039c018ec1.zip |
Minor fixes on L3GD20 Drivers
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9755 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ex')
-rw-r--r-- | os/ex/ST/l3gd20.c | 18 | ||||
-rw-r--r-- | os/ex/ST/l3gd20.h | 4 |
2 files changed, 17 insertions, 5 deletions
diff --git a/os/ex/ST/l3gd20.c b/os/ex/ST/l3gd20.c index fba1440da..6f090d32e 100644 --- a/os/ex/ST/l3gd20.c +++ b/os/ex/ST/l3gd20.c @@ -145,14 +145,17 @@ static msg_t sample_bias(void *ip) { uint32_t i, j; int32_t raw[L3GD20_NUMBER_OF_AXES]; int32_t buff[L3GD20_NUMBER_OF_AXES] = {0, 0, 0}; - + msg_t msg;
+ osalDbgCheck(ip != NULL); osalDbgAssert((((L3GD20Driver *)ip)->state == L3GD20_READY), "sample_bias(), invalid state"); for(i = 0; i < L3GD20_BIAS_ACQ_TIMES; i++){ - read_raw(ip, raw); + msg = read_raw(ip, raw);
+ if(msg != MSG_OK)
+ return msg; for(j = 0; j < L3GD20_NUMBER_OF_AXES; j++){ buff[j] += raw[j]; } @@ -163,7 +166,7 @@ static msg_t sample_bias(void *ip) { ((L3GD20Driver *)ip)->bias[i] = (buff[i] / L3GD20_BIAS_ACQ_TIMES); ((L3GD20Driver *)ip)->bias[i] *= ((L3GD20Driver *)ip)->sensitivity[i]; } - return MSG_OK; + return msg; } static msg_t set_bias(void *ip, int32_t *bp) { @@ -254,6 +257,12 @@ static msg_t set_full_scale(void *ip, l3gd20_fs_t fs) { scale = newfs / ((L3GD20Driver *)ip)->fullscale; ((L3GD20Driver *)ip)->fullscale = newfs;
+#if L3GD20_SHARED_SPI
+ spiAcquireBus(((L3GD20Driver *)ip)->config->spip);
+ spiStart(((L3GD20Driver *)ip)->config->spip,
+ ((L3GD20Driver *)ip)->config->spicfg);
+#endif /* L3GD20_SHARED_SPI */
+
/* Updating register.*/
l3gd20SPIReadRegister(((L3GD20Driver *)ip)->config->spip,
L3GD20_AD_CTRL_REG4, 1, &cr);
@@ -261,6 +270,9 @@ static msg_t set_full_scale(void *ip, l3gd20_fs_t fs) { cr |= fs;
l3gd20SPIWriteRegister(((L3GD20Driver *)ip)->config->spip,
L3GD20_AD_CTRL_REG4, 1, &cr);
+#if L3GD20_SHARED_SPI
+ spiReleaseBus(((L3GD20Driver *)ip)->config->spip);
+#endif /* L3GD20_SHARED_SPI */
/* Scaling sensitivity and bias. Re-calibration is suggested anyway. */ for(i = 0; i < L3GD20_NUMBER_OF_AXES; i++) { diff --git a/os/ex/ST/l3gd20.h b/os/ex/ST/l3gd20.h index e74837978..9f0377db9 100644 --- a/os/ex/ST/l3gd20.h +++ b/os/ex/ST/l3gd20.h @@ -40,7 +40,7 @@ /**
* @brief L3GD20 driver version string.
*/
-#define EX_L3GD20_VERSION "1.0.0"
+#define EX_L3GD20_VERSION "1.0.1"
/**
* @brief L3GD20 driver version major number.
@@ -55,7 +55,7 @@ /**
* @brief L3GD20 driver version patch number.
*/
-#define EX_L3GD20_PATCH 0
+#define EX_L3GD20_PATCH 1
/** @} */
/**
|