📄 mainfrm.cpp
字号:
// SleepEx(250,0);
/*按默认的配置,读回Endpoint6的数据并显示*/
bulkControl.pipeNum = 2;
buffer = &recievedat[0];
length = theApp.m_USBbufferlong;
Sx2BulkdataTrans( &bulkControl,
buffer,
length,
&recnBytes);
/*显示读回数据*/
theApp.Out("The data read from the endpiont 6:\n");
theApp.Out("The data is oven data.\n");
for(i = 0; i<64 ;)
{
int j = 0;
bool drawover = FALSE;
for(j = 0 ;j<9;j++)
{
if(i+j ==63)
{
theApp.Out("00%04d\n",(buffer[i+j]&0xff));
drawover = TRUE;
break;
}
else
{
theApp.Out("00%04d ",(buffer[i+j]&0xff));
}
}
if(drawover)
{
break;
}
i = i +9;
theApp.Out("00%04d\n",(buffer[i]&0xff));
i= i +1;
}
myRequest.direction = 0;
myRequest.index = 0;
myRequest.value = 3;
myRequest.request =0xb6;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
venderlong = 0;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
/*按默认的配置,读回Endpoint6的数据并显示*/
bulkControl.pipeNum = 3;
buffer = &recievedat[0];
length = theApp.m_USBbufferlong;
Sx2BulkdataTrans( &bulkControl,
buffer,
length,
&recnBytes);
/*显示读回数据*/
theApp.Out("The data read from the endpiont 8:\n");
theApp.Out("The data is odd data.\n");
for(i = 0; i<64 ;)
{
int j = 0;
bool drawover = FALSE;
for(j = 0 ;j<9;j++)
{
if(i+j == 63)
{
theApp.Out("00%04d\n",(buffer[i+j]&0xff));
drawover = TRUE;
break;
}
else
{
theApp.Out("00%04d ",(buffer[i+j]&0xff));
}
}
if(drawover)
{
break;
}
i = i +9;
theApp.Out("00%04d\n",(buffer[i]&0xff));
i= i +1;
}
}
void CMainFrame::OnBulkWrite()
{
//BULK数据的写操作
int i = 0;
char *buffer;
char senddat[512] = {0};
ULONG length;
BULK_TRANSFER_CONTROL bulkControl;
int recnBytes = 0;
/*写Endpoint2*/
bulkControl.pipeNum = 0;
for(i = 0;i<512;i++)
{
senddat[i] = i;
}
buffer = &senddat[0];
length =theApp.m_USBbufferlong;
Sx2BulkdataTrans( &bulkControl,
buffer,
length,
&recnBytes);
/*读回Endpoint6,并显示*/
bulkControl.pipeNum = 2;
for(i = 0;i<512;i++)
{
senddat[i] = 0;
}
buffer = &senddat[0];
length = theApp.m_USBbufferlong;
Sx2BulkdataTrans( &bulkControl,
buffer,
length,
&recnBytes);
/*显示读回数据*/
theApp.Out("The data send to the endpiont2 is:\n0,1,2,3.......to 0x3f.\n");
theApp.Out("The data read from the endpiont 6:\n");
for(i = 0; i<64 ;)
{
int j = 0;
bool drawover = FALSE;
for(j = 0 ;j<9;j++)
{
if(i+j == 63)
{
theApp.Out("0x%04x\n",(buffer[i+j]&0xff));
drawover = TRUE;
break;
}
else
{
theApp.Out("0x%04x ",(buffer[i+j]&0xff));
}
}
if(drawover)
{
break;
}
i = i +9;
theApp.Out("0x%04x\n",(buffer[i]&0xff));
i= i +1;
}
/*写Endpoint4*/
bulkControl.pipeNum = 1;
for(i = 0;i<theApp.m_USBbufferlong;i++)
{
senddat[i] = 0x3F-i;
}
buffer = &senddat[0];
length =theApp.m_USBbufferlong;
Sx2BulkdataTrans( &bulkControl,
buffer,
length,
&recnBytes);
/*读回Endpoint6,并显示*/
bulkControl.pipeNum = 3;
for(i = 0;i<512;i++)
{
senddat[i] = 0;
}
buffer = &senddat[0];
length = theApp.m_USBbufferlong;
Sx2BulkdataTrans( &bulkControl,
buffer,
length,
&recnBytes);
/*显示读回数据*/
theApp.Out("The data send to the endpiont4 is:\n0x3f,0x3e,0x3d.......to 0.\n");
theApp.Out("The data read from the endpiont 8:\n");
for(i = 0; i<64 ;)
{
int j = 0;
bool drawover = FALSE;
for(j = 0 ;j<9;j++)
{
if(i+j == 63)
{
theApp.Out("0x%04x\n",(buffer[i+j]&0xff));
drawover = TRUE;
break;
}
else
{
theApp.Out("0x%04x ",(buffer[i+j]&0xff));
}
}
if(drawover)
{
break;
}
i = i +9;
theApp.Out("0x%04x\n",(buffer[i]&0xff));
i= i +1;
}
}
void CMainFrame::OnLedOn()
{
// 点亮LED灯
/*命令请求定义*/
char buffer1[64];
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
ULONG venderlong;
int recnBytes = 0;
/*发送命令,使DSP先定入固定的数据*/
myRequest.direction = 0;
myRequest.index = 0;
myRequest.value = LED_ON;
myRequest.request = VR_LED_OPTION;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
venderlong = 0;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
theApp.Out("We have turn on the LED D5 on the SEED DEC55XX board.\n");
}
void CMainFrame::OnLedOff()
{
//关掉LED
/*命令请求定义*/
char buffer1[64];
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
ULONG venderlong;
int recnBytes = 0;
/*发送命令,使DSP先定入固定的数据*/
myRequest.direction = 0;
myRequest.index = 0;
myRequest.value = LED_OFF;
myRequest.request = VR_LED_OPTION;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
venderlong = 0;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
theApp.Out("We have turn off the LED D5 on the SEED DEC55XX board.\n");
}
void CMainFrame::OnLedBlink()
{
// 闪烁LED灯
/*命令请求定义*/
char buffer1[64];
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
ULONG venderlong;
int recnBytes = 0;
/*发送命令,使DSP先定入固定的数据*/
myRequest.direction = 0;
myRequest.index = 0;
myRequest.value = LED_BLINK;
myRequest.request = VR_LED_OPTION;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
venderlong = 0;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
theApp.Out("We make the LED D5 on the SEED DEC55XX board blinking.\n");
}
void CMainFrame::OnUsb20or11()
{
//得到USB工作在2.0标准,还是1.1标准
/*命令请求定义*/
char buffer1[64];
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
ULONG venderlong;
int recnBytes = 0;
/*发送命令,使DSP先定入固定的数据*/
myRequest.direction = 1;
myRequest.index = 0;
myRequest.value = 0;
myRequest.request = VR_USB_VERION;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
/*传回一个数据长度*/
venderlong = 1;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
if(buffer1[0] ==0x55)
{
theApp.Out("CY7C68001 is working under USB 2.0!\n");
}
else
{
if(buffer1[0] ==0x54)
{
theApp.Out("CY7C68001 is working under USB 1.1!\n");
}
else
{
theApp.Out("CY7C68001 is working error!\n");
}
}
}
void CMainFrame::OnCodecCircle()
{
//CODEC试听
int i = 0;
/*命令请求定义*/
char buffer1[64];
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
ULONG venderlong;
int recnBytes = 0;
/*发送命令,使DSP先写入固定的数据*/
myRequest.direction = 0;
myRequest.index = 0;
myRequest.value = 0;
myRequest.request = VR_CODEC_CIRCLE;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
venderlong = 0;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
theApp.Out("The CODEC is runing......\n");
}
void CMainFrame::OnCodecHalt()
{
// CODEC 停止
int i = 0;
/*命令请求定义*/
char buffer1[64];
VENDOR_OR_CLASS_REQUEST_CONTROL myRequest;
ULONG venderlong;
int recnBytes = 0;
/*发送命令,使DSP先写入固定的数据*/
theApp.m_CodecHalt = TRUE;
myRequest.direction = 0;
myRequest.index = 0;
myRequest.value = 0;
myRequest.request = VR_CODEC_HALT;
// vendor specific request type (2)
myRequest.requestType=2;
// recepient is device (0)
myRequest.recepient=0;
venderlong = 0;
Sx2SendVendorReq(&myRequest,
&buffer1[0],
venderlong,
&recnBytes);
theApp.Out("The CODEC halt!\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -