Don't send 16K of zeroes to the M0 at TX startup.

The M4 previously buffered 16K of zeroes for the M0 to transmit, whilst
waiting for the first USB bulk transfer from the host to complete. The
first bulk transfer was placed in the second 16K buffer.

This avoided the M0 transmitting uninitialised data, but was not a
reliable solution, and delayed the transmission of the first
host-supplied samples.

Now that the M0 is placed in TX_START mode, this trick is no longer
necessary, because the M0 can automatically send zeroes until the first
bulk transfer is completed.

As such, the first bulk transfer now goes to the first 16K buffer.
Once the M4 byte count is increased by the bulk transfer completion
callback, the M0 will start transmitting the samples immediately.
This commit is contained in:
Martin Ling
2021-12-24 13:03:19 +00:00
parent 00b5ed7d62
commit 68688e0ec4

View File

@ -409,22 +409,23 @@ void rx_mode(uint32_t seq) {
} }
void tx_mode(uint32_t seq) { void tx_mode(uint32_t seq) {
unsigned int phase = 1; unsigned int phase = 0;
transceiver_startup(TRANSCEIVER_MODE_TX); transceiver_startup(TRANSCEIVER_MODE_TX);
memset(&usb_bulk_buffer[0x0000], 0, 0x8000); // Set up OUT transfer of buffer 0.
// Account for having filled buffer 0.
m0_state.m4_count += 0x4000;
// Set up OUT transfer of buffer 1.
usb_transfer_schedule_block( usb_transfer_schedule_block(
&usb_endpoint_bulk_out, &usb_endpoint_bulk_out,
&usb_bulk_buffer[0x4000], &usb_bulk_buffer[0x0000],
0x4000, 0x4000,
transceiver_bulk_transfer_complete, transceiver_bulk_transfer_complete,
NULL NULL
); );
// Start transmitting zeros while the host fills buffer 1.
// 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); baseband_streaming_enable(&sgpio_config);
while (transceiver_request.seq == seq) { while (transceiver_request.seq == seq) {