Hallo!
Ich habe hier ein Programm für die serielle Schnittstelle nur leider kann ich es nicht übersetzen, auch wenn ich allen code rauskommentiere. Es erscheint diese Fehlermeldung:
Code:
Linking: main.elf
avr-gcc -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o -std=gnu99 -Wundef -MMD -MP -MF .dep/main.elf.d main.o --output main.elf -Wl,-Map=main.map,--cref -lm
c:/programme/winavr-20070525/bin/../lib/gcc/avr/4.1.2/../../../../avr/lib/avr5/crtm32.o: In function `__vectors':
../../../../../avr-libc-1.4.6/crt1/gcrt1.S:51: undefined reference to `main'
make: *** [main.elf] Error 1
Meine Suchen im Forum ergaben, dass ich vergessen habe eine Datei im Makefile zu linken. Nur welche?
Das ist mein Code:
Code:
/////////////////////////////////////////////////////////////////////
// Arios: Serial Interface functions //
/////////////////////////////////////////////////////////////////////
// Author: Johannes Neumann //
// Date of completion: **.**.**** //
/////////////////////////////////////////////////////////////////////
// Defines //////////////////////////////////////////////////////////
#include <avr/interrupt.h>
#include <avr/io.h>
//#include <avr/signal.h>
#include <string.h>
#define cReadBufferSize 32
#define cWriteBufferSize 512
#define cBlockung 1
#define cNonBlocking 0
#define cTXComplete 1;
#define cTXNotComplete 0;
// Variables ////////////////////////////////////////////////////////
volatile unsigned int TXComplete;
volatile unsigned int WritePointer0 = 0, WritePointer1 = 0;
volatile unsigned int ReadPointer0 = 0, ReadPointer1 = 0;
volatile unsigned char ReadBuffer[cReadBufferSize];
volatile unsigned char WriteBuffer[cWriteBufferSize];
// Init /////////////////////////////////////////////////////////////
void RS232_init(long unsigned int baudrate) {
UCSRA = 0x00;
UCSRB = (1 << RXCIE) | (1 << RXEN);
UCSRC = (1 << UCSZ1) | (1 << UCSZ0) | (1 << URSEL);
UBRRH = (((F_CPU/baudrate) >> 4) - 1) >> 8;
UBRRL = (((F_CPU/baudrate) >> 4) - 1) & 0xFF;
TXComplete = cTXComplete;
}
// Send /////////////////////////////////////////////////////////////
int RS232_send(char *c, int blocking) {
int i;
for (i=0; i< strlen(c);i++) {
if ((cWriteBufferSize + WritePointer1 - WritePointer0) % cWriteBufferSize >
(cWriteBufferSize - 2)) {
if (blocking) {
while((cWriteBufferSize + WritePointer1 - WritePointer0) % cWriteBufferSize >
(cWriteBufferSize - 2));
}
else
return i;
}
TXComplete = cTXComplete;
asm("cli");
WriteBuffer[WritePointer1++] = c[i];
if (WritePointer1 > cWriteBufferSize - 1) WritePointer1 = 0;
asm("sei");
UCSRB = (1<<TXEN) | (1<<UDRIE);
}
return i;
}
// Receive //////////////////////////////////////////////////////////
int RS232_receive(char *c, int length, int blocking) {
int i;
for (i=0; i<length; i++) {
if (ReadPointer0 == ReadPointer1) {
if (blocking) while(ReadPointer0 == ReadPointer1);
else return i;
}
c[i] = ReadBuffer[ReadPointer1++];
if (ReadPointer1 > cReadBufferSize - 1) ReadPointer1 = 0;
}
return length;
}
// Complete? ////////////////////////////////////////////////////////
int RS232_WritingComplete(void) {
return TXComplete;
}
// Count of Bytes in ReadBuffer /////////////////////////////////////
int RS232_GetBytesInReadBuffer(void) {
return (cReadBufferSize + ReadPointer1-ReadPointer0) % cReadBufferSize;
}
// Count of Bytes in WriteBuffer ////////////////////////////////////
int RS232_GetBytesInWriteBuffer(void) {
return (cWriteBufferSize + WritePointer1-WritePointer0) % cWriteBufferSize;
}
// Interrupt for Reading ////////////////////////////////////////////
SIGNAL (SIG_UART_RECV) {
ReadBuffer[ReadPointer0++] = UDR;
if (ReadPointer0 > cReadBufferSize) ReadPointer0 = 0;
}
// Interrupt for writing Data into UDR //////////////////////////////
SIGNAL (SIG_UART_DATA) {
UDR = WriteBuffer[WritePointer0++];
if (WritePointer0 < cWriteBufferSize - 1) WritePointer0 = 0;
if (WritePointer0 == WritePointer1) UCSRB = (1<<TXEN) | (1<<TXCIE);
}
// Interrupt for setting Complete-Flag //////////////////////////////
SIGNAL (SIG_UART_TRANS) {
UCSRB = (1<<RXCIE) | (1<<RXEN);
TXComplete = cTXComplete;
}
Danke,
Bääääär
Lesezeichen