I do not know how I can obtain user inputs from a keyboard and display those inputs to a terminal emulator (Real term).
I usually do the following to set up the stdin. However, I do realize that I cannot have the word KEYBOARD as a stream.
FILE receive_str = FDEV_SETUP_STREAM(NULL, KEYBOARD , _FDEV_SETUP_READ);
stdin = &receive_str;
The program is compiled with AVR Studio 4.18 under Windows 7, targeting an ATmega 32 microcontroller.
See http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html for information on the FDEV_SETUP_STREAM method of setting up stdio. In particular, what you put as “KEYBOARD” in your example above is supposed to be the function that provides the keyboard input. So the way you’ve written your code means that it’s looking for a function like this:
This would be a stream that always returns the letter
A, for example. Of course, it’s up to you to fill in that function with whatever code is necessary to read from whatever keyboard hardware you have connected to your microcontroller.The avr-libc manual linked above describes the other values you can return from this function, too, like _FDEV_ERR (if an error occurred) or _FDEV_EOF (if it’s the end-of-file, i.e., there is no more input to read).