/*! \brief Display results in bps */ static void display_perf_bps(U32 bandwidth) { if( bandwidth<10000 ) { print_dbg("Bandwidth: "); print_dbg(CL_GREEN); print_dbg_ulong( bandwidth ); print_dbg(CL_BLACK); print_dbg(" Bps\r\n"); } /* else if( bandwidth<10000000 ) { print_dbg("Bandwidth: "); print_dbg(CL_GREEN); print_dbg_ulong( bandwidth/1000 ); print_dbg(CL_BLACK); print_dbg(" KBps\r\n"); }*/ else { print_dbg("Bandwidth: "); print_dbg(CL_GREEN); //print_dbg_ulong( bandwidth/1000000 ); print_dbg_ulong( bandwidth/1000 ); print_dbg(CL_BLACK); print_dbg(" KBps\r\n"); //print_dbg(" MBps\r\n"); } }
static const u8* inode_unpickle(const u8* src, inode_t* in) { /// don't need to pickle indices because we recreate the op list from scratch // only need these flags: // in->preset = *src++; // play inclusion flag in->play = *src++; print_dbg(" ; opIdx: "); print_dbg_ulong(in->opIdx); print_dbg(" ; opInIdx: "); print_dbg_ulong(in->opInIdx); print_dbg("; got flag: "); print_dbg_ulong(in->play); // dummy byte for alignment ++src; // dummy byte for alignment ++src; //// FIXME: dumb, this isn't aligned yet.. // dummy byte for alignment // ++src; return src; }
static const u8* inode_unpickle(const u8* src, inode_t* in) { /// don't need to pickle indices because we recreate the op list from scratch // only need these flags: // in->preset = *src++; // play inclusion flag in->play = *src++; #ifdef PRINT_PICKLE print_dbg(" ; opIdx: "); print_dbg_ulong(in->opIdx); print_dbg(" ; opInIdx: "); print_dbg_ulong(in->opInIdx); print_dbg("; got flag: "); print_dbg_ulong(in->play); #endif // dummy byte for alignment ++src; // dummy byte for alignment ++src; // dummy byte for alignment ++src; return src; }
static const u8* onode_unpickle(const u8* src, onode_t* out) { u32 v32; /* // operator output index */ /* src = unpickle_32(src, &v32); */ /* out->opOutIdx = (u8)v32; */ // output target src = unpickle_32(src, &v32); out->target = (s16)v32; /* // index of parent op */ /* src = unpickle_32(src, &v32); */ /* out->opIdx = (s32)v32; */ // preset flag: 32 bits for alignment // src = unpickle_32(src, &v32); // out->preset = (u8)v32; #ifdef PRINT_PICKLE print_dbg(" ; opIdx: "); print_dbg_ulong(out->opIdx); print_dbg(" ; opOutIdx: "); print_dbg_ulong(out->opOutIdx); print_dbg(" ; target: "); print_dbg_ulong(out->target); #endif return src; }
/*! \brief Detect 30 and 60 angles */ void print_angles() { signed int res; static xyz_t angle ; // if ( ! is_acc_slow() ) { return } if( 0!=(res=is_acc_abs_angle_x(60)) ) angle.x = 60; else if( 0!=(res=is_acc_abs_angle_x(30)) ) angle.x = 30; else angle.x = 0 ; if ( angle.x > 0 ) { if( res>0 ) print_dbg("LEFT ") ; else if( res<0 ) print_dbg("RIGHT ") ; print_dbg_ulong(angle.x) ; print_dbg("\r\n") ; } if( 0!=(res=is_acc_abs_angle_y(60)) ) angle.y = 60; else if( 0!=(res=is_acc_abs_angle_y(30)) ) angle.y = 30; else angle.y = 0 ; if ( angle.y > 0 ) { if( res>0 ) print_dbg("DOWN ") ; else if( res<0 ) print_dbg("UP ") ; print_dbg_ulong(angle.y) ; print_dbg("\r\n") ; } }
/*! \brief This example shows how to access an external RAM connected to the SMC module. */ int main(void) { // Get base address of SRAM module volatile uint32_t *sram = SRAM; // Switch to external oscillator 0. pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); // Initialize debug serial line init_dbg_rs232(FOSC0); // Display a header to user print_dbg("\x1B[2J\x1B[H\r\nSMC Example\r\n"); print_dbg("Board running at "); print_dbg_ulong(FOSC0 / 1000000); print_dbg(" MHz\r\n"); print_dbg("Initializing SRAM..."); // Initialize the external SRAM chip. smc_init(FOSC0); print_dbg("done\r\n\r\n"); print_dbg("Testing SRAM...\r\n"); // Test each address location inside the chip with a write/readback uint32_t total_tests = 0; uint32_t total_errors = 0; for (uint32_t total_tests = 0; total_tests < SRAM_SIZE; total_tests++) { sram[total_tests] = total_tests; if (total_tests != sram[total_tests]) { total_errors++; print_dbg("Error at 0x"); print_dbg_hex((uint32_t)&sram[total_tests]); print_dbg("\r\n"); } } if (total_errors == 0) { print_dbg("SRAM test successfully completed\r\n"); } else { print_dbg("SRAM test completed with "); print_dbg_ulong(total_errors); print_dbg(" errors out of "); print_dbg_ulong(total_tests); print_dbg(" tests\r\n"); } while (true); return 0; }
void net_print(void) { print_dbg("\r\n net address: 0x"); print_dbg_hex((u32)(net)); print_dbg("\r\n net input count: "); print_dbg_ulong(net->numIns); print_dbg("\r\n net output count: "); print_dbg_ulong(net->numOuts); print_dbg("\r\n net op count: "); print_dbg_ulong(net->numOps); }
// toggle preset inclusion for output u8 net_toggle_out_preset(u32 id) { u8 tmp = preset_out_enabled(preset_get_select(), id) ^ 1; // net->outs[id].preset ^= 1; // return net->outs[id].preset; print_dbg("\r\n toggled output-preset_enable"); print_dbg(", out: "); print_dbg_ulong(id); print_dbg(", flag: "); print_dbg_ulong(tmp); preset_get_selected()->outs[id].enabled = tmp; return tmp; }
/** * \brief Output result through usart * * \param refhz Frequency of reference clock(Hz) * \param duration Reference clock cycles * \param msrhz Frequency of measured clock(Hz) */ void display_result(uint32_t refhz, uint32_t duration, uint32_t msrhz) { print_dbg("Reference Clock: "); print_dbg_ulong(refhz); print_dbg(" Hz\r\n"); print_dbg("Measured Time: "); print_dbg_ulong(duration); print_dbg(" reference clock cycle\r\n"); print_dbg("Measured Clock: "); print_dbg_ulong(msrhz); print_dbg(" Hz\r\n\n"); }
// function keys void handle_key_0(s32 val) { if(val == 0) { return; } if(check_key(0)) { // select op's inputs on ins page pages[ePageIns].select = net_op_in_idx(*pageSelect, 0); print_dbg("\r\n got 1st input index for selected op ( "); print_dbg_ulong( *pageSelect ); print_dbg(", result : "); print_dbg_ulong( net_op_in_idx(*pageSelect, 0)); // go to inputs page set_page(ePageIns); redraw_ins(); } show_foot(); }
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 }
/** * \brief Device enumeration step 15 * Enables UHI interfaces * * \param add USB address of the setup request * \param status Transfer status * \param payload_trans Number of data transfered during DATA phase */ static void uhc_enumeration_step15( usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans) { UNUSED(add); if ((status!=UHD_TRANS_NOERROR) || (payload_trans!=0)) { for(uint8_t i = 0; i < UHC_NB_UHI; i++) { uhc_uhis[i].uninstall(uhc_dev_enum); } uhc_enumeration_error((status == UHD_TRANS_DISCONNECT)? UHC_ENUM_DISCONNECT : UHC_ENUM_FAIL); return; } // Enable all UHIs supported for (uint8_t i = 0; i < UHC_NB_UHI; i++) { #if UHC_PRINT_DBG print_dbg("\r\n enabling UHI, idx: "); print_dbg_ulong(i); #endif uhc_uhis[i].enable(uhc_dev_enum); } uhc_enum_try = 0; UHC_ENUM_EVENT(uhc_dev_enum, UHC_ENUM_SUCCESS); }
/*! \brief Tests multiple-sector access functions. */ static void at45dbx_example_test_multiple_sector(void) { U32 position = 252; U32 nb_sector = 4; // Initialize counters. at45dbx_example_error_cnt = 0; // Write sectors. print_dbg("\tWriting sectors\r\n"); at45dbx_write_open(position); at45dbx_write_multiple_sector(nb_sector); at45dbx_write_close(); // Read written sectors. print_dbg("\tReading sectors\t"); at45dbx_read_open(position); at45dbx_read_multiple_sector(nb_sector); at45dbx_read_close(); if (!at45dbx_example_error_cnt) { print_dbg(TEST_SUCCESS); } else { print_dbg(TEST_FAIL "\t"); print_dbg_ulong(at45dbx_example_error_cnt); print_dbg(" errors\r\n"); } }
void handle_key_1(s32 val) { s16 newOut; if(val == 0) { return; } if(check_key(1)) { if(altMode) { print_dbg("\r\n splitting output: "); print_dbg_ulong(*pageSelect); newOut = net_split_out(*pageSelect); *pageSelect = newOut; redraw_outs(); } else { // include / exclude in selected preset // show preset name in head region draw_preset_name(); // include / exclude in preset net_toggle_out_preset(*pageSelect); // re-draw selected line to update inclusion glyph // render to tmp buffer render_line(*pageSelect, 0xf); // copy to scroll with highlight render_to_scroll_line(SCROLL_CENTER_LINE, 1); } } show_foot(); }
// init function void scaler_amp_init(void* scaler) { ParamScaler* sc = (ParamScaler*)scaler; print_dbg("\r\n initializing amp scaler for param, label: "); print_dbg(sc->desc->label); // check descriptor if( sc->desc->type != eParamTypeAmp) { print_dbg("\r\n !!! warning: wrong param type for amp scaler"); print_dbg(" ; this param has type: "); print_dbg_ulong(sc->desc->type); } // init flag for static data if(initFlag) { ;; } else { initFlag = 1; // assign tabVal = scaler_get_nv_data(eParamTypeAmp); tabRep = scaler_get_nv_rep(eParamTypeAmp); } sc->inMin = 0; sc->inMax = (tabSize - 1) << inRshift; /// FIXME: should consider requested param range, // and compute a customized multiplier here if necessary. }
// increment value io_t inc_param_value(u32 idx, io_t inc) { io_t in; s32 scaled; print_dbg("\r\n inc_param_value, index: "); print_dbg_ulong(idx); print_dbg(" , input: 0x"); print_dbg_hex(get_param_value(idx)); print_dbg(" , increment: 0x"); print_dbg_hex(inc); in = get_param_value(idx); // use scaler to increment and lookup scaled = scaler_inc( &(net->params[idx].scaler), &in, inc); print_dbg(" , new input: 0x"); print_dbg_hex(in); print_dbg(" , scaled: 0x"); print_dbg_hex(scaled); print_dbg("\r\n\r\n "); // store input value in pnode net->params[idx].data.value = in; net->params[idx].data.changed = 1; ctl_param_change(idx, scaled ); return in; }
const u8* param_unpickle(pnode_t* pnode, const u8* src) { u32 val; // load idx- src = unpickle_32(src, &val); // print_dbg("\r\n unpickled param index: "); // print_dbg_ulong(val); pnode->idx = (u8)val; // load value src = unpickle_32(src, &val); pnode->data.value = (ParamValue)val; print_dbg(" , val: "); print_dbg_ulong(val); // src = unpickle_32(src, &(pnode->data.value.asUint)); // print_dbg("\r\n unpickled param value: "); // print_dbg_ulong(val); // load preset-inclusion // src = unpickle_32(src, &val); // print_dbg("\r\n unpickled param preset flag: "); // print_dbg_ulong(val); // pnode->preset = (u8)val; // load descriptor src = pdesc_unpickle(&(pnode->desc), src); return src; }
void list_scan(dirList_t* list, const char* path) { FL_DIR dirstat; struct fs_dir_ent dirent; list->num = 0; strcpy(list->path, path); if( fl_opendir(path, &dirstat) ) { while (fl_readdir(&dirstat, &dirent) == 0) { if( !(dirent.is_dir) ) { strcpy((char*)(list->nameBuf + (list->num * DIR_LIST_NAME_LEN)), dirent.filename); print_dbg("\r\n added file: "); print_dbg(dirent.filename); print_dbg(" , count: "); print_dbg_ulong(list->num); list->num += 1; } } } print_dbg("\r\n scanned list at path: "); print_dbg(list->path); print_dbg(" , contents : \r\n"); print_dbg((const char*)list->nameBuf); print_dbg("\r\n"); }
// recall everything enabled in given preset void preset_recall(u32 preIdx) { u16 i; print_dbg("\r\n preset_recall INS"); // ins for(i=0; i<net_num_ins(); ++i) { if(presets[preIdx].ins[i].enabled) { print_dbg("\r\n recalling enabled input in target preset, idx: "); print_dbg_ulong(i); net_set_in_value( i, presets[preIdx].ins[i].value ); } } print_dbg("\r\n preset_recall OUTS"); // outs for(i=0; i<net_num_outs(); ++i) { if(presets[preIdx].outs[i].enabled) { print_dbg("\r\n recalling enabled output in target preset, idx: "); print_dbg_ulong(i); print_dbg("\r\n , value: 0x"); print_dbg_hex(presets[preIdx].outs[i].target); net_connect( i, presets[preIdx].outs[i].target ); } } /* print_dbg("\r\n preset_recall PARAMS"); */ /* // params */ /* for(i=0; i<net_num_params(); ++i) { */ /* if(presets[preIdx].params[i].enabled) { */ /* print_dbg("\r\n recalling enabled input in target preset, idx: "); */ /* print_dbg_ulong(i); */ /* set_param_value( i, presets[preIdx].params[i].value ); */ /* } */ /* } */ /// process for play mode if we're in play mode if(pageIdx == ePagePlay) { play_preset(preIdx); } // update selection select = preIdx; }
const u8* pdesc_unpickle(ParamDesc* pdesc, const u8* src) { u32 val; u32 i; print_dbg(", descriptor: "); // store label string for(i=0; i<PARAM_LABEL_LEN; ++i) { pdesc->label[i] = *src; ++src; } print_dbg(" , label: "); print_dbg(pdesc->label); // store type // pad for alignment src = unpickle_32(src, &val); pdesc->type = (u8)val; print_dbg(" \t, type: "); print_dbg_ulong(pdesc->type); // min src = unpickle_32(src, &val); pdesc->min = val; print_dbg(" \t, min: "); print_dbg_hex(pdesc->min); // max src = unpickle_32(src, &val); pdesc->max = val; print_dbg(" , max: "); print_dbg_ulong(pdesc->max); // store radix // pad for alignment src = unpickle_32(src, &val); pdesc->radix = (u8)val; print_dbg(" , radix: "); print_dbg_ulong(pdesc->radix); return src; }
const u8* pdesc_unpickle(ParamDesc* pdesc, const u8* src) { u32 val; u8 i; // store label string for(i=0; i<PARAM_LABEL_LEN; ++i) { pdesc->label[i] = *src; ++src; } print_dbg(" , label: "); print_dbg(pdesc->label); // store type pdesc->type = *src; ++src; print_dbg(" , type: "); print_dbg_ulong(pdesc->type); // store min src = unpickle_32(src, &val); pdesc->min = val; print_dbg(" , min: "); print_dbg_ulong(pdesc->min); // store max src = unpickle_32(src, &val); pdesc->max = val; print_dbg(" , max: "); print_dbg_ulong(pdesc->max); // store radix src = unpickle_32(src, &val); pdesc->radix = val; print_dbg(" , radix: "); print_dbg_ulong(pdesc->radix); return src; }
//void bfin_set_param(u8 idx, f32 x ) { void bfin_set_param(u8 idx, fix16_t x ) { #if 1 #else //static u32 ticks = 0; ParamValueCommon pval; pval.asInt = (s32)x; print_dbg("\r\n bfin_set_param, idx: "); print_dbg_ulong(idx); print_dbg(",\t val: 0x"); print_dbg_hex((u32)x); /* print_dbg(", \t elapsed ms: "); print_dbg_ulong(tcTicks - ticks); print_dbg("\r\n"); ticks = tcTicks; */ // app_pause(); // command bfin_wait(); spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS); spi_write(BFIN_SPI, MSG_SET_PARAM_COM); spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS); //idx bfin_wait(); spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS); spi_write(BFIN_SPI, idx); spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS); // val0 bfin_wait(); spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS); spi_write(BFIN_SPI, pval.asByte[0]); spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS); // val1 bfin_wait(); spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS); spi_write(BFIN_SPI, pval.asByte[1]); spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS); //val2 bfin_wait(); spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS); spi_write(BFIN_SPI, pval.asByte[2]); spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS); //val3 bfin_wait(); spi_selectChip(BFIN_SPI, BFIN_SPI_NPCS); spi_write(BFIN_SPI, pval.asByte[3]); spi_unselectChip(BFIN_SPI, BFIN_SPI_NPCS); // app_resume(); #endif }
static const u8* onode_unpickle(const u8* src, onode_t* out) { u32 v32; // output target src = unpickle_32(src, &v32); out->target = (s16)v32; #ifdef PRINT_PICKLE print_dbg(" ; opIdx: "); print_dbg_ulong(out->opIdx); print_dbg(" ; opOutIdx: "); print_dbg_ulong(out->opOutIdx); print_dbg(" ; target: "); print_dbg_ulong(out->target); #endif return src; }
// toggle play inclusion for input u8 net_toggle_in_play(u32 inIdx) { u32 pidx; if(inIdx < net->numIns) { net->ins[inIdx].play ^= 1; print_dbg("\r\n toggle in.play, op index: "); print_dbg_ulong(net->ins[inIdx].opIdx); print_dbg(" , input idx: "); print_dbg_ulong(net->ins[inIdx].opInIdx); print_dbg(" , result: "); print_dbg(net->ins[inIdx].play ? "1" : "0"); return net->ins[inIdx].play; } else { pidx = inIdx - net->numIns; net->params[pidx].play ^= 1; print_dbg("\r\n toggle param.play, index: "); print_dbg_ulong(pidx); print_dbg(" , result: "); print_dbg(net->params[pidx].play ? "1" : "0"); return net->params[pidx].play; } }
static u8* inode_pickle(inode_t* in, u8* dst) { /// don't need to pickle indices because we recreate the op list from scratch #ifdef PRINT_PICKLE print_dbg("\r\n pickling input node, op index: "); print_dbg_ulong(in->opIdx); print_dbg(" , input idx: "); print_dbg_ulong(in->opInIdx); print_dbg(" , play flag: "); print_dbg_ulong(in->play); #endif // play inclusion flag *dst++ = in->play; // dummy byte for alignment *dst++ = 0; // dummy byte for alignment *dst++ = 0; // dummy byte for alignment *dst++ = 0; return dst; }
// get DSP value given input s32 scaler_get_value(ParamScaler* sc, io_t in) { print_dbg("\r\n scaler_get_value, type: "); print_dbg_ulong(sc->desc->type); scaler_get_value_fn fn = scaler_get_val_pr[sc->desc->type]; if(fn != NULL) { return (*fn)(sc, in); } else { print_dbg("\r\n null function pointer in scaler_get_value"); return 0; } }
// redraw all lines, force selection void redraw_ins(void) { u8 i=0; s32 n = *pageSelect - 3; // num_ins() includes param count! const s32 max = net_num_ins() - 1; // set scroll region // FIXME: should be separate function i guess render_set_scroll(¢erScroll); print_dbg("\r\n redraw_ins() "); while(i<8) { print_dbg("\r\n input page redraw, n: "); print_dbg_ulong(n); if(n == -1) { // draw a blank line region_fill(lineRegion, 0); } else if(n == (max+1)) { // draw a blank line region_fill(lineRegion, 0); } else { if(n < -1) { n += (max + 2); } if( n > max ) { n -= (max + 2); } print_dbg(" , after wrap: "); print_dbg_ulong(n); render_line( n, 0xa ); } render_to_scroll_line(i, n == *pageSelect ? 1 : 0); ++i; ++n; } }
/*! \brief Performs a memory check on all DFs. */ static void at45dbx_example_check_mem(void) { if (at45dbx_mem_check()) { print_dbg("\tSize:\t"); print_dbg_ulong(AT45DBX_MEM_CNT << (AT45DBX_MEM_SIZE - 20)); print_dbg(" MB\t" TEST_SUCCESS); } else { print_dbg(TEST_FAIL); } }
// edit the current seleciton static void select_edit(s32 inc) { print_dbg("\r\n editing ins page selection, idx: "); print_dbg_ulong(*pageSelect); if(*pageSelect != -1) { // increment input value net_inc_in_value(*pageSelect, inc); // render to tmp buffer render_line(*pageSelect, 0xf); // copy to scroll with highlight render_to_scroll_line(SCROLL_CENTER_LINE, 1); } }
// query module name and version void scene_query_module(void) { volatile char * moduleName = sceneData->desc.moduleName; ModuleVersion * moduleVersion = &(sceneData->desc.moduleVersion); /// sets module name/version in scene data to reported name/version print_dbg("\r\n querying module name..."); bfin_get_module_name(moduleName); print_dbg("\r\n querying module version..."); bfin_get_module_version(moduleVersion); strcat((char*)moduleName, ".ldr"); 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); }