Exemple #1
0
int diag_sd_write(char *argv[])
{
	int rval = 0;
	int i, j;
	int total_secs;
	int sector, sectors;
	u8 *buf = (u8 *)DIAG_SD_BUF_START;

	rval = diag_sd_init(argv, "Write", 1);
	if (rval < 0)
		return rval;

	for (i = 0; i < SECTORS_PER_OP * SECTOR_SIZE / 16; i++) {
		for (j = 0; j < 16; j++) {
			buf[(i * 16) + j] = i;
		}
	}

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

		if ((sector + SECTORS_PER_OP) >= total_secs) {
			putstr("\r\n");
			sector = -SECTORS_PER_OP;
		}
	}

	putstr("\r\ndone!\r\n");

	return rval;
}
Exemple #2
0
static int diag_sd_init(char *argv[], const char *test_name, int verbose)
{
	int rval = 0;
	int slot, type;

	putstr("running SD ");
	putstr(test_name);
	putstr(" test ...\r\n");
	putstr("press any key to terminate!\r\n");

	if (strcmp(argv[0], "sd") == 0) {
		slot = SCARDMGR_SLOT_SD;
	} else if (strcmp(argv[0], "sdio") == 0) {
		slot = SCARDMGR_SLOT_SDIO;
	} else if (strcmp(argv[0], "sd2") == 0) {
		slot = SCARDMGR_SLOT_SD2;
	} else {
		slot = SCARDMGR_SLOT_SD;
	}

	if (strcmp(argv[1], "sd") == 0) {
		type = SDMMC_TYPE_SD;
	} else if (strcmp(argv[1], "sdhc") == 0) {
		type = SDMMC_TYPE_SDHC;
	} else if (strcmp(argv[1], "mmc") == 0) {
		type = SDMMC_TYPE_MMC;
	} else if (strcmp(argv[1], "MoviNAND") == 0) {
		type = SDMMC_TYPE_MOVINAND;
	} else {
		type = SDMMC_TYPE_AUTO;
	}

	timer_reset_count(TIMER2_ID);
	timer_enable(TIMER2_ID);
	rval = sdmmc_init(slot, type);
	timer_disable(TIMER2_ID);
	if (verbose) {
		putstr("\r\nInit takes: ");
		putdec(timer_get_count(TIMER2_ID));
		putstr("mS\r\n");
		putstr("SD clock: ");
		putdec(get_sd_freq_hz());
		putstr("Hz\r\n");
#if (SD_HAS_SDXC_CLOCK == 1)
		putstr("SDXC clock: ");
#if (CHIP_REV == A7S)
		putdec((u32)amb_get_sdio_clock_frequency(HAL_BASE_VP));
#else
		putdec((u32)amb_get_sdxc_clock_frequency(HAL_BASE_VP));
#endif
		putstr("Hz\r\n");
#endif
		putstr("total_secs: ");
		putdec(sdmmc_get_total_sectors());
		putstr("\r\n");
	}

	return rval;
}
static int cmd_nand_erase(int argc, char *argv[])
{
	u32 start_block, block, blocks, total_blocks;
	int i, rval;

	total_blocks = flnand.blocks_per_bank * flnand.banks;

	if (argc != 3) {
		uart_putstr("nand_erase [block] [blocks]!\r\n");
		uart_putstr("Total blocks: ");
		uart_putdec(total_blocks);
		uart_putstr("\r\n");
		return -1;
	}

	putstr("erase nand blocks including any bad blocks...\r\n");
	putstr("press enter to start!\r\n");
	putstr("press any key to terminate!\r\n");
	rval = uart_wait_escape(0xffffffff);
	if (rval == 0)
		return -1;

	strtou32(argv[1], &start_block);
	strtou32(argv[2], &blocks);

	for (i = 0, block = start_block; i < blocks; i++, block++) {
		if (uart_poll())
			break;
		if (block >= total_blocks)
			break;

		rval = nand_erase_block(block);

		putchar('.');

		if ((i & 0xf) == 0xf) {
			putchar(' ');
			putdec(i);
			putchar('/');
			putdec(blocks);
			putstr(" (");
			putdec(i * 100 / blocks);
			putstr("%)\t\t\r");
		}

		if (rval < 0) {
			putstr("\r\nfailed at block ");
			putdec(block);
			putstr("\r\n");
		}
	}

	putstr("\r\ndone!\r\n");

	return 0;
}
Exemple #4
0
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
polyval(				/* add vertex to a polygon */
register int  x,
register int y
)
{
    *cap++ = ' ';
    putdec(x);
    *cap++ = ' ';
    putdec(y);
}
Exemple #6
0
int diag_sd_write_speed(char *argv[])
{
	int rval = 0;
	int i, j;
	int total_secs;
	int sector, sectors;
	u8 *buf = (u8 *)DIAG_SD_BUF_START;
	u32 op_size;

	rval = diag_sd_init(argv, "Write Speed", 1);
	if (rval < 0)
		return rval;

	for (i = 0; i < SECTORS_PER_OP * SECTOR_SIZE / 16; i++) {
		for (j = 0; j < 16; j++) {
			buf[(i * 16) + j] = i;
		}
	}

	total_secs = sdmmc_get_total_sectors();
	op_size = 0;
	timer_reset_count(TIMER2_ID);
	timer_enable(TIMER2_ID);
	for (sector = 0; sector < total_secs; sector += SECTORS_PER_OP) {
		if (uart_poll())
			break;

		if ((total_secs - sector) < SECTORS_PER_OP)
			sectors = total_secs - sector;
		else
			sectors = SECTORS_PER_OP;

		rval = sdmmc_write_sector(sector, sectors, (unsigned int *)buf);
		if (rval < 0) {
			putstr("\r\nfailed at sector ");
			putdec(sector);
			putstr("\r\n");
			break;
		}
		op_size += sectors;
	}
	timer_disable(TIMER2_ID);

	putstr("\r\nTotally write 0x");
	puthex(op_size * SECTOR_SIZE);
	putstr(" Bytes in ");
	putdec(timer_get_count(TIMER2_ID));
	putstr(" mS, about ");
	putdec(op_size * 500 / timer_get_count(TIMER2_ID));
	putstr(" KB/s!\r\n\r\n");

	return rval;
}
void
mpoly(		/* start a polygon */
int  x, int y,
int  border, int pat, int color
)
{
    pflush();
    cura0 = (border<<6 & 0100) | (pat<<2 & 014) | (color & 03);
    cap = curargs;
    inpoly = TRUE;
    putdec(x);
    *cap++ = ' ';
    putdec(y);
}
Exemple #8
0
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;
}
Exemple #9
0
static void App_KeyboardInputReport(BYTE deviceAddress, USB_KEYBOARD_DATA *data)
{
    int i;
    /* process input report received from device */
    USBHostHID_ApiImportData(Appl_raw_report_buffer[deviceAddress].ReportData, Appl_raw_report_buffer[deviceAddress].ReportSize
            ,Appl_BufferModifierKeys, &Appl_ModifierKeysDetails[deviceAddress]);
    USBHostHID_ApiImportData(Appl_raw_report_buffer[deviceAddress].ReportData, Appl_raw_report_buffer[deviceAddress].ReportSize
            ,Appl_BufferNormalKeys, &Appl_NormalKeysDetails[deviceAddress]);

#ifdef DEBUG_MODE
    int i;
    putstr( "HID: Raw Report \r\n");
    putstr("ReportSize="); putdec(Appl_raw_report_buffer[deviceAddress].ReportSize);putstr("\r\n");
    for(i=0;i<(Appl_raw_report_buffer[deviceAddress].ReportSize);i++){
        puthex( Appl_raw_report_buffer[deviceAddress].ReportData[i]);
    }
    putstr("\r\n");
#endif

    // modifier
    *((BYTE *)&(data->modifier)) = Appl_raw_report_buffer[deviceAddress].ReportData[0];
    // keycode
    memcpy(data->keycode, &(Appl_raw_report_buffer[deviceAddress].ReportData[2]), 3);

    // check CapsLock NumericLock
    for(i=2;i<(Appl_raw_report_buffer[deviceAddress].ReportSize);i++){
        if(Appl_raw_report_buffer[deviceAddress].ReportData[i] != 0){
            if(Appl_raw_report_buffer[deviceAddress].ReportData[i] == HID_CAPS_LOCK_VAL){
                CAPS_Lock_Pressed[deviceAddress] = !CAPS_Lock_Pressed[deviceAddress];
                LED_Key_Pressed[deviceAddress] = TRUE;
                Appl_led_report_buffer[deviceAddress].CAPS_LOCK = CAPS_Lock_Pressed[deviceAddress];
            }else if(Appl_raw_report_buffer[deviceAddress].ReportData[i] == HID_NUM_LOCK_VAL){
                NUM_Lock_Pressed[deviceAddress] = !NUM_Lock_Pressed[deviceAddress];
                LED_Key_Pressed[deviceAddress] = TRUE;
                Appl_led_report_buffer[deviceAddress].NUM_LOCK = NUM_Lock_Pressed[deviceAddress];
            }
        }
    }

    if(CAPS_Lock_Pressed[deviceAddress]) data->modifier.capslock=1;
    else  data->modifier.capslock=0;

    if(NUM_Lock_Pressed[deviceAddress])  data->modifier.numlock=1;
    else  data->modifier.numlock=0;

    // clear receive buffer
    for(i=0;i<Appl_raw_report_buffer[deviceAddress].ReportSize;i++){
        Appl_raw_report_buffer[deviceAddress].ReportData[i] = 0;
    }

}
Exemple #10
0
heap_t* build_heap(uintptr_t *heap_vaddr, uint8_t is_kernel, uint8_t is_read_only)
{
	// Allocate the structure for our heap
	heap_t *heap = (heap_t*)HEAP_BEGIN;
	
	// Our heap size if the diff between the two addresses, minus the sizes of the structures
	uint32_t heap_size = HEAP_END - HEAP_BEGIN - sizeof(heap_t) - sizeof(block_header_t) - sizeof(block_footer_t);
	puts("building kernel heap: heap, ");
	
	// Configure it
	heap->kernel_heap = is_kernel;
	heap->read_only = is_read_only;
	heap->heap_size = heap_size + sizeof(heap_t) + sizeof(block_header_t) + sizeof(block_footer_t);
	
	puts("header, ");
	
	// Create first element
	block_header_t *hdr = (block_header_t*)(HEAP_BEGIN + sizeof(heap_t)); //alloc_page_to_vaddr(heap_vaddr);
	hdr->flags = 0;
	hdr->magic = HEAP_HEADER_MAGIC;
	hdr->size = heap_size + sizeof(block_header_t) + sizeof(block_footer_t);
	
	puts("footer, ");
	
	block_footer_t *ftr = (block_footer_t*)((uintptr_t)hdr + hdr->size - sizeof(block_footer_t) /*- sizeof(block_footer_t)*/);
	ftr->magic = HEAP_FOOTER_MAGIC;
	ftr->header = hdr;
	
	// Insert first element into the heap
	heap->heap_begin = hdr;
	
	puts("all good\n");
	
	puts("built heap at ");
	puthex((uintptr_t)heap);
	puts(", header at ");
	puthex((uintptr_t)hdr);
	puts(", footer at ");
	puthex((uintptr_t)ftr);
	puts(", heap size ");
	putdec(heap_size / PAGE_SIZE * 4);
	puts("kio \n");
	// We're done, our heap is ready !
	return heap;
}
Exemple #11
0
void putdec(unsigned long v) {
    if (v >= 10) {
        putdec(v / 10);
    }
    putchar(hexDigits[v % 10]);
}
Exemple #12
0
void isr_handler(registers_t regs)
{
   puts("recieved interrupt: ");
   putdec(regs.int_no);
   putch('\n');
}
Exemple #13
0
pass2()
{
	int saved[12] ;
	int i ;
	char line[LINELEN] ;
	char *tail, *arg, *temp, *temp2, *temp3 ;

	/* start pass 3 */
	switch_down(1) ;

	saved[0] = saved[1] = saved[2] = saved[3] = 0 ;
	saved[4] = saved[5] = saved[6] = saved[7] = saved[8] = 0 ;
	saved[9] = saved[10] = saved[11] = 0 ;

	ln1 = alloc(LINELEN) ;
	ln2 = alloc(LINELEN) ;
	ln3 = alloc(LINELEN) ;
	ln4 = alloc(LINELEN) ;
	ln5 = alloc(LINELEN) ;
	ln6 = alloc(LINELEN) ;

	p_read(ln1) ;
	p_read(ln2) ;
	p_read(ln3) ;
	p_read(ln4) ;
	p_read(ln5) ;

	while ( p_read(ln6) ) {

		/* inc or dec top or second on stack */
		if ( strcmp(Ldhl0,ln1) == 0 ||
			 strcmp(Ldhl2,ln1) == 0 ||
			 strcmp(Ldhl4,ln1) == 0 ||
			 strcmp(Ldhl6,ln1) == 0 ) {

			if ( strcmp("\tADD HL,SP",ln2) == 0 &&
				 strcmp(Pushhl,ln3) == 0 &&
				 strcmp("\tCALL ccgint",ln4) == 0 &&
				 (strcmp(Inchl,ln5) == 0 || strcmp(Dechl,ln5) == 0) &&
				 strcmp("\tCALL ccpint",ln6) == 0 ) {

				if ( strcmp(Ldhl6,ln1) == 0 ) {
					c_write(Popix);
					c_write(Popde);
					c_write(Popbc);
				}
				else if ( strcmp(Ldhl4,ln1) == 0 ) {
					c_write(Popde);
					c_write(Popbc);
				}
				else if ( strcmp(Ldhl2,ln1) == 0 ) {
					c_write(Popbc);
				}
				c_write(Pophl);
				c_write(ln5);
				if ( strcmp(Ldhl6,ln1) == 0 ) {
					c_write(Pushhl);
					c_write(Pushbc);
					c_write(Pushde);
					strcpy(ln1,Pushix);
					++saved[3];
				}
				else if ( strcmp(Ldhl4,ln1) == 0 ) {
					c_write(Pushhl);
					c_write(Pushbc);
					strcpy(ln1,Pushde);
					++saved[2];
				}
				else if ( strcmp(Ldhl2,ln1) == 0 ) {
					c_write(Pushhl);
					strcpy(ln1,Pushbc);
					++saved[1];
				}
				else {
					strcpy(ln1,Pushhl);
					++saved[0] ;
				}
				p_read(ln2);
				p_read(ln3);
				p_read(ln4);
				p_read(ln5);
				p_read(ln6);
			}
		}

		/* check for comparison against small constant and jump */
		if ( strcmp(Exdehl, ln1) == 0 &&
			 (arg=match(Ldhl, ln2)) && 
			(strcmp("\tCALL cceq",ln3) == 0 || strcmp("\tCALL ccne",ln3) == 0) )

		  if ( strcmp("\tLD A,H", ln4) == 0 &&
			 strcmp("\tOR L", ln5) == 0 &&
			((tail=match("\tJP NZ,",ln6)) || (tail=match("\tJP Z,",ln6)))) {

			  if ( (i=chk_arg(arg)) != 0 ) {
				if ( strcmp("\tCALL cceq",ln3) == 0 ) {
					if ( match("\tJP NZ,",ln6 ) ) {
						strcpy(line, "\tJP Z,") ;
					}
					else {
						strcpy(line, "\tJP NZ,") ;
					}
					strcat(line, tail) ;
					strcpy(ln6, line) ;
				}
				temp = ln1 ;
				temp2 = ln2 ;
				temp3 = ln3 ;
				ln1 = ln4 ;
				ln2 = ln5 ;
				ln3 = ln6 ;
				ln4 = temp ;
				ln5 = temp2 ;
				ln6 = temp3 ;
				p_read(ln4) ;
				p_read(ln5) ;
				p_read(ln6) ;
				++saved[3+i] ;
			}
		}

		/* lh hl,0 after test has ensured hl is zero */
		if ( strcmp("\tLD A,H", ln1) == 0 ) {
		  if ( strcmp("\tOR L", ln2) == 0 ) {
			if ( match("\tJP NZ,", ln3) ) {
			  if ( strcmp(Ldhl0, ln4) == 0 ) {
				temp = ln4 ;
				ln4 = ln5 ;
				ln5 = ln6 ;
				ln6 = temp ;
				p_read(ln6) ;
				++saved[9] ;
			  }
			}
		  }
		}

		/* return TOS, one item on stack */
		if ( strcmp(Pophl, ln3) == 0 ) {
		  if ( strcmp(Pushhl, ln4) == 0 ) {
			if ( strcmp(Popbc, ln5) == 0 ) {
			  if ( strcmp(Ret, ln6) == 0 ) {
				strcpy(ln4, Ret) ;
				p_read(ln5) ;
				p_read(ln6) ;
				++saved[10] ;
			  }
			}
		  }
		}

		/* return TOS, two items on stack */
		if ( strcmp(Pophl, ln2) == 0 ) {
		  if ( strcmp(Pushhl, ln3) == 0 ) {
			if ( strcmp(Popbc, ln4) == 0 ) {
			  if ( strcmp(Popbc, ln5) == 0 ) {
				if ( strcmp(Ret, ln6) == 0 ) {
				  strcpy(ln3, Popbc) ;
				  strcpy(ln4, Ret) ;
				  p_read(ln5) ;
				  p_read(ln6) ;
				  ++saved[11] ;
				}
			  }
			}
		  }
		}

		c_write(ln1);	
		temp = ln1;
		ln1 = ln2;
		ln2 = ln3;
		ln3 = ln4;
		ln4 = ln5;
		ln5 = ln6;
		ln6 = temp;
		if (cpm(CONIN, 255) == CTRLC) exit() ;
	}
	c_write(ln1);
	c_write(ln2);
	c_write(ln3);
	c_write(ln4);
	c_write(ln5);

	puts("INC or DEC top of stack       "); putdec(saved[0]) ;
	putchar('\n') ;
	puts("INC or DEC 2nd top of stack   "); putdec(saved[1]) ;
	putchar('\n') ;
	puts("INC or DEC 3rd top of stack   "); putdec(saved[2]) ;
	putchar('\n') ;
	puts("INC or DEC 4th top of stack   "); putdec(saved[3]) ;
	putchar('\n') ;
	puts("Test for == or != zero        "); putdec(saved[4]) ;
	putchar('\n') ;
	puts("Test for == or != +/-1        "); putdec(saved[5]) ;
	putchar('\n') ;
	puts("Test for == or != +/-2        "); putdec(saved[6]) ;
	putchar('\n') ;
	puts("Test for == or != +/-3        "); putdec(saved[7]) ;
	putchar('\n') ;
	puts("Test for == or != constant    "); putdec(saved[8]) ;
	putchar('\n') ;
	puts("LD HL,0 when HL is zero       "); putdec(saved[9]) ;
	putchar('\n') ;
	puts("Return TOS, one item on stack "); putdec(saved[10]) ;
	putchar('\n') ;
	puts("Return TOS, two on stack      "); putdec(saved[11]) ;
	putchar('\n') ;
	putchar('\n') ;
	i = saved[0]*9 + saved[1]*7  + saved[2]*5 + saved[3] ;
	i += saved[4]*7 + saved[5]*6 + saved[6]*5 + saved[7]*4 ;
	i += saved[8]*3 + saved[9]*3 + saved[10]*2 + saved[11]*2 ;
	pr_total(i);

	Total += i ;
}
Exemple #14
0
int main()
{
    printf("This works %d%%\n", 100);
    printf("Hello World!\n");
    printf("Norm  nums: %d %u %x %c %s%s", -1, -2, 0xabcdefab, 'X', "x", "\n");

    // Note: these don't work with __simple_printf!
    printf("BFill nums: %4d %12u %10x %3c %3s%s", -1, -2, 0xabcdefab, 'X', "x", "\n");
    printf("LFill nums: %04d %012u %010x %3c %3s%s", -1, -2, 0xabcdefab, 'X', "x", "\n");
#pragma GCC diagnostic ignored "-Wformat"
    // The underlying library actively ignores the zeros -- we want to test it!
    printf("RFill nums: %-04d %-012u %-010x %-3c %-3s%s", -1, -2, 0xabcdefab, 'X', "x", "\n");
    // The underlying library detects and handles this error - we want to test it!
    printf("%");
#pragma GCC diagnostic warning "-Wformat"

#ifdef __TINY_IO_H
    putstr("Put*  nums: ");
    putdec(-1);
    putchar(' ');
    putudec(-1);
    putchar(' ');
    puthex(0xabcdefab);
    putchar(' ');
    putchar('X');
    putchar(' ');
    putstr("x");
    putchar(' ');
    putfnum(0xabcdefab, 16, 0, 10, '0');
    putchar('\n');

    putlhex(-10000000000L);
    putchar(' ');
    putldec(-10000000000L);
    putchar(' ');
    putlfnum(0xabcdefabcdef, 16, 0, 16, '0');
    putchar('\n');
#endif

    char buf[80];
    sprintf(buf, "Norm  nums: %d %u %x %c %s", -1, -2, 0xabcdefab, 'X', "x");
    puts(buf);
    int d;
    unsigned u, x;
    char c;
    char s[20];
    int n = sscanf(buf, "Norm  nums: %d %u %x %c %s\n", &d, &u, &x, &c, s);
    printf("Scan  nums: %d %u %x %c %s (%d scanned)\n", d, u, x, c, s, n);

    printf("\nGimme a character: ");
    char ch = getchar();
    printf("\nYou typed: ");
    putchar(ch);
    putchar('\n');

    int age;
    do {
        printf("\nHow old are you? ");
        scanf("%u", &age);
    } while (!age);
    printf("In ten years, you'll be: %d\n\n", age + 10);

    sprintf(buf, "BFill nums: %4d %12u %10x %3c %3s", -1, -2, 0xabcdefab, 'X', "x");
    puts(buf);
    n = sscanf(buf, "BFill nums: %4d %12u %10x %3c %3s\n",&d, &u, &x, &c, s);
    printf("Scan  nums: %d %u %x %c %s (%d scanned)\n", d, u, x, c, s, n);

    sprintf(buf, "LFill nums: %04d %012u %010x %3c %3s", -1, -2, 0xabcdefab, 'X', "x");
    puts(buf);
    n = sscanf(buf, "LFill nums: %04d %012u %010x %3c %3s\n",&d, &u, &x, &c, s);
    printf("Scan  nums: %d %u %x %c %s (%d scanned)\n", d, u, x, c, s, n);

#ifdef __TINY_IO_H
    printf("\nEnter a string up to 4 characters: ");
    safe_gets(s, 5);
    printf("You entered: %s\n", s);

    printf("\nEnter a decimal: ");
    d = getdec();
    printf("You entered: %d\n", d);

    printf("\nEnter an unsigned decimal: ");
    u = getudec();
    printf("You entered: %d\n", u);

    printf("\nEnter a hex number: ");
    u = gethex();
    printf("You entered: %x\n", u);

    printf("\nEnter a 1-4 digit number: ");
    d = getfnum(10, 1, 4);
    printf("You entered: %d\n", (int)d);

    long long ld;
    unsigned long long lu, lx;

    printf("\nEnter a long long decimal: ");
    ld = getldec();
    printf("You entered: "); putldec(ld); putchar('\n');

    printf("\nEnter an unsigned long long decimal: ");
    lu = getludec();
    printf("You entered: "); putludec(lu); putchar('\n');

    printf("\nEnter a long long hex number: ");
    lx = getlhex();
    printf("You entered: "); putlhex(lx); putchar('\n');

    printf("\nEnter a 1-12 digit long long number: ");
    ld = getlfnum(10, 1, 12);
    printf("You entered: "); putldec(ld); putchar('\n');
#endif

    _serialLock = 1;
    printf("\n\nMultithreaded tests.\n"
           "Note this will be quite messed up because multiple cogs\n"
           "will be doing I/O on a character-by-character basis...\n");
    _start_cog_thread(threadStack(0), &testThread, (void*)1, &tls[0]);
    _start_cog_thread(threadStack(1), &testThread, (void*)2, &tls[1]);
    testThread(0);

    printf("\nBye!\n");

    return 0;
}
Exemple #15
0
void Terminal (void)
{
	U8 c;
	
	if (GetRxByte(&c) == FIFO_ERROR_UNDERFLOW)
		return;
	// While a usable user command on RS232 isn't received, build it
	if (!cmd)
	{
		build_cmd(c);
	}
	// perform the command
	if (cmd)
	{
		switch (cmd_type)
		{
			case CMD_UART:
				DrawUartReg(par_str1[0]-0x30);
				break;
			case CMD_RESET:
				RESET;
				break;
			case CMD_DMA:
				DrawDMAStatus();
				break;
			case CMD_CAN0:
				DrawCanStatus(0);
				break;
			case CMD_CAN1:
				DrawCanStatus(1);
				break;
			case CMD_CAN2:
				DrawCanStatus(2);
				break;
	
			
			#ifdef EN_SR_ZN_CYKL
				case CMD_CYKLE:
					puts((BYTE *)" Среднее время цикла - ");
					putdec(program.SrCikl_mks);
					puts((BYTE *)" мкс \n\r");
					break;
			#endif
		
			case CMD_ADDR:
				puts((BYTE *)" Адрес блока - ");
				putdec(ADDR,3);
				puts((BYTE *)"\n\r");
				
				break;
			case CMD_TIMERS:
				PrintTimerService();
				break;
			//=============================================
			case CMD_HELP:
				// Display help on USART
				puts((BYTE *)MSG_HELP);
				break;
			// Unknown command.
			default:
				// Display error message.
				puts((BYTE *)MSG_ER_CMD_NOT_FOUND);
				break;
		}
		// Reset vars.
		cmd_type = CMD_NONE;
		cmd = false;
		// Display prompt.
		puts((BYTE *)MSG_PROMPT);
	}
}
Exemple #16
0
int diag_sd_verify(char *argv[])
{
	int rval = 0;
	int i;
	int total_secs;
	int sector, sectors;
	u8 *wbuf = (u8 *)DIAG_SD_BUF_START;
	u8 *rbuf = (u8 *)DIAG_SD_BUF_START + 0x100000;

	rval = diag_sd_init(argv, "Verify", 1);
	if (rval < 0)
		return rval;

	for (i = 0; i < SECTORS_PER_OP * SECTOR_SIZE; i++) {
		wbuf[i] = rand() / SECTORS_PER_OP;
	}

	total_secs = sdmmc_get_total_sectors();
	for (i = 0, sector = 0, sectors = 0; sector < total_secs;
		i++, sector += SECTORS_PER_OP) {

		if (uart_poll())
			break;

		sectors++;
		if (sectors > SECTORS_PER_OP)
			sectors = 1;

		rval = sdmmc_write_sector(sector, sectors,
			(unsigned int *)wbuf);
		if (rval != 0) {
			putstr("Write sector fail ");
			putdec(rval);
			putstr(" @ ");
			putdec(sector);
			putstr(" : ");
			putdec(sectors);
			putstr("\r\n");
		}

		rval = sdmmc_read_sector(sector, sectors, (unsigned int *)rbuf);
		if (rval != 0) {
			putstr("Read sector fail ");
			putdec(rval);
			putstr(" @ ");
			putdec(sector);
			putstr(" : ");
			putdec(sectors);
			putstr("\r\n");
		}

		rval = diag_sd_verify_data(wbuf, rbuf,
			(sectors * SECTOR_SIZE), sector);

		putchar('.');

		if ((i & 0xf) == 0xf) {
			putchar(' ');
			putdec(sector);
			putchar('/');
			putdec(total_secs);
			putstr(" (");
			putdec(sector * 100 / total_secs);
			putstr("%)\t\t\r");
		}

		if ((sector + SECTORS_PER_OP) >= total_secs) {
			putstr("\r\n");
			sector = -SECTORS_PER_OP;
		}
	}

	putstr("\r\ndone!\r\n");

	return rval;
}