Skip to content

nRF52832 and nRF52 DK Support #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nRF51/52: fix style
  • Loading branch information
Fabien-Chouteau committed Feb 13, 2020
commit ab77012fcf00284dd039d890186f296a315cd21b
142 changes: 99 additions & 43 deletions arch/ARM/Nordic/devices/nrf52/nrf-device.adb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,30 @@ with NRF_SVD.TEMP; use NRF_SVD.TEMP;

package body nRF.Device is

Undocumented_Reg_FE0: UInt32
Undocumented_Reg_FE0 : UInt32
with Address => System'To_Address (16#F0000FE0#);
Undocumented_Reg_FE4: UInt32
Undocumented_Reg_FE4 : UInt32
with Address => System'To_Address (16#F0000FE4#);
Undocumented_Reg_FE8: UInt32
Undocumented_Reg_FE8 : UInt32
with Address => System'To_Address (16#F0000FE8#);
FE0_Is_Six: constant Boolean := (Undocumented_Reg_FE0 and 16#FF#) = 6;
FE4_Is_Zero: constant Boolean := (Undocumented_Reg_FE0 and 16#0F#) = 0;
FE0_Is_Six : constant Boolean := (Undocumented_Reg_FE0 and 16#FF#) = 6;
FE4_Is_Zero : constant Boolean := (Undocumented_Reg_FE0 and 16#0F#) = 0;

function Errata_12 return Boolean;
function Errata_16 return Boolean;
function Errata_31 return Boolean;
function Errata_32 return Boolean;
function Errata_36 return Boolean;
function Errata_37 return Boolean;
function Errata_57 return Boolean;
function Errata_66 return Boolean;
function Errata_136 return Boolean;
function Errata_182 return Boolean;
function Errata_108 return Boolean;

---------------
-- Errata_12 --
---------------

function Errata_12 return Boolean is
begin
Expand All @@ -31,11 +47,15 @@ package body nRF.Device is
return False;
end Errata_12;

E12_Undocumented_COMP_Reg_540: UInt32
E12_Undocumented_COMP_Reg_540 : UInt32
with Address => System'To_Address (16#40013540#);
E12_Undocumented_FICR_Reg_324: UInt32
E12_Undocumented_FICR_Reg_324 : UInt32
with Address => System'To_Address (16#10000324#);

---------------
-- Errata_16 --
---------------

function Errata_16 return Boolean is
begin
if FE0_Is_Six and FE4_Is_Zero and Undocumented_Reg_FE8 = 16#30# then
Expand All @@ -44,51 +64,75 @@ package body nRF.Device is
return False;
end Errata_16;

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

---------------
-- Errata_31 --
---------------

function Errata_31 return Boolean is
begin
return Errata_12;
end Errata_31;

E31_Undocumented_CLOCK_Reg_53C: UInt32 with
E31_Undocumented_CLOCK_Reg_53C : UInt32 with
Address => System'To_Address (16#4000053C#);
E31_Undocumented_FICR_Reg_244: UInt32 with
E31_Undocumented_FICR_Reg_244 : UInt32 with
Address => System'To_Address (16#10000244#);

---------------
-- Errata_32 --
---------------

function Errata_32 return Boolean is
begin
return Errata_16;
end Errata_32;

---------------
-- Errata_36 --
---------------

function Errata_36 return Boolean is
begin
return Errata_12;
end Errata_36;

---------------
-- Errata_37 --
---------------

function Errata_37 return Boolean is
begin
return Errata_16;
end Errata_37;

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

---------------
-- Errata_57 --
---------------

function Errata_57 return Boolean is
begin
return Errata_16;
end Errata_57;

E57_Undocumented_NFCT_Reg_610: UInt32 with
E57_Undocumented_NFCT_Reg_610 : UInt32 with
Address => System'To_Address (16#40005610#);
E57_Undocumented_NFCT_Reg_614: UInt32 with
E57_Undocumented_NFCT_Reg_614 : UInt32 with
Address => System'To_Address (16#40005614#);
E57_Undocumented_NFCT_Reg_618: UInt32 with
E57_Undocumented_NFCT_Reg_618 : UInt32 with
Address => System'To_Address (16#40005618#);
E57_Undocumented_NFCT_Reg_688: UInt32 with
E57_Undocumented_NFCT_Reg_688 : UInt32 with
Address => System'To_Address (16#40005688#);

---------------
-- Errata_66 --
---------------

function Errata_66 return Boolean is
begin
if FE0_Is_Six and FE4_Is_Zero and Undocumented_Reg_FE8 = 16#50# then
Expand All @@ -97,84 +141,96 @@ package body nRF.Device is
return False;
end Errata_66;

----------------
-- Errata_108 --
----------------

function Errata_108 return Boolean is
begin
return Errata_12;
end Errata_108;

E108_Undocumented_Reg_EE4: UInt32 with
E108_Undocumented_Reg_EE4 : UInt32 with
Address => System'To_Address (16#40000EE4#);
E108_Undocumented_FICR_Reg_258: UInt32 with
E108_Undocumented_FICR_Reg_258 : UInt32 with
Address => System'To_Address (16#10000258#);

----------------
-- Errata_136 --
----------------

function Errata_136 return Boolean is
begin
return Errata_12;
end Errata_136;

----------------
-- Errata_182 --
----------------

function Errata_182 return Boolean is
Undocumented_FICR_Reg_130: UInt32
Undocumented_FICR_Reg_130 : UInt32
with Address => System'To_Address (16#10000130#);
Undocumented_FICR_Reg_134: UInt32
Undocumented_FICR_Reg_134 : UInt32
with Address => System'To_Address (16#10000130#);
begin
return Undocumented_FICR_Reg_130 = 6 and Undocumented_FICR_Reg_134 = 6;
end Errata_182;

E182_Undocumented_Reg_73C: UInt32 with
E182_Undocumented_Reg_73C : UInt32 with
Address => System'To_Address (16#4000173C#);

begin
if Errata_12 then
-- Workaround for Errata 12 "COMP: Reference ladder not correctly
-- calibrated"
-- Workaround for Errata 12 "COMP: Reference ladder not correctly
-- calibrated"
E12_Undocumented_COMP_Reg_540 :=
Shift_Right(E12_Undocumented_FICR_Reg_324 and 16#1F00#, 8);
Shift_Right (E12_Undocumented_FICR_Reg_324 and 16#1F00#, 8);
end if;

if Errata_16 then
-- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU
-- IDLE"
-- Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU
-- IDLE"
E16_Undocumented_Reg_074 := 3131961357;
end if;

if Errata_31 then
-- Workaround for Errata 31 "CLOCK: Calibration values are not correctly
-- loaded from FICR at reset"
-- Workaround for Errata 31 "CLOCK: Calibration values are not correctly
-- loaded from FICR at reset"
E31_Undocumented_CLOCK_Reg_53C :=
Shift_Right(E31_Undocumented_FICR_Reg_244 and 16#E000#, 13);
Shift_Right (E31_Undocumented_FICR_Reg_244 and 16#E000#, 13);
end if;

if Errata_32 then
-- Workaround for Errata 32 "DIF: Debug session automatically enables
-- TracePort pins"
-- Workaround for Errata 32 "DIF: Debug session automatically enables
-- TracePort pins"
Debug_Periph.DEMCR.TRCENA := False;
end if;

if Errata_36 then
-- Workaround for Errata 36 "CLOCK: Some registers are not reset when
-- expected"
-- Workaround for Errata 36 "CLOCK: Some registers are not reset when
-- expected"
CLOCK_Periph.EVENTS_DONE.EVENTS_DONE := False;
CLOCK_Periph.EVENTS_CTTO.EVENTS_CTTO := False;
CLOCK_Periph.CTIV.CTIV := 0;
end if;

if Errata_37 then
-- Workaround for Errata 37 "RADIO: Encryption engine is slow by default"
-- Workaround for Errata 37 "RADIO: Encryption engine is slow by default"
E37_Undocumented_Reg_5A0 := 3;
end if;

if Errata_57 then
-- Workaround for Errata 57 "NFCT: NFC Modulation amplitude"
-- Workaround for Errata 57 "NFCT: NFC Modulation amplitude"
E57_Undocumented_NFCT_Reg_610 := 5;
E57_Undocumented_NFCT_Reg_688 := 1;
E57_Undocumented_NFCT_Reg_618 := 0;
E57_Undocumented_NFCT_Reg_614 := 16#3F#;
end if;

if Errata_66 then
-- Workaround for Errata 66 "TEMP: Linearity specification not met with
-- default settings"
-- Workaround for Errata 66 "TEMP: Linearity specification not met with
-- default settings"
TEMP_Periph.A0.A0 := FICR_Periph.TEMP.A0.A;
TEMP_Periph.A1.A1 := FICR_Periph.TEMP.A1.A;
TEMP_Periph.A2.A2 := FICR_Periph.TEMP.A2.A;
Expand All @@ -197,24 +253,24 @@ begin
end if;

if Errata_108 then
-- Workaround for Errata 108 "RAM: RAM content cannot be trusted upon
-- waking up from System ON Idle or System OFF mode"
-- Workaround for Errata 108 "RAM: RAM content cannot be trusted upon
-- waking up from System ON Idle or System OFF mode"
E108_Undocumented_Reg_EE4 := E108_Undocumented_FICR_Reg_258 and 16#4F#;
end if;

if Errata_136 then
-- Workaround for Errata 136 "System: Bits in RESETREAS are set when they
-- should not be"
-- Workaround for Errata 136 "System: Bits in RESETREAS are set when they
-- should not be"
if POWER_Periph.RESETREAS.RESETPIN = Detected then
POWER_Periph.RESETREAS.RESETPIN := Notdetected;
end if;
end if;

if Errata_182 then
-- Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and
-- #107 do not take effect"
-- Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and
-- #107 do not take effect"
E182_Undocumented_Reg_73C :=
E182_Undocumented_Reg_73C or Shift_Left(1, 10);
E182_Undocumented_Reg_73C or Shift_Left (1, 10);
end if;

end nRF.Device;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.Clock)
separate (nRF.Clock)
procedure Set_High_Freq_External_Frequency (Freq : High_Freq_Ext_Freq) is
begin
CLOCK_Periph.XTALFREQ.XTALFREQ := (case Freq is
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-ppi-add_to_group.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.PPI)
separate (nRF.PPI)
procedure Add_To_Group
(Chan : Channel_ID;
Group : Group_ID)
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-ppi-disable_channel.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.PPI)
separate (nRF.PPI)
procedure Disable_Channel (Chan : Channel_ID) is
Arr : CHENCLR_CH_Field_Array := (others => Chenclr_Ch0_Field_Reset);
begin
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-ppi-enable_channel.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.PPI)
separate (nRF.PPI)
procedure Enable_Channel (Chan : Channel_ID) is
Arr : CHENSET_CH_Field_Array := (others => Chenset_Ch0_Field_Reset);
begin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.PPI)
separate (nRF.PPI)
procedure Remove_From_Group
(Chan : Channel_ID;
Group : Group_ID)
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-rng-read.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.RNG)
separate (nRF.RNG)
function Read return UInt8 is
begin
-- Clear event
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-rtc-clear.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.RTC)
separate (nRF.RTC)
procedure Clear (This : Real_Time_Counter) is
begin
This.Periph.TASKS_CLEAR := 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-rtc-start.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.RTC)
separate (nRF.RTC)
procedure Start (This : Real_Time_Counter) is
begin
This.Periph.TASKS_START := 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-rtc-stop.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.RTC)
separate (nRF.RTC)
procedure Stop (This : Real_Time_Counter) is
begin
This.Periph.TASKS_STOP := 1;
Expand Down
7 changes: 6 additions & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-temperature-read.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
separate(nRF.Temperature)
with HAL;

separate (nRF.Temperature)
function Read return Temp_Celsius is
use type HAL.UInt32;

Raw : RAW_Temp;

begin

-- Clear event
Expand Down
4 changes: 2 additions & 2 deletions arch/ARM/Nordic/drivers/nrf51/nrf-timers-capture.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
separate(nRF.Timers)
separate (nRF.Timers)
procedure Capture (This : in out Timer;
Chan : Timer_Channel)
Chan : Timer_Channel)
is
begin
This.Periph.TASKS_CAPTURE (Integer (Chan)) := 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-timers-clear.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.Timers)
separate (nRF.Timers)
procedure Clear (This : in out Timer) is
begin
This.Periph.TASKS_CLEAR := 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-timers-start.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(NRF.Timers)
separate (nRF.Timers)
procedure Start (This : in out Timer) is
begin
This.Periph.TASKS_START := 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/Nordic/drivers/nrf51/nrf-timers-stop.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
separate(nRF.Timers)
separate (nRF.Timers)
procedure Stop (This : in out Timer) is
begin
This.Periph.TASKS_STOP := 1;
Expand Down
Loading