ZHCAB53B December 2020 – February 2024 DP83TG720R-Q1 , DP83TG720S-Q1
额外迟滞的示例代码:
cyg_uint8 TI_DP83TG720::GetSQI() {
static cyg_uint16 first_time = 1;
static cyg_uint16 prevSQI = 0;
cyg_uint16 regValue;
cyg_uint16 reg_link;
cyg_uint16 mse_lock;
cyg_uint16 currSQI;
cyg_uint16 result;
static cyg_uint32 mse_iir = 0;
cyg_uint16 mse_out;
reg_link = ReadRegister(0x1F, 0x0180);
regValue = ReadRegister(0x1F, 0x0875);
mse_lock = (regValue & 0x3FF);
if (first_time == 1) {
mse_iir = mse_lock << 8;
}
else {
mse_iir = mse_lock + mse_iir - ((mse_iir + 128) >> 8);
}
mse_out = (mse_iir + 128) >> 8;
//comparison without hysterisis
if ((first_time == 1) && ((reg_link & 0x3007) == 0x3007)){
if (mse_out >= 0x5E) {
currSQI = 0x1; }
else if (mse_out >= 0x4E) {
currSQI = 0x2; }
else if (mse_out >= 0x3E) {
currSQI = 0x3; }
else if (mse_out >= 0x2B) {
currSQI = 0x4; }
else if (mse_out >= 0x1E) {
currSQI = 0x5; }
else if (mse_out >= 0xD) {
currSQI = 0x6; }
else {
currSQI = 0x7; }
first_time = 0;
}
//comparison with hysterisis
else if ((first_time == 0) && ((reg_link & 0x3007) == 0x3007)){
if (prevSQI == 0x1) {
if (mse_out < 0x5E) //threshold1_down
{
currSQI = 0x2; }
else {
currSQI = 0x1; } }
else if (prevSQI == 0x2) {
if (mse_out < 0x4E) //threshold2_down
{
currSQI = 0x3; }
else if (mse_out > 0x67) //threshold2_up
{
currSQI = 0x1; }
else {
currSQI = 0x2; } }
else if (prevSQI == 0x3) {
if (mse_out < 0x3E) //threshold3_down
{
currSQI = 0x4; }
else if (mse_out > 0x56) //threshold3_up
{
currSQI = 0x2; }
else {
currSQI = 0x3; } }
else if (prevSQI == 0x4) {
if (mse_out < 0x2B) //threshold4_down
{
currSQI = 0x5; }
else if (mse_out > 0x46) //threshold4_up
{
currSQI = 0x3; }
else {
currSQI = 0x4; } }
else if (prevSQI == 0x5) {
if (mse_out < 0x1E) //threshold5_down
{
currSQI = 0x6; }
else if (mse_out > 0x36) //threshold5_up
{
currSQI = 0x4; }
else {
currSQI = 0x5; } }
else if (prevSQI == 0x6) {
if (mse_out < 0xD) //threshold6_down
{
currSQI = 0x7; }
else if (mse_out > 0x26) //threshold6_up
{
currSQI = 0x5; }
else {
currSQI = 0x6; } }
else if (prevSQI == 0x7) {
if (mse_out > 0x16) //threshold7_up
{
currSQI = 0x6; }
else {
currSQI = 0x7; } }
else {
currSQI = prevSQI; }
}
//sqi at link-loss
else {
first_time = 1;
currSQI = 0x0;
}
result = currSQI;
prevSQI = result;
return static_cast<cyg_uint8>(result);
}