38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
|
#include "power.h"
|
||
|
|
||
|
uint16_t adc_values[10];
|
||
|
float eem_current;
|
||
|
float voltages[8];
|
||
|
|
||
|
void eem_power_init()
|
||
|
{
|
||
|
HAL_GPIO_WritePin(EEM_POWER_SW_GPIO_Port, EEM_POWER_SW_Pin, GPIO_PIN_SET);
|
||
|
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_values, sizeof(adc_values));
|
||
|
}
|
||
|
|
||
|
void power_adc_calculate()
|
||
|
{
|
||
|
eem_current = EEM_ADC2CURRENT(adc_values[ADC_EEM_CURRENT_VAL], adc_values[ADC_EEM_CURRENT_REF]);
|
||
|
voltages[ADC_3V3] = ADC2VOLTAGE_3V3(adc_values[ADC_3V3]);
|
||
|
voltages[ADC_3V3MP] = ADC2VOLTAGE_3V3(adc_values[ADC_3V3MP]);
|
||
|
voltages[ADC_5V_1] = ADC2VOLTAGE_5V(adc_values[ADC_5V_1]);
|
||
|
voltages[ADC_5V_2] = ADC2VOLTAGE_5V(adc_values[ADC_5V_2]);
|
||
|
voltages[ADC_12V] = ADC2VOLTAGE_12V(adc_values[ADC_12V]);
|
||
|
voltages[ADC_GND1] = ADC2VOLTAGE_GND(adc_values[ADC_GND1]);
|
||
|
voltages[ADC_GND2] = ADC2VOLTAGE_GND(adc_values[ADC_GND2]);
|
||
|
}
|
||
|
|
||
|
void eem_power_off()
|
||
|
{
|
||
|
HAL_GPIO_WritePin(EEM_POWER_SW_GPIO_Port, EEM_POWER_SW_Pin, GPIO_PIN_SET);
|
||
|
}
|
||
|
|
||
|
void eem_power_on()
|
||
|
{
|
||
|
HAL_GPIO_WritePin(EEM_POWER_SW_GPIO_Port, EEM_POWER_SW_Pin, GPIO_PIN_RESET);
|
||
|
}
|
||
|
|
||
|
void eem_power_toggle()
|
||
|
{
|
||
|
HAL_GPIO_TogglePin(EEM_POWER_SW_GPIO_Port, EEM_POWER_SW_Pin);
|
||
|
}
|