*
*/
-void uart0_init(void) {
+/*
+ * 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
+ */
+
+void mmap_init(u8 memtype);
+void uart0_init(void);
+void uart0_send_string(char *txbuf);
+void uart0_send_char(char send);
+
+/*
+ * main function
+ */
+
+int main(void) {
+
+ /* memory mapping of interrupt vectors to static ram */
+
+ //mmap_init(MMAP_RAM);
+
+ /* uart initialization */
- PINSEL0|=((1<<0)|(1<<2)); /* pin select: tx, rx */
+#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 arm_init(void) {
+/*
+ * functions
+ */
+
+void mmap_init(u8 memtype) {
+
+ MEMMAP=memtype;
+}
+
+void uart0_init(void) {
+
+ 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
+}
+
+void uart0_send_string(char *txbuf) {
+
+ int i;
+
+ i=0;
- /* pin selection */
- uart0_init();
+ while(txbuf[i])
+ UART0_THR=txbuf[i++];
+ UART0_THR='\n';
+ UART0_THR='\r';
+ while(!(UART0_LSR&(1<<6))) {}
}
-void main(void) {
+void uart0_send_char(char send) {
- /* initialization */
- arm_init();
+ while(!(UART0_LSR&(1<<5)))
+ continue;
+ UART0_THR=send;
}