freemyipod r684 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r683‎ | r684 | r685 >
Date:22:45, 30 March 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Implement UART console on iPod Classic
Modified paths:
  • /emcore/trunk/SOURCES (modified) (history)
  • /emcore/trunk/console.c (modified) (history)
  • /emcore/trunk/target/ipodclassic/target.h (modified) (history)
  • /emcore/trunk/target/ipodnano3g/s5l8702.h (modified) (history)
  • /emcore/trunk/target/ipodnano3g/target.h (modified) (history)

Diff [purge]

Index: emcore/trunk/console.c
@@ -25,6 +25,7 @@
2626 #include "console.h"
2727 #include "lcdconsole.h"
2828 #include "usb/dbgconsole.h"
 29+#include "uart.h"
2930 #include "format.h"
3031 #include "thread.h"
3132 #include <stdarg.h>
@@ -46,6 +47,9 @@
4748 {
4849 mutex_init(&console_mutex);
4950 mutex_init(&console_readmutex);
 51+#ifdef HAVE_UART
 52+ uart_init();
 53+#endif
5054 }
5155
5256 void cputc_internal(unsigned int consoles, char string) ICODE_ATTR;
@@ -57,6 +61,9 @@
5862 #ifdef HAVE_USB
5963 if (consoles & 2) dbgconsole_putc(string);
6064 #endif
 65+#ifdef HAVE_UART
 66+ if (consoles & 4) uart_putc(string);
 67+#endif
6168 }
6269
6370 static int cprfunc(void* ptr, unsigned char letter)
@@ -114,6 +121,9 @@
115122 #ifdef HAVE_USB
116123 if (consoles & 2) dbgconsole_puts(string);
117124 #endif
 125+#ifdef HAVE_UART
 126+ if (consoles & 4) uart_puts(string);
 127+#endif
118128 mutex_unlock(&console_mutex);
119129 }
120130
@@ -126,6 +136,9 @@
127137 #ifdef HAVE_USB
128138 if (consoles & 2) dbgconsole_write(string, length);
129139 #endif
 140+#ifdef HAVE_UART
 141+ if (consoles & 4) uart_write(string, length);
 142+#endif
130143 mutex_unlock(&console_mutex);
131144 }
132145
@@ -145,6 +158,9 @@
146159 #ifdef HAVE_USB
147160 if ((consoles & 2) && (result = dbgconsole_getc(timeout)) != -1) return result;
148161 #endif
 162+#ifdef HAVE_UART
 163+ if ((consoles & 4) && (result = uart_getc(timeout)) != -1) return result;
 164+#endif
149165 mutex_unlock(&console_readmutex);
150166 }
151167
@@ -155,6 +171,9 @@
156172 #ifdef HAVE_USB
157173 if ((consoles & 2) && (result = dbgconsole_read(buffer, length, timeout))) return result;
158174 #endif
 175+#ifdef HAVE_UART
 176+ if ((consoles & 2) && (result = uart_read(buffer, length, timeout))) return result;
 177+#endif
159178 mutex_unlock(&console_readmutex);
160179 }
161180
@@ -164,13 +183,23 @@
165184 mutex_lock(&console_readmutex, TIMEOUT_BLOCK);
166185 while (length)
167186 {
 187+ if (
168188 #ifdef HAVE_USB
169 - if (length && (consoles & 2) && (result = dbgconsole_read(buffer, length, timeout)))
 189+ ((consoles & 2) && (result = dbgconsole_read(buffer, length, timeout)))
 190+#else
 191+ false
 192+#endif
 193+ ||
 194+#ifdef HAVE_UART
 195+ ((consoles & 4) && (result = uart_read(buffer, length, timeout)))
 196+#else
 197+ false
 198+#endif
 199+ )
170200 {
171201 buffer = &buffer[result];
172202 length -= result;
173203 }
174 -#endif
175204 }
176205 mutex_unlock(&console_readmutex);
177206 }
Index: emcore/trunk/target/ipodnano3g/s5l8702.h
@@ -767,6 +767,17 @@
768768 #define WHEELTX (*((uint32_t volatile*)(0x3C20001C)))
769769
770770
 771+/////UART/////
 772+#define ULCON (*((uint32_t volatile*)0x3cc00000))
 773+#define UCON (*((uint32_t volatile*)0x3cc00004))
 774+#define UFCON (*((uint32_t volatile*)0x3cc00008))
 775+#define UMCON (*((uint32_t volatile*)0x3cc0000c))
 776+#define UFSTAT (*((uint32_t volatile*)0x3cc00018))
 777+#define UTXH (*((uint8_t volatile*)0x3cc00020))
 778+#define URXH (*((uint8_t volatile*)0x3cc00024))
 779+#define UBRDIV (*((uint32_t volatile*)0x3cc00028))
 780+
 781+
771782 /////CLOCK GATES/////
772783 #define CLOCKGATE_LCD 1
773784 #define CLOCKGATE_USB_1 2
Index: emcore/trunk/target/ipodnano3g/target.h
@@ -60,6 +60,8 @@
6161
6262 #define HAVE_BOOTFLASH
6363
 64+#define HAVE_UART
 65+
6466 //#define HAVE_STORAGE
6567 //#define HAVE_FLASH_STORAGE
6668 //#define HAVE_STORAGE_FLUSH
Index: emcore/trunk/target/ipodclassic/target.h
@@ -61,6 +61,8 @@
6262
6363 #define HAVE_BOOTFLASH
6464
 65+#define HAVE_UART
 66+
6567 #define HAVE_STORAGE
6668 #define HAVE_HDD_STORAGE
6769 #define HAVE_STORAGE_FLUSH
Index: emcore/trunk/SOURCES
@@ -50,6 +50,7 @@
5151 target/ipodnano3g/clickwheel.c
5252 target/ipodnano3g/spi.c
5353 target/ipodnano3g/targetinit.c
 54+target/ipodnano3g/uart.c
5455 usb/synopsysotg.c
5556 #endif
5657