mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-04 06:16:42 +00:00
Merge pull request #14 from Caemor/fix-os-90-spi-message-on-linux-too-long
Set spi chunk limit on linux with cfg! to fix error
This commit is contained in:
+11
-1
@@ -100,8 +100,18 @@ where
|
|||||||
{
|
{
|
||||||
// activate spi with cs low
|
// activate spi with cs low
|
||||||
self.cs.set_low();
|
self.cs.set_low();
|
||||||
|
|
||||||
// transfer spi data
|
// transfer spi data
|
||||||
spi.write(data)?;
|
// Be careful!! Linux has a default limit of 4096 bytes per spi transfer
|
||||||
|
// see https://raspberrypi.stackexchange.com/questions/65595/spi-transfer-fails-with-buffer-size-greater-than-4096
|
||||||
|
if cfg!(target_os = "linux") {
|
||||||
|
for data_chunk in data.chunks(4096) {
|
||||||
|
spi.write(data_chunk)?;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
spi.write(data)?;
|
||||||
|
}
|
||||||
|
|
||||||
// deativate spi with cs high
|
// deativate spi with cs high
|
||||||
self.cs.set_high();
|
self.cs.set_high();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user