Skip to content

Commit

Permalink
Properly initialize alternate DW radios
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgecrw committed Sep 11, 2023
1 parent ceadedd commit 70b22ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions software/firmware/src/boards/revL/pinout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions software/firmware/src/peripherals/src/ranging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 70b22ae

Please sign in to comment.