buf.c.
The smoothing buffer is still kept separate from the main buffering system,
but as samples come in via interrupt, they are placed into a "standard" elua
buf. The size of this buf is configured according to whether one is grabbing
a bunch of samples rapidly (burst), or singly in order to accommodate the
expected number of incoming samples. If smoothing is enabled, incoming
samples are claimed until the smoothing buffer is full, and then remaining
samples are left in the main buffer until they are collected. This means that
whether one is collecting single samples or samples at burst rate, and
smoothing is enabled, the filter will only be providing samples that have
enough history.
Added a function to manually flush both smoothing and main buffers.
This would be useful if you know your state has changed and you only want
fresh samples that are going to be collected after a flush.
Also, a lot of functionality moved into elua_adc.c and common.c
(boundaries for what belongs where, might be evaluated), reducing the number
of platform.c specific functions dramatically.
Basic functionality seems to be working, but some more testing should be done.
Also, given that there's now a dynamic buffer behind everything, a shift in
the way sampling is handled could be done:
sample and burst functions could be made to be non-blocking, and to never
return anything except for errors.
a separate getsamples function could be used for removing samples collected by
either function from the buffer.
Suggestions are welcome as it would be nice to keep usage paradigms stable
after the 0.6 release.
- complete rewrite of the PIO module. New usage:
pio.PA = 10 -- set the value of PA to 10
pio.PB_1 = 1 -- set the value of pin 1 of PB to 1
local value = pio.PB -- get the value of PB
local value = pio.PB_3 -- get the value of pin 3 of PB
pio.PA_DIR = pio.OUTPUT/pio.INPUT - set the direction of PA
pio.dir[ pio.PA ] = pio.OUTPUT/pio.INPUT - same as above
pio.PA_2_DIR = pio.OUTPUT/pio.INPUT - set the direction of pin 2 of PA
pio.dir[ pio.PA_2 ] = pio.OUTPUT/pio.INPUT - same as above
pio.PA_PULL = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - set pulls on PA
pio.pull[ pio.PA ] = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - same as above
pio.P0_3_PULL = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - set pulls on pin 3 of P0
pio.pull[ pio.P0_3 ] = pio.PULLUP/pio.PULLDOWN/pio.NOPULL - same as above
- samples modified to use the new PIO syntax
- bugfix in AT91SAM7X256 UART int handler
- fixed yet another bug in AVR32's libc (actually replaced strcmp (which is broken on AVR32) with a custom version).
Code which was previously using buffer has been updated to work with the
changes.
API has also changed in accordance:
int buf_set(unsigned resid, unsigned resnum, u8 logsize, size_t dsize);
int buf_is_enabled( unsigned resid, unsigned resnum );
unsigned buf_get_size( unsigned resid, unsigned resnum );
unsigned buf_get_count( unsigned resid, unsigned resnum );
int buf_write( unsigned resid, unsigned resnum, t_buf_data *data, size_t dsize );
int buf_read( unsigned resid, unsigned resnum, t_buf_data *data, size_t dsize );
Essentially buf_rx_cb and buf_get_char have been renamed to buf_write and
buf_read. For these, one now passes a pointer to where the data is coming
from or going to, and a dsize parameter indicating how many bytes should be
copied. Also, buf_set takes this same dsize parameter, and keeps it in the
struct. This allows us to ensure that when data is read or written the
number of bytes matches the buffer element size.
I thought about maintaining compatibility functions to provide the original
buf_rx_cb and buf_get_byte API calls, however there weren't a large number
of uses of buf, so it wasn't hard to convert things.
One caveat: BUF_MOD_INCR assumes that byte counts for alternate type sizes
will be powers of 2.
Also, BUF_SIZE_xx's are assumed to refer to element counts.
- UART buffering enabled on LM3S
This doesn't include switching the ADC code over to using these buffers quite
yet.
I'm open to comments on these modifications if theres a better or simpler
approach. I've checked to make sure buffers work on LM3S, but I don't own any
other platforms to make sure there aren't unintended side-effects.
the heap instead of the stack. Also, the stack size was bumped to at least
2048 bytes on all backends. Hopefully this will take care of most issues
related to stack overflows.
- new buffering system available. Originally I planned to make it fully
generic, but I came to the conclusions that this would take too much
development work and system resources (RAM/Flash) if done properly, so
currently it's only used on UART RX (although it could be easily extended
for other peripherals). For an example of use check the AT91SAM7X and
AVR32 backend (platform_init and associated interrupt handlers and also
platform_conf.h).
- new XMODEM implementation. Better, cleaner, bug fixed, and BSD instead of
GPL.
- AVR32 can use the huge (32MBytes) SDRAM on the board as system memory now.
- fixed an error in elua_sbrk/_sbrk_r (and revised the compilation options
for dlmalloc).
- added the CPU module and interrupt support on the STR9 platform.
- uart module changes: 'sendstr' is out, but the regular 'send' will send
strings instead of simple chars (which makes sense since Lua doesn't have
a "char" type). Also, the 'timer_id' and 'timout' parameters of the 'recv'
function are now optional.