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.
Screenshot of terminal window.
#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};
#if HIF_TYPE == HIF_AT90USB
do
{
}
while (EOF == inchar);
#endif
hif_printf(FLASH_STRING(
"\n\rHIF Example : %s : %ld bit/s\n\r"),BOARD_NAME,br);
hif_echo(FLASH_STRING(
"$Revision$\n\r"));
PRINTF(
"File: %s:%d\n\r",__FILE__,__LINE__);
PROMPT();
while(1)
{
if (EOF != inchar)
{
if (inchar == '\r' || inchar == '\n')
{
PROMPT();
}
else
{
}
}
}
}