PER Firmware
Loading...
Searching...
No Matches
switches.c File Reference
#include "switches.h"
#include <string.h>
#include "led.h"
#include "main.h"
#include "state.h"
#include "common/phal_F4/gpio/gpio.h"
Include dependency graph for switches.c:

Classes

struct  pdu_switch_output_t
 

Functions

static const pdu_switch_output_tswitches_get_output (switches_t switch_id)
 
static uint16_t switches_convert_high_power_current_ma (uint16_t adc_counts)
 
static uint16_t switches_convert_low_power_current_ma (uint16_t adc_counts)
 
static uint16_t switches_convert_voltage_mv (uint16_t adc_counts, int r1_ohm, int r2_ohm)
 
static void switches_select_mux_channel (uint8_t channel)
 
static void switches_update_mux_measurements (void)
 
static void switches_update_currents (void)
 
static void switches_update_voltages (void)
 
void switches_init (void)
 
void switches_periodic (void)
 
void switches_set_state (switches_t switch_id, bool enabled)
 
bool switches_is_enabled (switches_t switch_id)
 
uint16_t switches_get_mux_adc_counts (uint8_t channel)
 
void switches_enable_default_rails (void)
 

Variables

static constexpr uint16_t ADC_MAX_COUNTS = 4095
 
static constexpr int LV_24V_R1 = 47000
 
static constexpr int LV_24V_R2 = 3400
 
static constexpr int LV_5V_R1 = 4300
 
static constexpr int LV_5V_R2 = 3400
 
static constexpr int LV_3V3_R1 = 4300
 
static constexpr int LV_3V3_R2 = 10000
 
static constexpr int HP_CS_R1 = 180
 
static constexpr int HP_CS_R2 = 330
 
static constexpr int HP_CS_R3 = 500
 
static constexpr float HP_CS_R_SENSE = 0.002f
 
static constexpr uint16_t CS_GAIN = 100
 
static constexpr int8_t LED_NONE = -1
 
static const pdu_switch_output_t PDU_SWITCH_OUTPUTS []
 

Function Documentation

◆ switches_convert_high_power_current_ma()

static uint16_t switches_convert_high_power_current_ma ( uint16_t adc_counts)
static
Here is the caller graph for this function:

◆ switches_convert_low_power_current_ma()

static uint16_t switches_convert_low_power_current_ma ( uint16_t adc_counts)
static
Here is the caller graph for this function:

◆ switches_convert_voltage_mv()

static uint16_t switches_convert_voltage_mv ( uint16_t adc_counts,
int r1_ohm,
int r2_ohm )
static
Here is the caller graph for this function:

◆ switches_enable_default_rails()

void switches_enable_default_rails ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_get_mux_adc_counts()

uint16_t switches_get_mux_adc_counts ( uint8_t channel)

◆ switches_get_output()

static const pdu_switch_output_t * switches_get_output ( switches_t switch_id)
static
Here is the caller graph for this function:

◆ switches_init()

void switches_init ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_is_enabled()

bool switches_is_enabled ( switches_t switch_id)
Here is the call graph for this function:

◆ switches_periodic()

void switches_periodic ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_select_mux_channel()

static void switches_select_mux_channel ( uint8_t channel)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_set_state()

void switches_set_state ( switches_t switch_id,
bool enabled )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_update_currents()

static void switches_update_currents ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_update_mux_measurements()

static void switches_update_mux_measurements ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switches_update_voltages()

static void switches_update_voltages ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ADC_MAX_COUNTS

uint16_t ADC_MAX_COUNTS = 4095
staticconstexpr

◆ CS_GAIN

uint16_t CS_GAIN = 100
staticconstexpr

◆ HP_CS_R1

int HP_CS_R1 = 180
staticconstexpr

◆ HP_CS_R2

int HP_CS_R2 = 330
staticconstexpr

◆ HP_CS_R3

int HP_CS_R3 = 500
staticconstexpr

◆ HP_CS_R_SENSE

