File tree 2 files changed +5
-3
lines changed
hardware/esp8266com/esp8266/libraries/SPI
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -121,14 +121,14 @@ void SPIClass::setBitOrder(uint8_t bitOrder) {
121
121
* @return
122
122
*/
123
123
static uint32_t ClkRegToFreq (spiClk_t * reg) {
124
- return (F_CPU / ((reg->regPre + 1 ) * (reg->regN + 1 )));
124
+ return (SPI_MAX_SPEED / ((reg->regPre + 1 ) * (reg->regN + 1 )));
125
125
}
126
126
127
127
void SPIClass::setFrequency (uint32_t freq) {
128
128
static uint32_t lastSetFrequency = 0 ;
129
129
static uint32_t lastSetRegister = 0 ;
130
130
131
- if (freq >= F_CPU ) {
131
+ if (freq >= SPI_MAX_SPEED ) {
132
132
setClockDivider (0x80000000 );
133
133
return ;
134
134
}
@@ -164,7 +164,7 @@ void SPIClass::setFrequency(uint32_t freq) {
164
164
reg.regN = calN;
165
165
166
166
while (calPreVari++ <= 1 ) { // test different variants for Pre (we calculate in int so we miss the decimals, testing is the easyest and fastest way)
167
- calPre = (((F_CPU / (reg.regN + 1 )) / freq) - 1 ) + calPreVari;
167
+ calPre = (((SPI_MAX_SPEED / (reg.regN + 1 )) / freq) - 1 ) + calPreVari;
168
168
if (calPre > 0x1FFF ) {
169
169
reg.regPre = 0x1FFF ; // 8191
170
170
} else if (calPre <= 0 ) {
Original file line number Diff line number Diff line change 45
45
#define SPI_CLOCK_DIV64 0x04fc1001 // 250 KHz
46
46
#endif
47
47
48
+ #define SPI_MAX_SPEED (80000000L )
49
+
48
50
const uint8_t SPI_MODE0 = 0x00 ; // /< CPOL: 0 CPHA: 0
49
51
const uint8_t SPI_MODE1 = 0x01 ; // /< CPOL: 0 CPHA: 1
50
52
const uint8_t SPI_MODE2 = 0x10 ; // /< CPOL: 1 CPHA: 0
You can’t perform that action at this time.
0 commit comments