From 2195c46dbf7e7a35fde8ed9a2bf1a7fc7e828ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= Date: Thu, 3 Jul 2025 19:28:52 +0200 Subject: [PATCH] Update for simpler AFE --- src/main.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/main.c b/src/main.c index b4869eb..1a43d0a 100644 --- a/src/main.c +++ b/src/main.c @@ -29,8 +29,8 @@ #define INIT_GAIN 127 #define LO_PIN 9 -#define RX_PIN 13 -#define FB_PIN 5 +#define RX_PIN 10 +#define FB_PIN 11 #define PSU_PIN 23 #define PIO pio1 @@ -161,17 +161,12 @@ static void init_fb() gpio_disable_pulls(FB_PIN); pio_gpio_init(PIO, FB_PIN); - // NOTE: Not sure if this is ideal. - hw_set_bits(&PIO->input_sync_bypass, 1u << RX_PIN); - gpio_set_input_hysteresis_enabled(RX_PIN, false); gpio_set_drive_strength(FB_PIN, GPIO_DRIVE_STRENGTH_2MA); gpio_set_slew_rate(FB_PIN, GPIO_SLEW_RATE_SLOW); const uint16_t insn[] = { - pio_encode_mov_not(pio_pins, pio_pins) | pio_encode_sideset(1, 1) | - pio_encode_delay(0), - //pio_encode_nop() | pio_encode_sideset(1, 0) | pio_encode_delay(0), + pio_encode_mov_not(pio_pins, pio_pins) | pio_encode_delay(3), }; pio_program_t prog = { @@ -187,11 +182,9 @@ static void init_fb() origin_fb = pio_add_program(PIO, &prog); pio_sm_config pc = pio_get_default_sm_config(); - sm_config_set_sideset(&pc, 1, false, true); sm_config_set_in_pins(&pc, RX_PIN); sm_config_set_out_pins(&pc, FB_PIN, 1); sm_config_set_set_pins(&pc, FB_PIN, 1); - sm_config_set_sideset_pins(&pc, FB_PIN); sm_config_set_wrap(&pc, origin_fb, origin_fb + prog.length - 1); sm_config_set_clkdiv_int_frac(&pc, 1, 0); pio_sm_init(PIO, SM_FB, origin_fb, &pc); @@ -288,9 +281,9 @@ static void init_ad() static void lo_generate_phase(uint32_t *buf, size_t len, uint32_t step, uint32_t phase) { - for (size_t i = 0; i < len; i++) { - uint32_t bits = 0; + uint32_t bits = 0; + for (size_t i = 0; i < len; i++) { for (int j = 0; j < 32; j++) { bits <<= 1; bits |= phase >> 31;