46 lines
1.2 KiB
Markdown
46 lines
1.2 KiB
Markdown
|
|
## GPIO Interrupt
|
|
|
|
> This example is used to trig gpio interrupt.
|
|
|
|
+ Select GPIO Port
|
|
```
|
|
// in main.c
|
|
/**
|
|
* Select Interrupt pin
|
|
*/
|
|
#define GPIO_INPUT_PORTx GPIOB
|
|
#define GPIO_INPUT_PINx GPIO_Pin_00
|
|
#define CONFIG_GPIO_IRQ GPIOB_IRQn
|
|
```
|
|
|
|
+ Select GPIO interrupt trigger mode
|
|
```
|
|
// in main.c
|
|
/**
|
|
* Select Interrupt source
|
|
*/
|
|
#define GPIO_INTERRUPT_TRIGGER GPIO_Trigger_Level
|
|
#define GPIO_INTERRUPT_POLARITY GPIO_Polarity_Low_Fall
|
|
```
|
|
|
|
|
|
## Note-Log
|
|
Use serial port with baudrate 115200 8bit, no parity check.
|
|
+ Select UART log pin
|
|
```
|
|
// in syslog.c
|
|
#define CONFIG_LOG_DEVICE_TX_IO_PORTx GPIOA
|
|
#define CONFIG_LOG_DEVICE_TX_IO_PINx GPIO_Pin_15
|
|
#define CONFIG_LOG_DEVICE_TX_IO_AF GPIO_AF_1
|
|
```
|
|
|
|
* If you want to use `PB1` as an interrupt, set IO to normal IO.(RST pin by default)
|
|
```
|
|
SYSCFG_SetRstPin2NormalIO(true); // set RST IO to normal IO
|
|
```
|
|
* If you want to use `PB[2:5]` as an interrupt, set IO to normal IO, and Restore IO to JTAG IO at the end.(JTAG pin by default)
|
|
```
|
|
SYSCFG_SetICEPin2NormalIO(true); // set JTAG IO to normal IO
|
|
SYSCFG_SetICEPin2NormalIO(false); // set normal IO to JTAG IO
|
|
``` |