IDE & CompactFlash card device driver
A fast device driver that can be used to access data stored in IDE hard disk drive & CompactFlash memory cards.
Overview
The emFile IDE and CompactFlash device driver can be used to access data stored to IDE hard disk drives and CompactFlash (CF) memory cards.
Supported Devices: The IDE and CompactFlash device driver supports most ATA compatible hard disk drives and CompactFlash (CF) memory cards. The access to the storage device is performed using using true IDE or memory card mode.
How embedded devices work
CompactFlash is a small, removable mass storage device. The CompactFlash storage card contains a single chip controller and flash memory module(s) in a matchbook-sized package with a 50-pin connector consisting of two rows of 25 female contacts each on 50 mil (1.27 mm) centers. The controller interfaces with a host system allowing data to be written to and read from the flash memory module(s).
CompactFlash cards are designed with flash technology, a nonvolatile storage solution that does not require a battery to retain data indefinitely. The CompactFlash card specification version 2.0 supports data rates up to 16 MB/second and capacities up to 137 GBytes. CF cards consume only five percent of the power required by small disk drives.
CompactFlash cards support both 3.3V and 5V operation and can be interchanged between 3.3V and 5V systems. This means that any CF card can operate at either voltage. Other small form factor flash cards may be available to operate at 3.3V or 5V, but any single card can operate at only one of the voltages. CF+ data storage cards are also available using magnetic disk (IBM Microdrive).
Modes of operation (interface modes)
Compact Flash cards can operate in three modes:
- Memory card mode
- I/O card mode
- True IDE mode
Supported modes of operation (interface modes)
Currently, TRUE IDE and MEMORY CARD mode are supported.
IDE (ATA) drives
Just like CompactFlash cards, ATA drives have a built-in controller to drive and control the mechanical hardware in a drive. Actually there are two types of connecting ATA drives. 5.25 and 3.5 inch drives are using a 40 pin male interface to connect to an IDE controller. 2.5 and 1.8 inch drives, mostly used in Notebooks and embedded systems, have a 50 pin male interface.
Modes of operation (interface modes)
ATA drives can operate in a variety of different modes:
- PIO (Programmed I/O)
- Multiword DMA
- Ultra DMA
Supported modes of operation (interface modes)
Currently, only PIO mode through TRUE IDE is supported.
Fail-safe operation
Unexpected reset
The data will be preserved.
Power failure
Power failure can be critical: If the card does not have sufficient time to complete a write operation, data may be lost. Countermeasures: make sure the power supply for the card drops slowly.
Sample usage - IDE/CF device driver
The following sample shows how to configure an instance of the IDE/CF device driver. To add the driver, FS_AddDevice() is called with the driver type set to FS_IDE_Driver.
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#define ALLOC_SIZE 0x800 // Size defined in bytes
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static U32 _aMemBlock[ALLOC_SIZE / 4]; // Memory pool used for semi-dynamic allocation.
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* FS_X_AddDevices
*
* Function description
* This function is called by the FS during FS_Init().
* It is supposed to add all devices, using primarily FS_AddDevice().
*
* Note
* (1) Other API functions
* Other API functions may NOT be called, since this function is called
* during initialization. The devices are not yet ready at this point.
*/
void FS_X_AddDevices(void) {
FS_AssignMemory(&_aMemBlock[0], sizeof(_aMemBlock));
FS_AddDevice(&FS_IDE_Driver);
FS_IDE_SetHWType(0, &FS_IDE_HW_Default);
#if FS_USE_FILE_BUFFER
//
// Enable the file buffer to increase the performance when reading/writing a small number of bytes.
//
FS_ConfigFileBufferDefault(512, FS_FILE_BUFFER_WRITE);
#endif
}