CuVoodoo STM32F1 firmware template
Data Structures | Macros | Functions | Variables
busvoodoo_global.h File Reference

BusVoodoo global definitions and methods (API) More...

Go to the source code of this file.

Data Structures

struct  busvoodoo_mode_t
 BusVoodoo mode interface. More...
 

Macros

#define BUSVOODOO_5VPULLUP_PORT   B
 5V pull-up enable pin (active low)
 
#define BUSVOODOO_5VPULLUP_PIN   4
 5V pull-up enable pin (active low)
 
#define BUSVOODOO_OEPULLUP_PORT   A
 bus switch output enable pin to enable embedded pull-ups (active low)
 
#define BUSVOODOO_OEPULLUP_PIN   15
 bus switch output enable pin to enable embedded pull-ups (active low)
 
#define BUSVOODOO_LVEN_PORT   A
 low voltage (LV) enable pin (active high)
 
#define BUSVOODOO_LVEN_PIN   6
 low voltage (LV) enable pin (active high)
 
#define BUSVOODOO_HVEN_PORT   A
 high voltage (HV) enable pin (active low)
 
#define BUSVOODOO_HVEN_PIN   7
 high voltage (HV) enable pin (active low)
 
#define BUSVOODOO_VOUTEN_PORT   B
 voltage output (5V and 3.3V) enable pin (active low)
 
#define BUSVOODOO_VOUTEN_PIN   3
 voltage output (5V and 3.3V) enable pin (active low)
 
#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_LV_CHANNEL   11
 ADC channel to measure LV rail.
 
#define BUSVOODOO_HV_CHANNEL   15
 ADC channel to measure HV rail.
 
#define BUSVOODOO_LVCTL_PORT   A
 pin to control LV output voltage
 
#define BUSVOODOO_LVCTL_PIN   4
 pin to control LV output voltage
 
#define BUSVOODOO_LVCTL_CHANNEL   CHANNEL_1
 DAC channel to control LV output voltage.
 
#define BUSVOODOO_LV_SET(x)   ((0.8*(1+30.0/10.0)-x)*(10.0/30.0)+0.8)
 voltage to output for the DAC to set the desired LV output voltage (based on resistor values on the LV adjust pins and LV voltage reference)
 
#define BUSVOODOO_HVCTL_PORT   A
 pin to control HV output voltage
 
#define BUSVOODOO_HVCTL_PIN   5
 pin to control HV output voltage
 
#define BUSVOODOO_HVCTL_CHANNEL   CHANNEL_2
 DAC channel to control HV output voltage.
 
#define BUSVOODOO_HV_SET(x)   ((1.25*(1+100.0/10.0)-x)*(10.0/100.0)+1.25)
 voltage to output for the DAC to set the desired HV output voltage (based on resistor values on the HV adjust pins and HV voltage reference)
 
#define BUSVOODOO_RS232_EN_PORT   B
 RS-232 pin to enable receiver (active low, pulled up)
 
#define BUSVOODOO_RS232_EN_PIN   5
 RS-232 pin to enable receiver (active low, pulled up)
 
#define BUSVOODOO_RS232_SHDN_PORT   C
 RS-232 pin to enable transmitter (active high, pulled low)
 
#define BUSVOODOO_RS232_SHDN_PIN   15
 RS-232 pin to enable transmitter (active high, pulled low)
 
#define BUSVOODOO_RS232_RTS_PORT   A
 RS-232 Request-To-Send output pin.
 
#define BUSVOODOO_RS232_RTS_PIN   1
 RS-232 Request-To-Send output pin.
 
#define BUSVOODOO_RS232_CTS_PORT   A
 RS-232 Clear-To-Send input pin.
 
#define BUSVOODOO_RS232_CTS_PIN   0
 RS-232 Clear-To-Send input pin.
 
#define BUSVOODOO_RS232_TX_PORT   A
 RS-232 Transmit output pin.
 
#define BUSVOODOO_RS232_TX_PIN   2
 RS-232 Transmit output pin.
 
#define BUSVOODOO_RS232_RX_PORT   A
 RS-232 Receive input pin.
 
#define BUSVOODOO_RS232_RX_PIN   3
 RS-232 Receive input pin.
 
#define BUSVOODOO_RS485_RE_PORT   C
 RS-485 pin to enable receiver (active low, pulled up)
 
#define BUSVOODOO_RS485_RE_PIN   13
 RS-485 pin to enable receiver (active low, pulled up)
 
