slow down adc to give idle some time back
This commit is contained in:
@ -9,22 +9,12 @@
|
||||
|
||||
|
||||
|
||||
static const double SHUNT_RESISTOR = 20.0;
|
||||
static const double U_REF = 3.3;
|
||||
static const double I_THRESHOLD = 0.005;
|
||||
static const uint16_t N_MAX = 4095;
|
||||
|
||||
|
||||
|
||||
static volatile uint16_t frontendAdcThreshold = 0;
|
||||
static volatile bool frontendEnabled = false;
|
||||
|
||||
|
||||
void frontendInit() {
|
||||
// double u_threshold = I_THRESHOLD * SHUNT_RESISTOR;
|
||||
// frontendAdcThreshold = (uint16_t) (u_threshold / U_REF * ((double) N_MAX));
|
||||
// logMsg("frontendInit, threshold calculated: %d", frontendAdcThreshold);
|
||||
|
||||
HAL_ADCEx_Calibration_Start(&frontendAdc);
|
||||
logMsg("frontendInit, calibration done");
|
||||
HAL_ADC_Start_IT(&frontendAdc);
|
||||
@ -44,7 +34,10 @@ void frontendDisable() {
|
||||
}
|
||||
|
||||
void frontendAdcCallback(ADC_HandleTypeDef* hadc) {
|
||||
uint16_t rawValue = HAL_ADC_GetValue(hadc);
|
||||
HAL_GPIO_TogglePin(Debug_Signal_GPIO_Port, Debug_Signal_Pin);
|
||||
HAL_GPIO_TogglePin(Debug_Signal_1_GPIO_Port, Debug_Signal_1_Pin);
|
||||
uint32_t rawValue = HAL_ADC_GetValue(hadc);
|
||||
if (rawValue > frontendAdcThreshold) {
|
||||
HAL_GPIO_TogglePin(Frontend_Out_GPIO_Port, Frontend_Out_Pin);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user