{"record":{"id":"33692e13f4089299","repo":"embassy-rs/embassy","slug":"not-implemented-33692e","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/dts/mod.rs","lineNumber":128,"sourceCode":"        Self { _peri }\n    }\n\n    /// Reconfigure the driver.\n    pub fn set_config(&mut self, config: &Config) {\n        Self::regs().cfgr1().modify(|w| {\n            w.set_smp_time(config.sample_time as u8);\n            w.set_intrig_sel(config.trigger as u8);\n        });\n    }\n\n    /// Get the read-only factory calibration values used for converting a\n    /// measurement to a temperature.\n    pub fn factory_calibration() -> FactoryCalibration {\n        let t0valr1 = Self::regs().t0valr1().read();\n        let t0 = match t0valr1.t0() {\n            0 => 30,\n            1 => 130,\n            _ => unimplemented!(),\n        };\n        let fmt0 = Hertz::hz(t0valr1.fmt0() as u32 * 100);\n\n        let ramp_coeff = Self::regs().rampvalr().read().ramp_coeff();\n\n        FactoryCalibration { t0, fmt0, ramp_coeff }\n    }\n\n    /// Perform an asynchronous temperature measurement. The returned future can\n    /// be awaited to obtain the measurement.\n    ///\n    /// The future returned waits for the next measurement to complete.\n    ///\n    /// # Example\n    ///\n    /// ```no_run\n    /// use embassy_stm32::{bind_interrupts, dts};\n    /// use embassy_stm32::dts::Dts;","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/dts/mod.rs#L110-L146","documentation":"The DTS (digital temperature sensor) factory_calibration() reads T0VALR1 and maps the encoded reference temperature t0: 0 => 30 °C, 1 => 130 °C; any other encoded value hits an unimplemented!() panic. The library throws it because the register encoding is documented as 2 values and anything else indicates silicon/register surprises. In practice it fires when the DTS calibration block was not programmed (reads 0xFF / reserved values).","triggerScenarios":"Calling Dts::factory_calibration() when T0VALR1.T0 contains a value other than 0 or 1 — typically because DTS calibration data was never written to OTP/system flash, or reading before the DTS/its clock is enabled so the read returns garbage.","commonSituations":"Using DTS on an STM32 whose factory calibration area is erased or not loaded (custom bootloader, clone/defective chip); forgetting to enable the DTS peripheral clock before reading calibration registers.","solutions":["Ensure the DTS peripheral clock is enabled (via RCC) before calling factory_calibration()","Verify factory calibration data exists in the calibration area for your exact chip part number","Call the runtime calibration path (calibrate / measure with the driver's calibration routine) instead of relying on factory constants","If the chip encodes additional t0 values, patch the match arms in embassy-stm32/src/dts/mod.rs"],"exampleFix":"// before\nlet cal = Dts::factory_calibration(); // panics if t0 encoding unexpected\n// after\nlet cal = dts.calibrate(&mut sensor).await; // runtime calibration instead","handlingStrategy":"fallback","validationCode":"let t0 = Dts::regs().t0valr1().read().t0();\nif t0 > 1 {\n    // fall back to runtime calibration\n    return None;\n}","typeGuard":"fn valid_t0_encoding(t0: u8) -> bool {\n    matches!(t0, 0 | 1)\n}","tryCatchPattern":"// panic-based; guard reads first\nif !valid_t0_encoding(t0_raw) {\n    let cal = runtime_calibration();\n}","preventionTips":["Enable DTS clock before reading calibration registers","Verify your chip's calibration OTP is intact","Prefer runtime calibration over factory constants","Check chip errata for DTS register encodings"],"tags":["embedded","stm32","dts","temperature","unimplemented"],"backgroundTag":"unsupported-enum-value","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}