diff --git a/src/ftdipp_mpsse.cpp b/src/ftdipp_mpsse.cpp index 0cf2f38..dd30255 100644 --- a/src/ftdipp_mpsse.cpp +++ b/src/ftdipp_mpsse.cpp @@ -484,7 +484,7 @@ void FTDIpp_MPSSE::gpio_set_dir(uint16_t dir) * @param[in] gpio: pins bitmask * @param[int] low_pins: select between CBUS or DBUS */ -void FTDIpp_MPSSE::gpio_set_input(uint16_t gpio, bool low_pins) +void FTDIpp_MPSSE::gpio_set_input(uint8_t gpio, bool low_pins) { if (low_pins) _cable.bit_low_dir &= ~gpio; @@ -492,12 +492,24 @@ void FTDIpp_MPSSE::gpio_set_input(uint16_t gpio, bool low_pins) _cable.bit_high_dir &= ~gpio; } +/** + * configure pins as input + * @param[in] gpio: pins bitmask + */ +void FTDIpp_MPSSE::gpio_set_input(uint16_t gpio) +{ + if (gpio & 0x00ff) + _cable.bit_low_dir &= ~(gpio & 0x00ff); + if (gpio & 0xff00) + _cable.bit_high_dir &= ~((gpio >> 8) & 0x00ff); +} + /** * configure low or high pins as output * @param[in] gpio: pins bitmask * @param[int] low_pins: select between CBUS or DBUS */ -void FTDIpp_MPSSE::gpio_set_output(uint16_t gpio, bool low_pins) +void FTDIpp_MPSSE::gpio_set_output(uint8_t gpio, bool low_pins) { if (low_pins) _cable.bit_low_dir |= gpio; @@ -505,6 +517,18 @@ void FTDIpp_MPSSE::gpio_set_output(uint16_t gpio, bool low_pins) _cable.bit_high_dir |= gpio; } +/** + * configure pins as output + * @param[in] gpio: pins bitmask + */ +void FTDIpp_MPSSE::gpio_set_output(uint16_t gpio) +{ + if (gpio & 0x00ff) + _cable.bit_low_dir |= (gpio & 0x00ff); + if (gpio & 0xff00) + _cable.bit_high_dir |= ((gpio >> 8) & 0x00ff); +} + /** * private method to write ftdi half bank GPIOs (pins state are in _cable) * @param[in] low or high half bank diff --git a/src/ftdipp_mpsse.hpp b/src/ftdipp_mpsse.hpp index 4dc8633..3540c06 100644 --- a/src/ftdipp_mpsse.hpp +++ b/src/ftdipp_mpsse.hpp @@ -42,8 +42,14 @@ class FTDIpp_MPSSE { /* gpio direction */ void gpio_set_dir(uint8_t dir, bool low_pins); void gpio_set_dir(uint16_t dir); - void gpio_set_input(uint16_t gpio, bool low_pins); - void gpio_set_output(uint16_t gpio, bool low_pins); + /* configure as input low/high pins */ + void gpio_set_input(uint8_t gpio, bool low_pins); + /* configure as input pins */ + void gpio_set_input(uint16_t gpio); + /* configure as output low/high pins */ + void gpio_set_output(uint8_t gpio, bool low_pins); + /* configure as output pins */ + void gpio_set_output(uint16_t gpio); protected: void open_device(const std::string &serial, unsigned int baudrate);