snapshot of my first "working" version from turn-on of Altus Metrum v0.1
authorBdale Garbee <bdale@gag.com>
Wed, 6 Feb 2008 06:10:45 +0000 (23:10 -0700)
committerBdale Garbee <bdale@gag.com>
Wed, 6 Feb 2008 06:10:45 +0000 (23:10 -0700)
13 files changed:
Makefile
Windows/usbser.sys
adc/adc.c
adc/adc.h
i2c/eeprom.c
i2c/eeprom.h
i2c/i2cInt.c
init.gdb [new file with mode: 0644]
main.c
oocd_flash_lpc2148.script [new file with mode: 0644]
openocd-debug.cfg [new file with mode: 0644]
openocd-flash.cfg [new file with mode: 0644]
sysdefs.h

index 28b15e1a7f09cd2b7d0cb91e9cbd08f1abd0c07b..11bd29d5aefc37e2efbd027481722fc15e053eb2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.SILENT: 
+#.SILENT: 
 
 #
 #  -D CFG_CONSOLE_USB   for console on USB
@@ -17,7 +17,7 @@ export OBJCOPY=arm-elf-objcopy
 export OBJDUMP=arm-elf-objdump
 export CRT0=boot.s
 export WARNINGS=-Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wunused
-export CFLAGS=$(WARNINGS) -D RUN_MODE=RUN_FROM_ROM -D GCC_ARM7 $(INCLUDES) $(BASEINCLUDE) -mcpu=arm7tdmi -T$(LDSCRIPT) -g -O3 -fomit-frame-pointer $(LPC2148DEMO_OPTS)
+export CFLAGS=$(WARNINGS) -D RUN_MODE=RUN_FROM_ROM -D GCC_ARM7 $(INCLUDES) $(BASEINCLUDE) -mcpu=arm7tdmi -T$(LDSCRIPT) -g -O3 -fomit-frame-pointer $(LPC2148DEMO_OPTS) -DFC1025 -DBDALE
 export LDSCRIPT=lpc2148-rom.ld
 export LINKER_FLAGS=$(COMMON)/common.a -Xlinker -olpc2148.elf -Xlinker -M -Xlinker -Map=lpc2148.map
 export ROOT=$(shell pwd)
@@ -38,11 +38,22 @@ all :
        @for i in $(SUBDIRS); do \
        (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) all); done
        make lpc2148.hex
+       make lpc2148.bin
+
+program:       lpc2148.bin
+       sudo openocd -f ./openocd-flash.cfg
+
+debug: lpc2148.bin
+       sudo openocd -f ./openocd-debug.cfg
 
 lpc2148.hex : .depend Makefile lpc2148.elf
        $(OBJCOPY) lpc2148.elf -O ihex lpc2148.hex
        @echo "Length is " `grep __"end_of_text__ = ." *.map | cut -b 17-35` "bytes"
 
+lpc2148.bin : .depend Makefile lpc2148.elf
+       $(OBJCOPY) lpc2148.elf -O binary lpc2148.bin
+       @echo "Length is " `grep __"end_of_text__ = ." *.map | cut -b 17-35` "bytes"
+
 lpc2148.elf : .depend Makefile $(ARM_OBJ) $(COMMON)/common.a $(CRT0) $(LDSCRIPT)
        $(CC) $(CFLAGS) $(ARM_OBJ) -nostartfiles $(CRT0) $(LINKER_FLAGS)
        $(OBJDUMP) -d -S lpc2148.elf >lpc2148.lst
index b390c36e335e50efc4dafeeb399886e88cf7b449..065c75f81a4bb71ba1f0484ded0c011b41a93110 100755 (executable)
Binary files a/Windows/usbser.sys and b/Windows/usbser.sys differ
index 358a18d9dc33346357d3a84a39271af2678c67e1..21d8572b4252efa3e97eb8237ec6a73c44ac6e2f 100644 (file)
--- a/adc/adc.c
+++ b/adc/adc.c
@@ -7,6 +7,7 @@
 //
 int adcRead0_3 (void)
 {
+  AD0_CR = AD_CR_CLKS10 | AD_CR_PDN | ((11 - 1) << AD_CR_CLKDIVSHIFT) | AD_CR_SEL3;
   AD0_CR |= AD_CR_START_NOW;
 
   while (!(AD0_DR3 & AD_DR_DONE))
index a17bf8d48cf304a88b62794f4fceec4011ef548b..5765e5ffdcb3e9bb51a55ee289fc0ed8e5dffe5b 100644 (file)
--- a/adc/adc.h
+++ b/adc/adc.h
@@ -2,6 +2,7 @@
 #define _ADC_H_
 
 int adcRead0_3 (void);
+int adcRead0_7 (void);
 void adcInit (void);
 
 #endif
index d537508e3dd90de470c5822b1e0f9b90cc32a092..8a89298c9d097912b1771c0ff370a6cb960d047a 100644 (file)
@@ -28,9 +28,15 @@ int eepromSetAddress (U32 address)
   address %= EEPROM_SIZE;
 
   if ((rwAddress = address) >= 65536)
+#ifdef FC1025
+    deviceAddress |= 0x08;
+  else
+    deviceAddress &= ~0x08;
+#else
     deviceAddress |= 0x02;
   else
     deviceAddress &= ~0x02;
+#endif
 
   return r;
 }
