Just use the async version of writeRead. You don't really need to block if I understand correctly. Btw, the blocking writeRead will block you even if you don't pass a response buffer.
Using async can also help you bypass the 64B limit by sending multiple requests immediately following without waiting for the round trip.
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/dcpng7pUiycJ.
To post to this group, send email to ioio-...@googlegroups.com.
To unsubscribe from this group, send email to ioio-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ioio-users?hl=en.
Don't have the source in front of me, you may be right. But if you figure out the buffer size, why not just:
1. Async send enough bytes to fill it.
2. Every time you get the rising edge on the pin, async send additional 32B.
Either way, a trivial firmware mod can fix that.
@Ytai: Fundamentally, the issue is not about blocking. The point is after the 8KB audio buffer of the vs chip has been filled, any bytes send to it via SPI are lost until there's space again in that buffer. The chip signals this via the dreq pin. If this pin goes high, there's space for at least 32 bytes. I.e. the SPI transfers have to be timed according to the state of that pin. Just firing (async) SPI transfers would lead to data loses since the audio buffer would overflow. Thus, it's necessary to wait for dreq to be high, then 32 bytes can be send. If the buffer becomes full due to that transfer, dreq will become low. So, before the next transfer is started, we have to wait until the previous transfer happened and assure that dreq is high.
If we use the async spi call, a simple check of dreq would not be sufficient, since dreq might still be high because the transfer did not happen yet (or because the state change of dreq to low has not yet been reported). This was the reason why I requested an answer byte. BTW: if I understand the sources correctly, writeRead without a response buffer of at least 1 byte effectively does _not_ block: writeRead calls writeReadAsync which returns a result in state "ready" if the readSize is 0. WriteRead then "waits" until the result is ready, which it already is. In effect writeRead does not block in that scenario.
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/r3W5dA_xgCUJ.
Got it.
Maybe open accessory mode will help, as it has lower latency.
Otherwise, custom firmware is the way to go.
That's exactly what I tried. And yes, it works - for low quality audio streams (i.e. low transfer rate / buffer empties slowly). For high quality audio, it's to slow, because currently, I have to do this on android. Yes, I will look into the firmware and try to do it there (as soon as I have time). I just hoped there would be a way without a firmware change.
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ioio-users/-/oOxXXvnMeB8J.
--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
I think you must have some flow control mechanism, similar to the one available today in SPI, UART and I2C. Otherwise, you are guaranteed to run into an overflow or underflow.
Your results are encouraging though. They mean that your goal is feasible.
It would be nice if your new functionality can fit in the existing design rather than require an independent firmware and library. Do you know how much throughput can be achieved on SPI simply by increasing the SPI tx buffers and sending data as fast ad possible?
This could be measured on the Android side using the existing API, as flow control is already built into the protocol and implementation.