Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:35

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_def.h
0004   * @author  MCD Application Team
0005   * @brief   This file contains HAL common defines, enumeration, macros and
0006   *          structures definitions.
0007   ******************************************************************************
0008   * @attention
0009   *
0010   * Copyright (c) 2017 STMicroelectronics.
0011   * All rights reserved.
0012   *
0013   * This software is licensed under terms that can be found in the LICENSE file
0014   * in the root directory of this software component.
0015   * If no LICENSE file comes with this software, it is provided AS-IS.
0016   *
0017   ******************************************************************************
0018   */
0019 
0020 /* Define to prevent recursive inclusion -------------------------------------*/
0021 #ifndef STM32H7xx_HAL_DEF
0022 #define STM32H7xx_HAL_DEF
0023 
0024 #ifdef __cplusplus
0025  extern "C" {
0026 #endif
0027 
0028 /* Includes ------------------------------------------------------------------*/
0029 #include "stm32h7xx.h"
0030 #include "Legacy/stm32_hal_legacy.h"
0031 #include <stddef.h>
0032 #ifdef __rtems__
0033 /* this is to avoid definition of log function which conflicts with
0034  * freebsd's systm.h log function. Whole theatre just to make sure
0035  * we do have float_t available (defined in math.h) which is later
0036  * used in HAL */
0037 #define __math_68881 1
0038 #endif /* __rtems__ */
0039 #include <math.h>
0040 
0041 /* Exported types ------------------------------------------------------------*/
0042 
0043 /**
0044   * @brief  HAL Status structures definition
0045   */
0046 typedef enum
0047 {
0048   HAL_OK       = 0x00,
0049   HAL_ERROR    = 0x01,
0050   HAL_BUSY     = 0x02,
0051   HAL_TIMEOUT  = 0x03
0052 } HAL_StatusTypeDef;
0053 
0054 /**
0055   * @brief  HAL Lock structures definition
0056   */
0057 typedef enum
0058 {
0059   HAL_UNLOCKED = 0x00,
0060   HAL_LOCKED   = 0x01
0061 } HAL_LockTypeDef;
0062 
0063 /* Exported macro ------------------------------------------------------------*/
0064 
0065 #define HAL_MAX_DELAY      0xFFFFFFFFU
0066 
0067 #define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) == (BIT))
0068 #define HAL_IS_BIT_CLR(REG, BIT)         (((REG) & (BIT)) == 0U)
0069 
0070 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)               \
0071                         do{                                                      \
0072                               (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
0073                               (__DMA_HANDLE__).Parent = (__HANDLE__);             \
0074                           } while(0)
0075 
0076 #if !defined(UNUSED)
0077 #define UNUSED(x) ((void)(x))    /* To avoid gcc/g++ warnings */
0078 #endif /* UNUSED */
0079 
0080 /** @brief Reset the Handle's State field.
0081   * @param __HANDLE__: specifies the Peripheral Handle.
0082   * @note  This macro can be used for the following purpose: 
0083   *          - When the Handle is declared as local variable; before passing it as parameter
0084   *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro 
0085   *            to set to 0 the Handle's "State" field.
0086   *            Otherwise, "State" field may have any random value and the first time the function 
0087   *            HAL_PPP_Init() is called, the low level hardware initialization will be missed
0088   *            (i.e. HAL_PPP_MspInit() will not be executed).
0089   *          - When there is a need to reconfigure the low level hardware: instead of calling
0090   *            HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
0091   *            In this later function, when the Handle's "State" field is set to 0, it will execute the function
0092   *            HAL_PPP_MspInit() which will reconfigure the low level hardware.
0093   * @retval None
0094   */
0095 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
0096 
0097 #if (USE_RTOS == 1)
0098   #error " USE_RTOS should be 0 in the current HAL release "
0099 #else
0100   #define __HAL_LOCK(__HANDLE__)                                           \
0101                                 do{                                        \
0102                                     if((__HANDLE__)->Lock == HAL_LOCKED)   \
0103                                     {                                      \
0104                                        return HAL_BUSY;                    \
0105                                     }                                      \
0106                                     else                                   \
0107                                     {                                      \
0108                                        (__HANDLE__)->Lock = HAL_LOCKED;    \
0109                                     }                                      \
0110                                   }while (0)
0111 
0112   #define __HAL_UNLOCK(__HANDLE__)                                          \
0113                                   do{                                       \
0114                                       (__HANDLE__)->Lock = HAL_UNLOCKED;    \
0115                                     }while (0)
0116 #endif /* USE_RTOS */
0117 
0118 
0119 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
0120   #ifndef __weak
0121     #define __weak  __attribute__((weak))
0122   #endif
0123   #ifndef __packed
0124     #define __packed  __attribute__((packed))
0125   #endif
0126 #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
0127   #ifndef __weak
0128     #define __weak   __attribute__((weak))
0129   #endif /* __weak */
0130   #ifndef __packed
0131     #define __packed __attribute__((__packed__))
0132   #endif /* __packed */
0133 #endif /* __GNUC__ */
0134 
0135 
0136 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
0137 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
0138   #ifndef __ALIGN_BEGIN
0139     #define __ALIGN_BEGIN
0140   #endif
0141   #ifndef __ALIGN_END
0142     #define __ALIGN_END      __attribute__ ((aligned (4)))
0143   #endif
0144 #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
0145   #ifndef __ALIGN_END
0146     #define __ALIGN_END    __attribute__ ((aligned (4)))
0147   #endif /* __ALIGN_END */
0148   #ifndef __ALIGN_BEGIN
0149     #define __ALIGN_BEGIN
0150   #endif /* __ALIGN_BEGIN */
0151 #else
0152   #ifndef __ALIGN_END
0153     #define __ALIGN_END
0154   #endif /* __ALIGN_END */
0155   #ifndef __ALIGN_BEGIN
0156     #if defined   (__CC_ARM)      /* ARM Compiler V5 */
0157       #define __ALIGN_BEGIN    __align(4)
0158     #elif defined (__ICCARM__)    /* IAR Compiler */
0159       #define __ALIGN_BEGIN
0160     #endif /* __CC_ARM */
0161   #endif /* __ALIGN_BEGIN */
0162 #endif /* __GNUC__ */
0163 
0164 /* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */
0165 #if defined   (__GNUC__)        /* GNU Compiler */
0166   #define ALIGN_32BYTES(buf)  buf __attribute__ ((aligned (32)))                                    
0167 #elif defined (__ICCARM__)    /* IAR Compiler */
0168   #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf  
0169 #elif defined   (__CC_ARM)      /* ARM Compiler */
0170   #define ALIGN_32BYTES(buf) __align(32) buf  
0171 #endif
0172 
0173 /**
0174   * @brief  __RAM_FUNC definition
0175   */
0176 #if defined ( __CC_ARM   ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
0177 /* ARM Compiler V4/V5 and V6
0178    --------------------------
0179    RAM functions are defined using the toolchain options.
0180    Functions that are executed in RAM should reside in a separate source module.
0181    Using the 'Options for File' dialog you can simply change the 'Code / Const'
0182    area of a module to a memory space in physical RAM.
0183    Available memory areas are declared in the 'Target' tab of the 'Options for Target'
0184    dialog.
0185 */
0186 #define __RAM_FUNC
0187 
0188 #elif defined ( __ICCARM__ )
0189 /* ICCARM Compiler
0190    ---------------
0191    RAM functions are defined using a specific toolchain keyword "__ramfunc".
0192 */
0193 #define __RAM_FUNC __ramfunc
0194 
0195 #elif defined   (  __GNUC__  )
0196 /* GNU Compiler
0197    ------------
0198   RAM functions are defined using a specific toolchain attribute
0199    "__attribute__((section(".RamFunc")))".
0200 */
0201 #define __RAM_FUNC __attribute__((section(".RamFunc")))
0202 
0203 #endif
0204 
0205 /**
0206   * @brief  __NOINLINE definition
0207   */
0208 #if defined ( __CC_ARM   ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined   (  __GNUC__  )
0209 /* ARM V4/V5 and V6 & GNU Compiler
0210    -------------------------------
0211 */
0212 #define __NOINLINE __attribute__ ( (noinline) )
0213 
0214 #elif defined ( __ICCARM__ )
0215 /* ICCARM Compiler
0216    ---------------
0217 */
0218 #define __NOINLINE _Pragma("optimize = no_inline")
0219 
0220 #endif
0221 
0222 
0223 #ifdef __cplusplus
0224 }
0225 #endif
0226 
0227 #endif /* STM32H7xx_HAL_DEF */
0228 
0229