/* * uart_driver.c * * Created on: Nov 8, 2016 * Author: barnekow */ #include "uart_driver.h" #include #include // These will override _read and _write in syscalls.c, which are // prototyped as weak int _read(int file, char *ptr, int len) { int DataIdx; // Modified the for loop in order to get the correct behavior for fgets int byteCnt = 0; for (DataIdx = 0; DataIdx < len; DataIdx++) { //*ptr++ = __io_getchar(); byteCnt++; //*ptr++ = usart2_getch(); *ptr = usart2_getch(); if(*ptr == '\n') break; ptr++; } //return len; return byteCnt; // Return byte count } int _write(int file, char *ptr, int len) { int DataIdx; for (DataIdx = 0; DataIdx < len; DataIdx++) { usart2_putch(*ptr++); } return len; } char usart2_getch(){ char c; while((*(USART_SR)&(1<