Fix mouse_send() on chibiOS so it won't lock up the firmware
This commit is contained in:
		
							parent
							
								
									b11a776cef
								
							
						
					
					
						commit
						b1bf0879ad
					
				
					 1 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -715,15 +715,16 @@ void send_mouse(report_mouse_t *report) {
 | 
			
		|||
    osalSysUnlock();
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  osalSysUnlock();
 | 
			
		||||
 | 
			
		||||
  osalSysLock();
 | 
			
		||||
  if(usbGetTransmitStatusI(&USB_DRIVER, MOUSE_IN_EPNUM)) {
 | 
			
		||||
    /* Need to either suspend, or loop and call unlock/lock during
 | 
			
		||||
     * every iteration - otherwise the system will remain locked,
 | 
			
		||||
     * no interrupts served, so USB not going through as well.
 | 
			
		||||
     * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
 | 
			
		||||
    osalThreadSuspendS(&(&USB_DRIVER)->epc[MOUSE_IN_EPNUM]->in_state->thread);
 | 
			
		||||
    if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[MOUSE_IN_EPNUM]->in_state->thread, MS2ST(10)==MSG_TIMEOUT)) {
 | 
			
		||||
      osalSysUnlock();
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t));
 | 
			
		||||
  osalSysUnlock();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue