// search for specified dsp file and load it u8 files_load_dsp_name(const char* name) { void* fp; u32 size = 0; u8 ret; // ModuleVersion modVers; delay_ms(10); app_pause(); fp = list_open_file_name(&dspList, name, "r", &size); if( fp != NULL) { print_dbg("\r\n found file, loading dsp: "); print_dbg(name); fake_fread(bfinLdrData, size, fp); fl_fclose(fp); bfinLdrSize = size; if(bfinLdrSize > 0) { print_dbg("\r\n loading bfin from buf"); // reboot the dsp with new firmware in RAM bfin_load_buf(); print_dbg("\r\n finished load"); // write module name in global scene data ///////////////// /// FIXME: filename and reported modulename should be decoupled /// bees should search for aleph-module-x.y.z.ldr /// but try aleph-module*.ldr on failure //// /// query name and version to the scene data // scene_query_module(); /// now set it to the actual filename because we are dumb scene_set_module_name(name); /////////////////////////// print_dbg("\r\n sceneData->moduleName : "); print_dbg(name); ret = 1; } else { print_dbg("\r\n bfin ldr size was <=0, aborting"); ret = 0; } } else { print_dbg("\r\n error: fp was null in files_load_dsp_name \r\n"); ret = 0; } app_resume(); return ret; }
// this is called from the event queue to start the app // return >0 if there is an error doing firstrun init u8 app_launch(u8 firstrun) { u32 waitForCard; print_dbg("\r\n app launch"); print_dbg("\r\n firstrun: "); print_dbg_ulong(firstrun); if(firstrun) { // it is the first run. // need to copy audio module binary from sdcard to internal flash. render_boot("first run. waiting for SDcard..."); render_update(); print_dbg("\r\n SD check... "); while (!sd_mmc_spi_mem_check()) { waitForCard++; } print_dbg("\r\nfound SD card. "); render_boot("found sdcard.. reading DSP..."); render_update(); // search for our dsp and load it // return success (0 == fail) if( files_search_dsp() ) { ;; } else { screen_clear(); return 0; } } else { // firstrun pattern was set, so there should be a blackfin executable in flash. // read from flash to RAM render_boot("loading flash to RAM..."); render_update(); flash_read_ldr(); render_boot( "booting DSP from flash..."); render_update(); // reboot DSP from RAM bfin_load_buf(); } render_boot("waiting for bfin init... "); render_update(); bfin_wait_ready(); // set encoder sensitivity set_enc_thresh(3, 16); delay_ms(20); // enable audio render_boot("run "); render_update(); bfin_enable(); // enable timers init_app_timers(); render_startup(); render_update(); // set app event handlers mix_assign_event_handlers(); return 1; }
// this is called from main event handler u8 app_launch(u8 firstrun) { print_dbg("\r\n launching app with firstrun: "); print_dbg_ulong(firstrun); // net_print(); render_boot("BEES"); render_boot(versionString); if(firstrun) { render_boot("launching app, first run"); print_dbg("\r\n first run, writing nonvolatile data..."); ///... write param scaler data // this is done at firstrun instead of being linked statically, // so that users can tune scaler data offline without recompiling render_boot("init param scaling data..."); flash_init_scaler_data(); print_dbg("\r\n first run, try and load default DSP"); render_boot("launching default DSP..."); files_load_dsp_name("aleph-waves.ldr"); render_boot("waiting for DSP init..."); bfin_wait_ready(); // print_dbg(" requesting param report..."); render_boot("requesting DSP params"); net_report_params(); // print_dbg("\r\n enable DSP audio..."); render_boot("enabling audio"); bfin_enable(); render_boot("writing default dsp to flash..."); // files_store_default_dsp_name("aleph-waves.ldr"); } else { app_pause(); print_dbg("\r\n booting default ldr from flash... "); render_boot("booting DSP from flash"); // flash_read_ldr(); bfin_load_buf(); print_dbg("\r\n DSP booted, waiting to query params..."); render_boot("waiting for DSP init..."); /// blackfin should clear ready pin ASAP on boot. /// but give it a moment to accomplish that. delay_ms(2); bfin_wait_ready(); print_dbg(" requesting param report..."); render_boot("requesting DSP params"); net_report_params(); print_dbg("\r\n enable DSP audio..."); render_boot("enabling audio"); bfin_enable(); print_dbg("\r\n reading default scene... "); render_boot("reading default scene"); scene_read_default(); app_resume(); } // init pages (fill graphics buffers) print_dbg("\r\n pages_init..."); pages_init(); print_dbg("\r\n play_init..."); play_init(); // enable timers print_dbg("\r\n enable app timers..."); render_boot("enabling app timers..."); init_app_timers(); // pull up power control pin, enabling soft-powerdown gpio_set_gpio_pin(POWER_CTL_PIN); // assign app event handlers print_dbg("\r\n assigning handlers "); render_boot("assigning UI handlers..."); assign_bees_event_handlers(); // update page rendering and handlers pages_reselect(); // start in play mode pages_toggle_play(); return 1; }