Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
b2db09ad
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b2db09ad
编写于
4月 23, 2018
作者:
lymzzyh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Bsp][i.mx rt]USB device support HS
上级
4c0be8c7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
2 deletion
+60
-2
bsp/imxrt1052-evk/drivers/drv_usbd.c
bsp/imxrt1052-evk/drivers/drv_usbd.c
+60
-2
未找到文件。
bsp/imxrt1052-evk/drivers/drv_usbd.c
浏览文件 @
b2db09ad
...
...
@@ -23,7 +23,7 @@
#error Can not using 2 controller as usb device
#endif
#endif
#define FSL_USB_HS
/* USB PHY condfiguration */
#define BOARD_USB_PHY_D_CAL (0x0CU)
...
...
@@ -81,6 +81,27 @@ void USB_DeviceClockInit(uint8_t controllerId)
#endif
}
#ifdef RT_USING_EHCI0_AS_DEVICE
#ifdef FSL_USB_HS
static
struct
ep_id
_ehci0_ep_pool
[]
=
{
{
0x0
,
USB_EP_ATTR_CONTROL
,
USB_DIR_INOUT
,
64
,
ID_ASSIGNED
},
{
0x1
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x1
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x2
,
USB_EP_ATTR_INT
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x2
,
USB_EP_ATTR_INT
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x3
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x3
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x4
,
USB_EP_ATTR_INT
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x4
,
USB_EP_ATTR_INT
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x5
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x5
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x6
,
USB_EP_ATTR_INT
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x6
,
USB_EP_ATTR_INT
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x7
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x7
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0xFF
,
USB_EP_ATTR_TYPE_MASK
,
USB_DIR_MASK
,
0
,
ID_ASSIGNED
},
};
#else
static
struct
ep_id
_ehci0_ep_pool
[]
=
{
{
0x0
,
USB_EP_ATTR_CONTROL
,
USB_DIR_INOUT
,
64
,
ID_ASSIGNED
},
...
...
@@ -100,6 +121,7 @@ static struct ep_id _ehci0_ep_pool[] =
{
0x7
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
64
,
ID_UNASSIGNED
},
{
0xFF
,
USB_EP_ATTR_TYPE_MASK
,
USB_DIR_MASK
,
0
,
ID_ASSIGNED
},
};
#endif
void
USB_OTG1_IRQHandler
(
void
)
{
/* enter interrupt */
...
...
@@ -133,6 +155,7 @@ static rt_err_t _ehci0_ep_enable(uep_t ep)
{
usb_device_endpoint_init_struct_t
ep_init
;
usb_device_endpoint_callback_struct_t
ep_callback
;
rt_uint32_t
param
=
ep
->
ep_desc
->
bEndpointAddress
;
RT_ASSERT
(
ep
!=
RT_NULL
);
RT_ASSERT
(
ep
->
ep_desc
!=
RT_NULL
);
ep_init
.
maxPacketSize
=
ep
->
ep_desc
->
wMaxPacketSize
;
...
...
@@ -140,7 +163,7 @@ static rt_err_t _ehci0_ep_enable(uep_t ep)
ep_init
.
transferType
=
ep
->
ep_desc
->
bmAttributes
;
ep_init
.
zlt
=
0
;
ep_callback
.
callbackFn
=
usb_device_endpoint_callback
;
ep_callback
.
callbackParam
=
(
void
*
)
ep_init
.
endpointAddress
;
ep_callback
.
callbackParam
=
(
void
*
)
param
;
ep_callback
.
isBusy
=
0
;
USB_DeviceInitEndpoint
(
ehci0_handle
,
&
ep_init
,
&
ep_callback
);
return
RT_EOK
;
...
...
@@ -220,6 +243,27 @@ static rt_err_t drv_ehci0_usbd_init(rt_device_t device)
}
#endif
#ifdef RT_USING_EHCI1_AS_DEVICE
#ifdef FSL_USB_HS
static
struct
ep_id
_ehci1_ep_pool
[]
=
{
{
0x0
,
USB_EP_ATTR_CONTROL
,
USB_DIR_INOUT
,
64
,
ID_ASSIGNED
},
{
0x1
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x1
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x2
,
USB_EP_ATTR_INT
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x2
,
USB_EP_ATTR_INT
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x3
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x3
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x4
,
USB_EP_ATTR_INT
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x4
,
USB_EP_ATTR_INT
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x5
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x5
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x6
,
USB_EP_ATTR_INT
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x6
,
USB_EP_ATTR_INT
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0x7
,
USB_EP_ATTR_BULK
,
USB_DIR_IN
,
512
,
ID_UNASSIGNED
},
{
0x7
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
512
,
ID_UNASSIGNED
},
{
0xFF
,
USB_EP_ATTR_TYPE_MASK
,
USB_DIR_MASK
,
0
,
ID_ASSIGNED
},
};
#else
static
struct
ep_id
_ehci1_ep_pool
[]
=
{
{
0x0
,
USB_EP_ATTR_CONTROL
,
USB_DIR_INOUT
,
64
,
ID_ASSIGNED
},
...
...
@@ -239,6 +283,7 @@ static struct ep_id _ehci1_ep_pool[] =
{
0x7
,
USB_EP_ATTR_BULK
,
USB_DIR_OUT
,
64
,
ID_UNASSIGNED
},
{
0xFF
,
USB_EP_ATTR_TYPE_MASK
,
USB_DIR_MASK
,
0
,
ID_ASSIGNED
},
};
#endif
void
USB_OTG2_IRQHandler
(
void
)
{
/* enter interrupt */
...
...
@@ -373,6 +418,11 @@ static int rt_usbd_init(void)
/* Register endpoint infomation */
_fsl_udc_0
.
ep_pool
=
_ehci0_ep_pool
;
_fsl_udc_0
.
ep0
.
id
=
&
_ehci0_ep_pool
[
0
];
#ifdef FSL_USB_HS
_fsl_udc_0
.
device_is_hs
=
RT_TRUE
;
#else
_fsl_udc_0
.
device_is_hs
=
RT_FALSE
;
#endif
rt_device_register
((
rt_device_t
)
&
_fsl_udc_0
,
"usbd"
,
0
);
rt_usb_device_init
();
#endif
...
...
@@ -384,6 +434,11 @@ static int rt_usbd_init(void)
/* Register endpoint infomation */
_fsl_udc_1
.
ep_pool
=
_ehci1_ep_pool
;
_fsl_udc_1
.
ep0
.
id
=
&
_ehci1_ep_pool
[
0
];
#ifdef FSL_USB_HS
_fsl_udc_1
.
device_is_hs
=
RT_TRUE
;
#else
_fsl_udc_1
.
device_is_hs
=
RT_FALSE
;
#endif
rt_device_register
((
rt_device_t
)
&
_fsl_udc_1
,
"usbd"
,
0
);
rt_usb_device_init
();
#endif
...
...
@@ -410,6 +465,7 @@ static usb_status_t usb_device_endpoint_callback(usb_device_handle handle, usb_d
}
if
(
message
->
isSetup
)
{
//rt_kprintf("1udcd:%#08X\n",udcd);
rt_usbd_ep0_setup_handler
(
udcd
,
(
struct
urequest
*
)
message
->
buffer
);
}
else
if
(
ep_addr
==
0x00
)
...
...
@@ -423,6 +479,7 @@ static usb_status_t usb_device_endpoint_callback(usb_device_handle handle, usb_d
USB_DeviceSetStatus
(
handle
,
kUSB_DeviceStatusDeviceState
,
&
state
);
}
}
//rt_kprintf("2udcd:%#08X\n",udcd);
rt_usbd_ep0_out_handler
(
udcd
,
message
->
length
);
}
else
if
(
ep_addr
==
0x80
)
...
...
@@ -436,6 +493,7 @@ static usb_status_t usb_device_endpoint_callback(usb_device_handle handle, usb_d
USB_DeviceSetStatus
(
handle
,
kUSB_DeviceStatusDeviceState
,
&
state
);
}
}
//rt_kprintf("3udcd:%#08X\n",udcd);
rt_usbd_ep0_in_handler
(
udcd
);
}
else
if
(
ep_addr
&
0x80
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录