misc.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /**
  2. ******************************************************************************
  3. * @file misc.h
  4. * @author MCD Application Team
  5. * @version V3.5.0
  6. * @date 11-March-2011
  7. * @brief This file contains all the functions prototypes for the miscellaneous
  8. * firmware library functions (add-on to CMSIS functions).
  9. ******************************************************************************
  10. * @attention
  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 2011 STMicroelectronics</center></h2>
  20. ******************************************************************************
  21. */
  22. /* Define to prevent recursive inclusion -------------------------------------*/
  23. #ifndef __MISC_H
  24. #define __MISC_H
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Includes ------------------------------------------------------------------*/
  29. #include "stm32f10x.h"
  30. /** @addtogroup STM32F10x_StdPeriph_Driver
  31. * @{
  32. */
  33. /** @addtogroup MISC
  34. * @{
  35. */
  36. /** @defgroup MISC_Exported_Types
  37. * @{
  38. */
  39. /**
  40. * @brief NVIC Init Structure definition
  41. */
  42. typedef struct
  43. {
  44. //--通道
  45. uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
  46. This parameter can be a value of @ref IRQn_Type
  47. (For the complete STM32 Devices IRQ Channels list, please
  48. refer to stm32f10x.h file) */
  49. //--抢占优先级
  50. uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
  51. specified in NVIC_IRQChannel. This parameter can be a value
  52. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  53. //--响应优先级
  54. uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
  55. in NVIC_IRQChannel. This parameter can be a value
  56. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  57. //--是否使能中断
  58. FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
  59. will be enabled or disabled.
  60. This parameter can be set either to ENABLE or DISABLE */
  61. } NVIC_InitTypeDef;
  62. /**
  63. * @}
  64. */
  65. /** @defgroup NVIC_Priority_Table
  66. * @{
  67. */
  68. /**
  69. @code
  70. The table below gives the allowed values of the pre-emption priority and subpriority according
  71. to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
  72. ============================================================================================================================
  73. NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description
  74. ============================================================================================================================
  75. NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority
  76. | | | 4 bits for subpriority
  77. ----------------------------------------------------------------------------------------------------------------------------
  78. NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority
  79. | | | 3 bits for subpriority
  80. ----------------------------------------------------------------------------------------------------------------------------
  81. NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority
  82. | | | 2 bits for subpriority
  83. ----------------------------------------------------------------------------------------------------------------------------
  84. NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority
  85. | | | 1 bits for subpriority
  86. ----------------------------------------------------------------------------------------------------------------------------
  87. NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority
  88. | | | 0 bits for subpriority
  89. ============================================================================================================================
  90. @endcode
  91. */
  92. /**
  93. * @}
  94. */
  95. /** @defgroup MISC_Exported_Constants
  96. * @{
  97. */
  98. /** @defgroup Vector_Table_Base
  99. * @{
  100. */
  101. #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
  102. #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
  103. #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
  104. ((VECTTAB) == NVIC_VectTab_FLASH))
  105. /**
  106. * @}
  107. */
  108. /** @defgroup System_Low_Power
  109. * @{
  110. */
  111. #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
  112. #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
  113. #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
  114. #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
  115. ((LP) == NVIC_LP_SLEEPDEEP) || \
  116. ((LP) == NVIC_LP_SLEEPONEXIT))
  117. /**
  118. * @}
  119. */
  120. /** @defgroup Preemption_Priority_Group
  121. * @{
  122. */
  123. #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
  124. 4 bits for subpriority */
  125. #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
  126. 3 bits for subpriority */
  127. #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
  128. 2 bits for subpriority */
  129. #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
  130. 1 bits for subpriority */
  131. #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
  132. 0 bits for subpriority */
  133. #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
  134. ((GROUP) == NVIC_PriorityGroup_1) || \
  135. ((GROUP) == NVIC_PriorityGroup_2) || \
  136. ((GROUP) == NVIC_PriorityGroup_3) || \
  137. ((GROUP) == NVIC_PriorityGroup_4))
  138. #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  139. #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  140. #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
  141. /**
  142. * @}
  143. */
  144. /** @defgroup SysTick_clock_source
  145. * @{
  146. */
  147. #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
  148. #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
  149. #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
  150. ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  151. /**
  152. * @}
  153. */
  154. /**
  155. * @}
  156. */
  157. /** @defgroup MISC_Exported_Macros
  158. * @{
  159. */
  160. /**
  161. * @}
  162. */
  163. /** @defgroup MISC_Exported_Functions
  164. * @{
  165. */
  166. void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); //中断分组
  167. void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); //中断优先级设置
  168. void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  169. void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
  170. void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #endif /* __MISC_H */
  175. /**
  176. * @}
  177. */
  178. /**
  179. * @}
  180. */
  181. /**
  182. * @}
  183. */
  184. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/