use crate::pac::dma::ch::ch_ctrl_trig::TREQ_SEL_A;
use crate::pac::{uart0::RegisterBlock, UART0, UART1};
use crate::resets::SubsystemReset;
use crate::typelevel::Sealed;
use core::ops::Deref;
#[doc(inline)]
pub use rp_hal_common::uart::{DataBits, Parity, StopBits, UartConfig};
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
BadArgument,
}
pub trait State: Sealed {}
pub trait UartDevice: Deref<Target = RegisterBlock> + SubsystemReset + Sealed + 'static {
const ID: usize;
fn tx_dreq() -> u8
where
Self: Sized;
fn rx_dreq() -> u8
where
Self: Sized;
}
impl UartDevice for UART0 {
const ID: usize = 0;
fn tx_dreq() -> u8 {
TREQ_SEL_A::UART0_TX.into()
}
fn rx_dreq() -> u8 {
TREQ_SEL_A::UART0_RX.into()
}
}
impl Sealed for UART0 {}
impl UartDevice for UART1 {
const ID: usize = 1;
fn tx_dreq() -> u8 {
TREQ_SEL_A::UART1_TX.into()
}
fn rx_dreq() -> u8 {
TREQ_SEL_A::UART1_RX.into()
}
}
impl Sealed for UART1 {}
pub struct Enabled;
pub struct Disabled;
impl State for Enabled {}
impl Sealed for Enabled {}
impl State for Disabled {}
impl Sealed for Disabled {}
pub enum FifoWatermark {
Bytes4,
Bytes8,
Bytes16,
Bytes24,
Bytes28,
}