添加运行指示灯(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_ */
|
||||
+42
-2
@@ -9,10 +9,11 @@
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "dfs_fs.h"
|
||||
#include <rtdbg.h>
|
||||
#include "RUN_LED.h"
|
||||
|
||||
#include <dbhelper.h>
|
||||
#define DB_NAME "/rt.db"
|
||||
|
||||
#define DBG_TAG "main"
|
||||
@@ -25,8 +26,47 @@ int main(void)
|
||||
{
|
||||
rt_thread_mdelay(100); //等待sd_mount线程挂载文件系统,可使用IPC信号量完成同步,提高实时性
|
||||
|
||||
int db_helper_init(void);
|
||||
thread_RUN_LED();
|
||||
|
||||
//int db_HelperInit;
|
||||
// db_HelperInit = db_helper_init();
|
||||
|
||||
// if(db_HelperInit =RT_EOK){
|
||||
// rt_kprintf("HelperInit database\n");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// int db_helper_init();
|
||||
|
||||
// sqlite3 *db;
|
||||
// int8_t rc;
|
||||
|
||||
// rc = sqlite3_open("rt.db", &db);
|
||||
// if (rc != SQLITE_OK)
|
||||
// {
|
||||
//rt_kprintf("Cannot open database: %s\n", sqlite3_errmsg(db));
|
||||
//return -1;
|
||||
// }else{
|
||||
// rt_kprintf("Database opened successfully\n");
|
||||
// sqlite3_close(db);
|
||||
// }
|
||||
// sqlite3_os_init();
|
||||
//if(int sqlite3_os_init()==RT_EOK){LOG_D("Sqlite int RT_EOK!");}
|
||||
|
||||
|
||||
// sqlite3_os_init();
|
||||
|
||||
/* int rc = db_connect("/rt.db");
|
||||
if (rc <0) {
|
||||
const char *sql = "CREATE TABLE student(id INTEGER PRIMARY KEY AUTOINCREMENT,name varchar(32) NOT NULL,score INT NOT NULL);";
|
||||
int db_create_database(sql);
|
||||
}*/
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ int stm32_sdcard_mount(void)
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
|
||||
2048, RT_THREAD_PRIORITY_MAX - 2, 20);
|
||||
1024*4, RT_THREAD_PRIORITY_MAX - 2, 20);
|
||||
if (tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(tid);
|
||||
|
||||
Reference in new issue
Block a user