File tree Expand file tree Collapse file tree 4 files changed +15
-1
lines changed
common-hal/microcontroller
shared-bindings/microcontroller Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ SRC_SDK := \
229
229
src/rp2_common/pico_printf/printf.c \
230
230
src/rp2_common/pico_runtime/runtime.c \
231
231
src/rp2_common/pico_stdio/stdio.c \
232
+ src/rp2_common/pico_stdlib/stdlib.c \
232
233
src/rp2_common/pico_unique_id/unique_id.c \
233
234
$(SRC_SDK_CYW43 ) \
234
235
Original file line number Diff line number Diff line change 28
28
#include <string.h>
29
29
30
30
#include "py/mphal.h"
31
+ #include "py/runtime.h"
31
32
#include "common-hal/microcontroller/Processor.h"
32
33
#include "shared-bindings/microcontroller/Processor.h"
33
34
#include "shared-bindings/microcontroller/ResetReason.h"
34
35
36
+ #include "pico/stdlib.h"
35
37
#include "src/rp2_common/hardware_adc/include/hardware/adc.h"
36
38
#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h"
37
39
@@ -59,6 +61,16 @@ uint32_t common_hal_mcu_processor_get_frequency(void) {
59
61
return clock_get_hz (clk_sys );
60
62
}
61
63
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
+
62
74
void common_hal_mcu_processor_get_uid (uint8_t raw_id []) {
63
75
pico_unique_board_id_t retrieved_id ;
64
76
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
48
48
USB_NUM_ENDPOINT_PAIRS = 8
49
49
50
50
INTERNAL_FLASH_FILESYSTEM = 1
51
+ CIRCUITPY_SETTABLE_PROCESSOR_FREQUENCY = 1
Original file line number Diff line number Diff line change 67
67
//| frequency: int
68
68
//| """The CPU operating frequency in Hertz.
69
69
//|
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.
71
71
//| On most boards, ``frequency`` is read-only.
72
72
//| """
73
73
You can’t perform that action at this time.
0 commit comments