py32f0xx_hal_led.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_hal_led.h
  4. * @author MCU Application Team
  5. * @brief Header file of LED HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. #ifndef __PY32F0xx_HAL_LED_H
  31. #define __PY32F0xx_HAL_LED_H
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /* Includes ------------------------------------------------------------------*/
  36. #include "py32f0xx_hal_def.h"
  37. /** @addtogroup PY32F0xx_HAL_Driver
  38. * @{
  39. */
  40. /** @defgroup LED LED
  41. * @brief LED HAL module driver
  42. * @{
  43. */
  44. /* Exported Types ------------------------------------------------------------*/
  45. /** @defgroup LED_Exported_Types LED Exported Types
  46. * @brief LED HAL module driver
  47. * @{
  48. */
  49. /**
  50. * @brief LED Init Structure definition
  51. */
  52. typedef struct
  53. {
  54. uint32_t ComDrive; /*!< Specifies the LED COM drive capability.
  55. This parameter can be a value of @ref LED_COMDrive */
  56. uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the LED clock.
  57. This parameter can be a number between Min_Data = 0x00(div1) and Max_Data = 0xFF(div256) */
  58. uint32_t ComNum; /*!< Specifies the number of COM open.
  59. This parameter can be a number between Min_Data = 0(1COM) and Max_Data = 3(4COM) */
  60. uint32_t LightTime; /*!< Specifies LED Lighting time.
  61. This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
  62. uint32_t DeadTime; /*!< Specifies LED Dead time.
  63. This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
  64. } LED_InitTypeDef;
  65. /**
  66. * @brief HAL LED State structures definition
  67. */
  68. typedef enum
  69. {
  70. HAL_LED_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
  71. HAL_LED_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  72. HAL_LED_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
  73. HAL_LED_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  74. HAL_LED_STATE_ERROR = 0x04U /*!< Error */
  75. }HAL_LED_StateTypeDef;
  76. #if (USE_HAL_LED_REGISTER_CALLBACKS == 1)
  77. typedef struct __LED_HandleTypeDef
  78. #else
  79. typedef struct
  80. #endif
  81. {
  82. LED_TypeDef *Instance;
  83. LED_InitTypeDef Init;
  84. HAL_LockTypeDef Lock; /* Locking object */
  85. __IO HAL_LED_StateTypeDef State; /* LED communication state */
  86. #if (USE_HAL_LED_REGISTER_CALLBACKS == 1)
  87. void (* MspInitCallback)(struct __LED_HandleTypeDef *hled);
  88. void (* LightComplateCallback)(struct __LED_HandleTypeDef *hled);
  89. #endif
  90. } LED_HandleTypeDef;
  91. /**
  92. * @}
  93. */
  94. /* Exported Macros -----------------------------------------------------------*/
  95. /** @defgroup LED_Exported_Macros LED Exported Macros
  96. * @{
  97. */
  98. #define __HAL_LED_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, LED_CR_LEDON)
  99. /** @brief Disable the specified LED peripheral.
  100. * @param __HANDLE__ specifies the LED Handle.
  101. * @retval None
  102. */
  103. #define __HAL_LED_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, LED_CR_LEDON)
  104. #define __HAL_LED_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->IR = (__FLAG__))
  105. #define __HAL_LED_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
  106. /**
  107. * @}
  108. */
  109. /* Exported Constants --------------------------------------------------------*/
  110. /** @defgroup LED_Exported_constants LED Exported Constants
  111. * @{
  112. */
  113. /** @defgroup LED_Display_Value LED Display Value
  114. * @{
  115. */
  116. #define LED_DISP_NONE 0x00
  117. #define LED_DISP_FULL 0xFF
  118. #define LED_DISP_0 0x3F
  119. #define LED_DISP_1 0x06
  120. #define LED_DISP_2 0x5B
  121. #define LED_DISP_3 0x4F
  122. #define LED_DISP_4 0x66
  123. #define LED_DISP_5 0x6D
  124. #define LED_DISP_6 0x7D
  125. #define LED_DISP_7 0x07
  126. #define LED_DISP_8 0x7F
  127. #define LED_DISP_9 0x6F
  128. #define LED_DISP_A 0x77
  129. #define LED_DISP_B 0x7C
  130. #define LED_DISP_C 0x39
  131. #define LED_DISP_D 0x5E
  132. #define LED_DISP_E 0x79
  133. #define LED_DISP_F 0x71
  134. #define LED_DISP_H 0x76
  135. #define LED_DISP_P 0x73
  136. #define LED_DISP_U 0x3E
  137. #define LED_DISP_DOT 0x80
  138. /**
  139. * @}
  140. */
  141. /** @defgroup LED_COM_Select LED COM Select
  142. * @{
  143. */
  144. #define LED_COM0 (0x01<<0)
  145. #define LED_COM1 (0x01<<1)
  146. #define LED_COM2 (0x01<<2)
  147. #define LED_COM3 (0x01<<3)
  148. #define LED_COM_ALL (LED_COM0 | LED_COM1 | LED_COM2 | LED_COM3)
  149. /**
  150. * @}
  151. */
  152. /** @defgroup LED_COMDrive LED COM Drive
  153. * @{
  154. */
  155. #define LED_COMDRIVE_LOW 0
  156. #define LED_COMDRIVE_HIGH LED_CR_EHS
  157. /**
  158. * @}
  159. */
  160. /**
  161. * @}
  162. */
  163. /* Private macros ------------------------------------------------------------*/
  164. /** @defgroup LED_Private_Macros LED Private Macros
  165. * @{
  166. */
  167. #define IS_LED_COM_DRIVE(__DRIVE__) (((__DRIVE__) == LED_COMDRIVE_LOW) || \
  168. ((__DRIVE__) == LED_COMDRIVE_HIGH))
  169. #define IS_LED_PRISCALER(__PRISCALER__) (((__PRISCALER__) >= 0x00u) && \
  170. ((__PRISCALER__) <= 0xFF))
  171. #define IS_LED_COM_NUM(__NUM__) (((__NUM__) >= 0x00u) && ((__NUM__) <= 0x3))
  172. #define IS_LED_LIGHT_TIME(__TIME__) (((__TIME__) >= 0x1u) && ((__TIME__) <= 0xFF))
  173. #define IS_LED_DEAD_TIME(__TIME__) (((__TIME__) >= 0x1u) && ((__TIME__) <= 0xFF))
  174. /**
  175. * @}
  176. */
  177. /* Exported Functions --------------------------------------------------------*/
  178. /** @defgroup LED_Exported_Functions LED Exported Functions
  179. * @{
  180. */
  181. /** @addtogroup LED_Exported_Functions_Group1 Initialization/de-initialization functions
  182. * @brief Initialization and Configuration functions
  183. * @{
  184. */
  185. /* Initialization and Configuration functions **********************************/
  186. HAL_StatusTypeDef HAL_LED_Init(LED_HandleTypeDef *hled);
  187. void HAL_LED_MspInit(LED_HandleTypeDef *hled);
  188. /**
  189. * @}
  190. */
  191. /** @addtogroup LED_Exported_Functions_Group2 LED Operation Functions
  192. * @{
  193. */
  194. /* LED operation functions *****************************************************/
  195. HAL_StatusTypeDef HAL_LED_SetComDisplay(LED_HandleTypeDef *hled, uint8_t comCh, uint8_t data);
  196. void HAL_LED_LightCpltCallback(LED_HandleTypeDef *hled);
  197. void HAL_LED_IRQHandler(LED_HandleTypeDef *hled);
  198. /**
  199. * @}
  200. */
  201. /**
  202. * @}
  203. */
  204. /**
  205. * @}
  206. */
  207. /**
  208. * @}
  209. */
  210. #endif