Rev 119 | Rev 171 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 119 | Rev 146 | ||
---|---|---|---|
Line 503... | Line 503... | ||
503 | /****************************************************************************************************************************************/ |
503 | /****************************************************************************************************************************************/ |
504 | u8 Fat16_Deinit(void) |
504 | u8 Fat16_Deinit(void) |
505 | { |
505 | { |
506 | s16 returnvalue = 0; |
506 | s16 returnvalue = 0; |
507 | u8 cnt; |
507 | u8 cnt; |
- | 508 | ||
- | 509 | UART1_PutString("\r\n FAT16 deinit..."); |
|
508 | // declare the filepointers as unused. |
510 | // declare the filepointers as unused. |
509 | for(cnt = 0; cnt < FILE_MAX_OPEN; cnt++) |
511 | for(cnt = 0; cnt < FILE_MAX_OPEN; cnt++) |
510 | { |
512 | { |
511 | if(FilePointer[cnt].State == FSTATE_USED) |
513 | if(FilePointer[cnt].State == FSTATE_USED) |
512 | { |
514 | { |
Line 514... | Line 516... | ||
514 | } |
516 | } |
Line 515... | Line 517... | ||
515 | 517 | ||
516 | } |
518 | } |
517 | SDC_Deinit(); // uninitialize interface to sd-card |
519 | SDC_Deinit(); // uninitialize interface to sd-card |
- | 520 | Partition.IsValid = 0; // mark data in partition structure as invalid |
|
518 | Partition.IsValid = 0; // mark data in partition structure as invalid |
521 | UART1_PutString("ok"); |
519 | return(returnvalue); |
522 | return(returnvalue); |
Line 520... | Line 523... | ||
520 | } |
523 | } |
521 | 524 | ||
Line 873... | Line 876... | ||
873 | // calculate byte offset of the current cluster within that fat sector |
876 | // calculate byte offset of the current cluster within that fat sector |
874 | byte = fat_byte_offset % BYTES_PER_SECTOR; |
877 | byte = fat_byte_offset % BYTES_PER_SECTOR; |
875 | // if new sector is not the sector in buffer or the last cluster in the chain was traced |
878 | // if new sector is not the sector in buffer or the last cluster in the chain was traced |
876 | if((sector != sector_in_buffer) || !repeat) |
879 | if((sector != sector_in_buffer) || !repeat) |
877 | { // write sector in buffer |
880 | { // write sector in buffer |
878 | if(SD_SUCCESS != SDC_PutSector(sector_in_buffer,buffer)) return 0; |
881 | if(SD_SUCCESS != SDC_PutSector(sector_in_buffer,buffer)) |
- | 882 | { |
|
- | 883 | Fat16_Deinit(); |
|
- | 884 | return 0; |
|
- | 885 | } |
|
879 | } |
886 | } |
880 | } |
887 | } |
881 | while(repeat); |
888 | while(repeat); |
Line 882... | Line 889... | ||
882 | 889 |