00001 #ifndef _spisinkh_ 00002 #define _spisinkh_ 00003 #include "avrdevice.h" 00004 00005 // This class monitors the /SS, SCLK, and MISO pin of the AVR and 00006 // prints the results one byte at a time to stdout. 00007 // PetrH: Implemented using simulated polling (each 1 us). TODO: Rewrite. 00008 class SpiSink : public SimulationMember { 00009 private: 00010 unsigned char _port; 00011 Pin _ss; // Output to AVR 00012 Pin _sclk; // Output to AVR 00013 Pin _miso; // Output to AVR 00014 bool _ssState; 00015 bool _sclkState; 00016 bool _misoState; 00017 unsigned _state; 00018 unsigned char _sr; 00019 bool _clockIsIdleHigh; 00020 bool _clockSampleOnLeadingEdge; 00021 bool _prevClkState; 00022 bool _prevSS; 00023 public: 00024 SpiSink( Net& ssNet, 00025 Net& sclkNet, 00026 Net& misoNet, 00027 bool clockIsIdleHigh = true, 00028 bool clockSampleOnLeadingEdge = true 00029 ) throw(); 00030 private: // SimulationMember 00031 int Step(bool &trueHwStep, SystemClockOffset *timeToNextStepIn_ns=0); 00032 00033 }; 00034 00035 #endif