pwrmon.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /**
  2. ******************************************************************************
  3. * @file pwrmon.h
  4. * @author MCD Application Team
  5. * @brief This header file contains the functions prototypes for the
  6. * Current/Power Monitor device driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __PWRMON_H
  22. #define __PWRMON_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include <stdint.h>
  28. /** @addtogroup BSP
  29. * @{
  30. */
  31. /** @addtogroup Components
  32. * @{
  33. */
  34. /** @addtogroup PWRMON
  35. * @{
  36. */
  37. /** @defgroup PWRMON_Exported_Types
  38. * @{
  39. */
  40. /** @defgroup PWRMON_Operating_Mode_enum Power Monitor Operating Mode enums
  41. * @{
  42. */
  43. typedef enum {
  44. OPERATING_MODE_TRIGGERED = 0,
  45. OPERATING_MODE_CONTINUOUS,
  46. OPERATING_MODE_NB
  47. } PWRMON_OperatingMode_t;
  48. /**
  49. * @}
  50. */
  51. /** @defgroup PWRMON_Conversion_Time_enum Power Monitor Conversion_Time enums
  52. * @{
  53. */
  54. typedef enum {
  55. CONVERT_TIME_140 = 0,
  56. CONVERT_TIME_204,
  57. CONVERT_TIME_332,
  58. CONVERT_TIME_588,
  59. CONVERT_TIME_1100,
  60. CONVERT_TIME_2116,
  61. CONVERT_TIME_4156,
  62. CONVERT_TIME_8244,
  63. CONVERT_TIME_NB
  64. } PWRMON_ConvertTime_t;
  65. /**
  66. * @}
  67. */
  68. /** @defgroup PWRMON_Conversion_Time_enum Power Monitor Conversion_Time enums
  69. * @{
  70. */
  71. typedef enum {
  72. AVERAGING_MODE_1 = 0,
  73. AVERAGING_MODE_4,
  74. AVERAGING_MODE_16,
  75. AVERAGING_MODE_64,
  76. AVERAGING_MODE_128,
  77. AVERAGING_MODE_256,
  78. AVERAGING_MODE_512,
  79. AVERAGING_MODE_1024,
  80. AVERAGING_MODE_NB
  81. } PWRMON_AveragingMode_t;
  82. /**
  83. * @}
  84. */
  85. /** @defgroup PWRMON_Device_Configuration_structure Power Monitor Device Configuration structure
  86. * @{
  87. */
  88. typedef struct
  89. {
  90. PWRMON_ConvertTime_t ShuntConvertTime;
  91. PWRMON_ConvertTime_t BusConvertTime;
  92. PWRMON_AveragingMode_t AveragingMode;
  93. } PWRMON_Config_t;
  94. /**
  95. * @}
  96. */
  97. /** @defgroup PWRMON_Alert_Polarity_enum Power Monitor Alert Polarity enums
  98. * @{
  99. */
  100. typedef enum {
  101. ALERT_POLARITY_NORMAL = 0,
  102. ALERT_POLARITY_INVERTED,
  103. ALERT_POLARITY_NB
  104. } PWRMON_AlertPolarity_t;
  105. /**
  106. * @}
  107. */
  108. /** @defgroup PWRMON_Alert_Latch_Enable_enum Power Monitor Alert Latch Enable enums
  109. * @{
  110. */
  111. typedef enum {
  112. ALERT_LATCH_DISABLE = 0,
  113. ALERT_LATCH_ENABLE,
  114. ALERT_LATCH_NB
  115. } PWRMON_AlertLatchEnable_t;
  116. /**
  117. * @}
  118. */
  119. /** @defgroup PWRMON_Alert_Function_enum Power Monitor Alert Function enums
  120. * @{
  121. */
  122. typedef enum {
  123. ALERT_FUNCTION_NONE = 0,
  124. ALERT_FUNCTION_SOL,
  125. ALERT_FUNCTION_SUL,
  126. ALERT_FUNCTION_BOL,
  127. ALERT_FUNCTION_BUL,
  128. ALERT_FUNCTION_POL,
  129. ALERT_FUNCTION_NB,
  130. } PWRMON_AlertFunction_t;
  131. /**
  132. * @}
  133. */
  134. /** @defgroup PWRMON_Alert_Configuration_structure Power Monitor Alert Configuration structure
  135. * @{
  136. */
  137. typedef struct
  138. {
  139. PWRMON_AlertPolarity_t Polarity;
  140. PWRMON_AlertLatchEnable_t LatchEnable;
  141. } PWRMON_AlertPinConfig_t;
  142. /**
  143. * @}
  144. */
  145. /** @defgroup PWRMON_Voltage_Input_enum Power Monitor Voltage Input enums
  146. * @{
  147. */
  148. typedef enum {
  149. VOLTAGE_INPUT_SHUNT = 0,
  150. VOLTAGE_INPUT_BUS,
  151. VOLTAGE_INPUT_ALL,
  152. VOLTAGE_INPUT_NB
  153. } PWRMON_InputSignal_t;
  154. /**
  155. * @}
  156. */
  157. /** @defgroup PWRMON_Flag_enum Power Monitor Flag enums
  158. * @{
  159. */
  160. typedef enum {
  161. FLAG_ALERT_FUNCTION = 0,
  162. FLAG_CONVERSION_READY,
  163. FLAG_MATH_OVERFLOW,
  164. FLAG_NB
  165. } PWRMON_Flag_t;
  166. /**
  167. * @}
  168. */
  169. /** @defgroup PWRMON_Driver_structure Power Monitor Driver structure
  170. * @{
  171. */
  172. typedef struct
  173. {
  174. void (*Init)(uint16_t, PWRMON_Config_t *);
  175. void (*DeInit)(uint16_t);
  176. uint16_t (*ReadId)(uint16_t);
  177. void (*Reset)(uint16_t);
  178. void (*SetCalibration)(uint16_t, uint16_t);
  179. uint16_t (*GetCalibration)(uint16_t);
  180. void (*SetAlertFunction)(uint16_t, PWRMON_AlertFunction_t);
  181. PWRMON_AlertFunction_t (*GetAlertFunction)(uint16_t);
  182. void (*AlertPinConfig)(uint16_t, PWRMON_AlertPinConfig_t *);
  183. void (*SetVBusThreshold)(uint16_t, uint16_t);
  184. uint16_t (*GetVBusThreshold)(uint16_t);
  185. void (*SetVShuntThreshold)(uint16_t, int16_t);
  186. int16_t (*GetVShuntThreshold)(uint16_t);
  187. void (*SetPowerThreshold)(uint16_t, uint32_t);
  188. uint32_t (*GetPowerThreshold)(uint16_t);
  189. void (*AlertThresholdEnableIT)(uint16_t);
  190. void (*AlertThresholdDisableIT)(uint16_t);
  191. void (*ConversionReadyEnableIT)(uint16_t);
  192. void (*ConversionReadyDisableIT)(uint16_t);
  193. void (*StartConversion)(uint16_t, PWRMON_InputSignal_t, PWRMON_OperatingMode_t);
  194. void (*StopConversion)(uint16_t);
  195. uint16_t (*GetVBus)(uint16_t);
  196. int16_t (*GetVShunt)(uint16_t);
  197. uint16_t (*GetPower)(uint16_t);
  198. int16_t (*GetCurrent)(uint16_t);
  199. uint8_t (*GetFlag)(uint16_t, PWRMON_Flag_t);
  200. } PWRMON_Drv_t;
  201. /**
  202. * @}
  203. */
  204. /**
  205. * @}
  206. */
  207. /**
  208. * @}
  209. */
  210. /**
  211. * @}
  212. */
  213. /**
  214. * @}
  215. */
  216. #ifdef __cplusplus
  217. }
  218. #endif
  219. #endif /* __PWRMON_H */
  220. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/