py32f0xx_hal.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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 __PY32F002B_HAL_H
  33. #define __PY32F002B_HAL_H
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /* Includes ------------------------------------------------------------------*/
  38. #include "py32f002b_hal_conf.h"
  39. /** @addtogroup PY32F002B_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. /** @defgroup SYSCFG_Exported_Constants SYSCFG Exported Constants
  76. * @{
  77. */
  78. /** @defgroup SYSCFG_BootMode Boot Mode
  79. * @{
  80. */
  81. #define SYSCFG_BOOT_MAINFLASH 0x00000000U /*!< Main Flash memory mapped at 0x0000 0000 */
  82. #define SYSCFG_BOOT_SYSTEMFLASH SYSCFG_CFGR1_MEM_MODE_0 /*!< System Flash memory mapped at 0x0000 0000 */
  83. #define SYSCFG_BOOT_SRAM (SYSCFG_CFGR1_MEM_MODE_1 | SYSCFG_CFGR1_MEM_MODE_0) /*!< Embedded SRAM mapped at 0x0000 0000 */
  84. /**
  85. * @}
  86. */
  87. /** @defgroup SYSTEM_CH1_SRC TIM1 CH1 SOURCE
  88. * @{
  89. */
  90. #define SYSCFG_CH1_SRC_TIM1_GPIO 0x00000000U
  91. #if defined(COMP1)
  92. #define SYSCFG_CH1_SRC_TIM1_COMP1 SYSCFG_CFGR1_TIM1_IC1_SRC_0
  93. #define SYSCFG_CH1_SRC_TIM1_COMP2 SYSCFG_CFGR1_TIM1_IC1_SRC_1
  94. #endif
  95. /**
  96. * @}
  97. */
  98. /** @defgroup SYSTEM_I2C_FMP I2C FAST MODE ENABLE CONTORL
  99. * @{
  100. */
  101. #define SYSCFG_I2C_FMP_PA2 SYSCFG_CFGR1_I2C_PA2_FMP
  102. #define SYSCFG_I2C_FMP_PB3 SYSCFG_CFGR1_I2C_PB3_FMP
  103. #define SYSCFG_I2C_FMP_PB4 SYSCFG_CFGR1_I2C_PB4_FMP
  104. #define SYSCFG_I2C_FMP_PB6 SYSCFG_CFGR1_I2C_PB6_FMP
  105. /**
  106. * @}
  107. */
  108. #if defined(SYSCFG_CFGR2_ETR_SRC_TIM1)
  109. /** @defgroup SYSCFG_CFGR2_ETR_SRC_TIM1 TIM1 ETR SRC
  110. * @{
  111. */
  112. #define SYSCFG_ETR_SRC_TIM1_GPIO 0x00000000
  113. #if defined(COMP1)
  114. #define SYSCFG_ETR_SRC_TIM1_COMP1 SYSCFG_CFGR2_ETR_SRC_TIM1_0
  115. #define SYSCFG_ETR_SRC_TIM1_COMP2 SYSCFG_CFGR2_ETR_SRC_TIM1_1
  116. #endif
  117. #define SYSCFG_ETR_SRC_TIM1_ADC (SYSCFG_CFGR2_ETR_SRC_TIM1_1 | SYSCFG_CFGR2_ETR_SRC_TIM1_0)
  118. /**
  119. * @}
  120. */
  121. #endif /* SYSCFG_CFGR2_ETR_SRC_TIM1 */
  122. /**
  123. * @}
  124. */
  125. /* Exported macro ------------------------------------------------------------*/
  126. /** @defgroup HAL_Exported_Macros HAL Exported Macros
  127. * @{
  128. */
  129. /** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
  130. * @brief Freeze/Unfreeze Peripherals in Debug mode
  131. * Note:
  132. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  133. * debug mode (not accessible by the user software in normal mode).
  134. * Refer to errata sheet of these devices for more details.
  135. * @{
  136. */
  137. /* Peripherals on APB1 */
  138. #if defined(DBGMCU_APB_FZ1_DBG_IWDG_STOP)
  139. #define __HAL_DBGMCU_FREEZE_IWDG() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_IWDG_STOP))
  140. #define __HAL_DBGMCU_UNFREEZE_IWDG() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_IWDG_STOP))
  141. #endif /* DBGMCU_APB_FZ1_DBG_IWDG_STOP */
  142. #if defined(DBGMCU_APB_FZ1_DBG_I2C1_STOP)
  143. #define __HAL_DBGMCU_FREEZE_I2C1() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_I2C1_STOP))
  144. #define __HAL_DBGMCU_UNFREEZE_I2C1() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_I2C1_STOP))
  145. #endif /* DBGMCU_APB_FZ1_DBG_I2C1_STOP */
  146. #if defined(DBGMCU_APB_FZ1_DBG_LPTIM_STOP)
  147. #define __HAL_DBGMCU_FREEZE_LPTIM() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_LPTIM_STOP))
  148. #define __HAL_DBGMCU_UNFREEZE_LPTIM() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_LPTIM_STOP))
  149. #endif /* DBGMCU_APB_FZ1_DBG_LPTIM_STOP */
  150. #if defined(DBGMCU_APB_FZ2_DBG_TIM1_STOP)
  151. #define __HAL_DBGMCU_FREEZE_TIM1() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM1_STOP))
  152. #define __HAL_DBGMCU_UNFREEZE_TIM1() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM1_STOP))
  153. #endif /* DBGMCU_APB_FZ2_DBG_TIM1_STOP */
  154. #if defined(DBGMCU_APB_FZ2_DBG_TIM14_STOP)
  155. #define __HAL_DBGMCU_FREEZE_TIM14() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM14_STOP))
  156. #define __HAL_DBGMCU_UNFREEZE_TIM14() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM14_STOP))
  157. #endif /* DBGMCU_APB_FZ2_DBG_TIM14_STOP */
  158. /**
  159. * @}
  160. */
  161. /** @defgroup SYSCFG_Exported_Macros SYSCFG Exported Macros
  162. * @{
  163. */
  164. #if defined(COMP1)
  165. /** @brief Enable or disable COMP1 output as TIM1 ocref_Clr input.
  166. */
  167. #define __HAL_SYSCFG_COMP1_OCREF_CLR_TIM1_ENABLE() SET_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_COMP1_OCREF_CLR_TIM1)
  168. #define __HAL_SYSCFG_COMP1_OCREF_CLR_TIM1_DISABLE() CLEAR_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_COMP1_OCREF_CLR_TIM1)
  169. /** @brief Enable or disable COMP2 output as TIM1 ocref_Clr input.
  170. */
  171. #define __HAL_SYSCFG_COMP2_OCREF_CLR_TIM1_ENABLE() SET_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_COMP2_OCREF_CLR_TIM1)
  172. #define __HAL_SYSCFG_COMP2_OCREF_CLR_TIM1_DISABLE() CLEAR_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_COMP2_OCREF_CLR_TIM1)
  173. #endif
  174. /** @brief SYSCFG Break Cortex-M0+ Lockup lock.
  175. * Enables and locks the connection of Cortex-M0+ LOCKUP (Hardfault) output to TIM1 Break input
  176. * @note The selected configuration is locked and can be unlocked only by system reset.
  177. */
  178. #define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_LOCKUP_LOCK)
  179. #if defined(SYSCFG_CFGR2_COMP1_BRK_TIM1)
  180. /** @brief COMP1 as Timer1 Break input
  181. */
  182. #define __HAL_SYSCFG_COMP1_BREAK_TIM1() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM1)
  183. #endif
  184. #if defined(SYSCFG_CFGR2_COMP2_BRK_TIM1)
  185. /** @brief COMP2 as Timer1 Break input
  186. */
  187. #define __HAL_SYSCFG_COMP2_BREAK_TIM1() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM1)
  188. #endif
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @}
  194. */
  195. /* Private Macros -------------------------------------------------------------*/
  196. /** @defgroup HAL_Private_Macros HAL Private Macros
  197. * @{
  198. */
  199. #define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \
  200. ((FREQ) == HAL_TICK_FREQ_100HZ) || \
  201. ((FREQ) == HAL_TICK_FREQ_1KHZ))
  202. /**
  203. * @}
  204. */
  205. /* Exported functions --------------------------------------------------------*/
  206. /** @defgroup HAL_Exported_Functions HAL Exported Functions
  207. * @{
  208. */
  209. /** @addtogroup HAL_Exported_Functions_Group1
  210. * @{
  211. */
  212. /* Initialization and de-initialization functions ******************************/
  213. HAL_StatusTypeDef HAL_Init(void);
  214. HAL_StatusTypeDef HAL_DeInit(void);
  215. void HAL_MspInit(void);
  216. void HAL_MspDeInit(void);
  217. HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
  218. /**
  219. * @}
  220. */
  221. /** @addtogroup HAL_Exported_Functions_Group2
  222. * @{
  223. */
  224. /* Peripheral Control functions ************************************************/
  225. void HAL_IncTick(void);
  226. void HAL_Delay(uint32_t Delay);
  227. uint32_t HAL_GetTick(void);
  228. uint32_t HAL_GetTickPrio(void);
  229. HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq);
  230. uint32_t HAL_GetTickFreq(void);
  231. void HAL_SuspendTick(void);
  232. void HAL_ResumeTick(void);
  233. uint32_t HAL_GetHalVersion(void);
  234. uint32_t HAL_GetREVID(void);
  235. uint32_t HAL_GetDEVID(void);
  236. uint32_t HAL_GetUIDw0(void);
  237. uint32_t HAL_GetUIDw1(void);
  238. uint32_t HAL_GetUIDw2(void);
  239. /**
  240. * @}
  241. */
  242. /** @addtogroup HAL_Exported_Functions_Group3
  243. * @{
  244. */
  245. /* HAL Debug functions *********************************************************/
  246. void HAL_DBGMCU_EnableDBGMCUStopMode(void);
  247. void HAL_DBGMCU_DisableDBGMCUStopMode(void);
  248. /**
  249. * @}
  250. */
  251. /** @addtogroup HAL_Exported_Functions_Group4
  252. * @{
  253. */
  254. /* SYSCFG configuration functions **********************************************/
  255. void HAL_SYSCFG_SetRemapMemory(uint32_t Memory);
  256. uint32_t HAL_SYSCFG_GetRemapMemory(void);
  257. void HAL_SYSCFG_SetTIM1CH1Source(uint32_t Source);
  258. uint32_t HAL_SYSCFG_GetTIM1CH1Source(void);
  259. void HAL_SYSCFG_EnableI2CFastModePlus(uint32_t I2CFastModePlus);
  260. void HAL_SYSCFG_DisableI2CFastModePlus(uint32_t I2CFastModePlus);
  261. void HAL_SYSCFG_TIM1ETRSource(uint32_t ETRSource);
  262. void HAL_SYSCFG_EnableGPIONoiseFilter(GPIO_TypeDef *GPIOx,uint16_t GPIO_Pin);
  263. void HAL_SYSCFG_DisableGPIONoiseFilter(GPIO_TypeDef *GPIOx,uint16_t GPIO_Pin);
  264. /**
  265. * @}
  266. */
  267. /**
  268. * @}
  269. */
  270. /* Private types -------------------------------------------------------------*/
  271. /* Private variables ---------------------------------------------------------*/
  272. /** @defgroup HAL_Private_Variables HAL Private Variables
  273. * @{
  274. */
  275. /**
  276. * @}
  277. */
  278. /* Private constants ---------------------------------------------------------*/
  279. /** @defgroup HAL_Private_Constants HAL Private Constants
  280. * @{
  281. */
  282. /**
  283. * @}
  284. */
  285. /* Private macros ------------------------------------------------------------*/
  286. /* Private functions ---------------------------------------------------------*/
  287. /**
  288. * @}
  289. */
  290. /**
  291. * @}
  292. */
  293. #ifdef __cplusplus
  294. }
  295. #endif
  296. #endif /* __PY32F002B_HAL_H */
  297. /************************ (C) COPYRIGHT Puya *****END OF FILE****/