summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/modpyb.c
diff options
context:
space:
mode:
Diffstat (limited to 'esp8266/modpyb.c')
-rw-r--r--esp8266/modpyb.c10
1 files changed, 8 insertions, 2 deletions
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);