X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=rpikern;a=blobdiff_plain;f=src%2Fserial.c;h=1bc13fedee87a5ab0b39f6e5c5f0e3326779951c;hp=465afc72e2c2f4dad6a863808ba222a968839940;hb=32ccc707bc0821d7ff4248fe9f58e92e9c6ebef9;hpb=993155fee2327f1f3cda285c9548bbb09688a3f3 diff --git a/src/serial.c b/src/serial.c index 465afc7..1bc13fe 100644 --- a/src/serial.c +++ b/src/serial.c @@ -15,15 +15,15 @@ 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); + /*gpio_fsel(14, FSEL_ALT0); + gpio_fsel(15, FSEL_ALT0);*/ REG_ICR = 0x7ff; /* clear pending interrupts */ /* calculate baud rate divisor */ bdiv_fp6 = (UART_CLK << 6) / (16 * baud); - REG_IBRD = 1;//(bdiv_fp6 >> 6) & 0xffff; /* 16 bits integer part */ - REG_FBRD = 40;//bdiv_fp6 & 0x3f; /* 6 bits fractional precision */ + REG_IBRD = (bdiv_fp6 >> 6) & 0xffff; /* 16 bits integer part */ + REG_FBRD = bdiv_fp6 & 0x3f; /* 6 bits fractional precision */ /* line control: fifo enable, 8n1 */ REG_LCRH = LCRH_FIFOEN | LCRH_8BITS; @@ -36,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; } @@ -49,9 +51,6 @@ int ser_getchar(void) void ser_printstr(const char *s) { while(*s) { - if(*s == '\n') { - ser_putchar('\r'); - } ser_putchar(*s++); } }