mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-19 14:07:57 +00:00
wait_for_buffer() now handles TX buffers.
Feels a bit awkward to read LLI src/dest to determine if RX or TX. But it works.
This commit is contained in:
@@ -156,12 +156,15 @@ void disable() {
|
|||||||
gpdma_channel_sgpio.disable();
|
gpdma_channel_sgpio.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
baseband::buffer_t wait_for_rx_buffer() {
|
baseband::buffer_t wait_for_buffer() {
|
||||||
const auto next_index = thread_wait.sleep();
|
const auto next_index = thread_wait.sleep();
|
||||||
|
|
||||||
if( next_index >= 0 ) {
|
if( next_index >= 0 ) {
|
||||||
const size_t free_index = (next_index + transfers_per_buffer - 2) & transfers_mask;
|
const size_t free_index = (next_index + transfers_per_buffer - 2) & transfers_mask;
|
||||||
return { reinterpret_cast<sample_t*>(lli_loop[free_index].destaddr), transfer_samples };
|
const auto src = lli_loop[free_index].srcaddr;
|
||||||
|
const auto dst = lli_loop[free_index].destaddr;
|
||||||
|
const auto p = (src == reinterpret_cast<uint32_t>(&LPC_SGPIO->REG_SS[0])) ? dst : src;
|
||||||
|
return { reinterpret_cast<sample_t*>(p), transfer_samples };
|
||||||
} else {
|
} else {
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ bool is_enabled();
|
|||||||
|
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
baseband::buffer_t wait_for_rx_buffer();
|
baseband::buffer_t wait_for_buffer();
|
||||||
|
|
||||||
} /* namespace dma */
|
} /* namespace dma */
|
||||||
} /* namespace baseband */
|
} /* namespace baseband */
|
||||||
|
@@ -77,7 +77,7 @@ void BasebandThread::run() {
|
|||||||
|
|
||||||
while( !chThdShouldTerminate() ) {
|
while( !chThdShouldTerminate() ) {
|
||||||
// TODO: Place correct sampling rate into buffer returned here:
|
// TODO: Place correct sampling rate into buffer returned here:
|
||||||
const auto buffer_tmp = baseband::dma::wait_for_rx_buffer();
|
const auto buffer_tmp = baseband::dma::wait_for_buffer();
|
||||||
if( buffer_tmp ) {
|
if( buffer_tmp ) {
|
||||||
buffer_c8_t buffer {
|
buffer_c8_t buffer {
|
||||||
buffer_tmp.p, buffer_tmp.count, sampling_rate
|
buffer_tmp.p, buffer_tmp.count, sampling_rate
|
||||||
|
Reference in New Issue
Block a user