#include "mmc.h"
#include "board.h"
#include "storage.h"
#include "console.h"
#include "buffer.h"
Include dependency graph for mmc.c:
Go to the source code of this file.
Functions | |
unsigned char | MmcCommand (unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4, unsigned char c5) |
Do one MMC command and return the MMC SPI R1 response. | |
unsigned char | MmcWaitForData () |
MMC Wait For Data start token 0xfe. | |
void | MmcGetData (unsigned int amountOctets) |
Read a Data Block from MMC. | |
unsigned char | GetStorageInformation () |
Returns MMC Card Identification Register in diskSect. | |
unsigned char | RebootMMC () |
Try to switch on the MMC. | |
Public unsigned char | InitMMC () |
Start-up the MMC card. | |
void | PerformBlockRead () |
Perform the actual reading of 512 octets from MMC. | |
void | ConsoleDecipherMMCResponse (unsigned char c) |
Print a human-readable R1 response to console. | |
Public unsigned char | SeekSector (unsigned long sectorN) |
Perform MMC Seek Command for offset sectorN*512. | |
Public unsigned char | ReadPhysicalSector () |
Perform block read of previously sought sector to diskSect. | |
unsigned char | WritePhysicalSector () |
Perform MMC block write from *dataBufPtr to sector sectorAddress.l. |
Definition in file mmc.c.
|
Print a human-readable R1 response to console.
Definition at line 397 of file mmc.c. References KEY_BUTTON, Address::l, sectorAddress, and SPIGetChar(). Referenced by SeekSector().
Here is the call graph for this function: ![]() |
|
Returns MMC Card Identification Register in diskSect.
Definition at line 171 of file mmc.c. References DiskBlock::Raw::buf, diskSect, MmcCommand(), MmcGetData(), MmcWaitForData(), and DiskBlock::raw. Referenced by InitMMC().
Here is the call graph for this function: ![]() |
|
Start-up the MMC card.
Definition at line 246 of file mmc.c. References DiskBlock::Raw::buf, Delay(), diskSect, GetStorageInformation(), Temp::i, MMC_OFF, MmcCommand(), MMCDeselect, MMCSelect, NO, Public, DiskBlock::raw, ReadPhysicalSector(), RebootMMC(), SeekSector(), SPIPutChar, SPIPutCharWithoutWaiting, SPIWait, temp, and YES. Referenced by InitStorage(), and OpenFile().
Here is the call graph for this function: ![]() |
|
Do one MMC command and return the MMC SPI R1 response. Returns 0xff in case of timeout (relies on weak pull-up on the MISO pin). Note that the parameter bytes are used for temporary storage after they are written out. Definition at line 19 of file mmc.c. References Delay(), MMCDeselect, MMCSelect, SPI8Clocks(), SPI_RESULT_BYTE, SPIGetChar(), SPIPutChar, SPIPutCharWithoutWaiting, and SPIWait. Referenced by GetStorageInformation(), InitMMC(), RebootMMC(), SeekSector(), and WritePhysicalSector().
Here is the call graph for this function: ![]() |
|
Read a Data Block from MMC. Use shared global pointer dataBufPtr declared in buffer.h. Does not affect MMC chip select signal.
Definition at line 159 of file mmc.c. References DiskBlock::Raw::buf, dataBufPtr, diskSect, DiskBlock::raw, and SPIGetChar(). Referenced by GetStorageInformation().
Here is the call graph for this function: ![]() |
|
MMC Wait For Data start token 0xfe. First any 0xFF's are read off the mmc. The first non-ff octet is examined. If it's the 0xfe data start token, everything is fine. If not, then some error has occurred. Since we're in an embedded system, it's unclear what we should do then. Current approach is to say all ok but make read block return 0xff's by dropping the MMC card offline. Before that we read "lots" of octets from the MMC to flush any pending data. Finally we return "ALL OK". It's not disasterous at least as long as we don't WRITE to MMC. 12/2005: Well, now we do write to mmc... Definition at line 105 of file mmc.c. References MMCDeselect, SPI8Clocks(), and SPIGetChar(). Referenced by GetStorageInformation(), and ReadPhysicalSector().
Here is the call graph for this function: ![]() |
|
Perform the actual reading of 512 octets from MMC. Note: This is the fast routine to read complete disk block If you have DMA, write this to use it! Definition at line 330 of file mmc.c. References DiskBlock::Raw::buf, dataBufPtr, diskSect, DiskBlock::raw, SPI_RESULT_BYTE, SPIPutCharWithoutWaiting, and SPIWait. Referenced by ReadPhysicalSector().
|
|
Perform block read of previously sought sector to diskSect.
Definition at line 463 of file mmc.c. References MMCDeselect, MMCSelect, MmcWaitForData(), PerformBlockRead(), Public, and SPI8Clocks(). Referenced by InitMMC(), and ReadDiskSector().
Here is the call graph for this function: ![]() |
|
Try to switch on the MMC.
Definition at line 217 of file mmc.c. References Delay(), MmcCommand(), and SPI8Clocks(). Referenced by InitMMC(), and SeekSector().
Here is the call graph for this function: ![]() |
|
Perform MMC Seek Command for offset sectorN*512. In English: Send the Read Sector command to MMC Definition at line 431 of file mmc.c. References Address::b, Address::B::b0, Address::B::b1, Address::B::b2, ConsoleDecipherMMCResponse(), Address::l, MmcCommand(), MMCDeselect, Public, RebootMMC(), and sectorAddress. Referenced by InitMMC(), PrepareToReadDiskSector(), and ReadDiskSector().
Here is the call graph for this function: ![]() |
|
Perform MMC block write from *dataBufPtr to sector sectorAddress.l.
Definition at line 484 of file mmc.c. References Address::b, Address::B::b0, Address::B::b1, Address::B::b2, DiskBlock::Raw::buf, dataBufPtr, diskSect, Address::l, MmcCommand(), MMCDeselect, DiskBlock::raw, sectorAddress, SPI8Clocks(), SPIGetChar(), SPIPutCharWithoutWaiting, and SPIWait. Referenced by WriteDiskSector().
Here is the call graph for this function: ![]() |