git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@248 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2008-03-27 11:48:28 +00:00
parent 810cd75140
commit ef14f74f92
9 changed files with 1057 additions and 0 deletions

View File

@ -0,0 +1,227 @@
#
# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
#
##############################################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#
##############################################################################################
# Start of default section
#
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
MCU = arm7tdmi
# List all default C defines here, like -D_DEBUG=1
DDEFS =
# 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
#
# Define project name here
PROJECT = ch
# Define linker script file here
LDSCRIPT= ch.ld
# List all user C define here, like -D_DEBUG=1
UDEFS =
# Define ASM defines here
UADEFS =
# List ARM-mode C source files here
CSRC = ../../ports/ARM7-LPC214x/chcore.c \
../../ports/ARM7-LPC214x/vic.c \
../../ports/ARM7-LPC214x/lpc214x_serial.c \
../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \
../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chmtx.c \
../../src/chevents.c ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c \
../../src/chserial.c \
../../src/lib/evtimer.c ../../test/test.c \
board.c
# List ARM-mode C++ source files here
CPPSRC = ../../src/lib/ch.cpp main.cpp
# List THUMB-mode C sources here
# NOTE: If any module is compiled in thumb mode then -mthumb-interwork is
# enabled for all modules and that lowers performance.
TSRC =
# List ASM source files here
ASMSRC = ../../ports/ARM7-LPC214x/crt0.s ../../ports/ARM7/chsys.s
# List all user directories here
UINCDIR = ../../src/include ../../src/lib \
../../ports/ARM7 ../../ports/ARM7-LPC214x
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS =
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -D THUMB
# Common options here
# NOTE: -ffixed-r7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in
# chconf.h.
# NOTE: -falign-functions=16 may improve the performance, not always, but
# increases the code size.
OPT = -O2 -ggdb -fomit-frame-pointer
#OPT += -ffixed-r7
OPT += -falign-functions=16
# C++ specific options here
# NOTE: -fno-rtti saves a LOT of code space, remove it only if you really need
# RTTI.
CPPOPT = -fno-rtti
# Define warning options here
WARN = -Wall
#
# End of user defines
##############################################################################################
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
ADEFS = $(DADEFS) $(UADEFS)
AOBJS = $(CSRC:.c=.o)
TOBJS = $(TSRC:.c=.o)
CPPOBJS = $(CPPSRC:.cpp=.o)
ASMOBJS = $(ASMSRC:.s=.o)
OBJS = $(ASMOBJS) $(CPPOBJS) $(AOBJS) $(TOBJS)
LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
CFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(WARN) -Wa,-alms=$(<:.cpp=.lst) $(DEFS)
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
ODFLAGS = -x --syms
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
CFLAGS += -D THUMB_PRESENT
CPPFLAGS += -D THUMB_PRESENT
ASFLAGS += -D THUMB_PRESENT
ifneq ($(CSRC),)
# Mixed ARM and THUMB case.
CFLAGS += -mthumb-interwork
CPPFLAGS += -mthumb-interwork
LDFLAGS += -mthumb-interwork
else
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly.
CFLAGS += -D THUMB_NO_INTERWORKING
CPPFLAGS += -D THUMB_NO_INTERWORKING
LDFLAGS += -mthumb
ASFLAGS += -D THUMB_NO_INTERWORKING
endif
endif
# Generate dependency information
CFLAGS += -MD -MP -MF .dep/$(@F).d
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
#
# Makefile rules
#
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp
$(CPPOBJS) : %.o : %.cpp
@echo
$(CPPC) -c $(CPPFLAGS) $(AOPT) -I . $(INCDIR) $< -o $@
$(AOBJS) : %.o : %.c
@echo
$(CC) -c $(CFLAGS) $(AOPT) -I . $(INCDIR) $< -o $@
$(TOBJS) : %.o : %.c
@echo
$(CC) -c $(CFLAGS) $(TOPT) -I . $(INCDIR) $< -o $@
$(ASMOBJS) : %.o : %.s
@echo
$(AS) -c $(ASFLAGS) -I . $(INCDIR) $< -o $@
%elf: $(OBJS)
@echo
$(LD) $(ASMOBJS) $(AOBJS) $(TOBJS) $(CPPOBJS) $(LDFLAGS) $(LIBS) -o $@
%hex: %elf
$(HEX) $< $@
%bin: %elf
$(BIN) $< $@
%dmp: %elf
$(OD) $(ODFLAGS) $< > $@
clean:
-rm -f $(OBJS)
-rm -f $(PROJECT).elf
-rm -f $(PROJECT).dmp
-rm -f $(PROJECT).map
-rm -f $(PROJECT).hex
-rm -f $(PROJECT).bin
-rm -f $(CSRC:.c=.c.bak)
-rm -f $(CSRC:.c=.lst)
-rm -f $(CPPSRC:.cpp=.c.bak)
-rm -f $(CPPSRC:.cpp=.lst)
-rm -f $(TSRC:.c=.c.bak)
-rm -f $(TSRC:.c=.lst)
-rm -f $(ASMSRC:.s=.s.bak)
-rm -f $(ASMSRC:.s=.lst)
-rm -fR .dep
#
# Include the dependency files, should be the last of the makefile
#
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# *** EOF ***

