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_paced.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-or-later
3 */
4
35
36#ifndef ESP_SDR_ESP_SDR_PACED_H_
37#define ESP_SDR_ESP_SDR_PACED_H_
38
39#include <stdbool.h>
40#include <stddef.h>
41#include <stdint.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
51
53#define ESP_SDR_PACED_INPUT_HZ 80000000U
54
57 uint64_t samples;
59 uint32_t late;
61 uint32_t late_max;
63 uint32_t events;
64};
65
75int esp_sdr_rx_paced_start(uint32_t rate_hz);
76
84bool esp_sdr_rx_paced_poll(int32_t *i, int32_t *q);
85
98uint32_t esp_sdr_rx_paced_fill_iq8(int8_t *out, size_t n, unsigned int shift);
99
102
108typedef bool (*esp_sdr_tx_paced_input_t)(void *user, int16_t *i, int16_t *q);
109
124int esp_sdr_tx_paced_start(uint32_t rate_hz, unsigned int interp, unsigned int power,
125 esp_sdr_tx_paced_input_t input, void *user);
126
132
135
137unsigned int esp_sdr_tx_paced_power_max(void);
138
140static inline __attribute__((always_inline)) uint32_t esp_sdr_paced_cycles(void)
141{
142 uint32_t v;
143
144#if defined(CONFIG_SOC_SERIES_ESP32C6)
145 /* The C6's machine performance counter (mpccr). */
146 __asm__ volatile("csrr %0, 0x7e2" : "=r"(v));
147#else
148 __asm__ volatile("csrr %0, cycle" : "=r"(v));
149#endif
150 return v;
151}
152
154static inline void esp_sdr_paced_cycles_enable(void)
155{
156#if defined(CONFIG_SOC_SERIES_ESP32C6)
157 /* The machine performance counter (mpccr) counts CPU cycles. */
158 __asm__ volatile("csrw 0x7e0, %0" ::"r"(1));
159 __asm__ volatile("csrw 0x7e1, %0" ::"r"(1));
160#endif
161}
162
169
175
178
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif /* ESP_SDR_ESP_SDR_PACED_H_ */
bool(* esp_sdr_tx_paced_input_t)(void *user, int16_t *i, int16_t *q)
Definition esp_sdr_paced.h:108
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_r...
bool esp_sdr_rx_paced_poll(int32_t *i, int32_t *q)
Produce the next receive sample if it is due.
void esp_sdr_tx_paced_stop(void)
Turn the transmit chain off and release the radio; no-op when stopped.
uint32_t esp_sdr_paced_deadline(void)
When the running stream's next sample is due, on esp_sdr_paced_cycles().
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).
Definition esp_sdr_paced.h:140
void esp_sdr_paced_get_stats(struct esp_sdr_paced_stats *stats)
Statistics of the running or last stream.
void esp_sdr_rx_paced_stop(void)
Stop receiving and release the radio; no-op when stopped.
int esp_sdr_rx_paced_start(uint32_t rate_hz)
Start receiving at rate_hz.
bool esp_sdr_tx_paced_poll(void)
Write the next DAC value if it is due, then compute the one after.
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.
void esp_sdr_paced_sync(void)
Restart the running stream's clock: the next sample is due one period from now. Call once interrupts ...
static void esp_sdr_paced_cycles_enable(void)
Make esp_sdr_paced_cycles() count CPU cycles (a stream's start does it too).
Definition esp_sdr_paced.h:154
Definition esp_sdr_paced.h:55
uint32_t events
Definition esp_sdr_paced.h:63
uint64_t samples
Definition esp_sdr_paced.h:57
uint32_t late_max
Definition esp_sdr_paced.h:61
uint32_t late
Definition esp_sdr_paced.h:59