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:
clean:
rm -f lpcload fwbc.hex fwbc
+
+arm_clean:
+ rm -f fwbc.hex fwbc
*
*/
+/*
+ * 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;
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;
}