text stringlengths 0 234 |
|---|
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 |
Info.Card_Type := High_Capacity_SD_Card; |
end if; |
if (Rsp and SD_OCR_Power_Up) = 0 then |
Status := Error; |
else |
Status := OK; |
exit; |
end if; |
end loop; |
if Status = Command_Timeout_Error |
and then Info.Card_Type = Multimedia_Card |
then |
for I in 1 .. 5 loop |
This.Delay_Milliseconds (200); |
-- CMD1: SEND_OP_COND query voltage |
Send_Cmd (This, Cmd_Desc (Send_Op_Cond), 16#00ff_8000#, Status); |
if Status /= OK then |
return; |
end if; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.