keil_examples/USBHostLite/UsbHost/Fat/usbhost_fat.c
/*
**************************************************************************************************************
*                                              PUT SHORT FILE NAME
*
* Description: This function fills the file entry with the short file name given by the user
*
* Arguments  : ent_name_given    File name given by the user
*              entry             Pointer to the FILE_ENTRY structure
*
* Returns    : None
*
**************************************************************************************************************
*/
PUT SHORT FILE NAME
Description: This function fills the file entry with the short file name given by the user

Arguments  : ent_name_given    File name given by the user
entry             Pointer to the FILE_ENTRY structure

Returns    : None
PUT SHORT FILE NAME Description : This function fills the file entry with the short file name given by the user Arguments : ent_name_given File name given by the user entry Pointer to the FILE_ENTRY structure Returns : None
void  FAT_PutSFN (uint8_t  *ent_name_given,
                  FILE_ENTRY  *entry)
{
    uint32_t  idx;
    MS_BulkRecv(entry->EntrySec, 1, FATBuffer);
    for (idx = 0; idx < 8; idx++) {        
        if (*ent_name_given == '.') {
            while (idx < 8) {
                FATBuffer[entry->EntrySecOffset + idx] = 0x20;
                idx++;
            }
            ent_name_given++;
        } else {
            FATBuffer[entry->EntrySecOffset + idx] = *ent_name_given;
            ent_name_given++;
        }
    }
    for (idx = 8; idx < 11; idx++) {                      
        if (*ent_name_given == '.') {
            while (idx < 11) {
                FATBuffer[entry->EntrySecOffset + idx] = 0x20;
                idx++;
            }
        } else {
            FATBuffer[entry->EntrySecOffset + idx] = *ent_name_given;
            ent_name_given++;
        }
    }
    FATBuffer[entry->EntrySecOffset + idx] = 0x20;
    for (idx = 12; idx < 32; idx++) {                           
        FATBuffer[entry->EntrySecOffset + idx] = 0;
    }
    MS_BulkSend(entry->EntrySec, 1, FATBuffer);                 
}
void FAT_PutSFN ( uint8_t * ent_name_given , FILE_ENTRY * entry ) { uint32_t idx ; MS_BulkRecv ( entry -> EntrySec , 1 , FATBuffer ) ; for ( idx = 0 ; idx < 8 ; idx ++ ) { if ( * ent_name_given == ' ' ) { while ( idx < 8 ) { FATBuffer [ entry -> EntrySecOffset + idx ] = 0x20 ; idx ++ ; } ent_name_given ++ ; } else { FATBuffer [ entry -> EntrySecOffset + idx ] = * ent_name_given ; ent_name_given ++ ; } } for ( idx = 8 ; idx < 11 ; idx ++ ) { if ( * ent_name_given == ' ' ) { while ( idx < 11 ) { FATBuffer [ entry -> EntrySecOffset + idx ] = 0x20 ; idx ++ ; } } else { FATBuffer [ entry -> EntrySecOffset + idx ] = * ent_name_given ; ent_name_given ++ ; } } FATBuffer [ entry -> EntrySecOffset + idx ] = 0x20 ; for ( idx = 12 ; idx < 32 ; idx ++ ) { FATBuffer [ entry -> EntrySecOffset + idx ] = 0 ; } MS_BulkSend ( entry -> EntrySec , 1 , FATBuffer ) ; }
PUT SHORT FILE NAME
Description: This function fills the file entry with the short file name given by the user
PUT SHORT FILE NAME Description : This function fills the file entry with the short file name given by the user
/* Read the sector from root directory containing the free entry */ /* Fill the first eight charecters of the entry with file name   */ /* Fill the next 3 charecters with file extension */ /* Fill all the remaining bytes with 0's    */ /* Write the sector into the root directory */