-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstm32l4s5i_iot01_psensor.c
102 lines (86 loc) · 2.05 KB
/
stm32l4s5i_iot01_psensor.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
101
/**
******************************************************************************
* @file stm32l4s5i_iot01_psensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the pressure 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_psensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32L4S5I_IOT01
* @{
*/
/** @defgroup STM32L4S5I_IOT01_PRESSURE PRESSURE
* @{
*/
/** @defgroup STM32L4S5I_IOT01_PRESSURE_Private_Variables PRESSURE Private Variables
* @{
*/
static PSENSOR_DrvTypeDef *Psensor_drv;
/**
* @}
*/
/** @defgroup STM32L4S5I_IOT01_PRESSURE_Private_Functions PRESSURE Private Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Pressure Sensor driver.
* @retval PSENSOR status
*/
uint32_t BSP_PSENSOR_Init(void)
{
uint32_t ret;
if(LPS22HB_P_Drv.ReadID(LPS22HB_I2C_ADDRESS) != LPS22HB_WHO_AM_I_VAL)
{
ret = PSENSOR_ERROR;
}
else
{
Psensor_drv = &LPS22HB_P_Drv;
/* PSENSOR Init */
Psensor_drv->Init(LPS22HB_I2C_ADDRESS);
ret = PSENSOR_OK;
}
return ret;
}
/**
* @brief Read ID of LPS22HB.
* @retval LPS22HB ID value.
*/
uint8_t BSP_PSENSOR_ReadID(void)
{
return Psensor_drv->ReadID(LPS22HB_I2C_ADDRESS);
}
/**
* @brief Read Pressure register of LPS22HB.
* @retval LPS22HB measured pressure value.
*/
float BSP_PSENSOR_ReadPressure(void)
{
return Psensor_drv->ReadPressure(LPS22HB_I2C_ADDRESS);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/