| | |
| | | int sprintftime = 0; |
| | | int putstrtime = 0; |
| | | const unsigned char buf1[16]={0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x00}; |
| | | char str1[256]; |
| | | char str1[128]; |
| | | int LineCount=0; |
| | | int Uart1baudval=0; |
| | | int Uart2baudval=0; |
| | |
| | | |
| | | int ShowInitInfo() |
| | | { |
| | | /* |
| | | int len1=0; |
| | | clearscreen(); |
| | | uint32_t us1,us2,us3,us4,us5,us6; |
| | | |
| | | // Locate(1,1); |
| | | |
| | | /* |
| | | LoadFlashDatas(); |
| | | |
| | | LoadAndUpdateStoreCfg(); |
| | | |
| | | HAL_StatusTypeDef res; |
| | | stStoreCfg * pFCfg = (stStoreCfg *) GetCurStoreCfgAddr(); |
| | | stStoreCfg * pFCfg2 = GetNextStoreCfgAddr(pFCfg); |
| | | |
| | | int t11=GetuS(); |
| | | |
| | | for (int i=0;i<20;i++) |
| | | { |
| | | tims[i]=GetuS(); |
| | | } |
| | | clearscreen(); |
| | | len1+=sprintf(str1+len1," Ver 001 \r\n"); |
| | | len1+=sprintf(str1+len1," Uart1Baud %d Uart2Baud %d UID %08x %08x %08x \r\n",Uart1Baud,Uart2Baud,pUID[0],pUID[1],pUID[2]); |
| | | len1+=sprintf(str1+len1," Flash = %d %d %d %d res = %d ",FlashDatas[0],FlashDatas[1],FlashDatas[2],FlashDatas[3],res); |
| | | len1+=sprintf(str1+len1,"flash operation = %u %u %u\r\n",t11-t10,t10,t11); |
| | | PutStr(str1,len1); |
| | | len1=0; |
| | | len1+=sprintf(str1+len1,"%08X %X %X , PowerOn %X UpTime %X %X %X %X \r\n", |
| | | (uint32_t)pFCfg,pFCfg[0].Sign1,pFCfg[0].SN1,pFCfg[0].PowerCount,pFCfg[0].UpTime,pFCfg[0].UserData1,pFCfg[0].CRC1,pFCfg[0].EndSign1); |
| | | len1+=sprintf(str1+len1,"%08X %X %X , PowerOn %X UpTime %X %X %X %X \r\n", |
| | | (uint32_t)pFCfg2,Cfg2.Sign1,Cfg2.SN1,Cfg2.PowerCount,Cfg2.UpTime,Cfg2.UserData1,Cfg2.CRC1,Cfg2.EndSign1); |
| | | PutStr(str1,len1); |
| | | */ |
| | | len1=0; |
| | | /* |
| | | for (int i=0;i<8;i++) |
| | | { |
| | | len1=0; |
| | | len1+=sprintf(str1+len1,"%02X:",i*32); |
| | | for (int j=0;j<8;j++) |
| | | { |
| | | len1+=sprintf(str1+len1," %02X",pFlash1[i*32+j]); |
| | | } |
| | | len1+=sprintf(str1+len1," %02X",pFlash1[i*32+8]); |
| | | for (int j=9;j<16;j++) |
| | | { |
| | | len1+=sprintf(str1+len1," %02X",pFlash1[i*32+j]); |
| | | } |
| | | len1+=sprintf(str1+len1," | %02X",pFlash1[i*32+16]); |
| | | for (int j=17;j<24;j++) |
| | | { |
| | | len1+=sprintf(str1+len1," %02X",pFlash1[i*32+j]); |
| | | } |
| | | len1+=sprintf(str1+len1," %02X",pFlash1[i*32+24]); |
| | | for (int j=25;j<32;j++) |
| | | { |
| | | len1+=sprintf(str1+len1," %02X",pFlash1[i*32+j]); |
| | | } |
| | | len1+=sprintf(str1+len1,"\r\n"); |
| | | PutStr(str1,len1); |
| | | } |
| | | */ |
| | | us1=GetuS(); |
| | | int crc1 = crc_check(buf1,16); //7us |
| | | us2=GetuS(); |
| | |
| | | // RunTimer(0,1000); |
| | | // StartTimer(2,1000); |
| | | Locate(13,1);LineCount=3; |
| | | */ |
| | | return 0; |
| | | } |
| | | |
| | |
| | | int timeus1; |
| | | int timeus2; |
| | | |
| | | len1=sprintf((char *)str1," N %8d Tk %8d %9u CFG %02X R %d M %d S %d %4d IN %04X OUT %04X \r\n", |
| | | KMem.nRunCount, haltick, theUs, KMem.EffJumperSW, bKBusRepeater, bKBusMaster, bKBusSlave, Clk2, KMem.WX[0],KMem.WY[0]); |
| | | // len1=sprintf((char *)str1," N %8d Tk %8d %9u CFG %02X R %d M %d S %d %4d IN %04X OUT %04X \r\n", |
| | | // KMem.nRunCount, haltick, theUs, KMem.EffJumperSW, bKBusRepeater, bKBusMaster, bKBusSlave, Clk2, KMem.WX[0],KMem.WY[0]); |
| | | //len1=sprintf((char *)str1,"U%02X%02XA",x2,x2); |
| | | // Locate(10,1); |
| | | timeus1=GetuS(); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | #define AVGCount 8 |
| | | |
| | | int nCount5 = 0; |
| | | unsigned short ADC_TEMP[16] ={0}; |
| | | |
| | | int ADCProcess() |
| | | { |
| | |
| | | // 16 -- Temp --> 6 |
| | | // 17 -- Vref --> 7 |
| | | |
| | | uint16_t ADC_ConvertedValue=0; |
| | | |
| | | |
| | | uint16_t ADC_ConvertedValue=0; |
| | | static int CurChannel=LL_ADC_CHANNEL_0; |
| | | //static int waitcount = 0; |
| | | |
| | |
| | | if ((channels & LL_ADC_CHANNEL_0) == LL_ADC_CHANNEL_0) |
| | | { |
| | | KMem.ADCValues[0] = ADC_ConvertedValue; |
| | | nextchannel = LL_ADC_CHANNEL_8; |
| | | if (KMem.ADCValues[0] < 2200) |
| | | nextchannel = LL_ADC_CHANNEL_7; |
| | | if (KMem.ADCValues[0] < 1500) |
| | | { |
| | | PowerDownEvent=1; |
| | | }else |
| | | { |
| | | PowerDownEvent=0; |
| | | } |
| | | }else if ((channels & LL_ADC_CHANNEL_8) == LL_ADC_CHANNEL_8) |
| | | } |
| | | else if ((channels & LL_ADC_CHANNEL_7) == LL_ADC_CHANNEL_7) |
| | | { |
| | | KMem.ADCValues[2] = ADC_ConvertedValue; |
| | | ADC_TEMP[0] += ADC_ConvertedValue; |
| | | |
| | | |
| | | nextchannel = LL_ADC_CHANNEL_8; |
| | | } |
| | | else if ((channels & LL_ADC_CHANNEL_8) == LL_ADC_CHANNEL_8) |
| | | { |
| | | ADC_TEMP[1] += ADC_ConvertedValue; |
| | | |
| | | nCount5++; |
| | | |
| | | if (nCount5 >= AVGCount) { |
| | | |
| | | KMem.ADCValues[3] = ADC_TEMP[0]/AVGCount; |
| | | |
| | | KMem.ADCValues[4] = ADC_TEMP[1]/AVGCount; |
| | | ADC_TEMP[0]=0; |
| | | ADC_TEMP[1]=0; |
| | | nCount5 = 0 ; |
| | | |
| | | } |
| | | // KMem.ADCValues[3] = 255;//ADC_TEMP[0]/16; |
| | | // KMem.ADCValues[4] = 768; //ADC_TEMP[1]/16; |
| | | nextchannel = LL_ADC_CHANNEL_9; |
| | | |
| | | }else if ((channels & LL_ADC_CHANNEL_9) == LL_ADC_CHANNEL_9) |
| | | { |
| | | KMem.ADCValues[5] = ADC_ConvertedValue; |
| | | nextchannel = LL_ADC_CHANNEL_TEMPSENSOR; |
| | | |
| | | }else if ((channels & LL_ADC_CHANNEL_16) == LL_ADC_CHANNEL_16) |
| | |
| | | }else if ((channels & LL_ADC_CHANNEL_17) == LL_ADC_CHANNEL_17) |
| | | { |
| | | KMem.ADCValues[7] = ADC_ConvertedValue; |
| | | KMem.ADCValues[5] = *((unsigned short *)ADCrefAddr); |
| | | KMem.ADCValues[8] = *((unsigned short *)ADCrefAddr); |
| | | |
| | | nextchannel = LL_ADC_CHANNEL_0; |
| | | }else |