Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
66d33f79
Commit
66d33f79
authored
Dec 18, 2018
by
me-no-dev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for CPU Frequency switching
Experimental!
parent
0de0d3f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
cores/esp32/esp32-hal-misc.c
cores/esp32/esp32-hal-misc.c
+26
-3
cores/esp32/esp32-hal.h
cores/esp32/esp32-hal.h
+3
-0
No files found.
cores/esp32/esp32-hal-misc.c
View file @
66d33f79
...
...
@@ -25,6 +25,7 @@
#include "esp_bt.h"
#endif //CONFIG_BT_ENABLED
#include <sys/time.h>
#include "soc/rtc.h"
#include "esp32-hal.h"
//Undocumented!!! Get chip temperature in Farenheit
...
...
@@ -41,19 +42,41 @@ void yield()
vPortYield
();
}
static
uint32_t
_cpu_freq_mhz
=
240
;
bool
cpuFrequencySet
(
uint32_t
cpu_freq_mhz
){
if
(
_cpu_freq_mhz
==
cpu_freq_mhz
){
return
true
;
}
rtc_cpu_freq_config_t
conf
;
if
(
!
rtc_clk_cpu_freq_mhz_to_config
(
cpu_freq_mhz
,
&
conf
)){
log_e
(
"CPU clock could not be set to %u MHz"
,
cpu_freq_mhz
);
return
false
;
}
rtc_clk_cpu_freq_set_config
(
&
conf
);
_cpu_freq_mhz
=
conf
.
freq_mhz
;
return
true
;
}
uint32_t
cpuFrequencyGet
(){
rtc_cpu_freq_config_t
conf
;
rtc_clk_cpu_freq_get_config
(
&
conf
);
return
conf
.
freq_mhz
;
}
unsigned
long
IRAM_ATTR
micros
()
{
return
(
unsigned
long
)
esp_timer_get_time
(
);
return
(
unsigned
long
)
(
esp_timer_get_time
()
*
(
240
/
_cpu_freq_mhz
)
);
}
unsigned
long
IRAM_ATTR
millis
()
{
return
(
unsigned
long
)
(
esp_timer_get_time
()
/
1000
);
return
(
unsigned
long
)
(
micros
()
/
1000
);
}
void
delay
(
uint32_t
ms
)
{
vTaskDelay
(
ms
/
portTICK_PERIOD_MS
);
vTaskDelay
(
ms
/
portTICK_PERIOD_MS
/
(
240
/
_cpu_freq_mhz
)
);
}
void
IRAM_ATTR
delayMicroseconds
(
uint32_t
us
)
...
...
cores/esp32/esp32-hal.h
View file @
66d33f79
...
...
@@ -72,6 +72,9 @@ void yield(void);
//returns chip temperature in Celsius
float
temperatureRead
();
bool
cpuFrequencySet
(
uint32_t
cpu_freq_mhz
);
uint32_t
cpuFrequencyGet
();
unsigned
long
micros
();
unsigned
long
millis
();
void
delay
(
uint32_t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment