text
stringlengths
0
234
-----------
-- Reset --
-----------
procedure Reset (This : in out SDMMC_Controller)
is
begin
if This.Periph.all'Address = SDMMC1_Base then
RCC_Periph.APB2RSTR.SDMMC1RST := True;
RCC_Periph.APB2RSTR.SDMMC1RST := False;
elsif This.Periph.all'Address = SDMMC2_Base then
RCC_Periph.APB2RSTR.SDMMC2RST := True;
RCC_Periph.APB2RSTR.SDMMC2RST := False;
else
raise Unknown_Device;
end if;
end Reset;
----------------------
-- Set_Clock_Source --
----------------------
procedure Set_Clock_Source
(This : in out SDMMC_Controller;
Src : SDMMC_Clock_Source)
is
Sel_Value : constant Boolean := Src = Src_Sysclk;
begin
if This.Periph.all'Address = SDMMC1_Base then
RCC_Periph.DKCFGR2.SDMMC1SEL := Sel_Value;
elsif This.Periph.all'Address = SDMMC2_Base then
RCC_Periph.DKCFGR2.SDMMC2SEL := Sel_Value;
else
raise Unknown_Device;
end if;
case Src is
when Src_Sysclk =>
STM32.SDMMC.Set_Clk_Src_Speed
(This, System_Clock_Frequencies.SYSCLK);
when Src_48Mhz =>
STM32.SDMMC.Set_Clk_Src_Speed
(This, 48_000_000);
end case;
end Set_Clock_Source;
------------------------------
-- System_Clock_Frequencies --
------------------------------
function System_Clock_Frequencies return RCC_System_Clocks
is
Source : constant UInt2 := RCC_Periph.CFGR.SWS;
Result : RCC_System_Clocks;
begin
Result.I2SCLK := 0;
case Source is
when 0 =>
-- HSI as source
Result.SYSCLK := HSI_VALUE;
when 1 =>
-- HSE as source
Result.SYSCLK := HSE_VALUE;
when 2 =>
-- PLL as source
declare
HSE_Source : constant Boolean := RCC_Periph.PLLCFGR.PLLSRC;
Pllm : constant UInt32 :=
UInt32 (RCC_Periph.PLLCFGR.PLLM);
Plln : constant UInt32 :=
UInt32 (RCC_Periph.PLLCFGR.PLLN);
Pllp : constant UInt32 :=
(UInt32 (RCC_Periph.PLLCFGR.PLLP) + 1) * 2;
Pllvco : UInt32;
begin
if not HSE_Source then
Pllvco := HSI_VALUE;
else
Pllvco := HSE_VALUE;
end if;
Pllvco := Pllvco / Pllm;
Result.I2SCLK := Pllvco;
Pllvco := Pllvco * Plln;
Result.SYSCLK := Pllvco / Pllp;
Function Definition: procedure Reset_All_ADC_Units is
Function Body: begin
RCC_Periph.APB2RSTR.ADCRST := True;
RCC_Periph.APB2RSTR.ADCRST := False;
end Reset_All_ADC_Units;
------------------
-- Enable_Clock --
------------------