1 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
2 * Modifications by Jacob Alexander 2014 <haata@kiibohd.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __USB_INTERNAL_H
19 #define __USB_INTERNAL_H
22 * Internal driver structures
29 * Device configuration states:
31 * Attached <-> Powered
32 * Powered -(reset)-> Default
33 * Default -(SET_ADDRESS)-> Address
34 * Address -(SET_CONFIGURATION)-> Configured
35 * Configured -(SET_CONFIGURATION 0)-> Address
36 * Address -(SET_ADDRESS 0)-> Default
37 * [Default, Configured, Address] -(reset)-> Default
40 // ----- Defines -----
48 // ----- Structs -----
50 struct usbd_ep_pipe_state_t {
51 enum usb_ep_pingpong pingpong; /* next desc to use */
52 enum usb_data01 data01;
56 const uint8_t *copy_source;
58 ep_callback_t callback;
63 enum usb_ep_dir ep_dir;
66 struct usbd_ep_state_t {
68 struct usbd_ep_pipe_state_t pipe[2];
70 struct usbd_ep_pipe_state_t rx;
71 struct usbd_ep_pipe_state_t tx;
77 struct usbd_function_ctx_header functions;
78 struct usbd_function control_function;
79 const struct usbd_device *identity;
83 USBD_STATE_DISABLED = 0,
85 USBD_STATE_SETTING_ADDRESS,
89 enum usb_ctrl_req_dir ctrl_dir;
90 struct usbd_ep_state_t ep_state[USB_MAX_EP];
93 extern struct usbd_t usb;
97 // ----- Functions -----
99 void usb_restart(void);
100 void usb_enable(void);
101 const struct usbd_config *usb_get_config_data(int config);