Microchip® Advanced Software Framework

mci.h File Reference
#include <avr32/io.h>
#include "compiler.h"
#include "sd_mmc_cmd.h"
#include "conf_sd_mmc_mci.h"

Macros

Return Values
#define MCI_SUCCESS   0
 Successful completion. More...
 
#define MCI_FAILURE   -1
 Failure because of some unspecified reason. More...
 
#define MCI_INVALID_INPUT   1
 Input value out of range. More...
 
Controller bus width
#define MCI_BUS_SIZE_1_BIT   0x00
 Bus Width Selected 1 bit. More...
 
#define MCI_BUS_SIZE_4_BIT   0x02
 Bus Width Selected 4 bits. More...
 
#define MCI_BUS_SIZE_8_BIT   0x03
 Bus Width Selected 8 bits. More...
 
Controller slot available
#define MCI_SLOT_A   0x00
 Slot A Selected. More...
 
#define MCI_SLOT_B   0x01
 Slot B Selected. More...
 
#define MCI_LAST_SLOTS   MCI_SLOT_B
 Last Slot Available by the MCI. More...
 
#define MCI_DEFAULT_SLOT   MCI_SLOT_A
 Default Slot Selected. More...
 
#define MCI_NR_SLOTS   2
 Number of MCI slots. More...
 
Driver Default Value Configuration (should not be modified)
#define MCI_DEFAULT_DTOLMUL   0x07
 Data Timeout Multiplier. More...
 
#define MCI_DEFAULT_DTOLCYC   0x02
 Data Timeout Cycle Number. More...
 
#define MCI_DEFAULT_DTOREG
 
CMDR Register bits definition
#define MCI_SPCMD_NONE   (AVR32_MCI_CMDR_SPCMD_NO_SPEC_CMD<<AVR32_MCI_CMDR_SPCMD_OFFSET)
 
#define MCI_SPCMD_INIT   (AVR32_MCI_CMDR_SPCMD_INIT_CMD <<AVR32_MCI_CMDR_SPCMD_OFFSET)
 
#define MCI_SPCMD_SYNC   (AVR32_MCI_CMDR_SPCMD_SYNC_CMD <<AVR32_MCI_CMDR_SPCMD_OFFSET)
 
#define MCI_SPCMD_IT_CMD   (AVR32_MCI_CMDR_SPCMD_INT_CMD <<AVR32_MCI_CMDR_SPCMD_OFFSET)
 
#define MCI_SPCMD_IT_REP   (AVR32_MCI_CMDR_SPCMD_INT_RESP <<AVR32_MCI_CMDR_SPCMD_OFFSET)
 
#define MCI_TRCMD_NO   (AVR32_MCI_TRCMD_NO_TRANS <<AVR32_MCI_TRCMD_OFFSET)
 
#define MCI_TRCMD_START   (AVR32_MCI_TRCMD_START_TRANS<<AVR32_MCI_TRCMD_OFFSET)
 
#define MCI_TRCMD_STOP   (AVR32_MCI_TRCMD_STOP_TRANS <<AVR32_MCI_TRCMD_OFFSET)
 
#define MCI_RSPTYP_NO   (AVR32_MCI_RSPTYP_NO_RESP <<AVR32_MCI_RSPTYP_OFFSET)
 
#define MCI_RSPTYP_48   (AVR32_MCI_RSPTYP_48_BIT_RESP <<AVR32_MCI_RSPTYP_OFFSET)
 
#define MCI_RSPTYP_48B   (AVR32_MCI_RSPTYP_48_BIT_RESP_WITH_BUSY<<AVR32_MCI_RSPTYP_OFFSET)
 
#define MCI_RSPTYP_136   (AVR32_MCI_RSPTYP_136_BIT_RESP <<AVR32_MCI_RSPTYP_OFFSET)
 
#define MCI_TRTYP_BLOCK   (AVR32_MCI_TRTYP_BLOCK <<AVR32_MCI_TRTYP_OFFSET)
 
