main.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2006-2024, 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. * 2019-10-24 Magicoe first version
  10. * 2020-01-10 Kevin/Karl Add PS demo
  11. * 2020-09-21 supperthomas fix the main.c
  12. *
  13. */
  14. #include <rtdevice.h>
  15. #include <rtthread.h>
  16. #include "drv_pin.h"
  17. #define LED_PIN ((2 * 32) + 13) /* PTC13, RGB LED RED */
  18. #define BTN_PIN ((2 * 32) + 10) /* PTC10, SW3 (User) */
  19. static rt_bool_t s_led_state = RT_FALSE; /* Current LED state */
  20. static void app_btn_irq_callback(void *args)
  21. {
  22. RT_UNUSED(args);
  23. rt_kprintf("SW3 pressed\n");
  24. }
  25. int main(void)
  26. {
  27. rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
  28. rt_pin_write(LED_PIN, PIN_LOW);
  29. rt_pin_mode(BTN_PIN, PIN_MODE_INPUT_PULLUP);
  30. rt_pin_attach_irq(BTN_PIN, PIN_IRQ_MODE_FALLING, app_btn_irq_callback, RT_NULL);
  31. rt_pin_irq_enable(BTN_PIN, PIN_IRQ_ENABLE);
  32. #if defined(__CC_ARM)
  33. rt_kprintf("using armcc, version: %d\n", __ARMCC_VERSION);
  34. #elif defined(__clang__)
  35. rt_kprintf("using armclang, version: %d\n", __ARMCC_VERSION);
  36. #elif defined(__ICCARM__)
  37. rt_kprintf("using iccarm, version: %d\n", __VER__);
  38. #elif defined(__GNUC__)
  39. rt_kprintf("using gcc, version: %d.%d\n", __GNUC__, __GNUC_MINOR__);
  40. #endif
  41. rt_kprintf("NXP MCXE247\r\n");
  42. while (1)
  43. {
  44. /* Toggle LED state */
  45. s_led_state = !s_led_state;
  46. rt_pin_write(LED_PIN, s_led_state ? PIN_HIGH : PIN_LOW);
  47. rt_thread_mdelay(500); /* Delay 500mS */
  48. }
  49. }
  50. // end file