/*******************************************************************************
* Function Name : Analysis_PDO(void)
* Description : 解析PDO、PPS函数
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void Analysis_PDO(void)
{
UINT8 Temp;
UINT16 PDO_Value = 0;
if(RecvPDOFlag == 1){
LCD_Fill(0,0,159,12,CYAN);
LCD_DrawLine(0,0,159,0,CYAN);
LCD_DrawLine(0,0,0,127,CYAN);
LCD_DrawLine(159,0,159,127,CYAN);
LCD_DrawLine(0,127,159,127,CYAN);
if(Versions == 2) //判断PD版本
{
LCD_ShowString(3,0,"Power Delivery 3.0",BLACK,CYAN,12,0);
}else{
LCD_ShowString(3,0,"Power Delivery 2.0",BLACK,CYAN,12,0);
}
Union_Header = (_Union_Header *)PDO_BUF; //解析SourceCap
for(Temp=0;Temp<SourceCapNDO;Temp++)//pdo的档位
{
Union_SrcCap = (_Union_SrcCap*)(&PDO_BUF[2+(Temp*4)]);
if((Union_SrcCap->SrcCapStruct.DataH8>>6)== 0x00) //表示固定档
{
PDO_Value =((((Union_SrcCap->SrcCapStruct.VoltH4<<6)+( Union_SrcCap->SrcCapStruct.VoltL6))*50)/100);
if( PDO_Value/10 >= 10) //电压
{
LCD_ShowFloatNum1(108-7*6,(Temp+1)*12,(float)PDO_Value/10,4,CYAN,BLACK,12);
}else{
LCD_ShowFloatNum1(108-6*6,(Temp+1)*12,(float)PDO_Value/10,3,CYAN,BLACK,12);
}
PDO_Value=((((Union_SrcCap->SrcCapStruct.CurrentH2<<8)+( Union_SrcCap->SrcCapStruct.CurrentL8))*10)/10); //电流
LCD_ShowFloatNum1(120,(Temp+1)*12,(float)PDO_Value/100,3,CYAN,BLACK,12);
LCD_ShowString(108,(Temp+1)*12,"@",CYAN,BLACK,12,0);
LCD_ShowString(3,(Temp+1)*12,"< > Fix",CYAN,BLACK,12,0);
LCD_ShowIntNum(10,(Temp+1)*12,Temp+1,1,CYAN,BLACK,12);
LCD_ShowString(108-2*6,(Temp+1)*12,"V",CYAN,BLACK,12,0);
LCD_ShowString(145,(Temp+1)*12,"A",CYAN,BLACK,12,0);
}else if((Union_SrcCap->SrcCapStruct.DataH8>>6)== 0x03){//表示PPS
Union_PPS_SrcCap = (_Union_PPS_SrcCap*)(&PDO_BUF[2+(Temp*4)]); //转换为PPS
PDO_Value = (Union_PPS_SrcCap->SRC_Cap_PPS_Struct.VoltMin);
if(PDO_Value/10 >= 10)
{
LCD_ShowFloatNum1(111-10*6,(Temp+1)*12,(float)PDO_Value/10,4,CYAN,BLACK,12);
}else{
LCD_ShowFloatNum1(111-9*6,(Temp+1)*12,(float)PDO_Value/10,3,CYAN,BLACK,12);
}
PDO_Value = ((Union_PPS_SrcCap->SRC_Cap_PPS_Struct.VoltMaxH1<<7) + (Union_PPS_SrcCap->SRC_Cap_PPS_Struct.VoltMaxL7));
LCD_ShowString(75,(Temp+1)*12,"-",CYAN,BLACK,12,0);
if(PDO_Value/10 >= 10)
{
LCD_ShowFloatNum1(108-4*6,(Temp+1)*12,(float)PDO_Value/10,4,CYAN,BLACK,12);
}else{
LCD_ShowFloatNum1(108-3*6,(Temp+1)*12,(float)PDO_Value/10,3,CYAN,BLACK,12);
}
PDO_Value = ((Union_PPS_SrcCap->SRC_Cap_PPS_Struct.Current)*50)/10;
LCD_ShowFloatNum1(120,(Temp+1)*12,(float)PDO_Value/100,3,CYAN,BLACK,12);
LCD_ShowString(3,(Temp+1)*12,"< > PPS",CYAN,BLACK,12,0);
LCD_ShowIntNum(10,(Temp+1)*12,Temp+1,1,CYAN,BLACK,12);
LCD_ShowString(108,(Temp+1)*12,"V",CYAN,BLACK,12,0);
LCD_ShowString(145,(Temp+1)*12,"A",CYAN,BLACK,12,0);
}
}
LCD_ShowString(44,(Temp+2)*12-6,"Fixed",BLACK,CYAN,12,0);
LCD_ShowString(92,(Temp+2)*12-6,"PPS",CYAN,BLACK,12,0);
RecvPDOFlag = 0;
}
}
因A口协议属于未公开状态,本次将不进行讲解。有兴趣的小伙伴可以多了解一下,附送一张QC2.0的协议规范。