L4 HAL Drivers

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32l4xx_hal_def.h Source File

stm32l4xx_hal_def.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_def.h
00004   * @author  MCD Application Team
00005   * @version V1.1.0
00006   * @date    16-September-2015
00007   * @brief   This file contains HAL common defines, enumeration, macros and
00008   *          structures definitions.
00009   ******************************************************************************
00010   * @attention
00011   *
00012   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00013   *
00014   * Redistribution and use in source and binary forms, with or without modification,
00015   * are permitted provided that the following conditions are met:
00016   *   1. Redistributions of source code must retain the above copyright notice,
00017   *      this list of conditions and the following disclaimer.
00018   *   2. Redistributions in binary form must reproduce the above copyright notice,
00019   *      this list of conditions and the following disclaimer in the documentation
00020   *      and/or other materials provided with the distribution.
00021   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00022   *      may be used to endorse or promote products derived from this software
00023   *      without specific prior written permission.
00024   *
00025   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00026   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00028   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00029   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00031   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00033   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035   *
00036   ******************************************************************************
00037   */
00038 
00039 /* Define to prevent recursive inclusion -------------------------------------*/
00040 #ifndef __STM32L4xx_HAL_DEF
00041 #define __STM32L4xx_HAL_DEF
00042 
00043 #ifdef __cplusplus
00044  extern "C" {
00045 #endif
00046 
00047 /* Includes ------------------------------------------------------------------*/
00048 #include "stm32l4xx.h"
00049 #include "stm32_hal_legacy.h"  /* Aliases file for old names compatibility */
00050 #include <stdio.h>
00051 
00052 /* Exported types ------------------------------------------------------------*/
00053 
00054 /**
00055   * @brief  HAL Status structures definition
00056   */
00057 typedef enum
00058 {
00059   HAL_OK       = 0x00,
00060   HAL_ERROR    = 0x01,
00061   HAL_BUSY     = 0x02,
00062   HAL_TIMEOUT  = 0x03
00063 } HAL_StatusTypeDef;
00064 
00065 /**
00066   * @brief  HAL Lock structures definition
00067   */
00068 typedef enum
00069 {
00070   HAL_UNLOCKED = 0x00,
00071   HAL_LOCKED   = 0x01
00072 } HAL_LockTypeDef;
00073 
00074 /* Exported macros -----------------------------------------------------------*/
00075 
00076 #define HAL_MAX_DELAY      0xFFFFFFFF
00077 
00078 #define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) == (BIT))
00079 #define HAL_IS_BIT_CLR(REG, BIT)         (((REG) & (BIT)) == RESET)
00080 
00081 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)             \
00082                         do{                                                      \
00083                             (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
00084                             (__DMA_HANDLE__).Parent = (__HANDLE__);              \
00085                         } while(0)
00086 
00087 #define UNUSED(x) ((void)(x))
00088                          
00089 /** @brief Reset the Handle's State field.
00090   * @param __HANDLE__: specifies the Peripheral Handle.
00091   * @note  This macro can be used for the following purpose: 
00092   *          - When the Handle is declared as local variable; before passing it as parameter
00093   *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro 
00094   *            to set to 0 the Handle's "State" field.
00095   *            Otherwise, "State" field may have any random value and the first time the function 
00096   *            HAL_PPP_Init() is called, the low level hardware initialization will be missed
00097   *            (i.e. HAL_PPP_MspInit() will not be executed).
00098   *          - When there is a need to reconfigure the low level hardware: instead of calling
00099   *            HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
00100   *            In this later function, when the Handle's "State" field is set to 0, it will execute the function
00101   *            HAL_PPP_MspInit() which will reconfigure the low level hardware.
00102   * @retval None
00103   */
00104 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
00105 
00106 #if (USE_RTOS == 1)
00107   /* Reserved for future use */
00108   #error " USE_RTOS should be 0 in the current HAL release "
00109 #else
00110   #define __HAL_LOCK(__HANDLE__)                                           \
00111                                 do{                                        \
00112                                     if((__HANDLE__)->Lock == HAL_LOCKED)   \
00113                                     {                                      \
00114                                        return HAL_BUSY;                    \
00115                                     }                                      \
00116                                     else                                   \
00117                                     {                                      \
00118                                        (__HANDLE__)->Lock = HAL_LOCKED;    \
00119                                     }                                      \
00120                                   }while (0)
00121 
00122   #define __HAL_UNLOCK(__HANDLE__)                                          \
00123                                   do{                                       \
00124                                       (__HANDLE__)->Lock = HAL_UNLOCKED;    \
00125                                     }while (0)
00126 #endif /* USE_RTOS */
00127 
00128 #if  defined ( __GNUC__ )
00129   #ifndef __weak
00130     #define __weak   __attribute__((weak))
00131   #endif /* __weak */
00132   #ifndef __packed
00133     #define __packed __attribute__((__packed__))
00134   #endif /* __packed */
00135 #endif /* __GNUC__ */
00136 
00137 
00138 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
00139 #if defined   (__GNUC__)        /* GNU Compiler */
00140   #ifndef __ALIGN_END
00141     #define __ALIGN_END    __attribute__ ((aligned (4)))
00142   #endif /* __ALIGN_END */
00143   #ifndef __ALIGN_BEGIN
00144     #define __ALIGN_BEGIN
00145   #endif /* __ALIGN_BEGIN */
00146 #else
00147   #ifndef __ALIGN_END
00148     #define __ALIGN_END
00149   #endif /* __ALIGN_END */
00150   #ifndef __ALIGN_BEGIN
00151     #if defined   (__CC_ARM)      /* ARM Compiler */
00152       #define __ALIGN_BEGIN    __align(4)
00153     #elif defined (__ICCARM__)    /* IAR Compiler */
00154       #define __ALIGN_BEGIN
00155     #endif /* __CC_ARM */
00156   #endif /* __ALIGN_BEGIN */
00157 #endif /* __GNUC__ */
00158 
00159 /**
00160   * @brief  __RAM_FUNC definition
00161   */
00162 #if defined ( __CC_ARM   )
00163 /* ARM Compiler
00164    ------------
00165    RAM functions are defined using the toolchain options.
00166    Functions that are executed in RAM should reside in a separate source module.
00167    Using the 'Options for File' dialog you can simply change the 'Code / Const'
00168    area of a module to a memory space in physical RAM.
00169    Available memory areas are declared in the 'Target' tab of the 'Options for Target'
00170    dialog.
00171 */
00172 #define __RAM_FUNC HAL_StatusTypeDef
00173 
00174 #elif defined ( __ICCARM__ )
00175 /* ICCARM Compiler
00176    ---------------
00177    RAM functions are defined using a specific toolchain keyword "__ramfunc".
00178 */
00179 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
00180 
00181 #elif defined   (  __GNUC__  )
00182 /* GNU Compiler
00183    ------------
00184   RAM functions are defined using a specific toolchain attribute
00185    "__attribute__((section(".RamFunc")))".
00186 */
00187 #define __RAM_FUNC HAL_StatusTypeDef  __attribute__((section(".RamFunc")))
00188 
00189 #endif
00190 
00191 /** 
00192   * @brief  __NOINLINE definition
00193   */ 
00194 #if defined ( __CC_ARM   ) || defined   (  __GNUC__  )
00195 /* ARM & GNUCompiler 
00196    ---------------- 
00197 */
00198 #define __NOINLINE __attribute__ ( (noinline) )  
00199 
00200 #elif defined ( __ICCARM__ )
00201 /* ICCARM Compiler
00202    ---------------
00203 */
00204 #define __NOINLINE _Pragma("optimize = no_inline")
00205 
00206 #endif
00207 
00208 
00209 #ifdef __cplusplus
00210 }
00211 #endif
00212 
00213 #endif /* ___STM32L4xx_HAL_DEF */
00214 
00215 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
00216