ftdipp_mpsse: add method to configure individually pins direction
This commit is contained in:
parent
2398ee1445
commit
b0f73aa8d9
|
|
@ -479,6 +479,32 @@ void FTDIpp_MPSSE::gpio_set_dir(uint16_t dir)
|
||||||
_cable.bit_high_dir = (dir >> 8) & 0xff;
|
_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)
|
* private method to write ftdi half bank GPIOs (pins state are in _cable)
|
||||||
* @param[in] low or high half bank
|
* @param[in] low or high half bank
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,11 @@ class FTDIpp_MPSSE {
|
||||||
/* full access */
|
/* full access */
|
||||||
bool gpio_write(uint16_t gpio);
|
bool gpio_write(uint16_t gpio);
|
||||||
bool gpio_write(uint8_t gpio, bool low_pins);
|
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(uint8_t dir, bool low_pins);
|
||||||
void gpio_set_dir(uint16_t dir);
|
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:
|
protected:
|
||||||
void open_device(const std::string &serial, unsigned int baudrate);
|
void open_device(const std::string &serial, unsigned int baudrate);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue