• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx_hal_def.h
4   * @author  MCD Application Team
5   * @brief   This file contains HAL common defines, enumeration, macros and
6   *          structures definitions.
7   ******************************************************************************
8   * @attention
9   *
10   * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
11   * All rights reserved.</center></h2>
12   *
13   * This software component is licensed by ST under BSD 3-Clause license,
14   * the "License"; You may not use this file except in compliance with the
15   * License. You may obtain a copy of the License at:
16   *                        opensource.org/licenses/BSD-3-Clause
17   *
18   ******************************************************************************
19   */
20 
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef STM32MP1xx_HAL_DEF
23 #define STM32MP1xx_HAL_DEF
24 
25 #ifdef __cplusplus
26  extern "C" {
27 #endif
28 
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32mp1xx.h"
31 #include <stdio.h>
32 
33 /* Exported types ------------------------------------------------------------*/
34 
35 /**
36   * @brief  HAL Status structures definition
37   */
38 typedef enum
39 {
40   HAL_OK       = 0x00U,
41   HAL_ERROR    = 0x01U,
42   HAL_BUSY     = 0x02U,
43   HAL_TIMEOUT  = 0x03U
44 } HAL_StatusTypeDef;
45 
46 /**
47   * @brief  HAL Lock structures definition
48   */
49 typedef enum
50 {
51   HAL_UNLOCKED = 0x00U,
52   HAL_LOCKED   = 0x01U
53 } HAL_LockTypeDef;
54 
55 /* Exported macros -----------------------------------------------------------*/
56 
57 //#define UNUSED(X) (void)X      /* To avoid gcc/g++ warnings */
58 
59 #define HAL_MAX_DELAY      0xFFFFFFFFU
60 
61 #define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) == (BIT))
62 #define HAL_IS_BIT_CLR(REG, BIT)         (((REG) & (BIT)) == 0U)
63 
64 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)               \
65                         do{                                                        \
66                               (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
67                               (__DMA_HANDLE__).Parent = (__HANDLE__);             \
68                           } while(0U)
69 
70 /** @brief Reset the Handle's State field.
71   * @param __HANDLE__ specifies the Peripheral Handle.
72   * @note  This macro can be used for the following purpose:
73   *          - When the Handle is declared as local variable; before passing it as parameter
74   *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro
75   *            to set to 0 the Handle's "State" field.
76   *            Otherwise, "State" field may have any random value and the first time the function
77   *            HAL_PPP_Init() is called, the low level hardware initialization will be missed
78   *            (i.e. HAL_PPP_MspInit() will not be executed).
79   *          - When there is a need to reconfigure the low level hardware: instead of calling
80   *            HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
81   *            In this later function, when the Handle's "State" field is set to 0, it will execute the function
82   *            HAL_PPP_MspInit() which will reconfigure the low level hardware.
83   * @retval None
84   */
85 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
86 
87 #if (USE_RTOS == 1U)
88 /* Reserved for future use */
89   #error " USE_RTOS should be 0 in the current HAL release "
90 #else
91   #define __HAL_LOCK(__HANDLE__)                                           \
92                                 do{                                        \
93                                     if((__HANDLE__)->Lock == HAL_LOCKED)   \
94                                     {                                      \
95                                        return HAL_BUSY;                    \
96                                     }                                      \
97                                     else                                   \
98                                     {                                      \
99                                        (__HANDLE__)->Lock = HAL_LOCKED;    \
100                                     }                                      \
101                                   }while (0U)
102 
103   #define __HAL_UNLOCK(__HANDLE__)                                          \
104                                   do{                                       \
105                                       (__HANDLE__)->Lock = HAL_UNLOCKED;    \
106                                     }while (0U)
107 #endif /* USE_RTOS */
108 
109 #if  defined ( __GNUC__ )
110   #ifndef __weak
111     #define __weak   __attribute__((weak))
112   #endif /* __weak */
113   #ifndef __packed
114     #define __packed __attribute__((__packed__))
115   #endif /* __packed */
116 #endif /* __GNUC__ */
117 
118 
119 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
120 #if defined   (__GNUC__)        /* GNU Compiler */
121   #ifndef __ALIGN_END
122 #define __ALIGN_END    __attribute__ ((aligned (4U)))
123   #endif /* __ALIGN_END */
124   #ifndef __ALIGN_BEGIN
125     #define __ALIGN_BEGIN
126   #endif /* __ALIGN_BEGIN */
127 #else
128   #ifndef __ALIGN_END
129     #define __ALIGN_END
130   #endif /* __ALIGN_END */
131   #ifndef __ALIGN_BEGIN
132     #if defined   (__CC_ARM)      /* ARM Compiler */
133 #define __ALIGN_BEGIN    __align(4U)
134     #elif defined (__ICCARM__)    /* IAR Compiler */
135       #define __ALIGN_BEGIN
136     #endif /* __CC_ARM */
137   #endif /* __ALIGN_BEGIN */
138 #endif /* __GNUC__ */
139 
140 /**
141   * @brief  __RAM_FUNC definition
142   */
143 #if defined ( __CC_ARM   )
144 /* ARM Compiler
145    ------------
146    RAM functions are defined using the toolchain options.
147    Functions that are executed in RAM should reside in a separate source module.
148    Using the 'Options for File' dialog you can simply change the 'Code / Const'
149    area of a module to a memory space in physical RAM.
150    Available memory areas are declared in the 'Target' tab of the 'Options for Target'
151    dialog.
152 */
153 #define __RAM_FUNC
154 
155 #elif defined ( __ICCARM__ )
156 /* ICCARM Compiler
157    ---------------
158    RAM functions are defined using a specific toolchain keyword "__ramfunc".
159 */
160 #define __RAM_FUNC __ramfunc
161 
162 #elif defined   (  __GNUC__  )
163 /* GNU Compiler
164    ------------
165   RAM functions are defined using a specific toolchain attribute
166    "__attribute__((section(".RamFunc")))".
167 */
168 #define __RAM_FUNC __attribute__((section(".RamFunc")))
169 
170 #endif
171 
172 /**
173   * @brief  __NOINLINE definition
174   */
175 #if defined ( __CC_ARM   ) || defined   (  __GNUC__  )
176 /* ARM & GNUCompiler
177    ----------------
178 */
179 #define __NOINLINE __attribute__ ( (noinline) )
180 
181 #elif defined ( __ICCARM__ )
182 /* ICCARM Compiler
183    ---------------
184 */
185 #define __NOINLINE _Pragma("optimize = no_inline")
186 
187 #endif
188 
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* STM32MP1xx_HAL_DEF */
195 
196 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
197