stm32l0xx_hal_def.h 7.3 KB

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