cleanup
[rpikern] / src / serial.c
index ddd5923..1bc13fe 100644 (file)
@@ -14,8 +14,11 @@ void init_serial(int baud)
 
        /* disable pullups for GPIO 14 & 15 */
        gpio_pullups(0xc000, 0, PUD_DISABLE);
+       /* select alt0 function for GPIO 14 & 15 */
+       /*gpio_fsel(14, FSEL_ALT0);
+       gpio_fsel(15, FSEL_ALT0);*/
 
-       REG_ICR = 0;    /* clear pending interrupts */
+       REG_ICR = 0x7ff;        /* clear pending interrupts */
 
        /* calculate baud rate divisor */
        bdiv_fp6 = (UART_CLK << 6) / (16 * baud);
@@ -33,6 +36,8 @@ void init_serial(int baud)
 
 void ser_putchar(int c)
 {
+       if(c == '\n') ser_putchar('\r');
+
        while(REG_FR & FR_TXFF);
        REG_DR = c & 0xff;
 }
@@ -46,9 +51,6 @@ int ser_getchar(void)
 void ser_printstr(const char *s)
 {
        while(*s) {
-               if(*s == '\n') {
-                       ser_putchar('\r');
-               }
                ser_putchar(*s++);
        }
 }