main.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**************************************************************************//**
  2. * @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-1-16 Wayne First version
  9. *
  10. ******************************************************************************/
  11. #include <rtconfig.h>
  12. #include <rtdevice.h>
  13. #include <drv_gpio.h>
  14. /* defined the LEDR pin: PH4 */
  15. #define LEDR NU_GET_PININDEX(NU_PH, 4)
  16. /* defined the LEDG pin: PH6 */
  17. #define LEDG NU_GET_PININDEX(NU_PH, 6)
  18. int main(int argc, char **argv)
  19. {
  20. #if defined(RT_USING_PIN)
  21. int counter = 0;
  22. /* set pin mode to output */
  23. rt_pin_mode(LEDR, PIN_MODE_OUTPUT);
  24. rt_pin_mode(LEDG, PIN_MODE_OUTPUT);
  25. while (counter++ < 10)
  26. {
  27. rt_pin_write(LEDR, PIN_HIGH);
  28. rt_pin_write(LEDG, PIN_LOW);
  29. rt_thread_mdelay(500);
  30. rt_pin_write(LEDR, PIN_LOW);
  31. rt_pin_write(LEDG, PIN_HIGH);
  32. rt_thread_mdelay(500);
  33. }
  34. #endif
  35. return 0;
  36. }