添加运行指示灯(pc13)线程run_led
This commit is contained in:
1 parent
a4c17b36b4
commit
fd05dbf01b
9 files changed
+191
-16
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include"drv_common.h"
|
||||
|
||||
#define LED_PIN GET_PIN(C,13)
|
||||
|
||||
/* 线程 1 的入口函数 */
|
||||
void RUN_LED(void *parameter)
|
||||
{
|
||||
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
|
||||
while (1)
|
||||
{
|
||||
rt_pin_write(LED_PIN, PIN_HIGH);
|
||||
rt_thread_mdelay(500);
|
||||
rt_pin_write(LED_PIN, PIN_LOW);
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
}
|
||||
|
||||
/* 线程示例 */
|
||||
void thread_RUN_LED(void)
|
||||
{
|
||||
/* 初始化线程 1,名称是 thread1,入口是 thread1_entry*/
|
||||
rt_thread_t tid;
|
||||
tid = rt_thread_create("led", RUN_LED, RT_NULL, 512, 3, 10);
|
||||
|
||||
if (tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Failed to create led thread!\n");
|
||||
}
|
||||
// return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-10-19 Administrator the first version
|
||||
*/
|
||||
#ifndef APPLICATIONS_RUN_LED_RUN_LED_H_
|
||||
#define APPLICATIONS_RUN_LED_RUN_LED_H_
|
||||
|
||||
void thread_RUN_LED(void);
|
||||
|
||||
#endif /* APPLICATIONS_RUN_LED_RUN_LED_H_ */
|
||||
Reference in new issue
Block a user