Skip to content

Commit d00fba8

Browse files
committed
nRF52832 and nRF52 DK Support
1 parent bd611e0 commit d00fba8

File tree

196 files changed

+39341
-2467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+39341
-2467
lines changed

arch/ARM/Nordic/devices/nrf51-device.ads renamed to arch/ARM/Nordic/devices/nrf51/nrf-device.ads

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929
-- --
3030
------------------------------------------------------------------------------
3131

32-
with nRF51.GPIO; use nRF51.GPIO;
33-
with nRF51.RTC; use nRF51.RTC;
34-
with NRF51_SVD.RTC;
35-
with nRF51.TWI; use nRF51.TWI;
36-
with NRF51_SVD.TWI;
37-
with nRF51.SPI_Master; use nRF51.SPI_Master;
38-
with NRF51_SVD.SPI;
39-
with nRF51.Timers; use nRF51.Timers;
40-
with NRF51_SVD.TIMER;
41-
with nRF51.UART; use nRF51.UART;
42-
with NRF51_SVD.UART;
32+
with nRF.GPIO; use nRF.GPIO;
33+
with nRF.RTC; use nRF.RTC;
34+
with NRF_SVD.RTC;
35+
with nRF.TWI; use nRF.TWI;
36+
with NRF_SVD.TWI;
37+
with nRF.SPI_Master; use nRF.SPI_Master;
38+
with NRF_SVD.SPI;
39+
with nRF.Timers; use nRF.Timers;
40+
with NRF_SVD.TIMER;
41+
with nRF.UART; use nRF.UART;
42+
with NRF_SVD.UART;
4343

44-
package nRF51.Device is
44+
package nRF.Device is
4545

4646
P00 : aliased GPIO_Point := (Pin => 00);
4747
P01 : aliased GPIO_Point := (Pin => 01);
@@ -76,27 +76,27 @@ package nRF51.Device is
7676
P30 : aliased GPIO_Point := (Pin => 30);
7777
P31 : aliased GPIO_Point := (Pin => 31);
7878

