Skip to content

Commit 07200fb

Browse files
committed
stm32/i2c: Ensure buffer is DMA-compatible before transfer.
1 parent 6132b6e commit 07200fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ports/stm32/pyb_i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ static mp_obj_t pyb_i2c_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
843843
pyb_buf_get_for_send(args[0].u_obj, &bufinfo, data);
844844

845845
// if option is set and IRQs are enabled then we can use DMA
846-
bool use_dma = *self->use_dma && query_irq() == IRQ_STATE_ENABLED;
846+
bool use_dma = (*self->use_dma && query_irq() == IRQ_STATE_ENABLED && DMA_BUFFER(bufinfo.buf));
847847

848848
DMA_HandleTypeDef tx_dma;
849849
if (use_dma) {
@@ -1019,7 +1019,7 @@ static mp_obj_t pyb_i2c_mem_read(size_t n_args, const mp_obj_t *pos_args, mp_map
10191019
}
10201020

10211021
// if option is set and IRQs are enabled then we can use DMA
1022-
bool use_dma = *self->use_dma && query_irq() == IRQ_STATE_ENABLED;
1022+
bool use_dma = (*self->use_dma && query_irq() == IRQ_STATE_ENABLED && DMA_BUFFER(vstr.buf));
10231023

10241024
HAL_StatusTypeDef status;
10251025
if (!use_dma) {

0 commit comments

Comments
 (0)