从下面这篇**中,我好像找到答案了
评述:我在某个CortextM3的源码里的debug.c找到了fputc。应该说,某些系统是通过fputc建立联系,而不是putchar的。如下:
void fputc_hook(char ch)
{
if (DebugType == 0)
{
UARTWriteByte(ch, 1000);
}
else
{
VirtualUartWrite(ch);
}
}
int fputc(int ch, FILE *f)
{
uint8 dgbBuffer[DEBUG_TIME_LEN];
uint32 tmpcnt, i;
if (ch == '\n')
{
tmpcnt = SysTickCounter;
for (i = 0; i < DEBUG_TIME_LEN; i++)
{
dgbBuffer[i] = tmpcnt % 10;
tmpcnt = tmpcnt / 10;
}
fputc_hook('\r');
fputc_hook('\n');
fputc_hook('[');
for (i = 0; i < DEBUG_TIME_LEN; i++)
{
fputc_hook(dgbBuffer[DEBUG_TIME_LEN - 1 -i]+0x30);
if (DEBUG_TIME_LEN - 1 -i == 2)
{
fputc_hook('.');
}
}
fputc_hook(']');
return OK;
}
fputc_hook(ch);
return OK;
}
|