Skip to content

Commit 0524008

Browse files
outlandnishsandeepmistry
authored andcommitted
update compatibility mode for different F_CPU values
1 parent 9c8d057 commit 0524008

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

libraries/SPI/SPI.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,13 @@ extern SPIClass SPI1;
145145

146146
// For compatibility with sketches designed for AVR @ 16 MHz
147147
// New programs should use SPI.beginTransaction to set the SPI clock
148-
#if F_CPU == 16000000
149-
#define SPI_CLOCK_DIV2 2
150-
#define SPI_CLOCK_DIV4 4
151-
#define SPI_CLOCK_DIV8 8
152-
#define SPI_CLOCK_DIV16 16
153-
#define SPI_CLOCK_DIV32 32
154-
#define SPI_CLOCK_DIV64 64
155-
#define SPI_CLOCK_DIV128 128
156-
#endif
157-
148+
#ifdef F_CPU
149+
#define DIVISOR F_CPU / 16000000
150+
#define SPI_CLOCK_DIV2 2 * DIVISOR
151+
#define SPI_CLOCK_DIV4 4 * DIVISOR
152+
#define SPI_CLOCK_DIV8 8 * DIVISOR
153+
#define SPI_CLOCK_DIV16 16 * DIVISOR
154+
#define SPI_CLOCK_DIV32 32 * DIVISOR
155+
#define SPI_CLOCK_DIV64 64 * DIVISOR
156+
#define SPI_CLOCK_DIV128 128 * DIVISOR
158157
#endif

0 commit comments

Comments
 (0)