Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32f1xx_hal_def.h Source File

stm32f1xx_hal_def.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f1xx_hal_def.h
00004   * @author  MCD Application Team
00005   * @version V1.0.4
00006   * @date    29-April-2016
00007   * @brief   This file contains HAL common defines, enumeration, macros and 
00008   *          structures definitions. 
00009   ******************************************************************************
00010   * @attention
00011   *
00012   * <h2><center>&copy; COPYRIGHT(c) 2016 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 __STM32F1xx_HAL_DEF
00041 #define __STM32F1xx_HAL_DEF
00042 
00043 #ifdef __cplusplus
00044  extern "C" {
00045 #endif
00046 
00047 /* Includes ------------------------------------------------------------------*/
00048 #include "stm32f1xx.h"
00049 #include "Legacy/stm32_hal_legacy.h"
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 macro ------------------------------------------------------------*/
00075 
00076 #define HAL_MAX_DELAY      0xFFFFFFFF
00077 
00078 #define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) != RESET)
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   #error " USE_RTOS should be 0 in the current HAL release "
00108 #else
00109   #define __HAL_LOCK(__HANDLE__)                                           \
00110                                 do{                                        \
00111                                     if((__HANDLE__)->Lock == HAL_LOCKED)  \
00112                                     {                                      \
00113                                        return HAL_BUSY;                    \
00114                                     }                                      \
00115                                     else                                   \
00116                                     {                                      \
00117                                        (__HANDLE__)->Lock = HAL_LOCKED;    \
00118                                     }                                      \
00119                                   }while (0)
00120 
00121   #define __HAL_UNLOCK(__HANDLE__)                                          \
00122                                   do{                                       \
00123                                       (__HANDLE__)->Lock = HAL_UNLOCKED;   \
00124                                     }while (0)
00125 #endif /* USE_RTOS */
00126 
00127 #if  defined ( __GNUC__ )
00128   #ifndef __weak
00129     #define __weak   __attribute__((weak))
00130   #endif /* __weak */
00131   #ifndef __packed
00132     #define __packed __attribute__((__packed__))
00133   #endif /* __packed */
00134 #endif /* __GNUC__ */
00135 
00136 
00137 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
00138 #if defined   (__GNUC__)        /* GNU Compiler */
00139   #ifndef __ALIGN_END
00140     #define __ALIGN_END    __attribute__ ((aligned (4)))
00141   #endif /* __ALIGN_END */
00142   #ifndef __ALIGN_BEGIN  
00143     #define __ALIGN_BEGIN
00144   #endif /* __ALIGN_BEGIN */
00145 #else
00146   #ifndef __ALIGN_END
00147     #define __ALIGN_END
00148   #endif /* __ALIGN_END */
00149   #ifndef __ALIGN_BEGIN      
00150     #if defined   (__CC_ARM)      /* ARM Compiler */
00151       #define __ALIGN_BEGIN    __align(4)  
00152     #elif defined (__ICCARM__)    /* IAR Compiler */
00153       #define __ALIGN_BEGIN 
00154     #endif /* __CC_ARM */
00155   #endif /* __ALIGN_BEGIN */
00156 #endif /* __GNUC__ */
00157 
00158 /** 
00159   * @brief  __RAM_FUNC definition
00160   */ 
00161 #if defined ( __CC_ARM   )
00162 /* ARM Compiler
00163    ------------
00164    RAM functions are defined using the toolchain options. 
00165    Functions that are executed in RAM should reside in a separate source module.
00166    Using the 'Options for File' dialog you can simply change the 'Code / Const' 
00167    area of a module to a memory space in physical RAM.
00168    Available memory areas are declared in the 'Target' tab of the 'Options for Target'
00169    dialog. 
00170 */
00171 #define __RAM_FUNC HAL_StatusTypeDef 
00172 
00173 #elif defined ( __ICCARM__ )
00174 /* ICCARM Compiler
00175    ---------------
00176    RAM functions are defined using a specific toolchain keyword "__ramfunc". 
00177 */
00178 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
00179 
00180 #elif defined   (  __GNUC__  )
00181 /* GNU Compiler
00182    ------------
00183   RAM functions are defined using a specific toolchain attribute 
00184    "__attribute__((section(".RamFunc")))".
00185 */
00186 #define __RAM_FUNC HAL_StatusTypeDef  __attribute__((section(".RamFunc")))
00187 
00188 #endif
00189 
00190 /** 
00191   * @brief  __NOINLINE definition
00192   */ 
00193 #if defined ( __CC_ARM   ) || defined   (  __GNUC__  )
00194 /* ARM & GNUCompiler 
00195    ---------------- 
00196 */
00197 #define __NOINLINE __attribute__ ( (noinline) )  
00198 
00199 #elif defined ( __ICCARM__ )
00200 /* ICCARM Compiler
00201    ---------------
00202 */
00203 #define __NOINLINE _Pragma("optimize = no_inline")
00204 
00205 #endif
00206 
00207 
00208 #ifdef __cplusplus
00209 }
00210 #endif
00211 
00212 #endif /* ___STM32F1xx_HAL_DEF */
00213 
00214 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/