Skip to content
Snippets Groups Projects
Commit 21b5fbbe authored by Clément Foucher's avatar Clément Foucher
Browse files

Include readPin function to GPIO API.

parent 74974de7
No related branches found
No related tags found
No related merge requests found
......@@ -84,6 +84,18 @@ void GpioApi::writePin(pin_t pin, uint8_t value)
}
}
uint8_t GpioApi::readPin(pin_t pin)
{
gpio_pin_t pin_number = this->getPinNumber(pin);
const struct device* port = this->getGpioDevice(pin);
if (port != nullptr)
{
return (uint8_t) gpio_pin_get(port, pin_number);
}
return 0;
}
gpio_pin_t GpioApi::getPinNumber(pin_t pin)
{
return (((uint8_t)pin) & 0x0F) + 1;
......
......@@ -123,6 +123,7 @@ public:
void resetPin(pin_t pin);
void togglePin(pin_t pin);
void writePin(pin_t pin, uint8_t value);
uint8_t readPin(pin_t pin);
private:
gpio_pin_t getPinNumber(pin_t pin);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment