main
TylerK Replace discrete-analog board with MCU/IC redesign: STM32G031 P&O MPPT + CC/CV firmware, LM5175 buck-boost, INA180 curr… e48ba30 1mo ago
/*
 * pwm_ref.h -- drives PA4 (TIM14_CH1) so that, after the R22/C26 RC low-pass
 * filter (10k / 100nF, tau=1ms), the resulting DC level equals the desired
 * MCU_MPPT_REF voltage that trims the LM5175 FB summing node.
 *
 * Assumes CubeMX has configured TIM14 CH1 on PA4 in PWM mode with a period
 * (ARR) chosen for a PWM frequency comfortably above 1/tau -- e.g. 64MHz
 * timer clock / ARR=1279 gives 50kHz, ~50x the RC corner, for clean
 * averaging with no perceptible ripple at the summing node.
 */
#ifndef PWM_REF_H
#define PWM_REF_H

void pwm_ref_init(void);

/* Set the commanded VBATT setpoint; internally converts to V_MCU_REF then
 * to a PWM duty cycle and updates the timer compare register. */
void pwm_ref_set_vbatt_setpoint(float vbatt_setpoint);

#endif /* PWM_REF_H */