mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 14:07:30 +00:00
Halt sweep when USB buffer full
This commit is contained in:
parent
0f758584bf
commit
51806b936c
3 changed files with 36 additions and 2 deletions
|
|
@ -223,7 +223,7 @@ void usb_init(usbd_recv_callback_t receive_callback) {
|
|||
}
|
||||
bool usb_transmit(const uint8_t *data, uint16_t length) {
|
||||
// attempt to add data to fifo
|
||||
if(usb_transmit_fifo_level + length > sizeof(usb_transmit_fifo)) {
|
||||
if(length > usb_available_buffer()) {
|
||||
// data won't fit, abort
|
||||
return false;
|
||||
}
|
||||
|
|
@ -280,3 +280,7 @@ void USB_LP_IRQHandler(void)
|
|||
{
|
||||
HAL_PCD_IRQHandler(&hpcd_USB_FS);
|
||||
}
|
||||
|
||||
uint16_t usb_available_buffer() {
|
||||
return sizeof(usb_transmit_fifo) - usb_transmit_fifo_level;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ typedef void(*usbd_recv_callback_t)(const uint8_t *buf, uint16_t len);
|
|||
|
||||
void usb_init(usbd_recv_callback_t receive_callback);
|
||||
bool usb_transmit(const uint8_t *data, uint16_t length);
|
||||
uint16_t usb_available_buffer();
|
||||
void usb_log(const char *log, uint16_t length);
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue