Пример как буферизовывал rs232, перегрузил функции.. глобальный printf пользует putchar(), scanf - getchar().. ////////////////////////////////////////
void putbuf (signed char c) {
if (!sendfull) {
if (!sendactive && !sendstop) {
sendactive = 1;
S0TBUF = c;
}
else {
S0TIE = 0;
_nop_ ();
_nop_ ();
outbuf[oend++ & (OLEN-1)] = c;
if (((oend ^ ostart) & (OLEN-1)) == 0) sendfull = 1;
S0TIE = 1;
}
}
}
////////////////////////////////////////
signed char putchar (signed char c) {
while (sendfull)
{}
putbuf (c);
return (c);
}
////////////////////////////////////////
signed char _getkey (void)
{
return inbuf[(istart++)&(ILEN-1)];
}
////////////////////////////////////////
signed char getchar(void)
{
signed char c;
c =_getkey();
return c;
}
////////////////////////////////////////