diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-10-02 21:54:46 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-10-02 22:17:39 -0400 |
commit | 978b321f80603a08ff1b61cfbfb11c3ef2c64906 (patch) | |
tree | a0d3408336b50cf6ee29e9d953abeb96850a70d8 /src/avr/usbserial.c | |
parent | 7c7573f69f3068d61dd6c12d25b265045fb54787 (diff) | |
download | kutter-978b321f80603a08ff1b61cfbfb11c3ef2c64906.tar.gz kutter-978b321f80603a08ff1b61cfbfb11c3ef2c64906.tar.xz kutter-978b321f80603a08ff1b61cfbfb11c3ef2c64906.zip |
avr: Disable usb serial interrupts while processing data
There's no need to keep taking interrupts if the high-level code is
busy processing messages.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/avr/usbserial.c')
-rw-r--r-- | src/avr/usbserial.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/avr/usbserial.c b/src/avr/usbserial.c index 6ee60841..7405e534 100644 --- a/src/avr/usbserial.c +++ b/src/avr/usbserial.c @@ -48,12 +48,14 @@ int_fast8_t usb_read_bulk_out(void *data, uint_fast8_t max_len) { UENUM = USB_CDC_EP_BULK_OUT; - if (!(UEINTX & (1<<RWAL))) + if (!(UEINTX & (1<<RXOUTI))) { // No data ready + UEIENX = 1<<RXOUTE; return -1; + } uint8_t len = UEBCLX; usb_read_packet(data, len); - UEINTX = (uint8_t)~(1<<FIFOCON); + UEINTX = (uint8_t)~((1<<FIFOCON) | (1<<RXOUTI)); return len; } @@ -61,11 +63,13 @@ int_fast8_t usb_send_bulk_in(void *data, uint_fast8_t len) { UENUM = USB_CDC_EP_BULK_IN; - if (!(UEINTX & (1<<RWAL))) + if (!(UEINTX & (1<<TXINI))) { // Buffer full + UEIENX = 1<<TXINE; return -1; + } usb_write_packet(data, len); - UEINTX = (uint8_t)~((1<<FIFOCON) | (1<<RXOUTI)); + UEINTX = (uint8_t)~((1<<FIFOCON) | (1<<TXINI) | (1<<RXOUTI)); return len; } @@ -231,12 +235,12 @@ ISR(USB_COM_vect) } if (ueint & (1<<USB_CDC_EP_BULK_OUT)) { UENUM = USB_CDC_EP_BULK_OUT; - UEINTX = ~(1<<RXOUTI); + UEIENX = 0; usb_notify_bulk_out(); } if (ueint & (1<<USB_CDC_EP_BULK_IN)) { UENUM = USB_CDC_EP_BULK_IN; - UEINTX = ~((1<<RXOUTI) | (1<<TXINI)); + UEIENX = 0; usb_notify_bulk_in(); } UENUM = old_uenum; |