From 767db9f06cecaf5a9d0d66f307e91591e7d956b9 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Tue, 20 Sep 2022 11:09:50 +0100 Subject: [PATCH] Don't start baseband streaming until TX buffer is first filled. --- firmware/hackrf_usb/usb_api_transceiver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/hackrf_usb/usb_api_transceiver.c b/firmware/hackrf_usb/usb_api_transceiver.c index 0ae52077..e1a63ca0 100644 --- a/firmware/hackrf_usb/usb_api_transceiver.c +++ b/firmware/hackrf_usb/usb_api_transceiver.c @@ -431,6 +431,7 @@ void rx_mode(uint32_t seq) void tx_mode(uint32_t seq) { unsigned int usb_count = 0; + bool started = false; transceiver_startup(TRANSCEIVER_MODE_TX); @@ -443,13 +444,12 @@ void tx_mode(uint32_t seq) NULL); usb_count += USB_TRANSFER_SIZE; - // Enable streaming. The M0 is in TX_START mode, and will automatically - // send zeroes until the host fills buffer 0. Once that buffer is filled, - // the bulk transfer completion handler will increase the M4 count, and - // the M0 will switch to TX_RUN mode and transmit the first data. - baseband_streaming_enable(&sgpio_config); - while (transceiver_request.seq == seq) { + if (!started && (m0_state.m4_count == USB_BULK_BUFFER_SIZE)) { + // Buffer is now full, start streaming. + baseband_streaming_enable(&sgpio_config); + started = true; + } if ((usb_count - m0_state.m0_count) <= USB_TRANSFER_SIZE) { usb_transfer_schedule_block( &usb_endpoint_bulk_out,