eCos update

Started by Jean-Rene David February 27, 2004
I now have eCos running on my IAR KickStart card
with a LPC2106. RedBoot also runs, though I wasn't
yet able to download a program in RAM and execute
it from RedBoot.

I had to correct some stuff in the bugzilla port
to get rid of compiler errors and warnings and get
the thing working.

A few of the things that still need to get done:

- Flash driver for the onboard Flash
- Clarify the PLL configuration code. Right now
there's nothing "real" about the real-time
clock...
- get eCos and an application compiled and working
in thumb instruction set.
- etc.

How are the other people running eCos on the
LPC2000 doing? Maybe we should start contributing
to the bugzilla port at some point, instead of
doing our separate thing.




An Engineer's Guide to the LPC2100 Series

What is the footprint's size of ecos on LCP ?

Thx

Ben

-----Message d'origine-----
De : Jean-Rene David [mailto:]
Envoy: vendredi 27 frier 2004 18:53
:
Objet : [lpc2000] eCos update

I now have eCos running on my IAR KickStart card with a LPC2106. RedBoot
also runs, though I wasn't yet able to download a program in RAM and execute
it from RedBoot.

I had to correct some stuff in the bugzilla port to get rid of compiler
errors and warnings and get the thing working.

A few of the things that still need to get done:

- Flash driver for the onboard Flash
- Clarify the PLL configuration code. Right now
there's nothing "real" about the real-time
clock...
- get eCos and an application compiled and working
in thumb instruction set.
- etc.

How are the other people running eCos on the LPC2000 doing? Maybe we should
start contributing to the bugzilla port at some point, instead of doing our
separate thing.
Yahoo! Groups Links



Message
Can someone point me to some circular buffer routines?
 
TIA,
 
Curt
 



--- In , "Curt Powell" <curt.powell@s...>
wrote:
> Can someone point me to some circular buffer routines?
There are various ways to implement circular buffers. The easiest
way, and most robust way, IMHO is to use a counter to track how many
items are in the list rather than comparing head and tail.

example
typedef struct{
U8 fifo[uart_FIFO_SIZE];
U32 head;
U32 tail;
U32 holding;
} uart_Buffer;
// put a byte into the list
if(s->rx.holding >= uart_FIFO_SIZE)
{
//Full, so got to throw away the oldest byte
s->rx.holding = uart_FIFO_SIZE - 1;
s->rx.tail++;
if(s->rx.tail >= uart_FIFO_SIZE)
{
s->rx.tail = 0;
}
}
s->rx.fifo[s->rx.head] = b;
s->rx.head++;
if(s->rx.head >= uart_FIFO_SIZE)
{
s->rx.head = 0;
}
s->rx.holding++; // pull a byte out of the list
if(s->rx.holding > 0)
{
*pData = s->rx.fifo[s->rx.tail];
s->rx.tail++;
if(s->rx.tail >= uart_FIFO_SIZE)
{
s->rx.tail = 0;
}
s->rx.holding--;
retval = 1;
}

// initialise
s->rx.tail = s->rx.head = s->rx.holding = 0;



Charles,

Do you find this version to be "thread safe" when a UART ISR is filling
it and the main program is processing (i.e. emptying) it?

Curt

-----Original Message-----
From: embeddedjanitor [mailto:]
Sent: Thursday, March 04, 2004 11:49 AM
To:
Subject: [lpc2000] Re: Circular buffers --- In , "Curt Powell" <curt.powell@s...>
wrote:
> Can someone point me to some circular buffer routines?
There are various ways to implement circular buffers. The easiest
way, and most robust way, IMHO is to use a counter to track how many
items are in the list rather than comparing head and tail.

example
typedef struct{
U8 fifo[uart_FIFO_SIZE];
U32 head;
U32 tail;
U32 holding;
} uart_Buffer;
// put a byte into the list
if(s->rx.holding >= uart_FIFO_SIZE)
{
//Full, so got to throw away the oldest byte
s->rx.holding = uart_FIFO_SIZE - 1;
s->rx.tail++;
if(s->rx.tail >= uart_FIFO_SIZE)
{
s->rx.tail = 0;
}
}
s->rx.fifo[s->rx.head] = b;
s->rx.head++;
if(s->rx.head >= uart_FIFO_SIZE)
{
s->rx.head = 0;
}
s->rx.holding++; // pull a byte out of the list
if(s->rx.holding > 0)
{
*pData = s->rx.fifo[s->rx.tail];
s->rx.tail++;
if(s->rx.tail >= uart_FIFO_SIZE)
{
s->rx.tail = 0;
}
s->rx.holding--;
retval = 1;
}

// initialise
s->rx.tail = s->rx.head = s->rx.holding = 0;
Yahoo! Groups Links




Circular buufers are a technique not routines

Typical psuedocode:

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

procedure addbyte(data) {
buffer[onpointer]a;
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" <>
>Subject: Circular buffers
>
>Can someone point me to some circular buffer routines?
>
>TIA,
>
>Curt >
>



At 11:57 AM 3/4/04 -0800, you wrote:
>Charles,
>
>Do you find this version to be "thread safe" when a UART ISR is filling
>it and the main program is processing (i.e. emptying) it?
>
>Curt

It could be made so but it's not as it is written.

Robert

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III


--- In , "Curt Powell" <curt.powell@s...>
wrote:
> Charles,
>
> Do you find this version to be "thread safe" when a UART ISR is
filling
> it and the main program is processing (i.e. emptying) it?
>

No this is just the circular buffer itself. I normally wrap
the "foreground" code in interrupt enable/disable code to make it
interrupt safe.



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]a;
> 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" <>
>>Subject: Circular buffers
>>
>>Can someone point me to some circular buffer routines?
>>
>>TIA,
>>
>>Curt
>>
>>
>>
>>
> Yahoo! Groups Links





At 10:55 PM 3/4/04 +0100, you wrote:
>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"
It's not thread safe. It'll work in a cooperative tasking environment but
not in a pre-emptive or interrupt environment w/o further protection.

It's also missing overflow protection but that's a different issue.

It's fine as an illustration of the general concept though which is what is
was presented as.

Robert " 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III