stm32ral/stm32mp/instances/
tim2.rs1#![allow(non_snake_case, non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#[cfg(not(feature = "nosync"))]
8pub use crate::stm32mp::peripherals::tim2::Instance;
9pub use crate::stm32mp::peripherals::tim2::{RegisterBlock, ResetValues};
10pub use crate::stm32mp::peripherals::tim2::{
11 TIM2_ARR, TIM2_BDTR, TIM2_CCER, TIM2_CCMR1ALTERNATE2, TIM2_CCMR2ALTERNATE18, TIM2_CCMR3,
12 TIM2_CCR1, TIM2_CCR2, TIM2_CCR3, TIM2_CCR4, TIM2_CCR5, TIM2_CCR6, TIM2_CNT, TIM2_CR1, TIM2_CR2,
13 TIM2_DCR, TIM2_DIER, TIM2_DMAR, TIM2_EGR, TIM2_PSC, TIM2_RCR, TIM2_SMCR, TIM2_SR,
14};
15
16pub mod TIM2 {
18 use super::ResetValues;
19
20 #[cfg(not(feature = "nosync"))]
21 use super::Instance;
22
23 #[cfg(not(feature = "nosync"))]
24 const INSTANCE: Instance = Instance {
25 addr: 0x40000000,
26 _marker: ::core::marker::PhantomData,
27 };
28
29 pub const reset: ResetValues = ResetValues {
31 TIM2_CR1: 0x00000000,
32 TIM2_CR2: 0x00000000,
33 TIM2_SMCR: 0x00000000,
34 TIM2_DIER: 0x00000000,
35 TIM2_SR: 0x00000000,
36 TIM2_EGR: 0x00000000,
37 TIM2_CCMR1ALTERNATE2: 0x00000000,
38 TIM2_CCMR2ALTERNATE18: 0x00000000,
39 TIM2_CCER: 0x00000000,
40 TIM2_CNT: 0x00000000,
41 TIM2_PSC: 0x00000000,
42 TIM2_ARR: 0x0000FFFF,
43 TIM2_RCR: 0x00000000,
44 TIM2_CCR1: 0x00000000,
45 TIM2_CCR2: 0x00000000,
46 TIM2_CCR3: 0x00000000,
47 TIM2_CCR4: 0x00000000,
48 TIM2_BDTR: 0x00000000,
49 TIM2_DCR: 0x00000000,
50 TIM2_DMAR: 0x00000000,
51 TIM2_CCMR3: 0x00000000,
52 TIM2_CCR5: 0x00000000,
53 TIM2_CCR6: 0x00000000,
54 };
55
56 #[cfg(not(feature = "nosync"))]
57 #[allow(renamed_and_removed_lints)]
58 #[allow(private_no_mangle_statics)]
59 #[no_mangle]
60 static mut TIM2_TAKEN: bool = false;
61
62 #[cfg(not(feature = "nosync"))]
75 #[inline]
76 pub fn take() -> Option<Instance> {
77 external_cortex_m::interrupt::free(|_| unsafe {
78 if TIM2_TAKEN {
79 None
80 } else {
81 TIM2_TAKEN = true;
82 Some(INSTANCE)
83 }
84 })
85 }
86
87 #[cfg(not(feature = "nosync"))]
94 #[inline]
95 pub fn release(inst: Instance) {
96 external_cortex_m::interrupt::free(|_| unsafe {
97 if TIM2_TAKEN && inst.addr == INSTANCE.addr {
98 TIM2_TAKEN = false;
99 } else {
100 panic!("Released a peripheral which was not taken");
101 }
102 });
103 }
104
105 #[cfg(not(feature = "nosync"))]
111 #[inline]
112 pub unsafe fn steal() -> Instance {
113 TIM2_TAKEN = true;
114 INSTANCE
115 }
116}
117
118pub const TIM2: *const RegisterBlock = 0x40000000 as *const _;