1, to obtain pin numbers
#define PIN_NUM GET_PIN(F,10)
GET_PIN is defined inside the drv_gpio.h
#define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA)/(0x0400UL) )) + PIN)
2, is provided gpio mode rt_pin_mode (KEY_PIN, PIN_MODE_INPUT_PULLUP);
Input 1: pull-up, pull-down, analog, floating
Output 2: pull-up, pull-down, pull, open drain
Interrupt 3: rising edge, falling edge, both edges, high, low, trigger
#define PIN_LOW 0x00
#define PIN_HIGH 0x01
#define PIN_MODE_OUTPUT 0x00
#define PIN_MODE_INPUT 0x01
#define PIN_MODE_INPUT_PULLUP 0x02
#define PIN_MODE_INPUT_PULLDOWN 0x03
#define PIN_MODE_OUTPUT_OD 0x04
#define PIN_IRQ_MODE_RISING 0x00
#define PIN_IRQ_MODE_FALLING 0x01
#define PIN_IRQ_MODE_RISING_FALLING 0x02
#define PIN_IRQ_MODE_HIGH_LEVEL 0x03
#define PIN_IRQ_MODE_LOW_LEVEL 0x04
#define PIN_IRQ_DISABLE 0x00
#define PIN_IRQ_ENABLE 0x01
3, to read or set the output level gpio
rt_pin_write (PIN_NUM, PIN_HIGH); // output high
4, set the interrupt mode gpio
rt_pin_mode(KEY_PIN, PIN_MODE_INPUT_PULLUP);
rt_pin_attach_irq(KEY_PIN,PIN_IRQ_MODE_FALLING,key_callback,(void*)"lcd backlight on");
rt_pin_irq_enable(KEY_PIN,PIN_IRQ_ENABLE);
void key_callback (void * args) // interrupt callback
{
char * args = A;
}