@@ -157,8 +157,10 @@ static bool handle_devMsgOut(uint8_t rhport, void *data, size_t len, size_t pack
157
157
static uint8_t termChar ;
158
158
static uint8_t termCharRequested = false;
159
159
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 ;
162
164
163
165
// Our own private lock, mostly for the state variable.
164
166
#define criticalEnter () do { (void) osal_mutex_lock(usbtmcLock,OSAL_TIMEOUT_WAIT_FOREVER); } while (0)
@@ -362,7 +364,7 @@ bool tud_usbtmc_start_bus_read()
362
364
case STATE_RCV :
363
365
break ;
364
366
default :
365
- TU_VERIFY ( false) ;
367
+ return false;
366
368
}
367
369
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 ));
368
370
return true;
@@ -464,61 +466,60 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
464
466
switch (usbtmc_state .state )
465
467
{
466
468
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 ;
481
484
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 ;
485
488
486
489
#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 ));
491
494
492
- break ;
495
+ break ;
493
496
#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;
500
504
}
501
- return true;
502
-
503
505
case STATE_RCV :
504
506
if (!handle_devMsgOut (rhport , usbtmc_state .ep_bulk_out_buf , xferred_bytes , xferred_bytes ))
505
507
{
506
508
usbd_edpt_stall (rhport , usbtmc_state .ep_bulk_out );
507
- TU_VERIFY ( false) ;
509
+ return false;
508
510
}
509
511
return true;
510
512
511
513
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;
514
515
515
516
case STATE_TX_REQUESTED :
516
517
case STATE_TX_INITIATED :
517
518
case STATE_ABORTING_BULK_IN :
518
519
case STATE_ABORTING_BULK_IN_SHORTED :
519
520
case STATE_ABORTING_BULK_IN_ABORTED :
520
521
default :
521
- TU_VERIFY ( false) ;
522
+ return false;
522
523
}
523
524
}
524
525
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
567
568
568
569
default :
569
570
TU_ASSERT (false);
570
- return false;
571
571
}
572
572
}
573
573
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
871
871
case USB488_bREQUEST_LOCAL_LOCKOUT :
872
872
{
873
873
TU_VERIFY (request -> bmRequestType == 0xA1 ); // in,class,interface
874
- TU_VERIFY (false);
875
874
return false;
876
875
}
877
876
#endif
878
877
879
878
default :
880
- TU_VERIFY (false);
881
879
return false;
882
880
}
883
- TU_VERIFY (false);
884
881
}
885
882
886
883
#endif /* CFG_TUD_TSMC */
0 commit comments