diff --git a/common/a-reatim.ads b/common/a-reatim.ads index 66f7d49..54d410b 100644 --- a/common/a-reatim.ads +++ b/common/a-reatim.ads @@ -33,6 +33,8 @@ -- -- ------------------------------------------------------------------------------ +-- Modified from GCC 4.9.1, then GCC 7.1.0, for Cortex GNAT RTS. + package Ada.Real_Time with SPARK_Mode, Abstract_State => (Clock_Time with Synchronous, @@ -149,9 +151,13 @@ private -- Replaces Duration, which has a different representation on -- systems with 32-bit Duration. - type Time is new Time_Base; + FreeRTOS_Tick : constant := 0.001; + -- FreeRTOSConfig.h has set configTICK_RATE_HZ to 1000 + + type Time is new Time_Base range 0.0 .. (2 ** 32 - 1) * FreeRTOS_Tick; + -- and configUSE_16_BIT_TICKS to 0 (so we get 32-bit clock values). - Time_First : constant Time := 0.0; + Time_First : constant Time := Time'First; Time_Last : constant Time := Time'Last; diff --git a/common/a-retide.adb b/common/a-retide.adb index f0f1473..ac751cf 100644 --- a/common/a-retide.adb +++ b/common/a-retide.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, 2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, 2016-2017, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -29,6 +29,8 @@ -- -- ------------------------------------------------------------------------------ +-- Modified from GCC 4.9.1 for Cortex GNAT RTS. + with Interfaces; package body Ada.Real_Time.Delays is @@ -40,12 +42,14 @@ package body Ada.Real_Time.Delays is Convention => C, External_Name => "vTaskDelay"; Timespan_To_Delay : constant Time_Span := T - Clock; - -- ??? need to round, see ARM - Ticks_To_Delay : constant Integer := Timespan_To_Delay / Tick; begin - if Ticks_To_Delay > 0 then + if Timespan_To_Delay > 0.0 then + -- Need to avoid problems with ambiguity; and the version in + -- Real_Time returns Integer, whereas we actually want + -- Unsigned_32. vTaskDelay - (Ticks_To_Delay => Interfaces.Unsigned_32 (Ticks_To_Delay)); + (Interfaces.Unsigned_32 + (Standard."/" (Timespan_To_Delay, Tick))); end if; end Delay_Until; diff --git a/test-arduino-due/testbed.adb b/test-arduino-due/testbed.adb index c01237e..bfafa19 100644 --- a/test-arduino-due/testbed.adb +++ b/test-arduino-due/testbed.adb @@ -111,11 +111,5 @@ begin -- Check streams Streams.Check (42); - declare - use type Ada.Real_Time.Time; - begin - loop - delay until Ada.Real_Time.Clock + Ada.Real_Time.Seconds (10); - end loop; - end; + delay until Ada.Real_Time.Time_Last; end Testbed; diff --git a/test-stm32f4/testbed.adb b/test-stm32f4/testbed.adb index 027049c..f01d7d1 100644 --- a/test-stm32f4/testbed.adb +++ b/test-stm32f4/testbed.adb @@ -108,11 +108,5 @@ begin -- Check streams Streams.Check (42); - declare - use type Ada.Real_Time.Time; - begin - loop - delay until Ada.Real_Time.Clock + Ada.Real_Time.Seconds (10); - end loop; - end; + delay until Ada.Real_Time.Time_Last; end Testbed; diff --git a/test-stm32f429i/testbed.adb b/test-stm32f429i/testbed.adb index 027049c..f01d7d1 100644 --- a/test-stm32f429i/testbed.adb +++ b/test-stm32f429i/testbed.adb @@ -108,11 +108,5 @@ begin -- Check streams Streams.Check (42); - declare - use type Ada.Real_Time.Time; - begin - loop - delay until Ada.Real_Time.Clock + Ada.Real_Time.Seconds (10); - end loop; - end; + delay until Ada.Real_Time.Time_Last; end Testbed;