avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] stdio input functions are now there


From: Joerg Wunsch
Subject: [avr-libc-dev] stdio input functions are now there
Date: Thu, 26 Dec 2002 23:13:56 +0100
User-agent: Mutt/1.2.5i

Hi,

in order to slowly complete our stdio implementation, i wrote the
basic input functions: fgetc(), fgets(), and all the derivatives
thereof.

The scanf family might be next, as time permits.  Like the printf
family, it will likely become huge and thus be implemented with
several options.

Also, all this lacks a good terminal driver example to be as useful
as one might expect it: if you just write the usual simple
uart_getchar() implementation like this, and provide it as the
put function to fdevopen():

int
uart_getchar(void)
{
  uint8_t c;

  loop_until_bit_is_set(UCSRA, RXC);
#ifdef UPE
  if (UCSRA & (_BV(FE) | _BV(DOR) | _BV(UPE)))
#else
  if (UCSRA & (_BV(FE) | _BV(DOR)))
#endif
    return -1;
  c = UDR;
  /* behaviour similar to Unix stty ICRNL */
  if (c == '\r')
    return (uint8_t)'\n';

  return c;
}

...it will basically do, but it will behave like a "raw" tty
stream under Unix, without any echo, without line-editing etc.
However, providing a more advanced example will be most useful
when it's also moved to an interrupt-drivne approach, but that's
beyond what my time currently permits.
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]