void LoadConfig() { cfg_Init("verge.cfg"); cfg_SetDefaultKeyValue("startmap", ""); if (cfg_KeyPresent("xres")) v3_xres = cfg_GetIntKeyValue("xres"); if (cfg_KeyPresent("yres")) v3_yres = cfg_GetIntKeyValue("yres"); // Overkill (2010-04-29): Scaling policies. if (cfg_KeyPresent("scalewin")) { int value = cfg_GetIntKeyValue("scalewin"); if(value >= 0 && value < SCALE_FORMAT_COUNT) { v3_scale_win = (ScaleFormat) value; } } if (cfg_KeyPresent("scalefull")) { int value = cfg_GetIntKeyValue("scalefull"); if(value >= 0 && value < SCALE_FORMAT_COUNT) { v3_scale_full = (ScaleFormat) value; } } if (cfg_KeyPresent("window_x_res")) v3_window_xres = cfg_GetIntKeyValue("window_x_res"); if (cfg_KeyPresent("window_y_res")) v3_window_yres = cfg_GetIntKeyValue("window_y_res"); if (cfg_KeyPresent("windowmode")) windowmode = cfg_GetIntKeyValue("windowmode") ? true : false; if (cfg_KeyPresent("nosound")) sound = cfg_GetIntKeyValue("nosound") ? false : true; if (cfg_KeyPresent("soundengine")) soundengine = cfg_GetIntKeyValue("soundengine"); if (cfg_KeyPresent("automax")) automax = cfg_GetIntKeyValue("automax") ? true : false; if (cfg_KeyPresent("startmap")) strcpy(mapname, cfg_GetKeyValue("startmap")); if (cfg_KeyPresent("appname")) setWindowTitle(cfg_GetKeyValue("appname")); if (cfg_KeyPresent("gamerate")) gamerate = cfg_GetIntKeyValue("gamerate"); if (cfg_KeyPresent("v3isuberlikethetens")) cheats = true; if (cfg_KeyPresent("editcode")) editcode = cfg_GetIntKeyValue("editcode") ? true : false; if (cfg_KeyPresent("logconsole")) { logconsole = true; initConsole(); } else if (cfg_KeyPresent("logconsole-normalstdout")) { logconsole = true; } void platform_ProcessConfig(); platform_ProcessConfig(); }
int main() { // This is needed for FreeRTOS. NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); InitDebug(); cfg_Init( ); PolePosition_Init(); // This MUST be initialized before fullCAN MotorPosition_Init(FEEDBACK_POLE_POSITION); fullCAN_Init( 1000000, cfg_GetControllerID() ); if ( cfg_GetControllerID() == 0) { fullCAN_SetTerminationState(ENABLE); } else { fullCAN_SetTerminationState(DISABLE); } d1k_STDIO_CAN_Init( CAN2, fullCAN_GetControllerId() + FULLCAN_IDBASE_STDIO_TX, fullCAN_GetControllerId() + FULLCAN_IDBASE_STDIO_RX ); d1k_portal_Init( ); ControlLoopInit(); InitLEDs( ); adc_Init( 100000 ); motor_Init( ); fault_Init( ); diag_Init( ); fan_Init( ); fan_SetDutyCycle( 1.0f ); printf("fullStartup! Controller: %u\r\n", (uint16)fullCAN_GetControllerId()); vTaskStartScheduler( ); }