I want to read 256kBytes from a SPI Flash. I need to send a 4-bytes command to the Flash and AFTER that the SPI Flash send back 256kBytes of data.
In order to use qapi_SPIM_Full_Duplex() I need a buffer of 256kBytes PLUS 4 bytes, because the function is full-duplex, so start writing to the receiving buffer at the beginning of transmission.
I know I can allocate just a slightly bigger buffer, but as API is a pain. Imagine an application code that wants to read data from SPI Flash. It doesn't know anything about SPI Flash, full-duplex and length of command (4 bytes). How could the application know to allocate 4 bytes more to the buffer?
I was thinking to keep CS asserted and calls two times qapi_SPIM_Full_Duplex(), but it seems CS goes deasserted as soon as the function returns. Even with QAPI_SPIM_CS_KEEP_ASSERTED_E.
Is it possible to have a function for half-duplex transactions?