📄 dongle.c
字号:
printf(" Word10 : %x \n",Dongle->WORD10.Data);
printf(" Word11 : %x \n",Dongle->WORD11.Data);
}
#endif
//////////////////////////////////////////////////////////////////////////
// //
// Function: DoPlugPlayDongle //
// //
// Description: //
// Detects the intelligent dongles. //
// //
// Input : UIR port //
// Output: Signature of the dongle //
//////////////////////////////////////////////////////////////////////////
UINT DoPlugPlayDongle(UINT UirPort)
{
UINT val,tmp;
DEBUGMSG(ZONE_FIRMODE, (TEXT("DoPlugPlayDongle -->\r\n")));
// Make the Pins IRSL1-2 as Inputs
NSC_WriteBankReg(UirPort,BANK7,7,0x00);
val = (UINT)(NSC_ReadBankReg(UirPort,BANK7,4) & 0xf);
// Make the Pins IRSL1-2 as output
NSC_WriteBankReg(UirPort,BANK7,7,0x08);
// Now Detect CIR part of it
// Invert IRSL1 for detecting 36Khz support
tmp = val ^ 2;
NSC_WriteBankReg(UirPort,BANK7,4,(UCHAR)(tmp & 0xf));
// Now Check for IRSL3 settings
tmp = (UINT)NSC_ReadBankReg(UirPort,BANK7,4) ^ val;
// If IRSL3 set, 36 K supported
if (GetBit(tmp,3))
val = SetBit(val,5);
// Extract IRSL1-2 value from the the signature
tmp = val ^ 4;
NSC_WriteBankReg(UirPort,BANK7,4,(UCHAR)(tmp & 0xf));
// Now Check for IRSL3 settings
tmp = (UINT)NSC_ReadBankReg(UirPort,BANK7,4) ^ val;
// If IRSL3 set, 38 K supported
if (GetBit(tmp,3))
val = SetBit(val,7);
// Test for HP with no Rx Mux
if (!(((val & 0xf) == 0xc) || ((val & 0xf) == 0xd))) {
// Set 40k Support if IRSl0 has inverted
if (GetBit(tmp,0))
val = SetBit(val,6);
}
// Now test for 56.9K support
// Extract IRSL1-2 value from the the signature
tmp = val ^ 6;
NSC_WriteBankReg(UirPort,BANK7,4,(UCHAR)(tmp & 0xf));
// Now Check for IRSL3 settings
tmp = (UINT)NSC_ReadBankReg(UirPort,BANK7,4) ^ val;
// If IRSL3 set, 56.9K supported
if (GetBit(tmp,3))
val = SetBit(val,9);
DEBUGMSG(ZONE_FIRMODE, (TEXT("DoPlugPlayDongle <--\r\n")));
return (val);
}
//////////////////////////////////////////////////////////////////////////
// //
// Function: SetSharpDongle //
// //
// Description: //
// //
//////////////////////////////////////////////////////////////////////////
void SetSharpDongle(UINT UirPort,int Mode)
{
NSC_WriteBankReg(UirPort,BANK7,7,0x28);
}
//////////////////////////////////////////////////////////////////////////
// //
// Function: SetTemicDongle //
// //
// Description: //
// Set the IBM Transceiver mode //
// Mode = 0 - SIR, MIR //
// Mode = 1 - FIR //
// Mode = 2 - Low Power Mode //
// //
//////////////////////////////////////////////////////////////////////////
void SetTemicDongle(UINT UirPort,int Mode)
{
DEBUGMSG(ZONE_FIRMODE, (TEXT("SetTemicDongle -->\r\n")));
#ifdef UNDER_CE
//
// NOTE: This was the original code that works with the TEMIC dongles
// that I have. I don't want to disable ints and stall
// execution (for even 1ms).
//
switch (Mode) {
case 1:
// Set up the IRSL pins
NSC_WriteBankReg(UirPort,BANK7,7,0x28);
// Mode select
NSC_WriteBankReg(UirPort,BANK7,4,0x1);
// 64ns Tx pulse
NSC_WriteBankReg(UirPort,BANK7,4,0x81);
delay(20);
// Mode select off
NSC_WriteBankReg(UirPort,BANK7,4,0x80);
break;
case 0:
NSC_WriteBankReg(UirPort,BANK7,7,0x28);
NSC_WriteBankReg(UirPort,BANK7,4,0x81);
delay(50);
NSC_WriteBankReg(UirPort,BANK7,4,0x80);
break;
case 2:
NSC_WriteBankReg(UirPort,BANK7,7,0x28);
NSC_WriteBankReg(UirPort,BANK7,4,0x1);
break;
default:
break;
}
#else // UNDER_CE
UCHAR ucIsExtendedMode, ucIER, ucVal, ucLSR, i = 0;
_disable();
ucIsExtendedMode = (NSC_ReadBankReg(UirPort, 2, 2) & 0x01);
if ( !ucIsExtendedMode ) {
//
// Disable ints.
//
ucIER = GetCOMPort(UirPort, INT_ENABLE_REG_OFFSET);
SetCOMPort(UirPort, INT_ENABLE_REG_OFFSET, ALL_INTS_DISABLE);
}
switch( Mode ) {
case 0:
NSC_WriteBankReg(UirPort, BANK7, 7, 0x28);
// Make sure the Tx line is low
NSC_WriteBankReg(UirPort, BANK7, 4, 0x00);
NdisStallExecution(10);
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
// Trigger the Bandwidth line from high to low
NSC_WriteBankReg(UirPort, BANK7, 4, 0x01);
NdisStallExecution( 20 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
NSC_WriteBankReg(UirPort,BANK7,4,0x06);
NdisStallExecution( 1000 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
break;
case 1:
NSC_WriteBankReg(UirPort, BANK7, 7, 0x28);
NSC_WriteBankReg(UirPort, BANK7, 4, 0x01);
NdisStallExecution( 20 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
NSC_WriteBankReg(UirPort, BANK7, 4, 0x81);
// NdisStallExecution( 20 );
NdisStallExecution(10);
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
NSC_WriteBankReg(UirPort, BANK7, 4, 0x86);
NdisStallExecution( 1000 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
break;
case 2:
NSC_WriteBankReg(UirPort, BANK7, 7, 0x28);
NSC_WriteBankReg(UirPort, BANK7, 4, 0x1);
break;
default:
break;
}
if ( !ucIsExtendedMode ) {
//
// Make sure no extraneous characters in rx fifo.
// (Should be in Bank 0)
//
for ( i=0 ; i <= 254 ; i++ ) {
ucLSR = GetCOMPort(UirPort, LINE_STAT_REG_OFFSET);
if (ucLSR & LINESTAT_DATAREADY)
ucVal = GetCOMPort(UirPort, XFER_REG_OFFSET);
}
SetCOMPort(UirPort, INT_ENABLE_REG_OFFSET, ucIER);
}
_enable();
DEBUGMSG(ZONE_FIRMODE, (TEXT("SetTemicDongle <--\r\n")));
#endif // !UNDER_CE
}
//////////////////////////////////////////////////////////////////////////
// //
// Function: SetDellDongle //
// //
// Description: //
// Set the Dell Transceiver mode //
// Mode = 0 - SIR, MIR //
// Mode = 1 - FIR //
// Mode = 2 - Low Power Mode //
// //
//////////////////////////////////////////////////////////////////////////
void SetDellDongle(UINT UirPort,int Mode)
{
UCHAR ucIsExtendedMode, ucIER, ucVal, ucLSR, i = 0;
DEBUGMSG(ZONE_FIRMODE, (TEXT("SetDellDongle -->\r\n")));
#ifndef UNDER_CE
_disable();
#endif // !UNDER_CE
ucIsExtendedMode = (NSC_ReadBankReg(UirPort, 2, 2) & 0x01);
if ( !ucIsExtendedMode ) {
//
// Disable ints.
//
ucIER = GetCOMPort(UirPort, INT_ENABLE_REG_OFFSET);
SetCOMPort(UirPort, INT_ENABLE_REG_OFFSET, ALL_INTS_DISABLE);
}
switch( Mode ) {
case 0:
NSC_WriteBankReg(UirPort,BANK7,7,0x28);
NSC_WriteBankReg(UirPort,BANK7,4,0x02);
NdisStallExecution( 20 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
NSC_WriteBankReg(UirPort, BANK7, 4, 0x00);
NdisStallExecution( 1000 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
break;
case 1:
NSC_WriteBankReg(UirPort, BANK7, 7, 0x28);
NSC_WriteBankReg(UirPort, BANK7, 4, 0x2);
NdisStallExecution( 20 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
NSC_WriteBankReg(UirPort, BANK7, 4, 0x82);
NdisStallExecution( 20 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
NSC_WriteBankReg(UirPort, BANK7, 4, 0x80);
NdisStallExecution( 1000 );
#ifdef OUTMSG
RETAILMSG(1,(TEXT("NdisStallExecution\r\n")));
#endif
break;
case 2:
NSC_WriteBankReg(UirPort, BANK7, 7, 0x28);
NSC_WriteBankReg(UirPort, BANK7, 4, 0x2);
break;
default:
break;
}
if ( !ucIsExtendedMode ) {
//
// Make sure no extraneous characters in rx fifo.
// (Should be in Bank 0)
//
for ( i=0 ; i <= 254 ; i++ ) {
ucLSR = GetCOMPort(UirPort, LINE_STAT_REG_OFFSET);
if (ucLSR & LINESTAT_DATAREADY)
ucVal = GetCOMPort(UirPort, XFER_REG_OFFSET);
}
SetCOMPort(UirPort, INT_ENABLE_REG_OFFSET, ucIER);
}
#ifndef UNDER_CE
_enable();
#endif // !UNDER_CE
DEBUGMSG(ZONE_FIRMODE, (TEXT("SetDellDongle <--\r\n")));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -