gpio fix; author: HTotoo (#3302)

This commit is contained in:
未来方舟
2026-08-23 18:20:14 +08:00
committed by GitHub
parent 84e7f517ba
commit cad70d6e39
+12 -12
View File
@@ -251,36 +251,36 @@ struct GPIO {
// Physical Level Operations // Physical Level Operations
void set() const { __attribute__((always_inline)) void set() const {
palSetPad(_gpio_port, _gpio_pad); palSetPad(_gpio_port, _gpio_pad);
} }
void clear() const { __attribute__((always_inline)) void clear() const {
palClearPad(_gpio_port, _gpio_pad); palClearPad(_gpio_port, _gpio_pad);
} }
void toggle() const { __attribute__((always_inline)) void toggle() const {
palTogglePad(_gpio_port, _gpio_pad); palTogglePad(_gpio_port, _gpio_pad);
} }
void output() const { __attribute__((always_inline)) void output() const {
palSetPadMode(_gpio_port, _gpio_pad, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(_gpio_port, _gpio_pad, PAL_MODE_OUTPUT_PUSHPULL);
} }
void input() const { __attribute__((always_inline)) void input() const {
palSetPadMode(_gpio_port, _gpio_pad, PAL_MODE_INPUT); palSetPadMode(_gpio_port, _gpio_pad, PAL_MODE_INPUT);
} }
void write(const bool value) const { __attribute__((always_inline)) void write(const bool value) const {
palWritePad(_gpio_port, _gpio_pad, value); palWritePad(_gpio_port, _gpio_pad, value);
} }
bool read() const { __attribute__((always_inline)) bool read() const {
return palReadPad(_gpio_port, _gpio_pad); return palReadPad(_gpio_port, _gpio_pad);
} }
// Turns the feature ON based on its polarity // Turns the feature ON based on its polarity
void setActive() const { __attribute__((always_inline)) void setActive() const {
if (_polarity == Polarity::ActiveHigh) { if (_polarity == Polarity::ActiveHigh) {
set(); set();
} else { } else {
@@ -289,7 +289,7 @@ struct GPIO {
} }
// Turns the feature OFF based on its polarity // Turns the feature OFF based on its polarity
void setInactive() const { __attribute__((always_inline)) void setInactive() const {
if (_polarity == Polarity::ActiveHigh) { if (_polarity == Polarity::ActiveHigh) {
clear(); clear();
} else { } else {
@@ -298,7 +298,7 @@ struct GPIO {
} }
// Sets the logical state of the feature // Sets the logical state of the feature
void setState(const bool active) const { __attribute__((always_inline)) void setState(const bool active) const {
if (active) { if (active) {
setActive(); setActive();
} else { } else {
@@ -307,12 +307,12 @@ struct GPIO {
} }
// Returns true if the feature is logically active/enabled // Returns true if the feature is logically active/enabled
bool isEnabled() const { __attribute__((always_inline)) bool isEnabled() const {
const bool physical_state = read(); const bool physical_state = read();
return (_polarity == Polarity::ActiveHigh) ? physical_state : !physical_state; return (_polarity == Polarity::ActiveHigh) ? physical_state : !physical_state;
} }
bool operator!=(const GPIO& other) const { __attribute__((always_inline)) bool operator!=(const GPIO& other) const {
return (port() != other.port()) || (pad() != other.pad()); return (port() != other.port()) || (pad() != other.pad());
} }