aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
authorAlexandru RADOVICI <[email protected]>2024-04-02 19:42:37 +0300
committerAlexandru RADOVICI <[email protected]>2024-04-02 19:42:37 +0300
commit7b9546c9c8206147d1d79ba34ac19e97bb735c57 (patch)
treeedf8b79ac606299dd61a1ca7d27a1e46d75ec843 /embassy-rp/src
parente29b5619d1dafb46a25f42a5b3552605bb3c2d86 (diff)
rename the Channel trait to Slice and the PwmPin to PwmChannel
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/pwm.rs120
1 files changed, 60 insertions, 60 deletions
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs
index 3b980108a..2a6772043 100644
--- a/embassy-rp/src/pwm.rs
+++ b/embassy-rp/src/pwm.rs
@@ -129,7 +129,7 @@ impl<'d, T: Channel> Pwm<'d, T> {
129 #[inline] 129 #[inline]
130 pub fn new_output_a( 130 pub fn new_output_a(
131 inner: impl Peripheral<P = T> + 'd, 131 inner: impl Peripheral<P = T> + 'd,
132 a: impl Peripheral<P = impl PwmPinA<T>> + 'd, 132 a: impl Peripheral<P = impl PwmChannelA<T>> + 'd,
133 config: Config, 133 config: Config,
134 ) -> Self { 134 ) -> Self {
135 into_ref!(a); 135 into_ref!(a);
@@ -140,7 +140,7 @@ impl<'d, T: Channel> Pwm<'d, T> {
140 #[inline] 140 #[inline]
141 pub fn new_output_b( 141 pub fn new_output_b(
142 inner: impl Peripheral<P = T> + 'd, 142 inner: impl Peripheral<P = T> + 'd,
143 b: impl Peripheral<P = impl PwmPinB<T>> + 'd, 143 b: impl Peripheral<P = impl PwmChannelB<T>> + 'd,
144 config: Config, 144 config: Config,
145 ) -> Self { 145 ) -> Self {
146 into_ref!(b); 146 into_ref!(b);
@@ -151,8 +151,8 @@ impl<'d, T: Channel> Pwm<'d, T> {
151 #[inline] 151 #[inline]
152 pub fn new_output_ab( 152 pub fn new_output_ab(
153 inner: impl Peripheral<P = T> + 'd, 153 inner: impl Peripheral<P = T> + 'd,
154 a: impl Peripheral<P = impl PwmPinA<T>> + 'd, 154 a: impl Peripheral<P = impl PwmChannelA<T>> + 'd,
155 b: impl Peripheral<P = impl PwmPinB<T>> + 'd, 155 b: impl Peripheral<P = impl PwmChannelB<T>> + 'd,
156 config: Config, 156 config: Config,
157 ) -> Self { 157 ) -> Self {
158 into_ref!(a, b); 158 into_ref!(a, b);
@@ -163,7 +163,7 @@ impl<'d, T: Channel> Pwm<'d, T> {
163 #[inline] 163 #[inline]
164 pub fn new_input( 164 pub fn new_input(
165 inner: impl Peripheral<P = T> + 'd, 165 inner: impl Peripheral<P = T> + 'd,
166 b: impl Peripheral<P = impl PwmPinB<T>> + 'd, 166 b: impl Peripheral<P = impl PwmChannelB<T>> + 'd,
167 mode: InputMode, 167 mode: InputMode,
168 config: Config, 168 config: Config,
169 ) -> Self { 169 ) -> Self {
@@ -175,8 +175,8 @@ impl<'d, T: Channel> Pwm<'d, T> {
175 #[inline] 175 #[inline]
176 pub fn new_output_input( 176 pub fn new_output_input(
177 inner: impl Peripheral<P = T> + 'd, 177 inner: impl Peripheral<P = T> + 'd,
178 a: impl Peripheral<P = impl PwmPinA<T>> + 'd, 178 a: impl Peripheral<P = impl PwmChannelA<T>> + 'd,
179 b: impl Peripheral<P = impl PwmPinB<T>> + 'd, 179 b: impl Peripheral<P = impl PwmChannelB<T>> + 'd,
180 mode: InputMode, 180 mode: InputMode,
181 config: Config, 181 config: Config,
182 ) -> Self { 182 ) -> Self {
@@ -301,24 +301,24 @@ impl<'d, T: Channel> Drop for Pwm<'d, T> {
301} 301}
302 302
303mod sealed { 303mod sealed {
304 pub trait Channel {} 304 pub trait Slice {}
305} 305}
306 306
307/// PWM Channel. 307/// PWM Slice.
308pub trait Channel: Peripheral<P = Self> + sealed::Channel + Sized + 'static { 308pub trait Slice: Peripheral<P = Self> + sealed::Channel + Sized + 'static {
309 /// Channel number. 309 /// Slice number.
310 fn number(&self) -> u8; 310 fn number(&self) -> u8;
311 311
312 /// Channel register block. 312 /// Slice register block.
313 fn regs(&self) -> pac::pwm::Channel { 313 fn regs(&self) -> pac::pwm::Channel {
314 pac::PWM.ch(self.number() as _) 314 pac::PWM.ch(self.number() as _)
315 } 315 }
316} 316}
317 317
318macro_rules! channel { 318macro_rules! slice {
319 ($name:ident, $num:expr) => { 319 ($name:ident, $num:expr) => {
320 impl sealed::Channel for peripherals::$name {} 320 impl sealed::Slice for peripherals::$name {}
321 impl Channel for peripherals::$name { 321 impl Slice for peripherals::$name {
322 fn number(&self) -> u8 { 322 fn number(&self) -> u8 {
323 $num 323 $num
324 } 324 }
@@ -326,53 +326,53 @@ macro_rules! channel {
326 }; 326 };
327} 327}
328 328
329channel!(PWM_SLICE0, 0); 329slice!(PWM_SLICE0, 0);
330channel!(PWM_SLICE1, 1); 330slice!(PWM_SLICE1, 1);
331channel!(PWM_SLICE2, 2); 331slice!(PWM_SLICE2, 2);
332channel!(PWM_SLICE3, 3); 332slice!(PWM_SLICE3, 3);
333channel!(PWM_SLICE4, 4); 333slice!(PWM_SLICE4, 4);
334channel!(PWM_SLICE5, 5); 334slice!(PWM_SLICE5, 5);
335channel!(PWM_SLICE6, 6); 335slice!(PWM_SLICE6, 6);
336channel!(PWM_SLICE7, 7); 336slice!(PWM_SLICE7, 7);
337 337
338/// PWM Pin A. 338/// PWM Channel A.
339pub trait PwmPinA<T: Channel>: GpioPin {} 339pub trait PwmChannelA<T: Slice>: GpioPin {}
340/// PWM Pin B. 340/// PWM Channel B.
341pub trait PwmPinB<T: Channel>: GpioPin {} 341pub trait PwmChannelB<T: Slice>: GpioPin {}
342 342
343macro_rules! impl_pin { 343macro_rules! impl_channel {
344 ($pin:ident, $channel:ident, $kind:ident) => { 344 ($pin:ident, $channel:ident, $kind:ident) => {
345 impl $kind<peripherals::$channel> for peripherals::$pin {} 345 impl $kind<peripherals::$channel> for peripherals::$pin {}
346 }; 346 };
347} 347}
348 348
349impl_pin!(PIN_0, PWM_SLICE0, PwmPinA); 349impl_channel!(PIN_0, PWM_SLICE0, PwmChannelA);
350impl_pin!(PIN_1, PWM_SLICE0, PwmPinB); 350impl_channel!(PIN_1, PWM_SLICE0, PwmChannelB);
351impl_pin!(PIN_2, PWM_SLICE1, PwmPinA); 351impl_channel!(PIN_2, PWM_SLICE1, PwmChannelA);
352impl_pin!(PIN_3, PWM_SLICE1, PwmPinB); 352impl_channel!(PIN_3, PWM_SLICE1, PwmChannelB);
353impl_pin!(PIN_4, PWM_SLICE2, PwmPinA); 353impl_channel!(PIN_4, PWM_SLICE2, PwmChannelA);
354impl_pin!(PIN_5, PWM_SLICE2, PwmPinB); 354impl_channel!(PIN_5, PWM_SLICE2, PwmChannelB);
355impl_pin!(PIN_6, PWM_SLICE3, PwmPinA); 355impl_channel!(PIN_6, PWM_SLICE3, PwmChannelA);
356impl_pin!(PIN_7, PWM_SLICE3, PwmPinB); 356impl_channel!(PIN_7, PWM_SLICE3, PwmChannelB);
357impl_pin!(PIN_8, PWM_SLICE4, PwmPinA); 357impl_channel!(PIN_8, PWM_SLICE4, PwmChannelA);
358impl_pin!(PIN_9, PWM_SLICE4, PwmPinB); 358impl_channel!(PIN_9, PWM_SLICE4, PwmChannelB);
359impl_pin!(PIN_10, PWM_SLICE5, PwmPinA); 359impl_channel!(PIN_10, PWM_SLICE5, PwmChannelA);
360impl_pin!(PIN_11, PWM_SLICE5, PwmPinB); 360impl_channel!(PIN_11, PWM_SLICE5, PwmChannelB);
361impl_pin!(PIN_12, PWM_SLICE6, PwmPinA); 361impl_channel!(PIN_12, PWM_SLICE6, PwmChannelA);
362impl_pin!(PIN_13, PWM_SLICE6, PwmPinB); 362impl_channel!(PIN_13, PWM_SLICE6, PwmChannelB);
363impl_pin!(PIN_14, PWM_SLICE7, PwmPinA); 363impl_channel!(PIN_14, PWM_SLICE7, PwmChannelA);
364impl_pin!(PIN_15, PWM_SLICE7, PwmPinB); 364impl_channel!(PIN_15, PWM_SLICE7, PwmChannelB);
365impl_pin!(PIN_16, PWM_SLICE0, PwmPinA); 365impl_channel!(PIN_16, PWM_SLICE0, PwmChannelA);
366impl_pin!(PIN_17, PWM_SLICE0, PwmPinB); 366impl_channel!(PIN_17, PWM_SLICE0, PwmChannelB);
367impl_pin!(PIN_18, PWM_SLICE1, PwmPinA); 367impl_channel!(PIN_18, PWM_SLICE1, PwmChannelA);
368impl_pin!(PIN_19, PWM_SLICE1, PwmPinB); 368impl_channel!(PIN_19, PWM_SLICE1, PwmChannelB);
369impl_pin!(PIN_20, PWM_SLICE2, PwmPinA); 369impl_channel!(PIN_20, PWM_SLICE2, PwmChannelA);
370impl_pin!(PIN_21, PWM_SLICE2, PwmPinB); 370impl_channel!(PIN_21, PWM_SLICE2, PwmChannelB);
371impl_pin!(PIN_22, PWM_SLICE3, PwmPinA); 371impl_channel!(PIN_22, PWM_SLICE3, PwmChannelA);
372impl_pin!(PIN_23, PWM_SLICE3, PwmPinB); 372impl_channel!(PIN_23, PWM_SLICE3, PwmChannelB);
373impl_pin!(PIN_24, PWM_SLICE4, PwmPinA); 373impl_channel!(PIN_24, PWM_SLICE4, PwmChannelA);
374impl_pin!(PIN_25, PWM_SLICE4, PwmPinB); 374impl_channel!(PIN_25, PWM_SLICE4, PwmChannelB);
375impl_pin!(PIN_26, PWM_SLICE5, PwmPinA); 375impl_channel!(PIN_26, PWM_SLICE5, PwmChannelA);
376impl_pin!(PIN_27, PWM_SLICE5, PwmPinB); 376impl_channel!(PIN_27, PWM_SLICE5, PwmChannelB);
377impl_pin!(PIN_28, PWM_SLICE6, PwmPinA); 377impl_channel!(PIN_28, PWM_SLICE6, PwmChannelA);
378impl_pin!(PIN_29, PWM_SLICE6, PwmPinB); 378impl_channel!(PIN_29, PWM_SLICE6, PwmChannelB);