-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstm32l475e_iot01_tsensor.c
95 lines (77 loc) · 1.94 KB
/
stm32l475e_iot01_tsensor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
******************************************************************************
* @file stm32l475e_iot01_tsensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the temperature sensor
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l475e_iot01_tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L475E_IOT01
* @{
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE TEMPERATURE
* @{
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Private_Variables TEMPERATURE Private Variables
* @{
*/
static TSENSOR_DrvTypeDef *tsensor_drv;
/**
* @}
*/
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Private_Functions TEMPERATURE Private Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Temperature Sensor driver.
* @retval TSENSOR status
*/
uint32_t BSP_TSENSOR_Init(void)
{
uint8_t ret = TSENSOR_ERROR;
#ifdef USE_LPS22HB_TEMP
tsensor_drv = &LPS22HB_T_Drv;
#else /* USE_HTS221_TEMP */
tsensor_drv = &HTS221_T_Drv;
#endif
/* Low level init */
SENSOR_IO_Init();
/* TSENSOR Init */
tsensor_drv->Init(TSENSOR_I2C_ADDRESS, NULL);
ret = TSENSOR_OK;
return ret;
}
/**
* @brief Read Temperature register of TS751.
* @retval STTS751 measured temperature value.
*/
float BSP_TSENSOR_ReadTemp(void)
{
return tsensor_drv->ReadTemp(TSENSOR_I2C_ADDRESS);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/