1
0
Fork 0

Master mode remains active

It remains active even if the USB link is suspended or otherwise
temporarilly goes down.
This commit is contained in:
Fred Sundvik 2016-03-13 21:38:51 +02:00
parent f7275f0ede
commit 59657355d2

View file

@ -88,11 +88,13 @@ static THD_FUNCTION(serialThread, arg) {
EVENT_MASK(2), EVENT_MASK(2),
CHN_INPUT_AVAILABLE); CHN_INPUT_AVAILABLE);
bool need_wait = false; bool need_wait = false;
bool is_master = false;
while(true) { while(true) {
if (need_wait) { if (need_wait) {
chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000)); chEvtWaitAnyTimeout(ALL_EVENTS, MS2ST(1000));
} }
bool is_master = usbGetDriverStateI(&USBD1) == USB_ACTIVE; // Always stay as master, even if the USB goes into sleep mode
is_master |= usbGetDriverStateI(&USBD1) == USB_ACTIVE;
router_set_master(is_master); router_set_master(is_master);
need_wait = true; need_wait = true;