Skip to content

Commit

Permalink
Finish thumbv7em implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed Jun 9, 2021
1 parent 305cf7e commit 43f3be9
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 116 deletions.
16 changes: 0 additions & 16 deletions hal/src/thumbv6m/sercom/v2/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,19 +637,11 @@ macro_rules! spi_pads_from_pins {
) => {
$crate::sercom::v2::spi::Pads<
$crate::sercom::v2::$Sercom,
<<<<<<< HEAD
$crate::__opt_type!( $crate::sercom::v2::pad::PinToNITuple<$DI> ),
$crate::__opt_type!( $crate::sercom::v2::pad::PinToNITuple<$DO> ),
$crate::__opt_type!( $crate::sercom::v2::pad::PinToNITuple<$CK> ),
$crate::__opt_type!( $crate::sercom::v2::pad::PinToNITuple<$SS> ),
>
=======
__spi_pad_type!($($Sercom, $DI_PadNum, $DI_Id)?),
__spi_pad_type!($($Sercom, $DO_PadNum, $DO_Id)?),
__spi_pad_type!($($Sercom, $CK_PadNum, $CK_Id)?),
__spi_pad_type!($($Sercom, $SS_PadNum, $SS_Id)?),
>;
>>>>>>> 4450d53c7 (Begin implementing v2 UART driver)
};
}

Expand Down Expand Up @@ -689,7 +681,6 @@ macro_rules! spi_pads_from_pins {
/// [`PinId`]: crate::gpio::v2::PinId
#[cfg(feature = "samd21")]
#[macro_export]
<<<<<<< HEAD
macro_rules! spi_pads_from_pins {
(
$Sercom:ident
Expand All @@ -699,13 +690,6 @@ macro_rules! spi_pads_from_pins {
$( , SS = $SS:ty )?
) => {
$crate::sercom::v2::spi::Pads<
=======
#[doc(hidden)]
macro_rules! __spi_pad_type {
() => { NoneT };
($Sercom:ident, $PadNum:ident, $Id:ident) => {
$crate::sercom::v2::pads::Pad<
>>>>>>> 4450d53c7 (Begin implementing v2 UART driver)
$crate::sercom::v2::$Sercom,
$crate::__opt_type!( $( $crate::gpio::v2::SpecificPinId<$DI> )? ),
$crate::__opt_type!( $( $crate::gpio::v2::SpecificPinId<$DO> )? ),
Expand Down
39 changes: 22 additions & 17 deletions hal/src/thumbv6m/sercom/v2/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
//!
//! # [`Config`]
//!
//! Next, create a [`Config`] struct, which represents the UART peripheral in its
//! disabled state. A `Config` is specified with three type parameters: the
//! Next, create a [`Config`] struct, which represents the UART peripheral in
//! its disabled state. A `Config` is specified with three type parameters: the
//! [`Pads`] type; an [`OpMode`], which defaults to [`Master`]; and a
//! [`CharSize`], which defaults to [`EightBit`].
//!
Expand Down Expand Up @@ -106,8 +106,8 @@
//!
//! # [`Uart`]
//!
//! An [`Uart`] struct can only be created from a [`Config`], and it has only one
//! type parameter, the corresponding config.
//! An [`Uart`] struct can only be created from a [`Config`], and it has only
//! one type parameter, the corresponding config.
//!
//! ```
//! use atsamd_hal::gpio::v2::{PA08, PA09};
Expand All @@ -121,8 +121,9 @@
//! type Uart = uart::Uart<Config>;
//! ```
//!
//! Only the [`Uart`] struct can actually perform transactions. To do so, use the
//! embedded HAL traits, like [`serial::Read`](Read) and [`serial::Write`](Write).
//! Only the [`Uart`] struct can actually perform transactions. To do so, use
//! the embedded HAL traits, like [`serial::Read`](Read) and
//! [`serial::Write`](Write).
//!
//! ```
//! use nb::block;
Expand All @@ -134,14 +135,16 @@
//! # Splitting and joining
//!
//! A fully configured [`Uart`] struct can be split into `Tx` and `Rx` halves.
//! That way, different parts of the program can individually send or receive UART transactions.
//! Splitting is only available for [`Uart`]s which can transmit and receive.
//! That way, different parts of the program can individually send or receive
//! UART transactions. Splitting is only available for [`Uart`]s which can
//! transmit and receive.
//!
//! ## Splitting
//!
//! Calling [`Uart::split`] will return three objects: a [`UartRx`], a [`UartTx`], and a [`UartCore`].
//! The [`UartCore`] struct holds the underlying [`Config`], and is necessary to keep around is the two
//! halves should be recombined by calling [`UartCore::join`].
//! Calling [`Uart::split`] will return three objects: a [`UartRx`], a
//! [`UartTx`], and a [`UartCore`]. The [`UartCore`] struct holds the underlying
//! [`Config`], and is necessary to keep around is the two halves should be
//! recombined by calling [`UartCore::join`].
//!
//! ```
//! use nb::block;
Expand All @@ -156,8 +159,8 @@
//!
//! ## Joining
//!
//! Recombining the [`UartRx`] and [`UartTx`] halves back into a full [`Uart`] is necessary if the
//! UART peripheral should be reconfigured
//! Recombining the [`UartRx`] and [`UartTx`] halves back into a full [`Uart`]
//! is necessary if the UART peripheral should be reconfigured
//!
//! ```
//! // Assume uart is a fully configured `Uart` with transmit/receive capability
Expand Down Expand Up @@ -1176,8 +1179,8 @@ where
///
/// This function will calculate the best BAUD register setting based on the
/// stored GCLK frequency and desired baud rate. The maximum baud rate is
/// GCLK frequency/oversampling. Values outside this range will saturate at the
/// maximum supported baud rate.
/// GCLK frequency/oversampling. Values outside this range will saturate at
/// the maximum supported baud rate.
///
/// Note that 3x oversampling is not supported.
#[inline]
Expand Down Expand Up @@ -1223,7 +1226,8 @@ where
}

#[inline]
/// Calculate baudrate value using the asynchronous frational method (Table 24-2)
/// Calculate baudrate value using the asynchronous frational method (Table
/// 24-2)
fn calculate_baud_asynchronous_fractional(baudrate: u32, clk_freq: u32, n_samples: u8) -> u16 {
todo!();
}
Expand Down Expand Up @@ -1741,7 +1745,8 @@ impl<C: ValidConfig, S: Sercom> Registers for UartTx<C, S> {

impl<C: ValidConfig, S: Sercom> Sealed for UartTx<C, S> {}

/// Struct containing the core [`Config`] when a [`Uart`] is [`split`](Uart::split).
/// Struct containing the core [`Config`] when a [`Uart`] is
/// [`split`](Uart::split).
///
/// The `rx` and `tx` halves can be `join`ed to form a full-duplex [`Uart`]
/// struct. `join`ing is necessary in order to reconfigure a [`Uart`], or
Expand Down

0 comments on commit 43f3be9

Please sign in to comment.