From a5bfd0e961dea35e20353b80cd959679b9d01f57 Mon Sep 17 00:00:00 2001 From: Kizarm Date: Sun, 5 Jan 2025 11:49:29 +0100 Subject: [PATCH] small change --- V203/usb/ch32v203/adcscope.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/V203/usb/ch32v203/adcscope.cpp b/V203/usb/ch32v203/adcscope.cpp index 9689970..6a23a7d 100644 --- a/V203/usb/ch32v203/adcscope.cpp +++ b/V203/usb/ch32v203/adcscope.cpp @@ -69,12 +69,18 @@ static inline void AdcCalibrate (void) noexcept { RCC.APB2PRSTR.B.ADC1RST = SET; RCC.APB2PRSTR.B.ADC1RST = RESET; // set channels - ADC1.RSQR3__CHANNEL.B.SQ1__CHSEL = 0u; // CH0 - ADC1.RSQR3__CHANNEL.B.SQ2 = 1u; // CH1 + ADC1.RSQR3__CHANNEL.modify([](ADC1_Type::RSQR3__CHANNEL_DEF & r) -> auto { + r.B.SQ1__CHSEL = 0u; // CH0 + r.B.SQ2 = 1u; // CH1 + return r.R; + }); ADC1.RSQR1.B.L = ADC_MAXCHANNELS - 1U; // 2 regular conversion - static constexpr unsigned ts = 0u; - ADC1.SAMPTR2_CHARGE2.B.SMP2_TKCG2 = ts; - ADC1.SAMPTR2_CHARGE2.B.SMP3_TKCG3 = ts; + ADC1.SAMPTR2_CHARGE2.modify([](ADC1_Type::SAMPTR2_CHARGE2_DEF & r) -> auto { + static constexpr unsigned ts = 0u; + r.B.SMP0_TKCG0 = ts; + r.B.SMP1_TKCG1 = ts; + return r.R; + }); ADC1.CTLR1.B.SCAN = SET; ADC1.CTLR2.B.ADON = SET;