Subversion Repositories FuelGauge

Rev

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

Rev Author Line No. Line
2 mjames 1
/**
2
  ******************************************************************************
3
  * @file    stm32f0xx_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) 2016 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 __STM32F0xx_HAL_DEF
23
#define __STM32F0xx_HAL_DEF
24
 
25
#ifdef __cplusplus
26
 extern "C" {
27
#endif
28
 
29
/* Includes ------------------------------------------------------------------*/
30
#include "stm32f0xx.h"
6 mjames 31
#include "Legacy/stm32_hal_legacy.h"
2 mjames 32
#include <stddef.h>
33
 
34
/* Exported types ------------------------------------------------------------*/
35
 
36
/**
37
  * @brief  HAL Status structures definition  
38
  */  
39
typedef enum
40
{
41
  HAL_OK       = 0x00U,
42
  HAL_ERROR    = 0x01U,
43
  HAL_BUSY     = 0x02U,
44
  HAL_TIMEOUT  = 0x03U
45
} HAL_StatusTypeDef;
46
 
47
/**
48
  * @brief  HAL Lock structures definition  
49
  */
50
typedef enum
51
{
52
  HAL_UNLOCKED = 0x00U,
53
  HAL_LOCKED   = 0x01U  
54
} HAL_LockTypeDef;
55
 
56
/* Exported macro ------------------------------------------------------------*/
57
 
6 mjames 58
#define UNUSED(X) (void)X      /* To avoid gcc/g++ warnings */
59
 
2 mjames 60
#define HAL_MAX_DELAY      0xFFFFFFFFU
61
 
62
#define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) == (BIT))
63
#define HAL_IS_BIT_CLR(REG, BIT)         (((REG) & (BIT)) == 0U)
64
 
6 mjames 65
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)               \
2 mjames 66
                        do{                                                        \
6 mjames 67
                              (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
68
                              (__DMA_HANDLE__).Parent = (__HANDLE__);             \
69
                          } while(0U)
2 mjames 70
 
71
/** @brief Reset the Handle's State field.
72
  * @param __HANDLE__ specifies the Peripheral Handle.
73
  * @note  This macro can be used for the following purpose:
74
  *          - When the Handle is declared as local variable; before passing it as parameter
75
  *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro
76
  *            to set to 0 the Handle's "State" field.
77
  *            Otherwise, "State" field may have any random value and the first time the function
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
  */
6 mjames 86
#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
2 mjames 87
 
6 mjames 88
#if (USE_RTOS == 1U)
89
  /* Reserved for future use */
2 mjames 90
  #error " USE_RTOS should be 0 in the current HAL release "
91
#else
92
  #define __HAL_LOCK(__HANDLE__)                                           \
93
                                do{                                        \
94
                                    if((__HANDLE__)->Lock == HAL_LOCKED)   \
95
                                    {                                      \
96
                                       return HAL_BUSY;                    \
97
                                    }                                      \
98
                                    else                                   \
99
                                    {                                      \
100
                                       (__HANDLE__)->Lock = HAL_LOCKED;    \
101
                                    }                                      \
6 mjames 102
                                  }while (0U)
2 mjames 103
 
104
  #define __HAL_UNLOCK(__HANDLE__)                                          \
105
                                  do{                                       \
106
                                      (__HANDLE__)->Lock = HAL_UNLOCKED;    \
6 mjames 107
                                    }while (0U)
2 mjames 108
#endif /* USE_RTOS */
109
 
6 mjames 110
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
2 mjames 111
  #ifndef __weak
6 mjames 112
    #define __weak  __attribute__((weak))
113
  #endif
114
  #ifndef __packed
115
    #define __packed  __attribute__((packed))
116
  #endif
117
#elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
118
  #ifndef __weak
2 mjames 119
    #define __weak   __attribute__((weak))
120
  #endif /* __weak */
121
  #ifndef __packed
122
    #define __packed __attribute__((__packed__))
123
  #endif /* __packed */
124
#endif /* __GNUC__ */
125
 
126
 
127
/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
6 mjames 128
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
129
  #ifndef __ALIGN_BEGIN
130
    #define __ALIGN_BEGIN
131
  #endif
2 mjames 132
  #ifndef __ALIGN_END
6 mjames 133
    #define __ALIGN_END      __attribute__ ((aligned (4)))
134
  #endif
135
#elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
136
  #ifndef __ALIGN_END
2 mjames 137
    #define __ALIGN_END    __attribute__ ((aligned (4)))
138
  #endif /* __ALIGN_END */
139
  #ifndef __ALIGN_BEGIN  
140
    #define __ALIGN_BEGIN
141
  #endif /* __ALIGN_BEGIN */
142
#else
143
  #ifndef __ALIGN_END
144
    #define __ALIGN_END
145
  #endif /* __ALIGN_END */
146
  #ifndef __ALIGN_BEGIN      
6 mjames 147
    #if defined   (__CC_ARM)      /* ARM Compiler V5*/
2 mjames 148
      #define __ALIGN_BEGIN    __align(4)  
149
    #elif defined (__ICCARM__)    /* IAR Compiler */
150
      #define __ALIGN_BEGIN 
151
    #endif /* __CC_ARM */
152
  #endif /* __ALIGN_BEGIN */
153
#endif /* __GNUC__ */
154
 
155
/**
156
  * @brief  __NOINLINE definition
157
  */
6 mjames 158
#if defined ( __CC_ARM   ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined   (  __GNUC__  )
159
/* ARM V4/V5 and V6 & GNU Compiler
160
   -------------------------------
2 mjames 161
*/
162
#define __NOINLINE __attribute__ ( (noinline) )
163
 
164
#elif defined ( __ICCARM__ )
165
/* ICCARM Compiler
166
   ---------------
167
*/
168
#define __NOINLINE _Pragma("optimize = no_inline")
169
 
170
#endif
171
 
172
#ifdef __cplusplus
173
}
174
#endif
175
 
176
#endif /* ___STM32F0xx_HAL_DEF */
177
 
178
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/