diff --git a/boards/known/str-e912.lua b/boards/known/str-e912.lua new file mode 100644 index 00000000..1f6b5f21 --- /dev/null +++ b/boards/known/str-e912.lua @@ -0,0 +1,26 @@ +-- STR-E912 build configuration + +return { + cpu = 'str912faw44', + components = { + sercon = { uart = 0, speed = 115200 }, + 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 }, + adc = { buf_size = 2, first_timer = 0, num_timers = 0 }, + xmodem = true + }, + config = { + vtmr = { num = 4, freq = 16 }, + }, + modules = { + generic = 'all', + exclude_generic = { "net", "can" }, + platform = 'all' + } +} + diff --git a/boards/known/str9-comstick.lua b/boards/known/str9-comstick.lua new file mode 100644 index 00000000..814adc4e --- /dev/null +++ b/boards/known/str9-comstick.lua @@ -0,0 +1,26 @@ +-- STR9-comStick board build configuration + +return { + cpu = 'str912faw44', + components = { + sercon = { uart = 1, speed = 115200 }, + 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 }, + adc = { buf_size = 2, first_timer = 0, num_timers = 0 }, + xmodem = true + }, + config = { + vtmr = { num = 4, freq = 16 }, + }, + modules = { + generic = 'all', + exclude_generic = { "net", "can" }, + platform = 'all' + } +} + diff --git a/src/platform/str9/build_config.lua b/src/platform/str9/build_config.lua new file mode 100644 index 00000000..d20d3beb --- /dev/null +++ b/src/platform/str9/build_config.lua @@ -0,0 +1,18 @@ +-- This is the platform specific board configuration file +-- It is used by the generic board configuration system (config/) + +module( ..., package.seeall ) + +-- Add specific components to the 'components' table +function add_platform_components( t ) +end + +-- Add specific configuration to the 'configs' table +function add_platform_configs( t ) +end + +-- Return an array of all the available platform modules for the given cpu +function get_platform_modules( cpu ) + return { pio = {} } +end + diff --git a/src/platform/str9/cpu_str912faw44.h b/src/platform/str9/cpu_str912faw44.h new file mode 100644 index 00000000..820e65a1 --- /dev/null +++ b/src/platform/str9/cpu_str912faw44.h @@ -0,0 +1,51 @@ +// eLua platform configuration + +#ifndef __CPU_STR912FAW44_H__ +#define __CPU_STR912FAW44_H__ + +#include "stacks.h" +#include "type.h" +#include "platform_ints.h" + +// Number of resources (0 if not available/not implemented) +#define NUM_PIO 10 +#define NUM_SPI 2 +#define NUM_UART 3 +#define NUM_PWM 4 +#define NUM_ADC 8 +#define NUM_CAN 0 +#define NUM_I2C 2 + +// One timer is reserved for the system timer / vtimers +#define NUM_TIMER 3 +#define NUM_PHYS_TIMER 4 + +// ADC Configuration Params +#define ADC_BIT_RESOLUTION 10 + +// CPU frequency (needed by the CPU module and MMCFS code, 0 if not used) +u32 SCU_GetMCLKFreqValue(); +#define CPU_FREQUENCY ( SCU_GetMCLKFreqValue() * 1000 ) + +// PIO prefix ('0' for P0, P1, ... or 'A' for PA, PB, ...) +#define PIO_PREFIX '0' +// 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 8 + +// Allocator data: define your free memory zones here in two arrays +// (start address and end address) +#define SRAM_ORIGIN 0x40000000 +#define SRAM_SIZE 0x18000 +#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_GPIO_POSEDGE ),\ + _C( INT_GPIO_NEGEDGE ),\ + _C( INT_TMR_MATCH ), + +#endif // #ifndef __CPU_STR912FAW44_H__ + diff --git a/src/platform/str9/platform_conf.h b/src/platform/str9/platform_conf.h deleted file mode 100644 index ab1e4937..00000000 --- a/src/platform/str9/platform_conf.h +++ /dev/null @@ -1,149 +0,0 @@ -// eLua platform configuration - -#ifndef __PLATFORM_CONF_H__ -#define __PLATFORM_CONF_H__ - -#include "auxmods.h" -#include "stacks.h" -#include "type.h" -#include "elua_int.h" -#include "buf.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_ADC -//#define BUILD_RPC -#define BUILD_LUA_INT_HANDLERS -#define BUILD_C_INT_HANDLERS - -#define PLATFORM_HAS_SYSTIMER - -// ***************************************************************************** -// UART/Timer IDs configuration data (used in main.c) - -#ifdef ELUA_BOARD_STRE912 -#define CON_UART_ID 0 -#else // STR9-comStick -#define CON_UART_ID 1 -#endif - -#define CON_UART_SPEED 115200 -#define TERM_LINES 25 -#define TERM_COLS 80 - -// ***************************************************************************** -// Configuration data - -// Virtual timers (0 if not used) -#define VTMR_NUM_TIMERS 4 -#define VTMR_FREQ_HZ 16 -#define VTMR_TIMER_ID 3 - -// Number of resources (0 if not available/not implemented) -#define NUM_PIO 10 -#define NUM_SPI 2 -#define NUM_UART 3 -#define NUM_PWM 4 -#define NUM_ADC 8 -#define NUM_CAN 0 -#define NUM_I2C 2 - -// One timer is reserved for the system timer / vtimers -#define NUM_TIMER 3 -#define NUM_PHYS_TIMER 4 - -// ADC Configuration Params -#define ADC_BIT_RESOLUTION 10 -#define BUF_ENABLE_ADC -#define ADC_BUF_SIZE BUF_SIZE_2 - -// These should be adjusted to support multiple ADC devices -#define ADC_TIMER_FIRST_ID 0 -#define ADC_NUM_TIMERS 0 - -// RPC boot options -#define RPC_UART_ID CON_UART_ID -#define RPC_UART_SPEED CON_UART_SPEED - -// Interrupt queue configuration -#define PLATFORM_INT_QUEUE_LOG_SIZE BUF_SIZE_32 - -// CPU frequency (needed by the CPU module and MMCFS code, 0 if not used) -u32 SCU_GetMCLKFreqValue(); -#define CPU_FREQUENCY ( SCU_GetMCLKFreqValue() * 1000 ) - -// PIO prefix ('0' for P0, P1, ... or 'A' for PA, PB, ...) -#define PIO_PREFIX '0' -// 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 8 - -// Allocator data: define your free memory zones here in two arrays -// (start address and end address) -#define SRAM_ORIGIN 0x40000000 -#define SRAM_SIZE 0x18000 -#define MEM_START_ADDRESS { ( void* )end } -#define MEM_END_ADDRESS { ( void* )( SRAM_ORIGIN + SRAM_SIZE - STACK_SIZE_TOTAL - 1 ) } - -// ***************************************************************************** -// Auxiliary libraries that will be compiled for this platform - -// The name of the platform specific libs table -#define PS_LIB_TABLE_NAME "str9" - -#ifdef BUILD_ADC -#define ADCLINE _ROM( AUXLIB_ADC, luaopen_adc, adc_map ) -#else -#define ADCLINE -#endif - -#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 )\ - ADCLINE\ - _ROM( AUXLIB_PD, luaopen_pd, pd_map )\ - _ROM( AUXLIB_UART, luaopen_uart, uart_map )\ - _ROM( AUXLIB_TERM, luaopen_term, term_map )\ - _ROM( AUXLIB_PACK, luaopen_pack, pack_map )\ - _ROM( AUXLIB_BIT, luaopen_bit, bit_map )\ - _ROM( AUXLIB_CPU, luaopen_cpu, cpu_map)\ - _ROM( AUXLIB_CPU, luaopen_elua, elua_map)\ - _ROM( AUXLIB_I2C, luaopen_i2c, i2c_map)\ - _ROM( AUXLIB_SPI, luaopen_spi, spi_map)\ - _ROM( AUXLIB_ELUA, luaopen_elua, elua_map)\ - RPCLINE\ - _ROM( AUXLIB_PWM, luaopen_pwm, pwm_map)\ - _ROM( LUA_MATHLIBNAME, luaopen_math, math_map )\ - _ROM( PS_LIB_TABLE_NAME, luaopen_platform, platform_map ) - - // Interrupt list -#define INT_GPIO_POSEDGE ELUA_INT_FIRST_ID -#define INT_GPIO_NEGEDGE ( ELUA_INT_FIRST_ID + 1 ) -#define INT_TMR_MATCH ( ELUA_INT_FIRST_ID + 2 ) -#define INT_ELUA_LAST INT_TMR_MATCH - -#define PLATFORM_CPU_CONSTANTS\ - _C( INT_GPIO_POSEDGE ),\ - _C( INT_GPIO_NEGEDGE ),\ - _C( INT_TMR_MATCH ) - -#endif // #ifndef __PLATFORM_CONF_H__ - diff --git a/src/platform/str9/platform_generic.h b/src/platform/str9/platform_generic.h new file mode 100644 index 00000000..0826f6bc --- /dev/null +++ b/src/platform/str9/platform_generic.h @@ -0,0 +1,12 @@ +// Platform customization header + +#ifndef __PLATFORM_GENERIC_H__ +#define __PLATFORM_GENERIC_H__ + +#define PLATFORM_HAS_SYSTIMER + +// ID of the hardware timer used to implement physical timers +#define VTMR_TIMER_ID 3 + +#endif // #ifndef __PLATFORM_GENERIC_H__ + diff --git a/src/platform/str9/platform_ints.h b/src/platform/str9/platform_ints.h new file mode 100644 index 00000000..85514df1 --- /dev/null +++ b/src/platform/str9/platform_ints.h @@ -0,0 +1,14 @@ +// This header lists all interrupts defined for this platform + +#ifndef __PLATFORM_INTS_H__ +#define __PLATFORM_INTS_H__ + +#include "elua_int.h" + +#define INT_GPIO_POSEDGE ELUA_INT_FIRST_ID +#define INT_GPIO_NEGEDGE ( ELUA_INT_FIRST_ID + 1 ) +#define INT_TMR_MATCH ( ELUA_INT_FIRST_ID + 2 ) +#define INT_ELUA_LAST INT_TMR_MATCH + +#endif // #ifndef __PLATFORM_INTS_H__ +