static int diag_sd_verify_data(u8* origin, u8* data, u32 len, int sector) { int err_cnt = 0; u32 i; for (i = 0; i < len; i++) { if (origin[i] != data[i]) { err_cnt++; putstr("\r\nSector "); putdec(i / SECTOR_SIZE + sector); putstr(" byte "); putdec(i % SECTOR_SIZE); putstr(" failed data origin: 0x"); puthex(origin[i]); putstr(" data: 0x"); puthex(data[i]); putstr("\r\n"); } } return err_cnt; }
int help(int argc, const char** argv) { shell_func func; //Check if they are trying to find help for a particular command if (argc > 1) { func = get_help(argv[1]); if (func == NULL) { putstr("Sorry no help exists for the command '"); putstr(argv[1]); putstr("'\n"); } else { func(argc, (const char **)argv); } } else { //List all possible commands putstr("Available commands:"); putoptions(get_commands("")); putch('\n'); } return 0; }
pascal int prtdbl(double dbl, int width, int precision, char E) { static char buf[200]; int nn; if (width > 199) width = 199; if (width < -199) width = -199; nn = sprtdbl(buf, dbl, width, precision, E); putstr(buf,width); return nn; }
void addtopl(char *s) { curs(tlx, tly); if((tlx + strlen(s)) > COLNO) { putsym('\n'); } putstr(s); tlx = curx; tly = cury; flags.topl = 1; }
void main(void) { int i; TRISD = 0b00000111; // All SCK, SDI, D_C, _SCE and _RES are output pins. initlcd(); putstr(" PCD-8544 LCD "); // A test message.... Also a new year's greeting. :) cursorxy(0,1); // Next line. putstr("Graphical Demo"); for(;;) { for(i=0;i<num_of_points;i++) { plot_pt[i] = (char)(rand() % 256); // Generate random numbers. Default is 0-255. } plotline(plot_pt, num_of_points, 255, 10, 2); // Plot the smooth(er) line graph. plotbars(plot_pt, num_of_points, 255, 10, 4); // Plot the bar graph version with the same points. // DelayS(5); // Remark this line if you want to see some really blazing fast plotting. :) } }
static void deliver_by_window (struct qtmsg *qt_msg, int how) { long size; winid datawin = create_nhwindow(how); for (size = 0; size < qt_msg->size; size += (long)strlen(in_line)) { (void) dlb_fgets(in_line, 80, msg_file); convert_line(); putstr(datawin, 0, out_line); } display_nhwindow(datawin, true); destroy_nhwindow(datawin); }
int main(void) { u2_init(); // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111"); //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111"); putstr("\ntx_only\n"); // Control LEDs hal_set_leds(0x0, 0x3); if (USE_BUFFER_INTERRUPT) pic_register_handler(IRQ_BUFFER, buffer_irq_handler); pic_register_handler(IRQ_OVERRUN, overrun_irq_handler); pic_register_handler(IRQ_UNDERRUN, underrun_irq_handler); //pic_register_handler(IRQ_TIMER, timer_irq_handler); //hal_set_timeout(timer_delta); ethernet_register_link_changed_callback(link_changed_callback); ethernet_init(); // initialize double buffering state machine for DSP RX -> Ethernet dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0, &dsp_rx_recv_args, &dsp_rx_send_args, dbsm_nop_inspector); // setup receive from ETH // bp_receive_to_buf(CPU_RX_BUF, PORT_ETH, 1, 0, BP_LAST_LINE); #if 0 if (hwconfig_simulation_p()){ // If we're simulating, pretend that we got a start command from the host u2_mac_addr_t host = {{ 0x00, 0x0A, 0xE4, 0x3E, 0xD2, 0xD5 }}; start_rx_cmd(&host); } #endif start_tx_transfers(); // send constant buffers to DSP TX while(1){ if (!USE_BUFFER_INTERRUPT) buffer_irq_handler(0); } }
void inventory(void) { clear(NULL); fgcolor(NULL, C_WHITE); putstr(NULL, 1, 1, "Inventory"); /* item_t *item = inv->head; if (item == NULL) { fgcolor(NULL, C_GREY); putstr(NULL, 1, 3, "Empty"); } else { int y = 3; while (item != NULL) { putstr(NULL, 1, y++, item->name); item = item->next; } } */ fgcolor(NULL, C_GREY); putstr(NULL, 1, 23, "[? for help]"); update(); getkey(); }
void main(void) { char txtbuf[16]=""; Init_Dev(); PORTB=0x00; putstr("\nLongQiu s.&t. Co. Ltd."); putstr("\nhttp://shop36265907.taobao.com"); Dly_ms(1000); PORTB=0xFF; EnableInterrupts; for(;;) { Dly_ms(500); //----------PWM0---------------------------------- sprintf(txtbuf,"\nFrequence: %d0Hz",PWMPER1); putstr(txtbuf); sprintf(txtbuf,"\n duty circle: %d%%",(PWMPER1-PWMDTY1)*100/PWMDTY1); putstr(txtbuf); PORTB_PB0=~PORTB_PB0; }//for(;;) } //main
void redotoplin() { home(); if (strchr(toplines, '\n')) cl_end(); putstr(toplines); cl_end(); tlx = curx; tly = cury; flags.toplin = 1; if (tly > 1) more(); }
static void envset(char *a, char *b) { int al = strlen(a); static char hptr[5]; char *tp = sbrk(al + strlen(b) + 2); if (tp == (char *) -1) { putstr("out of memory.\n"); return; } strcpy(tp, a); tp[al] = '='; strcpy(tp + al + 1, b); env[envn++] = tp; }
/* * Parse the init table, then set up the pointers after the processed * data, and adjust the brk() value to allow for the tables */ static void parse_inittab(void) { idata = inittab = sdata; while (sdata < sdata_end) parse_initline(); /* Allocate space for the control arrays */ initpid = (uint16_t *) idata; idata += 2 * initcount; initptr = (uint8_t **) idata; idata += sizeof(void *) * initcount; if (brk(idata) == -1) putstr("unable to return space\n"); memset(initpid, 0, 2 * initcount); memset(initptr, 0, sizeof(uint8_t *) * initcount); }
void ia_voir(t_world *world, t_cli *ia) { int i; t_card pos; int nb_case; putstr("\033[33mClient numero : "); print_nb(ia->numero); putstr(" voir\n\033[39m"); pos.y = ia->pos.y; pos.x = ia->pos.x; pos.direction = ia->pos.direction; save_cmd(ia, MSG_DEB_VOIR, LEN_DEB_VOIR, 'W'); i = 0; nb_case = 1; while (i <= ia->lvl) { look_rank(world, &pos, nb_case, ia); select_incr(world, &pos, nb_case + 1); nb_case += CASE_PER_LEVEL; i++; } save_cmd(ia, MSG_FIN_VOIR, LEN_FIN_VOIR, 'W'); }
/* =========================================================================== * Write the output window window[0..outcnt-1] and update bytes_out. * (Used for the decompressed data only.) */ void flush_window(void) { unsigned n; uch *in, *out, ch; in = window; out = &output_data[output_ptr]; for (n = 0; n < outcnt; n++) ch = *out++ = *in++; bytes_out += (ulg)outcnt; output_ptr += (ulg)outcnt; outcnt = 0; putstr("."); }
unsigned int serial_load(void *dst) { unsigned char *p = dst; unsigned int idle, len; putstr("Send binary now..."); len = 0; while (len == 0) { for (idle = 0; (idle < 200000); idle++) { if (checkch()) { *p++ = getch(); len++; idle = 0; } } } putstr("\nReceived 0x"); putnum(len); putstr(" bytes\n"); return len; }
void text_Tests(void) { gfx_Cls() ; printf("Text Tests\n") ; putstr("Text Tests") ; txt_Attributes(BOLD + INVERSE + ITALIC + UNDERLINED) ; txt_Xgap(3) ; txt_Ygap(3) ; txt_BGcolour(YELLOW) ; txt_FGcolour(WHITE) ; txt_FontID(FONT3) ; txt_MoveCursor(5, 0) ; putstr("Hello There") ; txt_MoveCursor(6, 2) ; txt_Height(2) ; txt_Width(2) ; txt_Inverse(OFF) ; txt_Italic(OFF) ; txt_Opacity(TRANSPARENT) ; txt_Set(TEXT_COLOUR, LIME) ; txt_Underline(ON) ; txt_Bold(OFF) ; txt_Wrap(88) ; putstr("Hello There") ; txt_Height(1) ; txt_Width(1) ; putCH('z') ; txt_Wrap(0) ; // reset printf("Char height= %d Width= %d\n", charheight('w'), charwidth('w') ) ; txt_BGcolour(BLACK) ; txt_FGcolour(LIME) ; txt_FontID(FONT3) ; txt_MoveCursor(0,0) ; // reset }
static void envset(const char *a, const char *b) { int al = strlen(a); static char hptr[5]; /* May unalign the memory pool but we don't care by this point */ char *tp = sbrk(al + strlen(b) + 2); if (tp == (char *) -1) { putstr("out of memory.\n"); return; } strcpy(tp, a); tp[al] = '='; strcpy(tp + al + 1, b); env[envn++] = tp; }
int copyboot(struct open_file *fp, char *addr) { size_t n; int i, blknum; char *buf; /* Need to use a buffer that can be mapped into DVMA space. */ buf = alloc(bbinfo.bbi_block_size); if (!buf) panic("bootxx: alloc failed"); for (i = 0; i < bbinfo.bbi_block_count; i++) { if ((blknum = bbinfo.bbi_block_table[i]) == 0) break; #ifdef DEBUG printf("bootxx: block # %d = %d\n", i, blknum); #endif if ((fp->f_dev->dv_strategy)(fp->f_devdata, F_READ, blknum, bbinfo.bbi_block_size, buf, &n)) { putstr("bootxx: read failed\n"); return -1; } if (n != bbinfo.bbi_block_size) { putstr("bootxx: short read\n"); return -1; } memcpy(addr, buf, bbinfo.bbi_block_size); addr += bbinfo.bbi_block_size; } return 0; }
void nand_demo() { int (*OS_Entry)(void *); unsigned int offset; int blockno; int blockstart; int blockend; int page; enable_nand(); blockstart=0x20000/0x4000; blockend=blockstart+(0x170000/0x4000); offset=0x31000000; for(blockno=blockstart;blockno<(blockend+1);blockno++) { for(page=0;page<32;page++) { NAND_ReadPage(blockno,page,offset); offset = offset + 512; } } clean_cache(); putstr("OS read successfully\r\n"); putstr("Press any key to continue\r\n"); getchar(); OS_Entry=(int *)0x31000000; OS_Entry(1); }
void start_armboot() { led_flash(); uart_init(); putstr("Lab 4:\r\n"); putstr("Hello World!\r\n"); while(1) { char ch; print_menu(); ch = getchar(); switch(ch) { case '1': NOR_check_id(); break; case '2': putstr("Which block do you want to erase?(0..9)?\r\n"); ch = getchar(); if(ch == '0') putstr("Do you want to erase me? y/n\r\n"); ch = getchar(); if(ch == 'y'||ch == 'Y') NOR_erase_block(0); else NOR_erase_block(ch - '0'); break; case '3': putstr("Here is a nand demo\r\n"); nand_demo(); break; } } }
inline static void buffer_irq_handler(unsigned irq) { // hal_toggle_leds(LED_A); uint32_t status = buffer_pool_status->status; if (0 && (status & ~BPS_IDLE_ALL)){ putstr("status = "); puthex32_nl(status); } dbsm_process_status(&dsp_tx_sm, status); dbsm_process_status(&dsp_rx_sm, status); }
void hex_dump(unsigned char *data, size_t num) { int i; long oldNum; char buf[90]; char *bufp; int line_resid; while (num) { bufp = buf; binarytohex(bufp, (unsigned long)data, 4); bufp += 8; *bufp++ = ':'; *bufp++ = ' '; oldNum = num; for (i = 0; i < 16 && num; i++, num--) { binarytohex(bufp, (unsigned long)data[i], 1); bufp += 2; *bufp++ = (i == 7) ? '-' : ' '; } line_resid = (16 - i) * 3; if (line_resid) { memset(bufp, ' ', line_resid); bufp += line_resid; } memcpy(bufp, "| ", 2); bufp += 2; for (i = 0; i < 16 && oldNum; i++, oldNum--) *bufp++ = BL_ISPRINT(data[i]) ? data[i] : '.'; line_resid = 16 - i; if (line_resid) { memset(bufp, ' ', 16 - i); bufp += 16 - i; } *bufp++ = '\r'; *bufp++ = '\n'; *bufp++ = '\0'; putstr(buf); data += 16; } }
void puthex32(NS16550_t uart, unsigned long val) { const char *C_HEX = "0123456789ABCDEF"; char str[11]; int i; str[0] = '0'; str[1] = 'x'; for (i=0;i<8;i++) str[i+2] = C_HEX[(val & (0xF << (28 - (i*4)))) >> (28 - (i*4))]; str[10] = 0; putstr(uart, str); }
int diag_sd_read(char *argv[]) { int rval = 0; int i = 0; int total_secs; int sector, sectors; u8 *buf = (u8 *)DIAG_SD_BUF_START; rval = diag_sd_init(argv, "Read", 1); if (rval < 0) return rval; total_secs = sdmmc_get_total_sectors(); for (sector = 0, i = 0; sector < total_secs; sector += SECTORS_PER_OP, i++) { if (uart_poll()) break; if ((total_secs - sector) < SECTORS_PER_OP) sectors = total_secs - sector; else sectors = SECTORS_PER_OP; rval = sdmmc_read_sector(sector, sectors, (unsigned int *)buf); putchar('.'); if ((i & 0xf) == 0xf) { putchar(' '); putdec(sector); putchar('/'); putdec(total_secs); putstr(" ("); putdec(sector * 100 / total_secs); putstr("%)\t\t\r"); } if (rval < 0) { putstr("\r\nfailed at sector "); putdec(sector); putstr("\r\n"); break; } if ((sector + SECTORS_PER_OP) >= total_secs) { putstr("\r\n"); sector = -SECTORS_PER_OP; } } putstr("\r\ndone!\r\n"); return rval; }
static void pragmastmt(void) { usch *sb; if (flslvl) return; if (sloscan() != WSPACE) error("bad #pragma"); sb = stringbuf; savstr((const usch *)"\n#pragma "); savln(); putstr(sb); prtline(); stringbuf = sb; }
void nds_show_keys() { winid win; int i; char buffer[BUFSZ]; win = create_nhwindow(NHW_TEXT); for (i = 0; i < numkeys; i++) { sprintf(buffer, "%s = %s", nds_key_to_string(keymap[i].key), nds_command_to_string(keymap[i].command)); putstr(win, ATR_NONE, buffer); } display_nhwindow(win, FALSE); destroy_nhwindow(win); }
void stat_reset(void) /* Reset the statusline pointer and clear old messages if expired. */ { if (stat_ktl > 0 && --stat_ktl == 0) { statusrow= STATUSROW; need_help= 1; } if (need_help && statusrow < (24-2)) { if (statusrow > STATUSROW) stat_start(0); stat_start(0); putstr( "Type '+' or '-' to change, 'r' to read, '?' for more help, 'q' to exit"); } statusrow= STATUSROW; need_help= 0; }
int kprintf(const char *fmt, ...) { char buf[DBG_BUFF_SIZE]; va_list args; if (!fmt) { return 0; } va_start(args, fmt); vsnprintf(buf, DBG_BUFF_SIZE, fmt, args); putstr(buf); va_end(args); return 1; }
void print_atom(CELLP cp, int mode) // アトムの表示 { switch (cp->id) { case _FIX: fprintf(cur_fpo, "%ld", ((NUMP)cp)->value.fix); break; case _FLT: fprintf(cur_fpo, "%#.6g", ((NUMP)cp)->value.flt); break; case _ATOM: putstr(mode, ((ATOMP)cp)->name); break; default: error(ULO); } }
/* * Print current position to output file. */ void prtline() { usch *s, *os = stringbuf; if (Mflag) { if (dMflag) return; /* no output */ if (ifiles->lineno == 1) { s = sheap("%s: %s\n", Mfile, ifiles->fname); write(ofd, s, strlen((char *)s)); } } else if (!Pflag) putstr(sheap("\n# %d \"%s\"\n", ifiles->lineno, ifiles->fname)); stringbuf = os; }