View File

@ -0,0 +1,199 @@
#
# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
#
##############################################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#
##############################################################################################
# Start of default section
#
TRGT = arm-elf-
CC = $(TRGT)gcc
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
OD = $(TRGT)objdump
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
MCU = arm7tdmi
# List all default C defines here, like -D_DEBUG=1
DDEFS =
# 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
#
# Define project name here
PROJECT = ch
# Define linker script file here
LDSCRIPT= ch.ld
# List all user C define here, like -D_DEBUG=1
UDEFS =
# Define ASM defines here
UADEFS =
# List ARM-mode C source files here
ASRC =
# List THUMB-mode C sources here
# NOTE: If any module is compiled in thumb mode then -mthumb-interwork is
# enabled for all modules and that lowers performance.
TSRC = ../../ports/ARM7-LPC214x/chcore.c \
../../ports/ARM7-LPC214x/vic.c \
../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \
../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chmtx.c \
../../src/chevents.c ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c \
../../src/chserial.c \
board.c main.c
# List ASM source files here
ASMSRC = ../../ports/ARM7-LPC214x/crt0.s ../../ports/ARM7/chsys.s
# List all user directories here
UINCDIR = ../../src/include ../../src/lib \
../../ports/ARM7 ../../ports/ARM7-LPC214x
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS =
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -D THUMB
# Common options here
# NOTE: -ffixed-r7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in
# chconf.h.
# NOTE: -falign-functions=16 may improve the performance, not always, but
# increases the code size.
OPT = -Os -ggdb -fomit-frame-pointer
#OPT += -ffixed-r7
OPT += -falign-functions=16
# Define warning options here
WARN = -Wall -Wstrict-prototypes
#
# End of user defines
##############################################################################################
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
ADEFS = $(DADEFS) $(UADEFS)
AOBJS = $(ASRC:.c=.o)
TOBJS = $(TSRC:.c=.o)
OBJS = $(ASMOBJS) $(AOBJS) $(TOBJS)
ASMOBJS = $(ASMSRC:.s=.o)
LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
ODFLAGS = -x --syms
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
CPFLAGS += -D THUMB_PRESENT
ASFLAGS += -D THUMB_PRESENT
ifneq ($(ASRC),)
# Mixed ARM and THUMB case.
CPFLAGS += -mthumb-interwork
LDFLAGS += -mthumb-interwork
else
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly.
CPFLAGS += -D THUMB_NO_INTERWORKING
LDFLAGS += -mthumb
ASFLAGS += -D THUMB_NO_INTERWORKING
endif
endif
# Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d
#
# Makefile rules
#
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp
$(AOBJS) : %.o : %.c
@echo
$(CC) -c $(CPFLAGS) $(AOPT) -I . $(INCDIR) $< -o $@
$(TOBJS) : %.o : %.c
@echo
$(CC) -c $(CPFLAGS) $(TOPT) -I . $(INCDIR) $< -o $@
$(ASMOBJS) : %.o : %.s
@echo
$(AS) -c $(ASFLAGS) -I . $(INCDIR) $< -o $@
%elf: $(OBJS)
@echo
$(CC) $(ASMOBJS) $(AOBJS) $(TOBJS) $(LDFLAGS) $(LIBS) -o $@
%hex: %elf
$(HEX) $< $@
%bin: %elf
$(BIN) $< $@
%dmp: %elf
$(OD) $(ODFLAGS) $< > $@
clean:
-rm -f $(OBJS)
-rm -f $(PROJECT).elf
-rm -f $(PROJECT).dmp
-rm -f $(PROJECT).map
-rm -f $(PROJECT).hex
-rm -f $(PROJECT).bin
-rm -f $(ASRC:.c=.c.bak)
-rm -f $(ASRC:.c=.lst)
-rm -f $(TSRC:.c=.c.bak)
-rm -f $(TSRC:.c=.lst)
-rm -f $(ASMSRC:.s=.s.bak)
-rm -f $(ASMSRC:.s=.lst)
-rm -fR .dep
#
# Include the dependency files, should be the last of the makefile
#
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# *** EOF ***

