aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src/uart
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-04-05 00:35:25 +0200
committerDario Nieuwenhuis <[email protected]>2024-04-05 00:48:46 +0200
commita84b33995eacc32e0e13d70293fa9bd7b2bd75f8 (patch)
treecfd48dbdad8885495cf20c4832f373444b867397 /embassy-rp/src/uart
parentab85eb4b60cd49ebcd43d2305f42327685f5e5a6 (diff)
rp: remove mod sealed.
Diffstat (limited to 'embassy-rp/src/uart')
-rw-r--r--embassy-rp/src/uart/mod.rs55
1 files changed, 24 insertions, 31 deletions
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs
index 65dcf4eb4..ee2dcb27d 100644
--- a/embassy-rp/src/uart/mod.rs
+++ b/embassy-rp/src/uart/mod.rs
@@ -12,8 +12,7 @@ use pac::uart::regs::Uartris;
12 12
13use crate::clocks::clk_peri_freq; 13use crate::clocks::clk_peri_freq;
14use crate::dma::{AnyChannel, Channel}; 14use crate::dma::{AnyChannel, Channel};
15use crate::gpio::sealed::Pin; 15use crate::gpio::{AnyPin, SealedPin};
16use crate::gpio::AnyPin;
17use crate::interrupt::typelevel::{Binding, Interrupt}; 16use crate::interrupt::typelevel::{Binding, Interrupt};
18use crate::pac::io::vals::{Inover, Outover}; 17use crate::pac::io::vals::{Inover, Outover};
19use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; 18use crate::{interrupt, pac, peripherals, Peripheral, RegExt};
@@ -1107,35 +1106,26 @@ impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for Uart<'d, T, M>
1107 } 1106 }
1108} 1107}
1109 1108
1110mod sealed { 1109trait SealedMode {}
1111 use super::*;
1112 1110
1113 pub trait Mode {} 1111trait SealedInstance {
1112 const TX_DREQ: u8;
1113 const RX_DREQ: u8;
1114 1114
1115 pub trait Instance { 1115 fn regs() -> pac::uart::Uart;
1116 const TX_DREQ: u8;
1117 const RX_DREQ: u8;
1118 1116
1119 type Interrupt: interrupt::typelevel::Interrupt; 1117 fn buffered_state() -> &'static buffered::State;
1120 1118
1121 fn regs() -> pac::uart::Uart; 1119 fn dma_state() -> &'static DmaState;
1122
1123 fn buffered_state() -> &'static buffered::State;
1124
1125 fn dma_state() -> &'static DmaState;
1126 }
1127 pub trait TxPin<T: Instance> {}
1128 pub trait RxPin<T: Instance> {}
1129 pub trait CtsPin<T: Instance> {}
1130 pub trait RtsPin<T: Instance> {}
1131} 1120}
1132 1121
1133/// UART mode. 1122/// UART mode.
1134pub trait Mode: sealed::Mode {} 1123#[allow(private_bounds)]
1124pub trait Mode: SealedMode {}
1135 1125
1136macro_rules! impl_mode { 1126macro_rules! impl_mode {
1137 ($name:ident) => { 1127 ($name:ident) => {
1138 impl sealed::Mode for $name {} 1128 impl SealedMode for $name {}
1139 impl Mode for $name {} 1129 impl Mode for $name {}
1140 }; 1130 };
1141} 1131}
@@ -1149,16 +1139,18 @@ impl_mode!(Blocking);
1149impl_mode!(Async); 1139impl_mode!(Async);
1150 1140
1151/// UART instance. 1141/// UART instance.
1152pub trait Instance: sealed::Instance {} 1142#[allow(private_bounds)]
1143pub trait Instance: SealedInstance {
1144 /// Interrupt for this instance.
1145 type Interrupt: interrupt::typelevel::Interrupt;
1146}
1153 1147
1154macro_rules! impl_instance { 1148macro_rules! impl_instance {
1155 ($inst:ident, $irq:ident, $tx_dreq:expr, $rx_dreq:expr) => { 1149 ($inst:ident, $irq:ident, $tx_dreq:expr, $rx_dreq:expr) => {
1156 impl sealed::Instance for peripherals::$inst { 1150 impl SealedInstance for peripherals::$inst {
1157 const TX_DREQ: u8 = $tx_dreq; 1151 const TX_DREQ: u8 = $tx_dreq;
1158 const RX_DREQ: u8 = $rx_dreq; 1152 const RX_DREQ: u8 = $rx_dreq;
1159 1153
1160 type Interrupt = crate::interrupt::typelevel::$irq;
1161
1162 fn regs() -> pac::uart::Uart { 1154 fn regs() -> pac::uart::Uart {
1163 pac::$inst 1155 pac::$inst
1164 } 1156 }
@@ -1176,7 +1168,9 @@ macro_rules! impl_instance {
1176 &STATE 1168 &STATE
1177 } 1169 }
1178 } 1170 }
1179 impl Instance for peripherals::$inst {} 1171 impl Instance for peripherals::$inst {
1172 type Interrupt = crate::interrupt::typelevel::$irq;
1173 }
1180 }; 1174 };
1181} 1175}
1182 1176
@@ -1184,17 +1178,16 @@ impl_instance!(UART0, UART0_IRQ, 20, 21);
1184impl_instance!(UART1, UART1_IRQ, 22, 23); 1178impl_instance!(UART1, UART1_IRQ, 22, 23);
1185 1179
1186/// Trait for TX pins. 1180/// Trait for TX pins.
1187pub trait TxPin<T: Instance>: sealed::TxPin<T> + crate::gpio::Pin {} 1181pub trait TxPin<T: Instance>: crate::gpio::Pin {}
1188/// Trait for RX pins. 1182/// Trait for RX pins.
1189pub trait RxPin<T: Instance>: sealed::RxPin<T> + crate::gpio::Pin {} 1183pub trait RxPin<T: Instance>: crate::gpio::Pin {}
1190/// Trait for Clear To Send (CTS) pins. 1184/// Trait for Clear To Send (CTS) pins.
1191pub trait CtsPin<T: Instance>: sealed::CtsPin<T> + crate::gpio::Pin {} 1185pub trait CtsPin<T: Instance>: crate::gpio::Pin {}
1192/// Trait for Request To Send (RTS) pins. 1186/// Trait for Request To Send (RTS) pins.
1193pub trait RtsPin<T: Instance>: sealed::RtsPin<T> + crate::gpio::Pin {} 1187pub trait RtsPin<T: Instance>: crate::gpio::Pin {}
1194 1188
1195macro_rules! impl_pin { 1189macro_rules! impl_pin {
1196 ($pin:ident, $instance:ident, $function:ident) => { 1190 ($pin:ident, $instance:ident, $function:ident) => {
1197 impl sealed::$function<peripherals::$instance> for peripherals::$pin {}
1198 impl $function<peripherals::$instance> for peripherals::$pin {} 1191 impl $function<peripherals::$instance> for peripherals::$pin {}
1199 }; 1192 };
1200} 1193}