misc.h 6.1 KB

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