tae32f53xx_ll_def.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_def.h
  4. * @author MCD Application Team
  5. * @brief This file contains LL common defines, enumeration, macros and
  6. * structures definitions.
  7. *
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; Copyright (c) 2020 Tai-Action.
  12. * All rights reserved.</center></h2>
  13. *
  14. * This software is licensed by Tai-Action under BSD 3-Clause license,
  15. * the "License"; You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef _TAE32F53XX_LL_DEF_H_
  23. #define _TAE32F53XX_LL_DEF_H_
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif /* __cplusplus */
  27. /* Includes ------------------------------------------------------------------*/
  28. #include <stddef.h>
  29. #include "tae32f53xx.h"
  30. /** @addtogroup TAE32F53xx_LL_Driver
  31. * @{
  32. */
  33. /** @defgroup DEFINE_LL DEFINE LL
  34. * @brief DEFINE LL
  35. * @{
  36. */
  37. /* Exported constants --------------------------------------------------------*/
  38. /** @defgroup DEFINE_LL_Exported_Constants DEFINE LL Exported Constants
  39. * @brief DEFINE LL Exported Constants
  40. * @{
  41. */
  42. /**
  43. * @brief LL wait forever time definition
  44. */
  45. #define LL_WAIT_FOREVER 0xFFFFFFFFUL
  46. /**
  47. * @brief LL wait max delay time definition
  48. */
  49. #define LL_MAX_DELAY (LL_WAIT_FOREVER - 1U)
  50. /**
  51. * @}
  52. */
  53. /* Exported types ------------------------------------------------------------*/
  54. /** @defgroup DEFINE_LL_Exported_Types DEFINE LL Exported Types
  55. * @brief DEFINE LL Exported Types
  56. * @{
  57. */
  58. /**
  59. * @brief LL Status type definition
  60. */
  61. typedef enum {
  62. LL_OK = 0x00U, /*! LL status OK */
  63. LL_ERROR = 0x01U, /*! LL status ERROR */
  64. LL_BUSY = 0x02U, /*! LL status BUSY */
  65. LL_TIMEOUT = 0x03U, /*! LL status TIMEOUT */
  66. LL_FAILED = 0x04U, /*! LL status FAILED */
  67. } LL_StatusETypeDef;
  68. /**
  69. * @brief LL Flag status type definition
  70. */
  71. typedef enum {
  72. RESET = 0, /*!< LL flag status RESET */
  73. SET = !RESET, /*!< LL flag status SET */
  74. } LL_FlagStatusETypeDef;
  75. /**
  76. * @brief LL Functional status type definition
  77. */
  78. typedef enum {
  79. DISABLE = 0, /*!< LL functional status DISABLE */
  80. ENABLE = !DISABLE, /*!< LL functional status ENABLE */
  81. } LL_FuncStatusETypeDef;
  82. /**
  83. * @brief LL Error status type definiton
  84. */
  85. typedef enum {
  86. SUCCESS = 0U, /*!< LL error status SUCCESS */
  87. ERROR = !SUCCESS, /*!< LL error status ERROR */
  88. } LL_ErrStatusETypeDef;
  89. /**
  90. * @}
  91. */
  92. /* Exported macro ------------------------------------------------------------*/
  93. /** @defgroup DEFINE_LL_Exported_Macros DEFINE LL Exported Macros
  94. * @brief DEFINE LL Exported Macros
  95. * @{
  96. */
  97. /* Compiler ALIAS and WEAK attribute definition */
  98. #if defined (__CC_ARM) /*!< AC5 Compiler */
  99. #define __ALIAS_FUNC(FUNC) __attribute__ ((weak, alias(#FUNC)))
  100. #define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void) __attribute__ ((weak, alias(#FUNC_ALIAS)));
  101. #elif defined (__ICCARM__) /*!< IAR Compiler */
  102. #define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void);_Pragma(_STRINGIFY(_WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS)))
  103. #define _WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) weak WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS)
  104. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*!< AC6 Compiler */
  105. #define __ALIAS_FUNC(FUNC) __attribute__ ((weak, alias(#FUNC)))
  106. #define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void) __attribute__ ((weak, alias(#FUNC_ALIAS)));
  107. #elif defined (__GNUC__) /*!< GCC Compiler */
  108. #define __ALIAS_FUNC(FUNC) __attribute__ ((weak, alias(#FUNC)))
  109. #define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void) __attribute__ ((weak, alias(#FUNC_ALIAS)));
  110. #else
  111. #error Not supported compiler type
  112. #endif
  113. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  114. /* Compiler aligned on 4-bytes attribute definition */
  115. #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
  116. #ifndef __ALIGN_END
  117. #define __ALIGN_END __attribute__ ((aligned (4)))
  118. #endif
  119. #ifndef __ALIGN_BEGIN
  120. #define __ALIGN_BEGIN
  121. #endif
  122. #else
  123. #ifndef __ALIGN_END
  124. #define __ALIGN_END
  125. #endif
  126. #ifndef __ALIGN_BEGIN
  127. #if defined (__CC_ARM) /* ARM Compiler */
  128. #define __ALIGN_BEGIN __align(4)
  129. #elif defined (__ICCARM__) /* IAR Compiler */
  130. #define __ALIGN_BEGIN
  131. #endif
  132. #endif
  133. #endif
  134. /* Compiler __NOINLINE attribute definition */
  135. #if defined (__CC_ARM) || defined (__GNUC__) /* ARM & GNUCompiler */
  136. #define __NOINLINE __attribute__ ( (noinline) )
  137. #elif defined (__ICCARM__) /* ICCARM Compiler */
  138. #define __NOINLINE _Pragma("optimize = no_inline")
  139. #endif
  140. /* Compiler misc attribute definition */
  141. #if defined (__CC_ARM) /*!< AC5 Compiler */
  142. #define __NO_INIT __attribute__((zero_init))
  143. #define __AT(n) __attribute__((at(n)))
  144. #define __SECTION(SECT) __attribute__((section(#SECT)))
  145. #elif defined (__ICCARM__) /*!< IAR Compiler */
  146. #define __NO_INIT __no_init
  147. #define __AT(n) @(n)
  148. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*!< AC6 Compiler */
  149. #define __NO_INIT
  150. #define __AT(n) __attribute__ ((section(".ARM.__at_"#n)))
  151. #define __SECTION(SECT) __attribute__((section(#SECT)))
  152. #elif defined (__GNUC__) /*!< GCC Compiler */
  153. #define __NO_INIT __attribute__((zero_init))
  154. #define __AT(n)
  155. #define __SECTION(SECT) __attribute__((section(#SECT)))
  156. #endif
  157. /**
  158. * @brief Bit left shift definition
  159. * @param pos left shift position
  160. * @return Bit left shift value
  161. */
  162. #define BIT(pos) (1U << (pos))
  163. /**
  164. * @brief Set bit definition
  165. * @param REG register
  166. * @param BIT Bit to set
  167. * @return None
  168. */
  169. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  170. /**
  171. * @brief Clear bit definition
  172. * @param REG register
  173. * @param BIT Bit to clear
  174. * @return None
  175. */
  176. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  177. /**
  178. * @brief Read bit definition
  179. * @param REG register
  180. * @param BIT Bit to read
  181. * @return None
  182. */
  183. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  184. /**
  185. * @brief Clear register definiton
  186. * @param REG register
  187. * @return None
  188. */
  189. #define CLEAR_REG(REG) ((REG) = (0x0))
  190. /**
  191. * @brief Write register definiton
  192. * @param REG register
  193. * @param VAL write value
  194. * @return None
  195. */
  196. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  197. /**
  198. * @brief Read register definition
  199. * @param REG register
  200. * @return None
  201. */
  202. #define READ_REG(REG) ((REG))
  203. /**
  204. * @brief Modify register definition
  205. * @param REG register
  206. * @param CLEARMASK clear mask
  207. * @param SETMASK set mask
  208. * @return None
  209. */
  210. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  211. /**
  212. * @brief Position value definition
  213. * @param VAL value
  214. * @return None
  215. */
  216. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  217. /**
  218. * @brief To avoid gcc/g++ warnings
  219. * @param X avoid warning param
  220. * @return None
  221. */
  222. #define LL_UNUSED(X) (void)X
  223. /**
  224. * @brief Macro for counting the element number of an array
  225. * @param a Array to be Counted
  226. * @return size of Array
  227. */
  228. #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
  229. /**
  230. * @}
  231. */
  232. /* Exported functions --------------------------------------------------------*/
  233. /* Private types -------------------------------------------------------------*/
  234. /* Private variables ---------------------------------------------------------*/
  235. /* Private constants ---------------------------------------------------------*/
  236. /* Private macros ------------------------------------------------------------*/
  237. /* Private functions ---------------------------------------------------------*/
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. #ifdef __cplusplus
  245. }
  246. #endif /* __cplusplus */
  247. #endif /* _TAE32F53XX_LL_DEF_H_ */
  248. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/