Silicon Laboratories SI2494/39, SI2493/57/34/15/04 manual Rev 265

Models: SI2493/57/34/15/04 SI2494/39

1 304
Download 304 pages 21.65 Kb
Page 265
Image 265

AN93

AssertRTS(true); //RTS=1 for transmitting

 

Delay(300); //Delay to allow the line to turn around

// Alternatively use USE CTS

iLength = strlen(caUA_PKT_STR);

 

WriteFile(hCom, caUA_PKT_STR, iLength, &ulNoOfbytes, 0);

// Tx UA messge

Delay(100);

 

while(1) // Short training happens now!

 

{

 

AssertRTS(false); printf("RTS=0 Rx ");

//RTS=0 for receiving

cpInputRd=WaitForResponse(caRX_PKT_STR,cpInputRd,3000);//Rx RR message iLength = strlen(cpInput_test);

for (int i=0; i<iLength; i++)

printf("%02x ", (unsigned char)cpInput_test[i]);printf("**%d ", *cpInputRd); //Alternatively use CTS

Delay(150);

do{ // flush out the bytes for last RX packets.

BOOL bError = !ReadFile(hCom, cpInputWr, 1, &ulNoOfbytes, 0); //ulNoOfbytes=1 printf("%02x ", (unsigned char)cpInputWr[0]);

}while (ulNoOfbytes); printf("\n");

 

AssertRTS(true); printf("RTS=1 Tx ");

//RTS=1 for transmitting

Delay(50); // morrie 01/20/06 iLength = strlen(caRR_PKT_STR);

for (i=0; i<iLength; i++)printf("%02x ", (unsigned char)caRR_PKT_STR[i]); printf("\n"); WriteFile(hCom, caRR_PKT_STR, iLength, &ulNoOfbytes,0); //Tx RR message

Delay(100); //Delay x ms to complete TX sending before set RTS=0 for RX

}

return;

}

 

 

// -------------------------------------------------------------------------------------

 

// Use this call to check CTS

status

// DWORD iEVentMAsk;

//

wait for EV_CTS

//BOOL WaitCommEvent(HANDLE hFile, &iEVentMAsk, LPOVERLAPPED lpOverlapped);

//----------------------------------------------------------------

void SetupSerPort()

{

 

BOOL

bSuccess;

hCom = CreateFile(pcCommPort, GENERIC_READ GENERIC_WRITE, 0,

 

NULL, OPEN_EXISTING, 0, NULL);

if (hCom == INVALID_HANDLE_VALUE)

{

// Handle the error.

printf ("CreateFile failed with error %d.\n", GetLastError()); exit(1);

Rev. 1.3

265

Page 265
Image 265
Silicon Laboratories SI2494/39, SI2493/57/34/15/04 manual Rev 265