/********************************************************************* * * _FSTask */ static void _FSTask(void) { FS_FILE * pFile; if (FS_IsLLFormatted("") == 0) { printf("Low level formatting"); FS_FormatLow(""); /* Erase & Low-level format the flash */ } if (FS_IsHLFormatted("") == 0) { printf("High level formatting\n"); FS_Format("", NULL); /* High-level format the flash */ } FS_SetAutoMount("", 0); FS_Mount(""); while (1) { while (1) { char ac[30]; if (FS_IsVolumeMounted("")) { pFile = FS_FOpen("Log.txt", "a+"); sprintf(ac, "OS_Time = %.8d\r\n", OS_GetTime()); FS_Write(pFile, ac, 20); FS_FClose(pFile); } OS_Delay(1000); } } }
/********************************************************************* * * _USBTask */ static void _USBTask(void) { _AddMSD(); USB_Start(); while(1) { // // Wait for configuration // while ((USB_GetState() & (USB_STAT_CONFIGURED | USB_STAT_SUSPENDED)) != USB_STAT_CONFIGURED) { BSP_ToggleLED(0); USB_OS_Delay(50); } BSP_SetLED(0); FS_Unmount(""); USB_MSD_Task(); // Task, does only return when device is non-configured mode FS_Mount(""); } }
int main() { Init(); #ifndef MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Mount(NULL, NULL); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.backlight); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); #if !HAS_EXTENDED_AUDIO // If Extended Audio is present, move startup msg to Splash page to allow additional audio hardware initialization time MUSIC_Play(MUSIC_STARTUP); #else if (Transmitter.splash_delay < 5) MUSIC_Play(MUSIC_STARTUP); // if no splash page startup msg is used force playing here #endif GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if HAS_DATALOG DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) ; //Only do this after we've initialized all channel data so the saftey works PROTOCOL_InitModules(); GUI_DrawScreen(); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //This does not appear to have any impact on power //and has been disabled in common/devo/power.c //but it helps a huge amount for the emulator PWR_Sleep(); } #endif }
int main() { Init(); #ifndef MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Mount(NULL, NULL); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.brightness); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); MUSIC_Play(MUSIC_STARTUP); GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if DATALOG_ENABLED DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) ; //Only do this after we've initialized all channel data so the saftey works PROTOCOL_Init(0); GUI_DrawScreen(); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //PWR_Sleep(); //This does not appear to have any impact on power } #endif }
void debug_filesystem(void) { FS_HANDLE FileHandle=0; UINT32 command; FILE_INFO fileinfo={0}; UINT08 ShortFileName[13]={0}; UINT08 FileBuffer[512]; int FileNo; int iter; do { ShowMenu(); command = ReadKeyInput("Select Command"); switch(command) { case 0x01: { int ret; ret = FS_OpenDriver(); if(ret == 1) dbgprint("Open Driver Success!\n"); else dbgprint("Open Driver Error!\n"); } break; case 0x02: rprint0n("No Use\n"); break; case 0x03: //Mount if(!FS_Mount()) { rprint0n("Mount Fail!\n"); break; } //Open Root Dir fileinfo.Target[0] = '*'; fileinfo.Target[1] = '.'; fileinfo.Target[2] = '*'; if(!FS_OpenRootDir(&fileinfo)) { rprint0n("Open Root Directory Fail!\n"); break; } //Find Start FS_FindStart(&fileinfo); //Show File Name for(iter=0; iter<fileinfo.TotalCount; iter++) { rprint0n("File%02d : ", iter); if(FS_GetFile(iter, &fileinfo)) { if(FS_GetFileName(&fileinfo, ShortFileName) ) { rprint0n("%s : ", ShortFileName); if(FS_IsDirectory(&fileinfo)) { rprint0n("Directory", ShortFileName); } else { rprint0n("File", ShortFileName); } #if 0 { UINT08 index; UINT08 LongFileName[512]={0}; index = FS_GetLongFileName(&fileinfo, LongFileName); ViewLongName(LongFileName, index); } #endif } } rprint0n("\n"); } break; case 0x04: FileNo = (int)ReadDecimalKeyInput("File Number"); if(FileNo >= fileinfo.TotalCount) { rprint0n("Invalid File Number !\n"); break; } //Get File if(FS_GetFile(FileNo, &fileinfo)) { if(FS_IsDirectory(&fileinfo)) { //rprint0n("File Open Fail - Directory\n"); if(FS_OpenDir(&fileinfo)) { FS_FindStart(&fileinfo); //Show File Name for(iter=0; iter<fileinfo.TotalCount; iter++) { rprint0n("File%02d : ", iter); if(FS_GetFile(iter, &fileinfo)) { if(FS_GetFileName(&fileinfo, ShortFileName) ) { rprint0n("%s : ", ShortFileName); if(FS_IsDirectory(&fileinfo)) { rprint0n("Directory", ShortFileName); } else { rprint0n("File", ShortFileName); } } } rprint0n("\n"); } } break; } //Open File FileHandle = FS_OpenFile(&fileinfo); if(FileHandle == 0xFFFFFFFF) { rprint0n("Invalid File Handle!\n"); break; } } rprint0n("File Open - Index %d\n", FileNo); break; case 0x05: if(FileHandle == 0) break; if(FileHandle == 0xFFFFFFFF) break; if(FileHandle == 0xCCCCCCCC) break; //Read File if(FS_ReadFile(FileHandle, FileBuffer, 1)) { dbgprint("^B^============= File Read ===============\n"); hexdump("Read File", FileBuffer, 512); dbgprint("^B^============================================\n"); break; } rprint0n("File Read Fail! or End of File\n"); break; case 0x06: rprint0n("File Close\n"); FS_CloseFile(FileHandle); //Close File break; case 0x07: //UnMount break; case 0xFF: command = INVALID_COMMAND; } }while(command != INVALID_COMMAND); }