#include #include #include #include "send.h" #include // init slave // // void init_twi_slave (uint8_t addr) { //DDRC = 0xff; // set slave addr to 1 // do not respond to general call TWAR = (addr<<1)|0; // enable twi interface and interrupt and acks TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA); TWCR |= TWSTO; } // recv data // // volatile uint8_t do_things; volatile uint8_t value; volatile uint8_t index; SIGNAL (SIG_2WIRE_SERIAL) { // grab the value value = TWDR; //if(value != 2) //reset if(TWSR == 0) TWCR |= TWSTO; send_byte (value); //send over the serial connection // do things //do_things = 1; // allow i2c to continue TWCR |= _BV(TWINT); //PORTC = 0xFF; } // print data // // int main (void) { init_twi_slave (1); send_init (); DDRB = 0xFF; sei (); do_things = 0; uint16_t sleep; uint8_t i; while (1) { PORTB = ~TWSR; if(TWSR == 0) TWCR |= TWSTO; } return 0; }