Skip to content

Commit

Permalink
Set gpio low on close
Browse files Browse the repository at this point in the history
  • Loading branch information
nurikk-sa committed Mar 5, 2023
1 parent fef0ea8 commit ccd1f4a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions sources/leddevice/dev_ftdi/ProviderFtdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#define ANY_FTDI_VENDOR 0x0
#define ANY_FTDI_PRODUCT 0x0

#define PIN_VALUES 0b00000000
#define PIN_DIRECTIONS_OUTPUTS 0b00000011
#define PIN_DIRECTIONS_INPUTS 0b00000000

ProviderFtdi::ProviderFtdi(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig),
_ftdic(NULL),
Expand Down Expand Up @@ -90,16 +94,16 @@ int ProviderFtdi::open()
{
return rc;
}
if ((rc = writeByte(0x80)) != 1)
if ((rc = writeByte(SET_BITS_LOW)) != 1)
{
return rc;
}

if ((rc = writeByte(0x00)) != 1)
if ((rc = writeByte(0b00000000)) != 1)
{
return rc;
}
if ((rc = writeByte(0x0b)) != 1)
if ((rc = writeByte(0b00000011)) != 1)
{
return rc;
}
Expand All @@ -112,6 +116,12 @@ int ProviderFtdi::close()
if (_ftdic != NULL)
{
Debug(_log, "Closing FTDI device");
unsigned char cmd[] = {
SET_BITS_LOW,
0b00000000,
0b00000000
};
ftdi_write_data(_ftdic, cmd, 1);
ftdi_set_bitmode(_ftdic, 0x00, BITMODE_RESET);
ftdi_usb_close(_ftdic);
ftdi_free(_ftdic);
Expand Down

0 comments on commit ccd1f4a

Please sign in to comment.