misc.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**
  2. ******************************************************************************
  3. * @file misc.h
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 06-March-2015
  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. * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __MISC_H
  30. #define __MISC_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm32f4xx.h"
  36. /** @addtogroup STM32F4xx_StdPeriph_Driver
  37. * @{
  38. */
  39. /** @addtogroup MISC
  40. * @{
  41. */
  42. /* Exported types ------------------------------------------------------------*/
  43. /**
  44. * @brief NVIC Init Structure definition
  45. */
  46. typedef struct
  47. {
  48. uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
  49. This parameter can be an enumerator of @ref IRQn_Type
  50. enumeration (For the complete STM32 Devices IRQ Channels
  51. list, please refer to stm32f4xx.h file) */
  52. uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
  53. specified in NVIC_IRQChannel. This parameter can be a value
  54. between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table
  55. A lower priority value indicates a higher priority */
  56. uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
  57. in NVIC_IRQChannel. This parameter can be a value
  58. between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table
  59. A lower priority value indicates a higher priority */
  60. FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
  61. will be enabled or disabled.
  62. This parameter can be set either to ENABLE or DISABLE */
  63. } NVIC_InitTypeDef;
  64. /* Exported constants --------------------------------------------------------*/
  65. /** @defgroup MISC_Exported_Constants
  66. * @{
  67. */
  68. /** @defgroup MISC_Vector_Table_Base
  69. * @{
  70. */
  71. #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
  72. #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
  73. #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
  74. ((VECTTAB) == NVIC_VectTab_FLASH))
  75. /**
  76. * @}
  77. */
  78. /** @defgroup MISC_System_Low_Power
  79. * @{
  80. */
  81. #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
  82. #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
  83. #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
  84. #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
  85. ((LP) == NVIC_LP_SLEEPDEEP) || \
  86. ((LP) == NVIC_LP_SLEEPONEXIT))
  87. /**
  88. * @}
  89. */
  90. /** @defgroup MISC_Preemption_Priority_Group
  91. * @{
  92. */
  93. #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
  94. 4 bits for subpriority */
  95. #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
  96. 3 bits for subpriority */
  97. #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
  98. 2 bits for subpriority */
  99. #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
  100. 1 bits for subpriority */
  101. #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
  102. 0 bits for subpriority */
  103. #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
  104. ((GROUP) == NVIC_PriorityGroup_1) || \
  105. ((GROUP) == NVIC_PriorityGroup_2) || \
  106. ((GROUP) == NVIC_PriorityGroup_3) || \
  107. ((GROUP) == NVIC_PriorityGroup_4))
  108. #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  109. #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
  110. #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
  111. /**
  112. * @}
  113. */
  114. /** @defgroup MISC_SysTick_clock_source
  115. * @{
  116. */
  117. #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
  118. #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
  119. #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
  120. ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
  121. /**
  122. * @}
  123. */
  124. /**
  125. * @}
  126. */
  127. /* Exported macro ------------------------------------------------------------*/
  128. /* Exported functions --------------------------------------------------------*/
  129. void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  130. void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
  131. void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
  132. void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
  133. void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137. #endif /* __MISC_H */
  138. /**
  139. * @}
  140. */
  141. /**
  142. * @}
  143. */
  144. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/