msp432/sysctl.rs
1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright Tock Contributors 2022.
4
5//! System Controller (SYSCTL)
6
7use kernel::utilities::registers::interfaces::ReadWriteable;
8use kernel::utilities::registers::{register_bitfields, register_structs, ReadOnly, ReadWrite};
9use kernel::utilities::StaticRef;
10
11const SYSCTL_BASE: StaticRef<SysCtlRegisters> =
12 unsafe { StaticRef::new(0xE004_3000 as *const SysCtlRegisters) };
13
14register_structs! {
15 /// SYSCTL
16 SysCtlRegisters {
17 /// Reboot Control Register
18 (0x0000 => reboot_ctl: ReadWrite<u32, SYS_REBOOT_CTL::Register>),
19 /// NMI Control and Status Register
20 (0x0004 => nmi_ctlstat: ReadWrite<u32, SYS_NMI_CTLSTAT::Register>),
21 /// Watchdog Reset Control Register
22 (0x0008 => wdtreset_ctl: ReadWrite<u32, SYS_WDTRESET_CTL::Register>),
23 /// Peripheral Halt Control Register
24 (0x000C => perihalt_ctl: ReadWrite<u32, SYS_PERIHALT_CTL::Register>),
25 /// SRAM Size Register
26 (0x0010 => sram_size: ReadOnly<u32>),
27 /// SRAM Bank Enable Register
28 (0x0014 => sram_banken: ReadWrite<u32, SYS_SRAM_BANKEN::Register>),
29 /// SRAM Bank Retention Control Register
30 (0x0018 => sram_bankret: ReadWrite<u32, SYS_SRAM_BANKRET::Register>),
31 (0x001C => _reserved0),
32 /// Flash Size Register
33 (0x0020 => flash_size: ReadOnly<u32>),
34 (0x0024 => _reserved1),
35 /// Digital I/O Glitch Filter Control Register
36 (0x0030 => dio_gltflt_ctl: ReadWrite<u32>),
37 (0x0034 => _reserved2),
38 /// IP Protected Secure Zone Data Access Unlock Register
39 (0x0040 => secdata_unlock: ReadWrite<u32>),
40 (0x0044 => _reserved3),
41 /// Master Unlock Register
42 (0x1000 => master_unlock: ReadWrite<u32>),
43 /// Boot Override Request Register
44 (0x1004 => bootover_req_0: ReadWrite<u32>),
45 /// Boot Override Request Register
46 (0x1008 => bootover_req_1: ReadWrite<u32>),
47 /// Boot Override Acknowledge Register
48 (0x100C => bootover_ack: ReadWrite<u32>),
49 /// Reset Request Register
50 (0x1010 => reset_req: ReadWrite<u32, SYS_RESET_REQ::Register>),
51 /// Reset Status and Override Register
52 (0x1014 => reset_statover: ReadWrite<u32, SYS_RESET_STATOVER::Register>),
53 (0x1018 => _reserved4),
54 /// System Status Register
55 (0x1020 => system_stat: ReadOnly<u32, SYS_SYSTEM_STAT::Register>),
56 (0x1024 => @END),
57 }
58}
59
60register_bitfields![u32,
61 SYS_REBOOT_CTL [
62 /// Write 1 initiates a Reboot of the device
63 REBOOT OFFSET(0) NUMBITS(1) [],
64 /// Key to enable writes to bit 0
65 WKEY OFFSET(8) NUMBITS(8) []
66 ],
67 SYS_NMI_CTLSTAT [
68 /// CS interrupt as a source of NMI
69 CS_SRC OFFSET(0) NUMBITS(1) [
70 /// Disables CS interrupt as a source of NMI
71 DisablesCSInterruptAsASourceOfNMI = 0,
72 /// Enables CS interrupt as a source of NMI
73 EnablesCSInterruptAsASourceOfNMI = 1
74 ],
75 /// PSS interrupt as a source of NMI
76 PSS_SRC OFFSET(1) NUMBITS(1) [
77 /// Disables the PSS interrupt as a source of NMI
78 DisablesThePSSInterruptAsASourceOfNMI = 0,
79 /// Enables the PSS interrupt as a source of NMI
80 EnablesThePSSInterruptAsASourceOfNMI = 1
81 ],
82 /// PCM interrupt as a source of NMI
83 PCM_SRC OFFSET(2) NUMBITS(1) [
84 /// Disbles the PCM interrupt as a source of NMI
85 DisblesThePCMInterruptAsASourceOfNMI = 0,
86 /// Enables the PCM interrupt as a source of NMI
87 EnablesThePCMInterruptAsASourceOfNMI = 1
88 ],
89 /// RSTn/NMI pin configuration
90 PIN_SRC OFFSET(3) NUMBITS(1) [
91 /// Configures the RSTn_NMI pin as a source of POR Class Reset
92 ConfiguresTheRSTn_NMIPinAsASourceOfPORClassReset = 0,
93 /// Configures the RSTn_NMI pin as a source of NMI
94 ConfiguresTheRSTn_NMIPinAsASourceOfNMI = 1
95 ],
96 /// CS interrupt was the source of NMI
97 CS_FLG OFFSET(16) NUMBITS(1) [
98 /// indicates CS interrupt was not the source of NMI
99 IndicatesCSInterruptWasNotTheSourceOfNMI = 0,
100 /// indicates CS interrupt was the source of NMI
101 IndicatesCSInterruptWasTheSourceOfNMI = 1
102 ],
103 /// PSS interrupt was the source of NMI
104 PSS_FLG OFFSET(17) NUMBITS(1) [
105 /// indicates the PSS interrupt was not the source of NMI
106 IndicatesThePSSInterruptWasNotTheSourceOfNMI = 0,
107 /// indicates the PSS interrupt was the source of NMI
108 IndicatesThePSSInterruptWasTheSourceOfNMI = 1
109 ],
110 /// PCM interrupt was the source of NMI
111 PCM_FLG OFFSET(18) NUMBITS(1) [
112 /// indicates the PCM interrupt was not the source of NMI
113 IndicatesThePCMInterruptWasNotTheSourceOfNMI = 0,
114 /// indicates the PCM interrupt was the source of NMI
115 IndicatesThePCMInterruptWasTheSourceOfNMI = 1
116 ],
117 /// RSTn/NMI pin was the source of NMI
118 PIN_FLG OFFSET(19) NUMBITS(1) [
119 /// Indicates the RSTn_NMI pin was not the source of NMI
120 IndicatesTheRSTn_NMIPinWasNotTheSourceOfNMI = 0,
121 /// Indicates the RSTn_NMI pin was the source of NMI
122 IndicatesTheRSTn_NMIPinWasTheSourceOfNMI = 1
123 ]
124 ],
125 SYS_WDTRESET_CTL [
126 /// WDT timeout reset type
127 TIMEOUT OFFSET(0) NUMBITS(1) [
128 /// WDT timeout event generates Soft reset
129 WDTTimeoutEventGeneratesSoftReset = 0,
130 /// WDT timeout event generates Hard reset
131 WDTTimeoutEventGeneratesHardReset = 1
132 ],
133 /// WDT password violation reset type
134 VIOLATION OFFSET(1) NUMBITS(1) [
135 /// WDT password violation event generates Soft reset
136 WDTPasswordViolationEventGeneratesSoftReset = 0,
137 /// WDT password violation event generates Hard reset
138 WDTPasswordViolationEventGeneratesHardReset = 1
139 ]
140 ],
141 SYS_PERIHALT_CTL [
142 /// Freezes IP operation when CPU is halted
143 HALT_T16_0 OFFSET(0) NUMBITS(1) [
144 /// IP operation unaffected when CPU is halted
145 IPOperationUnaffectedWhenCPUIsHalted = 0,
146 /// freezes IP operation when CPU is halted
147 FreezesIPOperationWhenCPUIsHalted = 1
148 ],
149 /// Freezes IP operation when CPU is halted
150 HALT_T16_1 OFFSET(1) NUMBITS(1) [
151 /// IP operation unaffected when CPU is halted
152 IPOperationUnaffectedWhenCPUIsHalted = 0,
153 /// freezes IP operation when CPU is halted
154 FreezesIPOperationWhenCPUIsHalted = 1
155 ],
156 /// Freezes IP operation when CPU is halted
157 HALT_T16_2 OFFSET(2) NUMBITS(1) [
158 /// IP operation unaffected when CPU is halted
159 IPOperationUnaffectedWhenCPUIsHalted = 0,
160 /// freezes IP operation when CPU is halted
161 FreezesIPOperationWhenCPUIsHalted = 1
162 ],
163 /// Freezes IP operation when CPU is halted
164 HALT_T16_3 OFFSET(3) NUMBITS(1) [
165 /// IP operation unaffected when CPU is halted
166 IPOperationUnaffectedWhenCPUIsHalted = 0,
167 /// freezes IP operation when CPU is halted
168 FreezesIPOperationWhenCPUIsHalted = 1
169 ],
170 /// Freezes IP operation when CPU is halted
171 HALT_T32_0 OFFSET(4) NUMBITS(1) [
172 /// IP operation unaffected when CPU is halted
173 IPOperationUnaffectedWhenCPUIsHalted = 0,
174 /// freezes IP operation when CPU is halted
175 FreezesIPOperationWhenCPUIsHalted = 1
176 ],
177 /// Freezes IP operation when CPU is halted
178 HALT_eUA0 OFFSET(5) NUMBITS(1) [
179 /// IP operation unaffected when CPU is halted
180 IPOperationUnaffectedWhenCPUIsHalted = 0,
181 /// freezes IP operation when CPU is halted
182 FreezesIPOperationWhenCPUIsHalted = 1
183 ],
184 /// Freezes IP operation when CPU is halted
185 HALT_eUA1 OFFSET(6) NUMBITS(1) [
186 /// IP operation unaffected when CPU is halted
187 IPOperationUnaffectedWhenCPUIsHalted = 0,
188 /// freezes IP operation when CPU is halted
189 FreezesIPOperationWhenCPUIsHalted = 1
190 ],
191 /// Freezes IP operation when CPU is halted
192 HALT_eUA2 OFFSET(7) NUMBITS(1) [
193 /// IP operation unaffected when CPU is halted
194 IPOperationUnaffectedWhenCPUIsHalted = 0,
195 /// freezes IP operation when CPU is halted
196 FreezesIPOperationWhenCPUIsHalted = 1
197 ],
198 /// Freezes IP operation when CPU is halted
199 HALT_eUA3 OFFSET(8) NUMBITS(1) [
200 /// IP operation unaffected when CPU is halted
201 IPOperationUnaffectedWhenCPUIsHalted = 0,
202 /// freezes IP operation when CPU is halted
203 FreezesIPOperationWhenCPUIsHalted = 1
204 ],
205 /// Freezes IP operation when CPU is halted
206 HALT_eUB0 OFFSET(9) NUMBITS(1) [
207 /// IP operation unaffected when CPU is halted
208 IPOperationUnaffectedWhenCPUIsHalted = 0,
209 /// freezes IP operation when CPU is halted
210 FreezesIPOperationWhenCPUIsHalted = 1
211 ],
212 /// Freezes IP operation when CPU is halted
213 HALT_eUB1 OFFSET(10) NUMBITS(1) [
214 /// IP operation unaffected when CPU is halted
215 IPOperationUnaffectedWhenCPUIsHalted = 0,
216 /// freezes IP operation when CPU is halted
217 FreezesIPOperationWhenCPUIsHalted = 1
218 ],
219 /// Freezes IP operation when CPU is halted
220 HALT_eUB2 OFFSET(11) NUMBITS(1) [
221 /// IP operation unaffected when CPU is halted
222 IPOperationUnaffectedWhenCPUIsHalted = 0,
223 /// freezes IP operation when CPU is halted
224 FreezesIPOperationWhenCPUIsHalted = 1
225 ],
226 /// Freezes IP operation when CPU is halted
227 HALT_eUB3 OFFSET(12) NUMBITS(1) [
228 /// IP operation unaffected when CPU is halted
229 IPOperationUnaffectedWhenCPUIsHalted = 0,
230 /// freezes IP operation when CPU is halted
231 FreezesIPOperationWhenCPUIsHalted = 1
232 ],
233 /// Freezes IP operation when CPU is halted
234 HALT_ADC OFFSET(13) NUMBITS(1) [
235 /// IP operation unaffected when CPU is halted
236 IPOperationUnaffectedWhenCPUIsHalted = 0,
237 /// freezes IP operation when CPU is halted
238 FreezesIPOperationWhenCPUIsHalted = 1
239 ],
240 /// Freezes IP operation when CPU is halted
241 HALT_WDT OFFSET(14) NUMBITS(1) [
242 /// IP operation unaffected when CPU is halted
243 IPOperationUnaffectedWhenCPUIsHalted = 0,
244 /// freezes IP operation when CPU is halted
245 FreezesIPOperationWhenCPUIsHalted = 1
246 ],
247 /// Freezes IP operation when CPU is halted
248 HALT_DMA OFFSET(15) NUMBITS(1) [
249 /// IP operation unaffected when CPU is halted
250 IPOperationUnaffectedWhenCPUIsHalted = 0,
251 /// freezes IP operation when CPU is halted
252 FreezesIPOperationWhenCPUIsHalted = 1
253 ]
254 ],
255 SYS_SRAM_BANKEN [
256 /// SRAM Bank0 enable
257 BNK0_EN OFFSET(0) NUMBITS(1) [],
258 /// SRAM Bank1 enable
259 BNK1_EN OFFSET(1) NUMBITS(1) [
260 /// Disables Bank1 of the SRAM
261 DisablesBank1OfTheSRAM = 0,
262 /// Enables Bank1 of the SRAM
263 EnablesBank1OfTheSRAM = 1
264 ],
265 /// SRAM Bank1 enable
266 BNK2_EN OFFSET(2) NUMBITS(1) [
267 /// Disables Bank2 of the SRAM
268 DisablesBank2OfTheSRAM = 0,
269 /// Enables Bank2 of the SRAM
270 EnablesBank2OfTheSRAM = 1
271 ],
272 /// SRAM Bank1 enable
273 BNK3_EN OFFSET(3) NUMBITS(1) [
274 /// Disables Bank3 of the SRAM
275 DisablesBank3OfTheSRAM = 0,
276 /// Enables Bank3 of the SRAM
277 EnablesBank3OfTheSRAM = 1
278 ],
279 /// SRAM Bank1 enable
280 BNK4_EN OFFSET(4) NUMBITS(1) [
281 /// Disables Bank4 of the SRAM
282 DisablesBank4OfTheSRAM = 0,
283 /// Enables Bank4 of the SRAM
284 EnablesBank4OfTheSRAM = 1
285 ],
286 /// SRAM Bank1 enable
287 BNK5_EN OFFSET(5) NUMBITS(1) [
288 /// Disables Bank5 of the SRAM
289 DisablesBank5OfTheSRAM = 0,
290 /// Enables Bank5 of the SRAM
291 EnablesBank5OfTheSRAM = 1
292 ],
293 /// SRAM Bank1 enable
294 BNK6_EN OFFSET(6) NUMBITS(1) [
295 /// Disables Bank6 of the SRAM
296 DisablesBank6OfTheSRAM = 0,
297 /// Enables Bank6 of the SRAM
298 EnablesBank6OfTheSRAM = 1
299 ],
300 /// SRAM Bank1 enable
301 BNK7_EN OFFSET(7) NUMBITS(1) [
302 /// Disables Bank7 of the SRAM
303 DisablesBank7OfTheSRAM = 0,
304 /// Enables Bank7 of the SRAM
305 EnablesBank7OfTheSRAM = 1
306 ],
307 /// SRAM ready
308 SRAM_RDY OFFSET(16) NUMBITS(1) [
309 /// SRAM is not ready for accesses. Banks are undergoing an enable or disable sequen
310 SRAM_RDY_0 = 0,
311 /// SRAM is ready for accesses. All SRAM banks are enabled/disabled according to val
312 SRAM_RDY_1 = 1
313 ]
314 ],
315 SYS_SRAM_BANKRET [
316 /// Bank0 retention
317 BNK0_RET OFFSET(0) NUMBITS(1) [],
318 /// Bank1 retention
319 BNK1_RET OFFSET(1) NUMBITS(1) [
320 /// Bank1 of the SRAM is not retained in LPM3 or LPM4
321 Bank1OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
322 /// Bank1 of the SRAM is retained in LPM3 and LPM4
323 Bank1OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
324 ],
325 /// Bank2 retention
326 BNK2_RET OFFSET(2) NUMBITS(1) [
327 /// Bank2 of the SRAM is not retained in LPM3 or LPM4
328 Bank2OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
329 /// Bank2 of the SRAM is retained in LPM3 and LPM4
330 Bank2OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
331 ],
332 /// Bank3 retention
333 BNK3_RET OFFSET(3) NUMBITS(1) [
334 /// Bank3 of the SRAM is not retained in LPM3 or LPM4
335 Bank3OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
336 /// Bank3 of the SRAM is retained in LPM3 and LPM4
337 Bank3OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
338 ],
339 /// Bank4 retention
340 BNK4_RET OFFSET(4) NUMBITS(1) [
341 /// Bank4 of the SRAM is not retained in LPM3 or LPM4
342 Bank4OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
343 /// Bank4 of the SRAM is retained in LPM3 and LPM4
344 Bank4OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
345 ],
346 /// Bank5 retention
347 BNK5_RET OFFSET(5) NUMBITS(1) [
348 /// Bank5 of the SRAM is not retained in LPM3 or LPM4
349 Bank5OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
350 /// Bank5 of the SRAM is retained in LPM3 and LPM4
351 Bank5OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
352 ],
353 /// Bank6 retention
354 BNK6_RET OFFSET(6) NUMBITS(1) [
355 /// Bank6 of the SRAM is not retained in LPM3 or LPM4
356 Bank6OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
357 /// Bank6 of the SRAM is retained in LPM3 and LPM4
358 Bank6OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
359 ],
360 /// Bank7 retention
361 BNK7_RET OFFSET(7) NUMBITS(1) [
362 /// Bank7 of the SRAM is not retained in LPM3 or LPM4
363 Bank7OfTheSRAMIsNotRetainedInLPM3OrLPM4 = 0,
364 /// Bank7 of the SRAM is retained in LPM3 and LPM4
365 Bank7OfTheSRAMIsRetainedInLPM3AndLPM4 = 1
366 ],
367 /// SRAM ready
368 SRAM_RDY OFFSET(16) NUMBITS(1) [
369 /// SRAM banks are being set up for retention. Entry into LPM3, LPM4 should not be a
370 SRAM_RDY_0 = 0,
371 /// SRAM is ready for accesses. All SRAM banks are enabled/disabled for retention ac
372 SRAM_RDY_1 = 1
373 ]
374 ],
375 SYS_RESET_REQ [
376 /// Generate POR
377 POR OFFSET(0) NUMBITS(1) [],
378 /// Generate Reboot_Reset
379 REBOOT OFFSET(1) NUMBITS(1) [],
380 /// Write key
381 WKEY OFFSET(8) NUMBITS(8) []
382 ],
383 SYS_RESET_STATOVER [
384 /// Indicates if SOFT Reset is active
385 SOFT OFFSET(0) NUMBITS(1) [],
386 /// Indicates if HARD Reset is active
387 HARD OFFSET(1) NUMBITS(1) [],
388 /// Indicates if Reboot Reset is active
389 REBOOT OFFSET(2) NUMBITS(1) [],
390 /// SOFT_Reset overwrite request
391 SOFT_OVER OFFSET(8) NUMBITS(1) [],
392 /// HARD_Reset overwrite request
393 HARD_OVER OFFSET(9) NUMBITS(1) [],
394 /// Reboot Reset overwrite request
395 RBT_OVER OFFSET(10) NUMBITS(1) []
396 ],
397 SYS_SYSTEM_STAT [
398 /// Debug Security active
399 DBG_SEC_ACT OFFSET(3) NUMBITS(1) [],
400 /// Indicates if JTAG and SWD Lock is active
401 JTAG_SWD_LOCK_ACT OFFSET(4) NUMBITS(1) [],
402 /// Indicates if IP protection is active
403 IP_PROT_ACT OFFSET(5) NUMBITS(1) []
404 ]
405];
406
407pub struct SysCtl {
408 registers: StaticRef<SysCtlRegisters>,
409}
410
411impl SysCtl {
412 pub const fn new() -> SysCtl {
413 SysCtl {
414 registers: SYSCTL_BASE,
415 }
416 }
417
418 pub fn enable_all_sram_banks(&self) {
419 self.registers
420 .sram_banken
421 .modify(SYS_SRAM_BANKEN::BNK7_EN::SET);
422 }
423}