35 lines
747 B
C++
35 lines
747 B
C++
#include "main.h"
|
|
#include "Can.h"
|
|
#include "initial.h"
|
|
#include "sys/systick.h"
|
|
#include <cstdio>
|
|
extern CAN_transmiter CAN0_transmiter; // CAN初始化
|
|
|
|
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) {
|
|
sys.initHardware();
|
|
sys.run();
|
|
|
|
while (1)
|
|
; // 不应该执行到这里
|
|
} |