Rev 28 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 28 | Rev 51 | ||
---|---|---|---|
1 | //############################################################################ |
1 | //############################################################################ |
2 | // - PPM2PentaxIR Uart for Debug only |
2 | // - PWM CTRL |
3 | // - ATMEGA8 mit 8MHz |
3 | // - ATMEGA8 mit 8MHz |
4 | // - Nur für den privaten Gebrauch |
4 | // - Nur für den privaten Gebrauch |
5 | // - Keine Garantie auf Fehlerfreiheit |
5 | // - Keine Garantie auf Fehlerfreiheit |
6 | // - Kommerzielle Nutzung nur mit meiner Zustimmung |
6 | // - Kommerzielle Nutzung nur mit meiner Zustimmung |
7 | // - walter Meyer @ www.freakware.de |
7 | // - walter Meyer @ www.freakware.de |
8 | //############################################################################*/ |
8 | //############################################################################*/ |
9 | 9 | ||
10 | #include "main.h" |
10 | #include "main.h" |
11 | #include "uart.h" |
11 | #include "uart.h" |
12 | 12 | ||
13 | void StartUART(void) |
13 | void StartUART(void) |
14 | { |
14 | { |
15 | 15 | ||
16 | // UART Double Speed (U2X) |
16 | // UART Double Speed (U2X) |
17 | UCSRA |= (1<<U2X); |
17 | UCSRA |= (1<<U2X); |
18 | /* Enable receiver and transmitter, no RX Int, no TX Int */ |
18 | /* Enable receiver and transmitter, no RX Int, no TX Int */ |
19 | UCSRB = (1<<RXEN)|(1<<TXEN); // (1<<RXCIE)|(1<<TXCIE) |
19 | UCSRB = (1<<RXEN)|(1<<TXEN); // (1<<RXCIE)|(1<<TXCIE) |
20 | /* Set frame format: 8data, 1stop bit */ |
20 | /* Set frame format: 8data, 1stop bit */ |
21 | UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); |
21 | UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); |
22 | 22 | ||
23 | //Teiler wird gesetzt |
23 | //Teiler wird gesetzt |
24 | UBRRL= (SYSCLK / (BAUD_RATE * 8L) -1 ); |
24 | UBRRL= (SYSCLK / (BAUD_RATE * 8L) -1 ); |
25 | 25 | ||
26 | //öffnet einen Kanal für printf (STDOUT) |
26 | //öffnet einen Kanal für printf (STDOUT) |
27 | fdevopen (uart_putchar, NULL); |
27 | fdevopen (uart_putchar, NULL); |
28 | 28 | ||
29 | } |
29 | } |
30 | 30 | ||
31 | int uart_putchar (char c) |
31 | int uart_putchar (char c) |
32 | { |
32 | { |
33 | if (c == '\n') uart_putchar('\r'); |
33 | if (c == '\n') uart_putchar('\r'); |
34 | loop_until_bit_is_set(UCSRA, UDRE); |
34 | loop_until_bit_is_set(UCSRA, UDRE); |
35 | UDR = c; |
35 | UDR = c; |
36 | 36 | ||
37 | return (0); |
37 | return (0); |
38 | } |
38 | } |
39 | 39 |