From 0cb5879d1da7780ca2b47111c15d81d9ee51bc93 Mon Sep 17 00:00:00 2001 From: Rocco Marco Guglielmi Date: Wed, 31 Aug 2016 18:24:24 +0000 Subject: 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 --- os/ex/ST/lis3mdl.c | 11 ++++++++++- os/ex/ST/lis3mdl.h | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'os') 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++) { diff --git a/os/ex/ST/lis3mdl.h b/os/ex/ST/lis3mdl.h index 0351ffdde..e62cd4fc2 100644 --- a/os/ex/ST/lis3mdl.h +++ b/os/ex/ST/lis3mdl.h @@ -40,7 +40,7 @@ /** * @brief LIS3MDL driver version string. */ -#define EX_LIS3MDL_VERSION "1.0.0" +#define EX_LIS3MDL_VERSION "1.0.1" /** * @brief LIS3MDL driver version major number. @@ -55,7 +55,7 @@ /** * @brief LIS3MDL driver version patch number. */ -#define EX_LIS3MDL_PATCH 0 +#define EX_LIS3MDL_PATCH 1 /** @} */ /** -- cgit v1.2.3