mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-24 21:21:31 +11:00
Constraint the uart::pin:: traits to UartDevice
This commit is contained in:
parent
a4a0bcf987
commit
a8a27672b8
|
@ -1,8 +1,10 @@
|
||||||
use crate::gpio::{bank0, FunctionUart, Pin};
|
use crate::gpio::{bank0, FunctionUart, Pin};
|
||||||
use crate::pac::{UART0, UART1};
|
use crate::pac::{UART0, UART1};
|
||||||
|
|
||||||
|
use super::UartDevice;
|
||||||
|
|
||||||
/// Declares a valid UART pinout.
|
/// Declares a valid UART pinout.
|
||||||
pub trait ValidUartPinout<UART> {
|
pub trait ValidUartPinout<UART: UartDevice> {
|
||||||
/// Indicates TX should be enabled for this pinout
|
/// Indicates TX should be enabled for this pinout
|
||||||
const TX_ENABLED: bool;
|
const TX_ENABLED: bool;
|
||||||
/// Indicates RX should be enabled for this pinout
|
/// Indicates RX should be enabled for this pinout
|
||||||
|
@ -15,6 +17,7 @@ pub trait ValidUartPinout<UART> {
|
||||||
|
|
||||||
impl<UART, TX, RX, CTS, RTS> ValidUartPinout<UART> for Pins<TX, RX, CTS, RTS>
|
impl<UART, TX, RX, CTS, RTS> ValidUartPinout<UART> for Pins<TX, RX, CTS, RTS>
|
||||||
where
|
where
|
||||||
|
UART: UartDevice,
|
||||||
TX: Tx<UART>,
|
TX: Tx<UART>,
|
||||||
RX: Rx<UART>,
|
RX: Rx<UART>,
|
||||||
CTS: Cts<UART>,
|
CTS: Cts<UART>,
|
||||||
|
@ -28,6 +31,7 @@ where
|
||||||
|
|
||||||
impl<UART, TX, RX> ValidUartPinout<UART> for (TX, RX)
|
impl<UART, TX, RX> ValidUartPinout<UART> for (TX, RX)
|
||||||
where
|
where
|
||||||
|
UART: UartDevice,
|
||||||
TX: Tx<UART>,
|
TX: Tx<UART>,
|
||||||
RX: Rx<UART>,
|
RX: Rx<UART>,
|
||||||
{
|
{
|
||||||
|
@ -39,6 +43,7 @@ where
|
||||||
|
|
||||||
impl<UART, TX, RX, CTS, RTS> ValidUartPinout<UART> for (TX, RX, CTS, RTS)
|
impl<UART, TX, RX, CTS, RTS> ValidUartPinout<UART> for (TX, RX, CTS, RTS)
|
||||||
where
|
where
|
||||||
|
UART: UartDevice,
|
||||||
TX: Tx<UART>,
|
TX: Tx<UART>,
|
||||||
RX: Rx<UART>,
|
RX: Rx<UART>,
|
||||||
CTS: Cts<UART>,
|
CTS: Cts<UART>,
|
||||||
|
@ -136,36 +141,36 @@ impl<TX, RX, CTS, RTS> Pins<TX, RX, CTS, RTS> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicates a valid TX pin for UART0 or UART1
|
/// Indicates a valid TX pin for UART0 or UART1
|
||||||
pub trait Tx<UART> {
|
pub trait Tx<UART: UartDevice> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
const ENABLED: bool;
|
const ENABLED: bool;
|
||||||
}
|
}
|
||||||
/// Indicates a valid RX pin for UART0 or UART1
|
/// Indicates a valid RX pin for UART0 or UART1
|
||||||
pub trait Rx<UART> {
|
pub trait Rx<UART: UartDevice> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
const ENABLED: bool;
|
const ENABLED: bool;
|
||||||
}
|
}
|
||||||
/// Indicates a valid CTS pin for UART0 or UART1
|
/// Indicates a valid CTS pin for UART0 or UART1
|
||||||
pub trait Cts<UART> {
|
pub trait Cts<UART: UartDevice> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
const ENABLED: bool;
|
const ENABLED: bool;
|
||||||
}
|
}
|
||||||
/// Indicates a valid RTS pin for UART0 or UART1
|
/// Indicates a valid RTS pin for UART0 or UART1
|
||||||
pub trait Rts<UART> {
|
pub trait Rts<UART: UartDevice> {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
const ENABLED: bool;
|
const ENABLED: bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<UART> Tx<UART> for () {
|
impl<UART: UartDevice> Tx<UART> for () {
|
||||||
const ENABLED: bool = false;
|
const ENABLED: bool = false;
|
||||||
}
|
}
|
||||||
impl<UART> Rx<UART> for () {
|
impl<UART: UartDevice> Rx<UART> for () {
|
||||||
const ENABLED: bool = false;
|
const ENABLED: bool = false;
|
||||||
}
|
}
|
||||||
impl<UART> Cts<UART> for () {
|
impl<UART: UartDevice> Cts<UART> for () {
|
||||||
const ENABLED: bool = false;
|
const ENABLED: bool = false;
|
||||||
}
|
}
|
||||||
impl<UART> Rts<UART> for () {
|
impl<UART: UartDevice> Rts<UART> for () {
|
||||||
const ENABLED: bool = false;
|
const ENABLED: bool = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue