You'll be happy to know for the first stages, I've got a new method for you with QUEUE support.
Code:
virtual bool transfer16(uint16_t *buffer, uint16_t length, uint16_t packetID);
Slave logging:
Code:
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 1
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
Queue size stays at 1 while it's being dequeued.
If i stop dequeing during the tests, you'll see that the Queue support is indeed working. The queue data printout is actually from the dequeue array, NOT the array from the master.
Code:
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 2
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 3
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 4
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 5
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 6
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 7
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 8
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 9
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 10
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 11
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 12
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 13
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 14
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 15
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 16
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
38758 5 0 3329 39522
38758 5 2 3329 39520
37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
HIT!
Queue size: 17
The Queue data: 37443 16 0 10 55 1 2 3 4 5 6 7 8 9 0 37487
The CRC is also in the QUEUE, as you can see the data:
37443 (0x9243) is the header
16 is the size of the array
0 is the switch statement of the slave ISR
10 is the length of the actual array
55 is the packetId
1 -> 0 is the actual array that will be send to the handler on the slave if a valid CRC is detected on dequeue
and the last word is the actual checksum to verify against.
First I'm going to try to finish off the 2 way acknowledgement version, then ill work on the F&F raw capture for support
teensy shouldnt have problems with queueing large data, i did a burn-in test few weeks back with the ESP and queued over 5000 entries, and these were with alternate 6 and 44 byte 8-bit arrays!
The SPI version will be queueing 16bit arrays, obviously.
And like we mentioned before, we're doing FIFO method, so first in first out. If you want to limit your queue size, we could also limit the queue entries by popping out the stale array in front before pushing a new array in back, based on queue size
Actually, I'll use a uint16_t that returns your packetID if your data was transfered, instead of a bool...
btw the loop test code im using is:
Code:
uint16_t buf[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
_time = micros();
Serial.print("returned value"); Serial.println(teensy_gpio.transfer16(buf, sizeof(buf) / 2, 55));
Serial.println(micros() - _time);
I also reduced the array return to a basic: { 0xAA55, 0, 0 } for void ack's, just to trigger valid CRC using smallest payload possible.
Keep in mind the slave ISR handler returns are setup this way:
{ 0xAA55, 0, 0 }
^--response header 0xAA55
^--1st 0 is set to the size of the array, look just after the function.
^--last 0 is where the CRC is calculated and set after. So the header, first 0 and the last 0 cannot be touched at all, but to put your own responses in, you could just do:
{ 0xAA55, 0, myVar, anotherVar, etc, 0 }
Hope im simplifying things enough