STM32CubeWL
STM32CubeWL copied to clipboard
SUBGHZ HAL driver using SPI polling and not DMA... too slow
Hi there!
I have measured the SPI comms using a logic analyzer:
As you can see there is plenty room for improvement using DMA instead of polling. I'm referring to stm32wlxx_hal_subghz.c SUBGHZSPI_Transmit() and SUBGHZSPI_Receive(): https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c#L1626-L1735
It would be better to formulate the SPI packet for transfer and then use DMA. This means that a HAL_SUBGHZ_ReadRegisters() would have to be rewritten: https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c#L863-L917
These unnecessary delays between each SPI byte will impact battery life. It is most notable when transmitting or receiving a large packet.
Best regards, Pieter https://piconomix.com