/*
- * cpu/mc9328/serial.c
- *
+ * cpu/mc9328/serial.c
+ *
* (c) Copyright 2004
* Techware Information Technology, Inc.
* http://www.techware.com.tw/
* MA 02111-1307 USA
*/
-
#include <common.h>
#include <mc9328.h>
-#if defined(CONFIG_UART1)
+#if defined(CONFIG_UART1)
/* GPIO PORT B */
#define reg_GIUS MX1_GIUS_C
#define GPIO_MASK 0xFFFFE1FF
#define UART_BASE 0x00206000
-
#elif defined (CONFIG_UART2)
/* GPIO PORT C */
#define GPIO_MASK 0x0FFFFFFF
#define UART_BASE 0x207000
-#endif
+#endif
#define reg_URXD (*((volatile u32 *)(UART_BASE+0x00)))
#define reg_UTXD (*((volatile u32 *)(UART_BASE+0x40)))
#define TXFE_MASK 0x4000 /* Tx buffer empty */
#define RDR_MASK 0x0001 /* receive data ready */
-
void serial_setbrg (void) {
-/* config I/O pins for UART */
-
+ /* config I/O pins for UART */
reg_GIUS &= GPIO_MASK;
reg_GPR &= GPIO_MASK;
-/* config UART */
-
+ /* config UART */
reg_UCR1 = 5;
reg_UCR2 = 0x4027;
reg_UCR4 = 1;
reg_UBRC = 8;
}
-
-
/*
* Initialise the serial port with the given baudrate. The settings
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*
*/
-
+
int serial_init (void) {
serial_setbrg ();
return (0);
}
-
-
/*
* Read a single byte from the serial port. Returns 1 on success, 0
* otherwise. When the function is succesfull, the character read is
return (u8)reg_URXD;
}
-
/*
* Output a single byte to the serial port.
*/
}
-
/*
* Test whether a character is in the RX buffer
*/
return reg_USR2 & RDR_MASK;
}
-
void serial_puts (const char *s) {
while (*s) {
serial_putc (*s++);
}
}
-