fix SPI CLOCK DIV with F_CPU @ 64MHz
This commit is contained in:
1 parent
ca4cbe9f79
commit
7a057bbad0
2 files changed
+12
-9
No files matched your search
@@ -188,17 +188,18 @@ void SPIClass::setClockDivider(uint8_t div)
|
||||
{
|
||||
uint32_t clockFreq;
|
||||
|
||||
if (div >= SPI_CLOCK_DIV128) {
|
||||
// Adafruit Note: nrf52 run at 64MHz
|
||||
if (div >= SPI_CLOCK_DIV512) {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_K125;
|
||||
} else if (div >= SPI_CLOCK_DIV64) {
|
||||
} else if (div >= SPI_CLOCK_DIV256) {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_K250;
|
||||
} else if (div >= SPI_CLOCK_DIV32) {
|
||||
} else if (div >= SPI_CLOCK_DIV128) {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_K500;
|
||||
} else if (div >= SPI_CLOCK_DIV16) {
|
||||
} else if (div >= SPI_CLOCK_DIV64) {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_M1;
|
||||
} else if (div >= SPI_CLOCK_DIV8) {
|
||||
} else if (div >= SPI_CLOCK_DIV32) {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_M2;
|
||||
} else if (div >= SPI_CLOCK_DIV4) {
|
||||
} else if (div >= SPI_CLOCK_DIV16) {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_M4;
|
||||
} else {
|
||||
clockFreq = SPI_FREQUENCY_FREQUENCY_M8;
|
||||
|
||||
+5
-3
@@ -137,9 +137,9 @@ void SPIClass::transfer(void *buf, size_t count)
|
||||
extern SPIClass SPI;
|
||||
#endif
|
||||
|
||||
// For compatibility with sketches designed for AVR @ 16 MHz
|
||||
// For compatibility with sketches designed for AVR @ 64 MHz
|
||||
// New programs should use SPI.beginTransaction to set the SPI clock
|
||||
#if F_CPU == 16000000
|
||||
#if F_CPU == 64000000 // feather52 run @ 64Mhz
|
||||
#define SPI_CLOCK_DIV2 2
|
||||
#define SPI_CLOCK_DIV4 4
|
||||
#define SPI_CLOCK_DIV8 8
|
||||
@@ -147,6 +147,8 @@ extern SPIClass SPI;
|
||||
#define SPI_CLOCK_DIV32 32
|
||||
#define SPI_CLOCK_DIV64 64
|
||||
#define SPI_CLOCK_DIV128 128
|
||||
#define SPI_CLOCK_DIV256 256
|
||||
#define SPI_CLOCK_DIV512 512
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user