aboutsummaryrefslogtreecommitdiffstats
path: root/os/ex/ST
diff options
context:
space:
mode:
authorRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-05-12 21:01:59 +0000
committerRocco Marco Guglielmi <roccomarco.guglielmi@live.com>2016-05-12 21:01:59 +0000
commitf5be820e9c8945c9995a917ede877b588c1cbba2 (patch)
tree8a8479874392a01bd04a568844b2979c30ed9865 /os/ex/ST
parentfde8d50497ecccbe399ff2f57e5789b487d210b9 (diff)
downloadChibiOS-f5be820e9c8945c9995a917ede877b588c1cbba2.tar.gz
ChibiOS-f5be820e9c8945c9995a917ede877b588c1cbba2.tar.bz2
ChibiOS-f5be820e9c8945c9995a917ede877b588c1cbba2.zip
Fixes an improvements to EX demos
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9471 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ex/ST')
-rw-r--r--os/ex/ST/lis3dsh.c21
-rw-r--r--os/ex/ST/lis3dsh.h9
2 files changed, 26 insertions, 4 deletions
diff --git a/os/ex/ST/lis3dsh.c b/os/ex/ST/lis3dsh.c
index 880cf391e..517b325e5 100644
--- a/os/ex/ST/lis3dsh.c
+++ b/os/ex/ST/lis3dsh.c
@@ -466,6 +466,24 @@ static msg_t reset_sensivity(void *ip) {
return MSG_OK;
}
+static msg_t get_temperature(void *ip, int8_t* tempp) {
+#if LIS3DSH_USE_SPI
+ osalDbgAssert((((LIS3DSHDriver *)ip)->config->spip->state == SPI_READY),
+ "read_raw(), channel not ready");
+#if LIS3DSH_SHARED_SPI
+ spiAcquireBus(((LIS3DSHDriver *)ip)->config->spip);
+ spiStart(((LIS3DSHDriver *)ip)->config->spip,
+ ((LIS3DSHDriver *)ip)->config->spicfg);
+#endif /* LIS3DSH_SHARED_SPI */
+ *tempp = lis3dshSPIReadRegister(((LIS3DSHDriver *)ip)->config->spip,
+ LIS3DSH_AD_OUT_T);
+#if LIS3DSH_SHARED_SPI
+ spiReleaseBus(((LIS3DSHDriver *)ip)->config->spip);
+#endif /* LIS3DSH_SHARED_SPI */
+#endif /* LIS3DSH_USE_SPI */
+ return MSG_OK;
+}
+
static const struct BaseSensorVMT vmt_basesensor = {
get_axes_number, read_raw, read_cooked
};
@@ -477,7 +495,8 @@ static const struct BaseAccelerometerVMT vmt_baseaccelerometer = {
static const struct LIS3DSHVMT vmt_lis3dsh = {
get_axes_number, read_raw, read_cooked,
- set_bias, reset_bias, set_sensivity, reset_sensivity
+ set_bias, reset_bias, set_sensivity, reset_sensivity,
+ get_temperature
};
/*===========================================================================*/
diff --git a/os/ex/ST/lis3dsh.h b/os/ex/ST/lis3dsh.h
index 7d1002f87..1f0ebcd17 100644
--- a/os/ex/ST/lis3dsh.h
+++ b/os/ex/ST/lis3dsh.h
@@ -241,7 +241,9 @@ typedef struct LIS3DSHDriver LIS3DSHDriver;
* @brief @p LIS3DSH specific methods.
*/
#define _lis3dsh_methods \
- _base_accelerometer_methods
+ _base_accelerometer_methods \
+ /* Retrieve the temperature of L3GD20 chip.*/ \
+ msg_t (*get_temperature)(void *instance, int8_t* temperature);
/**
* @extends BaseAccelerometerVMT
@@ -291,16 +293,17 @@ struct LIS3DSHDriver {
/**
* @brief Get current MEMS temperature.
* @detail This information is very useful especially for high accuracy IMU
+ * @note Value is raw since there is a lack of information in datasheet.
*
* @param[in] ip pointer to a @p BaseAccelerometer class.
- * @param[out] temp the MEMS temperature as single precision floating.
+ * @param[out] temp the MEMS temperature as raw data.
*
* @return The operation status.
* @retval MSG_OK if the function succeeded.
* @retval MSG_RESET if one or more errors occurred.
* @api
*/
-#define accelerometerGetTemp(ip, tpp) \
+#define accelerometerGetTemp(ip, tpp) \
(ip)->vmt_lis3dsh->get_temperature(ip, tpp)
/*===========================================================================*/