|
|
@ -760,12 +760,14 @@ STATIC mp_obj_t pyb_i2c_send(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ |
|
|
|
if (!use_dma) { |
|
|
|
status = HAL_I2C_Master_Transmit(self->i2c, i2c_addr, bufinfo.buf, bufinfo.len, args[2].u_int); |
|
|
|
} else { |
|
|
|
MP_HAL_CLEAN_DCACHE(bufinfo.buf, bufinfo.len); |
|
|
|
status = HAL_I2C_Master_Transmit_DMA(self->i2c, i2c_addr, bufinfo.buf, bufinfo.len); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!use_dma) { |
|
|
|
status = HAL_I2C_Slave_Transmit(self->i2c, bufinfo.buf, bufinfo.len, args[2].u_int); |
|
|
|
} else { |
|
|
|
MP_HAL_CLEAN_DCACHE(bufinfo.buf, bufinfo.len); |
|
|
|
status = HAL_I2C_Slave_Transmit_DMA(self->i2c, bufinfo.buf, bufinfo.len); |
|
|
|
} |
|
|
|
} |
|
|
@ -834,12 +836,14 @@ STATIC mp_obj_t pyb_i2c_recv(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ |
|
|
|
if (!use_dma) { |
|
|
|
status = HAL_I2C_Master_Receive(self->i2c, i2c_addr, (uint8_t*)vstr.buf, vstr.len, args[2].u_int); |
|
|
|
} else { |
|
|
|
MP_HAL_CLEANINVALIDATE_DCACHE(vstr.buf, vstr.len); |
|
|
|
status = HAL_I2C_Master_Receive_DMA(self->i2c, i2c_addr, (uint8_t*)vstr.buf, vstr.len); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!use_dma) { |
|
|
|
status = HAL_I2C_Slave_Receive(self->i2c, (uint8_t*)vstr.buf, vstr.len, args[2].u_int); |
|
|
|
} else { |
|
|
|
MP_HAL_CLEANINVALIDATE_DCACHE(vstr.buf, vstr.len); |
|
|
|
status = HAL_I2C_Slave_Receive_DMA(self->i2c, (uint8_t*)vstr.buf, vstr.len); |
|
|
|
} |
|
|
|
} |
|
|
@ -920,6 +924,7 @@ STATIC mp_obj_t pyb_i2c_mem_read(mp_uint_t n_args, const mp_obj_t *pos_args, mp_ |
|
|
|
dma_init(&rx_dma, self->rx_dma_descr, self->i2c); |
|
|
|
self->i2c->hdmatx = NULL; |
|
|
|
self->i2c->hdmarx = &rx_dma; |
|
|
|
MP_HAL_CLEANINVALIDATE_DCACHE(vstr.buf, vstr.len); |
|
|
|
status = HAL_I2C_Mem_Read_DMA(self->i2c, i2c_addr, mem_addr, mem_addr_size, (uint8_t*)vstr.buf, vstr.len); |
|
|
|
if (status == HAL_OK) { |
|
|
|
status = i2c_wait_dma_finished(self->i2c, args[3].u_int); |
|
|
@ -988,6 +993,7 @@ STATIC mp_obj_t pyb_i2c_mem_write(mp_uint_t n_args, const mp_obj_t *pos_args, mp |
|
|
|
dma_init(&tx_dma, self->tx_dma_descr, self->i2c); |
|
|
|
self->i2c->hdmatx = &tx_dma; |
|
|
|
self->i2c->hdmarx = NULL; |
|
|
|
MP_HAL_CLEAN_DCACHE(bufinfo.buf, bufinfo.len); |
|
|
|
status = HAL_I2C_Mem_Write_DMA(self->i2c, i2c_addr, mem_addr, mem_addr_size, bufinfo.buf, bufinfo.len); |
|
|
|
if (status == HAL_OK) { |
|
|
|
status = i2c_wait_dma_finished(self->i2c, args[3].u_int); |
|
|
|