4 #include "pgmstrings.h"
6 // Satisfy the IDE, which needs to see the include statment in the ino too.
8 #include <spi4teensy3.h>
12 class FTDIAsync : public FTDIAsyncOper
15 uint8_t OnInit(FTDI *pftdi);
18 uint8_t FTDIAsync::OnInit(FTDI *pftdi)
22 rcode = pftdi->SetBaudRate(115200);
26 ErrorMessage<uint8_t>(PSTR("SetBaudRate"), rcode);
29 rcode = pftdi->SetFlowControl(FTDI_SIO_DISABLE_FLOW_CTRL);
32 ErrorMessage<uint8_t>(PSTR("SetFlowControl"), rcode);
40 FTDI Ftdi(&Usb, &FtdiAsync);
46 Serial.begin( 115200 );
47 #if !defined(__MIPSEL__)
48 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
50 Serial.println("Start");
53 Serial.println("OSC did not start.");
57 next_time = millis() + 5000;
64 if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
67 char strbuf[] = "DEADBEEF";
68 //char strbuf[] = "The quick brown fox jumps over the lazy dog";
69 //char strbuf[] = "This string contains 61 character to demonstrate FTDI buffers"; //add one symbol to it to see some garbage
72 rcode = Ftdi.SndData(strlen(strbuf), (uint8_t*)strbuf);
75 ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
81 for (uint8_t i=0; i<64; i++)
85 rcode = Ftdi.RcvData(&rcvd, buf);
87 if (rcode && rcode != hrNAK)
88 ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
90 // The device reserves the first two bytes of data
91 // to contain the current values of the modem and line status registers.
93 Serial.print((char*)(buf+2));