text
stringlengths
0
234
Clear_Static_Flags (Controller);
Response := Controller.Periph.RESP1;
if (Response and SD_R6_Illegal_Cmd) = SD_R6_Illegal_Cmd then
return Illegal_Cmd;
elsif (Response and SD_R6_General_Unknown_Error) =
SD_R6_General_Unknown_Error
then
return General_Unknown_Error;
elsif (Response and SD_R6_Com_CRC_Failed) = SD_R6_Com_CRC_Failed then
return CRC_Check_Fail;
end if;
RCA := Response and 16#FFFF_0000#;
return OK;
end Response_R6_Error;
-----------------------
-- Response_R7_Error --
-----------------------
function Response_R7_Error
(Controller : in out SDMMC_Controller) return SD_Error
is
Start : constant Time := Clock;
Timeout : Boolean := False;
begin
while not Controller.Periph.STA.CCRCFAIL
and then not Controller.Periph.STA.CMDREND
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;
elsif Controller.Periph.STA.CMDREND then
Controller.Periph.ICR.CMDRENDC := True;
return OK;
else
return Error;
end if;
end Response_R7_Error;
-------------------
-- Stop_Transfer --
-------------------
function Stop_Transfer
(This : in out SDMMC_Controller) return SD_Error
is
Ret : SD_Error;
begin
Send_Cmd (This, Cmd_Desc (Stop_Transmission), 0, Ret);
return Ret;
end Stop_Transfer;
-----------------------
-- Set_Clk_Src_Speed --
-----------------------
procedure Set_Clk_Src_Speed
(This : in out SDMMC_Controller;
CLK : UInt32)
is
begin
This.CLK_In := CLK;
end Set_Clk_Src_Speed;
----------------
-- Initialize --
----------------
function Initialize
(This : in out SDMMC_Controller) return SD_Error
is
Ret : SD_Error;
begin