def _mcu_identify(self): # Obtain mcu information mcu = self.mcu_adc.get_mcu() self.debug_read_cmd = mcu.lookup_query_command( "debug_read order=%c addr=%u", "debug_result val=%u") self.mcu_type = mcu.get_constants().get("MCU", "") # Run MCU specific configuration cfg_funcs = [ ('rp2040', self.config_rp2040), ('sam3', self.config_sam3), ('sam4', self.config_sam4), ('same70', self.config_same70), ('samd21', self.config_samd21), ('samd51', self.config_samd51), ('stm32f1', self.config_stm32f1), ('stm32f2', self.config_stm32f2), ('stm32f4', self.config_stm32f4), ('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): func() break logging.info("mcu_temperature '%s' nominal base=%.6f slope=%.6f", mcu.get_name(), self.base_temperature, self.slope) # Setup manual base/slope override if self.temp1 is not None: if self.temp2 is not None: self.slope = (self.temp2 - self.temp1) / (self.adc2 - self.adc1) self.base_temperature = self.calc_base(self.temp1, self.adc1) # Setup min/max checks adc_range = [self.calc_adc(t) for t in [self.min_temp, self.max_temp]] self.mcu_adc.setup_minmax(SAMPLE_TIME, SAMPLE_COUNT, minval=min(adc_range), maxval=max(adc_range), range_check_count=RANGE_CHECK_COUNT)
def _mcu_identify(self): # our mcu is already identified. Configure fpga here and get version mcu = self._mcu cmd = mcu.lookup_query_command( "config_fpga fid=%c clk_pin=%u miso_pin=%u mosi_pin=%u cs_pin=%u " "program_pin=%u init_pin=%u done_pin=%u di_pin=%u", "fpga_init_done fid=%c", is_async=True, timeout=10, retry_time=100) rsp = cmd.send([ self._fid, self._flash_clk, self._flash_miso, self._flash_mosi, self._flash_cs, self._program, self._init, self._done, self._di ]) if rsp['fid'] != self._fid: raise self._printer.config_error( "invalid response during fpga identification") cmd = mcu.lookup_query_command( "fpga_setup fid=%c usart_bus=%u rate=%u timesync_pin=%u " "serr_pin=%u sreset_pin=%u", "fpga_config fid=%c version=%u gpio=%c pwm=%c stepper=%c " "endstop=%c uart=%c sd=%c eth=%c asm=%c dro=%c biss=%c move_cnt=%u", is_async=True) rsp = cmd.send([ self._fid, self._usart_bus, self._usart_rate, self._timesync, self._serr, self._sreset ]) if rsp['fid'] != self._fid or rsp['version'] != 66: raise self._printer.config_error( "invalid response during fpga identification") del rsp['fid'] self._config = {k: rsp[k] for k in rsp if not k.startswith('#')} self._classes = { k: rsp[k] for k in ('gpio', 'pwm', 'endstop', 'uart', 'dro', 'asm', 'eth', 'biss') } self._classes['step'] = rsp['stepper'] self._classes['dir'] = rsp['stepper'] logging.info(self._log_info())