在15.4协议栈中的例程
Viki Shi:
根据我的理解 在uartPrintf_flush内调用uart的输出接口函数 应该就可以了
FreePom:
回复 Viki Shi:
好的,我先实验一下
FreePom:
回复 Viki Shi:
好像不对,下面是UartPrintf_flush和UartPrintf_putch的源码,调用UartPrintf_putch是加载打印数据,如果还要调用UartPrintf_flush的话,就跟在其他任务调用uart的write接口打印一个样了
void UartPrintf_putch(char ch)
{
#if defined(BOARD_DISPLAY_USE_UART)/*uartPrintf_tail should never catch up with uartPrintf_head.Discard in-between bytes.*/if ( ((uartPrintf_head + 1) % UART_PRINTF_BUF_LEN) == uartPrintf_tail ){return;}
uartPrintf_outArray[uartPrintf_head] = ch;uartPrintf_head++;
if (uartPrintf_head >= UART_PRINTF_BUF_LEN){uartPrintf_head = 0;}
#endif /* BOARD_DISPLAY_USE_UART */
}
/*!* @briefPrintf-buffer flush function**In this implementation it is intended to be called by the*Idle task when nothing else is running.**This is achieved by setting up the Idle task in the TI-RTOS*configuration script like so:**var Idle = xdc.useModule('ti.sysbios.knl.Idle');*Idle.addFunc('&uartPrintf_flush');** @post::uartPrintf_tail is incremented to where uartPrintf_head*was at the time the function was called.*/
void UartPrintf_flush(void)
{
#if defined(BOARD_DISPLAY_USE_UART)/* Abort in case UART hasn't been initialized. */if(NULL == hUart){return;}else{/* Lock head position to avoid race conditions */uint16_t curHead = uartPrintf_head;/* Find out how much data must be output, and how to output it. */bool needWrap = curHead < uartPrintf_tail;uint16_t outLen= needWrap ? (UART_PRINTF_BUF_LEN – uartPrintf_tail+curHead): (curHead – uartPrintf_tail);
if(outLen){if(needWrap){UART_write(hUart, &uartPrintf_outArray[uartPrintf_tail],UART_PRINTF_BUF_LEN – uartPrintf_tail);UART_write(hUart, uartPrintf_outArray, curHead);}else{UART_write(hUart, &uartPrintf_outArray[uartPrintf_tail],outLen);}}
uartPrintf_tail = curHead;}
#endif /* BOARD_DISPLAY_USE_UART */
}