Simple USBHost library for Nucleo F446RE/F411RE/F401RE FRDM-KL46Z/KL25Z/F64F LPC4088/LPC1768
Dependents: F401RE-BTstack_example F401RE-USBHostMSD_HelloWorld
Fork of KL46Z-USBHost by
USBHostGPS.h
00001 // Simple USBHost GPS Dongle for FRDM-KL46Z 00002 #include "USBHost.h" 00003 #include "decodeNMEA.h" 00004 00005 #define PL2303_SET_LINE_CODING 0x20 00006 00007 class USBHostGPS : public IUSBEnumerator { 00008 public: 00009 00010 /** 00011 * Constructor 00012 */ 00013 USBHostGPS(int baud = 38400); 00014 00015 /** 00016 * Try to connect a USB GPS device 00017 * 00018 * @return true if connection was successful 00019 */ 00020 bool connect(); 00021 00022 /** 00023 * Check if a USB GPS is connected 00024 * 00025 * @returns true if a mouse is connected 00026 */ 00027 bool connected(); 00028 00029 int readNMEA(char* data, int size, int timeout_ms) { 00030 host->bulkRead(dev, bulk_in, (uint8_t*)data, size); 00031 return bulk_in->getLengthTransferred(); 00032 } 00033 void attachEventRaw(void (*ptr)(char* data, int size)) { 00034 if (ptr != NULL) { 00035 onUpdateRaw = ptr; 00036 } 00037 } 00038 00039 decodeNMEA nmea; 00040 00041 protected: 00042 //From IUSBEnumerator 00043 virtual void setVidPid(uint16_t vid, uint16_t pid); 00044 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed 00045 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used 00046 00047 private: 00048 USBHost * host; 00049 USBDeviceConnected* dev; 00050 USBEndpoint* bulk_in; 00051 bool dev_connected; 00052 bool gps_device_found; 00053 int gps_intf; 00054 00055 void rxHandler(); 00056 void (*onUpdateRaw)(char* data, int size); 00057 uint8_t bulk_buf[64]; 00058 int baud; 00059 void init(); 00060 };
Generated on Wed Jul 13 2022 05:41:27 by 1.7.2