소스 검색

Master mode remains active

It remains active even if the USB link is suspended or otherwise
temporarilly goes down.
Fred Sundvik 9 년 전
부모
커밋
59657355d2
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      serial_link/system/system.c

+ 3 - 1
serial_link/system/system.c

@@ -88,11 +88,13 @@ static THD_FUNCTION(serialThread, arg) {
         EVENT_MASK(2),
         CHN_INPUT_AVAILABLE);
     bool need_wait = false;
+    bool is_master = false;
     while(true) {
         if (need_wait) {
             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);
 
         need_wait = true;