lwIP related work.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1173 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
fb616e6101
commit
e8bbaf0cba
|
@ -0,0 +1,191 @@
|
||||||
|
##############################################################################
|
||||||
|
# Build global options
|
||||||
|
# NOTE: Can be overridden externally.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Compiler options here.
|
||||||
|
ifeq ($(USE_OPT),)
|
||||||
|
USE_OPT = -O2 -ggdb -fomit-frame-pointer -mabi=apcs-gnu
|
||||||
|
endif
|
||||||
|
|
||||||
|
# C++ specific options here (added to USE_OPT).
|
||||||
|
ifeq ($(USE_CPPOPT),)
|
||||||
|
USE_CPPOPT = -fno-rtti
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable this if you want the linker to remove unused code and data
|
||||||
|
ifeq ($(USE_LINK_GC),)
|
||||||
|
USE_LINK_GC = yes
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If enabled, this option allows to compile the application in THUMB mode.
|
||||||
|
ifeq ($(USE_THUMB),)
|
||||||
|
USE_THUMB = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Enable register caching optimization (read documentation).
|
||||||
|
ifeq ($(USE_CURRP_CACHING),)
|
||||||
|
USE_CURRP_CACHING = no
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build global options
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Project, sources and paths
|
||||||
|
#
|
||||||
|
|
||||||
|
# Define project name here
|
||||||
|
PROJECT = ch
|
||||||
|
|
||||||
|
# Define linker script file here
|
||||||
|
LDSCRIPT= ch.ld
|
||||||
|
|
||||||
|
# Imported source files
|
||||||
|
CHIBIOS = ../..
|
||||||
|
include ${CHIBIOS}/os/ports/GCC/ARM7/port.mk
|
||||||
|
include ${CHIBIOS}/os/kernel/kernel.mk
|
||||||
|
include ${CHIBIOS}/test/test.mk
|
||||||
|
include ./lwip/lwip.mk
|
||||||
|
|
||||||
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CSRC = ${PORTSRC} \
|
||||||
|
${KERNSRC} \
|
||||||
|
${TESTSRC} \
|
||||||
|
${CHIBIOS}/os/io/pal.c \
|
||||||
|
${CHIBIOS}/os/io/serial.c \
|
||||||
|
${CHIBIOS}/os/io/platforms/AT91SAM7X/pal_lld.c \
|
||||||
|
${CHIBIOS}/os/io/platforms/AT91SAM7X/serial_lld.c \
|
||||||
|
${CHIBIOS}/os/io/platforms/AT91SAM7X/at91lib/aic.c \
|
||||||
|
${LWNETIFSRC} \
|
||||||
|
${LWCORESRC} \
|
||||||
|
${LWIPV4SRC} \
|
||||||
|
${LWAPISRC} \
|
||||||
|
./lwip/arch/sys_arch.c \
|
||||||
|
./lwip/netif/ethernetif.c \
|
||||||
|
board.c main.c
|
||||||
|
|
||||||
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
# setting.
|
||||||
|
CPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACSRC =
|
||||||
|
|
||||||
|
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
ACPPSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCSRC =
|
||||||
|
|
||||||
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
||||||
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
||||||
|
# option that results in lower performance and larger code size.
|
||||||
|
TCPPSRC =
|
||||||
|
|
||||||
|
# List ASM source files here
|
||||||
|
ASMSRC = $(PORTASM) \
|
||||||
|
${CHIBIOS}/os/ports/GCC/ARM7/AT91SAM7X/vectors.s
|
||||||
|
|
||||||
|
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) $(LWINC) \
|
||||||
|
${CHIBIOS}/os/io \
|
||||||
|
${CHIBIOS}/os/io/platforms/AT91SAM7X \
|
||||||
|
${CHIBIOS}/os/various \
|
||||||
|
${CHIBIOS}/os/ports/GCC/ARM7/AT91SAM7X \
|
||||||
|
./lwip
|
||||||
|
|
||||||
|
#
|
||||||
|
# Project, sources and paths
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Compiler settings
|
||||||
|
#
|
||||||
|
|
||||||
|
MCU = arm7tdmi
|
||||||
|
|
||||||
|
TRGT = arm-elf-
|
||||||
|
CC = $(TRGT)gcc
|
||||||
|
CPPC = $(TRGT)g++
|
||||||
|
# Enable loading with g++ only if you need C++ runtime support.
|
||||||
|
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||||
|
# runtime support makes code size explode.
|
||||||
|
LD = $(TRGT)gcc
|
||||||
|
#LD = $(TRGT)g++
|
||||||
|
CP = $(TRGT)objcopy
|
||||||
|
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||||
|
OD = $(TRGT)objdump
|
||||||
|
HEX = $(CP) -O ihex
|
||||||
|
BIN = $(CP) -O binary
|
||||||
|
|
||||||
|
# ARM-specific options here
|
||||||
|
AOPT =
|
||||||
|
|
||||||
|
# THUMB-specific options here
|
||||||
|
TOPT = -mthumb -DTHUMB
|
||||||
|
|
||||||
|
# Define C warning options here
|
||||||
|
CWARN = -Wall -Wstrict-prototypes
|
||||||
|
|
||||||
|
# Define C++ warning options here
|
||||||
|
CPPWARN = -Wall
|
||||||
|
|
||||||
|
#
|
||||||
|
# Compiler settings
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of default section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all default C defines here, like -D_DEBUG=1
|
||||||
|
DDEFS = -DLWIP_PROVIDE_ERRNO
|
||||||
|
|
||||||
|
# List all default ASM defines here, like -D_DEBUG=1
|
||||||
|
DADEFS =
|
||||||
|
|
||||||
|
# List all default directories to look for include files here
|
||||||
|
DINCDIR =
|
||||||
|
|
||||||
|
# List the default directory to look for the libraries here
|
||||||
|
DLIBDIR =
|
||||||
|
|
||||||
|
# List all default libraries here
|
||||||
|
DLIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of default section
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Start of user section
|
||||||
|
#
|
||||||
|
|
||||||
|
# List all user C define here, like -D_DEBUG=1
|
||||||
|
UDEFS =
|
||||||
|
|
||||||
|
# Define ASM defines here
|
||||||
|
UADEFS =
|
||||||
|
|
||||||
|
# List all user directories here
|
||||||
|
UINCDIR =
|
||||||
|
|
||||||
|
# List the user directory to look for the libraries here
|
||||||
|
ULIBDIR =
|
||||||
|
|
||||||
|
# List all user libraries here
|
||||||
|
ULIBS =
|
||||||
|
|
||||||
|
#
|
||||||
|
# End of user defines
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
include ${CHIBIOS}/os/ports/GCC/ARM/rules.mk
|
|
@ -0,0 +1,180 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
#include <pal.h>
|
||||||
|
#include <serial.h>
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "at91lib/aic.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIQ Handler weak symbol defined in vectors.s.
|
||||||
|
*/
|
||||||
|
void FiqHandler(void);
|
||||||
|
|
||||||
|
static CH_IRQ_HANDLER(SpuriousHandler) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
AT91C_BASE_AIC->AIC_EOICR = 0;
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SYS IRQ handling here.
|
||||||
|
*/
|
||||||
|
static CH_IRQ_HANDLER(SYSIrqHandler) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
if (AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS) {
|
||||||
|
(void) AT91C_BASE_PITC->PITC_PIVR;
|
||||||
|
chSysLockFromIsr();
|
||||||
|
chSysTimerHandlerI();
|
||||||
|
chSysUnlockFromIsr();
|
||||||
|
}
|
||||||
|
AT91C_BASE_AIC->AIC_EOICR = 0;
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Digital I/O ports static configuration as defined in @p board.h.
|
||||||
|
*/
|
||||||
|
static const AT91SAM7XPIOConfig config =
|
||||||
|
{
|
||||||
|
{VAL_PIOA_ODSR, VAL_PIOA_OSR, VAL_PIOA_PUSR},
|
||||||
|
{VAL_PIOB_ODSR, VAL_PIOB_OSR, VAL_PIOB_PUSR}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Early initialization code.
|
||||||
|
* This initialization is performed just after reset before BSS and DATA
|
||||||
|
* segments initialization.
|
||||||
|
*/
|
||||||
|
void hwinit0(void) {
|
||||||
|
/*
|
||||||
|
* Flash Memory: 1 wait state, about 50 cycles in a microsecond.
|
||||||
|
*/
|
||||||
|
AT91C_BASE_MC->MC_FMR = (AT91C_MC_FMCN & (50 << 16)) | AT91C_MC_FWS_1FWS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Watchdog disabled.
|
||||||
|
*/
|
||||||
|
AT91C_BASE_WDTC->WDTC_WDMR = AT91C_WDTC_WDDIS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enables the main oscillator and waits 56 slow cycles as startup time.
|
||||||
|
*/
|
||||||
|
AT91C_BASE_PMC->PMC_MOR = (AT91C_CKGR_OSCOUNT & (7 << 8)) | AT91C_CKGR_MOSCEN;
|
||||||
|
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS))
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PLL setup: DIV = 14, MUL = 72, PLLCOUNT = 10
|
||||||
|
* PLLfreq = 96109714 Hz (rounded)
|
||||||
|
*/
|
||||||
|
AT91C_BASE_PMC->PMC_PLLR = (AT91C_CKGR_DIV & 14) |
|
||||||
|
(AT91C_CKGR_PLLCOUNT & (10 << 8)) |
|
||||||
|
(AT91C_CKGR_MUL & (72 << 16));
|
||||||
|
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK))
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Master clock = PLLfreq / 2 = 48054858 Hz (rounded)
|
||||||
|
*/
|
||||||
|
AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_PLL_CLK | AT91C_PMC_PRES_CLK_2;
|
||||||
|
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY))
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PIO initialization.
|
||||||
|
*/
|
||||||
|
palInit(&config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Late initialization code.
|
||||||
|
* This initialization is performed after BSS and DATA segments initialization
|
||||||
|
* and before invoking the main() function.
|
||||||
|
*/
|
||||||
|
void hwinit1(void) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default AIC setup, the device drivers will modify it as needed.
|
||||||
|
*/
|
||||||
|
AT91C_BASE_AIC->AIC_ICCR = 0xFFFFFFFF;
|
||||||
|
AT91C_BASE_AIC->AIC_SVR[0] = (AT91_REG)FiqHandler;
|
||||||
|
for (i = 1; i < 31; i++) {
|
||||||
|
AT91C_BASE_AIC->AIC_SVR[i] = (AT91_REG)NULL;
|
||||||
|
AT91C_BASE_AIC->AIC_EOICR = (AT91_REG)i;
|
||||||
|
}
|
||||||
|
AT91C_BASE_AIC->AIC_SPU = (AT91_REG)SpuriousHandler;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LCD pins setup.
|
||||||
|
*/
|
||||||
|
palClearPad(IOPORT2, PIOB_LCD_BL);
|
||||||
|
palSetPadMode(IOPORT2, PIOB_LCD_BL, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
|
|
||||||
|
palSetPad(IOPORT1, PIOA_LCD_RESET);
|
||||||
|
palSetPadMode(IOPORT1, PIOA_LCD_RESET, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Joystick and buttons setup.
|
||||||
|
*/
|
||||||
|
palSetGroupMode(IOPORT1,
|
||||||
|
PIOA_B1_MASK | PIOA_B2_MASK | PIOA_B3_MASK |
|
||||||
|
PIOA_B4_MASK | PIOA_B5_MASK,
|
||||||
|
PAL_MODE_INPUT);
|
||||||
|
palSetGroupMode(IOPORT2, PIOB_SW1_MASK | PIOB_SW2_MASK, PAL_MODE_INPUT);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MMC/SD slot setup.
|
||||||
|
*/
|
||||||
|
palSetGroupMode(IOPORT2,
|
||||||
|
PIOB_MMC_WP_MASK | PIOB_MMC_CP_MASK,
|
||||||
|
PAL_MODE_INPUT);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PIT Initialization.
|
||||||
|
*/
|
||||||
|
AIC_ConfigureIT(AT91C_ID_SYS,
|
||||||
|
AT91C_AIC_SRCTYPE_HIGH_LEVEL | (AT91C_AIC_PRIOR_HIGHEST - 1),
|
||||||
|
SYSIrqHandler);
|
||||||
|
AIC_EnableIT(AT91C_ID_SYS);
|
||||||
|
AT91C_BASE_PITC->PITC_PIMR = (MCK / 16 / CH_FREQUENCY) - 1;
|
||||||
|
AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITEN | AT91C_PITC_PITIEN;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Serial driver initialization, RTS/CTS pins enabled for USART0 only.
|
||||||
|
*/
|
||||||
|
sdInit();
|
||||||
|
AT91C_BASE_PIOA->PIO_PDR = AT91C_PA3_RTS0 | AT91C_PA4_CTS0;
|
||||||
|
AT91C_BASE_PIOA->PIO_ASR = AT91C_PIO_PA3 | AT91C_PIO_PA4;
|
||||||
|
AT91C_BASE_PIOA->PIO_PPUDR = AT91C_PIO_PA3 | AT91C_PIO_PA4;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ChibiOS/RT initialization.
|
||||||
|
*/
|
||||||
|
chSysInit();
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BOARD_H_
|
||||||
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#include "at91lib/AT91SAM7X256.h"
|
||||||
|
|
||||||
|
#define BOARD_OLIMEX_SAM7_EX256
|
||||||
|
|
||||||
|
#define CLK 18432000
|
||||||
|
#define MCK 48054857
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initial I/O setup.
|
||||||
|
*/
|
||||||
|
#define VAL_PIOA_ODSR 0x00000000 /* Output data. */
|
||||||
|
#define VAL_PIOA_OSR 0x00000000 /* Direction. */
|
||||||
|
#define VAL_PIOA_PUSR 0xFFFFFFFF /* Pull-up. */
|
||||||
|
|
||||||
|
#define VAL_PIOB_ODSR 0x00000000 /* Output data. */
|
||||||
|
#define VAL_PIOB_OSR 0x00000000 /* Direction. */
|
||||||
|
#define VAL_PIOB_PUSR 0xFFFFFFFF /* Pull-up. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I/O definitions.
|
||||||
|
*/
|
||||||
|
#define PIOA_LCD_RESET 2
|
||||||
|
#define PIOA_LCD_RESET_MASK (1 << PIOA_LCD_RESET)
|
||||||
|
#define PIOA_B1 7
|
||||||
|
#define PIOA_B1_MASK (1 << PIOA_B1)
|
||||||
|
#define PIOA_B2 8
|
||||||
|
#define PIOA_B2_MASK (1 << PIOA_B2)
|
||||||
|
#define PIOA_B3 9
|
||||||
|
#define PIOA_B3_MASK (1 << PIOA_B3)
|
||||||
|
#define PIOA_B4 14
|
||||||
|
#define PIOA_B4_MASK (1 << PIOA_B4)
|
||||||
|
#define PIOA_B5 15
|
||||||
|
#define PIOA_B5_MASK (1 << PIOA_B5)
|
||||||
|
#define PIOA_USB_PUP 25
|
||||||
|
#define PIOA_USB_PUP_MASK (1 << PIOA_USB_PUP)
|
||||||
|
#define PIOA_USB_PR 26
|
||||||
|
#define PIOA_USB_PR_MASK (1 << PIOA_USB_PR)
|
||||||
|
|
||||||
|
#define PIOB_PHY_PD 18
|
||||||
|
#define PIOB_PHY_PD_MASK (1 << PIOB_PHY_PD)
|
||||||
|
#define PIOB_AUDIO_OUT 19
|
||||||
|
#define PIOB_AUDIO_OUT_MASK (1 << PIOB_AUDIO_OUT)
|
||||||
|
#define PIOB_LCD_BL 20
|
||||||
|
#define PIOB_LCD_BL_MASK (1 << PIOB_LCD_BL)
|
||||||
|
#define PIOB_MMC_WP 22
|
||||||
|
#define PIOB_MMC_WP_MASK (1 << PIOB_MMC_WP)
|
||||||
|
#define PIOB_MMC_CP 23
|
||||||
|
#define PIOB_MMC_CP_MASK (1 << PIOB_MMC_CP)
|
||||||
|
#define PIOB_SW1 24
|
||||||
|
#define PIOB_SW1_MASK (1 << PIOB_SW1)
|
||||||
|
#define PIOB_SW2 25
|
||||||
|
#define PIOB_SW2_MASK (1 << PIOB_SW2)
|
||||||
|
#define PIOB_PHY_IRQ 26
|
||||||
|
#define PIOB_PHY_IRQ_MASK (1 << PIOB_PHY_IRQ)
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AT91SAM7X256 memory setup.
|
||||||
|
*/
|
||||||
|
__und_stack_size__ = 0x0004;
|
||||||
|
__abt_stack_size__ = 0x0004;
|
||||||
|
__fiq_stack_size__ = 0x0010;
|
||||||
|
__irq_stack_size__ = 0x0080;
|
||||||
|
__svc_stack_size__ = 0x0004;
|
||||||
|
__sys_stack_size__ = 0x0400;
|
||||||
|
__stacks_total_size__ = __und_stack_size__ + __abt_stack_size__ + __fiq_stack_size__ + __irq_stack_size__ + __svc_stack_size__ + __sys_stack_size__;
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
flash : org = 0x100000, len = 256k
|
||||||
|
ram : org = 0x200020, len = 64k - 0x20
|
||||||
|
}
|
||||||
|
|
||||||
|
__ram_start__ = ORIGIN(ram);
|
||||||
|
__ram_size__ = LENGTH(ram);
|
||||||
|
__ram_end__ = __ram_start__ + __ram_size__;
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0;
|
||||||
|
|
||||||
|
.text : ALIGN(16) SUBALIGN(16)
|
||||||
|
{
|
||||||
|
_text = .;
|
||||||
|
KEEP(*(vectors))
|
||||||
|
*(.text)
|
||||||
|
*(.text.*);
|
||||||
|
*(.rodata);
|
||||||
|
*(.rodata.*);
|
||||||
|
*(.glue_7t);
|
||||||
|
*(.glue_7);
|
||||||
|
*(.gcc*);
|
||||||
|
*(.ctors);
|
||||||
|
*(.dtors);
|
||||||
|
. = ALIGN(4);
|
||||||
|
_etext = .;
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
_textdata = _etext;
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
_data = .;
|
||||||
|
*(.data)
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.data.*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.ramtext)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_edata = .;
|
||||||
|
} > ram AT > flash
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
_bss_start = .;
|
||||||
|
*(.bss)
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.bss.*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_bss_end = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
/DISCARD/ :
|
||||||
|
{
|
||||||
|
*(.eh_*)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PROVIDE(end = .);
|
||||||
|
_end = .;
|
||||||
|
|
||||||
|
__heap_base__ = _end;
|
||||||
|
__heap_end__ = __ram_end__ - __stacks_total_size__;
|
|
@ -0,0 +1,379 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file src/templates/chconf.h
|
||||||
|
* @brief Configuration file template.
|
||||||
|
* @addtogroup Config
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CHCONF_H_
|
||||||
|
#define _CHCONF_H_
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Kernel parameters. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frequency of the system timer that drives the system ticks. This also
|
||||||
|
* defines the system tick time unit.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_FREQUENCY 1000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constant is the number of system ticks allowed for the threads before
|
||||||
|
* preemption occurs. This option is only meaningful if the option
|
||||||
|
* @p CH_USE_ROUNDROBIN is also active.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
|
||||||
|
#define CH_TIME_QUANTUM 20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled then the use of nested @p chSysLock() / @p chSysUnlock()
|
||||||
|
* operations is allowed.<br>
|
||||||
|
* For performance and code size reasons the recommended setting is to leave
|
||||||
|
* this option disabled.<br>
|
||||||
|
* You can use this option if you need to merge ChibiOS/RT with external
|
||||||
|
* libraries that require nested lock/unlock operations.
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_NESTED_LOCKS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the kernel performs the round robin scheduling algorithm
|
||||||
|
* on threads of equal priority.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_ROUNDROBIN) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_ROUNDROBIN TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of RAM bytes to use as system heap. If set to zero then the whole
|
||||||
|
* available RAM is used as system heap.
|
||||||
|
* @note In order to use the whole RAM as system heap the linker script must
|
||||||
|
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||||
|
* @note Requires @p CH_USE_HEAP.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HEAP_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HEAP_SIZE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Performance options. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then time efficient rather than space efficient code is used
|
||||||
|
* when two possible implementations exist.
|
||||||
|
* @note This is not related to the compiler optimization options.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
|
||||||
|
#define CH_OPTIMIZE_SPEED TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled defines a CPU register to be used as storage for the global
|
||||||
|
* @p currp variable. Caching this variable in a register can greatly
|
||||||
|
* improve both space and time efficiency of the generated code. Another side
|
||||||
|
* effect is that one less register has to be saved during the context switch
|
||||||
|
* resulting in lower RAM usage and faster code.
|
||||||
|
* @note This option is only usable with the GCC compiler and is only useful
|
||||||
|
* on processors with many registers like ARM cores.
|
||||||
|
* @note If this option is enabled then ALL the libraries linked to the
|
||||||
|
* ChibiOS/RT code <b>must</b> be recompiled with the GCC option @p
|
||||||
|
* -ffixed-@<reg@>.
|
||||||
|
* @note This option must be enabled in the Makefile, it is listed here for
|
||||||
|
* documentation.
|
||||||
|
*/
|
||||||
|
#if defined(__DOXYGEN__)
|
||||||
|
#define CH_CURRP_REGISTER_CACHE "reg"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Subsystem options. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the @p chThdWait() function is included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_WAITEXIT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Semaphores APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled then the threads are enqueued on semaphores by priority rather
|
||||||
|
* than FIFO order.
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMAPHORES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Semaphores the @p chSemWaitSignal() API is included
|
||||||
|
* in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_SEMSW TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Mutexes APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MUTEXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Conditional Variables APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MUTEXES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Conditional Variables APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_CONDVARS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_CONDVARS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Event flags APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
|
||||||
|
* the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_EVENTS.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_EVENTS_TIMEOUT TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Synchronous Messages APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled then messages are served by priority rather than in FIFO order.
|
||||||
|
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||||
|
* @note Requires @p CH_USE_MESSAGES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MESSAGES_PRIORITY FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the Asynchronous Messages (Mailboxes) APIs are included
|
||||||
|
* in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MAILBOXES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the I/O queues APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_SEMAPHORES.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_QUEUES TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the memory heap allocator APIs are included in the kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
|
||||||
|
* @note Mutexes are recommended.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_HEAP TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
|
||||||
|
* functions as backend for the system heap allocator.
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
* @note Requires @p CH_USE_HEAP.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MALLOC_HEAP FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the memory pools allocator APIs are included in the
|
||||||
|
* kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_MEMPOOLS TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If specified then the dynamic threads creation APIs are included in the
|
||||||
|
* kernel.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
* @note Requires @p CH_USE_WAITEXIT.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
|
||||||
|
#define CH_USE_DYNAMIC TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Debug options. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug option, if enabled then the checks on the API functions input
|
||||||
|
* parameters are activated.
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug option, if enabled then all the assertions in the kernel code are
|
||||||
|
* activated. This includes consistency checks inside the kernel, runtime
|
||||||
|
* anomalies and port-defined checks.
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_ASSERTS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug option, if enabled the context switch circular trace buffer is
|
||||||
|
* activated.
|
||||||
|
* @note The default is @p FALSE.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_TRACE FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug option, if enabled a runtime stack check is performed.
|
||||||
|
* @note The stack check is performed in a architecture/port dependent way. It
|
||||||
|
* may not be implemented at all.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_ENABLE_STACK_CHECK FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug option, if enabled the threads working area is filled with a byte
|
||||||
|
* pattern when a thread is created.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_FILL_THREADS FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debug option, if enabled a field is added to the @p Thread structure that
|
||||||
|
* counts the system ticks occurred while executing the thread.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||||
|
#define CH_DBG_THREADS_PROFILING TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Kernel hooks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User fields added to the end of the @p Thread structure.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_FIELDS \
|
||||||
|
struct { \
|
||||||
|
/* Add thread custom fields here.*/ \
|
||||||
|
void *p_timeouts; \
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User initialization code added to the @p chThdInit() API.
|
||||||
|
* @note It is invoked from within @p chThdInit().
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_INIT(tp) { \
|
||||||
|
/* Add thread initialization code here.*/ \
|
||||||
|
currp->p_timeouts = NULL; \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User finalization code added to the @p chThdExit() API.
|
||||||
|
* @note It is inserted into lock zone.
|
||||||
|
*/
|
||||||
|
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
|
||||||
|
#define THREAD_EXT_EXIT(tp) { \
|
||||||
|
/* Add thread finalization code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code inserted inside the idle thread loop immediately after an interrupt
|
||||||
|
* resumed execution.
|
||||||
|
*/
|
||||||
|
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define IDLE_LOOP_HOOK() { \
|
||||||
|
/* Idle loop code here.*/ \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _CHCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
**** This file incorporates work covered by the following copyright and ****
|
||||||
|
**** permission notice: ****
|
||||||
|
|
||||||
|
Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This file is part of the lwIP TCP/IP stack.
|
||||||
|
|
||||||
|
Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CC_H__
|
||||||
|
#define __CC_H__
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
|
||||||
|
typedef uint8_t u8_t;
|
||||||
|
typedef int8_t s8_t;
|
||||||
|
typedef uint16_t u16_t;
|
||||||
|
typedef int16_t s16_t;
|
||||||
|
typedef uint32_t u32_t;
|
||||||
|
typedef int32_t s32_t;
|
||||||
|
typedef uint32_t mem_ptr_t;
|
||||||
|
|
||||||
|
#define LWIP_PLATFORM_DIAG(x)
|
||||||
|
#define LWIP_PLATFORM_ASSERT(x) { \
|
||||||
|
chSysHalt(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BYTE_ORDER LITTLE_ENDIAN
|
||||||
|
|
||||||
|
#endif /* __CC_H__ */
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
**** This file incorporates work covered by the following copyright and ****
|
||||||
|
**** permission notice: ****
|
||||||
|
|
||||||
|
Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This file is part of the lwIP TCP/IP stack.
|
||||||
|
|
||||||
|
Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PERF_H__
|
||||||
|
#define __PERF_H__
|
||||||
|
|
||||||
|
#define PERF_START
|
||||||
|
#define PERF_STOP(x)
|
||||||
|
|
||||||
|
#endif /* __PERF_H__ */
|
|
@ -0,0 +1,159 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
**** This file incorporates work covered by the following copyright and ****
|
||||||
|
**** permission notice: ****
|
||||||
|
|
||||||
|
Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This file is part of the lwIP TCP/IP stack.
|
||||||
|
|
||||||
|
Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "lwip/mem.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
|
||||||
|
#include "arch/cc.h"
|
||||||
|
#include "arch/sys_arch.h"
|
||||||
|
|
||||||
|
static unsigned cnt;
|
||||||
|
|
||||||
|
void sys_init(void) {
|
||||||
|
|
||||||
|
cnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_sem_t sys_sem_new(u8_t count) {
|
||||||
|
|
||||||
|
sys_sem_t sem = mem_malloc(sizeof(Semaphore));
|
||||||
|
chSemInit(sem, (cnt_t)count);
|
||||||
|
return sem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sys_sem_free(sys_sem_t sem) {
|
||||||
|
|
||||||
|
mem_free(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sys_sem_signal(sys_sem_t sem) {
|
||||||
|
|
||||||
|
chSemSignal(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) {
|
||||||
|
systime_t time;
|
||||||
|
|
||||||
|
chSysLock();
|
||||||
|
time = chTimeNow();
|
||||||
|
chSemWaitTimeoutS(sem, (systime_t)timeout);
|
||||||
|
time = chTimeNow() - time;
|
||||||
|
chSysUnlock();
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_mbox_t sys_mbox_new(int size) {
|
||||||
|
sys_mbox_t mbox;
|
||||||
|
|
||||||
|
mbox = mem_malloc(sizeof(Mailbox) + sizeof(msg_t) * size);
|
||||||
|
chMBInit(mbox, (void *)(mbox + 1), size);
|
||||||
|
return mbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sys_mbox_free(sys_mbox_t mbox) {
|
||||||
|
|
||||||
|
mem_free(mbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sys_mbox_post(sys_mbox_t mbox, void *msg) {
|
||||||
|
|
||||||
|
chMBPost(mbox, (msg_t)msg, TIME_INFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg) {
|
||||||
|
|
||||||
|
if (chMBPost(mbox, (msg_t)msg, TIME_IMMEDIATE) == RDY_TIMEOUT)
|
||||||
|
return ERR_MEM;
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout) {
|
||||||
|
|
||||||
|
if (chMBFetchS(mbox, (msg_t *)msg, (systime_t)timeout) == RDY_TIMEOUT)
|
||||||
|
return ERR_MEM;
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
|
||||||
|
|
||||||
|
if (chMBFetchS(mbox, (msg_t *)msg, TIME_IMMEDIATE) == RDY_TIMEOUT)
|
||||||
|
return ERR_MEM;
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sys_timeouts *sys_arch_timeouts(void) {
|
||||||
|
|
||||||
|
return (struct sys_timeouts *)&currp->p_timeouts;
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg),
|
||||||
|
void *arg, int stacksize, int prio) {
|
||||||
|
size_t wsz = THD_WA_SIZE(stacksize);
|
||||||
|
void *wsp = mem_malloc(wsz);
|
||||||
|
if (wsp == NULL)
|
||||||
|
return NULL;
|
||||||
|
return (sys_thread_t)chThdCreateStatic(wsp, wsz, prio, (tfunc_t)thread, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_prot_t sys_arch_protect(void) {
|
||||||
|
|
||||||
|
chSysLock();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sys_arch_unprotect(sys_prot_t pval) {
|
||||||
|
|
||||||
|
chSysUnlock();
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
**** This file incorporates work covered by the following copyright and ****
|
||||||
|
**** permission notice: ****
|
||||||
|
|
||||||
|
Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This file is part of the lwIP TCP/IP stack.
|
||||||
|
|
||||||
|
Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
|
||||||
|
#ifndef __SYS_ARCH_H__
|
||||||
|
#define __SYS_ARCH_H__
|
||||||
|
|
||||||
|
typedef Semaphore * sys_sem_t;
|
||||||
|
typedef void * sys_mbox_t;
|
||||||
|
typedef Thread * sys_thread_t;
|
||||||
|
typedef int sys_prot_t;
|
||||||
|
|
||||||
|
#define SYS_MBOX_NULL (void *)0
|
||||||
|
#define SYS_THREAD_NULL (Thread *)0
|
||||||
|
#define SYS_SEM_NULL (Semaphore *)0
|
||||||
|
|
||||||
|
void sys_init(void);
|
||||||
|
sys_sem_t sys_sem_new(u8_t count);
|
||||||
|
void sys_sem_free(sys_sem_t sem);
|
||||||
|
void sys_sem_signal(sys_sem_t sem);
|
||||||
|
u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout);
|
||||||
|
|
||||||
|
sys_mbox_t sys_mbox_new(int size);
|
||||||
|
void sys_mbox_free(sys_mbox_t mbox);
|
||||||
|
void sys_mbox_post(sys_mbox_t mbox, void *msg);
|
||||||
|
err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg);
|
||||||
|
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
|
||||||
|
u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg);
|
||||||
|
|
||||||
|
struct sys_timeouts *sys_arch_timeouts(void);
|
||||||
|
|
||||||
|
sys_thread_t sys_thread_new(char *name,
|
||||||
|
void (* thread)(void *arg),
|
||||||
|
void *arg,
|
||||||
|
int stacksize,
|
||||||
|
int prio);
|
||||||
|
|
||||||
|
sys_prot_t sys_arch_protect(void);
|
||||||
|
void sys_arch_unprotect(sys_prot_t pval);
|
||||||
|
|
||||||
|
#endif /* __SYS_ARCH_H__ */
|
|
@ -0,0 +1,44 @@
|
||||||
|
# List of the required lwIP files.
|
||||||
|
LWNETIFSRC = \
|
||||||
|
${CHIBIOS}/ext/lwip/src/netif/etharp.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/netif/loopif.c
|
||||||
|
|
||||||
|
LWCORESRC = \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/dhcp.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/dns.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/init.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/mem.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/memp.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/netif.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/pbuf.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/raw.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/stats.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/sys.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/tcp.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/tcp_in.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/tcp_out.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/udp.c
|
||||||
|
|
||||||
|
LWIPV4SRC = \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/autoip.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/icmp.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/igmp.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/inet.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/inet_chksum.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/ip.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/ip_addr.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/core/ipv4/ip_frag.c
|
||||||
|
|
||||||
|
LWAPISRC = \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/api_lib.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/api_msg.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/err.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/netbuf.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/netdb.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/netifapi.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/sockets.c \
|
||||||
|
${CHIBIOS}/ext/lwip/src/api/tcpip.c
|
||||||
|
|
||||||
|
LWINC = \
|
||||||
|
${CHIBIOS}/ext/lwip/src/include \
|
||||||
|
${CHIBIOS}/ext/lwip/src/include/ipv4
|
|
@ -0,0 +1,333 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
**** This file incorporates work covered by the following copyright and ****
|
||||||
|
**** permission notice: ****
|
||||||
|
|
||||||
|
Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This file is part of the lwIP TCP/IP stack.
|
||||||
|
|
||||||
|
Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Ethernet Interface Skeleton
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is a skeleton for developing Ethernet network interface
|
||||||
|
* drivers for lwIP. Add code to the low_level functions and do a
|
||||||
|
* search-and-replace for the word "ethernetif" to replace it with
|
||||||
|
* something that better describes your network interface.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
|
#if 1 /* don't build, this is only a skeleton, see previous comment */
|
||||||
|
|
||||||
|
#include "lwip/def.h"
|
||||||
|
#include "lwip/mem.h"
|
||||||
|
#include "lwip/pbuf.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
|
#include <lwip/stats.h>
|
||||||
|
#include <lwip/snmp.h>
|
||||||
|
#include "netif/etharp.h"
|
||||||
|
#include "netif/ppp_oe.h"
|
||||||
|
|
||||||
|
/* Define those to better describe your network interface. */
|
||||||
|
#define IFNAME0 'e'
|
||||||
|
#define IFNAME1 'n'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper struct to hold private data used to operate your ethernet interface.
|
||||||
|
* Keeping the ethernet address of the MAC in this struct is not necessary
|
||||||
|
* as it is already kept in the struct netif.
|
||||||
|
* But this is only an example, anyway...
|
||||||
|
*/
|
||||||
|
struct ethernetif {
|
||||||
|
struct eth_addr *ethaddr;
|
||||||
|
/* Add whatever per-interface state that is needed here. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Forward declarations. */
|
||||||
|
static void ethernetif_input(struct netif *netif);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this function, the hardware should be initialized.
|
||||||
|
* Called from ethernetif_init().
|
||||||
|
*
|
||||||
|
* @param netif the already initialized lwip network interface structure
|
||||||
|
* for this ethernetif
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
low_level_init(struct netif *netif)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif = netif->state;
|
||||||
|
|
||||||
|
/* set MAC hardware address length */
|
||||||
|
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
||||||
|
|
||||||
|
/* set MAC hardware address */
|
||||||
|
////////// netif->hwaddr[0] = ;
|
||||||
|
////////// ...
|
||||||
|
////////// netif->hwaddr[5] = ;
|
||||||
|
|
||||||
|
/* maximum transfer unit */
|
||||||
|
netif->mtu = 1500;
|
||||||
|
|
||||||
|
/* device capabilities */
|
||||||
|
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
|
||||||
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
|
||||||
|
|
||||||
|
/* Do whatever else is needed to initialize interface. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function should do the actual transmission of the packet. The packet is
|
||||||
|
* contained in the pbuf that is passed to the function. This pbuf
|
||||||
|
* might be chained.
|
||||||
|
*
|
||||||
|
* @param netif the lwip network interface structure for this ethernetif
|
||||||
|
* @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
|
||||||
|
* @return ERR_OK if the packet could be sent
|
||||||
|
* an err_t value if the packet couldn't be sent
|
||||||
|
*
|
||||||
|
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
|
||||||
|
* strange results. You might consider waiting for space in the DMA queue
|
||||||
|
* to become availale since the stack doesn't retry to send a packet
|
||||||
|
* dropped because of memory failure (except for the TCP timers).
|
||||||
|
*/
|
||||||
|
|
||||||
|
static err_t
|
||||||
|
low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif = netif->state;
|
||||||
|
struct pbuf *q;
|
||||||
|
|
||||||
|
////////// initiate transfer();
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(q = p; q != NULL; q = q->next) {
|
||||||
|
/* Send the data from the pbuf to the interface, one pbuf at a
|
||||||
|
time. The size of the data in each pbuf is kept in the ->len
|
||||||
|
variable. */
|
||||||
|
////////// send data from(q->payload, q->len);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////// signal that packet should be sent();
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LINK_STATS_INC(link.xmit);
|
||||||
|
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should allocate a pbuf and transfer the bytes of the incoming
|
||||||
|
* packet from the interface into the pbuf.
|
||||||
|
*
|
||||||
|
* @param netif the lwip network interface structure for this ethernetif
|
||||||
|
* @return a pbuf filled with the received packet (including MAC header)
|
||||||
|
* NULL on memory error
|
||||||
|
*/
|
||||||
|
static struct pbuf *
|
||||||
|
low_level_input(struct netif *netif)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif = netif->state;
|
||||||
|
struct pbuf *p, *q;
|
||||||
|
u16_t len;
|
||||||
|
|
||||||
|
/* Obtain the size of the packet and put it into the "len"
|
||||||
|
variable. */
|
||||||
|
////////// len = ;
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||||
|
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
|
||||||
|
|
||||||
|
if (p != NULL) {
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We iterate over the pbuf chain until we have read the entire
|
||||||
|
* packet into the pbuf. */
|
||||||
|
for(q = p; q != NULL; q = q->next) {
|
||||||
|
/* Read enough bytes to fill this pbuf in the chain. The
|
||||||
|
* available data in the pbuf is given by the q->len
|
||||||
|
* variable. */
|
||||||
|
////////// read data into(q->payload, q->len);
|
||||||
|
}
|
||||||
|
////////// acknowledge that packet has been read();
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LINK_STATS_INC(link.recv);
|
||||||
|
} else {
|
||||||
|
////////// drop packet();
|
||||||
|
LINK_STATS_INC(link.memerr);
|
||||||
|
LINK_STATS_INC(link.drop);
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function should be called when a packet is ready to be read
|
||||||
|
* from the interface. It uses the function low_level_input() that
|
||||||
|
* should handle the actual reception of bytes from the network
|
||||||
|
* interface. Then the type of the received packet is determined and
|
||||||
|
* the appropriate input function is called.
|
||||||
|
*
|
||||||
|
* @param netif the lwip network interface structure for this ethernetif
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
ethernetif_input(struct netif *netif)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif;
|
||||||
|
struct eth_hdr *ethhdr;
|
||||||
|
struct pbuf *p;
|
||||||
|
|
||||||
|
ethernetif = netif->state;
|
||||||
|
|
||||||
|
/* move received packet into a new pbuf */
|
||||||
|
p = low_level_input(netif);
|
||||||
|
/* no packet could be read, silently ignore this */
|
||||||
|
if (p == NULL) return;
|
||||||
|
/* points to packet payload, which starts with an Ethernet header */
|
||||||
|
ethhdr = p->payload;
|
||||||
|
|
||||||
|
switch (htons(ethhdr->type)) {
|
||||||
|
/* IP or ARP packet? */
|
||||||
|
case ETHTYPE_IP:
|
||||||
|
case ETHTYPE_ARP:
|
||||||
|
#if PPPOE_SUPPORT
|
||||||
|
/* PPPoE packet? */
|
||||||
|
case ETHTYPE_PPPOEDISC:
|
||||||
|
case ETHTYPE_PPPOE:
|
||||||
|
#endif /* PPPOE_SUPPORT */
|
||||||
|
/* full packet send to tcpip_thread to process */
|
||||||
|
if (netif->input(p, netif)!=ERR_OK)
|
||||||
|
{ LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
||||||
|
pbuf_free(p);
|
||||||
|
p = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
pbuf_free(p);
|
||||||
|
p = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be called at the beginning of the program to set up the
|
||||||
|
* network interface. It calls the function low_level_init() to do the
|
||||||
|
* actual setup of the hardware.
|
||||||
|
*
|
||||||
|
* This function should be passed as a parameter to netif_add().
|
||||||
|
*
|
||||||
|
* @param netif the lwip network interface structure for this ethernetif
|
||||||
|
* @return ERR_OK if the loopif is initialized
|
||||||
|
* ERR_MEM if private data couldn't be allocated
|
||||||
|
* any other err_t on error
|
||||||
|
*/
|
||||||
|
err_t
|
||||||
|
ethernetif_init(struct netif *netif)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif;
|
||||||
|
|
||||||
|
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||||
|
|
||||||
|
ethernetif = mem_malloc(sizeof(struct ethernetif));
|
||||||
|
if (ethernetif == NULL) {
|
||||||
|
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n"));
|
||||||
|
return ERR_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LWIP_NETIF_HOSTNAME
|
||||||
|
/* Initialize interface hostname */
|
||||||
|
netif->hostname = "lwip";
|
||||||
|
#endif /* LWIP_NETIF_HOSTNAME */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the snmp variables and counters inside the struct netif.
|
||||||
|
* The last argument should be replaced with your link speed, in units
|
||||||
|
* of bits per second.
|
||||||
|
*/
|
||||||
|
NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, ???);
|
||||||
|
|
||||||
|
netif->state = ethernetif;
|
||||||
|
netif->name[0] = IFNAME0;
|
||||||
|
netif->name[1] = IFNAME1;
|
||||||
|
/* We directly use etharp_output() here to save a function call.
|
||||||
|
* You can instead declare your own function an call etharp_output()
|
||||||
|
* from it if you have to do some checks before sending (e.g. if link
|
||||||
|
* is available...) */
|
||||||
|
netif->output = etharp_output;
|
||||||
|
netif->linkoutput = low_level_output;
|
||||||
|
|
||||||
|
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
||||||
|
|
||||||
|
/* initialize the hardware */
|
||||||
|
low_level_init(netif);
|
||||||
|
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* 0 */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ch.h>
|
||||||
|
#include <pal.h>
|
||||||
|
#include <serial.h>
|
||||||
|
#include <test.h>
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
static WORKING_AREA(waThread1, 64);
|
||||||
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
|
while (TRUE) {
|
||||||
|
palSetPad(IOPORT2, PIOB_LCD_BL);
|
||||||
|
chThdSleepMilliseconds(100);
|
||||||
|
palClearPad(IOPORT2, PIOB_LCD_BL);
|
||||||
|
chThdSleepMilliseconds(900);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Entry point, note, the main() function is already a thread in the system
|
||||||
|
* on entry.
|
||||||
|
*/
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Activates the serial driver 1 using the driver default configuration.
|
||||||
|
*/
|
||||||
|
sdStart(&SD1, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates the blinker thread.
|
||||||
|
*/
|
||||||
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Normal main() thread activity.
|
||||||
|
*/
|
||||||
|
while (TRUE) {
|
||||||
|
chThdSleepMilliseconds(500);
|
||||||
|
if (!palReadPad(IOPORT2, PIOB_SW1))
|
||||||
|
sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
|
||||||
|
if (!palReadPad(IOPORT2, PIOB_SW2))
|
||||||
|
TestThread(&SD1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
*****************************************************************************
|
||||||
|
** ChibiOS/RT port for ARM7TDMI AT91SAM7X256. **
|
||||||
|
*****************************************************************************
|
||||||
|
|
||||||
|
** TARGET **
|
||||||
|
|
||||||
|
The demo runs on an Olimex SAM7-EX256 board.
|
||||||
|
|
||||||
|
** The Demo **
|
||||||
|
|
||||||
|
The demo currently just flashes the LCD background using a thread.
|
||||||
|
The button SW1 prints an "Hello World!" string on COM1, the button SW2
|
||||||
|
activates che ChibiOS/RT test suite, output on COM1.
|
||||||
|
|
||||||
|
** Build Procedure **
|
||||||
|
|
||||||
|
The demo was built using the YAGARTO toolchain but any toolchain based on GCC
|
||||||
|
and GNU userspace programs will work.
|
||||||
|
|
||||||
|
** Notes **
|
||||||
|
|
||||||
|
Some files used by the demo are not part of ChibiOS/RT but are Atmel copyright
|
||||||
|
and are licensed under a different license, see the header present in all the
|
||||||
|
source files under ./demos/AT91SAM7X256/at91lib for details.
|
||||||
|
Also note that not all the files present in the Atmel library are distribuited
|
||||||
|
with ChibiOS/RT, you can find the whole library on the Atmel web site:
|
||||||
|
|
||||||
|
http://www.atmel.com
|
Loading…
Reference in New Issue