Skip to content

Commit 7250271

Browse files
committed
0
0 parents  commit 7250271

File tree

514 files changed

+325461
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+325461
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// <<< Use Configuration Wizard in Context Menu >>>
2+
// <h> Debug MCU Configuration
3+
// <o0.0> DBG_SLEEP
4+
// <i> Debug Sleep Mode
5+
// <i> 0: (FCLK=On, HCLK=Off) FCLK is clocked by the system clock as previously configured by the software while HCLK is disabled
6+
// <i> 1: (FCLK=On, HCLK=On) HCLK is fed by the same clock that is provided to FCLK
7+
// <o0.1> DBG_STOP
8+
// <i> Debug Stop Mode
9+
// <i> 0: (FCLK=Off, HCLK=Off) Clock controller disables all clocks
10+
// <i> 1: (FCLK=On, HCLK=On) FCLK and HCLK are provided by the internal RC oscillator which remains active
11+
// <o0.2> DBG_STANDBY
12+
// <i> Debug Standby Mode
13+
// <i> 0: (FCLK=Off, HCLK=Off) The whole digital part is unpowered.
14+
// <i> 1: (FCLK=On, HCLK=On) Digital part is powered and FCLK and HCLK are provided by the internal RC oscillator which remains active
15+
// <o0.8> DBG_IWDG_STOP
16+
// <i> Debug independent watchdog stopped when core is halted
17+
// <i> 0: The watchdog counter clock continues even if the core is halted
18+
// <i> 1: The watchdog counter clock is stopped when the core is halted
19+
// <o0.9> DBG_WWDG_STOP
20+
// <i> Debug window watchdog stopped when core is halted
21+
// <i> 0: The window watchdog counter clock continues even if the core is halted
22+
// <i> 1: The window watchdog counter clock is stopped when the core is halted
23+
// <o0.10> DBG_TIM1_STOP
24+
// <i> Timer 1 counter stopped when core is halted
25+
// <i> 0: The clock of the involved Timer Counter is fed even if the core is halted
26+
// <i> 1: The clock of the involved Timer counter is stopped when the core is halted
27+
// <o0.11> DBG_TIM2_STOP
28+
// <i> Timer 2 counter stopped when core is halted
29+
// <i> 0: The clock of the involved Timer Counter is fed even if the core is halted
30+
// <i> 1: The clock of the involved Timer counter is stopped when the core is halted
31+
// <o0.12> DBG_TIM3_STOP
32+
// <i> Timer 3 counter stopped when core is halted
33+
// <i> 0: The clock of the involved Timer Counter is fed even if the core is halted
34+
// <i> 1: The clock of the involved Timer counter is stopped when the core is halted
35+
// <o0.13> DBG_TIM4_STOP
36+
// <i> Timer 4 counter stopped when core is halted
37+
// <i> 0: The clock of the involved Timer Counter is fed even if the core is halted
38+
// <i> 1: The clock of the involved Timer counter is stopped when the core is halted
39+
// <o0.14> DBG_CAN1_STOP
40+
// <i> Debug CAN1 stopped when Core is halted
41+
// <i> 0: Same behavior as in normal mode
42+
// <i> 1: CAN1 receive registers are frozen
43+
// <o0.15> DBG_I2C1_SMBUS_TIMEOUT
44+
// <i> I2C1 SMBUS timeout mode stopped when Core is halted
45+
// <i> 0: Same behavior as in normal mode
46+
// <i> 1: The SMBUS timeout is frozen
47+
// <o0.16> DBG_I2C2_SMBUS_TIMEOUT
48+
// <i> I2C2 SMBUS timeout mode stopped when Core is halted
49+
// <i> 0: Same behavior as in normal mode
50+
// <i> 1: The SMBUS timeout is frozen
51+
// <o0.17> DBG_TIM8_STOP
52+
// <i> Timer 8 counter stopped when core is halted
53+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
54+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
55+
// <o0.18> DBG_TIM5_STOP
56+
// <i> Timer 5 counter stopped when core is halted
57+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
58+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
59+
// <o0.19> DBG_TIM6_STOP
60+
// <i> Timer 6 counter stopped when core is halted
61+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
62+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
63+
// <o0.20> DBG_TIM7_STOP
64+
// <i> Timer 7 counter stopped when core is halted
65+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
66+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
67+
// <o0.21> DBG_CAN2_STOP
68+
// <i> Debug CAN2 stopped when Core is halted
69+
// <i> 0: Same behavior as in normal mode
70+
// <i> 1: CAN2 receive registers are frozen
71+
// <o0.25> DBG_TIM12_STOP
72+
// <i> Timer 12 counter stopped when core is halted
73+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
74+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
75+
// <o0.26> DBG_TIM13_STOP
76+
// <i> Timer 13 counter stopped when core is halted
77+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
78+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
79+
// <o0.27> DBG_TIM14_STOP
80+
// <i> Timer 14 counter stopped when core is halted
81+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
82+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
83+
// <o0.28> DBG_TIM9_STOP
84+
// <i> Timer 9 counter stopped when core is halted
85+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
86+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
87+
// <o0.29> DBG_TIM10_STOP
88+
// <i> Timer 10 counter stopped when core is halted
89+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
90+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
91+
// <o0.30> DBG_TIM11_STOP
92+
// <i> Timer 11 counter stopped when core is halted
93+
// <i> 0: The clock of the involved timer counter is fed even if the core is halted, and the outputs behave normally.
94+
// <i> 1: The clock of the involved timer counter is stopped when the core is halted, and the outputs are disabled (as if there were an emergency stop in response to a break event).
95+
// </h>
96+
DbgMCU_CR = 0x00000007;
97+
// <<< end of configuration section >>>

