Subversion Repositories FuelGauge

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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"
  31. #if defined(USE_HAL_LEGACY)
  32.   #include "Legacy/stm32_hal_legacy.h"
  33. #endif
  34. #include <stddef.h>
  35.  
  36. /* Exported types ------------------------------------------------------------*/
  37.  
  38. /**
  39.   * @brief  HAL Status structures definition  
  40.   */  
  41. typedef enum
  42. {
  43.   HAL_OK       = 0x00U,
  44.   HAL_ERROR    = 0x01U,
  45.   HAL_BUSY     = 0x02U,
  46.   HAL_TIMEOUT  = 0x03U
  47. } HAL_StatusTypeDef;
  48.  
  49. /**
  50.   * @brief  HAL Lock structures definition  
  51.   */
  52. typedef enum
  53. {
  54.   HAL_UNLOCKED = 0x00U,
  55.   HAL_LOCKED   = 0x01U  
  56. } HAL_LockTypeDef;
  57.  
  58. /* Exported macro ------------------------------------------------------------*/
  59.  
  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.  
  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. #define UNUSED(X) (void)X      /* To avoid gcc/g++ warnings */
  72.  
  73. /** @brief Reset the Handle's State field.
  74.   * @param __HANDLE__ specifies the Peripheral Handle.
  75.   * @note  This macro can be used for the following purpose:
  76.   *          - When the Handle is declared as local variable; before passing it as parameter
  77.   *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  78.   *            to set to 0 the Handle's "State" field.
  79.   *            Otherwise, "State" field may have any random value and the first time the function
  80.   *            HAL_PPP_Init() is called, the low level hardware initialization will be missed
  81.   *            (i.e. HAL_PPP_MspInit() will not be executed).
  82.   *          - When there is a need to reconfigure the low level hardware: instead of calling
  83.   *            HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  84.   *            In this later function, when the Handle's "State" field is set to 0, it will execute the function
  85.   *            HAL_PPP_MspInit() which will reconfigure the low level hardware.
  86.   * @retval None
  87.   */
  88. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
  89.  
  90. #if (USE_RTOS == 1)
  91.   #error " USE_RTOS should be 0 in the current HAL release "
  92. #else
  93.   #define __HAL_LOCK(__HANDLE__)                                           \
  94.                                 do{                                        \
  95.                                     if((__HANDLE__)->Lock == HAL_LOCKED)   \
  96.                                     {                                      \
  97.                                        return HAL_BUSY;                    \
  98.                                     }                                      \
  99.                                     else                                   \
  100.                                     {                                      \
  101.                                        (__HANDLE__)->Lock = HAL_LOCKED;    \
  102.                                     }                                      \
  103.                                   }while (0)
  104.  
  105.   #define __HAL_UNLOCK(__HANDLE__)                                          \
  106.                                   do{                                       \
  107.                                       (__HANDLE__)->Lock = HAL_UNLOCKED;    \
  108.                                     }while (0)
  109. #endif /* USE_RTOS */
  110.  
  111. #if  defined ( __GNUC__ )
  112.   #ifndef __weak
  113.     #define __weak   __attribute__((weak))
  114.   #endif /* __weak */
  115.   #ifndef __packed
  116.     #define __packed __attribute__((__packed__))
  117.   #endif /* __packed */
  118. #endif /* __GNUC__ */
  119.  
  120.  
  121. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  122. #if defined   (__GNUC__)        /* GNU Compiler */
  123.   #ifndef __ALIGN_END
  124.     #define __ALIGN_END    __attribute__ ((aligned (4)))
  125.   #endif /* __ALIGN_END */
  126.   #ifndef __ALIGN_BEGIN  
  127.     #define __ALIGN_BEGIN
  128.   #endif /* __ALIGN_BEGIN */
  129. #else
  130.   #ifndef __ALIGN_END
  131.     #define __ALIGN_END
  132.   #endif /* __ALIGN_END */
  133.   #ifndef __ALIGN_BEGIN      
  134.     #if defined   (__CC_ARM)      /* ARM Compiler */
  135.       #define __ALIGN_BEGIN    __align(4)  
  136.     #elif defined (__ICCARM__)    /* IAR Compiler */
  137.       #define __ALIGN_BEGIN
  138.     #endif /* __CC_ARM */
  139.   #endif /* __ALIGN_BEGIN */
  140. #endif /* __GNUC__ */
  141.  
  142. /**
  143.   * @brief  __NOINLINE definition
  144.   */
  145. #if defined ( __CC_ARM   ) || defined   (  __GNUC__  )
  146. /* ARM & GNUCompiler
  147.    ----------------
  148. */
  149. #define __NOINLINE __attribute__ ( (noinline) )
  150.  
  151. #elif defined ( __ICCARM__ )
  152. /* ICCARM Compiler
  153.    ---------------
  154. */
  155. #define __NOINLINE _Pragma("optimize = no_inline")
  156.  
  157. #endif
  158.  
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162.  
  163. #endif /* ___STM32F0xx_HAL_DEF */
  164.  
  165. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  166.  
  167.