From 84be40e742cdc27b59d9b47905dadaa55e7d0868 Mon Sep 17 00:00:00 2001 From: Kizarm Date: Sat, 30 Nov 2024 11:03:21 +0100 Subject: [PATCH] small repair --- V203/usb/ch32v203/gpio.h | 24 +++++++++++++++++------- V203/usb/scope/firmware/structures.h | 14 +++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/V203/usb/ch32v203/gpio.h b/V203/usb/ch32v203/gpio.h index c34955e..cd669df 100644 --- a/V203/usb/ch32v203/gpio.h +++ b/V203/usb/ch32v203/gpio.h @@ -33,13 +33,23 @@ class GpioClass { //r.B.IOPCEN = SET; return r.R; }); - const uint32_t pos = pin << 2; - port.CFGLR.modify([=](GPIOA_Type::CFGLR_DEF & r)->auto { - uint32_t t = r.R; - t &= ~(0xFu << pos); - t |= _mode << pos; - return t; - }); + if (pin < 8u) { + const uint32_t pos = pin << 2; + port.CFGLR.modify([=](GPIOA_Type::CFGLR_DEF & r)->auto { + uint32_t t = r.R; + t &= ~(0xFu << pos); + t |= _mode << pos; + return t; + }); + } else { + const uint32_t pos = (pin - 8u) << 2; + port.CFGHR.modify([=](GPIOA_Type::CFGHR_DEF & r)->auto { + uint32_t t = r.R; + t &= ~(0xFu << pos); + t |= _mode << pos; + return t; + }); + } } void operator<< (const bool b) const { port.BSHR.R = b ? 1u << pin : 1u << (pin + 16); diff --git a/V203/usb/scope/firmware/structures.h b/V203/usb/scope/firmware/structures.h index fb4ebc1..a8b53aa 100644 --- a/V203/usb/scope/firmware/structures.h +++ b/V203/usb/scope/firmware/structures.h @@ -28,16 +28,16 @@ struct TrigerSettings { }; static_assert (sizeof(TrigerSettings) == 10, "TrigerSettings error"); enum VOLTAGE_SCALE { - S100mV = 0b0011, // 1:1 x10 - S200mV = 0b0111, // 1:1 x5 - S500mV = 0b1011, // 1:1 x2 + S100mV = 0b1100, // 1:1 x10 + S200mV = 0b1110, // 1:1 x5 + S500mV = 0b1101, // 1:1 x2 S1V = 0b0000, // 1:10 x10 - S2V = 0b0100, // 1:10 x5 - S5V = 0b1000, // 1:10 x2 + S2V = 0b0010, // 1:10 x5 + S5V = 0b0001, // 1:10 x2 - S10V = 0b0001, // 1:100x10 - S20V = 0b0101, // 1:100x5 + S10V = 0b1000, // 1:100x10 + S20V = 0b1010, // 1:100x5 S50V = 0b1001, // 1:100x2 }; union ChannelVoltage {