1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2020-07-27 thread-liu first version 9 */ 10 11 #include "board.h" 12 #ifdef BSP_USING_EXTI 13 14 //#define DRV_DEBUG 15 #define LOG_TAG "drv.exti" 16 #include <drv_log.h> 17 18 /* defined the KEY2 pin: */ 19 #define KEY2_PIN GET_PIN(A, 13) 20 key2_on(void * args)21void key2_on(void *args) 22 { 23 rt_kprintf("press key2!\n"); 24 } 25 exti_sample(void)26static int exti_sample(void) 27 { 28 rt_pin_mode(KEY2_PIN, PIN_MODE_INPUT_PULLUP); 29 rt_pin_attach_irq(KEY2_PIN, PIN_IRQ_MODE_FALLING, key2_on, RT_NULL); 30 rt_pin_irq_enable(KEY2_PIN, PIN_IRQ_ENABLE); 31 32 return RT_EOK; 33 } 34 INIT_DEVICE_EXPORT(exti_sample); 35 36 #endif 37