index bfd1412405aa57fcb655edfc8cb37de7ad38fc0a..e10ba8f024cac1240d8107636016879b804b4eb0 100644 (file)
@@ -6,7 +6,11 @@
 //
 #define EEPROM_ADDRESS  (0xa0)
 #define EEPROM_SIZE     (131072)
-#define EEPROM_PAGESIZE (256)
+#ifdef FC1025
+# define EEPROM_PAGESIZE (128)
+#else
+# define EEPROM_PAGESIZE (256)
+#endif
 
 //
 //
index 80f0bdf706e5cb970306d26d77eff8aadd152776..24cb26d6d86908655a6bc5417a021fc915bbdd8c 100644 (file)
@@ -185,8 +185,16 @@ void i2cInit (void)
 
   I2C0_CONCLR = I2C_CONCLR_MASK;
   I2C0_CONSET = I2C_CONSET_I2EN;
+#ifdef FC1025
+  // the Microchip 24FC1025 can handle a 1 Mhz clock
+  // PCLK / (i2c_clock * 2), with 48 Mhz PCLK that's 24...
+  // for AltusMetrum, 14.7456 Mhz xtal, it's 29.4912, use 30.
+  I2C0_SCLL   = 30;
+  I2C0_SCLH   = 30;
+#else
   I2C0_SCLL   = 240;
   I2C0_SCLH   = 240;
+#endif
 
   //
   //  Initialize the interrupt vector
diff --git a/init.gdb b/init.gdb
new file mode 100644 (file)
index 0000000..2f3d1b9
--- /dev/null
+++ b/init.gdb
@@ -0,0 +1,19 @@
+# configure gdb to use openocd to talk to the LPC2148 board via Olimex USB JTAG
+
+#target remote localhost:3333
+#monitor arm7_9 sw_bkpts enable
+#monitor poll
+
+target remote localhost:3333
+monitor reset
+monitor sleep 500
+monitor soft_reset_halt
+#monitor mww 0xFFFFFF00 0x01
+#monitor reg pc 0x00000000
+monitor poll
+monitor wait_halt
+monitor ARM7_9 force_hw_bkpts enable
+symbol-file lpc2148.elf
+thbreak main
+#load
+continue
diff --git a/main.c b/main.c
index 7f668d0b52812b3bf133fb32d48db98cc1849adb..7a7fe8c538041627469f20b89560033cfa23bf93 100644 (file)
--- a/main.c
+++ b/main.c
@@ -58,29 +58,39 @@ xTaskHandle taskHandles [TASKHANDLE_LAST];
 int main (void)
 {
   cpuSetupHardware ();
+//#ifndef BDALE
   uartInit (0, BAUD_UART0, 64);
   uartInit (1, BAUD_UART1, 64);
+//#endif
 #ifndef CFG_USB_MSC
   usbserInit ();
 #else
   usbmassInit ();
 #endif
+//#ifndef BDALE
   rtcInit ();
   adcInit ();
   dacInit ();
+//#endif
   i2cInit ();
+//#ifndef BDALE
   eintsInit ();
   fiqInit ();
   iapInit ();
+//#endif
 
   memset (taskHandles, 0, sizeof (taskHandles));
 
   xTaskCreate (vSensorsTask,  (const signed portCHAR * const) "Sensors",  512,                      NULL, (configMAX_PRIORITIES - 2), &taskHandles [TASKHANDLE_SENSORS]);
+//#ifndef BDALE
 #ifndef CFG_CONSOLE_UART1
   xTaskCreate (vGPSTask,      (const signed portCHAR * const) "GPS",      768,                      NULL, (tskIDLE_PRIORITY + 1),     &taskHandles [TASKHANDLE_GPS]);
 #endif
+//#endif
   xTaskCreate (vMonitorTask,  (const signed portCHAR * const) "Monitor",  1024,                     NULL, (tskIDLE_PRIORITY + 1),     &taskHandles [TASKHANDLE_MONITOR]);
+//#ifndef BDALE
   xTaskCreate (vLEDFlashTask, (const signed portCHAR * const) "LEDx",     configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1),     &taskHandles [TASKHANDLE_LED]);
