text
stringlengths
0
234
end if;
-- In this code fragment we use the approach suited for the case in which
-- we are calculating the CRC for a section of system memory rather than a
-- block of application data. We pretend that Section2 is a memory section.
-- All we need is a known starting address and a known length. Given that,
-- we can create a view of it as if it is an object of type Block_32 (or
-- whichever block type is appropriate).
declare
subtype Memory_Section is Block_32 (1 .. Section2'Length);
type Section_Pointer is access all Memory_Section with Storage_Size => 0;
function As_Memory_Section_Reference is new Ada.Unchecked_Conversion
(Source => System.Address, Target => Section_Pointer);
begin
Update_CRC
(CRC_Unit,
Controller'Access,
Stream,
Input => As_Memory_Section_Reference (Section2'Address).all);
Function Definition: procedure DSB is
Function Body: begin
Asm ("dsb", Volatile => True);
end DSB;
---------
-- ISB --
---------
procedure ISB is
begin
Asm ("isb", Volatile => True);
end ISB;
-----------------------
-- Cache_Maintenance --
-----------------------
procedure Cache_Maintenance
(Start : System.Address;
Len : Natural)
is
begin
if not D_Cache_Enabled then
return;
end if;
declare
function To_U32 is new Ada.Unchecked_Conversion
(System.Address, UInt32);
Op_Size : Integer_32 := Integer_32 (Len);
Op_Addr : UInt32 := To_U32 (Start);
Reg : UInt32 with Volatile, Address => Reg_Address;
begin
DSB;
while Op_Size > 0 loop
Reg := Op_Addr;
Op_Addr := Op_Addr + Data_Cache_Line_Size;
Op_Size := Op_Size - Integer_32 (Data_Cache_Line_Size);
end loop;
DSB;
ISB;
Function Definition: function To_Char is new Ada.Unchecked_Conversion (Source => UInt8,
Function Body: Target => Character);
function To_UInt8 is new Ada.Unchecked_Conversion (Source => Character,
Target => UInt8);
procedure Write (This : in out TP_Device; Cmd : String);
procedure Read (This : in out TP_Device; Str : out String);
-----------
-- Write --
-----------
procedure Write (This : in out TP_Device; Cmd : String) is
Status : UART_Status;
Data : UART_Data_8b (Cmd'Range);
begin
for Index in Cmd'Range loop
Data (Index) := To_UInt8 (Cmd (Index));
end loop;
This.Port.Transmit (Data, Status);
if Status /= Ok then
-- No error handling...
raise Program_Error;
end if;
-- This.Time.Delay_Microseconds ((11 * 1000000 / 19_2000) + Cmd'Length);
end Write;
----------
-- Read --
----------