small repair

This commit is contained in:
Kizarm 2024-11-30 11:03:21 +01:00
parent b12b9b92af
commit 84be40e742
2 changed files with 24 additions and 14 deletions

View file

@ -33,13 +33,23 @@ class GpioClass {
//r.B.IOPCEN = SET; //r.B.IOPCEN = SET;
return r.R; return r.R;
}); });
const uint32_t pos = pin << 2; if (pin < 8u) {
port.CFGLR.modify([=](GPIOA_Type::CFGLR_DEF & r)->auto { const uint32_t pos = pin << 2;
uint32_t t = r.R; port.CFGLR.modify([=](GPIOA_Type::CFGLR_DEF & r)->auto {
t &= ~(0xFu << pos); uint32_t t = r.R;
t |= _mode << pos; t &= ~(0xFu << pos);
return t; 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 { void operator<< (const bool b) const {
port.BSHR.R = b ? 1u << pin : 1u << (pin + 16); port.BSHR.R = b ? 1u << pin : 1u << (pin + 16);

View file

@ -28,16 +28,16 @@ struct TrigerSettings {
}; };
static_assert (sizeof(TrigerSettings) == 10, "TrigerSettings error"); static_assert (sizeof(TrigerSettings) == 10, "TrigerSettings error");
enum VOLTAGE_SCALE { enum VOLTAGE_SCALE {
S100mV = 0b0011, // 1:1 x10 S100mV = 0b1100, // 1:1 x10
S200mV = 0b0111, // 1:1 x5 S200mV = 0b1110, // 1:1 x5
S500mV = 0b1011, // 1:1 x2 S500mV = 0b1101, // 1:1 x2
S1V = 0b0000, // 1:10 x10 S1V = 0b0000, // 1:10 x10
S2V = 0b0100, // 1:10 x5 S2V = 0b0010, // 1:10 x5
S5V = 0b1000, // 1:10 x2 S5V = 0b0001, // 1:10 x2
S10V = 0b0001, // 1:100x10 S10V = 0b1000, // 1:100x10
S20V = 0b0101, // 1:100x5 S20V = 0b1010, // 1:100x5
S50V = 0b1001, // 1:100x2 S50V = 0b1001, // 1:100x2
}; };
union ChannelVoltage { union ChannelVoltage {