stm32g0_staging/stm32g030/mod.rs
1/*!Peripheral access API for STM32G030 microcontrollers (generated using svd2rust v0.35.0 (c94dc77 2025-01-15))
2
3You can find an overview of the generated API [here].
4
5API features to be included in the [next]
6svd2rust release can be generated by cloning the svd2rust [repository], checking out the above commit, and running `cargo doc --open`.
7
8[here]: https://docs.rs/svd2rust/0.35.0/svd2rust/#peripheral-api
9[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased
10[repository]: https://github.com/rust-embedded/svd2rust*/
11use core::marker::PhantomData;
12use core::ops::Deref;
13///Number available in the NVIC for configuring priority
14pub const NVIC_PRIO_BITS: u8 = 2;
15#[cfg(feature = "rt")]
16pub use self::Interrupt as interrupt;
17pub use cortex_m::peripheral::Peripherals as CorePeripherals;
18pub use cortex_m::peripheral::{
19 CBP, CPUID, DCB, DWT, FPB, ITM, MPU, NVIC, SCB, SYST, TPIU,
20};
21#[cfg(feature = "rt")]
22pub use cortex_m_rt::interrupt;
23#[cfg(feature = "rt")]
24extern "C" {
25 fn WWDG();
26 fn RTC_STAMP();
27 fn FLASH();
28 fn RCC();
29 fn EXTI0_1();
30 fn EXTI2_3();
31 fn EXTI4_15();
32 fn DMA1_CHANNEL1();
33 fn DMA1_CHANNEL2_3();
34 fn DMA1_CHANNEL4_5_DMAMUX();
35 fn ADC();
36 fn TIM1_BRK_UP_TRG_COM();
37 fn TIM1_CC();
38 fn TIM3();
39 fn TIM14();
40 fn TIM16();
41 fn TIM17();
42 fn I2C1();
43 fn I2C2();
44 fn SPI1();
45 fn SPI2();
46 fn USART1();
47 fn USART2();
48 fn CEC();
49}
50#[doc(hidden)]
51#[repr(C)]
52pub union Vector {
53 _handler: unsafe extern "C" fn(),
54 _reserved: u32,
55}
56#[cfg(feature = "rt")]
57#[doc(hidden)]
58#[link_section = ".vector_table.interrupts"]
59#[no_mangle]
60pub static __INTERRUPTS: [Vector; 31] = [
61 Vector { _handler: WWDG },
62 Vector { _reserved: 0 },
63 Vector { _handler: RTC_STAMP },
64 Vector { _handler: FLASH },
65 Vector { _handler: RCC },
66 Vector { _handler: EXTI0_1 },
67 Vector { _handler: EXTI2_3 },
68 Vector { _handler: EXTI4_15 },
69 Vector { _reserved: 0 },
70 Vector { _handler: DMA1_CHANNEL1 },
71 Vector {
72 _handler: DMA1_CHANNEL2_3,
73 },
74 Vector {
75 _handler: DMA1_CHANNEL4_5_DMAMUX,
76 },
77 Vector { _handler: ADC },
78 Vector {
79 _handler: TIM1_BRK_UP_TRG_COM,
80 },
81 Vector { _handler: TIM1_CC },
82 Vector { _reserved: 0 },
83 Vector { _handler: TIM3 },
84 Vector { _reserved: 0 },
85 Vector { _reserved: 0 },
86 Vector { _handler: TIM14 },
87 Vector { _reserved: 0 },
88 Vector { _handler: TIM16 },
89 Vector { _handler: TIM17 },
90 Vector { _handler: I2C1 },
91 Vector { _handler: I2C2 },
92 Vector { _handler: SPI1 },
93 Vector { _handler: SPI2 },
94 Vector { _handler: USART1 },
95 Vector { _handler: USART2 },
96 Vector { _reserved: 0 },
97 Vector { _handler: CEC },
98];
99///Enumeration of all the interrupts.
100#[cfg_attr(feature = "defmt", derive(defmt::Format))]
101#[derive(Copy, Clone, Debug, PartialEq, Eq)]
102#[repr(u16)]
103pub enum Interrupt {
104 ///0 - Window watchdog interrupt
105 WWDG = 0,
106 ///2 - RTC and TAMP interrupts
107 RTC_STAMP = 2,
108 ///3 - Flash global interrupt
109 FLASH = 3,
110 ///4 - RCC global interrupt
111 RCC = 4,
112 ///5 - EXTI line 0 and 1 interrupt
113 EXTI0_1 = 5,
114 ///6 - EXTI line 2 and 3 interrupt
115 EXTI2_3 = 6,
116 ///7 - EXTI line 4 to 15 interrupt
117 EXTI4_15 = 7,
118 ///9 - DMA channel 1 interrupt
119 DMA1_CHANNEL1 = 9,
120 ///10 - DMA channel 2 and 3 interrupts
121 DMA1_CHANNEL2_3 = 10,
122 ///11 - interrupts for DMA1 channels 4-5 and DMAMUX
123 DMA1_CHANNEL4_5_DMAMUX = 11,
124 ///12 - ADC interrupt (ADC combined with EXTI 17 and 18)
125 ADC = 12,
126 ///13 - TIM1 break, update, trigger
127 TIM1_BRK_UP_TRG_COM = 13,
128 ///14 - TIM1 Capture Compare interrupt
129 TIM1_CC = 14,
130 ///16 - TIM3 global interrupt
131 TIM3 = 16,
132 ///19 - TIM14 global interrupt
133 TIM14 = 19,
134 ///21 - TIM16 global interrupt
135 TIM16 = 21,
136 ///22 - TIM17 global interrupt
137 TIM17 = 22,
138 ///23 - I2C1 global interrupt
139 I2C1 = 23,
140 ///24 - I2C2 global interrupt
141 I2C2 = 24,
142 ///25 - SPI1 global interrupt
143 SPI1 = 25,
144 ///26 - SPI2 global interrupt
145 SPI2 = 26,
146 ///27 - USART1 global interrupt
147 USART1 = 27,
148 ///28 - USART2 global interrupt
149 USART2 = 28,
150 ///30 - CEC global interrupt
151 CEC = 30,
152}
153unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
154 #[inline(always)]
155 fn number(self) -> u16 {
156 self as u16
157 }
158}
159///Analog to Digital ConverteR
160///
161///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#ADC)
162pub struct ADC {
163 _marker: PhantomData<*const ()>,
164}
165unsafe impl Send for ADC {}
166impl ADC {
167 ///Pointer to the register block
168 pub const PTR: *const adc::RegisterBlock = 0x4001_2400 as *const _;
169 ///Return the pointer to the register block
170 #[inline(always)]
171 pub const fn ptr() -> *const adc::RegisterBlock {
172 Self::PTR
173 }
174 /// Steal an instance of this peripheral
175 ///
176 /// # Safety
177 ///
178 /// Ensure that the new instance of the peripheral cannot be used in a way
179 /// that may race with any existing instances, for example by only
180 /// accessing read-only or write-only registers, or by consuming the
181 /// original peripheral and using critical sections to coordinate
182 /// access between multiple new instances.
183 ///
184 /// Additionally, other software such as HALs may rely on only one
185 /// peripheral instance existing to ensure memory safety; ensure
186 /// no stolen instances are passed to such software.
187 pub unsafe fn steal() -> Self {
188 Self { _marker: PhantomData }
189 }
190}
191impl Deref for ADC {
192 type Target = adc::RegisterBlock;
193 #[inline(always)]
194 fn deref(&self) -> &Self::Target {
195 unsafe { &*Self::PTR }
196 }
197}
198impl core::fmt::Debug for ADC {
199 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
200 f.debug_struct("ADC").finish()
201 }
202}
203///Analog to Digital ConverteR
204pub mod adc;
205///Independent watchdog
206///
207///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#IWDG)
208pub struct IWDG {
209 _marker: PhantomData<*const ()>,
210}
211unsafe impl Send for IWDG {}
212impl IWDG {
213 ///Pointer to the register block
214 pub const PTR: *const iwdg::RegisterBlock = 0x4000_3000 as *const _;
215 ///Return the pointer to the register block
216 #[inline(always)]
217 pub const fn ptr() -> *const iwdg::RegisterBlock {
218 Self::PTR
219 }
220 /// Steal an instance of this peripheral
221 ///
222 /// # Safety
223 ///
224 /// Ensure that the new instance of the peripheral cannot be used in a way
225 /// that may race with any existing instances, for example by only
226 /// accessing read-only or write-only registers, or by consuming the
227 /// original peripheral and using critical sections to coordinate
228 /// access between multiple new instances.
229 ///
230 /// Additionally, other software such as HALs may rely on only one
231 /// peripheral instance existing to ensure memory safety; ensure
232 /// no stolen instances are passed to such software.
233 pub unsafe fn steal() -> Self {
234 Self { _marker: PhantomData }
235 }
236}
237impl Deref for IWDG {
238 type Target = iwdg::RegisterBlock;
239 #[inline(always)]
240 fn deref(&self) -> &Self::Target {
241 unsafe { &*Self::PTR }
242 }
243}
244impl core::fmt::Debug for IWDG {
245 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
246 f.debug_struct("IWDG").finish()
247 }
248}
249///Independent watchdog
250pub mod iwdg;
251///System window watchdog
252///
253///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#WWDG)
254pub struct WWDG {
255 _marker: PhantomData<*const ()>,
256}
257unsafe impl Send for WWDG {}
258impl WWDG {
259 ///Pointer to the register block
260 pub const PTR: *const wwdg::RegisterBlock = 0x4000_2c00 as *const _;
261 ///Return the pointer to the register block
262 #[inline(always)]
263 pub const fn ptr() -> *const wwdg::RegisterBlock {
264 Self::PTR
265 }
266 /// Steal an instance of this peripheral
267 ///
268 /// # Safety
269 ///
270 /// Ensure that the new instance of the peripheral cannot be used in a way
271 /// that may race with any existing instances, for example by only
272 /// accessing read-only or write-only registers, or by consuming the
273 /// original peripheral and using critical sections to coordinate
274 /// access between multiple new instances.
275 ///
276 /// Additionally, other software such as HALs may rely on only one
277 /// peripheral instance existing to ensure memory safety; ensure
278 /// no stolen instances are passed to such software.
279 pub unsafe fn steal() -> Self {
280 Self { _marker: PhantomData }
281 }
282}
283impl Deref for WWDG {
284 type Target = wwdg::RegisterBlock;
285 #[inline(always)]
286 fn deref(&self) -> &Self::Target {
287 unsafe { &*Self::PTR }
288 }
289}
290impl core::fmt::Debug for WWDG {
291 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
292 f.debug_struct("WWDG").finish()
293 }
294}
295///System window watchdog
296pub mod wwdg;
297///Flash
298///
299///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#FLASH)
300pub struct FLASH {
301 _marker: PhantomData<*const ()>,
302}
303unsafe impl Send for FLASH {}
304impl FLASH {
305 ///Pointer to the register block
306 pub const PTR: *const flash::RegisterBlock = 0x4002_2000 as *const _;
307 ///Return the pointer to the register block
308 #[inline(always)]
309 pub const fn ptr() -> *const flash::RegisterBlock {
310 Self::PTR
311 }
312 /// Steal an instance of this peripheral
313 ///
314 /// # Safety
315 ///
316 /// Ensure that the new instance of the peripheral cannot be used in a way
317 /// that may race with any existing instances, for example by only
318 /// accessing read-only or write-only registers, or by consuming the
319 /// original peripheral and using critical sections to coordinate
320 /// access between multiple new instances.
321 ///
322 /// Additionally, other software such as HALs may rely on only one
323 /// peripheral instance existing to ensure memory safety; ensure
324 /// no stolen instances are passed to such software.
325 pub unsafe fn steal() -> Self {
326 Self { _marker: PhantomData }
327 }
328}
329impl Deref for FLASH {
330 type Target = flash::RegisterBlock;
331 #[inline(always)]
332 fn deref(&self) -> &Self::Target {
333 unsafe { &*Self::PTR }
334 }
335}
336impl core::fmt::Debug for FLASH {
337 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
338 f.debug_struct("FLASH").finish()
339 }
340}
341///Flash
342pub mod flash;
343///Reset and clock control
344///
345///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#RCC)
346pub struct RCC {
347 _marker: PhantomData<*const ()>,
348}
349unsafe impl Send for RCC {}
350impl RCC {
351 ///Pointer to the register block
352 pub const PTR: *const rcc::RegisterBlock = 0x4002_1000 as *const _;
353 ///Return the pointer to the register block
354 #[inline(always)]
355 pub const fn ptr() -> *const rcc::RegisterBlock {
356 Self::PTR
357 }
358 /// Steal an instance of this peripheral
359 ///
360 /// # Safety
361 ///
362 /// Ensure that the new instance of the peripheral cannot be used in a way
363 /// that may race with any existing instances, for example by only
364 /// accessing read-only or write-only registers, or by consuming the
365 /// original peripheral and using critical sections to coordinate
366 /// access between multiple new instances.
367 ///
368 /// Additionally, other software such as HALs may rely on only one
369 /// peripheral instance existing to ensure memory safety; ensure
370 /// no stolen instances are passed to such software.
371 pub unsafe fn steal() -> Self {
372 Self { _marker: PhantomData }
373 }
374}
375impl Deref for RCC {
376 type Target = rcc::RegisterBlock;
377 #[inline(always)]
378 fn deref(&self) -> &Self::Target {
379 unsafe { &*Self::PTR }
380 }
381}
382impl core::fmt::Debug for RCC {
383 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
384 f.debug_struct("RCC").finish()
385 }
386}
387///Reset and clock control
388pub mod rcc;
389///Power control
390///
391///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#PWR)
392pub struct PWR {
393 _marker: PhantomData<*const ()>,
394}
395unsafe impl Send for PWR {}
396impl PWR {
397 ///Pointer to the register block
398 pub const PTR: *const pwr::RegisterBlock = 0x4000_7000 as *const _;
399 ///Return the pointer to the register block
400 #[inline(always)]
401 pub const fn ptr() -> *const pwr::RegisterBlock {
402 Self::PTR
403 }
404 /// Steal an instance of this peripheral
405 ///
406 /// # Safety
407 ///
408 /// Ensure that the new instance of the peripheral cannot be used in a way
409 /// that may race with any existing instances, for example by only
410 /// accessing read-only or write-only registers, or by consuming the
411 /// original peripheral and using critical sections to coordinate
412 /// access between multiple new instances.
413 ///
414 /// Additionally, other software such as HALs may rely on only one
415 /// peripheral instance existing to ensure memory safety; ensure
416 /// no stolen instances are passed to such software.
417 pub unsafe fn steal() -> Self {
418 Self { _marker: PhantomData }
419 }
420}
421impl Deref for PWR {
422 type Target = pwr::RegisterBlock;
423 #[inline(always)]
424 fn deref(&self) -> &Self::Target {
425 unsafe { &*Self::PTR }
426 }
427}
428impl core::fmt::Debug for PWR {
429 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
430 f.debug_struct("PWR").finish()
431 }
432}
433///Power control
434pub mod pwr;
435///DMA controller
436///
437///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#DMA1)
438pub struct DMA1 {
439 _marker: PhantomData<*const ()>,
440}
441unsafe impl Send for DMA1 {}
442impl DMA1 {
443 ///Pointer to the register block
444 pub const PTR: *const dma1::RegisterBlock = 0x4002_0000 as *const _;
445 ///Return the pointer to the register block
446 #[inline(always)]
447 pub const fn ptr() -> *const dma1::RegisterBlock {
448 Self::PTR
449 }
450 /// Steal an instance of this peripheral
451 ///
452 /// # Safety
453 ///
454 /// Ensure that the new instance of the peripheral cannot be used in a way
455 /// that may race with any existing instances, for example by only
456 /// accessing read-only or write-only registers, or by consuming the
457 /// original peripheral and using critical sections to coordinate
458 /// access between multiple new instances.
459 ///
460 /// Additionally, other software such as HALs may rely on only one
461 /// peripheral instance existing to ensure memory safety; ensure
462 /// no stolen instances are passed to such software.
463 pub unsafe fn steal() -> Self {
464 Self { _marker: PhantomData }
465 }
466}
467impl Deref for DMA1 {
468 type Target = dma1::RegisterBlock;
469 #[inline(always)]
470 fn deref(&self) -> &Self::Target {
471 unsafe { &*Self::PTR }
472 }
473}
474impl core::fmt::Debug for DMA1 {
475 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
476 f.debug_struct("DMA1").finish()
477 }
478}
479///DMA controller
480pub mod dma1;
481///DMAMUX
482///
483///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#DMAMUX)
484pub struct DMAMUX {
485 _marker: PhantomData<*const ()>,
486}
487unsafe impl Send for DMAMUX {}
488impl DMAMUX {
489 ///Pointer to the register block
490 pub const PTR: *const dmamux::RegisterBlock = 0x4002_0800 as *const _;
491 ///Return the pointer to the register block
492 #[inline(always)]
493 pub const fn ptr() -> *const dmamux::RegisterBlock {
494 Self::PTR
495 }
496 /// Steal an instance of this peripheral
497 ///
498 /// # Safety
499 ///
500 /// Ensure that the new instance of the peripheral cannot be used in a way
501 /// that may race with any existing instances, for example by only
502 /// accessing read-only or write-only registers, or by consuming the
503 /// original peripheral and using critical sections to coordinate
504 /// access between multiple new instances.
505 ///
506 /// Additionally, other software such as HALs may rely on only one
507 /// peripheral instance existing to ensure memory safety; ensure
508 /// no stolen instances are passed to such software.
509 pub unsafe fn steal() -> Self {
510 Self { _marker: PhantomData }
511 }
512}
513impl Deref for DMAMUX {
514 type Target = dmamux::RegisterBlock;
515 #[inline(always)]
516 fn deref(&self) -> &Self::Target {
517 unsafe { &*Self::PTR }
518 }
519}
520impl core::fmt::Debug for DMAMUX {
521 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
522 f.debug_struct("DMAMUX").finish()
523 }
524}
525///DMAMUX
526pub mod dmamux;
527///General-purpose I/Os
528///
529///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#GPIOA)
530pub struct GPIOA {
531 _marker: PhantomData<*const ()>,
532}
533unsafe impl Send for GPIOA {}
534impl GPIOA {
535 ///Pointer to the register block
536 pub const PTR: *const gpioa::RegisterBlock = 0x5000_0000 as *const _;
537 ///Return the pointer to the register block
538 #[inline(always)]
539 pub const fn ptr() -> *const gpioa::RegisterBlock {
540 Self::PTR
541 }
542 /// Steal an instance of this peripheral
543 ///
544 /// # Safety
545 ///
546 /// Ensure that the new instance of the peripheral cannot be used in a way
547 /// that may race with any existing instances, for example by only
548 /// accessing read-only or write-only registers, or by consuming the
549 /// original peripheral and using critical sections to coordinate
550 /// access between multiple new instances.
551 ///
552 /// Additionally, other software such as HALs may rely on only one
553 /// peripheral instance existing to ensure memory safety; ensure
554 /// no stolen instances are passed to such software.
555 pub unsafe fn steal() -> Self {
556 Self { _marker: PhantomData }
557 }
558}
559impl Deref for GPIOA {
560 type Target = gpioa::RegisterBlock;
561 #[inline(always)]
562 fn deref(&self) -> &Self::Target {
563 unsafe { &*Self::PTR }
564 }
565}
566impl core::fmt::Debug for GPIOA {
567 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
568 f.debug_struct("GPIOA").finish()
569 }
570}
571///General-purpose I/Os
572pub mod gpioa;
573///General-purpose I/Os
574///
575///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#GPIOB)
576pub struct GPIOB {
577 _marker: PhantomData<*const ()>,
578}
579unsafe impl Send for GPIOB {}
580impl GPIOB {
581 ///Pointer to the register block
582 pub const PTR: *const gpiob::RegisterBlock = 0x5000_0400 as *const _;
583 ///Return the pointer to the register block
584 #[inline(always)]
585 pub const fn ptr() -> *const gpiob::RegisterBlock {
586 Self::PTR
587 }
588 /// Steal an instance of this peripheral
589 ///
590 /// # Safety
591 ///
592 /// Ensure that the new instance of the peripheral cannot be used in a way
593 /// that may race with any existing instances, for example by only
594 /// accessing read-only or write-only registers, or by consuming the
595 /// original peripheral and using critical sections to coordinate
596 /// access between multiple new instances.
597 ///
598 /// Additionally, other software such as HALs may rely on only one
599 /// peripheral instance existing to ensure memory safety; ensure
600 /// no stolen instances are passed to such software.
601 pub unsafe fn steal() -> Self {
602 Self { _marker: PhantomData }
603 }
604}
605impl Deref for GPIOB {
606 type Target = gpiob::RegisterBlock;
607 #[inline(always)]
608 fn deref(&self) -> &Self::Target {
609 unsafe { &*Self::PTR }
610 }
611}
612impl core::fmt::Debug for GPIOB {
613 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
614 f.debug_struct("GPIOB").finish()
615 }
616}
617///General-purpose I/Os
618pub mod gpiob;
619///General-purpose I/Os
620///
621///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#GPIOB)
622pub struct GPIOC {
623 _marker: PhantomData<*const ()>,
624}
625unsafe impl Send for GPIOC {}
626impl GPIOC {
627 ///Pointer to the register block
628 pub const PTR: *const gpiob::RegisterBlock = 0x5000_0800 as *const _;
629 ///Return the pointer to the register block
630 #[inline(always)]
631 pub const fn ptr() -> *const gpiob::RegisterBlock {
632 Self::PTR
633 }
634 /// Steal an instance of this peripheral
635 ///
636 /// # Safety
637 ///
638 /// Ensure that the new instance of the peripheral cannot be used in a way
639 /// that may race with any existing instances, for example by only
640 /// accessing read-only or write-only registers, or by consuming the
641 /// original peripheral and using critical sections to coordinate
642 /// access between multiple new instances.
643 ///
644 /// Additionally, other software such as HALs may rely on only one
645 /// peripheral instance existing to ensure memory safety; ensure
646 /// no stolen instances are passed to such software.
647 pub unsafe fn steal() -> Self {
648 Self { _marker: PhantomData }
649 }
650}
651impl Deref for GPIOC {
652 type Target = gpiob::RegisterBlock;
653 #[inline(always)]
654 fn deref(&self) -> &Self::Target {
655 unsafe { &*Self::PTR }
656 }
657}
658impl core::fmt::Debug for GPIOC {
659 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
660 f.debug_struct("GPIOC").finish()
661 }
662}
663///General-purpose I/Os
664pub use self::gpiob as gpioc;
665///General-purpose I/Os
666///
667///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#GPIOB)
668pub struct GPIOD {
669 _marker: PhantomData<*const ()>,
670}
671unsafe impl Send for GPIOD {}
672impl GPIOD {
673 ///Pointer to the register block
674 pub const PTR: *const gpiob::RegisterBlock = 0x5000_0c00 as *const _;
675 ///Return the pointer to the register block
676 #[inline(always)]
677 pub const fn ptr() -> *const gpiob::RegisterBlock {
678 Self::PTR
679 }
680 /// Steal an instance of this peripheral
681 ///
682 /// # Safety
683 ///
684 /// Ensure that the new instance of the peripheral cannot be used in a way
685 /// that may race with any existing instances, for example by only
686 /// accessing read-only or write-only registers, or by consuming the
687 /// original peripheral and using critical sections to coordinate
688 /// access between multiple new instances.
689 ///
690 /// Additionally, other software such as HALs may rely on only one
691 /// peripheral instance existing to ensure memory safety; ensure
692 /// no stolen instances are passed to such software.
693 pub unsafe fn steal() -> Self {
694 Self { _marker: PhantomData }
695 }
696}
697impl Deref for GPIOD {
698 type Target = gpiob::RegisterBlock;
699 #[inline(always)]
700 fn deref(&self) -> &Self::Target {
701 unsafe { &*Self::PTR }
702 }
703}
704impl core::fmt::Debug for GPIOD {
705 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
706 f.debug_struct("GPIOD").finish()
707 }
708}
709///General-purpose I/Os
710pub use self::gpiob as gpiod;
711///General-purpose I/Os
712///
713///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#GPIOB)
714pub struct GPIOF {
715 _marker: PhantomData<*const ()>,
716}
717unsafe impl Send for GPIOF {}
718impl GPIOF {
719 ///Pointer to the register block
720 pub const PTR: *const gpiob::RegisterBlock = 0x5000_1400 as *const _;
721 ///Return the pointer to the register block
722 #[inline(always)]
723 pub const fn ptr() -> *const gpiob::RegisterBlock {
724 Self::PTR
725 }
726 /// Steal an instance of this peripheral
727 ///
728 /// # Safety
729 ///
730 /// Ensure that the new instance of the peripheral cannot be used in a way
731 /// that may race with any existing instances, for example by only
732 /// accessing read-only or write-only registers, or by consuming the
733 /// original peripheral and using critical sections to coordinate
734 /// access between multiple new instances.
735 ///
736 /// Additionally, other software such as HALs may rely on only one
737 /// peripheral instance existing to ensure memory safety; ensure
738 /// no stolen instances are passed to such software.
739 pub unsafe fn steal() -> Self {
740 Self { _marker: PhantomData }
741 }
742}
743impl Deref for GPIOF {
744 type Target = gpiob::RegisterBlock;
745 #[inline(always)]
746 fn deref(&self) -> &Self::Target {
747 unsafe { &*Self::PTR }
748 }
749}
750impl core::fmt::Debug for GPIOF {
751 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
752 f.debug_struct("GPIOF").finish()
753 }
754}
755///General-purpose I/Os
756pub use self::gpiob as gpiof;
757///Cyclic redundancy check calculation unit
758///
759///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#CRC)
760pub struct CRC {
761 _marker: PhantomData<*const ()>,
762}
763unsafe impl Send for CRC {}
764impl CRC {
765 ///Pointer to the register block
766 pub const PTR: *const crc::RegisterBlock = 0x4002_3000 as *const _;
767 ///Return the pointer to the register block
768 #[inline(always)]
769 pub const fn ptr() -> *const crc::RegisterBlock {
770 Self::PTR
771 }
772 /// Steal an instance of this peripheral
773 ///
774 /// # Safety
775 ///
776 /// Ensure that the new instance of the peripheral cannot be used in a way
777 /// that may race with any existing instances, for example by only
778 /// accessing read-only or write-only registers, or by consuming the
779 /// original peripheral and using critical sections to coordinate
780 /// access between multiple new instances.
781 ///
782 /// Additionally, other software such as HALs may rely on only one
783 /// peripheral instance existing to ensure memory safety; ensure
784 /// no stolen instances are passed to such software.
785 pub unsafe fn steal() -> Self {
786 Self { _marker: PhantomData }
787 }
788}
789impl Deref for CRC {
790 type Target = crc::RegisterBlock;
791 #[inline(always)]
792 fn deref(&self) -> &Self::Target {
793 unsafe { &*Self::PTR }
794 }
795}
796impl core::fmt::Debug for CRC {
797 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
798 f.debug_struct("CRC").finish()
799 }
800}
801///Cyclic redundancy check calculation unit
802pub mod crc;
803///External interrupt/event controller
804///
805///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#EXTI)
806pub struct EXTI {
807 _marker: PhantomData<*const ()>,
808}
809unsafe impl Send for EXTI {}
810impl EXTI {
811 ///Pointer to the register block
812 pub const PTR: *const exti::RegisterBlock = 0x4002_1800 as *const _;
813 ///Return the pointer to the register block
814 #[inline(always)]
815 pub const fn ptr() -> *const exti::RegisterBlock {
816 Self::PTR
817 }
818 /// Steal an instance of this peripheral
819 ///
820 /// # Safety
821 ///
822 /// Ensure that the new instance of the peripheral cannot be used in a way
823 /// that may race with any existing instances, for example by only
824 /// accessing read-only or write-only registers, or by consuming the
825 /// original peripheral and using critical sections to coordinate
826 /// access between multiple new instances.
827 ///
828 /// Additionally, other software such as HALs may rely on only one
829 /// peripheral instance existing to ensure memory safety; ensure
830 /// no stolen instances are passed to such software.
831 pub unsafe fn steal() -> Self {
832 Self { _marker: PhantomData }
833 }
834}
835impl Deref for EXTI {
836 type Target = exti::RegisterBlock;
837 #[inline(always)]
838 fn deref(&self) -> &Self::Target {
839 unsafe { &*Self::PTR }
840 }
841}
842impl core::fmt::Debug for EXTI {
843 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
844 f.debug_struct("EXTI").finish()
845 }
846}
847///External interrupt/event controller
848pub mod exti;
849///General purpose timers
850///
851///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#TIM16)
852pub struct TIM16 {
853 _marker: PhantomData<*const ()>,
854}
855unsafe impl Send for TIM16 {}
856impl TIM16 {
857 ///Pointer to the register block
858 pub const PTR: *const tim16::RegisterBlock = 0x4001_4400 as *const _;
859 ///Return the pointer to the register block
860 #[inline(always)]
861 pub const fn ptr() -> *const tim16::RegisterBlock {
862 Self::PTR
863 }
864 /// Steal an instance of this peripheral
865 ///
866 /// # Safety
867 ///
868 /// Ensure that the new instance of the peripheral cannot be used in a way
869 /// that may race with any existing instances, for example by only
870 /// accessing read-only or write-only registers, or by consuming the
871 /// original peripheral and using critical sections to coordinate
872 /// access between multiple new instances.
873 ///
874 /// Additionally, other software such as HALs may rely on only one
875 /// peripheral instance existing to ensure memory safety; ensure
876 /// no stolen instances are passed to such software.
877 pub unsafe fn steal() -> Self {
878 Self { _marker: PhantomData }
879 }
880}
881impl Deref for TIM16 {
882 type Target = tim16::RegisterBlock;
883 #[inline(always)]
884 fn deref(&self) -> &Self::Target {
885 unsafe { &*Self::PTR }
886 }
887}
888impl core::fmt::Debug for TIM16 {
889 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
890 f.debug_struct("TIM16").finish()
891 }
892}
893///General purpose timers
894pub mod tim16;
895///General purpose timers
896///
897///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#TIM16)
898pub struct TIM17 {
899 _marker: PhantomData<*const ()>,
900}
901unsafe impl Send for TIM17 {}
902impl TIM17 {
903 ///Pointer to the register block
904 pub const PTR: *const tim16::RegisterBlock = 0x4001_4800 as *const _;
905 ///Return the pointer to the register block
906 #[inline(always)]
907 pub const fn ptr() -> *const tim16::RegisterBlock {
908 Self::PTR
909 }
910 /// Steal an instance of this peripheral
911 ///
912 /// # Safety
913 ///
914 /// Ensure that the new instance of the peripheral cannot be used in a way
915 /// that may race with any existing instances, for example by only
916 /// accessing read-only or write-only registers, or by consuming the
917 /// original peripheral and using critical sections to coordinate
918 /// access between multiple new instances.
919 ///
920 /// Additionally, other software such as HALs may rely on only one
921 /// peripheral instance existing to ensure memory safety; ensure
922 /// no stolen instances are passed to such software.
923 pub unsafe fn steal() -> Self {
924 Self { _marker: PhantomData }
925 }
926}
927impl Deref for TIM17 {
928 type Target = tim16::RegisterBlock;
929 #[inline(always)]
930 fn deref(&self) -> &Self::Target {
931 unsafe { &*Self::PTR }
932 }
933}
934impl core::fmt::Debug for TIM17 {
935 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
936 f.debug_struct("TIM17").finish()
937 }
938}
939///General purpose timers
940pub use self::tim16 as tim17;
941///Universal synchronous asynchronous receiver transmitter
942///
943///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#USART1)
944pub struct USART1 {
945 _marker: PhantomData<*const ()>,
946}
947unsafe impl Send for USART1 {}
948impl USART1 {
949 ///Pointer to the register block
950 pub const PTR: *const usart1::RegisterBlock = 0x4001_3800 as *const _;
951 ///Return the pointer to the register block
952 #[inline(always)]
953 pub const fn ptr() -> *const usart1::RegisterBlock {
954 Self::PTR
955 }
956 /// Steal an instance of this peripheral
957 ///
958 /// # Safety
959 ///
960 /// Ensure that the new instance of the peripheral cannot be used in a way
961 /// that may race with any existing instances, for example by only
962 /// accessing read-only or write-only registers, or by consuming the
963 /// original peripheral and using critical sections to coordinate
964 /// access between multiple new instances.
965 ///
966 /// Additionally, other software such as HALs may rely on only one
967 /// peripheral instance existing to ensure memory safety; ensure
968 /// no stolen instances are passed to such software.
969 pub unsafe fn steal() -> Self {
970 Self { _marker: PhantomData }
971 }
972}
973impl Deref for USART1 {
974 type Target = usart1::RegisterBlock;
975 #[inline(always)]
976 fn deref(&self) -> &Self::Target {
977 unsafe { &*Self::PTR }
978 }
979}
980impl core::fmt::Debug for USART1 {
981 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
982 f.debug_struct("USART1").finish()
983 }
984}
985///Universal synchronous asynchronous receiver transmitter
986pub mod usart1;
987///Universal synchronous asynchronous receiver transmitter
988///
989///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#USART1)
990pub struct USART2 {
991 _marker: PhantomData<*const ()>,
992}
993unsafe impl Send for USART2 {}
994impl USART2 {
995 ///Pointer to the register block
996 pub const PTR: *const usart1::RegisterBlock = 0x4000_4400 as *const _;
997 ///Return the pointer to the register block
998 #[inline(always)]
999 pub const fn ptr() -> *const usart1::RegisterBlock {
1000 Self::PTR
1001 }
1002 /// Steal an instance of this peripheral
1003 ///
1004 /// # Safety
1005 ///
1006 /// Ensure that the new instance of the peripheral cannot be used in a way
1007 /// that may race with any existing instances, for example by only
1008 /// accessing read-only or write-only registers, or by consuming the
1009 /// original peripheral and using critical sections to coordinate
1010 /// access between multiple new instances.
1011 ///
1012 /// Additionally, other software such as HALs may rely on only one
1013 /// peripheral instance existing to ensure memory safety; ensure
1014 /// no stolen instances are passed to such software.
1015 pub unsafe fn steal() -> Self {
1016 Self { _marker: PhantomData }
1017 }
1018}
1019impl Deref for USART2 {
1020 type Target = usart1::RegisterBlock;
1021 #[inline(always)]
1022 fn deref(&self) -> &Self::Target {
1023 unsafe { &*Self::PTR }
1024 }
1025}
1026impl core::fmt::Debug for USART2 {
1027 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1028 f.debug_struct("USART2").finish()
1029 }
1030}
1031///Universal synchronous asynchronous receiver transmitter
1032pub use self::usart1 as usart2;
1033///Serial peripheral interface/Inter-IC sound
1034///
1035///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#SPI1)
1036pub struct SPI1 {
1037 _marker: PhantomData<*const ()>,
1038}
1039unsafe impl Send for SPI1 {}
1040impl SPI1 {
1041 ///Pointer to the register block
1042 pub const PTR: *const spi1::RegisterBlock = 0x4001_3000 as *const _;
1043 ///Return the pointer to the register block
1044 #[inline(always)]
1045 pub const fn ptr() -> *const spi1::RegisterBlock {
1046 Self::PTR
1047 }
1048 /// Steal an instance of this peripheral
1049 ///
1050 /// # Safety
1051 ///
1052 /// Ensure that the new instance of the peripheral cannot be used in a way
1053 /// that may race with any existing instances, for example by only
1054 /// accessing read-only or write-only registers, or by consuming the
1055 /// original peripheral and using critical sections to coordinate
1056 /// access between multiple new instances.
1057 ///
1058 /// Additionally, other software such as HALs may rely on only one
1059 /// peripheral instance existing to ensure memory safety; ensure
1060 /// no stolen instances are passed to such software.
1061 pub unsafe fn steal() -> Self {
1062 Self { _marker: PhantomData }
1063 }
1064}
1065impl Deref for SPI1 {
1066 type Target = spi1::RegisterBlock;
1067 #[inline(always)]
1068 fn deref(&self) -> &Self::Target {
1069 unsafe { &*Self::PTR }
1070 }
1071}
1072impl core::fmt::Debug for SPI1 {
1073 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1074 f.debug_struct("SPI1").finish()
1075 }
1076}
1077///Serial peripheral interface/Inter-IC sound
1078pub mod spi1;
1079///Serial peripheral interface/Inter-IC sound
1080///
1081///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#SPI1)
1082pub struct SPI2 {
1083 _marker: PhantomData<*const ()>,
1084}
1085unsafe impl Send for SPI2 {}
1086impl SPI2 {
1087 ///Pointer to the register block
1088 pub const PTR: *const spi1::RegisterBlock = 0x4000_3800 as *const _;
1089 ///Return the pointer to the register block
1090 #[inline(always)]
1091 pub const fn ptr() -> *const spi1::RegisterBlock {
1092 Self::PTR
1093 }
1094 /// Steal an instance of this peripheral
1095 ///
1096 /// # Safety
1097 ///
1098 /// Ensure that the new instance of the peripheral cannot be used in a way
1099 /// that may race with any existing instances, for example by only
1100 /// accessing read-only or write-only registers, or by consuming the
1101 /// original peripheral and using critical sections to coordinate
1102 /// access between multiple new instances.
1103 ///
1104 /// Additionally, other software such as HALs may rely on only one
1105 /// peripheral instance existing to ensure memory safety; ensure
1106 /// no stolen instances are passed to such software.
1107 pub unsafe fn steal() -> Self {
1108 Self { _marker: PhantomData }
1109 }
1110}
1111impl Deref for SPI2 {
1112 type Target = spi1::RegisterBlock;
1113 #[inline(always)]
1114 fn deref(&self) -> &Self::Target {
1115 unsafe { &*Self::PTR }
1116 }
1117}
1118impl core::fmt::Debug for SPI2 {
1119 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1120 f.debug_struct("SPI2").finish()
1121 }
1122}
1123///Serial peripheral interface/Inter-IC sound
1124pub use self::spi1 as spi2;
1125///Advanced-timers
1126///
1127///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#TIM1)
1128pub struct TIM1 {
1129 _marker: PhantomData<*const ()>,
1130}
1131unsafe impl Send for TIM1 {}
1132impl TIM1 {
1133 ///Pointer to the register block
1134 pub const PTR: *const tim1::RegisterBlock = 0x4001_2c00 as *const _;
1135 ///Return the pointer to the register block
1136 #[inline(always)]
1137 pub const fn ptr() -> *const tim1::RegisterBlock {
1138 Self::PTR
1139 }
1140 /// Steal an instance of this peripheral
1141 ///
1142 /// # Safety
1143 ///
1144 /// Ensure that the new instance of the peripheral cannot be used in a way
1145 /// that may race with any existing instances, for example by only
1146 /// accessing read-only or write-only registers, or by consuming the
1147 /// original peripheral and using critical sections to coordinate
1148 /// access between multiple new instances.
1149 ///
1150 /// Additionally, other software such as HALs may rely on only one
1151 /// peripheral instance existing to ensure memory safety; ensure
1152 /// no stolen instances are passed to such software.
1153 pub unsafe fn steal() -> Self {
1154 Self { _marker: PhantomData }
1155 }
1156}
1157impl Deref for TIM1 {
1158 type Target = tim1::RegisterBlock;
1159 #[inline(always)]
1160 fn deref(&self) -> &Self::Target {
1161 unsafe { &*Self::PTR }
1162 }
1163}
1164impl core::fmt::Debug for TIM1 {
1165 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1166 f.debug_struct("TIM1").finish()
1167 }
1168}
1169///Advanced-timers
1170pub mod tim1;
1171///System configuration controller
1172///
1173///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#SYSCFG)
1174pub struct SYSCFG {
1175 _marker: PhantomData<*const ()>,
1176}
1177unsafe impl Send for SYSCFG {}
1178impl SYSCFG {
1179 ///Pointer to the register block
1180 pub const PTR: *const syscfg::RegisterBlock = 0x4001_0000 as *const _;
1181 ///Return the pointer to the register block
1182 #[inline(always)]
1183 pub const fn ptr() -> *const syscfg::RegisterBlock {
1184 Self::PTR
1185 }
1186 /// Steal an instance of this peripheral
1187 ///
1188 /// # Safety
1189 ///
1190 /// Ensure that the new instance of the peripheral cannot be used in a way
1191 /// that may race with any existing instances, for example by only
1192 /// accessing read-only or write-only registers, or by consuming the
1193 /// original peripheral and using critical sections to coordinate
1194 /// access between multiple new instances.
1195 ///
1196 /// Additionally, other software such as HALs may rely on only one
1197 /// peripheral instance existing to ensure memory safety; ensure
1198 /// no stolen instances are passed to such software.
1199 pub unsafe fn steal() -> Self {
1200 Self { _marker: PhantomData }
1201 }
1202}
1203impl Deref for SYSCFG {
1204 type Target = syscfg::RegisterBlock;
1205 #[inline(always)]
1206 fn deref(&self) -> &Self::Target {
1207 unsafe { &*Self::PTR }
1208 }
1209}
1210impl core::fmt::Debug for SYSCFG {
1211 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1212 f.debug_struct("SYSCFG").finish()
1213 }
1214}
1215///System configuration controller
1216pub mod syscfg;
1217///Tamper and backup registers
1218///
1219///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#TAMP)
1220pub struct TAMP {
1221 _marker: PhantomData<*const ()>,
1222}
1223unsafe impl Send for TAMP {}
1224impl TAMP {
1225 ///Pointer to the register block
1226 pub const PTR: *const tamp::RegisterBlock = 0x4000_b000 as *const _;
1227 ///Return the pointer to the register block
1228 #[inline(always)]
1229 pub const fn ptr() -> *const tamp::RegisterBlock {
1230 Self::PTR
1231 }
1232 /// Steal an instance of this peripheral
1233 ///
1234 /// # Safety
1235 ///
1236 /// Ensure that the new instance of the peripheral cannot be used in a way
1237 /// that may race with any existing instances, for example by only
1238 /// accessing read-only or write-only registers, or by consuming the
1239 /// original peripheral and using critical sections to coordinate
1240 /// access between multiple new instances.
1241 ///
1242 /// Additionally, other software such as HALs may rely on only one
1243 /// peripheral instance existing to ensure memory safety; ensure
1244 /// no stolen instances are passed to such software.
1245 pub unsafe fn steal() -> Self {
1246 Self { _marker: PhantomData }
1247 }
1248}
1249impl Deref for TAMP {
1250 type Target = tamp::RegisterBlock;
1251 #[inline(always)]
1252 fn deref(&self) -> &Self::Target {
1253 unsafe { &*Self::PTR }
1254 }
1255}
1256impl core::fmt::Debug for TAMP {
1257 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1258 f.debug_struct("TAMP").finish()
1259 }
1260}
1261///Tamper and backup registers
1262pub mod tamp;
1263///Inter-integrated circuit
1264///
1265///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#I2C1)
1266pub struct I2C1 {
1267 _marker: PhantomData<*const ()>,
1268}
1269unsafe impl Send for I2C1 {}
1270impl I2C1 {
1271 ///Pointer to the register block
1272 pub const PTR: *const i2c1::RegisterBlock = 0x4000_5400 as *const _;
1273 ///Return the pointer to the register block
1274 #[inline(always)]
1275 pub const fn ptr() -> *const i2c1::RegisterBlock {
1276 Self::PTR
1277 }
1278 /// Steal an instance of this peripheral
1279 ///
1280 /// # Safety
1281 ///
1282 /// Ensure that the new instance of the peripheral cannot be used in a way
1283 /// that may race with any existing instances, for example by only
1284 /// accessing read-only or write-only registers, or by consuming the
1285 /// original peripheral and using critical sections to coordinate
1286 /// access between multiple new instances.
1287 ///
1288 /// Additionally, other software such as HALs may rely on only one
1289 /// peripheral instance existing to ensure memory safety; ensure
1290 /// no stolen instances are passed to such software.
1291 pub unsafe fn steal() -> Self {
1292 Self { _marker: PhantomData }
1293 }
1294}
1295impl Deref for I2C1 {
1296 type Target = i2c1::RegisterBlock;
1297 #[inline(always)]
1298 fn deref(&self) -> &Self::Target {
1299 unsafe { &*Self::PTR }
1300 }
1301}
1302impl core::fmt::Debug for I2C1 {
1303 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1304 f.debug_struct("I2C1").finish()
1305 }
1306}
1307///Inter-integrated circuit
1308pub mod i2c1;
1309///Inter-integrated circuit
1310///
1311///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#I2C1)
1312pub struct I2C2 {
1313 _marker: PhantomData<*const ()>,
1314}
1315unsafe impl Send for I2C2 {}
1316impl I2C2 {
1317 ///Pointer to the register block
1318 pub const PTR: *const i2c1::RegisterBlock = 0x4000_5800 as *const _;
1319 ///Return the pointer to the register block
1320 #[inline(always)]
1321 pub const fn ptr() -> *const i2c1::RegisterBlock {
1322 Self::PTR
1323 }
1324 /// Steal an instance of this peripheral
1325 ///
1326 /// # Safety
1327 ///
1328 /// Ensure that the new instance of the peripheral cannot be used in a way
1329 /// that may race with any existing instances, for example by only
1330 /// accessing read-only or write-only registers, or by consuming the
1331 /// original peripheral and using critical sections to coordinate
1332 /// access between multiple new instances.
1333 ///
1334 /// Additionally, other software such as HALs may rely on only one
1335 /// peripheral instance existing to ensure memory safety; ensure
1336 /// no stolen instances are passed to such software.
1337 pub unsafe fn steal() -> Self {
1338 Self { _marker: PhantomData }
1339 }
1340}
1341impl Deref for I2C2 {
1342 type Target = i2c1::RegisterBlock;
1343 #[inline(always)]
1344 fn deref(&self) -> &Self::Target {
1345 unsafe { &*Self::PTR }
1346 }
1347}
1348impl core::fmt::Debug for I2C2 {
1349 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1350 f.debug_struct("I2C2").finish()
1351 }
1352}
1353///Inter-integrated circuit
1354pub use self::i2c1 as i2c2;
1355///Real-time clock
1356///
1357///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#RTC)
1358pub struct RTC {
1359 _marker: PhantomData<*const ()>,
1360}
1361unsafe impl Send for RTC {}
1362impl RTC {
1363 ///Pointer to the register block
1364 pub const PTR: *const rtc::RegisterBlock = 0x4000_2800 as *const _;
1365 ///Return the pointer to the register block
1366 #[inline(always)]
1367 pub const fn ptr() -> *const rtc::RegisterBlock {
1368 Self::PTR
1369 }
1370 /// Steal an instance of this peripheral
1371 ///
1372 /// # Safety
1373 ///
1374 /// Ensure that the new instance of the peripheral cannot be used in a way
1375 /// that may race with any existing instances, for example by only
1376 /// accessing read-only or write-only registers, or by consuming the
1377 /// original peripheral and using critical sections to coordinate
1378 /// access between multiple new instances.
1379 ///
1380 /// Additionally, other software such as HALs may rely on only one
1381 /// peripheral instance existing to ensure memory safety; ensure
1382 /// no stolen instances are passed to such software.
1383 pub unsafe fn steal() -> Self {
1384 Self { _marker: PhantomData }
1385 }
1386}
1387impl Deref for RTC {
1388 type Target = rtc::RegisterBlock;
1389 #[inline(always)]
1390 fn deref(&self) -> &Self::Target {
1391 unsafe { &*Self::PTR }
1392 }
1393}
1394impl core::fmt::Debug for RTC {
1395 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1396 f.debug_struct("RTC").finish()
1397 }
1398}
1399///Real-time clock
1400pub mod rtc;
1401///General purpose timers
1402///
1403///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#TIM14)
1404pub struct TIM14 {
1405 _marker: PhantomData<*const ()>,
1406}
1407unsafe impl Send for TIM14 {}
1408impl TIM14 {
1409 ///Pointer to the register block
1410 pub const PTR: *const tim14::RegisterBlock = 0x4000_2000 as *const _;
1411 ///Return the pointer to the register block
1412 #[inline(always)]
1413 pub const fn ptr() -> *const tim14::RegisterBlock {
1414 Self::PTR
1415 }
1416 /// Steal an instance of this peripheral
1417 ///
1418 /// # Safety
1419 ///
1420 /// Ensure that the new instance of the peripheral cannot be used in a way
1421 /// that may race with any existing instances, for example by only
1422 /// accessing read-only or write-only registers, or by consuming the
1423 /// original peripheral and using critical sections to coordinate
1424 /// access between multiple new instances.
1425 ///
1426 /// Additionally, other software such as HALs may rely on only one
1427 /// peripheral instance existing to ensure memory safety; ensure
1428 /// no stolen instances are passed to such software.
1429 pub unsafe fn steal() -> Self {
1430 Self { _marker: PhantomData }
1431 }
1432}
1433impl Deref for TIM14 {
1434 type Target = tim14::RegisterBlock;
1435 #[inline(always)]
1436 fn deref(&self) -> &Self::Target {
1437 unsafe { &*Self::PTR }
1438 }
1439}
1440impl core::fmt::Debug for TIM14 {
1441 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1442 f.debug_struct("TIM14").finish()
1443 }
1444}
1445///General purpose timers
1446pub mod tim14;
1447///General-purpose-timers
1448///
1449///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#TIM3)
1450pub struct TIM3 {
1451 _marker: PhantomData<*const ()>,
1452}
1453unsafe impl Send for TIM3 {}
1454impl TIM3 {
1455 ///Pointer to the register block
1456 pub const PTR: *const tim3::RegisterBlock = 0x4000_0400 as *const _;
1457 ///Return the pointer to the register block
1458 #[inline(always)]
1459 pub const fn ptr() -> *const tim3::RegisterBlock {
1460 Self::PTR
1461 }
1462 /// Steal an instance of this peripheral
1463 ///
1464 /// # Safety
1465 ///
1466 /// Ensure that the new instance of the peripheral cannot be used in a way
1467 /// that may race with any existing instances, for example by only
1468 /// accessing read-only or write-only registers, or by consuming the
1469 /// original peripheral and using critical sections to coordinate
1470 /// access between multiple new instances.
1471 ///
1472 /// Additionally, other software such as HALs may rely on only one
1473 /// peripheral instance existing to ensure memory safety; ensure
1474 /// no stolen instances are passed to such software.
1475 pub unsafe fn steal() -> Self {
1476 Self { _marker: PhantomData }
1477 }
1478}
1479impl Deref for TIM3 {
1480 type Target = tim3::RegisterBlock;
1481 #[inline(always)]
1482 fn deref(&self) -> &Self::Target {
1483 unsafe { &*Self::PTR }
1484 }
1485}
1486impl core::fmt::Debug for TIM3 {
1487 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1488 f.debug_struct("TIM3").finish()
1489 }
1490}
1491///General-purpose-timers
1492pub mod tim3;
1493///System configuration controller
1494///
1495///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#VREFBUF)
1496pub struct VREFBUF {
1497 _marker: PhantomData<*const ()>,
1498}
1499unsafe impl Send for VREFBUF {}
1500impl VREFBUF {
1501 ///Pointer to the register block
1502 pub const PTR: *const vrefbuf::RegisterBlock = 0x4001_0030 as *const _;
1503 ///Return the pointer to the register block
1504 #[inline(always)]
1505 pub const fn ptr() -> *const vrefbuf::RegisterBlock {
1506 Self::PTR
1507 }
1508 /// Steal an instance of this peripheral
1509 ///
1510 /// # Safety
1511 ///
1512 /// Ensure that the new instance of the peripheral cannot be used in a way
1513 /// that may race with any existing instances, for example by only
1514 /// accessing read-only or write-only registers, or by consuming the
1515 /// original peripheral and using critical sections to coordinate
1516 /// access between multiple new instances.
1517 ///
1518 /// Additionally, other software such as HALs may rely on only one
1519 /// peripheral instance existing to ensure memory safety; ensure
1520 /// no stolen instances are passed to such software.
1521 pub unsafe fn steal() -> Self {
1522 Self { _marker: PhantomData }
1523 }
1524}
1525impl Deref for VREFBUF {
1526 type Target = vrefbuf::RegisterBlock;
1527 #[inline(always)]
1528 fn deref(&self) -> &Self::Target {
1529 unsafe { &*Self::PTR }
1530 }
1531}
1532impl core::fmt::Debug for VREFBUF {
1533 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1534 f.debug_struct("VREFBUF").finish()
1535 }
1536}
1537///System configuration controller
1538pub mod vrefbuf;
1539///MCU debug component
1540///
1541///See peripheral [structure](https://stm32-rs.github.io/stm32-rs/STM32G030.html#DBG)
1542pub struct DBG {
1543 _marker: PhantomData<*const ()>,
1544}
1545unsafe impl Send for DBG {}
1546impl DBG {
1547 ///Pointer to the register block
1548 pub const PTR: *const dbg::RegisterBlock = 0x4001_5800 as *const _;
1549 ///Return the pointer to the register block
1550 #[inline(always)]
1551 pub const fn ptr() -> *const dbg::RegisterBlock {
1552 Self::PTR
1553 }
1554 /// Steal an instance of this peripheral
1555 ///
1556 /// # Safety
1557 ///
1558 /// Ensure that the new instance of the peripheral cannot be used in a way
1559 /// that may race with any existing instances, for example by only
1560 /// accessing read-only or write-only registers, or by consuming the
1561 /// original peripheral and using critical sections to coordinate
1562 /// access between multiple new instances.
1563 ///
1564 /// Additionally, other software such as HALs may rely on only one
1565 /// peripheral instance existing to ensure memory safety; ensure
1566 /// no stolen instances are passed to such software.
1567 pub unsafe fn steal() -> Self {
1568 Self { _marker: PhantomData }
1569 }
1570}
1571impl Deref for DBG {
1572 type Target = dbg::RegisterBlock;
1573 #[inline(always)]
1574 fn deref(&self) -> &Self::Target {
1575 unsafe { &*Self::PTR }
1576 }
1577}
1578impl core::fmt::Debug for DBG {
1579 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
1580 f.debug_struct("DBG").finish()
1581 }
1582}
1583///MCU debug component
1584pub mod dbg;
1585#[no_mangle]
1586static mut DEVICE_PERIPHERALS: bool = false;
1587/// All the peripherals.
1588#[allow(non_snake_case)]
1589pub struct Peripherals {
1590 ///ADC
1591 pub ADC: ADC,
1592 ///IWDG
1593 pub IWDG: IWDG,
1594 ///WWDG
1595 pub WWDG: WWDG,
1596 ///FLASH
1597 pub FLASH: FLASH,
1598 ///RCC
1599 pub RCC: RCC,
1600 ///PWR
1601 pub PWR: PWR,
1602 ///DMA1
1603 pub DMA1: DMA1,
1604 ///DMAMUX
1605 pub DMAMUX: DMAMUX,
1606 ///GPIOA
1607 pub GPIOA: GPIOA,
1608 ///GPIOB
1609 pub GPIOB: GPIOB,
1610 ///GPIOC
1611 pub GPIOC: GPIOC,
1612 ///GPIOD
1613 pub GPIOD: GPIOD,
1614 ///GPIOF
1615 pub GPIOF: GPIOF,
1616 ///CRC
1617 pub CRC: CRC,
1618 ///EXTI
1619 pub EXTI: EXTI,
1620 ///TIM16
1621 pub TIM16: TIM16,
1622 ///TIM17
1623 pub TIM17: TIM17,
1624 ///USART1
1625 pub USART1: USART1,
1626 ///USART2
1627 pub USART2: USART2,
1628 ///SPI1
1629 pub SPI1: SPI1,
1630 ///SPI2
1631 pub SPI2: SPI2,
1632 ///TIM1
1633 pub TIM1: TIM1,
1634 ///SYSCFG
1635 pub SYSCFG: SYSCFG,
1636 ///TAMP
1637 pub TAMP: TAMP,
1638 ///I2C1
1639 pub I2C1: I2C1,
1640 ///I2C2
1641 pub I2C2: I2C2,
1642 ///RTC
1643 pub RTC: RTC,
1644 ///TIM14
1645 pub TIM14: TIM14,
1646 ///TIM3
1647 pub TIM3: TIM3,
1648 ///VREFBUF
1649 pub VREFBUF: VREFBUF,
1650 ///DBG
1651 pub DBG: DBG,
1652}
1653impl Peripherals {
1654 /// Returns all the peripherals *once*.
1655 #[cfg(feature = "critical-section")]
1656 #[inline]
1657 pub fn take() -> Option<Self> {
1658 critical_section::with(|_| {
1659 if unsafe { DEVICE_PERIPHERALS } {
1660 return None;
1661 }
1662 Some(unsafe { Peripherals::steal() })
1663 })
1664 }
1665 /// Unchecked version of `Peripherals::take`.
1666 ///
1667 /// # Safety
1668 ///
1669 /// Each of the returned peripherals must be used at most once.
1670 #[inline]
1671 pub unsafe fn steal() -> Self {
1672 DEVICE_PERIPHERALS = true;
1673 Peripherals {
1674 ADC: ADC::steal(),
1675 IWDG: IWDG::steal(),
1676 WWDG: WWDG::steal(),
1677 FLASH: FLASH::steal(),
1678 RCC: RCC::steal(),
1679 PWR: PWR::steal(),
1680 DMA1: DMA1::steal(),
1681 DMAMUX: DMAMUX::steal(),
1682 GPIOA: GPIOA::steal(),
1683 GPIOB: GPIOB::steal(),
1684 GPIOC: GPIOC::steal(),
1685 GPIOD: GPIOD::steal(),
1686 GPIOF: GPIOF::steal(),
1687 CRC: CRC::steal(),
1688 EXTI: EXTI::steal(),
1689 TIM16: TIM16::steal(),
1690 TIM17: TIM17::steal(),
1691 USART1: USART1::steal(),
1692 USART2: USART2::steal(),
1693 SPI1: SPI1::steal(),
1694 SPI2: SPI2::steal(),
1695 TIM1: TIM1::steal(),
1696 SYSCFG: SYSCFG::steal(),
1697 TAMP: TAMP::steal(),
1698 I2C1: I2C1::steal(),
1699 I2C2: I2C2::steal(),
1700 RTC: RTC::steal(),
1701 TIM14: TIM14::steal(),
1702 TIM3: TIM3::steal(),
1703 VREFBUF: VREFBUF::steal(),
1704 DBG: DBG::steal(),
1705 }
1706 }
1707}