Skip to content

Commit 075d0ab

Browse files
committed
Created a UART API definition in softuart.h to allow the example code to access printf() and scanf() functionality
1 parent 0ddd377 commit 075d0ab

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

include/uart/api.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/** \file include/uart/api.h
2+
* This file is for defining a common API for accessing UARTs.
3+
* Defines top level functions which the printf and scanf access.
4+
**/
5+
6+
#ifndef FX2_UART
7+
#define FX2_UART
8+
9+
#include "fx2types.h"
10+
11+
/**
12+
* \brief initalizes UART.
13+
* This function accepts mask for rx and tx.Returns 0 if successful.
14+
* \param tx_pin The pin to which the UART_TX routine must be attached
15+
* \param rx_pin The pin to which the UART_RX routine must be attached
16+
**/
17+
BOOL uartX_init (enum pins_fx2 tx_pin, enum pins_fx2 rx_pin) __critical;
18+
19+
/**
20+
* \brief Sets the UART baud rate to one of the allowed parameters.
21+
* Possible Baud rates:
22+
* \li 2400
23+
* \li 4800
24+
* \li 9600
25+
* \li 19200
26+
* \li 28800
27+
* \li 38400
28+
* \li 57600
29+
* \li 115200
30+
* Returns 0 if successful.
31+
**/
32+
BOOL uartX_set_baud (enum uart_baud rate);
33+
34+
/**
35+
* \brief transmits data through UART
36+
* \param c The character to be sent out
37+
**/
38+
39+
void uartX_transmit(char c);
40+
41+
/**
42+
* \brief Returns if the transmit is blocking or not
43+
* 0 - Non Blocking
44+
* 1 - Blocking
45+
**/
46+
47+
BOOL uartX_check_blocking(char c);
48+
49+
/**
50+
* \brief receives data through UART.
51+
* Returns one byte at a time from the queue
52+
*
53+
**/
54+
char uartX_receive ();
55+
56+
/**
57+
* \brief Returns count number of bytes present in the buffer
58+
*
59+
**/
60+
unsigned char uartX_check_receive_buffer ();
61+
62+
/**
63+
* enum used for easy access for baud rate selection.
64+
*
65+
**/
66+
enum uart_baud { U_2400, U_4800, U_9600, U_19200, U_38400, U_57600, U_115200 };
67+
68+
/**
69+
* enum used for easy access to fx2 pins
70+
*
71+
**/
72+
enum pins_fx2 { PA_0,PA_1,PA_2,PA_3,PA_4,PA_5,PA_6,PA_7,
73+
PB_0,PB_1,PB_2,PB_3,PB_4,PB_5,PB_6,PB_7,
74+
PD_0,PD_1,PD_2,PD_3,PD_4,PD_5,PD_6,PD_7
75+
};
76+
77+
#endif

0 commit comments

Comments
 (0)