CuVoodoo STM32F1 firmware template
Macros | Functions | Variables
busvoodoo_global.c File Reference

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

Go to the source code of this file.

Macros

#define BUSVOODOO_LED_TIMER   1
 timer peripheral ID
 

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...
 
static void busvoodoo_leds_update (void)
 update LED status according to LED flags
 
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...
 
static void busvoodoo_led_pulse_setup (void)
 setup the timer for pulsing LEDs
 
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 tim1_up_isr (void)
 interrupt service routine called on LED timeout
 
void busvoodoo_leds_blink (double period, double duty)
 set LED blinking pattern More...
 
static void busvoodoo_global_power_led_update (void)
 updates the red power LED status 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...
 
static void busvoodoo_global_power (void *argument)
 switch 3V3 and 5V power rails on/off More...
 
static void busvoodoo_global_lv (void *argument)
 set LV linear drop-out voltage regulator voltage More...
 
static void busvoodoo_global_hv (void *argument)
 set HV step-up voltage regulator voltage More...
 
static void busvoodoo_global_pinout (void *argument)
 display I/O and RS/CAN connector pinouts More...
 

Variables

static volatile uint32_t busvoodoo_global_led_blue_timeout = 0
 number of remaining milliseconds the blue LED should stay on
 
static volatile bool busvoodoo_global_led_blue_timer = false
 if the timer for the blue LED is enabled
 
static volatile uint32_t busvoodoo_global_led_red_timeout = 0
 number of remaining milliseconds the red LED should stay on
 
static volatile bool busvoodoo_global_led_red_timer = false
 if the timer for the red LED is enabled
 
static volatile bool busvoodoo_global_led_blinking = false
 if the LEDs are in a blinking pattern
 
static const float busvoodoo_version_voltages [] = {100.0/(10.0+100.0)*3.3}
 hardware version voltages, calculated from divider ratios, starting with version A
 
const char * busvoodoo_global_pinout_io [10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 I/O connector pinout.
 
const char * busvoodoo_global_pinout_rscan [5] = {NULL, NULL, NULL, NULL, NULL}
 RS/CAN connector pinout.
 
const char * busvoodoo_io_names [13] = {"I2C_SMBA/SPI_NSS/I2S_WS/UART1_CK", "SDIO_CMD", "UART1_CTS/SPI_SCK/I2S_CK", "SDIO_D3/UART2_RX", "I2C_SDA/UART1_RX", "SDIO_D0", "SPI_MOSI/I2S_SD", "SDIO_CK", "I2C_SCL/UART1_TX", "SDIO_D1", "I2S_MCK", "UART1_RTS/SPI_MISO", "SDIO_D2/UART2_TX"}
 I/O individual signal names.
 
const uint32_t busvoodoo_io_ports [13] = {GPIOB, GPIOD, GPIOB, GPIOC, GPIOB, GPIOC, GPIOB, GPIOC, GPIOB, GPIOC, GPIOC, GPIOB, GPIOC}
 port of individual signals
 
const uint32_t busvoodoo_io_pins [13] = {GPIO12, GPIO2, GPIO13, GPIO11, GPIO11, GPIO8, GPIO15, GPIO12, GPIO10, GPIO9, GPIO6, GPIO14, GPIO10}
 pin of individual signals
 
const uint8_t busvoodoo_io_groups [13] = {6, 6, 4, 4, 1, 1, 5, 5, 2, 2, 3, 3, 3}
 which I/O pin (group) does the signal belong to
 
bool busvoodoo_full = false
 is the BusVoodoo board fully populated (with HV voltage regulator, RS-232, RS-485, CAN transceiver on the back side)
 
char busvoodoo_version = '0'
 version of the hardware board
 
char busvoodoo_global_string [64]
 shared string buffer, i.e. More...
 
const struct menu_command_t busvoodoo_global_commands []
 list of supported commands for base BusVoodoo More...
 
const uint8_t busvoodoo_global_commands_nb = LENGTH(busvoodoo_global_commands)
 number supported commands for base BusVoodoo
 
const struct menu_command_t busvoodoo_global_full_commands []
 list of supported commands for BusVoodoo full only More...
 
const uint8_t busvoodoo_global_full_commands_nb = LENGTH(busvoodoo_global_full_commands)
 number supported commands for BusVoodoo full only
 

Detailed Description

BusVoodoo global definitions and methods (code)

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.c.

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_global_hv()

static void busvoodoo_global_hv ( void *  argument)
static

set HV step-up voltage regulator voltage

Parameters
[in]argumentvoltage to set (0 to switch off, NULL to get voltage)

Definition at line 699 of file busvoodoo_global.c.

◆ busvoodoo_global_lv()

static void busvoodoo_global_lv ( void *  argument)
static

set LV linear drop-out voltage regulator voltage

Parameters
[in]argumentvoltage to set (0 to switch off, NULL to get voltage)

Definition at line 661 of file busvoodoo_global.c.

◆ busvoodoo_global_pinout()

static void busvoodoo_global_pinout ( void *  argument)
static

display I/O and RS/CAN connector pinouts

Parameters
[in]argumentnot used

Definition at line 736 of file busvoodoo_global.c.

◆ busvoodoo_global_power()

static void busvoodoo_global_power ( void *  argument)
static

switch 3V3 and 5V power rails on/off

Parameters
[in]argumentstring: "on" to switch on, "off" to switch off, NULL to get status

Definition at line 626 of file busvoodoo_global.c.

◆ busvoodoo_global_power_led_update()

static void busvoodoo_global_power_led_update ( void  )
static

updates the red power LED status

Note
the red LED is used to indicate if power is enabled on Vout, LV, or HV

Definition at line 545 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_commands

const struct menu_command_t busvoodoo_global_commands[]
Initial value:
= {
{
.shortcut = 'p',
.name = "pinout",
.command_description = "show connector pinout",
.argument = MENU_ARGUMENT_NONE,
.argument_description = NULL,
.command_handler = &busvoodoo_global_pinout,
},
{
.shortcut = 'P',
.name = "power",
.command_description = "switch 3V3 and 5V power rails on/off, or read internal voltages",
.argument = MENU_ARGUMENT_STRING,
.argument_description = "[on|off]",
.command_handler = &busvoodoo_global_power,
},
{
.shortcut = 'L',
.name = "LV",
.command_description = "set voltage on low voltage power rail (0, 0.3-4.8, 5V), or read voltage on pin",
.argument = MENU_ARGUMENT_FLOAT,
.argument_description = "[voltage]",
.command_handler = &busvoodoo_global_lv,
},
}
static void busvoodoo_global_power(void *argument)
switch 3V3 and 5V power rails on/off
static void busvoodoo_global_lv(void *argument)
set LV linear drop-out voltage regulator voltage
static void busvoodoo_global_pinout(void *argument)
display I/O and RS/CAN connector pinouts

list of supported commands for base BusVoodoo

Definition at line 880 of file busvoodoo_global.c.

◆ busvoodoo_global_full_commands

const struct menu_command_t busvoodoo_global_full_commands[]
Initial value:
= {
{
.shortcut = 'H',
.name = "HV",
.command_description = "set voltage on high voltage power rail (0, 3.3-24V), or read voltage on pin",
.argument = MENU_ARGUMENT_FLOAT,
.argument_description = "[voltage]",
.command_handler = &busvoodoo_global_hv,
},
}
static void busvoodoo_global_hv(void *argument)
set HV step-up voltage regulator voltage

list of supported commands for BusVoodoo full only

Definition at line 909 of file busvoodoo_global.c.

◆ 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.