File tree Expand file tree Collapse file tree
common-hal/microcontroller
shared-bindings/microcontroller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ SRC_SDK := \
229229 src/rp2_common/pico_printf/printf.c \
230230 src/rp2_common/pico_runtime/runtime.c \
231231 src/rp2_common/pico_stdio/stdio.c \
232+ src/rp2_common/pico_stdlib/stdlib.c \
232233 src/rp2_common/pico_unique_id/unique_id.c \
233234 $(SRC_SDK_CYW43 ) \
234235
Original file line number Diff line number Diff line change 2828#include <string.h>
2929
3030#include "py/mphal.h"
31+ #include "py/runtime.h"
3132#include "common-hal/microcontroller/Processor.h"
3233#include "shared-bindings/microcontroller/Processor.h"
3334#include "shared-bindings/microcontroller/ResetReason.h"
3435
36+ #include "pico/stdlib.h"
3537#include "src/rp2_common/hardware_adc/include/hardware/adc.h"
3638#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h"
3739
@@ -59,6 +61,16 @@ uint32_t common_hal_mcu_processor_get_frequency(void) {
5961 return clock_get_hz (clk_sys );
6062}
6163
64+ uint32_t common_hal_mcu_processor_set_frequency (mcu_processor_obj_t * self ,
65+ uint32_t frequency ) {
66+ uint32_t freq = frequency / 1000 ;
67+
68+ if (!set_sys_clock_khz (freq , false)) {
69+ mp_raise_ValueError (translate ("Invalid frequency supplied" ));
70+ }
71+ return clock_get_hz (clk_sys );
72+ }
73+
6274void common_hal_mcu_processor_get_uid (uint8_t raw_id []) {
6375 pico_unique_board_id_t retrieved_id ;
6476 pico_get_unique_board_id (& retrieved_id );
Original file line number Diff line number Diff line change @@ -48,3 +48,4 @@ CIRCUITPY_BUILD_EXTENSIONS ?= uf2
4848USB_NUM_ENDPOINT_PAIRS = 8
4949
5050INTERNAL_FLASH_FILESYSTEM = 1
51+ CIRCUITPY_SETTABLE_PROCESSOR_FREQUENCY = 1
Original file line number Diff line number Diff line change 6767//| frequency: int
6868//| """The CPU operating frequency in Hertz.
6969//|
70- //| **Limitations:** Setting the ``frequency`` is possible only on some i.MX boards.
70+ //| **Limitations:** Setting the ``frequency`` is possible on RP2040 boards and some i.MX boards.
7171//| On most boards, ``frequency`` is read-only.
7272//| """
7373
You can’t perform that action at this time.
0 commit comments