Вот цитата их хелпа CAVR:
Цитата
For devices with 2 UARTs, respectively 2 USARTs, there will be two tabs present: UART0 and UART1, respectively USART0 and USART1.
The functions of configuration check and list boxes will be the same as described above.
The UART0 (USART0) will use the normal putchar and getchar functions.
In case of interrupt driven buffered communication, UART0 (USART0) will use the following variables:
rx_buffer0, rx_wr_index0, rx_rd_index0, rx_counter0, rx_buffer_overflow0,
tx_buffer0, tx_wr_index0, tx_rd_index0, tx_counter0.
The UART1 (USART1) will use the putchar1 and getchar1 functions.
In case of interrupt driven buffered communication, UART1 (USART1) will use the following variables:
rx_buffer1, rx_wr_index1, rx_rd_index1, rx_counter1, rx_buffer_overflow1,
tx_buffer1, tx_wr_index1, tx_rd_index1, tx_counter1.
Цитата
If you intend to use other peripherals for Input/Output, you must modify accordingly the getchar and putchar functions like in the example below:
/* inform the compiler that an alternate version
of the putchar function will be used */
#define _ALTERNATE_PUTCHAR_
/* now define the new putchar function */
void putchar(char c) {
/* write your code here */
}
Цитата
For the ATxmega chips the getchar and putchar functions use by default the USARTC0.
If you wish to use another USART, you must define the _ATXMEGA_USART_ preprocessor macro prior to #include the stdio.h header file, like in the example below:
/* use the ATxmega128A1 USARTD0 for getchar and putchar functions */
#define _ATXMEGA_USART_ USARTD0
/* use the Standard C I/O functions */
#include <stdio.h>
The _ATXMEGA_USART_ macro needs to be defined only once in the whole program, as the compiler will treat it like it is globally defined
Цитата
void printf(char flash *fmtstr [ , arg1, arg2, ...])
outputs formatted text, using putchar, according to the format specifiers in the fmtstr string.
Дальше либо шаманство с перегрузкой, либо просто добавить в своей putchar() проверку, куда отправляются данные, и вызывать соответствующую функция. Сделать можно, к примеру, установкой глобальной переменной uart_number.
Сообщение отредактировал Savrik - Feb 14 2010, 11:36