inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

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