Electronics

DIT Adafruit FeatherM0 RS232 Library

The source code can be found on GitHub.

2017-06-05 09:42

This library provides:

See the 02_RS232 tutorial for a demo on how to use the library.

Adafruit_FeatherM0_RS232.h

Adafruit_FeatherM0_RS232.c

RS232_cofigure()

In lines 43..65 we find the function RS232_configure() that configures SERCOM0 of an Atmel ATSAMD21G18A MCU for RS232 communication.

All this pad and pinmux voodoo comes from the fact, that modern MCUs have more function-blocks than they have pins available to connect them all to the outside world.

Since usually not all the function-blocks are needed for every application the MCU designers work around that by connecting the pins to more than one MCU function-block using pin-multiplexing (pinumx). During the initialization of the MCU the application designer can connect the function-blocks in- and outputs (pads) to the pins they want them use to communicate to the outside world.

RS232_configure_callback()

In lines 70..81 we find the function RS232_configure_callback() that assigns a callback function to an USART callback event and enables the callback if a function is assigned.

Callback functions are called by the ASF USART module, for example:

There are a couple of other events you can attach a callback function to (see usart.h: enum usart_callback), depending on you application's needs.

RS232_enable()

In lines 86..90 we find the function RS232_enable() that enables the USART.

There is nothing fancy here. We just call the usart library function. This function only exists to have a complete RS232 API.