stm32ral/stm32f4/stm32f413/
usart.rs

1#![allow(non_snake_case, non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3//! Universal synchronous asynchronous receiver transmitter
4
5#[cfg(not(feature = "nosync"))]
6pub use crate::stm32f4::peripherals::usart::Instance;
7pub use crate::stm32f4::peripherals::usart::{RegisterBlock, ResetValues};
8pub use crate::stm32f4::peripherals::usart::{BRR, CR1, CR2, CR3, DR, GTPR, SR};
9
10/// Access functions for the UART10 peripheral instance
11pub mod UART10 {
12    use super::ResetValues;
13
14    #[cfg(not(feature = "nosync"))]
15    use super::Instance;
16
17    #[cfg(not(feature = "nosync"))]
18    const INSTANCE: Instance = Instance {
19        addr: 0x40011c00,
20        _marker: ::core::marker::PhantomData,
21    };
22
23    /// Reset values for each field in UART10
24    pub const reset: ResetValues = ResetValues {
25        SR: 0x00C00000,
26        DR: 0x00000000,
27        BRR: 0x00000000,
28        CR1: 0x00000000,
29        CR2: 0x00000000,
30        CR3: 0x00000000,
31        GTPR: 0x00000000,
32    };
33
34    #[cfg(not(feature = "nosync"))]
35    #[allow(renamed_and_removed_lints)]
36    #[allow(private_no_mangle_statics)]
37    #[no_mangle]
38    static mut UART10_TAKEN: bool = false;
39
40    /// Safe access to UART10
41    ///
42    /// This function returns `Some(Instance)` if this instance is not
43    /// currently taken, and `None` if it is. This ensures that if you
44    /// do get `Some(Instance)`, you are ensured unique access to
45    /// the peripheral and there cannot be data races (unless other
46    /// code uses `unsafe`, of course). You can then pass the
47    /// `Instance` around to other functions as required. When you're
48    /// done with it, you can call `release(instance)` to return it.
49    ///
50    /// `Instance` itself dereferences to a `RegisterBlock`, which
51    /// provides access to the peripheral's registers.
52    #[cfg(not(feature = "nosync"))]
53    #[inline]
54    pub fn take() -> Option<Instance> {
55        external_cortex_m::interrupt::free(|_| unsafe {
56            if UART10_TAKEN {
57                None
58            } else {
59                UART10_TAKEN = true;
60                Some(INSTANCE)
61            }
62        })
63    }
64
65    /// Release exclusive access to UART10
66    ///
67    /// This function allows you to return an `Instance` so that it
68    /// is available to `take()` again. This function will panic if
69    /// you return a different `Instance` or if this instance is not
70    /// already taken.
71    #[cfg(not(feature = "nosync"))]
72    #[inline]
73    pub fn release(inst: Instance) {
74        external_cortex_m::interrupt::free(|_| unsafe {
75            if UART10_TAKEN && inst.addr == INSTANCE.addr {
76                UART10_TAKEN = false;
77            } else {
78                panic!("Released a peripheral which was not taken");
79            }
80        });
81    }
82
83    /// Unsafely steal UART10
84    ///
85    /// This function is similar to take() but forcibly takes the
86    /// Instance, marking it as taken irregardless of its previous
87    /// state.
88    #[cfg(not(feature = "nosync"))]
89    #[inline]
90    pub unsafe fn steal() -> Instance {
91        UART10_TAKEN = true;
92        INSTANCE
93    }
94}
95
96/// Raw pointer to UART10
97///
98/// Dereferencing this is unsafe because you are not ensured unique
99/// access to the peripheral, so you may encounter data races with
100/// other users of this peripheral. It is up to you to ensure you
101/// will not cause data races.
102///
103/// This constant is provided for ease of use in unsafe code: you can
104/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
105pub const UART10: *const RegisterBlock = 0x40011c00 as *const _;
106
107/// Access functions for the UART5 peripheral instance
108pub mod UART5 {
109    use super::ResetValues;
110
111    #[cfg(not(feature = "nosync"))]
112    use super::Instance;
113
114    #[cfg(not(feature = "nosync"))]
115    const INSTANCE: Instance = Instance {
116        addr: 0x40005000,
117        _marker: ::core::marker::PhantomData,
118    };
119
120    /// Reset values for each field in UART5
121    pub const reset: ResetValues = ResetValues {
122        SR: 0x00C00000,
123        DR: 0x00000000,
124        BRR: 0x00000000,
125        CR1: 0x00000000,
126        CR2: 0x00000000,
127        CR3: 0x00000000,
128        GTPR: 0x00000000,
129    };
130
131    #[cfg(not(feature = "nosync"))]
132    #[allow(renamed_and_removed_lints)]
133    #[allow(private_no_mangle_statics)]
134    #[no_mangle]
135    static mut UART5_TAKEN: bool = false;
136
137    /// Safe access to UART5
138    ///
139    /// This function returns `Some(Instance)` if this instance is not
140    /// currently taken, and `None` if it is. This ensures that if you
141    /// do get `Some(Instance)`, you are ensured unique access to
142    /// the peripheral and there cannot be data races (unless other
143    /// code uses `unsafe`, of course). You can then pass the
144    /// `Instance` around to other functions as required. When you're
145    /// done with it, you can call `release(instance)` to return it.
146    ///
147    /// `Instance` itself dereferences to a `RegisterBlock`, which
148    /// provides access to the peripheral's registers.
149    #[cfg(not(feature = "nosync"))]
150    #[inline]
151    pub fn take() -> Option<Instance> {
152        external_cortex_m::interrupt::free(|_| unsafe {
153            if UART5_TAKEN {
154                None
155            } else {
156                UART5_TAKEN = true;
157                Some(INSTANCE)
158            }
159        })
160    }
161
162    /// Release exclusive access to UART5
163    ///
164    /// This function allows you to return an `Instance` so that it
165    /// is available to `take()` again. This function will panic if
166    /// you return a different `Instance` or if this instance is not
167    /// already taken.
168    #[cfg(not(feature = "nosync"))]
169    #[inline]
170    pub fn release(inst: Instance) {
171        external_cortex_m::interrupt::free(|_| unsafe {
172            if UART5_TAKEN && inst.addr == INSTANCE.addr {
173                UART5_TAKEN = false;
174            } else {
175                panic!("Released a peripheral which was not taken");
176            }
177        });
178    }
179
180    /// Unsafely steal UART5
181    ///
182    /// This function is similar to take() but forcibly takes the
183    /// Instance, marking it as taken irregardless of its previous
184    /// state.
185    #[cfg(not(feature = "nosync"))]
186    #[inline]
187    pub unsafe fn steal() -> Instance {
188        UART5_TAKEN = true;
189        INSTANCE
190    }
191}
192
193/// Raw pointer to UART5
194///
195/// Dereferencing this is unsafe because you are not ensured unique
196/// access to the peripheral, so you may encounter data races with
197/// other users of this peripheral. It is up to you to ensure you
198/// will not cause data races.
199///
200/// This constant is provided for ease of use in unsafe code: you can
201/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
202pub const UART5: *const RegisterBlock = 0x40005000 as *const _;
203
204/// Access functions for the UART7 peripheral instance
205pub mod UART7 {
206    use super::ResetValues;
207
208    #[cfg(not(feature = "nosync"))]
209    use super::Instance;
210
211    #[cfg(not(feature = "nosync"))]
212    const INSTANCE: Instance = Instance {
213        addr: 0x40007800,
214        _marker: ::core::marker::PhantomData,
215    };
216
217    /// Reset values for each field in UART7
218    pub const reset: ResetValues = ResetValues {
219        SR: 0x00C00000,
220        DR: 0x00000000,
221        BRR: 0x00000000,
222        CR1: 0x00000000,
223        CR2: 0x00000000,
224        CR3: 0x00000000,
225        GTPR: 0x00000000,
226    };
227
228    #[cfg(not(feature = "nosync"))]
229    #[allow(renamed_and_removed_lints)]
230    #[allow(private_no_mangle_statics)]
231    #[no_mangle]
232    static mut UART7_TAKEN: bool = false;
233
234    /// Safe access to UART7
235    ///
236    /// This function returns `Some(Instance)` if this instance is not
237    /// currently taken, and `None` if it is. This ensures that if you
238    /// do get `Some(Instance)`, you are ensured unique access to
239    /// the peripheral and there cannot be data races (unless other
240    /// code uses `unsafe`, of course). You can then pass the
241    /// `Instance` around to other functions as required. When you're
242    /// done with it, you can call `release(instance)` to return it.
243    ///
244    /// `Instance` itself dereferences to a `RegisterBlock`, which
245    /// provides access to the peripheral's registers.
246    #[cfg(not(feature = "nosync"))]
247    #[inline]
248    pub fn take() -> Option<Instance> {
249        external_cortex_m::interrupt::free(|_| unsafe {
250            if UART7_TAKEN {
251                None
252            } else {
253                UART7_TAKEN = true;
254                Some(INSTANCE)
255            }
256        })
257    }
258
259    /// Release exclusive access to UART7
260    ///
261    /// This function allows you to return an `Instance` so that it
262    /// is available to `take()` again. This function will panic if
263    /// you return a different `Instance` or if this instance is not
264    /// already taken.
265    #[cfg(not(feature = "nosync"))]
266    #[inline]
267    pub fn release(inst: Instance) {
268        external_cortex_m::interrupt::free(|_| unsafe {
269            if UART7_TAKEN && inst.addr == INSTANCE.addr {
270                UART7_TAKEN = false;
271            } else {
272                panic!("Released a peripheral which was not taken");
273            }
274        });
275    }
276
277    /// Unsafely steal UART7
278    ///
279    /// This function is similar to take() but forcibly takes the
280    /// Instance, marking it as taken irregardless of its previous
281    /// state.
282    #[cfg(not(feature = "nosync"))]
283    #[inline]
284    pub unsafe fn steal() -> Instance {
285        UART7_TAKEN = true;
286        INSTANCE
287    }
288}
289
290/// Raw pointer to UART7
291///
292/// Dereferencing this is unsafe because you are not ensured unique
293/// access to the peripheral, so you may encounter data races with
294/// other users of this peripheral. It is up to you to ensure you
295/// will not cause data races.
296///
297/// This constant is provided for ease of use in unsafe code: you can
298/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
299pub const UART7: *const RegisterBlock = 0x40007800 as *const _;
300
301/// Access functions for the UART8 peripheral instance
302pub mod UART8 {
303    use super::ResetValues;
304
305    #[cfg(not(feature = "nosync"))]
306    use super::Instance;
307
308    #[cfg(not(feature = "nosync"))]
309    const INSTANCE: Instance = Instance {
310        addr: 0x40007c00,
311        _marker: ::core::marker::PhantomData,
312    };
313
314    /// Reset values for each field in UART8
315    pub const reset: ResetValues = ResetValues {
316        SR: 0x00C00000,
317        DR: 0x00000000,
318        BRR: 0x00000000,
319        CR1: 0x00000000,
320        CR2: 0x00000000,
321        CR3: 0x00000000,
322        GTPR: 0x00000000,
323    };
324
325    #[cfg(not(feature = "nosync"))]
326    #[allow(renamed_and_removed_lints)]
327    #[allow(private_no_mangle_statics)]
328    #[no_mangle]
329    static mut UART8_TAKEN: bool = false;
330
331    /// Safe access to UART8
332    ///
333    /// This function returns `Some(Instance)` if this instance is not
334    /// currently taken, and `None` if it is. This ensures that if you
335    /// do get `Some(Instance)`, you are ensured unique access to
336    /// the peripheral and there cannot be data races (unless other
337    /// code uses `unsafe`, of course). You can then pass the
338    /// `Instance` around to other functions as required. When you're
339    /// done with it, you can call `release(instance)` to return it.
340    ///
341    /// `Instance` itself dereferences to a `RegisterBlock`, which
342    /// provides access to the peripheral's registers.
343    #[cfg(not(feature = "nosync"))]
344    #[inline]
345    pub fn take() -> Option<Instance> {
346        external_cortex_m::interrupt::free(|_| unsafe {
347            if UART8_TAKEN {
348                None
349            } else {
350                UART8_TAKEN = true;
351                Some(INSTANCE)
352            }
353        })
354    }
355
356    /// Release exclusive access to UART8
357    ///
358    /// This function allows you to return an `Instance` so that it
359    /// is available to `take()` again. This function will panic if
360    /// you return a different `Instance` or if this instance is not
361    /// already taken.
362    #[cfg(not(feature = "nosync"))]
363    #[inline]
364    pub fn release(inst: Instance) {
365        external_cortex_m::interrupt::free(|_| unsafe {
366            if UART8_TAKEN && inst.addr == INSTANCE.addr {
367                UART8_TAKEN = false;
368            } else {
369                panic!("Released a peripheral which was not taken");
370            }
371        });
372    }
373
374    /// Unsafely steal UART8
375    ///
376    /// This function is similar to take() but forcibly takes the
377    /// Instance, marking it as taken irregardless of its previous
378    /// state.
379    #[cfg(not(feature = "nosync"))]
380    #[inline]
381    pub unsafe fn steal() -> Instance {
382        UART8_TAKEN = true;
383        INSTANCE
384    }
385}
386
387/// Raw pointer to UART8
388///
389/// Dereferencing this is unsafe because you are not ensured unique
390/// access to the peripheral, so you may encounter data races with
391/// other users of this peripheral. It is up to you to ensure you
392/// will not cause data races.
393///
394/// This constant is provided for ease of use in unsafe code: you can
395/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
396pub const UART8: *const RegisterBlock = 0x40007c00 as *const _;
397
398/// Access functions for the UART9 peripheral instance
399pub mod UART9 {
400    use super::ResetValues;
401
402    #[cfg(not(feature = "nosync"))]
403    use super::Instance;
404
405    #[cfg(not(feature = "nosync"))]
406    const INSTANCE: Instance = Instance {
407        addr: 0x40011800,
408        _marker: ::core::marker::PhantomData,
409    };
410
411    /// Reset values for each field in UART9
412    pub const reset: ResetValues = ResetValues {
413        SR: 0x00C00000,
414        DR: 0x00000000,
415        BRR: 0x00000000,
416        CR1: 0x00000000,
417        CR2: 0x00000000,
418        CR3: 0x00000000,
419        GTPR: 0x00000000,
420    };
421
422    #[cfg(not(feature = "nosync"))]
423    #[allow(renamed_and_removed_lints)]
424    #[allow(private_no_mangle_statics)]
425    #[no_mangle]
426    static mut UART9_TAKEN: bool = false;
427
428    /// Safe access to UART9
429    ///
430    /// This function returns `Some(Instance)` if this instance is not
431    /// currently taken, and `None` if it is. This ensures that if you
432    /// do get `Some(Instance)`, you are ensured unique access to
433    /// the peripheral and there cannot be data races (unless other
434    /// code uses `unsafe`, of course). You can then pass the
435    /// `Instance` around to other functions as required. When you're
436    /// done with it, you can call `release(instance)` to return it.
437    ///
438    /// `Instance` itself dereferences to a `RegisterBlock`, which
439    /// provides access to the peripheral's registers.
440    #[cfg(not(feature = "nosync"))]
441    #[inline]
442    pub fn take() -> Option<Instance> {
443        external_cortex_m::interrupt::free(|_| unsafe {
444            if UART9_TAKEN {
445                None
446            } else {
447                UART9_TAKEN = true;
448                Some(INSTANCE)
449            }
450        })
451    }
452
453    /// Release exclusive access to UART9
454    ///
455    /// This function allows you to return an `Instance` so that it
456    /// is available to `take()` again. This function will panic if
457    /// you return a different `Instance` or if this instance is not
458    /// already taken.
459    #[cfg(not(feature = "nosync"))]
460    #[inline]
461    pub fn release(inst: Instance) {
462        external_cortex_m::interrupt::free(|_| unsafe {
463            if UART9_TAKEN && inst.addr == INSTANCE.addr {
464                UART9_TAKEN = false;
465            } else {
466                panic!("Released a peripheral which was not taken");
467            }
468        });
469    }
470
471    /// Unsafely steal UART9
472    ///
473    /// This function is similar to take() but forcibly takes the
474    /// Instance, marking it as taken irregardless of its previous
475    /// state.
476    #[cfg(not(feature = "nosync"))]
477    #[inline]
478    pub unsafe fn steal() -> Instance {
479        UART9_TAKEN = true;
480        INSTANCE
481    }
482}
483
484/// Raw pointer to UART9
485///
486/// Dereferencing this is unsafe because you are not ensured unique
487/// access to the peripheral, so you may encounter data races with
488/// other users of this peripheral. It is up to you to ensure you
489/// will not cause data races.
490///
491/// This constant is provided for ease of use in unsafe code: you can
492/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
493pub const UART9: *const RegisterBlock = 0x40011800 as *const _;
494
495/// Access functions for the USART1 peripheral instance
496pub mod USART1 {
497    use super::ResetValues;
498
499    #[cfg(not(feature = "nosync"))]
500    use super::Instance;
501
502    #[cfg(not(feature = "nosync"))]
503    const INSTANCE: Instance = Instance {
504        addr: 0x40011000,
505        _marker: ::core::marker::PhantomData,
506    };
507
508    /// Reset values for each field in USART1
509    pub const reset: ResetValues = ResetValues {
510        SR: 0x00C00000,
511        DR: 0x00000000,
512        BRR: 0x00000000,
513        CR1: 0x00000000,
514        CR2: 0x00000000,
515        CR3: 0x00000000,
516        GTPR: 0x00000000,
517    };
518
519    #[cfg(not(feature = "nosync"))]
520    #[allow(renamed_and_removed_lints)]
521    #[allow(private_no_mangle_statics)]
522    #[no_mangle]
523    static mut USART1_TAKEN: bool = false;
524
525    /// Safe access to USART1
526    ///
527    /// This function returns `Some(Instance)` if this instance is not
528    /// currently taken, and `None` if it is. This ensures that if you
529    /// do get `Some(Instance)`, you are ensured unique access to
530    /// the peripheral and there cannot be data races (unless other
531    /// code uses `unsafe`, of course). You can then pass the
532    /// `Instance` around to other functions as required. When you're
533    /// done with it, you can call `release(instance)` to return it.
534    ///
535    /// `Instance` itself dereferences to a `RegisterBlock`, which
536    /// provides access to the peripheral's registers.
537    #[cfg(not(feature = "nosync"))]
538    #[inline]
539    pub fn take() -> Option<Instance> {
540        external_cortex_m::interrupt::free(|_| unsafe {
541            if USART1_TAKEN {
542                None
543            } else {
544                USART1_TAKEN = true;
545                Some(INSTANCE)
546            }
547        })
548    }
549
550    /// Release exclusive access to USART1
551    ///
552    /// This function allows you to return an `Instance` so that it
553    /// is available to `take()` again. This function will panic if
554    /// you return a different `Instance` or if this instance is not
555    /// already taken.
556    #[cfg(not(feature = "nosync"))]
557    #[inline]
558    pub fn release(inst: Instance) {
559        external_cortex_m::interrupt::free(|_| unsafe {
560            if USART1_TAKEN && inst.addr == INSTANCE.addr {
561                USART1_TAKEN = false;
562            } else {
563                panic!("Released a peripheral which was not taken");
564            }
565        });
566    }
567
568    /// Unsafely steal USART1
569    ///
570    /// This function is similar to take() but forcibly takes the
571    /// Instance, marking it as taken irregardless of its previous
572    /// state.
573    #[cfg(not(feature = "nosync"))]
574    #[inline]
575    pub unsafe fn steal() -> Instance {
576        USART1_TAKEN = true;
577        INSTANCE
578    }
579}
580
581/// Raw pointer to USART1
582///
583/// Dereferencing this is unsafe because you are not ensured unique
584/// access to the peripheral, so you may encounter data races with
585/// other users of this peripheral. It is up to you to ensure you
586/// will not cause data races.
587///
588/// This constant is provided for ease of use in unsafe code: you can
589/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
590pub const USART1: *const RegisterBlock = 0x40011000 as *const _;
591
592/// Access functions for the USART2 peripheral instance
593pub mod USART2 {
594    use super::ResetValues;
595
596    #[cfg(not(feature = "nosync"))]
597    use super::Instance;
598
599    #[cfg(not(feature = "nosync"))]
600    const INSTANCE: Instance = Instance {
601        addr: 0x40004400,
602        _marker: ::core::marker::PhantomData,
603    };
604
605    /// Reset values for each field in USART2
606    pub const reset: ResetValues = ResetValues {
607        SR: 0x00C00000,
608        DR: 0x00000000,
609        BRR: 0x00000000,
610        CR1: 0x00000000,
611        CR2: 0x00000000,
612        CR3: 0x00000000,
613        GTPR: 0x00000000,
614    };
615
616    #[cfg(not(feature = "nosync"))]
617    #[allow(renamed_and_removed_lints)]
618    #[allow(private_no_mangle_statics)]
619    #[no_mangle]
620    static mut USART2_TAKEN: bool = false;
621
622    /// Safe access to USART2
623    ///
624    /// This function returns `Some(Instance)` if this instance is not
625    /// currently taken, and `None` if it is. This ensures that if you
626    /// do get `Some(Instance)`, you are ensured unique access to
627    /// the peripheral and there cannot be data races (unless other
628    /// code uses `unsafe`, of course). You can then pass the
629    /// `Instance` around to other functions as required. When you're
630    /// done with it, you can call `release(instance)` to return it.
631    ///
632    /// `Instance` itself dereferences to a `RegisterBlock`, which
633    /// provides access to the peripheral's registers.
634    #[cfg(not(feature = "nosync"))]
635    #[inline]
636    pub fn take() -> Option<Instance> {
637        external_cortex_m::interrupt::free(|_| unsafe {
638            if USART2_TAKEN {
639                None
640            } else {
641                USART2_TAKEN = true;
642                Some(INSTANCE)
643            }
644        })
645    }
646
647    /// Release exclusive access to USART2
648    ///
649    /// This function allows you to return an `Instance` so that it
650    /// is available to `take()` again. This function will panic if
651    /// you return a different `Instance` or if this instance is not
652    /// already taken.
653    #[cfg(not(feature = "nosync"))]
654    #[inline]
655    pub fn release(inst: Instance) {
656        external_cortex_m::interrupt::free(|_| unsafe {
657            if USART2_TAKEN && inst.addr == INSTANCE.addr {
658                USART2_TAKEN = false;
659            } else {
660                panic!("Released a peripheral which was not taken");
661            }
662        });
663    }
664
665    /// Unsafely steal USART2
666    ///
667    /// This function is similar to take() but forcibly takes the
668    /// Instance, marking it as taken irregardless of its previous
669    /// state.
670    #[cfg(not(feature = "nosync"))]
671    #[inline]
672    pub unsafe fn steal() -> Instance {
673        USART2_TAKEN = true;
674        INSTANCE
675    }
676}
677
678/// Raw pointer to USART2
679///
680/// Dereferencing this is unsafe because you are not ensured unique
681/// access to the peripheral, so you may encounter data races with
682/// other users of this peripheral. It is up to you to ensure you
683/// will not cause data races.
684///
685/// This constant is provided for ease of use in unsafe code: you can
686/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
687pub const USART2: *const RegisterBlock = 0x40004400 as *const _;
688
689/// Access functions for the USART3 peripheral instance
690pub mod USART3 {
691    use super::ResetValues;
692
693    #[cfg(not(feature = "nosync"))]
694    use super::Instance;
695
696    #[cfg(not(feature = "nosync"))]
697    const INSTANCE: Instance = Instance {
698        addr: 0x40004800,
699        _marker: ::core::marker::PhantomData,
700    };
701
702    /// Reset values for each field in USART3
703    pub const reset: ResetValues = ResetValues {
704        SR: 0x00C00000,
705        DR: 0x00000000,
706        BRR: 0x00000000,
707        CR1: 0x00000000,
708        CR2: 0x00000000,
709        CR3: 0x00000000,
710        GTPR: 0x00000000,
711    };
712
713    #[cfg(not(feature = "nosync"))]
714    #[allow(renamed_and_removed_lints)]
715    #[allow(private_no_mangle_statics)]
716    #[no_mangle]
717    static mut USART3_TAKEN: bool = false;
718
719    /// Safe access to USART3
720    ///
721    /// This function returns `Some(Instance)` if this instance is not
722    /// currently taken, and `None` if it is. This ensures that if you
723    /// do get `Some(Instance)`, you are ensured unique access to
724    /// the peripheral and there cannot be data races (unless other
725    /// code uses `unsafe`, of course). You can then pass the
726    /// `Instance` around to other functions as required. When you're
727    /// done with it, you can call `release(instance)` to return it.
728    ///
729    /// `Instance` itself dereferences to a `RegisterBlock`, which
730    /// provides access to the peripheral's registers.
731    #[cfg(not(feature = "nosync"))]
732    #[inline]
733    pub fn take() -> Option<Instance> {
734        external_cortex_m::interrupt::free(|_| unsafe {
735            if USART3_TAKEN {
736                None
737            } else {
738                USART3_TAKEN = true;
739                Some(INSTANCE)
740            }
741        })
742    }
743
744    /// Release exclusive access to USART3
745    ///
746    /// This function allows you to return an `Instance` so that it
747    /// is available to `take()` again. This function will panic if
748    /// you return a different `Instance` or if this instance is not
749    /// already taken.
750    #[cfg(not(feature = "nosync"))]
751    #[inline]
752    pub fn release(inst: Instance) {
753        external_cortex_m::interrupt::free(|_| unsafe {
754            if USART3_TAKEN && inst.addr == INSTANCE.addr {
755                USART3_TAKEN = false;
756            } else {
757                panic!("Released a peripheral which was not taken");
758            }
759        });
760    }
761
762    /// Unsafely steal USART3
763    ///
764    /// This function is similar to take() but forcibly takes the
765    /// Instance, marking it as taken irregardless of its previous
766    /// state.
767    #[cfg(not(feature = "nosync"))]
768    #[inline]
769    pub unsafe fn steal() -> Instance {
770        USART3_TAKEN = true;
771        INSTANCE
772    }
773}
774
775/// Raw pointer to USART3
776///
777/// Dereferencing this is unsafe because you are not ensured unique
778/// access to the peripheral, so you may encounter data races with
779/// other users of this peripheral. It is up to you to ensure you
780/// will not cause data races.
781///
782/// This constant is provided for ease of use in unsafe code: you can
783/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
784pub const USART3: *const RegisterBlock = 0x40004800 as *const _;
785
786/// Access functions for the USART6 peripheral instance
787pub mod USART6 {
788    use super::ResetValues;
789
790    #[cfg(not(feature = "nosync"))]
791    use super::Instance;
792
793    #[cfg(not(feature = "nosync"))]
794    const INSTANCE: Instance = Instance {
795        addr: 0x40011400,
796        _marker: ::core::marker::PhantomData,
797    };
798
799    /// Reset values for each field in USART6
800    pub const reset: ResetValues = ResetValues {
801        SR: 0x00C00000,
802        DR: 0x00000000,
803        BRR: 0x00000000,
804        CR1: 0x00000000,
805        CR2: 0x00000000,
806        CR3: 0x00000000,
807        GTPR: 0x00000000,
808    };
809
810    #[cfg(not(feature = "nosync"))]
811    #[allow(renamed_and_removed_lints)]
812    #[allow(private_no_mangle_statics)]
813    #[no_mangle]
814    static mut USART6_TAKEN: bool = false;
815
816    /// Safe access to USART6
817    ///
818    /// This function returns `Some(Instance)` if this instance is not
819    /// currently taken, and `None` if it is. This ensures that if you
820    /// do get `Some(Instance)`, you are ensured unique access to
821    /// the peripheral and there cannot be data races (unless other
822    /// code uses `unsafe`, of course). You can then pass the
823    /// `Instance` around to other functions as required. When you're
824    /// done with it, you can call `release(instance)` to return it.
825    ///
826    /// `Instance` itself dereferences to a `RegisterBlock`, which
827    /// provides access to the peripheral's registers.
828    #[cfg(not(feature = "nosync"))]
829    #[inline]
830    pub fn take() -> Option<Instance> {
831        external_cortex_m::interrupt::free(|_| unsafe {
832            if USART6_TAKEN {
833                None
834            } else {
835                USART6_TAKEN = true;
836                Some(INSTANCE)
837            }
838        })
839    }
840
841    /// Release exclusive access to USART6
842    ///
843    /// This function allows you to return an `Instance` so that it
844    /// is available to `take()` again. This function will panic if
845    /// you return a different `Instance` or if this instance is not
846    /// already taken.
847    #[cfg(not(feature = "nosync"))]
848    #[inline]
849    pub fn release(inst: Instance) {
850        external_cortex_m::interrupt::free(|_| unsafe {
851            if USART6_TAKEN && inst.addr == INSTANCE.addr {
852                USART6_TAKEN = false;
853            } else {
854                panic!("Released a peripheral which was not taken");
855            }
856        });
857    }
858
859    /// Unsafely steal USART6
860    ///
861    /// This function is similar to take() but forcibly takes the
862    /// Instance, marking it as taken irregardless of its previous
863    /// state.
864    #[cfg(not(feature = "nosync"))]
865    #[inline]
866    pub unsafe fn steal() -> Instance {
867        USART6_TAKEN = true;
868        INSTANCE
869    }
870}
871
872/// Raw pointer to USART6
873///
874/// Dereferencing this is unsafe because you are not ensured unique
875/// access to the peripheral, so you may encounter data races with
876/// other users of this peripheral. It is up to you to ensure you
877/// will not cause data races.
878///
879/// This constant is provided for ease of use in unsafe code: you can
880/// simply call for example `write_reg!(gpio, GPIOA, ODR, 1);`.
881pub const USART6: *const RegisterBlock = 0x40011400 as *const _;