1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:37:46 +00:00

Kernel: Allow enabling high level detection on GPIOs

Co-authored-by: Timon Kruiper <timonkruiper@gmail.com>
Co-authored-by: Ollrogge <nils-ollrogge@outlook.de>
This commit is contained in:
Marco Cutecchia 2023-03-16 11:12:11 +01:00 committed by Linus Groh
parent 28acf25035
commit bb8092d6a1
2 changed files with 17 additions and 0 deletions

View file

@ -94,4 +94,19 @@ void GPIO::internal_enable_pins(u32 enable[2], PullUpDownState state)
// I don't know if the RPi3 has that already, so this uses the old BCM2835 approach for now. // I don't know if the RPi3 has that already, so this uses the old BCM2835 approach for now.
} }
void GPIO::set_pin_high_detect_enable(unsigned pin_number, bool enable)
{
if (enable) {
if (pin_number < 32)
m_registers->high_detect_enable.bits[0] = m_registers->high_detect_enable.bits[0] | (1 << pin_number);
else
m_registers->high_detect_enable.bits[1] = m_registers->high_detect_enable.bits[1] | (1 << (pin_number - 32));
} else {
if (pin_number < 32)
m_registers->high_detect_enable.bits[0] = m_registers->high_detect_enable.bits[0] & ~(1 << pin_number);
else
m_registers->high_detect_enable.bits[1] = m_registers->high_detect_enable.bits[1] & ~(1 << (pin_number - 32));
}
}
} }

View file

@ -50,6 +50,8 @@ public:
internal_enable_pins(enable, state); internal_enable_pins(enable, state);
} }
void set_pin_high_detect_enable(unsigned pin_number, bool enable);
private: private:
GPIO(); GPIO();
void internal_enable_pins(u32 enable[2], PullUpDownState state); void internal_enable_pins(u32 enable[2], PullUpDownState state);