Shows SPI activity. Replace SPI with SPIDebug, and replace chip select's DigitalOutput with CSDebug. Outputs debug info on stdout. Currently only outputs 8-bit debug info. Easy enough to change that if your SPI debug uses a larger data width.

Dependents:   SST25VF064C

Revision:
0:0f32ac84dca5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SPIDebug.h	Tue Apr 10 04:42:12 2012 +0000
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////////
+// SPIDebug.h
+//
+// COPYRIGHT (c) 2012 by David Van Wagner
+//
+// dave@vanwagner.org
+// http://techwithdave.blogspot.com
+//
+// License: Creative Commons Attribution-ShareAlike 3.0 Unported License
+// http://creativecommons.org/licenses/by-sa/3.0/
+///////////////////////////////////////////////////////////////////////////////
+
+#include <mbed.h>
+
+class SPIDebug
+{
+private:
+    SPI* spi;
+    
+public:
+    SPIDebug(PinName mosi, PinName miso, PinName sclk, const char *name = NULL);
+    virtual ~SPIDebug();
+    void format(int bits, int mode = 0);
+    void frequency(int hz = 10000000);
+    virtual int write(int value);
+    static bool debug; // allow to be changed to control whether there are debug messages
+};
+
+class CSDebug
+{
+private:
+    DigitalOut* cs;
+
+public:
+    CSDebug(PinName pin);
+    ~CSDebug();
+    void write(bool state);
+};