c2b040193a777c09bdc595c95492b57a2521db87
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

1) /* MIPS I system
2)  * Copyright 2011-2012 Stefan Schuermans <stefan@schuermans.info>
3)  * Copyleft GNU public license V2 or later
4)  *          http://www.gnu.org/copyleft/gpl.html
5)  */
6) 
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

39) /**
40)  * @brief check if transmitting a character is possible
41)  * @return if transmitting a character is possible
42)  */
43) int uart_can_tx(void)
44) {
45)   return *(uart_ptr + 4);
46) }
47) 
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

48) /**
49)  * @brief transmit a character
50)  * @param[in] chr character to transmit
51)  */
52) void uart_tx(unsigned short chr)
53) {
Stefan Schuermans add read_enable signal to d...

Stefan Schuermans authored 12 years ago

54)   while (!*(uart_ptr + 4));
55)   *(unsigned short *)(uart_ptr + 8) = chr;
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

56) }
57) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

58) /**
59)  * @brief check if receiving a character is possible
60)  * @return if receiving a character is possible
61)  */
62) int uart_can_rx(void)
63) {
64)   return *(uart_ptr + 5);
65) }
66) 
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

67) /**
68)  * @brief receive a character
69)  * @return character received
70)  */
71) unsigned short uart_rx(void)
72) {
Stefan Schuermans add read_enable signal to d...

Stefan Schuermans authored 12 years ago

73)   while (!*(uart_ptr + 5));
74)   unsigned short chr = *(unsigned short *)(uart_ptr + 12);
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

75)   return chr;
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

76) }
77)