7f7ba9accbce36eabadcd8a1a0437311ed848e5d
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

1) #include "uart.h"
2) 
3) static volatile unsigned char *const uart_ptr =
4)   (volatile unsigned char *)0x80000300;
5) 
6) /**
7)  * @brief configure baudrate scaler
8)  * @param[in] scale baudrate scaler (1 = 7.143 Mhz)
9)  */
10) void uart_cfg_scale(unsigned short scale)
11) {
12)   *(unsigned short *)(uart_ptr + 0) = scale;
13) }
14) 
15) /**
16)  * @brief configure number of data bits
17)  * @param[in] bits number of data bits
18)  */
19) void uart_cfg_bits(unsigned char bits)
20) {
21)   *(uart_ptr + 2) = bits;
22) }
23) 
24) /**
25)  * @brief configure number of stop bits
26)  * @param[in] stop number of stop bits
27)  */
28) void uart_cfg_stop(unsigned char stop)
29) {
30)   *(uart_ptr + 3) = stop;
31) }
32) 
33) /**
34)  * @brief transmit a character
35)  * @param[in] chr character to transmit
36)  */
37) void uart_tx(unsigned short chr)
38) {
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

39)   while (!*(uart_ptr + 4)); /* wait for ready */
40)   *(unsigned short *)(uart_ptr + 8) = chr; /* write data */
41) }
42) 
43) /**
44)  * @brief receive a character
45)  * @return character received
46)  */
47) unsigned short uart_rx(void)
48) {
49)   while (!*(uart_ptr + 5)); /* wait for data */
50)   unsigned short chr = *(unsigned short *)(uart_ptr + 12); /* read data */
51)   *(unsigned short *)(uart_ptr + 12) = 0; /* remove data from FIFO */
52)   return chr;