Skip to content

Commit 3083e9c

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 3083e9c

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

include/uart/api.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 uartX_init accepts the baud_rate and the mask.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 , and blocks till complete.
36+
* uartX_transmit_blocking(char c) blocks until the character
37+
* has been transmitted out.
38+
**/
39+
40+
void uartX_transmit(char c);
41+
42+
/**
43+
* \brief Returns if the transmit is blocking or not
44+
* 0 - Non Blocking
45+
* 1 - Blocking
46+
**/
47+
48+
BOOL uartX_check_blocking(char c);
49+
50+
/**
51+
* \brief receives data through UART.
52+
* Returns one byte at a time from the queue
53+
*
54+
**/
55+
char uartX_receive ();
56+
57+
/**
58+
* \brief Returns count number of bytes present in the buffer
59+
*
60+
**/
61+
unsigned char uartX_check_receive_buffer ();
62+
63+
/**
64+
* enum used for easy access for baud rate selection.
65+
*
66+
**/
67+
enum uart_baud { U_2400, U_4800, U_9600, U_19200, U_38400, U_57600, U_115200 };
68+
69+
/**
70+
* enum used for easy access to fx2 pins
71+
*
72+
**/
73+
enum pins_fx2 { PA_0,PA_1,PA_2,PA_3,PA_4,PA_5,PA_6,PA_7,
74+
PB_0,PB_1,PB_2,PB_3,PB_4,PB_5,PB_6,PB_7,
75+
PD_0,PD_1,PD_2,PD_3,PD_4,PD_5,PD_6,PD_7
76+
};
77+
78+
#endif

0 commit comments

Comments
 (0)