heto po (courtesy of XNA_7 aka sevenstring):
unsigned int SerialToParallel_16bit(void)
{
unsigned int myData=0;
unsigned char ctr = 15; //we have 16 bits to shift in
CLK=0; //map to port pin
CS=0; //map to port pin. SO is also mapped to a port pin
do
{
if (SO) myData |= (1U<<ctr); //if the SO pin is high, shift 0x0001 "ctr" times to right then logical-OR that value to myDATA's value.
CLK=1; //shift in the next serial data bit using this high-to-....
CLK=0; // ... low clock transition.
ctr--; // update our bit counter
}
while (ctr != 255);// let it overflow hehe (because when ctr == 0, the SO pin still holds the last data bit and must be process still)
CS=1
return myData;
}