Skip to content

Commit

Permalink
Fix issue with USB CDC at reboot (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Apr 26, 2024
1 parent b35658b commit 8e22859
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions ChibiOS/NESHTEC_NESHNODE_V1/nanoCLR/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ osThreadDef(CLRStartupThread, osPriorityNormal, 4096, "CLRStartupThread");
// Application entry point.
int main(void)
{
// find out wakeup reason
// find out wakeup reason
if ((PWR->CSR1 & PWR_CSR1_WUIF) == PWR_CSR1_WUIF)
{
// standby, match WakeupReason_FromStandby enum
Expand Down Expand Up @@ -74,17 +74,6 @@ int main(void)
crcStart(NULL);
#endif

// Initializes a serial-over-USB CDC driver.
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg);

// Activates the USB driver and then the USB bus pull-up on D+.
// Note, a delay is inserted in order to not have to disconnect the cable after a reset
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(100);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);

// create the receiver thread
osThreadCreate(osThread(ReceiverThread), NULL);

Expand All @@ -108,3 +97,17 @@ int main(void)
osDelay(100);
}
}

void WP_Message_PrepareReception_Target()
{
// Initializes a serial-over-USB CDC driver.
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg);

// Activates the USB driver and then the USB bus pull-up on D+.
// Note, a delay is inserted in order to not have to disconnect the cable after a reset
usbDisconnectBus(serusbcfg.usbp);
chThdSleepMilliseconds(100);
usbStart(serusbcfg.usbp, &usbcfg);
usbConnectBus(serusbcfg.usbp);
}

0 comments on commit 8e22859

Please sign in to comment.