meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

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