text
stringlengths
0
234
and then not Controller.Periph.STA.CTIMEOUT
loop
if Clock - Start > Milliseconds (1000) then
Timeout := True;
exit;
end if;
end loop;
if Timeout or else Controller.Periph.STA.CTIMEOUT then
-- Card is not v2.0 compliant or card does not support the set
-- voltage range
Controller.Periph.ICR.CTIMEOUTC := True;
return Timeout_Error;
elsif Controller.Periph.STA.CCRCFAIL then
Controller.Periph.ICR.CCRCFAILC := True;
return CRC_Check_Fail;
end if;
if SD_Command (Controller.Periph.RESPCMD.RESPCMD) /=
Command_Index
then
return Illegal_Cmd;
end if;
Clear_Static_Flags (Controller);
R1 := Controller.Periph.RESP1;
if (R1 and SD_OCR_ERRORMASK) = 0 then
return OK;
end if;
if (R1 and SD_OCR_ADDR_OUT_OF_RANGE) /= 0 then
return Address_Out_Of_Range;
elsif (R1 and SD_OCR_ADDR_MISALIGNED) /= 0 then
return Address_Missaligned;
elsif (R1 and SD_OCR_BLOCK_LEN_ERR) /= 0 then
return Block_Length_Error;
elsif (R1 and SD_OCR_ERASE_SEQ_ERR) /= 0 then
return Erase_Seq_Error;
elsif (R1 and SD_OCR_BAD_ERASE_PARAM) /= 0 then
return Bad_Erase_Parameter;
elsif (R1 and SD_OCR_WRITE_PROT_VIOLATION) /= 0 then
return Write_Protection_Violation;
elsif (R1 and SD_OCR_LOCK_UNLOCK_FAILED) /= 0 then
return Lock_Unlock_Failed;
elsif (R1 and SD_OCR_COM_CRC_FAILED) /= 0 then
return CRC_Check_Fail;
elsif (R1 and SD_OCR_ILLEGAL_CMD) /= 0 then
return Illegal_Cmd;
elsif (R1 and SD_OCR_CARD_ECC_FAILED) /= 0 then
return Card_ECC_Failed;
elsif (R1 and SD_OCR_CC_ERROR) /= 0 then
return CC_Error;
elsif (R1 and SD_OCR_GENERAL_UNKNOWN_ERROR) /= 0 then
return General_Unknown_Error;
elsif (R1 and SD_OCR_STREAM_READ_UNDERRUN) /= 0 then
return Stream_Read_Underrun;
elsif (R1 and SD_OCR_STREAM_WRITE_UNDERRUN) /= 0 then
return Stream_Write_Underrun;
elsif (R1 and SD_OCR_CID_CSD_OVERWRITE) /= 0 then
return CID_CSD_Overwrite;
elsif (R1 and SD_OCR_WP_ERASE_SKIP) /= 0 then
return WP_Erase_Skip;
elsif (R1 and SD_OCR_CARD_ECC_DISABLED) /= 0 then
return Card_ECC_Disabled;
elsif (R1 and SD_OCR_ERASE_RESET) /= 0 then
return Erase_Reset;
elsif (R1 and SD_OCR_AKE_SEQ_ERROR) /= 0 then
return AKE_SEQ_Error;
else
return General_Unknown_Error;
end if;
end Response_R1_Error;
-----------------------
-- Response_R2_Error --
-----------------------
function Response_R2_Error
(Controller : in out SDMMC_Controller) return SD_Error
is
begin
while not Controller.Periph.STA.CCRCFAIL
and then not Controller.Periph.STA.CMDREND
and then not Controller.Periph.STA.CTIMEOUT
loop
null;
end loop;
if Controller.Periph.STA.CTIMEOUT then
-- Card is not v2.0 compliant or card does not support the set
-- voltage range
Controller.Periph.ICR.CTIMEOUTC := True;
return Timeout_Error;