avrada_lib_2.1.0_fe38c6dc/src/avr-wait-delays.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
with Ada.Unchecked_Conversion;
with Interfaces;                   use Interfaces;

package body AVR.Wait.Delays is


   procedure Wait_1ms is new Generic_Wait_USecs (Crystal_Hertz => 16_000_000,
                                                 Micro_Seconds => 1_000);

   function To_Milliseconds is new Ada.Unchecked_Conversion (Source => Duration,
                                                             Target => Integer_32);

   procedure Delay_For (D : Duration) is
      Milliseconds : constant Integer_32 := To_Milliseconds (D);
   begin
      if Milliseconds > 0 then
         for I in 1 .. Milliseconds loop
            Wait_1ms;
         end loop;
      end if;
   end Delay_For;

end AVR.Wait.Delays;