79-
RTC_0 : aliased Real_Time_Counter (NRF51_SVD.RTC.RTC0_Periph'Access);
80-
RTC_1 : aliased Real_Time_Counter (NRF51_SVD.RTC.RTC1_Periph'Access);
79+
RTC_0 : aliased Real_Time_Counter (NRF_SVD.RTC.RTC0_Periph'Access);
80+
RTC_1 : aliased Real_Time_Counter (NRF_SVD.RTC.RTC1_Periph'Access);
8181

8282

8383
-- Be carefull of shared resources between the TWI and SPI controllers.
8484
-- TWI_O and SPI_Master_0 cannot be used at the same time.
8585
-- TWI_1 and SPI_Master_1 cannot be used at the same time.
8686
--
87-
-- See nRF51 Series Reference Manual, chapter Memory.Instantiation.
87+
-- See nRF Series Reference Manual, chapter Memory.Instantiation.
8888

89-
TWI_0 : aliased TWI_Master (NRF51_SVD.TWI.TWI0_Periph'Access);
90-
TWI_1 : aliased TWI_Master (NRF51_SVD.TWI.TWI1_Periph'Access);
89+
TWI_0 : aliased TWI_Master (NRF_SVD.TWI.TWI0_Periph'Access);
90+
TWI_1 : aliased TWI_Master (NRF_SVD.TWI.TWI1_Periph'Access);
9191

92-
SPI_Master_0 : aliased nRF51.SPI_Master.SPI_Master (NRF51_SVD.SPI.SPI0_Periph'Access);
93-
SPI_Master_1 : aliased nRF51.SPI_Master.SPI_Master (NRF51_SVD.SPI.SPI1_Periph'Access);
92+
SPI_Master_0 : aliased nRF.SPI_Master.SPI_Master (NRF_SVD.SPI.SPI0_Periph'Access);
93+
SPI_Master_1 : aliased nRF.SPI_Master.SPI_Master (NRF_SVD.SPI.SPI1_Periph'Access);
9494

9595

96-
Timer_0 : aliased Timer (NRF51_SVD.TIMER.TIMER0_Periph'Access);
97-
Timer_1 : aliased Timer (NRF51_SVD.TIMER.TIMER1_Periph'Access);
98-
Timer_2 : aliased Timer (NRF51_SVD.TIMER.TIMER2_Periph'Access);
96+
Timer_0 : aliased Timer (NRF_SVD.TIMER.TIMER0_Periph'Access);
97+
Timer_1 : aliased Timer (NRF_SVD.TIMER.TIMER1_Periph'Access);
98+
Timer_2 : aliased Timer (NRF_SVD.TIMER.TIMER2_Periph'Access);
9999

100100

101-
UART_0 : aliased UART_Device (NRF51_SVD.UART.UART0_Periph'Access);
102-
end nRF51.Device;
101+
UART_0 : aliased UART_Device (NRF_SVD.UART.UART0_Periph'Access);
102+
end nRF.Device;
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
with System;
2+
with HAL; use HAL;
3+
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;
9+
10+
package body nRF.Device is
11+
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+
21+
function Errata_12 return Boolean is
22+
begin
23+
if FE0_Is_Six and FE4_Is_Zero then
24+
case Undocumented_Reg_FE8 and 16#F0# is
25+
when 16#30# => return True;
26+
when 16#40# => return True;
27+
when 16#50# => return True;
28+
when others => return False;
29+
end case;
30+
end if;
31+
return False;
32+
end Errata_12;
33+
34+
E12_Undocumented_COMP_Reg_540: UInt32
35+
with Address => System'To_Address (16#40013540#);
36+
E12_Undocumented_FICR_Reg_324: UInt32
37+
with Address => System'To_Address (16#10000324#);
38+
39+
function Errata_16 return Boolean is
40+
begin
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;
45+
end Errata_16;
46+
47+
E16_Undocumented_Reg_074: UInt32
48+
with Address => System'To_Address (16#4007C074#);
49+
50+
function Errata_31 return Boolean is
51+
begin
52+
return Errata_12;
53+
end Errata_31;
54+
55+
E31_Undocumented_CLOCK_Reg_53C: UInt32 with
56+
Address => System'To_Address (16#4000053C#);
57+
E31_Undocumented_FICR_Reg_244: UInt32 with
58+
Address => System'To_Address (16#10000244#);
59+
60+
function Errata_32 return Boolean is
61+
begin
62+
return Errata_16;
63+
end Errata_32;
64+
65+
function Errata_36 return Boolean is
66+
begin
67+
return Errata_12;
68+
end Errata_36;
69+
70+
function Errata_37 return Boolean is
71+
begin
72+
return Errata_16;
73+
end Errata_37;
74+
75+
E37_Undocumented_Reg_5A0: UInt32 with
76+
Address => System'To_Address (16#400005A0#);
77+
78+
function Errata_57 return Boolean is
79+
begin
80+
return Errata_16;
81+
end Errata_57;
82+
83+
E57_Undocumented_NFCT_Reg_610: UInt32 with
84+
Address => System'To_Address (16#40005610#);
85+
E57_Undocumented_NFCT_Reg_614: UInt32 with
86+
Address => System'To_Address (16#40005614#);
87+
E57_Undocumented_NFCT_Reg_618: UInt32 with
88+
Address => System'To_Address (16#40005618#);
89+
E57_Undocumented_NFCT_Reg_688: UInt32 with
90+
Address => System'To_Address (16#40005688#);
91+
92+
function Errata_66 return Boolean is
93+
begin
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;
98+
end Errata_66;
99+
100+
function Errata_108 return Boolean is
101+
begin
102+
return Errata_12;
103+
end Errata_108;
104+
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+
110+
function Errata_136 return Boolean is
111+
begin
112+
return Errata_12;
113+
end Errata_136;
114+
115+
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#);
120+
begin
121+
return Undocumented_FICR_Reg_130 = 6 and Undocumented_FICR_Reg_134 = 6;
122+
end Errata_182;
123+
124+
E182_Undocumented_Reg_73C: UInt32 with
125+
Address => System'To_Address (16#4000173C#);
126+
127+
begin
128+
if Errata_12 then
129+
-- Workaround for Errata 12 "COMP: Reference ladder not correctly
130+
-- calibrated"
131+
E12_Undocumented_COMP_Reg_540 :=
132+
Shift_Right(E12_Undocumented_FICR_Reg_324 and 16#1F00#, 8);
133+
end if;
134+
135+
if Errata_16 then
136+
-- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU
137+
-- IDLE"
138+
E16_Undocumented_Reg_074 := 3131961357;
139+
end if;
140+
141+
if Errata_31 then
142+
-- Workaround for Errata 31 "CLOCK: Calibration values are not correctly
143+
-- loaded from FICR at reset"
144+
E31_Undocumented_CLOCK_Reg_53C :=
145+
Shift_Right(E31_Undocumented_FICR_Reg_244 and 16#E000#, 13);
146+
end if;
147+
148+
if Errata_32 then
149+
-- Workaround for Errata 32 "DIF: Debug session automatically enables
150+
-- TracePort pins"
151+
Debug_Periph.DEMCR.TRCENA := False;
152+
end if;
153+
154+
if Errata_36 then
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;
160+
end if;
161+
162+
if Errata_37 then
163+
-- Workaround for Errata 37 "RADIO: Encryption engine is slow by default"
164+
E37_Undocumented_Reg_5A0 := 3;
165+
end if;
166+
167+
if Errata_57 then
168+
-- Workaround for Errata 57 "NFCT: NFC Modulation amplitude"
169+
E57_Undocumented_NFCT_Reg_610 := 5;
170+
E57_Undocumented_NFCT_Reg_688 := 1;
171+
E57_Undocumented_NFCT_Reg_618 := 0;
172+
E57_Undocumented_NFCT_Reg_614 := 16#3F#;
173+
end if;
174+
175+
if Errata_66 then
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;
197+
end if;
198+
199+
if Errata_108 then
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#;
203+
end if;
204+
205+
if Errata_136 then
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;
211+
end if;
212+
213+
if Errata_182 then
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);
218+
end if;
219+
220+
end nRF.Device;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
------------------------------------------------------------------------------
2+
-- --
3+
-- Copyright (C) 2016, AdaCore --
4+
-- --
5+
-- Redistribution and use in source and binary forms, with or without --
6+
-- modification, are permitted provided that the following conditions are --
7+
-- met: --
8+
-- 1. Redistributions of source code must retain the above copyright --
9+
-- notice, this list of conditions and the following disclaimer. --
10+
-- 2. Redistributions in binary form must reproduce the above copyright --
11+
-- notice, this list of conditions and the following disclaimer in --
12+
-- the documentation and/or other materials provided with the --
13+
-- distribution. --
14+
-- 3. Neither the name of the copyright holder nor the names of its --
15+
-- contributors may be used to endorse or promote products derived --
16+
-- from this software without specific prior written permission. --
17+
-- --
18+
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
19+
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
20+
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
21+
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
22+
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
23+
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
24+
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
25+
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
26+
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
27+
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
28+
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
29+
-- --
30+
------------------------------------------------------------------------------
31+
32+
with nRF.GPIO; use nRF.GPIO;
33+
with nRF.RTC; use nRF.RTC;
34+
with NRF_SVD.RTC;
35+
with nRF.TWI; use nRF.TWI;
36+
with NRF_SVD.TWI;
37+
with nRF.SPI_Master; use nRF.SPI_Master;
38+
with NRF_SVD.SPI;
39+
with nRF.Timers; use nRF.Timers;
40+
with NRF_SVD.TIMER;
41+
with nRF.UART; use nRF.UART;
42+
with NRF_SVD.UART;
43+
44+
package nRF.Device is
45+
pragma Elaborate_Body;
46+
47+
P00 : aliased GPIO_Point := (Pin => 00);
48+
P01 : aliased GPIO_Point := (Pin => 01);
49+
P02 : aliased GPIO_Point := (Pin => 02);
50+
P03 : aliased GPIO_Point := (Pin => 03);
51+
P04 : aliased GPIO_Point := (Pin => 04);
52+
P05 : aliased GPIO_Point := (Pin => 05);
53+
P06 : aliased GPIO_Point := (Pin => 06);
54+
P07 : aliased GPIO_Point := (Pin => 07);
55+
P08 : aliased GPIO_Point := (Pin => 08);
56+
P09 : aliased GPIO_Point := (Pin => 09);
57+
P10 : aliased GPIO_Point := (Pin => 10);
58+
P11 : aliased GPIO_Point := (Pin => 11);
59+
P12 : aliased GPIO_Point := (Pin => 12);
60+
P13 : aliased GPIO_Point := (Pin => 13);
61+
P14 : aliased GPIO_Point := (Pin => 14);
62+
P15 : aliased GPIO_Point := (Pin => 15);
63+
P16 : aliased GPIO_Point := (Pin => 16);
64+
P17 : aliased GPIO_Point := (Pin => 17);
65+
P18 : aliased GPIO_Point := (Pin => 18);
66+
P19 : aliased GPIO_Point := (Pin => 19);
67+
P20 : aliased GPIO_Point := (Pin => 20);
68+
P21 : aliased GPIO_Point := (Pin => 21);
69+
P22 : aliased GPIO_Point := (Pin => 22);
70+
P23 : aliased GPIO_Point := (Pin => 23);
71+
P24 : aliased GPIO_Point := (Pin => 24);
72+
P25 : aliased GPIO_Point := (Pin => 25);
73+
P26 : aliased GPIO_Point := (Pin => 26);
74+
P27 : aliased GPIO_Point := (Pin => 27);
75+
P28 : aliased GPIO_Point := (Pin => 28);
76+
P29 : aliased GPIO_Point := (Pin => 29);
77+
P30 : aliased GPIO_Point := (Pin => 30);
78+
P31 : aliased GPIO_Point := (Pin => 31);
79+
80+
RTC_0 : aliased Real_Time_Counter (NRF_SVD.RTC.RTC0_Periph'Access);
81+
RTC_1 : aliased Real_Time_Counter (NRF_SVD.RTC.RTC1_Periph'Access);
82+
83+
84+
-- Be carefull of shared resources between the TWI and SPI controllers.
85+
-- TWI_O and SPI_Master_0 cannot be used at the same time.
86+
-- TWI_1 and SPI_Master_1 cannot be used at the same time.
87+
--
88+
-- See nRF Series Reference Manual, chapter Memory.Instantiation.
89+
90+
TWI_0 : aliased TWI_Master (NRF_SVD.TWI.TWI0_Periph'Access);
91+
TWI_1 : aliased TWI_Master (NRF_SVD.TWI.TWI1_Periph'Access);
92+
93+
SPI_Master_0 : aliased nRF.SPI_Master.SPI_Master (NRF_SVD.SPI.SPI0_Periph'Access);
94+
SPI_Master_1 : aliased nRF.SPI_Master.SPI_Master (NRF_SVD.SPI.SPI1_Periph'Access);
95+
96+
97+
Timer_0 : aliased Timer (NRF_SVD.TIMER.TIMER0_Periph'Access);
98+
Timer_1 : aliased Timer (NRF_SVD.TIMER.TIMER1_Periph'Access);
99+
Timer_2 : aliased Timer (NRF_SVD.TIMER.TIMER2_Periph'Access);
100+
Timer_3 : aliased Timer (NRF_SVD.TIMER.TIMER3_Periph'Access);
101+
Timer_4 : aliased Timer (NRF_SVD.TIMER.TIMER4_Periph'Access);
102+
103+
104+
UART_0 : aliased UART_Device (NRF_SVD.UART.UART0_Periph'Access);
105+
end nRF.Device;

0 commit comments

Comments
 (0)