AtomSoft
Well-Known Member
Hey all i know you all are probably tired of me making threads by now.
Im trying to figure out how to bitbang a SPI Slave and i have a theory only so please be nice when criticizing me
In theory i would think i need to wait for the SS or CS pin to go low so i would do:
meaning to wait until CS pin is low. Once its low continue.
Then i need to get the command which is 8 bits (1 byte)
I would also use the above to collect 1 byte of data at a time determined by command and other variables.
Do you think it would work?
Im trying to figure out how to bitbang a SPI Slave and i have a theory only so please be nice when criticizing me
In theory i would think i need to wait for the SS or CS pin to go low so i would do:
Code:
while(cs == 1);
meaning to wait until CS pin is low. Once its low continue.
Then i need to get the command which is 8 bits (1 byte)
Code:
char CMD,x=0; //ComManD
for(x=0;x<8;x++){ //loop 8 times
while(SCL == 0); //wait until CLOCK is HIGH to get bit (Serial CLock)
if(SDI) //if SDI pin is high (Serial Data In)
CMD|=1; //add a 1 if its high if not just shift (automatically a 0)
CMD=CMD<<1; //shift over 1
while(SCL == 1); //wait until CLOCK is LOW to get continue loop
}
I would also use the above to collect 1 byte of data at a time determined by command and other variables.
Do you think it would work?
Last edited: