📄 testanalog.c
字号:
default:
DBG_FlowStrPrint("[It is an input value error. Try to input it.]\r\n", FLOW_LV);
testResult = TEST_API_INITIALIZE;
break;
}
// Dispatch according to the evaluation result.
if( testResult == TEST_API_COMPLETE
|| testResult == TEST_API_ERROR ) {
DBG_FlowStrPrint("[The selected evaluation ended.]\r\n", FLOW_LV);
break;
}
}
// Evaluation complete adjudgement
if( inputData[0] == QUIT_BIG || inputData[0] == QUIT_LITTLE ) {
DBG_FlowStrPrint("\r\n[USB Host USBD API Test ended.]", FLOW_LV);
break;
}
}
// return;
}
/*
//=============================================================================
// Function_Name: TestMain
// description : Evaluate start main function
// argument : unsigned char testMenu
// return :
//=============================================================================
*/
static long TestMain ( unsigned char testMenu )
{
unsigned char testStatus;
// Initialize variables
testStatus = TEST_API_ERROR;
// Initialize
ChipReset();
switch( testMenu ) {
// Test1: LS Signal Quality ( Legacy USB Compliance Test )
case TEST_API_LS_SIGNAL :
Test_1();
testStatus = TEST_API_COMPLETE;
break;
// Test2: FS Signal Quality ( Legacy USB Compliance Test )
case TEST_API_FS_SIGNAL:
Test_2();
testStatus = TEST_API_COMPLETE;
break;
// Test3: Host HS Signal Quality ( Host High-speed Electrical Test )
case TEST_API_HS_SIGNAL:
Test_3();
testStatus = TEST_API_COMPLETE;
break;
// Test4: Single Step Get Descriptor( Host High-speed Electrical Test )
case TEST_API_SINGLE_STEP_GDES:
Test_4();
testStatus = TEST_API_COMPLETE;
break;
// Test5: Drop/Droop ( Legacy USB Compliance Test )
case TEST_API_DROP_DROOP:
Test_5();
testStatus = TEST_API_COMPLETE;
break;
// Test6: Host Disconnect Detect ( Host High-speed Electrical Test )
case TEST_API_DISCON_DET:
Test_6();
testStatus = TEST_API_COMPLETE;
break;
// Test7: Host Test J/K, SE0_NAK ( Host High-speed Electrical Test )
case TEST_API_J_K_SE0_NAK:
Test_7();
testStatus = TEST_API_COMPLETE;
break;
// Test8: Host CHIRP Timing ( Host High-speed Electrical Test )
case TEST_API_CHIRP:
Test_8();
testStatus = TEST_API_COMPLETE;
break;
// Test9: Host Suspend/Resume Timing ( Host High-speed Electrical Test )
case TEST_API_SUSPEND_RESUME:
Test_9();
testStatus = TEST_API_COMPLETE;
break;
// Test10: Receive "Test Data" Test ( Option )
case TEST_API_TEST_DATA_RCV:
Test_10();
testStatus = TEST_API_COMPLETE;
break;
// Test11: Receive "Test Data" Test ( Option )
case TEST_API_SET_TERMSLOPE_VALUE:
Test_11();
testStatus = TEST_API_COMPLETE;
break;
// Should not run into here
default:
testStatus = TEST_API_ERROR;
break;
}
return testStatus;
}
/*
//=============================================================================
// Function_Name: Test_1
// description : 1.LS Signal Quality
// argument : none
// return : none
//=============================================================================
*/
void Test_1 ( void )
{
// Display the Start test message
DBG_FlowStrPrint("\r\n[1.Host LS Signal Quality Test Start]\r\n\r\n", FLOW_LV);
// Device connect handler
TestDevConnect();
// Execute result adjudgement
if( SendReset() != STATUS_SUCCESS ) {
// complete with Error.
DBG_FlowStrPrint("[Send Reset Error]\r\n", FLOW_LV);
return;
}
// Send Get Device Descriptor request
SendGetDeviceDescriptorReq();
// Display the Test complete message
DBG_FlowStrPrint("\r\n[1.Host LS Signal Quality Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_2
// description : 2.FS Signal Quality
// argument : none
// return : none
//=============================================================================
*/
void Test_2 ( void )
{
// Display the start test message.
DBG_FlowStrPrint("\r\n[2.Host FS Signal Quality Test Start]\r\n\r\n", FLOW_LV);
// device connect handler
TestDevConnect();
// Execute result adjudgement
if( SendReset() != STATUS_SUCCESS ) {
// Complete with Error.
DBG_FlowStrPrint("[Send Reset Error]\r\n", FLOW_LV);
return;
}
// Send Get Device Descriptor request
SendGetDeviceDescriptorReq();
// Display the Test complete message
DBG_FlowStrPrint("\r\n[2.Host FS Signal Quality Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_3
// description : 3.Host HS Signal Quality
// argument : none
// return : none
//=============================================================================
*/
void Test_3 ( void )
{
// Display the Start test message
DBG_FlowStrPrint("\r\n[3.Host HS Signal Quality Test Start]\r\n\r\n", FLOW_LV);
// Send test packet
SendTestPacket();
// Display the Test complete message
DBG_FlowStrPrint("\r\n[3.Host HS Signal Quality Test Complete]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_4
// description : Test4: Single Step Set Feature
// argument : none
// return : none
//=============================================================================
*/
void Test_4 ( void )
{
unsigned short inputDataSize;
char inputData[80];
unsigned char setupData[8];
long retValue;
// Display the Start test message
DBG_FlowStrPrint("\r\n[4.Single Step Get Descriptor Test Start]\r\n\r\n", FLOW_LV);
// Device connect handler
TestDevConnect();
// Check execute result
if( SendReset() != STATUS_SUCCESS ) {
// Complete with Error.
DBG_FlowStrPrint("[Send Reset Error]\r\n", FLOW_LV);
return;
}
/* Send request*/
// Initialize the variables
memset( setupData, 0, sizeof(setupData) );
// Set GetDeviceDescriptor data
setupData[0] = DIR_DEVICE_TO_HOST | RECIPIENT_DEVICE;
setupData[1] = SREQ_GET_DESCRIPTOR;
setupData[2] = 0;
setupData[3] = DTYPE_DEVICE;
setupData[4] = 0;
setupData[5] = 0;
setupData[6] = 0x00;
setupData[7] = 0x01;
DBG_FlowStrPrint("The test begins.Please press return.]\r\n", FLOW_LV);
FlowGetStr( inputData, &inputDataSize, 0 );
// Send request
retValue = SingleStepSendRequest( setupData );
if( retValue != STATUS_SUCCESS ){
DBG_FlowStrPrint("\r\n[Request error generation両両]\r\n", FLOW_LV);
}
DBG_FlowStrPrint("\r\n[When you want to end the evaluation", FLOW_LV);
TestHitAnyKey();
DBG_FlowStrPrint("\r\n", FLOW_LV);
// Process complete
// Cancel the Auto mode temporarily
RegSet(REG08_H_NegoControl_0,BIT_AutoModeCancel);
while((RegRead(REG08_H_NegoControl_0) & MASK_AutoModeCancel) == BIT_AutoModeCancel);
RegModify(REG08_H_NegoControl_0,MASK_AutoMode,BIT_AutoMode_GoIDLE);
while((RegRead(REG08_H_NegoControl_0) & MASK_HostState) != BIT_HostState_IDLE);
// Display the Test complete message
DBG_FlowStrPrint("\r\n[4.Single Step Get Descriptor Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_5
// description : 5.Drop/Droop
// argument : none
// return : none
//=============================================================================
*/
void Test_5 ( void )
{
// Display the Start test message
DBG_FlowStrPrint("\r\n[5.Drop/Droop Test Start]\r\n\r\n", FLOW_LV);
DropDroop();
// Display the Test complete message
DBG_FlowStrPrint("\r\n[5.Drop/Droop Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_6
// description : 6.Host Disconnect Detect
// argument : none
// return : none
//=============================================================================
*/
void Test_6 ( void )
{
unsigned long inputNumber;
unsigned short inputDataSize;
char inputData[80];
// Display the Start test message
DBG_FlowStrPrint("\r\n[6.Host Disconnect Detect Test Start]\r\n\r\n", FLOW_LV);
while(1){
// Test Menu judgment
DBG_FlowStrPrint("[ Please select the evaluation item ]\r\n", FLOW_LV);
DBG_FlowStrPrint("[ in the alphanumeric character of 1-2 and q. ]\r\n", FLOW_LV);
DBG_FlowStrPrint("[1: Normal Mode]\r\n", FLOW_LV);
DBG_FlowStrPrint("[2: Force HS Mode]\r\n", FLOW_LV);
DBG_FlowStrPrint("[Q: Exit]\r\n", FLOW_LV);
//Waiting for key input & get key input data
while(1) {
memset( inputData, 0x00, sizeof(inputData) );
FlowGetStr( inputData, &inputDataSize, 0 );
inputNumber = atol((const char *)inputData);
if( (inputNumber == TEST_API_DISCON_DET_NORMAL) || (inputNumber == TEST_API_DISCON_DET_FORCE)
|| (inputData[0] == QUIT_BIG) || (inputData[0] == QUIT_LITTLE) ) {
break;
} else {
DBG_FlowStrPrint("[It is an input value error. Try to input it.]\r\n", FLOW_LV);
}
}
if( inputNumber == TEST_API_DISCON_DET_NORMAL ){
// Device connect handler
TestDevConnect();
// Check execute result
if( SendReset() != STATUS_SUCCESS ) {
// complete with Error.
DBG_FlowStrPrint("[Send Reset Error]\r\n", FLOW_LV);
return;
}
// detect Device disconnection
DeviceDisconnectDetect();
// Eveluatation complete adjudgement
memset( inputData, 0x00, sizeof(inputData) );
DBG_FlowStrPrint("\r\n[Detection processing completion.]\r\n",FLOW_LV);
DBG_FlowStrPrint("Please press return when Q(q) is continued when ending here.]\r\n", FLOW_LV);
FlowGetStr( inputData, &inputDataSize, 0 );
if( inputData[0] == QUIT_BIG || inputData[0] == QUIT_LITTLE ){
break;
}
DBG_FlowStrPrint("\r\n",FLOW_LV);
} else if( inputNumber == TEST_API_DISCON_DET_FORCE ){
DBG_FlowStrPrint("\r\n[It compulsorily makes it to High Speed Mode.]\r\n", FLOW_LV);
DBG_FlowStrPrint("\r\n[When it is possible to prepare it", FLOW_LV);
TestHitAnyKey();
// Cancel the Auto mode temporarily
RegWrite(REG08_H_NegoControl_0,BIT_AutoModeCancel);
while((RegRead(REG08_H_NegoControl_0) & MASK_AutoModeCancel) == BIT_AutoModeCancel);
RegSet(REG08_H_USB_Test, BIT_Test_Force_Enable);
RegSet(REG08_H_USB_Test, BIT_EnHS_Test);
RegWrite(REG08_H_SIE_IntStat_0, INT_ALL_CLEAR);
DBG_FlowStrPrint("[It compulsorily made it to High Speed Mode.", FLOW_LV);
DBG_FlowStrPrint("[Disconnecting and leopard when disconnecting device is detected.]\r\n", FLOW_LV);
DBG_FlowStrPrint("[Please disconnect the device when you want to end the evaluation.]\r\n", FLOW_LV);
while(1){
if( (RegRead(REG08_H_SIE_IntStat_0) & MASK_DetectDiscon) == BIT_DetectDiscon){
/* Detect the disconnection*/
/* Clear the interrupt status */
DBG_FlowStrPrint("[Disconnecting the device is detected. ]\r\n\r\n", FLOW_LV);
DBG_FlowStrPrint("Please press return when Q(q) is continued when ending here.]\r\n", FLOW_LV);
FlowGetStr( inputData, &inputDataSize, 0 );
RegWrite(REG08_H_USB_Test, 0x00);
if( inputData[0] == QUIT_BIG || inputData[0] == QUIT_LITTLE ){
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -