hal_misc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ////////////////////////////////////////////////////////////////////////////////
  2. /// @file hal_misc.h
  3. /// @author AE TEAM
  4. /// @brief THIS FILE CONTAINS ALL THE FUNCTIONS PROTOTYPES FOR THE NVIC
  5. /// FIRMWARE LIBRARY.
  6. ////////////////////////////////////////////////////////////////////////////////
  7. /// @attention
  8. ///
  9. /// THE EXISTING FIRMWARE IS ONLY FOR REFERENCE, WHICH IS DESIGNED TO PROVIDE
  10. /// CUSTOMERS WITH CODING INFORMATION ABOUT THEIR PRODUCTS SO THEY CAN SAVE
  11. /// TIME. THEREFORE, MINDMOTION SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT OR
  12. /// CONSEQUENTIAL DAMAGES ABOUT ANY CLAIMS ARISING OUT OF THE CONTENT OF SUCH
  13. /// HARDWARE AND/OR THE USE OF THE CODING INFORMATION CONTAINED HEREIN IN
  14. /// CONNECTION WITH PRODUCTS MADE BY CUSTOMERS.
  15. ///
  16. /// <H2><CENTER>&COPY; COPYRIGHT MINDMOTION </CENTER></H2>
  17. ////////////////////////////////////////////////////////////////////////////////
  18. // Define to prevent recursive inclusion
  19. #ifndef __HAL_MISC_H
  20. #define __HAL_MISC_H
  21. // Files includes
  22. #include "types.h"
  23. #include "reg_common.h"
  24. ////////////////////////////////////////////////////////////////////////////////
  25. /// @addtogroup MM32_Hardware_Abstract_Layer
  26. /// @{
  27. ////////////////////////////////////////////////////////////////////////////////
  28. /// @defgroup NVIC_HAL
  29. /// @brief NVIC HAL modules
  30. /// @{
  31. ////////////////////////////////////////////////////////////////////////////////
  32. /// @defgroup NVIC_Exported_Types
  33. /// @{
  34. ////////////////////////////////////////////////////////////////////////////////
  35. /// @brief NVIC Init Structure definition
  36. ////////////////////////////////////////////////////////////////////////////////
  37. typedef struct {
  38. u8 NVIC_IRQChannel;
  39. u8 NVIC_IRQChannelPreemptionPriority;
  40. u8 NVIC_IRQChannelSubPriority;
  41. FunctionalState NVIC_IRQChannelCmd;
  42. } NVIC_InitTypeDef;
  43. ////////////////////////////////////////////////////////////////////////////////
  44. /// @brief NVIC New Init Structure definition
  45. ////////////////////////////////////////////////////////////////////////////////
  46. typedef struct {
  47. u8 NVIC_IRQChannel;
  48. u8 NVIC_IRQChannelPreemptionPriority; // Cortex-M0 not used
  49. u8 NVIC_IRQChannelSubPriority;
  50. FunctionalState NVIC_IRQChannelCmd;
  51. } exNVIC_Init_TypeDef;
  52. /// @}
  53. ////////////////////////////////////////////////////////////////////////////////
  54. ////////////////////////////////////////////////////////////////////////////////
  55. /// @defgroup NVIC_Exported_Constants
  56. /// @{
  57. #define NVIC_VectTab_RAM (0x20000000U)
  58. #define NVIC_VectTab_FLASH (0x08000000U)
  59. #define NVIC_LP_SEVONPEND (0x10U)
  60. #define NVIC_LP_SLEEPDEEP (0x04U)
  61. #define NVIC_LP_SLEEPONEXIT (0x02U)
  62. #define NVIC_PriorityGroup_0 (0x0700U) // 0 bits for pre-emption priority 4 bits for subpriority
  63. #define NVIC_PriorityGroup_1 (0x0600U) // 1 bits for pre-emption priority 3 bits for subpriority
  64. #define NVIC_PriorityGroup_2 (0x0500U) // 2 bits for pre-emption priority 2 bits for subpriority
  65. #define NVIC_PriorityGroup_3 (0x0400U) // 3 bits for pre-emption priority 1 bits for subpriority
  66. #define NVIC_PriorityGroup_4 (0x0300U) // 4 bits for pre-emption priority 0 bits for subpriority
  67. #define AIRCR_VECTKEY_MASK (0x05FA0000U)
  68. #define SysTick_CLKSource_HCLK_Div8 (0xFFFFFFFBU)
  69. #define SysTick_CLKSource_EXTCLK (0xFFFFFFFBU)
  70. #define SysTick_CLKSource_HCLK (0x00000004U)
  71. /// @}
  72. ////////////////////////////////////////////////////////////////////////////////
  73. /// @defgroup NVIC_Exported_Variables
  74. /// @{
  75. #ifdef _HAL_NVIC_C_
  76. #define GLOBAL
  77. #else
  78. #define GLOBAL extern
  79. #endif
  80. #undef GLOBAL
  81. /// @}
  82. ////////////////////////////////////////////////////////////////////////////////
  83. /// @defgroup NVIC_Exported_Functions
  84. /// @{
  85. void NVIC_PriorityGroupConfig(u32 priority_group);
  86. void NVIC_SetVectorTable(u32 vect_tab, u32 offset);
  87. void NVIC_SystemLPConfig(u8 low_power_mode, FunctionalState state);
  88. void NVIC_Init(NVIC_InitTypeDef* init_struct);
  89. void SysTick_CLKSourceConfig(u32 systick_clk_source);
  90. void exNVIC_Init(exNVIC_Init_TypeDef* init_struct);
  91. /// @}
  92. /// @}
  93. /// @}
  94. ////////////////////////////////////////////////////////////////////////////////
  95. #endif // __HAL_NVIC_H
  96. ////////////////////////////////////////////////////////////////////////////////