Skip to content

Conversation

@welcometotheroot
Copy link
Contributor

The STM32L4xx series uses a channel-based DMA with CSELR (Channel Selection Register) for request routing, distinct from F2/F4/F7 (stream+channel), F1 (hardwired channels), and L4+ (DMAMUX).

Header (TFT_eSPI_STM32.h):

  • Add STM32L4xx detection block between F1xx and the fallback
  • Define STM32_DMA to enable DMA code paths
  • Map SPI1_TX to DMA1_Channel3, SPI2_TX to DMA1_Channel5

Source (TFT_eSPI_STM32.c):

  • Add DMA IRQ handlers for STM32L4 (DMA1_Channel3/5)
  • Add initDMA() with CSELR routing via DMA_REQUEST_1
  • Set spiHal.State = HAL_SPI_STATE_READY before first use, since spiHal is a separate handle from Arduino's internal SPI and only has Instance set via INIT_TFT_DATA_BUS. Without this, HAL_SPI_Transmit_DMA silently returns HAL_BUSY on every call.

Tested on STM32L412KB with ST7735 80x160 display on SPI1 at 40MHz.

The STM32L4xx series uses a channel-based DMA with CSELR (Channel
Selection Register) for request routing, distinct from F2/F4/F7
(stream+channel), F1 (hardwired channels), and L4+ (DMAMUX).

Header (TFT_eSPI_STM32.h):
- Add STM32L4xx detection block between F1xx and the fallback
- Define STM32_DMA to enable DMA code paths
- Map SPI1_TX to DMA1_Channel3, SPI2_TX to DMA1_Channel5

Source (TFT_eSPI_STM32.c):
- Add DMA IRQ handlers for STM32L4 (DMA1_Channel3/5)
- Add initDMA() with CSELR routing via DMA_REQUEST_1
- Set spiHal.State = HAL_SPI_STATE_READY before first use, since
  spiHal is a separate handle from Arduino's internal SPI and only
  has Instance set via INIT_TFT_DATA_BUS. Without this,
  HAL_SPI_Transmit_DMA silently returns HAL_BUSY on every call.

Tested on STM32L412KB with ST7735 80x160 display on SPI1 at 40MHz.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Owner

@Bodmer Bodmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the input to the library.

@Bodmer Bodmer merged commit 202c310 into Bodmer:master Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants