stm32: Enable ADC support on stm32g0

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-12-19 21:30:33 -05:00
parent 88325b6c93
commit 1c24317380
4 changed files with 57 additions and 12 deletions

View file

@ -70,6 +70,7 @@ class PrinterTemperatureMCU:
('stm32f042', self.config_stm32f0x2),
('stm32f070', self.config_stm32f070),
('stm32f072', self.config_stm32f0x2),
('stm32g0', self.config_stm32g0),
('', self.config_unknown)]
for name, func in cfg_funcs:
if self.mcu_type.startswith(name):
@ -133,6 +134,11 @@ class PrinterTemperatureMCU:
self.slope = 3.3 / -.004300
cal_adc_30 = self.read16(0x1FFFF7B8) / 4095.
self.base_temperature = self.calc_base(30., cal_adc_30)
def config_stm32g0(self):
cal_adc_30 = self.read16(0x1FFF75A8) * 3.0 / (3.3 * 4095.)
cal_adc_130 = self.read16(0x1FFF75CA) * 3.0 / (3.3 * 4095.)
self.slope = (130. - 30.) / (cal_adc_130 - cal_adc_30)
self.base_temperature = self.calc_base(30., cal_adc_30)
def read16(self, addr):
params = self.debug_read_cmd.send([1, addr])
return params['val']