USB device stack, with KL25Z fixes for USB 3.0 hosts and sleep/resume interrupt handling
Dependents: frdm_Slider_Keyboard idd_hw2_figlax_PanType idd_hw2_appachu_finger_chording idd_hw3_AngieWangAntonioDeLimaFernandesDanielLim_BladeSymphony ... more
Fork of USBDevice by
USBHID Class Reference
#include <USBHID.h>
Inherits USBDevice.
Inherited by USBKeyboard, USBMouse, and USBMouseKeyboard.
Public Member Functions | |
USBHID (uint8_t output_report_length=64, uint8_t input_report_length=64, uint16_t vendor_id=0x1234, uint16_t product_id=0x0006, uint16_t product_release=0x0001, bool connect=true) | |
Constructor. | |
bool | send (HID_REPORT *report) |
Send a Report. | |
bool | sendNB (HID_REPORT *report) |
Send a Report. | |
bool | sendTO (HID_REPORT *report, int timeout_ms) |
Send a Report with timeout. | |
bool | read (HID_REPORT *report) |
Read a report: blocking. | |
bool | readNB (HID_REPORT *report) |
Read a report: non blocking. | |
bool | writeTO (uint8_t endpoint, uint8_t *buffer, uint32_t size, uint32_t maxSize, int timeout_ms) |
Write a certain endpoint. |
Detailed Description
USBHID example.
#include "mbed.h" #include "USBHID.h" USBHID hid; HID_REPORT recv; BusOut leds(LED1,LED2,LED3,LED4); int main(void) { while (1) { hid.read(&recv); leds = recv.data[0]; } }
Definition at line 50 of file USBHID.h.
Constructor & Destructor Documentation
USBHID | ( | uint8_t | output_report_length = 64 , |
uint8_t | input_report_length = 64 , |
||
uint16_t | vendor_id = 0x1234 , |
||
uint16_t | product_id = 0x0006 , |
||
uint16_t | product_release = 0x0001 , |
||
bool | connect = true |
||
) |
Constructor.
- Parameters:
-
output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes) input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes) vendor_id Your vendor_id product_id Your product_id product_release Your preoduct_release connect Connect the device
Definition at line 24 of file USBHID.cpp.
Member Function Documentation
bool read | ( | HID_REPORT * | report ) |
Read a report: blocking.
- Parameters:
-
report pointer to the report to fill
- Returns:
- true if successful
Definition at line 50 of file USBHID.cpp.
bool readNB | ( | HID_REPORT * | report ) |
Read a report: non blocking.
- Parameters:
-
report pointer to the report to fill
- Returns:
- true if successful
Definition at line 62 of file USBHID.cpp.
bool send | ( | HID_REPORT * | report ) |
Send a Report.
warning: blocking
- Parameters:
-
report Report which will be sent (a report is defined by all data and the length)
- Returns:
- true if successful
Definition at line 34 of file USBHID.cpp.
bool sendNB | ( | HID_REPORT * | report ) |
Send a Report.
warning: non blocking
- Parameters:
-
report Report which will be sent (a report is defined by all data and the length)
- Returns:
- true if successful
Definition at line 39 of file USBHID.cpp.
bool sendTO | ( | HID_REPORT * | report, |
int | timeout_ms | ||
) |
Send a Report with timeout.
Blocks until the report has been sent or the timeout expires, whichever comes first.
- Parameters:
-
report Report to be sent timeout_ms Timeout in milliseconds
- Returns:
- true if successful
Definition at line 44 of file USBHID.cpp.
bool writeTO | ( | uint8_t | endpoint, |
uint8_t * | buffer, | ||
uint32_t | size, | ||
uint32_t | maxSize, | ||
int | timeout_ms | ||
) | [inherited] |
Write a certain endpoint.
Blocks until the report has been sent successfully, or until the timeout expires, whichever comes first.
- Parameters:
-
endpoint endpoint to write buffer data contained in buffer will be write size the number of bytes to write maxSize the maximum length that can be written on this endpoint timeout_ms timeout in milliseconds
- Returns:
- true if successful, false on error or timeout
Definition at line 928 of file USBDevice.cpp.
Generated on Tue Jul 12 2022 18:05:22 by 1.7.2