Yeah, your code seems to indicate that you are waiting for the clock line to do something?

Your device must generate the clock in this case.