A buffer can be reset individuelly

This commit is contained in:
anton smeenk 2023-11-01 17:09:11 +01:00
parent 9474f1576a
commit ba9f5111d5

View File

@ -1114,13 +1114,11 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
buf.from_buffer(buffer) buf.from_buffer(buffer)
}) })
} }
pub fn slave_reset_buffer(&self, address_type: AddressType) { pub fn slave_reset_buffer(&self, dir: Dir, address_type: AddressType) {
T::state().mutex.lock(|f| { T::state().mutex.lock(|f| {
let mut state_m = f.borrow_mut(); let mut state_m = f.borrow_mut();
let buf_r = &mut state_m.buffers[address_type as usize][Dir::READ as usize]; let buf = &mut state_m.buffers[address_type as usize][dir as usize];
buf_r.reset(); buf.reset();
let buf_w = &mut state_m.buffers[address_type as usize][Dir::WRITE as usize];
buf_w.reset();
}) })
} }