Datasheet
Mmc_Init
Mmc_Read_Sector
325
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
unsigned char Mmc_Init();
Returns
- 1 - if MMC/SD card was detected and successfully initialized
- 0 - otherwise
Description
Initializes hardware SPI communication; The function returns 1 if MMC card is
present and successfully initialized, otherwise returns 0.
Mmc_Init needs to be called before using other functions of this library.
Requires
Global variables :
- Mmc_Chip_Select: Chip Select line
- Mmc_Chip_Select_Direction: Direction of the Chip Select pin
must be defined before using this function.
Example
// MMC module connections
sfr sbit Mmc_Chip_Select at PORTG.B1;
sfr sbit Mmc_Chip_Select_Direction at DDRG.B1;
// MMC module connections
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
ING);
Spi_Rd_Ptr = SPI1_Read;
error = Mmc_Init(); // Init with CS line at PORTB.B2
Prototype
unsigned char Mmc_Read_Sector(unsigned long sector, char* dbuff);
Returns Returns 0 if read was successful, or 1 if an error occurred.
Description
Function reads one sector (512 bytes) from MMC card at sector address
sector. Read data is stored in the array data. Function returns 0 if read was
successful, or 1 if an error occurred.
Requires Library needs to be initialized, see Mmc_Init.
Example
error = Mmc_Read_Sector(sector, data);