sunxi_hal_udc.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * ===========================================================================================
  3. *
  4. * Filename: sunxi_usb_common.h
  5. *
  6. * Description: USB HAL definition.
  7. * ===========================================================================================
  8. */
  9. #ifndef SUNXI_HAL_UDC_H
  10. #define SUNXI_HAL_UDC_H
  11. #include <stdint.h>
  12. #include "ch9.h"
  13. typedef enum {
  14. UDC_EVENT_RX_STANDARD_REQUEST = 1,
  15. UDC_EVENT_RX_CLASS_REQUEST = 2,
  16. UDC_EVENT_RX_DATA = 3,
  17. UDC_EVENT_TX_COMPLETE = 4,
  18. } udc_callback_event_t;
  19. typedef enum {
  20. UDC_ERRNO_SUCCESS = 0,
  21. UDC_ERRNO_CMD_NOT_SUPPORTED = -1,
  22. UDC_ERRNO_CMD_INVALID = -2,
  23. UDC_ERRNO_BUF_NULL = -3,
  24. UDC_ERRNO_BUF_FULL = -4,
  25. UDC_ERRNO_EP_INVALID = -5,
  26. UDC_ERRNO_RX_NOT_READY = -6,
  27. UDC_ERRNO_TX_BUSY = -7,
  28. } udc_errno_t;
  29. typedef udc_errno_t (*udc_callback_t)(uint8_t ep_addr, udc_callback_event_t event,
  30. void *data, uint32_t len);
  31. int32_t hal_udc_init(void);
  32. int32_t hal_udc_deinit(void);
  33. int32_t hal_udc_enter_test_mode(uint32_t test_mode);
  34. void hal_udc_device_desc_init(struct usb_device_descriptor *device_desc);
  35. void hal_udc_config_desc_init(void *config_desc, uint32_t len);
  36. void hal_udc_string_desc_init(const void *string_desc);
  37. void hal_udc_register_callback(udc_callback_t user_callback);
  38. int32_t hal_udc_ep_read(uint8_t ep_addr, void *buf, uint32_t len);
  39. int32_t hal_udc_ep_write(uint8_t ep_addr, void *buf , uint32_t len);
  40. void hal_udc_ep_enable(uint8_t ep_addr, uint16_t maxpacket, uint32_t ts_type);
  41. void hal_udc_ep_disable(uint8_t ep_addr);
  42. void hal_udc_ep_set_buf(uint8_t ep_addr, void *buf, uint32_t len);
  43. ssize_t ed_test(const char *buf, size_t count);
  44. ssize_t hal_udc_driverlevel_adjust(int driverlevel);
  45. #endif