2014-02-25 09:16 AM
Hi,
I am trying to modify function static uint8_t Explore_Disk (char* path , uint8_t recu_level); from USB host example for writing our more than 1 subdirectory and for SD card. I added : else if(recu_level == 3) { LCD_DbgLog('' | | |''); } and if(((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 2)) { Explore_Disk(fn, 3); } so now my code looks like that: static uint8_t Explore_Disk (char* path , uint8_t recu_level) { FRESULT res; FILINFO fno; DIR dir; char *fn; //char tmp[14]; char tmp[21]; res = f_opendir(&dir, path); if (res == FR_OK) { while(((SD_Detect())==SD_PRESENT)) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } fn = fno.fname; strcpy(tmp, fn); line_idx++; if(line_idx > 14) { line_idx = 0; LCD_SetTextColor(Green); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, '' ''); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, ''Press Key to continue...''); LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR); } if(recu_level == 1) { LCD_DbgLog('' |__''); } else if(recu_level == 2) { LCD_DbgLog('' | |__''); } /******** ADDED*********/ else if(recu_level == 3) { LCD_DbgLog('' | | |''); /***********************/ if((fno.fattrib & AM_MASK) == AM_DIR) { strcat(tmp, ''\n''); LCD_UsrLog((void *)tmp); } else { strcat(tmp, ''\n''); LCD_DbgLog((void *)tmp); } if(((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 1)) { Explore_Disk(fn, 2); } /******** ADDED*********/ if(((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 2)) { Explore_Disk(fn, 3); } /***********************/ } } return res; } The problem is,that it still doesnt write out more than 1 subdirectory and the recu_level is never 3, but I have really no clue why. Does anyone has any idea why please? Thank you. Jan2014-02-25 10:06 AM
What's the purpose here?
Do you have an adequate stack to permit this recursion?2014-02-25 10:22 AM
There is no special purpose, I would like to just know, how does it work and why my modification doesnt work. And I have no special stack, I just hoped that this small modification could help.