| 123456789101112131415161718192021222324252627282930 |
- /* Minimal polled USB CDC-ACM device stack for ATmega8U2 (no LUFA, no interrupts) */
- #ifndef USB_H
- #define USB_H
- #include <stdint.h>
- #include <stdbool.h>
- #define USB_PACKET 64
- void usb_init(void);
- void usb_task(void); /* call often: reset + EP0 handling */
- bool usb_ready(void); /* true once host configured device */
- uint8_t usb_rx(uint8_t *buf); /* copy one OUT packet (<=64B), 0=none */
- void usb_tx(const uint8_t *buf, uint8_t n); /* send one IN packet (<=64B), drops on timeout */
- /* EP0 helpers for vendor requests (data stage may span several 32 B packets) */
- #define EP0_SIZE 32
- bool ep0_wait(uint8_t mask);
- void ep0_stall(void);
- void ep0_status_in(void); /* finish an OUT/no-data request */
- void ep0_status_out(void); /* finish an IN request */
- void ep0_send(const void *p, uint16_t len, uint16_t wlen, bool pgm); /* whole IN request */
- uint8_t ep0_rx(uint8_t *buf); /* next OUT data packet, 0xFF on abort/timeout */
- bool ep0_tx(const uint8_t *buf, uint8_t n); /* next IN data packet, false on abort */
- /* implemented by the application */
- void usb_vendor_request(uint8_t bmRT, uint8_t bReq, uint16_t wValue, uint16_t wIndex, uint16_t wLength);
- void usb_reset_hook(void); /* USB bus reset seen */
- #endif
|