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

Committer:
davervw
Date:
Tue Apr 10 04:42:12 2012 +0000
Revision:
0:0f32ac84dca5
SPIDebug library initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davervw 0:0f32ac84dca5 1 ///////////////////////////////////////////////////////////////////////////////
davervw 0:0f32ac84dca5 2 // SPIDebug.h
davervw 0:0f32ac84dca5 3 //
davervw 0:0f32ac84dca5 4 // COPYRIGHT (c) 2012 by David Van Wagner
davervw 0:0f32ac84dca5 5 //
davervw 0:0f32ac84dca5 6 // dave@vanwagner.org
davervw 0:0f32ac84dca5 7 // http://techwithdave.blogspot.com
davervw 0:0f32ac84dca5 8 //
davervw 0:0f32ac84dca5 9 // License: Creative Commons Attribution-ShareAlike 3.0 Unported License
davervw 0:0f32ac84dca5 10 // http://creativecommons.org/licenses/by-sa/3.0/
davervw 0:0f32ac84dca5 11 ///////////////////////////////////////////////////////////////////////////////
davervw 0:0f32ac84dca5 12
davervw 0:0f32ac84dca5 13 #include <mbed.h>
davervw 0:0f32ac84dca5 14
davervw 0:0f32ac84dca5 15 class SPIDebug
davervw 0:0f32ac84dca5 16 {
davervw 0:0f32ac84dca5 17 private:
davervw 0:0f32ac84dca5 18 SPI* spi;
davervw 0:0f32ac84dca5 19
davervw 0:0f32ac84dca5 20 public:
davervw 0:0f32ac84dca5 21 SPIDebug(PinName mosi, PinName miso, PinName sclk, const char *name = NULL);
davervw 0:0f32ac84dca5 22 virtual ~SPIDebug();
davervw 0:0f32ac84dca5 23 void format(int bits, int mode = 0);
davervw 0:0f32ac84dca5 24 void frequency(int hz = 10000000);
davervw 0:0f32ac84dca5 25 virtual int write(int value);
davervw 0:0f32ac84dca5 26 static bool debug; // allow to be changed to control whether there are debug messages
davervw 0:0f32ac84dca5 27 };
davervw 0:0f32ac84dca5 28
davervw 0:0f32ac84dca5 29 class CSDebug
davervw 0:0f32ac84dca5 30 {
davervw 0:0f32ac84dca5 31 private:
davervw 0:0f32ac84dca5 32 DigitalOut* cs;
davervw 0:0f32ac84dca5 33
davervw 0:0f32ac84dca5 34 public:
davervw 0:0f32ac84dca5 35 CSDebug(PinName pin);
davervw 0:0f32ac84dca5 36 ~CSDebug();
davervw 0:0f32ac84dca5 37 void write(bool state);
davervw 0:0f32ac84dca5 38 };