Here is the init:
// initialize state
twi_state = TWI_READY;
// activate internal pullups for twi.
// initialize twi prescaler and bit rate
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
/* twi bit rate formula from atmega128 manual pg 204
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
note: TWBR should be 10 or higher for master mode
It is 72 for a 16mhz Wiring board with 100kHz TWI */
// enable twi module, acks, and twi interrupt
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
So according to the last line, init seems to do some TWEN, TWIE and TWEA bits but what is _BV? Bit value (macro)? Should I just do TWCR=0 to clear everything for the end()? Can someone confirm? Right now I am just forcing pinMode to the A4 and A5 and it works fine but I feel like I am doing the wrong thing.
I hate Arduino style of no end to begin. It’s a very amateurish approach, do one thing once and be happy, don’t expand into doing several things one at a time repeatedly for weeks without resetting. Like the DUE audio stuff, you can play one sample and no way to reset to do it again (as of a few months ago). :0