Struct grand_central_m4::sercom::v2::uart::Config [−][src]
Expand description
A configurable, disabled UART peripheral
This struct
represents a configurable UART peripheral in its disabled
state. It is generic over the set of Pads
and CharSize
.
Upon creation, the Config
takes ownership of the
Sercom
and resets it, returning it configured as an UART peripheral
with a default configuration:
EightBit
- No parity
- One stop bit
- LSB-first
Config
uses a builder-pattern API to configure the peripheral,
culminating in a call to enable
, which consumes the Config
and
returns enabled Uart
. The enable
method is
restricted to ValidConfig
s.
Implementations
Create a new Config
in the default configuration
This function will enable the corresponding APB clock, reset the
Sercom
peripheral, and return a Config
in the default
configuration:
Config
takes ownership of the Sercom
and Pads
.
Users must configure GCLK manually. The freq
parameter represents the
GCLK frequency for this Sercom
instance.
Change the CharSize
.
Change the CharSize
to DynCharSize
. The UART’s character
size will be changed to the default CharSizeEnum::EightBit
, and can
then be changed dynamically on an enabled Uart
without changing
the underlying Config
’s type through the [reconfigure
](Uart::
reconfigure) method.
Change the bit order of transmission (builder pattern version)
Change the bit order of transmission (setter version)
Get the current bit order
Change the parity setting (builder pattern version)
Change the parity setting (setter version)
Get the current parity setting
Change the stop bit setting (builder pattern version)
Change the stop bit setting (setter version)
Get the current stop bit setting
Enable or disable the start of frame detector (builder pattern version)
When set, the UART will generate interrupts for RXC and/or RXS if these interrupt flags have been enabled.
Enable or disable the start of frame detector (setter version)
When set, the UART will generate interrupts for RXC and/or RXS if these interrupt flags have been enabled.
Get the current SOF detector setting
Enable or disable the collision detector (builder pattern version)
When set, the UART will detect collisions and update the corresponding flag in the STATUS register.
Enable or disable the collision detector (setter version)
When set, the UART will detect collisions and update the corresponding flag in the STATUS register.
Get the current collision detector setting
Set the baud rate (builder pattern version)
This function will calculate the best BAUD register setting based on the stored GCLK frequency and desired baud rate. The maximum baud rate is GCLK frequency/oversampling. Values outside this range will saturate at the maximum supported baud rate.
Note that 3x oversampling is not supported.
Set the baud rate (setter version)
This function will calculate the best BAUD register setting based on the stored GCLK frequency and desired baud rate. The maximum baud rate is GCLK frequency/oversampling. Values outside this range will saturate at the maximum supported baud rate.
Note that 3x oversampling is not supported.
Get the contents of the BAUD
register and the current baud mode. Note
that only the CONTENTS of BAUD
are returned, and not the actual baud
rate. Refer to the datasheet to convert the BAUD
register contents
into a baud rate.
Control the buffer overflow notification (builder pattern version)
If set to true, an Error::Overflow
will be
issued as soon as an overflow occurs. Otherwise, it will not be
issued until its place within the data stream.
Control the buffer overflow notification (setter version)
If set to true, an Error::Overflow
will be
issued as soon as an overflow occurs. Otherwise, it will not be
issued until its place within the data stream.
Get the current immediate overflow notification setting
Run in standby mode (builder pattern version)
When set, the UART peripheral will run in standby mode. See the datasheet for more details.
Run in standby mode (setter version)
When set, the UART peripheral will run in standby mode. See the datasheet for more details.
Get the current run in standby mode
Enable or disable IrDA encoding (builder pattern version)
The pulse length controls the minimum pulse length that is required for a pulse to be accepted by the IrDA receiver with regards to the serial engine clock period. See datasheet for more information.
Enable or disable IrDA encoding (setter version)
The pulse length controls the minimum pulse length that is required for a pulse to be accepted by the IrDA receiver with regards to the serial engine clock period. See datasheet for more information.
Get the current IrDA encoding setting. The return type is the pulse
length wrapped in an Option
.
Dynamically change the character size
Get the current character size setting
Enable the UART peripheral and return a Uart
struct.
UART transactions are not possible until the peripheral is enabled.
This method is limited to ValidConfig
s