📄 card.h
字号:
# define HTDSU_STATUS_OUT_OF_FRAME 0x0020
# define HTDSU_STATUS_OUT_OF_SERVICE 0x0040
# define HTDSU_STATUS_NO_SIGNAL 0x0080
# define HTDSU_STATUS_NO_CURRENT 0x0100
# define HTDSU_STATUS_NO_DIAL_TONE 0x0200
# define HTDSU_STATUS_ON_LINE 0x0400
# define HTDSU_STATUS_NO_ANSWER 0x0800
# define HTDSU_STATUS_CARRIER_DETECT 0x1000
# define HTDSU_STATUS_RINGING 0x2000
# define HTDSU_STATUS_REMOTE_RESPONSE 0x4000
USHORT StatusLine1;
USHORT StatusLine2;
/* 0xFEA, 0xFEC
// The error counter registers are used when running the command:
// HTDSU_CMD_REMOTETP_LOOPBACK. The counters are incremented if a
// test pattern error is detected, and they are reset when the test
// is terminated.
*/
#define HTDSU_ERROR_COPROCESSOR 0x0800
#define HTDSU_ERROR_DSU2 0x1000
#define HTDSU_ERROR_DSU1 0x2000
#define HTDSU_ERROR_LOW_BYTE 0x4000
#define HTDSU_ERROR_HIGH_BYTE 0x8000
USHORT ErrorsLine1;
USHORT ErrorsLine2;
/* 0xFEE
// The adapter firmware sets test SelfTestStatus register if it detects
// an error during the HTDSU_CMD_SELFTEST command. Otherwise this register
// is reset to zero.
*/
#define HTDSU_SELFTEST_OK (HTDSU_ERROR_HIGH_BYTE | \
HTDSU_ERROR_LOW_BYTE | \
HTDSU_ERROR_COPROCESSOR)
#define HTDSU_SELFTEST_TIMEOUT 40000 // 4 seconds.
USHORT SelfTestStatus;
/* 0xFF0
// Reserved hardware register.
*/
USHORT Reserved2;
/* 0xFF2
// DSU serial number.
*/
USHORT SerialNumber;
/* 0xFF4
// Co-processor firmware checksum.
*/
USHORT CoProcessorCheckSum;
/* 0xFF6
// DSU firmware checksum.
*/
USHORT DsuCheckSum;
/* 0xFF8
// Co-processor firmware version.
*/
# define HTDSU_COPROCESSOR_VERSION 0x0340
USHORT CoProcessorVersion;
/* 0xFFA
// DSU firmware version.
*/
# define HTDSU_DSU_VERSION 0x0013
USHORT DsuVersion;
/* 0xFFC
// DSU hardware ID.
*/
# define HTDSU_DSU_ID 0x0050
USHORT DsuId;
/* 0xFFE
// Co-processor ID.
*/
# define HTDSU_COPROCESSOR_ID 0x0060
USHORT CoProcessorId;
} HTDSU_REGISTERS, * PHTDSU_REGISTERS;
/*
// Turn off structure packing.
*/
#include <poppack.h>
/*
// The adapter memory structure must be sized the same as the hardware!
*/
#define HTDSU_MEMORY_SIZE sizeof(HTDSU_REGISTERS)
/*
// Enable the currently accepted interrupts on the adapter.
*/
#define CardEnableInterrupt(Adapter) \
{WRITE_REGISTER_USHORT(&Adapter->AdapterRam->InterruptEnable, \
Adapter->InterruptEnableFlag);}
/*
// Disable all interrupts on the adapter.
*/
#define CardDisableInterrupt(Adapter) \
{WRITE_REGISTER_USHORT(&Adapter->AdapterRam->InterruptEnable, \
HTDSU_INTR_DISABLE);}
/*
// Clear all the current interrupts on the adapter.
*/
#define CardClearInterrupt(Adapter) \
{WRITE_REGISTER_USHORT(&Adapter->AdapterRam->InterruptClear, 1);}
/*
// Return TRUE if all interrupts are disabled on the adapter.
*/
#define CardAreInterruptsDisabled(Adapter) \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->InterruptEnable) == \
HTDSU_INTR_DISABLE)
/*
// Return the current interrupt status from the adapter.
*/
#define CardGetInterrupt(Adapter) \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->InterruptStatus))
/*
// Start sending the current packet out.
*/
#define CardStartTransmit(Adapter) \
{WRITE_REGISTER_USHORT(&Adapter->AdapterRam->TxDataEmpty, 0);}
/*
// Return non-zero if transmit buffer is empty
*/
#define CardTransmitEmpty(Adapter) \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->TxDataEmpty))
/*
// Tell the adapter we're done with the packet just received.
*/
#define CardReceiveAvailable(Adapter) \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->RxDataAvailable))
/*
// Tell the adapter we're done with the packet just received.
*/
#define CardReceiveComplete(Adapter) \
{WRITE_REGISTER_USHORT(&Adapter->AdapterRam->RxDataAvailable, 0);}
/*
// Tell the adapter to pick up the line.
*/
#define CardLineAnswer(Adapter, CardLine) \
CardDoCommand(Adapter, CardLine, HTDSU_CMD_ANSWER)
/*
// Return non-zero if remote unit has responded to ring from this line.
*/
#define CardStatusRingBack(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_REMOTE_RESPONSE) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_REMOTE_RESPONSE) \
)
/*
// Return non-zero if this phone line is ringing.
*/
#define CardStatusRinging(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_RINGING) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_RINGING) \
)
/*
// Return non-zero if this line has detected a carrier signal.
*/
#define CardStatusCarrierDetect(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_CARRIER_DETECT) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_CARRIER_DETECT) \
)
/*
// Return non-zero if the number we dialed on this line did not answer.
*/
#define CardStatusNoAnswer(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_NO_ANSWER) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_NO_ANSWER) \
)
/*
// Return non-zero if the selected line is ready to use.
*/
#define CardStatusOnLine(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_ON_LINE) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_ON_LINE) \
)
/*
// Return non-zero if no dial tone is present on this line.
*/
#define CardStatusNoDialTone(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_NO_DIAL_TONE) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_NO_DIAL_TONE) \
)
/*
// Return non-zero if this line has no sealing current.
*/
#define CardStatusNoCurrent(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_NO_CURRENT) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_NO_CURRENT) \
)
/*
// Return non-zero if this line has no signal present.
*/
#define CardStatusNoSignal(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_NO_SIGNAL) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_NO_SIGNAL) \
)
/*
// Return non-zero if this line has been placed out of service by the switch.
*/
#define CardStatusOutOfService(Adapter, CardLine) \
((CardLine == HTDSU_CMD_LINE1) ? \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine1) & \
HTDSU_STATUS_OUT_OF_SERVICE) : \
(READ_REGISTER_USHORT(&Adapter->AdapterRam->StatusLine2) & \
HTDSU_STATUS_OUT_OF_SERVICE) \
)
#endif // _CARD_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -