ftdipp_mpsse: add method to configure individually pins direction

This commit is contained in:
Gwenhael Goavec-Merou 2020-10-30 08:18:38 +01:00
parent 2398ee1445
commit b0f73aa8d9
2 changed files with 29 additions and 0 deletions

View File

@ -479,6 +479,32 @@ void FTDIpp_MPSSE::gpio_set_dir(uint16_t dir)
_cable.bit_high_dir = (dir >> 8) & 0xff;
}
/**
* configure low or high pins as input
* @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)
{
if (low_pins)
_cable.bit_low_dir &= ~gpio;
else
_cable.bit_high_dir &= ~gpio;
}
/**
* 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)
{
if (low_pins)
_cable.bit_low_dir |= gpio;
else
_cable.bit_high_dir |= gpio;
}
/**
* private method to write ftdi half bank GPIOs (pins state are in _cable)
* @param[in] low or high half bank

View File

@ -39,8 +39,11 @@ class FTDIpp_MPSSE {
/* full access */
bool gpio_write(uint16_t gpio);
bool gpio_write(uint8_t gpio, bool low_pins);
/* 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);
protected:
void open_device(const std::string &serial, unsigned int baudrate);