#define BUSVOODOO_RS485_DE_PORT   C
 RS-485 pin to enable transmitter (active high, pulled low)
 
#define BUSVOODOO_RS485_DE_PIN   14
 RS-485 pin to enable transmitter (active high, pulled low)
 
#define BUSVOODOO_RS485_TX_PORT   A
 RS-485 Transmit output pin.
 
#define BUSVOODOO_RS485_TX_PIN   2
 RS-485 Transmit output pin.
 
#define BUSVOODOO_RS485_RX_PORT   A
 RS-485 Receive input pin.
 
#define BUSVOODOO_RS485_RX_PIN   3
 RS-485 Receive input pin.
 
#define BUSVOODOO_HW_VERSION_PORT   B
 pin to identify hardware version
 
#define BUSVOODOO_HW_VERSION_PIN   0
 pin to identify hardware version
 
#define BUSVOODOO_HW_VERSION_CHANNEL   8
 ADC to identify hardware version.
 
#define BUSVOODOO_LED_PULSE   100
 recommended duration in ms for pulsing LEDs to show activity
 

Functions

void busvoodoo_setup (void)
 setup BusVoodoo board
 
void busvoodoo_safe_state (void)
 set safe state by disabling all outputs
 
bool busvoodoo_vout_switch (bool on)
 switch 3V3 and 5V power outputs on I/O connector More...
 
float busvoodoo_vreg_get (uint8_t channel)
 read voltage from power rail More...
 
float busvoodoo_lv_set (float voltage)
 set voltage on low voltage adjustable voltage regulator More...
 
float busvoodoo_hv_set (float voltage)
 set voltage on high voltage adjustable voltage regulator More...
 
float busvoodoo_embedded_pullup (bool on)
 enable embedded pull-up resistors More...
 
void busvoodoo_led_blue_on (void)
 switch on blue LED More...
 
void busvoodoo_led_blue_off (void)
 switch off blue LED More...
 
void busvoodoo_led_red_on (void)
 switch on red LED More...
 
void busvoodoo_led_red_off (void)
 switch off red LED More...
 
void busvoodoo_leds_off (void)
 switch off blue and red LEDs More...
 
void busvoodoo_led_blue_pulse (uint32_t ms)
 pulse blue LED for short duration More...
 
void busvoodoo_led_red_pulse (uint32_t ms)
 pulse red LED for short duration More...
 
void busvoodoo_leds_blink (double period, double duty)
 set LED blinking pattern More...
 
bool busvoodoo_global_actions (char *actions, bool perform, bool(*action_handler)(const char *action, uint32_t repetition, bool perform))
 parse and perform actions More...
 

Variables

const char * busvoodoo_io_names [13]
 I/O individual signal names.
 
const uint32_t busvoodoo_io_ports [13]
 port of individual signals
 
const uint32_t busvoodoo_io_pins [13]
 pin of individual signals
 
const uint8_t busvoodoo_io_groups [13]
 which I/O pin (group) does the signal belong to
 
bool busvoodoo_full
 is the BusVoodoo board fully populated (with HV voltage regulator, RS-232, RS-485, CAN transceiver on the back side)
 
char busvoodoo_version
 version of the hardware board
 
const struct menu_command_t busvoodoo_global_commands []
 list of supported commands for base BusVoodoo
 
const uint8_t busvoodoo_global_commands_nb
 number supported commands for base BusVoodoo
 
const struct menu_command_t busvoodoo_global_full_commands []
 list of supported commands for BusVoodoo full only
 
const uint8_t busvoodoo_global_full_commands_nb
 number supported commands for BusVoodoo full only
 
const char * busvoodoo_global_pinout_io [10]
 I/O connector pinout.
 
const char * busvoodoo_global_pinout_rscan [5]
 RS/CAN connector pinout.
 
char busvoodoo_global_string [64]
 shared string buffer, i.e. More...
 

Detailed Description

BusVoodoo global definitions and methods (API)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2018
Note
peripherals used: time the blue and red LEDs are connector to TIM1_CH1: user timer 1 to count time for pulses or channel 1 to generate PWM for blinking

Definition in file busvoodoo_global.h.

Function Documentation

◆ busvoodoo_embedded_pullup()

float busvoodoo_embedded_pullup ( bool  on)

enable embedded pull-up resistors

Note
the embedded pull-up resistor use the voltage on the LV power rail (set or externally provided)
Parameters
[in]onenable (true) or disable (false) embedded pull-up resistors
Returns
voltage applied on pull-up resistors, or NaN if channel is invalid (or error happened)

