In the original Pull Request, when the buffer needed to wrap the write, the level was incremented by `tocopy` bytes again instead of only `btw` (bytes left to copy after wrap).
Previously some invalid values (not a 2^n value) were accepted, in which cases it compiled without error, BUT creates major runtime bugs. To prevent this, all '_depth' inputs (including the config '#define FIFOFAST_MAX_DEPTH_POINTABLE') are rounded up to the next possible value.
The upper bound check implemended by '_FFF_GET_ARRAYDEPTH_P' was maually tested with a reasonable size of 255, 256 and 257 elements and it behaved as expected.
improved usage of struct member 'level'
- 'level' contains now real value, even if fifo is full
- demo-code compiles with 25% less flash usage
- less if-statements required, performance therefore increased
Before .level == .mask could mean either full or almost full, depending on the members .write and .read. This design decision was supposed to reduce ram usage as much as possible, but was responsible for more if-statements in the code. Now .level can be .mask+1, but this requires a larger datatype for fifos with a depth 256 or larger, which is chosen automatically. Overall, the new code reduces the flash usage of the test code by 25%!
Most macros are now also implemented as an inline function. These function accept a pointer toa pointable fifo as a parameter. The "read" and "add" functions are not implemented yet
To correctly create an array it is best to state the size at time of declaration. Unfortunatly the size must be specified in the .h AND .c file. We recommend using a #define'd value
... Example code is included ath the end of fifofast_demo.c
[change] structure name generation has been unified. This requires no change in the user's code
[note] optimisation has been disabled, because else GCC optimizes fifos away, DESPITE volatile declaration (at least for testing in the simulator)
[cleanup] in preparation to re-introduce the inline functions the three pointable fifo-types have been unified. You can gloabally select the desired max size with 'FIFOFAST_INDEX_TYPE'