UART on the Intel Edison

Using MRAA to access UART functionality

The MRAA library can be utilised to add UART functionality to C/C++ code on the Edison.

MRAA needs to be version 0.7.0 or later for read/write functionality to work. (Refer to –insert link– for instructions to verify/update the installed version of MRAA).

Sample code for initialising the UART context/functionality on the Intel Edison:

mraa_init();

mraa_uart_context uart;
uart = mraa_uart_init(0);

if (uart == NULL) {
        fprintf(stderr, "UART failed to setup\n");
        return EXIT_FAILURE;
}

//UART Settings
mraa_uart_set_baudrate(uart, 115200);
mraa_uart_set_mode(uart, 8,MRAA_UART_PARITY_NONE , 1);
mraa_uart_set_flowcontrol(uart, 0, 0);
mraa_uart_set_timeout(uart, 0, 0, 0);

The ‘0’ in mraa_uart_init(0) performs the UART initialisation on the UART1 bus. Changing this number to other indexes has yet to work, i.e. UART2 functionality has yet to be verified. (7/10/2015).

UART test code

The program “uart.test.c” is a very basic program to test and verify UART functionality on the Intel Edison. The basic operation of the code is as follows:

  1. Initialise MRAA on the Edison

  2. Initialise a UART context on the Edison with the following configuration

    • Edison UART Port: UART1
    • Baud rate: 115200
    • Parity: None
    • Data bits: 8bits
    • Stop bits: 1bit
    • Hardware flow control: None
  3. Write “H” onto the UART1 bus

  4. Wait to read a single byte on the UART1 bus

  5. Output the read single byte to the console (stdout)

  6. Write another “H” onto the UART1 bus

  7. Stop and deinitialise the UART context

The existing R02 Edi-Sound boards have been hardware modded to have UART1 present on the Raspberry PI Header.

Sending and receiving of the UART bytes can be done using:

  • Sparkfun FTDI basic:

    1. Ensure the Logic Level switch is in the correct voltage position (3V3 or 5V)
    2. Connect “Edison TX - FTDI Basic RX”, “Edison RX - FTDI Basic TX”, “Edison GND to FTDI Basic GND”

with...

  • RealTerm:

    1. Ensure the UART settings on the PORT tab match the settings in “uart_test.c” or custom uart context initialisation code
    2. Send numbers of characters with EOL as +CR

The UART has been used with Baud Rates of 9600, 115200. (7/10/2015)