X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=keyboard%2Fergodox%2Ftwimaster.c;h=f91c08e6e4e83ccd0fc570848d82845a43b0c9f5;hb=e56edbfe9007d13b37361b5c608cff631776627a;hp=6959d81c0e1661924f04d19d98dabf629800f801;hpb=777d1fba76c4c89b2e82ba6f62fb321f4ae68054;p=max%2Ftmk_keyboard.git diff --git a/keyboard/ergodox/twimaster.c b/keyboard/ergodox/twimaster.c index 6959d81c..f91c08e6 100644 --- a/keyboard/ergodox/twimaster.c +++ b/keyboard/ergodox/twimaster.c @@ -26,10 +26,16 @@ *************************************************************************/ void i2c_init(void) { - /* initialize TWI clock: 400 kHz clock, TWPS = 0 => prescaler = 1 */ + /* initialize TWI clock + * minimal values in Bit Rate Register (TWBR) and minimal Prescaler + * bits in the TWI Status Register should give us maximal possible + * I2C bus speed - about 444 kHz + * + * for more details, see 20.5.2 in ATmega16/32 secification + */ - TWSR = 0; /* no prescaler */ - TWBR = ((F_CPU/SCL_CLOCK)-16)/2; /* must be > 10 for stable operation */ + TWSR = 0; /* no prescaler */ + TWBR = 10; /* must be >= 10 for stable operation */ }/* i2c_init */