aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-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)
/*===========================================================================*/