拿到板子的第一件事情当然是点灯喽
1.先按照官方的开发指南安装下载工具
https://docs.qq.com/doc/DTVVWWXpLRVl6cER2
2.打开rtthred studio创建项目
3.新建一个文件夹用来存放自己的应用(个人喜好),创建led.c,led.h。
4.在头文件里包含board.h,在.c文件中创建跑马灯线程
led的引脚可以通过原理图查到 板子上也有写
- #include "LED.h"
- #define LED_red GET_PIN(E, 1)
- #define LED_green GET_PIN(E, 4)
- #define LED_blue GET_PIN(A, 1)
- void led_entry(void *parameter)
- {
- while(1)
- {
- rt_pin_write(LED_red, PIN_LOW);
- rt_pin_write(LED_green, PIN_HIGH);
- rt_pin_write(LED_blue, PIN_HIGH);
- rt_thread_mdelay(500);
- rt_pin_write(LED_red, PIN_HIGH);
- rt_pin_write(LED_green, PIN_LOW);
- rt_pin_write(LED_blue, PIN_HIGH);
- rt_thread_mdelay(500);
- rt_pin_write(LED_red, PIN_HIGH);
- rt_pin_write(LED_green, PIN_HIGH);
- rt_pin_write(LED_blue, PIN_LOW);
- rt_thread_mdelay(500);
- }
- }
- rt_thread_t led_thread;
- int led_init(void)
- {
- rt_pin_mode(LED_red, PIN_MODE_OUTPUT);
- rt_pin_mode(LED_green, PIN_MODE_OUTPUT);
- rt_pin_mode(LED_blue, PIN_MODE_OUTPUT);
- //创建led线程
- led_thread = rt_thread_create("led_thread", led_entry, RT_NULL, 512, 24, 10);
- //启动led线程
- if(RT_NULL != led_thread)
- {
- rt_thread_startup(led_thread);
- }
- return 0;
- }
5.最后 包含一下led的头文件 在主函数里调用初始化函数 三色交替的跑马灯就完成了