summaryrefslogtreecommitdiff
path: root/bsp/mm32f327x/Libraries/MM32F327x/HAL_Lib/Inc/hal_misc.h
blob: 0b7429963ee6ae745949b9a33fb6fbef10fe2687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
////////////////////////////////////////////////////////////////////////////////
/// @file     hal_misc.h
/// @author   AE TEAM
/// @brief    THIS FILE CONTAINS ALL THE FUNCTIONS PROTOTYPES FOR THE NVIC
///           FIRMWARE LIBRARY.
////////////////////////////////////////////////////////////////////////////////
/// @attention
///
/// THE EXISTING FIRMWARE IS ONLY FOR REFERENCE, WHICH IS DESIGNED TO PROVIDE
/// CUSTOMERS WITH CODING INFORMATION ABOUT THEIR PRODUCTS SO THEY CAN SAVE
/// TIME. THEREFORE, MINDMOTION SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT OR
/// CONSEQUENTIAL DAMAGES ABOUT ANY CLAIMS ARISING OUT OF THE CONTENT OF SUCH
/// HARDWARE AND/OR THE USE OF THE CODING INFORMATION CONTAINED HEREIN IN
/// CONNECTION WITH PRODUCTS MADE BY CUSTOMERS.
///
/// <H2><CENTER>&COPY; COPYRIGHT MINDMOTION </CENTER></H2>
////////////////////////////////////////////////////////////////////////////////

// Define to prevent recursive inclusion
#ifndef __HAL_MISC_H
#define __HAL_MISC_H

// Files includes
#include "types.h"
#include "reg_common.h"

////////////////////////////////////////////////////////////////////////////////
/// @addtogroup MM32_Hardware_Abstract_Layer
/// @{

////////////////////////////////////////////////////////////////////////////////
/// @defgroup NVIC_HAL
/// @brief NVIC HAL modules
/// @{

////////////////////////////////////////////////////////////////////////////////
/// @defgroup NVIC_Exported_Types
/// @{

////////////////////////////////////////////////////////////////////////////////
/// @brief  NVIC Init Structure definition
////////////////////////////////////////////////////////////////////////////////
typedef struct {
    u8 NVIC_IRQChannel;
    u8 NVIC_IRQChannelPreemptionPriority;
    u8 NVIC_IRQChannelSubPriority;
    FunctionalState NVIC_IRQChannelCmd;
} NVIC_InitTypeDef;

////////////////////////////////////////////////////////////////////////////////
/// @brief  NVIC New Init Structure definition
////////////////////////////////////////////////////////////////////////////////
typedef struct {
    u8              NVIC_IRQChannel;
    u8              NVIC_IRQChannelPreemptionPriority;                          // Cortex-M0 not used
    u8              NVIC_IRQChannelSubPriority;
    FunctionalState NVIC_IRQChannelCmd;
} exNVIC_Init_TypeDef;

/// @}
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
/// @defgroup NVIC_Exported_Constants
/// @{

#define NVIC_VectTab_RAM        (0x20000000U)
#define NVIC_VectTab_FLASH      (0x08000000U)

#define NVIC_LP_SEVONPEND       (0x10U)
#define NVIC_LP_SLEEPDEEP       (0x04U)
#define NVIC_LP_SLEEPONEXIT     (0x02U)

#define NVIC_PriorityGroup_0     (0x0700U) // 0 bits for pre-emption priority 4 bits for subpriority 
#define NVIC_PriorityGroup_1     (0x0600U) // 1 bits for pre-emption priority 3 bits for subpriority 
#define NVIC_PriorityGroup_2     (0x0500U) // 2 bits for pre-emption priority 2 bits for subpriority 
#define NVIC_PriorityGroup_3     (0x0400U) // 3 bits for pre-emption priority 1 bits for subpriority 
#define NVIC_PriorityGroup_4     (0x0300U) // 4 bits for pre-emption priority 0 bits for subpriority 

#define AIRCR_VECTKEY_MASK (0x05FA0000U)

#define SysTick_CLKSource_HCLK_Div8     (0xFFFFFFFBU)


#define SysTick_CLKSource_EXTCLK        (0xFFFFFFFBU)
#define SysTick_CLKSource_HCLK          (0x00000004U)
/// @}



////////////////////////////////////////////////////////////////////////////////
/// @defgroup NVIC_Exported_Variables
/// @{

#ifdef _HAL_NVIC_C_

#define GLOBAL
#else
#define GLOBAL extern
#endif

#undef GLOBAL

/// @}

////////////////////////////////////////////////////////////////////////////////
/// @defgroup NVIC_Exported_Functions
/// @{

void NVIC_PriorityGroupConfig(u32 priority_group);
void NVIC_SetVectorTable(u32 vect_tab, u32 offset);

void NVIC_SystemLPConfig(u8 low_power_mode, FunctionalState state);
void NVIC_Init(NVIC_InitTypeDef* init_struct);

void SysTick_CLKSourceConfig(u32 systick_clk_source);

void exNVIC_Init(exNVIC_Init_TypeDef* init_struct);

/// @}

/// @}

/// @}

////////////////////////////////////////////////////////////////////////////////
#endif // __HAL_NVIC_H 
////////////////////////////////////////////////////////////////////////////////