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