mirror of
https://github.com/hathach/tinyusb.git
synced 2026-02-04 21:15:52 +00:00
Merge pull request #3422 from Tails86/add-vendor_write_clear
Added tud_vendor_write_clear() which forcefully clears TX buffer
This commit is contained in:
@ -196,6 +196,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
|
||||
tud_vendor_write_str("\r\nWebUSB interface connected\r\n");
|
||||
tud_vendor_write_flush();
|
||||
} else {
|
||||
tud_vendor_write_clear(); // anything left in the buffer is now thrown out
|
||||
blink_interval_ms = BLINK_MOUNTED;
|
||||
}
|
||||
|
||||
|
||||
7
src/class/vendor/vendor_device.c
vendored
7
src/class/vendor/vendor_device.c
vendored
@ -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
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
7
src/class/vendor/vendor_device.h
vendored
7
src/class/vendor/vendor_device.h
vendored
@ -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
|
||||
|
||||
Reference in New Issue
Block a user