void CheckTimeout(void) { char command[80]; int time; U64 nps; // Report search speed if (!(nodes % 1000000)) DisplaySpeed(); // We check for timeout or new commands only every so often, // to save some time, unless the engine is operating // in the weakening mode or has received "go nodes" command. // In that cases, we check for timeout as often as we can. if (!Timer.special_mode || Timer.nps_limit > 65535) { if (nodes & 4095 || root_depth == 1) return; } if (Timer.GetData(MAX_NODES) > 0 && nodes >= Timer.GetData(MAX_NODES) ) { abort_search = 1; return; } // Slowdown loop if (Timer.nps_limit && root_depth > 1) { time = Timer.GetElapsedTime() + 1; nps = GetNps(time); while ((int)nps > Timer.nps_limit) { Timer.WasteTime(10); time = Timer.GetElapsedTime() + 1; nps = GetNps(time); if (Timeout()) { abort_search = 1; return; } } } // Process commands that might terminatethe search if (InputAvailable()) { ReadLine(command, sizeof(command)); if (strcmp(command, "stop") == 0) abort_search = 1; else if (strcmp(command, "ponderhit") == 0) pondering = 0; } // Have we already used our allocated time? if (Timeout()) abort_search = 1; }
//***************************************************************************** // // The main loop for the user interface. // //***************************************************************************** int main(void) { unsigned long ulPanel; // // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is // a workaround to allow the PLL to operate reliably. // if(REVISION_IS_A2) { SysCtlLDOSet(SYSCTL_LDO_2_75V); } // // Set the clocking to run at 50MHz from the PLL. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Set the priority of the interrupts. // IntPrioritySet(INT_CAN0, 0x00); IntPrioritySet(FAULT_SYSTICK, 0x20); // // Configure SysTick to generate an interrupt every millisecond. // SysTickPeriodSet(SysCtlClockGet() / 1000); SysTickIntEnable(); SysTickEnable(); // // Initialize the push button driver. // ButtonsInit(); // // Initialize the CAN communication channel. // CANCommInit(); // // Initialize the UART used to perform a "firmware update". // UpdateUARTInit(); // // Initialize the display. // RIT128x96x4Init(3500000); // // Add the screen-clearing widget to the widget tree. As the first widget // in the tree, this will always be drawn first, resulting in a blank // screen before anything else is drawn. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground); // // Display the splash screen. // DisplaySplash(); // // Set the CAN device ID to one. // CANSetID(1); // // The "Voltage Control Mode" panel should be displayed first. // ulPanel = PANEL_VOLTAGE; // // Loop forever. // while(1) { // // Determine which panel to display. // switch(ulPanel) { // // The "Voltage Control Mode" panel should be displayed. // case PANEL_VOLTAGE: { ulPanel = DisplayVoltage(); break; } // // The "VComp Control Mode" panel should be displayed. // case PANEL_VCOMP: { ulPanel = DisplayVComp(); break; } // // The "Current Control Mode" panel should be displayed. // case PANEL_CURRENT: { ulPanel = DisplayCurrent(); break; } // // The "Speed Control Mode" panel should be displayed. // case PANEL_SPEED: { ulPanel = DisplaySpeed(); break; } // // The "Position Control Mode" panel should be displayed. // case PANEL_POSITION: { ulPanel = DisplayPosition(); break; } // // The "Configuration" panel should be displayed. // case PANEL_CONFIGURATION: { ulPanel = DisplayConfig(); break; } // // The "Device List" panel should be displayed. // case PANEL_DEV_LIST: { ulPanel = DisplayDevList(); break; } // // The "Firmware Update" panel should be displayed. // case PANEL_UPDATE: { ulPanel = DisplayUpdate(); break; } // // The "Help" panel should be displayed. // case PANEL_HELP: { ulPanel = DisplayHelp(); break; } // // The "About" panel should be displayed. // case PANEL_ABOUT: { ulPanel = DisplayAbout(); break; } } } }