Skip to main content

rp2350_pac/generated/
mod.rs

1//! RP2350 Hardware Register Definitions
2//!
3//! Auto-generated from RP2350.svd - DO NOT EDIT MANUALLY
4
5#![allow(dead_code)]
6#![allow(non_camel_case_types)]
7#![allow(clippy::identity_op)]
8
9use core::marker::PhantomData;
10use core::ops::Deref;
11
12pub mod common;
13
14// ============================================================================
15// Interrupt Handlers
16// ============================================================================
17
18unsafe extern "C" {
19    fn TIMER0_IRQ_0();
20    fn TIMER0_IRQ_1();
21    fn TIMER0_IRQ_2();
22    fn TIMER0_IRQ_3();
23    fn TIMER1_IRQ_0();
24    fn TIMER1_IRQ_1();
25    fn TIMER1_IRQ_2();
26    fn TIMER1_IRQ_3();
27    fn PWM_IRQ_WRAP_0();
28    fn PWM_IRQ_WRAP_1();
29    fn DMA_IRQ_0();
30    fn DMA_IRQ_1();
31    fn DMA_IRQ_2();
32    fn DMA_IRQ_3();
33    fn USBCTRL_IRQ();
34    fn PIO0_IRQ_0();
35    fn PIO0_IRQ_1();
36    fn PIO1_IRQ_0();
37    fn PIO1_IRQ_1();
38    fn PIO2_IRQ_0();
39    fn PIO2_IRQ_1();
40    fn IO_IRQ_BANK0();
41    fn IO_IRQ_BANK0_NS();
42    fn IO_IRQ_QSPI();
43    fn IO_IRQ_QSPI_NS();
44    fn SIO_IRQ_FIFO();
45    fn SIO_IRQ_BELL();
46    fn SIO_IRQ_FIFO_NS();
47    fn SIO_IRQ_BELL_NS();
48    fn SIO_IRQ_MTIMECMP();
49    fn CLOCKS_IRQ();
50    fn SPI0_IRQ();
51    fn SPI1_IRQ();
52    fn UART0_IRQ();
53    fn UART1_IRQ();
54    fn ADC_IRQ_FIFO();
55    fn I2C0_IRQ();
56    fn I2C1_IRQ();
57    fn OTP_IRQ();
58    fn TRNG_IRQ();
59    fn PLL_SYS_IRQ();
60    fn PLL_USB_IRQ();
61    fn POWMAN_IRQ_POW();
62    fn POWMAN_IRQ_TIMER();
63    fn SPARE_IRQ_0();
64    fn SPARE_IRQ_1();
65    fn SPARE_IRQ_2();
66    fn SPARE_IRQ_3();
67    fn SPARE_IRQ_4();
68    fn SPARE_IRQ_5();
69}
70
71/// Union type for interrupt vectors
72#[doc(hidden)]
73#[repr(C)]
74pub union Vector {
75    _handler: unsafe extern "C" fn(),
76    _reserved: u32,
77}
78
79/// RP2350 interrupt vector table (52 interrupts)
80#[doc(hidden)]
81#[unsafe(link_section = ".vector_table.interrupts")]
82#[unsafe(no_mangle)]
83pub static __INTERRUPTS: [Vector; 52] = [
84    Vector {
85        _handler: TIMER0_IRQ_0,
86    },
87    Vector {
88        _handler: TIMER0_IRQ_1,
89    },
90    Vector {
91        _handler: TIMER0_IRQ_2,
92    },
93    Vector {
94        _handler: TIMER0_IRQ_3,
95    },
96    Vector {
97        _handler: TIMER1_IRQ_0,
98    },
99    Vector {
100        _handler: TIMER1_IRQ_1,
101    },
102    Vector {
103        _handler: TIMER1_IRQ_2,
104    },
105    Vector {
106        _handler: TIMER1_IRQ_3,
107    },
108    Vector {
109        _handler: PWM_IRQ_WRAP_0,
110    },
111    Vector {
112        _handler: PWM_IRQ_WRAP_1,
113    },
114    Vector {
115        _handler: DMA_IRQ_0,
116    },
117    Vector {
118        _handler: DMA_IRQ_1,
119    },
120    Vector {
121        _handler: DMA_IRQ_2,
122    },
123    Vector {
124        _handler: DMA_IRQ_3,
125    },
126    Vector {
127        _handler: USBCTRL_IRQ,
128    },
129    Vector {
130        _handler: PIO0_IRQ_0,
131    },
132    Vector {
133        _handler: PIO0_IRQ_1,
134    },
135    Vector {
136        _handler: PIO1_IRQ_0,
137    },
138    Vector {
139        _handler: PIO1_IRQ_1,
140    },
141    Vector {
142        _handler: PIO2_IRQ_0,
143    },
144    Vector {
145        _handler: PIO2_IRQ_1,
146    },
147    Vector {
148        _handler: IO_IRQ_BANK0,
149    },
150    Vector {
151        _handler: IO_IRQ_BANK0_NS,
152    },
153    Vector {
154        _handler: IO_IRQ_QSPI,
155    },
156    Vector {
157        _handler: IO_IRQ_QSPI_NS,
158    },
159    Vector {
160        _handler: SIO_IRQ_FIFO,
161    },
162    Vector {
163        _handler: SIO_IRQ_BELL,
164    },
165    Vector {
166        _handler: SIO_IRQ_FIFO_NS,
167    },
168    Vector {
169        _handler: SIO_IRQ_BELL_NS,
170    },
171    Vector {
172        _handler: SIO_IRQ_MTIMECMP,
173    },
174    Vector {
175        _handler: CLOCKS_IRQ,
176    },
177    Vector { _handler: SPI0_IRQ },
178    Vector { _handler: SPI1_IRQ },
179    Vector {
180        _handler: UART0_IRQ,
181    },
182    Vector {
183        _handler: UART1_IRQ,
184    },
185    Vector {
186        _handler: ADC_IRQ_FIFO,
187    },
188    Vector { _handler: I2C0_IRQ },
189    Vector { _handler: I2C1_IRQ },
190    Vector { _handler: OTP_IRQ },
191    Vector { _handler: TRNG_IRQ },
192    Vector { _reserved: 0 }, // Reserved
193    Vector { _reserved: 0 }, // Reserved
194    Vector {
195        _handler: PLL_SYS_IRQ,
196    },
197    Vector {
198        _handler: PLL_USB_IRQ,
199    },
200    Vector {
201        _handler: POWMAN_IRQ_POW,
202    },
203    Vector {
204        _handler: POWMAN_IRQ_TIMER,
205    },
206    Vector {
207        _handler: SPARE_IRQ_0,
208    },
209    Vector {
210        _handler: SPARE_IRQ_1,
211    },
212    Vector {
213        _handler: SPARE_IRQ_2,
214    },
215    Vector {
216        _handler: SPARE_IRQ_3,
217    },
218    Vector {
219        _handler: SPARE_IRQ_4,
220    },
221    Vector {
222        _handler: SPARE_IRQ_5,
223    },
224];
225
226/// RP2350 Interrupt enumeration
227#[derive(Copy, Clone, Debug, PartialEq, Eq)]
228#[repr(u16)]
229pub enum Interrupt {
230    /// 0 - TIMER0 interrupt
231    TIMER0_IRQ_0 = 0,
232    /// 1 - TIMER0 interrupt
233    TIMER0_IRQ_1 = 1,
234    /// 2 - TIMER0 interrupt
235    TIMER0_IRQ_2 = 2,
236    /// 3 - TIMER0 interrupt
237    TIMER0_IRQ_3 = 3,
238    /// 4 - TIMER1 interrupt
239    TIMER1_IRQ_0 = 4,
240    /// 5 - TIMER1 interrupt
241    TIMER1_IRQ_1 = 5,
242    /// 6 - TIMER1 interrupt
243    TIMER1_IRQ_2 = 6,
244    /// 7 - TIMER1 interrupt
245    TIMER1_IRQ_3 = 7,
246    /// 8 - PWM interrupt
247    PWM_IRQ_WRAP_0 = 8,
248    /// 9 - PWM interrupt
249    PWM_IRQ_WRAP_1 = 9,
250    /// 10 - DMA interrupt
251    DMA_IRQ_0 = 10,
252    /// 11 - DMA interrupt
253    DMA_IRQ_1 = 11,
254    /// 12 - DMA interrupt
255    DMA_IRQ_2 = 12,
256    /// 13 - DMA interrupt
257    DMA_IRQ_3 = 13,
258    /// 14 - USB interrupt
259    USBCTRL_IRQ = 14,
260    /// 15 - PIO0 interrupt
261    PIO0_IRQ_0 = 15,
262    /// 16 - PIO0 interrupt
263    PIO0_IRQ_1 = 16,
264    /// 17 - PIO1 interrupt
265    PIO1_IRQ_0 = 17,
266    /// 18 - PIO1 interrupt
267    PIO1_IRQ_1 = 18,
268    /// 19 - PIO2 interrupt
269    PIO2_IRQ_0 = 19,
270    /// 20 - PIO2 interrupt
271    PIO2_IRQ_1 = 20,
272    /// 21 - IO_BANK0 interrupt
273    IO_IRQ_BANK0 = 21,
274    /// 22 - IO_BANK0 interrupt
275    IO_IRQ_BANK0_NS = 22,
276    /// 23 - IO_QSPI interrupt
277    IO_IRQ_QSPI = 23,
278    /// 24 - IO_QSPI interrupt
279    IO_IRQ_QSPI_NS = 24,
280    /// 25 - SIO interrupt
281    SIO_IRQ_FIFO = 25,
282    /// 26 - SIO interrupt
283    SIO_IRQ_BELL = 26,
284    /// 27 - SIO interrupt
285    SIO_IRQ_FIFO_NS = 27,
286    /// 28 - SIO interrupt
287    SIO_IRQ_BELL_NS = 28,
288    /// 29 - SIO interrupt
289    SIO_IRQ_MTIMECMP = 29,
290    /// 30 - CLOCKS interrupt
291    CLOCKS_IRQ = 30,
292    /// 31 - SPI0 interrupt
293    SPI0_IRQ = 31,
294    /// 32 - SPI1 interrupt
295    SPI1_IRQ = 32,
296    /// 33 - UART0 interrupt
297    UART0_IRQ = 33,
298    /// 34 - UART1 interrupt
299    UART1_IRQ = 34,
300    /// 35 - ADC interrupt
301    ADC_IRQ_FIFO = 35,
302    /// 36 - I2C0 interrupt
303    I2C0_IRQ = 36,
304    /// 37 - I2C1 interrupt
305    I2C1_IRQ = 37,
306    /// 38 - OTP interrupt
307    OTP_IRQ = 38,
308    /// 39 - TRNG interrupt
309    TRNG_IRQ = 39,
310    /// 42 - PLL_SYS interrupt
311    PLL_SYS_IRQ = 42,
312    /// 43 - PLL_USB interrupt
313    PLL_USB_IRQ = 43,
314    /// 44 - POWMAN interrupt
315    POWMAN_IRQ_POW = 44,
316    /// 45 - POWMAN interrupt
317    POWMAN_IRQ_TIMER = 45,
318    /// 46 - SPARE_IRQ interrupt
319    SPARE_IRQ_0 = 46,
320    /// 47 - SPARE_IRQ interrupt
321    SPARE_IRQ_1 = 47,
322    /// 48 - SPARE_IRQ interrupt
323    SPARE_IRQ_2 = 48,
324    /// 49 - SPARE_IRQ interrupt
325    SPARE_IRQ_3 = 49,
326    /// 50 - SPARE_IRQ interrupt
327    SPARE_IRQ_4 = 50,
328    /// 51 - SPARE_IRQ interrupt
329    SPARE_IRQ_5 = 51,
330}
331
332unsafe impl rp2350_rt::peripheral::nvic::InterruptNumber for Interrupt {
333    #[inline(always)]
334    fn number(self) -> u16 {
335        self as u16
336    }
337}
338
339// ============================================================================
340// Peripheral Wrapper Macro
341// ============================================================================
342
343/// Helper macro to create peripheral wrappers
344macro_rules! peripheral {
345    ($name:ident, $reg:ty, $base:expr) => {
346        impl $name {
347            /// Pointer to the peripheral's register block
348            pub const PTR: *const $reg = $base as *const $reg;
349
350            /// Steal an instance of this peripheral
351            ///
352            /// # Safety
353            ///
354            /// Ensure that the new instance of the peripheral cannot be used in a way
355            /// that may race with any existing instances.
356            #[inline]
357            pub const unsafe fn steal() -> Self {
358                Self {
359                    _marker: PhantomData,
360                }
361            }
362        }
363
364        impl Deref for $name {
365            type Target = $reg;
366
367            #[inline(always)]
368            fn deref(&self) -> &Self::Target {
369                unsafe { &*Self::PTR }
370            }
371        }
372
373        impl core::fmt::Debug for $name {
374            fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
375                f.debug_struct(stringify!($name)).finish()
376            }
377        }
378    };
379}
380
381// ============================================================================
382// Peripheral Definitions
383// ============================================================================
384
385/// RESETS peripheral
386pub struct RESETS {
387    _marker: PhantomData<*const ()>,
388}
389
390unsafe impl Send for RESETS {}
391
392peripheral!(RESETS, resets::RegisterBlock, 0x40020000);
393
394/// RESETS register module
395pub mod resets;
396
397/// PSM peripheral
398pub struct PSM {
399    _marker: PhantomData<*const ()>,
400}
401
402unsafe impl Send for PSM {}
403
404peripheral!(PSM, psm::RegisterBlock, 0x40018000);
405
406/// PSM register module
407pub mod psm;
408
409/// CLOCKS peripheral
410pub struct CLOCKS {
411    _marker: PhantomData<*const ()>,
412}
413
414unsafe impl Send for CLOCKS {}
415
416peripheral!(CLOCKS, clocks::RegisterBlock, 0x40010000);
417
418/// CLOCKS register module
419pub mod clocks;
420
421/// TICKS peripheral
422pub struct TICKS {
423    _marker: PhantomData<*const ()>,
424}
425
426unsafe impl Send for TICKS {}
427
428peripheral!(TICKS, ticks::RegisterBlock, 0x40108000);
429
430/// TICKS register module
431pub mod ticks;
432
433/// PADS_BANK0 peripheral
434pub struct PADS_BANK0 {
435    _marker: PhantomData<*const ()>,
436}
437
438unsafe impl Send for PADS_BANK0 {}
439
440peripheral!(PADS_BANK0, pads_bank0::RegisterBlock, 0x40038000);
441
442/// PADS_BANK0 register module
443pub mod pads_bank0;
444
445/// PADS_QSPI peripheral
446pub struct PADS_QSPI {
447    _marker: PhantomData<*const ()>,
448}
449
450unsafe impl Send for PADS_QSPI {}
451
452peripheral!(PADS_QSPI, pads_qspi::RegisterBlock, 0x40040000);
453
454/// PADS_QSPI register module
455pub mod pads_qspi;
456
457/// IO_QSPI peripheral
458pub struct IO_QSPI {
459    _marker: PhantomData<*const ()>,
460}
461
462unsafe impl Send for IO_QSPI {}
463
464peripheral!(IO_QSPI, io_qspi::RegisterBlock, 0x40030000);
465
466/// IO_QSPI register module
467pub mod io_qspi;
468
469/// IO_BANK0 peripheral
470pub struct IO_BANK0 {
471    _marker: PhantomData<*const ()>,
472}
473
474unsafe impl Send for IO_BANK0 {}
475
476peripheral!(IO_BANK0, io_bank0::RegisterBlock, 0x40028000);
477
478/// IO_BANK0 register module
479pub mod io_bank0;
480
481/// SYSINFO peripheral
482pub struct SYSINFO {
483    _marker: PhantomData<*const ()>,
484}
485
486unsafe impl Send for SYSINFO {}
487
488peripheral!(SYSINFO, sysinfo::RegisterBlock, 0x40000000);
489
490/// SYSINFO register module
491pub mod sysinfo;
492
493/// SHA-256 hash function implementation
494pub struct SHA256 {
495    _marker: PhantomData<*const ()>,
496}
497
498unsafe impl Send for SHA256 {}
499
500peripheral!(SHA256, sha256::RegisterBlock, 0x400f8000);
501
502/// SHA-256 hash function implementation
503pub mod sha256;
504
505/// FIFO status and write access for HSTX
506pub struct HSTX_FIFO {
507    _marker: PhantomData<*const ()>,
508}
509
510unsafe impl Send for HSTX_FIFO {}
511
512peripheral!(HSTX_FIFO, hstx_fifo::RegisterBlock, 0x50600000);
513
514/// FIFO status and write access for HSTX
515pub mod hstx_fifo;
516
517/// Control interface to HSTX. For FIFO write access and status, see the HSTX_FIFO register block.
518pub struct HSTX_CTRL {
519    _marker: PhantomData<*const ()>,
520}
521
522unsafe impl Send for HSTX_CTRL {}
523
524peripheral!(HSTX_CTRL, hstx_ctrl::RegisterBlock, 0x400c0000);
525
526/// Control interface to HSTX. For FIFO write access and status, see the HSTX_FIFO register block.
527pub mod hstx_ctrl;
528
529/// Cortex-M33 EPPB vendor register block for RP2350
530pub struct EPPB {
531    _marker: PhantomData<*const ()>,
532}
533
534unsafe impl Send for EPPB {}
535
536peripheral!(EPPB, eppb::RegisterBlock, 0xe0080000);
537
538/// Cortex-M33 EPPB vendor register block for RP2350
539pub mod eppb;
540
541/// TEAL registers accessible through the debug interface
542pub struct PPB {
543    _marker: PhantomData<*const ()>,
544}
545
546unsafe impl Send for PPB {}
547
548peripheral!(PPB, ppb::RegisterBlock, 0xe0000000);
549
550/// TEAL registers accessible through the debug interface
551pub mod ppb;
552
553/// PPB_NS peripheral
554pub struct PPB_NS {
555    _marker: PhantomData<*const ()>,
556}
557
558unsafe impl Send for PPB_NS {}
559
560peripheral!(PPB_NS, ppb_ns::RegisterBlock, 0xe0020000);
561
562/// PPB_NS register module
563pub mod ppb_ns;
564
565/// QSPI Memory Interface.
566pub struct QMI {
567    _marker: PhantomData<*const ()>,
568}
569
570unsafe impl Send for QMI {}
571
572peripheral!(QMI, qmi::RegisterBlock, 0x400d0000);
573
574/// QSPI Memory Interface.
575pub mod qmi;
576
577/// QSPI flash execute-in-place block
578pub struct XIP_CTRL {
579    _marker: PhantomData<*const ()>,
580}
581
582unsafe impl Send for XIP_CTRL {}
583
584peripheral!(XIP_CTRL, xip_ctrl::RegisterBlock, 0x400c8000);
585
586/// QSPI flash execute-in-place block
587pub mod xip_ctrl;
588
589/// Auxiliary DMA access to XIP FIFOs, via fast AHB bus access
590pub struct XIP_AUX {
591    _marker: PhantomData<*const ()>,
592}
593
594unsafe impl Send for XIP_AUX {}
595
596peripheral!(XIP_AUX, xip_aux::RegisterBlock, 0x50500000);
597
598/// Auxiliary DMA access to XIP FIFOs, via fast AHB bus access
599pub mod xip_aux;
600
601/// Register block for various chip control signals
602pub struct SYSCFG {
603    _marker: PhantomData<*const ()>,
604}
605
606unsafe impl Send for SYSCFG {}
607
608peripheral!(SYSCFG, syscfg::RegisterBlock, 0x40008000);
609
610/// Register block for various chip control signals
611pub mod syscfg;
612
613/// Controls the crystal oscillator
614pub struct XOSC {
615    _marker: PhantomData<*const ()>,
616}
617
618unsafe impl Send for XOSC {}
619
620peripheral!(XOSC, xosc::RegisterBlock, 0x40048000);
621
622/// Controls the crystal oscillator
623pub mod xosc;
624
625/// PLL_SYS peripheral
626pub struct PLL_SYS {
627    _marker: PhantomData<*const ()>,
628}
629
630unsafe impl Send for PLL_SYS {}
631
632peripheral!(PLL_SYS, pll_sys::RegisterBlock, 0x40050000);
633
634/// PLL_SYS register module
635pub mod pll_sys;
636
637/// PLL_USB peripheral
638pub struct PLL_USB {
639    _marker: PhantomData<*const ()>,
640}
641
642unsafe impl Send for PLL_USB {}
643
644peripheral!(PLL_USB, pll_usb::RegisterBlock, 0x40058000);
645
646/// PLL_USB register module
647pub mod pll_usb;
648
649/// Hardware access control registers
650pub struct ACCESSCTRL {
651    _marker: PhantomData<*const ()>,
652}
653
654unsafe impl Send for ACCESSCTRL {}
655
656peripheral!(ACCESSCTRL, accessctrl::RegisterBlock, 0x40060000);
657
658/// Hardware access control registers
659pub mod accessctrl;
660
661/// UART0 peripheral
662pub struct UART0 {
663    _marker: PhantomData<*const ()>,
664}
665
666unsafe impl Send for UART0 {}
667
668peripheral!(UART0, uart0::RegisterBlock, 0x40070000);
669
670/// UART0 register module
671pub mod uart0;
672
673/// UART1 peripheral
674pub struct UART1 {
675    _marker: PhantomData<*const ()>,
676}
677
678unsafe impl Send for UART1 {}
679
680peripheral!(UART1, uart1::RegisterBlock, 0x40078000);
681
682/// UART1 register module
683pub mod uart1;
684
685/// ROSC peripheral
686pub struct ROSC {
687    _marker: PhantomData<*const ()>,
688}
689
690unsafe impl Send for ROSC {}
691
692peripheral!(ROSC, rosc::RegisterBlock, 0x400e8000);
693
694/// ROSC register module
695pub mod rosc;
696
697/// Controls vreg, bor, lposc, chip resets & xosc startup, powman and provides scratch register for general use and for bootcode use
698pub struct POWMAN {
699    _marker: PhantomData<*const ()>,
700}
701
702unsafe impl Send for POWMAN {}
703
704peripheral!(POWMAN, powman::RegisterBlock, 0x40100000);
705
706/// Controls vreg, bor, lposc, chip resets & xosc startup, powman and provides scratch register for general use and for bootcode use
707pub mod powman;
708
709/// WATCHDOG peripheral
710pub struct WATCHDOG {
711    _marker: PhantomData<*const ()>,
712}
713
714unsafe impl Send for WATCHDOG {}
715
716peripheral!(WATCHDOG, watchdog::RegisterBlock, 0x400d8000);
717
718/// WATCHDOG register module
719pub mod watchdog;
720
721/// DMA with separate read and write masters
722pub struct DMA {
723    _marker: PhantomData<*const ()>,
724}
725
726unsafe impl Send for DMA {}
727
728peripheral!(DMA, dma::RegisterBlock, 0x50000000);
729
730/// DMA with separate read and write masters
731pub mod dma;
732
733/// Controls time and alarms
734pub struct TIMER0 {
735    _marker: PhantomData<*const ()>,
736}
737
738unsafe impl Send for TIMER0 {}
739
740peripheral!(TIMER0, timer0::RegisterBlock, 0x400b0000);
741
742/// Controls time and alarms
743pub mod timer0;
744
745/// TIMER1 peripheral
746pub struct TIMER1 {
747    _marker: PhantomData<*const ()>,
748}
749
750unsafe impl Send for TIMER1 {}
751
752peripheral!(TIMER1, timer1::RegisterBlock, 0x400b8000);
753
754/// TIMER1 register module
755pub mod timer1;
756
757/// Simple PWM
758pub struct PWM {
759    _marker: PhantomData<*const ()>,
760}
761
762unsafe impl Send for PWM {}
763
764peripheral!(PWM, pwm::RegisterBlock, 0x400a8000);
765
766/// Simple PWM
767pub mod pwm;
768
769/// Control and data interface to SAR ADC
770pub struct ADC {
771    _marker: PhantomData<*const ()>,
772}
773
774unsafe impl Send for ADC {}
775
776peripheral!(ADC, adc::RegisterBlock, 0x400a0000);
777
778/// Control and data interface to SAR ADC
779pub mod adc;
780
781/// DW_apb_i2c address block
782pub struct I2C0 {
783    _marker: PhantomData<*const ()>,
784}
785
786unsafe impl Send for I2C0 {}
787
788peripheral!(I2C0, i2c0::RegisterBlock, 0x40090000);
789
790/// DW_apb_i2c address block
791pub mod i2c0;
792
793/// I2C1 peripheral
794pub struct I2C1 {
795    _marker: PhantomData<*const ()>,
796}
797
798unsafe impl Send for I2C1 {}
799
800peripheral!(I2C1, i2c1::RegisterBlock, 0x40098000);
801
802/// I2C1 register module
803pub mod i2c1;
804
805/// SPI0 peripheral
806pub struct SPI0 {
807    _marker: PhantomData<*const ()>,
808}
809
810unsafe impl Send for SPI0 {}
811
812peripheral!(SPI0, spi0::RegisterBlock, 0x40080000);
813
814/// SPI0 register module
815pub mod spi0;
816
817/// SPI1 peripheral
818pub struct SPI1 {
819    _marker: PhantomData<*const ()>,
820}
821
822unsafe impl Send for SPI1 {}
823
824peripheral!(SPI1, spi1::RegisterBlock, 0x40088000);
825
826/// SPI1 register module
827pub mod spi1;
828
829/// Programmable IO block
830pub struct PIO0 {
831    _marker: PhantomData<*const ()>,
832}
833
834unsafe impl Send for PIO0 {}
835
836peripheral!(PIO0, pio0::RegisterBlock, 0x50200000);
837
838/// Programmable IO block
839pub mod pio0;
840
841/// PIO1 peripheral
842pub struct PIO1 {
843    _marker: PhantomData<*const ()>,
844}
845
846unsafe impl Send for PIO1 {}
847
848peripheral!(PIO1, pio1::RegisterBlock, 0x50300000);
849
850/// PIO1 register module
851pub mod pio1;
852
853/// PIO2 peripheral
854pub struct PIO2 {
855    _marker: PhantomData<*const ()>,
856}
857
858unsafe impl Send for PIO2 {}
859
860peripheral!(PIO2, pio2::RegisterBlock, 0x50400000);
861
862/// PIO2 register module
863pub mod pio2;
864
865/// Register block for busfabric control signals and performance counters
866pub struct BUSCTRL {
867    _marker: PhantomData<*const ()>,
868}
869
870unsafe impl Send for BUSCTRL {}
871
872peripheral!(BUSCTRL, busctrl::RegisterBlock, 0x40068000);
873
874/// Register block for busfabric control signals and performance counters
875pub mod busctrl;
876
877/// Single-cycle IO block
878pub struct SIO {
879    _marker: PhantomData<*const ()>,
880}
881
882unsafe impl Send for SIO {}
883
884peripheral!(SIO, sio::RegisterBlock, 0xd0000000);
885
886/// Single-cycle IO block
887pub mod sio;
888
889/// SIO_NS peripheral
890pub struct SIO_NS {
891    _marker: PhantomData<*const ()>,
892}
893
894unsafe impl Send for SIO_NS {}
895
896peripheral!(SIO_NS, sio_ns::RegisterBlock, 0xd0020000);
897
898/// SIO_NS register module
899pub mod sio_ns;
900
901/// Additional registers mapped adjacent to the bootram, for use by the bootrom.
902pub struct BOOTRAM {
903    _marker: PhantomData<*const ()>,
904}
905
906unsafe impl Send for BOOTRAM {}
907
908peripheral!(BOOTRAM, bootram::RegisterBlock, 0x400e0000);
909
910/// Additional registers mapped adjacent to the bootram, for use by the bootrom.
911pub mod bootram;
912
913/// Coresight block - RP specific registers
914pub struct CORESIGHT_TRACE {
915    _marker: PhantomData<*const ()>,
916}
917
918unsafe impl Send for CORESIGHT_TRACE {}
919
920peripheral!(CORESIGHT_TRACE, coresight_trace::RegisterBlock, 0x50700000);
921
922/// Coresight block - RP specific registers
923pub mod coresight_trace;
924
925/// USB FS/LS controller device registers
926pub struct USB {
927    _marker: PhantomData<*const ()>,
928}
929
930unsafe impl Send for USB {}
931
932peripheral!(USB, usb::RegisterBlock, 0x50110000);
933
934/// USB FS/LS controller device registers
935pub mod usb;
936
937/// ARM TrustZone RNG register block
938pub struct TRNG {
939    _marker: PhantomData<*const ()>,
940}
941
942unsafe impl Send for TRNG {}
943
944peripheral!(TRNG, trng::RegisterBlock, 0x400f0000);
945
946/// ARM TrustZone RNG register block
947pub mod trng;
948
949/// Glitch detector controls
950pub struct GLITCH_DETECTOR {
951    _marker: PhantomData<*const ()>,
952}
953
954unsafe impl Send for GLITCH_DETECTOR {}
955
956peripheral!(GLITCH_DETECTOR, glitch_detector::RegisterBlock, 0x40158000);
957
958/// Glitch detector controls
959pub mod glitch_detector;
960
961/// SNPS OTP control IF (SBPI and RPi wrapper control)
962pub struct OTP {
963    _marker: PhantomData<*const ()>,
964}
965
966unsafe impl Send for OTP {}
967
968peripheral!(OTP, otp::RegisterBlock, 0x40120000);
969
970/// SNPS OTP control IF (SBPI and RPi wrapper control)
971pub mod otp;
972
973/// Predefined OTP data layout for RP2350
974pub struct OTP_DATA {
975    _marker: PhantomData<*const ()>,
976}
977
978unsafe impl Send for OTP_DATA {}
979
980peripheral!(OTP_DATA, otp_data::RegisterBlock, 0x40130000);
981
982/// Predefined OTP data layout for RP2350
983pub mod otp_data;
984
985/// Predefined OTP data layout for RP2350
986pub struct OTP_DATA_RAW {
987    _marker: PhantomData<*const ()>,
988}
989
990unsafe impl Send for OTP_DATA_RAW {}
991
992peripheral!(OTP_DATA_RAW, otp_data_raw::RegisterBlock, 0x40134000);
993
994/// Predefined OTP data layout for RP2350
995pub mod otp_data_raw;
996
997/// For managing simulation testbenches
998pub struct TBMAN {
999    _marker: PhantomData<*const ()>,
1000}
1001
1002unsafe impl Send for TBMAN {}
1003
1004peripheral!(TBMAN, tbman::RegisterBlock, 0x40160000);
1005
1006/// For managing simulation testbenches
1007pub mod tbman;
1008
1009/// DPRAM layout for USB device.
1010pub struct USB_DPRAM {
1011    _marker: PhantomData<*const ()>,
1012}
1013
1014unsafe impl Send for USB_DPRAM {}
1015
1016peripheral!(USB_DPRAM, usb_dpram::RegisterBlock, 0x50100000);
1017
1018/// DPRAM layout for USB device.
1019pub mod usb_dpram;
1020
1021/// SPARE_IRQ peripheral
1022pub struct SPARE_IRQ {
1023    _marker: PhantomData<*const ()>,
1024}
1025
1026unsafe impl Send for SPARE_IRQ {}
1027
1028peripheral!(SPARE_IRQ, spare_irq::RegisterBlock, 0x00000000);
1029
1030/// SPARE_IRQ register module
1031pub mod spare_irq;
1032
1033// ============================================================================
1034// Peripherals - All device peripherals
1035// ============================================================================
1036
1037use core::sync::atomic::{AtomicBool, Ordering};
1038
1039/// Guard to ensure peripherals are taken only once
1040static TAKEN: AtomicBool = AtomicBool::new(false);
1041
1042/// All the peripherals.
1043#[allow(non_snake_case)]
1044pub struct Peripherals {
1045    /// RESETS peripheral
1046    pub RESETS: RESETS,
1047    /// PSM peripheral
1048    pub PSM: PSM,
1049    /// CLOCKS peripheral
1050    pub CLOCKS: CLOCKS,
1051    /// TICKS peripheral
1052    pub TICKS: TICKS,
1053    /// PADS_BANK0 peripheral
1054    pub PADS_BANK0: PADS_BANK0,
1055    /// PADS_QSPI peripheral
1056    pub PADS_QSPI: PADS_QSPI,
1057    /// IO_QSPI peripheral
1058    pub IO_QSPI: IO_QSPI,
1059    /// IO_BANK0 peripheral
1060    pub IO_BANK0: IO_BANK0,
1061    /// SYSINFO peripheral
1062    pub SYSINFO: SYSINFO,
1063    /// SHA-256 hash function implementation
1064    pub SHA256: SHA256,
1065    /// FIFO status and write access for HSTX
1066    pub HSTX_FIFO: HSTX_FIFO,
1067    /// Control interface to HSTX. For FIFO write access and status, see the HSTX_FIFO register block.
1068    pub HSTX_CTRL: HSTX_CTRL,
1069    /// Cortex-M33 EPPB vendor register block for RP2350
1070    pub EPPB: EPPB,
1071    /// TEAL registers accessible through the debug interface
1072    pub PPB: PPB,
1073    /// PPB_NS peripheral
1074    pub PPB_NS: PPB_NS,
1075    /// QSPI Memory Interface.
1076    pub QMI: QMI,
1077    /// QSPI flash execute-in-place block
1078    pub XIP_CTRL: XIP_CTRL,
1079    /// Auxiliary DMA access to XIP FIFOs, via fast AHB bus access
1080    pub XIP_AUX: XIP_AUX,
1081    /// Register block for various chip control signals
1082    pub SYSCFG: SYSCFG,
1083    /// Controls the crystal oscillator
1084    pub XOSC: XOSC,
1085    /// PLL_SYS peripheral
1086    pub PLL_SYS: PLL_SYS,
1087    /// PLL_USB peripheral
1088    pub PLL_USB: PLL_USB,
1089    /// Hardware access control registers
1090    pub ACCESSCTRL: ACCESSCTRL,
1091    /// UART0 peripheral
1092    pub UART0: UART0,
1093    /// UART1 peripheral
1094    pub UART1: UART1,
1095    /// ROSC peripheral
1096    pub ROSC: ROSC,
1097    /// Controls vreg, bor, lposc, chip resets & xosc startup, powman and provides scratch register for general use and for bootcode use
1098    pub POWMAN: POWMAN,
1099    /// WATCHDOG peripheral
1100    pub WATCHDOG: WATCHDOG,
1101    /// DMA with separate read and write masters
1102    pub DMA: DMA,
1103    /// Controls time and alarms
1104    pub TIMER0: TIMER0,
1105    /// TIMER1 peripheral
1106    pub TIMER1: TIMER1,
1107    /// Simple PWM
1108    pub PWM: PWM,
1109    /// Control and data interface to SAR ADC
1110    pub ADC: ADC,
1111    /// DW_apb_i2c address block
1112    pub I2C0: I2C0,
1113    /// I2C1 peripheral
1114    pub I2C1: I2C1,
1115    /// SPI0 peripheral
1116    pub SPI0: SPI0,
1117    /// SPI1 peripheral
1118    pub SPI1: SPI1,
1119    /// Programmable IO block
1120    pub PIO0: PIO0,
1121    /// PIO1 peripheral
1122    pub PIO1: PIO1,
1123    /// PIO2 peripheral
1124    pub PIO2: PIO2,
1125    /// Register block for busfabric control signals and performance counters
1126    pub BUSCTRL: BUSCTRL,
1127    /// Single-cycle IO block
1128    pub SIO: SIO,
1129    /// SIO_NS peripheral
1130    pub SIO_NS: SIO_NS,
1131    /// Additional registers mapped adjacent to the bootram, for use by the bootrom.
1132    pub BOOTRAM: BOOTRAM,
1133    /// Coresight block - RP specific registers
1134    pub CORESIGHT_TRACE: CORESIGHT_TRACE,
1135    /// USB FS/LS controller device registers
1136    pub USB: USB,
1137    /// ARM TrustZone RNG register block
1138    pub TRNG: TRNG,
1139    /// Glitch detector controls
1140    pub GLITCH_DETECTOR: GLITCH_DETECTOR,
1141    /// SNPS OTP control IF (SBPI and RPi wrapper control)
1142    pub OTP: OTP,
1143    /// Predefined OTP data layout for RP2350
1144    pub OTP_DATA: OTP_DATA,
1145    /// Predefined OTP data layout for RP2350
1146    pub OTP_DATA_RAW: OTP_DATA_RAW,
1147    /// For managing simulation testbenches
1148    pub TBMAN: TBMAN,
1149    /// DPRAM layout for USB device.
1150    pub USB_DPRAM: USB_DPRAM,
1151    /// SPARE_IRQ peripheral
1152    pub SPARE_IRQ: SPARE_IRQ,
1153}
1154
1155impl Peripherals {
1156    /// Returns all the peripherals *once*.
1157    #[inline]
1158    pub fn take() -> Option<Self> {
1159        if TAKEN.swap(true, Ordering::AcqRel) {
1160            None
1161        } else {
1162            Some(unsafe { Self::steal() })
1163        }
1164    }
1165
1166    /// Unchecked version of `Peripherals::take`.
1167    ///
1168    /// # Safety
1169    ///
1170    /// Each of the returned peripherals must be used at most once.
1171    #[inline]
1172    pub unsafe fn steal() -> Self {
1173        unsafe {
1174            Peripherals {
1175                RESETS: RESETS::steal(),
1176                PSM: PSM::steal(),
1177                CLOCKS: CLOCKS::steal(),
1178                TICKS: TICKS::steal(),
1179                PADS_BANK0: PADS_BANK0::steal(),
1180                PADS_QSPI: PADS_QSPI::steal(),
1181                IO_QSPI: IO_QSPI::steal(),
1182                IO_BANK0: IO_BANK0::steal(),
1183                SYSINFO: SYSINFO::steal(),
1184                SHA256: SHA256::steal(),
1185                HSTX_FIFO: HSTX_FIFO::steal(),
1186                HSTX_CTRL: HSTX_CTRL::steal(),
1187                EPPB: EPPB::steal(),
1188                PPB: PPB::steal(),
1189                PPB_NS: PPB_NS::steal(),
1190                QMI: QMI::steal(),
1191                XIP_CTRL: XIP_CTRL::steal(),
1192                XIP_AUX: XIP_AUX::steal(),
1193                SYSCFG: SYSCFG::steal(),
1194                XOSC: XOSC::steal(),
1195                PLL_SYS: PLL_SYS::steal(),
1196                PLL_USB: PLL_USB::steal(),
1197                ACCESSCTRL: ACCESSCTRL::steal(),
1198                UART0: UART0::steal(),
1199                UART1: UART1::steal(),
1200                ROSC: ROSC::steal(),
1201                POWMAN: POWMAN::steal(),
1202                WATCHDOG: WATCHDOG::steal(),
1203                DMA: DMA::steal(),
1204                TIMER0: TIMER0::steal(),
1205                TIMER1: TIMER1::steal(),
1206                PWM: PWM::steal(),
1207                ADC: ADC::steal(),
1208                I2C0: I2C0::steal(),
1209                I2C1: I2C1::steal(),
1210                SPI0: SPI0::steal(),
1211                SPI1: SPI1::steal(),
1212                PIO0: PIO0::steal(),
1213                PIO1: PIO1::steal(),
1214                PIO2: PIO2::steal(),
1215                BUSCTRL: BUSCTRL::steal(),
1216                SIO: SIO::steal(),
1217                SIO_NS: SIO_NS::steal(),
1218                BOOTRAM: BOOTRAM::steal(),
1219                CORESIGHT_TRACE: CORESIGHT_TRACE::steal(),
1220                USB: USB::steal(),
1221                TRNG: TRNG::steal(),
1222                GLITCH_DETECTOR: GLITCH_DETECTOR::steal(),
1223                OTP: OTP::steal(),
1224                OTP_DATA: OTP_DATA::steal(),
1225                OTP_DATA_RAW: OTP_DATA_RAW::steal(),
1226                TBMAN: TBMAN::steal(),
1227                USB_DPRAM: USB_DPRAM::steal(),
1228                SPARE_IRQ: SPARE_IRQ::steal(),
1229            }
1230        }
1231    }
1232
1233    /// Release the peripherals back to the pool
1234    ///
1235    /// After calling this, `take()` will succeed again.
1236    #[inline]
1237    pub fn release(self) {
1238        TAKEN.store(false, Ordering::Release);
1239    }
1240}