support restart multiple ports at once, support execute log return
parent
b71014583e
commit
7df0667bde
|
@ -57,7 +57,7 @@
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Variables */
|
/* USER CODE BEGIN Variables */
|
||||||
extern uint8_t port_restart;
|
extern uint8_t port_restart;
|
||||||
extern bool flag_restart;
|
extern uint8_t number_restart;
|
||||||
//Timer
|
//Timer
|
||||||
osTimerId_t PwrBtnLongPressTimerHandle;
|
osTimerId_t PwrBtnLongPressTimerHandle;
|
||||||
const osTimerAttr_t PwrBtnLongPressTimer_attributes = {
|
const osTimerAttr_t PwrBtnLongPressTimer_attributes = {
|
||||||
|
@ -661,16 +661,38 @@ void StartEventDetect(void *argument)
|
||||||
/* USER CODE BEGIN Application */
|
/* USER CODE BEGIN Application */
|
||||||
|
|
||||||
void StartCdcMonitorTask(void *argument){
|
void StartCdcMonitorTask(void *argument){
|
||||||
|
uint8_t port_restart_temp[64]={0};
|
||||||
|
uint32_t number_restart_temp =0;
|
||||||
|
bool beep_flag = false;
|
||||||
for(;;){
|
for(;;){
|
||||||
if(flag_restart && port_restart<12){
|
if(number_restart){
|
||||||
flag_restart = false;
|
number_restart_temp = number_restart;
|
||||||
uint8_t port_restart_temp = port_restart;
|
memcpy(port_restart_temp,&port_restart,number_restart_temp<=12 ? number_restart_temp : 12);
|
||||||
Log(info,sys,"Port%d restart",port_restart_temp);
|
number_restart = 0;
|
||||||
PWR_Enable(port_restart_temp, false,400);
|
// turn off usb port device
|
||||||
TaskBeep(50,1);
|
for(uint8_t i=0;i<number_restart_temp;i++){
|
||||||
PWR_Enable(port_restart_temp, true,0);
|
if(port_restart_temp[i]<12){
|
||||||
|
PWR_Enable(port_restart_temp[i], false,200);
|
||||||
|
Log(info,sys,"USB Port%d power off",port_restart_temp[i]);
|
||||||
|
CDC_Transmit_FS(&port_restart_temp[i],1);
|
||||||
}
|
}
|
||||||
osDelay(200);
|
}
|
||||||
|
//turn on usb port device
|
||||||
|
beep_flag = false;
|
||||||
|
for(uint8_t i=0;i<number_restart_temp;i++){
|
||||||
|
if(port_restart_temp[i]<12){
|
||||||
|
PWR_Enable(port_restart_temp[i], true,200);
|
||||||
|
Log(info,sys,"USB Port%d power on",port_restart_temp[i]);
|
||||||
|
CDC_Transmit_FS(&port_restart_temp[i],1);
|
||||||
|
beep_flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(beep_flag){
|
||||||
|
beep_flag = false;
|
||||||
|
TaskBeep(50, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
osDelay(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void StartLogtoUartTask(void *argument){
|
void StartLogtoUartTask(void *argument){
|
||||||
|
|
|
@ -68,5 +68,6 @@
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="reserved-for-future-use"/> "/>
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|
|
@ -100,8 +100,8 @@ uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
|
||||||
|
|
||||||
/* USER CODE BEGIN PRIVATE_VARIABLES */
|
/* USER CODE BEGIN PRIVATE_VARIABLES */
|
||||||
|
|
||||||
extern uint8_t port_restart = 0;
|
extern uint8_t port_restart[64] = {0};
|
||||||
extern bool flag_restart = false;
|
extern uint32_t number_restart = 0;
|
||||||
/* USER CODE END PRIVATE_VARIABLES */
|
/* 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_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
|
||||||
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
|
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
|
||||||
|
|
||||||
port_restart = Buf[0];
|
memcpy(port_restart,Buf,*Len<=64 ? *Len : 64);
|
||||||
flag_restart = true;
|
number_restart = *Len<=64 ? *Len : 64;
|
||||||
|
|
||||||
Log(info,sys,"cdc receive %d",port_restart);
|
|
||||||
return (USBD_OK);
|
return (USBD_OK);
|
||||||
/* USER CODE END 6 */
|
/* USER CODE END 6 */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue