Compare commits
2 commits
c6b7407588
...
f5fb02c190
Author | SHA1 | Date | |
---|---|---|---|
f5fb02c190 | |||
24d6acdb53 |
1 changed files with 19 additions and 6 deletions
25
src/main.c
25
src/main.c
|
@ -25,7 +25,7 @@
|
|||
#define CLK_SYS_HZ (300 * MHZ)
|
||||
|
||||
#define LO_PIN 9
|
||||
#define RX_PIN 13
|
||||
#define RX_PIN 8
|
||||
#define FB_PIN 5
|
||||
#define PSU_PIN 23
|
||||
|
||||
|
@ -87,6 +87,14 @@ static queue_t iq_queue;
|
|||
static uint8_t iq_queue_buffer[IQ_QUEUE_LEN][IQ_BLOCK_LEN];
|
||||
static size_t iq_queue_pos = 0;
|
||||
|
||||
static uint32_t rnd = 0;
|
||||
|
||||
inline static __unused uint32_t rnd_next()
|
||||
{
|
||||
rnd = rnd * 0x41c64e6d + 12345;
|
||||
return rnd;
|
||||
}
|
||||
|
||||
static void dma_channel_clear_chain_to(int ch)
|
||||
{
|
||||
uint32_t ctrl = dma_hw->ch[ch].al1_ctrl;
|
||||
|
@ -128,7 +136,7 @@ static void init_lo()
|
|||
sm_config_set_out_shift(&pc, false, true, 32);
|
||||
pio_sm_init(PIO, LO_SM, prog.origin, &pc);
|
||||
|
||||
pio_sm_set_consecutive_pindirs(PIO, LO_SM, LO_PIN, 1, GPIO_OUT);
|
||||
pio_sm_set_consecutive_pindirs(PIO, LO_SM, LO_PIN, 1, GPIO_IN);
|
||||
pio_sm_exec_wait_blocking(PIO, LO_SM, pio_encode_set(pio_pins, 0));
|
||||
}
|
||||
|
||||
|
@ -477,10 +485,12 @@ static void rf_rx(void)
|
|||
int head = (dma_hw->ch[dma_ch_in_cos].write_addr - base) / 4;
|
||||
int delta = (head < pos ? head + RX_WORDS : head) - pos;
|
||||
|
||||
sleep_us(10);
|
||||
|
||||
while (delta < RX_STRIDE) {
|
||||
sleep_us(1);
|
||||
int wait = rnd_next() & 63;
|
||||
|
||||
for (int i = 0; i < wait; i++)
|
||||
asm volatile("nop");
|
||||
|
||||
head = (dma_hw->ch[dma_ch_in_cos].write_addr - base) / 4;
|
||||
delta = (head < pos ? head + RX_WORDS : head) - pos;
|
||||
}
|
||||
|
@ -616,7 +626,10 @@ static void do_rx()
|
|||
fwrite(block, IQ_BLOCK_LEN, 1, stdout);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
sleep_us(25);
|
||||
int wait = rnd_next() & 0x1fff;
|
||||
|
||||
for (int i = 0; i < wait; i++)
|
||||
asm volatile("nop");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue