1 /* USB Host to PL2303-based USB GPS unit interface */
2 /* Navibee GM720 receiver - Sirf Star III */
7 #include <cdcprolific.h>
9 // Satisfy the IDE, which needs to see the include statment in the ino too.
11 #include <spi4teensy3.h>
15 class PLAsyncOper : public CDCAsyncOper {
17 uint8_t OnInit(ACM *pacm);
20 uint8_t PLAsyncOper::OnInit(ACM *pacm) {
24 rcode = pacm->SetControlLineState(1);
27 ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
32 lc.dwDTERate = 4800; //default serial speed of GPS unit
37 rcode = pacm->SetLineCoding(&lc);
40 ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);
47 PLAsyncOper AsyncOper;
48 PL2303 Pl(&Usb, &AsyncOper);
50 #define READ_DELAY 100
54 #if !defined(__MIPSEL__)
55 while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
57 Serial.println("Start");
60 Serial.println("OSCOKIRQ failed to assert");
67 uint8_t buf[64]; //serial buffer equals Max.packet size of bulk-IN endpoint
74 if((long)(millis() - read_delay) >= 0L) {
75 read_delay += READ_DELAY;
76 rcode = Pl.RcvData(&rcvd, buf);
77 if(rcode && rcode != hrNAK)
78 ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
79 if(rcvd) { //more than zero bytes received
80 for(uint16_t i = 0; i < rcvd; i++) {
81 Serial.print((char)buf[i]); //printing on the screen
82 }//for( uint16_t i=0; i < rcvd; i++...
84 }//if( read_delay > millis()...
85 }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..