Cleanup executor

This commit is contained in:
Stefan `Sec` Zehl 2011-07-13 01:13:50 +02:00
parent 02b45cdce2
commit 12818d6411
1 changed files with 26 additions and 27 deletions

View File

@ -4,77 +4,76 @@
#include "lcd/lcd.h" #include "lcd/lcd.h"
#include "lcd/allfonts.h" #include "lcd/allfonts.h"
#include "lcd/print.h"
#include "usb/usbmsc.h" #include "usb/usbmsc.h"
#include "filesystem/ff.h" #include "filesystem/ff.h"
extern void * sram_top;
/**************************************************************************/ /**************************************************************************/
void put_rc_y (FRESULT rc, int y) {
DoString(0,y,f_get_rc_string(rc));
}
void put_rc (FRESULT rc){
put_rc_y(rc,0);
};
extern void * sram_top;
void execute_file (const char * fname){ void execute_file (const char * fname){
FRESULT res; FRESULT res;
FIL file; FIL file;
UINT readbytes; UINT readbytes;
void (*dst)(void); void (*dst)(void);
/* XXX: why doesn't this work? sram_top contains garbage?
dst=(void (*)(void)) (sram_top); dst=(void (*)(void)) (sram_top);
lcdPrint("T:"); lcdPrintIntHex(dst); lcdNl();
*/
dst=(void (*)(void)) 0x10001800;
res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ); res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);
put_rc(res); lcdPrint("open: ");
lcdPrintln(f_get_rc_string(res));
lcdRefresh();
if(res){ if(res){
return; return;
}; };
res = f_read(&file, (char *)dst, RAMCODE, &readbytes); res = f_read(&file, (char *)dst, RAMCODE, &readbytes);
put_rc_y(res,8); lcdPrint("read: ");
lcdPrintln(f_get_rc_string(res));
lcdRefresh();
if(res){ if(res){
return; return;
}; };
int dx; lcdPrintInt(readbytes);
dx=DoString(0,16,"read: "); lcdPrintln(" bytes");
DoInt(dx,16,readbytes); lcdRefresh();
lcdDisplay(0);
dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode! dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode!
dst(); dst();
getInput();
}; };
/**************************************************************************/ /**************************************************************************/
void execute_menu(void){ void execute_menu(void){
// int dx=0; FATFS FatFs; /* File system object for logical drive */
int dy=0; FRESULT res;
DoString(0,dy,"Enter RAM!");dy+=8; lcdPrintln("Enter RAM!");
lcdDisplay(0); lcdRefresh();
while(getInput()!=BTN_NONE); while(getInput()!=BTN_NONE);
FATFS FatFs; /* File system object for logical drive */ res=f_mount(0, &FatFs);
put_rc(f_mount(0, &FatFs)); lcdPrint("Mount:");
lcdPrintln(f_get_rc_string(res));
execute_file("0:test.c0d"); execute_file("0:test.c0d");
lcdDisplay(0); lcdRefresh();
while(!getInput());
}; };
void msc_menu(void){ void msc_menu(void){
DoString(0,8,"MSC Enabled."); DoString(0,8,"MSC Enabled.");
lcdDisplay(0); lcdDisplay(0);
usbMSCInit(); usbMSCInit();
getInputWait(); while(!getInputRaw())delayms(10);
DoString(0,16,"MSC Disabled."); DoString(0,16,"MSC Disabled.");
usbMSCOff(); usbMSCOff();
}; };