Skip to content

Commit

Permalink
2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-leaps committed Aug 10, 2024
1 parent 8ed4dab commit a036f7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lesson-04/stm32c031-keil/lesson.uvprojx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<TargetName>Debug</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6190000::V6.19::ARMCLANG</pCCUsed>
<pCCUsed>6220000::V6.22::ARMCLANG</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
Expand Down Expand Up @@ -314,7 +314,7 @@
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>2</Optim>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
Expand Down
28 changes: 28 additions & 0 deletions lesson-27/stm32c031-qxk-keil/bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ void SysTick_Handler(void) {
QXK_ISR_EXIT(); /* inform QXK about exiting an ISR */
}

void EXTI4_15_IRQHandler(void); // prototype
void EXTI4_15_IRQHandler(void) {
QXK_ISR_ENTRY(); /* inform QXK about entering an ISR */

/* falling edge? */
if ((EXTI->FPR1 & (1U << B1_PIN)) != 0U) {
EXTI->FPR1 = (1U << B1_PIN); /* clear interrupt */
QXSemaphore_signal(&SW1_sema);
}

QXK_ISR_EXIT(); /* inform QXK about exiting an ISR */
}

void BSP_init(void) {
// enable GPIOA clock port for the LEDs
RCC->IOPENR |= (1U << 0U);
Expand All @@ -37,11 +50,22 @@ void BSP_init(void) {
GPIOA->OSPEEDR |= ((1U << 2U*LD4_PIN) | (1U << 2U*LD5_PIN));
GPIOA->PUPDR &= ~((3U << 2U*LD4_PIN) | (3U << 2U*LD5_PIN));

// enable GPIOC clock port for the Button B1
RCC->IOPENR |= (1U << 2U);

// configure Button B1 (PC.13) pins as input, no pull-up, pull-down
GPIOC->MODER &= ~(3U << 2*B1_PIN);
GPIOC->OSPEEDR &= ~(3U << 2*B1_PIN);
GPIOC->OSPEEDR |= (1U << 2*B1_PIN);
GPIOC->PUPDR &= ~(3U << 2*B1_PIN);

// configure Button B1 interrupt as falling edge
EXTI->EMR1 &= ~(1U << B1_PIN);
EXTI->IMR1 |= (1U << B1_PIN);
EXTI->RTSR1 &= ~(1U << B1_PIN);
EXTI->FTSR1 |= (1U << B1_PIN);
EXTI->EXTICR[3] &= ~(7U << 8); // EXTI port C line 13
EXTI->EXTICR[3] |= (2U << 8); // EXTI port C line 13
}

void BSP_ledRedOn(void) {
Expand Down Expand Up @@ -75,6 +99,10 @@ void QF_onStartup(void) {

/* set the SysTick interrupt priority (highest) */
NVIC_SetPriority(SysTick_IRQn, 0U);
NVIC_SetPriority(EXTI4_15_IRQn, 0U);

/* enable interrupts */
NVIC_EnableIRQ(EXTI4_15_IRQn);
}
/*..........................................................................*/
void QF_onCleanup(void) {
Expand Down

0 comments on commit a036f7c

Please sign in to comment.