From 3edfff8d593927e367e9707b80f3dc066295b01b Mon Sep 17 00:00:00 2001 From: bernd Date: Tue, 19 Jul 2011 08:30:57 +0200 Subject: [PATCH 01/24] Wrapped ARM specific code with #ifdef ARM because of simulat0r --- firmware/applications/iggy.c | 2 ++ firmware/core/lpc134x.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/firmware/applications/iggy.c b/firmware/applications/iggy.c index 539299d..97b03b4 100644 --- a/firmware/applications/iggy.c +++ b/firmware/applications/iggy.c @@ -142,7 +142,9 @@ void main_iggy(void) { gpioSetValue (RB_LCD_BL, 0); SCB_SCR |= SCB_SCR_SLEEPDEEP; PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN; +#ifdef ARM __asm volatile ("WFI"); +#endif }else{ //DoString(0,yctr+30,"OK "); ; diff --git a/firmware/core/lpc134x.h b/firmware/core/lpc134x.h index 80b38ec..5a7332e 100644 --- a/firmware/core/lpc134x.h +++ b/firmware/core/lpc134x.h @@ -1937,8 +1937,13 @@ typedef struct #define NVIC ((NVIC_Type *) NVIC_BASE_ADDRESS) +#ifdef ARM static inline void __enable_irq() { __asm volatile ("cpsie i"); } static inline void __disable_irq() { __asm volatile ("cpsid i"); } +#else +void __enable_irq(); +void __disable_irq(); +#endif typedef enum IRQn { From c5e8b92c4aed1b60b7750b8429fde1573bbb3696 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 19 Jul 2011 09:59:16 +0200 Subject: [PATCH 02/24] Rename key to openbeaconkey to reduce global namespace pollution --- firmware/funk/openbeacon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/funk/openbeacon.c b/firmware/funk/openbeacon.c index 4c1810b..2b919bf 100644 --- a/firmware/funk/openbeacon.c +++ b/firmware/funk/openbeacon.c @@ -6,7 +6,7 @@ #include "filesystem/ff.h" //const uint32_t key[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; -const uint32_t key[4] = { 0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E }; +const uint32_t openbeaconkey[4] = { 0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E }; const uint8_t useencryption = 1; const uint8_t mac[5] = {1,2,3,2,1}; @@ -83,7 +83,7 @@ uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq, buf[12]=0xff; // salt (0xffff always?) buf[13]=0xff; - return nrf_snd_pkt_crc_encr(16,buf,useencryption?key:NULL); + return nrf_snd_pkt_crc_encr(16,buf,useencryption?openbeaconkey:NULL); } uint8_t openbeaconSend(void) From 6a8da5427472cd866c564fa0586b36a0ebb1111a Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 19 Jul 2011 10:01:00 +0200 Subject: [PATCH 03/24] Add APP=loadable, simple loadable module wrapper to run them as app. Build with "make APP=loadable LAPP=spaceinvaders" --- firmware/applications/Makefile | 7 +++ firmware/applications/loadable.c | 78 ++++++++++++++++++++++++++++++++ firmware/applications/mkwrapper | 6 +++ 3 files changed, 91 insertions(+) create mode 100644 firmware/applications/loadable.c diff --git a/firmware/applications/Makefile b/firmware/applications/Makefile index 6d034d3..50b0058 100644 --- a/firmware/applications/Makefile +++ b/firmware/applications/Makefile @@ -21,6 +21,13 @@ endif OBJS += $(ME_OBJ).o endif +ifeq "$(APP)" "loadable" +ifndef LAPP +LAPP=blinktest +endif +OBJS += ../loadable/$(LAPP).o +endif + WRAP=wrapper LIBNAME=app diff --git a/firmware/applications/loadable.c b/firmware/applications/loadable.c new file mode 100644 index 0000000..63ec6cb --- /dev/null +++ b/firmware/applications/loadable.c @@ -0,0 +1,78 @@ +#include +#include + +#include "basic/basic.h" +#include "lcd/lcd.h" +#include "lcd/print.h" +#include "usb/usbmsc.h" + +/**************************************************************************/ +void gotoISP(void) { + DoString(0,0,"Enter ISP!"); + lcdDisplay(); + ISPandReset(); +} + +void lcd_mirror(void) { + lcdToggleFlag(LCD_MIRRORX); +}; + +void lcd_invert(void) { + lcdToggleFlag(LCD_INVERTED); +}; + +void adc_check(void) { + int dx=0; + int dy=8; + // Print Voltage + dx=DoString(0,dy,"Voltage:"); + while ((getInputRaw())==BTN_NONE){ + DoInt(dx,dy,GetVoltage()); + lcdDisplay(); + }; + dy+=8; + dx=DoString(0,dy,"Done."); +}; + +void msc_menu(void){ + DoString(0,8,"MSC Enabled."); + lcdDisplay(); + usbMSCInit(); + while(!getInputRaw())delayms(10); + DoString(0,16,"MSC Disabled."); + usbMSCOff(); +}; + +extern void (*ram)(void); + +const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP}; +const struct MENU_DEF menu_again = {"Run Loadable", &ram}; +const struct MENU_DEF menu_nop = {"---", NULL}; +const struct MENU_DEF menu_msc = {"MSC", &msc_menu}; +const struct MENU_DEF menu_volt = {"Akku", &adc_check}; +const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror}; +const struct MENU_DEF menu_invert = {"Invert", &lcd_invert}; + +static menuentry menu[] = { + &menu_again, + &menu_ISP, + &menu_nop, + &menu_msc, + &menu_mirror, + &menu_invert, + &menu_volt, + NULL, +}; + +static const struct MENU mainmenu = {"Mainmenu", menu}; + + +/**************************************************************************/ + +void main_loadable(void) { + + lcdFill(0); // clear display buffer + lcdDisplay(); + handleMenu(&mainmenu); + gotoISP(); +}; diff --git a/firmware/applications/mkwrapper b/firmware/applications/mkwrapper index 50224fc..174a124 100755 --- a/firmware/applications/mkwrapper +++ b/firmware/applications/mkwrapper @@ -1,6 +1,9 @@ #!/bin/sh for a in $* ; do + case $a in + */*) continue;; + esac base=${a%.o} echo "void main_$base(void);" echo "void tick_$base(void);" @@ -10,6 +13,9 @@ echo echo "void wrapper(void){" for a in $* ; do + case $a in + */*) continue;; + esac base=${a%.o} echo "main_$base();" done From 20d9fee4318089dd1cbe8775565bfd2b5be43e96 Mon Sep 17 00:00:00 2001 From: bernd Date: Tue, 19 Jul 2011 10:09:03 +0200 Subject: [PATCH 04/24] Added simulat0r --- simulat0r/Makefile | 27 ++ simulat0r/bin/update-bridge-files.sh | 27 ++ simulat0r/firmware/Makefile | 108 ++++++++ simulat0r/firmware/Makefile.inc | 46 ++++ simulat0r/firmware/Makefile.util | 1 + simulat0r/firmware/applications/Makefile | 66 +++++ simulat0r/firmware/applications/adc.c | 2 + simulat0r/firmware/applications/bsx.c | 2 + simulat0r/firmware/applications/cdc.c | 2 + simulat0r/firmware/applications/default.c | 12 + simulat0r/firmware/applications/ecc.c | 2 + simulat0r/firmware/applications/exe.c | 2 + simulat0r/firmware/applications/executor.c | 2 + simulat0r/firmware/applications/font.c | 2 + simulat0r/firmware/applications/fs.c | 2 + simulat0r/firmware/applications/funk.c | 2 + simulat0r/firmware/applications/iggy.c | 2 + simulat0r/firmware/applications/life.c | 1 + simulat0r/firmware/applications/lilafisch.c | 2 + simulat0r/firmware/applications/mandelbrot.c | 2 + simulat0r/firmware/applications/mandelbrot2.c | 2 + simulat0r/firmware/applications/menutest.c | 2 + simulat0r/firmware/applications/minimal.c | 2 + simulat0r/firmware/applications/rect.c | 1 + simulat0r/firmware/applications/remote.c | 2 + simulat0r/firmware/applications/s.c | 2 + simulat0r/firmware/applications/schneider.c | 2 + simulat0r/firmware/applications/scroll.c | 2 + simulat0r/firmware/applications/sec.c | 2 + .../firmware/applications/spaceinvaders.c | 2 + simulat0r/firmware/applications/vcard.c | 2 + simulat0r/firmware/applications/waldbrand.c | 1 + simulat0r/firmware/basic/basic.c | 2 + simulat0r/firmware/basic/basic.h | 2 + simulat0r/firmware/basic/byteorder.c | 2 + simulat0r/firmware/basic/byteorder.h | 2 + simulat0r/firmware/basic/crc.c | 2 + simulat0r/firmware/basic/delayms.c | 2 + simulat0r/firmware/basic/ecc.c | 2 + simulat0r/firmware/basic/ecc.h | 2 + simulat0r/firmware/basic/keyin.c | 2 + simulat0r/firmware/basic/menu.c | 2 + simulat0r/firmware/basic/reinvoke_isp.c | 12 + simulat0r/firmware/basic/uuid.c | 2 + simulat0r/firmware/basic/voltage.c | 12 + simulat0r/firmware/basic/xxtea.c | 2 + simulat0r/firmware/basic/xxtea.h | 2 + simulat0r/firmware/core/Makefile | 56 +++++ simulat0r/firmware/core/adc/adc.c | 2 + simulat0r/firmware/core/adc/adc.h | 2 + simulat0r/firmware/core/cmd/cmd.c | 2 + simulat0r/firmware/core/cmd/cmd.h | 2 + simulat0r/firmware/core/cpu/cpu.c | 2 + simulat0r/firmware/core/cpu/cpu.h | 2 + simulat0r/firmware/core/gpio/gpio.c | 65 +++++ simulat0r/firmware/core/gpio/gpio.h | 2 + simulat0r/firmware/core/i2c/i2c.c | 2 + simulat0r/firmware/core/i2c/i2c.h | 2 + simulat0r/firmware/core/iap/iap.c | 2 + simulat0r/firmware/core/iap/iap.h | 2 + simulat0r/firmware/core/libc/ctype.c | 2 + simulat0r/firmware/core/libc/stdio.c | 2 + simulat0r/firmware/core/libc/string.c | 2 + simulat0r/firmware/core/lpc134x.h | 2 + simulat0r/firmware/core/pmu/pmu.c | 2 + simulat0r/firmware/core/pmu/pmu.h | 2 + simulat0r/firmware/core/projectconfig.h | 2 + simulat0r/firmware/core/pwm/pwm.c | 2 + simulat0r/firmware/core/pwm/pwm.h | 2 + simulat0r/firmware/core/rom_drivers.h | 2 + simulat0r/firmware/core/ssp/ssp.c | 23 ++ simulat0r/firmware/core/ssp/ssp.h | 2 + simulat0r/firmware/core/sysdefs.h | 2 + simulat0r/firmware/core/sysinit.c | 83 +++++++ simulat0r/firmware/core/sysinit.h | 2 + simulat0r/firmware/core/systick/systick.c | 231 ++++++++++++++++++ simulat0r/firmware/core/systick/systick.h | 2 + simulat0r/firmware/core/timer16/timer16.c | 2 + simulat0r/firmware/core/timer16/timer16.h | 2 + simulat0r/firmware/core/timer32/timer32.c | 2 + simulat0r/firmware/core/timer32/timer32.h | 2 + simulat0r/firmware/core/uart/uart.c | 2 + simulat0r/firmware/core/uart/uart.h | 2 + simulat0r/firmware/core/uart/uart_buf.c | 2 + simulat0r/firmware/core/usbcdc/cdc.h | 2 + simulat0r/firmware/core/usbcdc/cdc_buf.c | 2 + simulat0r/firmware/core/usbcdc/cdc_buf.h | 2 + simulat0r/firmware/core/usbcdc/cdcuser.c | 2 + simulat0r/firmware/core/usbcdc/cdcuser.h | 2 + simulat0r/firmware/core/usbcdc/config.h | 2 + simulat0r/firmware/core/usbcdc/usb.h | 2 + simulat0r/firmware/core/usbcdc/usbcfg.h | 2 + simulat0r/firmware/core/usbcdc/usbcore.c | 2 + simulat0r/firmware/core/usbcdc/usbcore.h | 2 + simulat0r/firmware/core/usbcdc/usbdesc.c | 2 + simulat0r/firmware/core/usbcdc/usbdesc.h | 2 + simulat0r/firmware/core/usbcdc/usbhw.c | 2 + simulat0r/firmware/core/usbcdc/usbhw.h | 2 + simulat0r/firmware/core/usbcdc/usbreg.h | 2 + simulat0r/firmware/core/usbcdc/usbuser.c | 2 + simulat0r/firmware/core/usbcdc/usbuser.h | 2 + simulat0r/firmware/core/wdt/wdt.c | 2 + simulat0r/firmware/core/wdt/wdt.h | 2 + simulat0r/firmware/filesystem/Makefile | 30 +++ simulat0r/firmware/filesystem/at45db041d.c | 2 + simulat0r/firmware/filesystem/at45db041d.h | 2 + simulat0r/firmware/filesystem/diskio.c | 2 + simulat0r/firmware/filesystem/diskio.h | 2 + simulat0r/firmware/filesystem/execute.c | 12 + simulat0r/firmware/filesystem/execute.h | 2 + simulat0r/firmware/filesystem/ff.c | 2 + simulat0r/firmware/filesystem/ff.h | 2 + simulat0r/firmware/filesystem/ffconf.h | 2 + simulat0r/firmware/filesystem/integer.h | 2 + simulat0r/firmware/filesystem/iobase.c | 2 + simulat0r/firmware/filesystem/iobase.h | 2 + simulat0r/firmware/filesystem/mmc.c | 2 + simulat0r/firmware/filesystem/mmc.h | 2 + simulat0r/firmware/filesystem/select.c | 2 + simulat0r/firmware/filesystem/select.h | 2 + simulat0r/firmware/filesystem/util.c | 2 + simulat0r/firmware/funk/Makefile | 25 ++ simulat0r/firmware/funk/filetransfer.c | 2 + simulat0r/firmware/funk/filetransfer.h | 2 + simulat0r/firmware/funk/nrf24l01p.c | 2 + simulat0r/firmware/funk/nrf24l01p.h | 2 + simulat0r/firmware/funk/openbeacon.c | 2 + simulat0r/firmware/funk/openbeacon.h | 2 + simulat0r/firmware/funk/rftransfer.c | 2 + simulat0r/firmware/funk/rftransfer.h | 2 + simulat0r/firmware/lcd/Makefile | 45 ++++ simulat0r/firmware/lcd/backlight.c | 20 ++ simulat0r/firmware/lcd/backlight.h | 2 + simulat0r/firmware/lcd/decoder.c | 2 + simulat0r/firmware/lcd/decoder.h | 2 + simulat0r/firmware/lcd/display.c | 56 +++++ simulat0r/firmware/lcd/display.h | 2 + simulat0r/firmware/lcd/fonts.h | 2 + simulat0r/firmware/lcd/fonts/invaders.c | 2 + simulat0r/firmware/lcd/fonts/invaders.h | 2 + simulat0r/firmware/lcd/fonts/orbitron14.c | 2 + simulat0r/firmware/lcd/fonts/orbitron14.h | 2 + simulat0r/firmware/lcd/fonts/smallfonts.c | 2 + simulat0r/firmware/lcd/fonts/smallfonts.h | 2 + simulat0r/firmware/lcd/fonts/ubuntu18.c | 2 + simulat0r/firmware/lcd/fonts/ubuntu18.h | 2 + simulat0r/firmware/lcd/fonts/ubuntu29.c | 2 + simulat0r/firmware/lcd/fonts/ubuntu29.h | 2 + simulat0r/firmware/lcd/fonts/ubuntu36.c | 2 + simulat0r/firmware/lcd/fonts/ubuntu36.h | 2 + simulat0r/firmware/lcd/lcd.h | 2 + simulat0r/firmware/lcd/print.c | 2 + simulat0r/firmware/lcd/print.h | 2 + simulat0r/firmware/lcd/render.c | 2 + simulat0r/firmware/lcd/render.h | 8 + simulat0r/firmware/libc-unc0llide.h | 50 ++++ simulat0r/firmware/loadable/Makefile | 12 + simulat0r/firmware/loadable/Makefile.sub | 57 +++++ simulat0r/firmware/loadable/blinktest.c | 2 + simulat0r/firmware/loadable/blinktest2.c | 2 + simulat0r/firmware/loadable/spaceinvaders.c | 2 + simulat0r/firmware/lpc1xxx/LPC11xx_handlers.c | 2 + simulat0r/firmware/lpc1xxx/LPC13xx_handlers.c | 3 + simulat0r/firmware/lpc1xxx/LPC1xxx_startup.c | 2 + simulat0r/firmware/main.c | 2 + simulat0r/firmware/sysdefs.h | 2 + simulat0r/firmware/usb/Makefile | 36 +++ simulat0r/firmware/usb/usb.h | 2 + simulat0r/firmware/usb/usbconfig.c | 2 + simulat0r/firmware/usb/usbconfig.h | 2 + simulat0r/firmware/usb/usbhid.c | 2 + simulat0r/firmware/usb/usbhid.h | 2 + simulat0r/firmware/usb/usbmsc.c | 2 + simulat0r/firmware/usb/usbmsc.h | 2 + simulat0r/firmware/usbcdc/cdc.h | 2 + simulat0r/firmware/usbcdc/cdc_buf.c | 2 + simulat0r/firmware/usbcdc/cdc_buf.h | 2 + simulat0r/firmware/usbcdc/cdcuser.c | 2 + simulat0r/firmware/usbcdc/cdcuser.h | 2 + simulat0r/firmware/usbcdc/config.h | 2 + simulat0r/firmware/usbcdc/usb.h | 2 + simulat0r/firmware/usbcdc/usbcfg.h | 2 + simulat0r/firmware/usbcdc/usbcore.c | 2 + simulat0r/firmware/usbcdc/usbcore.h | 2 + simulat0r/firmware/usbcdc/usbdesc.c | 2 + simulat0r/firmware/usbcdc/usbdesc.h | 2 + simulat0r/firmware/usbcdc/usbhw.c | 2 + simulat0r/firmware/usbcdc/usbhw.h | 2 + simulat0r/firmware/usbcdc/usbreg.h | 2 + simulat0r/firmware/usbcdc/usbuser.c | 2 + simulat0r/firmware/usbcdc/usbuser.h | 2 + simulat0r/gui/CMakeLists.txt | 68 ++++++ simulat0r/gui/qsimulat0r.cc | 194 +++++++++++++++ simulat0r/gui/simulat0rthread.cc | 19 ++ simulat0r/gui/simulat0rthread.h | 17 ++ simulat0r/simcore/Makefile | 19 ++ simulat0r/simcore/misc.c | 8 + simulat0r/simcore/simcore.c | 42 ++++ simulat0r/simcore/simulator.h | 20 ++ simulat0r/tui/Makefile | 30 +++ simulat0r/tui/simulat0r.c | 32 +++ 201 files changed, 1899 insertions(+) create mode 100644 simulat0r/Makefile create mode 100755 simulat0r/bin/update-bridge-files.sh create mode 100644 simulat0r/firmware/Makefile create mode 100644 simulat0r/firmware/Makefile.inc create mode 100644 simulat0r/firmware/Makefile.util create mode 100644 simulat0r/firmware/applications/Makefile create mode 100644 simulat0r/firmware/applications/adc.c create mode 100644 simulat0r/firmware/applications/bsx.c create mode 100644 simulat0r/firmware/applications/cdc.c create mode 100644 simulat0r/firmware/applications/default.c create mode 100644 simulat0r/firmware/applications/ecc.c create mode 100644 simulat0r/firmware/applications/exe.c create mode 100644 simulat0r/firmware/applications/executor.c create mode 100644 simulat0r/firmware/applications/font.c create mode 100644 simulat0r/firmware/applications/fs.c create mode 100644 simulat0r/firmware/applications/funk.c create mode 100644 simulat0r/firmware/applications/iggy.c create mode 100644 simulat0r/firmware/applications/life.c create mode 100644 simulat0r/firmware/applications/lilafisch.c create mode 100644 simulat0r/firmware/applications/mandelbrot.c create mode 100644 simulat0r/firmware/applications/mandelbrot2.c create mode 100644 simulat0r/firmware/applications/menutest.c create mode 100644 simulat0r/firmware/applications/minimal.c create mode 100644 simulat0r/firmware/applications/rect.c create mode 100644 simulat0r/firmware/applications/remote.c create mode 100644 simulat0r/firmware/applications/s.c create mode 100644 simulat0r/firmware/applications/schneider.c create mode 100644 simulat0r/firmware/applications/scroll.c create mode 100644 simulat0r/firmware/applications/sec.c create mode 100644 simulat0r/firmware/applications/spaceinvaders.c create mode 100644 simulat0r/firmware/applications/vcard.c create mode 100644 simulat0r/firmware/applications/waldbrand.c create mode 100644 simulat0r/firmware/basic/basic.c create mode 100644 simulat0r/firmware/basic/basic.h create mode 100644 simulat0r/firmware/basic/byteorder.c create mode 100644 simulat0r/firmware/basic/byteorder.h create mode 100644 simulat0r/firmware/basic/crc.c create mode 100644 simulat0r/firmware/basic/delayms.c create mode 100644 simulat0r/firmware/basic/ecc.c create mode 100644 simulat0r/firmware/basic/ecc.h create mode 100644 simulat0r/firmware/basic/keyin.c create mode 100644 simulat0r/firmware/basic/menu.c create mode 100644 simulat0r/firmware/basic/reinvoke_isp.c create mode 100644 simulat0r/firmware/basic/uuid.c create mode 100644 simulat0r/firmware/basic/voltage.c create mode 100644 simulat0r/firmware/basic/xxtea.c create mode 100644 simulat0r/firmware/basic/xxtea.h create mode 100644 simulat0r/firmware/core/Makefile create mode 100644 simulat0r/firmware/core/adc/adc.c create mode 100644 simulat0r/firmware/core/adc/adc.h create mode 100644 simulat0r/firmware/core/cmd/cmd.c create mode 100644 simulat0r/firmware/core/cmd/cmd.h create mode 100644 simulat0r/firmware/core/cpu/cpu.c create mode 100644 simulat0r/firmware/core/cpu/cpu.h create mode 100644 simulat0r/firmware/core/gpio/gpio.c create mode 100644 simulat0r/firmware/core/gpio/gpio.h create mode 100644 simulat0r/firmware/core/i2c/i2c.c create mode 100644 simulat0r/firmware/core/i2c/i2c.h create mode 100644 simulat0r/firmware/core/iap/iap.c create mode 100644 simulat0r/firmware/core/iap/iap.h create mode 100644 simulat0r/firmware/core/libc/ctype.c create mode 100644 simulat0r/firmware/core/libc/stdio.c create mode 100644 simulat0r/firmware/core/libc/string.c create mode 100644 simulat0r/firmware/core/lpc134x.h create mode 100644 simulat0r/firmware/core/pmu/pmu.c create mode 100644 simulat0r/firmware/core/pmu/pmu.h create mode 100644 simulat0r/firmware/core/projectconfig.h create mode 100644 simulat0r/firmware/core/pwm/pwm.c create mode 100644 simulat0r/firmware/core/pwm/pwm.h create mode 100644 simulat0r/firmware/core/rom_drivers.h create mode 100644 simulat0r/firmware/core/ssp/ssp.c create mode 100644 simulat0r/firmware/core/ssp/ssp.h create mode 100644 simulat0r/firmware/core/sysdefs.h create mode 100644 simulat0r/firmware/core/sysinit.c create mode 100644 simulat0r/firmware/core/sysinit.h create mode 100644 simulat0r/firmware/core/systick/systick.c create mode 100644 simulat0r/firmware/core/systick/systick.h create mode 100644 simulat0r/firmware/core/timer16/timer16.c create mode 100644 simulat0r/firmware/core/timer16/timer16.h create mode 100644 simulat0r/firmware/core/timer32/timer32.c create mode 100644 simulat0r/firmware/core/timer32/timer32.h create mode 100644 simulat0r/firmware/core/uart/uart.c create mode 100644 simulat0r/firmware/core/uart/uart.h create mode 100644 simulat0r/firmware/core/uart/uart_buf.c create mode 100644 simulat0r/firmware/core/usbcdc/cdc.h create mode 100644 simulat0r/firmware/core/usbcdc/cdc_buf.c create mode 100644 simulat0r/firmware/core/usbcdc/cdc_buf.h create mode 100644 simulat0r/firmware/core/usbcdc/cdcuser.c create mode 100644 simulat0r/firmware/core/usbcdc/cdcuser.h create mode 100644 simulat0r/firmware/core/usbcdc/config.h create mode 100644 simulat0r/firmware/core/usbcdc/usb.h create mode 100644 simulat0r/firmware/core/usbcdc/usbcfg.h create mode 100644 simulat0r/firmware/core/usbcdc/usbcore.c create mode 100644 simulat0r/firmware/core/usbcdc/usbcore.h create mode 100644 simulat0r/firmware/core/usbcdc/usbdesc.c create mode 100644 simulat0r/firmware/core/usbcdc/usbdesc.h create mode 100644 simulat0r/firmware/core/usbcdc/usbhw.c create mode 100644 simulat0r/firmware/core/usbcdc/usbhw.h create mode 100644 simulat0r/firmware/core/usbcdc/usbreg.h create mode 100644 simulat0r/firmware/core/usbcdc/usbuser.c create mode 100644 simulat0r/firmware/core/usbcdc/usbuser.h create mode 100644 simulat0r/firmware/core/wdt/wdt.c create mode 100644 simulat0r/firmware/core/wdt/wdt.h create mode 100644 simulat0r/firmware/filesystem/Makefile create mode 100644 simulat0r/firmware/filesystem/at45db041d.c create mode 100644 simulat0r/firmware/filesystem/at45db041d.h create mode 100644 simulat0r/firmware/filesystem/diskio.c create mode 100644 simulat0r/firmware/filesystem/diskio.h create mode 100644 simulat0r/firmware/filesystem/execute.c create mode 100644 simulat0r/firmware/filesystem/execute.h create mode 100644 simulat0r/firmware/filesystem/ff.c create mode 100644 simulat0r/firmware/filesystem/ff.h create mode 100644 simulat0r/firmware/filesystem/ffconf.h create mode 100644 simulat0r/firmware/filesystem/integer.h create mode 100644 simulat0r/firmware/filesystem/iobase.c create mode 100644 simulat0r/firmware/filesystem/iobase.h create mode 100644 simulat0r/firmware/filesystem/mmc.c create mode 100644 simulat0r/firmware/filesystem/mmc.h create mode 100644 simulat0r/firmware/filesystem/select.c create mode 100644 simulat0r/firmware/filesystem/select.h create mode 100644 simulat0r/firmware/filesystem/util.c create mode 100644 simulat0r/firmware/funk/Makefile create mode 100644 simulat0r/firmware/funk/filetransfer.c create mode 100644 simulat0r/firmware/funk/filetransfer.h create mode 100644 simulat0r/firmware/funk/nrf24l01p.c create mode 100644 simulat0r/firmware/funk/nrf24l01p.h create mode 100644 simulat0r/firmware/funk/openbeacon.c create mode 100644 simulat0r/firmware/funk/openbeacon.h create mode 100644 simulat0r/firmware/funk/rftransfer.c create mode 100644 simulat0r/firmware/funk/rftransfer.h create mode 100644 simulat0r/firmware/lcd/Makefile create mode 100644 simulat0r/firmware/lcd/backlight.c create mode 100644 simulat0r/firmware/lcd/backlight.h create mode 100644 simulat0r/firmware/lcd/decoder.c create mode 100644 simulat0r/firmware/lcd/decoder.h create mode 100644 simulat0r/firmware/lcd/display.c create mode 100644 simulat0r/firmware/lcd/display.h create mode 100644 simulat0r/firmware/lcd/fonts.h create mode 100644 simulat0r/firmware/lcd/fonts/invaders.c create mode 100644 simulat0r/firmware/lcd/fonts/invaders.h create mode 100644 simulat0r/firmware/lcd/fonts/orbitron14.c create mode 100644 simulat0r/firmware/lcd/fonts/orbitron14.h create mode 100644 simulat0r/firmware/lcd/fonts/smallfonts.c create mode 100644 simulat0r/firmware/lcd/fonts/smallfonts.h create mode 100644 simulat0r/firmware/lcd/fonts/ubuntu18.c create mode 100644 simulat0r/firmware/lcd/fonts/ubuntu18.h create mode 100644 simulat0r/firmware/lcd/fonts/ubuntu29.c create mode 100644 simulat0r/firmware/lcd/fonts/ubuntu29.h create mode 100644 simulat0r/firmware/lcd/fonts/ubuntu36.c create mode 100644 simulat0r/firmware/lcd/fonts/ubuntu36.h create mode 100644 simulat0r/firmware/lcd/lcd.h create mode 100644 simulat0r/firmware/lcd/print.c create mode 100644 simulat0r/firmware/lcd/print.h create mode 100644 simulat0r/firmware/lcd/render.c create mode 100644 simulat0r/firmware/lcd/render.h create mode 100644 simulat0r/firmware/libc-unc0llide.h create mode 100644 simulat0r/firmware/loadable/Makefile create mode 100644 simulat0r/firmware/loadable/Makefile.sub create mode 100644 simulat0r/firmware/loadable/blinktest.c create mode 100644 simulat0r/firmware/loadable/blinktest2.c create mode 100644 simulat0r/firmware/loadable/spaceinvaders.c create mode 100644 simulat0r/firmware/lpc1xxx/LPC11xx_handlers.c create mode 100644 simulat0r/firmware/lpc1xxx/LPC13xx_handlers.c create mode 100644 simulat0r/firmware/lpc1xxx/LPC1xxx_startup.c create mode 100644 simulat0r/firmware/main.c create mode 100644 simulat0r/firmware/sysdefs.h create mode 100644 simulat0r/firmware/usb/Makefile create mode 100644 simulat0r/firmware/usb/usb.h create mode 100644 simulat0r/firmware/usb/usbconfig.c create mode 100644 simulat0r/firmware/usb/usbconfig.h create mode 100644 simulat0r/firmware/usb/usbhid.c create mode 100644 simulat0r/firmware/usb/usbhid.h create mode 100644 simulat0r/firmware/usb/usbmsc.c create mode 100644 simulat0r/firmware/usb/usbmsc.h create mode 100644 simulat0r/firmware/usbcdc/cdc.h create mode 100644 simulat0r/firmware/usbcdc/cdc_buf.c create mode 100644 simulat0r/firmware/usbcdc/cdc_buf.h create mode 100644 simulat0r/firmware/usbcdc/cdcuser.c create mode 100644 simulat0r/firmware/usbcdc/cdcuser.h create mode 100644 simulat0r/firmware/usbcdc/config.h create mode 100644 simulat0r/firmware/usbcdc/usb.h create mode 100644 simulat0r/firmware/usbcdc/usbcfg.h create mode 100644 simulat0r/firmware/usbcdc/usbcore.c create mode 100644 simulat0r/firmware/usbcdc/usbcore.h create mode 100644 simulat0r/firmware/usbcdc/usbdesc.c create mode 100644 simulat0r/firmware/usbcdc/usbdesc.h create mode 100644 simulat0r/firmware/usbcdc/usbhw.c create mode 100644 simulat0r/firmware/usbcdc/usbhw.h create mode 100644 simulat0r/firmware/usbcdc/usbreg.h create mode 100644 simulat0r/firmware/usbcdc/usbuser.c create mode 100644 simulat0r/firmware/usbcdc/usbuser.h create mode 100644 simulat0r/gui/CMakeLists.txt create mode 100644 simulat0r/gui/qsimulat0r.cc create mode 100644 simulat0r/gui/simulat0rthread.cc create mode 100644 simulat0r/gui/simulat0rthread.h create mode 100644 simulat0r/simcore/Makefile create mode 100644 simulat0r/simcore/misc.c create mode 100644 simulat0r/simcore/simcore.c create mode 100644 simulat0r/simcore/simulator.h create mode 100644 simulat0r/tui/Makefile create mode 100644 simulat0r/tui/simulat0r.c 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 Date: Tue, 19 Jul 2011 10:11:07 +0200 Subject: [PATCH 05/24] Added mkwrapper for simulat0r --- simulat0r/firmware/applications/mkwrapper | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 simulat0r/firmware/applications/mkwrapper diff --git a/simulat0r/firmware/applications/mkwrapper b/simulat0r/firmware/applications/mkwrapper new file mode 100755 index 0000000..adc805d --- /dev/null +++ b/simulat0r/firmware/applications/mkwrapper @@ -0,0 +1,2 @@ +#!/bin/sh +. ../../../firmware/applications/mkwrapper From 18dc47fa2bee0e5ae87463f5891b79e8b30f257f Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 19 Jul 2011 10:14:54 +0200 Subject: [PATCH 06/24] Fix dependecies and building for APP=loadable --- firmware/applications/Makefile | 23 ++++++++++++++++------- firmware/applications/mkwrapper | 7 +++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/firmware/applications/Makefile b/firmware/applications/Makefile index 50b0058..25a35c4 100644 --- a/firmware/applications/Makefile +++ b/firmware/applications/Makefile @@ -21,13 +21,6 @@ endif OBJS += $(ME_OBJ).o endif -ifeq "$(APP)" "loadable" -ifndef LAPP -LAPP=blinktest -endif -OBJS += ../loadable/$(LAPP).o -endif - WRAP=wrapper LIBNAME=app @@ -49,6 +42,22 @@ LIBFILE=lib$(LIBNAME).a all: $(LIBFILE) +ifeq "$(APP)" "loadable" +ifndef LAPP +LAPP=blinktest +endif +LSRC=../loadable/$(LAPP).c +LOBJ=loadable_$(LAPP).o + +.PHONY: $(LOBJ) + +$(LOBJ): + $(CC) $(CFLAGS) -o $@ $(LSRC) + $(RM) $(LIBFILE) + +OBJS += $(LOBJ) +endif + $(LIBFILE): $(OBJS) $(WRAPOBJ) $(AR) rcs $@ $(OBJS) $(WRAPOBJ) diff --git a/firmware/applications/mkwrapper b/firmware/applications/mkwrapper index 174a124..26830e1 100755 --- a/firmware/applications/mkwrapper +++ b/firmware/applications/mkwrapper @@ -2,7 +2,7 @@ for a in $* ; do case $a in - */*) continue;; + loadable_*) continue;; esac base=${a%.o} echo "void main_$base(void);" @@ -14,7 +14,7 @@ echo "void wrapper(void){" for a in $* ; do case $a in - */*) continue;; + loadable_*) continue;; esac base=${a%.o} echo "main_$base();" @@ -25,6 +25,9 @@ echo "}" echo "void tick_wrapper(void){" for a in $* ; do + case $a in + loadable_*) continue;; + esac base=${a%.o} grep -q \ tick_$base ${base}.c && echo "tick_$base();" done From c30b6ce0472c5eb35356afec9e609fdaff4cf8da Mon Sep 17 00:00:00 2001 From: bernd Date: Tue, 19 Jul 2011 10:20:30 +0200 Subject: [PATCH 07/24] Added alternate enter key --- simulat0r/gui/qsimulat0r.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/simulat0r/gui/qsimulat0r.cc b/simulat0r/gui/qsimulat0r.cc index 36cf9ae..a5ae2d9 100644 --- a/simulat0r/gui/qsimulat0r.cc +++ b/simulat0r/gui/qsimulat0r.cc @@ -97,6 +97,7 @@ public: static const int keyUp=16777235; static const int keyDown=16777237; static const int keyEnter=16777227; + static const int keyAltEnter=32; // Space static const int keyLeft=16777234; static const int keyRight=16777236; LCD* te; @@ -152,6 +153,7 @@ public: 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()==keyAltEnter) clearBit(buttonState,BTN_ENTER); if(event->key()==keyLeft) clearBit(buttonState,BTN_LEFT); if(event->key()==keyRight) clearBit(buttonState,BTN_RIGHT); } @@ -161,6 +163,7 @@ public: 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()==keyAltEnter) setBit(buttonState,BTN_ENTER); if(event->key()==keyLeft) setBit(buttonState,BTN_LEFT); if(event->key()==keyRight) setBit(buttonState,BTN_RIGHT); } From cef9ad954087c81b3bdf18258466828b85aca882 Mon Sep 17 00:00:00 2001 From: bernd Date: Tue, 19 Jul 2011 12:28:21 +0200 Subject: [PATCH 08/24] Added life application --- firmware/applications/life.c | 246 +++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 firmware/applications/life.c diff --git a/firmware/applications/life.c b/firmware/applications/life.c new file mode 100644 index 0000000..128a437 --- /dev/null +++ b/firmware/applications/life.c @@ -0,0 +1,246 @@ +#include + +#include "basic/basic.h" + +#include "lcd/render.h" +#include "lcd/display.h" +#include "lcd/allfonts.h" + +void ReinvokeISP(void); +void EnableWatchdog(uint32_t ms); +void delayms(uint32_t ms); + +/**************************************************************************/ +#define POS_PLAYER_Y 60 +#define ENEMY_ROWS 3 +#define ENEMY_COLUMNS 6 +#define DISABLED 255 + + +unsigned char rnd1(); + +struct gamestate { + char player; + char shot_x, shot_y; + char alive; + char move, direction, lastcol; + bool killed; + char enemy_x[ENEMY_ROWS][ENEMY_COLUMNS]; + char enemy_row_y[ENEMY_ROWS]; + +} game = {RESX/2-4, DISABLED, 0,ENEMY_ROWS*ENEMY_COLUMNS, 0, -1, ENEMY_COLUMNS-1, false}; +char key; + + +void checkISP(void) { + if(gpioGetValue(RB_BTN2)==0){ + gpioSetValue (RB_LED1, CFG_LED_ON); + delayms(200); + gpioSetValue (RB_LED1, CFG_LED_OFF); + while(gpioGetValue(RB_BTN0)==0); + EnableWatchdog(1000*5); + ReinvokeISP(); + } +} + + +void draw_rect(char x0, char y0, char x1, char y1) { + for(char x=x0; x<=x1; ++x) { + lcdSetPixel(x,y0,true); + lcdSetPixel(x,y1,true); + } + for(char y=y0+1; y0; --x) { + for(uchar y=1; y Date: Tue, 19 Jul 2011 12:35:08 +0200 Subject: [PATCH 09/24] Code cleanup: removed remaining spaceinvader definitions --- firmware/applications/life.c | 38 +----------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/firmware/applications/life.c b/firmware/applications/life.c index 128a437..03bc23f 100644 --- a/firmware/applications/life.c +++ b/firmware/applications/life.c @@ -6,44 +6,8 @@ #include "lcd/display.h" #include "lcd/allfonts.h" -void ReinvokeISP(void); -void EnableWatchdog(uint32_t ms); -void delayms(uint32_t ms); - -/**************************************************************************/ -#define POS_PLAYER_Y 60 -#define ENEMY_ROWS 3 -#define ENEMY_COLUMNS 6 -#define DISABLED 255 - - unsigned char rnd1(); -struct gamestate { - char player; - char shot_x, shot_y; - char alive; - char move, direction, lastcol; - bool killed; - char enemy_x[ENEMY_ROWS][ENEMY_COLUMNS]; - char enemy_row_y[ENEMY_ROWS]; - -} game = {RESX/2-4, DISABLED, 0,ENEMY_ROWS*ENEMY_COLUMNS, 0, -1, ENEMY_COLUMNS-1, false}; -char key; - - -void checkISP(void) { - if(gpioGetValue(RB_BTN2)==0){ - gpioSetValue (RB_LED1, CFG_LED_ON); - delayms(200); - gpioSetValue (RB_LED1, CFG_LED_OFF); - while(gpioGetValue(RB_BTN0)==0); - EnableWatchdog(1000*5); - ReinvokeISP(); - } -} - - void draw_rect(char x0, char y0, char x1, char y1) { for(char x=x0; x<=x1; ++x) { lcdSetPixel(x,y0,true); @@ -135,7 +99,7 @@ void calc_area() { for(uchar x=1; x<=RESX; ++x) { for(uchar y=1; y<=RESY; ++y) { uchar sum=sum_area(life,x-1,y-1,x+1,y+1)-life[x][y]; - new[x][y]=sum==3||sum==2&&life[x][y]; + new[x][y]=sum==3||(sum==2&&life[x][y]); } } swap_areas(); From ed7119b45d76d6919b715bc7435a98f41a2beef6 Mon Sep 17 00:00:00 2001 From: kiu Date: Wed, 20 Jul 2011 00:00:37 +0200 Subject: [PATCH 10/24] initial flame test --- firmware/applications/flame.c | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 firmware/applications/flame.c diff --git a/firmware/applications/flame.c b/firmware/applications/flame.c new file mode 100644 index 0000000..812f617 --- /dev/null +++ b/firmware/applications/flame.c @@ -0,0 +1,71 @@ +#include "basic/basic.h" +#include "core/i2c/i2c.h" + +#define FLAME_I2C_WRITE 0xC4 +#define FLAME_I2C_READ 0xC5 + +#define FLAME_I2C_CR_INPUT 0x00 +#define FLAME_I2C_CR_PSC0 0x01 +#define FLAME_I2C_CR_PWM0 0x02 +#define FLAME_I2C_CR_PSC1 0x03 +#define FLAME_I2C_CR_PWM1 0x04 +#define FLAME_I2C_CR_LS0 0x05 + +#define FLAME_I2C_LS0_OFF 0x00 +#define FLAME_I2C_LS0_ON 0x01 +#define FLAME_I2C_LS0_PWM0 0x02 +#define FLAME_I2C_LS0_PWM1 0x03 + +#define FLAME_I2C_LS0_LED0 0x00 +#define FLAME_I2C_LS0_LED1 0x02 +#define FLAME_I2C_LS0_LED2 0x04 +#define FLAME_I2C_LS0_LED3 0x06 + +#define FLAME_MODE_ON 0x00 +#define FLAME_MODE_A 0x01 +#define FLAME_MODE_B 0x02 +#define FLAME_MODE_C 0x03 + +#define FLAME_MODE_MIN 0x00 +#define FLAME_MODE_MAX 0x03 + +void ReinvokeISP(void); + +/**************************************************************************/ + +void flameSetI2C(uint8_t cr, uint8_t value) { + I2CMasterBuffer[0] = FLAME_I2C_WRITE; + I2CMasterBuffer[1] = cr; + I2CMasterBuffer[2] = value; + I2CWriteLength = 3; + I2CReadLength = 0; + i2cEngine(); +} + +void tick_flame(void) { // every 10ms +} + +void main_flame(void) { + + usbMSCInit(); + i2cInit(I2CMASTER); // Init I2C + +// flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_ON << FLAME_I2C_LS0_LED0); // set led to on +// flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led to off + + flameSetI2C(FLAME_I2C_CR_PSC0, 0x66); // set prescaler + flameSetI2C(FLAME_I2C_CR_PWM0, 0x33); // set pwm + flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_PWM0 << FLAME_I2C_LS0_LED0); // set led to pwm + + char key; + while (1) { + key = getInput(); + if (key == BTN_LEFT) { + DoString(0,50,"ISP!"); + lcdDisplay(); + ISPandReset(); + } + } + + return; +} From f5c5ccea3dda78b4741272822c7ff5f8194f96b1 Mon Sep 17 00:00:00 2001 From: kiu Date: Wed, 20 Jul 2011 00:03:15 +0200 Subject: [PATCH 11/24] removed unused init --- firmware/applications/flame.c | 1 - 1 file changed, 1 deletion(-) diff --git a/firmware/applications/flame.c b/firmware/applications/flame.c index 812f617..3e75dd5 100644 --- a/firmware/applications/flame.c +++ b/firmware/applications/flame.c @@ -47,7 +47,6 @@ void tick_flame(void) { // every 10ms void main_flame(void) { - usbMSCInit(); i2cInit(I2CMASTER); // Init I2C // flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_ON << FLAME_I2C_LS0_LED0); // set led to on From 38ee62537b483ab7412fb448c86010d48998e324 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 06:00:02 +0200 Subject: [PATCH 12/24] Correct LED colors and positions --- simulat0r/gui/qsimulat0r.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/simulat0r/gui/qsimulat0r.cc b/simulat0r/gui/qsimulat0r.cc index a5ae2d9..f519766 100644 --- a/simulat0r/gui/qsimulat0r.cc +++ b/simulat0r/gui/qsimulat0r.cc @@ -27,6 +27,15 @@ extern int lcd_layout; time_t starttime; long framecount=0; +const int colorGreenLED=QColor(0,255,0).rgb(); +const int colorRedLED=QColor(255,0,0).rgb(); +const int colorOffLED=QColor(64,64,64).rgb(); + +const int colorPixelOn=QColor(255,192,0).rgb(); +const int colorPixelOff=QColor(64,64,64).rgb(); +const int colorInvertedPixelOn=QColor(128,128,128).rgb(); // inverted and on => dark +const int colorInvertedPixelOff=QColor(128,255,128).rgb(); // inverted and off => bright + class LCD : public QWidget { public: static const int ledsize=10; @@ -41,8 +50,8 @@ public: 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(); + void drawLED(QImage& pixmap,int led, int x, int y,int colorOn) { + int color=simGetLED(led)?colorOn:colorOffLED; for(int minix=0; minix Date: Wed, 20 Jul 2011 06:25:11 +0200 Subject: [PATCH 13/24] Stay close to r0ket firmware and just #define away some lowlevel functions --- simulat0r/firmware/core/i2c/i2c.c | 36 +++++++++++++++++++-- simulat0r/firmware/lcd/display.c | 54 ++++--------------------------- 2 files changed, 40 insertions(+), 50 deletions(-) diff --git a/simulat0r/firmware/core/i2c/i2c.c b/simulat0r/firmware/core/i2c/i2c.c index 6a27b27..cca2ebc 100644 --- a/simulat0r/firmware/core/i2c/i2c.c +++ b/simulat0r/firmware/core/i2c/i2c.c @@ -1,2 +1,34 @@ -/* AUTOGENERATED SOURCE FILE */ -#include "../../../../firmware/core/i2c/i2c.c" + +// dummy implementation instead of #include "../../../../firmware/core/i2c/i2c.c" + + +#include "i2c.h" + +volatile uint32_t I2CMasterState = I2CSTATE_IDLE; +volatile uint32_t I2CSlaveState = I2CSTATE_IDLE; + +volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE]; +volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE]; +volatile uint32_t I2CReadLength; +volatile uint32_t I2CWriteLength; + +volatile uint32_t RdIndex = 0; +volatile uint32_t WrIndex = 0; + + +void I2C_IRQHandler(void) { +} + +uint32_t i2cInit( uint32_t I2cMode ) { + return( TRUE ); +} + +uint32_t i2cEngine( void ) { + return I2CSTATE_IDLE; +} + +/****************************************************************************** +** End Of File +******************************************************************************/ + + diff --git a/simulat0r/firmware/lcd/display.c b/simulat0r/firmware/lcd/display.c index 8e12c67..de1d975 100644 --- a/simulat0r/firmware/lcd/display.c +++ b/simulat0r/firmware/lcd/display.c @@ -1,56 +1,14 @@ -#if 0 -#include "../firmware/lcd/display.c" -#else +#define lcdDisplay _hideaway_lcdDisplay +#define lcdInit _hideaway_lcdInit +#include "../../../firmware/lcd/display.c" +#undef lcdDisplay +#undef lcdInit -#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 Date: Wed, 20 Jul 2011 06:28:41 +0200 Subject: [PATCH 14/24] Cleaned up function declarations --- simulat0r/simcore/simulator.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/simulat0r/simcore/simulator.h b/simulat0r/simcore/simulator.h index 5d85dec..82b0d2f 100644 --- a/simulat0r/simcore/simulator.h +++ b/simulat0r/simcore/simulator.h @@ -3,10 +3,7 @@ #include -void simlcdPrepareUpdate(); -void simlcdWrite(int ignored, int bit); -void simlcdLineFeed(); -void simlcdCompleteUpdate(); +void simlcdDisplayUpdate(); int simButtonPressed(int button); From 575f1a7d423493b8ad511bf0c3b716140d25b51b Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:05:58 +0200 Subject: [PATCH 15/24] Use generated include-bridges for Makefiles --- simulat0r/bin/update-bridge-files.sh | 21 +++++++- simulat0r/firmware/applications/Makefile | 68 +----------------------- simulat0r/firmware/core/Makefile | 58 +------------------- simulat0r/firmware/filesystem/Makefile | 32 +---------- simulat0r/firmware/funk/Makefile | 27 +--------- simulat0r/firmware/lcd/Makefile | 47 +--------------- simulat0r/firmware/loadable/Makefile | 14 +---- simulat0r/firmware/loadable/Makefile.sub | 57 -------------------- simulat0r/firmware/usb/Makefile | 38 +------------ 9 files changed, 34 insertions(+), 328 deletions(-) delete mode 100644 simulat0r/firmware/loadable/Makefile.sub diff --git a/simulat0r/bin/update-bridge-files.sh b/simulat0r/bin/update-bridge-files.sh index 5d74ef4..f278dc5 100755 --- a/simulat0r/bin/update-bridge-files.sh +++ b/simulat0r/bin/update-bridge-files.sh @@ -5,6 +5,13 @@ true # echo $1 } +if test ! -d simulat0r/firmware -o ! -d firmware +then +echo ERROR: +echo This script must be run from toplevel r0ket directory +exit +fi + echo "Updating directories" for i in `find firmware/ -type d ` do @@ -14,7 +21,7 @@ else mkdir -v simulat0r/$i fi done -echo "Updating bridge files" +echo "Updating bridge files for C source" for i in `find firmware/ \! -path firmware/lcd/allfonts.h -type f -iname \*.[ch]` do if test -f simulat0r/$i; @@ -25,3 +32,15 @@ do (printf "/* AUTOGENERATED SOURCE FILE */\n"; echo \#include \"`dirname $i | sed "s#[^/]*#..#g" `/../$i\") >simulat0r/$i fi done + +echo "Updating bridge files for Makefiles" +for i in `find firmware/ -type f -iname Makefile` +do + if test -f simulat0r/$i; + then + verbmsg "OK File already exists: $i" + else + echo Writing bridge file simulat0r/$i + (printf "# GENERATED INCLUDE BRIDGE/\n"; echo include `dirname $i | sed "s#[^/]*#..#g" `/../$i) >simulat0r/$i + fi +done diff --git a/simulat0r/firmware/applications/Makefile b/simulat0r/firmware/applications/Makefile index 6d034d3..adbca02 100644 --- a/simulat0r/firmware/applications/Makefile +++ b/simulat0r/firmware/applications/Makefile @@ -1,66 +1,2 @@ -########################################################################## -# 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: +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/applications/Makefile diff --git a/simulat0r/firmware/core/Makefile b/simulat0r/firmware/core/Makefile index ec1df9e..f85ccd8 100644 --- a/simulat0r/firmware/core/Makefile +++ b/simulat0r/firmware/core/Makefile @@ -1,56 +1,2 @@ -########################################################################## -# 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 +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/core/Makefile diff --git a/simulat0r/firmware/filesystem/Makefile b/simulat0r/firmware/filesystem/Makefile index 76b2d19..b6fed1f 100644 --- a/simulat0r/firmware/filesystem/Makefile +++ b/simulat0r/firmware/filesystem/Makefile @@ -1,30 +1,2 @@ -########################################################################## -# 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 +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/filesystem/Makefile diff --git a/simulat0r/firmware/funk/Makefile b/simulat0r/firmware/funk/Makefile index dd2a593..e5dba98 100644 --- a/simulat0r/firmware/funk/Makefile +++ b/simulat0r/firmware/funk/Makefile @@ -1,25 +1,2 @@ -########################################################################## -# 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 +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/funk/Makefile diff --git a/simulat0r/firmware/lcd/Makefile b/simulat0r/firmware/lcd/Makefile index fe639a3..d17981e 100644 --- a/simulat0r/firmware/lcd/Makefile +++ b/simulat0r/firmware/lcd/Makefile @@ -1,45 +1,2 @@ -########################################################################## -# 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) > $@ +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/lcd/Makefile diff --git a/simulat0r/firmware/loadable/Makefile b/simulat0r/firmware/loadable/Makefile index fa86f1e..38a36e7 100644 --- a/simulat0r/firmware/loadable/Makefile +++ b/simulat0r/firmware/loadable/Makefile @@ -1,12 +1,2 @@ -# 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 - +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/loadable/Makefile diff --git a/simulat0r/firmware/loadable/Makefile.sub b/simulat0r/firmware/loadable/Makefile.sub deleted file mode 100644 index aa2f3ee..0000000 --- a/simulat0r/firmware/loadable/Makefile.sub +++ /dev/null @@ -1,57 +0,0 @@ -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/usb/Makefile b/simulat0r/firmware/usb/Makefile index d54ddf3..76d0639 100644 --- a/simulat0r/firmware/usb/Makefile +++ b/simulat0r/firmware/usb/Makefile @@ -1,36 +1,2 @@ -########################################################################## -# 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) - +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/usb/Makefile From ffcd95d412e9d5e36c68530cf00318e811bf3a47 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:07:50 +0200 Subject: [PATCH 16/24] Added new include bridge files --- simulat0r/firmware/applications/flame.c | 2 ++ simulat0r/firmware/applications/loadable.c | 2 ++ simulat0r/firmware/basic/Makefile | 2 ++ simulat0r/firmware/usbcdc/Makefile | 2 ++ 4 files changed, 8 insertions(+) create mode 100644 simulat0r/firmware/applications/flame.c create mode 100644 simulat0r/firmware/applications/loadable.c create mode 100644 simulat0r/firmware/basic/Makefile create mode 100644 simulat0r/firmware/usbcdc/Makefile diff --git a/simulat0r/firmware/applications/flame.c b/simulat0r/firmware/applications/flame.c new file mode 100644 index 0000000..2b63c47 --- /dev/null +++ b/simulat0r/firmware/applications/flame.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/flame.c" diff --git a/simulat0r/firmware/applications/loadable.c b/simulat0r/firmware/applications/loadable.c new file mode 100644 index 0000000..1700a51 --- /dev/null +++ b/simulat0r/firmware/applications/loadable.c @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/loadable.c" diff --git a/simulat0r/firmware/basic/Makefile b/simulat0r/firmware/basic/Makefile new file mode 100644 index 0000000..64a786e --- /dev/null +++ b/simulat0r/firmware/basic/Makefile @@ -0,0 +1,2 @@ +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/basic/Makefile diff --git a/simulat0r/firmware/usbcdc/Makefile b/simulat0r/firmware/usbcdc/Makefile new file mode 100644 index 0000000..2bb4268 --- /dev/null +++ b/simulat0r/firmware/usbcdc/Makefile @@ -0,0 +1,2 @@ +# GENERATED INCLUDE BRIDGE/ +include ../../../firmware/usbcdc/Makefile From fca18b502933e772cf882d46b73e8a2e3cce5aa8 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:41:14 +0200 Subject: [PATCH 17/24] Added workaround ARM asm --- simulat0r/firmware/basic/xxtea.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/simulat0r/firmware/basic/xxtea.c b/simulat0r/firmware/basic/xxtea.c index 77604be..c315d35 100644 --- a/simulat0r/firmware/basic/xxtea.c +++ b/simulat0r/firmware/basic/xxtea.c @@ -1,2 +1,4 @@ -/* AUTOGENERATED SOURCE FILE */ +/* use SAFE version instead of ARM asm */ +#define SAFE + #include "../../../firmware/basic/xxtea.c" From 72eb4e0c0627c57443776d31fa7585ff068b51f1 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:42:08 +0200 Subject: [PATCH 18/24] Removed crc function stub as now we get it from app library --- simulat0r/simcore/misc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/simulat0r/simcore/misc.c b/simulat0r/simcore/misc.c index b006768..36c5cfb 100644 --- a/simulat0r/simcore/misc.c +++ b/simulat0r/simcore/misc.c @@ -1,6 +1,3 @@ -int crc16(int x) { -} - void __disable_irq() { } From 2ced2603798659e2576a1f54c77fe941dde18051 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:45:54 +0200 Subject: [PATCH 19/24] =?UTF-8?q?Simulat0r=20doesn=C2=B4t=20have=20siprint?= =?UTF-8?q?f,=20use=20sprintf=20instead=20where=20needed=20by=20firmware?= =?UTF-8?q?=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simulat0r/firmware/libc-unc0llide.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/simulat0r/firmware/libc-unc0llide.h b/simulat0r/firmware/libc-unc0llide.h index 19d8cf8..0ca4b6a 100644 --- a/simulat0r/firmware/libc-unc0llide.h +++ b/simulat0r/firmware/libc-unc0llide.h @@ -1,5 +1,13 @@ /* This header is "gcc -include"d for all compilations of firmware files when building as simulat0r. +*/ + +/* +The following symbols are expected from r0ket firmware to come from libc +*/ +#define siprintf sprintf + +/* 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. */ From 5629836c37242ad8b01b0aac80d91a308bf8a327 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:57:06 +0200 Subject: [PATCH 20/24] Use patching include bridge for simulat0r/firmware Makefile --- simulat0r/firmware/Makefile | 110 +----------------------------------- 1 file changed, 3 insertions(+), 107 deletions(-) diff --git a/simulat0r/firmware/Makefile b/simulat0r/firmware/Makefile index dd71a3a..3c50af5 100644 --- a/simulat0r/firmware/Makefile +++ b/simulat0r/firmware/Makefile @@ -1,108 +1,4 @@ -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 +# GENERATED INCLUDE BRIDGE/ +include ../../firmware/Makefile +.IGNORE: $(OUTFILE).elf $(OUTFILE).bin From 032e3a4fbb890c4af23bdebbb93d5adb3239f0d9 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 07:59:35 +0200 Subject: [PATCH 21/24] Find all the firmware in libraries greatly simplifies CMakeLists.txt --- simulat0r/gui/CMakeLists.txt | 38 ++++++++++++++---------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/simulat0r/gui/CMakeLists.txt b/simulat0r/gui/CMakeLists.txt index 0bb9087..f209214 100644 --- a/simulat0r/gui/CMakeLists.txt +++ b/simulat0r/gui/CMakeLists.txt @@ -7,6 +7,10 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR} ../../firmware/applications ../../firmware/filesystem ../../firmware/lcd +../../firmware/funk +../../firmware/basic +../../firmware/core +../../firmware/usbcdc ../../firmware/usb) include(${QT_USE_FILE}) @@ -27,28 +31,6 @@ 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 ) @@ -62,7 +44,17 @@ add_executable(qsimulat0r ${qsimulat0r_SRCS} ${MocSources} ${FIRMWARE_OBJS} ) -target_link_libraries(qsimulat0r ${QT_LIBRARIES} libapp.a liblcd.a libusb.a libfat.a) +target_link_libraries(qsimulat0r +${QT_LIBRARIES} +libapp.a +liblcd.a +libusb.a +libfat.a +libfunk.a +libusbcdc.a +libbasic.a +libcore.a +) From 0ecb6ddffb92f4a8babdc6dc6153197a655cdc1c Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 08:01:01 +0200 Subject: [PATCH 22/24] Added include bridge file --- simulat0r/firmware/applications/cbitset.h | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 simulat0r/firmware/applications/cbitset.h diff --git a/simulat0r/firmware/applications/cbitset.h b/simulat0r/firmware/applications/cbitset.h new file mode 100644 index 0000000..913a87e --- /dev/null +++ b/simulat0r/firmware/applications/cbitset.h @@ -0,0 +1,2 @@ +/* AUTOGENERATED SOURCE FILE */ +#include "../../../firmware/applications/cbitset.h" From eabf38452f236523040221231d4f5c831f03f4e1 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 08:03:02 +0200 Subject: [PATCH 23/24] Use cbitset for game of life to reduce data size - making it run on r0ket --- firmware/applications/cbitset.h | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 firmware/applications/cbitset.h diff --git a/firmware/applications/cbitset.h b/firmware/applications/cbitset.h new file mode 100644 index 0000000..4e76b82 --- /dev/null +++ b/firmware/applications/cbitset.h @@ -0,0 +1,53 @@ +#ifndef CBITFIELD_H +#define CBITFIELD_H + +#define BITSETCHUNKSIZE 32 + +#define one ((uint32_t)1) + +struct bitset { + uint16_t size; + uint32_t bits[BITSET_SIZE/BITSETCHUNKSIZE+1]; +}; + +static inline void bitset_set(struct bitset *bs,uint16_t index, uint8_t value) { + uint16_t base=index/BITSETCHUNKSIZE; + uint16_t offset=index%BITSETCHUNKSIZE; + if(value) { + bs->bits[base]|=(one<bits[base]&=~(one<bits[base]^=(one<bits[base]&(one< Date: Wed, 20 Jul 2011 08:08:09 +0200 Subject: [PATCH 24/24] Use cbitset for game of life to reduce data size - making it run on r0ket --- firmware/applications/life.c | 150 +++++++++++++++++------------------ 1 file changed, 71 insertions(+), 79 deletions(-) diff --git a/firmware/applications/life.c b/firmware/applications/life.c index 03bc23f..bafee14 100644 --- a/firmware/applications/life.c +++ b/firmware/applications/life.c @@ -2,9 +2,17 @@ #include "basic/basic.h" -#include "lcd/render.h" +//#include "lcd/render.h" #include "lcd/display.h" -#include "lcd/allfonts.h" +//#include "lcd/allfonts.h" + +#define BITSET_X (RESX+2) +#define BITSET_Y (RESY+2) +#define BITSET_SIZE (BITSET_X*BITSET_Y) + +#include "cbitset.h" + +typedef uint8_t uchar; unsigned char rnd1(); @@ -28,78 +36,63 @@ void fill_rect(char x0, char y0, char x1, char y1) { } #define STARTVALUE 10 -typedef unsigned char uchar; -typedef uchar row_t[RESY+2]; -uchar buf1[RESX+2][RESY+2]; -uchar buf2[RESX+2][RESY+2]; -row_t *life =buf1; -row_t *new =buf2; + +struct bitset _buf1,*buf1=&_buf1; +struct bitset _buf2,*buf2=&_buf2; + +struct bitset *life =&_buf1; +struct bitset *new =&_buf2; void swap_areas() { - row_t *tmp=life; + struct bitset *tmp=life; life=new; new=tmp; } -void fill_area(uchar area[RESX+2][RESY+2], uchar x0, uchar y0, uchar x1, uchar y1,uchar value) { +void fill_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) { for(uchar x=x0; x<=x1; ++x) { for(uchar y=y0; y<=y1; ++y) { - area[x][y]=value; + bitset_set2(area,x,y,value); } } } -bool find_area(uchar area[RESX+2][RESY+2], uchar x0, uchar y0, uchar x1, uchar y1,uchar value) { +bool find_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) { for(uchar x=x0; x<=x1; ++x) { for(uchar y=y0; y<=y1; ++y) { - if(area[x][y]==value) return true; + if(bitset_get2(area,x,y)==value) return true; } } return false; } -uint32_t sum_area(uchar area[RESX+2][RESY+2], uchar x0, uchar y0, uchar x1, uchar y1) { +uint32_t sum_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1) { uint32_t sum=0; for(uchar x=x0; x<=x1; ++x) { for(uchar y=y0; y<=y1; ++y) { - sum+=area[x][y]; + sum+=bitset_get2(area,x,y); } } return sum; } void draw_area() { - for(uchar x=1; x<=RESX; ++x) { - for(uchar y=1; y<=RESY; ++y) { - lcdSetPixel(x,y,life[x+1][y+1]&1); + for(uchar x=0; x0; --x) { - for(uchar y=1; y