Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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