File System Component  Version 6.6
MDK-Professional Middleware for Devices with Flash File System
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Media Support Routines

Media support routines provide media management functions. More...

Functions

int32_t fs_mc_read_cd (uint32_t drive_num)
 Callback function used to read Card Detect (CD) pin state when Memory Card is used in SPI mode.
 
int32_t fs_mc_read_wp (uint32_t drive_num)
 Callback function used to read Write Protect (WP) pin state when Memory Card is used in SPI mode.
 
int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss)
 Callback function used to control Slave Select signal when Memory Card is used in SPI mode.
 
fsLockUnlockfs_mc_lock_unlock (uint32_t drive_num)
 Callback function used to retrieve password management information in order to manage locked memory card device during initialization.
 

Description

Function Documentation

fsLockUnlock * fs_mc_lock_unlock ( uint32_t  drive_num)
Parameters
[in]drive_numMemory Card Drive number
Returns
pointer to fsLockUnlock structure or NULL when structure not available

The function fs_mc_lock_unlock returns media lock/unlock information structure. Application optionally implements this function and ensure proper drive_num mapping.

The argument drive_num is specifying a Memory Card drive instance number.

Code Example

// Memory card password
const uint8_t mc0_pass[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
// Media lock/unlock information structure
fsLockUnlock mc0_lock;
// Provide password management information
fsLockUnlock *fs_mc_lock_unlock (uint32_t drive_num) {
if (drive_num == 0) {
// Drive M0 is requesting password protection info
mc0_lock.password = mc0_pass;
mc0_lock.length = 5;
mc0_lock.flags = 0; // Unlock memory card
return (&mc0_lock);
}
return (NULL);
}
int32_t fs_mc_read_cd ( uint32_t  drive_num)
Parameters
[in]drive_numMemory Card Drive number
Returns
1:card detected, 0:card not detected, or error

The function fs_mc_read_cd returns memory card detection state. Application optionally implements this function and ensure proper drive_num mapping to Card Detect (CD) pin on the Memory Card socket.

The argument drive_num is specifying a Memory Card drive instance number.

Code Example

int32_t fs_mc_read_cd (uint32_t drive_num) {
switch (drive_num) {
case 0:
printf ("Drive M0 requests Memory Card detection state!\n");
if (GPIO->PINSTATE & MC0_CARD_DETECT_PIN) {
// Memory Card is detected
return 1;
}
break;
case 1:
printf ("Drive M1 requests Memory Card detection state!\n");
if (GPIO->PINSTATE & MC1_CARD_DETECT_PIN) {
// Memory Card is detected
return 1;
}
break;
default:
break;
}
// Card not detected or error
return (0);
}
int32_t fs_mc_read_wp ( uint32_t  drive_num)
Parameters
[in]drive_numMemory Card Drive number
Returns
1:write protected, 0:not write protected, or error

The function fs_mc_read_wp returns memory card write protection state. Application optionally implements this function and ensure proper drive_num mapping to Write Protect (WP) pin on the Memory Card socket.

The argument drive_num is specifying a Memory Card drive instance number.

int32_t fs_mc_spi_control_ss ( uint32_t  drive_num,
uint32_t  ss 
)
Parameters
[in]drive_numMemory Card Drive number
[in]ssSlave select signal state
Returns
execution status
  • slave select signal state: 1:active, 0:inactive
  • -1: slave select signal control is not implemented

The function fs_mc_spi_control_ss controls Slave Select (SS) signal state. Application optionally implements this function and ensure proper drive_num mapping to SS pin on the Memory Card socket. Its return value indicates current SS signal state or when -1 is returned, that SS signal control is not implemented by this function and must be controlled using SPI driver.

The argument drive_num is specifying a Memory Card drive instance number.

The argument ss is specifying a Slave Select signal state: 0=inactive, 1=active