Mikroelektronika MIKROE-350 Ficha De Dados
Mmc_Init
257
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub function Mmc_Init() as 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
dim Mmc_Chip_Select as sbit sfr at PORTB.B2
dim Mmc_Chip_Select_Direction as sbit sfr at DDRB.B2
' MMC module connections
dim Mmc_Chip_Select as sbit sfr at PORTB.B2
dim Mmc_Chip_Select_Direction as sbit sfr at DDRB.B2
' MMC module connections
error = Mmc_Init() ' Init with CS line at PORTB.B2
dim i as byte
...
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
ING)
Spi_Rd_Ptr = @SPI1_Read // Pass pointer to SPI Read function
of used SPI module
i = Mmc_Init()
dim i as byte
...
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEAD-
ING)
Spi_Rd_Ptr = @SPI1_Read // Pass pointer to SPI Read function
of used SPI module
i = Mmc_Init()