Home arrow Support arrow Forums

Luminary Micro Forums

wella

Platinum Boarder

2008/11/21 09:11

Universal Stellaris ware ringbuf

Hi,

could be possible to add to your Stellaris ware a universal ringbuf implementation? I mean not only (unsigned) char.

I noticed this drawback during writing 16bit SSI driver and
RingBufWriteOne((unsigned char) (x >> 8) & 0x000000FF);
RingBufWriteOne((unsigned char) (x) & 0x000000FF);
seemed to have been a little bit stupid.

Thank You

P.S.
Yes, I can rewrote ringbuf.c (I did) but this is not long term solution this is only patch.

login or register to reply

LMI Dave

Platinum Boarder

2008/11/24 08:19

Re:Universal Stellaris ware ringbuf

I'm not quite clear on what you are asking for. In the case that you quote, you should be able to accomplish the same thing using a single call:

Code:

 RingBufWrite(ptRingBuf, (unsigned char *)&xsizeof(u_int16));



The existing ring buffer module is intended to allow you to chose what you write to it. The pointers are unsigned char types purely since this describes the smallest unit that you can write and, hence, this offers the most flexibility allowing the caller to chose the size of the blocks that the buffer contains rather than having the library enforce some arbitrary granularity.

login or register to reply

wella

Platinum Boarder

2008/11/25 03:18

Re:Universal Stellaris ware ringbuf

Thanks Dave,

I have overlooked this function. However, there is one big BUT. I think, this function was primarily used to store data from byte array.

RingBufWrite, this way degrades cortex to 8 bit stupid device(due to "for" loop inside and calling function RingBufWriteOne for each byte and disabling interrupt).

RingBufWriteOne16, RingBufWriteOne32?

[my opinion]
Flexibility is nice concept but with 16bit SSI fast device, 50MHz Cortex-M3 and RTOS situation,
{call - push, call - push, disable int, enable int, pop, call - push, disable int, enable int, pop, pop} to store 16bit value is luxury.


Martin

Post edited by: wella, at: 2008/11/25 03:19

login or register to reply

LMI Dave

Platinum Boarder

2008/11/25 12:47

Re:Universal Stellaris ware ringbuf

True enough - our general purpose ring buffer implementation trades off optimal performance for flexibility. As with all the code we ship, however, you are welcome to modify and optimize it for your specific application (as you have done already).

login or register to reply