summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNConrad <[email protected]>2022-06-26 14:34:34 -0400
committerNConrad <[email protected]>2022-06-26 14:34:34 -0400
commitc675debfb2dcff1697cb6643afb60c26309bdfcf (patch)
tree2ed8e8176242906ef262b26bdd8e75693c6d9ca4
parent239b5d52790051949c281e60ba96ac674669f026 (diff)
USBTMC: Handle busy interrupt in.
-rw-r--r--src/class/usbtmc/usbtmc.h5
-rw-r--r--src/class/usbtmc/usbtmc_device.c32
2 files changed, 23 insertions, 14 deletions
diff --git a/src/class/usbtmc/usbtmc.h b/src/class/usbtmc/usbtmc.h
index 7d7005c2e..e7016ae24 100644
--- a/src/class/usbtmc/usbtmc.h
+++ b/src/class/usbtmc/usbtmc.h
@@ -189,7 +189,10 @@ typedef enum {
USBTMC_STATUS_FAILED = 0x80,
USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS = 0x81,
USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS = 0x82,
- USBTMC_STATUS_SPLIT_IN_PROGRESS = 0x83
+ USBTMC_STATUS_SPLIT_IN_PROGRESS = 0x83,
+
+ /****** USBTMC 488 *************/
+ USB488_STATUS_INTERRUPT_IN_BUSY = 0x20
} usbtmc_status_enum;
/************************************************************
diff --git a/src/class/usbtmc/usbtmc_device.c b/src/class/usbtmc/usbtmc_device.c
index b5232ab91..c50ca65d5 100644
--- a/src/class/usbtmc/usbtmc_device.c
+++ b/src/class/usbtmc/usbtmc_device.c
@@ -831,26 +831,32 @@ bool usbtmcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request
bTag = request->wValue & 0x7F;
TU_VERIFY(request->bmRequestType == 0xA1);
- TU_VERIFY((request->wValue & (~0x7F)) == 0u); // Other bits are required to be zero
+ TU_VERIFY((request->wValue & (~0x7F)) == 0u); // Other bits are required to be zero (USB488v1.0 Table 11)
TU_VERIFY(bTag >= 0x02 && bTag <= 127);
TU_VERIFY(request->wIndex == usbtmc_state.itf_id);
TU_VERIFY(request->wLength == 0x0003);
rsp.bTag = (uint8_t)bTag;
if(usbtmc_state.ep_int_in != 0)
{
- rsp.USBTMC_status = USBTMC_STATUS_SUCCESS;
- rsp.statusByte = 0x00; // Use interrupt endpoint, instead.
-
- usbtmc_read_stb_interrupt_488_t intMsg =
+ rsp.statusByte = 0x00; // Use interrupt endpoint, instead. Must be 0x00 (USB488v1.0 4.3.1.2)
+ if(usbd_edpt_busy(rhport, usbtmc_state.ep_int_in))
+ {
+ rsp.USBTMC_status = USB488_STATUS_INTERRUPT_IN_BUSY;
+ }
+ else
{
- .bNotify1 = {
- .one = 1,
- .bTag = bTag & 0x7Fu,
- },
- .StatusByte = tud_usbtmc_get_stb_cb(&(rsp.USBTMC_status))
- };
- // USB488 spec states that transfer must be queued before control request response sent.
- usbd_edpt_xfer(rhport, usbtmc_state.ep_int_in, (void*)&intMsg, sizeof(intMsg));
+ rsp.USBTMC_status = USBTMC_STATUS_SUCCESS;
+ usbtmc_read_stb_interrupt_488_t intMsg =
+ {
+ .bNotify1 = {
+ .one = 1,
+ .bTag = bTag & 0x7Fu,
+ },
+ .StatusByte = tud_usbtmc_get_stb_cb(&(rsp.USBTMC_status))
+ };
+ // Must be queued before control request response sent (USB488v1.0 4.3.1.2)
+ usbd_edpt_xfer(rhport, usbtmc_state.ep_int_in, (void*)&intMsg, sizeof(intMsg));
+ }
}
else
{