Add frequency setting for RP2040 boards.
This commit is contained in:
parent
037bfb39e3
commit
a84a8855ed
|
@ -229,6 +229,7 @@ SRC_SDK := \
|
|||
src/rp2_common/pico_printf/printf.c \
|
||||
src/rp2_common/pico_runtime/runtime.c \
|
||||
src/rp2_common/pico_stdio/stdio.c \
|
||||
src/rp2_common/pico_stdlib/stdlib.c \
|
||||
src/rp2_common/pico_unique_id/unique_id.c \
|
||||
$(SRC_SDK_CYW43) \
|
||||
|
||||
|
|
|
@ -28,10 +28,12 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
#include "common-hal/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
#include "shared-bindings/microcontroller/ResetReason.h"
|
||||
|
||||
#include "pico/stdlib.h"
|
||||
#include "src/rp2_common/hardware_adc/include/hardware/adc.h"
|
||||
#include "src/rp2_common/hardware_clocks/include/hardware/clocks.h"
|
||||
|
||||
|
@ -59,6 +61,16 @@ uint32_t common_hal_mcu_processor_get_frequency(void) {
|
|||
return clock_get_hz(clk_sys);
|
||||
}
|
||||
|
||||
uint32_t common_hal_mcu_processor_set_frequency(mcu_processor_obj_t *self,
|
||||
uint32_t frequency) {
|
||||
uint32_t freq = frequency / 1000;
|
||||
|
||||
if (!set_sys_clock_khz(freq, false)) {
|
||||
mp_raise_ValueError(translate("Invalid frequency supplied"));
|
||||
}
|
||||
return clock_get_hz(clk_sys);
|
||||
}
|
||||
|
||||
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
|
||||
pico_unique_board_id_t retrieved_id;
|
||||
pico_get_unique_board_id(&retrieved_id);
|
||||
|
|
|
@ -48,3 +48,4 @@ CIRCUITPY_BUILD_EXTENSIONS ?= uf2
|
|||
USB_NUM_ENDPOINT_PAIRS = 8
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
CIRCUITPY_SETTABLE_PROCESSOR_FREQUENCY = 1
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
//| frequency: int
|
||||
//| """The CPU operating frequency in Hertz.
|
||||
//|
|
||||
//| **Limitations:** Setting the ``frequency`` is possible only on some i.MX boards.
|
||||
//| **Limitations:** Setting the ``frequency`` is possible on RP2040 boards and some i.MX boards.
|
||||
//| On most boards, ``frequency`` is read-only.
|
||||
//| """
|
||||
|
||||
|
|
Loading…
Reference in New Issue