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 LinksMessage
Re: [lpc2000] Circular buffers
2004-03-04 by Peter Kuhar
Attachments
- No local attachments were found for this message.