void show_ddmi (void) { FloatOrUInt calibration_tx; FloatOrUInt calibration_rx; dev_control (dev_sfp, dev_on); Delayms(400); if(SFP_Init()) { Delayms(50); float buffer2[16][5]; float buffer[5]; float current_tx=0; float current_rx=0; SFP_READ_DDMI_All_float(buffer); current_tx = buffer[3]; current_rx = buffer[4]; for (int i=0;i<16;i++) { SFP_READ_DDMI_All_float(buffer); //if((buffer[3] < (current_tx+current_tx*0.005)) || (buffer[3] > (current_tx-current_tx*0.005))) current_tx=buffer[3]; if((buffer[4] < (current_rx+current_rx*0.005)) || (buffer[4] > (current_rx-current_rx*0.005))) current_rx=buffer[4]; //Delayms(15); printf("TX: %2.3f dbm\n\r",current_tx); printf("RX: %2.3f dbm\n\r",current_rx); } buffer[3]=0.0; buffer[4]=0.0; for(int i=0;i<8;i++) { buffer[3]+=buffer2[i][3]; buffer[4]+=buffer2[i][4]; } buffer[3]/=8; buffer[4]/=8; } dev_control (dev_sfp, dev_off); GPIO_ResetBits(SFP_POWER_PORT, SFP_POWER); bkpram(GC_LOAD,calibration_tx.fInt,GC_CALIBRATION_TX,GC_CALIBRATION_LENGTH); bkpram(GC_LOAD,calibration_rx.fInt,GC_CALIBRATION_RX,GC_CALIBRATION_LENGTH); //printf("SFP Temperature: %02.2f\n\r",buffer[0]); //printf("SFP Voltage: %02.2f\n\r",buffer[1]); printf("%02.2f\n\r",buffer[3]-calibration_tx.f); //printf("SFP RX Power: %02.2f dbm\n\r",buffer[4]-calibration_rx.f); }
void SFP_READ_DDMI (SFP_Data* ddmi) { if(SFP_Init()==0){ ddmi->connected = 0; ddmi->temp = -500.0; ddmi->current = -500.0; ddmi->rx_power = -500.0; ddmi->rx_power_dbm = -500.0; ddmi->tx_power = -500.0; ddmi->tx_power_dbm = -500.0; ddmi->voltage = -500.0; } else { ddmi->connected = 1; ddmi->temp = SFP_READ_DDMI_Single_float(temperature); ddmi->voltage = SFP_READ_DDMI_Single_float(voltage); ddmi->current = SFP_READ_DDMI_Single_float(current); ddmi->tx_power = SFP_READ_DDMI_Single_float(tx_mw); ddmi->rx_power = SFP_READ_DDMI_Single_float(rx_mw); } }