RTT的两种方案:
一. 使用RTThread studio+stm32 CubeMx编写程序(Studio是基于芯片创建工程)
二. 使用env 工具配合keil5 编程
我正在学习,目前觉得第一种方案比较好,至于原因会在后面的连载中详述。
本期首先介绍一下如何建立工程:
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
/* defined the LED0 pin: PB1 */
#define LED0_PIN GET_PIN(B, 1)
int main(void)
{
int count = 1;
/* set LED0 pin mode to output */
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
while (count++)
{
rt_pin_write(LED0_PIN, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(LED0_PIN, PIN_LOW);
rt_thread_mdelay(500);
}
return RT_EOK;
}
新建的默认工程为频率为1hz的led灯闪烁。
在有新功能可添加到applications文件夹中。同时可使用ST官方软件STM