int main(void) { DO_TEST_HARNESS_PRE_INIT(); setupIO(); setupADC(); setupTimer(); setupStateMachine(); pAverager = AVERAGER_GetAverager(U16, BUFFER_SIZE); sei(); WD_DISABLE(); DO_TEST_HARNESS_POST_INIT(); while (true) { DO_TEST_HARNESS_RUNNING(); if (ADC_TestAndClear(&adc)) { adcHandler(); } if (TMR8_Tick_TestAndClear(&appTick)) { applicationTick(); } } return 0; }
int main(void) { DO_TEST_HARNESS_SETUP(); WD_DISABLE(); setupIO(); readTestMode(); setupTimers(); smIndex = setupStateMachine(); TS_Setup(); Threshold_Init(); Filter_Init(); Flush_Reset(); COMMS_Init(); sei(); runNormalApplication(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // slot that is used to determine what the user typed in and if it is a valid command connect(ui->lineEdit, SIGNAL(editingFinished()), this, SLOT(someSlot())); // sets up the state machine so that later in the program, we just have to move between states // instead of having to figure out what to do every time setupStateMachine(); // load data from the SQL database, this is mostly information that is easier to manage in // SQL. Things like adjacent tiles to every tile, tile/room descriptions and so on. readSQL(); }
int main(void) { /* Disable watchdog: not required for this application */ MCUSR &= ~(1 << WDRF); wdt_disable(); setupStateMachine(); setupTimer(); setupIO(); initialiseMap(); UART_Init(UART0, 9600, 32, 32, false); I2C_SetPrescaler(64); DS3231_Init(); UC_BTN_Init(APP_TICK_MS); TLC5916_Init(&tlc, SR_ShiftOut, tlcLatchFn, tlcOEFn); TLC5916_OutputEnable(&tlc, true); uint8_t displayBytes[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; TLC5916_ClockOut(displayBytes, 10, &tlc); /* All processing interrupt based from here */ sei(); /* First get the time from the DS3231. * Don't worry about the state machine or any events, just get the time * and see if it's greater than the compile time */ DS3231_ReadDeviceDateTime(NULL); while ( !DS3231_IsIdle() ) { I2C_Task(); } DS3231_GetDateTime(&tm); DS3231_SetRate(DS3231_RATE_1HZ); DS3231_SQWINTControl(DS3231_SQW); DS3231_UpdateControl(); while ( !DS3231_IsIdle() ) { I2C_Task(); } s_unixtime = time_to_unix_seconds(&tm); if (s_unixtime < COMPILE_TIME_INT) { TM compile_time = COMPILE_TIME_STRUCT; DS3231_SetDeviceDateTime(&compile_time, false, NULL); while ( !DS3231_IsIdle() ) { I2C_Task(); } s_unixtime = COMPILE_TIME_INT; } updateUnixTimeDigits(); //putTimeToUART(); s_displayDirty = true; while (true) { if (TMR8_Tick_TestAndClear(&appTick)) { applicationTick(); } if (TMR8_Tick_TestAndClear(&heartbeatTick)) { s_BlinkState = !s_BlinkState; s_displayDirty |= true; } if (PCINT_TestAndClear(secondTickVector)) { s_bTick = !s_bTick; if (s_bTick && (SM_GetState(&sm) == (SM_STATEID)DISPLAY)) { s_unixtime++; updateUnixTimeDigits(); s_displayDirty |= true; } for(uint8_t i = 0; i < (uint8_t)SM_GetState(&sm); ++i) { //IO_Control(HB_PORT, HB_PIN, IO_OFF); //IO_Control(HB_PORT, HB_PIN, IO_ON); } } if (s_displayDirty) { updateDisplay(); s_displayDirty |= false; } I2C_Task(); } }