Expand description
Type-level tools to configure SERCOM pads
This module helps configure Pin
s as SERCOM pads. It provides type-level
tools to convert Pin
s to the correct PinMode
and to enforce type-level
constraints at compile-time.
§Overview
A SERCOM pad is defined by two types, its corresponding Sercom
instance
and its PadNum
, from Pad0
to Pad3
. However, a given SERCOM pad
can usually be mapped to several possible PinId
s.
There are two primary traits defined in this module:
- The
IsPad
trait is implemented onPin
types that are properly configured as SERCOM pads, withPinMode
AlternateC
orAlternateD
. It acts as both a type class for SERCOM pads and as a type-level function to recover the correspondingSercom
andPadNum
types from thePin
. - The
GetPad
trait maps eachPinId
to its corresponding, pad-related types. ThePadMode
alias usesGetPad
to recover the correspondingPinMode
for a given SERCOM pad, while thePad
alias recovers the configuredPin
type.
§IOSET (SAMD51/SAME5x only)
SAMx5x chips do not allow arbitrary combinations of PinId
for a given
SERCOM. Instead, all PinId
s must belong to the same IOSET. This module
defines a [type-level enum], IoSet
, to enforce this restriction, and the
InIoSet
type class is responsible for labeling each IsPad
type with
its corresponding, valid IoSet
(s).
Enums§
- Pad0
- Type-level variant of
PadNum
representing SERCOM pad 0 - Pad1
- Type-level variant of
PadNum
representing SERCOM pad 1 - Pad2
- Type-level variant of
PadNum
representing SERCOM pad 2 - Pad3
- Type-level variant of
PadNum
representing SERCOM pad 3 - Undoc
IoSet1 - This type is not present with the selected feature set, defined for documentation only
- Undoc
IoSet2 - This type is not present with the selected feature set, defined for documentation only
Traits§
- GetPad
- Type-level function mapping
PinId
s to SERCOM-pad-related types - InIoSet
- This trait is not present with the selected feature set, defined for documentation only
- IoSet
- This trait is not present with the selected feature set, defined for documentation only
- IsI2c
Pad - Type class for
Pin
s which can be used as I2C pads - IsPad
- Type class for
Pin
s configured as SERCOM pads - Optional
Pad - Type-level equivalent of
Option<Pad>
- Optional
PadNum - Type-level equivalent of
Option<PadNum>
- PadNum
- Type-level enum representing a SERCOM pad number
- SomePad
- Type-level equivalent of
Some(Pad)