feat: 保存已验证的CH390网络打通基线

This commit is contained in:
2026-04-17 07:09:55 +08:00
parent 59eecf428f
commit 6aba77df9a
44 changed files with 6428 additions and 3372 deletions
+12 -16
View File
@@ -29,10 +29,8 @@
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include "CH390.h"
#include "config.h"
#include "flash_param.h"
#include "uart_trans.h"
#include "debug_log.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -70,6 +68,7 @@ void MX_FREERTOS_Init(void);
/* USER CODE BEGIN PFP */
static void CH390_HardwareReset(void);
static void LED_Init(void);
void Debug_TrapWithRttHint(const char *tag);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
@@ -129,14 +128,15 @@ int main(void)
HAL_Init();
/* USER CODE BEGIN Init */
debug_log_init();
debug_log_boot("hal-init");
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
debug_log_boot("clock-config");
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
@@ -148,6 +148,7 @@ int main(void)
MX_USART3_UART_Init();
MX_SPI1_Init();
/* USER CODE BEGIN 2 */
debug_log_boot("peripherals-ready");
/* LED 初始化 */
LED_Init();
@@ -157,14 +158,17 @@ int main(void)
/* Initialize configuration from Flash (fallback to defaults on invalid data) */
config_init();
debug_log_boot("config-ready");
/* USER CODE END 2 */
/* Init scheduler */
osKernelInitialize(); /* Call init function for freertos objects (in cmsis_os2.c) */
MX_FREERTOS_Init();
debug_log_boot("freertos-init");
/* Start scheduler */
debug_log_boot("scheduler-start");
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
@@ -225,19 +229,10 @@ void SystemClock_Config(void)
/**
* @brief 重定向 printf 到 UART1(调试输出)
*/
#ifdef __GNUC__
int _write(int file, char *ptr, int len)
void Debug_TrapWithRttHint(const char *tag)
{
HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, HAL_MAX_DELAY);
return len;
debug_log_fault(tag);
}
#else
int fputc(int ch, FILE *f)
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}
#endif
/* USER CODE END 4 */
@@ -249,6 +244,7 @@ void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
debug_log_fault("error-handler");
__disable_irq();
while (1)
{