Beispiel #1
0
// search for specified scene file and load it
// return 1 on success, 0 on failure
u8 files_load_scene_name(const char* name) {
  void* fp;
  u32 size = 0;
  u8 ret = 0;

  app_pause();

  fp = list_open_file_name(&sceneList, name, "r", &size);

  if( fp != NULL) {	  
    fake_fread((volatile u8*)sceneData, sizeof(sceneData_t), fp);
    fl_fclose(fp);
    scene_read_buf();

    // try and load dsp module indicated by scene descriptor
    //// DUDE! NO!!! scene does this. when did this happen!
    //// probably snuck in in some merge.
    //    ret = files_load_dsp_name(sceneData->desc.moduleName);
  } else {
    print_dbg("\r\n error: fp was null in files_load_scene_name \r\n");
    ret = 0;
  } 
  app_resume();
  return ret;
}
Beispiel #2
0
// store scene to sdcard at name
void files_store_scene_name(const char* name, u8 ext) {
  //u32 i;
  void* fp;
  char namebuf[64] = SCENES_PATH;
  u8* pScene;

  app_pause();

  strcat(namebuf, name);

  if(ext) {
    // weird..
    strip_space(namebuf, 32);
    strcat(namebuf, ".scn");
  }

  print_dbg("\r\n opening scene file for writing: ");
  print_dbg(namebuf);

  // fill the scene RAM buffer from current state of system
  scene_write_buf(); 
  // open FP for writing
  fp = fl_fopen(namebuf, "wb");
  pScene = (u8*)sceneData;
  fl_fwrite((const void*)pScene, sizeof(sceneData_t), 1, fp);
  fl_fclose(fp);
  // rescan
  list_scan(&sceneList, SCENES_PATH);
  delay_ms(10);

  app_resume();
}
Beispiel #3
0
void bfin_get_num_params(volatile u32* num) {
#if 1

  *num = 0;

#else
  u16 x;

  app_pause();

  // command 
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_NUM_PARAMS_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  print_dbg("\r\n : spi_write MSG_GET_NUM_PARAMS");

  // read num
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);  
  *num = (u8)(x & 0xff);

  print_dbg("\r\n : spi_read numparams: ");
  print_dbg_ulong(*num);

  app_resume();