float HP_CS_R_SENSE = 0.002f
staticconstexpr

◆ LED_NONE

int8_t LED_NONE = -1
staticconstexpr

◆ LV_24V_R1

int LV_24V_R1 = 47000
staticconstexpr

◆ LV_24V_R2

int LV_24V_R2 = 3400
staticconstexpr

◆ LV_3V3_R1

int LV_3V3_R1 = 4300
staticconstexpr

◆ LV_3V3_R2

int LV_3V3_R2 = 10000
staticconstexpr

◆ LV_5V_R1

int LV_5V_R1 = 4300
staticconstexpr

◆ LV_5V_R2

int LV_5V_R2 = 3400
staticconstexpr

◆ PDU_SWITCH_OUTPUTS

const pdu_switch_output_t PDU_SWITCH_OUTPUTS[]
static
Initial value:
= {
{.switch_id = SW_PUMP_1, .ctrl_port = PUMP_1_CTRL_GPIO_Port, .ctrl_pin = PUMP_1_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_PUMP_1},
{.switch_id = SW_PUMP_2, .ctrl_port = PUMP_2_CTRL_GPIO_Port, .ctrl_pin = PUMP_2_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_PUMP_2},
{.switch_id = SW_SDC, .ctrl_port = nullptr, .ctrl_pin = 0, .has_ctrl_output = false, .led_id = LED_SDC},
{.switch_id = SW_HXFAN, .ctrl_port = HXFAN_CTRL_GPIO_Port, .ctrl_pin = HXFAN_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_HXFAN},
{.switch_id = SW_FAN_1, .ctrl_port = FAN_1_CTRL_GPIO_Port, .ctrl_pin = FAN_1_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_NONE},
{.switch_id = SW_FAN_2, .ctrl_port = FAN_2_CTRL_GPIO_Port, .ctrl_pin = FAN_2_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_NONE},
{.switch_id = SW_FAN_3, .ctrl_port = FAN_3_CTRL_GPIO_Port, .ctrl_pin = FAN_3_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_NONE},
{.switch_id = SW_FAN_4, .ctrl_port = FAN_4_CTRL_GPIO_Port, .ctrl_pin = FAN_4_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_NONE},
{.switch_id = SW_AMK1, .ctrl_port = nullptr, .ctrl_pin = 0, .has_ctrl_output = false, .led_id = LED_NONE},
{.switch_id = SW_AMK2, .ctrl_port = nullptr, .ctrl_pin = 0, .has_ctrl_output = false, .led_id = LED_NONE},
{.switch_id = SW_DASH, .ctrl_port = nullptr, .ctrl_pin = 0, .has_ctrl_output = false, .led_id = LED_DASH},
{.switch_id = SW_ABOX, .ctrl_port = nullptr, .ctrl_pin = 0, .has_ctrl_output = false, .led_id = LED_ABOX},
{.switch_id = SW_MAIN, .ctrl_port = MAIN_CTRL_GPIO_Port, .ctrl_pin = MAIN_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_MAIN},
{.switch_id = SW_DLFR, .ctrl_port = DLFR_CTRL_GPIO_Port, .ctrl_pin = DLFR_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_DLFR},
{.switch_id = SW_DLBK, .ctrl_port = DLBK_CTRL_GPIO_Port, .ctrl_pin = DLBK_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_DLBK},
{.switch_id = SW_BLT, .ctrl_port = BLT_CTRL_GPIO_Port, .ctrl_pin = BLT_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_BLT},
{.switch_id = SW_CRIT_5V, .ctrl_port = CRIT_5V_CTRL_GPIO_Port, .ctrl_pin = CRIT_5V_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_5V_CRIT},
{.switch_id = SW_TV, .ctrl_port = TV_CTRL_GPIO_Port, .ctrl_pin = TV_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_TV},
{.switch_id = SW_DAQ, .ctrl_port = nullptr, .ctrl_pin = 0, .has_ctrl_output = false, .led_id = LED_DAQ},
{.switch_id = SW_FAN_5V, .ctrl_port = FAN_5V_CTRL_GPIO_Port, .ctrl_pin = FAN_5V_CTRL_Pin, .has_ctrl_output = true, .led_id = LED_5V_FAN},
}
#define LED_BLT
Definition led.h:36
#define LED_DAQ
Definition led.h:34
#define LED_5V_CRIT
Definition led.h:35
#define LED_PUMP_2
Definition led.h:24
#define LED_5V_FAN
Definition led.h:32
#define LED_ABOX
Definition led.h:30
#define LED_SDC
Definition led.h:27
#define LED_PUMP_1
Definition led.h:23
#define LED_DLFR
Definition led.h:26
#define LED_DLBK
Definition led.h:25
#define LED_DASH
Definition led.h:29
#define LED_HXFAN
Definition led.h:31
#define LED_MAIN
Definition led.h:28
#define LED_TV
Definition led.h:33
#define FAN_4_CTRL_GPIO_Port
Definition main.h:149
#define DLBK_CTRL_GPIO_Port
Definition main.h:171
#define FAN_1_CTRL_GPIO_Port
Definition main.h:152
#define BLT_CTRL_GPIO_Port
Definition main.h:200
#define DLFR_CTRL_Pin
Definition main.h:168
#define DLBK_CTRL_Pin
Definition main.h:172
#define TV_CTRL_GPIO_Port
Definition main.h:212
#define HXFAN_CTRL_GPIO_Port
Definition main.h:134
#define PUMP_1_CTRL_GPIO_Port
Definition main.h:121
#define FAN_3_CTRL_Pin
Definition main.h:147
#define FAN_2_CTRL_Pin
Definition main.h:156
#define FAN_4_CTRL_Pin
Definition main.h:150
#define MAIN_CTRL_Pin
Definition main.h:178
#define PUMP_2_CTRL_GPIO_Port
Definition main.h:127
#define BLT_CTRL_Pin
Definition main.h:201
#define CRIT_5V_CTRL_Pin
Definition main.h:207
#define CRIT_5V_CTRL_GPIO_Port
Definition main.h:206
#define MAIN_CTRL_GPIO_Port
Definition main.h:177
#define TV_CTRL_Pin
Definition main.h:213
#define FAN_5V_CTRL_Pin
Definition main.h:219
#define FAN_3_CTRL_GPIO_Port
Definition main.h:146
#define FAN_1_CTRL_Pin
Definition main.h:153
#define FAN_5V_CTRL_GPIO_Port
Definition main.h:218
#define DLFR_CTRL_GPIO_Port
Definition main.h:167
#define FAN_2_CTRL_GPIO_Port
Definition main.h:155
#define HXFAN_CTRL_Pin
Definition main.h:135
#define PUMP_2_CTRL_Pin
Definition main.h:128
#define PUMP_1_CTRL_Pin
Definition main.h:122
static constexpr int8_t LED_NONE
Definition switches.c:35
@ SW_FAN_2
Definition switches.h:16
@ SW_DAQ
Definition switches.h:39
@ SW_FAN_4
Definition switches.h:18
@ SW_TV
Definition switches.h:38
@ SW_HXFAN
Definition switches.h:12
@ SW_ABOX
Definition switches.h:24
@ SW_MAIN
Definition switches.h:25
@ SW_SDC
Definition switches.h:11
@ SW_DLBK
Definition switches.h:27
@ SW_PUMP_1
Definition switches.h:9
@ SW_BLT
Definition switches.h:35
@ SW_FAN_5V
Definition switches.h:40
@ SW_DLFR
Definition switches.h:26
@ SW_FAN_1
Definition switches.h:15
@ SW_AMK1
Definition switches.h:19
@ SW_DASH
Definition switches.h:23
@ SW_FAN_3
Definition switches.h:17
@ SW_PUMP_2
Definition switches.h:10
@ SW_AMK2
Definition switches.h:20
@ SW_CRIT_5V
Definition switches.h:37