5 changed files with 73 additions and 7 deletions
@ -0,0 +1,48 @@ |
|||||
|
/*
|
||||
|
* ext_interrupt.c |
||||
|
* |
||||
|
* Created on: 3 Sep 2019 |
||||
|
* Author: maximilian |
||||
|
*/ |
||||
|
|
||||
|
#include "ext_interrupt.h" |
||||
|
|
||||
|
void initExtInt(void) |
||||
|
{ |
||||
|
// Initialization structs
|
||||
|
GPIO_InitTypeDef exti_gpio; |
||||
|
|
||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); |
||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); |
||||
|
|
||||
|
//Additionally we need to initialize corresponding GPIOs
|
||||
|
exti_gpio.GPIO_Pin = GPIO_Pin_8; |
||||
|
exti_gpio.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
||||
|
exti_gpio.GPIO_Speed = GPIO_Speed_50MHz; |
||||
|
GPIO_Init(GPIOC, &exti_gpio); |
||||
|
|
||||
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource8); |
||||
|
|
||||
|
EXTI_InitTypeDef EXTI_InitStructure; |
||||
|
EXTI_InitStructure.EXTI_Line = EXTI_Line8; |
||||
|
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; |
||||
|
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; |
||||
|
EXTI_InitStructure.EXTI_LineCmd = ENABLE; |
||||
|
EXTI_Init(&EXTI_InitStructure); |
||||
|
|
||||
|
NVIC_InitTypeDef NVIC_InitStructure; |
||||
|
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn; //Enable keypad external interrupt channel
|
||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; //Priority 2,
|
||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; //Sub priority 2
|
||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //Enable external interrupt channel
|
||||
|
NVIC_Init(&NVIC_InitStructure); |
||||
|
osPrintf("Ext. int initialized."); |
||||
|
} |
||||
|
|
||||
|
void EXTI9_5_IRQHandler(void) |
||||
|
{ |
||||
|
osPrintf("Got interrupt."); |
||||
|
if(EXTI_GetITStatus(EXTI_Line8) != RESET) { |
||||
|
EXTI_ClearITPendingBit(EXTI_Line0); |
||||
|
} |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
/*
|
||||
|
* ext_interrupt.h |
||||
|
* |
||||
|
* Created on: 3 Sep 2019 |
||||
|
* Author: maximilian |
||||
|
*/ |
||||
|
|
||||
|
#ifndef PLATFORM_EXT_INTERRUPT_H_ |
||||
|
#define PLATFORM_EXT_INTERRUPT_H_ |
||||
|
|
||||
|
#include "stm32f10x.h" |
||||
|
#include <stdlib.h> |
||||
|
|
||||
|
void initExtInt(void); |
||||
|
|
||||
|
#endif /* PLATFORM_EXT_INTERRUPT_H_ */ |
Loading…
Reference in new issue