#endif
}
Beispiel #4
0
// search for named .dsc file and load into network param desc memory
extern u8 files_load_desc(const char* name) {
  char path[64] = DSP_PATH;
  void * fp;
  int nparams = -1;
  // word buffer for 4-byte unpickling
  u8 nbuf[4];
  // buffer for binary blob of single descriptor
  u8 dbuf[PARAM_DESC_PICKLE_BYTES];
  // unpacked descriptor
  ParamDesc desc;
  int i;
  u8 ret = 0;

  app_pause();

  strcat(path, name);
  strip_ext(path);
  strcat(path, ".dsc");

  print_dbg("\r\n  opening .dsc file at path: ");
  print_dbg(path);

  fp = fl_fopen(path, "r");
  if(fp == NULL) {
    print_dbg("... error opening .dsc file.");
    print_dbg(path);
    ret = 1;
  } else {

    // get number of parameters
    fake_fread(nbuf, 4, fp);
    unpickle_32(nbuf, (u32*)&nparams); 

    /// loop over params
    if(nparams > 0) {
      net_clear_params();
      //    net->numParams = nparams;

      for(i=0; i<nparams; i++) {
	//  FIXME: a little gross,
	// to be interleaving network and file manipulation like this...
	///....
	// read into desc buffer
	fake_fread(dbuf, PARAM_DESC_PICKLE_BYTES, fp);
	// unpickle directly into network descriptor memory
	pdesc_unpickle( &desc, dbuf );
	// copy descriptor to network and increment count
	net_add_param(i, (const ParamDesc*)(&desc));     
 
      }
    } else {
      print_dbg("\r\n error: crazy parameter count from descriptor file.");
      ret = 1;
    }
  }
  fl_fclose(fp);
  app_resume();
  return ret;
}
Beispiel #5
0
// load from default
void scene_read_default(void) {
  app_pause();
  print_dbg("\r\n reading default scene from flash... ");
  flash_read_scene();
  
  print_dbg("\r\n finished reading ");  
  app_resume();
}
Beispiel #6
0
void bfin_get_param_desc(u16 paramIdx, volatile ParamDesc* pDesc) {
  ParamValue pval;
  u16 x; // u16 for spi_read()
  u8 i;

  app_pause();
  // command 
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_PARAM_DESC_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  // idx
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, paramIdx);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  // read label
  for(i=0; i<PARAM_LABEL_LEN; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pDesc->label[i] = (char)(x & 0xff);
  }
  // read unit
  for(i=0; i<PARAM_UNIT_LEN; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pDesc->unit[i] = (char)(x & 0xff);
  }
  // read type
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pDesc->type = (U8)(x & 0xff);
  // read min
  for(i=0; i<4; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pval.asByte[i] = (u8)(x & 0xff);
  }
  pDesc->min = pval.asInt;
  // read max
  for(i=0; i<4; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pval.asByte[i] = (u8)(x & 0xff);
  }
  pDesc->max = pval.asInt;

  app_resume();
}
Beispiel #7
0
// load from default
void scene_read_default(void) {
  app_pause();
  /* print_dbg("\r\n reading default scene from flash... "); */
  /* flash_read_scene(); */
  print_dbg("\r\n reading default scene from card... ");
  files_load_scene_name(DEFAULT_SCENE_NAME_EXT);
  
  print_dbg("\r\n finished reading ");  
  app_resume();
}
Beispiel #8
0
// 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;
}
Beispiel #9
0
// store scene to sdcard at name
void files_store_scene_name(const char* name, u8 ext) {
  //u32 i;
  void* fp;
  char namebuf[64] = SCENES_PATH;
  u8* pScene;

  app_pause();

  strcat(namebuf, name);

  if(ext) {
    // weird..
    strip_space(namebuf, 32);
    strcat(namebuf, ".scn");
  }

  print_dbg("\r\n opening scene file for writing: ");
  print_dbg(namebuf);

  // fill the scene RAM buffer from current state of system
  scene_write_buf(); 
  print_dbg("\r\n filled scene binary buffer");

  // open FP for writing
  fp = fl_fopen(namebuf, "wb");
  print_dbg("\r\n opened file for binary write at 0x");
  print_dbg_hex((u32)fp);

  pScene = (u8*)sceneData;
  print_dbg("\r\n writing data from scene buffer at 0x");
  print_dbg_hex((u32)pScene);
  print_dbg(", size : ");
  print_dbg_hex(sizeof(sceneData_t));
  

  // dump the scene data to debug output...

  fl_fwrite((const void*)pScene, sizeof(sceneData_t), 1, fp);
  fl_fclose(fp);

  print_dbg("\r\n ... finished writing, closed file pointer");

  // rescan
  list_scan(&sceneList, SCENES_PATH);
  delay_ms(10);

  print_dbg("\r\n re-scanned scene file list and waited.");

  app_resume();
}
Beispiel #10
0
// destroy last operator created
s16 net_pop_op(void) {
  const s16 opIdx = net->numOps - 1;
  op_t* op = net->ops[opIdx];
  int i=0;
  int x, y;

  app_pause();
  // bail if system op
  if(net_op_flag (opIdx, eOpFlagSys)) { return 1; }
  // de-init
  op_deinit(op);
  // store the global index of the first input
  x = net_op_in_idx(opIdx, 0);
  y = x + op->numInputs;

  // check if anything connects here
  for(i=0; i<net->numOuts; i++) {
    // this check works b/c we know this is last op in list
    if( net->outs[i].target >= x ) {
      if( net->outs[i].target < y) {
	net_disconnect(i);
      } else {
	//	net->outs[i].target -= op->numInputs;
	net_connect(i, net->outs[i].target - op->numInputs); 
      }
    }
  }
  // erase input nodes
  while(x < y) {
    net_init_inode(x++);
  }
  // store the global index of the first output
  x = net_op_out_idx(opIdx, 0);
  y = x + op->numOutputs;
  // erase output nodes
  while(x < y) {
    net_init_onode(x++);
  }

  net->numIns -= op->numInputs;
  net->numOuts -= op->numOutputs;

  net->opPoolOffset -= op_registry[op->type].size;
  net->numOps -= 1;

  app_resume();
  return 0;

}
Beispiel #11
0
// get parameter value
s32 bfin_get_param(u8 idx) {
#if 1
#else
  ParamValueCommon pval;
  u16 x;
  
  app_pause();

  // command
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_PARAM_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  // idx
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, idx);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  /// read value
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[0] = (u8)x;

  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[1] = (u8)x;

  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[2] = (u8)x;

  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); // don't care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pval.asByte[3] = (u8)x;

  app_resume();

  return pval.asInt;
  
