forked from djmuhlestein/fx2lib
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a UART API definition in softuart.h to allow the example code…
… to access printf() and scanf() functionality
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** \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 uartX_init accepts the baud_rate and the mask.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 , and blocks till complete. | ||
* uartX_transmit_blocking(char c) blocks until the character | ||
* has been transmitted 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 |