#ifndef USBSTACK_HID_H_ #define USBSTACK_HID_H_ /* * Tiny USB stack * HID device driver * * Copyright (C) 2014 Michael Buesch * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include struct usb_ctrl; struct usb_hid_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdHID; uint8_t bCountryCode; uint8_t bNumDescriptors; uint8_t bClassDescriptorType; uint16_t wClassDescriptorLength; } __attribute__ ((packed)); #define USB_HID_UNHANDLED 0xFF /** usb_hid_reset - Reset all state */ void usb_hid_reset(void); /** usb_hid_control_rx - Handle a received EP0 frame in the HID layer. * @ctl: The received control frame * @reply_buf: Buffer for reply. Buffer size is USBCFG_EP0_MAXSIZE. * On success, returns the number of bytes in reply_buf. * On failure, returns USB_APP_UNHANDLED. */ uint8_t usb_hid_control_rx(struct usb_ctrl *ctl, uint8_t *reply_buf); /** usb_hid_ep1_rx - Handle a received EP1 frame in the HID layer. * @data: The received frame * @size: The size of the received frame * @reply_buf: Buffer for reply. Buffer size is USBCFG_EP1_MAXSIZE. * On success, returns the number of bytes in reply_buf. * On failure, returns USB_HID_UNHANDLED. */ uint8_t usb_hid_ep1_rx(uint8_t *data, uint8_t size, uint8_t *reply_buf); /** usb_hid_ep1_tx_poll - TX data poll on EP1. */ uint8_t usb_hid_ep1_tx_poll(uint8_t *buf); /** usb_hid_ep2_rx - Handle a received EP2 frame in the HID layer. * @data: The received frame * @size: The size of the received frame * @reply_buf: Buffer for reply. Buffer size is USBCFG_EP2_MAXSIZE. * On success, returns the number of bytes in reply_buf. * On failure, returns USB_HID_UNHANDLED. */ uint8_t usb_hid_ep2_rx(uint8_t *data, uint8_t size, uint8_t *reply_buf); /** usb_hid_ep2_tx_poll - TX data poll on EP2. */ uint8_t usb_hid_ep2_tx_poll(uint8_t *buf); uint16_t usb_hid_get_descriptor_length(void); #endif /* USBSTACK_HID_H_ */