Michael Spencer / Smoothie

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USB.h Source File

USB.h

00001 #ifndef _USB_HPP
00002 #define _USB_HPP
00003 
00004 #include "descriptor.h"
00005 
00006 #ifndef N_DESCRIPTORS
00007 #define N_DESCRIPTORS 48
00008 #endif
00009 
00010 #include "USBDevice.h"
00011 
00012 #include "Module.h"
00013 
00014 class USB : public USBDevice, public Module {
00015     static usbdesc_base *descriptors[N_DESCRIPTORS];
00016 
00017     static usbdesc_device device;
00018     static usbdesc_configuration conf;
00019 public:
00020     USB();
00021     USB(uint16_t idVendor, uint16_t idProduct, uint16_t bcdFirmwareRevision);
00022 
00023     void init(void);
00024 
00025     bool USBEvent_busReset(void);
00026     bool USBEvent_connectStateChanged(bool connected);
00027     bool USBEvent_suspendStateChanged(bool suspended);
00028 
00029     bool USBEvent_Request(CONTROL_TRANSFER&);
00030     bool USBEvent_RequestComplete(CONTROL_TRANSFER&, uint8_t *, uint32_t);
00031 
00032     bool USBEvent_EPIn(uint8_t, uint8_t);
00033     bool USBEvent_EPOut(uint8_t, uint8_t);
00034 
00035     bool USBCallback_setConfiguration(uint8_t configuration);
00036     bool USBCallback_setInterface(uint16_t interface, uint8_t alternate);
00037 
00038     void on_module_loaded(void);
00039     void on_idle(void*);
00040 
00041     int addDescriptor(usbdesc_base *descriptor);
00042     int addDescriptor(void *descriptor);
00043 //     int findDescriptor(uint8_t start, uint8_t type, uint8_t index, uint8_t alternate);
00044     int addInterface(usbdesc_interface *);
00045     int addEndpoint(usbdesc_endpoint *);
00046     int addString(const void *);
00047     int getFreeEndpoint();
00048     int findStringIndex(uint8_t strid);
00049 
00050     void dumpDescriptors();
00051     void dumpDevice(usbdesc_device *);
00052     void dumpConfiguration(usbdesc_configuration *);
00053     void dumpInterface(usbdesc_interface *);
00054     void dumpEndpoint(usbdesc_endpoint *);
00055     void dumpString(int i);
00056     void dumpString(usbdesc_string *);
00057     void dumpCDC(uint8_t *);
00058 };
00059 
00060 #endif /* _USB_HPP */