main.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 LEDB_PIN ((0*32)+10)
  18. #define BUTTON_PIN ((0*32)+23)
  19. static void sw_pin_cb(void *args);
  20. int main(void)
  21. {
  22. #if defined(__CC_ARM)
  23. rt_kprintf("using armcc, version: %d\n", __ARMCC_VERSION);
  24. #elif defined(__clang__)
  25. rt_kprintf("using armclang, version: %d\n", __ARMCC_VERSION);
  26. #elif defined(__ICCARM__)
  27. rt_kprintf("using iccarm, version: %d\n", __VER__);
  28. #elif defined(__GNUC__)
  29. rt_kprintf("using gcc, version: %d.%d\n", __GNUC__, __GNUC_MINOR__);
  30. #endif
  31. rt_pin_mode(LEDB_PIN, PIN_MODE_OUTPUT); /* Set GPIO as Output */
  32. rt_pin_mode(BUTTON_PIN, PIN_MODE_INPUT_PULLUP);
  33. rt_pin_attach_irq(BUTTON_PIN, PIN_IRQ_MODE_FALLING, sw_pin_cb, RT_NULL);
  34. rt_pin_irq_enable(BUTTON_PIN, 1);
  35. rt_kprintf("MCXN947 HelloWorld\r\n");
  36. #ifdef RT_USING_SDIO
  37. rt_thread_mdelay(2000);
  38. if (dfs_mount("sd", "/", "elm", 0, NULL) == 0)
  39. {
  40. rt_kprintf("sd mounted to /\n");
  41. }
  42. else
  43. {
  44. rt_kprintf("sd mount to / failed\n");
  45. }
  46. #endif
  47. while (1)
  48. {
  49. rt_pin_write(LEDB_PIN, PIN_HIGH); /* Set GPIO output 1 */
  50. rt_thread_mdelay(500); /* Delay 500mS */
  51. rt_pin_write(LEDB_PIN, PIN_LOW); /* Set GPIO output 0 */
  52. rt_thread_mdelay(500); /* Delay 500mS */
  53. }
  54. }
  55. static void sw_pin_cb(void *args)
  56. {
  57. rt_kprintf("sw pressed\r\n");
  58. }
  59. // end file