User manual

mikroC PRO for dsPIC
MikroElektronika
415
Mmc_Init
Prototype
unsigned int Mmc_Init();
Description Initializes MMC through hardware SPI interface.
Mmc_Init needs to be called before using other functions of this library.
Parameters None.
Returns - 0 - if MMC/SD card was detected and successfully initialized
- 1 - otherwise
Requires The appropriate hardware SPI module must be previously initialized.
Global variables :
- Mmc_Chip_Select: Chip Select line
- Mmc_Chip_Select_Direction: Direction of the Chip Select pin
must be dened before using this function.
Example
// MMC module connections
sbit Mmc_Chip_Select at LATF0_bit;
sbit Mmc_Chip_Select_Direction at TRISF0_bit;
// MMC module connections
...
// Initialize the SPI module
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_
PRESCALE_PRI_64,_SPI_SS_DISABLE,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_
IDLE);
// Loop until MMC is initialized
while (Mmc_Init())
;
// Reinitialize the SPI module at higher speed (change primary prescaler).
SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_
PRESCALE_PRI_4,_SPI_SS_DISABLE,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_
IDLE);
Notes None.