Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Circular buffers

2004-03-04 by Peter Kuhar

I belive this is te best way to do it. Using linked list is to
procesor and memory consumnig. If you use add byte only in interrupt
rutine and getbyte only in main program it's considered to be "thread
safe"
> Circular buufers are a technique not routines

> Typical psuedocode:

>     buffer[1024];
>     int onpointer=0,offpointer=0;

>     procedure addbyte(data) {
>           buffer[onpointer]=data;
>           onpointer++;
>           onpointer= onpointer & 1023;
>     }

>     function getbyte() {
>           res
>           if (onpointer==offpointer)
>                  return 0;   // no data available
>           res=buffer[offpointer];
>           offpointer++;
>           offpointer=offpointer & 1023
>           ret res;
>      }

> onpointer alwasy points the the first avaliable free space. offpointer
> always points to the next item avaliable

> Owen

>>Message: 11
>>   Date: Wed, 3 Mar 2004 22:59:44 -0800
>>   From: "Curt Powell" <curt.powell@...>
>>Subject: Circular buffers
>>
>>Can someone point me to some circular buffer routines?
>> 
>>TIA,
>> 
>>Curt
>> 
>>
>>  
>>





 
> Yahoo! Groups Links

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.