add support for usbtmc vendor-spicific command messages
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//Limitations:
|
//Limitations:
|
||||||
// "vendor-specific" commands are not handled.
|
// "vendor-specific" commands are handled similar to normal massages, except that the MsgID is changed to "vendor-specific".
|
||||||
// Dealing with "termchar" must be handled by the application layer,
|
// Dealing with "termchar" must be handled by the application layer,
|
||||||
// though additional error checking is does in this module.
|
// though additional error checking is does in this module.
|
||||||
// talkOnly and listenOnly are NOT supported. They're not permitted
|
// talkOnly and listenOnly are NOT supported. They're not permitted
|
||||||
@@ -171,6 +171,8 @@ tu_static uint8_t termChar;
|
|||||||
|
|
||||||
tu_static uint8_t termCharRequested = false;
|
tu_static uint8_t termCharRequested = false;
|
||||||
|
|
||||||
|
tu_static uint8_t usbtmcVendorSpecificRequested = false;
|
||||||
|
|
||||||
#if OSAL_MUTEX_REQUIRED
|
#if OSAL_MUTEX_REQUIRED
|
||||||
static OSAL_MUTEX_DEF(usbtmcLockBuffer);
|
static OSAL_MUTEX_DEF(usbtmcLockBuffer);
|
||||||
#endif
|
#endif
|
||||||
@@ -226,7 +228,14 @@ bool tud_usbtmc_transmit_dev_msg_data(
|
|||||||
TU_VERIFY(usbtmc_state.state == STATE_TX_REQUESTED);
|
TU_VERIFY(usbtmc_state.state == STATE_TX_REQUESTED);
|
||||||
usbtmc_msg_dev_dep_msg_in_header_t *hdr = (usbtmc_msg_dev_dep_msg_in_header_t*)usbtmc_epbuf.epin;
|
usbtmc_msg_dev_dep_msg_in_header_t *hdr = (usbtmc_msg_dev_dep_msg_in_header_t*)usbtmc_epbuf.epin;
|
||||||
tu_varclr(hdr);
|
tu_varclr(hdr);
|
||||||
|
if(usbtmcVendorSpecificRequested)
|
||||||
|
{
|
||||||
|
hdr->header.MsgID = USBTMC_MSGID_VENDOR_SPECIFIC_IN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hdr->header.MsgID = USBTMC_MSGID_DEV_DEP_MSG_IN;
|
hdr->header.MsgID = USBTMC_MSGID_DEV_DEP_MSG_IN;
|
||||||
|
}
|
||||||
hdr->header.bTag = usbtmc_state.lastBulkInTag;
|
hdr->header.bTag = usbtmc_state.lastBulkInTag;
|
||||||
hdr->header.bTagInverse = (uint8_t)~(usbtmc_state.lastBulkInTag);
|
hdr->header.bTagInverse = (uint8_t)~(usbtmc_state.lastBulkInTag);
|
||||||
hdr->TransferSize = len;
|
hdr->TransferSize = len;
|
||||||
@@ -512,6 +521,7 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
|
|||||||
|
|
||||||
switch(msg->header.MsgID) {
|
switch(msg->header.MsgID) {
|
||||||
case USBTMC_MSGID_DEV_DEP_MSG_OUT:
|
case USBTMC_MSGID_DEV_DEP_MSG_OUT:
|
||||||
|
usbtmcVendorSpecificRequested = false;
|
||||||
if(!handle_devMsgOutStart(rhport, msg, xferred_bytes))
|
if(!handle_devMsgOutStart(rhport, msg, xferred_bytes))
|
||||||
{
|
{
|
||||||
usbd_edpt_stall(rhport, usbtmc_state.ep_bulk_out);
|
usbd_edpt_stall(rhport, usbtmc_state.ep_bulk_out);
|
||||||
@@ -520,6 +530,7 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case USBTMC_MSGID_DEV_DEP_MSG_IN:
|
case USBTMC_MSGID_DEV_DEP_MSG_IN:
|
||||||
|
usbtmcVendorSpecificRequested = false;
|
||||||
TU_VERIFY(handle_devMsgIn(msg, xferred_bytes));
|
TU_VERIFY(handle_devMsgIn(msg, xferred_bytes));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -532,7 +543,19 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case USBTMC_MSGID_VENDOR_SPECIFIC_MSG_OUT:
|
case USBTMC_MSGID_VENDOR_SPECIFIC_MSG_OUT:
|
||||||
|
usbtmcVendorSpecificRequested = true;
|
||||||
|
if(!handle_devMsgOutStart(rhport, msg, xferred_bytes))
|
||||||
|
{
|
||||||
|
usbd_edpt_stall(rhport, usbtmc_state.ep_bulk_out);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case USBTMC_MSGID_VENDOR_SPECIFIC_IN:
|
case USBTMC_MSGID_VENDOR_SPECIFIC_IN:
|
||||||
|
usbtmcVendorSpecificRequested = true;
|
||||||
|
TU_VERIFY(handle_devMsgIn(msg, xferred_bytes));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usbd_edpt_stall(rhport, usbtmc_state.ep_bulk_out);
|
usbd_edpt_stall(rhport, usbtmc_state.ep_bulk_out);
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user