2-1 STM32_Template/Library/misc.c

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
/**
2+
******************************************************************************
3+
* @file misc.c
4+
* @author MCD Application Team
5+
* @version V3.5.0
6+
* @date 11-March-2011
7+
* @brief This file provides all the miscellaneous firmware functions (add-on
8+
* to CMSIS functions).
9+
******************************************************************************
10+
* @attention
11+
*
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
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
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.
18+
*
19+
* <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
20+
******************************************************************************
21+
*/
22+
23+
/* Includes ------------------------------------------------------------------*/
24+
#include "misc.h"
25+
26+
/** @addtogroup STM32F10x_StdPeriph_Driver
27+
* @{
28+
*/
29+
30+
/** @defgroup MISC
31+
* @brief MISC driver modules
32+
* @{
33+
*/
34+
35+
/** @defgroup MISC_Private_TypesDefinitions
36+
* @{
37+
*/
38+
39+
/**
40+
* @}
41+
*/
42+
43+
/** @defgroup MISC_Private_Defines
44+
* @{
45+
*/
46+
47+
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
48+
/**
49+
* @}
50+
*/
51+
52+
/** @defgroup MISC_Private_Macros
53+
* @{
54+
*/
55+
56+
/**
57+
* @}
58+
*/
59+
60+
/** @defgroup MISC_Private_Variables
61+
* @{
62+
*/
63+
64+
/**
65+
* @}
66+
*/
67+
68+
/** @defgroup MISC_Private_FunctionPrototypes
69+
* @{
70+
*/
71+
72+
/**
73+
* @}
74+
*/
75+
76+
/** @defgroup MISC_Private_Functions
77+
* @{
78+
*/
79+
80+
/**
81+
* @brief Configures the priority grouping: pre-emption priority and subpriority.
82+
* @param NVIC_PriorityGroup: specifies the priority grouping bits length.
83+
* This parameter can be one of the following values:
84+
* @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority
85+
* 4 bits for subpriority
86+
* @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority
87+
* 3 bits for subpriority
88+
* @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority
89+
* 2 bits for subpriority
90+
* @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority
91+
* 1 bits for subpriority
92+
* @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority
93+
* 0 bits for subpriority
94+
* @retval None
95+
*/
96+
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
97+
{
98+
/* Check the parameters */
99+
assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
100+
101+
/* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
102+
SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
103+
}
104+
105+
/**
106+
* @brief Initializes the NVIC peripheral according to the specified
107+
* parameters in the NVIC_InitStruct.
108+
* @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure that contains
109+
* the configuration information for the specified NVIC peripheral.
110+
* @retval None
111+
*/
112+
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
113+
{
114+
uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
115+
116+
/* Check the parameters */
117+
assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
118+
assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority));
119+
assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority));
120+
121+
if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
122+
{
123+
/* Compute the Corresponding IRQ Priority --------------------------------*/
124+
tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
125+
tmppre = (0x4 - tmppriority);
126+
tmpsub = tmpsub >> tmppriority;
127+
128+
tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
129+
tmppriority |= NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
130+
tmppriority = tmppriority << 0x04;
131+
132+
NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
133+
134+
/* Enable the Selected IRQ Channels --------------------------------------*/
135+
NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
136+
(uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
137+
}
138+
else
139+
{
140+
/* Disable the Selected IRQ Channels -------------------------------------*/
141+
NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
142+
(uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
143+
}
144+
}
145+
146+
/**
147+
* @brief Sets the vector table location and Offset.
148+
* @param NVIC_VectTab: specifies if the vector table is in RAM or FLASH memory.
149+
* This parameter can be one of the following values:
150+
* @arg NVIC_VectTab_RAM
151+
* @arg NVIC_VectTab_FLASH
152+
* @param Offset: Vector Table base offset field. This value must be a multiple
153+
* of 0x200.
154+
* @retval None
155+
*/
156+
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
157+
{
158+
/* Check the parameters */
159+
assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
160+
assert_param(IS_NVIC_OFFSET(Offset));
161+
162+
SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
163+
}
164+
165+
/**
166+
* @brief Selects the condition for the system to enter low power mode.
167+
* @param LowPowerMode: Specifies the new mode for the system to enter low power mode.
168+
* This parameter can be one of the following values:
169+
* @arg NVIC_LP_SEVONPEND
170+
* @arg NVIC_LP_SLEEPDEEP
171+
* @arg NVIC_LP_SLEEPONEXIT
172+
* @param NewState: new state of LP condition. This parameter can be: ENABLE or DISABLE.
173+
* @retval None
174+
*/
175+
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
176+
{
177+
/* Check the parameters */
178+
assert_param(IS_NVIC_LP(LowPowerMode));
179+
assert_param(IS_FUNCTIONAL_STATE(NewState));
180+
181+
if (NewState != DISABLE)
182+
{
183+
SCB->SCR |= LowPowerMode;
184+
}
185+
else
186+
{
187+
SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
188+
}
189+
}
190+
191+
/**
192+
* @brief Configures the SysTick clock source.
193+
* @param SysTick_CLKSource: specifies the SysTick clock source.
194+
* This parameter can be one of the following values:
195+
* @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8 selected as SysTick clock source.
196+
* @arg SysTick_CLKSource_HCLK: AHB clock selected as SysTick clock source.
197+
* @retval None
198+
*/
199+
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
200+
{
201+
/* Check the parameters */
202+
assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
203+
if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
204+
{
205+
SysTick->CTRL |= SysTick_CLKSource_HCLK;
206+
}
207+
else
208+
{
209+
SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
210+
}
211+
}
212+
213+
/**
214+
* @}
215+
*/
216+
217+
/**
218+
* @}
219+
*/
220+
221+
/**
222+
* @}
223+
*/
224+
225+
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)