extern "C" void Init_CoreAPI_Extension() { Init_System(); Init_Application(); Init_Network(); Init_SQLite3(); Init_Log(); #if defined(OS_MACOSX) || defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) || defined(OS_ANDROID) Init_WebView(); #elif defined(OS_WP8) Init_WebView_extension(); #endif #if defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) || (defined(OS_MACOSX) && defined(RHODES_EMULATOR)) || defined(OS_ANDROID) || defined(OS_MACOSX) Init_NativeToolbar(); Init_NativeTabbar(); #elif defined(OS_WP8) Init_NativeToolbar_extension(); Init_NativeTabbar_extension(); #endif #if (defined(OS_MACOSX) && !defined(RHODES_EMULATOR)) Init_Navbar(); #endif #if defined(OS_MACOSX) || defined(OS_ANDROID) Init_RhoFile(); #endif }
int main(int argc, char **argv) { int nRes = 0; #ifdef RUBY_DEBUG_ENV ruby_set_debug_option(getenv("RUBY_DEBUG")); #endif #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif // MessageBox(0,"","",MB_OK); ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); Init_strscan(); Init_sqlite3_api(); Init_SyncEngine(); Init_System(); //Init_prelude(); rb_define_global_function("__rho_compile", __rho_compile, 1); nRes = ruby_run_node(ruby_options(argc, argv)); } return nRes; }
void IOPMaster(UNSIGNED argc, VOID *argv) { STATUS status; int ch = 0; int i; unsigned long pci_id; /* Access argc and argv just to avoid compilation warnings. */ status = (STATUS) argc + (STATUS) argv; printf("\n\r"); printf("Executing the System Code....\n\r"); /* Initilaize the Hardware */ #ifdef INCLUDE_ODYSSEY if ((status = Init_Hardware()) != NU_SUCCESS) printf("Error in init %d\r\n", status); #else init_galileo(); #endif INCLUDE_ODYSSEY /* Spawn the rest of the tasks and initialize */ Init_System(&System_Memory); /* Lower the Priority of this task */ NU_Change_Priority( (NU_TASK *)&IOPMaster_Task, 250 ); /* Now this task will be active with lowest priority and can be used to * any cleanup required */ for(;;){ NU_Sleep(500); Cleanup_System(); /* rlw: can we implement erc91 functionality here? */ } }
extern "C" void Init_CoreAPI_Extension() { Init_System(); Init_Network(); Init_SQLite3(); #if defined(OS_MACOSX) || defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) || defined(OS_WP8) Init_Log(); #endif #if defined(OS_MACOSX) || defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) Init_WebView(); #endif }
void main(void) { // The 'while' operating system Init_System(); while(ALWAYS) { Display_Process(); Menu_Process(); ADC_Process(); CMD_Process(); } }
int main(int argc, char **argv) { int nRes = 0; //_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF); #ifdef RUBY_DEBUG_ENV ruby_set_debug_option(getenv("RUBY_DEBUG")); #endif #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif #ifdef WIN32 SetEnvironmentVariable("RUBYOPT",""); SetEnvironmentVariable("RUBYLIB",""); #endif //WIN32 // MessageBox(0,"","",MB_OK); ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); Init_strscan(); //Init_sqlite3_api(); Init_SyncEngine(); Init_System(); //Init_prelude(); rb_define_global_function("__rho_compile", __rho_compile, 1); nRes = ruby_run_node(ruby_options(argc, argv)); } return nRes; }
void main(void) { uint16_t i ; Init_System(); // 系统初始化 // _EINT(); // 开总中断 //__bis_SR_register(LPM3_bits); //进入LPM3 P1OUT |= BIT0; P8OUT |= BIT1; Init_Key(); while(1) { if( Read_Key1() ) { P1OUT ^= BIT0; } if(Read_Key2()) { P8OUT ^= BIT1; } } }
void Initialize( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, output_controls *out_control, mpi_datatypes *mpi_data, MPI_Comm comm ) { char msg[MAX_STR]; if( Init_MPI_Datatypes(system, workspace, mpi_data, comm, msg) == FAILURE ) { fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n", system->my_rank ); fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: initialized mpi datatypes\n", system->my_rank ); #endif if( Init_System(system, control, msg) == FAILURE ){ fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: system could not be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: system initialized\n", system->my_rank ); #endif if( Init_Simulation_Data( system, control, data, msg ) == FAILURE ) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: initialized simulation data\n", system->my_rank ); #endif if( Init_Workspace( system, control, workspace, mpi_data->world, msg ) == FAILURE ) { fprintf( stderr, "p%d:init_workspace: not enough memory\n", system->my_rank ); fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: initialized workspace\n", system->my_rank ); #endif if( Init_Lists( system, control, data, workspace, lists, mpi_data, msg ) == FAILURE ) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: system could not be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: initialized lists\n", system->my_rank ); #endif if( Init_Output_Files(system,control,out_control,mpi_data,msg)== FAILURE) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: could not open output files! terminating...\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: output files opened\n", system->my_rank ); #endif if( control->tabulate ) { if( Init_Lookup_Tables( system, control, workspace, mpi_data, msg ) == FAILURE ) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } #if defined(DEBUG) fprintf( stderr, "p%d: initialized lookup tables\n", system->my_rank ); #endif } Init_Force_Functions( control ); #if defined(DEBUG) fprintf( stderr, "p%d: initialized force functions\n", system->my_rank ); #endif /*#if defined(TEST_FORCES) Init_Force_Test_Functions(); fprintf(stderr,"p%d: initialized force test functions\n",system->my_rank); #endif*/ }
extern "C" void Init_CoreAPI_Extension() { Init_System(); Init_Application(); Init_Network(); Init_SQLite3(); //#if defined(OS_MACOSX) || defined(OS_ANDROID) || defined(OS_WINCE) Init_NewORM_extension(); //#endif Init_Log(); #if defined(OS_MACOSX) || defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) || defined(OS_ANDROID) Init_WebView(); #elif defined(OS_WP8) Init_WebView_extension(); #endif #if defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) || (defined(OS_MACOSX) && defined(RHODES_EMULATOR)) || defined(OS_ANDROID) || defined(OS_MACOSX) Init_NativeToolbar(); Init_NativeTabbar(); #elif defined(OS_WP8) Init_NativeToolbar_extension(); Init_NativeTabbar_extension(); #endif #if defined(OS_MACOSX) || defined(RHODES_EMULATOR) Init_Navbar(); #endif #if defined(OS_WINDOWS_DESKTOP) || defined(RHODES_EMULATOR) || defined(OS_WINCE) || defined(OS_MACOSX) || defined(OS_ANDROID) Init_Notification(); #endif #if defined(OS_MACOSX) || defined(OS_ANDROID) || defined(WINDOWS_PLATFORM) Init_RhoFile(); #endif #if defined(OS_WINDOWS_DESKTOP) || defined(OS_WINCE) || defined(RHODES_EMULATOR) Init_NativeMenuBar(); #endif #if defined(OS_WINCE) || defined(OS_ANDROID) //Init_Led(); #endif #if defined(OS_ANDROID) || defined(OS_WINCE) || defined(OS_MACOSX) || (defined(OS_WINDOWS_DESKTOP) && !defined(RHODES_EMULATOR)) Init_Push(); #endif #if defined(OS_ANDROID) || (defined(OS_MACOSX) && !defined(RHODES_EMULATOR)) || defined(OS_WINCE) Init_Intent(); #endif #if defined(OS_ANDROID) || defined(OS_WINCE) || (defined(OS_MACOSX) && !defined(RHODES_EMULATOR)) || defined(OS_WP8)|| defined(OS_WINDOWS_DESKTOP) || defined(RHODES_EMULATOR) Init_Timer_extension(); #endif #if defined(OS_ANDROID) || defined(OS_WP8) || (defined(OS_MACOSX) && !defined(RHODES_EMULATOR)) Init_Config_extension(); #endif }
void RhoRubyStart() { const char* szRoot = rho_native_rhopath(); //VALUE moduleRhom; #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif { #ifdef ENABLE_RUBY_VM_STAT g_collect_stat = 1; #endif RUBY_INIT_STACK; ruby_init(); #if defined(WIN32) rb_w32_sysinit(NULL,NULL); #endif #if defined(DEBUG) //enable_gc_profile(); #endif //rb_funcall(rb_mGC, rb_intern("stress="), 1, Qtrue); ruby_init_loadpath(szRoot); #ifdef RHODES_EMULATOR { VALUE load_path = GET_VM()->load_path; char* app_path = malloc(strlen(szRoot)+100); rb_ary_clear(load_path); strcpy(app_path, szRoot); strcat(app_path, "app"); rb_ary_push(load_path, rb_str_new2(app_path) ); strcpy(app_path, rho_simconf_getRhodesPath()); strcat(app_path, "/lib/framework"); rb_ary_push(load_path, rb_str_new2(app_path) ); } #endif Init_strscan(); Init_sqlite3_api(); Init_GeoLocation(); Init_SyncEngine(); Init_AsyncHttp(); Init_System(); Init_Phonebook(); Init_WebView(); Init_RhoConf(); Init_Alert(); Init_SignatureCapture(); Init_RhoBluetooth(); Init_RhodesNativeViewManager(); Init_Camera(); Init_stringio(); Init_DateTimePicker(); Init_NativeBar(); Init_RhoSupport(); Init_MapView(); Init_RingtoneManager(); Init_socket(); Init_NavBar(); Init_RhoEvent(); Init_Calendar(); //TODO: RhoSimulator - load extensions dll dynamically #if !defined(RHODES_EMULATOR) && !defined(RHO_SYMBIAN) Init_Extensions(); #endif //RHODES_EMULATOR #ifdef ENABLE_RUBY_VM_STAT struct timeval start; struct timeval end; gettimeofday (&start, NULL); #endif #ifdef RHODES_EMULATOR rb_const_set(rb_cObject, rb_intern("RHODES_EMULATOR"), Qtrue); require_compiled(rb_str_new2("rhoframework"), &framework ); framework = rb_const_get(rb_cObject,rb_intern("RHO_FRAMEWORK")); #else { VALUE res = rho_ruby_disable_gc(); require_compiled(rb_str_new2("rhoframework"), &framework ); rho_ruby_enable_gc(res); } #endif //RHODES_EMULATOR if ( framework == 0 || framework == Qnil ) { RAWLOG_FATAL("RHO framework creating failed. Application will exit."); } #ifdef ENABLE_RUBY_VM_STAT gettimeofday (&end, NULL); if ( end.tv_sec > 0 ) g_require_compiled_msec += (end.tv_sec - start.tv_sec) * 1000; else g_require_compiled_msec += (end.tv_usec - start.tv_usec)/1000; #endif rb_gc_register_mark_object(framework); CONST_ID(framework_mid, "serve"); CONST_ID(framework_mid2, "serve_index"); CONST_ID(initApp_mid, "init_app"); CONST_ID(onConfigConflicts_mid, "on_config_conflicts"); CONST_ID(activateApp_mid, "activate_app"); CONST_ID(deactivateApp_mid, "deactivate_app"); CONST_ID(uiCreated_mid, "ui_created"); CONST_ID(uiDestroyed_mid, "ui_destroyed"); CONST_ID(loadServerSources_mid,"load_server_sources"); CONST_ID(loadAllSyncSources_mid,"load_all_sync_sources"); CONST_ID(resetDBOnSyncUserChanged_mid, "reset_db_on_sync_user_changed"); //moduleRhom = rb_const_get(rb_cObject, rb_intern("Rhom")); #ifdef ENABLE_RUBY_VM_STAT g_collect_stat = 0; #endif } }
// The only difference with the MPI-only function is calls to Init_ListsOMP and Init_Force_FunctionsOMP(). void InitializeOMP( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, output_controls *out_control, mpi_datatypes *mpi_data, MPI_Comm comm ) { char msg[MAX_STR]; if (Init_MPI_Datatypes(system, workspace, mpi_data, comm, msg) == FAILURE) { fprintf( stderr, "p%d: init_mpi_datatypes: could not create datatypes\n", system->my_rank ); fprintf( stderr, "p%d: mpi_data couldn't be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } if (Init_System(system, control, msg) == FAILURE) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: system could not be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } if (Init_Simulation_Data( system, control, data, msg ) == FAILURE) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: sim_data couldn't be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } if (Init_Workspace( system, control, workspace, mpi_data->world, msg ) == FAILURE) { fprintf( stderr, "p%d:init_workspace: not enough memory\n", system->my_rank ); fprintf( stderr, "p%d:workspace couldn't be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } if (Init_ListsOMP( system, control, data, workspace, lists, mpi_data, msg ) == FAILURE) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: system could not be initialized! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } if (Init_Output_Files(system,control,out_control,mpi_data,msg)== FAILURE) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: could not open output files! terminating...\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } if (control->tabulate) { if (Init_Lookup_Tables( system, control, workspace, mpi_data, msg ) == FAILURE) { fprintf( stderr, "p%d: %s\n", system->my_rank, msg ); fprintf( stderr, "p%d: couldn't create lookup table! terminating.\n", system->my_rank ); MPI_Abort( mpi_data->world, CANNOT_INITIALIZE ); } } Init_Force_FunctionsOMP( control ); }
void RhoRubyStart() { #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif { #ifdef ENABLE_RUBY_VM_STAT g_collect_stat = 1; #endif RUBY_INIT_STACK; ruby_init(); #if defined(WIN32) rb_w32_sysinit(NULL,NULL); #endif #if defined(DEBUG) //enable_gc_profile(); #endif //rb_funcall(rb_mGC, rb_intern("stress="), 1, Qtrue); ruby_init_loadpath(RhoGetRootPath()); Init_strscan(); Init_sqlite3_api(); Init_GeoLocation(); Init_SyncEngine(); Init_System(); Init_Phonebook(); Init_WebView(); Init_RhoConf(); Init_Alert(); Init_Camera(); Init_stringio(); Init_RhoSupport(); #ifdef ENABLE_RUBY_VM_STAT struct timeval start; struct timeval end; gettimeofday (&start, NULL); #endif require_compiled(rb_str_new2("rhoframework"), &framework ); #ifdef ENABLE_RUBY_VM_STAT gettimeofday (&end, NULL); if ( end.tv_sec > 0 ) g_require_compiled_msec += (end.tv_sec - start.tv_sec) * 1000; else g_require_compiled_msec += (end.tv_usec - start.tv_usec)/1000; #endif rb_gc_register_mark_object(framework); CONST_ID(framework_mid, "serve"); CONST_ID(framework_mid2, "serve_index"); #ifdef ENABLE_RUBY_VM_STAT g_collect_stat = 0; #endif } }
void IOPMaster(UNSIGNED argc, VOID *argv) { STATUS status; int ch = 0; int i; unsigned long pci_id; /* Access argc and argv just to avoid compilation warnings. */ status = (STATUS) argc + (STATUS) argv; printf("\n\r"); printf("Executing the System Code....\n\r"); /* Initilaize the Hardware */ #ifdef INCLUDE_ODYSSEY #if 0 if ((status = Init_Hardware()) != NU_SUCCESS) printf("Error in init %d\r\n", status); gt_init(); gt_initdma(0); gt_initdma(1); board_type = memmaps.aBoardType[getSlotNumber()]; init_buf(get_slotno()); #else init_galileo(); /* enable the Switches */ *((U8 *)(0xBC0F8000)) = 0; a_id = b_id = c_id = d_id = e_id = f_id = h_id = 0; /* Init the E bridge */ printf("Initializing the Bridge E...."); pci_id = get_pci_id(0, BRIDGE_21154_ID, 0); if ( pci_id ) { bridge_init(pci_id, PCI_G_NUM, PCI_E_NUM, PCI_E_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); e_id = pci_id; } else { printf("Fail\n\r"); goto done; } /* Init the F bridge */ printf("Initializing the Bridge F...."); pci_id = get_pci_id(0, BRIDGE_21154_ID, 1); if ( pci_id ) { bridge_init(pci_id, PCI_G_NUM, PCI_F_NUM, PCI_F_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); f_id = pci_id; } else { printf("Fail\n\r"); goto done; } /* Init the H bridge */ printf("Initializing the Bridge H...."); pci_id = get_pci_id(PCI_F_NUM, BRIDGE_21154_ID, 0); if ( pci_id ) { bridge_init(pci_id, PCI_F_NUM, PCI_H_NUM, PCI_H_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); h_id = pci_id; } else { printf("Fail\n\r"); goto done; } /* Init the C bridge */ printf("Initializing the Bridge C...."); pci_id = get_pci_id(PCI_F_NUM, BRIDGE_21154_ID, 1); if ( pci_id ) { bridge_init(pci_id, PCI_F_NUM, PCI_C_NUM, PCI_C_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); c_id = pci_id; } else { printf("Fail\n\r"); goto done; } /* Init the D bridge */ printf("Initializing the Bridge D...."); pci_id = get_pci_id(PCI_F_NUM, BRIDGE_21154_ID, 2); if ( pci_id ) { bridge_init(pci_id, PCI_F_NUM, PCI_D_NUM, PCI_D_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); d_id = pci_id; } else { printf("Fail\n\r"); goto done; } /* Init the A bridge */ printf("Initializing the Bridge A...."); pci_id = get_pci_id(PCI_H_NUM, BRIDGE_21154_ID, 0); if ( pci_id ) { bridge_init(pci_id, PCI_H_NUM, PCI_A_NUM, PCI_A_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); a_id = pci_id; } else { printf("Fail\n\r"); goto done; } /* Init the B bridge */ printf("Initializing the Bridge B...."); pci_id = get_pci_id(PCI_H_NUM, BRIDGE_21154_ID, 1); if ( pci_id ) { bridge_init(pci_id, PCI_H_NUM, PCI_B_NUM, PCI_B_SUB, 0xFFFFFFFF, 0); printf("OK\n\r"); b_id = pci_id; } else { printf("Fail\n\r"); goto done; } #endif #else init_galileo(); #endif INCLUDE_ODYSSEY done: /* Spawn the rest of the tasks and initialize */ Init_System(&System_Memory); /* Lower the Priority of this task */ NU_Change_Priority( (NU_TASK *)&IOPMaster_Task, 250 ); /* Now this task will be active with lowest priority and can be used to * any cleanup required */ for(;;){ NU_Sleep(500); Cleanup_System(); /* rlw: can we implement erc91 functionality here? */ } }
void RhoRubyStart() { //VALUE moduleRhom; #ifdef HAVE_LOCALE_H setlocale(LC_CTYPE, ""); #endif { #ifdef ENABLE_RUBY_VM_STAT g_collect_stat = 1; #endif RUBY_INIT_STACK; ruby_init(); #if defined(WIN32) rb_w32_sysinit(NULL,NULL); #endif #if defined(DEBUG) //enable_gc_profile(); #endif //rb_funcall(rb_mGC, rb_intern("stress="), 1, Qtrue); ruby_init_loadpath(rho_native_rhopath()); Init_strscan(); Init_sqlite3_api(); Init_GeoLocation(); Init_SyncEngine(); Init_AsyncHttp(); Init_System(); Init_Phonebook(); Init_WebView(); Init_RhoConf(); Init_Alert(); Init_SignatureTool(); Init_Camera(); Init_stringio(); Init_DateTimePicker(); Init_NativeBar(); Init_RhoSupport(); Init_MapView(); Init_RingtoneManager(); Init_socket(); Init_NavBar(); Init_Extensions(); #ifdef ENABLE_RUBY_VM_STAT struct timeval start; struct timeval end; gettimeofday (&start, NULL); #endif require_compiled(rb_str_new2("rhoframework"), &framework ); #ifdef ENABLE_RUBY_VM_STAT gettimeofday (&end, NULL); if ( end.tv_sec > 0 ) g_require_compiled_msec += (end.tv_sec - start.tv_sec) * 1000; else g_require_compiled_msec += (end.tv_usec - start.tv_usec)/1000; #endif rb_gc_register_mark_object(framework); CONST_ID(framework_mid, "serve"); CONST_ID(framework_mid2, "serve_index"); CONST_ID(initApp_mid, "init_app"); CONST_ID(activateApp_mid, "activate_app"); CONST_ID(deactivateApp_mid, "deactivate_app"); CONST_ID(loadServerSources_mid,"load_server_sources"); //moduleRhom = rb_const_get(rb_cObject, rb_intern("Rhom")); #ifdef ENABLE_RUBY_VM_STAT g_collect_stat = 0; #endif } }
int main (void) { unsigned char i; unsigned char playfile; unsigned char SD_State_Old = 255; /* Initialize */ SYS_ConfigureOscillator(); Init_App(); Init_System(); PWM_SetColor(OFF); RTCC_SetTime(); /* Display Banner */ UART_DisplayBanner(); /* Play start up message out of debug port */ UART_DEBUG_SendStringConstCRLN("Starting..."); /* Display status of PIR sensor */ if(PIR_STATUS) { UART_DEBUG_SendStringConstCRLN("PIR sensor initialized"); } else { UART_DEBUG_SendStringConstCRLN("PIR sensor not working"); } /* Flash LEDS */ MSC_RedLEDOFF(); for(i=0; i<20;i++) { PWM_SetColor(i>>1); MSC_RedLEDTOGGLE(); MSC_DelayUS(50000); } MSC_RedLEDOFF(); /* Play start-up song */ DAC_Play_Startup(); PWM_SetColor(RED); /* Read Voltage rails */ ADC_ReadVIN(); ADC_ReadFiveVoltRail(); while(1) { //RTCC_Read(&CurrentTime); /* SD card routine */ if(SD_CardPresent()) { SD_POWER(ON); if(SD_State == NOT_INITIALIZED) { if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("Initializing SD Card"); } InitSD(); } else if(SD_State == INITIALIZED) { if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("Searching the FAT32 partition for WAV files"); } if(InitFAT()) { UART_DEBUG_SendStringConstCRLN("SD card is correctly formatted FAT32 and contains WAV files"); SD_State = WAV_READY; } } else if(SD_State == WAV_READY) { if(Valid_Wav) { /* there are WAV files to be played */ if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("Ready to play WAV"); } PWM_SetColor(GREEN); if(Motion == TRUE || DoorOpened == TRUE) { UART_DEBUG_SendStringConstCRLN("Motion Detected: Selecting random file for playback"); playfile = (unsigned char)TMR_RandomNum((long)WaveFilesNumLow,(long)WaveFilesNumHigh); /* Check to see if the file is marked as valid */ while(ValidWAVFiles[playfile] != PASS) { if(playfile >= WaveFilesNumHigh) { playfile = 0; } else { playfile++; } } PWM_SetColor(BLUE); PIR_Interrupt(OFF); UART_DEBUG_SendStringConst("Playing WAV file: "); UART_DEBUG_SendStringConstCRLN(&FileList[playfile].name); if(WAV_PlayFile_Random_Sector(playfile)) { UART_DEBUG_SendStringConstCRLN("Wav played successfully"); } else { UART_DEBUG_SendStringConstCRLN("Wav failed"); if(SD_CardPresent() == FAIL) { SD_State = NOT_INITIALIZED; UART_DEBUG_SendStringConstCRLN("SD card removed"); } } Motion = FALSE; DoorOpened = FALSE; PIR_Interrupt(ON); PWM_SetColor(GREEN); MSC_RedLEDOFF(); } } else { /* there are no satisfactory WAV files on the card */ if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN(" WAV files are corrupted"); } /* Reinitialize */ SD_State = NOT_INITIALIZED; } } } else { SD_State = NOT_INITIALIZED; if(SD_State_Old != SD_State) { UART_DEBUG_SendStringConstCRLN("No SD card found"); } if(Motion == TRUE || DoorOpened == TRUE) { PIR_Interrupt(OFF); MSC_RedLEDON(); PWM_SetColor(WHITE); MSC_DelayUS(50000); Motion = FALSE; DoorOpened = FALSE; PIR_Interrupt(ON); } MSC_RedLEDOFF(); SD_POWER(OFF); PWM_SetColor(RED); } SD_State_Old = SD_State; } }