tm4c123x-hal 0.8.0

HAL for the TM4C123x family of microcontrollers
Documentation
//! Serial

use core::fmt;
use core::marker::PhantomData;

use crate::hal::prelude::*;
use crate::hal::serial;
use nb::{self, block};
pub use tm4c123x::{UART0, UART1, UART2, UART3, UART4, UART5, UART6, UART7};
use void::Void;

use crate::gpio::{gpioa, gpiob, gpioc, gpiod, gpioe, gpiof};
use crate::gpio::{AlternateFunction, OutputMode, AF1, AF2};
use crate::sysctl;
use crate::sysctl::Clocks;
use crate::time::Bps;

pub use tm4c_hal::serial::*;

pub use tm4c_hal::serial::*;

pub use tm4c_hal::{uart_hal_macro, uart_pin_macro};

/// Serial abstraction
pub struct Serial<UART, TX, RX, RTS, CTS> {
    uart: UART,
    tx_pin: TX,
    rx_pin: RX,
    rts_pin: RTS,
    cts_pin: CTS,
    nl_mode: NewlineMode,
}

/// Serial receiver
pub struct Rx<UART, RX, CTS> {
    _uart: PhantomData<UART>,
    pin: RX,
    flow_pin: CTS,
}

/// Serial transmitter
pub struct Tx<UART, TX, RTS> {
    uart: UART,
    pin: TX,
    flow_pin: RTS,
    nl_mode: NewlineMode,
}

uart_pin_macro!(UART0,
    cts: [],
    rts: [],
    rx: [(gpioa::PA0, AF1)],
    tx: [(gpioa::PA1, AF1)],
);

uart_pin_macro!(UART1,
    cts: [(gpioc::PC5, AF2),(gpiof::PF1, AF1)],
    rts: [(gpioc::PC4, AF2),(gpiof::PF0, AF1)],
    rx: [(gpiob::PB0, AF1),(gpioc::PC4, AF2)],
    tx: [(gpiob::PB1, AF1),(gpioc::PC5, AF2)],
);

uart_pin_macro!(UART2,
    cts: [],
    rts: [],
    rx: [(gpiod::PD6, AF1)],
    tx: [(gpiod::PD7, AF1)],
);

uart_pin_macro!(UART3,
    cts: [],
    rts: [],
    rx: [(gpioc::PC6, AF1)],
    tx: [(gpioc::PC7, AF1)],
);

uart_pin_macro!(UART4,
    cts: [],
    rts: [],
    rx: [(gpioc::PC4, AF1)],
    tx: [(gpioc::PC5, AF1)],
);

uart_pin_macro!(UART5,
    cts: [],
    rts: [],
    rx: [(gpioe::PE4, AF1)],
    tx: [(gpioe::PE5, AF1)],
);

uart_pin_macro!(UART6,
    cts: [],
    rts: [],
    rx: [(gpiod::PD4, AF1)],
    tx: [(gpiod::PD5, AF1)],
);

uart_pin_macro!(UART7,
    cts: [],
    rts: [],
    rx: [(gpioe::PE0, AF1)],
    tx: [(gpioe::PE1, AF1)],
);

uart_hal_macro! {
    UART0: (Uart0, uart0),
    UART1: (Uart1, uart1),
    UART2: (Uart2, uart2),
    UART3: (Uart3, uart3),
    UART4: (Uart4, uart4),
    UART5: (Uart5, uart5),
    UART6: (Uart6, uart6),
    UART7: (Uart7, uart7),
}