View File

@ -0,0 +1,135 @@
/*
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 <lpc214x.h>
#include <vic.h>
#include <lpc214x_serial.h>
//#include "lpc214x_ssp.h"
#include "board.h"
//#include "mmcsd.h"
//#include "buzzer.h"
/*
* Non-vectored IRQs handling here.
*/
__attribute__((naked))
static void IrqHandler(void) {
chSysIRQEnterI();
/* nothing */
VICVectAddr = 0;
chSysIRQExitI();
}
/*
* Timer 0 IRQ handling here.
*/
__attribute__((naked))
static void T0IrqHandler(void) {
chSysIRQEnterI();
T0IR = 1; /* Clear interrupt on match MR0. */
chSysTimerHandlerI();
VICVectAddr = 0;
chSysIRQExitI();
}
/*
* Hardware initialization goes here.
* NOTE: Interrupts are still disabled.
*/
void hwinit(void) {
/*
* All peripherals clock disabled by default in order to save power.
*/
PCONP = PCRTC | PCTIM0;
/*
* MAM setup.
*/
MAMTIM = 0x3; /* 3 cycles for flash accesses. */
MAMCR = 0x2; /* MAM fully enabled. */
/*
* PLL setup for Fosc=12MHz and CCLK=48MHz.
* P=2 M=3.
*/
PLL *pll = PLLBase;
pll->PLL0_CFG = 0x23; /* P and M values. */
pll->PLL0_CON = 0x1; /* Enalbles the PLL 0. */
pll->PLL0_FEED = 0xAA;
pll->PLL0_FEED = 0x55;
while (!(pll->PLL0_STAT & 0x400))
; /* Wait for PLL lock. */
pll->PLL0_CON = 0x3; /* Connects the PLL. */
pll->PLL0_FEED = 0xAA;
pll->PLL0_FEED = 0x55;
/*
* VPB setup.
* PCLK = CCLK / 4.
*/
VPBDIV = VPD_D4;
/*
* I/O pins configuration.
*/
PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2;
IO0DIR = VAL_FIO0DIR;
IO0SET = 0xFFFFFFFF;
IO1DIR = VAL_FIO1DIR;
IO1SET = 0xFFFFFFFF;
/*
* Interrupt vectors assignment.
*/
InitVIC();
VICDefVectAddr = (IOREG32)IrqHandler;
/*
* System Timer initialization, 1ms intervals.
*/
SetVICVector(T0IrqHandler, 0, SOURCE_Timer0);
VICIntEnable = INTMASK(SOURCE_Timer0);
TC *timer = T0Base;
timer->TC_PR = VAL_TC0_PRESCALER;
timer->TC_MR0 = (PCLK / CH_FREQUENCY) / (VAL_TC0_PRESCALER + 1);
timer->TC_MCR = 3; /* Interrupt and clear TC on match MR0. */
timer->TC_TCR = 2; /* Reset counter and prescaler. */
timer->TC_TCR = 1; /* Timer enabled. */
/*
* Other subsystems.
*/
InitSerial(1, 2);
// InitSSP();
// InitMMC();
// InitBuzzer();
}

