Skip to content

Commit 96da6bd

Browse files
committed
WIP: Errata abatement in package elaboration
1 parent 89efa7b commit 96da6bd

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
with System;
2+
with HAL; use HAL;
3+
4+
with Cortex_M_SVD.Debug;
5+
with NRF_SVD.CLOCK;
6+
with NRF_SVD.FICR;
7+
with NRF_SVD.TEMP;
8+
9+
package body nRF.Device is
10+
11+
function Errata_12 return Boolean is
12+
Undocumented_Reg_FE0: UInt32
13+
with Address => System'To_Address (16#F0000FE0#);
14+
Undocumented_Reg_FE4: UInt32
15+
with Address => System'To_Address (16#F0000FE4#);
16+
Undocumented_Reg_FE8: UInt32
17+
with Address => System'To_Address (16#F0000FE8#);
18+
FE0_Check: constant Boolean := (Undocumented_Reg_FE0 and 16#FF#) = 6;
19+
FE4_Check: constant Boolean := (Undocumented_Reg_FE0 and 16#0F#) = 0;
20+
begin
21+
if FE0_Check and FE4_Check then
22+
case Undocumented_Reg_FE8 and 16#F0# is
23+
when 16#30# => return True;
24+
when 16#40# => return True;
25+
when 16#50# => return True;
26+
when others => return False;
27+
end case;
28+
end if;
29+
return False;
30+
end Errata_12;
31+
32+
E12_Undocumented_COMP_Reg_540: UInt32
33+
with Address => System'To_Address (16#40013540#);
34+
E12_Undocumented_FICR_Reg_324: UInt32
35+
with Address => System'To_Address (16#10000324#);
36+
37+
function Errata_16 return Boolean is
38+
begin
39+
return True;
40+
end Errata_16;
41+
42+
E16_Undocumented_Reg_074: UInt32
43+
with Address => System'To_Address (16#4007C074#);
44+
45+
function Errata_31 return Boolean is
46+
begin
47+
return True;
48+
end Errata_31;
49+
50+
E31_Undocumented_CLOCK_Reg_53C: UInt32 with
51+
Address => System'To_Address (16#4000053C#);
52+
E31_Undocumented_FICR_Reg_244: UInt32 with
53+
Address => System'To_Address (16#10000244#);
54+
55+
function Errata_32 return Boolean is
56+
begin
57+
return True;
58+
end Errata_32;
59+
60+
function Errata_36 return Boolean is
61+
begin
62+
return True;
63+
end Errata_36;
64+
65+
function Errata_37 return Boolean is
66+
begin
67+
return True;
68+
end Errata_37;
69+
70+
E37_Undocumented_Reg_5A0: UInt32 with
71+
Address => System'To_Address (16#400005A0#);
72+
73+
function Errata_57 return Boolean is
74+
begin
75+
return True;
76+
end Errata_57;
77+
78+
E57_Undocumented_NFCT_Reg_610: UInt32 with
79+
Address => System'To_Address (16#40005610#);
80+
E57_Undocumented_NFCT_Reg_614: UInt32 with
81+
Address => System'To_Address (16#40005614#);
82+
E57_Undocumented_NFCT_Reg_618: UInt32 with
83+
Address => System'To_Address (16#40005618#);
84+
E57_Undocumented_NFCT_Reg_688: UInt32 with
85+
Address => System'To_Address (16#40005688#);
86+
87+
function Errata_66 return Boolean is
88+
begin
89+
return True;
90+
end Errata_66;
91+
92+
function Errata_108 return Boolean is
93+
begin
94+
return True;
95+
end Errata_108;
96+
97+
function Errata_136 return Boolean is
98+
begin
99+
return True;
100+
end Errata_136;
101+
102+
function Errata_182 return Boolean is
103+
begin
104+
return True;
105+
end Errata_182;
106+
107+
begin
108+
if Errata_12 then
109+
-- Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated"
110+
E12_Undocumented_COMP_Reg_540 :=
111+
Shift_Right(E12_Undocumented_FICR_Reg_324 and 16#1F00#, 8);
112+
end if;
113+
114+
if Errata_16 then
115+
-- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE"
116+
E16_Undocumented_Reg_074 := 3131961357;
117+
end if;
118+
119+
if Errata_31 then
120+
-- Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset"
121+
E31_Undocumented_CLOCK_Reg_53C :=
122+
Shift_Right(E31_Undocumented_FICR_Reg_244 and 16#E000#, 13);
123+
end if;
124+
125+
if Errata_32 then
126+
-- Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins"
127+
Cortex_M_SVD.Debug.Debug_Periph.DEMCR.TRCENA := False;
128+
end if;
129+
130+
if Errata_36 then
131+
-- Workaround for Errata 36 "CLOCK: Some registers are not reset when expected"
132+
NRF_SVD.CLOCK.CLOCK_Periph.EVENTS_DONE.EVENTS_DONE := False;
133+
NRF_SVD.CLOCK.CLOCK_Periph.EVENTS_CTTO.EVENTS_CTTO := False;
134+
NRF_SVD.CLOCK.CLOCK_Periph.CTIV.CTIV := 0;
135+
end if;
136+
137+
if Errata_37 then
138+
-- Workaround for Errata 37 "RADIO: Encryption engine is slow by default"
139+
E37_Undocumented_Reg_5A0 := 3;
140+
end if;
141+
142+
if Errata_57 then
143+
-- Workaround for Errata 57 "NFCT: NFC Modulation amplitude"
144+
E57_Undocumented_NFCT_Reg_610 := 5;
145+
E57_Undocumented_NFCT_Reg_688 := 1;
146+
E57_Undocumented_NFCT_Reg_618 := 0;
147+
E57_Undocumented_NFCT_Reg_614 := 16#3F#;
148+
end if;
149+
150+
if Errata_66 then
151+
-- Workaround for Errata 66 "TEMP: Linearity specification not met with default settings"
152+
NRF_SVD.TEMP.TEMP_Periph.A0.A0 := NRF_SVD.FICR.FICR_Periph.TEMP.A0.A;
153+
NRF_SVD.TEMP.TEMP_Periph.A1.A1 := NRF_SVD.FICR.FICR_Periph.TEMP.A1.A;
154+
NRF_SVD.TEMP.TEMP_Periph.A2.A2 := NRF_SVD.FICR.FICR_Periph.TEMP.A2.A;
155+
NRF_SVD.TEMP.TEMP_Periph.A3.A3 := NRF_SVD.FICR.FICR_Periph.TEMP.A3.A;
156+
NRF_SVD.TEMP.TEMP_Periph.A4.A4 := NRF_SVD.FICR.FICR_Periph.TEMP.A4.A;
157+
NRF_SVD.TEMP.TEMP_Periph.A5.A5 := NRF_SVD.FICR.FICR_Periph.TEMP.A5.A;
158+
159+
NRF_SVD.TEMP.TEMP_Periph.B0.B0 := NRF_SVD.FICR.FICR_Periph.TEMP.B0.B;
160+
NRF_SVD.TEMP.TEMP_Periph.B1.B1 := NRF_SVD.FICR.FICR_Periph.TEMP.B1.B;
161+
NRF_SVD.TEMP.TEMP_Periph.B2.B2 := NRF_SVD.FICR.FICR_Periph.TEMP.B2.B;
162+
NRF_SVD.TEMP.TEMP_Periph.B3.B3 := NRF_SVD.FICR.FICR_Periph.TEMP.B3.B;
163+
NRF_SVD.TEMP.TEMP_Periph.B4.B4 := NRF_SVD.FICR.FICR_Periph.TEMP.B4.B;
164+
NRF_SVD.TEMP.TEMP_Periph.B5.B5 := NRF_SVD.FICR.FICR_Periph.TEMP.B5.B;
165+
166+
NRF_SVD.TEMP.TEMP_Periph.T0.T0 := NRF_SVD.FICR.FICR_Periph.TEMP.T0.T;
167+
NRF_SVD.TEMP.TEMP_Periph.T1.T1 := NRF_SVD.FICR.FICR_Periph.TEMP.T1.T;
168+
NRF_SVD.TEMP.TEMP_Periph.T2.T2 := NRF_SVD.FICR.FICR_Periph.TEMP.T2.T;
169+
NRF_SVD.TEMP.TEMP_Periph.T3.T3 := NRF_SVD.FICR.FICR_Periph.TEMP.T3.T;
170+
NRF_SVD.TEMP.TEMP_Periph.T4.T4 := NRF_SVD.FICR.FICR_Periph.TEMP.T4.T;
171+
end if;
172+
173+
if Errata_108 then
174+
-- Workaround for Errata 108 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode"
175+
null;
176+
end if;
177+
178+
if Errata_136 then
179+
-- Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be"
180+
null;
181+
end if;
182+
183+
if Errata_182 then
184+
-- Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and #107 do not take effect"
185+
null;
186+
end if;
187+
188+
end nRF.Device;

arch/ARM/Nordic/devices/nrf52/nrf-device.ads

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ with nRF.UART; use nRF.UART;
4242
with NRF_SVD.UART;
4343

4444
package nRF.Device is
45+
pragma Elaborate_Body;
4546

4647
P00 : aliased GPIO_Point := (Pin => 00);
4748
P01 : aliased GPIO_Point := (Pin => 01);

0 commit comments

Comments
 (0)