]> hackdaworld.org Git - my-code/arm.git/commitdiff
fwbc transmitting 0x23 now, though it's still curious. Makefile updates.
authorhackbard <hackbard@staubsauger.localdomain>
Wed, 8 Aug 2007 16:31:58 +0000 (18:31 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Wed, 8 Aug 2007 16:31:58 +0000 (18:31 +0200)
betty/Makefile
betty/fwbc.c

index 1155b457630e4dcc117f63716694cb9c12ce2fbb..a1e44da03a48d9809273fc9df93bf5a6feef89ac 100644 (file)
@@ -3,10 +3,17 @@ CFLAGS = -Wall
 
 ARMCC = /scratch/arm-elf/bin/arm-elf-gcc
 ARMCFLAGS = -Wall -mcpu=arm7tdmi-s 
-
 ARMOBJCOPY = /scratch/arm-elf/bin/arm-elf-objcopy
 
-all: lpcload fwbc.hex
+HOSTOBJECTS = lpcload
+
+ARMOBJECTS = fwbc.hex
+
+# all projects
+all: $(HOSTOBJECTS) $(ARMOBJECTS)
+
+# arm code
+arm: arm_clean $(ARMOBJECTS)
 
 # fwbc
 fwbc:
@@ -17,3 +24,6 @@ fwbc.hex: fwbc
 
 clean:
        rm -f lpcload fwbc.hex fwbc
+
+arm_clean:
+       rm -f fwbc.hex fwbc
index a625716b4123a9b4c6d3f0d4108663a29b87c888..9682ee8292fb4396fb98f16f29aaf2560844e0a6 100644 (file)
@@ -6,48 +6,97 @@
  *
  */
 
+/*
+ * include files
+ */
+
 #include "lpc2xxx.h"
 
+/*
+ * defines
+ */
+
+/* misc */
 #define OSC_CLOCK              10000000
 #define BAUDRATE               9600
 #define P_DIV                  4
 #define P_CLOCK                        (OSC_CLOCK/P_DIV)
 
+/* memory mapping */
+#define        MMAP_BL                 0x00
+#define MMAP_RAM               0x02
+#define MMAP_EXT               0x03
+
+/*
+ * type definitions
+ */
+
 typedef unsigned char u8;
 typedef unsigned int u32;
 
+/*
+ * function prototypes
+ */
 
-/* memory mapping */
+void mmap_init(u8 memtype);
+void uart0_init(void);
+void uart0_send_string(char *txbuf);
+void uart0_send_char(char send);
 
-#define        MMAP_BL         0x00
-#define MMAP_RAM       0x02
-#define MMAP_EXT       0x03
+/*
+ * main function
+ */
 
-void mmap_init(u8 memtype) {
+int main(void) {
 
-       MEMMAP=memtype;
+       /* memory mapping of interrupt vectors to static ram */
+
+       //mmap_init(MMAP_RAM);
+
+       /* uart initialization */
+
+#ifdef USE_FUNCTIONS
+       //uart0_init();
+#else
+       PINSEL0=0x05;                   // pin select -> tx, rx
+       UART0_FCR=0x07;                 // enable fifo
+       UART0_LCR=0x83;                 // set dlab + word length
+       UART0_DLL=0x10;                 // br: 9600 @ 10/4 mhz
+       UART0_DLM=0x00;
+       UART0_LCR=0x03;                 // unset dlab
+#endif
+
+       /* external memory init */
+
+       while(1) {
+               while(!(UART0_LSR&(1<<5)))
+                       continue;
+               UART0_THR=0x23;
+       }
+
+       return 0;
 }
 
-void uart0_init(void) {
+/*
+ * functions
+ */
 
-       /* pin select -> tx rx */
-       PINSEL0=0x05;
+void mmap_init(u8 memtype) {
 
-       /* enable fifo */
-       UART0_FCR=0x07;
+       MEMMAP=memtype;
+}
 
-       /* set dlab + word length */
-       UART0_LCR=0x83;
+void uart0_init(void) {
 
-       /* set baud rate to 9600 @ 10/4 mhz */
-       UART0_DLL=0x10;
+       PINSEL0=0x05;                   // pin select -> tx, rx
+       UART0_FCR=0x07;                 // enable fifo
+       UART0_LCR=0x83;                 // set dlab + word length
+       UART0_DLL=0x10;                 // br: 9600 @ 10/4 mhz
        UART0_DLM=0x00;
-
-       /* unset dlab */
-       UART0_LCR=0x03;
+       UART0_LCR=0x03;                 // unset dlab
 }
 
-void uart_send(char *txbuf) {
+void uart0_send_string(char *txbuf) {
 
        int i;
 
@@ -61,20 +110,11 @@ void uart_send(char *txbuf) {
        while(!(UART0_LSR&(1<<6))) {}
 }
 
-int main(void) {
-
-       char txbuf[]="uart0 working";
+void uart0_send_char(char send) {
 
-       /* memory mapping of interrupt vectors to static ram */
-       mmap_init(MMAP_RAM);
+       while(!(UART0_LSR&(1<<5)))
+               continue;
 
-       /* initialization */
-       uart0_init();
-
-       while(1) {
-               uart_send(txbuf);
-       }
-
-       return 0;
+       UART0_THR=send;
 }