Skip to content

Commit 747f1e6

Browse files
committed
impl From<OTHER_MODE> for MODEs
1 parent 7886776 commit 747f1e6

File tree

1 file changed

+313
-0
lines changed

1 file changed

+313
-0
lines changed

src/gpio.rs

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,319 @@ impl<MODE, const P: char, const N: u8> PinExt for PX<MODE, P, N> {
424424
}
425425
}
426426

427+
impl<MODE, const P: char, const N: u8, const A: u8> From<PX<Input<MODE>, P, N>>
428+
for PX<Alternate<AF<A>>, P, N>
429+
{
430+
#[inline(always)]
431+
fn from(f: PX<Input<MODE>, P, N>) -> Self {
432+
f.into_alternate::<A>()
433+
}
434+
}
435+
436+
impl<MODE, const P: char, const N: u8, const A: u8> From<PX<Output<MODE>, P, N>>
437+
for PX<Alternate<AF<A>>, P, N>
438+
{
439+
#[inline(always)]
440+
fn from(f: PX<Output<MODE>, P, N>) -> Self {
441+
f.into_alternate::<A>()
442+
}
443+
}
444+
445+
impl<const P: char, const N: u8, const A: u8> From<PX<Analog, P, N>>
446+
for PX<Alternate<AF<A>>, P, N>
447+
{
448+
#[inline(always)]
449+
fn from(f: PX<Analog, P, N>) -> Self {
450+
f.into_alternate::<A>()
451+
}
452+
}
453+
454+
impl<const P: char, const N: u8, const A: u8, const B: u8> From<PX<AlternateOD<AF<B>>, P, N>>
455+
for PX<Alternate<AF<A>>, P, N>
456+
{
457+
#[inline(always)]
458+
fn from(f: PX<AlternateOD<AF<B>>, P, N>) -> Self {
459+
f.into_alternate::<A>()
460+
}
461+
}
462+
463+
impl<MODE, const P: char, const N: u8, const A: u8> From<PX<Input<MODE>, P, N>>
464+
for PX<AlternateOD<AF<A>>, P, N>
465+
{
466+
#[inline(always)]
467+
fn from(f: PX<Input<MODE>, P, N>) -> Self {
468+
f.into_alternate_open_drain::<A>()
469+
}
470+
}
471+
472+
impl<MODE, const P: char, const N: u8, const A: u8> From<PX<Output<MODE>, P, N>>
473+
for PX<AlternateOD<AF<A>>, P, N>
474+
{
475+
#[inline(always)]
476+
fn from(f: PX<Output<MODE>, P, N>) -> Self {
477+
f.into_alternate_open_drain::<A>()
478+
}
479+
}
480+
481+
impl<const P: char, const N: u8, const A: u8> From<PX<Analog, P, N>>
482+
for PX<AlternateOD<AF<A>>, P, N>
483+
{
484+
#[inline(always)]
485+
fn from(f: PX<Analog, P, N>) -> Self {
486+
f.into_alternate_open_drain::<A>()
487+
}
488+
}
489+
490+
impl<const P: char, const N: u8, const A: u8, const B: u8> From<PX<Alternate<AF<B>>, P, N>>
491+
for PX<AlternateOD<AF<A>>, P, N>
492+
{
493+
#[inline(always)]
494+
fn from(f: PX<Alternate<AF<B>>, P, N>) -> Self {
495+
f.into_alternate_open_drain::<A>()
496+
}
497+
}
498+
499+
impl<const P: char, const N: u8> From<PX<Input<Floating>, P, N>> for PX<Input<PullDown>, P, N> {
500+
#[inline(always)]
501+
fn from(f: PX<Input<Floating>, P, N>) -> Self {
502+
f.into_pull_down_input()
503+
}
504+
}
505+
506+
impl<const P: char, const N: u8> From<PX<Input<PullUp>, P, N>> for PX<Input<PullDown>, P, N> {
507+
#[inline(always)]
508+
fn from(f: PX<Input<PullUp>, P, N>) -> Self {
509+
f.into_pull_down_input()
510+
}
511+
}
512+
513+
impl<MODE, const P: char, const N: u8> From<PX<Output<MODE>, P, N>> for PX<Input<PullDown>, P, N> {
514+
#[inline(always)]
515+
fn from(f: PX<Output<MODE>, P, N>) -> Self {
516+
f.into_pull_down_input()
517+
}
518+
}
519+
520+
impl<const P: char, const N: u8> From<PX<Analog, P, N>> for PX<Input<PullDown>, P, N> {
521+
#[inline(always)]
522+
fn from(f: PX<Analog, P, N>) -> Self {
523+
f.into_pull_down_input()
524+
}
525+
}
526+
527+
impl<MODE, const P: char, const N: u8> From<PX<Alternate<MODE>, P, N>>
528+
for PX<Input<PullDown>, P, N>
529+
{
530+
#[inline(always)]
531+
fn from(f: PX<Alternate<MODE>, P, N>) -> Self {
532+
f.into_pull_down_input()
533+
}
534+
}
535+
536+
impl<MODE, const P: char, const N: u8> From<PX<AlternateOD<MODE>, P, N>>
537+
for PX<Input<PullDown>, P, N>
538+
{
539+
#[inline(always)]
540+
fn from(f: PX<AlternateOD<MODE>, P, N>) -> Self {
541+
f.into_pull_down_input()
542+
}
543+
}
544+
545+
impl<const P: char, const N: u8> From<PX<Input<Floating>, P, N>> for PX<Input<PullUp>, P, N> {
546+
#[inline(always)]
547+
fn from(f: PX<Input<Floating>, P, N>) -> Self {
548+
f.into_pull_up_input()
549+
}
550+
}
551+
552+
impl<const P: char, const N: u8> From<PX<Input<PullDown>, P, N>> for PX<Input<PullUp>, P, N> {
553+
#[inline(always)]
554+
fn from(f: PX<Input<PullDown>, P, N>) -> Self {
555+
f.into_pull_up_input()
556+
}
557+
}
558+
559+
impl<MODE, const P: char, const N: u8> From<PX<Output<MODE>, P, N>> for PX<Input<PullUp>, P, N> {
560+
#[inline(always)]
561+
fn from(f: PX<Output<MODE>, P, N>) -> Self {
562+
f.into_pull_up_input()
563+
}
564+
}
565+
566+
impl<const P: char, const N: u8> From<PX<Analog, P, N>> for PX<Input<PullUp>, P, N> {
567+
#[inline(always)]
568+
fn from(f: PX<Analog, P, N>) -> Self {
569+
f.into_pull_up_input()
570+
}
571+
}
572+
573+
impl<MODE, const P: char, const N: u8> From<PX<Alternate<MODE>, P, N>> for PX<Input<PullUp>, P, N> {
574+
#[inline(always)]
575+
fn from(f: PX<Alternate<MODE>, P, N>) -> Self {
576+
f.into_pull_up_input()
577+
}
578+
}
579+
580+
impl<MODE, const P: char, const N: u8> From<PX<AlternateOD<MODE>, P, N>>
581+
for PX<Input<PullUp>, P, N>
582+
{
583+
#[inline(always)]
584+
fn from(f: PX<AlternateOD<MODE>, P, N>) -> Self {
585+
f.into_pull_up_input()
586+
}
587+
}
588+
589+
impl<const P: char, const N: u8> From<PX<Input<PullDown>, P, N>> for PX<Input<Floating>, P, N> {
590+
#[inline(always)]
591+
fn from(f: PX<Input<PullDown>, P, N>) -> Self {
592+
f.into_floating_input()
593+
}
594+
}
595+
596+
impl<const P: char, const N: u8> From<PX<Input<PullUp>, P, N>> for PX<Input<Floating>, P, N> {
597+
#[inline(always)]
598+
fn from(f: PX<Input<PullUp>, P, N>) -> Self {
599+
f.into_floating_input()
600+
}
601+
}
602+
603+
impl<MODE, const P: char, const N: u8> From<PX<Output<MODE>, P, N>> for PX<Input<Floating>, P, N> {
604+
#[inline(always)]
605+
fn from(f: PX<Output<MODE>, P, N>) -> Self {
606+
f.into_floating_input()
607+
}
608+
}
609+
610+
impl<const P: char, const N: u8> From<PX<Analog, P, N>> for PX<Input<Floating>, P, N> {
611+
#[inline(always)]
612+
fn from(f: PX<Analog, P, N>) -> Self {
613+
f.into_floating_input()
614+
}
615+
}
616+
617+
impl<MODE, const P: char, const N: u8> From<PX<Alternate<MODE>, P, N>>
618+
for PX<Input<Floating>, P, N>
619+
{
620+
#[inline(always)]
621+
fn from(f: PX<Alternate<MODE>, P, N>) -> Self {
622+
f.into_floating_input()
623+
}
624+
}
625+
626+
impl<MODE, const P: char, const N: u8> From<PX<AlternateOD<MODE>, P, N>>
627+
for PX<Input<Floating>, P, N>
628+
{
629+
#[inline(always)]
630+
fn from(f: PX<AlternateOD<MODE>, P, N>) -> Self {
631+
f.into_floating_input()
632+
}
633+
}
634+
635+
impl<MODE, const P: char, const N: u8> From<PX<Input<MODE>, P, N>> for PX<Output<OpenDrain>, P, N> {
636+
#[inline(always)]
637+
fn from(f: PX<Input<MODE>, P, N>) -> Self {
638+
f.into_open_drain_output()
639+
}
640+
}
641+
642+
impl<const P: char, const N: u8> From<PX<Output<PushPull>, P, N>> for PX<Output<OpenDrain>, P, N> {
643+
#[inline(always)]
644+
fn from(f: PX<Output<PushPull>, P, N>) -> Self {
645+
f.into_open_drain_output()
646+
}
647+
}
648+
649+
impl<const P: char, const N: u8> From<PX<Analog, P, N>> for PX<Output<OpenDrain>, P, N> {
650+
#[inline(always)]
651+
fn from(f: PX<Analog, P, N>) -> Self {
652+
f.into_open_drain_output()
653+
}
654+
}
655+
656+
impl<MODE, const P: char, const N: u8> From<PX<Alternate<MODE>, P, N>>
657+
for PX<Output<OpenDrain>, P, N>
658+
{
659+
#[inline(always)]
660+
fn from(f: PX<Alternate<MODE>, P, N>) -> Self {
661+
f.into_open_drain_output()
662+
}
663+
}
664+
665+
impl<MODE, const P: char, const N: u8> From<PX<AlternateOD<MODE>, P, N>>
666+
for PX<Output<OpenDrain>, P, N>
667+
{
668+
#[inline(always)]
669+
fn from(f: PX<AlternateOD<MODE>, P, N>) -> Self {
670+
f.into_open_drain_output()
671+
}
672+
}
673+
674+
impl<MODE, const P: char, const N: u8> From<PX<Input<MODE>, P, N>> for PX<Output<PushPull>, P, N> {
675+
#[inline(always)]
676+
fn from(f: PX<Input<MODE>, P, N>) -> Self {
677+
f.into_push_pull_output()
678+
}
679+
}
680+
681+
impl<const P: char, const N: u8> From<PX<Output<OpenDrain>, P, N>> for PX<Output<PushPull>, P, N> {
682+
#[inline(always)]
683+
fn from(f: PX<Output<OpenDrain>, P, N>) -> Self {
684+
f.into_push_pull_output()
685+
}
686+
}
687+
688+
impl<const P: char, const N: u8> From<PX<Analog, P, N>> for PX<Output<PushPull>, P, N> {
689+
#[inline(always)]
690+
fn from(f: PX<Analog, P, N>) -> Self {
691+
f.into_push_pull_output()
692+
}
693+
}
694+
695+
impl<MODE, const P: char, const N: u8> From<PX<Alternate<MODE>, P, N>>
696+
for PX<Output<PushPull>, P, N>
697+
{
698+
#[inline(always)]
699+
fn from(f: PX<Alternate<MODE>, P, N>) -> Self {
700+
f.into_push_pull_output()
701+
}
702+
}
703+
704+
impl<MODE, const P: char, const N: u8> From<PX<AlternateOD<MODE>, P, N>>
705+
for PX<Output<PushPull>, P, N>
706+
{
707+
#[inline(always)]
708+
fn from(f: PX<AlternateOD<MODE>, P, N>) -> Self {
709+
f.into_push_pull_output()
710+
}
711+
}
712+
713+
impl<MODE, const P: char, const N: u8> From<PX<Input<MODE>, P, N>> for PX<Analog, P, N> {
714+
#[inline(always)]
715+
fn from(f: PX<Input<MODE>, P, N>) -> Self {
716+
f.into_analog()
717+
}
718+
}
719+
720+
impl<MODE, const P: char, const N: u8> From<PX<Output<MODE>, P, N>> for PX<Analog, P, N> {
721+
#[inline(always)]
722+
fn from(f: PX<Output<MODE>, P, N>) -> Self {
723+
f.into_analog()
724+
}
725+
}
726+
727+
impl<MODE, const P: char, const N: u8> From<PX<Alternate<MODE>, P, N>> for PX<Analog, P, N> {
728+
#[inline(always)]
729+
fn from(f: PX<Alternate<MODE>, P, N>) -> Self {
730+
f.into_analog()
731+
}
732+
}
733+
734+
impl<MODE, const P: char, const N: u8> From<PX<AlternateOD<MODE>, P, N>> for PX<Analog, P, N> {
735+
#[inline(always)]
736+
fn from(f: PX<AlternateOD<MODE>, P, N>) -> Self {
737+
f.into_analog()
738+
}
739+
}
427740
impl<MODE, const P: char, const N: u8> PX<MODE, P, N> {
428741
/// Configures the pin to operate alternate mode
429742
pub fn into_alternate<const A: u8>(self) -> PX<Alternate<AF<A>>, P, N> {

0 commit comments

Comments
 (0)