Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Common SPI interface for SD/MMC stack

Typedefs

typedef uint8_t sd_mmc_spi_errno_t
 Type of return error code. More...
 

Functions

bool sd_mmc_spi_adtc_start (sdmmc_cmd_def_t cmd, uint32_t arg, uint16_t block_size, uint16_t nb_block, bool access_block)
 Send a adtc command on the selected slot A adtc command is used for read/write access. More...
 
bool sd_mmc_spi_adtc_stop (sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command to stop a adtc command on the selected slot. More...
 
void sd_mmc_spi_deselect_device (uint8_t slot)
 Deselect a slot. More...
 
static __inline__ uint8_t sd_mmc_spi_get_bus_width (uint8_t slot)
 Return the maximum bus width of a slot. More...
 
sd_mmc_spi_errno_t sd_mmc_spi_get_errno (void)
 Return the error code of last function. More...
 
uint32_t sd_mmc_spi_get_response (void)
 Return the 32 bits response of the last command. More...
 
static __inline__ void sd_mmc_spi_get_response_128 (uint8_t *resp)
 
void sd_mmc_spi_init (void)
 Initializes the low level driver. More...
 
static __inline__ bool sd_mmc_spi_is_high_speed_capable (void)
 Return the high speed capability of the driver. More...
 
bool sd_mmc_spi_read_word (uint32_t *value)
 Read a word on the line. More...
 
void sd_mmc_spi_select_device (uint8_t slot, uint32_t clock, uint8_t bus_width, bool high_speed)
 Select a slot and initialize it. More...
 
void sd_mmc_spi_send_clock (void)
 Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before card install. More...
 
bool sd_mmc_spi_send_cmd (sdmmc_cmd_def_t cmd, uint32_t arg)
 Send a command on the selected slot. More...
 
bool sd_mmc_spi_start_read_blocks (void *dest, uint16_t nb_block)
 Start a read blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer. More...
 
bool sd_mmc_spi_start_write_blocks (const void *src, uint16_t nb_block)
 Start a write blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer. More...
 
bool sd_mmc_spi_wait_end_of_read_blocks (void)
 Wait the end of transfer initiated by mci_start_read_blocks() More...
 
bool sd_mmc_spi_wait_end_of_write_blocks (void)
 Wait the end of transfer initiated by mci_start_write_blocks() More...
 
bool sd_mmc_spi_write_word (uint32_t value)
 Write a word on the line. More...
 

Return error codes

#define SD_MMC_SPI_NO_ERR   0
 
#define SD_MMC_SPI_ERR   1
 
#define SD_MMC_SPI_ERR_RESP_TIMEOUT   2
 
#define SD_MMC_SPI_ERR_RESP_BUSY_TIMEOUT   3
 
#define SD_MMC_SPI_ERR_READ_TIMEOUT   4
 
#define SD_MMC_SPI_ERR_WRITE_TIMEOUT   5
 
#define SD_MMC_SPI_ERR_RESP_CRC   6
 
#define SD_MMC_SPI_ERR_READ_CRC   7
 
#define SD_MMC_SPI_ERR_WRITE_CRC   8
 
#define SD_MMC_SPI_ERR_ILLEGAL_COMMAND   9
 
#define SD_MMC_SPI_ERR_WRITE   10
 
#define SD_MMC_SPI_ERR_OUT_OF_RANGE   11
 

#define SD_MMC_SPI_ERR   1
#define SD_MMC_SPI_ERR_ILLEGAL_COMMAND   9
#define SD_MMC_SPI_ERR_OUT_OF_RANGE   11
#define SD_MMC_SPI_ERR_READ_CRC   7
#define SD_MMC_SPI_ERR_READ_TIMEOUT   4
#define SD_MMC_SPI_ERR_RESP_BUSY_TIMEOUT   3
#define SD_MMC_SPI_ERR_RESP_CRC   6
#define SD_MMC_SPI_ERR_RESP_TIMEOUT   2
#define SD_MMC_SPI_ERR_WRITE   10
#define SD_MMC_SPI_ERR_WRITE_CRC   8
#define SD_MMC_SPI_ERR_WRITE_TIMEOUT   5
#define SD_MMC_SPI_NO_ERR   0

typedef uint8_t sd_mmc_spi_errno_t

Type of return error code.

bool sd_mmc_spi_adtc_start ( sdmmc_cmd_def_t  cmd,
uint32_t  arg,
uint16_t  block_size,
uint16_t  nb_block,
bool  access_block 
)

Send a adtc command on the selected slot A adtc command is used for read/write access.

Parameters
cmdCommand definition
argArgument of the command
block_sizeBlock size used for the transfer
nb_blockTotal number of block for this transfer
access_blockif true, the x_read_blocks() and x_write_blocks() functions must be used after this function. If false, the mci_read_word() and mci_write_word() functions must be used after this function.
Returns
true if success, otherwise false
bool sd_mmc_spi_adtc_stop ( sdmmc_cmd_def_t  cmd,
uint32_t  arg 
)

Send a command to stop a adtc command on the selected slot.

Parameters
cmdCommand definition
argArgument of the command
Returns
true if success, otherwise false
void sd_mmc_spi_deselect_device ( uint8_t  slot)

Deselect a slot.

Parameters
slotSelected slot
static __inline__ uint8_t sd_mmc_spi_get_bus_width ( uint8_t  slot)
static

Return the maximum bus width of a slot.

Parameters
slotSelected slot
Returns
1, 4 or 8 lines.

References UNUSED().

sd_mmc_spi_errno_t sd_mmc_spi_get_errno ( void  )

Return the error code of last function.

Returns
error code
uint32_t sd_mmc_spi_get_response ( void  )

Return the 32 bits response of the last command.

Returns
32 bits response
static __inline__ void sd_mmc_spi_get_response_128 ( uint8_t *  resp)
static

References UNUSED().

void sd_mmc_spi_init ( void  )

Initializes the low level driver.

This enable the clock required and the hardware interface.

Referenced by memories_initialization(), prv_sd_mmc_resources_init(), and sd_mmc_resources_init().

static __inline__ bool sd_mmc_spi_is_high_speed_capable ( void  )
static

Return the high speed capability of the driver.

Returns
true, if the high speed is supported
bool sd_mmc_spi_read_word ( uint32_t *  value)

Read a word on the line.

Parameters
valuePointer on a word to fill
Returns
true if success, otherwise false
void sd_mmc_spi_select_device ( uint8_t  slot,
uint32_t  clock,
uint8_t  bus_width,
bool  high_speed 
)

Select a slot and initialize it.

Parameters
slotSelected slot
clockMaximum clock to use (Hz)
bus_widthBus width to use (1, 4 or 8)
high_speedtrue, to enable high speed mode
void sd_mmc_spi_send_clock ( void  )

Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before card install.

bool sd_mmc_spi_send_cmd ( sdmmc_cmd_def_t  cmd,
uint32_t  arg 
)

Send a command on the selected slot.

Parameters
cmdCommand definition
argArgument of the command
Returns
true if success, otherwise false
bool sd_mmc_spi_start_read_blocks ( void *  dest,
uint16_t  nb_block 
)

Start a read blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer.

Parameters
destPointer on the buffer to fill
nb_blockNumber of block to transfer
Returns
true if started, otherwise false
bool sd_mmc_spi_start_write_blocks ( const void *  src,
uint16_t  nb_block 
)

Start a write blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer.

Parameters
srcPointer on the buffer to send
nb_blockNumber of block to transfer
Returns
true if started, otherwise false
bool sd_mmc_spi_wait_end_of_read_blocks ( void  )

Wait the end of transfer initiated by mci_start_read_blocks()

Returns
true if success, otherwise false
bool sd_mmc_spi_wait_end_of_write_blocks ( void  )

Wait the end of transfer initiated by mci_start_write_blocks()

Returns
true if success, otherwise false
bool sd_mmc_spi_write_word ( uint32_t  value)

Write a word on the line.

Parameters
valueWord to send
Returns
true if success, otherwise false