View File

@ -0,0 +1,64 @@
/*
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_
#define BOARD_OLIMEX_LCP_P2148
/*
* The following values are implementation dependent. You may change them in
* order to match your HW.
*/
#define FOSC 12000000
#define CCLK 48000000
#define PCLK 12000000
#define VAL_TC0_PRESCALER 0
/*
* Pins configuration for Olimex LPC-P2148.
*
* PINSEL0
* P0 P0 P0 P0 P0 P0 RXD TXD SSE MOS MIS SCK SDA SCL RXD TXD
* 15 14 13 12 11 10 1 1 L0 I0 O0 0 0 0 0 0
* 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01
* IN IN OUT OUT OUT OUT -- -- -- -- -- -- -- -- -- --
* 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
*
* PINSEL1
* P0 AD P0 P0 -- -- AO -- VB P0 P0 P0 MOS MIS SCK P0
* 31 03 29 28 -- -- UT -- US 22 21 20 I1 O1 1 16
* 00 01 00 00 00 00 10 00 01 00 00 00 10 10 10 00
* OUT -- OUT OUT -- -- -- -- -- OUT OUT OUT -- -- -- IN
* 1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0
*
* PINSEL2
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- GP DBG --
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- IO --
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0 1 00
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- IN -- --
*/
#define VAL_PINSEL0 0x00055555
#define VAL_PINSEL1 0x100840A8
#define VAL_PINSEL2 0x00000004
#define VAL_FIO0DIR 0xB0703C00
#define VAL_FIO1DIR 0x00000000
#endif /* _BOARD_H_ */

View File

