OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libc/] [src/] [sys-userspace/] [arch-arm/] [sys_getc.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Library calls for uart rx.
3
 *
4
 * Copyright (C) 2009 B Labs Ltd.
5
 *
6
 */
7
#include <stdio.h>
8
#include <libdev/uart.h>
9
 
10
char fgetc(FILE * file)
11
{
12
        return uart_rx_char(uart_print_base);
13
}
14
 
15
#define MAX_LINE_LEN            256
16
char data[MAX_LINE_LEN];
17
 
18
char *fgetline(FILE * file)
19
{
20
        int index = 0;
21
 
22
        /*
23
         * Line will end if,
24
         * 1. We have recieved 256 chars or
25
         * 2. we recieved EOL: '\n' followed by '\r'
26
         */
27
        while((data[index] != '\n' && ((data[index++] = fgetc(file)) != '\r')) ||
28
              index != MAX_LINE_LEN);
29
 
30
        return data;
31
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.