busvoodoo_uart_generic: minor, replace printf with puts
This commit is contained in:
parent
dfcdd512d1
commit
cbc37e3a45
|
@ -138,11 +138,11 @@ bool busvoodoo_uart_generic_setup(char** prefix, const char* line)
|
|||
}
|
||||
}
|
||||
if (BUSVOODOO_UART_SETTING_PARITY == busvoodoo_uart_generic_setting) { // if next setting
|
||||
printf("1) none\n");
|
||||
printf("2) even\n");
|
||||
printf("3) odd\n");
|
||||
printf("4) mark\n");
|
||||
printf("5) space\n");
|
||||
puts("1) none\n");
|
||||
puts("2) even\n");
|
||||
puts("3) odd\n");
|
||||
puts("4) mark\n");
|
||||
puts("5) space\n");
|
||||
snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "parity (1,2,3,4,5) [%u]", busvoodoo_uart_generic_parity+1); // prepare next setting
|
||||
*prefix = busvoodoo_global_string; // display next setting
|
||||
}
|
||||
|
@ -158,10 +158,10 @@ bool busvoodoo_uart_generic_setup(char** prefix, const char* line)
|
|||
}
|
||||
}
|
||||
if (BUSVOODOO_UART_SETTING_STOPBITS == busvoodoo_uart_generic_setting) { // if next setting
|
||||
printf("1) 0.5\n");
|
||||
printf("2) 1\n");
|
||||
printf("3) 1.5\n");
|
||||
printf("4) 2\n");
|
||||
puts("1) 0.5\n");
|
||||
puts("2) 1\n");
|
||||
puts("3) 1.5\n");
|
||||
puts("4) 2\n");
|
||||
snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "stop bits (1,2,3,4) [%c]", USART_STOPBITS_0_5 == busvoodoo_uart_generic_stopbits ? '1' : (USART_STOPBITS_1 == busvoodoo_uart_generic_stopbits ? '2' : (USART_STOPBITS_1_5 == busvoodoo_uart_generic_stopbits ? '3' : '4'))); // prepare next setting
|
||||
*prefix = busvoodoo_global_string; // display next setting
|
||||
}
|
||||
|
@ -194,8 +194,8 @@ bool busvoodoo_uart_generic_setup(char** prefix, const char* line)
|
|||
goto setting_done; // actually go to next setting
|
||||
#endif
|
||||
}
|
||||
printf("1) no flow control\n");
|
||||
printf("2) RTS/CTS hardware flow control\n");
|
||||
puts("1) no flow control\n");
|
||||
puts("2) RTS/CTS hardware flow control\n");
|
||||
snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "flow control (1,2) [%c]", busvoodoo_uart_generic_hwflowctl ? '2' : '1'); // prepare next setting
|
||||
*prefix = busvoodoo_global_string; // display next setting
|
||||
}
|
||||
|
@ -221,9 +221,9 @@ setting_drive:
|
|||
busvoodoo_uart_generic_setting = BUSVOODOO_UART_SETTING_DONE; // go to next setting
|
||||
goto setting_done; // actually go to next setting
|
||||
}
|
||||
printf("1) push-pull (3.3V)\n");
|
||||
printf("2) open-drain, with embedded pull-up resistors (2kO)\n");
|
||||
printf("3) open-drain, with external pull-up resistors\n");
|
||||
puts("1) push-pull (3.3V)\n");
|
||||
puts("2) open-drain, with embedded pull-up resistors (2kO)\n");
|
||||
puts("3) open-drain, with external pull-up resistors\n");
|
||||
snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "drive mode (1,2,3) [%c]", busvoodoo_uart_generic_drive ? '1' : (busvoodoo_uart_generic_pullup ? '2' : '3')); // show drive mode
|
||||
*prefix = busvoodoo_global_string; // display next setting
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ setting_done:
|
|||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
if (!busvoodoo_uart_generic_drive && busvoodoo_uart_generic_pullup) { // enable embedded pull-ups if used
|
||||
busvoodoo_embedded_pullup(true); // set embedded pull-ups
|
||||
printf("use LV to set pull-up voltage\n");
|
||||
puts("use LV to set pull-up voltage\n");
|
||||
}
|
||||
#endif
|
||||
usart_enable(busvoodoo_uart_generic_specific->usart); // enable USART
|
||||
|
@ -358,7 +358,7 @@ static void busvoodoo_uart_generic_read(void)
|
|||
if (busvoodoo_uart_generic_specific->rx_pre) {
|
||||
(*busvoodoo_uart_generic_specific->rx_pre)();
|
||||
}
|
||||
printf("read: ");
|
||||
puts("read: ");
|
||||
while (!(USART_SR(busvoodoo_uart_generic_specific->usart) & USART_SR_RXNE) && !user_input_available); // wait for incoming data to be available (or user input to exit)
|
||||
if ((USART_SR(busvoodoo_uart_generic_specific->usart) & USART_SR_RXNE)) { // verify if data has been received
|
||||
busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // enable blue LED to show reception
|
||||
|
@ -369,19 +369,19 @@ static void busvoodoo_uart_generic_read(void)
|
|||
// display data
|
||||
printf("'%c'/0x%02x", input, input);
|
||||
// display errors
|
||||
printf("(");
|
||||
putc('(');
|
||||
if (error_noise) {
|
||||
printf("noise");
|
||||
puts("noise");
|
||||
} else if (error_framing) {
|
||||
printf("framing");
|
||||
puts("framing");
|
||||
} else if (usart_enhanced_parity_error(busvoodoo_uart_generic_specific->usart)) {
|
||||
printf("parity");
|
||||
puts("parity");
|
||||
} else {
|
||||
printf("no");
|
||||
puts("no");
|
||||
}
|
||||
printf(" error)");
|
||||
puts(" error)");
|
||||
}
|
||||
printf("\n");
|
||||
putc('\n');
|
||||
if (user_input_available) { // user interrupted flow
|
||||
user_input_get(); // discard user input
|
||||
}
|
||||
|
@ -499,14 +499,14 @@ static bool busvoodoo_uart_generic_action(const char* action, uint32_t repetitio
|
|||
static void busvoodoo_uart_generic_command_actions(void* argument)
|
||||
{
|
||||
if (NULL == argument || 0 == strlen(argument)) {
|
||||
printf("available actions (separated by space or ,):\n");
|
||||
printf("0\twrite decimal value\n");
|
||||
printf("0x0\twrite hexadecimal value\n");
|
||||
printf("0b0\twrite binary value\n");
|
||||
printf("\"a\"/'a'\twrite ASCII characters\n");
|
||||
printf("r\tread value\n");
|
||||
printf("u/m\twait 1 us/ms\n");
|
||||
printf(":n\trepeat action n times\n");
|
||||
puts("available actions (separated by space or ,):\n");
|
||||
puts("0\twrite decimal value\n");
|
||||
puts("0x0\twrite hexadecimal value\n");
|
||||
puts("0b0\twrite binary value\n");
|
||||
puts("\"a\"/'a'\twrite ASCII characters\n");
|
||||
puts("r\tread value\n");
|
||||
puts("u/m\twait 1 us/ms\n");
|
||||
puts(":n\trepeat action n times\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -518,9 +518,9 @@ static void busvoodoo_uart_generic_command_actions(void* argument)
|
|||
strncpy(copy, argument, strlen(argument) + 1);
|
||||
// verify and perform actions
|
||||
if (!busvoodoo_global_actions(copy, false, &busvoodoo_uart_generic_action)) { // verify actions
|
||||
printf("malformed action(s)\n");
|
||||
puts("malformed action(s)\n");
|
||||
} else { // action are ok
|
||||
printf("press any key to exit\n");
|
||||
puts("press any key to exit\n");
|
||||
busvoodoo_global_actions(argument, true, &busvoodoo_uart_generic_action); // perform action
|
||||
if (user_input_available) { // user interrupted flow
|
||||
user_input_get(); // discard user input
|
||||
|
@ -543,11 +543,11 @@ static void busvoodoo_uart_generic_command_transmit(void* argument)
|
|||
if (NULL == argument || 0 == strlen(argument)) { // nothing to transmit
|
||||
argument = "\r\n"; // transmit CR+LF
|
||||
}
|
||||
printf("press any key to exit\n");
|
||||
puts("press any key to exit\n");
|
||||
for (uint16_t i = 0; ((char*)(argument))[i] && !user_input_available; i++) {
|
||||
while ((0 == (USART_SR(busvoodoo_uart_generic_specific->usart) & USART_SR_TXE) && !user_input_available)); // wait for transmit buffer to be empty
|
||||
if (USART_SR(busvoodoo_uart_generic_specific->usart) & USART_SR_TXE) { // we can send a character
|
||||
printf("%c", ((char*)(argument))[i]); // echo character to transmit
|
||||
putc(((char*)(argument))[i]); // echo character to transmit
|
||||
busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // pulse blue LED to show transmission
|
||||
usart_enhanced_send(busvoodoo_uart_generic_specific->usart, ((char*)(argument))[i]); // transmit character
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ static void busvoodoo_uart_generic_command_transmit(void* argument)
|
|||
user_input_get(); // discard user input
|
||||
}
|
||||
if (strcmp(argument, "\r\n")) {
|
||||
printf("\n");
|
||||
putc('\n');
|
||||
}
|
||||
if (busvoodoo_uart_generic_specific->tx_post) {
|
||||
(*busvoodoo_uart_generic_specific->tx_post)();
|
||||
|
@ -577,7 +577,7 @@ static void busvoodoo_uart_generic_command_receive(void* argument)
|
|||
} else if (0 == strcmp(argument, "b") || 0 == strcmp(argument, "bin")) { // user wants binary display
|
||||
display_bin = true; // remember to display in binary
|
||||
} else {
|
||||
printf("malformed argument\n");
|
||||
puts("malformed argument\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ static void busvoodoo_uart_generic_command_receive(void* argument)
|
|||
if (busvoodoo_uart_generic_specific->rx_pre) {
|
||||
(*busvoodoo_uart_generic_specific->rx_pre)();
|
||||
}
|
||||
printf("press any key to exit\n");
|
||||
puts("press any key to exit\n");
|
||||
while (!user_input_available) { // check for user input to exit
|
||||
if ((USART_SR(busvoodoo_uart_generic_specific->usart) & USART_SR_RXNE)) { // verify if data has been received
|
||||
uint8_t input = usart_enhanced_recv(busvoodoo_uart_generic_specific->usart); // receive character
|
||||
|
@ -602,7 +602,7 @@ static void busvoodoo_uart_generic_command_receive(void* argument)
|
|||
}
|
||||
}
|
||||
user_input_get(); // discard user input
|
||||
printf("\n"); // get to next line
|
||||
putc('\n'); // get to next line
|
||||
if (busvoodoo_uart_generic_specific->rx_post) {
|
||||
(*busvoodoo_uart_generic_specific->rx_post)();
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ static void busvoodoo_uart_generic_command_transceive(void* argument)
|
|||
if (busvoodoo_uart_generic_specific->rx_pre) {
|
||||
(*busvoodoo_uart_generic_specific->rx_pre)();
|
||||
}
|
||||
printf("press 5 times escape to exit\n");
|
||||
puts("press 5 times escape to exit\n");
|
||||
char last_c = 0; // last user character received
|
||||
uint8_t esc_count = 0; // number of times escape has press received
|
||||
while (true) { // check for escape sequence
|
||||
|
@ -659,10 +659,10 @@ static void busvoodoo_uart_generic_command_transceive(void* argument)
|
|||
if ((USART_SR(busvoodoo_uart_generic_specific->usart) & USART_SR_RXNE)) { // verify if data has been received
|
||||
char input = usart_enhanced_recv(busvoodoo_uart_generic_specific->usart); // receive character
|
||||
busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // enable blue LED to show reception
|
||||
printf("%c", input); // print received character
|
||||
putc(input); // print received character
|
||||
}
|
||||
}
|
||||
printf("\n"); // get to next line
|
||||
putc('\n'); // get to next line
|
||||
if (busvoodoo_uart_generic_specific->rx_post) {
|
||||
(*busvoodoo_uart_generic_specific->rx_post)();
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ static void busvoodoo_uart_generic_command_transceive(void* argument)
|
|||
static void busvoodoo_uart_generic_command_error(void* argument)
|
||||
{
|
||||
(void)argument; // argument not used
|
||||
printf("press any key to exit\n");
|
||||
puts("press any key to exit\n");
|
||||
while (!user_input_available) { // wait until user interrupt
|
||||
busvoodoo_uart_generic_read(); // read incoming data (this also checks for errors
|
||||
}
|
||||
|
@ -750,11 +750,11 @@ static void busvoodoo_uart_generic_command_detect(void* argument)
|
|||
{
|
||||
(void)argument; // argument not used
|
||||
if (!busvoodoo_uart_generic_specific->timer) {
|
||||
printf("baud rate detection not possible (no timer available)\n");
|
||||
puts("baud rate detection not possible (no timer available)\n");
|
||||
return;
|
||||
}
|
||||
printf("the more traffic is incoming, the better the detection\n");
|
||||
printf("press any key to exit\n");
|
||||
puts("the more traffic is incoming, the better the detection\n");
|
||||
puts("press any key to exit\n");
|
||||
|
||||
// setup USART to receive character
|
||||
uint8_t uart_databits = 8; // start with 8 bits since this is the most common case (i.e. no additional parity bit is used)
|
||||
|
@ -973,7 +973,7 @@ static void busvoodoo_uart_generic_command_detect(void* argument)
|
|||
// print received data if a configuration has been found
|
||||
if (uart_configuration_valid < LENGTH(uart_configurations)) { // valid configuration existing
|
||||
if (uart_configurations[uart_configuration_valid].databits >= 7 && usart_data_relevant < 0x80) { // this is probably valid ASCII data
|
||||
printf("%c", usart_data_relevant);
|
||||
putc(usart_data_relevant);
|
||||
} else {
|
||||
printf("0x%02x ", usart_data_relevant);
|
||||
}
|
||||
|
@ -983,7 +983,7 @@ static void busvoodoo_uart_generic_command_detect(void* argument)
|
|||
}
|
||||
}
|
||||
user_input_get(); // clear input used to interrupt previous loop
|
||||
printf("\n");
|
||||
putc('\n');
|
||||
|
||||
// switch off RX
|
||||
if (busvoodoo_uart_generic_specific->rx_post) {
|
||||
|
|
Loading…
Reference in New Issue