2 * Copyright © 2018 Keith Packard <keithp@keithp.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 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 #ifndef _AO_USB_GEN_H_
16 #define _AO_USB_GEN_H_
20 #include "ao_product.h"
26 #define USE_USB_STDIO 1
30 #define AO_USB_OUT_SLEEP_ADDR (&ao_stdin_ready)
32 #define AO_USB_OUT_SLEEP_ADDR (&ao_usb_out_avail)
36 uint8_t dir_type_recip;
43 #define AO_USB_EP0_GOT_RESET 1
44 #define AO_USB_EP0_GOT_SETUP 2
45 #define AO_USB_EP0_GOT_RX_DATA 4
46 #define AO_USB_EP0_GOT_TX_ACK 8
49 * End point register indices
52 #define AO_USB_CONTROL_EPR 0
53 #define AO_USB_INT_EPR 1
54 #define AO_USB_OUT_EPR 2
55 #define AO_USB_IN_EPR 3
57 /* Device interfaces required */
59 /* Queue IN bytes to EP0 */
61 ao_usb_dev_ep0_init(void);
64 ao_usb_dev_ep0_in(const void *data, uint16_t len);
67 ao_usb_dev_ep0_in_busy(void);
69 /* Receive OUT bytes from EP0 */
71 ao_usb_dev_ep0_out(void *data, uint16_t len);
73 /* Set device address */
75 ao_usb_dev_set_address(uint8_t address);
78 ao_usb_dev_enable(void);
81 ao_usb_dev_disable(void);
84 ao_usb_dev_init(void);
86 /* Queue IN bytes to EPn */
88 ao_usb_dev_ep_in(uint8_t ep, const void *data, uint16_t len);
91 ao_usb_dev_ep_in_busy(uint8_t ep);
93 /* Receive OUT bytes from EPn */
95 ao_usb_dev_ep_out(uint8_t ep, void *data, uint16_t len);
98 /* General interfaces provided */
101 ao_usb_ep0_interrupt(uint8_t mask);
104 ao_usb_in_interrupt(uint32_t mask);
107 ao_usb_out_interrupt(uint32_t mask);
110 ao_usb_int_interrupt(uint32_t mask);
112 #endif /* _AO_USB_GEN_H_ */