Avoid losing sampling timer on reset

This commit is contained in:
Jan Hamal Dvořák 2024-08-02 23:16:00 +02:00
parent 6b444587b6
commit 3410740b4a

View file

@ -322,8 +322,6 @@ static void rf_rx_start()
dma_ch_samp_cos = dma_claim_unused_channel(true);
dma_t_samp = dma_claim_unused_timer(true);
dma_channel_config dma_conf;
/* Copy PDM bitstream into decimator. */
@ -363,9 +361,6 @@ static void rf_rx_start()
dma_channel_configure(dma_ch_mix2, &dma_conf, &PIO->txf[LO_SM], NULL, LO_PHASE_WORDS,
false);
/* Pacing timer for the sampling script trigger channel. */
dma_timer_set_fraction(dma_t_samp, 1, CLK_SYS_HZ / (sample_rate * DECIMATE));
/* Trigger accumulator values push. */
dma_conf = dma_channel_get_default_config(dma_ch_samp_cos);
channel_config_set_transfer_data_size(&dma_conf, DMA_SIZE_32);
@ -562,7 +557,7 @@ static void run_command(uint8_t cmd, uint32_t arg)
if (0x01 == cmd) {
/* Tune to a new center frequency */
frequency = arg;
rx_lo_init(arg + sample_rate, true);
rx_lo_init(frequency + sample_rate, true);
} else if (0x02 == cmd) {
/* Set the rate at which IQ sample pairs are sent */
sample_rate = arg;
@ -684,6 +679,9 @@ int main()
rx_lo_init(frequency + sample_rate, true);
dma_t_samp = dma_claim_unused_timer(true);
dma_timer_set_fraction(dma_t_samp, 1, CLK_SYS_HZ / (sample_rate * DECIMATE));
while (true) {
if (check_command() > 0) {
static const uint32_t header[3] = { __builtin_bswap32(0x52544c30),