You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
8.5KB

  1. /**
  2. ******************************************************************************
  3. * @file misc.h
  4. * @author MCD Application Team
  5. * @version V3.4.0
  6. * @date 10/15/2010
  7. * @brief This file contains all the functions prototypes for the miscellaneous
  8. * firmware library functions (add-on to CMSIS functions).
  9. ******************************************************************************
  10. * @copy
  11. *
  12. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  13. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  14. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  15. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  16. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  17. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  18. *
  19. * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __MISC_H
  23. #define __MISC_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f10x.h"
  29. /** @addtogroup STM32F10x_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup MISC
  33. * @{
  34. */
  35. /** @defgroup MISC_Exported_Types
  36. * @{
  37. */
  38. /**
  39. * @brief NVIC Init Structure definition
  40. */
  41. typedef struct
  42. {
  43. uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
  44. This parameter can be a value of @ref IRQn_Type
  45. (For the complete STM32 Devices IRQ Channels list, please
  46. refer to stm32f10x.h file) */
  47. uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
  48. specified in NVIC_IRQChannel. This parameter can be a value
  49. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  50. uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
  51. in NVIC_IRQChannel. This parameter can be a value
  52. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  53. FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
  54. will be enabled or disabled.
  55. This parameter can be set either to ENABLE or DISABLE */
  56. } NVIC_InitTypeDef;
  57. /**
  58. * @}
  59. */
  60. /** @defgroup NVIC_Priority_Table
  61. * @{
  62. */
  63. /**
  64. @code
  65. The table below gives the allowed values of the pre-emption priority and subpriority according
  66. to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
  67. ============================================================================================================================
  68. NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description
  69. ============================================================================================================================
  70. NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority
  71. | | | 4 bits for subpriority
  72. ----------------------------------------------------------------------------------------------------------------------------
  73. NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority
  74. | | | 3 bits for subpriority
  75. ----------------------------------------------------------------------------------------------------------------------------
  76. NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority
  77. | | | 2 bits for subpriority
  78. ----------------------------------------------------------------------------------------------------------------------------
  79. NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority
  80. | | | 1 bits for subpriority
  81. ----------------------------------------------------------------------------------------------------------------------------
  82. NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority
  83. | | | 0 bits for subpriority
  84. ============================================================================================================================
  85. @endcode
  86. */
  87. /**
  88. * @}
  89. */
  90. /** @defgroup MISC_Exported_Constants
  91. * @{
  92. */
  93. /** @defgroup Vector_Table_Base
  94. * @{
  95. */
  96. #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
  97. #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
  98. #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
  99. ((VECTTAB) == NVIC_VectTab_FLASH))
  100. /**
  101. * @}
  102. */
  103. /** @defgroup System_Low_Power
  104. * @{
  105. */
  106. #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
  107. #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
  108. #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
  109. #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
  110. ((LP) == NVIC_LP_SLEEPDEEP) || \
  111. ((LP) == NVIC_LP_SLEEPONEXIT))
  112. /**
  113. * @}
  114. */
  115. /** @defgroup Preemption_Priority_Group
  116. * @{
  117. */
  118. #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
  119. 4 bits for subpriority */
  120. #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
  121. 3 bits for subpriority */
  122. #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
  123. 2 bits for subpriority */
  124. #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
  125. 1 bits for subpriority */
  126. #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
  127. 0 bits for subpriority */
  128. #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
  129. ((GROUP) == NVIC_PriorityGroup_1) || \
  130. ((GROUP) == NVIC_PriorityGroup_2) || \
  131. ((GROUP) == NVIC_PriorityGroup_3) || \
  132. ((GROUP) == NVIC_PriorityGroup_4))
  133. #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  134. #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  135. #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
  136. /**
  137. * @}
  138. */
  139. /** @defgroup SysTick_clock_source
  140. * @{
  141. */
  142. #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
  143. #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
  144. #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
  145. ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  146. /**
  147. * @}
  148. */
  149. /**
  150. * @}
  151. */
  152. /** @defgroup MISC_Exported_Macros
  153. * @{
  154. */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup MISC_Exported_Functions
  159. * @{
  160. */
  161. void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  162. void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
  163. void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  164. void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
  165. void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. #endif /* __MISC_H */
  170. /**
  171. * @}
  172. */
  173. /**
  174. * @}
  175. */
  176. /**
  177. * @}
  178. */
  179. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/