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