mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
0d9fcf9909
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.
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
// eLua "char device" buffering system
|
|
|
|
#ifndef __BUF_H__
|
|
#define __BUF_H__
|
|
|
|
#include "type.h"
|
|
|
|
// [TODO] the buffer data type is currently u8, is this OK?
|
|
typedef u8 t_buf_data;
|
|
|
|
// IDs of "bufferable" devices
|
|
enum
|
|
{
|
|
BUF_ID_UART = 0,
|
|
BUF_ID_FIRST = BUF_ID_UART,
|
|
BUF_ID_LAST = BUF_ID_UART,
|
|
BUF_ID_TOTAL = BUF_ID_LAST - BUF_ID_FIRST + 1
|
|
};
|
|
|
|
// This structure describes a buffer
|
|
typedef struct
|
|
{
|
|
u8 logsize;
|
|
volatile u16 wptr, rptr, count;
|
|
t_buf_data *buf;
|
|
} buf_desc;
|
|
|
|
// Buffer sizes (there are power of 2 to speed up modulo operations)
|
|
enum
|
|
{
|
|
BUF_SIZE_NONE = 0,
|
|
BUF_SIZE_16 = 4,
|
|
BUF_SIZE_32,
|
|
BUF_SIZE_64,
|
|
BUF_SIZE_128,
|
|
BUF_SIZE_256,
|
|
BUF_SIZE_512,
|
|
BUF_SIZE_1024,
|
|
BUF_SIZE_2048,
|
|
BUF_SIZE_4096,
|
|
BUF_SIZE_8192,
|
|
BUF_SIZE_16384,
|
|
BUF_SIZE_32768
|
|
};
|
|
|
|
// Buffer API
|
|
int buf_set( unsigned resid, unsigned resnum, u8 logsize );
|
|
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_get_char( unsigned resid, unsigned resnum );
|
|
void buf_rx_cb( unsigned resid, unsigned resnum, t_buf_data data );
|
|
|
|
#endif
|