#include #include "intrins.h" #include "spi.h" #include "spi_cfg.h" #define Delay10us() {_nop_();_nop_();} //----------------------------------------------------------------------------- void CS_HIGH(void) { SS = 1; } void CS_LOW(void) { SS = 0 ; } unsigned char spiReadWrite(unsigned char Byte) { unsigned char i; EA = 0; for (i = 0; i < 8; i++) { MOSI = (Byte & 0x80); SCLK = 1; Delay10us(); Byte <<= 1; Byte |= MISO; SCLK = 0; Delay10us(); } EA = 1; return (Byte); }