aboutsummaryrefslogtreecommitdiffstats
path: root/os/ex/ST/lis3mdl.c
diff options
context:
space:
mode:
authorRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-08-31 18:24:24 +0000
committerRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-08-31 18:24:24 +0000
commit0cb5879d1da7780ca2b47111c15d81d9ee51bc93 (patch)
tree1c9957abd653712edaf0a2717038b71107dabf70 /os/ex/ST/lis3mdl.c
parent9e1cb54809cc61857be7af6243f1841a03832111 (diff)
downloadChibiOS-0cb5879d1da7780ca2b47111c15d81d9ee51bc93.tar.gz
ChibiOS-0cb5879d1da7780ca2b47111c15d81d9ee51bc93.tar.bz2
ChibiOS-0cb5879d1da7780ca2b47111c15d81d9ee51bc93.zip
Fixes in LIS3MDL driver, added a new demo for STM32 Nucleo-64 F401RE
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9757 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ex/ST/lis3mdl.c')
-rw-r--r--os/ex/ST/lis3mdl.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/os/ex/ST/lis3mdl.c b/os/ex/ST/lis3mdl.c
index 5c7169868..760ddacde 100644
--- a/os/ex/ST/lis3mdl.c
+++ b/os/ex/ST/lis3mdl.c
@@ -107,7 +107,8 @@ static size_t get_axes_number(void *ip) {
}
static msg_t read_raw(void *ip, int32_t axes[LIS3MDL_NUMBER_OF_AXES]) {
- uint16_t tmp;
+ int16_t tmp;
+ msg_t msg = MSG_OK;
osalDbgCheck((ip != NULL) && (axes != NULL));
osalDbgAssert((((LIS3MDLDriver *)ip)->state == LIS3MDL_READY),
"read_raw(), invalid state");
@@ -272,6 +273,11 @@ static msg_t set_full_scale(void *ip, lis3mdl_fs_t fs) {
if(newfs != ((LIS3MDLDriver *)ip)->fullscale) {
scale = newfs / ((LIS3MDLDriver *)ip)->fullscale;
((LIS3MDLDriver *)ip)->fullscale = newfs;
+#if LIS3MDL_SHARED_I2C
+ i2cAcquireBus(((LIS3MDLDriver *)ip)->config->i2cp);
+ i2cStart(((LIS3MDLDriver *)ip)->config->i2cp,
+ ((LIS3MDLDriver *)ip)->config->i2ccfg);
+#endif /* LIS3MDL_SHARED_I2C */
/* Updating register.*/
cr = lis3mdlI2CReadRegister(((LIS3MDLDriver *)ip)->config->i2cp,
@@ -287,6 +293,9 @@ static msg_t set_full_scale(void *ip, lis3mdl_fs_t fs) {
LIS3MDL_AD_CTRL_REG2, cr);
if(msg != MSG_OK)
return msg;
+#if LIS3MDL_SHARED_I2C
+ i2cReleaseBus(((LIS3MDLDriver *)ip)->config->i2cp);
+#endif /* LIS3MDL_SHARED_I2C */
/* Scaling sensitivity and bias. Re-calibration is suggested anyway. */
for(i = 0; i < LIS3MDL_NUMBER_OF_AXES; i++) {