ftdipp_mpsse: add method to update pins direction

This commit is contained in:
Gwenhael Goavec-Merou 2020-10-28 19:48:59 +01:00
parent ed006711b7
commit 05e1c57cc5
2 changed files with 25 additions and 0 deletions

View File

@ -456,6 +456,29 @@ bool FTDIpp_MPSSE::gpio_write(uint8_t gpio, bool low_pins)
return (mpsse_write() >= 0);
}
/**
* update half bank pins direction (no write is done at this time)
* @param[in] dir: pins direction (1 out, 0 in) for low or high bank
* @param[in] low_pins: high/low half bank
*/
void FTDIpp_MPSSE::gpio_set_dir(uint8_t dir, bool low_pins)
{
if (low_pins)
_cable.bit_low_dir = dir;
else
_cable.bit_high_dir = dir;
}
/**
* update full bank pins direction (no write is done at this time)
* @param[in] dir: pins direction (1 out, 0 in) for low or high bank
*/
void FTDIpp_MPSSE::gpio_set_dir(uint16_t dir)
{
_cable.bit_low_dir = dir & 0xff;
_cable.bit_high_dir = (dir >> 8) & 0xff;
}
/**
* private method to write ftdi half bank GPIOs (pins state are in _cable)
* @param[in] low or high half bank

View File

@ -39,6 +39,8 @@ class FTDIpp_MPSSE {
/* full access */
bool gpio_write(uint16_t gpio);
bool gpio_write(uint8_t gpio, bool low_pins);
void gpio_set_dir(uint8_t dir, bool low_pins);
void gpio_set_dir(uint16_t dir);
protected:
void open_device(const std::string &serial, unsigned int baudrate);