From 70b22ae4125a96226779f50f95594440d84b84f6 Mon Sep 17 00:00:00 2001 From: Will Hedgecock Date: Mon, 11 Sep 2023 11:50:32 -0500 Subject: [PATCH] Properly initialize alternate DW radios --- software/firmware/src/boards/revL/pinout.h | 4 ++++ .../firmware/src/peripherals/src/ranging.c | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/software/firmware/src/boards/revL/pinout.h b/software/firmware/src/boards/revL/pinout.h index 83e28548..3f843deb 100644 --- a/software/firmware/src/boards/revL/pinout.h +++ b/software/firmware/src/boards/revL/pinout.h @@ -27,8 +27,12 @@ #define PIN_RADIO_SPI_CS2 24 #define PIN_RADIO_SPI_CS3 25 #define PIN_RADIO_INTERRUPT 27 +#define PIN_RADIO_INTERRUPT2 51 +#define PIN_RADIO_INTERRUPT3 79 #define PIN_RADIO_RESET 50 #define PIN_RADIO_WAKEUP 26 +#define PIN_RADIO_WAKEUP2 53 +#define PIN_RADIO_WAKEUP3 88 #define PIN_RADIO_SPI_SCK_FUNCTION AM_HAL_PIN_31_M3SCK #define PIN_RADIO_SPI_MISO_FUNCTION AM_HAL_PIN_33_M3MISO #define PIN_RADIO_SPI_MOSI_FUNCTION AM_HAL_PIN_32_M3MOSI diff --git a/software/firmware/src/peripherals/src/ranging.c b/software/firmware/src/peripherals/src/ranging.c index 23ef6bcf..fe28441f 100644 --- a/software/firmware/src/peripherals/src/ranging.c +++ b/software/firmware/src/peripherals/src/ranging.c @@ -145,6 +145,12 @@ void ranging_radio_init(uint8_t *uid) // Set up the DW3000 wake-up pin as an output, initially set to low configASSERT0(am_hal_gpio_pinconfig(PIN_RADIO_WAKEUP, am_hal_gpio_pincfg_output)); am_hal_gpio_output_clear(PIN_RADIO_WAKEUP); +#if REVISION_ID >= REVISION_L + configASSERT0(am_hal_gpio_pinconfig(PIN_RADIO_WAKEUP2, am_hal_gpio_pincfg_output)); + am_hal_gpio_output_clear(PIN_RADIO_WAKEUP2); + configASSERT0(am_hal_gpio_pinconfig(PIN_RADIO_WAKEUP3, am_hal_gpio_pincfg_output)); + am_hal_gpio_output_clear(PIN_RADIO_WAKEUP3); +#endif // Set up the DW3000 antenna selection pins #if REVISION_ID < REVISION_L @@ -167,6 +173,22 @@ void ranging_radio_init(uint8_t *uid) configASSERT0(am_hal_gpio_interrupt_control(AM_HAL_GPIO_INT_CHANNEL_0, AM_HAL_GPIO_INT_CTRL_INDV_ENABLE, &radio_interrupt_pin)); NVIC_SetPriority(GPIO0_001F_IRQn + GPIO_NUM2IDX(PIN_RADIO_INTERRUPT), NVIC_configMAX_SYSCALL_INTERRUPT_PRIORITY); NVIC_EnableIRQ(GPIO0_001F_IRQn + GPIO_NUM2IDX(PIN_RADIO_INTERRUPT)); +#if REVISION_ID >= REVISION_L + radio_interrupt_pin = PIN_RADIO_INTERRUPT2; + am_hal_gpio_pincfg_t interrupt_pin_config = AM_HAL_GPIO_PINCFG_INPUT; + interrupt_pin_config.GP.cfg_b.ePullup = AM_HAL_GPIO_PIN_PULLDOWN_50K; + configASSERT0(am_hal_gpio_pinconfig(PIN_RADIO_INTERRUPT2, interrupt_pin_config)); + configASSERT0(am_hal_gpio_interrupt_control(AM_HAL_GPIO_INT_CHANNEL_0, AM_HAL_GPIO_INT_CTRL_INDV_ENABLE, &radio_interrupt_pin)); + //NVIC_SetPriority(GPIO0_001F_IRQn + GPIO_NUM2IDX(PIN_RADIO_INTERRUPT2), NVIC_configMAX_SYSCALL_INTERRUPT_PRIORITY); + //NVIC_EnableIRQ(GPIO0_001F_IRQn + GPIO_NUM2IDX(PIN_RADIO_INTERRUPT2)); + radio_interrupt_pin = PIN_RADIO_INTERRUPT3; + am_hal_gpio_pincfg_t interrupt_pin_config = AM_HAL_GPIO_PINCFG_INPUT; + interrupt_pin_config.GP.cfg_b.ePullup = AM_HAL_GPIO_PIN_PULLDOWN_50K; + configASSERT0(am_hal_gpio_pinconfig(PIN_RADIO_INTERRUPT3, interrupt_pin_config)); + configASSERT0(am_hal_gpio_interrupt_control(AM_HAL_GPIO_INT_CHANNEL_0, AM_HAL_GPIO_INT_CTRL_INDV_ENABLE, &radio_interrupt_pin)); + //NVIC_SetPriority(GPIO0_001F_IRQn + GPIO_NUM2IDX(PIN_RADIO_INTERRUPT3), NVIC_configMAX_SYSCALL_INTERRUPT_PRIORITY); + //NVIC_EnableIRQ(GPIO0_001F_IRQn + GPIO_NUM2IDX(PIN_RADIO_INTERRUPT3)); +#endif // Initialize the SPI module and enable all relevant SPI pins am_hal_gpio_pincfg_t sck_config = g_AM_BSP_GPIO_IOM0_SCK;