Hallo,

ich bin gerade dabei, für einen Kran mit 4 Motoren, die über zwei L293D Motortreiber angesteuert werden, eine eigene Library zu schreiben (auch wenns noch nicht so aussieht (siehe unten). Ich verwende die Control M32.

Ich konnte die Library zwar ohne Probleme im Makefile hinzufügen, sie wird auch compiliert, aber die Funktionen, die ich im Programm aus der Lib aufrufe, haben "implict declaration of funktion ...", wie es der Compiler formuliert. Es ist zwar kein Fehler, sondern nur eine Warnung, doch das Programm funktioniert nicht.

Library:
Code:
#include "RP6ControlLib.h"

//Funktions:

void initKran(void)
{
 DDRD |= IO_PD5; // Motor_1 Enable
 
 DDRC |= IO_PC2; // Motor_1 Eingang A
 DDRC |= IO_PC3; // Motor_1 Eingang B
 
 DDRC |= IO_PC4; // Motor_2 Enable
 DDRC |= IO_PC7; // Motor_2 Eingang A
 DDRC |= IO_PC5; // Motor_2 Eingang B
 
 DDRA |= ADC3;   // Motor_3 Enable
 DDRA |= ADC4;   // Motor_3 Eingang A
 DDRA |= ADC5;   // Motor_3 Eingang B
 
 DDRA |= ADC2;   // Motor_4 Enable
 DDRA |= ADC7;   // Motor_4 Eingang A
 DDRA |= ADC6;   // Motor_4 Eingang B
}

void setKranDirection(int motor, char direction)
{
  switch(motor)
  {
     case 1: 
	       if(direction == 'l')
	        {
	         PORTC |= IO_PC2;
	         PORTC &= ~IO_PC3;
	        }
	       else
	        {
	         PORTC |= IO_PC3;
		     PORTC &= ~IO_PC2;
		    }
	        break;
	     
	 case 2:
	       if(direction == 'l')
	        {
		     PORTC |= IO_PC7;
		     PORTC &= ~IO_PC5;
	     	}
	       else
	        {
		     PORTC |= IO_PC5;
			 PORTC &= ~IO_PC7;
		    }
			break;
			
	 case 3:
	       if(direction == 'l')
		    {
			 PORTA |= ADC4;
			 PORTA &= ~ADC5;
			}
		   else
		    {
			 PORTA |= ADC5;
			 PORTA &= ~ADC4;
			}
			break;
	       
	 case 4:
		   if(direction == 'l')
            {
             PORTA |= ADC7;
             PORTA &= ~ADC6;
			}
		   else
			{
			 PORTA |= ADC6;
			 PORTA &= ~ADC7;
		    }
	    
	    
  }
}
Programm:
Code:
#include "RP6ControlLib.h"

int main(void)
{
 initRP6Control();
 initKran();
 
 setKranDirection(1,'l');
 
 while(1);
 
 return 0;
}
Comilerausgabe:
Code:
> "E:\Daten\RP6\Programme\Eigene Programme\Kran\\make_all.bat" 

E:\Daten\RP6\Programme\Eigene Programme\Kran>set LANG=C 

E:\Daten\RP6\Programme\Eigene Programme\Kran>make all 

-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: Kran.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=Kran.lst -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/Kran.o.d Kran.c -o Kran.o
Kran.c: In function 'main':
Kran.c:6: warning: implicit declaration of function 'initKran'
Kran.c:8: warning: implicit declaration of function 'setKranDirection'
Kran.c:13:2: warning: no newline at end of file

Compiling: ../RP6lib/RP6control/RP6ControlLib.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=../RP6lib/RP6control/RP6ControlLib.lst -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/RP6ControlLib.o.d ../RP6lib/RP6control/RP6ControlLib.c -o ../RP6lib/RP6control/RP6ControlLib.o

Compiling: ../RP6lib/RP6common/RP6uart.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=../RP6lib/RP6common/RP6uart.lst -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/RP6uart.o.d ../RP6lib/RP6common/RP6uart.c -o ../RP6lib/RP6common/RP6uart.o

Compiling: ../RP6lib/Kran/Library.c
avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=../RP6lib/Kran/Library.lst -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/Library.o.d ../RP6lib/Kran/Library.c -o ../RP6lib/Kran/Library.o

Linking: Kran.elf
avr-gcc -mmcu=atmega32 -I. -gdwarf-2   -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=Kran.o -I../RP6lib -I../RP6lib/RP6control -I../RP6lib/RP6common -std=gnu99 -MD -MP -MF .dep/Kran.elf.d Kran.o ../RP6lib/RP6control/RP6ControlLib.o ../RP6lib/RP6common/RP6uart.o ../RP6lib/Kran/Library.o --output Kran.elf -Wl,-Map=Kran.map,--cref    -lm

Creating load file for Flash: Kran.hex
avr-objcopy -O ihex -R .eeprom Kran.elf Kran.hex

Creating Extended Listing: Kran.lss
avr-objdump -h -S Kran.elf > Kran.lss

Creating Symbol Table: Kran.sym
avr-nm -n Kran.elf > Kran.sym

Size after:
AVR Memory Usage
----------------
Device: atmega32

Program:    3244 bytes (9.9% Full)
(.text + .data + .bootloader)

Data:         90 bytes (4.4% Full)
(.data + .bss + .noinit)



-------- end --------


> Process Exit Code: 0
> Time Taken: 00:02
Ich hoffe, ihr könnt mir helfen!

lg
Michi