misc.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
  45. This parameter can be a value of @ref IRQn_Type
  46. (For the complete STM32 Devices IRQ Channels list, please
  47. refer to stm32f10x.h file) */
  48. uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
  49. specified in NVIC_IRQChannel. This parameter can be a value
  50. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  51. uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
  52. in NVIC_IRQChannel. This parameter can be a value
  53. between 0 and 15 as described in the table @ref NVIC_Priority_Table */
  54. FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
  55. will be enabled or disabled.
  56. This parameter can be set either to ENABLE or DISABLE */
  57. } NVIC_InitTypeDef;
  58. /**
  59. * @}
  60. */
  61. /** @defgroup NVIC_Priority_Table
  62. * @{
  63. */
  64. /**
  65. @code
  66. The table below gives the allowed values of the pre-emption priority and subpriority according
  67. to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function
  68. ============================================================================================================================
  69. NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description
  70. ============================================================================================================================
  71. NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority
  72. | | | 4 bits for subpriority
  73. ----------------------------------------------------------------------------------------------------------------------------
  74. NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority
  75. | | | 3 bits for subpriority
  76. ----------------------------------------------------------------------------------------------------------------------------
  77. NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority
  78. | | | 2 bits for subpriority
  79. ----------------------------------------------------------------------------------------------------------------------------
  80. NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority
  81. | | | 1 bits for subpriority
  82. ----------------------------------------------------------------------------------------------------------------------------
  83. NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority
  84. | | | 0 bits for subpriority
  85. ============================================================================================================================
  86. @endcode
  87. */
  88. /**
  89. * @}
  90. */
  91. /** @defgroup MISC_Exported_Constants
  92. * @{
  93. */
  94. /** @defgroup Vector_Table_Base
  95. * @{
  96. */
  97. #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
  98. #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
  99. #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
  100. ((VECTTAB) == NVIC_VectTab_FLASH))
  101. /**
  102. * @}
  103. */
  104. /** @defgroup System_Low_Power
  105. * @{
  106. */
  107. #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
  108. #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
  109. #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
  110. #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
  111. ((LP) == NVIC_LP_SLEEPDEEP) || \
  112. ((LP) == NVIC_LP_SLEEPONEXIT))
  113. /**
  114. * @}
  115. */
  116. /** @defgroup Preemption_Priority_Group
  117. * @{
  118. */
  119. #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
  120. 4 bits for subpriority */
  121. #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
  122. 3 bits for subpriority */
  123. #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
  124. 2 bits for subpriority */
  125. #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
  126. 1 bits for subpriority */
  127. #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
  128. 0 bits for subpriority */
  129. #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
  130. ((GROUP) == NVIC_PriorityGroup_1) || \
  131. ((GROUP) == NVIC_PriorityGroup_2) || \
  132. ((GROUP) == NVIC_PriorityGroup_3) || \
  133. ((GROUP) == NVIC_PriorityGroup_4))
  134. #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  135. #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  136. #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
  137. /**
  138. * @}
  139. */
  140. /** @defgroup SysTick_clock_source
  141. * @{
  142. */
  143. #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
  144. #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
  145. #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
  146. ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  147. /**
  148. * @}
  149. */
  150. /**
  151. * @}
  152. */
  153. /** @defgroup MISC_Exported_Macros
  154. * @{
  155. */
  156. /**
  157. * @}
  158. */
  159. /** @defgroup MISC_Exported_Functions
  160. * @{
  161. */
  162. void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  163. void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
  164. void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  165. void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
  166. void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  167. #ifdef __cplusplus
  168. }
  169. #endif
  170. #endif /* __MISC_H */
  171. /**
  172. * @}
  173. */
  174. /**
  175. * @}
  176. */
  177. /**
  178. * @}
  179. */
  180. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/