#endif
}
Beispiel #12
0
// update
void render_update(void) {
  app_pause();

  // scrolling region
  if((pageCenterScroll->reg)->dirty) {
    scroll_draw(pageCenterScroll);
  }
  // standard regions
  region_update(headRegion);
  region_update(footRegion[0]);
  region_update(footRegion[1]);
  region_update(footRegion[2]);
  region_update(footRegion[3]);

  app_resume();
}
Beispiel #13
0
void bfin_get_num_params(volatile u32* num) {
  u16 x;

  app_pause();

  // command 
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_NUM_PARAMS_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  // read num
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);  
  *num = (u8)(x & 0xff);

  app_resume();

}
Beispiel #14
0
// get module version
void bfin_get_module_version(ModuleVersion* vers) {
  u16 x;
  
  app_pause();

  // command
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_MODULE_VERSION_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);

  // major
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  vers->maj = x;

  // minor
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  vers->min = x;

  // rev
  vers->rev = 0;
  // rev high
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  vers->rev |= ((x << 8) & 0xff00);

    // rev low
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  vers->rev |= (x & 0x00ff);

  app_resume();
}
Beispiel #15
0
// load bfin executable from the RAM buffer
void bfin_load_buf(void) {
  u64 i; /// byte index in .ldr

  if(bfinLdrSize > BFIN_LDR_MAX_BYTES) {
    print_dbg("\r\n bfin load error: size : "); print_dbg_hex(bfinLdrSize);
    return;
  }

  app_pause();

  bfin_start_transfer();

  for(i=0; i<bfinLdrSize; i++) {
    bfin_transfer_byte(bfinLdrData[i]);
  }

  bfin_end_transfer();
  
  app_resume();
}
Beispiel #16
0
// get module name
void bfin_get_module_name(volatile char* buf) {
  u16 x; // u16 for spi_read()
  u8 i;

  app_pause();

  // command 
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_MODULE_NAME_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  for(i=0; i<MODULE_NAME_LEN; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    buf[i] = (char)(x & 0xff);
  }

  app_resume();
}
Beispiel #17
0
// search for specified scene file and load it
// return 1 on success, 0 on failure
u8 files_load_scene_name(const char* name) {
  void* fp;
  u32 size = 0;
  u8 ret = 0;

    //// ahhhhh, i see.. 
    /// this is overwriting the descriptor in sceneData as well as the serialized blob.
    /// woud be fine, except it f***s up the comparison later.
    /// for now, let's do this ugly-ass workaround.

  char oldModuleName[MODULE_NAME_LEN];
  /// store extant module name
  strncpy(oldModuleName, sceneData->desc.moduleName, MODULE_NAME_LEN);

  app_pause();

  fp = list_open_file_name(&sceneList, name, "r", &size);

  if( fp != NULL) {	  
    print_dbg("\r\n reading binary into sceneData serialized data buffer...");
    fake_fread((volatile u8*)sceneData, sizeof(sceneData_t), fp);
    print_dbg(" done.");
    
    /// copy old name back to descriptor field... dumb dumb dumb.
    strncpy(sceneData->desc.moduleName, oldModuleName, MODULE_NAME_LEN);
    
    fl_fclose(fp);
    scene_read_buf();

    // try and load dsp module indicated by scene descriptor
    //// DUDE! NO!!! scene does this. when did this happen!
    //// probably snuck in in some merge.
    //    ret = files_load_dsp_name(sceneData->desc.moduleName);
  } else {
    print_dbg("\r\n error: fp was null in files_load_scene_name \r\n");
    ret = 0;
  } 

  app_resume();
  return ret;
}
Beispiel #18
0
// load bfin executable from the RAM buffer
void bfin_load_buf(void) {
#if 1
#else
  u64 i; /// byte index in .ldr

  /////
  //// TEST: print contents of buffer
  /* print_dbg("\r\n\r\n .ldr buffer for: "); */
  /* contents(i=0; i<bfinLdrSize; i++) { */
  /*   print_dbg("\r\n 0x"); */
  /*   print_dbg_hex(bfinLdrData[i]); */
  /* } */
  /* print_dbg("\r\n\r\n"); */
  ////
  /////////

  ////////////
  //// tESTING don't check
#if 0
  if(bfinLdrSize > BFIN_LDR_MAX_BYTES) {
    print_dbg("\r\n bfin load error: size : "); print_dbg_hex(bfinLdrSize);
    return;
  }
#endif
  ///////////////
  ////////////////

  app_pause();

  bfin_start_transfer();

  for(i=0; i<bfinLdrSize; i++) {
    bfin_transfer_byte(bfinLdrData[i]);
  }

  bfin_end_transfer();
 
  app_resume();
#endif
}
Beispiel #19
0
// write current state as default
void scene_write_default(void) {
  
  app_pause();

  render_boot("writing default scene");
  print_dbg("\r\n writing default scene to card... ");

  files_store_scene_name(DEFAULT_SCENE_NAME_EXT, 0);

  //  app_resume();

/* #if 0 */
/*   s8 neq = 0; */
/*   s8 modName[MODULE_NAME_LEN]; */
/* #endif */

/*   app_pause(); */
  /* render_boot("writing scene to flash"); */

  /* print_dbg("\r\n writing scene to flash... "); */
/*   print_dbg("module name: "); */
/*   print_dbg(sceneData->desc.moduleName); */

/*   //  flash_write_scene(); */
  

/* # if 0 // not storing .ldr in flash for the moment! */
/*   // write default LDR if changed  */
/*   neq = strncmp((const char*)modName, (const char*)sceneData->desc.moduleName, MODULE_NAME_LEN); */
/*   if(neq) { */
/*     render_boot("writing DSP to flash"); */
/*     print_dbg("\r\n writing default LDR from scene descriptor"); */
/*     files_store_default_dsp_name(sceneData->desc.moduleName); */
/*   }  */
/* #endif     */
  delay_ms(20);
  print_dbg("\r\n finished writing default scene");
  app_resume();
  
}
Beispiel #20
0
// write current state as default
void scene_write_default(void) {
  s8 neq = 0;
  s8 modName[MODULE_NAME_LEN];

  app_pause();
  render_boot("writing scene to flash");

  print_dbg("\r\n writing scene to flash... ");
  print_dbg("module name: ");
  print_dbg(sceneData->desc.moduleName);

  flash_write_scene();

  // write default LDR if changed 
  neq = strncmp((const char*)modName, (const char*)sceneData->desc.moduleName, MODULE_NAME_LEN);
  if(neq) {
    render_boot("writing DSP to flash");
    print_dbg("\r\n writing default LDR from scene descriptor");
    //    files_store_default_dsp_name(sceneData->desc.moduleName);
  }    
  delay_ms(20);
  print_dbg("\r\n finished writing default scene");
  app_resume();
}
Beispiel #21
0
// destroy last operator created
s16 net_pop_op(void) {
  const s16 opIdx = net->numOps - 1;
  op_t* op = net->ops[opIdx];
  int i, j;
  int x, y;
  int ins;
  int numInsSave = net->numIns;
  int idxOld, idxNew;

  app_pause();
  // bail if system op
  if(net_op_flag (opIdx, eOpFlagSys)) { return 1; }
  // de-init
  op_deinit(op);
  ins = op->numInputs;
  // store the global index of the first input
  x = net_op_in_idx(opIdx, 0);
  y = x + ins;

  // check if anything connects here
  for(i=0; i<net->numOuts; i++) {
    // this check works b/c we know this is last op in list
    if( net->outs[i].target >= x ) {
      if( net->outs[i].target < y) {
	net_disconnect(i);
      } else {
	/// this should take care of both param and op input targets.
	net_connect(i, net->outs[i].target - op->numInputs); 
      }
    }
  }
  // erase input nodes
  while(x < y) {
    net_init_inode(x++);
  }
  // store the global index of the first output
  x = net_op_out_idx(opIdx, 0);
  y = x + op->numOutputs;
  // erase output nodes
  while(x < y) {
    net_init_onode(x++);
  }

  net->numIns -= op->numInputs;
  net->numOuts -= op->numOutputs;

  net->opPoolOffset -= op_registry[op->type].size;
  net->numOps -= 1;

  // FIXME: shift preset param data and connections to params, 
  // since they share an indexing list with inputs and we just changed it.

  for(i=0; i<NET_PRESETS_MAX; ++i) {
    // shift parameter nodes in preset data
    for(j=0; j<net->numParams; ++j) {
      // this was the old param index
      idxOld = j + numInsSave;
      // copy to new param index
      idxNew = idxOld - ins;
      presets[i].ins[idxNew].value = presets[i].ins[idxOld].value;
      presets[i].ins[idxNew].enabled = presets[i].ins[idxOld].enabled;
      // clear the old data.
      presets[i].ins[idxOld].enabled = 0;
      presets[i].ins[idxOld].value = 0;
    }

  }


  app_resume();
  return 0;

}
Beispiel #22
0
// search for specified scaler file and load it to specified buffer
// return 1 on success, 0 on failure
u8 files_load_scaler_name(const char* name, s32* dst, u32 dstSize) {
  void* fp;
  u32 size = 0;
  u32 i;
  union { u32 u; s32 s; u8 b[4]; } swap;
  u8 ret = 0;
  //// test
  //s32* p = dst;
  ///

  app_pause();
  fp = list_open_file_name(&scalerList, name, "r", &size);
  if( fp != NULL) {	  

    print_dbg("\r\n scaler file pointer: 0x");
    print_dbg_hex((u32)fp);
#ifdef SCALER_LE
    swap.b[3] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[0] = fl_fgetc(fp);
#else
    swap.b[0] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[3] = fl_fgetc(fp);
#endif
    size = swap.u;

    print_dbg("\r\n read size (words): 0x");
    print_dbg_ulong(size);

    if(size > dstSize) {
      print_dbg("\r\n warning: requested scaler data is > target, truncating");
      for(i=0; i<dstSize; ++i) {

#ifdef SCALER_LE
    swap.b[3] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[0] = fl_fgetc(fp);
#else
    swap.b[0] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[3] = fl_fgetc(fp);
#endif
	*dst++ = swap.s;
      }
    } else if (size < dstSize) {
      print_dbg("\r\n warning: requested scaler data is < target, padding");
      for(i=0; i<size; ++i) {
#ifdef SCALER_LE
    swap.b[3] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[0] = fl_fgetc(fp);
#else
    swap.b[0] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[3] = fl_fgetc(fp);
#endif
	*dst++ = swap.s;
      }
      // remainder
      size = dstSize - size;
      for(i=0; i<size; ++i) {
	*dst++ = 0;
      }
    } else {
      for(i=0; i<size; ++i) {
#ifdef SCALER_LE
    swap.b[3] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[0] = fl_fgetc(fp);
#else
    swap.b[0] = fl_fgetc(fp);
    swap.b[1] = fl_fgetc(fp);
    swap.b[2] = fl_fgetc(fp);
    swap.b[3] = fl_fgetc(fp);
#endif
	*dst++ = swap.s;
      }
    }
    fl_fclose(fp);
    ret = 1;
  } else {
    print_dbg("\r\n error: fp was null in files_load_scaler_name \r\n");
    ret = 0;
  } 

  print_dbg("\r\n finished loading scaler file (?)");

  ///// TEST: verify
  /* for(i=0; i<size; i++) { */
  /*   print_dbg(" 0x"); print_dbg_hex(p[i]); if((i%4)==0) { print_dbg("\r\n"); } */
  /* } */

  app_resume();
  return ret;
}
Beispiel #23
0
// set current state of system from global RAM buffer
void scene_read_buf(void) {
  s8 modName[MODULE_NAME_LEN];
  const u8* src = (u8*)&(sceneData->pickle);

  /// FIXME: we really should be using this comparison
  
  //  s8 neq = 0;
  //  u32 i;

  app_pause();

  // store current mod name in scene desc
  memcpy(modName, sceneData->desc.moduleName, MODULE_NAME_LEN);

  ///// always load:
    print_dbg("\r\n loading module name: ");
    print_dbg(sceneData->desc.moduleName);
    files_load_dsp_name(sceneData->desc.moduleName);
    //  }

    bfin_wait_ready();

    net_clear_user_ops();

    net_report_params();

  // unpickle network 
  print_dbg("\r\n unpickling network for scene recall...");
  src = net_unpickle(src);

  // unpickle presets
  print_dbg("\r\n unpickling presets for scene recall...");
  src = presets_unpickle(src);
  
  print_dbg("\r\n copied stored network and presets to RAM ");

  /* for(i=0; i<net->numParams; i++) { */
  /*   print_dbg("\r\n param "); */
  /*   print_dbg_ulong(i); */
  /*   print_dbg(" : "); */
  /*   print_dbg(net->params[i].desc.label); */
  /*   print_dbg(" ; val "); */
  /*   print_dbg_hex((u32)net->params[i].data.value); */
  /* } */

  // compare module name  

  //// is strncmp f*****g with us??
  ///  neq = strncmp((const char*)modName, (const char*)sceneData->desc.moduleName, MODULE_NAME_LEN);
  
  //  if(neq) {
    // load bfin module if it doesn't match the current scene desc

  //...
    
    bfin_wait_ready();

  //// well let's try it, actually that would explain some things..
    //  delay_ms(10);

  // update bfin parameters
  net_send_params();
  print_dbg("\r\n sent new params");

  delay_ms(5);

  // enable audio processing
  bfin_enable();
  
  app_resume();
}
Beispiel #24
0
void bfin_get_param_desc(u16 paramIdx, volatile ParamDesc* pDesc) {
#if 1
#else
  ParamValueCommon pval;
  u16 x; // u16 for spi_read()
  u8 i;

  app_pause();
  // command 
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, MSG_GET_PARAM_DESC_COM);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  // idx
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, paramIdx);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  // read label
  for(i=0; i<PARAM_LABEL_LEN; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pDesc->label[i] = (char)(x & 0xff);
  }
  /*
    //// don't need with new type system... didn't exactly need anyways
  // read unit
  for(i=0; i<PARAM_UNIT_LEN; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pDesc->unit[i] = (char)(x & 0xff);
  }
  */
  // read type
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pDesc->type = (U8)(x & 0xff);
  // read min
  for(i=0; i<4; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pval.asByte[i] = (u8)(x & 0xff);
  }
  pDesc->min = pval.asInt;
  // read max
  for(i=0; i<4; i++) {
    spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
    spi_write(BFIN_SPI, 0); //dont care
    spi_read(BFIN_SPI, &x);
    spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
    pval.asByte[i] = (u8)(x & 0xff);
  }
  pDesc->max = pval.asInt;

  // read radix
  spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS);
  spi_write(BFIN_SPI, 0); //dont care
  spi_read(BFIN_SPI, &x);
  spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS);
  pDesc->radix = (u8)(x & 0xff);

  app_resume();
