]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F1/stm32f1xx_hal_def.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F1 / stm32f1xx_hal_def.h
1 /**
2   ******************************************************************************
3   * @file    stm32f1xx_hal_def.h
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    15-December-2014
7   * @brief   This file contains HAL common defines, enumeration, macros and 
8   *          structures definitions. 
9   ******************************************************************************
10   * @attention
11   *
12   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13   *
14   * Redistribution and use in source and binary forms, with or without modification,
15   * are permitted provided that the following conditions are met:
16   *   1. Redistributions of source code must retain the above copyright notice,
17   *      this list of conditions and the following disclaimer.
18   *   2. Redistributions in binary form must reproduce the above copyright notice,
19   *      this list of conditions and the following disclaimer in the documentation
20   *      and/or other materials provided with the distribution.
21   *   3. Neither the name of STMicroelectronics nor the names of its contributors
22   *      may be used to endorse or promote products derived from this software
23   *      without specific prior written permission.
24   *
25   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35   *
36   ******************************************************************************
37   */
38
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STM32F1xx_HAL_DEF
41 #define __STM32F1xx_HAL_DEF
42
43 #ifdef __cplusplus
44  extern "C" {
45 #endif
46
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f1xx.h"
49 #include "stm32_hal_legacy.h"
50
51 /* Exported types ------------------------------------------------------------*/
52
53 /** 
54   * @brief  HAL Status structures definition  
55   */  
56 typedef enum 
57 {
58   HAL_OK       = 0x00,
59   HAL_ERROR    = 0x01,
60   HAL_BUSY     = 0x02,
61   HAL_TIMEOUT  = 0x03
62 } HAL_StatusTypeDef;
63
64 /** 
65   * @brief  HAL Lock structures definition  
66   */
67 typedef enum 
68 {
69   HAL_UNLOCKED = 0x00,
70   HAL_LOCKED   = 0x01  
71 } HAL_LockTypeDef;
72
73 /* Exported macro ------------------------------------------------------------*/
74 #ifndef NULL
75   #define NULL      0
76 #endif
77
78 #define HAL_MAX_DELAY      0xFFFFFFFF
79
80 #define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) != RESET)
81 #define HAL_IS_BIT_CLR(REG, BIT)         (((REG) & (BIT)) == RESET)
82
83 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_)           \
84                         do{                                                  \
85                               (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \
86                               (__DMA_HANDLE_).Parent = (__HANDLE__);             \
87                           } while(0)
88
89 #define UNUSED(x) ((void)(x))
90
91 /** @brief Reset the Handle's State field.
92   * @param __HANDLE__: specifies the Peripheral Handle.
93   * @note  This macro can be used for the following purpose: 
94   *          - When the Handle is declared as local variable; before passing it as parameter
95   *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro 
96   *            to set to 0 the Handle's "State" field.
97   *            Otherwise, "State" field may have any random value and the first time the function 
98   *            HAL_PPP_Init() is called, the low level hardware initialization will be missed
99   *            (i.e. HAL_PPP_MspInit() will not be executed).
100   *          - When there is a need to reconfigure the low level hardware: instead of calling
101   *            HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
102   *            In this later function, when the Handle's "State" field is set to 0, it will execute the function
103   *            HAL_PPP_MspInit() which will reconfigure the low level hardware.
104   * @retval None
105   */
106 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
107
108 #if (USE_RTOS == 1)
109   #error " USE_RTOS should be 0 in the current HAL release "
110 #else
111   #define __HAL_LOCK(__HANDLE__)                                           \
112                                 do{                                        \
113                                     if((__HANDLE__)->Lock == HAL_LOCKED)  \
114                                     {                                      \
115                                        return HAL_BUSY;                    \
116                                     }                                      \
117                                     else                                   \
118                                     {                                      \
119                                        (__HANDLE__)->Lock = HAL_LOCKED;    \
120                                     }                                      \
121                                   }while (0)
122
123   #define __HAL_UNLOCK(__HANDLE__)                                          \
124                                   do{                                       \
125                                       (__HANDLE__)->Lock = HAL_UNLOCKED;   \
126                                     }while (0)
127 #endif /* USE_RTOS */
128
129 #if  defined ( __GNUC__ )
130   #ifndef __weak
131     #define __weak   __attribute__((weak))
132   #endif /* __weak */
133   #ifndef __packed
134     #define __packed __attribute__((__packed__))
135   #endif /* __packed */
136 #endif /* __GNUC__ */
137
138
139 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
140 #if defined   (__GNUC__)        /* GNU Compiler */
141   #ifndef __ALIGN_END
142     #define __ALIGN_END    __attribute__ ((aligned (4)))
143   #endif /* __ALIGN_END */
144   #ifndef __ALIGN_BEGIN  
145     #define __ALIGN_BEGIN
146   #endif /* __ALIGN_BEGIN */
147 #else
148   #ifndef __ALIGN_END
149     #define __ALIGN_END
150   #endif /* __ALIGN_END */
151   #ifndef __ALIGN_BEGIN      
152     #if defined   (__CC_ARM)      /* ARM Compiler */
153       #define __ALIGN_BEGIN    __align(4)  
154     #elif defined (__ICCARM__)    /* IAR Compiler */
155       #define __ALIGN_BEGIN 
156     #endif /* __CC_ARM */
157   #endif /* __ALIGN_BEGIN */
158 #endif /* __GNUC__ */
159
160 /** 
161   * @brief  __RAM_FUNC definition
162   */ 
163 #if defined ( __CC_ARM   )
164 /* ARM Compiler
165    ------------
166    RAM functions are defined using the toolchain options. 
167    Functions that are executed in RAM should reside in a separate source module.
168    Using the 'Options for File' dialog you can simply change the 'Code / Const' 
169    area of a module to a memory space in physical RAM.
170    Available memory areas are declared in the 'Target' tab of the 'Options for Target'
171    dialog. 
172 */
173 #define __RAM_FUNC HAL_StatusTypeDef 
174
175 #elif defined ( __ICCARM__ )
176 /* ICCARM Compiler
177    ---------------
178    RAM functions are defined using a specific toolchain keyword "__ramfunc". 
179 */
180 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
181
182 #elif defined   (  __GNUC__  )
183 /* GNU Compiler
184    ------------
185   RAM functions are defined using a specific toolchain attribute 
186    "__attribute__((section(".RamFunc")))".
187 */
188 #define __RAM_FUNC HAL_StatusTypeDef  __attribute__((section(".RamFunc")))
189
190 #endif
191
192 /** 
193   * @brief  __NOINLINE definition
194   */ 
195 #if defined ( __CC_ARM   ) || defined   (  __GNUC__  )
196 /* ARM & GNUCompiler 
197    ---------------- 
198 */
199 #define __NOINLINE __attribute__ ( (noinline) )  
200
201 #elif defined ( __ICCARM__ )
202 /* ICCARM Compiler
203    ---------------
204 */
205 #define __NOINLINE _Pragma("optimize = no_inline")
206
207 #endif
208
209
210 #ifdef __cplusplus
211 }
212 #endif
213
214 #endif /* ___STM32F1xx_HAL_DEF */
215
216 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/