Subversion Repositories EngineBay2

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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