diff options
| author | Zixun LI <[email protected]> | 2025-12-21 23:55:14 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-21 23:55:14 +0100 |
| commit | b209b177ecc41ca733a4420c60fb7c1170be2342 (patch) | |
| tree | 1aee3065fa56808156178b41983d4399e8dfedb0 /src | |
| parent | 53f9f8618ee19b6c884a25293d860125c8c1a08b (diff) | |
| parent | b53739dee47ae21a21eaa74e9ae6d17d0def32c8 (diff) | |
Merge pull request #3422 from Tails86/add-vendor_write_clear
Added tud_vendor_write_clear() which forcefully clears TX buffer
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/vendor/vendor_device.c | 7 | ||||
| -rw-r--r-- | src/class/vendor/vendor_device.h | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/class/vendor/vendor_device.c b/src/class/vendor/vendor_device.c index 9972911e0..b8e6fec6f 100644 --- a/src/class/vendor/vendor_device.c +++ b/src/class/vendor/vendor_device.c @@ -160,6 +160,13 @@ uint32_t tud_vendor_n_write_available(uint8_t idx) { vendord_interface_t *p_itf = &_vendord_itf[idx]; return tu_edpt_stream_write_available(&p_itf->stream.tx); } + +bool tud_vendor_n_write_clear(uint8_t idx) { + TU_VERIFY(idx < CFG_TUD_VENDOR, 0); + vendord_interface_t *p_itf = &_vendord_itf[idx]; + tu_edpt_stream_clear(&p_itf->stream.tx); + return true; +} #endif //--------------------------------------------------------------------+ diff --git a/src/class/vendor/vendor_device.h b/src/class/vendor/vendor_device.h index d59c885d2..c3de4c49d 100644 --- a/src/class/vendor/vendor_device.h +++ b/src/class/vendor/vendor_device.h @@ -91,6 +91,9 @@ uint32_t tud_vendor_n_write_flush(uint8_t idx); // Return number of bytes available for writing in TX FIFO uint32_t tud_vendor_n_write_available(uint8_t idx); + +// Clear the transmit FIFO +bool tud_vendor_n_write_clear(uint8_t idx); #endif // Write a null-terminated string to TX FIFO @@ -148,6 +151,10 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t tud_vendor_write_flush(void) { TU_ATTR_ALWAYS_INLINE static inline uint32_t tud_vendor_write_available(void) { return tud_vendor_n_write_available(0); } + +TU_ATTR_ALWAYS_INLINE static inline bool tud_vendor_write_clear(void) { + return tud_vendor_n_write_clear(0); +} #endif // backward compatible |
