text
stringlengths 0
234
|
|---|
return Shift_Left (Val and 16#00_00_00_ff#, 24)
|
or Shift_Left (Val and 16#00_00_ff_00#, 8)
|
or Shift_Right (Val and 16#00_ff_00_00#, 8)
|
or Shift_Right (Val and 16#ff_00_00_00#, 24);
|
end Swap32;
|
------------------
|
-- BE32_To_Host --
|
------------------
|
function BE32_To_Host (Val : UInt32) return UInt32 is
|
use System;
|
begin
|
if Default_Bit_Order = Low_Order_First then
|
return Swap32 (Val);
|
else
|
return Val;
|
end if;
|
end BE32_To_Host;
|
---------------------------------
|
-- Card_Identification_Process --
|
---------------------------------
|
procedure Card_Identification_Process
|
(This : in out SDMMC_Driver'Class;
|
Info : out Card_Information;
|
Status : out SD_Error)
|
is
|
Rsp : UInt32;
|
W0, W1, W2, W3 : UInt32;
|
Rca : UInt32;
|
begin
|
-- Reset controller
|
This.Reset (Status);
|
if Status /= OK then
|
return;
|
end if;
|
-- CMD0: Sets the SDCard state to Idle
|
Send_Cmd (This, Go_Idle_State, 0, Status);
|
if Status /= OK then
|
return;
|
end if;
|
-- CMD8: IF_Cond, voltage supplied: 0x1 (2.7V - 3.6V)
|
-- It is mandatory for the host compliant to Physical Spec v2.00
|
-- to send CMD8 before ACMD41
|
Send_Cmd (This, Send_If_Cond, 16#1a5#, Status);
|
if Status = OK then
|
-- at least SD Card 2.0
|
Info.Card_Type := STD_Capacity_SD_Card_v2_0;
|
Read_Rsp48 (This, Rsp);
|
if (Rsp and 16#fff#) /= 16#1a5# then
|
-- Bad voltage or bad pattern.
|
Status := Error;
|
return;
|
end if;
|
else
|
-- If SD Card, then it's v1.1
|
Info.Card_Type := STD_Capacity_SD_Card_V1_1;
|
end if;
|
for I in 1 .. 5 loop
|
This.Delay_Milliseconds (200);
|
-- CMD55: APP_CMD
|
-- This is done manually to handle error (this command is not
|
-- supported by mmc).
|
Send_Cmd (This, Cmd_Desc (App_Cmd), 0, Status);
|
if Status /= OK then
|
if Status = Command_Timeout_Error
|
and then I = 1
|
and then Info.Card_Type = STD_Capacity_SD_Card_V1_1
|
then
|
-- Not an SDCard. Suppose MMC.
|
Info.Card_Type := Multimedia_Card;
|
exit;
|
end if;
|
return;
|
end if;
|
-- ACMD41: SD_SEND_OP_COND (no crc check)
|
-- Arg: HCS=1, XPC=0, S18R=0
|
Send_Cmd
|
(This, Acmd_Desc (SD_App_Send_Op_Cond), 16#40ff_0000#, Status);
|
if Status /= OK then
|
return;
|
end if;
|
Read_Rsp48 (This, Rsp);
|
if (Rsp and SD_OCR_High_Capacity) = SD_OCR_High_Capacity then
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.