misc.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. ******************************************************************************
  3. * @file misc.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 18-April-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 "stm32f2xx.h"
  30. /** @addtogroup STM32F2xx_StdPeriph_Driver
  31. * @{
  32. */
  33. /** @addtogroup MISC
  34. * @{
  35. */
  36. /* Exported types ------------------------------------------------------------*/
  37. /**
  38. * @brief NVIC Init Structure definition
  39. */
  40. typedef struct
  41. {
  42. uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
  43. This parameter can be an enumerator of @ref IRQn_Type
  44. enumeration (For the complete STM32 Devices IRQ Channels
  45. list, please refer to stm32f2xx.h file) */
  46. uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
  47. specified in NVIC_IRQChannel. This parameter can be a value
  48. between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table
  49. A lower priority value indicates a higher priority */
  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 MISC_NVIC_Priority_Table
  53. A lower priority value indicates a higher priority */
  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. /* Exported constants --------------------------------------------------------*/
  59. /** @defgroup MISC_Exported_Constants
  60. * @{
  61. */
  62. /** @defgroup MISC_Vector_Table_Base
  63. * @{
  64. */
  65. #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
  66. #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
  67. #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
  68. ((VECTTAB) == NVIC_VectTab_FLASH))
  69. /**
  70. * @}
  71. */
  72. /** @defgroup MISC_System_Low_Power
  73. * @{
  74. */
  75. #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
  76. #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
  77. #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
  78. #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
  79. ((LP) == NVIC_LP_SLEEPDEEP) || \
  80. ((LP) == NVIC_LP_SLEEPONEXIT))
  81. /**
  82. * @}
  83. */
  84. /** @defgroup MISC_Preemption_Priority_Group
  85. * @{
  86. */
  87. #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
  88. 4 bits for subpriority */
  89. #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
  90. 3 bits for subpriority */
  91. #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
  92. 2 bits for subpriority */
  93. #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
  94. 1 bits for subpriority */
  95. #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
  96. 0 bits for subpriority */
  97. #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
  98. ((GROUP) == NVIC_PriorityGroup_1) || \
  99. ((GROUP) == NVIC_PriorityGroup_2) || \
  100. ((GROUP) == NVIC_PriorityGroup_3) || \
  101. ((GROUP) == NVIC_PriorityGroup_4))
  102. #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  103. #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  104. #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
  105. /**
  106. * @}
  107. */
  108. /** @defgroup MISC_SysTick_clock_source
  109. * @{
  110. */
  111. #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
  112. #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
  113. #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
  114. ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  115. /**
  116. * @}
  117. */
  118. /**
  119. * @}
  120. */
  121. /* Exported macro ------------------------------------------------------------*/
  122. /* Exported functions --------------------------------------------------------*/
  123. void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  124. void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
  125. void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  126. void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
  127. void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131. #endif /* __MISC_H */
  132. /**
  133. * @}
  134. */
  135. /**
  136. * @}
  137. */
  138. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/