preso na biblioteca i2cmaster

0

Eu quero tentar reparar minhas baterias com o código do hacker smbus sobre o arduino. primeiro foi tem alguns problemas. Eu tentei corrigi-los e eu corrigi. agora eu tenho problema na biblioteca

i2c\test_i2cmaster.c.o: In function main': C:\Users\ugur\Documents\Arduino\libraries\i2c/test_i2cmaster.c:22: multiple definition ofmain' i2c\main.c.o:C:\Users\ugur\Documents\Arduino\libraries\i2c/main.c:88: first defined here i2c\twimaster.c.o: In function i2c_init': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:31: multiple definition ofi2c_init' i2c\i2cmaster.S.o:(.text+0x10): first defined here i2c\twimaster.c.o: In function i2c_start': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:42: multiple definition ofi2c_start' i2c\i2cmaster.S.o:(.text+0x1a): first defined here i2c\twimaster.c.o: In function i2c_start_wait': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:78: multiple definition ofi2c_start_wait' i2c\i2cmaster.S.o:(.text+0x36): first defined here i2c\twimaster.c.o: In function i2c_rep_start': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:130: multiple definition ofi2c_rep_start' i2c\i2cmaster.S.o:(.text+0x22): first defined here i2c\twimaster.c.o: In function i2c_stop': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:141: multiple definition ofi2c_stop' i2c\i2cmaster.S.o:(.text+0x4a): first defined here i2c\twimaster.c.o: In function i2c_write': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:161: multiple definition ofi2c_write' i2c\i2cmaster.S.o:(.text+0x5a): first defined here i2c\twimaster.c.o: In function i2c_readAck': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:182: multiple definition ofi2c_readAck' i2c\i2cmaster.S.o:(.text+0x96): first defined here i2c\twimaster.c.o: In function i2c_readNak': C:\Users\ugur\Documents\Arduino\libraries\i2c/twimaster.c:197: multiple definition ofi2c_readNak' i2c\i2cmaster.S.o:(.text+0x92): first defined here

a biblioteca é;

ifndef F_CPU

define F_CPU 16000000UL

endif

incluir

incluir

define F_SCL 100000UL // frequência de SCL

define o Prescaler 1

define TWBR_val ((((F_CPU / F_SCL) / Prescaler) - 16) / 2)

void I2C_init (void) {     TWBR = TWBR_val; }

uint8_t I2C_start (endereço uint8_t) {     // reset do registro de controle do TWI     TWCR = 0;     // transmitir a condição START     TWCR = (1 <

// check if the start condition was successfully transmitted
if((TWSR & 0xF8) != TW_START){ return 1; }

// load slave address into data register
TWDR = address;
// start transmission of address
TWCR = (1<<TWINT) | (1<<TWEN);
// wait for end of transmission
while( !(TWCR & (1<<TWINT)) );

// check if the device has acknowledged the READ / WRITE mode
uint8_t twst = TW_STATUS & 0xF8;
if ( (twst != TW_MT_SLA_ACK) && (twst != TW_MR_SLA_ACK) ) return 1;

return 0;

}

void I2C_write (uint8_t data) {     // carrega dados no registro de dados     TWDR = dados;     // iniciar a transmissão de dados     TWCR = (1 <

if( (TWSR & 0xF8) != TW_MT_DATA_ACK ){ return 1; }

return 0;

}

uint8_t I2C_read_ack (void) {

// start TWI module and acknowledge data after reception
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); 
// wait for end of transmission
while( !(TWCR & (1<<TWINT)) );
// return received data from TWDR
return TWDR;

}

uint8_t I2C_read_nack (void) {

// start receiving without acknowledging reception
TWCR = (1<<TWINT) | (1<<TWEN);
// wait for end of transmission
while( !(TWCR & (1<<TWINT)) );
// return received data from TWDR
return TWDR;

}

void I2C_stop (void) {     // transmitir condição de parada     TWCR = (1 <

como eu posso consertar isso? Eu sou novo no arduino e c / c + +

    
por Uğur Kırçıl 05.04.2014 / 16:39

1 resposta

0

De qualquer forma, para usar outra biblioteca i2c? programa principal é este

link

    
por 06.04.2014 / 13:21

Tags