Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.
Dependencies: FastIO FastPWM SimpleDMA mbed
Fork of Pinscape_Controller by
Revision 55:e47a4b7ab348, committed 2016-02-11
- Comitter:
- mjr
- Date:
- Thu Feb 11 19:14:12 2016 +0000
- Parent:
- 54:af65c577a563
- Child:
- 56:c435f370f511
- Commit message:
- Roll forward (USBHid.cpp protocol additions)
Changed in this revision
--- a/USBDevice/USBDevice/USBHAL.h Thu Feb 11 19:08:37 2016 +0000 +++ b/USBDevice/USBDevice/USBHAL.h Thu Feb 11 19:14:12 2016 +0000 @@ -112,6 +112,10 @@ bool (USBHAL::*epCallback[10 - 2])(void); #elif defined(TARGET_STM32F4XX) bool (USBHAL::*epCallback[8 - 2])(void); +#elif defined(TARGET_KL25Z) + bool (USBHAL::*epCallback[32])(void); + bool EP0_IN_callback(); + bool EP0_OUT_callback(); #else bool (USBHAL::*epCallback[32 - 2])(void); #endif
--- a/USBDevice/USBHID/USBHID.cpp Thu Feb 11 19:08:37 2016 +0000 +++ b/USBDevice/USBHID/USBHID.cpp Thu Feb 11 19:14:12 2016 +0000 @@ -146,6 +146,23 @@ { switch (transfer->setup.bRequest) { + case GET_REPORT: + // not implemented + break; + + case GET_IDLE: + // retrieve the idle rate from an interface + idleData = getIdleTime(transfer->setup.wIndex, LSB(transfer->setup.wValue)); + transfer->ptr = &idleData; + transfer->remaining = 1; + transfer->direction = DEVICE_TO_HOST; + success = true; + break; + + case GET_PROTOCOL: + // not implemented + break; + case SET_REPORT: // First byte will be used for report ID outputReport.data[0] = transfer->setup.wValue & 0xff; @@ -156,6 +173,23 @@ transfer->direction = HOST_TO_DEVICE; transfer->notify = true; success = true; + break; + + case SET_IDLE: + // Set idle time - time between INTERRUPT IN reports from the + // device when there are no changes to report. setup.wIndex + // is the interface index (we're setting the idle time for the + // given interface only). MSB(setup.wValue) gives the interval + // in 4ms units, with the special case that 0 means infinity. + setIdleTime(transfer->setup.wIndex, LSB(transfer->setup.wValue), MSB(transfer->setup.wValue)); + transfer->remaining = 0; + transfer->direction = DEVICE_TO_HOST; + success = true; + + case SET_PROTOCOL: + // not implemented + break; + default: break; }
--- a/USBDevice/USBHID/USBHID.h Thu Feb 11 19:08:37 2016 +0000 +++ b/USBDevice/USBHID/USBHID.h Thu Feb 11 19:14:12 2016 +0000 @@ -149,7 +149,39 @@ * @returns pointer to the configuration descriptor */ virtual uint8_t * configurationDesc(); - + + /* + * Set the idle time on the given interface. The idle time is the time between + * INTERRUPT IN reports sent from the device to the host in the absence of any + * updates in values. E.g., for a keyboard, this is the time between reports + * when there's no new key up/down activity to report. An infinite idle time + * means that reports are sent only when new activity occurs. + * + * @param ifc Interface index (this specifies which interface is affected, in + * cases where the device has multiple interfaces) + * + * @param reportID Report ID (specifies which report type is affected, in cases + * where the device has multiple report types) + * + * @param t Idle time in 4ms units, with the special case that 0 means infinity. + * The maximum value is 255 units (1.02s). + */ + virtual void setIdleTime(int ifc, int reportId, int t) { } + + /* + * Get the idle time on the given interface. Returns the idle time information + * previously set with setIdleTime(). + * + * @param ifc Interface index (specifies which interface is being queried, in + * cases where the device has multiple interfaces) + * + * @param reportID Report ID (specifies which report type is being queried, in + * cases where the device has multiple report types) + * + * @return The idle time currently set on the interface, in 4ms units. 0 means + * infinity (so reports will only be sent when there's new data) + */ + virtual uint8_t getIdleTime(int ifc, int reportId) { return 0; } /* * HID Report received by SET_REPORT request. Warning: Called in ISR context @@ -183,6 +215,7 @@ HID_REPORT outputReport; uint8_t output_length; uint8_t input_length; + uint8_t idleData; }; #endif
--- a/USBDevice/USBHID/USBHID_Types.h Thu Feb 11 19:08:37 2016 +0000 +++ b/USBDevice/USBHID/USBHID_Types.h Thu Feb 11 19:14:12 2016 +0000 @@ -35,10 +35,12 @@ #define REPORT_DESCRIPTOR (34) /* Class requests */ -#define GET_REPORT (0x1) -#define GET_IDLE (0x2) -#define SET_REPORT (0x9) -#define SET_IDLE (0xa) +#define GET_REPORT (0x01) +#define GET_IDLE (0x02) +#define GET_PROTOCOL (0x03) +#define SET_REPORT (0x09) +#define SET_IDLE (0x0a) +#define SET_PROTOCOL (0x0b) /* HID Class Report Descriptor */ /* Short items: size is 0, 1, 2 or 3 specifying 0, 1, 2 or 4 (four) bytes */