取消全局变量通知更新固件,改为osThreadFlagsWait

This commit is contained in:
不吃油炸鸡
2026-03-25 16:00:47 +08:00
parent 58b3446ef5
commit 26b6bded24
4 changed files with 33 additions and 29 deletions

View File

@@ -23,14 +23,8 @@
/* USER CODE BEGIN INCLUDE */
/* 全局标志位,供 main.c 检测跳转 */
volatile bool g_update_req = false;
bool get_update_request(void) {
return g_update_req;
}
void set_update_request(bool req) {
g_update_req = req;
}
#include "user_TasksInit.h"
/* USER CODE END INCLUDE */
/* Private typedef -----------------------------------------------------------*/
@@ -276,7 +270,9 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
Buf[*Len] = 0; // 截断
if (strstr((char*)Buf, "update") != NULL) {
set_update_request(true); // 置位,主循环看到后执行 JumpToBootloader
if (MessageReceiveTaskHandle != NULL) {
osThreadFlagsSet(MessageReceiveTaskHandle, FLAG_USB_UPDATE_REQ);
}
}
Buf[*Len] = temp_char; // 恢复 (虽然这里可能不需要)

View File

@@ -109,8 +109,7 @@ extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
void set_update_request(bool req);
bool get_update_request(void);
/* USER CODE END EXPORTED_FUNCTIONS */
/**