|
| 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; |
0 commit comments