22
33//! Generic SPI interface for display drivers
44
5- use embedded_hal:: digital:: blocking:: OutputPin ;
6- use embedded_hal:: spi:: blocking:: Write ;
5+ use embedded_hal:: {
6+ digital:: blocking:: OutputPin ,
7+ spi:: blocking:: { SpiBusWrite , SpiDevice } ,
8+ } ;
79
810use display_interface:: { DataFormat , DisplayError , WriteOnlyDataCommand } ;
911
1012type Result = core:: result:: Result < ( ) , DisplayError > ;
1113
12- fn send_u8 < SPI : Write < u8 > > ( spi : & mut SPI , words : DataFormat < ' _ > ) -> Result {
14+ fn send_u8 < SPI > ( spi : & mut SPI , words : DataFormat < ' _ > ) -> Result
15+ where
16+ SPI : SpiDevice ,
17+ SPI :: Bus : SpiBusWrite ,
18+ {
1319 match words {
1420 DataFormat :: U8 ( slice) => spi. write ( slice) . map_err ( |_| DisplayError :: BusWriteError ) ,
1521 DataFormat :: U16 ( slice) => {
@@ -115,7 +121,8 @@ pub struct SPIInterface<SPI, DC, CS> {
115121
116122impl < SPI , DC , CS > SPIInterface < SPI , DC , CS >
117123where
118- SPI : Write < u8 > ,
124+ SPI : SpiDevice ,
125+ SPI :: Bus : SpiBusWrite ,
119126 DC : OutputPin ,
120127 CS : OutputPin ,
121128{
@@ -149,7 +156,8 @@ where
149156
150157impl < SPI , DC , CS > WriteOnlyDataCommand for SPIInterface < SPI , DC , CS >
151158where
152- SPI : Write < u8 > ,
159+ SPI : SpiDevice ,
160+ SPI :: Bus : SpiBusWrite ,
153161 DC : OutputPin ,
154162 CS : OutputPin ,
155163{
@@ -172,7 +180,8 @@ pub struct SPIInterfaceNoCS<SPI, DC> {
172180
173181impl < SPI , DC > SPIInterfaceNoCS < SPI , DC >
174182where
175- SPI : Write < u8 > ,
183+ SPI : SpiDevice ,
184+ SPI :: Bus : SpiBusWrite ,
176185 DC : OutputPin ,
177186{
178187 /// Create new SPI interface for communciation with a display driver
@@ -189,7 +198,8 @@ where
189198
190199impl < SPI , DC > WriteOnlyDataCommand for SPIInterfaceNoCS < SPI , DC >
191200where
192- SPI : Write < u8 > ,
201+ SPI : SpiDevice ,
202+ SPI :: Bus : SpiBusWrite ,
193203 DC : OutputPin ,
194204{
195205 fn send_commands ( & mut self , cmds : DataFormat < ' _ > ) -> Result {
0 commit comments