22b456946e289c89da296dcaceeb18de71761713
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) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

33) /**
34)  * @brief check if transmitting a character is possible
35)  * @return if transmitting a character is possible
36)  */
37) int uart_can_tx(void)
38) {
39)   return *(uart_ptr + 4);
40) }
41) 
Stefan Schuermans implemented TX part of UART...

Stefan Schuermans authored 12 years ago

42) /**
43)  * @brief transmit a character
44)  * @param[in] chr character to transmit
45)  */
46) void uart_tx(unsigned short chr)
47) {
Stefan Schuermans add read_enable signal to d...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

50) }
51) 
Stefan Schuermans UART firmware for testing i...

Stefan Schuermans authored 12 years ago

52) /**
53)  * @brief check if receiving a character is possible
54)  * @return if receiving a character is possible
55)  */
56) int uart_can_rx(void)
57) {
58)   return *(uart_ptr + 5);
59) }
60) 
Stefan Schuermans added FIFO to UART RX

Stefan Schuermans authored 12 years ago

61) /**
62)  * @brief receive a character
63)  * @return character received
64)  */
65) unsigned short uart_rx(void)
66) {
Stefan Schuermans add read_enable signal to d...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

70) }
71)