1 /*
2  * Copyright (c) 2006-2022, 100ask Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author                Notes
8  * 2022-06-06      Alen      Add key code for 100ask f103 mini
9  */
10 
11 #include <rtthread.h>
12 #include <drv_gpio.h>
13 
14 #ifdef BSP_USING_USER_KEY
15 #define KEY         GET_PIN(A, 0)
KEY_IRQHandler(void * args)16 static void KEY_IRQHandler(void *args)
17 {
18     rt_kprintf("Key Status: ");
19     if(rt_pin_read(KEY) == 0)
20     {
21         rt_kprintf("pressed.\r\n");
22     }
23     else
24     {
25         rt_kprintf("released.\r\n");
26     }
27 }
28 
29 
rt_hw_user_key_init(void)30 static int rt_hw_user_key_init(void)
31 {
32     rt_pin_mode(KEY, PIN_IRQ_MODE_RISING_FALLING);
33     rt_pin_attach_irq(KEY, PIN_IRQ_MODE_RISING_FALLING, KEY_IRQHandler, RT_NULL);
34     rt_pin_irq_enable(KEY, RT_TRUE);
35 
36     return RT_EOK;
37 }
38 
39 INIT_COMPONENT_EXPORT(rt_hw_user_key_init);
40 #endif
41 
42 
43