py32f0xx_hal_def.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_hal_def.h
  4. * @author MCU Application Team
  5. * @version V1.0.0
  6. * @date
  7. * @brief This file contains HAL common defines, enumeration, macros and
  8. * structures definitions.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  13. * All rights reserved.</center></h2>
  14. *
  15. * This software component is licensed by Puya under BSD 3-Clause license,
  16. * the "License"; You may not use this file except in compliance with the
  17. * License. You may obtain a copy of the License at:
  18. * opensource.org/licenses/BSD-3-Clause
  19. *
  20. ******************************************************************************
  21. * @attention
  22. *
  23. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  24. * All rights reserved.</center></h2>
  25. *
  26. * This software component is licensed by ST under BSD 3-Clause license,
  27. * the "License"; You may not use this file except in compliance with the
  28. * License. You may obtain a copy of the License at:
  29. * opensource.org/licenses/BSD-3-Clause
  30. *
  31. ******************************************************************************
  32. */
  33. /* Define to prevent recursive inclusion -------------------------------------*/
  34. #ifndef __PY32F0xx_HAL_DEF
  35. #define __PY32F0xx_HAL_DEF
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /* Includes ------------------------------------------------------------------*/
  40. #include "py32f0xx.h"
  41. #include <stdio.h>
  42. /* Exported types ------------------------------------------------------------*/
  43. /**
  44. * @brief HAL Status structures definition
  45. */
  46. typedef enum
  47. {
  48. HAL_OK = 0x00U,
  49. HAL_ERROR = 0x01U,
  50. HAL_BUSY = 0x02U,
  51. HAL_TIMEOUT = 0x03U
  52. } HAL_StatusTypeDef;
  53. /**
  54. * @brief HAL Lock structures definition
  55. */
  56. typedef enum
  57. {
  58. HAL_UNLOCKED = 0x00U,
  59. HAL_LOCKED = 0x01U
  60. } HAL_LockTypeDef;
  61. /* Exported macro ------------------------------------------------------------*/
  62. #define HAL_MAX_DELAY 0xFFFFFFFFU
  63. #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U)
  64. #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
  65. #if (defined(DMA) || defined(DMA1))
  66. #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
  67. do{ \
  68. (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
  69. (__DMA_HANDLE__).Parent = (__HANDLE__); \
  70. } while(0U)
  71. #endif
  72. #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
  73. /** @brief Reset the Handle's State field.
  74. * @param __HANDLE__: specifies the Peripheral Handle.
  75. * @note This macro can be used for the following purpose:
  76. * - When the Handle is declared as local variable; before passing it as parameter
  77. * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  78. * to set to 0 the Handle's "State" field.
  79. * Otherwise, "State" field may have any random value and the first time the function
  80. * HAL_PPP_Init() is called, the low level hardware initialization will be missed
  81. * (i.e. HAL_PPP_MspInit() will not be executed).
  82. * - When there is a need to reconfigure the low level hardware: instead of calling
  83. * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  84. * In this later function, when the Handle's "State" field is set to 0, it will execute the function
  85. * HAL_PPP_MspInit() which will reconfigure the low level hardware.
  86. * @retval None
  87. */
  88. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
  89. #if (USE_RTOS == 1U)
  90. /* Reserved for future use */
  91. #error "USE_RTOS should be 0 in the current HAL release"
  92. #else
  93. #define __HAL_LOCK(__HANDLE__) \
  94. do{ \
  95. if((__HANDLE__)->Lock == HAL_LOCKED) \
  96. { \
  97. return HAL_BUSY; \
  98. } \
  99. else \
  100. { \
  101. (__HANDLE__)->Lock = HAL_LOCKED; \
  102. } \
  103. }while (0U)
  104. #define __HAL_UNLOCK(__HANDLE__) \
  105. do{ \
  106. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  107. }while (0U)
  108. #endif /* USE_RTOS */
  109. #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
  110. #ifndef __weak
  111. #define __weak __attribute__((weak))
  112. #endif /* __weak */
  113. #ifndef __packed
  114. #define __packed __attribute__((__packed__))
  115. #endif /* __packed */
  116. #endif /* __GNUC__ */
  117. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  118. #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
  119. #ifndef __ALIGN_END
  120. #define __ALIGN_END __attribute__ ((aligned (4)))
  121. #endif /* __ALIGN_END */
  122. #ifndef __ALIGN_BEGIN
  123. #define __ALIGN_BEGIN
  124. #endif /* __ALIGN_BEGIN */
  125. #else
  126. #ifndef __ALIGN_END
  127. #define __ALIGN_END
  128. #endif /* __ALIGN_END */
  129. #ifndef __ALIGN_BEGIN
  130. #if defined (__CC_ARM) /* ARM Compiler */
  131. #define __ALIGN_BEGIN __align(4)
  132. #elif defined (__ICCARM__) /* IAR Compiler */
  133. #define __ALIGN_BEGIN
  134. #endif /* __CC_ARM */
  135. #endif /* __ALIGN_BEGIN */
  136. #endif /* __GNUC__ */
  137. /**
  138. * @brief __RAM_FUNC definition
  139. */
  140. #if defined ( __CC_ARM )
  141. /* ARM Compiler
  142. ------------
  143. RAM functions are defined using the toolchain options.
  144. Functions that are executed in RAM should reside in a separate source module.
  145. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  146. area of a module to a memory space in physical RAM.
  147. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  148. dialog.
  149. */
  150. #define __RAM_FUNC
  151. #elif defined ( __ICCARM__ )
  152. /* ICCARM Compiler
  153. ---------------
  154. RAM functions are defined using a specific toolchain keyword "__ramfunc".
  155. */
  156. #define __RAM_FUNC __ramfunc
  157. #elif defined ( __GNUC__ )
  158. /* GNU Compiler
  159. ------------
  160. RAM functions are defined using a specific toolchain attribute
  161. "__attribute__((section(".RamFunc")))".
  162. */
  163. #define __RAM_FUNC __attribute__((section(".RamFunc")))
  164. #endif
  165. /**
  166. * @brief __NOINLINE definition
  167. */
  168. #if defined ( __CC_ARM ) || defined ( __GNUC__ )
  169. /* ARM & GNUCompiler
  170. ----------------
  171. */
  172. #define __NOINLINE __attribute__ ( (noinline) )
  173. #elif defined ( __ICCARM__ )
  174. /* ICCARM Compiler
  175. ---------------
  176. */
  177. #define __NOINLINE _Pragma("optimize = no_inline")
  178. #endif
  179. #if defined (USE_HAL_DRIVER)
  180. #include "py32f0xx_hal.h"
  181. #endif /* USE_HAL_DRIVER */
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif /* ___PY32F0xx_HAL_DEF */