The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
132:9baf128c2fab
Child:
142:4eea097334d6
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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