FreeBSD/sys/boot/arm/at91/libat91/sd-card.c
//*----------------------------------------------------------------------------
//* \fn    MCI_SendCommand
//* \brief Generic function to send a command to the MMC or SDCard
//*----------------------------------------------------------------------------
\fn    MCI_SendCommand
\brief Generic function to send a command to the MMC or SDCard
\ fn MCI_SendCommand \ brief Generic function to send a command to the MMC or SDCard
static int
MCI_SendCommand(
	unsigned int Cmd,
	unsigned int Arg)
{
	unsigned int error;
	unsigned int errorMask = AT91C_MCI_SR_ERROR;
	unsigned int opcode = Cmd & 0x3F;
	if (opcode == 41)
		errorMask &= ~AT91C_MCI_RCRCE;
	AT91C_BASE_MCI->MCI_ARGR = Arg;
	AT91C_BASE_MCI->MCI_CMDR = Cmd;
	error = wait_ready();
	if ((error & errorMask) != 0) {
		return (1);
	}
	return 0;
}
static int MCI_SendCommand ( unsigned int Cmd , unsigned int Arg ) { unsigned int error ; unsigned int errorMask = AT91C_MCI_SR_ERROR ; unsigned int opcode = Cmd & 0x3F ; if ( opcode == 41 ) errorMask &= ~ AT91C_MCI_RCRCE ; AT91C_BASE_MCI -> MCI_ARGR = Arg ; AT91C_BASE_MCI -> MCI_CMDR = Cmd ; error = wait_ready ( ) ; if ( ( error & errorMask ) != 0 ) { return ( 1 ) ; } return 0 ; }
\fn    MCI_SendCommand
\brief Generic function to send a command to the MMC or SDCard
\ fn MCI_SendCommand \ brief Generic function to send a command to the MMC or SDCard
//printf("SendCmd %d (%x) arg %x\n", opcode, Cmd, Arg); // Don't check response CRC on ACMD41 (R3 response type).