@ -0,0 +1,95 @@
/*
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/>.
*/
/*
* LPC2148 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 = 0x00000000, len = 512k - 12k
ram : org = 0x40000200, len = 32k - 0x200 - 288
}
__ram_start__ = ORIGIN(ram);
__ram_size__ = LENGTH(ram);
__ram_end__ = __ram_start__ + __ram_size__;
__dma_start__ = 0x7FD00000;
__dma_size__ = 8k;
__dma_end__ = 0x7FD00000 + __dma_size__;
SECTIONS
{
. = 0;
.text :
{
_text = .;
*(.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
}
PROVIDE(end = .);
_end = .;
__heap_base__ = _end;
__heap_end__ = __ram_end__ - __stacks_total_size__;

View File

@ -0,0 +1,169 @@
/*
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/>.
*/
/*
* Configuration file for LPC214x-GCC demo project.
*/
/**
* @addtogroup Config
* @{
*/
#ifndef _CHCONF_H_
#define _CHCONF_H_
/** Configuration option: if specified then time efficient rather than space
* efficient code is used when two possible implementations exist, note
* that this is not related to the compiler optimization options.*/
#define CH_OPTIMIZE_SPEED
/** Configuration option: if specified then the Virtual Timers subsystem is
* included in the kernel.*/
#define CH_USE_VIRTUAL_TIMERS
/** Configuration option: if specified then the System Timer subsystem is
* included in the kernel.*/
#define CH_USE_SYSTEMTIME
/** Configuration option: if specified then the \p chThdSleep() function is
* included in the kernel.
* @note requires \p CH_USE_VIRTUAL_TIMERS.*/
#define CH_USE_SLEEP
/** Configuration option: if specified then the \p chThdResume()
* function is included in the kernel.*/
#define CH_USE_RESUME
/** Configuration option: if specified then the \p chThdSuspend()
* function is included in the kernel.*/
#define CH_USE_SUSPEND
/** Configuration option: if specified then the \p chThdTerminate()
* and \p chThdShouldTerminate() functions are included in the kernel.*/
#define CH_USE_TERMINATE
/** Configuration option: if specified then the \p chThdWait() function
* is included in the kernel.*/
#define CH_USE_WAITEXIT
/** Configuration option: if specified then the Semaphores APIs are included
* in the kernel.*/
#define CH_USE_SEMAPHORES
/** Configuration option: if specified then the Semaphores atomic Signal+Wait
* APIs are included in the kernel.*/
#define CH_USE_SEMSW
/** Configuration option: if specified then the Semaphores with timeout APIs
* are included in the kernel.
* @note requires \p CH_USE_SEMAPHORES.
* @note requires \p CH_USE_VIRTUAL_TIMERS.*/
#define CH_USE_SEMAPHORES_TIMEOUT
/** Configuration option: if specified then the Mutexes APIs are included in
* the kernel.*/
#define CH_USE_MUTEXES
/** Configuration option: if specified then the Events APIs are included in
* the kernel.*/
#define CH_USE_EVENTS
/** Configuration option: if specified then the \p chEvtWaitTimeout()
* function is included in the kernel.
* @note requires \p CH_USE_EVENTS.
* @note requires \p CH_USE_VIRTUAL_TIMERS.*/
#define CH_USE_EVENTS_TIMEOUT
/** Configuration option: if specified then the Synchronous Messages APIs are
* included in the kernel.*/
#define CH_USE_MESSAGES
/** Configuration option: if specified then the \p chMsgSendWithEvent()
* function is included in the kernel.
* @note requires \p CH_USE_MESSAGES.
* @note requires \p CH_USE_VIRTUAL_TIMERS.*/
#define CH_USE_MESSAGES_EVENT
/** Configuration option: If enabled then the threads have an option to serve
* messages by priority instead of FIFO order.
* @note requires \p CH_USE_MESSAGES.*/
//#define CH_USE_MESSAGES_PRIORITY
/** Configuration option: if specified then the
* \p chThdGetExitEventSource() function is included in the kernel.
* @note requires \p CH_USE_MESSAGES.
* @note requires \p CH_USE_EVENTS.*/
#define CH_USE_EXIT_EVENT
/** Configuration option: if specified then the I/O queues APIs are included
* in the kernel.*/
#define CH_USE_QUEUES
/** Configuration option: if specified then the halfduplex queue APIs are
* included in the kernel.*/
#define CH_USE_QUEUES_HALFDUPLEX
/** Configuration option: if specified then the I/O queues with timeout
* APIs are included in the kernel.
* @note requires \p CH_USE_SEMAPHORES_TIMEOUT.*/
#define CH_USE_QUEUES_TIMEOUT
/** Configuration option: if specified then the full duplex serial driver APIs
* are included in the kernel.*/
#define CH_USE_SERIAL_FULLDUPLEX
/** Configuration option: if specified then the half duplex serial driver APIs
* are included in the kernel.*/
#define CH_USE_SERIAL_HALFDUPLEX
/** Configuration option: Frequency of the system timer that drives the system
* ticks. This also defines the system time unit.*/
#define CH_FREQUENCY 1000
/** Configuration option: This constant is the number of ticks allowed for the
* threads before preemption occurs.*/
#define CH_TIME_QUANTUM 20
/** Configuration option: 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 useable 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>.
*/
//#define CH_CURRP_REGISTER_CACHE "r7"
/** Configuration option: Includes basic debug support to the kernel.
* @note the debug support is port-dependent, it may be not present on some
* targets. In that case stub functions will be included.
*/
//#define CH_USE_DEBUG
/** Debug option: Includes the threads context switch tracing feature.
*/
//#define CH_USE_TRACE
#endif /* _CHCONF_H_ */
/** @} */

View File

