text
stringlengths 0
234
|
|---|
overriding procedure Reset
|
(This : in out SDMMC_Controller;
|
Status : out SD_Error)
|
is
|
begin
|
-- Make sure the POWER register is writable by waiting a bit after
|
-- the Power_Off command
|
DCTRL_Write_Delay;
|
This.Periph.POWER.PWRCTRL := Power_Off;
|
-- Use the Default SDMMC peripheral configuration for SD card init
|
This.Periph.CLKCR := (others => <>);
|
This.Set_Clock (400_000);
|
This.Periph.DTIMER := SD_DATATIMEOUT;
|
This.Periph.CLKCR.CLKEN := False;
|
DCTRL_Write_Delay;
|
This.Periph.POWER.PWRCTRL := Power_On;
|
-- Wait for the clock to stabilize.
|
DCTRL_Write_Delay;
|
This.Periph.CLKCR.CLKEN := True;
|
delay until Clock + Milliseconds (20);
|
Status := OK;
|
end Reset;
|
---------------
|
-- Set_Clock --
|
---------------
|
overriding procedure Set_Clock
|
(This : in out SDMMC_Controller;
|
Freq : Natural)
|
is
|
Div : UInt32;
|
CLKCR : CLKCR_Register;
|
begin
|
Div := (This.CLK_In + UInt32 (Freq) - 1) / UInt32 (Freq);
|
-- Make sure the POWER register is writable by waiting a bit after
|
-- the Power_Off command
|
DCTRL_Write_Delay;
|
if Div <= 1 then
|
This.Periph.CLKCR.BYPASS := True;
|
else
|
Div := Div - 2;
|
CLKCR := This.Periph.CLKCR;
|
CLKCR.BYPASS := False;
|
if Div > UInt32 (CLKCR_CLKDIV_Field'Last) then
|
CLKCR.CLKDIV := CLKCR_CLKDIV_Field'Last;
|
else
|
CLKCR.CLKDIV := CLKCR_CLKDIV_Field (Div);
|
end if;
|
This.Periph.CLKCR := CLKCR;
|
end if;
|
end Set_Clock;
|
------------------
|
-- Set_Bus_Size --
|
------------------
|
overriding procedure Set_Bus_Size
|
(This : in out SDMMC_Controller;
|
Mode : Wide_Bus_Mode)
|
is
|
function To_WIDBUS_Field is new Ada.Unchecked_Conversion
|
(Wide_Bus_Mode, CLKCR_WIDBUS_Field);
|
begin
|
This.Periph.CLKCR.WIDBUS := To_WIDBUS_Field (Mode);
|
end Set_Bus_Size;
|
------------------
|
-- Send_Command --
|
------------------
|
overriding procedure Send_Cmd
|
(This : in out SDMMC_Controller;
|
Cmd : Cmd_Desc_Type;
|
Arg : UInt32;
|
Status : out SD_Error)
|
is
|
CMD_Reg : CMD_Register := This.Periph.CMD;
|
begin
|
if Cmd.Rsp = Rsp_Invalid or else Cmd.Tfr = Tfr_Invalid then
|
raise Program_Error with "Not implemented";
|
end if;
|
This.Periph.ARG := Arg;
|
CMD_Reg.CMDINDEX := CMD_CMDINDEX_Field (Cmd.Cmd);
|
CMD_Reg.WAITRESP := (case Cmd.Rsp is
|
when Rsp_No => No_Response,
|
when Rsp_R2 => Long_Response,
|
when others => Short_Response);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.