stm32f1_hal/afio/
uart_remap.rs

1#![allow(unused_variables)]
2use super::*;
3use crate::{
4    gpio::*,
5    pac::{UART4, UART5, USART1, USART2, USART3},
6};
7
8// table
9// Do NOT manually modify the code.
10// It's generated by scripts/generate_remap_table.py from scripts/table/stm32f1_remap_peripheral.csv
11
12// Binder types ------------------
13
14pub trait UartCkPin<REMAP> {
15    #[inline(always)]
16    fn is_pin(&self) -> bool {
17        true
18    }
19}
20impl<T> UartCkPin<T> for NonePin {
21    #[inline(always)]
22    fn is_pin(&self) -> bool {
23        false
24    }
25}
26pub trait UartCtsPin<REMAP> {
27    #[inline(always)]
28    fn is_pin(&self) -> bool {
29        true
30    }
31}
32impl<T> UartCtsPin<T> for NonePin {
33    #[inline(always)]
34    fn is_pin(&self) -> bool {
35        false
36    }
37}
38pub trait UartRtsPin<REMAP> {
39    #[inline(always)]
40    fn is_pin(&self) -> bool {
41        true
42    }
43}
44impl<T> UartRtsPin<T> for NonePin {
45    #[inline(always)]
46    fn is_pin(&self) -> bool {
47        false
48    }
49}
50pub trait UartRxPin<REMAP> {
51    #[inline(always)]
52    fn is_pin(&self) -> bool {
53        true
54    }
55}
56impl<T> UartRxPin<T> for NonePin {
57    #[inline(always)]
58    fn is_pin(&self) -> bool {
59        false
60    }
61}
62pub trait UartTxPin<REMAP> {
63    #[inline(always)]
64    fn is_pin(&self) -> bool {
65        true
66    }
67}
68impl<T> UartTxPin<T> for NonePin {
69    #[inline(always)]
70    fn is_pin(&self) -> bool {
71        false
72    }
73}
74
75// Bind pins ---------------------
76
77impl<PULL: UpMode> UartRxPin<RemapDefault<UART4>> for PC11<Input<PULL>> {}
78impl UartTxPin<RemapDefault<UART4>> for PC10<Alternate<PushPull>> {}
79impl<PULL: UpMode> UartRxPin<RemapDefault<UART5>> for PD2<Input<PULL>> {}
80impl UartTxPin<RemapDefault<UART5>> for PC12<Alternate<PushPull>> {}
81impl<PULL: UpMode> UartRxPin<RemapDefault<USART1>> for PA10<Input<PULL>> {}
82impl UartTxPin<RemapDefault<USART1>> for PA9<Alternate<PushPull>> {}
83impl<PULL: UpMode> UartRxPin<RemapFull<USART1>> for PB7<Input<PULL>> {}
84impl UartTxPin<RemapFull<USART1>> for PB6<Alternate<PushPull>> {}
85impl UartCkPin<RemapDefault<USART2>> for PA4<Alternate<PushPull>> {}
86impl<PULL: UpMode> UartRxPin<RemapDefault<USART2>> for PA3<Input<PULL>> {}
87impl UartTxPin<RemapDefault<USART2>> for PA2<Alternate<PushPull>> {}
88impl UartCkPin<RemapFull<USART2>> for PD7<Alternate<PushPull>> {}
89impl<PULL: UpMode> UartRxPin<RemapFull<USART2>> for PD6<Input<PULL>> {}
90impl UartTxPin<RemapFull<USART2>> for PD5<Alternate<PushPull>> {}
91impl UartCkPin<RemapDefault<USART3>> for PB12<Alternate<PushPull>> {}
92impl<PULL: UpMode> UartRxPin<RemapDefault<USART3>> for PB11<Input<PULL>> {}
93impl UartTxPin<RemapDefault<USART3>> for PB10<Alternate<PushPull>> {}
94impl UartCkPin<RemapFull<USART3>> for PD10<Alternate<PushPull>> {}
95impl<PULL: UpMode> UartRxPin<RemapFull<USART3>> for PD9<Input<PULL>> {}
96impl UartTxPin<RemapFull<USART3>> for PD8<Alternate<PushPull>> {}
97impl UartCkPin<RemapPartial1<USART3>> for PC12<Alternate<PushPull>> {}
98impl<PULL: UpMode> UartRxPin<RemapPartial1<USART3>> for PC11<Input<PULL>> {}
99impl UartTxPin<RemapPartial1<USART3>> for PC10<Alternate<PushPull>> {}
100
101// Register operations ------------
102
103impl RemapMode<UART4> for RemapDefault<UART4> {
104    fn remap(afio: &mut Afio) {}
105}
106impl RemapMode<UART5> for RemapDefault<UART5> {
107    fn remap(afio: &mut Afio) {}
108}
109impl RemapMode<USART1> for RemapDefault<USART1> {
110    fn remap(afio: &mut Afio) {
111        afio.mapr.modify_mapr(|_, w| w.usart1_remap().clear_bit());
112    }
113}
114impl RemapMode<USART1> for RemapFull<USART1> {
115    fn remap(afio: &mut Afio) {
116        afio.mapr.modify_mapr(|_, w| w.usart1_remap().set_bit());
117    }
118}
119impl RemapMode<USART2> for RemapDefault<USART2> {
120    fn remap(afio: &mut Afio) {
121        afio.mapr.modify_mapr(|_, w| w.usart2_remap().clear_bit());
122    }
123}
124impl RemapMode<USART2> for RemapFull<USART2> {
125    fn remap(afio: &mut Afio) {
126        afio.mapr.modify_mapr(|_, w| w.usart2_remap().set_bit());
127    }
128}
129impl RemapMode<USART3> for RemapDefault<USART3> {
130    fn remap(afio: &mut Afio) {
131        afio.mapr
132            .modify_mapr(unsafe { |_, w| w.usart3_remap().bits(0b00) });
133    }
134}
135impl RemapMode<USART3> for RemapFull<USART3> {
136    fn remap(afio: &mut Afio) {
137        afio.mapr
138            .modify_mapr(unsafe { |_, w| w.usart3_remap().bits(0b11) });
139    }
140}
141impl RemapMode<USART3> for RemapPartial1<USART3> {
142    fn remap(afio: &mut Afio) {
143        afio.mapr
144            .modify_mapr(unsafe { |_, w| w.usart3_remap().bits(0b01) });
145    }
146}