From 6b89ee1b8eaa783f25c265a4f5af0f7246315c01 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 12 Oct 2018 11:30:04 +0200 Subject: [PATCH] Set spi chunk limit on linux with cfg! Not tested yet --- src/interface.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/interface.rs b/src/interface.rs index 1b1a6b9..76cbde5 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -100,8 +100,17 @@ where { // activate spi with cs low self.cs.set_low(); + // transfer spi data - spi.write(data)?; + // Be careful!! Linux has a default limit of 4096 bytes per spi transfer + 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 self.cs.set_high();