X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fstm32f4%2Fao_usb_gen.h;fp=src%2Fstm32f4%2Fao_usb_gen.h;h=b059ddb7c473136cd2947ce886f522a48741ec21;hp=0000000000000000000000000000000000000000;hb=0686a7b8aec524d81bda4c572549a3a068ce0eed;hpb=6aa451ce81bfdfe679e3f9902043a5f0d235c745 diff --git a/src/stm32f4/ao_usb_gen.h b/src/stm32f4/ao_usb_gen.h new file mode 100644 index 00000000..b059ddb7 --- /dev/null +++ b/src/stm32f4/ao_usb_gen.h @@ -0,0 +1,110 @@ +/* + * Copyright © 2018 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ + +#ifndef _AO_USB_GEN_H_ +#define _AO_USB_GEN_H_ + +#include "ao.h" +#include "ao_usb.h" +#include "ao_product.h" +#include + +#define USB_ECHO 0 + +#ifndef USE_USB_STDIO +#define USE_USB_STDIO 1 +#endif + +#if USE_USB_STDIO +#define AO_USB_OUT_SLEEP_ADDR (&ao_stdin_ready) +#else +#define AO_USB_OUT_SLEEP_ADDR (&ao_usb_out_avail) +#endif + +struct ao_usb_setup { + uint8_t dir_type_recip; + uint8_t request; + uint16_t value; + uint16_t index; + uint16_t length; +} ao_usb_setup; + +#define AO_USB_EP0_GOT_RESET 1 +#define AO_USB_EP0_GOT_SETUP 2 +#define AO_USB_EP0_GOT_RX_DATA 4 +#define AO_USB_EP0_GOT_TX_ACK 8 + +/* + * End point register indices + */ + +#define AO_USB_CONTROL_EPR 0 +#define AO_USB_INT_EPR 1 +#define AO_USB_OUT_EPR 2 +#define AO_USB_IN_EPR 3 + +/* Device interfaces required */ + +/* Queue IN bytes to EP0 */ +void +ao_usb_dev_ep0_init(void); + +void +ao_usb_dev_ep0_in(const void *data, uint16_t len); + +bool +ao_usb_dev_ep0_in_busy(void); + +/* Receive OUT bytes from EP0 */ +uint16_t +ao_usb_dev_ep0_out(void *data, uint16_t len); + +/* Set device address */ +void +ao_usb_dev_set_address(uint8_t address); + +void +ao_usb_dev_enable(void); + +void +ao_usb_dev_disable(void); + +void +ao_usb_dev_init(void); + +/* Queue IN bytes to EPn */ +void +ao_usb_dev_ep_in(uint8_t ep, const void *data, uint16_t len); + +bool +ao_usb_dev_ep_in_busy(uint8_t ep); + +/* Receive OUT bytes from EPn */ +uint16_t +ao_usb_dev_ep_out(uint8_t ep, void *data, uint16_t len); + + +/* General interfaces provided */ + +void +ao_usb_ep0_interrupt(uint8_t mask); + +void +ao_usb_in_interrupt(uint32_t mask); + +void +ao_usb_out_interrupt(uint32_t mask); + +#endif /* _AO_USB_GEN_H_ */ +