int main(void) { uint16_t tempSensor, battery; uint8_t capPushA, capPushB; uint8_t it=1; InitWDT(); InitCLOCK(); InitUART(); InitLED(); InitADC(); InitBuzzer(); InitCapPush(); EnableInterrupts(); while (1) { it--; if(it == 0) { it = 4; capPushA = senseCapPushA(); capPushB = senseCapPushB(); tempSensor = ReadTemp(); battery = ReadBattery(); MainLoop(capPushA, capPushB, tempSensor, battery); } SetupWDTToWakeUpCPU(2); // Wake up in 16 mS Sleep(); } return 0; }
int main(void) { sevenSegmentDisplay.Init(); InitBuzzer(); keyPad.Init(); uvLed.Init(); InitPauseSwitch(); realTimeClock.Init(); realTimeClock.RegisterRTCCallback(rtc_callback_function); sei(); inform_startup(); sevenSegmentDisplay.SetStandBy(true); while (1) { current_key = keyPad.GetPressedKey(); if (current_key != KEY_NONE) { delay_ms(250); ProcessKey(); } if(IsPauseSwitchOn() == true) { if (countDownTimerState == COUNT_DOWN_TIMER_STATE_STARTED) { PauseCountDownTimer(); } } else { if (countDownTimerState == COUNT_DOWN_TIMER_STATE_PAUSED) { StartCountDownTimer(); } } if (beepBuzz == true) { BeepBuzzer(); beepBuzz = false; } } }
/*-------------------------MAIN FUNCTION------------------------------ **********************************************************************/ int c_entry(void) { InitIR2110(); // Use for Driver PWM IC IR2110 // EnableIR2110(); DisableIR2110(); flag_soft_start = 1; #ifdef RUN_OK Delayms(3000); #endif // InitDAC(); // Initialize debug via UART0 // – 9600bps // – 8 data bit // – No parity // – 1 stop bit // – No flow control debug_frmwrk_init(); SetOutputDTR(); ClearDTR(); //data receive InitLedAlarmBattery(); InitLedAlarmOverload(); InitPWM(PWM_FREQUENCY,DEADTIME); SetDutyPWM(0,0); InitADC(ADC_FREQUENCY); InitTimerADCRead(); InitTimerProcessSinwave(); InitTimerProcessSensorRMSValue(); InitTimerMainProcess(); InitBuzzer(10000); #ifdef RUN_OK while(fist_startup) { if(f_Vin_RMS > VOLTAGE_MIN/*Vol*/) { flag_voltage_low = 0; flag_current_high = 0; fist_startup = 0; } } #endif while (1) { if ((LPC_UART1->LSR & UART_LSR_RDR)) { buff[0] = UART_ReceiveByte((LPC_UART_TypeDef *)LPC_UART1); if(buff[0] == 'I') { Delayms(100); SetDTR(); //data transmission printf_dbg("I,%d,\r",(uint32_t)(f_Vin_RMS*f_Iin_RMS)); Delayms(10); ClearDTR(); //data receive buff[0] = 0; } } } return 1; }