first commit
This commit is contained in:
47
Src/CanProtocol.cpp
Normal file
47
Src/CanProtocol.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "CanProtocol.h"
|
||||
#include "System.h"
|
||||
|
||||
// 一个任务函数,C 风格
|
||||
void Task1(void* param) {
|
||||
while (true) {
|
||||
std::cout << "Task1 running\n";
|
||||
vTaskDelay(1000); // 延时 1000ms
|
||||
}
|
||||
}
|
||||
|
||||
// 另一个任务函数
|
||||
void Task2(void* param) {
|
||||
while (true) {
|
||||
std::cout << "Task2 running\n";
|
||||
vTaskDelay(500); // 延时 500ms
|
||||
}
|
||||
}
|
||||
|
||||
void CanRecive(void)
|
||||
{
|
||||
// 创建“任务”,用 std::thread 代替 FreeRTOS 任务
|
||||
std::thread t1(Task1, nullptr);
|
||||
std::thread t2(Task2, nullptr);
|
||||
|
||||
// 如果想模拟 FreeRTOS,通常任务一直运行,主函数也可以阻塞
|
||||
t1.join();
|
||||
t2.join();
|
||||
}
|
||||
|
||||
//打开CAN盒子,同时如果有初始化,这里也会初始化
|
||||
uint8_t CanOpen(uint8_t Product, int DeviceType, int Chnl, int Baud, int OtherTyp1, int OtherType2)
|
||||
{
|
||||
switch (Product)
|
||||
{
|
||||
case SC_HHS:
|
||||
break;
|
||||
case ZLG:
|
||||
break;
|
||||
case GC:
|
||||
break;
|
||||
case PEAK_CAN:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user