drv_exti.c 732 B

123456789101112131415161718192021222324252627282930313233343536
  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. #include "board.h"
  11. #ifdef BSP_USING_EXTI
  12. //#define DRV_DEBUG
  13. #define LOG_TAG "drv.exti"
  14. #include <drv_log.h>
  15. /* defined the KEY2 pin: */
  16. #define KEY2_PIN GET_PIN(A, 13)
  17. void key2_on(void *args)
  18. {
  19. rt_kprintf("press key2!\n");
  20. }
  21. static int exti_sample(void)
  22. {
  23. rt_pin_mode(KEY2_PIN, PIN_MODE_INPUT_PULLUP);
  24. rt_pin_attach_irq(KEY2_PIN, PIN_IRQ_MODE_FALLING, key2_on, RT_NULL);
  25. rt_pin_irq_enable(KEY2_PIN, PIN_IRQ_ENABLE);
  26. return RT_EOK;
  27. }
  28. INIT_DEVICE_EXPORT(exti_sample);
  29. #endif