There is a problem in stm32g4_mcu.cpp in the current sense:
in the function:
float _readADCVoltageInline(const int pin){
uint32_t raw_adc = 0;
if(pin == PA2) // = ADC1_IN3 = phase U (OP1_OUT) on B-G431B-ESC1
raw_adc = adcBuffer1[1];
else if(pin == PA6) // = ADC2_IN3 = phase V (OP2_OUT) on B-G431B-ESC1
raw_adc = adcBuffer2[0];
else if(pin == PB1) // = ADC1_IN12 = phase W (OP3_OUT) on B-G431B-ESC1
raw_adc = adcBuffer1[0];
return raw_adc * _ADC_CONV;
}
The core of the problem is that the whole file is specific to the B-G431-ESC1 board, but is "masquerading" as a driver for the STM32G4. The #ifdefs protecting the compilation should specifically target the B-G431-ESC1 board, and not the G4 series.
Quite apart from the fact that this implementation with its hard-coded pins won't work for people using other G4 boards anyway,
it also forces dependence on the HAL OPAMP module, which at least in platformIO means compile problems unless you set the right build flags
and in this particular instance, prevents compilation on some boards due to its hard-coded reference to pin PB1.... PB1 is not used on the Nucleo G431 board for example, and therefore not defined in the STM core's headers as a pin. :-(
A short order solution should be to make the #ifdefs specifically target the ESC1 board. In the medium term, we should refactor the current sensing as discussed (work is ongoing :-) )
There is a problem in stm32g4_mcu.cpp in the current sense:
in the function:
The core of the problem is that the whole file is specific to the B-G431-ESC1 board, but is "masquerading" as a driver for the STM32G4. The #ifdefs protecting the compilation should specifically target the B-G431-ESC1 board, and not the G4 series.
A short order solution should be to make the #ifdefs specifically target the ESC1 board. In the medium term, we should refactor the current sensing as discussed (work is ongoing :-) )