25 #include <libopencmsis/core_cm3.h> 26 #include <libopencm3/stm32/gpio.h> 27 #include <libopencm3/stm32/rcc.h> 28 #include <libopencm3/stm32/dbgmcu.h> 29 #include <libopencm3/stm32/desig.h> 30 #include <libopencm3/stm32/dac.h> 40 #define BUSVOODOO_LV_DEFAULT (0.8*(1+30.0/10.0)) 41 #define BUSVOODOO_LV_TEST 2.5 42 #define BUSVOODOO_HV_DEFAULT (1.25*(1+100.0/10.0)) 43 #define BUSVOODOO_HV_TEST 12.0 50 static bool busvoodoo_hiz_setup(char** prefix, const char* line) 56 const char* pinout_io[10] = {
"GND",
"5V",
"3V3",
"LV", NULL, NULL, NULL, NULL, NULL, NULL};
61 const char* pinout_rscan[5] = {
"HV", NULL, NULL, NULL, NULL};
83 bool to_return =
false;
93 if (0==(DBGMCU_IDCODE&DBGMCU_IDCODE_DEV_ID_MASK)) {
95 }
else if (0x414!=(DBGMCU_IDCODE&DBGMCU_IDCODE_DEV_ID_MASK)) {
96 printf(
"this (DEV_ID=%03x) is not a high-density device: a wrong micro-controller might have been used\n", (DBGMCU_IDCODE&DBGMCU_IDCODE_DEV_ID_MASK));
99 if (0xffff==DESIG_FLASH_SIZE) {
100 printf(
"unknown flash size: this is probably a defective micro-controller\n");
106 printf(
"5V power rail voltage is too low: %.2fV\n", voltage);
112 }
else if (voltage>5.5) {
113 printf(
"5V power rail voltage is too high: %.2fV\n", voltage);
124 printf(
"3.3V power rail voltage is too low: %.2fV\n", voltage);
130 }
else if (voltage>3.6) {
131 printf(
"3.3V power rail voltage is too high: %.2fV\n", voltage);
143 printf(
"5V power rail voltage is too low when 5V output is enabled: %.2fV\n", voltage);
149 }
else if (voltage>5.5) {
150 printf(
"5V power rail voltage is too high when 5V output is enabled: %.2fV\n", voltage);
159 printf(
"3.3V power rail voltage is too low when 3V3 output is enabled: %.2fV\n", voltage);
165 }
else if (voltage>3.6) {
166 printf(
"3.3V power rail voltage is too high when 3V3 is enabled: %.2fV\n", voltage);
178 printf(
"LV voltage is %.2fV instead of 0V when the regulator is disabled\n", voltage);
228 printf(
"HV voltage is %.2fV instead of 0V when the regulator is disabled\n", voltage);
372 printf(
"5V power rail voltage is too low when used to pull up: %.2fV\n", voltage);
378 }
else if (voltage>5.5) {
379 printf(
"5V power rail voltage is too high when used to pull up: %.2fV\n", voltage);
446 printf(
"RS-485 RX is high while TX is set low\n");
458 printf(
"RS-485 RX is low while TX is set high\n");
483 printf(
"CAN RX is low while TX is set high\n");
495 printf(
"CAN RX is high while TX is set low\n");
505 printf(
"CAN RX is low while the output should be back to recessive\n");
525 printf(
"the test procedure has been aborted for safety reasons\n");
536 bool to_return =
false;
539 const char* lv_to =
"connect I/O pin 4 to ";
540 char* pinout[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
547 printf(
"%sI/O pin 1\n", lv_to);
564 printf(
"I/O pin 4 is high while it should be low and shorted to ground\n");
576 printf(
"%sI/O pin 2\n", lv_to);
591 printf(
"5V output is high while the power output should be switched off\n");
602 printf(
"%sI/O pin 3\n", lv_to);
617 printf(
"3V3 output is high while the power output should be switched off\n");
627 for (uint8_t io=1; io<=6; io++) {
632 printf(
"%sI/O pin %u\n", lv_to, io+4);
647 printf(
"I/O pin %u is high while it should be low\n", io+4);
671 printf(
"%sRS/CAN pin 1\n", lv_to);
687 printf(
"HV output is high while voltage regulator should be switched off\n");
700 printf(
"%sRS/CAN pin 3\n", lv_to);
715 printf(
"RS-485 output A is high while it should be low\n");
735 printf(
"CAN L output is low while it should be at recessive 2.5V\n");
743 printf(
"CAN L output is high while it should be at recessive 2.5V\n");
755 printf(
"CAN L output is high while it should at dominant <2.25V\n");
770 printf(
"%sRS/CAN pin 4\n", lv_to);
785 printf(
"RS-485 output B is high while it should be low\n");
805 printf(
"CAN H output is low while it should be at recessive 2.5V\n");
813 printf(
"CAN H output is high while it should be at recessive 2.5V\n");
825 printf(
"CAN H output is low while it dominant >2.75V\n");
826 printf(
"%.02f\n", voltage);
852 printf(
"connect RS/CAN pin 2 to RS/CAN pin 3\n");
869 printf(
"RS-232 RX is high while it should be set low by RS-232 TX\n");
888 printf(
"connect RS/CAN pin 4 to RS/CAN pin 5\n");
905 printf(
"RS-232 CTS is high while it should be set low by RS-232 RTS\n");
927 printf(
"user interrupted the test\n");
931 printf(
"the test procedure has been aborted for safety reasons\n");
946 RCC_CSR |= RCC_CSR_RMVF;
961 printf(
"device ID: %08x%08x%08x\n", DESIG_UNIQUE_ID0, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID2);
971 printf(
"performing self-test\n");
972 printf(
"remove all cables from connectors and press space to start (or any other key to abort)\n");
977 printf(
"self-test succeeded\n");
980 printf(
"self-test failed\n");
983 printf(
"self-test aborted\n");
993 printf(
"performing pins test\n");
994 printf(
"remove all cables from connectors and press space to start (or any other key to abort)\n");
999 printf(
"pins test succeeded\n");
1001 led_blink(0.5, 0.5);
1002 printf(
"pins test failed\n");
1005 printf(
"pins test aborted\n");
1014 "show hardware and firmware version",
1022 "reboot into DFU bootloader",
1030 "perform board self-test",
1038 "perform connector pins test",
1047 "High Impedance (Z)",
#define BUSVOODOO_5V_CHANNEL
ADC channel to measure 3.3V rail.
float busvoodoo_hv_set(float voltage)
set voltage on high voltage adjustable voltage regulator
#define BUSVOODOO_LV_TEST
target LV output voltage to test if we can set control the LV voltage regulator
static void busvoodoo_hiz_bootloader(void *argument)
switch to DFU bootloader
#define BUSVOODOO_HVCTL_CHANNEL
DAC channel to control HV output voltage.
static const struct menu_command_t busvoodoo_hiz_commands[]
HiZ menu commands.
BusVoodoo global definitions and methods (API)
#define BUSVOODOO_HVEN_PIN
high voltage (HV) enable pin (active low)
#define RCC_GPIO(x)
get RCC for GPIO based on GPIO identifier
void busvoodoo_oled_text_pinout(const char *pins[10], bool io_connector)
draw pin names on bottom (blue) part in display buffer
#define BUSVOODOO_LVCTL_PORT
pin to control LV output voltage
bool busvoodoo_vout_switch(bool on)
switch 3V3 and 5V power outputs on I/O connector
#define BUSVOODOO_RS232_EN_PORT
RS-232 pin to enable receiver (active low, pulled up)
#define BUSVOODOO_HV_SET(x)
voltage to output for the DAC to set the desired HV output voltage (based on resistor values on the H...
static bool busvoodoo_hiz_test_pins(void)
test if signals are soldered correctly to the connector pins
#define BUSVOODOO_HVEN_PORT
high voltage (HV) enable pin (active low)
#define BUSVOODOO_RS232_CTS_PORT
RS-232 Clear-To-Send input pin.
void busvoodoo_oled_update(void)
update OLED display RAM with current display buffer
float busvoodoo_lv_set(float voltage)
set voltage on low voltage adjustable voltage regulator
struct busvoodoo_mode_t busvoodoo_hiz_mode
HiZ mode interface definition.
#define BUSVOODOO_LVEN_PIN
low voltage (LV) enable pin (active high)
const char * busvoodoo_global_pinout_rscan[5]
RS/CAN connector pinout.
const uint32_t busvoodoo_io_pins[13]
pin of individual signals
static bool busvoodoo_hiz_test_self(void)
perform self tests
#define BUSVOODOO_RS232_TX_PORT
RS-232 Transmit output pin.
global definitions and methods (API)
enum menu_argument_t argument
what kind of argument it accepts
static void busvoodoo_hiz_exit(void)
exit HiZ mode
#define GPIO(x)
get GPIO based on GPIO identifier
#define BUSVOODOO_RS485_RX_PORT
RS-485 Receive input pin.
void sleep_us(uint32_t duration)
go to sleep for some microseconds
static void busvoodoo_hiz_command_test_self(void *argument)
command to perform board self-test
#define BUSVOODOO_HV_DEFAULT
default (when not driven) HV voltage regulator output voltage based on R1 and R2
#define BUSVOODOO_CAN_EN_PORT
signal to power CAN transceiver (active low, pulled high)
#define BUSVOODOO_RS485_RE_PORT
RS-485 pin to enable receiver (active low, pulled up)
bool busvoodoo_full
is the BusVoodoo board fully populated (with HV voltage regulator, RS-232, RS-485, CAN transceiver on the back side)
static void busvoodoo_hiz_version(void *argument)
show BusVoodoo version
const uint32_t busvoodoo_io_ports[13]
port of individual signals
#define BUSVOODOO_RS485_TX_PORT
RS-485 Transmit output pin.
#define BUSVOODOO_RS232_CTS_PIN
RS-232 Clear-To-Send input pin.
#define BUSVOODOO_LV_CHANNEL
ADC channel to measure LV rail.
#define BUSVOODOO_RS232_TX_PIN
RS-232 Transmit output pin.
#define BUSVOODOO_RS485_DE_PORT
RS-485 pin to enable transmitter (active high, pulled low)
#define BUSVOODOO_RS232_RTS_PIN
RS-232 Request-To-Send output pin.
const uint8_t busvoodoo_io_groups[13]
which I/O pin (group) does the signal belong to
#define BUSVOODOO_CAN_RX_PIN
CAN Receive input pin.
#define BUILD_MONTH
build month as number if known, or 0 if unknown
#define BUSVOODOO_HV_CHANNEL
ADC channel to measure HV rail.
const char * busvoodoo_global_pinout_io[10]
I/O connector pinout.
#define BUSVOODOO_LVCTL_PIN
pin to control LV output voltage
char user_input_get(void)
get user input
#define BUSVOODOO_RS232_EN_PIN
RS-232 pin to enable receiver (active low, pulled up)
static bool busvoodoo_hiz_setup(char **prefix, const char *line)
setup HiZ mode
float busvoodoo_vreg_get(uint8_t channel)
read voltage from power rail
const char * busvoodoo_io_names[13]
I/O individual signal names.
#define BUSVOODOO_VOUTEN_PORT
voltage output (5V and 3.3V) enable pin (active low)
void sleep_ms(uint32_t duration)
go to sleep for some milliseconds
#define BUSVOODOO_CAN_TX_PIN
CAN Transmit output pin.
size_t printf(const char *format,...)
print format string on user output
#define BUSVOODOO_VOUTEN_PIN
voltage output (5V and 3.3V) enable pin (active low)
#define BUSVOODOO_RS232_RX_PORT
RS-232 Receive input pin.
printing utilities to replace the large printf from the standard library (API)
#define BUSVOODOO_RS485_DE_PIN
RS-485 pin to enable transmitter (active high, pulled low)
void busvoodoo_oled_text_left(char *text)
draw mode text on top (yellow) left side in display buffer
#define BUSVOODOO_LVEN_PORT
low voltage (LV) enable pin (active high)
float busvoodoo_embedded_pullup(bool on)
enable embedded pull-up resistors
#define BUSVOODOO_HV_TEST
target HV output voltage to test if we can set control the HV voltage regulator
#define BUSVOODOO_RS232_RTS_PORT
RS-232 Request-To-Send output pin.
#define LENGTH(x)
get the length of an array
#define BUSVOODOO_RS485_RE_PIN
RS-485 pin to enable receiver (active low, pulled up)
#define BUSVOODOO_CAN_RX_PORT
CAN Receive input pin.
void busvoodoo_oled_text_right(char *text)
draw mode text on top (yellow) right side in display buffer
#define BUSVOODOO_RS232_RX_PIN
RS-232 Receive input pin.
#define BUSVOODOO_LV_DEFAULT
default (when not driven) LV voltage regulator output voltage based on R1 and R2
BusVoodoo high impedance (HiZ) default mode (API)
#define BUSVOODOO_RS485_RX_PIN
RS-485 Receive input pin.
library to show BusVoodoo mode information on SSD1306 OLED display: name, activity, pinout (API)
static void busvoodoo_hiz_command_test_pins(void *argument)
command to perform pins test
volatile bool user_input_available
flag set when user input is available
#define BUSVOODOO_RS485_TX_PIN
RS-485 Transmit output pin.
void busvoodoo_safe_state(void)
set safe state by disabling all outputs
#define BUILD_YEAR
build year as number if known, or 0 if unknown
char busvoodoo_version
version of the hardware board
BusVoodoo mode interface.
#define BUSVOODOO_RS232_SHDN_PORT
RS-232 pin to enable transmitter (active high, pulled low)
#define BUSVOODOO_3V3_CHANNEL
ADC channel to measure 5V rail.
#define BUSVOODOO_RS232_SHDN_PIN
RS-232 pin to enable transmitter (active high, pulled low)
#define BUILD_DAY
build day as number if known, or 0 if unknown
#define BUSVOODOO_CAN_TX_PORT
CAN Transmit output pin.
#define BUSVOODOO_CAN_EN_PIN
signal to power CAN transceiver (active low, pulled high)