1
0

main.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. static rt_uint8_t led_stack[ 512 ];
  27. static struct rt_thread led_thread;
  28. static void led_thread_entry(void* parameter)
  29. {
  30. unsigned int count=0;
  31. while (1)
  32. {
  33. /* toggle led */
  34. #ifndef RT_USING_FINSH
  35. rt_kprintf("led toggle, count : %d\r\n",count);
  36. #endif
  37. count++;
  38. gpio_toggle_pin_level(LED0);
  39. rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
  40. }
  41. }
  42. int main(void)
  43. {
  44. rt_err_t result;
  45. /* initialize led thread */
  46. result = rt_thread_init(&led_thread,
  47. "led",
  48. led_thread_entry,
  49. RT_NULL,
  50. (rt_uint8_t*)&led_stack[0],
  51. sizeof(led_stack),
  52. RT_THREAD_PRIORITY_MAX/3,
  53. 5);
  54. if (result == RT_EOK)
  55. {
  56. rt_thread_startup(&led_thread);
  57. }
  58. #ifdef SAM_CAN_EXAMPLE
  59. can_demo_run();
  60. #endif
  61. #ifdef SAM_I2C_EXAMPLE
  62. i2c_demo_run();
  63. #endif
  64. #ifdef SAM_ADC_EXAMPLE
  65. adc_demo_run();
  66. #endif
  67. return 0;
  68. }
  69. /*@}*/