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