基于OHCI的USB主机 —— 寄存器(传输)

启动控制传输
进行控制传输之前,需要设置好相应的 ED TD 参数(参见下一章),启动传输时需要设置 OHCI 寄存器中的控制传输 ED 头指针寄存器和控制传输的当前 ED 指针寄存器,然后设置控制寄存器允许处理控制传输列表,控制状态寄存器有控制传输列表数据需要传输,代码如下:
/**
  * 通过 Control 端口传输数据
  * @param *ed 需要进行数据收发的 ED 指针
  * @return 0 - 成功
  */
short ohciCtrlXfer ( AT91S_UHP_ED *ed)
{
    // Programming the CHED
    pUhp-> UHP_HcControlHeadED = ( unsigned int ) ed;
 
    // Programming the CCED
    pUhp-> UHP_HcControlCurrentED = ( unsigned int ) ed;
 
    // UHP: UHP is now operational and control list processing is enabled
    pUhp-> UHP_HcControl = 0x90;
   
    // UHP: Notify the Hc that the Control list is filled
    pUhp-> UHP_HcCommandStatus = OHCI_HC_COMMAND_STATUS_CLF;
   
    return 0;
}
 
启动批量传输
启动批量传输的流程与控制传输类似,只不过相应寄存器换为批量传输的寄存器了:
/**
  * 通过 Bulk 端口传输数据
  * @param *ed 需要进行数据收发的 ED 指针
  * @return 0 - 成功
  */
short ohciBulkXfer ( AT91S_UHP_ED *ed)
{
    // 禁止 ED
    pUhp-> UHP_HcControl = 0x180;
    pUhp-> UHP_HcCommandStatus = 0x00;
   
    // Programming the BHED
    pUhp-> UHP_HcBulkHeadED = ( unsigned int ) ed;
 
    // Programming the BCED
    pUhp-> UHP_HcBulkCurrentED = ( unsigned int ) ed;
 
    // UHP: UHP is now operational and control list processing is enabled
    pUhp-> UHP_HcControl = 0x0A0;
   
    // UHP: Notify the Hc that the Bulk list is filled
    pUhp-> UHP_HcCommandStatus = OHCI_HC_COMMAND_STATUS_BLF;
   
    return 0;
}
 

本文出自 “rainman ” 博客,请务必保留此出处http://lancelot.blog.51cto.com/393579/232493

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值