Modify the usb main function.
This commit is contained in:
parent
27247f7d00
commit
dd3104c4a1
|
@ -884,6 +884,10 @@ int usbh_control_transfer_xiuos(struct usbh_hubport *hport, usbh_pipe_t pipe, st
|
|||
int ret;
|
||||
|
||||
urb = usb_malloc(sizeof(struct usbh_urb));
|
||||
if (NULL == urb) {
|
||||
USB_LOG_ERR("No memory to alloc for usbh_urb\r\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(urb, 0, sizeof(struct usbh_urb));
|
||||
|
||||
usbh_control_urb_fill_xiuos(urb, hport, pipe, setup, buffer, setup->wLength, CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT, NULL, NULL);
|
||||
|
|
|
@ -869,6 +869,7 @@ int xhci_usbh_pipe_alloc(usbh_pipe_t *pipe, const struct usbh_endpoint_cfg *ep_c
|
|||
struct usb_mem_page ring_page;
|
||||
|
||||
if (NULL == ppipe) {
|
||||
USB_LOG_ERR("XHCI %s could not allocate xhci endpoint\n", xhci->name );
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ extern "C" {
|
|||
* USB3_ADDR_OFFSET_UPPER_BOUND can be found in <Rockchip RK3568 Technical Reference Manual, Revision 1.0> Part 2,
|
||||
* Table 16-1 USB3 Address Mapping.
|
||||
*/
|
||||
#define USB3_NUM 2
|
||||
#define USB3_0_ID 0
|
||||
#define USB3_1_ID 1
|
||||
#define USB3_0_BASE_ADDR 0xFCC00000
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "usb_host.h"
|
||||
#include "usb_mem.h"
|
||||
#include "usb_hc_xhci.h"
|
||||
#include "usyscall.h"
|
||||
#include "libipc.h"
|
||||
#include "rndis_service.h"
|
||||
#include "lwip_rndis_service.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static struct usbh_bus usb[USB3_NUM];
|
||||
|
||||
/* IPC rndis server */
|
||||
int IPC_DO_SERVE_FUNC(Ipc_usbh_rndis_eth_tx)(void *dataptr, size_t *tot_len){
|
||||
|
@ -19,7 +23,7 @@ IPC_SERVER_INTERFACE(Ipc_usbh_rndis_eth_control, 3);
|
|||
|
||||
IPC_SERVER_REGISTER_INTERFACES(IpcRndisServer, 2, Ipc_usbh_rndis_eth_tx, Ipc_usbh_rndis_eth_control);
|
||||
|
||||
int ipc_rndis_server_init(void)
|
||||
int ipc_rndis_server_init(void *para)
|
||||
{
|
||||
if (register_server("RndisServer") < 0) {
|
||||
printf("register server name: %s failed.\n", "RndisServer");
|
||||
|
@ -38,8 +42,12 @@ int ipc_lwip_client_init(void)
|
|||
struct Session *session;
|
||||
|
||||
session = usb_malloc(sizeof(struct Session));
|
||||
if (NULL == session) {
|
||||
printf("No memory to alloc for LWIPServer session\r\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
if(connect_session(session, "LWIPServer", 4096) < 0) {
|
||||
printf("connect session failed\n");
|
||||
printf("connect LWIPServer session failed\n");
|
||||
return -1;
|
||||
}
|
||||
g_session_lwip = session;
|
||||
|
@ -53,10 +61,47 @@ int lwip_rndis_data_recv(void *dataptr, size_t len)
|
|||
return ipc_lwip_rndis_data_recv(session, dataptr, len);
|
||||
}
|
||||
|
||||
/* usb main*/
|
||||
int main(){
|
||||
void ipc_rndis_init(void){
|
||||
int tid;
|
||||
|
||||
ipc_lwip_client_init();
|
||||
ipc_rndis_server_init();
|
||||
tid = thread(ipc_rndis_server_init, "ipc_rndis_server", NULL);
|
||||
if(tid < 0){
|
||||
printf("create thread ipc_rndis_server failed.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_init(int id)
|
||||
{
|
||||
if (0 == usbh_initialize(id, &usb[id])){
|
||||
printf("Init cherryusb host successfully.\r\n");
|
||||
}
|
||||
else{
|
||||
printf("Init cherryusb host failed.\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* usb main*/
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int id = USB3_0_ID;
|
||||
|
||||
if (argc >= 2) {
|
||||
id = atoi(argv[1]);
|
||||
if (id >= USB3_NUM) {
|
||||
printf("Invalid usb3 id(%d).\r\n", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
printf("usb3 id % init.\n", id);
|
||||
usb_init(id);
|
||||
|
||||
ipc_rndis_init();
|
||||
|
||||
while (1){
|
||||
usb_osal_msleep(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue