size_t __write(int handle, const unsigned char *buf, size_t cnt) { #ifdef USE_TTY_NOICE char *buf1 = (char *)buf; if (START_VUART) { for (int i = 0; i < cnt; i++) { char c = buf1[i]; if (c == '\n') { while (VUART_TX != 0) { } VUART_TX = '\r'; } while (VUART_TX != 0) { } VUART_TX = c; } } #endif #ifdef USE_TTY_WINIDEA (void)g_TRBuffer[0]; { unsigned char nCnt,nLen; for(nCnt = 0; nCnt < cnt; nCnt++) { while( TWBUFF_FULL() ) {} nLen = TWBUFF_TPTR; g_TWBuffer[nLen] = buf[nCnt]; nLen = TWBUFF_INC(nLen); TWBUFF_TPTR = nLen; } } #endif #if defined(USE_RAMLOG) { const unsigned char *pbuf = buf; for (int i = 0; i < cnt; i++) { ramlog_chr (*(pbuf + i)); } } #endif (void)buf; (void)cnt; return 0; // No error }
int8 Debug_printf(Debug_Level debugLevel, const char* pFormat, ...) { #if USE_DEBUG va_list args; char buff[TWBUFF_SIZE]; uint8 nLen, nSize, nCnt; if(!g_TConn) { return -1; } if (debugLevel > DEBUG_LEVEL) // do not display unecessary messages { return 0; } va_start(args,pFormat); nSize = vsprintf(buff,pFormat,args); if(nSize > TWBUFF_MAX) nSize = TWBUFF_MAX; va_end(args); for(nCnt=0; nCnt<nSize; nCnt++) { while(TWBUFF_FULL()) { if(!g_TConn) { return -1; } } nLen = TWBUFF_TPTR; g_TWBuffer[nLen] = buff[nCnt]; nLen = TWBUFF_INC(nLen); TWBUFF_TPTR = nLen; } #endif return 0; }