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 
19 // Define to prevent recursive inclusion
20 #ifndef __HAL_MISC_H
21 #define __HAL_MISC_H
22 
23 // Files includes
24 #include "types.h"
25 #include "reg_common.h"
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// @addtogroup MM32_Hardware_Abstract_Layer
29 /// @{
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// @defgroup NVIC_HAL
33 /// @brief NVIC HAL modules
34 /// @{
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 /// @defgroup NVIC_Exported_Types
38 /// @{
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// @brief  NVIC Init Structure definition
42 ////////////////////////////////////////////////////////////////////////////////
43 typedef struct {
44     u8 NVIC_IRQChannel;
45     u8 NVIC_IRQChannelPreemptionPriority;
46     u8 NVIC_IRQChannelSubPriority;
47     FunctionalState NVIC_IRQChannelCmd;
48 } NVIC_InitTypeDef;
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// @brief  NVIC New Init Structure definition
52 ////////////////////////////////////////////////////////////////////////////////
53 typedef struct {
54     u8              NVIC_IRQChannel;
55     u8              NVIC_IRQChannelPreemptionPriority;                          // Cortex-M0 not used
56     u8              NVIC_IRQChannelSubPriority;
57     FunctionalState NVIC_IRQChannelCmd;
58 } exNVIC_Init_TypeDef;
59 
60 /// @}
61 ////////////////////////////////////////////////////////////////////////////////
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// @defgroup NVIC_Exported_Constants
65 /// @{
66 
67 #define NVIC_VectTab_RAM        (0x20000000U)
68 #define NVIC_VectTab_FLASH      (0x08000000U)
69 
70 #define NVIC_LP_SEVONPEND       (0x10U)
71 #define NVIC_LP_SLEEPDEEP       (0x04U)
72 #define NVIC_LP_SLEEPONEXIT     (0x02U)
73 
74 #define NVIC_PriorityGroup_0     (0x0700U) // 0 bits for pre-emption priority 4 bits for subpriority
75 #define NVIC_PriorityGroup_1     (0x0600U) // 1 bits for pre-emption priority 3 bits for subpriority
76 #define NVIC_PriorityGroup_2     (0x0500U) // 2 bits for pre-emption priority 2 bits for subpriority
77 #define NVIC_PriorityGroup_3     (0x0400U) // 3 bits for pre-emption priority 1 bits for subpriority
78 #define NVIC_PriorityGroup_4     (0x0300U) // 4 bits for pre-emption priority 0 bits for subpriority
79 
80 #define AIRCR_VECTKEY_MASK (0x05FA0000U)
81 
82 #define SysTick_CLKSource_HCLK_Div8     (0xFFFFFFFBU)
83 
84 
85 #define SysTick_CLKSource_EXTCLK        (0xFFFFFFFBU)
86 #define SysTick_CLKSource_HCLK          (0x00000004U)
87 /// @}
88 
89 
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 /// @defgroup NVIC_Exported_Variables
93 /// @{
94 
95 #ifdef _HAL_NVIC_C_
96 
97 #define GLOBAL
98 #else
99 #define GLOBAL extern
100 #endif
101 
102 #undef GLOBAL
103 
104 /// @}
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// @defgroup NVIC_Exported_Functions
108 /// @{
109 
110 void NVIC_PriorityGroupConfig(u32 priority_group);
111 void NVIC_SetVectorTable(u32 vect_tab, u32 offset);
112 
113 void NVIC_SystemLPConfig(u8 low_power_mode, FunctionalState state);
114 void NVIC_Init(NVIC_InitTypeDef* init_struct);
115 
116 void SysTick_CLKSourceConfig(u32 systick_clk_source);
117 
118 void exNVIC_Init(exNVIC_Init_TypeDef* init_struct);
119 
120 /// @}
121 
122 /// @}
123 
124 /// @}
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 #endif // __HAL_NVIC_H
128 ////////////////////////////////////////////////////////////////////////////////
129