Skip to content

Commit

Permalink
Merge pull request #15 from badgeteam/tnt/fix-loopback
Browse files Browse the repository at this point in the history
Disable normal data flow during FPGA loopback
  • Loading branch information
renzenicolai authored Jun 12, 2022
2 parents 52e49d4 + 5a48103 commit 3917aea
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions uart_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,16 @@ void uart_task(void) {
}

if (length > 0) {
cdc_send(1, buffer, length);
if (get_webusb_connected(WEBUSB_IDX_FPGA)) {
tud_vendor_n_write(WEBUSB_IDX_FPGA, buffer, length);
}
if (fpga_loopback_active) {
for (uint32_t position = 0; position < length; position++) {
buffer[position] = buffer[position] ^ 0xa5;
}
uart_write_blocking(UART_FPGA, buffer, length);
} else {
cdc_send(1, buffer, length);
if (get_webusb_connected(WEBUSB_IDX_FPGA)) {
tud_vendor_n_write(WEBUSB_IDX_FPGA, buffer, length);
}
}
}

Expand All @@ -203,7 +204,7 @@ void uart_task(void) {
uart_write_blocking(UART_ESP32, buffer, length);
}

if (tud_cdc_n_available(USB_CDC_FPGA)) {
if (tud_cdc_n_available(USB_CDC_FPGA) && !fpga_loopback_active) {
length = tud_cdc_n_read(USB_CDC_FPGA, buffer, sizeof(buffer));
uart_write_blocking(UART_FPGA, buffer, length);
}
Expand Down

0 comments on commit 3917aea

Please sign in to comment.