aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/uarte.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-05-11 03:04:59 +0200
committerDario Nieuwenhuis <[email protected]>2021-05-17 00:57:20 +0200
commitbd9589d0ce71a2aa41c9fdf439d6de6349a09d83 (patch)
treebed94fa0d977604b1f9cbcb09d27b44791aca404 /embassy-nrf/src/uarte.rs
parentcd4111736c0384b1ef957df7f6aa51e3727c29b2 (diff)
nrf: add support for nrf52805, nrf52811, nrf52820
Diffstat (limited to 'embassy-nrf/src/uarte.rs')
-rw-r--r--embassy-nrf/src/uarte.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs
index 04907fb56..7581f7a8b 100644
--- a/embassy-nrf/src/uarte.rs
+++ b/embassy-nrf/src/uarte.rs
@@ -1,3 +1,5 @@
1#![macro_use]
2
1//! Async UART 3//! Async UART
2 4
3use core::future::Future; 5use core::future::Future;
@@ -10,6 +12,7 @@ use embassy::util::{AtomicWaker, OnDrop, Unborrow};
10use embassy_extras::unborrow; 12use embassy_extras::unborrow;
11use futures::future::poll_fn; 13use futures::future::poll_fn;
12 14
15use crate::chip::EASY_DMA_SIZE;
13use crate::fmt::{assert, panic, *}; 16use crate::fmt::{assert, panic, *};
14use crate::gpio::sealed::Pin as _; 17use crate::gpio::sealed::Pin as _;
15use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin}; 18use crate::gpio::{OptionalPin as GpioOptionalPin, Pin as GpioPin};
@@ -18,7 +21,6 @@ use crate::interrupt::Interrupt;
18use crate::pac; 21use crate::pac;
19use crate::peripherals; 22use crate::peripherals;
20use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task}; 23use crate::ppi::{AnyConfigurableChannel, ConfigurableChannel, Event, Ppi, Task};
21use crate::target_constants::EASY_DMA_SIZE;
22use crate::timer::Instance as TimerInstance; 24use crate::timer::Instance as TimerInstance;
23 25
24// Re-export SVD variants to allow user to directly set values. 26// Re-export SVD variants to allow user to directly set values.
@@ -445,7 +447,7 @@ impl<'d, U: Instance, T: TimerInstance> Write for UarteWithIdle<'d, U, T> {
445 } 447 }
446} 448}
447 449
448mod sealed { 450pub(crate) mod sealed {
449 use super::*; 451 use super::*;
450 452
451 pub struct State { 453 pub struct State {
@@ -471,23 +473,19 @@ pub trait Instance: sealed::Instance + 'static {
471 type Interrupt: Interrupt; 473 type Interrupt: Interrupt;
472} 474}
473 475
474macro_rules! impl_instance { 476macro_rules! impl_uarte {
475 ($type:ident, $irq:ident) => { 477 ($type:ident, $pac_type:ident, $irq:ident) => {
476 impl sealed::Instance for peripherals::$type { 478 impl crate::uarte::sealed::Instance for peripherals::$type {
477 fn regs() -> &'static pac::uarte0::RegisterBlock { 479 fn regs() -> &'static pac::uarte0::RegisterBlock {
478 unsafe { &*pac::$type::ptr() } 480 unsafe { &*pac::$pac_type::ptr() }
479 } 481 }
480 fn state() -> &'static sealed::State { 482 fn state() -> &'static crate::uarte::sealed::State {
481 static STATE: sealed::State = sealed::State::new(); 483 static STATE: crate::uarte::sealed::State = crate::uarte::sealed::State::new();
482 &STATE 484 &STATE
483 } 485 }
484 } 486 }
485 impl Instance for peripherals::$type { 487 impl crate::uarte::Instance for peripherals::$type {
486 type Interrupt = interrupt::$irq; 488 type Interrupt = crate::interrupt::$irq;
487 } 489 }
488 }; 490 };
489} 491}
490
491impl_instance!(UARTE0, UARTE0_UART0);
492#[cfg(any(feature = "52833", feature = "52840", feature = "9160"))]
493impl_instance!(UARTE1, UARTE1);