Merge pull request #2275 from lights0123/stm32-usart-invert
stm32: usart pin inversion
This commit is contained in:
		@@ -132,6 +132,14 @@ pub struct Config {
 | 
				
			|||||||
    /// Set this to true to swap the RX and TX pins.
 | 
					    /// Set this to true to swap the RX and TX pins.
 | 
				
			||||||
    #[cfg(any(usart_v3, usart_v4))]
 | 
					    #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
    pub swap_rx_tx: bool,
 | 
					    pub swap_rx_tx: bool,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Set this to true to invert TX pin signal values (V<sub>DD</sub> =0/mark, Gnd = 1/idle).
 | 
				
			||||||
 | 
					    #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
 | 
					    pub invert_tx: bool,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Set this to true to invert RX pin signal values (V<sub>DD</sub> =0/mark, Gnd = 1/idle).
 | 
				
			||||||
 | 
					    #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
 | 
					    pub invert_rx: bool,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Default for Config {
 | 
					impl Default for Config {
 | 
				
			||||||
@@ -147,6 +155,10 @@ impl Default for Config {
 | 
				
			|||||||
            assume_noise_free: false,
 | 
					            assume_noise_free: false,
 | 
				
			||||||
            #[cfg(any(usart_v3, usart_v4))]
 | 
					            #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
            swap_rx_tx: false,
 | 
					            swap_rx_tx: false,
 | 
				
			||||||
 | 
					            #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
 | 
					            invert_tx: false,
 | 
				
			||||||
 | 
					            #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
 | 
					            invert_rx: false,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -972,7 +984,11 @@ fn configure(
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #[cfg(any(usart_v3, usart_v4))]
 | 
					        #[cfg(any(usart_v3, usart_v4))]
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            w.set_txinv(config.invert_tx);
 | 
				
			||||||
 | 
					            w.set_rxinv(config.invert_rx);
 | 
				
			||||||
            w.set_swap(config.swap_rx_tx);
 | 
					            w.set_swap(config.swap_rx_tx);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[cfg(not(usart_v1))]
 | 
					    #[cfg(not(usart_v1))]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user