基础响应功能的实现
This commit is contained in:
+23
-31
@@ -1,40 +1,32 @@
|
||||
#include "main.h"
|
||||
#include "Can.h"
|
||||
#include "gd32c10x.h"
|
||||
#include "gd32c10x_can.h"
|
||||
#include "sys/OTA.h"
|
||||
#include "sys/config.h"
|
||||
#include "initial.h"
|
||||
#include "sys/systick.h"
|
||||
#include <cstdio>
|
||||
extern CAN_transmiter CAN0_transmiter; // CAN初始化
|
||||
|
||||
class BootloaderSystem {
|
||||
private:
|
||||
OTAHandler ota;
|
||||
|
||||
public:
|
||||
void initHardware() {
|
||||
extern CAN_transmiter CAN0_transmiter; // CAN初始化
|
||||
systick_config(); // 系统时钟初始化
|
||||
SystemCoreClockUpdate(); // 更新系统时钟变量
|
||||
CAN0_transmiter.init();
|
||||
}
|
||||
|
||||
void run() {
|
||||
// 检查是否触发OTA模式
|
||||
if (1) {
|
||||
// OTA模式
|
||||
while (1) {
|
||||
ota.process();
|
||||
for (volatile int i = 0; i < 500000; i++)
|
||||
; // 简单延时
|
||||
}
|
||||
} else {
|
||||
// 正常模式:跳转到APP
|
||||
ota.jumpToApplication();
|
||||
BootloaderSystem sys;
|
||||
extern OTAHandler ota;
|
||||
void BootloaderSystem::initHardware() {
|
||||
systick_config(); // 系统时钟初始化
|
||||
SystemCoreClockUpdate(); // 更新系统时钟变量
|
||||
USART0_init(); // 调试串口初始化
|
||||
CAN0_transmiter.init();
|
||||
}
|
||||
void BootloaderSystem::run() {
|
||||
// 检查是否触发OTA模式
|
||||
if (1) {
|
||||
// OTA模式
|
||||
while (1) {
|
||||
CAN0_transmiter.communication_check();
|
||||
ota.process();
|
||||
}
|
||||
} else {
|
||||
// 正常模式:跳转到APP
|
||||
ota.jumpToApplication();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
int main(void) {
|
||||
BootloaderSystem sys;
|
||||
sys.initHardware();
|
||||
sys.run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user