From 6e6e500f8a4f4ba610c7df3dcc209cb4372255a5 Mon Sep 17 00:00:00 2001 From: occheung Date: Tue, 18 Aug 2020 15:25:32 +0800 Subject: [PATCH] spi_slave: auto deselect chip --- src/spi_slave.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/spi_slave.rs b/src/spi_slave.rs index c4a1fb6..159e460 100644 --- a/src/spi_slave.rs +++ b/src/spi_slave.rs @@ -49,7 +49,9 @@ where 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| { 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 }) } }