busvoodoo_hiz: kick dog on user input + wait for disconnect
This commit is contained in:
parent
db98878e63
commit
7d8c5fbd72
|
@ -29,6 +29,7 @@
|
|||
#include <libopencm3/stm32/dbgmcu.h> // debug utilities
|
||||
#include <libopencm3/stm32/desig.h> // design utilities
|
||||
#include <libopencm3/stm32/dac.h> // DAC utilities
|
||||
#include <libopencm3/stm32/iwdg.h> // independent watchdog utilities
|
||||
|
||||
/* own libraries */
|
||||
#include "global.h" // board definitions
|
||||
|
@ -132,7 +133,9 @@ static bool busvoodoo_hiz_test_self(bool halt)
|
|||
printf("5V power rail voltage is too low: %.2fV\n", voltage);
|
||||
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
|
||||
while (!user_input_available) { // wait for user input
|
||||
iwdg_reset(); // kick the dog
|
||||
}
|
||||
}
|
||||
goto error;
|
||||
} else if (voltage > 5.5) {
|
||||
|
@ -416,7 +419,9 @@ 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
|
||||
while (!user_input_available) { // wait for user input
|
||||
iwdg_reset(); // kick the dog
|
||||
}
|
||||
} else {
|
||||
puts("the test procedure has been aborted for safety reasons\n");
|
||||
}
|
||||
|
@ -426,6 +431,23 @@ error:
|
|||
return to_return;
|
||||
}
|
||||
|
||||
#if BUSVOODOO_HARDWARE_VERSION == 2
|
||||
// make life easier since the ADC is the same
|
||||
#define BUSVOODOO_LV_CHANNEL BUSVOODOO_ADC_CHANNEL
|
||||
#endif
|
||||
|
||||
/** wait until pin 4/LV/ADC is disconnected
|
||||
* @return if it is interrupted by user input
|
||||
*/
|
||||
static bool busvoodoo_hiz_wait_pin4_disconnected(void)
|
||||
{
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 0.2 && !user_input_available); // wait until pin is disconnected
|
||||
return user_input_available;
|
||||
}
|
||||
|
||||
/** test if signals are soldered correctly to the connector pins
|
||||
* @param[in] halt halt on error instead of exiting immediately (exit on user input)
|
||||
* @return if pin test passed
|
||||
|
@ -454,6 +476,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, true); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 0.2 && !user_input_available); // wait until pin is shorted to ground
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -470,15 +493,11 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
}
|
||||
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
|
||||
pinout[0] = NULL; // clear pin to test
|
||||
#else
|
||||
// we can't test ground on pin 1 using pin 4 because it is already pulled low
|
||||
#endif
|
||||
|
||||
// test 5V output on pin 2
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
gpio_clear(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // enable Vout
|
||||
#else
|
||||
#define BUSVOODOO_LV_CHANNEL BUSVOODOO_ADC_CHANNEL
|
||||
#endif
|
||||
printf("%sI/O pin 2\n", lv_to);
|
||||
busvoodoo_leds_off(); // clear LEDs
|
||||
|
@ -488,7 +507,11 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, true); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
#endif
|
||||
if (busvoodoo_hiz_wait_pin4_disconnected()) {
|
||||
goto error;
|
||||
}
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 0.2 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -518,10 +541,15 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, true); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
#endif
|
||||
if (busvoodoo_hiz_wait_pin4_disconnected()) {
|
||||
goto error;
|
||||
}
|
||||
do {
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while ((busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 0.2 || busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 3.5) && !user_input_available); // wait until pin is connected
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for stable connection
|
||||
} while ((busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 0.2 || busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) > 3.5) && !user_input_available); // check to be sure it really is not on the 5V pin
|
||||
busvoodoo_led_red_on(); // clear red LED
|
||||
|
@ -553,7 +581,11 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, true); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
#endif
|
||||
if (busvoodoo_hiz_wait_pin4_disconnected()) {
|
||||
goto error;
|
||||
}
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 0.2 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -594,6 +626,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 0.2 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -622,6 +655,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 2.0 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -650,6 +684,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 2.0 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -710,6 +745,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 2.0 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -738,6 +774,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL) < 2.0 && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -810,6 +847,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (gpio_get(GPIO(BUSVOODOO_RS232_RX_PORT), GPIO(BUSVOODOO_RS232_RX_PIN)) && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -844,6 +882,7 @@ static bool busvoodoo_hiz_test_pins(bool halt)
|
|||
busvoodoo_oled_text_pinout((const char**)pinout, false); // display pins to user
|
||||
busvoodoo_oled_update(); // update screen
|
||||
do {
|
||||
iwdg_reset(); // kick the dog
|
||||
sleep_ms(100); // wait for user to make connection
|
||||
} while (gpio_get(GPIO(BUSVOODOO_RS232_CTS_PORT), GPIO(BUSVOODOO_RS232_CTS_PIN)) && !user_input_available); // wait until pin is connected
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
@ -875,7 +914,9 @@ error:
|
|||
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
|
||||
while (!user_input_available) { // wait for user input
|
||||
iwdg_reset(); // kick the dog
|
||||
}
|
||||
} else {
|
||||
puts("the test procedure has been aborted for safety reasons\n");
|
||||
}
|
||||
|
@ -939,6 +980,9 @@ static void busvoodoo_hiz_command_test_self(void* argument)
|
|||
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
|
||||
while (!user_input_available) { // wait for user input
|
||||
iwdg_reset(); // kick the dog
|
||||
}
|
||||
if (' ' == user_input_get()) { // space entered
|
||||
puts("self-test running\n");
|
||||
if (busvoodoo_hiz_test_self(halt)) { // perform self-test
|
||||
|
@ -984,6 +1028,9 @@ static void busvoodoo_hiz_command_test_pins(void* argument)
|
|||
busvoodoo_oled_update(); // update screen
|
||||
#endif
|
||||
puts("connect one lead of jumper wire to I/O pin 4 and press space to start (or any other key to abort)\n");
|
||||
while (!user_input_available) { // wait for user input
|
||||
iwdg_reset(); // kick the dog
|
||||
}
|
||||
if (' ' == user_input_get()) { // space entered
|
||||
if (busvoodoo_hiz_test_pins(halt)) { // perform pin test
|
||||
busvoodoo_led_red_off(); // clear red LED
|
||||
|
|
Loading…
Reference in New Issue