Ejemplo n.º 1
0
void draw_fsel(void) {
	uint8_t i;
	char *uptr;
	
	fsel_hasnextpage = 1;
	ser_puts("opendir");
	if (philes_opendir() == FR_OK) {
		ser_puts(" ok"); ser_nl();

		// skip until pagestart
		if (fsel_pagestart != 0) {
			for (i = 0; i < fsel_pagestart; i++) {
				if (philes_nextfile(0, 0) != FR_OK) {
					fsel_pagestart = 0;
					break;
				}
			}
		}
		
		// show files
		for (i = 0; i < FSEL_PAGESIZE; i++) {
			uptr = dmem + fsel_index2offs(i);
			memset(uptr, 32, 12);
			if (philes_nextfile(uptr, 0) != FR_OK) {
				fsel_hasnextpage = 0;
				// keep filling the screen though
			}
		}
	}
}
Ejemplo n.º 2
0
void main(void) {
	BYTE res;
	//UINT bytesread;
	//FIL	file1;

	DRESULT result;
	FRESULT fresult;
	
	SLAVE_STATUS = 0;
	GREEN_LEDS = 0xC3;

	ser_puts("@");
	delay2(10);
	
	ser_nl(); ser_puts(cnotice1); 
	ser_nl(); ser_puts(cnotice2);

	thrall(ptrfile, Buffer);
//	for(;;) {
//		philes_mount();
//		fresult = philes_opendir();
//		
//		if (fresult == FR_OK) {
//			philes_nextfile(ptrfile+10, 1);
//		}
//		ser_puts("=> "); ser_puts(ptrfile); ser_nl();
//
//		useimage(ptrfile, Buffer);
//		ser_puts("RELOAD");
//		delay2(100);
//	}
	print_result(result);
	ser_puts("\r\nWTF?");
}
Ejemplo n.º 3
0
void print_result(DRESULT result) {
	switch (result) {
		case 0:
			break;
		default:
			ser_puts(" :( ");
			print_hex((BYTE)result);
			ser_nl();
			break;
	}
}
Ejemplo n.º 4
0
void serial_test(void) {

	// serial communication
	ser_init(ser115200); // init

	char* console = (char*) "\nlightOs> "; // console message
	char* buffer;
	int buffer_len = 64; // size of buffer
	char* recString;



	ser_puts((const signed char*) "\n welcome to lightOS\n");
	while(1)
	{
		buffer = (char*) malloc(sizeof(char)*buffer_len);
		ser_puts((const signed char*) console);
		recString = ser_gets(buffer, buffer_len);
		ser_puts((const signed char*) recString);
		free(buffer);
	}
}
Ejemplo n.º 5
0
void main ( void )
{
     
     init_ext1();
     HW_delay(2);
     init_timer0();
     HW_delay(2);
     init_serial();
     HW_delay(300);

     ser_puts("Ola!");
     
     for (;;){			// main loop.
	  HW_delay(1);
     }
     
}
Ejemplo n.º 6
0
uint8_t menu_dispatch(uint8_t tick) {
	uint8_t result = MENURESULT_NOTHING;
	
	if (tick && (state == STATE_ABOOT2)) {
		aboot_anim(); 
	}

	if (inactivity) inactivity--;
	if (!inactivity && state == STATE_FSEL) {
		menu_init();
	}
	
	if (JOYSTICK != joy_status) {
		joy_status = JOYSTICK;
		
		inactivity = INACTIVITY;
		
		switch (state) {
		case STATE_ABOOT:
			if (joy_status == 0) {
				state = STATE_ABOOT2;
			}
			break;
			
		case STATE_MENU:
			if (joy_status & JOY_UP) menu_y = 0;
			else if (joy_status & JOY_DN) menu_y = 2;
			else menu_y = 1;
			
			if (joy_status & JOY_LT) menu_x = 0;
			else if (joy_status & JOY_RT) menu_x = 2;
			else menu_x = 1;

			draw_menu();
			
			if (joy_status & JOY_FIRE) {
				state = STATE_WAITBREAK;
				menu_selected = menu_x+menu_y*3;
			}
			break;
			
		case STATE_WAITBREAK:
			if (!(joy_status & JOY_FIRE)) {
				switch_state();
			}
			break;
			
		case STATE_WAITBREAK2:
			if (!(joy_status & JOY_FIRE)) {
				fsel_getselected(ptrfile + 10);
				ser_puts("Selected image: "); ser_puts(ptrfile); ser_nl();
				menu_init();
				result = MENURESULT_DISK;
			}
			break;
			
		case STATE_ABOOT2:
			if (!(joy_status & JOY_FIRE)) {
				menu_init();
			}
			break;
			
		case STATE_FSEL:
			if (joy_status & JOY_UP) {
				if (menu_y > 0)	{
					menu_y -= 1;
				} else if (fsel_pagestart != 0) {
					fsel_pagestart -= FSEL_PAGESIZE-1;
					menu_y = FSEL_NLINES-1;
					fsel_redraw = 1;
				}
			} 
			
			if (joy_status & JOY_DN) {
				if (menu_y  < FSEL_NLINES-1) {
					menu_y += 1;
				} else if (fsel_hasnextpage) {
					menu_y = 0;
					fsel_pagestart += FSEL_PAGESIZE-1;
					fsel_redraw = 1;
				}
			}
			
			if (joy_status & JOY_LT) {
				menu_x = (menu_x - 1) % 2;
			}
			
			if (joy_status & JOY_RT) {
				menu_x = (menu_x + 1) % 2;
			}
			
			if (fsel_redraw) {
				fsel_redraw = 0;
				draw_fsel();
			}

			fsel_showselection(0);
			menu_selected = menu_y*2 + menu_x;
			fsel_showselection(1);
			
			if (joy_status & JOY_FIRE != 0) {
				state = STATE_WAITBREAK2;
			}
		
			break;
		}
	}
	
	return result;
}
Ejemplo n.º 7
0
int main(void (*sr_read)(unsigned int start_sector,
			char *buffer, int num_sectors),
	 void (*ser_puts)(const char *buffer))
{
	char *dst = (char *)LINUX_LOADADDR;
	const struct mbr_part *part;
	unsigned found = 0;
	unsigned int i;

	BUILD_BUG_ON(sizeof(struct mbr_part) != 16);
	BUILD_BUG_ON(sizeof(struct mbr) != SECT_SIZE);

	if (mbr->sig != MBR_SIG) {
		ser_puts("S");
		die();
	}

	for (i = 0; i < NUM_PE; i++) {
		part = &mbr->pe[i];

		/* First partition is Linux */
		if (part->type != PART_TYPE_OTHER_DATA) {
			ser_puts("P");
			continue;
		}

		ser_puts("L");
		sr_read(part->lba, dst, part->num_sects);
		ser_puts(".\r\n");
		found = 1;
		break;
	}

	if (!found) {
		dbg_str("N");
		die();
	}

	/* Prepare ATAGS */
	atags->hdr.tag = ATAG_CORE;
	atags->hdr.size = atag_size(atag_core);
	atags->u.core.flags = 1;
	atags->u.core.pagesize = 4096;
	atags->u.core.rootdev = 0;
	atags = atag_next(atags);

#if (SDRAM_SIZE_MB > 32)
#error "Need to add additional ATAG_MEM for second bank!"
#endif
	atags->hdr.tag = ATAG_MEM;
	atags->hdr.size = atag_size(atag_mem);
	atags->u.mem.start = 0;
	atags->u.mem.size = 8 << 20;
	atags = atag_next(atags);

	atags->hdr.tag = ATAG_MEM;
	atags->hdr.size = atag_size(atag_mem);
	atags->u.mem.start = 0x1000000;
	atags->u.mem.size = 8 << 20;
	atags = atag_next(atags);

	atags->hdr.tag = ATAG_MEM;
	atags->hdr.size = atag_size(atag_mem);
	atags->u.mem.start = 0x4000000;
	atags->u.mem.size = 8 << 20;
	atags = atag_next(atags);

	atags->hdr.tag = ATAG_MEM;
	atags->hdr.size = atag_size(atag_mem);
	atags->u.mem.start = 0x5000000;
	atags->u.mem.size = 8 << 20;
	atags = atag_next(atags);

	atags->hdr.tag = ATAG_NONE;
	atags->hdr.size = 0;

	/* Start kernel, bye! */
	ser_puts("G\r\n");

	void (*kernel_start)(int, int, uint32_t) = (void *)LINUX_LOADADDR;
	kernel_start(0, TS72XX_MACH_NUM, ATAGS_OFFSET);

	return 0;
}