#endif
}
Beispiel #25
0
// 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;
}
Beispiel #26
0
// set current state of system from global RAM buffer
void scene_read_buf(void) {
  /// pointer to serial blob
  const u8* src = (u8*)&(sceneData->pickle);
  int i;
  // param count reported from dsp
  //  u32 paramsReported;
  //// TEST
  char moduleName[MODULE_NAME_LEN];
  ModuleVersion moduleVersion;
  ////

   app_pause();

  // store current mod name in scene desc
   //  memcpy(modName, sceneData->desc.moduleName, MODULE_NAME_LEN);
   
   // read scene name
  for(i=0; i<SCENE_NAME_LEN; i++) {
    sceneData->desc.sceneName[i] = *src;
    src++;
  }

   // read bees version
  sceneData->desc.beesVersion.min = *src;
  src++;
  sceneData->desc.beesVersion.maj = *src;
  src++;
  src = unpickle_16(src, &(sceneData->desc.beesVersion.rev));

 // read module name
  // target is temp module name buffer, so we can run a comparison 
  for(i=0; i<MODULE_NAME_LEN; i++) {
    moduleName[i] = *src;
    src++;
  }
  print_dbg("\r\n unpickled module name: ");
  print_dbg(moduleName);

   // read module version
  sceneData->desc.moduleVersion.min = *src;
  src++;
  sceneData->desc.moduleVersion.maj = *src;
  src++;
  src = unpickle_16(src, &(sceneData->desc.moduleVersion.rev));

  print_dbg("\r\n unpickled module version: ");
  print_dbg_ulong(sceneData->desc.moduleVersion.maj);
  print_dbg(".");
  print_dbg_ulong(sceneData->desc.moduleVersion.min);
  print_dbg(".");
  print_dbg_ulong(sceneData->desc.moduleVersion.rev);

  print_dbg("\r\n checking against module name from scene data: ");
  print_dbg(sceneData->desc.moduleName);

  if(strcmp(moduleName, sceneData->desc.moduleName) == 0) {
    print_dbg("\r\n requested module name is already loaded; skip DSP reboot.");
    // skip DSP load
    /// FIXME: should check module version too

  } else {
    strcpy(sceneData->desc.moduleName, moduleName);
    render_boot("loading DSP module:");
    render_boot(sceneData->desc.moduleName);

    ///// load the DSP now!  
    render_boot("loading module from sdcard");
    print_dbg("\r\n loading module from card, filename: ");
    print_dbg(sceneData->desc.moduleName);

    files_load_dsp_name(sceneData->desc.moduleName);

    render_boot("waiting for module init");
    print_dbg("\r\n waiting for DSP init...");
    bfin_wait_ready();

#if RELEASEBUILD==1
#else
  
    // query module name / version

    render_boot("querying module");

    print_dbg("\r\n querying module name...");
    bfin_get_module_name(moduleName);
    print_dbg("\r\n querying module version...");
    bfin_get_module_version(&moduleVersion);

    print_dbg("\r\n received module name: ");
    print_dbg((char*)moduleName);

    print_dbg("\r\n received module version: ");
    print_dbg_ulong(moduleVersion.maj);
    print_dbg(".");
    print_dbg_ulong(moduleVersion.min);
    print_dbg(".");
    print_dbg_ulong(moduleVersion.rev);

#ifdef BEEKEEP
#else
    // store in scene data
    render_boot("storing module version");

    sceneData->desc.moduleVersion.maj = moduleVersion.maj;
    sceneData->desc.moduleVersion.min = moduleVersion.min;
    sceneData->desc.moduleVersion.rev = moduleVersion.rev;
    strcpy(sceneData->desc.moduleName, (const char*)moduleName);
#endif

#endif

  } // load-module case
  app_pause();

  /// don't have to do this b/c net_unpickle will deinit anyways
  /*
  print_dbg("\r\n clearing operator list...");
  net_clear_user_ops();
  */

  //// FIXME: use .dsc
  /*
  print_dbg("\r\n reporting DSP parameters...");
  paramsReported = net_report_params();
  */

  /// FIXME:
  /// check the module version and warn if different!
  // there could also be a check here for mismatched parameter list.

  // unpickle network 
  render_boot("reading network");
  print_dbg("\r\n unpickling network for scene recall...");
  src = net_unpickle(src);
    
  // unpickle presets
  render_boot("reading presets");
  print_dbg("\r\n unpickling presets for scene recall...");
  src = presets_unpickle(src);

  render_boot("scene data stored in RAM");
  print_dbg("\r\n copied stored network and presets to RAM ");

  /* for(i=0; i<net->numParams; i++) { */
  /*   print_dbg("\r\n param "); */
  /*   print_dbg_ulong(i); */
  /*   print_dbg(" : "); */
  /*   print_dbg(net->params[i].desc.label); */
  /*   print_dbg(" ; val "); */
  /*   print_dbg_hex((u32)net->params[i].data.value); */
  /* } */

  render_boot("waiting for DSP");
  bfin_wait_ready();
  // update bfin parameters
  //  if(net->numParams != paramsReported) {
  //    print_dbg("\r\n !!!!!! WARNING ! param count from scene does not match reported count from DSP");
  //    render_boot("warning: param count mismatch!");
  //  } else {

#ifdef BEEKEEP
#else
  render_boot("sending param values");
  net_send_params();
#endif

  //  }

  print_dbg("\r\n sent new parameter values");

  delay_ms(5);


  render_boot("enabling audio");  // enable audio processing
  bfin_enable();
  
  app_resume();
}
Beispiel #27
0
// 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);

  while (!sd_mmc_spi_mem_check()) {
    render_boot("waiting for SD card...");
  }

  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");

    //// startup using default DSP name
    files_load_dsp_name(DEFAULT_LDR);
    
    render_boot("waiting for DSP init...");
    bfin_wait_ready();

    //    print_dbg("\r\n enable DSP audio...");
    render_boot("enabling audio");
    bfin_enable();
    
  } else {

    app_pause();

    /// blackfin should clear ready pin ASAP on boot.
    /// but give it a moment to accomplish that.
    delay_ms(2);

    /// read the default scene from sd card
    /// this also attempts to load associated .ldr    
    render_boot("reading default scene");
    print_dbg("\r\n loading default scene. current module name from sceneData: ");
    print_dbg(sceneData->desc.moduleName);

    scene_read_default();

    delay_ms(2); 

    app_resume();
    
   }

  // init pages (fill graphics buffers)
  render_boot("initializing gfx");
  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 if not firstrun 
  if(!firstrun) pages_toggle_play();

  return 1;
}