1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

register and clock changes

This commit is contained in:
John Doe
2015-06-02 00:11:20 +03:00
parent 1501818c67
commit 6ab3c76e03
7 changed files with 67 additions and 49 deletions

View File

@ -121,14 +121,14 @@ void SPIClass::setBitOrder(uint8_t bitOrder) {
* @return
*/
static uint32_t ClkRegToFreq(spiClk_t * reg) {
return (SPI_MAX_SPEED / ((reg->regPre + 1) * (reg->regN + 1)));
return (ESP8266_CLOCK / ((reg->regPre + 1) * (reg->regN + 1)));
}
void SPIClass::setFrequency(uint32_t freq) {
static uint32_t lastSetFrequency = 0;
static uint32_t lastSetRegister = 0;
if(freq >= SPI_MAX_SPEED) {
if(freq >= ESP8266_CLOCK) {
setClockDivider(0x80000000);
return;
}
@ -164,7 +164,7 @@ void SPIClass::setFrequency(uint32_t freq) {
reg.regN = calN;
while(calPreVari++ <= 1) { // test different variants for Pre (we calculate in int so we miss the decimals, testing is the easyest and fastest way)
calPre = (((SPI_MAX_SPEED / (reg.regN + 1)) / freq) - 1) + calPreVari;
calPre = (((ESP8266_CLOCK / (reg.regN + 1)) / freq) - 1) + calPreVari;
if(calPre > 0x1FFF) {
reg.regPre = 0x1FFF; // 8191
} else if(calPre <= 0) {