@@ -157,8 +157,10 @@ static bool handle_devMsgOut(uint8_t rhport, void *data, size_t len, size_t pack
157157static uint8_t termChar ;
158158static uint8_t termCharRequested = false;
159159
160- OSAL_MUTEX_DEF (usbtmcLockBuffer );
161- static osal_mutex_t usbtmcLock ;
160+ #if OSAL_MUTEX_REQUIRED
161+ static OSAL_MUTEX_DEF (usbtmcLockBuffer );
162+ #endif
163+ osal_mutex_t usbtmcLock ;
162164
163165// Our own private lock, mostly for the state variable.
164166#define criticalEnter () do { (void) osal_mutex_lock(usbtmcLock,OSAL_TIMEOUT_WAIT_FOREVER); } while (0)
@@ -362,7 +364,7 @@ bool tud_usbtmc_start_bus_read()
362364 case STATE_RCV :
363365 break ;
364366 default :
365- TU_VERIFY ( false) ;
367+ return false;
366368 }
367369 TU_VERIFY (usbd_edpt_xfer (usbtmc_state .rhport , usbtmc_state .ep_bulk_out , usbtmc_state .ep_bulk_out_buf , (uint16_t )usbtmc_state .ep_bulk_out_wMaxPacketSize ));
368370 return true;
@@ -464,61 +466,60 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
464466 switch (usbtmc_state .state )
465467 {
466468 case STATE_IDLE :
467- TU_VERIFY (xferred_bytes >= sizeof (usbtmc_msg_generic_t ));
468- msg = (usbtmc_msg_generic_t * )(usbtmc_state .ep_bulk_out_buf );
469- uint8_t invInvTag = (uint8_t )~(msg -> header .bTagInverse );
470- TU_VERIFY (msg -> header .bTag == invInvTag );
471- TU_VERIFY (msg -> header .bTag != 0x00 );
472-
473- switch (msg -> header .MsgID ) {
474- case USBTMC_MSGID_DEV_DEP_MSG_OUT :
475- if (!handle_devMsgOutStart (rhport , msg , xferred_bytes ))
476- {
477- usbd_edpt_stall (rhport , usbtmc_state .ep_bulk_out );
478- TU_VERIFY (false);
479- }
480- break ;
469+ {
470+ TU_VERIFY (xferred_bytes >= sizeof (usbtmc_msg_generic_t ));
471+ msg = (usbtmc_msg_generic_t * )(usbtmc_state .ep_bulk_out_buf );
472+ uint8_t invInvTag = (uint8_t )~(msg -> header .bTagInverse );
473+ TU_VERIFY (msg -> header .bTag == invInvTag );
474+ TU_VERIFY (msg -> header .bTag != 0x00 );
475+
476+ switch (msg -> header .MsgID ) {
477+ case USBTMC_MSGID_DEV_DEP_MSG_OUT :
478+ if (!handle_devMsgOutStart (rhport , msg , xferred_bytes ))
479+ {
480+ usbd_edpt_stall (rhport , usbtmc_state .ep_bulk_out );
481+ return false;
482+ }
483+ break ;
481484
482- case USBTMC_MSGID_DEV_DEP_MSG_IN :
483- TU_VERIFY (handle_devMsgIn (msg , xferred_bytes ));
484- break ;
485+ case USBTMC_MSGID_DEV_DEP_MSG_IN :
486+ TU_VERIFY (handle_devMsgIn (msg , xferred_bytes ));
487+ break ;
485488
486489#if (CFG_TUD_USBTMC_ENABLE_488 )
487- case USBTMC_MSGID_USB488_TRIGGER :
488- // Spec says we halt the EP if we didn't declare we support it.
489- TU_VERIFY (usbtmc_state .capabilities -> bmIntfcCapabilities488 .supportsTrigger );
490- TU_VERIFY (tud_usbtmc_msg_trigger_cb (msg ));
490+ case USBTMC_MSGID_USB488_TRIGGER :
491+ // Spec says we halt the EP if we didn't declare we support it.
492+ TU_VERIFY (usbtmc_state .capabilities -> bmIntfcCapabilities488 .supportsTrigger );
493+ TU_VERIFY (tud_usbtmc_msg_trigger_cb (msg ));
491494
492- break ;
495+ break ;
493496#endif
494- case USBTMC_MSGID_VENDOR_SPECIFIC_MSG_OUT :
495- case USBTMC_MSGID_VENDOR_SPECIFIC_IN :
496- default :
497- usbd_edpt_stall (rhport , usbtmc_state .ep_bulk_out );
498- TU_VERIFY (false);
499- return false;
497+ case USBTMC_MSGID_VENDOR_SPECIFIC_MSG_OUT :
498+ case USBTMC_MSGID_VENDOR_SPECIFIC_IN :
499+ default :
500+ usbd_edpt_stall (rhport , usbtmc_state .ep_bulk_out );
501+ return false;
502+ }
503+ return true;
500504 }
501- return true;
502-
503505 case STATE_RCV :
504506 if (!handle_devMsgOut (rhport , usbtmc_state .ep_bulk_out_buf , xferred_bytes , xferred_bytes ))
505507 {
506508 usbd_edpt_stall (rhport , usbtmc_state .ep_bulk_out );
507- TU_VERIFY ( false) ;
509+ return false;
508510 }
509511 return true;
510512
511513 case STATE_ABORTING_BULK_OUT :
512- TU_VERIFY (false);
513- return false; // Should be stalled by now, shouldn't have received a packet.
514+ return false;
514515
515516 case STATE_TX_REQUESTED :
516517 case STATE_TX_INITIATED :
517518 case STATE_ABORTING_BULK_IN :
518519 case STATE_ABORTING_BULK_IN_SHORTED :
519520 case STATE_ABORTING_BULK_IN_ABORTED :
520521 default :
521- TU_VERIFY ( false) ;
522+ return false;
522523 }
523524 }
524525 else if (ep_addr == usbtmc_state .ep_bulk_in )
@@ -567,7 +568,6 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
567568
568569 default :
569570 TU_ASSERT (false);
570- return false;
571571 }
572572 }
573573 else if (ep_addr == usbtmc_state .ep_int_in ) {
@@ -871,16 +871,13 @@ bool usbtmcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
871871 case USB488_bREQUEST_LOCAL_LOCKOUT :
872872 {
873873 TU_VERIFY (request -> bmRequestType == 0xA1 ); // in,class,interface
874- TU_VERIFY (false);
875874 return false;
876875 }
877876#endif
878877
879878 default :
880- TU_VERIFY (false);
881879 return false;
882880 }
883- TU_VERIFY (false);
884881}
885882
886883#endif /* CFG_TUD_TSMC */
0 commit comments