43 lines
806 B
C++
43 lines
806 B
C++
#include "Can.h"
|
|
#include "gd32c10x.h"
|
|
#include "gd32c10x_can.h"
|
|
#include "sys/OTA.h"
|
|
#include "sys/config.h"
|
|
#include "sys/systick.h"
|
|
|
|
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();
|
|
}
|
|
}
|
|
};
|
|
|
|
int main(void) {
|
|
BootloaderSystem sys;
|
|
sys.initHardware();
|
|
sys.run();
|
|
|
|
while (1)
|
|
; // 不应该执行到这里
|
|
} |