Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode added vscode tasks May 2, 2019

Hardware USART-library

This library currently only supports the arduino DUE hardware USART interface and a basic test interface for use with catch2

Including this library

When including this library, add these lines to your module's

#add USART_library
USART               ?= ../../../libraries/USART_library
include              $(USART)/

Though be sure you add those lines above these lines:

# Defer to the bmptk/ to do the work
include $(BMPTK)/

Then you'll be able to include the library like so in your project files: Note: always use the base class usart_connection_c as variable type and parameters for your classes, this way you can either use the test_usart_c for native applications or use the hardware_usart_c for embedded aplications

// include in class
#include <usart_connection.hpp>
// include in embedded main
#include <hardware_usart.hpp>
//include in catch/native main
#include <test_usart.hpp>

Using this library

When using this library it is first required you create an uartport like so

r2d2::usart_ports_c uart_port_one = r2d2::usart_ports_c::uart1;

uart1 corresponds to tx1 and rx1, uart2 to rx2 and tx2 etc. uart0 is also used for programming and communicating with the PC that's why it is not possible to use uart0 with this library.

To create and initialize a usart bus:

r2d2::hardware_usart_c usart_bus(9600, uart_port_one);

the first parameter is the baudrate, 9600 is used here as an example. Check which baudrate is applicable for you.

The bus can retreive and send chars with getc and putc

You can’t perform that action at this time.