main.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 Email Notes
  8. * 2022-04-16 Kevin.Liu kevin.liu.mchp@gmail.com First Release
  9. */
  10. #include <rtthread.h>
  11. #ifdef RT_USING_FINSH
  12. #include <finsh.h>
  13. #include <shell.h>
  14. #endif
  15. #include "atmel_start.h"
  16. #include <hal_gpio.h>
  17. #ifdef SAM_CAN_EXAMPLE
  18. #include "can_demo.h"
  19. #endif
  20. #ifdef SAM_I2C_EXAMPLE
  21. #include "i2c_demo.h"
  22. #endif
  23. #ifdef SAM_ADC_EXAMPLE
  24. #include "adc_demo.h"
  25. #endif
  26. #ifdef SAM_LWIP_EXAMPLE
  27. #include "lwip_demo.h"
  28. #endif
  29. static rt_uint8_t led_stack[ 512 ];
  30. static struct rt_thread led_thread;
  31. static void led_thread_entry(void* parameter)
  32. {
  33. unsigned int count=0;
  34. while (1)
  35. {
  36. /* toggle led */
  37. #ifndef RT_USING_FINSH
  38. rt_kprintf("led toggle, count : %d\r\n",count);
  39. #endif
  40. count++;
  41. gpio_toggle_pin_level(LED0);
  42. rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
  43. }
  44. }
  45. int main(void)
  46. {
  47. rt_err_t result;
  48. /* initialize led thread */
  49. result = rt_thread_init(&led_thread,
  50. "led",
  51. led_thread_entry,
  52. RT_NULL,
  53. (rt_uint8_t*)&led_stack[0],
  54. sizeof(led_stack),
  55. RT_THREAD_PRIORITY_MAX/3,
  56. 5);
  57. if (result == RT_EOK)
  58. {
  59. rt_thread_startup(&led_thread);
  60. }
  61. #ifdef SAM_CAN_EXAMPLE
  62. can_demo_run();
  63. #endif
  64. #ifdef SAM_I2C_EXAMPLE
  65. i2c_demo_run();
  66. #endif
  67. #ifdef SAM_ADC_EXAMPLE
  68. adc_demo_run();
  69. #endif
  70. #ifdef SAM_LWIP_EXAMPLE
  71. lwip_demo_run();
  72. #endif
  73. return 0;
  74. }
  75. /*@}*/