feat(core): OTA可用版本,添加看门狗功能并优化系统初始化日志
- 添加watchdog组件用于系统监控 - 在system_gd32e50x.c中增加USART0诊断输出,在IRC8M和PLL配置后 发送"APP"和"CLK"标识 - 优化AppSpiCommand类中的日志处理机制,使用临界区保护 - 添加对全0xFF数据包的过滤处理,避免无效命令处理 - 将OTA重启延时从滴答计数改为毫秒级延时,提高响应速度 - 移除温度传感器相关文件,添加看门狗相关文件到项目配置 - 更新FWDGT API调用方式,使用新的配置函数 - 增加详细的启动日志输出,便于调试和追踪初始化过程
This commit is contained in:
@@ -44,6 +44,19 @@ static constexpr uint16_t kRxBufSize = 128U;
|
||||
static constexpr uint16_t kTxBufSize = 64U;
|
||||
static constexpr uint16_t kLogBufSize = 128U;
|
||||
|
||||
static bool isAllBytesValue(const uint8_t *data, uint8_t len, uint8_t value)
|
||||
{
|
||||
if (!data || len == 0U) {
|
||||
return false;
|
||||
}
|
||||
for (uint8_t i = 0U; i < len; ++i) {
|
||||
if (data[i] != value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* 静态成员
|
||||
* ============================================================ */
|
||||
@@ -300,9 +313,19 @@ void AppSpiCommand::processCommand()
|
||||
|
||||
void AppSpiCommand::poll()
|
||||
{
|
||||
char log_copy[kLogBufSize] = {};
|
||||
bool has_log = false;
|
||||
|
||||
__disable_irq();
|
||||
if (s_logPending) {
|
||||
memcpy(log_copy, s_logBuf, sizeof(log_copy));
|
||||
s_logPending = false;
|
||||
printf("%s\r\n", s_logBuf);
|
||||
has_log = true;
|
||||
}
|
||||
__enable_irq();
|
||||
|
||||
if (has_log) {
|
||||
printf("%s\r\n", log_copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,6 +350,10 @@ void AppSpiCommand::onCsRelease()
|
||||
}
|
||||
s_csActive = false;
|
||||
spi_i2s_interrupt_disable(SPI0, SPI_I2S_INT_TBE);
|
||||
if (isAllBytesValue(s_rxBuf, s_rxLen, 0xFFU)) {
|
||||
s_rxLen = 0U;
|
||||
return;
|
||||
}
|
||||
processCommand();
|
||||
}
|
||||
|
||||
@@ -394,4 +421,4 @@ extern "C" void SPI0_IRQHandler(void)
|
||||
extern "C" void EXTI10_15_IRQHandler(void)
|
||||
{
|
||||
AppSpiCommand::onCsExtiInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user