Definition at line 373 of file busvoodoo_global.c.

◆ busvoodoo_global_actions()

bool busvoodoo_global_actions ( char *  actions,
bool  perform,
bool(*)(const char *action, uint32_t repetition, bool perform)  action_handler 
)

parse and perform actions

Note
performing action is a common command in mode and this function helps parsing them
Parameters
[in]actionsactions to perform
[in]performthe action (true) or just check it (false)
[in]action_handlerfunction handling the individual actions
Returns
true if the actions have been performed, false if any of them is malformed
Note
while parsing the actions the string will be modified

Definition at line 561 of file busvoodoo_global.c.

◆ busvoodoo_hv_set()

float busvoodoo_hv_set ( float  voltage)

set voltage on high voltage adjustable voltage regulator

Parameters
[in]voltagevoltage to set on adjustable voltage regulator (0, 3.3-24V)
Returns
voltage output, or NaN if error happened

Definition at line 343 of file busvoodoo_global.c.

◆ busvoodoo_led_blue_off()

void busvoodoo_led_blue_off ( void  )

switch off blue LED

Note
the red LED is handled independently
this will stop the blinking pattern

Definition at line 426 of file busvoodoo_global.c.

◆ busvoodoo_led_blue_on()

void busvoodoo_led_blue_on ( void  )

switch on blue LED

Note
the red LED is handled independently
this will stop the blinking pattern

Definition at line 419 of file busvoodoo_global.c.

◆ busvoodoo_led_blue_pulse()

void busvoodoo_led_blue_pulse ( uint32_t  ms)

pulse blue LED for short duration

Parameters
[in]msduration in ms
Note
the red LED is handled independently
this will stop the blinking pattern

Definition at line 468 of file busvoodoo_global.c.

◆ busvoodoo_led_red_off()

void busvoodoo_led_red_off ( void  )

switch off red LED

Note
the blue LED is handled independently
this will stop the blinking pattern

Definition at line 440 of file busvoodoo_global.c.

◆ busvoodoo_led_red_on()

void busvoodoo_led_red_on ( void  )

switch on red LED

Note
the blue LED is handled independently
this will stop the blinking pattern

Definition at line 433 of file busvoodoo_global.c.

◆ busvoodoo_led_red_pulse()

void busvoodoo_led_red_pulse ( uint32_t  ms)

pulse red LED for short duration

Parameters
[in]msduration in ms
Note
the red LED is handled independently
this will stop the blinking pattern

Definition at line 481 of file busvoodoo_global.c.

◆ busvoodoo_leds_blink()

void busvoodoo_leds_blink ( double  period,
double  duty 
)

set LED blinking pattern

Parameters
[in]periodblue+red pattern duration in seconds (up to 3+3)
[in]dutyblue LED on duty cycle, before switching to red (0-1)
Note
when exiting blink the blue and red LEDs will be off if they were pulsing before

Definition at line 511 of file busvoodoo_global.c.

◆ busvoodoo_leds_off()

void busvoodoo_leds_off ( void  )

switch off blue and red LEDs

Note
this will stop the blinking pattern

Definition at line 447 of file busvoodoo_global.c.

◆ busvoodoo_lv_set()

float busvoodoo_lv_set ( float  voltage)

set voltage on low voltage adjustable voltage regulator

Note
for voltages above 4.85V it will use the 5.0V from USB
Parameters
[in]voltagevoltage to set on adjustable voltage regulator (0, 0.3-4.8, 5V)
Returns
voltage output, or NaN if error happened

Definition at line 315 of file busvoodoo_global.c.

◆ busvoodoo_vout_switch()

bool busvoodoo_vout_switch ( bool  on)

switch 3V3 and 5V power outputs on I/O connector

Parameters
[in]onswitch on (true) or off (false) power output
Returns
if switching succeeded. else it means there is a probably a short on one of the outputs

Definition at line 226 of file busvoodoo_global.c.

◆ busvoodoo_vreg_get()

float busvoodoo_vreg_get ( uint8_t  channel)

read voltage from power rail

Parameters
[in]channelwhich power rail to read voltage from ADC inputs to measure voltages from voltage regulators
Returns
voltage, or NaN if channel is invalid (or error happened)

Definition at line 247 of file busvoodoo_global.c.

Variable Documentation

◆ busvoodoo_global_string

char busvoodoo_global_string[64]

shared string buffer, i.e.

used when configuring modes

Definition at line 72 of file busvoodoo_global.c.