COSA
An Object-Oriented Platform for Arduino Programming
API.h
Go to the documentation of this file.
1 
22 #ifndef COSA_USB_API_H
23 #define COSA_USB_API_H
24 
25 #include "Cosa/Types.h"
26 
27 #if defined(USBCON)
28 
29 class USBDevice_
30 {
31  public:
32  USBDevice_();
33  bool configured();
34  bool attach();
35  void detach();
36  void poll();
37 };
38 extern USBDevice_ USBDevice;
39 
40 typedef struct {
41  uint8_t bmRequestType;
42  uint8_t bRequest;
43  uint8_t wValueL;
44  uint8_t wValueH;
45  uint16_t wIndex;
46  uint16_t wLength;
47 } Setup;
48 
49 int HID_GetInterface(uint8_t* interfaceNum);
50 int HID_GetDescriptor(int i);
51 bool HID_Setup(Setup& setup);
52 void HID_SendReport(uint8_t id, const void* data, int len);
53 
54 int MSC_GetInterface(uint8_t* interfaceNum);
55 int MSC_GetDescriptor(int i);
56 bool MSC_Setup(Setup& setup);
57 bool MSC_Data(uint8_t rx,uint8_t tx);
58 
59 int CDC_GetInterface(uint8_t* interfaceNum);
60 int CDC_GetDescriptor(int i);
61 bool CDC_Setup(Setup& setup);
62 
63 #define TRANSFER_PGM 0x80
64 #define TRANSFER_RELEASE 0x40
65 #define TRANSFER_ZERO 0x20
66 
67 int USB_SendControl(uint8_t flags, const void* d, int len);
68 int USB_RecvControl(void* d, int len);
69 
70 uint8_t USB_Available(uint8_t ep);
71 int USB_Send(uint8_t ep, const void* data, int len);
72 int USB_Recv(uint8_t ep, void* data, int len);
73 int USB_Recv(uint8_t ep);
74 void USB_Flush(uint8_t ep);
75 
76 #endif
77 #endif