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

The esp-sdr gateware on the MCH2022 badge's iCE40UP5K. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/device.h>

Go to the source code of this file.

Data Structures

struct  esdr_fpga_trace
 The spectrum trace's look. More...
struct  esdr_fpga_dsp
 The DSP chain's settings. More...

Functions

bool esdr_fpga_loaded (const struct device *dev)
 Whether the FPGA (the parent lattice,ice40-fpga device) has a bitstream.
int esdr_fpga_write (const struct device *dev, const void *head, size_t head_len, const void *data, size_t len)
 One write frame: head then data (either may be empty) under one CS assertion.
int esdr_fpga_read (const struct device *dev, const void *head, size_t head_len, void *rx, size_t len)
 One read frame at the read clock: send head, then receive len bytes.
int esdr_fpga_reg_write (const struct device *dev, uint16_t addr, const uint16_t *words, size_t n)
 Write n words to the gateware's registers from addr on.
int esdr_fpga_reg_read (const struct device *dev, uint16_t addr, uint16_t *words, size_t n)
 Read n words (at most 2046) from addr on.
void esdr_fpga_set_read_frequency (const struct device *dev, uint32_t hz)
 Change the read clock (tests; the default comes from devicetree).
int esdr_fpga_palette (const struct device *dev, uint8_t first, const uint16_t *rgb565, size_t n)
 Load n RGB565 palette entries from first on.
int esdr_fpga_waterfall (const struct device *dev, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
 Place the waterfall: w columns (at most 320) of h rows; w = 0 turns it off.
int esdr_fpga_wf_line (const struct device *dev, const uint8_t *idx, size_t n)
 A new waterfall line on top: n palette indices, one per column.
int esdr_fpga_spectrum (const struct device *dev, uint16_t x, uint16_t y, uint16_t w, uint16_t h, const struct esdr_fpga_trace *t)
 Place the spectrum trace; w = 0 turns it off.
int esdr_fpga_columns (const struct device *dev, const uint8_t *rows, size_t n)
 New trace: the row (0 at the top) of each of n columns; redraws the trace.
int esdr_fpga_render (const struct device *dev, bool on, bool te_sync, bool line_dirty)
 Start or stop the renderer.
int esdr_fpga_redraw (const struct device *dev, bool waterfall, bool spectrum)
 Redraw regions now (or at the next TE).
int esdr_fpga_dsp_config (const struct device *dev, const struct esdr_fpga_dsp *cfg)
 Load window, average table and scales (dB relative to a full-scale tone).
int esdr_fpga_dsp_run (const struct device *dev, bool on, const struct esdr_fpga_dsp *cfg)
 Start or stop the DSP chain; starting restarts the average.
int esdr_fpga_samples (const struct device *dev, uint8_t format, bool resync, const void *data, size_t len)
 Samples for the DSP: format one of ESDR_FPGA_FMT_*, resync starts a new frame at the first of them.
int esdr_fpga_dsp_columns (const struct device *dev, int16_t *l, size_t n)
 The last line's levels per column, in L units (esdr_fpga_l_to_db()).
int16_t esdr_fpga_db_to_l (float db)
 dB to the gateware's level units (256 log2 of power) and back.

Detailed Description

The esp-sdr gateware on the MCH2022 badge's iCE40UP5K.

One SPI frame (one CS assertion) carries one command: an opcode byte, then its payload.

Function Documentation

◆ esdr_fpga_read()

int esdr_fpga_read ( const struct device * dev,
const void * head,
size_t head_len,
void * rx,
size_t len )

One read frame at the read clock: send head, then receive len bytes.

len must be a multiple of 4.

◆ esdr_fpga_render()

int esdr_fpga_render ( const struct device * dev,
bool on,
bool te_sync,
bool line_dirty )

Start or stop the renderer.

Parameters
devthe FPGA
onstart (true) or stop the renderer
te_syncstart renders on the panel's tearing-effect edge
line_dirtyredraw the waterfall after every new line