- Fri 16 January 2015
- embedded
- Tero Koskinen
- #aspects, #ada2012
Earlier with Ada 95 and Ada 2005, if you wanted to put a variable to some specific memory location, you had to use 'for Variable'Address use X' statement and Volatile pragma for that:
My_Var : Unsigned_32; for My_Var'Address use System'To_Address (16#FF00#); pragma Volatile (My_Var);
With Ada 2012 this becomes simpler when you use aspects:
My_Var : Unsigned_32 with Volatile, Address => System'To_Address (16#FF00#);
Here is another real life example from STM32F4 code:
package STM32F4 is GPIOC_ADDRESS : constant := 16#4002_0800#; GPIOC_MODE_ADDRESS : constant := GPIOC_ADDRESS + 0; GPIOC_MODE : Interfaces.Unsigned_32 with Volatile, Address => System'To_Address (GPIOC_MODE_ADDRESS); end STM32F4;