void SendChar(int ch) { #if defined(DEBUG_ENABLE_SEMIHOST) g_buf[g_buf_len++] = ch; g_buf[g_buf_len] = '\0'; if(g_buf_len + 1 >= sizeof(g_buf) || ch == '\n' || ch == '\0') { /* Send the char */ if(SH_DoCommand(0x04, (int)g_buf, NULL) != 0) { g_buf_len = 0; return; } else { int i; for(i=0;i<g_buf_len;i++) SendChar_ToUART(g_buf[i]); g_buf_len = 0; } } #else SendChar_ToUART(ch); #endif }
/** * @brief Routine to send a char * * @param None * * @returns Send value from UART debug port or semihost * * @details Send a target char to UART debug port or semihost. */ void SendChar(int ch) { #if defined(DEBUG_ENABLE_SEMIHOST) g_buf[g_buf_len++] = ch; g_buf[g_buf_len] = '\0'; if(g_buf_len + 1 >= sizeof(g_buf) || ch == '\n' || ch == '\0') { /* Send the char */ if(SH_DoCommand(0x04, (int)g_buf, NULL) != 0) { g_buf_len = 0; return; } // else // { // int i; // for(i=0;i<g_buf_len;i++) // SendChar_ToUART(g_buf[i]); // g_buf_len = 0; // } } #else // if(CurrentUARTMod == UARTMOD_DEBUG) SendChar_ToUART(ch); #endif }
void printf_UART(uint8_t *str, ...) { va_list args; va_start(args, str); while(*str != '\0') { if(*str == '%') { str++; if(*str == '\0') return; if(*str == 'd') { str++; printInteger(va_arg(args, int)); } else if(*str == 'x') { str++; printHex(va_arg(args, int)); } } SendChar_ToUART(*str++); } }