summaryrefslogtreecommitdiffstats
path: root/hid/firmware/usb_hid.h
blob: 38cc6f2317edfd8dd404000bdb18984ecdcee3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef USBSTACK_HID_H_
#define USBSTACK_HID_H_
/*
 *   Tiny USB stack
 *   HID device driver
 *
 *   Copyright (C) 2014 Michael Buesch <m@bues.ch>
 *
 *   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 <stdint.h>

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_ */
bues.ch cgit interface