mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation

Who changed what in which revision?

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