diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-04-05 00:35:25 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-04-05 00:48:46 +0200 |
| commit | a84b33995eacc32e0e13d70293fa9bd7b2bd75f8 (patch) | |
| tree | cfd48dbdad8885495cf20c4832f373444b867397 /embassy-rp/src/uart | |
| parent | ab85eb4b60cd49ebcd43d2305f42327685f5e5a6 (diff) | |
rp: remove mod sealed.
Diffstat (limited to 'embassy-rp/src/uart')
| -rw-r--r-- | embassy-rp/src/uart/mod.rs | 55 |
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 | ||
| 13 | use crate::clocks::clk_peri_freq; | 13 | use crate::clocks::clk_peri_freq; |
| 14 | use crate::dma::{AnyChannel, Channel}; | 14 | use crate::dma::{AnyChannel, Channel}; |
| 15 | use crate::gpio::sealed::Pin; | 15 | use crate::gpio::{AnyPin, SealedPin}; |
| 16 | use crate::gpio::AnyPin; | ||
| 17 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 16 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 18 | use crate::pac::io::vals::{Inover, Outover}; | 17 | use crate::pac::io::vals::{Inover, Outover}; |
| 19 | use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; | 18 | use 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 | ||
| 1110 | mod sealed { | 1109 | trait SealedMode {} |
| 1111 | use super::*; | ||
| 1112 | 1110 | ||
| 1113 | pub trait Mode {} | 1111 | trait 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. |
| 1134 | pub trait Mode: sealed::Mode {} | 1123 | #[allow(private_bounds)] |
| 1124 | pub trait Mode: SealedMode {} | ||
| 1135 | 1125 | ||
| 1136 | macro_rules! impl_mode { | 1126 | macro_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); | |||
| 1149 | impl_mode!(Async); | 1139 | impl_mode!(Async); |
| 1150 | 1140 | ||
| 1151 | /// UART instance. | 1141 | /// UART instance. |
| 1152 | pub trait Instance: sealed::Instance {} | 1142 | #[allow(private_bounds)] |
| 1143 | pub trait Instance: SealedInstance { | ||
| 1144 | /// Interrupt for this instance. | ||
| 1145 | type Interrupt: interrupt::typelevel::Interrupt; | ||
| 1146 | } | ||
| 1153 | 1147 | ||
| 1154 | macro_rules! impl_instance { | 1148 | macro_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); | |||
| 1184 | impl_instance!(UART1, UART1_IRQ, 22, 23); | 1178 | impl_instance!(UART1, UART1_IRQ, 22, 23); |
| 1185 | 1179 | ||
| 1186 | /// Trait for TX pins. | 1180 | /// Trait for TX pins. |
| 1187 | pub trait TxPin<T: Instance>: sealed::TxPin<T> + crate::gpio::Pin {} | 1181 | pub trait TxPin<T: Instance>: crate::gpio::Pin {} |
| 1188 | /// Trait for RX pins. | 1182 | /// Trait for RX pins. |
| 1189 | pub trait RxPin<T: Instance>: sealed::RxPin<T> + crate::gpio::Pin {} | 1183 | pub trait RxPin<T: Instance>: crate::gpio::Pin {} |
| 1190 | /// Trait for Clear To Send (CTS) pins. | 1184 | /// Trait for Clear To Send (CTS) pins. |
| 1191 | pub trait CtsPin<T: Instance>: sealed::CtsPin<T> + crate::gpio::Pin {} | 1185 | pub trait CtsPin<T: Instance>: crate::gpio::Pin {} |
| 1192 | /// Trait for Request To Send (RTS) pins. | 1186 | /// Trait for Request To Send (RTS) pins. |
| 1193 | pub trait RtsPin<T: Instance>: sealed::RtsPin<T> + crate::gpio::Pin {} | 1187 | pub trait RtsPin<T: Instance>: crate::gpio::Pin {} |
| 1194 | 1188 | ||
| 1195 | macro_rules! impl_pin { | 1189 | macro_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 | } |
