int _user_puts(char *s) { while(*s) { _user_putc(*s++); } return 0; }
// Retrieve a line of console-edited input const char *_user_gets(void) { unsigned char i; int c; for (i = 0; i < 100; i++) // Maximum number of iterations (bails out early if no input) { c = _user_getc(); if (c <= 0) { break; } if (c == 13) // CR { if (commEcho && c != 10) { _user_putc(c); } serialBuffer[serialBufferLength] = '\0'; serialBufferLength = 0; if (commEcho) { _user_putc(10); } return serialBuffer; } else if (c == 8 || c == 127) // BS and DEL { if (serialBufferLength > 0) { if (commEcho && c != 10) { _user_putc(8); _user_putc(32); _user_putc(8); } serialBufferLength--; serialBuffer[serialBufferLength] = '\0'; } } else if (c == 10) // LF { ; // ignore } else if (serialBufferLength + 1 < SERIAL_BUFFER_SIZE) { if (commEcho && c != 10) { _user_putc(c); } serialBuffer[serialBufferLength] = (char)c; serialBufferLength++; serialBuffer[serialBufferLength] = '\0'; } else { if (commEcho && c != 10) { _user_putc('\a'); } ; // Discard (out of buffer) } } return NULL; }
//transmit 0x55 to test baud rate of TX void baud_test(void) { char test_byte = 't'; _user_putc(test_byte); }
void _user_puthex1(int h1) { int c = h1 & 0x0f; if(c>=10) c += ('a' - ('9'+1)); _user_putc('0'+c); }