diff options
| author | Dien-Nhung Nguyen-Phu <kein@kienlab.com> | 2024-07-11 21:05:17 +0700 |
|---|---|---|
| committer | Dien-Nhung Nguyen-Phu <kein@kienlab.com> | 2024-07-11 22:18:56 +0700 |
| commit | 4f3b6f4283e0240060c04a137175cacfb385dc16 (patch) | |
| tree | 08678550d8577f9c30a5868dc5ae749c22de1d3e /src/usb/utils.h | |
| parent | 515c8a8eb9fec5f6992db7f5cf9b9c8bdb539f46 (diff) | |
usb: handle device request and route to interfaces
Diffstat (limited to 'src/usb/utils.h')
| -rw-r--r-- | src/usb/utils.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/usb/utils.h b/src/usb/utils.h new file mode 100644 index 0000000..595a8b7 --- /dev/null +++ b/src/usb/utils.h @@ -0,0 +1,30 @@ +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include "CH58x_common.h" + +enum USB_RESPONSE_TYPE { + USB_ACK = 0, + USB_NO_RESP, + USB_NAK, + USB_STALL, +}; + +void cfg_desc_append(void *desc); +int ep_cb_register(int ep_num, void (*cb)()); +int if_cb_register(uint8_t if_num, void (*cb)(USB_SETUP_REQ *request)); +void dma_register(uint8_t endpoint_number, void *buf_addr); + +uint16_t +usb_start_load_block(void *ep_IN_buf, void *buf, uint16_t len, int tog); +void ctrl_start_load_block(void *buf, uint16_t len); +int usb_load_next_chunk(); +void usb_flush(); + +void set_handshake(uint8_t ep_num, int type, int tog, uint8_t len); +void ctrl_ack(); + +void clear_handshake_sent_flag(); +int handshake_sent(); + +#endif /* __UTILS_H__ */ |