Skip to content

Commit 57b4b0e

Browse files
committed
Removing hardcoded CPU speed from Wire library.
Replacing CPU_FREQ with F_CPU.
1 parent 1747292 commit 57b4b0e

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

libraries/Wire/utility/twi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void twi_init(void)
7979
// initialize twi prescaler and bit rate
8080
cbi(TWSR, TWPS0);
8181
cbi(TWSR, TWPS1);
82-
TWBR = ((CPU_FREQ / TWI_FREQ) - 16) / 2;
82+
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
8383

8484
/* twi bit rate formula from atmega128 manual pg 204
8585
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))

libraries/Wire/utility/twi.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424

2525
//#define ATMEGA8
2626

27-
#ifndef CPU_FREQ
28-
#define CPU_FREQ 16000000L
29-
#endif
30-
3127
#ifndef TWI_FREQ
3228
#define TWI_FREQ 100000L
3329
#endif

0 commit comments

Comments
 (0)