#define BUFSIZE 80
unsigned int Get_Idx;
unsigned int Put_Idx;
unsigned char Tx_Buf[BUFSIZE];
int putchar(int ch)
{
unsigned int Get_Idx_Copy;
unsigned int Put_Idx_Copy;
Put_Idx_Copy = Put_Idx;
__enter_critical();
Get_Idx_Copy = Get_Idx;
__exit_critical();
Put_Idx_Copy += 1;
if(Put_Idx_Copy >= BUFSIZE)Put_Idx_Copy = 0;
if(Put_Idx_Copy == Get_Idx_Copy){
return (-1);
}
if(ch == -1) return (-2); // buffer not full check
Tx_Buf[Put_Idx_Copy] = (unsigned char)ch;
Put_Idx = Put_Idx_Copy;
return (ch);
}