Datasheet
Mmc_Fat_QuickFormat
328
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
unsigned char Mmc_Fat_QuickFormat(unsigned char *port, unsigned
char pin, char * mmc_fat_label)
Returns
- 0 - if MMC/SD card was detected, successfully formated and initialized
- 1 - if FAT16 format was unseccessful
- 255 - if MMC/SD card was not detected
Description
Formats to FAT16 and initializes MMC/SD card.
Parameters:
- port: chip select signal port address.
- pin: chip select pin.
- mmc_fat_label: volume label (11 characters in length). If less than 11
characters are provided, the label will be padded with spaces. If null
string is passed volume will not be labeled
Note: This routine can be used instead or in conjunction with Mmc_Fat_Init rou-
tine.
Note: If MMC/SD card already contains a valid boot sector, it will remain
unchanged (except volume label field) and only FAT and ROOT tables will be
erased. Also, the new volume label will be set.
Requires The appropriate hardware SPI module must be previously initialized.
Example
// Pointer to appropriate SPI Read function
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV128, _SPI_CLK_LO_LEAD-
ING);
Spi_Rd_Ptr = SPI1_Read;
// Format and initialize MMC/SD card and MMC_FAT16 library glob-
als
if (!Mmc_Fat_QuickFormat(&mmc_fat_label)) {
// Reinitialize the SPI module at higher speed (change primary
prescaler).
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
ING);
...
}