1 #include <cdc_XR21B1411.h>
3 // Satisfy IDE, which only needs to see the include statment in the ino.
5 #include <spi4teensy3.h>
9 class ACMAsyncOper : public CDCAsyncOper
12 uint8_t OnInit(ACM *pacm);
15 uint8_t ACMAsyncOper::OnInit(ACM *pacm)
19 rcode = pacm->SetControlLineState(3);
23 ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
28 lc.dwDTERate = 115200;
33 rcode = pacm->SetLineCoding(&lc);
36 ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);
42 ACMAsyncOper AsyncOper;
43 XR21B1411 Acm(&Usb, &AsyncOper);
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("\r\n\r\nStart");
52 if (Usb.Init() == -1) Serial.println("OSCOKIRQ failed to assert");
63 if(Serial.available()) {
64 uint8_t data = Serial.read();
66 rcode = Acm.SndData(1, &data);
68 ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
72 rcode = Acm.RcvData(&rcvd, buf);
73 if (rcode && rcode != hrNAK)
74 ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
76 if( rcvd ) { //more than zero bytes received
77 for(uint16_t i=0; i < rcvd; i++ ) {
78 Serial.print((char)buf[i]);