2012-01-10 20:49:42 +01:00
|
|
|
#include <hid.h>
|
|
|
|
#include <hiduniversal.h>
|
|
|
|
#include <hidescriptorparser.h>
|
2013-10-02 00:49:46 +02:00
|
|
|
#include <usbhub.h>
|
2013-12-05 03:56:06 +01:00
|
|
|
#include "pgmstrings.h"
|
2014-08-03 00:57:37 +02:00
|
|
|
|
|
|
|
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
|
|
|
#include <SPI.h>
|
2013-12-05 00:40:23 +01:00
|
|
|
#include <spi4teensy3.h>
|
|
|
|
#endif
|
2012-01-10 20:49:42 +01:00
|
|
|
|
2012-04-03 22:09:04 +02:00
|
|
|
class HIDUniversal2 : public HIDUniversal
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
|
2013-12-05 00:40:23 +01:00
|
|
|
|
2012-04-03 22:09:04 +02:00
|
|
|
protected:
|
|
|
|
virtual uint8_t OnInitSuccessful();
|
|
|
|
};
|
|
|
|
|
|
|
|
uint8_t HIDUniversal2::OnInitSuccessful()
|
|
|
|
{
|
|
|
|
uint8_t rcode;
|
2013-12-05 00:40:23 +01:00
|
|
|
|
2012-04-03 22:09:04 +02:00
|
|
|
HexDumper<USBReadParser, uint16_t, uint16_t> Hex;
|
|
|
|
ReportDescParser Rpt;
|
|
|
|
|
2013-12-30 04:55:03 +01:00
|
|
|
if ((rcode = GetReportDescr(0, &Hex)))
|
2012-04-03 22:09:04 +02:00
|
|
|
goto FailGetReportDescr1;
|
2013-12-05 00:40:23 +01:00
|
|
|
|
2013-12-30 04:55:03 +01:00
|
|
|
if ((rcode = GetReportDescr(0, &Rpt)))
|
2012-04-03 22:09:04 +02:00
|
|
|
goto FailGetReportDescr2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
FailGetReportDescr1:
|
|
|
|
USBTRACE("GetReportDescr1:");
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
FailGetReportDescr2:
|
|
|
|
USBTRACE("GetReportDescr2:");
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
Serial.println(rcode, HEX);
|
|
|
|
Release();
|
|
|
|
return rcode;
|
|
|
|
}
|
|
|
|
|
2013-12-05 00:40:23 +01:00
|
|
|
USB Usb;
|
|
|
|
//USBHub Hub(&Usb);
|
|
|
|
HIDUniversal2 Hid(&Usb);
|
|
|
|
UniversalReportParser Uni;
|
2012-01-10 20:49:42 +01:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin( 115200 );
|
2013-10-21 19:58:03 +02:00
|
|
|
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
2012-01-10 20:49:42 +01:00
|
|
|
Serial.println("Start");
|
|
|
|
|
|
|
|
if (Usb.Init() == -1)
|
|
|
|
Serial.println("OSC did not start.");
|
2013-12-05 00:40:23 +01:00
|
|
|
|
2012-01-10 20:49:42 +01:00
|
|
|
delay( 200 );
|
|
|
|
|
|
|
|
if (!Hid.SetReportParser(0, &Uni))
|
2013-12-05 00:40:23 +01:00
|
|
|
ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1 );
|
2012-01-10 20:49:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
Usb.Task();
|
|
|
|
}
|
|
|
|
|