@@ -73,6 +73,68 @@ OK, I have this up and running: I am streaming at a fixed BAUD, then counting th
So, I'm not convinced that I haven't fuxd anything here... it seems wild that we would have such a bottleneck to performance, and there are a few red flags here; namely that we have a lower bound of 11us between transmits, which would also explain our increasing error rate when we surpass 1 Mbit/sec (as the byte-wise period there is 10us or so).
At this point, I'm tempted to return to my old SAMD51 friend, who I know can do things ~ of this nature, fully ISR-d out, with no Flash-Code-Confusion, etc. But I'm also convinced that something is totally broken with the code that I'm operating with at the moment.
To start, there is this oddity in all of earle's code:
```cpp
intSerialPIO::read(){
// THE MUTEX ?????
CoreMutexm(&_mutex);
if(!_running||!m||(_rx==NOPIN)){
return-1;
}
if(_writer!=_reader){
autoret=_queue[_reader];
asmvolatile("":::"memory");// Ensure the value is read before advancing
autonext_reader=(_reader+1)%_fifoSize;
asmvolatile("":::"memory");// Ensure the reader value is only written once, correctly
_reader=next_reader;
returnret;
}
return-1;
}
```
Esp. the `CoreMutex` instantation, but also just that it's pretty bloated. Also the TX line is blocking, unless the PIO put_blocking doesn't actually block until the tx FIFO is clear,
```cpp
size_tSerialPIO::write(uint8_tc){
CoreMutexm(&_mutex);
if(!_running||!m||(_tx==NOPIN)){
return0;
}
uint32_tval=c;
if(_parity==UART_PARITY_NONE){
val|=7<<_bits;// Set 2 stop bits, the HW will only transmit the required number
Well - this [only blocks if the FIFO is full](https://cec-code-lab.aps.edu/robotics/resources/pico-c-api/group__hardware__pio.html), but the mutex aught to be adding some pretty bogus time.
In summary - I think it's other peoples' not-bespoke code hell again, and I want out of it. Abandoning this means falling back to the D51, which *I know* can do this, but it would mean that circuit building would get a lot more difficult, and basically the whole lab is on RP2040's.
So, we should go a little more hardo at this.
### UART TX/RX with Modified Earle Code
I'll try it my copy-pasta'ing the earle code, to see if I can remove some of the layers-of-abstraction cruft.