From 5cf6f2b8f3f2bee002b0e000277a2e4075a3a9c8 Mon Sep 17 00:00:00 2001 From: Bogdan Marinescu Date: Sat, 14 Jul 2012 14:16:11 +0300 Subject: [PATCH] Moved platform 'at91sam7x' to the new build system Also, a small fix in the timer interrupt handling code. --- boards/known/netduino.lua | 25 ++++ boards/known/sam7-ex256.lua | 25 ++++ src/common_tmr.c | 21 +--- src/platform/at91sam7x/cpu_at91sam7x256.h | 41 +++++++ src/platform/at91sam7x/cpu_at91sam7x512.h | 12 ++ src/platform/at91sam7x/platform_conf.h | 133 ---------------------- src/platform/at91sam7x/platform_generic.h | 14 +++ src/platform/at91sam7x/platform_ints.h | 12 ++ 8 files changed, 135 insertions(+), 148 deletions(-) create mode 100644 boards/known/netduino.lua create mode 100644 boards/known/sam7-ex256.lua create mode 100644 src/platform/at91sam7x/cpu_at91sam7x256.h create mode 100644 src/platform/at91sam7x/cpu_at91sam7x512.h delete mode 100644 src/platform/at91sam7x/platform_conf.h create mode 100644 src/platform/at91sam7x/platform_generic.h create mode 100644 src/platform/at91sam7x/platform_ints.h diff --git a/boards/known/netduino.lua b/boards/known/netduino.lua new file mode 100644 index 00000000..d73ee37d --- /dev/null +++ b/boards/known/netduino.lua @@ -0,0 +1,25 @@ +-- Netduino build configuration + +return { + cpu = 'at91sam7x512', + components = { + sercon = { uart = 0, speed = 115200, buf_size = 128 }, + romfs = true, + shell = true, + term = { lines = 25, cols = 80 }, + cints = true, + luaints = true, + linenoise = { shell_lines = 10, lua_lines = 50 }, + rpc = { uart = 0, speed = 115200 }, + xmodem = true + }, + config = { + egc = { mode = "alloc" }, + vtmr = { num = 4, freq = 4 }, + }, + modules = { + generic = 'all', + exclude_generic = { "i2c", "net", "adc", "spi", "can" }, + } +} + diff --git a/boards/known/sam7-ex256.lua b/boards/known/sam7-ex256.lua new file mode 100644 index 00000000..bb12c2d8 --- /dev/null +++ b/boards/known/sam7-ex256.lua @@ -0,0 +1,25 @@ +-- SAM7-EX256 build configuration + +return { + cpu = 'at91sam7x256', + components = { + sercon = { uart = 0, speed = 115200, buf_size = 128 }, + romfs = true, + shell = true, + term = { lines = 25, cols = 80 }, + cints = true, + luaints = true, + linenoise = { shell_lines = 10, lua_lines = 50 }, + rpc = { uart = 0, speed = 115200 }, + xmodem = true + }, + config = { + egc = { mode = "alloc" }, + vtmr = { num = 4, freq = 4 }, + }, + modules = { + generic = 'all', + exclude_generic = { "i2c", "net", "adc", "spi", "can" }, + } +} + diff --git a/src/common_tmr.c b/src/common_tmr.c index a26f5f71..2cc8585a 100644 --- a/src/common_tmr.c +++ b/src/common_tmr.c @@ -9,22 +9,9 @@ #include "utils.h" #include -// [TODO] when the new build system is ready, automatically add the -// code below in platform_conf.h -#if defined( BUILD_LUA_INT_HANDLERS ) || defined( BUILD_C_INT_HANDLERS ) -#define BUILD_INT_HANDLERS - -#ifndef INT_TMR_MATCH -#define INT_TMR_MATCH ELUA_INT_INVALID_INTERRUPT -#endif - +#ifdef BUILD_INT_HANDLERS extern const elua_int_descriptor elua_int_table[ INT_ELUA_LAST ]; - -#endif // #if defined( BUILD_LUA_INT_HANDLERS ) || defined( BUILD_C_INT_HANDLERS ) - -#ifndef VTMR_NUM_TIMERS -#define VTMR_NUM_TIMERS 0 -#endif // #ifndef VTMR_NUM_TIMERS +#endif // #ifdef BUILD_INT_HANDLERS #ifndef PLATFORM_HAS_SYSTIMER #warning This platform does not have a system timer. Your eLua image might not work as expected. @@ -335,7 +322,11 @@ int platform_timer_set_match_int( unsigned id, timer_data_type period_us, int ty if( id == PLATFORM_TIMER_SYS_ID ) return PLATFORM_TIMER_INT_INVALID_ID; else +#if INT_TMR_MATCH != ELUA_INT_INVALID_INTERRUPT return platform_s_timer_set_match_int( id, period_us, type ); +#else + return PLATFORM_TIMER_INT_INVALID_ID; +#endif } int cmn_tmr_int_set_status( elua_int_resnum resnum, int status ) diff --git a/src/platform/at91sam7x/cpu_at91sam7x256.h b/src/platform/at91sam7x/cpu_at91sam7x256.h new file mode 100644 index 00000000..6e213ad7 --- /dev/null +++ b/src/platform/at91sam7x/cpu_at91sam7x256.h @@ -0,0 +1,41 @@ +// AT91SAM7X256 CPU definition + +#ifndef __CPU_AT91SAM7X256__ +#define __CPU_AT91SAM7X256__ + +#include "stacks.h" +#include "platform_ints.h" +#include "board.h" + +// Number of resources (0 if not available/not implemented) +#define NUM_PIO 2 +#define NUM_SPI 0 +#define NUM_UART 2 +#define NUM_TIMER 3 +#define NUM_PWM 4 +#define NUM_ADC 0 +#define NUM_CAN 0 + +// CPU frequency (needed by the CPU module and MMCFS code, 0 if not used) +#define CPU_FREQUENCY BOARD_MCK + +// PIO prefix ('0' for P0, P1, ... or 'A' for PA, PB, ...) +#define PIO_PREFIX 'A' +// Pins per port configuration: +// #define PIO_PINS_PER_PORT (n) if each port has the same number of pins, or +// #define PIO_PIN_ARRAY { n1, n2, ... } to define pins per port in an array +// Use #define PIO_PINS_PER_PORT 0 if this isn't needed +#define PIO_PINS_PER_PORT 31 + +#define SRAM_ORIGIN 0x200000 +#ifndef SRAM_SIZE +#define SRAM_SIZE 0x10000 +#endif +#define INTERNAL_RAM_FIRST_FREE end +#define INTERNAL_RAM_LAST_FREE ( SRAM_ORIGIN + SRAM_SIZE - STACK_SIZE_TOTAL - 1 ) + +#define PLATFORM_CPU_CONSTANTS_INTS\ + _C( INT_UART_RX ), + +#endif // #ifndef __CPU_AT91SAM7X256__ + diff --git a/src/platform/at91sam7x/cpu_at91sam7x512.h b/src/platform/at91sam7x/cpu_at91sam7x512.h new file mode 100644 index 00000000..5e17168e --- /dev/null +++ b/src/platform/at91sam7x/cpu_at91sam7x512.h @@ -0,0 +1,12 @@ +// AT91SAM7X512 CPU definition +// Use AT91SAM7X256 as a base + +#ifndef __CPU_AT91SAM7X512_H__ +#define __CPU_AT91SAM7X512_H__ + +#define SRAM_SIZE 0x20000 + +#include "cpu_at91sam7x256.h" + +#endif + diff --git a/src/platform/at91sam7x/platform_conf.h b/src/platform/at91sam7x/platform_conf.h deleted file mode 100644 index 699203b8..00000000 --- a/src/platform/at91sam7x/platform_conf.h +++ /dev/null @@ -1,133 +0,0 @@ -// eLua platform configuration - -#ifndef __PLATFORM_CONF_H__ -#define __PLATFORM_CONF_H__ - -#include "auxmods.h" -#include "board.h" -#include "stacks.h" -#include "buf.h" -#include "elua_int.h" -#include "sermux.h" - -// ***************************************************************************** -// Define here what components you want for this platform - -#define BUILD_XMODEM -#define BUILD_SHELL -#define BUILD_ROMFS -#define BUILD_TERM -#define BUILD_CON_GENERIC -//#define BUILD_RPC -//#define BUILD_RFS -//#define BUILD_SERMUX -#define BUILD_C_INT_HANDLERS - -#define PLATFORM_HAS_SYSTIMER - -// ***************************************************************************** -// UART/Timer IDs configuration data (used in main.c) - -//#define CON_UART_ID ( SERMUX_SERVICE_ID_FIRST + 1 ) -#define CON_UART_ID 0 -#define CON_UART_SPEED 115200 -#define TERM_LINES 25 -#define TERM_COLS 80 - -// ***************************************************************************** -// Auxiliary libraries that will be compiled for this platform - -#if defined( ELUA_BOOT_RPC ) && !defined( BUILD_RPC ) -#define BUILD_RPC -#endif - -#if defined( BUILD_RPC ) -#define RPCLINE _ROM( AUXLIB_RPC, luaopen_rpc, rpc_map ) -#else -#define RPCLINE -#endif - -#define LUA_PLATFORM_LIBS_ROM\ - _ROM( AUXLIB_PIO, luaopen_pio, pio_map )\ - _ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\ - _ROM( AUXLIB_PD, luaopen_pd, pd_map )\ - _ROM( AUXLIB_UART, luaopen_uart, uart_map )\ - _ROM( AUXLIB_TERM, luaopen_term, term_map )\ - _ROM( AUXLIB_PWM, luaopen_pwm, pwm_map )\ - _ROM( AUXLIB_PACK, luaopen_pack, pack_map )\ - _ROM( AUXLIB_BIT, luaopen_bit, bit_map )\ - _ROM( AUXLIB_CPU, luaopen_cpu, cpu_map )\ - _ROM( AUXLIB_ELUA, luaopen_elua, elua_map )\ - RPCLINE\ - _ROM( LUA_MATHLIBNAME, luaopen_math, math_map ) - -// ***************************************************************************** -// Configuration data - -// Virtual timers (0 if not used) -#define VTMR_NUM_TIMERS 4 -#define VTMR_FREQ_HZ 4 - -// Number of resources (0 if not available/not implemented) -#define NUM_PIO 2 -#define NUM_SPI 0 -#define NUM_UART 2 -#if VTMR_NUM_TIMERS > 0 -#define NUM_TIMER 3 -#else -#define NUM_TIMER 2 -#endif -#define NUM_PWM 4 -#define NUM_ADC 0 -#define NUM_CAN 0 - -// RPC boot options -#define RPC_UART_ID CON_UART_ID -#define RPC_UART_SPEED CON_UART_SPEED - -// Enable RX buffering on UART -#define BUF_ENABLE_UART -#define CON_BUF_SIZE BUF_SIZE_128 - -// CPU frequency (needed by the CPU module and MMCFS code, 0 if not used) -#define CPU_FREQUENCY BOARD_MCK - -// PIO prefix ('0' for P0, P1, ... or 'A' for PA, PB, ...) -#define PIO_PREFIX 'A' -// Pins per port configuration: -// #define PIO_PINS_PER_PORT (n) if each port has the same number of pins, or -// #define PIO_PIN_ARRAY { n1, n2, ... } to define pins per port in an array -// Use #define PIO_PINS_PER_PORT 0 if this isn't needed -#define PIO_PINS_PER_PORT 31 - -// Allocator data: define your free memory zones here in two arrays -// (start address and end address) -#define SRAM_ORIGIN 0x200000 -#ifdef at91sam7x256 - #define SRAM_SIZE 0x10000 -#else - #define SRAM_SIZE 0x20000 -#endif -#define MEM_START_ADDRESS { ( void* )end } -#define MEM_END_ADDRESS { ( void* )( SRAM_ORIGIN + SRAM_SIZE - STACK_SIZE_TOTAL - 1 ) } - -/* -#define RFS_BUFFER_SIZE BUF_SIZE_512 -#define RFS_UART_ID ( SERMUX_SERVICE_ID_FIRST ) -#define RFS_TIMEOUT 100000 -#define RFS_UART_SPEED 115200 - -#define SERMUX_PHYS_ID 0 -#define SERMUX_PHYS_SPEED 115200 -#define SERMUX_NUM_VUART 2 -#define SERMUX_BUFFER_SIZES { RFS_BUFFER_SIZE, CON_BUF_SIZE } -*/ - -// Interrupt list -#define INT_UART_RX ELUA_INT_FIRST_ID -#define INT_ELUA_LAST INT_UART_RX - -#define PLATFORM_CPU_CONSTANTS\ - _C( INT_UART_RX ) - -#endif // #ifndef __PLATFORM_CONF_H__ diff --git a/src/platform/at91sam7x/platform_generic.h b/src/platform/at91sam7x/platform_generic.h new file mode 100644 index 00000000..9172a215 --- /dev/null +++ b/src/platform/at91sam7x/platform_generic.h @@ -0,0 +1,14 @@ +// Generic platform configuration file + +#ifndef __PLATFORM_GENERIC_H__ +#define __PLATFORM_GENERIC_H__ + +#define PLATFORM_HAS_SYSTIMER + +#if VTMR_NUM_TIMERS > 0 +#undef NUM_TIMER +#define NUM_TIMER 2 +#endif + +#endif // #ifndef __PLATFORM_GENERIC_H__ + diff --git a/src/platform/at91sam7x/platform_ints.h b/src/platform/at91sam7x/platform_ints.h new file mode 100644 index 00000000..65bac3a0 --- /dev/null +++ b/src/platform/at91sam7x/platform_ints.h @@ -0,0 +1,12 @@ +// List of interrupts for this platform + +#ifndef __PLATFORM_INTS_H__ +#define __PLATFORM_INTS_H__ + +#include "elua_int.h" + +#define INT_UART_RX ELUA_INT_FIRST_ID +#define INT_ELUA_LAST INT_UART_RX + +#endif +