Hallo Leute,
ich versuche mein UART mit printf einzubinden. Leider meldet es das der Type 'FILE' nicht findet, trotz das STDIO.h eingebunden ist.
Habt ihr eine Idee wo mein Fehler liegt?
------------------------------ ENGLISH -------------------------------------------
Hi guys,
I try to include my UART with printf. Unfortunately it reports that the type 'FILE' is not found, although STDIO.h is included.
Do you have any idea where my error is?
UART.h
#ifndef UART_H_ #define UART_H_ #ifndef BAUD #define BAUD 19200 #endif void UART_Init(void); int uartPutChar(char data, FILE *stream); char uartGetChar(void); //void uartPutString(const char *buffer); #endif /* UART_H_ */
UART.c
#include <avr/io.h> #include <avr/iom32.h> #include <stdlib.h> #include <stdio.h> #include "Clock.h" #include "UART.h" FILE mystdout = FDEV_SETUP_STREAM( uartPutChar, NULL, _FDEV_SETUP_WRITE ); void UART_Init() { UCSRB |= _BV(3); // TX aktiv UCSRB |= _BV(4); // RX aktivieren UBRRL=(uint8_t)(F_CPU/(BAUD*16L))-1; // Baudrate festlegen UBRRH=(uint8_t)((F_CPU/(BAUD*16L))-1)>>8; // Baudrate festlegen stdout = &mystdout; } //---------------------------------------------------------------------- // Titel : C-Funktion Zeichen zu UART senden. //---------------------------------------------------------------------- // Funktion : ... // IN : char data // OUT : ... //---------------------------------------------------------------------- int uartPutChar(char data, FILE *stream) { ////warte bis UDR leer ist UCSRA / USR bei z.B.: 2313 //while (!(UCSRA&32)); ////sende //UDR=data; if( data == '\n' ) uartPutChar( '\r', stream ); while (!(UCSRA&32)); UDR = data; return 0; } //---------------------------------------------------------------------- // Titel : C-Funktion Zeichen von UART holen. //---------------------------------------------------------------------- // Funktion : ... // IN : ... // OUT : data //---------------------------------------------------------------------- char uartGetChar() { char data=0; //warte bis RX-complete RXC UCSRA / USR bei z.B.: AT090S2313 while (!(UCSRA&128)); //empfangen data=UDR; return data; } //---------------------------------------------------------------------- // Titel : C-Funktion Zeichenkette zu UART senden. //---------------------------------------------------------------------- // Funktion : ... // IN : char *buffer, Zeichenkette mit NUll abgeschlossen // OUT : ... //---------------------------------------------------------------------- //void uartPutString(const char *buffer) //{ //for (int i=0; buffer[i] !=0;i++) //uartPutChar(buffer[i]); //}