application.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-03-30 Kyle First version
  9. * 2023-10-25 Raman Gopalan AT32UC3A: Access GPIO using RT's pin abstractions
  10. */
  11. #include <rtthread.h>
  12. #include <rtdevice.h>
  13. #include "compiler.h"
  14. #include "gpio.h"
  15. /* Mizar32's built-in LED */
  16. #define USER_LED_1 AVR32_PIN_PB29
  17. char thread_led1_stack[1024];
  18. struct rt_thread thread_led1;
  19. static void rt_thread_entry_led1(void* parameter)
  20. {
  21. rt_pin_mode(USER_LED_1, PIN_MODE_OUTPUT);
  22. while (1)
  23. {
  24. rt_pin_write(USER_LED_1, 1);
  25. rt_thread_delay(RT_TICK_PER_SECOND / 2); /* sleep 0.5 second and switch to other thread */
  26. rt_pin_write(USER_LED_1, 0);
  27. rt_thread_delay(RT_TICK_PER_SECOND / 2);
  28. }
  29. }
  30. int rt_application_init()
  31. {
  32. /* create led1 thread */
  33. rt_thread_init(&thread_led1,
  34. "led1",
  35. rt_thread_entry_led1,
  36. RT_NULL,
  37. &thread_led1_stack[0],
  38. sizeof(thread_led1_stack), 5, 5);
  39. rt_thread_startup(&thread_led1);
  40. return 0;
  41. }