1 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
2 * Modifications by Jacob Alexander 2014-2015 <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/>.
21 * Internal driver structures
28 * Device configuration states:
30 * Attached <-> Powered
31 * Powered -(reset)-> Default
32 * Default -(SET_ADDRESS)-> Address
33 * Address -(SET_CONFIGURATION)-> Configured
34 * Configured -(SET_CONFIGURATION 0)-> Address
35 * Address -(SET_ADDRESS 0)-> Default
36 * [Default, Configured, Address] -(reset)-> Default
39 // ----- Defines -----
47 // ----- Structs -----
49 struct usbd_ep_pipe_state_t {
50 enum usb_ep_pingpong pingpong; /* next desc to use */
51 enum usb_data01 data01;
55 const uint8_t *copy_source;
57 ep_callback_t callback;
62 enum usb_ep_dir ep_dir;
65 struct usbd_ep_state_t {
67 struct usbd_ep_pipe_state_t pipe[2];
69 struct usbd_ep_pipe_state_t rx;
70 struct usbd_ep_pipe_state_t tx;
76 struct usbd_function_ctx_header functions;
77 struct usbd_function control_function;
78 const struct usbd_device *identity;
82 USBD_STATE_DISABLED = 0,
84 USBD_STATE_SETTING_ADDRESS,
88 enum usb_ctrl_req_dir ctrl_dir;
89 struct usbd_ep_state_t ep_state[USB_MAX_EP];
92 extern struct usbd_t usb;
96 // ----- Functions -----
98 void usb_restart(void);
99 void usb_enable(void);
100 const struct usbd_config *usb_get_config_data(int config);