mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
resolved the -Os issue
This commit is contained in:
parent
c5579aa4f4
commit
346132a806
@ -285,7 +285,7 @@ int platform_i2c_recv_byte( unsigned id, int ack );
|
||||
// *****************************************************************************
|
||||
// Ethernet specific functions
|
||||
|
||||
void platform_eth_send_packet( const void* src, u32 size );
|
||||
void platform_eth_send_packet( const void* src, u32 size ,u8 endframe);
|
||||
u32 platform_eth_get_packet_nb( void* buf, u32 maxlen );
|
||||
void platform_eth_force_interrupt();
|
||||
u32 platform_eth_get_elapsed_time();
|
||||
|
@ -40,13 +40,17 @@ static u32 periodic_timer, arp_timer;
|
||||
|
||||
static void device_driver_send()
|
||||
{
|
||||
#ifdef ELUA_PLATFORM_AVR32
|
||||
platform_eth_send_packet( uip_buf, uip_len, TRUE);
|
||||
#else
|
||||
if( uip_len <= TOTAL_HEADER_LENGTH )
|
||||
platform_eth_send_packet( uip_buf, uip_len );
|
||||
platform_eth_send_packet( uip_buf, uip_len, TRUE);
|
||||
else
|
||||
{
|
||||
platform_eth_send_packet( uip_buf, TOTAL_HEADER_LENGTH );
|
||||
platform_eth_send_packet( ( u8* )uip_appdata, uip_len - TOTAL_HEADER_LENGTH );
|
||||
platform_eth_send_packet( uip_buf, TOTAL_HEADER_LENGTH, FALSE );
|
||||
platform_eth_send_packet( ( u8* )uip_appdata, uip_len - TOTAL_HEADER_LENGTH, TRUE );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// This gets called on both Ethernet RX interrupts and timer requests,
|
||||
@ -272,7 +276,7 @@ volatile static elua_net_ip elua_uip_accept_remote;
|
||||
|
||||
void elua_uip_appcall()
|
||||
{
|
||||
struct elua_uip_state *s;
|
||||
volatile struct elua_uip_state *s;
|
||||
elua_net_size temp;
|
||||
int sockno;
|
||||
|
||||
|
@ -22,6 +22,10 @@
|
||||
//#define BUILD_RFS
|
||||
//#define BUILD_SERMUX
|
||||
|
||||
#define BUILD_UIP
|
||||
//#define BUILD_DHCPC
|
||||
#define BUILD_DNS
|
||||
|
||||
// *****************************************************************************
|
||||
// UART/Timer IDs configuration data (used in main.c)
|
||||
|
||||
@ -60,6 +64,12 @@
|
||||
#define BUILD_RPC
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
#define NETLINE _ROM( AUXLIB_NET, luaopen_net, net_map )
|
||||
#else
|
||||
#define NETLINE
|
||||
#endif
|
||||
|
||||
#if defined( BUILD_RPC )
|
||||
#define RPCLINE _ROM( AUXLIB_RPC, luaopen_rpc, rpc_map )
|
||||
#else
|
||||
@ -73,6 +83,7 @@
|
||||
_ROM( AUXLIB_SPI, luaopen_spi, spi_map )\
|
||||
_ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\
|
||||
_ROM( AUXLIB_TERM, luaopen_term, term_map )\
|
||||
NETLINE\
|
||||
_ROM( AUXLIB_CPU, luaopen_cpu, cpu_map )\
|
||||
_ROM( AUXLIB_ELUA, luaopen_elua, elua_map )\
|
||||
RPCLINE\
|
||||
@ -153,4 +164,26 @@
|
||||
// *****************************************************************************
|
||||
// CPU constants that should be exposed to the eLua "cpu" module
|
||||
|
||||
|
||||
// Static TCP/IP configuration
|
||||
#define ELUA_CONF_IPADDR0 192
|
||||
#define ELUA_CONF_IPADDR1 168
|
||||
#define ELUA_CONF_IPADDR2 1
|
||||
#define ELUA_CONF_IPADDR3 10
|
||||
|
||||
#define ELUA_CONF_NETMASK0 255
|
||||
#define ELUA_CONF_NETMASK1 255
|
||||
#define ELUA_CONF_NETMASK2 255
|
||||
#define ELUA_CONF_NETMASK3 0
|
||||
|
||||
#define ELUA_CONF_DEFGW0 192
|
||||
#define ELUA_CONF_DEFGW1 168
|
||||
#define ELUA_CONF_DEFGW2 1
|
||||
#define ELUA_CONF_DEFGW3 1
|
||||
|
||||
#define ELUA_CONF_DNS0 192
|
||||
#define ELUA_CONF_DNS1 168
|
||||
#define ELUA_CONF_DNS2 1
|
||||
#define ELUA_CONF_DNS3 1
|
||||
|
||||
#endif // #ifndef __EVK1100_CONF_H__
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define __MIZAR32_CONF_H__
|
||||
|
||||
#include "sdramc.h"
|
||||
#include "sermux.h"
|
||||
#include "buf.h"
|
||||
|
||||
// *****************************************************************************
|
||||
@ -15,17 +16,27 @@
|
||||
|
||||
#define BUILD_MMCFS
|
||||
//#define BUILD_XMODEM
|
||||
//#define BUILD_SHELL
|
||||
//#define BUILD_ROMFS
|
||||
#define BUILD_SHELL
|
||||
#define BUILD_ROMFS
|
||||
//#define BUILD_TERM
|
||||
#define BUILD_CON_GENERIC
|
||||
//#define BUILD_CON_GENERIC
|
||||
//#define BUILD_RPC
|
||||
#define BUF_ENABLE_UART
|
||||
#define BUILD_C_INT_HANDLERS
|
||||
#define BUILA_LUA_INT_HANDLERS
|
||||
//#define BUILD_RFS
|
||||
//#define BUILD_SERMUX
|
||||
|
||||
#define BUILD_UIP
|
||||
//#define BUILD_DHCPC
|
||||
#define BUILD_DNS
|
||||
#define BUILD_CON_TCP
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// 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 CON_TIMER_ID 0
|
||||
@ -59,6 +70,12 @@
|
||||
#define BUILD_RPC
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
#define NETLINE _ROM( AUXLIB_NET, luaopen_net, net_map )
|
||||
#else
|
||||
#define NETLINE
|
||||
#endif
|
||||
|
||||
#if defined( BUILD_RPC )
|
||||
#define RPCLINE _ROM( AUXLIB_RPC, luaopen_rpc, rpc_map )
|
||||
#else
|
||||
@ -69,8 +86,10 @@
|
||||
_ROM( AUXLIB_PD, luaopen_pd, pd_map )\
|
||||
_ROM( AUXLIB_UART, luaopen_uart, uart_map )\
|
||||
_ROM( AUXLIB_PIO, luaopen_pio, pio_map )\
|
||||
_ROM( AUXLIB_SPI, luaopen_spi, spi_map )\
|
||||
_ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\
|
||||
_ROM( AUXLIB_TERM, luaopen_term, term_map )\
|
||||
NETLINE\
|
||||
_ROM( AUXLIB_CPU, luaopen_cpu, cpu_map )\
|
||||
_ROM( AUXLIB_ELUA, luaopen_elua, elua_map )\
|
||||
RPCLINE\
|
||||
@ -78,11 +97,15 @@
|
||||
_ROM( AUXLIB_PACK, luaopen_pack, pack_map )\
|
||||
_ROM( LUA_MATHLIBNAME, luaopen_math, math_map )
|
||||
|
||||
#if MINIMAL_ROM_MODULES_TO_FIT_IN_120KB
|
||||
/* Minimal ROM modules, to fit in 120KB */
|
||||
#undef LUA_PLATFORM_LIBS_ROM
|
||||
#define LUA_PLATFORM_LIBS_ROM\
|
||||
_ROM( AUXLIB_PIO, luaopen_pio, pio_map )\
|
||||
_ROM( AUXLIB_TMR, luaopen_tmr, tmr_map )\
|
||||
NETLINE
|
||||
|
||||
#endif
|
||||
|
||||
// *****************************************************************************
|
||||
// Configuration data
|
||||
@ -142,12 +165,49 @@
|
||||
#define MEM_START_ADDRESS { ( void* )SDRAM }
|
||||
#define MEM_END_ADDRESS { ( void* )( SDRAM + SDRAM_SIZE - 1 ) }
|
||||
|
||||
#define RFS_BUFFER_SIZE BUF_SIZE_512
|
||||
#define RFS_UART_ID ( SERMUX_SERVICE_ID_FIRST )
|
||||
#define RFS_TIMER_ID 0
|
||||
#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 )
|
||||
|
||||
// *****************************************************************************
|
||||
// CPU constants that should be exposed to the eLua "cpu" module
|
||||
|
||||
|
||||
// Static TCP/IP configuration
|
||||
|
||||
#define ELUA_CONF_IPADDR0 192
|
||||
#define ELUA_CONF_IPADDR1 168
|
||||
#define ELUA_CONF_IPADDR2 1
|
||||
#define ELUA_CONF_IPADDR3 10
|
||||
|
||||
#define ELUA_CONF_NETMASK0 255
|
||||
#define ELUA_CONF_NETMASK1 255
|
||||
#define ELUA_CONF_NETMASK2 255
|
||||
#define ELUA_CONF_NETMASK3 0
|
||||
|
||||
#define ELUA_CONF_DEFGW0 192
|
||||
#define ELUA_CONF_DEFGW1 168
|
||||
#define ELUA_CONF_DEFGW2 1
|
||||
#define ELUA_CONF_DEFGW3 1
|
||||
|
||||
#define ELUA_CONF_DNS0 192
|
||||
#define ELUA_CONF_DNS1 168
|
||||
#define ELUA_CONF_DNS2 1
|
||||
#define ELUA_CONF_DNS3 1
|
||||
|
||||
#endif // #ifndef __MIZAR32_CONF_H__
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- Configuration file for the AVR32 microcontrollers
|
||||
|
||||
specific_files = "crt0.s trampoline.s platform.c exception.s intc.c pm.c flashc.c pm_conf_clocks.c usart.c gpio.c tc.c spi.c platform_int.c"
|
||||
specific_files = "crt0.s trampoline.s platform.c exception.s intc.c pm.c flashc.c pm_conf_clocks.c usart.c gpio.c tc.c spi.c platform_int.c ethernet.c"
|
||||
addm( "FORAVR32" )
|
||||
|
||||
-- See board.h for possible BOARD values.
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Configuration file for the AVR32 microcontrollers
|
||||
|
||||
specific_files = "crt0.s trampoline.s platform.c exception.s intc.c pm.c flashc.c pm_conf_clocks.c usart.c gpio.c tc.c spi.c platform_int.c"
|
||||
specific_files = "crt0.s trampoline.s platform.c exception.s intc.c pm.c flashc.c pm_conf_clocks.c usart.c gpio.c tc.c spi.c platform_int.c ethernet.c"
|
||||
comp.Append(CPPDEFINES = 'FORAVR32')
|
||||
|
||||
# See board.h for possible BOARD values.
|
||||
|
@ -689,6 +689,7 @@ static unsigned long ulReadMDIO(volatile avr32_macb_t *macb, unsigned short usAd
|
||||
static void vWriteMDIO(volatile avr32_macb_t *macb, unsigned short usAddress, unsigned short usValue)
|
||||
{
|
||||
unsigned long status;
|
||||
u16 timeout = 0;
|
||||
|
||||
// initiate transaction : enable management port
|
||||
macb->ncr |= AVR32_MACB_NCR_MPE_MASK;
|
||||
@ -702,7 +703,7 @@ static void vWriteMDIO(volatile avr32_macb_t *macb, unsigned short usAddress, un
|
||||
// wait for PHY to be ready
|
||||
do {
|
||||
status = macb->nsr;
|
||||
} while (!(status & AVR32_MACB_NSR_IDLE_MASK));
|
||||
} while (!(status & AVR32_MACB_NSR_IDLE_MASK) && (timeout++ < TIMEOUT));
|
||||
// disable management port
|
||||
macb->ncr &= ~AVR32_MACB_NCR_MPE_MASK;
|
||||
}
|
||||
|
@ -15,6 +15,16 @@
|
||||
#include "common.h"
|
||||
#include "buf.h"
|
||||
#include "spi.h"
|
||||
#ifdef BUILD_MMCFS
|
||||
#include "diskio.h"
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
#include "ethernet.h"
|
||||
#include "uip_arp.h"
|
||||
#include "elua_uip.h"
|
||||
#include "uip-conf.h"
|
||||
#endif
|
||||
|
||||
// Platform-specific includes
|
||||
#include <avr32/io.h>
|
||||
@ -27,8 +37,21 @@
|
||||
#include "tc.h"
|
||||
#include "intc.h"
|
||||
|
||||
// UIP sys tick data
|
||||
// NOTE: when using virtual timers, SYSTICKHZ and VTMR_FREQ_HZ should have the
|
||||
// same value, as they're served by the same timer (the systick)
|
||||
#define SYSTICKHZ 4
|
||||
#define SYSTICKMS (1000 / SYSTICKHZ)
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
static int eth_timer_fired;
|
||||
#endif
|
||||
|
||||
// ****************************************************************************
|
||||
// Platform initialization
|
||||
#ifdef BUILD_UIP
|
||||
u32 platform_ethernet_setup(void);
|
||||
#endif
|
||||
|
||||
extern int pm_configure_clocks( pm_freq_param_t *param );
|
||||
|
||||
@ -44,6 +67,19 @@ __attribute__((__interrupt__)) static void tmr_int_handler()
|
||||
|
||||
tc_read_sr( tc, VTMR_CH );
|
||||
cmn_virtual_timer_cb();
|
||||
|
||||
#ifdef BUILD_MMCFS
|
||||
disk_timerproc();
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
// Indicate that a SysTick interrupt has occurred.
|
||||
eth_timer_fired = 1;
|
||||
|
||||
// Generate a fake Ethernet interrupt. This will perform the actual work
|
||||
// of incrementing the timers and taking the appropriate actions.
|
||||
platform_eth_force_interrupt();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -169,6 +205,11 @@ int platform_init()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
platform_ethernet_setup();
|
||||
#endif
|
||||
|
||||
cmn_platform_init();
|
||||
#ifdef ELUA_BOARD_MIZAR32
|
||||
platform_pio_op( 0, ( pio_type )1 << 0 , PLATFORM_IO_PIN_PULLUP );
|
||||
@ -625,4 +666,88 @@ int platform_cpu_get_global_interrupts()
|
||||
{
|
||||
return Is_global_interrupt_enabled();
|
||||
}
|
||||
// ****************************************************************************
|
||||
// Network support
|
||||
|
||||
|
||||
#ifdef BUILD_UIP
|
||||
static const gpio_map_t MACB_GPIO_MAP =
|
||||
{
|
||||
{AVR32_MACB_MDC_0_PIN, AVR32_MACB_MDC_0_FUNCTION },
|
||||
{AVR32_MACB_MDIO_0_PIN, AVR32_MACB_MDIO_0_FUNCTION },
|
||||
{AVR32_MACB_RXD_0_PIN, AVR32_MACB_RXD_0_FUNCTION },
|
||||
{AVR32_MACB_TXD_0_PIN, AVR32_MACB_TXD_0_FUNCTION },
|
||||
{AVR32_MACB_RXD_1_PIN, AVR32_MACB_RXD_1_FUNCTION },
|
||||
{AVR32_MACB_TXD_1_PIN, AVR32_MACB_TXD_1_FUNCTION },
|
||||
{AVR32_MACB_TX_EN_0_PIN, AVR32_MACB_TX_EN_0_FUNCTION },
|
||||
{AVR32_MACB_RX_ER_0_PIN, AVR32_MACB_RX_ER_0_FUNCTION },
|
||||
{AVR32_MACB_RX_DV_0_PIN, AVR32_MACB_RX_DV_0_FUNCTION },
|
||||
{AVR32_MACB_TX_CLK_0_PIN, AVR32_MACB_TX_CLK_0_FUNCTION}
|
||||
};
|
||||
|
||||
u32 platform_ethernet_setup()
|
||||
{
|
||||
static struct uip_eth_addr sTempAddr;
|
||||
// Assign GPIO to MACB
|
||||
gpio_enable_module(MACB_GPIO_MAP, sizeof(MACB_GPIO_MAP) / sizeof(MACB_GPIO_MAP[0]));
|
||||
|
||||
// initialize MACB & Phy Layers
|
||||
if (xMACBInit(&AVR32_MACB) == FALSE ) {
|
||||
return PLATFORM_ERR;
|
||||
}
|
||||
|
||||
sTempAddr.addr[0] = ETHERNET_CONF_ETHADDR0;
|
||||
sTempAddr.addr[1] = ETHERNET_CONF_ETHADDR1;
|
||||
sTempAddr.addr[2] = ETHERNET_CONF_ETHADDR2;
|
||||
sTempAddr.addr[3] = ETHERNET_CONF_ETHADDR3;
|
||||
sTempAddr.addr[4] = ETHERNET_CONF_ETHADDR4;
|
||||
sTempAddr.addr[5] = ETHERNET_CONF_ETHADDR5;
|
||||
|
||||
// Initialize the eLua uIP layer
|
||||
elua_uip_init( &sTempAddr );
|
||||
|
||||
return PLATFORM_OK;
|
||||
|
||||
}
|
||||
|
||||
void platform_eth_send_packet( const void* src, u32 size, u8 endframe )
|
||||
{
|
||||
lMACBSend(&AVR32_MACB,src, size, endframe);
|
||||
}
|
||||
|
||||
u32 platform_eth_get_packet_nb( void* buf, u32 maxlen )
|
||||
{
|
||||
u32 len;
|
||||
|
||||
/* Obtain the size of the packet. */
|
||||
len = ulMACBInputLength();
|
||||
|
||||
if (len > maxlen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( len ) {
|
||||
/* Let the driver know we are going to read a new packet. */
|
||||
vMACBRead( NULL, 0, len );
|
||||
vMACBRead( buf, len, len );
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void platform_eth_force_interrupt()
|
||||
{
|
||||
elua_uip_mainloop();
|
||||
}
|
||||
|
||||
u32 platform_eth_get_elapsed_time()
|
||||
{
|
||||
if( eth_timer_fired )
|
||||
{
|
||||
eth_timer_fired = 0;
|
||||
return SYSTICKMS;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user