SPI BIT BANG CODE IMPLEMENTATION

Do a bit of googling on software SPI.

I see lots of implementations. One in the Arduino libraries - open source. And others.

Master asserts chip select (a GPIO output pin connected to the slave device’s chip select). Assert usually means a 0 is output.

On most devices, the master then sends a command byte (rarely, two bytes), placing each data bit 1 or 0 on the GPIO data line, then toggling the clock GPIO with a square wave with a period of, say, 1 microsecond.

After the command is sent, and a brief delay (device specific), the master changes the GPIO data to an input with pullup. Then the master issues 8 clocks as above, and for each clock, reads the GPIO pin. The data will be asserted by the slave.

There are more details to this, but sounds like you’re needing to use what’s out there, not reinvent.