+//#endif
   vTaskStartScheduler ();
 
   return 0;
diff --git a/oocd_flash_lpc2148.script b/oocd_flash_lpc2148.script
new file mode 100644 (file)
index 0000000..8ec897b
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# The following commands will be executed on
+# reset (because of run_and_init in the config-file)
+# - wait for target halt
+# - erase memory
+# - flash content of file main.bin into target-memory
+# - shutdown openocd
+#
+# created by Martin Thomas
+# http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
+# based on information from Dominic Rath
+#
+arm7_9 dcc_downloads enable
+wait_halt
+sleep 10
+poll
+flash probe 0
+# erase first bank only:
+flash erase 0 0 26
+flash write 0 lpc2148.bin 0x0
+#flash write 0 scripts/lpc2148_freertos.bin 0x0
+#flash write 0 scripts/main.bin 0x0
+reset run
+sleep 10
+shutdown
+
diff --git a/openocd-debug.cfg b/openocd-debug.cfg
new file mode 100644 (file)
index 0000000..1fafcc9
--- /dev/null
@@ -0,0 +1,29 @@
+#daemon configuration
+telnet_port 4444
+gdb_port 3333
+#interface
+interface ft2232
+ft2232_device_desc "Olimex OpenOCD JTAG"
+ft2232_layout "olimex-jtag"
+ft2232_vid_pid 0x15BA 0x0003
+jtag_speed 3
+#use combined on interfaces or targets that can't set TRST/SRST separately
+#reset_config trst_and_srst separate
+reset_config trst_and_srst srst_pulls_trst
+#jtag scan chain
+#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
+jtag_device 4 0x1 0xf 0xe
+#target configuration
+daemon_startup reset
+#target <type> <startup mode>
+#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
+target arm7tdmi little run_and_init 0 arm7tdmi-s_r4
+run_and_halt_time 0 30
+#target_script 0 reset oocd_flash_lpc2148.script
+working_area 0 0x40000000 0x40000 nobackup
+#flash configuration
+#flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 14765 calc_checksum
+flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum
+arm7_9 swbkpts enable
+# For more information about the configuration files, take a look at:
+# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
diff --git a/openocd-flash.cfg b/openocd-flash.cfg
new file mode 100644 (file)
index 0000000..26131e9
--- /dev/null
@@ -0,0 +1,29 @@
+#daemon configuration
+telnet_port 4444
+gdb_port 3333
+#interface
+interface ft2232
+ft2232_device_desc "Olimex OpenOCD JTAG"
+ft2232_layout "olimex-jtag"
+ft2232_vid_pid 0x15BA 0x0003
+jtag_speed 3
+#use combined on interfaces or targets that can't set TRST/SRST separately
+#reset_config trst_and_srst separate
+reset_config trst_and_srst srst_pulls_trst
+#jtag scan chain
+#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
+jtag_device 4 0x1 0xf 0xe
+#target configuration
+daemon_startup reset
+#target <type> <startup mode>
+#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
+target arm7tdmi little run_and_init 0 arm7tdmi-s_r4
+run_and_halt_time 0 30
+target_script 0 reset oocd_flash_lpc2148.script
+working_area 0 0x40000000 0x40000 nobackup
+#flash configuration
+#flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 14765 calc_checksum
+flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum
+arm7_9 swbkpts enable
+# For more information about the configuration files, take a look at:
+# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
index 4d0e749178b3f53a15b7db27fdfa794b64495955..f55c158173fe1d93ec18c853d8524e380160a5b7 100644 (file)
--- a/sysdefs.h
+++ b/sysdefs.h
@@ -36,7 +36,7 @@ typedef volatile U32 REG32;
 //  Yuck.  Don't like this here, but what the heck...
 //
 #if !defined CFG_CONSOLE_USB && !defined CFG_CONSOLE_UART0 && !defined CFG_CONSOLE_UART1
-#error "Must define CFG_CONSOLE_USB, CFG_CONSOLE_UART0 or CFG_CONSOLE_UART1
+#error "Must define CFG_CONSOLE_USB, CFG_CONSOLE_UART0 or CFG_CONSOLE_UART1"
 #endif
 
 #if defined CFG_CONSOLE_USB && (defined CFG_CONSOLE_UART0 || defined CFG_CONSOLE_UART1)