text
stringlengths
0
234
Trigger : Regular_Channel_Conversion_Trigger;
Enable_EOC : Boolean;
Conversions : Regular_Channel_Conversions)
is
begin
This.CR2.EOCS := Enable_EOC;
This.CR2.CONT := Continuous;
This.CR1.SCAN := Conversions'Length > 1;
if Trigger.Enabler /= Trigger_Disabled then
This.CR2.EXTSEL := External_Events_Regular_Group'Enum_Rep (Trigger.Event);
This.CR2.EXTEN := External_Trigger'Enum_Rep (Trigger.Enabler);
else
This.CR2.EXTSEL := 0;
This.CR2.EXTEN := 0;
end if;
for Rank in Conversions'Range loop
declare
Conversion : Regular_Channel_Conversion renames Conversions (Rank);
begin
Configure_Regular_Channel
(This, Conversion.Channel, Rank, Conversion.Sample_Time);
-- We check the VBat first because that channel is also used for
-- the temperature sensor channel on some MCUs, in which case the
-- VBat conversion is the only one done. This order reflects that
-- hardware behavior.
if VBat_Conversion (This, Conversion.Channel) then
Enable_VBat_Connection;
elsif VRef_TemperatureSensor_Conversion (This, Conversion.Channel)
then
Enable_VRef_TemperatureSensor_Connection;
end if;
Function Definition: procedure Disable_Interrupt
Function Body: (This : in out SDMMC_Controller;
Interrupt : SDMMC_Interrupts)
is
begin
case Interrupt is
when Data_End_Interrupt =>
This.Periph.MASK.DATAENDIE := False;
when Data_CRC_Fail_Interrupt =>
This.Periph.MASK.DCRCFAILIE := False;
when Data_Timeout_Interrupt =>
This.Periph.MASK.DTIMEOUTIE := False;
when TX_FIFO_Empty_Interrupt =>
This.Periph.MASK.TXFIFOEIE := False;
when RX_FIFO_Full_Interrupt =>
This.Periph.MASK.RXFIFOFIE := False;
when TX_Underrun_Interrupt =>
This.Periph.MASK.TXUNDERRIE := False;
when RX_Overrun_Interrupt =>
This.Periph.MASK.RXOVERRIE := False;
end case;
end Disable_Interrupt;
------------------------
-- Delay_Milliseconds --
------------------------
overriding procedure Delay_Milliseconds
(This : SDMMC_Controller;
Amount : Natural)
is
pragma Unreferenced (This);
begin
delay until Clock + Milliseconds (Amount);
end Delay_Milliseconds;
-----------
-- Reset --
-----------
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;