|
@@ -23,23 +23,27 @@
|
|
|
#define PORT(offset) (UART0_BASE + (4 * offset))
|
|
|
#endif
|
|
|
|
|
|
+#ifndef IOTYPE
|
|
|
+#define IOTYPE char
|
|
|
+#endif
|
|
|
+
|
|
|
#ifndef PORT
|
|
|
#error please define the serial port address for your own machine
|
|
|
#endif
|
|
|
|
|
|
static inline unsigned int serial_in(int offset)
|
|
|
{
|
|
|
- return *((char *)PORT(offset));
|
|
|
+ return *((volatile IOTYPE *)PORT(offset)) & 0xFF;
|
|
|
}
|
|
|
|
|
|
static inline void serial_out(int offset, int value)
|
|
|
{
|
|
|
- *((char *)PORT(offset)) = value;
|
|
|
+ *((volatile IOTYPE *)PORT(offset)) = value & 0xFF;
|
|
|
}
|
|
|
|
|
|
void putc(char c)
|
|
|
{
|
|
|
- int timeout = 1024;
|
|
|
+ int timeout = 1000000;
|
|
|
|
|
|
while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
|
|
|
;
|