// used in printing a 2 digit hex number, outputs one of the two nibbles // the parameter is expected to be 0..F void UART_putnibble(uint8_t c) { if (c < 10) { UART_put('0' + c); } else { UART_put('A' + c - 10); } }
// classic Tx a C-string routine // As there is no .data (in the bootloader) it only makes sense for theis to use PSTR() void UART_puts(const char * str) { char c; do { c = PGM_READ_BYTE(str++); if (c) { UART_put(c); } } while (c != 0); }
//****************************************************************************** // UART Input Message //****************************************************************************** void chk_UART_msg(void) { UCHAR j; while( UART_input() ) // becomes true only when a byte has been received { // skip if no characters pending j = UART_get(); // get next character if( j == '\r' ) // on a enter (return) key press { // complete message (all messages end in carriage return) UART_msg_put("->"); UART_msg_process(); } else { if ((j != 0x02) ) // if not ^B { // if not command, then UART_put(j); // echo the character } else { ; } if( j == '\b' ) { // backspace editor if( msg_buf_idx != 0) { // if not 1st character then destructive UART_msg_put(" \b");// backspace msg_buf_idx--; } } else if( msg_buf_idx >= MSG_BUF_SIZE ) { // check message length too large UART_msg_put("\r\nToo Long!"); msg_buf_idx = 0; } else if ((display_mode == QUIET) && (msg_buf[0] != 0x02) && (msg_buf[0] != 'D') && (msg_buf[0] != 'N') && (msg_buf[0] != 'V') && (msg_buf_idx != 0)) { // if first character is bad in Quiet mode msg_buf_idx = 0; // then start over } else { // not complete message, store character msg_buf[msg_buf_idx] = j; msg_buf_idx++; if (msg_buf_idx > 2) { UART_msg_process(); } } } } }
void UART_Asser_PutChar(unsigned char txDataByte) { UART_put(PSoC_to_asser, txDataByte); pthread_kill(asser_pthread, SIGUSR1); usleep(10000); }
// Just outputs "\r\n" void UART_newline(void){ UART_put('\r'); UART_put('\n'); }