Forum > Embedded

A circular / ring buffer for embedded

<< < (2/5) > >>

AlexTP:
Unit code was read by me. Can be changed to have any buffer size, as  i see. but instead of "Inc(nnn)" we will need

Inc(nnn);
if nnn>=BufferLastOffset then nnn:= BufferStartOffset;

It must work with any size.
The xxxMask method won't be needed.

EDIT. Ops, then getting the buffer size as nWriteOffset-nReadOffset will be broken, sorry.

marcov:
I never really optimize on size, always on speed.

Typical firmwares are 20-30kb, while the smallest flash is 128k, and most have 512kb.

ccrause:

--- Quote from: marcov on October 10, 2022, 04:07:33 pm ---I don't do much AVR work, mostly dspic. (in C, not Pascal).

--- End quote ---

--- Quote from: marcov on October 11, 2022, 09:43:06 am ---I never really optimize on size, always on speed.

Typical firmwares are 20-30kb, while the smallest flash is 128k, and most have 512kb.

--- End quote ---
AVR resources are a bit more constrained:
Maximum flash = 256 kB (atmega2560/1)
Maximum RAM = 16 kB (atmega1284 & AVR128DB)
Minimum flash = 512 bytes (attiny4/5)
Minimum RAM = 32 bytes RAM (attiny4/5/9/10)
No RAM :o: attiny26/28

Thus the use of inlining would depend on whether a particular application is flash, RAM and/or speed constrained.


--- Quote from: d.ioannidis on October 10, 2022, 11:44:14 pm ---.... Maybe a define. some ifdef's and inform the user of the buffer library, for the pros and cons of enabling inline or not .
--- End quote ---
A define to control the use of inline seems like an acceptable option so that the user has some choice.

PascalDragon:
We really should adjust {$Inline} so that it works like in Delphi: at the call site. So that the user themselves can control that inlining is off while the code that is called is compiled with inline (and assuming the compiler would indeed inline it).  ::)

ccrause:

--- Quote from: PascalDragon on October 12, 2022, 07:35:16 am ---We really should adjust {$Inline} so that it works like in Delphi: at the call site. So that the user themselves can control that inlining is off while the code that is called is compiled with inline (and assuming the compiler would indeed inline it).  ::)

--- End quote ---
This seems like a really good idea!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version