busvoodoo_hiz: minor, replace printf with puts

This commit is contained in:
King Kévin 2020-03-09 15:17:50 +01:00
parent 7a874bdb77
commit 4194af4e10
1 changed files with 42 additions and 42 deletions

View File

@ -106,7 +106,7 @@ static bool busvoodoo_hiz_test_self(bool halt)
}
// ensure flash size is ok
if (0xffff == DESIG_FLASH_SIZE) {
printf("unknown flash size: this is probably a defective micro-controller\n");
puts("unknown flash size: this is probably a defective micro-controller\n");
}
#if BUSVOODOO_HARDWARE_VERSION != 2
@ -339,7 +339,7 @@ static bool busvoodoo_hiz_test_self(bool halt)
gpio_clear(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO(BUSVOODOO_RS485_TX_PIN)); // set TX low
sleep_us(100); // let voltage settle
if (gpio_get(GPIO(BUSVOODOO_RS485_RX_PORT), GPIO(BUSVOODOO_RS485_RX_PIN))) { // test if RX is still high
printf("RS-485 RX is high while TX is set low\n"); // warn user about the error
puts("RS-485 RX is high while TX is set low\n"); // warn user about the error
goto error;
}
// test high signal
@ -347,7 +347,7 @@ static bool busvoodoo_hiz_test_self(bool halt)
gpio_set(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO(BUSVOODOO_RS485_TX_PIN)); // set TX high
sleep_us(100); // let voltage settle
if (0 == gpio_get(GPIO(BUSVOODOO_RS485_RX_PORT), GPIO(BUSVOODOO_RS485_RX_PIN))) { // test if RX is still low
printf("RS-485 RX is low while TX is set high\n"); // warn user about the error
puts("RS-485 RX is low while TX is set high\n"); // warn user about the error
goto error;
}
// release transceiver
@ -369,7 +369,7 @@ static bool busvoodoo_hiz_test_self(bool halt)
gpio_set(GPIO(BUSVOODOO_CAN_TX_PORT), GPIO(BUSVOODOO_CAN_TX_PIN)); // set TX high
sleep_us(100); // let voltage settle
if (0 == gpio_get(GPIO(BUSVOODOO_CAN_RX_PORT), GPIO(BUSVOODOO_CAN_RX_PIN))) { // test if RX is still low
printf("CAN RX is low while TX is set high\n"); // warn user about the error
puts("CAN RX is low while TX is set high\n"); // warn user about the error
goto error;
}
// test low signal
@ -377,13 +377,13 @@ static bool busvoodoo_hiz_test_self(bool halt)
gpio_clear(GPIO(BUSVOODOO_CAN_TX_PORT), GPIO(BUSVOODOO_CAN_TX_PIN)); // set TX low
sleep_us(100); // let voltage settle
if (gpio_get(GPIO(BUSVOODOO_CAN_RX_PORT), GPIO(BUSVOODOO_CAN_RX_PIN))) { // test if RX is still high
printf("CAN RX is high while TX is set low\n"); // warn user about the error
puts("CAN RX is high while TX is set low\n"); // warn user about the error
goto error;
}
// test dominant timeout
sleep_ms(10); // after 5 ms the output should be switched back from dominant to recessive respite TX being low
if (!gpio_get(GPIO(BUSVOODOO_CAN_RX_PORT), GPIO(BUSVOODOO_CAN_RX_PIN))) { // test if RX is now low
printf("CAN RX is low while the output should be back to recessive\n"); // warn user about the error
puts("CAN RX is low while the output should be back to recessive\n"); // warn user about the error
goto error;
}
// release transceiver
@ -395,14 +395,14 @@ static bool busvoodoo_hiz_test_self(bool halt)
#endif // BUSVOODOO_HARDWARE_VERSION != 2
to_return = true; // all tests are successful
printf("self-test succeeded\n"); // notify user
puts("self-test succeeded\n"); // notify user
error:
if (!to_return) {
if (halt) { // halt on error if requested
busvoodoo_leds_blink(0.5, 0.5); // show error on LEDs
while (!user_input_available); // wait for user input
} else {
printf("the test procedure has been aborted for safety reasons\n");
puts("the test procedure has been aborted for safety reasons\n");
}
}
busvoodoo_safe_state(); // set back to safe state
@ -449,7 +449,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_set_mode(GPIO(BUSVOODOO_LVCTL_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(BUSVOODOO_LVCTL_PIN)); // set LV control pin as output
sleep_ms(100); // wait for voltage to settle an debounce
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 0.2) {
printf("I/O pin 4 is high while it should be low and shorted to ground\n");
puts("I/O pin 4 is high while it should be low and shorted to ground\n");
goto error;
}
gpio_set_mode(GPIO(BUSVOODOO_LVCTL_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO(BUSVOODOO_LVCTL_PIN)); // set LV control pin back to analog input for DAC
@ -484,7 +484,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_set(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // disable Vout
sleep_ms(100); // wait for voltage to settle and debounce
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 0.2) {
printf("5V output is high while the power output should be switched off\n");
puts("5V output is high while the power output should be switched off\n");
goto error;
}
pinout[1] = NULL; // clear pin to test
@ -517,7 +517,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_set(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // disable Vout
sleep_ms(100); // wait for voltage to settle and debounce
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 0.2) {
printf("3V3 output is high while the power output should be switched off\n");
puts("3V3 output is high while the power output should be switched off\n");
goto error;
}
pinout[2] = NULL; // clear pin to test
@ -589,7 +589,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
dac_disable(BUSVOODOO_HVCTL_CHANNEL); // disable HV control
sleep_ms(100); // wait for voltage to settle (and debounce)
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 0.2) {
printf("HV output is high while voltage regulator should be switched off\n");
puts("HV output is high while voltage regulator should be switched off\n");
goto error;
}
pinout[0] = NULL; // clear pin to test
@ -616,7 +616,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_set(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO(BUSVOODOO_RS485_TX_PIN)); // set TX high
sleep_ms(100); // wait for voltage to settle (and debounce)
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 1.0) {
printf("RS-485 output B is high while it should be low\n");
puts("RS-485 output B is high while it should be low\n");
goto error;
}
gpio_clear(GPIO(BUSVOODOO_RS485_DE_PORT), GPIO(BUSVOODOO_RS485_DE_PIN)); // set low to disable transmitter
@ -644,7 +644,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_clear(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO(BUSVOODOO_RS485_TX_PIN)); // set TX low
sleep_ms(100); // wait for voltage to settle (and debounce)
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 1.0) {
printf("RS-485 output A is high while it should be low\n");
puts("RS-485 output A is high while it should be low\n");
goto error;
}
gpio_clear(GPIO(BUSVOODOO_RS485_DE_PORT), GPIO(BUSVOODOO_RS485_DE_PIN)); // set low to disable transmitter
@ -662,11 +662,11 @@ static bool busvoodoo_hiz_test_pins(bool halt)
sleep_us(100); // let voltage settle
voltage = busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // get output voltage
if (voltage < 0.4) { // normally the lower limit is 2V, put pin 4 pulls it down because it is not strongly driven
printf("CAN L output is low while it should be at recessive 2.5V\n");
puts("CAN L output is low while it should be at recessive 2.5V\n");
goto error;
}
if (voltage > 3.0) { // normally the upper limit is 3V
printf("CAN L output is high while it should be at recessive 2.5V\n");
puts("CAN L output is high while it should be at recessive 2.5V\n");
goto error;
}
// test dominant output
@ -674,7 +674,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
sleep_us(100); // let voltage settle
voltage = busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // get output voltage
if (voltage > 2.5) {
printf("CAN L output is high while it should at dominant <2.25V\n");
puts("CAN L output is high while it should at dominant <2.25V\n");
goto error;
}
// release transceiver
@ -704,7 +704,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_clear(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO(BUSVOODOO_RS485_TX_PIN)); // set TX low
sleep_ms(100); // wait for voltage to settle (and debounce)
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 1.0) {
printf("RS-485 output A is high while it should be low\n");
puts("RS-485 output A is high while it should be low\n");
goto error;
}
gpio_clear(GPIO(BUSVOODOO_RS485_DE_PORT), GPIO(BUSVOODOO_RS485_DE_PIN)); // set low to disable transmitter
@ -732,7 +732,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_set(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO(BUSVOODOO_RS485_TX_PIN)); // set TX high
sleep_ms(100); // wait for voltage to settle (and debounce)
if (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 1.0) {
printf("RS-485 output B is high while it should be low\n");
puts("RS-485 output B is high while it should be low\n");
goto error;
}
gpio_clear(GPIO(BUSVOODOO_RS485_DE_PORT), GPIO(BUSVOODOO_RS485_DE_PIN)); // set low to disable transmitter
@ -750,11 +750,11 @@ static bool busvoodoo_hiz_test_pins(bool halt)
sleep_us(100); // let voltage settle
voltage = busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // get output voltage
if (voltage < 0.5) { // normally the lower limit is 2V, put pin 4 pulls it down because it is not strongly driven
printf("CAN H output is low while it should be at recessive 2.5V\n");
puts("CAN H output is low while it should be at recessive 2.5V\n");
goto error;
}
if (voltage > 3.0) { // normally the upper limit is 3V
printf("CAN H output is high while it should be at recessive 2.5V\n");
puts("CAN H output is high while it should be at recessive 2.5V\n");
goto error;
}
// test dominant output
@ -762,7 +762,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
sleep_us(100); // let voltage settle
voltage = busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // get output voltage
if (voltage < 2.5) {
printf("CAN H output is low while it dominant >2.75V\n");
puts("CAN H output is low while it dominant >2.75V\n");
printf("%.02f\n", voltage);
goto error;
}
@ -786,7 +786,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_clear(GPIO(BUSVOODOO_RS232_TX_PORT), GPIO(BUSVOODOO_RS232_TX_PIN)); // set low
gpio_set(GPIO(BUSVOODOO_RS232_RX_PORT), GPIO(BUSVOODOO_RS232_RX_PIN)); // pull high to avoid false negative
sleep_ms(5);
printf("connect RS/CAN pin 2 to RS/CAN pin 3\n");
puts("connect RS/CAN pin 2 to RS/CAN pin 3\n");
busvoodoo_leds_off(); // clear LEDs
busvoodoo_led_red_on(); // notify user to perform action
pinout[2] = "O"; // set target testing pin
@ -805,7 +805,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_clear(GPIO(BUSVOODOO_RS232_RX_PORT), GPIO(BUSVOODOO_RS232_RX_PIN)); // pull low to avoid false negative
sleep_ms(100); // wait for voltage to settle and debounce
if (!gpio_get(GPIO(BUSVOODOO_RS232_RX_PORT), GPIO(BUSVOODOO_RS232_RX_PIN))) { // check if RX is set low by TX
printf("RS-232 RX is high while it should be set low by RS-232 TX\n");
puts("RS-232 RX is high while it should be set low by RS-232 TX\n");
goto error;
}
gpio_set_mode(GPIO(BUSVOODOO_RS232_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_TX_PIN)); // free pin
@ -820,7 +820,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
// start by setting low since unconnected (pulled to ground by 3 kO) is considered as high
gpio_clear(GPIO(BUSVOODOO_RS232_RTS_PORT), GPIO(BUSVOODOO_RS232_RTS_PIN)); // set low
gpio_set(GPIO(BUSVOODOO_RS232_CTS_PORT), GPIO(BUSVOODOO_RS232_CTS_PIN)); // pull high to avoid false negative
printf("connect RS/CAN pin 4 to RS/CAN pin 5\n");
puts("connect RS/CAN pin 4 to RS/CAN pin 5\n");
busvoodoo_leds_off(); // clear LEDs
busvoodoo_led_red_on(); // notify user to perform action
pinout[6] = "O"; // set target testing pin
@ -839,7 +839,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
gpio_clear(GPIO(BUSVOODOO_RS232_CTS_PORT), GPIO(BUSVOODOO_RS232_CTS_PIN)); // pull low to avoid false negative
sleep_ms(100); // wait for voltage to settle an debounce
if (!gpio_get(GPIO(BUSVOODOO_RS232_CTS_PORT), GPIO(BUSVOODOO_RS232_CTS_PIN))) { // check if CTS is set high by RTS
printf("RS-232 CTS is high while it should be set low by RS-232 RTS\n");
puts("RS-232 CTS is high while it should be set low by RS-232 RTS\n");
goto error;
}
gpio_set_mode(GPIO(BUSVOODOO_RS232_RTS_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_RTS_PIN)); // free pin
@ -855,13 +855,13 @@ static bool busvoodoo_hiz_test_pins(bool halt)
error:
if (!to_return) {
if (user_input_available) {
printf("user interrupted the test\n");
puts("user interrupted the test\n");
to_return = true; // we don't consider this as error
} else if (halt) { // halt on error if requested
busvoodoo_leds_blink(0.5, 0.5); // show error on LEDs
while (!user_input_available); // wait for user input
} else {
printf("the test procedure has been aborted for safety reasons\n");
puts("the test procedure has been aborted for safety reasons\n");
}
}
busvoodoo_safe_state(); // go back to safe state
@ -912,31 +912,31 @@ static void busvoodoo_hiz_command_test_self(void* argument)
if (0 == strcmp(argument, "halt")) {
halt = true;
} else {
printf("malformed argument\n");
puts("malformed argument\n");
return;
}
}
printf("performing self-test\n");
puts("performing self-test\n");
if (halt) {
printf("WARNING: halting on error can cause hardware damages (press any key to exit halt state)\n");
puts("WARNING: halting on error can cause hardware damages (press any key to exit halt state)\n");
}
printf("remove all cables from connectors and press space to start (or any other key to abort)\n");
puts("remove all cables from connectors and press space to start (or any other key to abort)\n");
busvoodoo_leds_off(); // clear LEDs
busvoodoo_led_red_on(); // show red LED to indicate test started
if (' ' == user_input_get()) { // space entered
printf("self-test running\n");
puts("self-test running\n");
if (busvoodoo_hiz_test_self(halt)) { // perform self-test
busvoodoo_led_red_off(); // clear red LED
busvoodoo_led_blue_on(); // show blue to indicate test passed
} else {
busvoodoo_leds_blink(0.5, 0.5); // show error on LEDs
printf("self-test failed\n"); // notify user
puts("self-test failed\n"); // notify user
if (user_input_available) {
user_input_get(); // clear user input
}
}
} else {
printf("self-test aborted\n");
puts("self-test aborted\n");
}
}
@ -950,13 +950,13 @@ static void busvoodoo_hiz_command_test_pins(void* argument)
if (0 == strcmp(argument, "halt")) {
halt = true;
} else {
printf("malformed argument\n");
puts("malformed argument\n");
return;
}
}
printf("performing pins test\n");
puts("performing pins test\n");
if (halt) {
printf("WARNING: halting on error can cause hardware damages (press any key to exit halt state)\n");
puts("WARNING: halting on error can cause hardware damages (press any key to exit halt state)\n");
}
busvoodoo_leds_off(); // clear LEDs
busvoodoo_led_red_on(); // show red LED to indicate test started
@ -967,21 +967,21 @@ static void busvoodoo_hiz_command_test_pins(void* argument)
busvoodoo_oled_text_pinout((const char**)pinout, true); // reset pinout
busvoodoo_oled_update(); // update screen
#endif
printf("connect one lead of jumper wire to I/O pin 4 and press space to start (or any other key to abort)\n");
puts("connect one lead of jumper wire to I/O pin 4 and press space to start (or any other key to abort)\n");
if (' ' == user_input_get()) { // space entered
if (busvoodoo_hiz_test_pins(halt)) { // perform pin test
busvoodoo_led_red_off(); // clear red LED
busvoodoo_led_blue_on(); // show blue OK LED
printf("pins test succeeded\n"); // notify user
puts("pins test succeeded\n"); // notify user
} else {
busvoodoo_leds_blink(0.5, 0.5); // show error on LEDs
printf("pins test failed\n"); // notify user
puts("pins test failed\n"); // notify user
if (user_input_available) {
user_input_get(); // clear user input
}
}
} else {
printf("pins test aborted\n");
puts("pins test aborted\n");
busvoodoo_led_red_off(); // clear red LED
busvoodoo_led_blue_on(); // switch back to main blue LED
}