11/*
2- * Copyright (c) 2006-2022 , RT-Thread Development Team
2+ * Copyright (c) 2006-2025 , RT-Thread Development Team
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 *
@@ -223,6 +223,7 @@ static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_base_t pin,
223223 break ;
224224 }
225225 }
226+
226227 if (irqindex == -1 )
227228 {
228229 return - RT_ENOMEM ;
@@ -298,6 +299,7 @@ static rt_err_t nrf5x_pin_dettach_irq(struct rt_device *device, rt_base_t pin)
298299 break ;
299300 }
300301 }
302+
301303 if (i >= irq_quantity )
302304 {
303305 return - RT_ENOSYS ;
@@ -414,6 +416,7 @@ void button_1_callback(void *args)
414416 rt_pin_write (DK_BOARD_LED_1 , PIN_HIGH );
415417 }
416418}
419+
417420void button_2_callback (void * args )
418421{
419422 static int flag2 = 0 ;
@@ -428,6 +431,7 @@ void button_2_callback(void *args)
428431 rt_pin_write (DK_BOARD_LED_2 , PIN_HIGH );
429432 }
430433}
434+
431435void button_3_callback (void * args )
432436{
433437 static int flag3 = 0 ;
@@ -442,6 +446,7 @@ void button_3_callback(void *args)
442446 rt_pin_write (DK_BOARD_LED_3 , PIN_HIGH );
443447 }
444448}
449+
445450void button_4_callback (void * args )
446451{
447452 static int flag4 = 0 ;
@@ -470,21 +475,22 @@ void gpio_sample(void)
470475 rt_pin_write (DK_BOARD_LED_4 , PIN_HIGH );
471476
472477 rt_pin_attach_irq (DK_BOARD_BUTTON_1 , PIN_IRQ_MODE_FALLING ,
473- button_1_callback , (void * ) true); // true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
478+ button_1_callback , (void * ) true); /* true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT) */
474479 rt_pin_irq_enable (DK_BOARD_BUTTON_1 , PIN_IRQ_ENABLE );
475480
476481 rt_pin_attach_irq (DK_BOARD_BUTTON_2 , PIN_IRQ_MODE_FALLING ,
477- button_2_callback , (void * ) true); // true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
482+ button_2_callback , (void * ) true); /* true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT) */
478483 rt_pin_irq_enable (DK_BOARD_BUTTON_2 , PIN_IRQ_ENABLE );
479484
480485 rt_pin_attach_irq (DK_BOARD_BUTTON_3 , PIN_IRQ_MODE_FALLING ,
481- button_3_callback , (void * ) true); // true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
486+ button_3_callback , (void * ) true); /* true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT) */
482487 rt_pin_irq_enable (DK_BOARD_BUTTON_3 , PIN_IRQ_ENABLE );
483488
484489 rt_pin_attach_irq (DK_BOARD_BUTTON_4 , PIN_IRQ_MODE_FALLING ,
485- button_4_callback , (void * ) false); // true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
490+ button_4_callback , (void * ) false); /* true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT) */
486491 rt_pin_irq_enable (DK_BOARD_BUTTON_4 , PIN_IRQ_ENABLE );
487492}
488493MSH_CMD_EXPORT (gpio_sample , gpio sample );
489494
490495#endif /* RT_USING_PIN */
496+
0 commit comments