Skip to content

Commit

Permalink
Created a UART API definition in softuart.h to allow the example code…
Browse files Browse the repository at this point in the history
… to access printf() and scanf() functionality
  • Loading branch information
Roarin committed Jun 25, 2016
1 parent 0ddd377 commit dbba734
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions include/uart/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/** \file include/uart/api.h
* This file is for defining a common API for accessing UARTs.
**/

#ifndef UART_API_H
#define UART_API_H

#include "fx2types.h"
#include "stdarg.h"

/**
* \brief Initalizes UART.
* Returns TRUE if initialization is successful.
* \param Rate See uartX_set_baud()
**/
BOOL uartX_init(enum uart_baud rate, ...);

/**
* enum Standard available baud rates.
*
**/
enum uart_baud {
BAUD_FASTEST = -2,
BAUD_ANY = -1,
BAUD_INVALID = 0,
BAUD_2400 = 1,
BAUD_4800 = 2,
BAUD_9600 = 3,
BAUD_19200 = 4,
BAUD_38400 = 5,
BAUD_57600 = 6,
BAUD_115200 = 7
};

/**
* \brief Sets the UART baud rate to one of the allowed parameters.
* Possible Baud rates:
* \li 2400
* \li 4800
* \li 9600
* \li 19200
* \li 28800
* \li 38400
* \li 57600
* \li 115200
* Returns TRUE if successful.
**/
BOOL uartX_set_baud(enum uart_baud rate);

/**
* \brief Returns the baud rate currently being used.
**/
enum uart_baud uartX_get_baud();

/**
* \brief Transmits data through UART.
* \param c The character to be sent out.
**/

void uartX_tx(char c);

/**
* \brief Returns if the transmit is blocking or not.
* FALSE - Non Blocking
* TRUE - Blocking
**/

BOOL uartX_tx_will_block();

/**
* \brief Returns how many more bytes can be loaded into the buffer.
**/
BYTE uartX_tx_queue_len();

/**
* \brief Receives data through UART.
* Returns one byte at a time from the queue.
*
**/
char uartX_rx();

/**
* \brief Returns if the receive is blocking or not.
* FALSE - Non Blocking
* TRUE - Blocking
**/
BOOL uartX_rx_will_block();

/**
* \brief Returns count number of bytes present in the buffer.
*
**/
BYTE uartX_rx_queue_len();

#endif

0 comments on commit dbba734

Please sign in to comment.