1 |
/** |
1 |
/** |
2 |
****************************************************************************** |
2 |
****************************************************************************** |
3 |
* @file misc.h |
3 |
* @file misc.h |
4 |
* @author MCD Application Team |
4 |
* @author MCD Application Team |
5 |
* @version V3.4.0 |
5 |
* @version V3.4.0 |
6 |
* @date 10/15/2010 |
6 |
* @date 10/15/2010 |
7 |
* @brief This file contains all the functions prototypes for the miscellaneous |
7 |
* @brief This file contains all the functions prototypes for the miscellaneous |
8 |
* firmware library functions (add-on to CMSIS functions). |
8 |
* firmware library functions (add-on to CMSIS functions). |
9 |
****************************************************************************** |
9 |
****************************************************************************** |
10 |
* @copy |
10 |
* @copy |
11 |
* |
11 |
* |
12 |
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
12 |
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
13 |
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
13 |
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
14 |
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
14 |
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
15 |
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
15 |
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
16 |
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
16 |
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
17 |
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
17 |
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
18 |
* |
18 |
* |
19 |
* <h2><center>© COPYRIGHT 2010 STMicroelectronics</center></h2> |
19 |
* <h2><center>© COPYRIGHT 2010 STMicroelectronics</center></h2> |
20 |
*/ |
20 |
*/ |
21 |
|
21 |
|
22 |
/* Define to prevent recursive inclusion -------------------------------------*/ |
22 |
/* Define to prevent recursive inclusion -------------------------------------*/ |
23 |
#ifndef __MISC_H |
23 |
#ifndef __MISC_H |
24 |
#define __MISC_H |
24 |
#define __MISC_H |
25 |
|
25 |
|
26 |
#ifdef __cplusplus |
26 |
#ifdef __cplusplus |
27 |
extern "C" { |
27 |
extern "C" { |
28 |
#endif |
28 |
#endif |
29 |
|
29 |
|
30 |
/* Includes ------------------------------------------------------------------*/ |
30 |
/* Includes ------------------------------------------------------------------*/ |
31 |
#include "stm32f10x.h" |
31 |
#include "stm32f10x.h" |
32 |
|
32 |
|
33 |
/** @addtogroup STM32F10x_StdPeriph_Driver |
33 |
/** @addtogroup STM32F10x_StdPeriph_Driver |
34 |
* @{ |
34 |
* @{ |
35 |
*/ |
35 |
*/ |
36 |
|
36 |
|
37 |
/** @addtogroup MISC |
37 |
/** @addtogroup MISC |
38 |
* @{ |
38 |
* @{ |
39 |
*/ |
39 |
*/ |
40 |
|
40 |
|
41 |
/** @defgroup MISC_Exported_Types |
41 |
/** @defgroup MISC_Exported_Types |
42 |
* @{ |
42 |
* @{ |
43 |
*/ |
43 |
*/ |
44 |
|
44 |
|
45 |
/** |
45 |
/** |
46 |
* @brief NVIC Init Structure definition |
46 |
* @brief NVIC Init Structure definition |
47 |
*/ |
47 |
*/ |
48 |
|
48 |
|
49 |
typedef struct |
49 |
typedef struct |
50 |
{ |
50 |
{ |
51 |
uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. |
51 |
uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. |
52 |
This parameter can be a value of @ref IRQn_Type |
52 |
This parameter can be a value of @ref IRQn_Type |
53 |
(For the complete STM32 Devices IRQ Channels list, please |
53 |
(For the complete STM32 Devices IRQ Channels list, please |
54 |
refer to stm32f10x.h file) */ |
54 |
refer to stm32f10x.h file) */ |
55 |
|
55 |
|
56 |
uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel |
56 |
uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel |
57 |
specified in NVIC_IRQChannel. This parameter can be a value |
57 |
specified in NVIC_IRQChannel. This parameter can be a value |
58 |
between 0 and 15 as described in the table @ref NVIC_Priority_Table */ |
58 |
between 0 and 15 as described in the table @ref NVIC_Priority_Table */ |
59 |
|
59 |
|
60 |
uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified |
60 |
uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified |
61 |
in NVIC_IRQChannel. This parameter can be a value |
61 |
in NVIC_IRQChannel. This parameter can be a value |
62 |
between 0 and 15 as described in the table @ref NVIC_Priority_Table */ |
62 |
between 0 and 15 as described in the table @ref NVIC_Priority_Table */ |
63 |
|
63 |
|
64 |
FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel |
64 |
FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel |
65 |
will be enabled or disabled. |
65 |
will be enabled or disabled. |
66 |
This parameter can be set either to ENABLE or DISABLE */ |
66 |
This parameter can be set either to ENABLE or DISABLE */ |
67 |
} NVIC_InitTypeDef; |
67 |
} NVIC_InitTypeDef; |
68 |
|
68 |
|
69 |
/** |
69 |
/** |
70 |
* @} |
70 |
* @} |
71 |
*/ |
71 |
*/ |
72 |
|
72 |
|
73 |
/** @defgroup NVIC_Priority_Table |
73 |
/** @defgroup NVIC_Priority_Table |
74 |
* @{ |
74 |
* @{ |
75 |
*/ |
75 |
*/ |
76 |
|
76 |
|
77 |
/** |
77 |
/** |
78 |
@code |
78 |
@code |
79 |
The table below gives the allowed values of the pre-emption priority and subpriority according |
79 |
The table below gives the allowed values of the pre-emption priority and subpriority according |
80 |
to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function |
80 |
to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function |
81 |
============================================================================================================================ |
81 |
============================================================================================================================ |
82 |
NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description |
82 |
NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description |
83 |
============================================================================================================================ |
83 |
============================================================================================================================ |
84 |
NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority |
84 |
NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority |
85 |
| | | 4 bits for subpriority |
85 |
| | | 4 bits for subpriority |
86 |
---------------------------------------------------------------------------------------------------------------------------- |
86 |
---------------------------------------------------------------------------------------------------------------------------- |
87 |
NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority |
87 |
NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority |
88 |
| | | 3 bits for subpriority |
88 |
| | | 3 bits for subpriority |
89 |
---------------------------------------------------------------------------------------------------------------------------- |
89 |
---------------------------------------------------------------------------------------------------------------------------- |
90 |
NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority |
90 |
NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority |
91 |
| | | 2 bits for subpriority |
91 |
| | | 2 bits for subpriority |
92 |
---------------------------------------------------------------------------------------------------------------------------- |
92 |
---------------------------------------------------------------------------------------------------------------------------- |
93 |
NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority |
93 |
NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority |
94 |
| | | 1 bits for subpriority |
94 |
| | | 1 bits for subpriority |
95 |
---------------------------------------------------------------------------------------------------------------------------- |
95 |
---------------------------------------------------------------------------------------------------------------------------- |
96 |
NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority |
96 |
NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority |
97 |
| | | 0 bits for subpriority |
97 |
| | | 0 bits for subpriority |
98 |
============================================================================================================================ |
98 |
============================================================================================================================ |
99 |
@endcode |
99 |
@endcode |
100 |
*/ |
100 |
*/ |
101 |
|
101 |
|
102 |
/** |
102 |
/** |
103 |
* @} |
103 |
* @} |
104 |
*/ |
104 |
*/ |
105 |
|
105 |
|
106 |
/** @defgroup MISC_Exported_Constants |
106 |
/** @defgroup MISC_Exported_Constants |
107 |
* @{ |
107 |
* @{ |
108 |
*/ |
108 |
*/ |
109 |
|
109 |
|
110 |
/** @defgroup Vector_Table_Base |
110 |
/** @defgroup Vector_Table_Base |
111 |
* @{ |
111 |
* @{ |
112 |
*/ |
112 |
*/ |
113 |
|
113 |
|
114 |
#define NVIC_VectTab_RAM ((uint32_t)0x20000000) |
114 |
#define NVIC_VectTab_RAM ((uint32_t)0x20000000) |
115 |
#define NVIC_VectTab_FLASH ((uint32_t)0x08000000) |
115 |
#define NVIC_VectTab_FLASH ((uint32_t)0x08000000) |
116 |
#define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ |
116 |
#define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ |
117 |
((VECTTAB) == NVIC_VectTab_FLASH)) |
117 |
((VECTTAB) == NVIC_VectTab_FLASH)) |
118 |
/** |
118 |
/** |
119 |
* @} |
119 |
* @} |
120 |
*/ |
120 |
*/ |
121 |
|
121 |
|
122 |
/** @defgroup System_Low_Power |
122 |
/** @defgroup System_Low_Power |
123 |
* @{ |
123 |
* @{ |
124 |
*/ |
124 |
*/ |
125 |
|
125 |
|
126 |
#define NVIC_LP_SEVONPEND ((uint8_t)0x10) |
126 |
#define NVIC_LP_SEVONPEND ((uint8_t)0x10) |
127 |
#define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) |
127 |
#define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) |
128 |
#define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) |
128 |
#define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) |
129 |
#define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ |
129 |
#define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ |
130 |
((LP) == NVIC_LP_SLEEPDEEP) || \ |
130 |
((LP) == NVIC_LP_SLEEPDEEP) || \ |
131 |
((LP) == NVIC_LP_SLEEPONEXIT)) |
131 |
((LP) == NVIC_LP_SLEEPONEXIT)) |
132 |
/** |
132 |
/** |
133 |
* @} |
133 |
* @} |
134 |
*/ |
134 |
*/ |
135 |
|
135 |
|
136 |
/** @defgroup Preemption_Priority_Group |
136 |
/** @defgroup Preemption_Priority_Group |
137 |
* @{ |
137 |
* @{ |
138 |
*/ |
138 |
*/ |
139 |
|
139 |
|
140 |
#define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority |
140 |
#define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority |
141 |
4 bits for subpriority */ |
141 |
4 bits for subpriority */ |
142 |
#define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority |
142 |
#define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority |
143 |
3 bits for subpriority */ |
143 |
3 bits for subpriority */ |
144 |
#define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority |
144 |
#define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority |
145 |
2 bits for subpriority */ |
145 |
2 bits for subpriority */ |
146 |
#define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority |
146 |
#define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority |
147 |
1 bits for subpriority */ |
147 |
1 bits for subpriority */ |
148 |
#define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority |
148 |
#define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority |
149 |
0 bits for subpriority */ |
149 |
0 bits for subpriority */ |
150 |
|
150 |
|
151 |
#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ |
151 |
#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ |
152 |
((GROUP) == NVIC_PriorityGroup_1) || \ |
152 |
((GROUP) == NVIC_PriorityGroup_1) || \ |
153 |
((GROUP) == NVIC_PriorityGroup_2) || \ |
153 |
((GROUP) == NVIC_PriorityGroup_2) || \ |
154 |
((GROUP) == NVIC_PriorityGroup_3) || \ |
154 |
((GROUP) == NVIC_PriorityGroup_3) || \ |
155 |
((GROUP) == NVIC_PriorityGroup_4)) |
155 |
((GROUP) == NVIC_PriorityGroup_4)) |
156 |
|
156 |
|
157 |
#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) |
157 |
#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) |
158 |
|
158 |
|
159 |
#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) |
159 |
#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) |
160 |
|
160 |
|
161 |
#define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) |
161 |
#define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) |
162 |
|
162 |
|
163 |
/** |
163 |
/** |
164 |
* @} |
164 |
* @} |
165 |
*/ |
165 |
*/ |
166 |
|
166 |
|
167 |
/** @defgroup SysTick_clock_source |
167 |
/** @defgroup SysTick_clock_source |
168 |
* @{ |
168 |
* @{ |
169 |
*/ |
169 |
*/ |
170 |
|
170 |
|
171 |
#define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) |
171 |
#define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) |
172 |
#define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) |
172 |
#define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) |
173 |
#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ |
173 |
#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ |
174 |
((SOURCE) == SysTick_CLKSource_HCLK_Div8)) |
174 |
((SOURCE) == SysTick_CLKSource_HCLK_Div8)) |
175 |
/** |
175 |
/** |
176 |
* @} |
176 |
* @} |
177 |
*/ |
177 |
*/ |
178 |
|
178 |
|
179 |
/** |
179 |
/** |
180 |
* @} |
180 |
* @} |
181 |
*/ |
181 |
*/ |
182 |
|
182 |
|
183 |
/** @defgroup MISC_Exported_Macros |
183 |
/** @defgroup MISC_Exported_Macros |
184 |
* @{ |
184 |
* @{ |
185 |
*/ |
185 |
*/ |
186 |
|
186 |
|
187 |
/** |
187 |
/** |
188 |
* @} |
188 |
* @} |
189 |
*/ |
189 |
*/ |
190 |
|
190 |
|
191 |
/** @defgroup MISC_Exported_Functions |
191 |
/** @defgroup MISC_Exported_Functions |
192 |
* @{ |
192 |
* @{ |
193 |
*/ |
193 |
*/ |
194 |
|
194 |
|
195 |
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); |
195 |
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); |
196 |
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); |
196 |
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); |
197 |
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); |
197 |
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); |
198 |
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); |
198 |
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); |
199 |
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); |
199 |
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); |
200 |
|
200 |
|
201 |
#ifdef __cplusplus |
201 |
#ifdef __cplusplus |
202 |
} |
202 |
} |
203 |
#endif |
203 |
#endif |
204 |
|
204 |
|
205 |
#endif /* __MISC_H */ |
205 |
#endif /* __MISC_H */ |
206 |
|
206 |
|
207 |
/** |
207 |
/** |
208 |
* @} |
208 |
* @} |
209 |
*/ |
209 |
*/ |
210 |
|
210 |
|
211 |
/** |
211 |
/** |
212 |
* @} |
212 |
* @} |
213 |
*/ |
213 |
*/ |
214 |
|
214 |
|
215 |
/** |
215 |
/** |
216 |
* @} |
216 |
* @} |
217 |
*/ |
217 |
*/ |
218 |
|
218 |
|
219 |
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ |
219 |
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ |