1
0

application.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. * 2011-05-23 aozima first implementation for PIC32.
  9. */
  10. // Adds support for PIC32 Peripheral library functions and macros
  11. #include <plib.h>
  12. #include <rtthread.h>
  13. ALIGN(RT_ALIGN_SIZE)
  14. int thread_led1_stack[512];
  15. struct rt_thread thread_led1;
  16. void thread_led1_entry(void* parameter)
  17. {
  18. // configure PORTD.RD1 = output
  19. mPORTDSetPinsDigitalOut(BIT_1);
  20. while(1)
  21. {
  22. // .. Toggle the LED
  23. mPORTDToggleBits(BIT_1);
  24. rt_thread_delay( RT_TICK_PER_SECOND ); /* delay 1s */
  25. }
  26. }
  27. static void thread_led2_entry(void* parameter)
  28. {
  29. // configure PORTD.RD2 = output
  30. mPORTDSetPinsDigitalOut(BIT_2);
  31. while (1)
  32. {
  33. // .. Toggle the LED
  34. mPORTDToggleBits(BIT_2);
  35. rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* delay 0.5s */
  36. }
  37. }
  38. int rt_application_init(void)
  39. {
  40. rt_thread_t thread;
  41. rt_thread_init(&thread_led1,
  42. "led1",
  43. thread_led1_entry, RT_NULL,
  44. &thread_led1_stack[0], sizeof(thread_led1_stack),
  45. 20, 10);
  46. rt_thread_startup(&thread_led1);
  47. /* create led2 thread */
  48. thread = rt_thread_create("led2",
  49. thread_led2_entry, RT_NULL,
  50. 1024,
  51. 20, 5);
  52. if (thread != RT_NULL)
  53. rt_thread_startup(thread);
  54. return 0;
  55. }