esp-sdr-zephyr
Raw I/Q receive and transmit on the ESP32-S3/C6 Wi-Fi radio, for Zephyr
Loading...
Searching...
No Matches
esp_sdr_diag.h File Reference

ESP-SDR gapless receive on the ESP32-C5 through the modem diagnostic bus. More...

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  esp_sdr_diag_cfg
struct  esp_sdr_diag_stats

Macros

#define ESP_SDR_DIAG_PINS   8U
#define ESP_SDR_DIAG_BLOCK   8192U
#define ESP_SDR_DIAG_RING   57344U
#define ESP_SDR_DIAG_LSB_AUTO   0xffU
#define ESP_SDR_DIAG_LSB_MAX   6U
#define ESP_SDR_DIAG_DECIM_MIN   8U

Typedefs

typedef void(* esp_sdr_diag_sink_t) (void *user, const uint8_t *blk, size_t n, uint64_t index)
typedef void(* esp_sdr_diag_iq_sink_t) (void *user, const int32_t *iq, size_t n, uint64_t index)

Functions

int esp_sdr_diag_run (const struct esp_sdr_diag_cfg *cfg, struct esp_sdr_diag_stats *stats)
 Run the ring until the time is up, esp_sdr_diag_stop() or an overrun.
void esp_sdr_diag_stop (void)
 Ask a running esp_sdr_diag_run() to return.
bool esp_sdr_diag_active (void)
int esp_sdr_diag_level (uint8_t *lsb)
 The nibble window start that fits the current signal.
void esp_sdr_diag_armed_hook (void)
 Bench hook: called by esp_sdr_diag_run() once the dump engine runs, before the pads and the ring start. Weak and empty; a bench application can override it to change or record modem registers.

Detailed Description

ESP-SDR gapless receive on the ESP32-C5 through the modem diagnostic bus.

The dump engine keeps running with its SRAM bank handed back to the CPU, and the modem diagnostic bus carries the dump word (I and Q, 10 bits each). The GPIO matrix loops 8 of its lines back into the PARLIO receiver, which samples them at 40 MHz, every second sample of the 80 MS/s baseband, as 4 bits of I and 4 bits of Q per byte. A GDMA ring in SRAM bank 1 collects the bytes without the CPU. The CPU only has to keep up with the ring: 40 MB/s is 6 cycles per byte at 240 MHz.

Method after the ESPsoup firmware (github.com/pit711/espsoup-firmware), which follows ESP-SDR's ESP32-S31 streaming and credits Twotoz/C5VRX.

Byte layout: Q[lsb+3:lsb] in bits 3:0 and I[lsb+3:lsb] in bits 7:4, signed nibbles; the sample is the nibble times 2^lsb. Q and I are the library's receive word fields (esp_sdr_rx_burst): Q in bits 9:0, I in bits 19:10; a tone above the LO comes out as +f with I + jQ (measured against the 10-bit capture). A window that is too low wraps: esp_sdr_diag_level() picks one that does not.

Sampling every second sample of the bus without a filter aliases the band above 20 MHz offset: narrow the analog low-pass first.

The 8 pads are driven as outputs that toggle at up to 40 MHz: nothing may be connected to them.