FreeBSD/sys/boot/arm/at91/libat91/sd-card.c
//*----------------------------------------------------------------------------
//* \fn    MCI_ReadBlock
//* \brief Start the read for a single 512-byte block
//*----------------------------------------------------------------------------
\fn    MCI_ReadBlock
\brief Start the read for a single 512-byte block
\ fn MCI_ReadBlock \ brief Start the read for a single 512 - byte block
static int
MCI_StartReadBlock(unsigned blknum, void *dataBuffer)
{
	AT91C_BASE_MCI->MCI_MR |= ((SD_BLOCK_SIZE << 16) | AT91C_MCI_PDCMODE);
	AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS);
	AT91C_BASE_PDC_MCI->PDC_RPR  = (unsigned int)dataBuffer;
	AT91C_BASE_PDC_MCI->PDC_RCR  = SD_BLOCK_SIZE / 4;
	AT91C_BASE_PDC_MCI->PDC_PTCR = AT91C_PDC_RXTEN;
	if (!MCI_Device.IsSDHC)
		blknum *= SD_BLOCK_SIZE;
	if (MCI_SendCommand(READ_SINGLE_BLOCK_CMD, blknum)) {
		return AT91C_READ_ERROR;
	}
	MCI_Device.state = AT91C_MCI_RX_SINGLE_BLOCK;
	return 0;
}
static int MCI_StartReadBlock ( unsigned blknum , void * dataBuffer ) { AT91C_BASE_MCI -> MCI_MR |= ( ( SD_BLOCK_SIZE << 16 ) | AT91C_MCI_PDCMODE ) ; AT91C_BASE_PDC_MCI -> PDC_PTCR = ( AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS ) ; AT91C_BASE_PDC_MCI -> PDC_RPR = ( unsigned int ) dataBuffer ; AT91C_BASE_PDC_MCI -> PDC_RCR = SD_BLOCK_SIZE / 4 ; AT91C_BASE_PDC_MCI -> PDC_PTCR = AT91C_PDC_RXTEN ; if ( ! MCI_Device . IsSDHC ) blknum *= SD_BLOCK_SIZE ; if ( MCI_SendCommand ( READ_SINGLE_BLOCK_CMD , blknum ) ) { return AT91C_READ_ERROR ; } MCI_Device . state = AT91C_MCI_RX_SINGLE_BLOCK ; return 0 ; }
\fn    MCI_ReadBlock
\brief Start the read for a single 512-byte block
\ fn MCI_ReadBlock \ brief Start the read for a single 512 - byte block
// Init Mode Register // (PDC) Receiver Transfer Enable // SDHC wants block offset, non-HC wants byte offset. // Send the Read single block command