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
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-3.0-or-later */
2
9
10#ifndef ESDR_FPGA_H_
11#define ESDR_FPGA_H_
12
13#include <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
16
17#include <zephyr/device.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
24bool esdr_fpga_loaded(const struct device *dev);
25
29int esdr_fpga_write(const struct device *dev, const void *head, size_t head_len,
30 const void *data, size_t len);
31
37int esdr_fpga_read(const struct device *dev, const void *head, size_t head_len, void *rx,
38 size_t len);
39
41int esdr_fpga_reg_write(const struct device *dev, uint16_t addr, const uint16_t *words,
42 size_t n);
43
45int esdr_fpga_reg_read(const struct device *dev, uint16_t addr, uint16_t *words, size_t n);
46
48void esdr_fpga_set_read_frequency(const struct device *dev, uint32_t hz);
49
50/*
51 * Graphics. Regions are in screen pixels, in the display driver's orientation; every pixel is
52 * a palette index (entries ESDR_FPGA_PAL_BG.. are the trace's colours, the waterfall uses
53 * 0..247).
54 */
55
57int esdr_fpga_palette(const struct device *dev, uint8_t first, const uint16_t *rgb565, size_t n);
58
60int esdr_fpga_waterfall(const struct device *dev, uint16_t x, uint16_t y, uint16_t w,
61 uint16_t h);
62
64int esdr_fpga_wf_line(const struct device *dev, const uint8_t *idx, size_t n);
65
68 uint8_t flags;
69};
70
72int esdr_fpga_spectrum(const struct device *dev, uint16_t x, uint16_t y, uint16_t w,
73 uint16_t h, const struct esdr_fpga_trace *t);
74
76int esdr_fpga_columns(const struct device *dev, const uint8_t *rows, size_t n);
77
86int esdr_fpga_render(const struct device *dev, bool on, bool te_sync, bool line_dirty);
87
89int esdr_fpga_redraw(const struct device *dev, bool waterfall, bool spectrum);
90
91/*
92 * DSP: samples in (ESDR_FPGA_OP_SAMPLES), an FFT of 16..512 points, power in dB averaged per
93 * bin, and every frames_per_line frames a waterfall line and a new trace from the columns.
94 */
95
98 uint8_t log2n;
99 uint8_t window;
100 bool overlap;
101 float alpha;
103 uint16_t cols;
104 uint16_t zoom_start;
105 uint16_t zoom_step;
106 float wf_min_db;
107 float wf_max_db;
108 float tr_top_db;
110 uint16_t tr_rows;
112};
113
115int esdr_fpga_dsp_config(const struct device *dev, const struct esdr_fpga_dsp *cfg);
116
118int esdr_fpga_dsp_run(const struct device *dev, bool on, const struct esdr_fpga_dsp *cfg);
119
124int esdr_fpga_samples(const struct device *dev, uint8_t format, bool resync, const void *data,
125 size_t len);
126
128int esdr_fpga_dsp_columns(const struct device *dev, int16_t *l, size_t n);
129
131int16_t esdr_fpga_db_to_l(float db);
132float esdr_fpga_l_to_db(int16_t l);
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* ESDR_FPGA_H_ */
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_reg_read(const struct device *dev, uint16_t addr, uint16_t *words, size_t n)
Read n words (at most 2046) from addr on.
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_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.
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_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()).
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_redraw(const struct device *dev, bool waterfall, bool spectrum)
Redraw regions now (or at the next TE).
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_render(const struct device *dev, bool on, bool te_sync, bool line_dirty)
Start or stop the renderer.
bool esdr_fpga_loaded(const struct device *dev)
Whether the FPGA (the parent lattice,ice40-fpga device) has a bitstream.
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_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.
int16_t esdr_fpga_db_to_l(float db)
dB to the gateware's level units (256 log2 of power) and back.
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_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.
The DSP chain's settings.
Definition esdr_fpga.h:97
float alpha
Definition esdr_fpga.h:101
float full_scale
Definition esdr_fpga.h:111
uint16_t zoom_step
Definition esdr_fpga.h:105
float tr_top_db
Definition esdr_fpga.h:108
uint8_t window
Definition esdr_fpga.h:99
uint8_t log2n
Definition esdr_fpga.h:98
float wf_min_db
Definition esdr_fpga.h:106
float wf_max_db
Definition esdr_fpga.h:107
uint16_t cols
Definition esdr_fpga.h:103
float tr_bottom_db
Definition esdr_fpga.h:109
bool overlap
Definition esdr_fpga.h:100
uint16_t tr_rows
Definition esdr_fpga.h:110
uint8_t frames_per_line
Definition esdr_fpga.h:102
uint16_t zoom_start
Definition esdr_fpga.h:104
The spectrum trace's look.
Definition esdr_fpga.h:67
uint8_t flags
Definition esdr_fpga.h:68