#define MCI_TRTYP_MULTIPLE   (AVR32_MCI_TRTYP_MULTI_BLOCK<<AVR32_MCI_TRTYP_OFFSET)
 
#define MCI_TRTYP_STREAM   (AVR32_MCI_TRTYP_STREAM <<AVR32_MCI_TRTYP_OFFSET)
 
#define MCI_TRTYP_SDIO_BYTE   (AVR32_MCI_TRTYP_SDIO_BYTE <<AVR32_MCI_TRTYP_OFFSET)
 
#define MCI_TRTYP_SDIO_BLOCK   (AVR32_MCI_TRTYP_SDIO_BLOCK <<AVR32_MCI_TRTYP_OFFSET)
 
#define MCI_OPDCMD   (AVR32_MCI_OPDCMD_MASK)
 
#define MCI_MAXLAT   (AVR32_MCI_MAXLAT_MASK)
 
#define MCI_TRDIR   (AVR32_MCI_TRDIR_MASK)
 

Functions

static __always_inline int mci_cmd_ready (volatile avr32_mci_t *mci)
 Tests if the MCI is able to take a new command. More...
 
static __always_inline int mci_crc_error (volatile avr32_mci_t *mci)
 Tests if the MCI Status detects a CRC error. More...
 
static __always_inline int mci_data_block_ended (volatile avr32_mci_t *mci)
 Tests if the MCI has ended the block Transmission/ Reception. More...
 
void mci_disable (volatile avr32_mci_t *mci)
 Disables the MCI controller. More...
 
void mci_enable (volatile avr32_mci_t *mci)
 Enables the MCI controller. More...
 
static __always_inline int mci_get_sr (volatile avr32_mci_t *mci)
 Return the status register and cache in a shadow variable bits that are cleared when reading the status register. More...
 
int mci_init (volatile avr32_mci_t *mci, uint8_t card_slot, uint32_t pbb_hz)
 Initialize the MCI controller. More...
 
static __always_inline int mci_overrun_error (volatile avr32_mci_t *mci)
 Tests if an overrun occur. More...
 
static __always_inline uint32_t mci_rd_data (volatile avr32_mci_t *mci)
 Mci Read data. More...
 
unsigned int mci_read_response (volatile avr32_mci_t *mci)
 Read command argument response. More...
 
void mci_reset (volatile avr32_mci_t *mci)
 Resets the MCI controller. More...
 
static __always_inline int mci_rx_ready (volatile avr32_mci_t *mci)
 Tests if the MCI is ready to receive data. More...
 
int mci_select_card (volatile avr32_mci_t *mci, uint8_t card_slot, uint8_t bus_width)
 Mci Select slot Card. More...
 
int mci_send_cmd (volatile avr32_mci_t *mci, unsigned int cmd, unsigned int arg)
 Generic function to send a command to the MMC or SDCard. More...
 
void mci_set_block_count (volatile avr32_mci_t *mci, uint16_t cnt)
 Set Block Count. More...
 
void mci_set_block_size (volatile avr32_mci_t *mci, uint16_t length)
 Set Block Size. More...
 
int mci_set_bus_size (volatile avr32_mci_t *mci, uint8_t busWidth)
 Set SDIO Bus Width. More...
 
void mci_set_speed (volatile avr32_mci_t *mci, uint32_t pbb_hz, uint32_t card_speed)
 Set Speed Card. More...
 
void mci_stop (volatile avr32_mci_t *mci)
 Stop the MCI controller. More...
 
static __always_inline int mci_tx_ready (volatile avr32_mci_t *mci)
 Tests if the MCI is ready to transmit data. More...
 
static __always_inline int mci_underrun_error (volatile avr32_mci_t *mci)
 Tests if an underrun occur. More...
 
void mci_wait_busy_signal (volatile avr32_mci_t *mci)
 Mci Busy Status. More...
 
static __always_inline void mci_wr_data (volatile avr32_mci_t *mci, uint32_t data)
 Mci Write data. More...
 

Variables

int shadow_sr