static void SimpleBLEPeripheral_performPeriodicTask(void)//1mSÒ»´Î { unsigned char i; static unsigned char MS=200,MS200=5,SEC=10,MIN=60,Value; if(SampleCnt>=9) { if(ConnectStatus == GAPROLE_CONNECTED) DealBlueNotifyPacket(BLUE_CMD_HEART); for(i=0;i<18;i++) CurBuf[i]=0; SampleCnt = 0; } if(--MS) return; MS = 200; if(--MS200) return; MS200 = 5; //HalLedSet(LED_PIN,Value = Value ? 0 : 1); if(--SEC) return; SEC = 10; CurCnt=0; if(--MIN) return; MIN = 60; if(1)//µç³Ø²âÊÔ { // Read the battery voltage (V), only the first 12 bits uint32_t percent = AONBatMonBatteryVoltageGet(); // Convert to from V to mV to avoid fractions. // Fractional part is in the lower 8 bits thus converting is done as follows: // (1/256)/(1/1000) = 1000/256 = 125/32 // This is done most effectively by multiplying by 125 and then shifting // 5 bits to the right. percent = (percent * 125) >> 5; // Convert to percentage of maximum voltage. //percent = ((percent* 100) / BATT_MAX_VOLTAGE); percent = 100 * (percent -3000) / (BATT_MAX_VOLTAGE - 3000); if(percent > 100) percent = 100; Battery = percent; } DealBlueNotifyPacket(BLUE_CMD_BATTERY); } void gpt1_int_handle(void) { static unsigned int Value,MsCnt; long val0; short val1; TimerIntClear(GPT1_BASE,TIMER_TIMA_TIMEOUT); if(MsCnt++>1000) { HalLedSet(LED_PIN,Value = Value ? 0 : 1); MsCnt = 0; } if(PeriodCount++>(SamplePeriod-1)) { PeriodCount = 0; CurAvgVal=ADS1248ReadData(); ADS1248SetStart(1); ADS1248SetStart(0); val0 = CurAvgVal; val0 = val0 >> 8; if(SampleCnt<9) { val1 = val0; CurBuf[SampleCnt*2]= val1>>8; CurBuf[SampleCnt*2+1]= val1; SampleCnt++; } } }