busvoodoo_global: add definitions for dongle and remove unsupported features

This commit is contained in:
King Kévin 2020-03-09 12:56:24 +01:00
parent 2ed71d68e5
commit d911103ee7
2 changed files with 182 additions and 84 deletions

View File

@ -57,7 +57,7 @@ static volatile bool busvoodoo_global_led_red_timer = false;
static volatile bool busvoodoo_global_led_blinking = false;
/** hardware version voltages, calculated from divider ratios, starting with version A */
static const float busvoodoo_version_voltages[] = {100.0/(10.0+100.0)*3.3}; // version A start with revision 27
static const float busvoodoo_version_voltages[] = {100.0/(10.0+100.0)*3.3, 0.0}; // version A start with revision 27
const char* busvoodoo_global_pinout_io[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
const char* busvoodoo_global_pinout_rscan[5] = {NULL, NULL, NULL, NULL, NULL};
@ -81,6 +81,7 @@ void busvoodoo_setup(void)
rcc_periph_clock_enable(RCC_AFIO); // enable clock for alternate function (for communication)
busvoodoo_safe_state(); // put pins in safe state (for common light version)
#if BUSVOODOO_HARDWARE_VERSION != 2
// check if this BusVoodoo is a full flavor
rcc_periph_clock_enable(RCC_ADC12_IN(BUSVOODOO_HV_CHANNEL)); // enable clock for GPIO domain for HV channel
gpio_set(ADC12_IN_PORT(BUSVOODOO_HV_CHANNEL), ADC12_IN_PIN(BUSVOODOO_HV_CHANNEL)); // pull ADC HV high
@ -92,8 +93,10 @@ void busvoodoo_setup(void)
busvoodoo_full = true;
busvoodoo_safe_state(); // also put the full version pins in safe state
}
#endif
// setup ADC to measure the 5V, 3.3V, LV, and HV power rails voltages, and hardware version channel
#if BUSVOODOO_HARDWARE_VERSION != 2
rcc_periph_clock_enable(RCC_ADC12_IN(BUSVOODOO_5V_CHANNEL)); // enable clock for GPIO domain for 5V channel
gpio_set_mode(ADC12_IN_PORT(BUSVOODOO_5V_CHANNEL), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, ADC12_IN_PIN(BUSVOODOO_5V_CHANNEL)); // set 5V channel as analogue input for the ADC
rcc_periph_clock_enable(RCC_ADC12_IN(BUSVOODOO_3V3_CHANNEL)); // enable clock for GPIO domain for 3.3V channel
@ -104,6 +107,10 @@ void busvoodoo_setup(void)
gpio_set_mode(ADC12_IN_PORT(BUSVOODOO_HV_CHANNEL), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, ADC12_IN_PIN(BUSVOODOO_HV_CHANNEL)); // set HV channel as analogue input for the ADC
rcc_periph_clock_enable(RCC_ADC12_IN(BUSVOODOO_HW_VERSION_CHANNEL)); // enable clock for GPIO domain for hardware version channel
gpio_set_mode(ADC12_IN_PORT(BUSVOODOO_HW_VERSION_CHANNEL), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, ADC12_IN_PIN(BUSVOODOO_HW_VERSION_CHANNEL)); // set hardware version channel as analogue input for the ADC
#else
rcc_periph_clock_enable(RCC_ADC12_IN(BUSVOODOO_ADC_CHANNEL)); // enable clock for GPIO domain for ADC channel
gpio_set_mode(ADC12_IN_PORT(BUSVOODOO_ADC_CHANNEL), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, ADC12_IN_PIN(BUSVOODOO_ADC_CHANNEL)); // set ADC channel as analogue input for the ADC
#endif
rcc_periph_clock_enable(RCC_ADC1); // enable clock for ADC domain
adc_power_off(ADC1); // switch off ADC while configuring it
adc_disable_scan_mode(ADC1); // ensure scan mode is disabled
@ -136,6 +143,7 @@ void busvoodoo_setup(void)
}
}
#if BUSVOODOO_HARDWARE_VERSION != 2
// setup DAC to control LV and HV voltage outputs
gpio_set_mode(GPIO(BUSVOODOO_LVCTL_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO(BUSVOODOO_LVCTL_PIN)); // set LV pin as analog (the DAC will use it as output)
rcc_periph_clock_enable(RCC_DAC); // enable clock for DAC domain
@ -148,6 +156,7 @@ void busvoodoo_setup(void)
}
dac_set_trigger_source(DAC_CR_TSEL1_SW); // use software to trigger the voltage change
dac_set_trigger_source(DAC_CR_TSEL2_SW); // use software to trigger the voltage change
#endif
// enable timer for LED pulsing or blinking
rcc_periph_clock_enable(RCC_TIM(BUSVOODOO_LED_TIMER)); // enable clock for timer domain
@ -170,6 +179,7 @@ void busvoodoo_setup(void)
void busvoodoo_safe_state(void)
{
#if BUSVOODOO_HARDWARE_VERSION != 2
// disable voltage outputs
gpio_set(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // disable 5V and 3.3V output on connector
gpio_set_mode(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_VOUTEN_PIN)); // set pin as output (open-drain pulled high to disable the pMOS)
@ -188,12 +198,16 @@ void busvoodoo_safe_state(void)
gpio_set_mode(GPIO(BUSVOODOO_5VPULLUP_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_5VPULLUP_PIN)); // set pin as output (open-drain pulled high to disable the pMOS)
gpio_set(GPIO(BUSVOODOO_OEPULLUP_PORT), GPIO(BUSVOODOO_OEPULLUP_PIN)); // set pin high to disable embedded pull-up bus switch
gpio_set_mode(GPIO(BUSVOODOO_OEPULLUP_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_OEPULLUP_PIN)); // set pin as output (open-drain pulled high to disable the bus switch)
#else
gpio_set_mode(GPIO_PORT(BUSVOODOO_I2C_PULLUP_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(BUSVOODOO_I2C_PULLUP_PIN)); // per default don't drive to pull up
#endif
// disable all signal I/O outputs
for (uint8_t pin=0; pin<LENGTH(busvoodoo_io_ports) && pin<LENGTH(busvoodoo_io_pins); pin++) {
gpio_set_mode(busvoodoo_io_ports[pin], GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, busvoodoo_io_pins[pin]); // set pin back to input (floating)
}
#if BUSVOODOO_HARDWARE_VERSION != 2
if (busvoodoo_full) {
// disable RS-232 signals
gpio_set_mode(GPIO(BUSVOODOO_RS232_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS232_TX_PIN)); // set pin to floating
@ -213,14 +227,15 @@ void busvoodoo_safe_state(void)
gpio_set_mode(GPIO(BUSVOODOO_RS485_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS485_TX_PIN)); // set pin to floating
gpio_set_mode(GPIO(BUSVOODOO_RS485_RX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_RS485_RX_PIN)); // set pin to floating
#if BUSVOODOO_HARDWARE_VERSION!=0
#if BUSVOODOO_HARDWARE_VERSION != 0
// disable CAN transceiver and signals (put back to input floating)
gpio_set_mode(GPIO(BUSVOODOO_CAN_TX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_TX_PIN)); // set pin to floating
gpio_set_mode(GPIO(BUSVOODOO_CAN_RX_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_RX_PIN)); // set pin to floating
gpio_set(GPIO(BUSVOODOO_CAN_EN_PORT), GPIO(BUSVOODOO_CAN_EN_PIN)); // set high to power off transceiver
gpio_set_mode(GPIO(BUSVOODOO_CAN_EN_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO(BUSVOODOO_CAN_EN_PIN)); // use external pull-up resistor to set high by default
#endif
#endif // BUSVOODOO_HARDWARE_VERSION != 0
}
#endif // BUSVOODOO_HARDWARE_VERSION != 2
}
void busvoodoo_text_style(enum busvoodoo_text_style_t style)
@ -242,6 +257,91 @@ void busvoodoo_text_style(enum busvoodoo_text_style_t style)
}
}
float busvoodoo_vreg_get(uint8_t channel)
{
#if BUSVOODOO_HARDWARE_VERSION != 2
if (channel!=BUSVOODOO_5V_CHANNEL && channel!=BUSVOODOO_3V3_CHANNEL && channel!=BUSVOODOO_LV_CHANNEL && channel!=BUSVOODOO_HV_CHANNEL && channel!=BUSVOODOO_HW_VERSION_CHANNEL) { // check channel
#else
if (channel != BUSVOODOO_ADC_CHANNEL && channel!=BUSVOODOO_HW_VERSION_CHANNEL) { // check channel
#endif
return NAN;
}
// start by reading the internal voltage
uint8_t channels[1] = {ADC_CHANNEL17}; // voltages to convert: internal
adc_set_regular_sequence(ADC1, LENGTH(channels), channels); // set channel to convert
ADC_SR(ADC1) = 0; // reset flags
adc_start_conversion_direct(ADC1); // start conversion (without using trigger)
while (!adc_eoc(ADC1)); // wait until conversion finished
uint16_t internal_value = adc_read_regular(ADC1); // read voltage value (clears flag)
// read desired voltage
switch (channel) {
#if BUSVOODOO_HARDWARE_VERSION != 2
case BUSVOODOO_5V_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_5V_CHANNEL);
break;
case BUSVOODOO_3V3_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_3V3_CHANNEL);
break;
case BUSVOODOO_LV_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_LV_CHANNEL);
break;
case BUSVOODOO_HV_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_HV_CHANNEL);
break;
#else
case BUSVOODOO_ADC_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_ADC_CHANNEL);
break;
#endif
case BUSVOODOO_HW_VERSION_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_HW_VERSION_CHANNEL);
break;
default: // unknown channel
return NAN;
}
adc_set_regular_sequence(ADC1, LENGTH(channels), channels); // set channel to convert
ADC_SR(ADC1) = 0; // reset flags
adc_start_conversion_direct(ADC1); // start conversion (without using trigger)
while (!adc_eoc(ADC1)); // wait until conversion finished
uint16_t desired_value = adc_read_regular(ADC1); // read voltage value (clears flag)
// calculate desired voltage
float to_return = NAN; // voltage to return
switch (channel) { // get converted value and calculate according to the voltage divider on this channel
#if BUSVOODOO_HARDWARE_VERSION != 2
case BUSVOODOO_5V_CHANNEL:
to_return = desired_value/(10.0/(10.0+10.0));
break;
case BUSVOODOO_3V3_CHANNEL:
to_return = desired_value/(10.0/(10.0+10.0));
break;
case BUSVOODOO_LV_CHANNEL:
to_return = desired_value/(10.0/(10.0+10.0));
break;
case BUSVOODOO_HV_CHANNEL:
to_return = desired_value/(1.5/(10.0+1.5));
break;
#else
case BUSVOODOO_ADC_CHANNEL:
to_return = desired_value/(1.5/(10.0+1.5));
break;
#endif
case BUSVOODOO_HW_VERSION_CHANNEL:
to_return = desired_value;
break;
default: // unknown channel
to_return = NAN;
break;
}
if (!isnan(to_return)) {
to_return *= 1.2/internal_value; // calculate voltage from converted values using internal 1.2V voltage reference
}
return to_return;
}
#if BUSVOODOO_HARDWARE_VERSION != 2
bool busvoodoo_vout_switch(bool on)
{
if (on) { // we need to switch on Vout
@ -263,74 +363,6 @@ bool busvoodoo_vout_switch(bool on)
return to_return;
}
float busvoodoo_vreg_get(uint8_t channel)
{
if (channel!=BUSVOODOO_5V_CHANNEL && channel!=BUSVOODOO_3V3_CHANNEL && channel!=BUSVOODOO_LV_CHANNEL && channel!=BUSVOODOO_HV_CHANNEL && channel!=BUSVOODOO_HW_VERSION_CHANNEL) { // check channel
return NAN;
}
// start by reading the internal voltage
uint8_t channels[1] = {ADC_CHANNEL17}; // voltages to convert: internal
adc_set_regular_sequence(ADC1, LENGTH(channels), channels); // set channel to convert
ADC_SR(ADC1) = 0; // reset flags
adc_start_conversion_direct(ADC1); // start conversion (without using trigger)
while (!adc_eoc(ADC1)); // wait until conversion finished
uint16_t internal_value = adc_read_regular(ADC1); // read voltage value (clears flag)
// read desired voltage
switch (channel) {
case BUSVOODOO_5V_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_5V_CHANNEL);
break;
case BUSVOODOO_3V3_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_3V3_CHANNEL);
break;
case BUSVOODOO_LV_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_LV_CHANNEL);
break;
case BUSVOODOO_HV_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_HV_CHANNEL);
break;
case BUSVOODOO_HW_VERSION_CHANNEL:
channels[0] = ADC_CHANNEL(BUSVOODOO_HW_VERSION_CHANNEL);
break;
default: // unknown channel
return NAN;
}
adc_set_regular_sequence(ADC1, LENGTH(channels), channels); // set channel to convert
ADC_SR(ADC1) = 0; // reset flags
adc_start_conversion_direct(ADC1); // start conversion (without using trigger)
while (!adc_eoc(ADC1)); // wait until conversion finished
uint16_t desired_value = adc_read_regular(ADC1); // read voltage value (clears flag)
// calculate desired voltage
float to_return = NAN; // voltage to return
switch (channel) { // get converted value and calculate according to the voltage divider on this channel
case BUSVOODOO_5V_CHANNEL:
to_return = desired_value/(10.0/(10.0+10.0));
break;
case BUSVOODOO_3V3_CHANNEL:
to_return = desired_value/(10.0/(10.0+10.0));
break;
case BUSVOODOO_LV_CHANNEL:
to_return = desired_value/(10.0/(10.0+10.0));
break;
case BUSVOODOO_HV_CHANNEL:
to_return = desired_value/(1.5/(10.0+1.5));
break;
case BUSVOODOO_HW_VERSION_CHANNEL:
to_return = desired_value;
break;
default: // unknown channel
to_return = NAN;
break;
}
if (!isnan(to_return)) {
to_return *= 1.2/internal_value; // calculate voltage from converted values using internal 1.2V voltage reference
}
return to_return;
}
float busvoodoo_lv_set(float voltage)
{
float volt = NAN; // common variable for voltages
@ -388,15 +420,26 @@ float busvoodoo_hv_set(float voltage)
return volt; // return measured voltage
}
#endif // BUSVOODOO_HARDWARE_VERSION != 2
float busvoodoo_embedded_pullup(bool on)
{
#if BUSVOODOO_HARDWARE_VERSION != 2
if (on) { // enable embedded pull-ups
gpio_clear(GPIO(BUSVOODOO_OEPULLUP_PORT), GPIO(BUSVOODOO_OEPULLUP_PIN)); // switch on embedded pull-ups
} else { // disable embedded pull-ups
gpio_set(GPIO(BUSVOODOO_OEPULLUP_PORT), GPIO(BUSVOODOO_OEPULLUP_PIN)); // switch off embedded pull-up
}
return busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // set voltage on adjustable voltage regulator to be used by the embedded pull-ups
return busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // get voltage on adjustable voltage regulator to be used by the embedded pull-ups
#else
if (on) { // enable embedded pull-ups
gpio_set(GPIO_PORT(BUSVOODOO_I2C_PULLUP_PIN), GPIO_PIN(BUSVOODOO_I2C_PULLUP_PIN)); // pull up
gpio_set_mode(GPIO_PORT(BUSVOODOO_I2C_PULLUP_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(BUSVOODOO_I2C_PULLUP_PIN)); // set pin to output push-pull do drive pull-up resistors
} else { // disable embedded pull-ups
gpio_set_mode(GPIO_PORT(BUSVOODOO_I2C_PULLUP_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(BUSVOODOO_I2C_PULLUP_PIN)); // stop driving the pull-up resistors
}
return 3.3;
#endif
}
/** update LED status according to LED flags */
@ -564,12 +607,16 @@ void busvoodoo_leds_blink(double period, double duty)
static void busvoodoo_global_power_led_update(void)
{
bool power_led_on = false; // to calculate the final state of the power LED
#if BUSVOODOO_HARDWARE_VERSION != 2
power_led_on |= !gpio_get(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // check power rails output
power_led_on |= !gpio_get(GPIO(BUSVOODOO_5VPULLUP_PORT), GPIO(BUSVOODOO_5VPULLUP_PIN)); // check 5V output on LV pin
power_led_on |= gpio_get(GPIO(BUSVOODOO_LVEN_PORT), GPIO(BUSVOODOO_LVEN_PIN)); // check if low-voltage regulator is on
if (!busvoodoo_full) {
power_led_on |= !gpio_get(GPIO(BUSVOODOO_HVEN_PORT), GPIO(BUSVOODOO_HVEN_PIN)); // check if high-voltage regulator is on
}
#else
power_led_on = true; // the output can't be switched off
#endif
if (power_led_on) {
busvoodoo_led_red_on(); // switch on red LED to indicate one of the power output is on
} else {
@ -639,6 +686,7 @@ bool busvoodoo_global_actions(char* actions, bool perform, bool (*action_handler
/* command handlers */
#if BUSVOODOO_HARDWARE_VERSION != 2
/** switch 3V3 and 5V power rails on/off
* @param[in] argument string: "on" to switch on, "off" to switch off, NULL to get status
*/
@ -748,6 +796,23 @@ static void busvoodoo_global_hv(void* argument)
}
busvoodoo_global_power_led_update(); // update power output LED
}
#else // BUSVOODOO_HARDWARE_VERSION != 2
/** show voltage on ADC pin
* @param[in] argument not required
*/
static void busvoodoo_global_adc(void* argument)
{
(void)argument; // argument not used
float voltage = busvoodoo_vreg_get(BUSVOODOO_ADC_CHANNEL); // get ADC voltage
// print ADC voltage
if (voltage < 0.1) {
printf(": 0.00V\n");
} else {
printf(": %.2fV\n", voltage);
}
busvoodoo_global_power_led_update(); // update power output LED
}
#endif // BUSVOODOO_HARDWARE_VERSION != 2
/** display I/O and RS/CAN connector pinouts
* @param[in] argument not used
@ -757,6 +822,7 @@ static void busvoodoo_global_pinout(void* argument)
(void)argument; // argument is not used
bool no_pinout = true; // it no pinout has been displays
#if BUSVOODOO_HARDWARE_VERSION != 2
// display RS/CAN connector pinout
if (busvoodoo_full) { // only display on full version of the board
bool pin_used = false; // if no pins are used
@ -804,6 +870,7 @@ static void busvoodoo_global_pinout(void* argument)
no_pinout = false; // remember a pinout has been shown
}
}
#endif
// display I/O connector pinout
bool pin_used = false; // if no pins are used
@ -905,6 +972,7 @@ const struct menu_command_t busvoodoo_global_commands[] = {
.argument_description = NULL,
.command_handler = &busvoodoo_global_pinout,
},
#if BUSVOODOO_HARDWARE_VERSION != 2
{
.shortcut = 'P',
.name = "power",
@ -921,10 +989,21 @@ const struct menu_command_t busvoodoo_global_commands[] = {
.argument_description = "[voltage]",
.command_handler = &busvoodoo_global_lv,
},
#else
{
.shortcut = 'A',
.name = "adc",
.command_description = "read voltage on ADC pin",
.argument = MENU_ARGUMENT_NONE,
.argument_description = NULL,
.command_handler = &busvoodoo_global_adc,
},
#endif
};
const uint8_t busvoodoo_global_commands_nb = LENGTH(busvoodoo_global_commands);
#if BUSVOODOO_HARDWARE_VERSION != 2
const struct menu_command_t busvoodoo_global_full_commands[] = {
{
.shortcut = 'H',
@ -937,3 +1016,4 @@ const struct menu_command_t busvoodoo_global_full_commands[] = {
};
const uint8_t busvoodoo_global_full_commands_nb = LENGTH(busvoodoo_global_full_commands);
#endif

View File

@ -12,15 +12,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/** BusVoodoo global definitions and methods (API)
* @file busvoodoo_global.h
/** BusVoodoo global definitions and methods
* @file
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2018
* @date 2018-2020
* @note peripherals used: time @ref busvoodoo_led_timer
*/
#pragma once
#include "menu.h"
#if BUSVOODOO_HARDWARE_VERSION != 2
/** @defgroup busvoodoo_voltages pin to control voltage regulators and pull-ups definitions
* @{
*/
@ -39,8 +40,8 @@
/** @defgroup busvoodoo_adc ADC inputs to measure voltages from voltage regulators
* @{
*/
#define BUSVOODOO_3V3_CHANNEL 12 /**< ADC channel to measure 5V rail */
#define BUSVOODOO_5V_CHANNEL 9 /**< ADC channel to measure 3.3V rail */
#define BUSVOODOO_3V3_CHANNEL 12 /**< ADC channel to measure 3.3VV rail */
#define BUSVOODOO_5V_CHANNEL 9 /**< ADC channel to measure 5V rail */
#define BUSVOODOO_LV_CHANNEL 11 /**< ADC channel to measure LV rail */
#define BUSVOODOO_HV_CHANNEL 15 /**< ADC channel to measure HV rail */
/** @} */
@ -88,7 +89,7 @@
#define BUSVOODOO_RS485_RX_PIN 3 /**< RS-485 Receive input pin */
/** @} */
#if BUSVOODOO_HARDWARE_VERSION!=0
#if BUSVOODOO_HARDWARE_VERSION != 0
/** @defgroup busvoodoo_can CAN transceiver connection definition
* @{
*/
@ -99,7 +100,16 @@
#define BUSVOODOO_CAN_RX_PORT B /**< CAN Receive input pin */
#define BUSVOODOO_CAN_RX_PIN 8 /**< CAN Receive input pin */
/** @} */
#endif
#endif // BUSVOODOO_HARDWARE_VERSION != 0
#else // BUSVOODOO_HARDWARE_VERSION != 2
/** pin to directly pull up I²C lines (resistors are optional) */
#define BUSVOODOO_I2C_PULLUP_PIN PA15
/** @defgroup busvoodoo_adc ADC inputs to measure voltages
* @{
*/
#define BUSVOODOO_ADC_CHANNEL 9 /**< ADC channel to measure ADC input */
/** @} */
#endif // BUSVOODOO_HARDWARE_VERSION != 2
/** @defgroup busvoodoo_version ADC pin used to identify hardware version based on voltage
*/
@ -147,15 +157,19 @@ extern char busvoodoo_version;
extern const struct menu_command_t busvoodoo_global_commands[];
/** number supported commands for base BusVoodoo */
extern const uint8_t busvoodoo_global_commands_nb;
#if BUSVOODOO_HARDWARE_VERSION != 2
/** list of supported commands for BusVoodoo full only */
extern const struct menu_command_t busvoodoo_global_full_commands[];
/** number supported commands for BusVoodoo full only */
extern const uint8_t busvoodoo_global_full_commands_nb;
#endif
/** I/O connector pinout */
extern const char* busvoodoo_global_pinout_io[10];
#if BUSVOODOO_HARDWARE_VERSION != 2
/** RS/CAN connector pinout */
extern const char* busvoodoo_global_pinout_rscan[5];
#endif
/** shared string buffer, i.e. used when configuring modes */
extern char busvoodoo_global_string[64];
@ -169,16 +183,18 @@ void busvoodoo_safe_state(void);
* @note uses ANSII escape codes
*/
void busvoodoo_text_style(enum busvoodoo_text_style_t style);
/** switch 3V3 and 5V power outputs on I/O connector
* @param[in] on switch on (true) or off (false) power output
* @return if switching succeeded. else it means there is a probably a short on one of the outputs
*/
bool busvoodoo_vout_switch(bool on);
/** read voltage from power rail
* @param[in] channel which power rail to read voltage from @ref busvoodoo_adc
* @return voltage, or NaN if channel is invalid (or error happened)
*/
float busvoodoo_vreg_get(uint8_t channel);
#if BUSVOODOO_HARDWARE_VERSION != 2
/** switch 3V3 and 5V power outputs on I/O connector
* @param[in] on switch on (true) or off (false) power output
* @return if switching succeeded. else it means there is a probably a short on one of the outputs
*/
bool busvoodoo_vout_switch(bool on);
/** set voltage on low voltage adjustable voltage regulator
* @note for voltages above 4.85V it will use the 5.0V from USB
* @param[in] voltage voltage to set on adjustable voltage regulator (0, 0.3-4.8, 5V)
@ -190,12 +206,14 @@ float busvoodoo_lv_set(float voltage);
* @return voltage output, or NaN if error happened
*/
float busvoodoo_hv_set(float voltage);
#endif // BUSVOODOO_HARDWARE_VERSION != 2
/** enable embedded pull-up resistors
* @note the embedded pull-up resistor use the voltage on the LV power rail (set or externally provided)
* @param[in] on enable (true) or disable (false) embedded pull-up resistors
* @return voltage applied on pull-up resistors, or NaN if channel is invalid (or error happened)
*/
float busvoodoo_embedded_pullup(bool on);
/** switch on blue LED
* @note the red LED is handled independently
* @note this will stop the blinking pattern