John Mitchell / lpc4088_displaymodule_GC500_2_5inch

Dependencies:   DMBasicGUI DMSupport

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBHostGC.h Source File

USBHostGC.h

00001 #ifndef USBHOSTGC_H
00002 #define USBHOSTGC_H
00003 
00004 #include "lpc_swim.h"
00005 #include "lpc_swim_font.h"
00006 
00007 #include "USBHostConf.h"
00008 #include "USBHost.h"
00009 
00010 enum GC_IDS {
00011     GC_VENDOR_ID = 0x0925,
00012     GC_PRODUCT_ID = 0x1234,  // Earlier sofware versions
00013     GC_PRODUCT_ID_2 = 0x1235 // Later versions
00014 };
00015 
00016 enum GC_MESSAGE_DATA {
00017     GC_MESSAGE_LENGTH = 10,
00018     GC_CR = 13             // Make *sure* we use the same value for <CR> as the GC expects
00019 };
00020 
00021 // USBHost does not define these - GC assembler code does
00022 #define GET_CONFIGURATION 0x08
00023 #define GC_CONFIGURATION_DESCRIPTOR_LENGTH 0x22
00024 
00025 /**
00026  * A class to communicate with a USB GC.
00027  *
00028  */
00029 class USBHostGC : public IUSBEnumerator 
00030 {
00031 public:
00032     USBHostGC();
00033     ~USBHostGC();
00034 
00035     void SetDebugWindow(SWIM_WINDOW_T* newDebugWindow) { debugWindow = newDebugWindow; }
00036 
00037     bool DeviceIsGC(void) { return deviceIsGC; }
00038     
00039     void NoDeviceConnected(void);
00040     
00041     bool AttachGCDevice(USBDeviceConnected* usbDeviceConnected);
00042     
00043     void RXHandler(void);
00044     
00045     USB_TYPE SetDeviceReport(USBDeviceConnected * dev, const char* report, char* response);  
00046     
00047     bool ExecutingSetDeviceReport(void);
00048   
00049     
00050     // From IUSBEnumerator - implement these to make this class non-abstract
00051     virtual void setVidPid(uint16_t vid, uint16_t pid);
00052     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
00053     virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); // Must return true if the endpoint will be used
00054 
00055 private:
00056     void DebugPrint(const char* debugText);
00057     
00058     void AllocateReportBuffer(void);
00059 
00060     SWIM_WINDOW_T* debugWindow;
00061     USBHost* usbHost;
00062 
00063     bool deviceIsGC;
00064     int intfGC;
00065     uint8_t* reportBuffer;
00066     USBEndpoint* intInEndpointGC;
00067     USBDeviceConnected* usbGCDeviceConnected;
00068     
00069     bool volatile responseReceived;
00070     
00071     bool volatile alreadyInSetDeviceReport;
00072 };
00073 
00074 
00075 #endif