diff --git a/simulat0r/Makefile b/simulat0r/Makefile new file mode 100644 index 0000000..ae22d3d --- /dev/null +++ b/simulat0r/Makefile @@ -0,0 +1,27 @@ +all : tui gui + +.PHONY : tui gui tui-core clean + +tui-core : + $(MAKE) -C firmware + $(MAKE) -C simcore + $(MAKE) -C tui + +tui : tui-core + $(MAKE) -C gui/build clean # workaround for buggy dependency of gui build on libapp + +.IGNORE : tui + +gui : tui gui/build/Makefile + $(MAKE) -C gui/build VERBOSE=1 + +# bootstrap build directory +gui/build/Makefile : tui-core + install -d gui/build && cd gui/build && cmake .. + + +clean: + $(MAKE) -C firmware clean + $(MAKE) -C tui clean + $(MAKE) -C simcore clean + $(MAKE) -C gui/build clean # workaround for buggy dependency of gui build on libapp diff --git a/simulat0r/bin/update-bridge-files.sh b/simulat0r/bin/update-bridge-files.sh new file mode 100755 index 0000000..5d74ef4 --- /dev/null +++ b/simulat0r/bin/update-bridge-files.sh @@ -0,0 +1,27 @@ +#!/bin/sh +function verbmsg() +{ +true +# echo $1 +} + +echo "Updating directories" +for i in `find firmware/ -type d ` +do +if test -d simulat0r/$i +then verbmsg "OK Directory already exists: $i" +else mkdir -v simulat0r/$i +fi +done + +echo "Updating bridge files" +for i in `find firmware/ \! -path firmware/lcd/allfonts.h -type f -iname \*.[ch]` +do + if test -f simulat0r/$i; + then + verbmsg "OK File already exists: $i" + else + echo Writing bridge file simulat0r/$i + (printf "/* AUTOGENERATED SOURCE FILE */\n"; echo \#include \"`dirname $i | sed "s#[^/]*#..#g" `/../$i\") >simulat0r/$i + fi +done diff --git a/simulat0r/firmware/Makefile b/simulat0r/firmware/Makefile new file mode 100644 index 0000000..dd71a3a --- /dev/null +++ b/simulat0r/firmware/Makefile @@ -0,0 +1,108 @@ +VPATH = +OBJS = main.o + +########################################################################## +# Project-specific files +########################################################################## + +VPATH += +OBJS += +OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o basic/voltage.o +OBJS += basic/keyin.o basic/uuid.o +LIBS += core/libcore.a lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH = . +INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/core + +include $(ROOT_PATH)/Makefile.inc + +LDFLAGS+= -Wl,--gc-sections +VPATH += lpc1xxx +OBJS += $(TARGET)_handlers.o LPC1xxx_startup.o + +########################################################################## +# Startup files +########################################################################## +LDLIBS = -lm +LDLIBS += -Lapplications -lapp +LDLIBS += -Lfunk -lfunk +LDLIBS += -Lusbcdc -lusbcdc +LDLIBS += -Lfilesystem -lfat +LDLIBS += -Lbasic -lbasic +LDLIBS += -Llcd -llcd +LDLIBS += -Lcore -lcore +LDLIBS += -Lusb -lusb + + +LD_PATH = lpc1xxx +LD_SCRIPT = $(LD_PATH)/linkscript.ld +LD_TEMP = $(LD_PATH)/memory.ld + +### User targets: + +all: $(OUTFILE).bin + +protect: $(OUTFILE).bin + $(LPCFIX) -p 2 $(OUTFILE).bin + +loadables: $(OUTFILE).bin + @cd loadable && $(MAKE) + +clean: + rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex + @cd core && $(MAKE) clean +# @cd ../tools/bootloader && $(MAKE) clean + @cd lcd && $(MAKE) clean + @cd applications && $(MAKE) clean + @cd filesystem && $(MAKE) clean + @cd usb && $(MAKE) clean + @cd loadable && $(MAKE) clean + +### Internal targets + +%.o : %.c + $(CC) $(CFLAGS) -o $@ $< + +core/libcore.a: core/projectconfig.h + cd core && $(MAKE) ROOT_PATH=../$(ROOT_PATH) + +lcd/liblcd.a lcd/render.o lcd/display.o: + cd lcd && $(MAKE) ROOT_PATH=../$(ROOT_PATH) + +applications/libapp.a: + cd applications && $(MAKE) ROOT_PATH=../$(ROOT_PATH) + +filesystem/libfat.a: + cd filesystem && $(MAKE) ROOT_PATH=../$(ROOT_PATH) + +usb/libusb.a: + cd usb && $(MAKE) ROOT_PATH=../$(ROOT_PATH) + +../tools/bootloader/lpcfix: +# cd ../tools/bootloader && $(MAKE) + +$(LD_TEMP): + -@echo "MEMORY" > $(LD_TEMP) + -@echo "{" >> $(LD_TEMP) + -@echo " flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP) + -@echo " sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)-$(RAMCODE)" >> $(LD_TEMP) + -@echo "}" >> $(LD_TEMP) + -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP) + +.IGNORE: $(OUTFILE).elf +$(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(LIBS) $(LPCFIX) $(LD_TEMP) + $(CC) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS) + -@echo "" +# $(SIZE) $(OUTFILE).elf +# -@echo "" + +%.bin: %.elf +# $(OBJCOPY) $(OCFLAGS) -O binary $< $@ + -@echo "" +# $(LPCFIX) -c $@ + +.PHONY: $(LD_TEMP) lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a + diff --git a/simulat0r/firmware/Makefile.inc b/simulat0r/firmware/Makefile.inc new file mode 100644 index 0000000..c444d46 --- /dev/null +++ b/simulat0r/firmware/Makefile.inc @@ -0,0 +1,46 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +# The target, flash and ram of the LPC1xxx microprocessor. +# Use for the target the value: LPC11xx, LPC13xx or LPC17xx +TARGET = LPC13xx +FLASH = 32K +SRAM = 8K +RAMCODE=1K + +# For USB HID support the LPC134x reserves 384 bytes from the sram, +# if you don't want to use the USB features, just use 0 here. +SRAM_USB = 384 + +########################################################################## +# GNU GCC compiler prefix and location +########################################################################## + +#CROSS_COMPILE = arm-none-eabi- +AS = $(CROSS_COMPILE)gcc +CC = $(CROSS_COMPILE)gcc +LD = $(CROSS_COMPILE)ld +REALLD = $(CROSS_COMPILE)ld +SIZE = $(CROSS_COMPILE)size +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +OUTFILE = firmware +LPCFIX = /bin/echo + +ifeq (LPC11xx,$(TARGET)) + CORTEX_TYPE=m0 +else + CORTEX_TYPE=m3 +endif + +#CPU_TYPE = cortex-$(CORTEX_TYPE) +#CPU_TYPE=i686 + +########################################################################## +# Compiler settings, parameters and flags +########################################################################## + +CFLAGS = -std=c99 -c -g -O0 $(INCLUDE_PATHS) -Wall -funsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -DRAMCODE=$(RAMCODE) -fno-builtin -DSIMULATOR -I$(ROOT_PATH)/../simcore -include libc-unc0llide.h +#LDFLAGS = -nostartfiles + diff --git a/simulat0r/firmware/Makefile.util b/simulat0r/firmware/Makefile.util new file mode 100644 index 0000000..d643ce6 --- /dev/null +++ b/simulat0r/firmware/Makefile.util @@ -0,0 +1 @@ +include $(ROOT_PATH)/../../firmware/Makefile.util diff --git a/simulat0r/firmware/applications/Makefile b/simulat0r/firmware/applications/Makefile new file mode 100644 index 0000000..6d034d3 --- /dev/null +++ b/simulat0r/firmware/applications/Makefile @@ -0,0 +1,66 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +OBJS = default.o +OBJS += $(foreach mod,$(APP),$(mod).o) + +SRCS = $(foreach mod,$(APP),$(mod).c) + +ifndef APP +ME_OBJ=$(USERNAME) + +ifeq "$(ME_OBJ)" "" +ME_OBJ=$(USER) +endif + +ifeq "$(ME_OBJ)" "" +ME_OBJ=nouser +endif + +OBJS += $(ME_OBJ).o +endif + +WRAP=wrapper +LIBNAME=app + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= .. +INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I. + +include $(ROOT_PATH)/Makefile.inc + +WRAPOBJ=$(WRAP).o +WRAPSRC=$(WRAP).c +LIBFILE=lib$(LIBNAME).a + +########################################################################## +# Compiler settings, parameters and flags +########################################################################## + +all: $(LIBFILE) + +$(LIBFILE): $(OBJS) $(WRAPOBJ) + $(AR) rcs $@ $(OBJS) $(WRAPOBJ) + +%.o : %.c + $(CC) $(CFLAGS) -o $@ $< + +clean: + rm -f $(OBJS) $(WRAPOBJ) $(WRAPSRC) $(LIBFILE) *.o + +%.c: + @echo + @echo "You need to create $@ first" + @echo "It should contain a single function void main_filename(void)" + @echo + @exit 1 + +$(WRAPSRC): + ./mkwrapper $(OBJS) > $@ + +.PHONY: $(LIBFILE) $(WRAPSRC) $(SRCS) + +.SUFFIXES: diff --git a/simulat0r/firmware/applications/adc.c b/simulat0r/firmware/applications/adc.c new file mode 100644 index 0000000..65c9a12 --- /dev/null +++ b/simulat0r/firmware/applications/adc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/adc.c" diff --git a/simulat0r/firmware/applications/bsx.c b/simulat0r/firmware/applications/bsx.c new file mode 100644 index 0000000..e1accac --- /dev/null +++ b/simulat0r/firmware/applications/bsx.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/bsx.c" diff --git a/simulat0r/firmware/applications/cdc.c b/simulat0r/firmware/applications/cdc.c new file mode 100644 index 0000000..82f5543 --- /dev/null +++ b/simulat0r/firmware/applications/cdc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/cdc.c" diff --git a/simulat0r/firmware/applications/default.c b/simulat0r/firmware/applications/default.c new file mode 100644 index 0000000..9c699bc --- /dev/null +++ b/simulat0r/firmware/applications/default.c @@ -0,0 +1,12 @@ +/* AUTOGENERATED SOURCE FILE */ +#define main_default _hideaway_main_default +#define lcdInitConfig _hide_lcdInitConfig +#include "../../../firmware/applications/default.c" +#undef lcdInitConfig +#undef main_default + +int lcdInitConfig() { +} + +void main_default() { +} diff --git a/simulat0r/firmware/applications/ecc.c b/simulat0r/firmware/applications/ecc.c new file mode 100644 index 0000000..9196867 --- /dev/null +++ b/simulat0r/firmware/applications/ecc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/ecc.c" diff --git a/simulat0r/firmware/applications/exe.c b/simulat0r/firmware/applications/exe.c new file mode 100644 index 0000000..55419e7 --- /dev/null +++ b/simulat0r/firmware/applications/exe.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/exe.c" diff --git a/simulat0r/firmware/applications/executor.c b/simulat0r/firmware/applications/executor.c new file mode 100644 index 0000000..c1a0092 --- /dev/null +++ b/simulat0r/firmware/applications/executor.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/executor.c" diff --git a/simulat0r/firmware/applications/font.c b/simulat0r/firmware/applications/font.c new file mode 100644 index 0000000..cca894f --- /dev/null +++ b/simulat0r/firmware/applications/font.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/font.c" diff --git a/simulat0r/firmware/applications/fs.c b/simulat0r/firmware/applications/fs.c new file mode 100644 index 0000000..93a5827 --- /dev/null +++ b/simulat0r/firmware/applications/fs.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/fs.c" diff --git a/simulat0r/firmware/applications/funk.c b/simulat0r/firmware/applications/funk.c new file mode 100644 index 0000000..75cbee3 --- /dev/null +++ b/simulat0r/firmware/applications/funk.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/funk.c" diff --git a/simulat0r/firmware/applications/iggy.c b/simulat0r/firmware/applications/iggy.c new file mode 100644 index 0000000..15f7694 --- /dev/null +++ b/simulat0r/firmware/applications/iggy.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/iggy.c" diff --git a/simulat0r/firmware/applications/life.c b/simulat0r/firmware/applications/life.c new file mode 100644 index 0000000..aeef110 --- /dev/null +++ b/simulat0r/firmware/applications/life.c @@ -0,0 +1 @@ +#include "../../../firmware/applications/life.c" diff --git a/simulat0r/firmware/applications/lilafisch.c b/simulat0r/firmware/applications/lilafisch.c new file mode 100644 index 0000000..796ba59 --- /dev/null +++ b/simulat0r/firmware/applications/lilafisch.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/lilafisch.c" diff --git a/simulat0r/firmware/applications/mandelbrot.c b/simulat0r/firmware/applications/mandelbrot.c new file mode 100644 index 0000000..9923b38 --- /dev/null +++ b/simulat0r/firmware/applications/mandelbrot.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/mandelbrot.c" diff --git a/simulat0r/firmware/applications/mandelbrot2.c b/simulat0r/firmware/applications/mandelbrot2.c new file mode 100644 index 0000000..2b68734 --- /dev/null +++ b/simulat0r/firmware/applications/mandelbrot2.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/mandelbrot2.c" diff --git a/simulat0r/firmware/applications/menutest.c b/simulat0r/firmware/applications/menutest.c new file mode 100644 index 0000000..1f8a850 --- /dev/null +++ b/simulat0r/firmware/applications/menutest.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/menutest.c" diff --git a/simulat0r/firmware/applications/minimal.c b/simulat0r/firmware/applications/minimal.c new file mode 100644 index 0000000..4fb22ea --- /dev/null +++ b/simulat0r/firmware/applications/minimal.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/minimal.c" diff --git a/simulat0r/firmware/applications/rect.c b/simulat0r/firmware/applications/rect.c new file mode 100644 index 0000000..9d526bd --- /dev/null +++ b/simulat0r/firmware/applications/rect.c @@ -0,0 +1 @@ +#include "../../../firmware/applications/rect.c" diff --git a/simulat0r/firmware/applications/remote.c b/simulat0r/firmware/applications/remote.c new file mode 100644 index 0000000..eb451fe --- /dev/null +++ b/simulat0r/firmware/applications/remote.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/remote.c" diff --git a/simulat0r/firmware/applications/s.c b/simulat0r/firmware/applications/s.c new file mode 100644 index 0000000..c0fa7cf --- /dev/null +++ b/simulat0r/firmware/applications/s.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/s.c" diff --git a/simulat0r/firmware/applications/schneider.c b/simulat0r/firmware/applications/schneider.c new file mode 100644 index 0000000..10e93f0 --- /dev/null +++ b/simulat0r/firmware/applications/schneider.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/schneider.c" diff --git a/simulat0r/firmware/applications/scroll.c b/simulat0r/firmware/applications/scroll.c new file mode 100644 index 0000000..45234b9 --- /dev/null +++ b/simulat0r/firmware/applications/scroll.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/scroll.c" diff --git a/simulat0r/firmware/applications/sec.c b/simulat0r/firmware/applications/sec.c new file mode 100644 index 0000000..a7afb28 --- /dev/null +++ b/simulat0r/firmware/applications/sec.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/sec.c" diff --git a/simulat0r/firmware/applications/spaceinvaders.c b/simulat0r/firmware/applications/spaceinvaders.c new file mode 100644 index 0000000..ff36beb --- /dev/null +++ b/simulat0r/firmware/applications/spaceinvaders.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/spaceinvaders.c" diff --git a/simulat0r/firmware/applications/vcard.c b/simulat0r/firmware/applications/vcard.c new file mode 100644 index 0000000..c1e3972 --- /dev/null +++ b/simulat0r/firmware/applications/vcard.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/vcard.c" diff --git a/simulat0r/firmware/applications/waldbrand.c b/simulat0r/firmware/applications/waldbrand.c new file mode 100644 index 0000000..91da7b6 --- /dev/null +++ b/simulat0r/firmware/applications/waldbrand.c @@ -0,0 +1 @@ +#include "../../../firmware/applications/waldbrand.c" diff --git a/simulat0r/firmware/basic/basic.c b/simulat0r/firmware/basic/basic.c new file mode 100644 index 0000000..c04a2ff --- /dev/null +++ b/simulat0r/firmware/basic/basic.c @@ -0,0 +1,2 @@ +void rbInit() { +} diff --git a/simulat0r/firmware/basic/basic.h b/simulat0r/firmware/basic/basic.h new file mode 100644 index 0000000..c89232b --- /dev/null +++ b/simulat0r/firmware/basic/basic.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/basic.h" diff --git a/simulat0r/firmware/basic/byteorder.c b/simulat0r/firmware/basic/byteorder.c new file mode 100644 index 0000000..86d53e5 --- /dev/null +++ b/simulat0r/firmware/basic/byteorder.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/byteorder.c" diff --git a/simulat0r/firmware/basic/byteorder.h b/simulat0r/firmware/basic/byteorder.h new file mode 100644 index 0000000..753bd65 --- /dev/null +++ b/simulat0r/firmware/basic/byteorder.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/byteorder.h" diff --git a/simulat0r/firmware/basic/crc.c b/simulat0r/firmware/basic/crc.c new file mode 100644 index 0000000..a441b12 --- /dev/null +++ b/simulat0r/firmware/basic/crc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/crc.c" diff --git a/simulat0r/firmware/basic/delayms.c b/simulat0r/firmware/basic/delayms.c new file mode 100644 index 0000000..a628242 --- /dev/null +++ b/simulat0r/firmware/basic/delayms.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/delayms.c" diff --git a/simulat0r/firmware/basic/ecc.c b/simulat0r/firmware/basic/ecc.c new file mode 100644 index 0000000..d27fe0c --- /dev/null +++ b/simulat0r/firmware/basic/ecc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/ecc.c" diff --git a/simulat0r/firmware/basic/ecc.h b/simulat0r/firmware/basic/ecc.h new file mode 100644 index 0000000..f679817 --- /dev/null +++ b/simulat0r/firmware/basic/ecc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/ecc.h" diff --git a/simulat0r/firmware/basic/keyin.c b/simulat0r/firmware/basic/keyin.c new file mode 100644 index 0000000..9284cbf --- /dev/null +++ b/simulat0r/firmware/basic/keyin.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/keyin.c" diff --git a/simulat0r/firmware/basic/menu.c b/simulat0r/firmware/basic/menu.c new file mode 100644 index 0000000..d1001d1 --- /dev/null +++ b/simulat0r/firmware/basic/menu.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/menu.c" diff --git a/simulat0r/firmware/basic/reinvoke_isp.c b/simulat0r/firmware/basic/reinvoke_isp.c new file mode 100644 index 0000000..fb27202 --- /dev/null +++ b/simulat0r/firmware/basic/reinvoke_isp.c @@ -0,0 +1,12 @@ +#include + +void ReinvokeISP(void) { +} + +void EnableWatchdog(uint32_t ms) { +} + +void ISPandReset(int delay){ + EnableWatchdog(1000*delay); + ReinvokeISP(); +}; diff --git a/simulat0r/firmware/basic/uuid.c b/simulat0r/firmware/basic/uuid.c new file mode 100644 index 0000000..e54b164 --- /dev/null +++ b/simulat0r/firmware/basic/uuid.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/uuid.c" diff --git a/simulat0r/firmware/basic/voltage.c b/simulat0r/firmware/basic/voltage.c new file mode 100644 index 0000000..a56ae54 --- /dev/null +++ b/simulat0r/firmware/basic/voltage.c @@ -0,0 +1,12 @@ +#include + +#include "basic/basic.h" + +uint32_t results=5000; + +void VoltageCheck(void){ +}; + +uint32_t GetVoltage(void){ + return results; +}; diff --git a/simulat0r/firmware/basic/xxtea.c b/simulat0r/firmware/basic/xxtea.c new file mode 100644 index 0000000..77604be --- /dev/null +++ b/simulat0r/firmware/basic/xxtea.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/xxtea.c" diff --git a/simulat0r/firmware/basic/xxtea.h b/simulat0r/firmware/basic/xxtea.h new file mode 100644 index 0000000..336bcda --- /dev/null +++ b/simulat0r/firmware/basic/xxtea.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/basic/xxtea.h" diff --git a/simulat0r/firmware/core/Makefile b/simulat0r/firmware/core/Makefile new file mode 100644 index 0000000..ec1df9e --- /dev/null +++ b/simulat0r/firmware/core/Makefile @@ -0,0 +1,56 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +# The target, flash and ram of the LPC1xxx microprocessor. +# Use for the target the value: LPC11xx, LPC13xx or LPC17xx +TARGET = LPC13xx + +OBJS = sysinit.o +OBJS += adc/adc.o +#OBJS += cmd/cmd.o +OBJS += cpu/cpu.o +OBJS += gpio/gpio.o +OBJS += i2c/i2c.o +OBJS += iap/iap.o +OBJS += libc/ctype.o +OBJS += libc/stdio.o +OBJS += libc/string.o +OBJS += pmu/pmu.o +#OBJS += pwm/pwm.o +OBJS += ssp/ssp.o +OBJS += systick/systick.o +OBJS += timer16/timer16.o +OBJS += timer32/timer32.o +#OBJS += uart/uart.o +#OBJS += uart/uart_buf.o +#OBJS += usbcdc/cdcuser.o +#OBJS += usbcdc/cdc_buf.o +#OBJS += usbcdc/usbcore.o +#OBJS += usbcdc/usbdesc.o +#OBJS += usbcdc/usbhw.o +#OBJS += usbcdc/usbuser.o +OBJS += wdt/wdt.o + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= .. +INCLUDE_PATHS = -I$(ROOT_PATH) -I. + +include $(ROOT_PATH)/Makefile.inc + +########################################################################## +# Compiler settings, parameters and flags +########################################################################## + +all: libcore.a + +libcore.a: $(OBJS) + $(AR) rcs libcore.a $(OBJS) + +%.o : %.c projectconfig.h + $(CC) $(CFLAGS) -o $@ $< + +clean: + rm -f $(OBJS) libcore.a diff --git a/simulat0r/firmware/core/adc/adc.c b/simulat0r/firmware/core/adc/adc.c new file mode 100644 index 0000000..688d777 --- /dev/null +++ b/simulat0r/firmware/core/adc/adc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/adc/adc.c" diff --git a/simulat0r/firmware/core/adc/adc.h b/simulat0r/firmware/core/adc/adc.h new file mode 100644 index 0000000..652dde3 --- /dev/null +++ b/simulat0r/firmware/core/adc/adc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/adc/adc.h" diff --git a/simulat0r/firmware/core/cmd/cmd.c b/simulat0r/firmware/core/cmd/cmd.c new file mode 100644 index 0000000..10e1a8f --- /dev/null +++ b/simulat0r/firmware/core/cmd/cmd.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/cmd/cmd.c" diff --git a/simulat0r/firmware/core/cmd/cmd.h b/simulat0r/firmware/core/cmd/cmd.h new file mode 100644 index 0000000..ea4bb74 --- /dev/null +++ b/simulat0r/firmware/core/cmd/cmd.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/cmd/cmd.h" diff --git a/simulat0r/firmware/core/cpu/cpu.c b/simulat0r/firmware/core/cpu/cpu.c new file mode 100644 index 0000000..e75e97a --- /dev/null +++ b/simulat0r/firmware/core/cpu/cpu.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/cpu/cpu.c" diff --git a/simulat0r/firmware/core/cpu/cpu.h b/simulat0r/firmware/core/cpu/cpu.h new file mode 100644 index 0000000..39a503b --- /dev/null +++ b/simulat0r/firmware/core/cpu/cpu.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/cpu/cpu.h" diff --git a/simulat0r/firmware/core/gpio/gpio.c b/simulat0r/firmware/core/gpio/gpio.c new file mode 100644 index 0000000..2c8d214 --- /dev/null +++ b/simulat0r/firmware/core/gpio/gpio.c @@ -0,0 +1,65 @@ +#include +#include "basic/basic.h" +#include "../simcore/simulator.h" + +static bool compair(uint32_t a1, uint32_t a2, uint32_t b1, uint32_t b2) { + return a1==b1 && a2==b2; +} + +void gpioInit (void) { + printf("void gpioInit (void)\n"); +} + +void gpioSetDir (uint32_t portNum, uint32_t bitPos, gpioDirection_t dir) { + printf("void gpioSetDir (portNum %d, bitPos %d, dir %x)\n",portNum,bitPos,dir); +} + +uint32_t gpioGetValue (uint32_t portNum, uint32_t bitPos) { + if(compair(portNum, bitPos, RB_BTN3)) return simButtonPressed(BTN_UP); + if(compair(portNum, bitPos, RB_BTN2)) return simButtonPressed(BTN_DOWN); + if(compair(portNum, bitPos, RB_BTN4)) return simButtonPressed(BTN_ENTER); + if(compair(portNum, bitPos, RB_BTN0)) return simButtonPressed(BTN_LEFT); + if(compair(portNum, bitPos, RB_BTN1)) return simButtonPressed(BTN_RIGHT); + + if(compair(portNum, bitPos, RB_LED0)) return simGetLED(0); + if(compair(portNum, bitPos, RB_LED1)) return simGetLED(1); + if(compair(portNum, bitPos, RB_LED2)) return simGetLED(2); + if(compair(portNum, bitPos, RB_LED3)) return simGetLED(3); + + fprintf(stderr,"Unimplemented gpioGetValue portNum %d %x bit %d\n",portNum, portNum, bitPos); + return 0; +} + +void gpioSetValue (uint32_t portNum, uint32_t bitPos, uint32_t bitVal) { + if(compair(portNum, bitPos, RB_LED0)) return simSetLED(0,bitVal); + if(compair(portNum, bitPos, RB_LED1)) return simSetLED(1,bitVal); + if(compair(portNum, bitPos, RB_LED2)) return simSetLED(2,bitVal); + if(compair(portNum, bitPos, RB_LED3)) return simSetLED(3,bitVal); + + fprintf(stderr,"Unimplemented gpioSetValue portNum %d %x bit %d\n",portNum, portNum, bitPos); +} + +void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t sense, gpioInterruptEdge_t edge, gpioInterruptEvent_t event) { + printf("void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t sense, gpioInterruptEdge_t edge, gpioInterruptEvent_t event)\n"); +} + +void gpioIntEnable (uint32_t portNum, uint32_t bitPos) { + printf("void gpioIntEnable (uint32_t portNum, uint32_t bitPos)\n"); +} + +void gpioIntDisable (uint32_t portNum, uint32_t bitPos) { + printf("void gpioIntDisable (uint32_t portNum, uint32_t bitPos)\n"); +} + +uint32_t gpioIntStatus (uint32_t portNum, uint32_t bitPos) { + printf("uint32_t gpioIntStatus (uint32_t portNum, uint32_t bitPos)\n"); +} + +void gpioIntClear (uint32_t portNum, uint32_t bitPos) { + printf("void gpioIntClear (uint32_t portNum, uint32_t bitPos)\n"); +} + +void gpioSetPullup (volatile uint32_t *ioconRegister, gpioPullupMode_t mode) { + printf("void gpioSetPullup (volatile uint32_t *ioconRegister, gpioPullupMode_t mode)\n"); +} + diff --git a/simulat0r/firmware/core/gpio/gpio.h b/simulat0r/firmware/core/gpio/gpio.h new file mode 100644 index 0000000..39fb0c4 --- /dev/null +++ b/simulat0r/firmware/core/gpio/gpio.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/gpio/gpio.h" diff --git a/simulat0r/firmware/core/i2c/i2c.c b/simulat0r/firmware/core/i2c/i2c.c new file mode 100644 index 0000000..6a27b27 --- /dev/null +++ b/simulat0r/firmware/core/i2c/i2c.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/i2c/i2c.c" diff --git a/simulat0r/firmware/core/i2c/i2c.h b/simulat0r/firmware/core/i2c/i2c.h new file mode 100644 index 0000000..5e51ba2 --- /dev/null +++ b/simulat0r/firmware/core/i2c/i2c.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/i2c/i2c.h" diff --git a/simulat0r/firmware/core/iap/iap.c b/simulat0r/firmware/core/iap/iap.c new file mode 100644 index 0000000..971a9bc --- /dev/null +++ b/simulat0r/firmware/core/iap/iap.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/iap/iap.c" diff --git a/simulat0r/firmware/core/iap/iap.h b/simulat0r/firmware/core/iap/iap.h new file mode 100644 index 0000000..05db4ad --- /dev/null +++ b/simulat0r/firmware/core/iap/iap.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/iap/iap.h" diff --git a/simulat0r/firmware/core/libc/ctype.c b/simulat0r/firmware/core/libc/ctype.c new file mode 100644 index 0000000..c29e933 --- /dev/null +++ b/simulat0r/firmware/core/libc/ctype.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/libc/ctype.c" diff --git a/simulat0r/firmware/core/libc/stdio.c b/simulat0r/firmware/core/libc/stdio.c new file mode 100644 index 0000000..bb0123b --- /dev/null +++ b/simulat0r/firmware/core/libc/stdio.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/libc/stdio.c" diff --git a/simulat0r/firmware/core/libc/string.c b/simulat0r/firmware/core/libc/string.c new file mode 100644 index 0000000..19df49e --- /dev/null +++ b/simulat0r/firmware/core/libc/string.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/libc/string.c" diff --git a/simulat0r/firmware/core/lpc134x.h b/simulat0r/firmware/core/lpc134x.h new file mode 100644 index 0000000..af0ada7 --- /dev/null +++ b/simulat0r/firmware/core/lpc134x.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/core/lpc134x.h" diff --git a/simulat0r/firmware/core/pmu/pmu.c b/simulat0r/firmware/core/pmu/pmu.c new file mode 100644 index 0000000..ec44b41 --- /dev/null +++ b/simulat0r/firmware/core/pmu/pmu.c @@ -0,0 +1,2 @@ +#define volatile(x) volatile("nop") +#include "../../../../firmware/core/pmu/pmu.c" diff --git a/simulat0r/firmware/core/pmu/pmu.h b/simulat0r/firmware/core/pmu/pmu.h new file mode 100644 index 0000000..1ebe126 --- /dev/null +++ b/simulat0r/firmware/core/pmu/pmu.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/pmu/pmu.h" diff --git a/simulat0r/firmware/core/projectconfig.h b/simulat0r/firmware/core/projectconfig.h new file mode 100644 index 0000000..8b1724c --- /dev/null +++ b/simulat0r/firmware/core/projectconfig.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/core/projectconfig.h" diff --git a/simulat0r/firmware/core/pwm/pwm.c b/simulat0r/firmware/core/pwm/pwm.c new file mode 100644 index 0000000..6c48899 --- /dev/null +++ b/simulat0r/firmware/core/pwm/pwm.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/pwm/pwm.c" diff --git a/simulat0r/firmware/core/pwm/pwm.h b/simulat0r/firmware/core/pwm/pwm.h new file mode 100644 index 0000000..195d7a7 --- /dev/null +++ b/simulat0r/firmware/core/pwm/pwm.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/pwm/pwm.h" diff --git a/simulat0r/firmware/core/rom_drivers.h b/simulat0r/firmware/core/rom_drivers.h new file mode 100644 index 0000000..99c8086 --- /dev/null +++ b/simulat0r/firmware/core/rom_drivers.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/core/rom_drivers.h" diff --git a/simulat0r/firmware/core/ssp/ssp.c b/simulat0r/firmware/core/ssp/ssp.c new file mode 100644 index 0000000..cd5018a --- /dev/null +++ b/simulat0r/firmware/core/ssp/ssp.c @@ -0,0 +1,23 @@ +#define sspInit _hideaway_sspInit +#define sspSend _hideaway_sspSend +#define sspReceive _hideaway_sspReceive +#define sspSendReceive _hideaway_sspSendReceive + +#include "../../../../firmware/core/ssp/ssp.c" + +#undef sspInit +#undef sspSend +#undef sspReceive +#undef sspSendReceive + +void sspInit (uint8_t portNum, sspClockPolarity_t polarity, sspClockPhase_t phase) { +} + +void sspSend (uint8_t portNum, const uint8_t *buf, uint32_t length) { +} + +void sspReceive (uint8_t portNum, uint8_t *buf, uint32_t length) { +} + +void sspSendReceive(uint8_t portNum, uint8_t *buf, uint32_t length) { +} diff --git a/simulat0r/firmware/core/ssp/ssp.h b/simulat0r/firmware/core/ssp/ssp.h new file mode 100644 index 0000000..65a74e0 --- /dev/null +++ b/simulat0r/firmware/core/ssp/ssp.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/ssp/ssp.h" diff --git a/simulat0r/firmware/core/sysdefs.h b/simulat0r/firmware/core/sysdefs.h new file mode 100644 index 0000000..5d5db18 --- /dev/null +++ b/simulat0r/firmware/core/sysdefs.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/core/sysdefs.h" diff --git a/simulat0r/firmware/core/sysinit.c b/simulat0r/firmware/core/sysinit.c new file mode 100644 index 0000000..470d282 --- /dev/null +++ b/simulat0r/firmware/core/sysinit.c @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include +#include + +//#define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) +#define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) + +#include "core/lpc134x.h" + +void testByte(void* addr) { + fprintf(stderr,"Testing address %x : read ",addr); + fprintf(stderr,"%x, write ",(int)(*((char*)addr))); + ++(*((char*)addr)); + fprintf(stderr,"%x",(int)(*((char*)addr))); + --(*((char*)addr)); + fprintf(stderr," OK\n"); +} + +void testMemoryHack(void* addr,long size) { + fprintf(stderr,"Testing memory range %x - %x\n",addr,addr+size); + for(void* p=addr; p= sb.st_size) { + fprintf(stderr, "offset is past end of file\n"); + exit(EXIT_FAILURE); + } + + length = size; + + addr = mmap(address, length + offset - pa_offset, PROT_READ | PROT_WRITE, + MAP_PRIVATE, fd, pa_offset); + if (addr == MAP_FAILED) + handle_error("mmap"); + if(addr!=address) { + fprintf(stderr, "mmap: wanted %x, got %x: ",address,addr); + handle_error("mmap address discrepancy"); + } + // testMemoryHack(address,size); + fprintf(stderr,"Range %x tested\n",addr); +} + + +void systemInit() +{ + // setupMemoryHack((void*)0x40000000,0x1000000); + // setupMemoryHack((void*)0x50000000,10*1024*1024); + // setupMemoryHack((void*)0x10000000,10*1024*1024); + // systick stuff unmappable setupMemoryHack((void*)0xe0000000,0x10000); + +#if 0 + printf("Test %d\n",SSP_SSP0CR0); + printf("Test2 %d\n",++SSP_SSP0CR0); + printf("Test3 pre %x\n",&SYSTICK_STRELOAD); + // printf("Test3 %d\n",++SYSTICK_STRELOAD); +#endif +} diff --git a/simulat0r/firmware/core/sysinit.h b/simulat0r/firmware/core/sysinit.h new file mode 100644 index 0000000..043ddd9 --- /dev/null +++ b/simulat0r/firmware/core/sysinit.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/core/sysinit.h" diff --git a/simulat0r/firmware/core/systick/systick.c b/simulat0r/firmware/core/systick/systick.c new file mode 100644 index 0000000..3d5bff6 --- /dev/null +++ b/simulat0r/firmware/core/systick/systick.c @@ -0,0 +1,231 @@ +#warning "cleanupthisfile" +#if 0 +#include "../../firmware/core/systick/systick.c" +#else + +/**************************************************************************/ +/*! + @file systick.c + @author K. Townsend (microBuilder.eu) + @date 22 March 2010 + @version 0.10 + + @section DESCRIPTION + + Controls the 24-bit 'system tick' clock, which can be used as a + generic timer or to control time sharing with an embedded real-time + operating system (such as FreeRTOS). + + @section Example + + @code + #include "core/cpu/cpu.h" + #include "core/systick/systick.h" + + void main (void) + { + cpuInit(); + + // Start systick timer with one tick every 10ms + systickInit(10); + + while(1) + { + } + } + @endcode + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2010, microBuilder SARL + 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. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''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 COPYRIGHT HOLDER 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. +*/ +/**************************************************************************/ + +#include "systick.h" + +volatile uint32_t systickTicks = 0; // 1ms tick counter +volatile uint32_t systickRollovers = 0; + +void tick_wrapper(void); + +/**************************************************************************/ +/*! + @brief Systick interrupt handler +*/ +/**************************************************************************/ +void SysTick_Handler (void) +{ + systickTicks++; + + // Increment rollover counter + if (systickTicks == 0xFFFFFFFF) systickRollovers++; + + tick_wrapper(); +} + +/**************************************************************************/ +/*! + @brief Configures the systick timer + + @param[in] ticks + The number of clock cycles between each tick of the + systick timer. for example, 'CFG_CPU_CCLK / 1000' = + 1 millisecond. This value must not exceed 0x00FFFFFF. +*/ +/**************************************************************************/ +static uint32_t systickConfig(uint32_t ticks) +{ + fprintf(stderr,"systickConfig: unimplemented\n"); + return 0; + + // Check if 'ticks' is greater than maximum value + if (ticks > SYSTICK_STRELOAD_MASK) + { + return (1); + } + + // Reset counter + systickTicks = 0; + + // Set reload register + SYSTICK_STRELOAD = (ticks & SYSTICK_STRELOAD_MASK) - 1; + + // Load the systick counter value + SYSTICK_STCURR = 0; + + // Enable systick IRQ and timer + SYSTICK_STCTRL = SYSTICK_STCTRL_CLKSOURCE | + SYSTICK_STCTRL_TICKINT | + SYSTICK_STCTRL_ENABLE; + + return (0); +} + +/**************************************************************************/ +/*! + @brief Initialises the systick timer + + @param[in] delayMs + The number of milliseconds between each tick of the systick + timer. + + @note The shortest possible delay is 1 millisecond, which will + allow fine grained delays, but will cause more load on the + system than a 10mS delay. The resolution of the systick + timer needs to be balanced with the amount of processing + time you can spare. The delay should really only be set + to 1 mS if you genuinely have a need for 1mS delays, + otherwise a higher value like 5 or 10 mS is probably + more appropriate. +*/ +/**************************************************************************/ +void systickInit (uint32_t delayMs) +{ + systickConfig ((CFG_CPU_CCLK / 1000) * delayMs); +} + +/**************************************************************************/ +/*! + @brief Causes a blocking delay for 'delayTicks' ticks on the + systick timer. For example: systickDelay(100) would cause + a blocking delay for 100 ticks of the systick timer. + + @param[in] delayTicks + The number of systick ticks to cause a blocking delay for + + @Note This function takes into account the fact that the tick + counter may eventually roll over to 0 once it reaches + 0xFFFFFFFF. +*/ +/**************************************************************************/ +void systickDelay (uint32_t delayTicks) +{ + uint32_t curTicks; + curTicks = systickTicks; + + // Make sure delay is at least 1 tick in case of division, etc. + if (delayTicks == 0) delayTicks = 1; + + if (curTicks > 0xFFFFFFFF - delayTicks) + { + // Rollover will occur during delay + while (systickTicks >= curTicks) + { + while (systickTicks < (delayTicks - (0xFFFFFFFF - curTicks))); + } + } + else + { + while ((systickTicks - curTicks) < delayTicks); + } +} + +/**************************************************************************/ +/*! + @brief Returns the current value of the systick timer counter. + This value is incremented by one every time an interrupt + fires for the systick timer. +*/ +/**************************************************************************/ +uint32_t systickGetTicks(void) +{ + return systickTicks; +} + +/**************************************************************************/ +/*! + @brief Returns the current value of the systick timer rollover + counter. This value is incremented by one every time the + tick counter rolls over from 0xFFFFFFFF to 0. +*/ +/**************************************************************************/ +uint32_t systickGetRollovers(void) +{ + return systickRollovers; +} + +/**************************************************************************/ +/*! + @brief Returns the approximate number of seconds that the + systick timer has been running. +*/ +/**************************************************************************/ +uint32_t systickGetSecondsActive(void) +{ + uint32_t currentTick = systickTicks; + uint32_t rollovers = systickRollovers; + uint32_t secsActive = currentTick / (1000 / CFG_SYSTICK_DELAY_IN_MS); + secsActive += rollovers * (0xFFFFFFFF / (1000 / CFG_SYSTICK_DELAY_IN_MS)); + + return secsActive; +} + + + +#endif + diff --git a/simulat0r/firmware/core/systick/systick.h b/simulat0r/firmware/core/systick/systick.h new file mode 100644 index 0000000..6f34ff9 --- /dev/null +++ b/simulat0r/firmware/core/systick/systick.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/systick/systick.h" diff --git a/simulat0r/firmware/core/timer16/timer16.c b/simulat0r/firmware/core/timer16/timer16.c new file mode 100644 index 0000000..0474a85 --- /dev/null +++ b/simulat0r/firmware/core/timer16/timer16.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/timer16/timer16.c" diff --git a/simulat0r/firmware/core/timer16/timer16.h b/simulat0r/firmware/core/timer16/timer16.h new file mode 100644 index 0000000..81bacb8 --- /dev/null +++ b/simulat0r/firmware/core/timer16/timer16.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/timer16/timer16.h" diff --git a/simulat0r/firmware/core/timer32/timer32.c b/simulat0r/firmware/core/timer32/timer32.c new file mode 100644 index 0000000..e16113e --- /dev/null +++ b/simulat0r/firmware/core/timer32/timer32.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/timer32/timer32.c" diff --git a/simulat0r/firmware/core/timer32/timer32.h b/simulat0r/firmware/core/timer32/timer32.h new file mode 100644 index 0000000..0b80aeb --- /dev/null +++ b/simulat0r/firmware/core/timer32/timer32.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/timer32/timer32.h" diff --git a/simulat0r/firmware/core/uart/uart.c b/simulat0r/firmware/core/uart/uart.c new file mode 100644 index 0000000..117d445 --- /dev/null +++ b/simulat0r/firmware/core/uart/uart.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/uart/uart.c" diff --git a/simulat0r/firmware/core/uart/uart.h b/simulat0r/firmware/core/uart/uart.h new file mode 100644 index 0000000..152ac0c --- /dev/null +++ b/simulat0r/firmware/core/uart/uart.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/uart/uart.h" diff --git a/simulat0r/firmware/core/uart/uart_buf.c b/simulat0r/firmware/core/uart/uart_buf.c new file mode 100644 index 0000000..f7baf07 --- /dev/null +++ b/simulat0r/firmware/core/uart/uart_buf.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/uart/uart_buf.c" diff --git a/simulat0r/firmware/core/usbcdc/cdc.h b/simulat0r/firmware/core/usbcdc/cdc.h new file mode 100644 index 0000000..e3ba7da --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/cdc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/cdc.h" diff --git a/simulat0r/firmware/core/usbcdc/cdc_buf.c b/simulat0r/firmware/core/usbcdc/cdc_buf.c new file mode 100644 index 0000000..d462ebc --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/cdc_buf.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/cdc_buf.c" diff --git a/simulat0r/firmware/core/usbcdc/cdc_buf.h b/simulat0r/firmware/core/usbcdc/cdc_buf.h new file mode 100644 index 0000000..21ee87f --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/cdc_buf.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/cdc_buf.h" diff --git a/simulat0r/firmware/core/usbcdc/cdcuser.c b/simulat0r/firmware/core/usbcdc/cdcuser.c new file mode 100644 index 0000000..5c05857 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/cdcuser.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/cdcuser.c" diff --git a/simulat0r/firmware/core/usbcdc/cdcuser.h b/simulat0r/firmware/core/usbcdc/cdcuser.h new file mode 100644 index 0000000..17608b2 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/cdcuser.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/cdcuser.h" diff --git a/simulat0r/firmware/core/usbcdc/config.h b/simulat0r/firmware/core/usbcdc/config.h new file mode 100644 index 0000000..ee283d7 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/config.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/config.h" diff --git a/simulat0r/firmware/core/usbcdc/usb.h b/simulat0r/firmware/core/usbcdc/usb.h new file mode 100644 index 0000000..71cda7a --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usb.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usb.h" diff --git a/simulat0r/firmware/core/usbcdc/usbcfg.h b/simulat0r/firmware/core/usbcdc/usbcfg.h new file mode 100644 index 0000000..cc8ee03 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbcfg.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbcfg.h" diff --git a/simulat0r/firmware/core/usbcdc/usbcore.c b/simulat0r/firmware/core/usbcdc/usbcore.c new file mode 100644 index 0000000..9ed0796 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbcore.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbcore.c" diff --git a/simulat0r/firmware/core/usbcdc/usbcore.h b/simulat0r/firmware/core/usbcdc/usbcore.h new file mode 100644 index 0000000..dc0494e --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbcore.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbcore.h" diff --git a/simulat0r/firmware/core/usbcdc/usbdesc.c b/simulat0r/firmware/core/usbcdc/usbdesc.c new file mode 100644 index 0000000..7b3a224 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbdesc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbdesc.c" diff --git a/simulat0r/firmware/core/usbcdc/usbdesc.h b/simulat0r/firmware/core/usbcdc/usbdesc.h new file mode 100644 index 0000000..2142f32 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbdesc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbdesc.h" diff --git a/simulat0r/firmware/core/usbcdc/usbhw.c b/simulat0r/firmware/core/usbcdc/usbhw.c new file mode 100644 index 0000000..c21603c --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbhw.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbhw.c" diff --git a/simulat0r/firmware/core/usbcdc/usbhw.h b/simulat0r/firmware/core/usbcdc/usbhw.h new file mode 100644 index 0000000..8914a79 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbhw.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbhw.h" diff --git a/simulat0r/firmware/core/usbcdc/usbreg.h b/simulat0r/firmware/core/usbcdc/usbreg.h new file mode 100644 index 0000000..74b13d8 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbreg.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbreg.h" diff --git a/simulat0r/firmware/core/usbcdc/usbuser.c b/simulat0r/firmware/core/usbcdc/usbuser.c new file mode 100644 index 0000000..4594cdb --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbuser.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbuser.c" diff --git a/simulat0r/firmware/core/usbcdc/usbuser.h b/simulat0r/firmware/core/usbcdc/usbuser.h new file mode 100644 index 0000000..21de413 --- /dev/null +++ b/simulat0r/firmware/core/usbcdc/usbuser.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/usbcdc/usbuser.h" diff --git a/simulat0r/firmware/core/wdt/wdt.c b/simulat0r/firmware/core/wdt/wdt.c new file mode 100644 index 0000000..866ab3c --- /dev/null +++ b/simulat0r/firmware/core/wdt/wdt.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/wdt/wdt.c" diff --git a/simulat0r/firmware/core/wdt/wdt.h b/simulat0r/firmware/core/wdt/wdt.h new file mode 100644 index 0000000..d9ac35e --- /dev/null +++ b/simulat0r/firmware/core/wdt/wdt.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../../firmware/core/wdt/wdt.h" diff --git a/simulat0r/firmware/filesystem/Makefile b/simulat0r/firmware/filesystem/Makefile new file mode 100644 index 0000000..76b2d19 --- /dev/null +++ b/simulat0r/firmware/filesystem/Makefile @@ -0,0 +1,30 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +OBJS = + +OBJS += ff.o +OBJS += diskio.o +OBJS += iobase.o +OBJS += mmc.o +OBJS += at45db041d.o +OBJS += util.o +OBJS += select.o +OBJS += execute.o + +LIBNAME=fat + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= .. +INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I. + +include $(ROOT_PATH)/Makefile.inc + +########################################################################## +# Actual work +########################################################################## + +include $(ROOT_PATH)/Makefile.util diff --git a/simulat0r/firmware/filesystem/at45db041d.c b/simulat0r/firmware/filesystem/at45db041d.c new file mode 100644 index 0000000..4283942 --- /dev/null +++ b/simulat0r/firmware/filesystem/at45db041d.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/at45db041d.c" diff --git a/simulat0r/firmware/filesystem/at45db041d.h b/simulat0r/firmware/filesystem/at45db041d.h new file mode 100644 index 0000000..ca44d1d --- /dev/null +++ b/simulat0r/firmware/filesystem/at45db041d.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/at45db041d.h" diff --git a/simulat0r/firmware/filesystem/diskio.c b/simulat0r/firmware/filesystem/diskio.c new file mode 100644 index 0000000..31974b0 --- /dev/null +++ b/simulat0r/firmware/filesystem/diskio.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/diskio.c" diff --git a/simulat0r/firmware/filesystem/diskio.h b/simulat0r/firmware/filesystem/diskio.h new file mode 100644 index 0000000..c312d4e --- /dev/null +++ b/simulat0r/firmware/filesystem/diskio.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/diskio.h" diff --git a/simulat0r/firmware/filesystem/execute.c b/simulat0r/firmware/filesystem/execute.c new file mode 100644 index 0000000..c220e76 --- /dev/null +++ b/simulat0r/firmware/filesystem/execute.c @@ -0,0 +1,12 @@ +/* AUTOGENERATED SOURCE FILE */ + +#include +#include + +void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ + fprintf(stderr,"execute_file: unimplemented\n"); +} + +void executeSelect(char *ext){ + fprintf(stderr,"executeSelect: unimplemented\n"); +} diff --git a/simulat0r/firmware/filesystem/execute.h b/simulat0r/firmware/filesystem/execute.h new file mode 100644 index 0000000..5c6af99 --- /dev/null +++ b/simulat0r/firmware/filesystem/execute.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/execute.h" diff --git a/simulat0r/firmware/filesystem/ff.c b/simulat0r/firmware/filesystem/ff.c new file mode 100644 index 0000000..29a0fc8 --- /dev/null +++ b/simulat0r/firmware/filesystem/ff.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/ff.c" diff --git a/simulat0r/firmware/filesystem/ff.h b/simulat0r/firmware/filesystem/ff.h new file mode 100644 index 0000000..8291592 --- /dev/null +++ b/simulat0r/firmware/filesystem/ff.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/ff.h" diff --git a/simulat0r/firmware/filesystem/ffconf.h b/simulat0r/firmware/filesystem/ffconf.h new file mode 100644 index 0000000..0caa938 --- /dev/null +++ b/simulat0r/firmware/filesystem/ffconf.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/ffconf.h" diff --git a/simulat0r/firmware/filesystem/integer.h b/simulat0r/firmware/filesystem/integer.h new file mode 100644 index 0000000..23c0673 --- /dev/null +++ b/simulat0r/firmware/filesystem/integer.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/integer.h" diff --git a/simulat0r/firmware/filesystem/iobase.c b/simulat0r/firmware/filesystem/iobase.c new file mode 100644 index 0000000..cebf5ea --- /dev/null +++ b/simulat0r/firmware/filesystem/iobase.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/iobase.c" diff --git a/simulat0r/firmware/filesystem/iobase.h b/simulat0r/firmware/filesystem/iobase.h new file mode 100644 index 0000000..6c0433d --- /dev/null +++ b/simulat0r/firmware/filesystem/iobase.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/iobase.h" diff --git a/simulat0r/firmware/filesystem/mmc.c b/simulat0r/firmware/filesystem/mmc.c new file mode 100644 index 0000000..fdde8e8 --- /dev/null +++ b/simulat0r/firmware/filesystem/mmc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/mmc.c" diff --git a/simulat0r/firmware/filesystem/mmc.h b/simulat0r/firmware/filesystem/mmc.h new file mode 100644 index 0000000..0fd458c --- /dev/null +++ b/simulat0r/firmware/filesystem/mmc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/mmc.h" diff --git a/simulat0r/firmware/filesystem/select.c b/simulat0r/firmware/filesystem/select.c new file mode 100644 index 0000000..6c54b5c --- /dev/null +++ b/simulat0r/firmware/filesystem/select.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/select.c" diff --git a/simulat0r/firmware/filesystem/select.h b/simulat0r/firmware/filesystem/select.h new file mode 100644 index 0000000..c7b5e5c --- /dev/null +++ b/simulat0r/firmware/filesystem/select.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/select.h" diff --git a/simulat0r/firmware/filesystem/util.c b/simulat0r/firmware/filesystem/util.c new file mode 100644 index 0000000..e5f2d9e --- /dev/null +++ b/simulat0r/firmware/filesystem/util.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/filesystem/util.c" diff --git a/simulat0r/firmware/funk/Makefile b/simulat0r/firmware/funk/Makefile new file mode 100644 index 0000000..dd2a593 --- /dev/null +++ b/simulat0r/firmware/funk/Makefile @@ -0,0 +1,25 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +OBJS = + +OBJS += nrf24l01p.o +OBJS += rftransfer.o +OBJS += filetransfer.o + +LIBNAME=funk + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= .. +INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I. + +include $(ROOT_PATH)/Makefile.inc + +########################################################################## +# Actual work +########################################################################## + +include $(ROOT_PATH)/Makefile.util diff --git a/simulat0r/firmware/funk/filetransfer.c b/simulat0r/firmware/funk/filetransfer.c new file mode 100644 index 0000000..9e6d5c2 --- /dev/null +++ b/simulat0r/firmware/funk/filetransfer.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/filetransfer.c" diff --git a/simulat0r/firmware/funk/filetransfer.h b/simulat0r/firmware/funk/filetransfer.h new file mode 100644 index 0000000..865e88b --- /dev/null +++ b/simulat0r/firmware/funk/filetransfer.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/filetransfer.h" diff --git a/simulat0r/firmware/funk/nrf24l01p.c b/simulat0r/firmware/funk/nrf24l01p.c new file mode 100644 index 0000000..e8c5db4 --- /dev/null +++ b/simulat0r/firmware/funk/nrf24l01p.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/nrf24l01p.c" diff --git a/simulat0r/firmware/funk/nrf24l01p.h b/simulat0r/firmware/funk/nrf24l01p.h new file mode 100644 index 0000000..06491f4 --- /dev/null +++ b/simulat0r/firmware/funk/nrf24l01p.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/nrf24l01p.h" diff --git a/simulat0r/firmware/funk/openbeacon.c b/simulat0r/firmware/funk/openbeacon.c new file mode 100644 index 0000000..0c11675 --- /dev/null +++ b/simulat0r/firmware/funk/openbeacon.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/openbeacon.c" diff --git a/simulat0r/firmware/funk/openbeacon.h b/simulat0r/firmware/funk/openbeacon.h new file mode 100644 index 0000000..b5ceaab --- /dev/null +++ b/simulat0r/firmware/funk/openbeacon.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/openbeacon.h" diff --git a/simulat0r/firmware/funk/rftransfer.c b/simulat0r/firmware/funk/rftransfer.c new file mode 100644 index 0000000..f284b1d --- /dev/null +++ b/simulat0r/firmware/funk/rftransfer.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/rftransfer.c" diff --git a/simulat0r/firmware/funk/rftransfer.h b/simulat0r/firmware/funk/rftransfer.h new file mode 100644 index 0000000..06483f9 --- /dev/null +++ b/simulat0r/firmware/funk/rftransfer.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/funk/rftransfer.h" diff --git a/simulat0r/firmware/lcd/Makefile b/simulat0r/firmware/lcd/Makefile new file mode 100644 index 0000000..fe639a3 --- /dev/null +++ b/simulat0r/firmware/lcd/Makefile @@ -0,0 +1,45 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +OBJS = + +OBJS += display.o +OBJS += render.o +OBJS += decoder.o +OBJS += backlight.o +OBJS += print.o + +FONTS = $(basename $(wildcard fonts/*.c)) + +LIBNAME=lcd + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= .. +INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I. + +include $(ROOT_PATH)/Makefile.inc + +FOBJS= $(foreach ft,$(FONTS),$(ft).o) +OBJS+= $(FOBJS) + +########################################################################## +# Actual work +########################################################################## + +include $(ROOT_PATH)/Makefile.util + +all: allfonts.h + +$(FOBJS): $(foreach ft,$(FONTS),$(ft).h) fonts.h + +clean:: + rm -f fonts/*.o allfonts.h + touch allfonts.h + +.PHONY: allfonts.h + +allfonts.h: + (echo "#include ";for a in $(FONTS) ; do echo "#include "; done) > $@ diff --git a/simulat0r/firmware/lcd/backlight.c b/simulat0r/firmware/lcd/backlight.c new file mode 100644 index 0000000..837d0de --- /dev/null +++ b/simulat0r/firmware/lcd/backlight.c @@ -0,0 +1,20 @@ +#include "basic/basic.h" + +uint32_t brightness = 100; + +void backlightInit(void) { +} + +int backlightSetBrightness(uint32_t percentage) { + if ((percentage < 0) || (percentage > 100)) { + /* brightness must be a value between 1 and 100 */ + return -1; + } + + brightness = percentage; + return 0; +} + +uint32_t backlightGetBrightness(void) { + return brightness; +} diff --git a/simulat0r/firmware/lcd/backlight.h b/simulat0r/firmware/lcd/backlight.h new file mode 100644 index 0000000..7474421 --- /dev/null +++ b/simulat0r/firmware/lcd/backlight.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/lcd/backlight.h" diff --git a/simulat0r/firmware/lcd/decoder.c b/simulat0r/firmware/lcd/decoder.c new file mode 100644 index 0000000..64311d8 --- /dev/null +++ b/simulat0r/firmware/lcd/decoder.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/lcd/decoder.c" diff --git a/simulat0r/firmware/lcd/decoder.h b/simulat0r/firmware/lcd/decoder.h new file mode 100644 index 0000000..9024b81 --- /dev/null +++ b/simulat0r/firmware/lcd/decoder.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/lcd/decoder.h" diff --git a/simulat0r/firmware/lcd/display.c b/simulat0r/firmware/lcd/display.c new file mode 100644 index 0000000..8e12c67 --- /dev/null +++ b/simulat0r/firmware/lcd/display.c @@ -0,0 +1,56 @@ +#if 0 +#include "../firmware/lcd/display.c" +#else + +#include "../firmware/lcd/display.h" +#include "simulator.h" + +uint8_t lcdBuffer[RESX*RESY_B]; +int lcd_layout = 0; +const int TYPE_DATA=0; + + +void lcdInit(void) { + fprintf(stderr,"lcdInit(void)\n"); +} + + +void lcdFill(char f){ + int x; + for(x=0;x>1)&0x55)|((c<<1)&0xAA); \ + c = ((c>>2)&0x33)|((c<<2)&0xCC); \ + c = (c>>4) | (c<<4); \ + }while(0) diff --git a/simulat0r/firmware/libc-unc0llide.h b/simulat0r/firmware/libc-unc0llide.h new file mode 100644 index 0000000..19d8cf8 --- /dev/null +++ b/simulat0r/firmware/libc-unc0llide.h @@ -0,0 +1,50 @@ +/* +This header is "gcc -include"d for all compilations of firmware files when building as simulat0r. +The following symbols were found to be defined within glibc. +Use different names within simulat0r to keep the firmware and simulat0r-host universes collision-free. + */ +#define buf __r0ket_buf +#define deselect __r0ket_deselect +#define ECIES_embedded_public_key_validation __r0ket_ECIES_embedded_public_key_validation +#define ECIES_generate_key_pair __r0ket_ECIES_generate_key_pair +#define ECIES_public_key_validation __r0ket_ECIES_public_key_validation +#define f_sync __r0ket_f_sync +#define getInput __r0ket_getInput +#define isalnum __r0ket_isalnum +#define isalpha __r0ket_isalpha +#define isascii __r0ket_isascii +#define isblank __r0ket_isblank +#define iscntrl __r0ket_iscntrl +#define isdigit __r0ket_isdigit +#define isgraph __r0ket_isgraph +#define islower __r0ket_islower +#define isprint __r0ket_isprint +#define ispunct __r0ket_ispunct +#define isspace __r0ket_isspace +#define isupper __r0ket_isupper +#define isxdigit __r0ket_isxdigit +#define key __r0ket_key +#define memcmp __r0ket_memcmp +#define memcpy __r0ket_memcpy +#define memmove __r0ket_memmove +#define memset __r0ket_memset +#define printf __r0ket_printf +#define select __r0ket_select +#define snprintf __r0ket_snprintf +#define sprintf __r0ket_sprintf +#define strchr __r0ket_strchr +#define strcmp __r0ket_strcmp +#define strcpy __r0ket_strcpy +#define strlen __r0ket_strlen +#define strncmp __r0ket_strncmp +#define strncpy __r0ket_strncpy +#define strrchr __r0ket_strrchr +#define strtok __r0ket_strtok +#define strtok_r __r0ket_strtok_r +#define sync __r0ket_sync +#define tolower __r0ket_tolower +#define toupper __r0ket_toupper +#define vprintf __r0ket_vprintf +#define vsnprintf __r0ket_vsnprintf +#define vsprintf __r0ket_vsprintf +#define XTEA_init_key __r0ket_XTEA_init_key diff --git a/simulat0r/firmware/loadable/Makefile b/simulat0r/firmware/loadable/Makefile new file mode 100644 index 0000000..fa86f1e --- /dev/null +++ b/simulat0r/firmware/loadable/Makefile @@ -0,0 +1,12 @@ +# Make doesn't allow dependencies on parent directory, so we need to +# run make from one level up: + +MAKEFILE=loadable/Makefile.sub +MAKE+=--no-print-directory + +all: + @cd .. && $(MAKE) -f $(MAKEFILE) + +clean: + @cd .. && $(MAKE) -f $(MAKEFILE) clean + diff --git a/simulat0r/firmware/loadable/Makefile.sub b/simulat0r/firmware/loadable/Makefile.sub new file mode 100644 index 0000000..aa2f3ee --- /dev/null +++ b/simulat0r/firmware/loadable/Makefile.sub @@ -0,0 +1,57 @@ +DIR?= loadable + +########################################################################## +# User configuration and firmware specific object files +########################################################################## +SRCS = $(wildcard $(DIR)/*.c) +OBJS = $(foreach mod,$(SRCS),$(subst .c,.o,$(mod))) +ELFS = $(foreach mod,$(SRCS),$(subst .c,.elf,$(mod))) +BINS = $(foreach mod,$(SRCS),$(subst .c,.bin,$(mod))) +HDRS = $(foreach mod,$(SRCS),$(subst .c,.h,$(mod))) + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= . + +INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/core + +include $(ROOT_PATH)/Makefile.inc + +########################################################################## +# Compiler settings, parameters and flags +########################################################################## +FIRMWARE=$(ROOT_PATH)/$(OUTFILE).elf +LDSRCFILE=$(DIR)/ram.ld +LDFILE=$(DIR)/loadable.ld +CFLAGS+=-mlong-calls -fno-toplevel-reorder +LDFLAGS+= -R $(FIRMWARE) + +all: $(OBJS) $(ELFS) $(BINS) $(HDRS) + +$(LDFILE): + -@echo "MEMORY" > $(LDFILE) + -@echo "{" >> $(LDFILE) + -@echo " sram(rwx): ORIGIN = 0x10002000 - $(RAMCODE), LENGTH = $(RAMCODE)" >> $(LDFILE) + -@echo "}" >> $(LDFILE) + -@echo "INCLUDE $(LDSRCFILE)" >> $(LDFILE) + +%.o : %.c + $(CC) $(CFLAGS) -o $@ $< + +%.elf: %.o $(FIRMWARE) $(LDFILE) + $(LD) $(LDFLAGS) -T $(LDFILE) -o $@ $< + $(SIZE) $@ + +%.bin: %.elf + $(OBJCOPY) $(OCFLAGS) -O binary $< $@ + +%.h: %.bin $(DIR)/bin2h.pl + $(DIR)/bin2h.pl $< + +clean: + cd $(DIR) && rm -f *.o *.elf *.bin + +.SUFFIXES: + +.PHONY: $(LDFILE) diff --git a/simulat0r/firmware/loadable/blinktest.c b/simulat0r/firmware/loadable/blinktest.c new file mode 100644 index 0000000..234eb92 --- /dev/null +++ b/simulat0r/firmware/loadable/blinktest.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/loadable/blinktest.c" diff --git a/simulat0r/firmware/loadable/blinktest2.c b/simulat0r/firmware/loadable/blinktest2.c new file mode 100644 index 0000000..ebd11b7 --- /dev/null +++ b/simulat0r/firmware/loadable/blinktest2.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/loadable/blinktest2.c" diff --git a/simulat0r/firmware/loadable/spaceinvaders.c b/simulat0r/firmware/loadable/spaceinvaders.c new file mode 100644 index 0000000..406d744 --- /dev/null +++ b/simulat0r/firmware/loadable/spaceinvaders.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/loadable/spaceinvaders.c" diff --git a/simulat0r/firmware/lpc1xxx/LPC11xx_handlers.c b/simulat0r/firmware/lpc1xxx/LPC11xx_handlers.c new file mode 100644 index 0000000..3b934a1 --- /dev/null +++ b/simulat0r/firmware/lpc1xxx/LPC11xx_handlers.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/lpc1xxx/LPC11xx_handlers.c" diff --git a/simulat0r/firmware/lpc1xxx/LPC13xx_handlers.c b/simulat0r/firmware/lpc1xxx/LPC13xx_handlers.c new file mode 100644 index 0000000..c6c48af --- /dev/null +++ b/simulat0r/firmware/lpc1xxx/LPC13xx_handlers.c @@ -0,0 +1,3 @@ +/* +#include "../../../firmware/lpc1xxx/LPC13xx_handlers.c" +*/ diff --git a/simulat0r/firmware/lpc1xxx/LPC1xxx_startup.c b/simulat0r/firmware/lpc1xxx/LPC1xxx_startup.c new file mode 100644 index 0000000..73deb8b --- /dev/null +++ b/simulat0r/firmware/lpc1xxx/LPC1xxx_startup.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/lpc1xxx/LPC1xxx_startup.c" diff --git a/simulat0r/firmware/main.c b/simulat0r/firmware/main.c new file mode 100644 index 0000000..1c4c1d1 --- /dev/null +++ b/simulat0r/firmware/main.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../firmware/main.c" diff --git a/simulat0r/firmware/sysdefs.h b/simulat0r/firmware/sysdefs.h new file mode 100644 index 0000000..b6c693d --- /dev/null +++ b/simulat0r/firmware/sysdefs.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../firmware/sysdefs.h" diff --git a/simulat0r/firmware/usb/Makefile b/simulat0r/firmware/usb/Makefile new file mode 100644 index 0000000..d54ddf3 --- /dev/null +++ b/simulat0r/firmware/usb/Makefile @@ -0,0 +1,36 @@ +########################################################################## +# User configuration and firmware specific object files +########################################################################## + +OBJS = + +OBJS += usbconfig.o +OBJS += usbhid.o +OBJS += usbmsc.o + +LIBNAME=usb + +########################################################################## +# GNU GCC compiler flags +########################################################################## +ROOT_PATH?= .. +INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I. + +include $(ROOT_PATH)/Makefile.inc + +LIBFILE=lib$(LIBNAME).a +########################################################################## +# Compiler settings, parameters and flags +########################################################################## + +all: $(LIBFILE) + +$(LIBFILE): $(OBJS) + $(AR) rcs $@ $(OBJS) + +%.o : %.c + $(CC) $(CFLAGS) -o $@ $< + +clean: + rm -f $(OBJS) $(LIBFILE) + diff --git a/simulat0r/firmware/usb/usb.h b/simulat0r/firmware/usb/usb.h new file mode 100644 index 0000000..300b1e4 --- /dev/null +++ b/simulat0r/firmware/usb/usb.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usb.h" diff --git a/simulat0r/firmware/usb/usbconfig.c b/simulat0r/firmware/usb/usbconfig.c new file mode 100644 index 0000000..dffd54f --- /dev/null +++ b/simulat0r/firmware/usb/usbconfig.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usbconfig.c" diff --git a/simulat0r/firmware/usb/usbconfig.h b/simulat0r/firmware/usb/usbconfig.h new file mode 100644 index 0000000..f4660b7 --- /dev/null +++ b/simulat0r/firmware/usb/usbconfig.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usbconfig.h" diff --git a/simulat0r/firmware/usb/usbhid.c b/simulat0r/firmware/usb/usbhid.c new file mode 100644 index 0000000..80a684b --- /dev/null +++ b/simulat0r/firmware/usb/usbhid.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usbhid.c" diff --git a/simulat0r/firmware/usb/usbhid.h b/simulat0r/firmware/usb/usbhid.h new file mode 100644 index 0000000..223f407 --- /dev/null +++ b/simulat0r/firmware/usb/usbhid.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usbhid.h" diff --git a/simulat0r/firmware/usb/usbmsc.c b/simulat0r/firmware/usb/usbmsc.c new file mode 100644 index 0000000..d660d22 --- /dev/null +++ b/simulat0r/firmware/usb/usbmsc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usbmsc.c" diff --git a/simulat0r/firmware/usb/usbmsc.h b/simulat0r/firmware/usb/usbmsc.h new file mode 100644 index 0000000..9e2784f --- /dev/null +++ b/simulat0r/firmware/usb/usbmsc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usb/usbmsc.h" diff --git a/simulat0r/firmware/usbcdc/cdc.h b/simulat0r/firmware/usbcdc/cdc.h new file mode 100644 index 0000000..a7a26ca --- /dev/null +++ b/simulat0r/firmware/usbcdc/cdc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/cdc.h" diff --git a/simulat0r/firmware/usbcdc/cdc_buf.c b/simulat0r/firmware/usbcdc/cdc_buf.c new file mode 100644 index 0000000..e37d2fd --- /dev/null +++ b/simulat0r/firmware/usbcdc/cdc_buf.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/cdc_buf.c" diff --git a/simulat0r/firmware/usbcdc/cdc_buf.h b/simulat0r/firmware/usbcdc/cdc_buf.h new file mode 100644 index 0000000..b667b06 --- /dev/null +++ b/simulat0r/firmware/usbcdc/cdc_buf.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/cdc_buf.h" diff --git a/simulat0r/firmware/usbcdc/cdcuser.c b/simulat0r/firmware/usbcdc/cdcuser.c new file mode 100644 index 0000000..521d9c8 --- /dev/null +++ b/simulat0r/firmware/usbcdc/cdcuser.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/cdcuser.c" diff --git a/simulat0r/firmware/usbcdc/cdcuser.h b/simulat0r/firmware/usbcdc/cdcuser.h new file mode 100644 index 0000000..27728be --- /dev/null +++ b/simulat0r/firmware/usbcdc/cdcuser.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/cdcuser.h" diff --git a/simulat0r/firmware/usbcdc/config.h b/simulat0r/firmware/usbcdc/config.h new file mode 100644 index 0000000..4abc846 --- /dev/null +++ b/simulat0r/firmware/usbcdc/config.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/config.h" diff --git a/simulat0r/firmware/usbcdc/usb.h b/simulat0r/firmware/usbcdc/usb.h new file mode 100644 index 0000000..5c7cc8c --- /dev/null +++ b/simulat0r/firmware/usbcdc/usb.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usb.h" diff --git a/simulat0r/firmware/usbcdc/usbcfg.h b/simulat0r/firmware/usbcdc/usbcfg.h new file mode 100644 index 0000000..a09a7c1 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbcfg.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbcfg.h" diff --git a/simulat0r/firmware/usbcdc/usbcore.c b/simulat0r/firmware/usbcdc/usbcore.c new file mode 100644 index 0000000..b22988c --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbcore.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbcore.c" diff --git a/simulat0r/firmware/usbcdc/usbcore.h b/simulat0r/firmware/usbcdc/usbcore.h new file mode 100644 index 0000000..464271a --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbcore.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbcore.h" diff --git a/simulat0r/firmware/usbcdc/usbdesc.c b/simulat0r/firmware/usbcdc/usbdesc.c new file mode 100644 index 0000000..9f7ec49 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbdesc.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbdesc.c" diff --git a/simulat0r/firmware/usbcdc/usbdesc.h b/simulat0r/firmware/usbcdc/usbdesc.h new file mode 100644 index 0000000..fc40d77 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbdesc.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbdesc.h" diff --git a/simulat0r/firmware/usbcdc/usbhw.c b/simulat0r/firmware/usbcdc/usbhw.c new file mode 100644 index 0000000..4dc5d92 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbhw.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbhw.c" diff --git a/simulat0r/firmware/usbcdc/usbhw.h b/simulat0r/firmware/usbcdc/usbhw.h new file mode 100644 index 0000000..a5f9cb7 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbhw.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbhw.h" diff --git a/simulat0r/firmware/usbcdc/usbreg.h b/simulat0r/firmware/usbcdc/usbreg.h new file mode 100644 index 0000000..f7cb480 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbreg.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbreg.h" diff --git a/simulat0r/firmware/usbcdc/usbuser.c b/simulat0r/firmware/usbcdc/usbuser.c new file mode 100644 index 0000000..2e37158 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbuser.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbuser.c" diff --git a/simulat0r/firmware/usbcdc/usbuser.h b/simulat0r/firmware/usbcdc/usbuser.h new file mode 100644 index 0000000..0f3be77 --- /dev/null +++ b/simulat0r/firmware/usbcdc/usbuser.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/usbcdc/usbuser.h" diff --git a/simulat0r/gui/CMakeLists.txt b/simulat0r/gui/CMakeLists.txt new file mode 100644 index 0000000..0bb9087 --- /dev/null +++ b/simulat0r/gui/CMakeLists.txt @@ -0,0 +1,68 @@ +project (qsimulat0r) +cmake_minimum_required(VERSION 2.4.0) +find_package(Qt4 REQUIRED) + +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../firmware ${CMAKE_CURRENT_SOURCE_DIR}/../firmware/core) +link_directories(${CMAKE_CURRENT_BINARY_DIR} +../../firmware/applications +../../firmware/filesystem +../../firmware/lcd +../../firmware/usb) + +include(${QT_USE_FILE}) +set(qsimulat0r_SRCS + qsimulat0r.cc + simulat0rthread.cc +) + +set(MocHeaders + simulat0rthread.h +) + +qt4_automoc(${MocHeaders}) + +QT_WRAP_CPP(qsimulat0r MocSources ${qsimulat0r_SRCS}) + + +set(FIRMWARE_OBJS +../simcore/simcore.o +../simcore/misc.o + +../firmware/basic/basic.o +../firmware/basic/reinvoke_isp.o +../firmware/basic/delayms.o +../firmware/basic/uuid.o +../firmware/basic/keyin.o +../firmware/basic/voltage.o +../firmware/core/sysinit.o +../firmware/core/adc/adc.o +../firmware/core/cpu/cpu.o +../firmware/core/gpio/gpio.o +../firmware/core/i2c/i2c.o +../firmware/core/iap/iap.o +../firmware/core/libc/ctype.o +../firmware/core/libc/stdio.o +../firmware/core/libc/string.o +../firmware/core/pmu/pmu.o +../firmware/core/ssp/ssp.o +../firmware/core/systick/systick.o +../firmware/core/timer16/timer16.o +../firmware/core/timer32/timer32.o +../firmware/core/wdt/wdt.o +) + + +SET_SOURCE_FILES_PROPERTIES(${FIRMWARE_OBJS} PROPERTIES + GENERATED TRUE + EXTERNAL_OBJECT TRUE + OBJECT_DEPENDS TRUE +) + +add_executable(qsimulat0r ${qsimulat0r_SRCS} ${MocSources} + ${FIRMWARE_OBJS} +) + +target_link_libraries(qsimulat0r ${QT_LIBRARIES} libapp.a liblcd.a libusb.a libfat.a) + + + diff --git a/simulat0r/gui/qsimulat0r.cc b/simulat0r/gui/qsimulat0r.cc new file mode 100644 index 0000000..36cf9ae --- /dev/null +++ b/simulat0r/gui/qsimulat0r.cc @@ -0,0 +1,194 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#include "simulat0rthread.h" + +extern "C" { +#include "basic/basic.h" +#include "lcd/display.h" +#include "../simcore/simulator.h" +extern int lcd_layout; +} + +time_t starttime; +long framecount=0; + +class LCD : public QWidget { +public: + static const int ledsize=10; + static const int ledsep=1; + static const int paddingx=10; + static const int paddingy=10; + static const int pixh=3; + static const int pixw=3; + static const int sep=1; + static const int rasterx=pixh+sep; + static const int rastery=pixw+sep; + static const int dimx=RESX; //96; + static const int dimy=RESY; + + void drawLED(QImage& pixmap,int led, int x, int y) { + int color=simGetLED(led)?QColor(255,0,0).rgb():QColor(64,64,64).rgb(); + for(int minix=0; minixshowMessage("Initialized",5000); + statusBar()->showMessage("Temp",2000); + resize(2*LCD::paddingx+LCD::rasterx*RESX,2*LCD::paddingy+LCD::rastery*RESY+2*LCD::ledsize+2*LCD::ledsep+statusBar()->height()); + + show(); + setWindowTitle("r0ket simulat0r"); + } + + int buttonPressed(int button) { + return getAllBits(buttonState,button); + } + + int getAllBits(int i, int bit) { + return (i&bit)==bit; + } + + void setBit(int & i, int bit) { + statusBar()->showMessage("Set bit ",2000); + i=i|bit; + // setLowLevelButtonState(bit,1); + } + + void clearBit(int & i, int bit) { + statusBar()->showMessage("Clear bit ",2000); + i=i&(~bit); + // setLowLevelButtonState(bit,0); + } + + /* + void setLowLevelButtonState(int button, int state) { + if (button==BTN_UP) gpioSetValue(RB_BTN3, state); + if (button==BTN_DOWN) gpioSetValue(RB_BTN2, state); + if (button==BTN_ENTER) gpioSetValue(RB_BTN4, state); + if (button==BTN_LEFT) gpioSetValue(RB_BTN0, state); + if (button==BTN_RIGHT) gpioSetValue(RB_BTN1, state); + } + */ + + void keyPressEvent(QKeyEvent *event) { + if(event->isAutoRepeat()) return; + + if(event->key()==keyUp) clearBit(buttonState,BTN_UP); + if(event->key()==keyDown) clearBit(buttonState,BTN_DOWN); + if(event->key()==keyEnter) clearBit(buttonState,BTN_ENTER); + if(event->key()==keyLeft) clearBit(buttonState,BTN_LEFT); + if(event->key()==keyRight) clearBit(buttonState,BTN_RIGHT); + } + void keyReleaseEvent(QKeyEvent *event) { + if(event->isAutoRepeat()) return; + + if(event->key()==keyUp) setBit(buttonState,BTN_UP); + if(event->key()==keyDown) setBit(buttonState,BTN_DOWN); + if(event->key()==keyEnter) setBit(buttonState,BTN_ENTER); + if(event->key()==keyLeft) setBit(buttonState,BTN_LEFT); + if(event->key()==keyRight) setBit(buttonState,BTN_RIGHT); + } + +}; + +extern "C" { +void simlcdDisplayUpdate() { + hackptr->update(); + usleep(10000); +} + +int simButtonPressed(int button) { + return r0ketWidget->buttonPressed(button); +} + +void simSetLEDHook(int led){ + hackptr->update(); +} +} + +int main(int argc, char *argv[]) +{ + cout<<"Starting r0ket simulat0r..."<start(); + return app.exec(); +} diff --git a/simulat0r/gui/simulat0rthread.cc b/simulat0r/gui/simulat0rthread.cc new file mode 100644 index 0000000..90c3aec --- /dev/null +++ b/simulat0r/gui/simulat0rthread.cc @@ -0,0 +1,19 @@ +#include "simulat0rthread.h" + +extern "C" { +void simulator_main(); +} + +#include +#include +using namespace std; + +extern QWidget* hackptr; + +Simulat0rThread::~Simulat0rThread() { +} + +void Simulat0rThread::run() +{ + simulator_main(); +} diff --git a/simulat0r/gui/simulat0rthread.h b/simulat0r/gui/simulat0rthread.h new file mode 100644 index 0000000..9e54692 --- /dev/null +++ b/simulat0r/gui/simulat0rthread.h @@ -0,0 +1,17 @@ +#ifndef SIMULAT0RTHREAD_H +#define SIMULAT0RTHREAD_H + +#include +#include + +class Simulat0rThread : public QThread +{ + long loop; + // Q_OBJECT + + protected: + virtual ~Simulat0rThread(); + virtual void run(); +}; + +#endif diff --git a/simulat0r/simcore/Makefile b/simulat0r/simcore/Makefile new file mode 100644 index 0000000..3fc4357 --- /dev/null +++ b/simulat0r/simcore/Makefile @@ -0,0 +1,19 @@ + + +CFLAGS += -std=gnu99 +CFLAGS += -I../firmware +CFLAGS += -I../firmware/core # for gpio.h including projectconfig.h without path +CFLAGS += -I../simcore + +OBJS+= ../firmware/basic/*.o +OBJS+= ../firmware/core/*.o +OBJS+= ../firmware/core/*/*.o +LDFLAGS+= -L../firmware/applications +LIBS+= ../firmware/applications/libapp.a +LDFLAGS+= -L../firmware/lcd +LIBS+= ../firmware/lcd/liblcd.a +LDFLAGS+= -L../firmware/usb +LIBS+= ../firmware/usb/libusb.a + +.PHONY : all +all : simcore.o misc.o #$(OBJS) $(LIBS) diff --git a/simulat0r/simcore/misc.c b/simulat0r/simcore/misc.c new file mode 100644 index 0000000..b006768 --- /dev/null +++ b/simulat0r/simcore/misc.c @@ -0,0 +1,8 @@ +int crc16(int x) { +} + +void __disable_irq() { +} + +void __enable_irq() { +} diff --git a/simulat0r/simcore/simcore.c b/simulat0r/simcore/simcore.c new file mode 100644 index 0000000..937260c --- /dev/null +++ b/simulat0r/simcore/simcore.c @@ -0,0 +1,42 @@ + +#include "core/sysinit.h" + +#include "basic/basic.h" + +#include "lcd/render.h" + +#include "pmu/pmu.h" + +void ReinvokeISP(void); + +/**************************************************************************/ + +void wrapper(void); + +int simulator_main(void) { + + // Configure cpu and mandatory peripherals + systemInit(); + + // initialise basic badge functions + rbInit(); + + lcdInit(); // display + + lcdFill(0); + lcdDisplay(); + + wrapper(); // see module/ subdirectory +} + +static uint32_t ledstate[4]; + +int simGetLED(int led) { + return ledstate[led]; +} + +void simSetLED(int led,uint32_t bitVal) { + ledstate[led]=bitVal; + simSetLEDHook(led); +} + diff --git a/simulat0r/simcore/simulator.h b/simulat0r/simcore/simulator.h new file mode 100644 index 0000000..5d85dec --- /dev/null +++ b/simulat0r/simcore/simulator.h @@ -0,0 +1,20 @@ +#ifndef SIMULATOR_H +#define SIMULATOR_H + +#include + +void simlcdPrepareUpdate(); +void simlcdWrite(int ignored, int bit); +void simlcdLineFeed(); +void simlcdCompleteUpdate(); + +int simButtonPressed(int button); + +int simGetLED(int led); +void simSetLED(int led,uint32_t bitVal); +void simSetLEDHook(int led); + + +int simulator_main(void); + +#endif diff --git a/simulat0r/tui/Makefile b/simulat0r/tui/Makefile new file mode 100644 index 0000000..194bae0 --- /dev/null +++ b/simulat0r/tui/Makefile @@ -0,0 +1,30 @@ +ROOT_PATH=../firmware +include ../firmware/Makefile.inc + +CFLAGS += -std=gnu99 +CFLAGS += -I../firmware +CFLAGS += -I../firmware/core # for gpio.h including projectconfig.h without path +CFLAGS += -I../simcore + +OBJS+= ../firmware/basic/*.o +OBJS+= ../firmware/core/*.o +OBJS+= ../firmware/core/*/*.o +LDFLAGS+= -L../firmware/applications +LIBS+= ../firmware/applications/libapp.a +LDFLAGS+= -L../firmware/lcd +LIBS+= ../firmware/lcd/liblcd.a +LDFLAGS+= -L../firmware/usb +LIBS+= ../firmware/usb/libusb.a + +#LIBS += -lm +LIBS += ../firmware/filesystem/libfat.a +LIBS += ../firmware/core/libcore.a + + +OBJS+=../simcore/simcore.o ../simcore/misc.o + +.PHONY : all +all : simulat0r + +simulat0r : simulat0r.o $(OBJS) $(LIBS) + diff --git a/simulat0r/tui/simulat0r.c b/simulat0r/tui/simulat0r.c new file mode 100644 index 0000000..526a3c2 --- /dev/null +++ b/simulat0r/tui/simulat0r.c @@ -0,0 +1,32 @@ +#include "simulator.h" +#include "../firmware/lcd/display.h" + +#include + +extern int lcd_layout; + +void simlcdDisplayUpdate() { + write(1,"\033[H",3); + for(int y=0; y