esp-sdr-zephyr
Raw I/Q receive and transmit on the ESP32-S3/C6 Wi-Fi radio, for Zephyr
Loading...
Searching...
No Matches
CPU-paced streaming

Continuous receive and transmit, one sample at a time from the caller's loop, ESP32-C6 and ESP32-C5, transmit only on the ESP32-S31 (esp_sdr_paced.h, CONFIG_ESP_SDR_PACED). More...

Data Structures

struct  esp_sdr_paced_stats

Macros

#define ESP_SDR_PACED_INPUT_HZ   80000000U

Typedefs

typedef bool(* esp_sdr_tx_paced_input_t) (void *user, int16_t *i, int16_t *q)

Functions

int esp_sdr_rx_paced_start (uint32_t rate_hz)
 Start receiving at rate_hz.
bool esp_sdr_rx_paced_poll (int32_t *i, int32_t *q)
 Produce the next receive sample if it is due.
uint32_t esp_sdr_rx_paced_fill_iq8 (int8_t *out, size_t n, unsigned int shift)
 Produce the next n receive samples as they fall due, as 8-bit I, Q pairs. The tight form of esp_sdr_rx_paced_poll() for MS/s rates: blocks until the last one.
void esp_sdr_rx_paced_stop (void)
 Stop receiving and release the radio; no-op when stopped.
int esp_sdr_tx_paced_start (uint32_t rate_hz, unsigned int interp, unsigned int power, esp_sdr_tx_paced_input_t input, void *user)
 Turn the transmit chain on at the current frequency and start playing input at rate_hz.
bool esp_sdr_tx_paced_poll (void)
 Write the next DAC value if it is due, then compute the one after.
void esp_sdr_tx_paced_stop (void)
 Turn the transmit chain off and release the radio; no-op when stopped.
unsigned int esp_sdr_tx_paced_power_max (void)
 Highest power step: 2 dB per step of the vendor tone's backoff (none on the C5, S31).
static uint32_t esp_sdr_paced_cycles (void)
 The CPU cycle counter the paced streams run on (inlined into IRAM loops).
static void esp_sdr_paced_cycles_enable (void)
 Make esp_sdr_paced_cycles() count CPU cycles (a stream's start does it too).
uint32_t esp_sdr_paced_deadline (void)
 When the running stream's next sample is due, on esp_sdr_paced_cycles().
void esp_sdr_paced_sync (void)
 Restart the running stream's clock: the next sample is due one period from now. Call once interrupts are locked, after the start.
void esp_sdr_paced_get_stats (struct esp_sdr_paced_stats *stats)
 Statistics of the running or last stream.

Detailed Description

Continuous receive and transmit, one sample at a time from the caller's loop, ESP32-C6 and ESP32-C5, transmit only on the ESP32-S31 (esp_sdr_paced.h, CONFIG_ESP_SDR_PACED).

Guide: Paced streams.

Macro Definition Documentation

◆ ESP_SDR_PACED_INPUT_HZ

#define ESP_SDR_PACED_INPUT_HZ   80000000U

Input rate of the estimator: each receive output sums 80 MHz / rate of its samples.

Typedef Documentation

◆ esp_sdr_tx_paced_input_t

typedef bool(* esp_sdr_tx_paced_input_t) (void *user, int16_t *i, int16_t *q)

Transmit input: store the next sample (full scale +-32767) and return true, or return false when none is available (played as 0). Called from the poll, once per input sample: must not block.

Function Documentation

◆ esp_sdr_paced_deadline()

uint32_t esp_sdr_paced_deadline ( void )

When the running stream's next sample is due, on esp_sdr_paced_cycles().

For I/O between polls: stop it while (int32_t)(deadline - now) is small.

◆ esp_sdr_rx_paced_fill_iq8()

uint32_t esp_sdr_rx_paced_fill_iq8 ( int8_t * out,
size_t n,
unsigned int shift )

Produce the next n receive samples as they fall due, as 8-bit I, Q pairs. The tight form of esp_sdr_rx_paced_poll() for MS/s rates: blocks until the last one.

Parameters
out2 * n bytes, 2-byte aligned.
nSamples to produce. A poll a whole period or more late (the caller's I/O between calls) spans that many windows more: each sample it missed gets an equal share of its sums, so that the samples stay on their grid.
shiftRight shift of each sum before it saturates to -127 to 127.
Returns
Polls among them that came a whole period or more late.

◆ esp_sdr_rx_paced_poll()

bool esp_sdr_rx_paced_poll ( int32_t * i,
int32_t * q )

Produce the next receive sample if it is due.

Parameters
i,qThe sums over this sample's window of 80 MHz / rate inputs, each input within -512 to 511.
Returns
true when a sample was produced.

◆ esp_sdr_rx_paced_start()

int esp_sdr_rx_paced_start ( uint32_t rate_hz)

Start receiving at rate_hz.

Takes the radio until esp_sdr_rx_paced_stop(). The receiver keeps its frequency, gain and filter.

Parameters
rate_hzA divisor of both the CPU clock and 80 MHz, from 10 kHz.
Returns
0, -EINVAL for an unsupported rate, -EAGAIN before esp_sdr_init().

◆ esp_sdr_tx_paced_poll()

bool esp_sdr_tx_paced_poll ( void )

Write the next DAC value if it is due, then compute the one after.

Returns
true when a value was written.

◆ esp_sdr_tx_paced_start()

int esp_sdr_tx_paced_start ( uint32_t rate_hz,
unsigned int interp,
unsigned int power,
esp_sdr_tx_paced_input_t input,
void * user )

Turn the transmit chain on at the current frequency and start playing input at rate_hz.

Parameters
rate_hzInput rate; rate times interp must divide the CPU clock.
interpInterpolation factor: 1 (input straight to the DAC), 2, 4 or 8.
powerPower step, 0 weakest to esp_sdr_tx_paced_power_max(). No effect on the ESP32-C5 and ESP32-S31, whose level follows the samples only (doc/radio/gain.md).
inputCalled once per input sample from esp_sdr_tx_paced_poll().
userPassed to input.
Returns
0, -EINVAL, -ERANGE outside the transmit range, -EAGAIN before esp_sdr_init().