From 4e80db2b3f06633c55fbd1d4806bc6af66bfb638 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 19 Mar 2015 21:20:06 +0100 Subject: [PATCH] Use setClockSpeed to increase SPI clock speed This is only available in newer version of the API. It can be downloaded here: http://www.intel.com/support/edison/sb/CS-035180.htm and can both be used with the Edison and the Galileo Note that I tried to set the clock rate higher than 12 MHz, but it did not work --- usbhost.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usbhost.h b/usbhost.h index da710a1b..0a2b7bff 100644 --- a/usbhost.h +++ b/usbhost.h @@ -51,7 +51,11 @@ public: #if defined(__MIPSEL__) SPI.setClockDivider(1); #elif defined(__ARDUINO_X86__) - SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the API + #ifdef SPI_CLOCK_1M // Hack used to check if setClockSpeed is available + SPI.setClockSpeed(12000000); // The MAX3421E can handle up to 26MHz, but in practice this was the maximum that I could reliably use + #else + SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the old API + #endif #else SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz #endif