hal_entry.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. * 2021-10-10 Sherman first version
  9. * 2021-11-03 Sherman Add icu_sample
  10. */
  11. #include <rtthread.h>
  12. #include "hal_data.h"
  13. #ifdef RT_USING_NANO
  14. #include <drv_gpio.h>
  15. #else
  16. #include <rtdevice.h>
  17. #endif /* RT_USING_NANO */
  18. #define LED3_PIN BSP_IO_PORT_01_PIN_06
  19. #define USER_INPUT "P105"
  20. void hal_entry(void)
  21. {
  22. rt_kprintf("\nHello RT-Thread!\n");
  23. while (1)
  24. {
  25. rt_pin_write(LED3_PIN, PIN_HIGH);
  26. rt_thread_mdelay(500);
  27. rt_pin_write(LED3_PIN, PIN_LOW);
  28. rt_thread_mdelay(500);
  29. }
  30. }
  31. #ifndef RT_USING_NANO
  32. void irq_callback_test(void *args)
  33. {
  34. rt_kprintf("\n IRQ00 triggered \n");
  35. }
  36. void icu_sample(void)
  37. {
  38. /* init */
  39. rt_uint32_t pin = rt_pin_get(USER_INPUT);
  40. rt_kprintf("\n pin number : 0x%04X \n", pin);
  41. rt_err_t err = rt_pin_attach_irq(pin, PIN_IRQ_MODE_RISING, irq_callback_test, RT_NULL);
  42. if(RT_EOK != err)
  43. {
  44. rt_kprintf("\n attach irq failed. \n");
  45. }
  46. err = rt_pin_irq_enable(pin, PIN_IRQ_ENABLE);
  47. if(RT_EOK != err)
  48. {
  49. rt_kprintf("\n enable irq failed. \n");
  50. }
  51. }
  52. MSH_CMD_EXPORT(icu_sample, icu sample);
  53. #endif