CH579 Temperature sensor

Need to measure chip temperature and found two implementations of ADC_GetCurrentTS function. The first is:

UINT8?ADC_GetCurrentTS(?UINT16?ts_v?)
{
????UINT16??vol_ts;
????UINT16??D85_tem,?D85_vol,?D25;
????
????vol_ts?=?(ts_v*1060)>>11;
????D85_tem?=?(UINT16)((*((PUINT32)ROM_TMP_85C_ADDR)>>16)&0x00ff);?
????D85_vol?=?*((PUINT16)ROM_TMP_85C_ADDR);
????D25?=?*((PUINT32)ROM_TMP_25C_ADDR);
????
????
????return?(?D85_tem?-?(?D85_vol?-?vol_ts?+?8?)?*?16?/?D25?);
}

The second is:

int?ADC_GetCurrentTS(?UINT16?ts_v?)
{
????UINT16??vol_ts;
????UINT16??D85_tem,?D85_vol;
????UINT16??D25_tem,?D25_vol;
????UINT16??temperK;
????UINT32??temp;
????UINT8???sum,?sumck;
????int?????cal;????
????
????temperK?=?64;????//?mV/16^C
????vol_ts?=?(ts_v*1060)>>11;
????temp?=?(*((PUINT32)ROM_TMP_25C_ADDR));
????D25_tem?=?temp;
????D25_vol?=?(temp>>16);
????
????if(?D25_vol?!=?0?){?//?????????????
????????//?T?=?T85?+?(V-V85)*16/D25
????????cal?=??(D25_tem*temperK?+?vol_ts*16?+?(temperK>>1)?-?D25_vol*16)?/?temperK?;????
????????return?(?cal?);
????}
????else{??//???????????????D25_tem??
????????temp?=?(*((PUINT32)ROM_TMP_85C_ADDR));?????
????????sum?=?(UINT8)(temp>>24);????????//?×???×???????????
????????sumck?=?(UINT8)(temp>>16);
????????sumck?+=?(UINT8)(temp>>8);
????????sumck?+=?(UINT8)temp;
????????if(?sum?!=?sumck?)????????return?0xff;????????//????é?????í
????????
????????temperK?=?D25_tem;??????//?D25_tem?=?temperK?
????????D85_tem?=?(UINT16)((temp>>16)&0x00ff);?
????????D85_vol?=?(UINT16)temp;?
????????
????????//?T?=?T85?+?(V-V85)*16/D25
????????cal?=??(D85_tem*temperK?+?vol_ts*16?+?(temperK>>1)?-?D85_vol*16)?/?temperK?;????
????????return?(?cal?);??
????}
}

Which is better/more correct?


第二種是最新的,參考第二種


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频