s3c2440的USB主机控制器
时间:11-19
来源:互联网
点击:
全局变量数组
//const char pSetup1[8] ={0x80,0x06,0x00,0x01,0x00,0x00,0x40,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
//接收数据
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
(unsigned int) pData1,// Current Buffer Pointer,定义的全局变量数组
// char pData1[0x40];通过读取该数组,可以获知设备描述符
(unsigned int) &td[2],// Next TD
0x40);// Buffer Length
//零长度数据包
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) &td[3],// Next TD
0x0);// Buffer Length
//接收状态
CreateGenTd(
(unsigned int) &td[3],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
//设置寄存器
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
//控制列表处理使能,开始工作
rHcControl = 0x90;
//通知HC控制列表已填充
rHcCommandStatus = 0x02;
//第二步为设备分配地址
CreateEd(
(unsigned int) &ed,// ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0,// Endpoint
0,// Func Address
(unsigned int) &td[2],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
//建立PID
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
2,// DelayInterrupt
0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup2,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup2[8] ={0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
//接收零长度数据包
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
2,// DelayInterrupt
2,// Direction
1,// Buffer Rounding
(unsigned int) 0,// Current Buffer Pointer
(unsigned int) &td[2],// Next TD
0);// Buffer Length
//发送状态
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
2,// DelayInterrupt
1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
//第三步,主机用新的地址再次获取设备描述符
CreateEd(
(unsigned int) &ed, // ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0x0,// Endpoint
0x2,// Func Address,新的地址
(unsigned int) &td[3],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
0x2,// DelayInterrupt
0x0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup3,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup3[8] ={0x80,0x06,0x00,0x01,0x00,0x00,0x12,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
(unsigned int) pData3,// Current Buffer Pointer,定义的全局变量数组
// char pData3[0x12];通过读取该数组,可以获知设备描述符
(unsigned int) &td[2],// Next TD
0x12);// Buffer Length
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) &td[3],// Next TD
0x0);// Buffer Length
CreateGenTd(
(unsigned int) &td[3],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
//第四步,主机读取设备全部配置描述符
CreateEd(
(unsigned int) &ed, // ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0x0,// Endpoint
0x2,// Func Address
(unsigned int) &td[3],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
0x2,// DelayInterrupt
0x0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup4,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup4[8] ={0x80,0x06,0x00,0x02,0x00,0x00,0x40,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
(unsigned int) pData4,// Current Buffer Pointer,定义的全局变量数组
// char pData4[0x40];通过读取该数组,可以获知配置描述符
(unsigned int) &td[2],// Next TD
0x40);// Buffer Length
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) &td[3],// Next TD
0x0);// Buffer Length
CreateGenTd(
(unsigned int) &td[3],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
//第五步,主机发送SETUP数据包,用以设置配置,允许所有端点进入工作状态。
CreateEd(
(unsigned int) &ed, // ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0,// Endpoint
2,// Func Address
(unsigned int) &td[2],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
2,// DelayInterrupt
0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup5,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup5[8] ={0x00,0x09,0x01,0x00,0x00,0x00,0x00,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
2,// DelayInterrupt
2,// Direction
1,// Buffer Rounding
(unsigned int) 0,// Current Buffer Pointer
(unsigned int) &td[2],// Next TD
0);// Buffer Length
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
2,// DelayInterrupt
1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
return 0x88;
}
//const char pSetup1[8] ={0x80,0x06,0x00,0x01,0x00,0x00,0x40,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
//接收数据
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
(unsigned int) pData1,// Current Buffer Pointer,定义的全局变量数组
// char pData1[0x40];通过读取该数组,可以获知设备描述符
(unsigned int) &td[2],// Next TD
0x40);// Buffer Length
//零长度数据包
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) &td[3],// Next TD
0x0);// Buffer Length
//接收状态
CreateGenTd(
(unsigned int) &td[3],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
//设置寄存器
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
//控制列表处理使能,开始工作
rHcControl = 0x90;
//通知HC控制列表已填充
rHcCommandStatus = 0x02;
//第二步为设备分配地址
CreateEd(
(unsigned int) &ed,// ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0,// Endpoint
0,// Func Address
(unsigned int) &td[2],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
//建立PID
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
2,// DelayInterrupt
0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup2,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup2[8] ={0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
//接收零长度数据包
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
2,// DelayInterrupt
2,// Direction
1,// Buffer Rounding
(unsigned int) 0,// Current Buffer Pointer
(unsigned int) &td[2],// Next TD
0);// Buffer Length
//发送状态
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
2,// DelayInterrupt
1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
//第三步,主机用新的地址再次获取设备描述符
CreateEd(
(unsigned int) &ed, // ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0x0,// Endpoint
0x2,// Func Address,新的地址
(unsigned int) &td[3],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
0x2,// DelayInterrupt
0x0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup3,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup3[8] ={0x80,0x06,0x00,0x01,0x00,0x00,0x12,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
(unsigned int) pData3,// Current Buffer Pointer,定义的全局变量数组
// char pData3[0x12];通过读取该数组,可以获知设备描述符
(unsigned int) &td[2],// Next TD
0x12);// Buffer Length
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) &td[3],// Next TD
0x0);// Buffer Length
CreateGenTd(
(unsigned int) &td[3],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
//第四步,主机读取设备全部配置描述符
CreateEd(
(unsigned int) &ed, // ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0x0,// Endpoint
0x2,// Func Address
(unsigned int) &td[3],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
0x2,// DelayInterrupt
0x0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup4,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup4[8] ={0x80,0x06,0x00,0x02,0x00,0x00,0x40,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
(unsigned int) pData4,// Current Buffer Pointer,定义的全局变量数组
// char pData4[0x40];通过读取该数组,可以获知配置描述符
(unsigned int) &td[2],// Next TD
0x40);// Buffer Length
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) &td[3],// Next TD
0x0);// Buffer Length
CreateGenTd(
(unsigned int) &td[3],// TD Address
3,// Data Toggle
0x2,// DelayInterrupt
0x2,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
//第五步,主机发送SETUP数据包,用以设置配置,允许所有端点进入工作状态。
CreateEd(
(unsigned int) &ed, // ED Address
64,// Max packet
0,// TD format
0,// Skip
0,// Speed
0x0,// Direction
0,// Endpoint
2,// Func Address
(unsigned int) &td[2],// TDQTailPointer
(unsigned int) &td[0],// TDQHeadPointer
0,// ToggleCarry
0x0);// NextED
CreateGenTd(
(unsigned int) &td[0],// TD Address
2,// Data Toggle
2,// DelayInterrupt
0,// Direction
1,// Buffer Rounding
(unsigned int) pSetup5,// Current Buffer Pointer,定义的全局变量数组
//const char pSetup5[8] ={0x00,0x09,0x01,0x00,0x00,0x00,0x00,0x00};
(unsigned int) &td[1],// Next TD
8);// Buffer Length
CreateGenTd(
(unsigned int) &td[1],// TD Address
0,// Data Toggle
2,// DelayInterrupt
2,// Direction
1,// Buffer Rounding
(unsigned int) 0,// Current Buffer Pointer
(unsigned int) &td[2],// Next TD
0);// Buffer Length
CreateGenTd(
(unsigned int) &td[2],// TD Address
3,// Data Toggle
2,// DelayInterrupt
1,// Direction
1,// Buffer Rounding
0x0,// Current Buffer Pointer
(unsigned int) 0,// Next TD
0x0);// Buffer Length
rHcControlHeadED = (unsigned int )& ed;
rHcControlCurrentED = (unsigned int )& ed;
rHcControl = 0x90;
rHcCommandStatus = 0x02;
return 0x88;
}
s3c2440USB主机控制 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)