mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-14 18:38:55 +00:00
v1.0.3
This commit is contained in:
14
packages/third-party/cherryusb/common/usb_dc.h
vendored
14
packages/third-party/cherryusb/common/usb_dc.h
vendored
@@ -12,18 +12,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief USB Endpoint Configuration.
|
||||
*
|
||||
* Structure containing the USB endpoint configuration.
|
||||
*/
|
||||
struct usbd_endpoint_cfg {
|
||||
uint8_t ep_addr; /* Endpoint addr with direction */
|
||||
uint8_t ep_type; /* Endpoint type */
|
||||
uint16_t ep_mps; /* Endpoint max packet size */
|
||||
uint8_t ep_mult; /* Endpoint additional transcations in micro frame */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief init device controller registers.
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
@@ -61,7 +49,7 @@ uint8_t usbd_get_port_speed(const uint8_t port);
|
||||
*
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg);
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep);
|
||||
|
||||
/**
|
||||
* @brief Disable the selected endpoint
|
||||
|
||||
13
packages/third-party/cherryusb/common/usb_def.h
vendored
13
packages/third-party/cherryusb/common/usb_def.h
vendored
@@ -221,6 +221,7 @@
|
||||
#define USB_ENDPOINT_TYPE_BULK (2 << USB_ENDPOINT_TYPE_SHIFT)
|
||||
#define USB_ENDPOINT_TYPE_INTERRUPT (3 << USB_ENDPOINT_TYPE_SHIFT)
|
||||
#define USB_ENDPOINT_TYPE_MASK (3 << USB_ENDPOINT_TYPE_SHIFT)
|
||||
#define USB_GET_ENDPOINT_TYPE(x) ((x & USB_ENDPOINT_TYPE_MASK) >> USB_ENDPOINT_TYPE_SHIFT)
|
||||
|
||||
#define USB_ENDPOINT_SYNC_SHIFT 2
|
||||
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION (0 << USB_ENDPOINT_SYNC_SHIFT)
|
||||
@@ -245,6 +246,8 @@
|
||||
#define USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_ONE (1 << USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_SHIFT)
|
||||
#define USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_TWO (2 << USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_SHIFT)
|
||||
#define USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_MASK (3 << USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_SHIFT)
|
||||
#define USB_GET_MAXPACKETSIZE(x) ((x & USB_MAXPACKETSIZE_MASK) >> USB_MAXPACKETSIZE_SHIFT)
|
||||
#define USB_GET_MULT(x) ((x & USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_MASK) >> USB_MAXPACKETSIZE_ADDITIONAL_TRANSCATION_SHIFT)
|
||||
|
||||
/* bDevCapabilityType in Device Capability Descriptor */
|
||||
#define USB_DEVICE_CAPABILITY_WIRELESS_USB 1
|
||||
@@ -657,6 +660,16 @@ struct usb_desc_header {
|
||||
bmAttributes, /* bmAttributes */ \
|
||||
USB_CONFIG_POWER_MA(bMaxPower) /* bMaxPower */
|
||||
|
||||
#define USB_OTHERSPEED_CONFIG_DESCRIPTOR_INIT(wTotalLength, bNumInterfaces, bConfigurationValue, bmAttributes, bMaxPower) \
|
||||
0x09, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_OTHER_SPEED, /* bDescriptorType */ \
|
||||
WBVAL(wTotalLength), /* wTotalLength */ \
|
||||
bNumInterfaces, /* bNumInterfaces */ \
|
||||
bConfigurationValue, /* bConfigurationValue */ \
|
||||
0x00, /* iConfiguration */ \
|
||||
bmAttributes, /* bmAttributes */ \
|
||||
USB_CONFIG_POWER_MA(bMaxPower) /* bMaxPower */
|
||||
|
||||
#define USB_INTERFACE_DESCRIPTOR_INIT(bInterfaceNumber, bAlternateSetting, bNumEndpoints, \
|
||||
bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol, iInterface) \
|
||||
0x09, /* bLength */ \
|
||||
|
||||
332
packages/third-party/cherryusb/common/usb_errno.h
vendored
332
packages/third-party/cherryusb/common/usb_errno.h
vendored
@@ -1,320 +1,24 @@
|
||||
/*
|
||||
* Apache NuttX
|
||||
* Copyright 2020 The Apache Software Foundation
|
||||
* Copyright (c) 2023, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef __INCLUDE_ERRNO_H
|
||||
#define __INCLUDE_ERRNO_H
|
||||
#ifndef USB_ERRNO_H
|
||||
#define USB_ERRNO_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
#define USB_ERR_NOMEM 1
|
||||
#define USB_ERR_INVAL 2
|
||||
#define USB_ERR_NODEV 3
|
||||
#define USB_ERR_NOTCONN 4
|
||||
#define USB_ERR_NOTSUPP 5
|
||||
#define USB_ERR_BUSY 6
|
||||
#define USB_ERR_RANGE 7
|
||||
#define USB_ERR_STALL 8
|
||||
#define USB_ERR_BABBLE 9
|
||||
#define USB_ERR_NAK 10
|
||||
#define USB_ERR_DT 11
|
||||
#define USB_ERR_IO 12
|
||||
#define USB_ERR_SHUTDOWN 13
|
||||
#define USB_ERR_TIMEOUT 14
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Convenience/compatibility definition. If the errno is accessed from the
|
||||
* internal OS code, then the OS code should use the set_errno() and
|
||||
* get_errno(). Currently, those are just placeholders but would be needed
|
||||
* in the KERNEL mode build in order to instantiate the process address
|
||||
* environment as necessary to access the TLS-based errno variable.
|
||||
*/
|
||||
|
||||
/* Definitions of error numbers and the string that would be
|
||||
* returned by strerror().
|
||||
*/
|
||||
#ifndef CONFIG_USB_ERROR_USE_SYSTEM
|
||||
|
||||
#define EPERM 1
|
||||
#define EPERM_STR "Operation not permitted"
|
||||
#define ENOENT 2
|
||||
#define ENOENT_STR "No such file or directory"
|
||||
#define ESRCH 3
|
||||
#define ESRCH_STR "No such process"
|
||||
#define EINTR 4
|
||||
#define EINTR_STR "Interrupted system call"
|
||||
#define EIO 5
|
||||
#define EIO_STR "I/O error"
|
||||
#define ENXIO 6
|
||||
#define ENXIO_STR "No such device or address"
|
||||
#define E2BIG 7
|
||||
#define E2BIG_STR "Arg list too long"
|
||||
#define ENOEXEC 8
|
||||
#define ENOEXEC_STR "Exec format error"
|
||||
#define EBADF 9
|
||||
#define EBADF_STR "Bad file number"
|
||||
#define ECHILD 10
|
||||
#define ECHILD_STR "No child processes"
|
||||
#define EAGAIN 11
|
||||
#define EWOULDBLOCK EAGAIN
|
||||
#define EAGAIN_STR "Try again"
|
||||
#define ENOMEM 12
|
||||
#define ENOMEM_STR "Out of memory"
|
||||
#define EACCES 13
|
||||
#define EACCES_STR "Permission denied"
|
||||
#define EFAULT 14 /* Linux errno extension */
|
||||
#define EFAULT_STR "Bad address"
|
||||
#define ENOTBLK 15
|
||||
#define ENOTBLK_STR "Block device required"
|
||||
#define EBUSY 16
|
||||
#define EBUSY_STR "Device or resource busy"
|
||||
#define EEXIST 17
|
||||
#define EEXIST_STR "File exists"
|
||||
#define EXDEV 18
|
||||
#define EXDEV_STR "Cross-device link"
|
||||
#define ENODEV 19
|
||||
#define ENODEV_STR "No such device"
|
||||
#define ENOTDIR 20
|
||||
#define ENOTDIR_STR "Not a directory"
|
||||
#define EISDIR 21
|
||||
#define EISDIR_STR "Is a directory"
|
||||
#define EINVAL 22
|
||||
#define EINVAL_STR "Invalid argument"
|
||||
#define ENFILE 23
|
||||
#define ENFILE_STR "File table overflow"
|
||||
#define EMFILE 24
|
||||
#define EMFILE_STR "Too many open files"
|
||||
#define ENOTTY 25
|
||||
#define ENOTTY_STR "Not a typewriter"
|
||||
#define ETXTBSY 26
|
||||
#define ETXTBSY_STR "Text file busy"
|
||||
#define EFBIG 27
|
||||
#define EFBIG_STR "File too large"
|
||||
#define ENOSPC 28
|
||||
#define ENOSPC_STR "No space left on device"
|
||||
#define ESPIPE 29
|
||||
#define ESPIPE_STR "Illegal seek"
|
||||
#define EROFS 30
|
||||
#define EROFS_STR "Read-only file system"
|
||||
#define EMLINK 31
|
||||
#define EMLINK_STR "Too many links"
|
||||
#define EPIPE 32
|
||||
#define EPIPE_STR "Broken pipe"
|
||||
#define EDOM 33
|
||||
#define EDOM_STR "Math argument out of domain of func"
|
||||
#define ERANGE 34
|
||||
#define ERANGE_STR "Math result not representable"
|
||||
#define ENOMSG 35
|
||||
#define ENOMSG_STR "No message of desired type"
|
||||
#define EIDRM 36
|
||||
#define EIDRM_STR "Identifier removed"
|
||||
#define ECHRNG 37 /* Linux errno extension */
|
||||
#define ECHRNG_STR "Channel number out of range"
|
||||
#define EL2NSYNC 38 /* Linux errno extension */
|
||||
#define EL2NSYNC_STR "Level 2 not synchronized"
|
||||
#define EL3HLT 39 /* Linux errno extension */
|
||||
#define EL3HLT_STR "Level 3 halted"
|
||||
#define EL3RST 40 /* Linux errno extension */
|
||||
#define EL3RST_STR "Level 3 reset"
|
||||
#define ELNRNG 41 /* Linux errno extension */
|
||||
#define ELNRNG_STR "Link number out of range"
|
||||
#define EUNATCH 42 /* Linux errno extension */
|
||||
#define EUNATCH_STR "Protocol driver not attached"
|
||||
#define ENOCSI 43 /* Linux errno extension */
|
||||
#define ENOCSI_STR "No CSI structure available"
|
||||
#define EL2HLT 44 /* Linux errno extension */
|
||||
#define EL2HLT_STR "Level 2 halted"
|
||||
#define EDEADLK 45
|
||||
#define EDEADLK_STR "Resource deadlock would occur"
|
||||
#define ENOLCK 46
|
||||
#define ENOLCK_STR "No record locks available"
|
||||
|
||||
#define EBADE 50 /* Linux errno extension */
|
||||
#define EBADE_STR "Invalid exchange"
|
||||
#define EBADR 51 /* Linux errno extension */
|
||||
#define EBADR_STR "Invalid request descriptor"
|
||||
#define EXFULL 52 /* Linux errno extension */
|
||||
#define EXFULL_STR "Exchange full"
|
||||
#define ENOANO 53 /* Linux errno extension */
|
||||
#define ENOANO_STR "No anode"
|
||||
#define EBADRQC 54 /* Linux errno extension */
|
||||
#define EBADRQC_STR "Invalid request code"
|
||||
#define EBADSLT 55 /* Linux errno extension */
|
||||
#define EBADSLT_STR "Invalid slot"
|
||||
#define EDEADLOCK 56 /* Linux errno extension */
|
||||
#define EDEADLOCK_STR "File locking deadlock error"
|
||||
#define EBFONT 57 /* Linux errno extension */
|
||||
#define EBFONT_STR "Bad font file format"
|
||||
|
||||
#define ENOSTR 60
|
||||
#define ENOSTR_STR "Device not a stream"
|
||||
#define ENODATA 61
|
||||
#define ENODATA_STR "No data available"
|
||||
#define ETIME 62
|
||||
#define ETIME_STR "Timer expired"
|
||||
#define ENOSR 63
|
||||
#define ENOSR_STR "Out of streams resources"
|
||||
#define ENONET 64 /* Linux errno extension */
|
||||
#define ENONET_STR "Machine is not on the network"
|
||||
#define ENOPKG 65 /* Linux errno extension */
|
||||
#define ENOPKG_STR "Package not installed"
|
||||
#define EREMOTE 66 /* Linux errno extension */
|
||||
#define EREMOTE_STR "Object is remote"
|
||||
#define ENOLINK 67
|
||||
#define ENOLINK_STR "Link has been severed"
|
||||
#define EADV 68 /* Linux errno extension */
|
||||
#define EADV_STR "Advertise error"
|
||||
#define ESRMNT 69 /* Linux errno extension */
|
||||
#define ESRMNT_STR "Srmount error"
|
||||
#define ECOMM 70 /* Linux errno extension */
|
||||
#define ECOMM_STR "Communication error on send"
|
||||
#define EPROTO 71
|
||||
#define EPROTO_STR "Protocol error"
|
||||
|
||||
#define EMULTIHOP 74
|
||||
#define EMULTIHOP_STR "Multihop attempted"
|
||||
#define ELBIN 75 /* Linux errno extension */
|
||||
#define ELBIN_STR "Inode is remote"
|
||||
#define EDOTDOT 76 /* Linux errno extension */
|
||||
#define EDOTDOT_STR "RFS specific error"
|
||||
#define EBADMSG 77
|
||||
#define EBADMSG_STR "Not a data message"
|
||||
|
||||
#define EFTYPE 79
|
||||
#define EFTYPE_STR "Inappropriate file type or format"
|
||||
#define ENOTUNIQ 80 /* Linux errno extension */
|
||||
#define ENOTUNIQ_STR "Name not unique on network"
|
||||
#define EBADFD 81 /* Linux errno extension */
|
||||
#define EBADFD_STR "File descriptor in bad state"
|
||||
#define EREMCHG 82 /* Linux errno extension */
|
||||
#define EREMCHG_STR "Remote address changed"
|
||||
#define ELIBACC 83 /* Linux errno extension */
|
||||
#define ELIBACC_STR "Can not access a needed shared library"
|
||||
#define ELIBBAD 84 /* Linux errno extension */
|
||||
#define ELIBBAD_STR "Accessing a corrupted shared library"
|
||||
#define ELIBSCN 85 /* Linux errno extension */
|
||||
#define ELIBSCN_STR ".lib section in a.out corrupted"
|
||||
#define ELIBMAX 86 /* Linux errno extension */
|
||||
#define ELIBMAX_STR "Attempting to link in too many shared libraries"
|
||||
#define ELIBEXEC 87 /* Linux errno extension */
|
||||
#define ELIBEXEC_STR "Cannot exec a shared library directly"
|
||||
#define ENOSYS 88
|
||||
#define ENOSYS_STR "Function not implemented"
|
||||
#define ENMFILE 89 /* Cygwin */
|
||||
#define ENMFILE_STR "No more files"
|
||||
#define ENOTEMPTY 90
|
||||
#define ENOTEMPTY_STR "Directory not empty"
|
||||
#define ENAMETOOLONG 91
|
||||
#define ENAMETOOLONG_STR "File name too long"
|
||||
#define ELOOP 92
|
||||
#define ELOOP_STR "Too many symbolic links encountered"
|
||||
|
||||
#define EOPNOTSUPP 95
|
||||
#define EOPNOTSUPP_STR "Operation not supported on transport endpoint"
|
||||
#define EPFNOSUPPORT 96
|
||||
#define EPFNOSUPPORT_STR "Protocol family not supported"
|
||||
|
||||
#define ECONNRESET 104
|
||||
#define ECONNRESET_STR "Connection reset by peer"
|
||||
#define ENOBUFS 105
|
||||
#define ENOBUFS_STR "No buffer space available"
|
||||
#define EAFNOSUPPORT 106
|
||||
#define EAFNOSUPPORT_STR "Address family not supported by protocol"
|
||||
#define EPROTOTYPE 107
|
||||
#define EPROTOTYPE_STR "Protocol wrong type for socket"
|
||||
#define ENOTSOCK 108
|
||||
#define ENOTSOCK_STR "Socket operation on non-socket"
|
||||
#define ENOPROTOOPT 109
|
||||
#define ENOPROTOOPT_STR "Protocol not available"
|
||||
#define ESHUTDOWN 110 /* Linux errno extension */
|
||||
#define ESHUTDOWN_STR "Cannot send after transport endpoint shutdown"
|
||||
#define ECONNREFUSED 111
|
||||
#define ECONNREFUSED_STR "Connection refused"
|
||||
#define EADDRINUSE 112
|
||||
#define EADDRINUSE_STR "Address already in use"
|
||||
#define ECONNABORTED 113
|
||||
#define ECONNABORTED_STR "Software caused connection abort"
|
||||
#define ENETUNREACH 114
|
||||
#define ENETUNREACH_STR "Network is unreachable"
|
||||
#define ENETDOWN 115
|
||||
#define ENETDOWN_STR "Network is down"
|
||||
#define ETIMEDOUT 116
|
||||
#define ETIMEDOUT_STR "Connection timed out"
|
||||
#define EHOSTDOWN 117
|
||||
#define EHOSTDOWN_STR "Host is down"
|
||||
#define EHOSTUNREACH 118
|
||||
#define EHOSTUNREACH_STR "No route to host"
|
||||
#define EINPROGRESS 119
|
||||
#define EINPROGRESS_STR "Operation now in progress"
|
||||
#define EALREADY 120
|
||||
#define EALREADY_STR "Socket already connected"
|
||||
#define EDESTADDRREQ 121
|
||||
#define EDESTADDRREQ_STR "Destination address required"
|
||||
#define EMSGSIZE 122
|
||||
#define EMSGSIZE_STR "Message too long"
|
||||
#define EPROTONOSUPPORT 123
|
||||
#define EPROTONOSUPPORT_STR "Protocol not supported"
|
||||
#define ESOCKTNOSUPPORT 124 /* Linux errno extension */
|
||||
#define ESOCKTNOSUPPORT_STR "Socket type not supported"
|
||||
#define EADDRNOTAVAIL 125
|
||||
#define EADDRNOTAVAIL_STR "Cannot assign requested address"
|
||||
#define ENETRESET 126
|
||||
#define ENETRESET_STR "Network dropped connection because of reset"
|
||||
#define EISCONN 127
|
||||
#define EISCONN_STR "Transport endpoint is already connected"
|
||||
#define ENOTCONN 128
|
||||
#define ENOTCONN_STR "Transport endpoint is not connected"
|
||||
#define ETOOMANYREFS 129
|
||||
#define ETOOMANYREFS_STR "Too many references: cannot splice"
|
||||
#define EPROCLIM 130
|
||||
#define EPROCLIM_STR "Limit would be exceeded by attempted fork"
|
||||
#define EUSERS 131
|
||||
#define EUSERS_STR "Too many users"
|
||||
#define EDQUOT 132
|
||||
#define EDQUOT_STR "Quota exceeded"
|
||||
#define ESTALE 133
|
||||
#define ESTALE_STR "Stale NFS file handle"
|
||||
#define ENOTSUP 134
|
||||
#define ENOTSUP_STR "Not supported"
|
||||
#define ENOMEDIUM 135 /* Linux errno extension */
|
||||
#define ENOMEDIUM_STR "No medium found"
|
||||
#define ENOSHARE 136 /* Cygwin */
|
||||
#define ENOSHARE_STR "No such host or network path"
|
||||
#define ECASECLASH 137 /* Cygwin */
|
||||
#define ECASECLASH_STR "Filename exists with different case"
|
||||
#define EILSEQ 138
|
||||
#define EILSEQ_STR "Illegal byte sequence"
|
||||
#define EOVERFLOW 139
|
||||
#define EOVERFLOW_STR "Value too large for defined data type"
|
||||
#define ECANCELED 140
|
||||
#define ECANCELED_STR "Operation cancelled"
|
||||
#define ENOTRECOVERABLE 141
|
||||
#define ENOTRECOVERABLE_STR "State not recoverable"
|
||||
#define EOWNERDEAD 142
|
||||
#define EOWNERDEAD_STR "Previous owner died"
|
||||
#define ESTRPIPE 143 /* Linux errno extension */
|
||||
#define ESTRPIPE_STR "Streams pipe error"
|
||||
|
||||
#define __ELASTERROR 2000 /* Users can add values starting here */
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Return a pointer to the thread specific errno. */
|
||||
|
||||
int *__errno(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_ERRNO_H */
|
||||
#endif /* USB_ERRNO_H */
|
||||
|
||||
67
packages/third-party/cherryusb/common/usb_hc.h
vendored
67
packages/third-party/cherryusb/common/usb_hc.h
vendored
@@ -13,21 +13,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*usbh_complete_callback_t)(void *arg, int nbytes);
|
||||
typedef void *usbh_pipe_t;
|
||||
|
||||
/**
|
||||
* @brief USB Endpoint Configuration.
|
||||
*
|
||||
* Structure containing the USB endpoint configuration.
|
||||
*/
|
||||
struct usbh_endpoint_cfg {
|
||||
struct usbh_hubport *hport;
|
||||
uint8_t ep_addr; /* Endpoint addr with direction */
|
||||
uint8_t ep_type; /* Endpoint type */
|
||||
uint16_t ep_mps; /* Endpoint max packet size */
|
||||
uint8_t ep_interval; /* Endpoint interval */
|
||||
uint8_t mult; /* Endpoint additional transcation */
|
||||
};
|
||||
struct usbh_bus;
|
||||
|
||||
/**
|
||||
* @brief USB Iso Configuration.
|
||||
@@ -47,7 +34,10 @@ struct usbh_iso_frame_packet {
|
||||
* Structure containing the USB Urb configuration.
|
||||
*/
|
||||
struct usbh_urb {
|
||||
usbh_pipe_t pipe;
|
||||
void *hcpriv;
|
||||
struct usbh_hubport *hport;
|
||||
struct usb_endpoint_descriptor *ep;
|
||||
uint8_t data_toggle;
|
||||
struct usb_setup_packet *setup;
|
||||
uint8_t *transfer_buffer;
|
||||
uint32_t transfer_buffer_length;
|
||||
@@ -59,7 +49,11 @@ struct usbh_urb {
|
||||
uint32_t start_frame;
|
||||
usbh_complete_callback_t complete;
|
||||
void *arg;
|
||||
#if defined(__ICCARM__) || defined(__ICCRISCV__) || defined(__ICCRX__)
|
||||
struct usbh_iso_frame_packet *iso_packet;
|
||||
#else
|
||||
struct usbh_iso_frame_packet iso_packet[0];
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,14 +61,21 @@ struct usbh_urb {
|
||||
*
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usb_hc_init(void);
|
||||
int usb_hc_init(struct usbh_bus *bus);
|
||||
|
||||
/**
|
||||
* @brief usb host controller hardware deinit.
|
||||
*
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usb_hc_deinit(struct usbh_bus *bus);
|
||||
|
||||
/**
|
||||
* @brief Get frame number.
|
||||
*
|
||||
* @return frame number.
|
||||
*/
|
||||
uint16_t usbh_get_frame_number(void);
|
||||
uint16_t usbh_get_frame_number(struct usbh_bus *bus);
|
||||
/**
|
||||
* @brief control roothub.
|
||||
*
|
||||
@@ -82,35 +83,7 @@ uint16_t usbh_get_frame_number(void);
|
||||
* @param buf buf for reading response or write data.
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usbh_roothub_control(struct usb_setup_packet *setup, uint8_t *buf);
|
||||
|
||||
/**
|
||||
* @brief reconfig endpoint pipe.
|
||||
*
|
||||
* @param pipe A memory allocated for pipe.
|
||||
* @param dev_addr device address.
|
||||
* @param ep_mps endpoint max packet size.
|
||||
* @param mult endpoint additional transcation
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usbh_ep_pipe_reconfigure(usbh_pipe_t pipe, uint8_t dev_addr, uint8_t ep_mps, uint8_t mult);
|
||||
|
||||
/**
|
||||
* @brief Allocate pipe for endpoint
|
||||
*
|
||||
* @param pipe A memory location provided by the caller in which to save the allocated pipe.
|
||||
* @param ep_cfg Describes the endpoint info to be allocated.
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_cfg);
|
||||
|
||||
/**
|
||||
* @brief Free a pipe in which saves endpoint info.
|
||||
*
|
||||
* @param pipe A memory location provided by the caller in which to free the allocated endpoint info.
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usbh_pipe_free(usbh_pipe_t pipe);
|
||||
int usbh_roothub_control(struct usbh_bus *bus, struct usb_setup_packet *setup, uint8_t *buf);
|
||||
|
||||
/**
|
||||
* @brief Submit a usb transfer request to an endpoint.
|
||||
@@ -126,7 +99,7 @@ int usbh_submit_urb(struct usbh_urb *urb);
|
||||
/**
|
||||
* @brief Cancel a transfer request.
|
||||
*
|
||||
* This function will call When calls usbh_submit_urb and return -ETIMEOUT or -ESHUTDOWN.
|
||||
* This function will call When calls usbh_submit_urb and return -USB_ERR_TIMEOUT or -USB_ERR_SHUTDOWN.
|
||||
*
|
||||
* @param urb Usb request block.
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
|
||||
60
packages/third-party/cherryusb/common/usb_mem.h
vendored
60
packages/third-party/cherryusb/common/usb_mem.h
vendored
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef USB_MEM_H
|
||||
#define USB_MEM_H
|
||||
|
||||
#define USB_MEM_ALIGNX __attribute__((aligned(CONFIG_USB_ALIGN_SIZE)))
|
||||
|
||||
#if (CONFIG_USB_ALIGN_SIZE > 4)
|
||||
static inline void *usb_iomalloc(size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
void *align_ptr;
|
||||
int uintptr_size;
|
||||
size_t align_size;
|
||||
uint32_t align = CONFIG_USB_ALIGN_SIZE;
|
||||
|
||||
/* sizeof pointer */
|
||||
uintptr_size = sizeof(void *);
|
||||
uintptr_size -= 1;
|
||||
|
||||
/* align the alignment size to uintptr size byte */
|
||||
align = ((align + uintptr_size) & ~uintptr_size);
|
||||
|
||||
/* get total aligned size */
|
||||
align_size = ((size + uintptr_size) & ~uintptr_size) + align;
|
||||
/* allocate memory block from heap */
|
||||
ptr = usb_malloc(align_size);
|
||||
if (ptr != NULL) {
|
||||
/* the allocated memory block is aligned */
|
||||
if (((unsigned long)ptr & (align - 1)) == 0) {
|
||||
align_ptr = (void *)((unsigned long)ptr + align);
|
||||
} else {
|
||||
align_ptr = (void *)(((unsigned long)ptr + (align - 1)) & ~(align - 1));
|
||||
}
|
||||
|
||||
/* set the pointer before alignment pointer to the real pointer */
|
||||
*((unsigned long *)((unsigned long)align_ptr - sizeof(void *))) = (unsigned long)ptr;
|
||||
|
||||
ptr = align_ptr;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static inline void usb_iofree(void *ptr)
|
||||
{
|
||||
void *real_ptr;
|
||||
|
||||
real_ptr = (void *)*(unsigned long *)((unsigned long)ptr - sizeof(void *));
|
||||
usb_free(real_ptr);
|
||||
}
|
||||
#else
|
||||
#define usb_iomalloc(size) usb_malloc(size)
|
||||
#define usb_iofree(ptr) usb_free(ptr)
|
||||
#endif
|
||||
|
||||
#endif /* USB_MEM_H */
|
||||
47
packages/third-party/cherryusb/common/usb_osal.h
vendored
Normal file
47
packages/third-party/cherryusb/common/usb_osal.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef USB_OSAL_H
|
||||
#define USB_OSAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define USB_OSAL_WAITING_FOREVER (0xFFFFFFFFU)
|
||||
|
||||
typedef void *usb_osal_thread_t;
|
||||
typedef void *usb_osal_sem_t;
|
||||
typedef void *usb_osal_mutex_t;
|
||||
typedef void *usb_osal_mq_t;
|
||||
typedef void (*usb_thread_entry_t)(void *argument);
|
||||
|
||||
/*
|
||||
* Task with smaller priority value indicates higher task priority
|
||||
*/
|
||||
usb_osal_thread_t usb_osal_thread_create(const char *name, uint32_t stack_size, uint32_t prio, usb_thread_entry_t entry, void *args);
|
||||
void usb_osal_thread_delete(usb_osal_thread_t thread);
|
||||
|
||||
usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count);
|
||||
void usb_osal_sem_delete(usb_osal_sem_t sem);
|
||||
int usb_osal_sem_take(usb_osal_sem_t sem, uint32_t timeout);
|
||||
int usb_osal_sem_give(usb_osal_sem_t sem);
|
||||
void usb_osal_sem_reset(usb_osal_sem_t sem);
|
||||
|
||||
usb_osal_mutex_t usb_osal_mutex_create(void);
|
||||
void usb_osal_mutex_delete(usb_osal_mutex_t mutex);
|
||||
int usb_osal_mutex_take(usb_osal_mutex_t mutex);
|
||||
int usb_osal_mutex_give(usb_osal_mutex_t mutex);
|
||||
|
||||
usb_osal_mq_t usb_osal_mq_create(uint32_t max_msgs);
|
||||
void usb_osal_mq_delete(usb_osal_mq_t mq);
|
||||
int usb_osal_mq_send(usb_osal_mq_t mq, uintptr_t addr);
|
||||
int usb_osal_mq_recv(usb_osal_mq_t mq, uintptr_t *addr, uint32_t timeout);
|
||||
|
||||
size_t usb_osal_enter_critical_section(void);
|
||||
void usb_osal_leave_critical_section(size_t flag);
|
||||
|
||||
void usb_osal_msleep(uint32_t delay);
|
||||
|
||||
#endif /* USB_OSAL_H */
|
||||
18
packages/third-party/cherryusb/common/usb_util.h
vendored
18
packages/third-party/cherryusb/common/usb_util.h
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
* Copyright (c) 2022-2023, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -44,9 +44,9 @@
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#elif defined(__ICCARM__) || defined(__ICCRX__)
|
||||
#elif defined(__ICCARM__) || defined(__ICCRX__) || defined(__ICCRISCV__)
|
||||
#ifndef __USED
|
||||
#if __ICCARM_V8
|
||||
#if defined(__ICCARM_V8) || defined (__ICCRISCV__)
|
||||
#define __USED __attribute__((used))
|
||||
#else
|
||||
#define __USED __root
|
||||
@@ -54,7 +54,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#if __ICCARM_V8
|
||||
#if defined(__ICCARM_V8) || defined (__ICCRISCV__)
|
||||
#define __WEAK __attribute__((weak))
|
||||
#else
|
||||
#define __WEAK _Pragma("__weak")
|
||||
@@ -62,7 +62,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED
|
||||
#if __ICCARM_V8
|
||||
#if defined(__ICCARM_V8) || defined (__ICCRISCV__)
|
||||
#define __PACKED __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
@@ -71,7 +71,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_STRUCT
|
||||
#if __ICCARM_V8
|
||||
#if defined(__ICCARM_V8) || defined (__ICCRISCV__)
|
||||
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
@@ -80,7 +80,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_UNION
|
||||
#if __ICCARM_V8
|
||||
#if defined(__ICCARM_V8) || defined (__ICCRISCV__)
|
||||
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
@@ -89,7 +89,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __ALIGNED
|
||||
#if __ICCARM_V8
|
||||
#if defined(__ICCARM_V8) || defined (__ICCRISCV__)
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#elif (__VER__ >= 7080000)
|
||||
/* Needs IAR language extensions */
|
||||
@@ -203,4 +203,6 @@
|
||||
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
|
||||
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
|
||||
|
||||
#define USB_MEM_ALIGNX __attribute__((aligned(CONFIG_USB_ALIGN_SIZE)))
|
||||
|
||||
#endif /* USB_UTIL_H */
|
||||
|
||||
Reference in New Issue
Block a user