Skip to content

Commit a036f7c

Browse files
committed
2.2.3
1 parent 8ed4dab commit a036f7c

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lesson-04/stm32c031-keil/lesson.uvprojx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<TargetName>Debug</TargetName>
1111
<ToolsetNumber>0x4</ToolsetNumber>
1212
<ToolsetName>ARM-ADS</ToolsetName>
13-
<pCCUsed>6190000::V6.19::ARMCLANG</pCCUsed>
13+
<pCCUsed>6220000::V6.22::ARMCLANG</pCCUsed>
1414
<uAC6>1</uAC6>
1515
<TargetOption>
1616
<TargetCommonOption>
@@ -314,7 +314,7 @@
314314
</ArmAdsMisc>
315315
<Cads>
316316
<interw>1</interw>
317-
<Optim>2</Optim>
317+
<Optim>1</Optim>
318318
<oTime>0</oTime>
319319
<SplitLS>0</SplitLS>
320320
<OneElfS>1</OneElfS>

lesson-27/stm32c031-qxk-keil/bsp.c

+28
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ void SysTick_Handler(void) {
2323
QXK_ISR_EXIT(); /* inform QXK about exiting an ISR */
2424
}
2525

26+
void EXTI4_15_IRQHandler(void); // prototype
27+
void EXTI4_15_IRQHandler(void) {
28+
QXK_ISR_ENTRY(); /* inform QXK about entering an ISR */
29+
30+
/* falling edge? */
31+
if ((EXTI->FPR1 & (1U << B1_PIN)) != 0U) {
32+
EXTI->FPR1 = (1U << B1_PIN); /* clear interrupt */
33+
QXSemaphore_signal(&SW1_sema);
34+
}
35+
36+
QXK_ISR_EXIT(); /* inform QXK about exiting an ISR */
37+
}
38+
2639
void BSP_init(void) {
2740
// enable GPIOA clock port for the LEDs
2841
RCC->IOPENR |= (1U << 0U);
@@ -37,11 +50,22 @@ void BSP_init(void) {
3750
GPIOA->OSPEEDR |= ((1U << 2U*LD4_PIN) | (1U << 2U*LD5_PIN));
3851
GPIOA->PUPDR &= ~((3U << 2U*LD4_PIN) | (3U << 2U*LD5_PIN));
3952

53+
// enable GPIOC clock port for the Button B1
54+
RCC->IOPENR |= (1U << 2U);
55+
4056
// configure Button B1 (PC.13) pins as input, no pull-up, pull-down
4157
GPIOC->MODER &= ~(3U << 2*B1_PIN);
4258
GPIOC->OSPEEDR &= ~(3U << 2*B1_PIN);
4359
GPIOC->OSPEEDR |= (1U << 2*B1_PIN);
4460
GPIOC->PUPDR &= ~(3U << 2*B1_PIN);
61+
62+
// configure Button B1 interrupt as falling edge
63+
EXTI->EMR1 &= ~(1U << B1_PIN);
64+
EXTI->IMR1 |= (1U << B1_PIN);
65+
EXTI->RTSR1 &= ~(1U << B1_PIN);
66+
EXTI->FTSR1 |= (1U << B1_PIN);
67+
EXTI->EXTICR[3] &= ~(7U << 8); // EXTI port C line 13
68+
EXTI->EXTICR[3] |= (2U << 8); // EXTI port C line 13
4569
}
4670

4771
void BSP_ledRedOn(void) {
@@ -75,6 +99,10 @@ void QF_onStartup(void) {
7599

76100
/* set the SysTick interrupt priority (highest) */
77101
NVIC_SetPriority(SysTick_IRQn, 0U);
102+
NVIC_SetPriority(EXTI4_15_IRQn, 0U);
103+
104+
/* enable interrupts */
105+
NVIC_EnableIRQ(EXTI4_15_IRQn);
78106
}
79107
/*..........................................................................*/
80108
void QF_onCleanup(void) {

0 commit comments

Comments
 (0)