hal_entry.c 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2025 RT-Thread Development Team
  3. * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Change Logs:
  8. * Date Author Notes
  9. * 2025-09-27 hywing first version
  10. *
  11. */
  12. #include <rtthread.h>
  13. #include "hal_data.h"
  14. #ifdef RT_USING_NANO
  15. #include <drv_gpio.h>
  16. #else
  17. #include <rtdevice.h>
  18. #endif /* RT_USING_NANO */
  19. #define LED_PIN BSP_IO_PORT_01_PIN_06 /* Onboard LED pins */
  20. #define USER_BUTTON_PIN "P105"
  21. void on_button_clicked(void *args)
  22. {
  23. rt_kprintf("On Button Clicked\n");
  24. }
  25. void hal_entry(void)
  26. {
  27. rt_kprintf("\nHello RT-Thread!\n");
  28. rt_pin_attach_irq(rt_pin_get(USER_BUTTON_PIN), PIN_IRQ_MODE_RISING, on_button_clicked, RT_NULL);
  29. rt_pin_irq_enable(rt_pin_get(USER_BUTTON_PIN), PIN_IRQ_ENABLE);
  30. while (1)
  31. {
  32. rt_pin_write(LED_PIN, PIN_HIGH);
  33. rt_thread_mdelay(500);
  34. rt_pin_write(LED_PIN, PIN_LOW);
  35. rt_thread_mdelay(500);
  36. }
  37. }