* Changed Volatile_Full_Access attribute to pragma to mantain portability.
This commit is contained in:
parent
33456a114b
commit
37f1174946
5 changed files with 68 additions and 22 deletions
24
README.md
24
README.md
|
@ -1,2 +1,26 @@
|
||||||
# stm32-ada
|
# stm32-ada
|
||||||
Ada bindings for STM32 internals
|
Ada bindings for STM32 internals
|
||||||
|
|
||||||
|
## Hardware quirks and workarounds
|
||||||
|
|
||||||
|
### APB
|
||||||
|
|
||||||
|
APB does not support writes of parts of 32-bit registers.
|
||||||
|
The library provides acess to register fields as records.
|
||||||
|
This could lead compiler to emit byte and half-word writes
|
||||||
|
to APB registers causing erroneous effects.
|
||||||
|
As a workaround those registers should be read to local variable,
|
||||||
|
this variable altered, and then written back to hardware.
|
||||||
|
GNAT users may not need the workaround, because of its pragma
|
||||||
|
`Volatile_Full_Access` used in this library.
|
||||||
|
|
||||||
|
## Compiler specific notes
|
||||||
|
|
||||||
|
There are compiler-specific pragmas so your compiler may complain about them.
|
||||||
|
|
||||||
|
|
||||||
|
### GNAT
|
||||||
|
|
||||||
|
`Volatile_Full_Access` pragma is used on (at least writable) APB registers
|
||||||
|
as byte- and half-wide writes are not supported by APB. Read STM docs on
|
||||||
|
what those accesses actually do.
|
|
@ -27,12 +27,18 @@ package STM32.F4.EXTI is
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
type EXTI_Registers is record
|
type EXTI_Registers is record
|
||||||
IMR: Event_Set_Register with Volatile_Full_Access;
|
IMR: Event_Set_Register;
|
||||||
EMR: Event_Set_Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(IMR);
|
||||||
RTSR: Event_Set_Register with Volatile_Full_Access;
|
EMR: Event_Set_Register;
|
||||||
FTSR: Event_Set_Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(EMR);
|
||||||
SWIER: Event_Set_Register with Volatile_Full_Access;
|
RTSR: Event_Set_Register;
|
||||||
PR: Event_Set_Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(RTSR);
|
||||||
|
FTSR: Event_Set_Register;
|
||||||
|
Pragma Volatile_Full_Access(FTSR);
|
||||||
|
SWIER: Event_Set_Register;
|
||||||
|
Pragma Volatile_Full_Access(SWIER);
|
||||||
|
PR: Event_Set_Register;
|
||||||
|
Pragma Volatile_Full_Access(PR);
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
for EXTI_Registers use record
|
for EXTI_Registers use record
|
||||||
|
|
|
@ -117,8 +117,10 @@ package STM32.F4.PWR is
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
type PWR_Registers is record
|
type PWR_Registers is record
|
||||||
CR : Power_Control_Register with Volatile_Full_Access;
|
CR : Power_Control_Register;
|
||||||
CSR : Power_Control_Status_Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(CR);
|
||||||
|
CSR : Power_Control_Status_Register;
|
||||||
|
Pragma Volatile_Full_Access(CSR);
|
||||||
end record with Volatile;
|
end record with Volatile;
|
||||||
|
|
||||||
for PWR_Registers use record
|
for PWR_Registers use record
|
||||||
|
|
|
@ -114,13 +114,20 @@ package STM32.F4.SysCfg is
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
type SYSCFG_Registers is record
|
type SYSCFG_Registers is record
|
||||||
MEMRMP: Memory_Remap_Register with Volatile_Full_Access;
|
MEMRMP: Memory_Remap_Register;
|
||||||
PMC: Peripherial_Mode_Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(MEMRMP);
|
||||||
EXTICR1: External_Interrupt_Configuration_1.Register with Volatile_Full_Access;
|
PMC: Peripherial_Mode_Register;
|
||||||
EXTICR2: External_Interrupt_Configuration_2.Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(PMC);
|
||||||
EXTICR3: External_Interrupt_Configuration_3.Register with Volatile_Full_Access;
|
EXTICR1: External_Interrupt_Configuration_1.Register;
|
||||||
EXTICR4: External_Interrupt_Configuration_4.Register with Volatile_Full_Access;
|
Pragma Volatile_Full_Access(EXTICR1);
|
||||||
CMPCR: Compensation_Cell_Control_Register with Volatile_Full_Access;
|
EXTICR2: External_Interrupt_Configuration_2.Register;
|
||||||
|
Pragma Volatile_Full_Access(EXTICR2);
|
||||||
|
EXTICR3: External_Interrupt_Configuration_3.Register;
|
||||||
|
Pragma Volatile_Full_Access(EXTICR3);
|
||||||
|
EXTICR4: External_Interrupt_Configuration_4.Register;
|
||||||
|
Pragma Volatile_Full_Access(EXTICR4);
|
||||||
|
CMPCR: Compensation_Cell_Control_Register;
|
||||||
|
Pragma Volatile_Full_Access(CMPCR);
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
for SYSCFG_Registers use record
|
for SYSCFG_Registers use record
|
||||||
|
|
|
@ -226,13 +226,20 @@ package STM32.F4.USART is
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
type USART_Registers is record
|
type USART_Registers is record
|
||||||
SR: Status_Register with Volatile_Full_Access; -- Status register
|
SR: Status_Register; -- Status register
|
||||||
DR: Unsigned_32 with Volatile_Full_Access; -- Data register
|
Pragma Volatile_Full_Access(SR);
|
||||||
BRR: Baud_Rate_Register with Volatile_Full_Access; -- Baud rate register
|
DR: Unsigned_32; -- Data register
|
||||||
CR1: Control_Register_1 with Volatile_Full_Access; -- Control register 1
|
Pragma Volatile_Full_Access(DR);
|
||||||
CR2: Control_Register_2 with Volatile_Full_Access; -- Control register 2
|
BRR: Baud_Rate_Register; -- Baud rate register
|
||||||
CR3: Control_Register_3 with Volatile_Full_Access; -- Control register 3
|
Pragma Volatile_Full_Access(BRR);
|
||||||
GTPR: Guard_Time_and_Prescaler_Register with Volatile_Full_Access; -- Guard time and prescaler register
|
CR1: Control_Register_1; -- Control register 1
|
||||||
|
Pragma Volatile_Full_Access(CR1);
|
||||||
|
CR2: Control_Register_2; -- Control register 2
|
||||||
|
Pragma Volatile_Full_Access(CR2);
|
||||||
|
CR3: Control_Register_3; -- Control register 3
|
||||||
|
Pragma Volatile_Full_Access(CR3);
|
||||||
|
GTPR: Guard_Time_and_Prescaler_Register; -- Guard time and prescaler register
|
||||||
|
Pragma Volatile_Full_Access(GTPR);
|
||||||
end record with Volatile;
|
end record with Volatile;
|
||||||
for USART_Registers use record
|
for USART_Registers use record
|
||||||
SR at 16#00# range 0 .. 31;
|
SR at 16#00# range 0 .. 31;
|
||||||
|
|
Loading…
Reference in a new issue