PER Firmware
Loading...
Searching...
No Matches
auto_switch.h
Go to the documentation of this file.
1
11#ifndef _AUTO_SWITCH_H_
12#define _AUTO_SWITCH_H_
13
14#include <source/pdu/main.h>
15#include <stdbool.h>
16#include <stdint.h>
17
18// Static variables
19#define SHUNT_R 10000000
20#define ADC_MAX 4095
21
22// Voltage sense resistors
23#define LV_24V_R1 47000 // Ohms
24#define LV_24V_R2 3400
25#define LV_5V_R1 4300
26#define LV_5V_R2 3400
27#define LV_3V3_R1 4300
28#define LV_3V3_R2 10000
29#define AMK_24V_R1 124300
30#define AMK_24V_R2 10000
31
32// HP Current sense resistors
33#define HP_CS_R1 180 // Ohms
34#define HP_CS_R2 330 // Ohms
35#define HP_CS_R3 500 // Ohms
36
37// Upstream Current sense
38#define HP_CS_R_SENSE 0.002 // Ohms
39#define CS_GAIN 100
40
41// Enumeration
42typedef enum {
43 // High power switches
44 SW_PUMP_1,
45 SW_PUMP_2,
46 SW_SDC,
47 SW_HXFAN,
48 // High power switches (mux-sensed)
49 SW_FAN_1,
50 SW_FAN_2,
51 SW_FAN_3,
52 SW_FAN_4,
53 SW_AMK1,
54 SW_AMK2,
55
56 // Low power switches
57 SW_DASH,
58 SW_ABOX,
59 SW_MAIN,
60 SW_DLFR,
61 SW_DLBK,
62
63 // Not actually switches
64 CS_24V,
65 CS_5V,
66
67 // Number of switches with CS signals (used for array bounds)
68 // If switch has a current sense circuit, PLACE IT ABOVE THIS COMMENT
69 CS_SWITCH_COUNT,
70
71 // Low power switches (no CS)
72 SW_BLT,
73 // 5V switches (no CS)
74 SW_CRIT_5V,
75 SW_TV,
76 SW_DAQ,
77 SW_FAN_5V
78} switches_t;
79
80// Structures
81typedef struct {
82 uint16_t in_24v;
83 uint16_t out_5v;
84 uint16_t out_3v3;
85} voltage_t; // Voltage in mV
86
87typedef struct {
88 uint16_t current[CS_SWITCH_COUNT]; // Current in mA
89 voltage_t voltage;
91
92extern auto_switches_t auto_switches;
93
94// Function declarations
101void setSwitch(switches_t auto_switch_enum, bool state);
102
109bool getSwitchStatus(switches_t auto_switch_enum);
110
123void autoSwitchPeriodic();
124
129void checkSwitchFaults();
130
131uint16_t getMuxReading(uint8_t channel);
132
133#endif
void autoSwitchPeriodic()
Combined function that calls updateVoltage() and updateCurrent()
Definition auto_switch.c:253
void setSwitch(switches_t auto_switch_enum, bool state)
Enable or disable a switch.
Definition auto_switch.c:125
bool getSwitchStatus(switches_t auto_switch_enum)
Check if a switch is enabled.
Definition auto_switch.c:204
void checkSwitchFaults()
Checks the status of various auto switches to ensure rails are ok. Sets fault and activates blink ind...
Definition auto_switch.c:259
"PDU" node source code
Definition auto_switch.h:87
Definition auto_switch.h:81