Potrzebuje odczytywać dane z przetwornika ADS1110. Jestem początkujący dlatego prosiłbym o jakieś proste rozwiązanie i wyrozumiałość.
Szukałem różnych bibliotek do obsługi I2C, ale niestety żadne rozwiązanie nie doszło do skutku. Wszystkie kończyły się stosem błędów wywalanych przez kompilator.
Sam napisałem jedynie coś takiego, ale wywala błędy zamieszone poniżej
błędy kompilacji
Szukałem różnych bibliotek do obsługi I2C, ale niestety żadne rozwiązanie nie doszło do skutku. Wszystkie kończyły się stosem błędów wywalanych przez kompilator.
Sam napisałem jedynie coś takiego, ale wywala błędy zamieszone poniżej
#include <avr/io.h>
#include <util/delay.h>
#include "avrlib/i2c.h"
int main(void)
{
DDRD = 0xFF;
i2cInit();
while(1)
{
i2cSendStart();
i2cReceiveByte(TRUE);
// dane z magistrali wyswietlam na diodach z portu D
PORTD = i2cGetReceivedByte();
i2cSendStop();
}
return 0;
}błędy kompilacji
Compiling C: main.c
avr-gcc -c -mmcu=atmega8 -I. -gstabs -DF_CPU=1000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o
In file included from avrlib/i2c.h:68,
from main.c:4:
./global.h:25:24: error: avrlibdefs.h: No such file or directory
./global.h:27:25: error: avrlibtypes.h: No such file or directory
./global.h:35:1: warning: "F_CPU" redefined
<command-line>: warning: this is the location of the previous definition
In file included from main.c:4:
avrlib/i2c.h:132: error: expected ')' before 'bitrateKHz'
avrlib/i2c.h:136: error: expected ')' before 'deviceAddr'
avrlib/i2c.h:139: error: expected ')' before 'receiveDataLength'
avrlib/i2c.h:139: warning: function declaration isn't a prototype
avrlib/i2c.h:141: error: expected ')' before '(' token
avrlib/i2c.h:151: error: expected ')' before 'data'
avrlib/i2c.h:155: error: expected ')' before 'ackFlag'
avrlib/i2c.h:157: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i2cGetReceivedByte'
avrlib/i2c.h:159: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i2cGetStatus'
avrlib/i2c.h:164: error: expected ')' before 'deviceAddr'
avrlib/i2c.h:166: error: expected ')' before 'deviceAddr'
avrlib/i2c.h:169: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i2cMasterSendNI'
avrlib/i2c.h:171: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'i2cMasterReceiveNI'
main.c: In function 'main':
main.c:18: warning: implicit declaration of function 'i2cReceiveByte'
main.c:18: error: 'TRUE' undeclared (first use in this function)
main.c:18: error: (Each undeclared identifier is reported only once
main.c:18: error: for each function it appears in.)
main.c:19: warning: implicit declaration of function 'i2cGetReceivedByte'
make.exe: *** [main.o] Error 1