Skip to content

Commit 8692e91

Browse files
committed
Remaining errata workarounds
1 parent 96da6bd commit 8692e91

File tree

1 file changed

+90
-58
lines changed

1 file changed

+90
-58
lines changed
Lines changed: 90 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
with System;
22
with HAL; use HAL;
33

4-
with Cortex_M_SVD.Debug;
5-
with NRF_SVD.CLOCK;
6-
with NRF_SVD.FICR;
7-
with NRF_SVD.TEMP;
4+
with Cortex_M_SVD.Debug; use Cortex_M_SVD.Debug;
5+
with NRF_SVD.CLOCK; use NRF_SVD.CLOCK;
6+
with NRF_SVD.FICR; use NRF_SVD.FICR;
7+
with NRF_SVD.POWER; use NRF_SVD.POWER;
8+
with NRF_SVD.TEMP; use NRF_SVD.TEMP;
89

910
package body nRF.Device is
1011

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_Is_Six: constant Boolean := (Undocumented_Reg_FE0 and 16#FF#) = 6;
19+
FE4_Is_Zero: constant Boolean := (Undocumented_Reg_FE0 and 16#0F#) = 0;
20+
1121
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;
2022
begin
21-
if FE0_Check and FE4_Check then
23+
if FE0_Is_Six and FE4_Is_Zero then
2224
case Undocumented_Reg_FE8 and 16#F0# is
2325
when 16#30# => return True;
2426
when 16#40# => return True;
@@ -36,15 +38,18 @@ package body nRF.Device is
3638

3739
function Errata_16 return Boolean is
3840
begin
39-
return True;
41+
if FE0_Is_Six and FE4_Is_Zero and Undocumented_Reg_FE8 = 16#30# then
42+
return True;
43+
end if;
44+
return False;
4045
end Errata_16;
4146

4247
E16_Undocumented_Reg_074: UInt32
4348
with Address => System'To_Address (16#4007C074#);
4449

4550
function Errata_31 return Boolean is
4651
begin
47-
return True;
52+
return Errata_12;
4853
end Errata_31;
4954

5055
E31_Undocumented_CLOCK_Reg_53C: UInt32 with
@@ -54,25 +59,25 @@ package body nRF.Device is
5459

5560
function Errata_32 return Boolean is
5661
begin
57-
return True;
62+
return Errata_16;
5863
end Errata_32;
5964

6065
function Errata_36 return Boolean is
6166
begin
62-
return True;
67+
return Errata_12;
6368
end Errata_36;
6469

6570
function Errata_37 return Boolean is
6671
begin
67-
return True;
72+
return Errata_16;
6873
end Errata_37;
6974

7075
E37_Undocumented_Reg_5A0: UInt32 with
7176
Address => System'To_Address (16#400005A0#);
7277

7378
function Errata_57 return Boolean is
7479
begin
75-
return True;
80+
return Errata_16;
7681
end Errata_57;
7782

7883
E57_Undocumented_NFCT_Reg_610: UInt32 with
@@ -86,52 +91,72 @@ package body nRF.Device is
8691

8792
function Errata_66 return Boolean is
8893
begin
89-
return True;
94+
if FE0_Is_Six and FE4_Is_Zero and Undocumented_Reg_FE8 = 16#50# then
95+
return True;
96+
end if;
97+
return False;
9098
end Errata_66;
9199

92100
function Errata_108 return Boolean is
93101
begin
94-
return True;
102+
return Errata_12;
95103
end Errata_108;
96104

105+
E108_Undocumented_Reg_EE4: UInt32 with
106+
Address => System'To_Address (16#40000EE4#);
107+
E108_Undocumented_FICR_Reg_258: UInt32 with
108+
Address => System'To_Address (16#10000258#);
109+
97110
function Errata_136 return Boolean is
98111
begin
99-
return True;
112+
return Errata_12;
100113
end Errata_136;
101114

102115
function Errata_182 return Boolean is
116+
Undocumented_FICR_Reg_130: UInt32
117+
with Address => System'To_Address (16#10000130#);
118+
Undocumented_FICR_Reg_134: UInt32
119+
with Address => System'To_Address (16#10000130#);
103120
begin
104-
return True;
121+
return Undocumented_FICR_Reg_130 = 6 and Undocumented_FICR_Reg_134 = 6;
105122
end Errata_182;
106123

124+
E182_Undocumented_Reg_73C: UInt32 with
125+
Address => System'To_Address (16#4000173C#);
126+
107127
begin
108128
if Errata_12 then
109-
-- Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated"
129+
-- Workaround for Errata 12 "COMP: Reference ladder not correctly
130+
-- calibrated"
110131
E12_Undocumented_COMP_Reg_540 :=
111132
Shift_Right(E12_Undocumented_FICR_Reg_324 and 16#1F00#, 8);
112133
end if;
113134

114135
if Errata_16 then
115-
-- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE"
136+
-- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU
137+
-- IDLE"
116138
E16_Undocumented_Reg_074 := 3131961357;
117139
end if;
118140

119141
if Errata_31 then
120-
-- Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset"
142+
-- Workaround for Errata 31 "CLOCK: Calibration values are not correctly
143+
-- loaded from FICR at reset"
121144
E31_Undocumented_CLOCK_Reg_53C :=
122145
Shift_Right(E31_Undocumented_FICR_Reg_244 and 16#E000#, 13);
123146
end if;
124147

125148
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;
149+
-- Workaround for Errata 32 "DIF: Debug session automatically enables
150+
-- TracePort pins"
151+
Debug_Periph.DEMCR.TRCENA := False;
128152
end if;
129153

130154
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;
155+
-- Workaround for Errata 36 "CLOCK: Some registers are not reset when
156+
-- expected"
157+
CLOCK_Periph.EVENTS_DONE.EVENTS_DONE := False;
158+
CLOCK_Periph.EVENTS_CTTO.EVENTS_CTTO := False;
159+
CLOCK_Periph.CTIV.CTIV := 0;
135160
end if;
136161

137162
if Errata_37 then
@@ -148,41 +173,48 @@ begin
148173
end if;
149174

150175
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;
176+
-- Workaround for Errata 66 "TEMP: Linearity specification not met with
177+
-- default settings"
178+
TEMP_Periph.A0.A0 := FICR_Periph.TEMP.A0.A;
179+
TEMP_Periph.A1.A1 := FICR_Periph.TEMP.A1.A;
180+
TEMP_Periph.A2.A2 := FICR_Periph.TEMP.A2.A;
181+
TEMP_Periph.A3.A3 := FICR_Periph.TEMP.A3.A;
182+
TEMP_Periph.A4.A4 := FICR_Periph.TEMP.A4.A;
183+
TEMP_Periph.A5.A5 := FICR_Periph.TEMP.A5.A;
184+
185+
TEMP_Periph.B0.B0 := FICR_Periph.TEMP.B0.B;
186+
TEMP_Periph.B1.B1 := FICR_Periph.TEMP.B1.B;
187+
TEMP_Periph.B2.B2 := FICR_Periph.TEMP.B2.B;
188+
TEMP_Periph.B3.B3 := FICR_Periph.TEMP.B3.B;
189+
TEMP_Periph.B4.B4 := FICR_Periph.TEMP.B4.B;
190+
TEMP_Periph.B5.B5 := FICR_Periph.TEMP.B5.B;
191+
192+
TEMP_Periph.T0.T0 := FICR_Periph.TEMP.T0.T;
193+
TEMP_Periph.T1.T1 := FICR_Periph.TEMP.T1.T;
194+
TEMP_Periph.T2.T2 := FICR_Periph.TEMP.T2.T;
195+
TEMP_Periph.T3.T3 := FICR_Periph.TEMP.T3.T;
196+
TEMP_Periph.T4.T4 := FICR_Periph.TEMP.T4.T;
171197
end if;
172198

173199
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;
200+
-- Workaround for Errata 108 "RAM: RAM content cannot be trusted upon
201+
-- waking up from System ON Idle or System OFF mode"
202+
E108_Undocumented_Reg_EE4 := E108_Undocumented_FICR_Reg_258 and 16#4F#;
176203
end if;
177204

178205
if Errata_136 then
179-
-- Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be"
180-
null;
206+
-- Workaround for Errata 136 "System: Bits in RESETREAS are set when they
207+
-- should not be"
208+
if POWER_Periph.RESETREAS.RESETPIN = Detected then
209+
POWER_Periph.RESETREAS.RESETPIN := Notdetected;
210+
end if;
181211
end if;
182212

183213
if Errata_182 then
184-
-- Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and #107 do not take effect"
185-
null;
214+
-- Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and
215+
-- #107 do not take effect"
216+
E182_Undocumented_Reg_73C :=
217+
E182_Undocumented_Reg_73C or Shift_Left(1, 10);
186218
end if;
187219

188220
end nRF.Device;

0 commit comments

Comments
 (0)