text: /**
    ******************************************************************************
    * @file    misc.h
    * @author  MCD Application Team
    * @version V3.6.1
    * @date    05-March-2012
    * @brief   This file contains all the functions prototypes for the miscellaneous
    *          firmware library functions (add-on to CMSIS functions).
   *******************************************************************************
   * Copyright (c) 2014, STMicroelectronics
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of source code must retain the above copyright notice,
   *    this list of conditions and the following disclaimer.
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *    this list of conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   * 3. Neither the name of STMicroelectronics nor the names of its contributors
   *    may be used to endorse or promote products derived from this software
   *    without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *******************************************************************************
   */
  
  /* Define to prevent recursive inclusion -------------------------------------*/
  #ifndef __MISC_H
  #define __MISC_H
  
  #ifdef __cplusplus
   extern "C" {
  #endif
  
  /* Includes ------------------------------------------------------------------*/
  #include "stm32f10x.h"
  
  /** @addtogroup STM32F10x_StdPeriph_Driver
    * @{
    */
  
  /** @addtogroup MISC
    * @{
    */
  
  /** @defgroup MISC_Exported_Types
    * @{
    */
  
  /** 
    * @brief  NVIC Init Structure definition  
    */
  
  typedef struct
  {
    uint8_t NVIC_IRQChannel;                    /*!< Specifies the IRQ channel to be enabled or disabled.
                                                     This parameter can be a value of @ref IRQn_Type 
                                                     (For the complete STM32 Devices IRQ Channels list, please
                                                      refer to stm32f10x.h file) */
  
    uint8_t NVIC_IRQChannelPreemptionPriority;  /*!< Specifies the pre-emption priority for the IRQ channel
                                                     specified in NVIC_IRQChannel. This parameter can be a value
                                                     between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  
    uint8_t NVIC_IRQChannelSubPriority;         /*!< Specifies the subpriority level for the IRQ channel specified
                                                     in NVIC_IRQChannel. This parameter can be a value
                                                     between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  
    FunctionalState NVIC_IRQChannelCmd;         /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
                                                     will be enabled or disabled. 
                                                     This parameter can be set either to ENABLE or DISABLE */   
  } NVIC_InitTypeDef;
   
  /**
    * @}
    */
  
  /** @defgroup NVIC_Priority_Table 
    * @{
    */
  
  /**
  @code  
   The table below gives the allowed values of the pre-emption priority and subpriority according
   to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
    ============================================================================================================================
      NVIC_PriorityGroup   | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority  | Description
    ============================================================================================================================
     NVIC_PriorityGroup_0  |                0                  |            0-15             |   0 bits for pre-emption priority
                           |                                   |                             |   4 bits for subpriority
    ----------------------------------------------------------------------------------------------------------------------------
     NVIC_PriorityGroup_1  |                0-1                |            0-7              |   1 bits for pre-emption priority
                           |                                   |                             |   3 bits for subpriority
    ----------------------------------------------------------------------------------------------------------------------------    
     NVIC_PriorityGroup_2  |                0-3                |            0-3              |   2 bits for pre-emption priority
                           |                                   |                             |   2 bits for subpriority
    ----------------------------------------------------------------------------------------------------------------------------    
     NVIC_PriorityGroup_3  |                0-7                |            0-1              |   3 bits for pre-emption priority
                           |                                   |                             |   1 bits for subpriority
    ----------------------------------------------------------------------------------------------------------------------------    
     NVIC_PriorityGroup_4  |                0-15               |            0                |   4 bits for pre-emption priority
                           |                                   |                             |   0 bits for subpriority                       
    ============================================================================================================================
  @endcode
  */
  
  /**
    * @}
    */
  
  /** @defgroup MISC_Exported_Constants
    * @{
    */
  
  /** @defgroup Vector_Table_Base 
    * @{
    */
  
  #define NVIC_VectTab_RAM             ((uint32_t)0x20000000)
  #define NVIC_VectTab_FLASH           ((uint32_t)0x08000000)
  #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
                                    ((VECTTAB) == NVIC_VectTab_FLASH))
  /**
    * @}
    */
  
  /** @defgroup System_Low_Power 
    * @{
    */
  
  #define NVIC_LP_SEVONPEND            ((uint8_t)0x10)
  #define NVIC_LP_SLEEPDEEP            ((uint8_t)0x04)
  #define NVIC_LP_SLEEPONEXIT          ((uint8_t)0x02)
  #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
                          ((LP) == NVIC_LP_SLEEPDEEP) || \
                          ((LP) == NVIC_LP_SLEEPONEXIT))
  /**
    * @}
    */
  
  /** @defgroup Preemption_Priority_Group 
    * @{
    */
  
  #define NVIC_PriorityGroup_0         ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
                                                              4 bits for subpriority */
  #define NVIC_PriorityGroup_1         ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
                                                              3 bits for subpriority */
  #define NVIC_PriorityGroup_2         ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
                                                              2 bits for subpriority */
  #define NVIC_PriorityGroup_3         ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
                                                              1 bits for subpriority */
  #define NVIC_PriorityGroup_4         ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
                                                              0 bits for subpriority */
  
  #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
                                         ((GROUP) == NVIC_PriorityGroup_1) || \
                                         ((GROUP) == NVIC_PriorityGroup_2) || \
                                         ((GROUP) == NVIC_PriorityGroup_3) || \
                                         ((GROUP) == NVIC_PriorityGroup_4))
  
  #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY)  ((PRIORITY) < 0x10)
  
  #define IS_NVIC_SUB_PRIORITY(PRIORITY)  ((PRIORITY) < 0x10)
  
  #define IS_NVIC_OFFSET(OFFSET)  ((OFFSET) < 0x000FFFFF)
  
  /**
    * @}
    */
  
  /** @defgroup SysTick_clock_source 
    * @{
    */
  
  #define SysTick_CLKSource_HCLK_Div8    ((uint32_t)0xFFFFFFFB)
  #define SysTick_CLKSource_HCLK         ((uint32_t)0x00000004)
  #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
                                         ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  /**
    * @}
    */
  
  /**
    * @}
    */
  
  /** @defgroup MISC_Exported_Macros
    * @{
    */
  
  /**
    * @}
    */
  
  /** @defgroup MISC_Exported_Functions
    * @{
    */
  
  void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
  void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
  void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* __MISC_H */
  
  /**
    * @}
    */
  
  /**
    * @}
    */
  
  /**
    * @}
    */
  
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  