diff options
Diffstat (limited to 'firmware/test/uart')
-rw-r--r-- | firmware/test/uart/Makefile | 103 | ||||
-rw-r--r-- | firmware/test/uart/uarttest.c | 63 |
2 files changed, 166 insertions, 0 deletions
diff --git a/firmware/test/uart/Makefile b/firmware/test/uart/Makefile new file mode 100644 index 0000000..2a17077 --- /dev/null +++ b/firmware/test/uart/Makefile @@ -0,0 +1,103 @@ +#/* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED +# * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF +# * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. +# * THE AUTHORS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR +# * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. USE IT AT YOUR OWN RISK */ + +ARCH = arm-none-eabi +top_srcdir=${PWD}/../.. +LPC=${top_srcdir}/lpc17xx +DRV=${top_srcdir}/drivers +SRC=${top_srcdir}/src + +PROJ=uarttest +EXECNAME=$(PROJ).elf + +# Tool definitions +CC = $(ARCH)-gcc +LD = $(ARCH)-ld +AR = $(ARCH)-ar +AS = $(ARCH)-as +CP = $(ARCH)-objcopy +OD = $(ARCH)-objdump +SIZE = $(ARCH)-size +RM = rm +#Q = # @./quiet "$@" + +# Flags +CFLAGS = -W -Wall -Werror -O0 --std=gnu99 -fgnu89-inline -mcpu=cortex-m3 -mthumb +CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += -I${DRV} -I${LPC} +ASFLAGS = +LDFLAGS = --gc-sections + +STDLIB_LDFLAGS = + +CPFLAGS = +ODFLAGS = -x --syms +PRFLAGS ?= + +# Source files +LINKER_SCRIPT = ${LPC}/LPC17xx.ld +CSRCS = \ + ${LPC}/system_LPC17xx.c \ + ${LPC}/startup_LPC17xx.c \ + ${DRV}/led.c \ + ${DRV}/cli.c \ + ${DRV}/uart.c \ + ../test.c + +CSRCS += ${PROJ}.c +ASRCS = + + +OBJS = $(CSRCS:.c=.o) $(ASRCS:.s=.o) + +.PHONY: all size clean nuke + +all: ${PROJ}.bin ${PROJ}.hex + +size: ${PROJ}.elf + @$(SIZE) $< + +%.hex: %.elf + $Q $(CP) $(CPFLAGS) -O ihex $< $*.hex + +%.bin: %.elf + $Q $(CP) $(CPFLAGS) -O binary $< $*.bin + +${PROJ}.elf: $(LINKER_SCRIPT) $(OBJS) + $Q $(LD) -Map $(@:.elf=.map) $(LDFLAGS) -T $^ -o $@ $(STDLIB_LDFLAGS) + $Q $(OD) $(ODFLAGS) $@ > $(@:.elf=.dump) + @$(SIZE) $@ + +%.o: %.c + @$(CC) -MM $< -MF $*.d -MP + $Q $(CC) -c $(CFLAGS) $< -o $@ + +%.o: %.S + $Q $(AS) $(ASFLAGS) $< -o $@ + +clean: + @-$(RM) -f *.elf + @-\ +for D in "." "**"; do \ + $(RM) -f $$D/*.o $$D/*.d $$D/*.lst $$D/*.dump $$D/*.map; \ +done + +nuke: clean + -$(RM) -f *.hex *.bin + +.PHONY : flash +#flash: $(EXECNAME) +# $(CP) -O ihex $(EXECNAME) $(PROJ).hex +# openocd -f openocd.cfg -c 'flash write_image erase $(PROJ).hex' -c 'verify_image $(PROJ).hex' -c 'reset run' +flash: $(EXECNAME) + $(CP) -O binary $(EXECNAME) $(PROJ).bin + ../../fix-lpcchecksum $(PROJ).bin + openocd -f ../../openocd.cfg \ + -c 'flash write_image erase $(PROJ).bin' \ + -c 'verify_image $(PROJ).bin' \ + -c 'reset run' + +-include $(CSRCS:.c=.d) diff --git a/firmware/test/uart/uarttest.c b/firmware/test/uart/uarttest.c new file mode 100644 index 0000000..fb6822c --- /dev/null +++ b/firmware/test/uart/uarttest.c @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * uarttest.c + * + * Sun Dec 21 20:46:19 CET 2014 + * Copyright 2014 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of Pedal2Metal. + * + * Pedal2Metal 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 2 of the License, or + * (at your option) any later version. + * + * Pedal2Metal 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 Pedal2Metal; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "../test.h" + +// For SystemCoreClock +#include <LPC17xx.h> + +//#include <uart.h> +#include <cli.h> +/* +volatile unsigned int temp; +static void _delay(unsigned int del) +{ + for(unsigned int i = 0; i < del; i++) temp = i; +} +*/ +int main (void) +{ + //led_init(); + + cli_init(); + + cli_printf("\rWelcome to the amazing Pedal 2 Metal version zero dot dut!\n"); + //cli_printf("clk: %d\n", SystemCoreClock); + + int cnt = 0; + while(1) { + char cmd[256]; + int sz = sizeof(cmd); + while(sz == sizeof(cmd)) { + cli_printf("# "); + sz = cli_readline(cmd, sizeof(cmd)); + } + cli_printf("\n"); + + cli_printf("command %d: '%s' (%d)\n", cnt++, cmd, sz); + //for(int i = 0; i < sz; i++) cli_printf("%c\t(%d)\n", cmd[i], (int)cmd[i]); + } +} |