modified to compile for me

Dependencies:   FATFileSystem

Dependents:   N64_Output_XPAD

Fork of F401RE-USBHost by Norimasa Okamoto

Committer:
va009039
Date:
Fri Jan 31 13:45:07 2014 +0000
Revision:
8:6463cd1964c0
Parent:
3:a3872f7593e2
USB hub support.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:5160ee0c522d 1 // Simple USBHost GPS Dongle for FRDM-KL46Z
va009039 0:5160ee0c522d 2 #include "USBHost.h"
va009039 0:5160ee0c522d 3
va009039 0:5160ee0c522d 4 #define PL2303_SET_LINE_CODING 0x20
va009039 0:5160ee0c522d 5
va009039 8:6463cd1964c0 6 class USBHostGPS : public IUSBEnumerator {
va009039 0:5160ee0c522d 7 public:
va009039 8:6463cd1964c0 8
va009039 8:6463cd1964c0 9 /**
va009039 8:6463cd1964c0 10 * Constructor
va009039 8:6463cd1964c0 11 */
va009039 8:6463cd1964c0 12 USBHostGPS(int baud = 38400);
va009039 8:6463cd1964c0 13
va009039 8:6463cd1964c0 14 /**
va009039 8:6463cd1964c0 15 * Try to connect a USB GPS device
va009039 8:6463cd1964c0 16 *
va009039 8:6463cd1964c0 17 * @return true if connection was successful
va009039 8:6463cd1964c0 18 */
va009039 8:6463cd1964c0 19 bool connect();
va009039 8:6463cd1964c0 20
va009039 8:6463cd1964c0 21 /**
va009039 8:6463cd1964c0 22 * Check if a USB GPS is connected
va009039 8:6463cd1964c0 23 *
va009039 8:6463cd1964c0 24 * @returns true if a mouse is connected
va009039 8:6463cd1964c0 25 */
va009039 8:6463cd1964c0 26 bool connected();
va009039 8:6463cd1964c0 27
va009039 8:6463cd1964c0 28 int readNMEA(char* data, int size, int timeout_ms) {
va009039 8:6463cd1964c0 29 int result = host->BulkRead(bulk_in, (uint8_t*)data, size, timeout_ms);
va009039 8:6463cd1964c0 30 return (result >= 0) ? bulk_in->getLengthTransferred() : 0;
va009039 0:5160ee0c522d 31 }
va009039 8:6463cd1964c0 32 void attachEvent(void (*ptr)(uint8_t* data, int size)) {
va009039 8:6463cd1964c0 33 if (ptr != NULL) {
va009039 8:6463cd1964c0 34 onUpdate = ptr;
va009039 8:6463cd1964c0 35 }
va009039 0:5160ee0c522d 36 }
va009039 8:6463cd1964c0 37 void poll() {
va009039 8:6463cd1964c0 38 int result = host->BulkRead(bulk_in, buf, sizeof(buf), 0);
va009039 8:6463cd1964c0 39 if (result >= 0) {
va009039 8:6463cd1964c0 40 if (onUpdate) {
va009039 8:6463cd1964c0 41 (*onUpdate)(buf, bulk_in->getLengthTransferred());
va009039 8:6463cd1964c0 42 }
va009039 8:6463cd1964c0 43 }
va009039 8:6463cd1964c0 44 }
va009039 8:6463cd1964c0 45
va009039 8:6463cd1964c0 46 protected:
va009039 8:6463cd1964c0 47 //From IUSBEnumerator
va009039 8:6463cd1964c0 48 virtual void setVidPid(uint16_t vid, uint16_t pid);
va009039 8:6463cd1964c0 49 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
va009039 8:6463cd1964c0 50 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
va009039 0:5160ee0c522d 51
va009039 0:5160ee0c522d 52 private:
va009039 0:5160ee0c522d 53 USBHost * host;
va009039 8:6463cd1964c0 54 USBDeviceConnected* dev;
va009039 8:6463cd1964c0 55 USBEndpoint* bulk_in;
va009039 8:6463cd1964c0 56 bool dev_connected;
va009039 8:6463cd1964c0 57 bool gps_device_found;
va009039 8:6463cd1964c0 58 int gps_intf;
va009039 8:6463cd1964c0 59 void (*onUpdate)(uint8_t* data, int size);
va009039 8:6463cd1964c0 60 uint8_t buf[64];
va009039 8:6463cd1964c0 61 int baud;
va009039 8:6463cd1964c0 62 void init();
va009039 0:5160ee0c522d 63 };