MMC Card Reader Development

From OpenCircuits
(Difference between revisions)
Jump to: navigation, search
(update development)
 
(2 intermediate revisions by one user not shown)
Line 7: Line 7:
 
==Development Roadmap==
 
==Development Roadmap==
 
===Phase 1===
 
===Phase 1===
*Create stdio.h wrapper for file system in freertos_posix
+
*Create fatfs wrapper for file system in freertos_posix
*Use existing I2C EEPROM driver for development
+
*Use existing I2C EEPROM driver for development purpose
 
===Phase 2===
 
===Phase 2===
 
*Circuit design for interfacing MMC
 
*Circuit design for interfacing MMC
Line 26: Line 26:
 
==Software Implementation==
 
==Software Implementation==
 
*Use [http://elm-chan.org/fsw/ff/00index_e.html FatFs] for accessing FAT16 file system.  
 
*Use [http://elm-chan.org/fsw/ff/00index_e.html FatFs] for accessing FAT16 file system.  
*Create a stdio.h wrapper for [http://chungyan5.no-ip.org/vc/?root=freertos_posix freertos_posix]
+
*Create a FatFs Wrapper in [http://chungyan5.no-ip.org/vc/?root=freertos_posix freertos_posix] as an intermediate layer to map API in stdio.h to API in FatFs, for example:
 +
  +--------------------------------------------+
 +
  | POSIX              fopen()                |
 +
  |                      |                    |
 +
  |                      \|/                  |
 +
  |                    open()                |
 +
  |                      |                    |
 +
  |                      \|/                  |
 +
  +--------------------------------------------+
 +
  | FatFs Wrapper    fatfs_open()              |
 +
  |                      |                    |
 +
  |                      \|/                  |
 +
  +--------------------------------------------+
 +
  | FatFs              f_open()                |
 +
  |                      |                    |
 +
  |                      \|/                  |
 +
  |                disk_initialize()          |
 +
  |                      |                    |
 +
  |                      \|/                  |
 +
  +--------------------------------------------+
 +
  | EEPROM        i2c_eeprom_open()          |
 +
  +--------------------------------------------+
  
===Comparison of FatFs and stdio API===
+
 
*to be added
+
===Comparison of stdio and FatFs API===
 +
*selected list for concern
 +
{| border="1" cellspacing="0" cellpadding="5"
 +
! Function !! stdio.h !! FatFs !! Remarks
 +
|-
 +
| Open
 +
|
 +
  FILE *
 +
[http://www.cplusplus.com/reference/clibrary/cstdio/fopen/ fopen] (
 +
  const char * filename,
 +
  const char * mode
 +
 
 +
);
 +
|
 +
  FRESULT
 +
[http://elm-chan.org/fsw/ff/en/open.html f_open] (
 +
  FIL* FileObject,      /* Pointer to the blank file object structure */
 +
  const XCHAR* FileName, /* Pointer to the file neme */
 +
  BYTE ModeFlags        /* Mode flags */
 +
);
 +
|
 +
*'''FILE''' matches '''FIL'''
 +
*'''filename''' matches '''FileName'''
 +
*'''mode''' matches '''ModeFlags'''
 +
*stdio.h has no equivalent '''FRESULT'''
 +
|-
 +
| Read
 +
|
 +
  size_t
 +
[http://www.cplusplus.com/reference/clibrary/cstdio/fread/ fread] (
 +
  void * ptr,
 +
  size_t size,
 +
  size_t count,
 +
  FILE * stream
 +
);
 +
|
 +
  FRESULT
 +
[http://elm-chan.org/fsw/ff/en/read.html f_read] (
 +
  FIL* FileObject,    /* Pointer to the file object structure */
 +
  void* Buffer,      /* Pointer to the buffer to store read data */
 +
  UINT ByteToRead,    /* Number of bytes to read */
 +
  UINT* ByteRead      /* Pointer to the variable to return number of bytes read */
 +
);
 +
|
 +
*'''size_t''' matches '''ByteRead'''
 +
*'''ptr''' matches '''Buffer'''
 +
*'''count''' matches '''ByteToRead'''
 +
*'''stream''' matches '''FileObject'''
 +
*stdio.h has no equivalent '''FRESULT'''
 +
|-
 +
| Write
 +
|
 +
  size_t
 +
[http://www.cplusplus.com/reference/clibrary/cstdio/fwrite/ fwrite] (
 +
  const void * ptr,
 +
  size_t size,
 +
  size_t count,
 +
  FILE * stream
 +
);
 +
|
 +
  FRESULT
 +
[http://elm-chan.org/fsw/ff/en/write.html f_write] (
 +
  FIL* FileObject,    /* Pointer to the file object structure */
 +
  const void* Buffer,  /* Pointer to the data to be written */
 +
  UINT ByteToWrite,    /* Number of bytes to write */
 +
  UINT* ByteWritten    /* Pointer to the variable to return number of bytes written */
 +
);
 +
|
 +
*'''size_t''' matches '''ByteWritten'''
 +
*'''ptr''' matches '''Buffer'''
 +
*'''count''' matches '''ByteToWrite'''
 +
*'''stream''' matches '''FileObject'''
 +
*stdio.h has no equivalent '''FRESULT'''
 +
|-
 +
| Close
 +
|
 +
  int
 +
[http://www.cplusplus.com/reference/clibrary/cstdio/fclose/ fclose] (
 +
  FILE * stream
 +
);
 +
|
 +
  FRESULT
 +
[http://elm-chan.org/fsw/ff/en/close.html f_close] (
 +
  FIL* FileObject    /* Pointer to the file object structure */
 +
);
 +
|
 +
*'''int''' matches '''FRESULT'''
 +
*'''stream''' matches '''FileObject'''
 +
|-
 +
|}

Latest revision as of 20:51, 25 August 2009

This wiki describes the development of the MMC Card Reader Project

Contents

[edit] Architecture

  • See here for block diagram


[edit] Development Roadmap

[edit] Phase 1

  • Create fatfs wrapper for file system in freertos_posix
  • Use existing I2C EEPROM driver for development purpose

[edit] Phase 2

  • Circuit design for interfacing MMC

[edit] Phase 3

  • SPI driver for MMC

[edit] Phase 4

  • Test for normal read/write function
  • hotswap (should not hang or cause voltage dip)
  • multiple file read/write (protection)


[edit] Circuit and PCB


[edit] Software Implementation

  • Use FatFs for accessing FAT16 file system.
  • Create a FatFs Wrapper in freertos_posix as an intermediate layer to map API in stdio.h to API in FatFs, for example:
 +--------------------------------------------+
 | POSIX              fopen()                 |
 |                       |                    |
 |                      \|/                   |
 |                     open()                 |
 |                       |                    |
 |                      \|/                   |
 +--------------------------------------------+
 | FatFs Wrapper    fatfs_open()              |
 |                       |                    |
 |                      \|/                   |
 +--------------------------------------------+
 | FatFs              f_open()                |
 |                       |                    |
 |                      \|/                   |
 |                disk_initialize()           |
 |                       |                    |
 |                      \|/                   |
 +--------------------------------------------+
 | EEPROM         i2c_eeprom_open()           |
 +--------------------------------------------+


[edit] Comparison of stdio and FatFs API

  • selected list for concern
Function stdio.h FatFs Remarks
Open
 FILE * 

fopen (

 const char * filename, 
 const char * mode
 

);

 FRESULT 

f_open (

 FIL* FileObject,       /* Pointer to the blank file object structure */
 const XCHAR* FileName, /* Pointer to the file neme */
 BYTE ModeFlags         /* Mode flags */

);

  • FILE matches FIL
  • filename matches FileName
  • mode matches ModeFlags
  • stdio.h has no equivalent FRESULT
Read
 size_t 

fread (

 void * ptr, 
 size_t size, 
 size_t count, 
 FILE * stream 

);

 FRESULT 

f_read (

 FIL* FileObject,    /* Pointer to the file object structure */
 void* Buffer,       /* Pointer to the buffer to store read data */
 UINT ByteToRead,    /* Number of bytes to read */
 UINT* ByteRead      /* Pointer to the variable to return number of bytes read */

);

  • size_t matches ByteRead
  • ptr matches Buffer
  • count matches ByteToRead
  • stream matches FileObject
  • stdio.h has no equivalent FRESULT
Write
 size_t 

fwrite (

 const void * ptr, 
 size_t size, 
 size_t count, 
 FILE * stream 

);

 FRESULT 

f_write (

 FIL* FileObject,     /* Pointer to the file object structure */
 const void* Buffer,  /* Pointer to the data to be written */
 UINT ByteToWrite,    /* Number of bytes to write */
 UINT* ByteWritten    /* Pointer to the variable to return number of bytes written */

);

  • size_t matches ByteWritten
  • ptr matches Buffer
  • count matches ByteToWrite
  • stream matches FileObject
  • stdio.h has no equivalent FRESULT
Close
 int 

fclose (

 FILE * stream 

);

 FRESULT 

f_close (

 FIL* FileObject     /* Pointer to the file object structure */

);

  • int matches FRESULT
  • stream matches FileObject
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox