Mikroelektronika MIKROE-742 데이터 시트
273
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Mmc_Init
Prototype
function Mmc_Init(): byte;
Returns
-
0
- if MMC/SD card was detected and successfully initialized
-
1
- otherwise
Description
Initializes MMC through hardware SPI interface.
Parameters:
-
port
: chip select signal port address.
-
cspin
: chip select pin.
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.
The appropriate hardware SPI module must be previously initialized. See the
SPI1_Init, SPI1_Init_Advanced routines.
The appropriate hardware SPI module must be previously initialized. See the
SPI1_Init, SPI1_Init_Advanced routines.
Example
// MMC module connections
var Mmc_Chip_Select : sbit; sfr; at PORTB.B2;
var Mmc_Chip_Select_Direction : sbit; sfr; at DDRB.B2;
// MMC module connections
var Mmc_Chip_Select : sbit; sfr; at PORTB.B2;
var Mmc_Chip_Select_Direction : sbit; sfr; at DDRB.B2;
// MMC module connections
error = Mmc_Init(); // Init with CS line at PORTB.B2
var i : byte;
...
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
var i : byte;
...
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
ING);
Spi_Rd_Ptr := @SPI1_Read; // Pass pointer to SPI Read func-
tion of used SPI module
i = Mmc_Init();
tion of used SPI module
i = Mmc_Init();