From 7df0667bde1fe68cb1fe5a82b9027c82ce4d9edc Mon Sep 17 00:00:00 2001 From: ThinkPad-T460P Date: Sun, 7 Feb 2021 11:11:26 +0800 Subject: [PATCH] support restart multiple ports at once, support execute log return --- Core/Src/freertos.c | 40 ++++++++++++++++++++++++------- NaviKit_EC_stm32 Debug (1).launch | 1 + USB_DEVICE/App/usbd_cdc_if.c | 9 ++++--- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 4263f2a..c5afc57 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -57,7 +57,7 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN Variables */ extern uint8_t port_restart; -extern bool flag_restart; +extern uint8_t number_restart; //Timer osTimerId_t PwrBtnLongPressTimerHandle; const osTimerAttr_t PwrBtnLongPressTimer_attributes = { @@ -661,16 +661,38 @@ void StartEventDetect(void *argument) /* USER CODE BEGIN Application */ void StartCdcMonitorTask(void *argument){ + uint8_t port_restart_temp[64]={0}; + uint32_t number_restart_temp =0; + bool beep_flag = false; for(;;){ - if(flag_restart && port_restart<12){ - flag_restart = false; - uint8_t port_restart_temp = port_restart; - Log(info,sys,"Port%d restart",port_restart_temp); - PWR_Enable(port_restart_temp, false,400); - TaskBeep(50,1); - PWR_Enable(port_restart_temp, true,0); + if(number_restart){ + number_restart_temp = number_restart; + memcpy(port_restart_temp,&port_restart,number_restart_temp<=12 ? number_restart_temp : 12); + number_restart = 0; + // turn off usb port device + for(uint8_t i=0;i + diff --git a/USB_DEVICE/App/usbd_cdc_if.c b/USB_DEVICE/App/usbd_cdc_if.c index 5cf4df0..85639b2 100644 --- a/USB_DEVICE/App/usbd_cdc_if.c +++ b/USB_DEVICE/App/usbd_cdc_if.c @@ -100,8 +100,8 @@ uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; /* USER CODE BEGIN PRIVATE_VARIABLES */ -extern uint8_t port_restart = 0; -extern bool flag_restart = false; +extern uint8_t port_restart[64] = {0}; +extern uint32_t number_restart = 0; /* USER CODE END PRIVATE_VARIABLES */ /** @@ -269,10 +269,9 @@ static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); USBD_CDC_ReceivePacket(&hUsbDeviceFS); - port_restart = Buf[0]; - flag_restart = true; + memcpy(port_restart,Buf,*Len<=64 ? *Len : 64); + number_restart = *Len<=64 ? *Len : 64; - Log(info,sys,"cdc receive %d",port_restart); return (USBD_OK); /* USER CODE END 6 */ }