diff --git a/include/uart/api.h b/include/uart/api.h new file mode 100644 index 0000000..f89dd4d --- /dev/null +++ b/include/uart/api.h @@ -0,0 +1,77 @@ +/** \file include/uart/api.h + * This file is for defining a common API for accessing UARTs. + * Defines top level functions which the printf and scanf access. + **/ + +#ifndef FX2_UART +#define FX2_UART + +#include "fx2types.h" + +/** + * \brief initalizes UART. + * This function accepts mask for rx and tx.Returns 0 if successful. + * \param tx_pin The pin to which the UART_TX routine must be attached + * \param rx_pin The pin to which the UART_RX routine must be attached + **/ +BOOL uartX_init (enum pins_fx2 tx_pin, enum pins_fx2 rx_pin) __critical; + +/** + * \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 0 if successful. +**/ +BOOL uartX_set_baud (enum uart_baud rate); + +/** + * \brief transmits data through UART + * \param c The character to be sent out +**/ + +void uartX_transmit(char c); + +/** + * \brief Returns if the transmit is blocking or not + * 0 - Non Blocking + * 1 - Blocking +**/ + +BOOL uartX_check_blocking(char c); + +/** + * \brief receives data through UART. + * Returns one byte at a time from the queue + * +**/ +char uartX_receive (); + +/** + * \brief Returns count number of bytes present in the buffer + * +**/ +unsigned char uartX_check_receive_buffer (); + +/** + * enum used for easy access for baud rate selection. + * +**/ +enum uart_baud { U_2400, U_4800, U_9600, U_19200, U_38400, U_57600, U_115200 }; + +/** + * enum used for easy access to fx2 pins + * +**/ +enum pins_fx2 { PA_0,PA_1,PA_2,PA_3,PA_4,PA_5,PA_6,PA_7, + PB_0,PB_1,PB_2,PB_3,PB_4,PB_5,PB_6,PB_7, + PD_0,PD_1,PD_2,PD_3,PD_4,PD_5,PD_6,PD_7 + }; + +#endif