#include "mmc.h"
#include "board.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 386 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 239 of file mmc.c. References DiskBlock::Raw::buf, Delay(), diskSect, GetStorageInformation(), Temp::i, MMC_NOT_SELECTED, MMC_OFF, MMC_XCS, MmcCommand(), 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 MMC_NOT_SELECTED, MMC_OFF, MMC_SELECTED, MMC_XCS, NO, 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. Definition at line 102 of file mmc.c. References MMC_NOT_SELECTED, MMC_XCS, SPI8Clocks(), and SPIGetChar(). Referenced by GetStorageInformation(), ReadPhysicalSector(), and WritePhysicalSector().
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 Definition at line 319 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 464 of file mmc.c. References LED_OFF, LED_ON, MMC_NOT_SELECTED, MMC_SELECTED, MMC_XCS, MmcWaitForData(), PerformBlockRead(), Public, RED_LED, and SPI8Clocks(). Referenced by InitMMC(), and ReadDiskSector().
Here is the call graph for this function: |
|
Try to switch on the MMC.
Definition at line 211 of file mmc.c. References Delay(), and MmcCommand(). Referenced by InitMMC(), and SeekSector().
Here is the call graph for this function: |
|
Perform MMC Seek Command for offset sectorN*512.
Definition at line 418 of file mmc.c. References Address::b, Address::B::b0, Address::B::b1, Address::B::b2, ConsoleDecipherMMCResponse(), Address::l, MMC_NOT_SELECTED, MMC_XCS, MmcCommand(), 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 485 of file mmc.c. References Address::b, Address::B::b0, Address::B::b1, Address::B::b2, DiskBlock::Raw::buf, dataBufPtr, diskSect, Address::l, LED_OFF, LED_ON, MMC_NOT_SELECTED, MMC_SELECTED, MMC_XCS, MmcCommand(), MmcWaitForData(), DiskBlock::raw, RED_LED, sectorAddress, SPI8Clocks(), SPIGetChar(), SPIPutCharWithoutWaiting, and SPIWait. Referenced by WriteDiskSector().
Here is the call graph for this function: |