-
Notifications
You must be signed in to change notification settings - Fork 1
/
stm32l4s5i_iot01_hsensor.c
101 lines (86 loc) · 2.03 KB
/
stm32l4s5i_iot01_hsensor.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
95
96
97
98
99
100
/**
******************************************************************************
* @file stm32l4s5i_iot01_hsensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the humidity 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 "stm32l4s5i_iot01_hsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L4S5I_IOT01
* @{
*/
/** @defgroup STM32L4S5I_IOT01_HUMIDITY HUMIDITY
* @{
*/
/** @defgroup STM32L4S5I_IOT01_HUMIDITY_Private_Variables HUMIDITY Private Variables
* @{
*/
static HSENSOR_DrvTypeDef *Hsensor_drv;
/**
* @}
*/
/** @defgroup STM32L4S5I_IOT01_HUMIDITY_Private_Functions HUMIDITY Private Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Humidity Sensor driver.
* @retval HSENSOR status
*/
uint32_t BSP_HSENSOR_Init(void)
{
uint32_t ret;
if(HTS221_H_Drv.ReadID(HTS221_I2C_ADDRESS) != HTS221_WHO_AM_I_VAL)
{
ret = HSENSOR_ERROR;
}
else
{
Hsensor_drv = &HTS221_H_Drv;
/* HSENSOR Init */
Hsensor_drv->Init(HTS221_I2C_ADDRESS);
ret = HSENSOR_OK;
}
return ret;
}
/**
* @brief Read ID of HTS221.
* @retval HTS221 ID value.
*/
uint8_t BSP_HSENSOR_ReadID(void)
{
return Hsensor_drv->ReadID(HTS221_I2C_ADDRESS);
}
/**
* @brief Read Humidity register of HTS221.
* @retval HTS221 measured humidity value.
*/
float BSP_HSENSOR_ReadHumidity(void)
{
return Hsensor_drv->ReadHumidity(HTS221_I2C_ADDRESS);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/