Wait tx complete (#3165)

* Implement radio transmission drain mechanism and update shared memory structure
* don't wait for timeout if baseband already in shut down state
This commit is contained in:
Pezsma
2026-05-12 12:45:02 +02:00
committed by GitHub
parent 4dfbf666d0
commit 66f1835232
5 changed files with 32 additions and 5 deletions
+4
View File
@@ -443,6 +443,10 @@ void set_p25tx_data(const uint8_t* dibits, uint16_t frame_length) {
static bool baseband_image_running = false;
bool is_image_running() {
return baseband_image_running;
}
void run_image(const spi_flash::image_tag_t image_tag) {
if (baseband_image_running) {
chDbgPanic("BBRunning");
+1
View File
@@ -125,6 +125,7 @@ void request_rssi_beep();
void request_beep_stop();
void request_audio_beep(uint32_t freq, uint32_t sample_rate, uint32_t duration_ms);
bool is_image_running();
void run_image(const portapack::spi_flash::image_tag_t image_tag);
void run_prepared_image(const uint32_t m4_code);
void shutdown();
+14 -1
View File
@@ -50,7 +50,7 @@ using namespace hackrf::one;
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp"
#include "baseband_api.hpp"
#include "hal.h" // For LPC_SGPIO
#include <array>
@@ -413,6 +413,19 @@ void set_rx_max283x_iq_phase_calibration(const size_t v) {
}
void disable() {
if (direction == rf::Direction::Transmit && baseband::is_image_running()) {
static constexpr uint32_t radio_tx_drain_timeout_ms = 100;
shared_memory.radio_tx_drain = 1; // Request drain of the current DMA queue.
for (uint32_t waited_ms = 0;
shared_memory.radio_tx_drain && (waited_ms < radio_tx_drain_timeout_ms);
++waited_ms) {
chThdSleepMilliseconds(1);
}
}
/* Never allow shutdown to block indefinitely waiting for a drain
* acknowledgement that may never arrive in normal operation. */
shared_memory.radio_tx_drain = 0;
set_antenna_bias(false);
baseband_codec.set_mode(max5864::Mode::Shutdown);
#ifdef PRALINE