summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266
diff options
context:
space:
mode:
authorJosef Gajdusek <atx@atx.name>2015-05-15 09:56:41 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-05-28 21:28:29 +0300
commit492fd5cb6b8fcb8c88f238b20c28ca0bb2a1a84c (patch)
tree0205b77d8b55ff2e13beefb17dba14efc0e7f4b2 /esp8266
parenta16715ac623dccd66b1a113af255811bf92286e8 (diff)
downloadmicropython-492fd5cb6b8fcb8c88f238b20c28ca0bb2a1a84c.tar.gz
micropython-492fd5cb6b8fcb8c88f238b20c28ca0bb2a1a84c.zip
esp8266: Enable setting CPU frequency to 160MHz
Diffstat (limited to 'esp8266')
-rw-r--r--esp8266/esp_mphal.c4
-rw-r--r--esp8266/etshal.h1
-rw-r--r--esp8266/modpyb.c10
3 files changed, 8 insertions, 7 deletions
diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c
index 8eb8cc8ca2..736cf3b0a2 100644
--- a/esp8266/esp_mphal.c
+++ b/esp8266/esp_mphal.c
@@ -93,7 +93,3 @@ void HAL_Delay(uint32_t Delay) {
void mp_hal_set_interrupt_char(int c) {
// TODO
}
-
-uint32_t mp_hal_get_cpu_freq(void) {
- return ets_get_cpu_frequency();
-}
diff --git a/esp8266/etshal.h b/esp8266/etshal.h
index 5ee67d027f..61d8399db7 100644
--- a/esp8266/etshal.h
+++ b/esp8266/etshal.h
@@ -5,6 +5,5 @@ void ets_isr_unmask();
void ets_install_putc1();
void ets_isr_attach();
void uart_div_modify();
-uint32_t ets_get_cpu_frequency();
#endif // _INCLUDED_ETSHAL_H_
diff --git a/esp8266/modpyb.c b/esp8266/modpyb.c
index 5d57317b73..f02de9e305 100644
--- a/esp8266/modpyb.c
+++ b/esp8266/modpyb.c
@@ -81,10 +81,16 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_info_obj, 0, 1, pyb_info);
STATIC mp_obj_t pyb_freq(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
// get
- return mp_obj_new_int(mp_hal_get_cpu_freq() * 1000000);
+ return mp_obj_new_int(system_get_cpu_freq() * 1000000);
} else {
// set
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "can't change freq"));
+ mp_int_t freq = mp_obj_get_int(args[0]) / 1000000;
+ if (freq != 80 && freq != 160) {
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError,
+ "frequency can only be either 80Mhz or 160MHz"));
+ }
+ system_update_cpu_freq(freq);
+ return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_freq_obj, 0, 1, pyb_freq);