py32f0xx_hal.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_hal.h
  4. * @author MCU Application Team
  5. * @brief This file contains all the functions prototypes for the HAL
  6. * module driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by Puya 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. * @attention
  20. *
  21. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  22. * All rights reserved.</center></h2>
  23. *
  24. * This software component is licensed by ST under BSD 3-Clause license,
  25. * the "License"; You may not use this file except in compliance with the
  26. * License. You may obtain a copy of the License at:
  27. * opensource.org/licenses/BSD-3-Clause
  28. *
  29. ******************************************************************************
  30. */
  31. /* Define to prevent recursive inclusion -------------------------------------*/
  32. #ifndef __PY32F0xx_HAL_H
  33. #define __PY32F0xx_HAL_H
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /* Includes ------------------------------------------------------------------*/
  38. #include "py32f0xx_hal_conf.h"
  39. /** @addtogroup PY32F0xx_HAL_Driver
  40. * @{
  41. */
  42. /** @addtogroup HAL
  43. * @{
  44. */
  45. /* Exported constants --------------------------------------------------------*/
  46. /** @defgroup HAL_Exported_Constants HAL Exported Constants
  47. * @{
  48. */
  49. /** @defgroup HAL_TICK_FREQ Tick Frequency
  50. * @{
  51. */
  52. typedef enum
  53. {
  54. HAL_TICK_FREQ_10HZ = 100U,
  55. HAL_TICK_FREQ_100HZ = 10U,
  56. HAL_TICK_FREQ_1KHZ = 1U,
  57. HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
  58. } HAL_TickFreqTypeDef;
  59. /**
  60. * @}
  61. */
  62. /**
  63. * @}
  64. */
  65. /* Exported types ------------------------------------------------------------*/
  66. /* Exported variables --------------------------------------------------------*/
  67. /** @addtogroup HAL_Exported_Variables
  68. * @{
  69. */
  70. extern uint32_t uwTickPrio;
  71. extern uint32_t uwTickFreq;
  72. /**
  73. * @}
  74. */
  75. /* SYSCFG Exported Constants -------------------------------------------------*/
  76. /** @defgroup SYSCFG_Exported_Constants SYSCFG Exported Constants
  77. * @{
  78. */
  79. /** @defgroup SYSCFG_BootMode Boot Mode
  80. * @{
  81. */
  82. #define SYSCFG_BOOT_MAINFLASH 0x00000000U /*!< Main Flash memory mapped at 0x0000 0000 */
  83. #define SYSCFG_BOOT_SYSTEMFLASH SYSCFG_CFGR1_MEM_MODE_0 /*!< System Flash memory mapped at 0x0000 0000 */
  84. #define SYSCFG_BOOT_SRAM (SYSCFG_CFGR1_MEM_MODE_1 | SYSCFG_CFGR1_MEM_MODE_0) /*!< Embedded SRAM mapped at 0x0000 0000 */
  85. /**
  86. * @}
  87. */
  88. /**
  89. * @}
  90. */
  91. /* Exported macros -----------------------------------------------------------*/
  92. /** @defgroup HAL_Exported_Macros HAL Exported Macros
  93. * @{
  94. */
  95. /** @defgroup HAL_Freeze_Unfreeze_Peripherals HAL Freeze Unfreeze Peripherals
  96. * @brief Freeze/Unfreeze Peripherals in Debug mode
  97. * @{
  98. */
  99. #if defined(DBGMCU_APB_FZ1_DBG_RTC_STOP)
  100. #define __HAL_DBGMCU_FREEZE_RTC() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_RTC_STOP))
  101. #define __HAL_DBGMCU_UNFREEZE_RTC() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_RTC_STOP))
  102. #endif /* DBGMCU_APB_FZ_DBG_RTC_STOP */
  103. #if defined(DBGMCU_APB_FZ1_DBG_I2C_SMBUS_TIMEOUT)
  104. #define __HAL_DBGMCU_FREEZE_I2C_TIMEOUT() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_I2C_SMBUS_TIMEOUT))
  105. #define __HAL_DBGMCU_UNFREEZE_I2C_TIMEOUT() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_I2C_SMBUS_TIMEOUT))
  106. #endif /* DBGMCU_APB_FZ_DBG_I2C_SMBUS_TIMEOUT */
  107. #if defined(DBGMCU_APB_FZ1_DBG_IWDG_STOP)
  108. #define __HAL_DBGMCU_FREEZE_IWDG() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_IWDG_STOP))
  109. #define __HAL_DBGMCU_UNFREEZE_IWDG() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_IWDG_STOP))
  110. #endif /* DBGMCU_APB_FZ_DBG_IWDG_STOP */
  111. #if defined(DBGMCU_APB_FZ1_DBG_WWDG_STOP)
  112. #define __HAL_DBGMCU_FREEZE_WWDG() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_WWDG_STOP))
  113. #define __HAL_DBGMCU_UNFREEZE_WWDG() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_WWDG_STOP))
  114. #endif /* DBGMCU_APB_FZ_DBG_WWDG_STOP */
  115. #if defined(DBGMCU_APB_FZ1_DBG_TIM2_STOP)
  116. #define __HAL_DBGMCU_FREEZE_TIM2() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM2_STOP))
  117. #define __HAL_DBGMCU_UNFREEZE_TIM2() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM2_STOP))
  118. #endif /* DBGMCU_APB_FZ_DBG_TIM2_STOP */
  119. #if defined(DBGMCU_APB_FZ1_DBG_TIM3_STOP)
  120. #define __HAL_DBGMCU_FREEZE_TIM3() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM3_STOP))
  121. #define __HAL_DBGMCU_UNFREEZE_TIM3() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM3_STOP))
  122. #endif /* DBGMCU_APB_FZ_DBG_TIM3_STOP */
  123. #if defined(DBGMCU_APB_FZ1_DBG_TIM6_STOP)
  124. #define __HAL_DBGMCU_FREEZE_TIM6() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM6_STOP))
  125. #define __HAL_DBGMCU_UNFREEZE_TIM6() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM6_STOP))
  126. #endif /* DBGMCU_APB_FZ_DBG_TIM6_STOP */
  127. #if defined(DBGMCU_APB_FZ1_DBG_TIM7_STOP)
  128. #define __HAL_DBGMCU_FREEZE_TIM7() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM7_STOP))
  129. #define __HAL_DBGMCU_UNFREEZE_TIM7() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM7_STOP))
  130. #endif /* DBGMCU_APB_FZ_DBG_TIM7_STOP */
  131. #if defined(DBGMCU_APB_FZ1_DBG_TIM14_STOP)
  132. #define __HAL_DBGMCU_FREEZE_TIM14() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM14_STOP))
  133. #define __HAL_DBGMCU_UNFREEZE_TIM14() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM14_STOP))
  134. #endif /* DBGMCU_APB_FZ_DBG_TIM14_STOP */
  135. #if defined(DBGMCU_APB_FZ2_DBG_TIM1_STOP)
  136. #define __HAL_DBGMCU_FREEZE_TIM1() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM1_STOP))
  137. #define __HAL_DBGMCU_UNFREEZE_TIM1() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM1_STOP))
  138. #endif /* DBGMCU_APB_FZ_DBG_TIM1_STOP */
  139. #if defined(DBGMCU_APB_FZ2_DBG_TIM15_STOP)
  140. #define __HAL_DBGMCU_FREEZE_TIM15() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM15_STOP))
  141. #define __HAL_DBGMCU_UNFREEZE_TIM15() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM15_STOP))
  142. #endif /* DBGMCU_APB_FZ2_DBG_TIM15_STOP */
  143. #if defined(DBGMCU_APB_FZ2_DBG_TIM16_STOP)
  144. #define __HAL_DBGMCU_FREEZE_TIM16() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM16_STOP))
  145. #define __HAL_DBGMCU_UNFREEZE_TIM16() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM16_STOP))
  146. #endif /* DBGMCU_APB_FZ_DBG_TIM16_STOP */
  147. #if defined(DBGMCU_APB_FZ2_DBG_TIM17_STOP)
  148. #define __HAL_DBGMCU_FREEZE_TIM17() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM17_STOP))
  149. #define __HAL_DBGMCU_UNFREEZE_TIM17() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM17_STOP))
  150. #endif /* DBGMCU_APB_FZ_DBG_TIM17_STOP */
  151. /**
  152. * @}
  153. */
  154. /** @defgroup SYSCFG_Exported_Macros SYSCFG Exported Macros
  155. * @{
  156. */
  157. /** @brief SYSCFG Break Cortex-M0+ Lockup lock.
  158. * Enables and locks the connection of Cortex-M0+ LOCKUP (Hardfault) output to TIM1/15/16/17 Break input
  159. * @note The selected configuration is locked and can be unlocked only by system reset.
  160. */
  161. #define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_LOCKUP_LOCK)
  162. #if defined(SYSCFG_CFGR2_PVD_LOCK)
  163. /** @brief SYSCFG Break PVD lock.
  164. * Enables and locks the PVD connection with Timer1/15/16/17 Break input, as well as the PVDE and PLS[2:0] in the PWR_CR register
  165. * @note The selected configuration is locked and can be unlocked only by system reset
  166. */
  167. #define __HAL_SYSCFG_BREAK_PVD_LOCK() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_PVD_LOCK)
  168. #endif
  169. #if defined(SYSCFG_CFGR2_COMP1_BRK_TIM1)
  170. /** @brief SYSCFG COMP1 AS TIMx break.
  171. * COMP1 as Timer1Break input
  172. * @note The selected configuration is locked and can be unlocked only by system reset
  173. */
  174. #define __HAL_SYSCFG_COMP1_BREAK_TIM1() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM1)
  175. #endif
  176. #if defined(SYSCFG_CFGR2_COMP2_BRK_TIM1)
  177. #define __HAL_SYSCFG_COMP2_BREAK_TIM1() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM1)
  178. #endif
  179. #if defined(SYSCFG_CFGR2_COMP1_BRK_TIM16)
  180. #define __HAL_SYSCFG_COMP1_BREAK_TIM16() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM16)
  181. #endif
  182. #if defined(SYSCFG_CFGR2_COMP2_BRK_TIM16)
  183. #define __HAL_SYSCFG_COMP2_BREAK_TIM16() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM16)
  184. #endif
  185. #if defined(SYSCFG_CFGR2_COMP1_BRK_TIM17)
  186. #define __HAL_SYSCFG_COMP1_BREAK_TIM17() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM17)
  187. #endif
  188. #if defined(SYSCFG_CFGR2_COMP2_BRK_TIM17)
  189. #define __HAL_SYSCFG_COMP2_BREAK_TIM17() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM17)
  190. #endif
  191. /**
  192. * @}
  193. */
  194. /**
  195. * @}
  196. */
  197. /* Private Macros -------------------------------------------------------------*/
  198. /** @defgroup HAL_Private_Macros HAL Private Macros
  199. * @{
  200. */
  201. #define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \
  202. ((FREQ) == HAL_TICK_FREQ_100HZ) || \
  203. ((FREQ) == HAL_TICK_FREQ_1KHZ))
  204. /**
  205. * @}
  206. */
  207. /* Exported functions --------------------------------------------------------*/
  208. /** @addtogroup HAL_Exported_Functions
  209. * @{
  210. */
  211. /** @addtogroup HAL_Exported_Functions_Group1
  212. * @{
  213. */
  214. /* Initialization and de-initialization functions ******************************/
  215. HAL_StatusTypeDef HAL_Init(void);
  216. HAL_StatusTypeDef HAL_DeInit(void);
  217. void HAL_MspInit(void);
  218. void HAL_MspDeInit(void);
  219. HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
  220. /**
  221. * @}
  222. */
  223. /** @addtogroup HAL_Exported_Functions_Group2
  224. * @{
  225. */
  226. /* Peripheral Control functions ************************************************/
  227. void HAL_IncTick(void);
  228. void HAL_Delay(uint32_t Delay);
  229. uint32_t HAL_GetTick(void);
  230. uint32_t HAL_GetTickPrio(void);
  231. HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq);
  232. uint32_t HAL_GetTickFreq(void);
  233. void HAL_SuspendTick(void);
  234. void HAL_ResumeTick(void);
  235. uint32_t HAL_GetHalVersion(void);
  236. uint32_t HAL_GetREVID(void);
  237. uint32_t HAL_GetDEVID(void);
  238. uint32_t HAL_GetUIDw0(void);
  239. uint32_t HAL_GetUIDw1(void);
  240. uint32_t HAL_GetUIDw2(void);
  241. /**
  242. * @}
  243. */
  244. /** @addtogroup HAL_Exported_Functions_Group3
  245. * @{
  246. */
  247. /* HAL Debug functions *********************************************************/
  248. void HAL_DBGMCU_EnableDBGSleepMode(void);
  249. void HAL_DBGMCU_DisableDBGSleepMode(void);
  250. void HAL_DBGMCU_EnableDBGStopMode(void);
  251. void HAL_DBGMCU_DisableDBGStopMode(void);
  252. /**
  253. * @}
  254. */
  255. #if (defined(DMA)||defined(DMA1))
  256. /** @addtogroup HAL_Exported_Functions_Group4
  257. * @{
  258. */
  259. /* SYSCFG configuration functions **********************************************/
  260. void HAL_SYSCFG_DMA_Req(uint32_t Requset);
  261. /**
  262. * @}
  263. */
  264. #endif
  265. /**
  266. * @}
  267. */
  268. /* Private types -------------------------------------------------------------*/
  269. /* Private variables ---------------------------------------------------------*/
  270. /** @defgroup HAL_Private_Variables HAL Private Variables
  271. * @{
  272. */
  273. /**
  274. * @}
  275. */
  276. /* Private constants ---------------------------------------------------------*/
  277. /** @defgroup HAL_Private_Constants HAL Private Constants
  278. * @{
  279. */
  280. /**
  281. * @}
  282. */
  283. /* Private macros ------------------------------------------------------------*/
  284. /* Private functions ---------------------------------------------------------*/
  285. /**
  286. * @}
  287. */
  288. /**
  289. * @}
  290. */
  291. #ifdef __cplusplus
  292. }
  293. #endif
  294. #endif /* __PY32F0xx_HAL_H */
  295. /************************ (C) COPYRIGHT Puya *****END OF FILE****/