Skip to content

Commit c02cf4c

Browse files
committed
stm32/machine_i2s: Correctly set the DMA transfer size.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 4277022 commit c02cf4c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ports/stm32/machine_i2s.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,13 +584,19 @@ STATIC bool i2s_init(machine_i2s_obj_t *self) {
584584

585585
if (HAL_I2S_Init(&self->hi2s) == HAL_OK) {
586586
// Reset and initialize Tx and Rx DMA channels
587+
uint32_t pm_size;
588+
if (self->hi2s.Init.DataFormat == I2S_DATAFORMAT_16B) {
589+
pm_size = DMA_PDATAALIGN_HALFWORD | DMA_MDATAALIGN_HALFWORD;
590+
} else {
591+
pm_size = DMA_PDATAALIGN_WORD | DMA_MDATAALIGN_WORD;
592+
}
587593
if (self->mode == I2S_MODE_MASTER_RX) {
588594
dma_invalidate_channel(self->dma_descr_rx);
589-
dma_init(&self->hdma_rx, self->dma_descr_rx, DMA_PERIPH_TO_MEMORY, &self->hi2s);
595+
dma_init_with_size(&self->hdma_rx, self->dma_descr_rx, DMA_PERIPH_TO_MEMORY, pm_size, &self->hi2s);
590596
self->hi2s.hdmarx = &self->hdma_rx;
591597
} else { // I2S_MODE_MASTER_TX
592598
dma_invalidate_channel(self->dma_descr_tx);
593-
dma_init(&self->hdma_tx, self->dma_descr_tx, DMA_MEMORY_TO_PERIPH, &self->hi2s);
599+
dma_init_with_size(&self->hdma_tx, self->dma_descr_tx, DMA_MEMORY_TO_PERIPH, pm_size, &self->hi2s);
594600
self->hi2s.hdmatx = &self->hdma_tx;
595601
}
596602

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy