busvoodoo_onewire: minor, replace printf with puts

This commit is contained in:
King Kévin 2020-03-09 14:32:30 +01:00
parent b64845ef16
commit d9ae0d0fa2
1 changed files with 18 additions and 18 deletions

View File

@ -65,8 +65,8 @@ static bool busvoodoo_onewire_setup(char** prefix, const char* line)
switch (busvoodoo_onewire_setting) { switch (busvoodoo_onewire_setting) {
case BUSVOODOO_ONEWIRE_SETTING_NONE: case BUSVOODOO_ONEWIRE_SETTING_NONE:
busvoodoo_onewire_setting = BUSVOODOO_ONEWIRE_SETTING_PULLUP; // go to first setting busvoodoo_onewire_setting = BUSVOODOO_ONEWIRE_SETTING_PULLUP; // go to first setting
printf("1) use embedded pull-up resistor (2kO)\n"); puts("1) use embedded pull-up resistor (2kO)\n");
printf("2) use external pull-up resistor\n"); puts("2) use external pull-up resistor\n");
snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "pull-up mode (1,2) [%c]", busvoodoo_onewire_embedded_pullup ? '1' : '2'); // show pull-up setting snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "pull-up mode (1,2) [%c]", busvoodoo_onewire_embedded_pullup ? '1' : '2'); // show pull-up setting
*prefix = busvoodoo_global_string; // display next setting *prefix = busvoodoo_global_string; // display next setting
break; break;
@ -81,8 +81,8 @@ static bool busvoodoo_onewire_setup(char** prefix, const char* line)
} }
} }
if (BUSVOODOO_ONEWIRE_SETTING_POWER==busvoodoo_onewire_setting) { if (BUSVOODOO_ONEWIRE_SETTING_POWER==busvoodoo_onewire_setting) {
printf("1) don't drive 1-wire data line (target uses external or parasitic power)\n"); puts("1) don't drive 1-wire data line (target uses external or parasitic power)\n");
printf("2) power 1-wire data line at 3.3V when not communicating (not multi-master compatible)\n"); puts("2) power 1-wire data line at 3.3V when not communicating (not multi-master compatible)\n");
snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "power source (1,2) [%c]", busvoodoo_onewire_power ? '2' : '1'); // show power setting snprintf(busvoodoo_global_string, LENGTH(busvoodoo_global_string), "power source (1,2) [%c]", busvoodoo_onewire_power ? '2' : '1'); // show power setting
*prefix = busvoodoo_global_string; // display next setting *prefix = busvoodoo_global_string; // display next setting
} }
@ -107,7 +107,7 @@ static bool busvoodoo_onewire_setup(char** prefix, const char* line)
if (!busvoodoo_onewire_power) { if (!busvoodoo_onewire_power) {
busvoodoo_embedded_pullup(true); // set embedded pull-ups 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");
} }
busvoodoo_led_blue_off(); // disable blue LED because there is no activity busvoodoo_led_blue_off(); // disable blue LED because there is no activity
busvoodoo_onewire_setting = BUSVOODOO_ONEWIRE_SETTING_NONE; // restart settings next time busvoodoo_onewire_setting = BUSVOODOO_ONEWIRE_SETTING_NONE; // restart settings next time
@ -145,9 +145,9 @@ static void busvoodoo_onewire_write(uint8_t value)
printf("write: 0x%02x", value); printf("write: 0x%02x", value);
busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // pulse blue LED to show we are writing busvoodoo_led_blue_pulse(BUSVOODOO_LED_PULSE); // pulse blue LED to show we are writing
if (!onewire_master_write_byte(value)) { // send data bytes if (!onewire_master_write_byte(value)) { // send data bytes
printf(" (error)"); puts(" (error)");
} }
printf("\n"); putc('\n');
} }
/** read from 1-wire /** read from 1-wire
@ -200,7 +200,7 @@ static bool busvoodoo_onewire_action(const char* action, uint32_t repetition, bo
//if (!gpio_get(GPIO(ONEWIRE_MASTER_PORT), GPIO(ONEWIRE_MASTER_PIN))) { //if (!gpio_get(GPIO(ONEWIRE_MASTER_PORT), GPIO(ONEWIRE_MASTER_PIN))) {
// printf("WARNING: data line does not seem to be pulled up\n"); // printf("WARNING: data line does not seem to be pulled up\n");
//} //}
printf("start transaction: "); puts("start transaction: ");
bool presence = onewire_master_reset(); // send reset pulse and detect slave presence bool presence = onewire_master_reset(); // send reset pulse and detect slave presence
printf("slave presence %sdetected\n", presence ? "" : "not "); printf("slave presence %sdetected\n", presence ? "" : "not ");
} else if (1 == length && ']' == action[0]) { // stop transaction } else if (1 == length && ']' == action[0]) { // stop transaction
@ -302,16 +302,16 @@ static bool busvoodoo_onewire_action(const char* action, uint32_t repetition, bo
static void busvoodoo_onewire_command_actions(void* argument) static void busvoodoo_onewire_command_actions(void* argument)
{ {
if (NULL == argument || 0 == strlen(argument)) { if (NULL == argument || 0 == strlen(argument)) {
printf("available actions (separated by space or ,):\n"); puts("available actions (separated by space or ,):\n");
printf("[\tstart transaction: send reset pulse and detect slave presence\n"); puts("[\tstart transaction: send reset pulse and detect slave presence\n");
printf("]\tend transaction%s\n", busvoodoo_onewire_power ? " and provide power on data line" : ""); printf("]\tend transaction%s\n", busvoodoo_onewire_power ? " and provide power on data line" : "");
printf("0\twrite decimal byte\n"); puts("0\twrite decimal byte\n");
printf("0x0\twrite hexadecimal byte\n"); puts("0x0\twrite hexadecimal byte\n");
printf("0b0\twrite binary byte\n"); puts("0b0\twrite binary byte\n");
printf("\"a\"/'a'\twrite ASCII characters\n"); puts("\"a\"/'a'\twrite ASCII characters\n");
printf("r\tread byte\n"); puts("r\tread byte\n");
printf("u/m\twait 1 us/ms\n"); puts("u/m\twait 1 us/ms\n");
printf(":n\trepeat action n times\n"); puts(":n\trepeat action n times\n");
return; return;
} }
// copy argument since it will be modified // copy argument since it will be modified
@ -322,7 +322,7 @@ static void busvoodoo_onewire_command_actions(void* argument)
strncpy(copy, argument, strlen(argument)+1); strncpy(copy, argument, strlen(argument)+1);
// verify and perform actions // verify and perform actions
if (!busvoodoo_global_actions(copy, false, &busvoodoo_onewire_action)) { // verify actions if (!busvoodoo_global_actions(copy, false, &busvoodoo_onewire_action)) { // verify actions
printf("malformed action(s)\n"); puts("malformed action(s)\n");
} else { // action are OK } else { // action are OK
busvoodoo_global_actions(argument, true, &busvoodoo_onewire_action); // perform action busvoodoo_global_actions(argument, true, &busvoodoo_onewire_action); // perform action
} }