// One way communication from ATMEGA8 to host PC through SCK and MISO // lines without any addiontional hardware support on the ATMEL side, // and no device drivers on the host PC side. // // Why // No additional soldering needed to get (debugging) output, // since it uses the same lines as the ISP parallel programmer. // // On the ATMEL side: // - uses a polling loop which monitors the clock (SCK) // - uses MISO to send the data bit by bit // - continues after a timeout if no one is listening on the other // side. // On the host PC side: // - uses the parallel port (could be extended though) // - uses SCK to drive the clock to indicate the ATMEL we're ready // to receive the next bit. // // The speed is dependant on the speed the host PC toggles the clock // and whether the ATMEL can keep up. When the ATMEL runs at 1Mhz, I // get to ~100kbaud with some errors. // // TODO // - make communication bi-directional instead of only from // ATMEL to host PC using MOSI. Easy to do, just use MOSI also. // - add parity for error detection? // - make CPU configurable by making location of SCK/MISO pins // configurable. // - Use SPI protocol instead? // // (c)2005 R. Nijlunsing // License: LGPL (see http://www.gnu.org/copyleft/lesser.html) #include #include // All functions are defined extern to make them easy to include in a // library. However, for optimisations like skip-unused-functions use // one source file like 'main.c' which includes: // #define extern static // #include "msio.c" // ..and compile with something like: // gcc -finline-functions -funit-at-a-time main.c // See msio.c for explanation of functions. extern void msioInit(void); extern uint8_t msioSendByte(uint8_t s); extern uint8_t msioSendString(char *buffer); extern uint8_t msioSendUINT8_T(char *fmt, uint8_t val);