I'm struggling sketching to operate USB peripheral using USB Host Shield. But it doesn't work... The COM settings of the peripheral are as follows;
Baud Rate: 9600
Parity: Odd
Data Bits: 7
Stop Bit: 1
I'm afraid I have not yet set data bit on the sketch. Could you tell me how to set the data bits to be 7?
#include <cdcftdi.h>
#include <usbhub.h>
#include "pgmstrings.h"
// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>
class FTDIAsync : public FTDIAsyncOper
{
public:
uint8_t OnInit(FTDI *pftdi);
};
uint8_t FTDIAsync::OnInit(FTDI *pftdi)
{
uint8_t rcode = 0;
rcode = pftdi->SetBaudRate(9600);
if (rcode)
{
ErrorMessage<uint8_t>(PSTR("SetBaudRate"), rcode);
return rcode;
}
rcode = pftdi->SetData(FTDI_SIO_SET_DATA_STOP_BITS_1);
{
ErrorMessage<uint8_t>(PSTR("SetData 1"), rcode);
return rcode;
}
rcode = pftdi->SetData(FTDI_SIO_SET_DATA_PARITY_ODD);
{
ErrorMessage<uint8_t>(PSTR("SetData 2"), rcode);
return rcode;
}
rcode = pftdi->SetFlowControl(FTDI_SIO_DISABLE_FLOW_CTRL);
if (rcode)
ErrorMessage<uint8_t>(PSTR("SetFlowControl"), rcode);
return rcode;
}
USB Usb;
//USBHub Hub(&Usb);
FTDIAsync FtdiAsync;
FTDI Ftdi(&Usb, &FtdiAsync);