/* $Id$ */ /* Example for use of the HIF functions */ #include "board.h" #include "hif.h" #include "xmpl.h" #define PROMPT() PRINTF("\n\ruracoli[%02d]> ",lc++) int main(void) { int inchar; const uint32_t br = HIF_DEFAULT_BAUDRATE; uint8_t lc = 0; uint8_t msg[] = { 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x20, 0xb5, 0x72, 0x61, 0x63, 0x6f, 0x6c, 0x69, 0x21, '\n','\r',0x00}; /* setting up UART and adjusting the baudrate */ hif_init(br); sei(); #if HIF_TYPE == HIF_AT90USB /* * Wait for terminal user pressing a key so there is time to * attach a terminal emulator after the virtual serial port has * been established within the host OS. */ do { inchar = hif_getc(); } while (EOF == inchar);
The programm dumps at first a view text lines to the host interface, then waiting for input data. All characters received are echoed, except for '\n' and '\r' which where treated as line break, printing out a prompt with the current line number in square brackets.
This is an example screenshot of the terminal window, with the output of tree command, redirected to the HIF.