spi_slave: auto deselect chip

This commit is contained in:
occheung 2020-08-18 15:25:32 +08:00
parent 8547610661
commit 6e6e500f8a
1 changed files with 3 additions and 1 deletions

View File

@ -49,7 +49,9 @@ where
fn transfer<'w>(&mut self, words: &'w mut[u8]) -> Result<&'w [u8], Self::Error> { fn transfer<'w>(&mut self, words: &'w mut[u8]) -> Result<&'w [u8], Self::Error> {
self.0.do_on_get_ref_mut_data(move |mut dev| { self.0.do_on_get_ref_mut_data(move |mut dev| {
dev.select_chip(self.1); dev.select_chip(self.1);
dev.spi.transfer(words).map_err(Error::SPI) let result = dev.spi.transfer(words).map_err(Error::SPI);
dev.select_chip(0);
result
}) })
} }
} }