summaryrefslogtreecommitdiff
path: root/src/class/usbtmc/usbtmc_device.c
diff options
context:
space:
mode:
authorTommie Gannert <[email protected]>2024-02-26 11:41:50 +0100
committerTommie Gannert <[email protected]>2024-02-26 11:43:45 +0100
commit5ce7b147117826dd75c2d7b347df80b0177e7252 (patch)
tree6f31c905b3852160371206a64c2882821b634998 /src/class/usbtmc/usbtmc_device.c
parentf92c2c2758e47c1dd9a0e441f1a48188171ae403 (diff)
add notification support for device class USBTMC.
The ep_int_in is already used for responding to USB488 READ_STATUS_BYTE requests, but that EP is defined for all of USBTMC. This extends the functionality to let callers send notifications and receive ACKs.
Diffstat (limited to 'src/class/usbtmc/usbtmc_device.c')
-rw-r--r--src/class/usbtmc/usbtmc_device.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/class/usbtmc/usbtmc_device.c b/src/class/usbtmc/usbtmc_device.c
index 573654d58..debe445fd 100644
--- a/src/class/usbtmc/usbtmc_device.c
+++ b/src/class/usbtmc/usbtmc_device.c
@@ -240,6 +240,18 @@ bool tud_usbtmc_transmit_dev_msg_data(
return true;
}
+bool tud_usbtmc_transmit_notification_data(const void * data, size_t len)
+{
+#ifndef NDEBUG
+ TU_ASSERT(len >= 1);
+ TU_ASSERT(usbtmc_state.ep_int_in != 0);
+#endif
+ if (usbd_edpt_busy(usbtmc_state.rhport, usbtmc_state.ep_int_in)) return false;
+
+ TU_VERIFY(usbd_edpt_xfer(usbtmc_state.rhport, usbtmc_state.ep_int_in, (void *)data, len));
+ return true;
+}
+
void usbtmcd_init_cb(void)
{
usbtmc_state.capabilities = tud_usbtmc_get_capabilities_cb();
@@ -578,7 +590,9 @@ bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
}
}
else if (ep_addr == usbtmc_state.ep_int_in) {
- // Good?
+ if (tud_usbtmc_notification_complete_cb) {
+ TU_VERIFY(tud_usbtmc_notification_complete_cb());
+ }
return true;
}
return false;