/*Shif out function */ void doSPI_Msb_First(unsigned char d) //Shift out MSB first { unsigned char i; for(i = 0; i< 8; i++) { SDA = 0; if(d & 0x80) { //write the bit if ONE SDA = 1; } SCK = 0; //pulse the clock OFF to ON SCK = 1; //OFF->ON = rising edge d <<= 1; //displace data one bit left } } void doSPI_Lsb_First(unsigned char d) //Shift out LSB first { unsigned char i; for(i = 0; i< 8; i++) { SDA = 0; if(d & 0x01) { //write the bit if ONE SDA = 1; } SCK = 0; //pulse the clock OFF to ON SCK = 1; //OFF->ON = rising edge d >>= 1; //displace data one bit right } }