@ -0,0 +1,141 @@
/*
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.hpp>
#include <evtimer.h>
#include <lpc214x.h>
#include <lpc214x_serial.h>
using namespace chibios_rt;
/*
* LED blinking sequences.
*/
#define SLEEP 0
#define STOP 1
#define BITCLEAR 2
#define BITSET 3
typedef struct {
uint8_t action;
uint32_t value;
} bitop_t;
bitop_t LED1_sequence[] =
{
{BITCLEAR, 0x00000400},
{SLEEP, 200},
{BITSET, 0x00000400},
{SLEEP, 1800}
};
bitop_t LED2_sequence[] =
{
{SLEEP, 1000},
{BITCLEAR, 0x00000800},
{SLEEP, 200},
{BITSET, 0x00000800},
{SLEEP, 800}
};
bitop_t LED3_sequence[] =
{
{BITCLEAR, 0x80000000},
{SLEEP, 200},
{BITSET, 0x80000000},
{SLEEP, 300}
};
/**
* LED blinker thread class.
*/
class BlinkerThread : chibios_rt::BaseThread {
private:
WorkingArea(wa, 64);
bitop_t *base, *curr, *top;
protected:
virtual msg_t Main(void) {
while (TRUE) {
switch(curr->action) {
case SLEEP:
Sleep(curr->value);
break;
case STOP:
return 0;
case BITCLEAR:
IO0CLR = curr->value;
break;
case BITSET:
IO0SET = curr->value;
break;
}
if (++curr >= top)
curr = base;
}
}
public:
BlinkerThread(bitop_t *sequence, int n) : BaseThread(NORMALPRIO, 0, wa, sizeof wa) {
base = curr = sequence;
top = sequence + n;
}
};
extern "C" {
msg_t TestThread(void *p);
}
/*
* Executed as event handler at 500mS intervals.
*/
static void TimerHandler(eventid_t id) {
if (!(IO0PIN & 0x00018000)) // Both buttons
TestThread(&COM1);
}
/*
* Entry point, the interrupts are disabled on entry.
*/
int main(int argc, char **argv) {
static const evhandler_t evhndl[] = {
TimerHandler
};
static EvTimer evt;
struct EventListener el0;
System::Init();
evtInit(&evt, 500); /* Initializes an event timer object. */
evtStart(&evt); /* Starts the event timer. */
chEvtRegister(&evt.et_es, &el0, 0); /* Registers on the timer event source. */
BlinkerThread blinker1(LED1_sequence, sizeof(LED1_sequence) / sizeof(bitop_t));
BlinkerThread blinker2(LED2_sequence, sizeof(LED2_sequence) / sizeof(bitop_t));
BlinkerThread blinker3(LED3_sequence, sizeof(LED3_sequence) / sizeof(bitop_t));
while(1)
Event::Wait(ALL_EVENTS, evhndl);
return 0;
}

View File

@ -0,0 +1,25 @@
*****************************************************************************
** ChibiOS/RT port for ARM7TDMI LPC214X using G++. **
*****************************************************************************
** TARGET **
The demo runs on an Olimex LPC-P2148 board. The port on other boards or other
members of the LPC2000 family should be an easy task.
** The Demo **
The demo blinks the leds on the board by using multiple threads implemented
as C++ classes. Pressing both buttons activates the test procedure on the
serial port 1.
NOTE: the C++ GNU compiler can produce code sizes comparable to C if you
don't use RTTI and standard libraries, those are disabled by default
in the makefile. You can enable them if you have a lot of program space
available. It is possible to use a lot of C++ features without using
runtimes, just see the demo.
** Build Procedure **
The demo was built using the YAGARTO toolchain but any toolchain based on GCC
and GNU userspace programs will work.

View File

@ -37,6 +37,7 @@ static void IrqHandler(void) {
chSysIRQEnterI();
/* nothing */
VICVectAddr = 0;
chSysIRQExitI();
}
@ -51,6 +52,7 @@ static void T0IrqHandler(void) {
T0IR = 1; /* Clear interrupt on match MR0. */
chSysTimerHandlerI();
VICVectAddr = 0;
chSysIRQExitI();
}