2011-07-25 23:55:33 +00:00
|
|
|
#include <sysinit.h>
|
|
|
|
|
|
|
|
#include "basic/basic.h"
|
|
|
|
|
|
|
|
#include "lcd/print.h"
|
|
|
|
#include "filesystem/ff.h"
|
|
|
|
#include "usb/usbmsc.h"
|
|
|
|
|
|
|
|
|
2011-07-30 09:17:35 +00:00
|
|
|
FATFS FatFs;
|
2011-07-25 23:55:33 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
|
2011-07-30 09:17:35 +00:00
|
|
|
void init(void)
|
|
|
|
{
|
2011-07-26 23:02:26 +00:00
|
|
|
systickInit(SYSTICKSPEED);
|
|
|
|
|
2011-07-25 23:55:33 +00:00
|
|
|
gpioSetValue (RB_LED0, 0);
|
|
|
|
gpioSetValue (RB_LED1, 0);
|
|
|
|
gpioSetValue (RB_LED2, 0);
|
|
|
|
gpioSetValue (RB_LED3, 0);
|
|
|
|
IOCON_PIO1_11 = 0x0;
|
|
|
|
gpioSetDir(RB_LED3, gpioDirection_Output);
|
2011-07-30 09:17:35 +00:00
|
|
|
}
|
2011-07-25 23:55:33 +00:00
|
|
|
|
2011-07-30 09:17:35 +00:00
|
|
|
void format(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
lcdPrintln("Mount DF:");
|
|
|
|
res=f_mount(0, &FatFs);
|
|
|
|
lcdPrintln(f_get_rc_string(res));
|
|
|
|
lcdRefresh();
|
2011-07-25 23:55:33 +00:00
|
|
|
|
2011-07-30 09:17:35 +00:00
|
|
|
lcdPrintln("Formatting DF...");
|
|
|
|
res=f_mkfs(0,1,0);
|
|
|
|
lcdPrintln(f_get_rc_string(res));
|
|
|
|
lcdRefresh();
|
|
|
|
}
|
2011-07-25 23:55:33 +00:00
|
|
|
|
2011-07-30 09:17:35 +00:00
|
|
|
void msc(int timeout)
|
|
|
|
{
|
|
|
|
lcdPrintln("MSC Enabled.");
|
|
|
|
lcdRefresh();
|
|
|
|
delayms_power(300);
|
|
|
|
usbMSCInit();
|
|
|
|
while(timeout--)
|
|
|
|
delayms(1000);
|
|
|
|
lcdPrintln("MSC Disabled.");
|
|
|
|
usbMSCOff();
|
|
|
|
lcdRefresh();
|
|
|
|
}
|
2011-07-25 23:55:33 +00:00
|
|
|
|
2011-07-30 09:17:35 +00:00
|
|
|
void isp(void)
|
|
|
|
{
|
|
|
|
lcdPrintln("Enter ISP!");
|
|
|
|
lcdRefresh();
|
|
|
|
ISPandReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void main_initial(void) {
|
|
|
|
init();
|
|
|
|
format();
|
|
|
|
msc(10);
|
|
|
|
isp();
|
2011-07-25 23:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tick_initial(void){
|
|
|
|
static int foo=0;
|
|
|
|
static int toggle=0;
|
2011-07-26 23:02:26 +00:00
|
|
|
incTimer();
|
2011-07-25 23:55:33 +00:00
|
|
|
if(foo++>80){
|
|
|
|
toggle=1-toggle;
|
|
|
|
foo=0;
|
|
|
|
gpioSetValue (RB_LED0, toggle);
|
|
|
|
};
|
|
|
|
};
|