Norimasa Okamoto / USBLocalFileSystem

Dependencies:   USBDevice

Dependents:   KL46Z-lpc81isp lpcterm2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USB_HID.h Source File

USB_HID.h

00001 /* Copyright (c) 2010-2011 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 #pragma once
00020 
00021 #include "USBHID_Types.h"
00022 #include "USBDevice.h"
00023 
00024 #define HID_EPINT_IN   EP4IN
00025 #define HID_EPINT_OUT  EP4OUT
00026 
00027 /** USB HID device for CMSIS-DAP
00028  */
00029 class USB_HID {
00030 public:
00031 
00032     /**
00033     * Constructor
00034     *
00035     * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes)
00036     * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
00037     */
00038     USB_HID(USBDevice* device, uint8_t output_report_length = 64, uint8_t input_report_length = 64);
00039 
00040 
00041     /**
00042     * Send a Report. warning: blocking
00043     *
00044     * @param report Report which will be sent (a report is defined by all data and the length)
00045     * @returns true if successful
00046     */
00047     bool send(HID_REPORT *report);
00048     
00049     
00050     /**
00051     * Send a Report. warning: non blocking
00052     *
00053     * @param report Report which will be sent (a report is defined by all data and the length)
00054     * @returns true if successful
00055     */
00056     bool sendNB(HID_REPORT *report);
00057     
00058     /**
00059     * Read a report: blocking
00060     *
00061     * @param report pointer to the report to fill
00062     * @returns true if successful
00063     */
00064     bool read(HID_REPORT * report);
00065     
00066     /**
00067     * Read a report: non blocking
00068     *
00069     * @param report pointer to the report to fill
00070     * @returns true if successful
00071     */
00072     bool readNB(HID_REPORT * report);
00073 
00074     /*
00075     * Get the length of the report descriptor
00076     *
00077     * @returns the length of the report descriptor
00078     */
00079     virtual uint16_t reportDescLength();
00080 
00081     bool Request_callback(CONTROL_TRANSFER* transfer, uint8_t* hidDescriptor);
00082 protected:
00083     /*
00084     * Get the Report descriptor
00085     *
00086     * @returns pointer to the report descriptor
00087     */
00088     virtual uint8_t * reportDesc();
00089 
00090     uint16_t reportLength;
00091 
00092 private:
00093     USBDevice* _device;
00094     HID_REPORT outputReport;
00095     uint8_t output_length;
00096     uint8_t input_length;
00097 };