📄 testanalog.c
字号:
}
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);
}
}
} else {
break;
}
}
// Display the Test complete message
DBG_FlowStrPrint("\r\n[6.Host Disconnect Detect Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_7
// description : 7.Host Test J/K,SE0_NAK
// argument : none
// return : none
//=============================================================================
*/
void Test_7 ( void )
{
unsigned long inputNumber;
unsigned short inputDataSize;
char inputData[80];
// Display the Start test message
DBG_FlowStrPrint("\r\n[7.Host Test J/K,SE0_NAK Test Start]\r\n\r\n", FLOW_LV);
// Main loop
while(1) {
// TEst Menu judgement
DBG_FlowStrPrint("[ Please select the evaluation item ]\r\n", FLOW_LV);
DBG_FlowStrPrint("[ in the alphanumeric character of 1-3 and q. ]\r\n", FLOW_LV);
DBG_FlowStrPrint("[1: Test J]\r\n", FLOW_LV);
DBG_FlowStrPrint("[2: Test K]\r\n", FLOW_LV);
DBG_FlowStrPrint("[3: Test SE0_NAK]\r\n", FLOW_LV);
DBG_FlowStrPrint("[Q: Host Test J/K,SE0_NAK End.]\r\n", FLOW_LV);
//Waiting for key input & get key inout data
while(1) {
memset( inputData, 0x00, sizeof(inputData) );
FlowGetStr( inputData, &inputDataSize, 0 );
inputNumber = atol((const char *)inputData);
if( inputNumber == TEST_API_TEST_J
|| inputNumber == TEST_API_TEST_K || inputNumber == TEST_API_TEST_SE0_NAK
|| 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);
}
}
switch( inputNumber ) {
case TEST_API_TEST_J :
// Send Test_J
SendTest_J();
break;
case TEST_API_TEST_K :
// Send Test_J
SendTest_K();
break;
case TEST_API_TEST_SE0_NAK :
// Send Test_SE0_NAK
SendTest_SE0_NAK();
break;
// Nothing
default:
break;
}
// Eveluatation complete judgement
if( inputData[0] == QUIT_BIG || inputData[0] == QUIT_LITTLE ){
break;
}
DBG_FlowStrPrint("\r\n[The selected evaluation ended.]\r\n\r\n", FLOW_LV);
}
// Display the Test complete message
DBG_FlowStrPrint("\r\n[7.Host Test J/K,SE0_NAK Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_8
// description : 8.Host CHIRP Timing
// argument : none
// return : none
//=============================================================================
*/
void Test_8 ( void )
{
unsigned short inputDataSize;
char inputData[80];
// Display the Start test message
DBG_FlowStrPrint("\r\n[8.Host CHIRP Timing Test Start]\r\n\r\n", FLOW_LV);
// Device connect handler
TestDevConnect();
while(1){
// Confirm the timing of sending TestPacket
DBG_FlowStrPrint("[USB Reset is issued.if it is good.", FLOW_LV);
TestHitAnyKey();
// Execute High Speed HandShake
HighSpeedHandShake();
memset( inputData, 0x00, sizeof(inputData) );
DBG_FlowStrPrint("\r\n[Reset issue 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);
}
// Terminate the test mode
RegWrite(REG08_H_USB_Test, 0x00);
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[8.Host CHIRP Timing Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_9
// description : 9.Host Suspend/Resume Timing
// argument : none
// return : none
//=============================================================================
*/
void Test_9 ( void )
{
// Display the Start test message
DBG_FlowStrPrint("\r\n[9.Host Suspend/Resume Timing 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;
}
// Confirm the timing of sending Suspend
DBG_FlowStrPrint("\r\n[When you issue Suspend", FLOW_LV);
TestHitAnyKey();
// Send Suspend
SendSuspend(REMOTE_WAKEUP_DISABLE);
// Display the Test complete message
DBG_FlowStrPrint("\r\n[Suspend Test Complete]\r\n\r\n", FLOW_LV);
// Confirm the timing of sending Resume
DBG_FlowStrPrint("\r\n[It is Suspend.When you issue Resume", FLOW_LV);
TestHitAnyKey();
// Send Resume
SendResume();
// Display the Test complete message
DBG_FlowStrPrint("\r\n[Resume Test Complete]\r\n\r\n", FLOW_LV);
DBG_FlowStrPrint("\r\n[When you want to end the evaluation", FLOW_LV);
TestHitAnyKey();
// Terminate the test mode
RegWrite(REG08_H_USB_Test, 0x00);
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[9.Host Suspend/Resume Timing Test Complete]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_10
// description : 10.Test Data Receive
// argument : none
// return : none
//=============================================================================
*/
void Test_10 ( void )
{
// Display the start test message
DBG_FlowStrPrint("\r\n[10.Test Data Receive 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;
}
// Receive Test Packet
ReceiveTestPacket();
// Display the Test complete message
DBG_FlowStrPrint("\r\n[10.Test Data Receive Test End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: Test_11
// description : Set Term/Slope Value
// argument : none
// return : none
//=============================================================================
*/
void Test_11 ( void )
{
unsigned long inputNumber;
unsigned short inputDataSize;
char inputData[80];
// Display start test message
DBG_FlowStrPrint("\r\n[11.Set Term/Slope Value Start]\r\n\r\n", FLOW_LV);
DBG_FlowStrPrint("[Please input Term Value.]\r\n", FLOW_LV);
// Waiting for key input & get key inout data
while(1) {
memset( inputData, 0x00, sizeof(inputData) );
FlowGetStr( inputData, &inputDataSize, 0 );
inputNumber = atol((const char *)inputData);
if( 0 == inputNumber || (0 < inputNumber && inputNumber <= 3) ){
break;
} else {
DBG_FlowStrPrint("[It is an input value error. Try to input it.]\r\n", FLOW_LV);
}
}
TermValue = inputNumber;
DBG_FlowStrPrint("[Please input Slope Value.]\r\n", FLOW_LV);
// Waiting for key input & get the input data by key
while(1) {
memset( inputData, 0x00, sizeof(inputData) );
FlowGetStr( inputData, &inputDataSize, 0 );
inputNumber = atol((const char *)inputData);
if( 0 == inputNumber || (0 < inputNumber && inputNumber <= 3) ){
break;
} else {
DBG_FlowStrPrint("[It is an input value error. Try to input it.]\r\n", FLOW_LV);
}
}
SlopeValue = inputNumber;
DBG_FlowStrPrint("\r\n[TermValue = ", FLOW_LV);
DBG_FlowValPrint( PRINT_HEXA_MODE, DBG_STORE_BYTE, TermValue, FLOW_LV);
DBG_FlowStrPrint("]\r\n", FLOW_LV);
DBG_FlowStrPrint("[SlopeValue = ", FLOW_LV);
DBG_FlowValPrint( PRINT_HEXA_MODE, DBG_STORE_BYTE, SlopeValue, FLOW_LV);
DBG_FlowStrPrint("]\r\n", FLOW_LV);
TestHitAnyKey();
// Display the Test complete message
DBG_FlowStrPrint("\r\n\r\n[11.Set Term/Slope Value End]\r\n\r\n", FLOW_LV);
return;
}
/*
//=============================================================================
// Function_Name: DropDroop
// description : VBUS supply
// argument : none
// return : none
//=============================================================================
*/
static void DropDroop( void )
{
// Confirm the init state
if((RegRead(REG08_H_NegoControl_0) & MASK_HostState) != BIT_HostState_IDLE) {
TestAnalogErr( TEST_INIT, __LINE__ );
}
// GoWAIT_CONNECT
RegModify(REG08_H_NegoControl_0,MASK_AutoMode,BIT_AutoMode_GoWAIT_CONNECT);
DBG_FlowStrPrint("[WAIT_CONNECT The transition completion is standing by.]\r\n", FLOW_LV);
while(1) {
if( (RegRead(REG08_H_NegoControl_0) & MASK_HostState) == BIT_HostState_WAIT_CONNECT ) break;
}
DBG_FlowStrPrint("[WAIT_CONNECT transition completion]\r\n", FLOW_LV);
// Confirm the completion
DBG_FlowStrPrint("[When you stop the VBUS supply", FLOW_LV);
TestHitAnyKey();
RegModify(REG08_H_NegoControl_0,MASK_AutoMode,BIT_AutoMode_GoIDLE);
while((RegRead(REG08_H_NegoControl_0) & MASK_HostState) != BIT_HostState_IDLE);
}
/*
//=============================================================================
// Function_Name: SendReset
// description : Send Reset
// argument : none
// return : long execute result
//=============================================================================
*/
static long SendReset ( void )
{
OS_DlyTsk(100);
// Display the start to send Reset message
DBG_FlowStrPrint("[Send Reset Start]\r\n", FLOW_LV);
/*===========================/
Enable the necessary interrupts that related to the port
/===========================*/
RegModify(REG08_H_NegoControl_0,MASK_AutoMode,BIT_AutoMode_GoRESETtoOP);
// check Reset Complete Interrupt
while(1) {
if( (RegRead(REG08_H_SIE_IntStat_1) & MASK_ResetCmp) == BIT_ResetCmp ) break;
}
if( (RegRead(REG08_H_SIE_IntStat_0) & MASK_DetectDevChirpNG) != BIT_DetectDevChirpNG ){
// Display the sent Reset normally message
DBG_FlowStrPrint("[Send Reset Complete]\r\n", FLOW_LV);
DBG_FlowStrPrint("[OPERATIONALtransition completion]\r\n", FLOW_LV);
switch( (RegRead(REG08_H_NegoControl_1) & MASK_PortSpeed)>>SHIFT_PortSpeed ){
case HIGH_SPEED_MODE:
LED_On(1);
LED_On(2);
break;
case FULL_SPEED_MODE:
LED_On(1);
LED_Off(2);
break;
case LOW_SPEED_MODE:
LED_Off(1);
LED_On(2);
break;
}
return STATUS_SUCCESS;
} else {
// Display the sent reset error message.
DBG_FlowStrPrint("[Send Reset Error]\r\n", FLOW_LV);
return STATUS_UNSUCCESSFUL;
}
}
/*
//=============================================================================
// Function_Name: SendTestPacket
// description : Send Test Packet (Test4, Test11)
// argument : none
// return : none
//=============================================================================
*/
static void SendTestPacket ( void )
{
unsigned char testData[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -