|
31 | 31 |
|
32 | 32 | #include <stdio.h> |
33 | 33 | #include <zephyr/sys/reboot.h> |
| 34 | +#include <zephyr/pm/pm.h> |
| 35 | +#include <zephyr/pm/device.h> |
| 36 | +#include <zephyr/sys_clock.h> |
| 37 | +#include <zephyr/drivers/hwinfo.h> |
34 | 38 |
|
35 | 39 | #include "modmachine.h" |
36 | 40 |
|
@@ -61,3 +65,30 @@ MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause); |
61 | 65 | static void mp_machine_idle(void) { |
62 | 66 | k_yield(); |
63 | 67 | } |
| 68 | + |
| 69 | +static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) { |
| 70 | + mp_int_t milliseconds = mp_obj_get_int(args[0]); |
| 71 | + // Get the UART device |
| 72 | + const struct device *uart0 = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); |
| 73 | + // Set UART device to low power state |
| 74 | + pm_device_action_run(uart0, PM_DEVICE_ACTION_SUSPEND); |
| 75 | + k_sleep(K_MSEC(milliseconds)); |
| 76 | + // Set UART device back to active state |
| 77 | + pm_device_action_run(uart0, PM_DEVICE_ACTION_RESUME); |
| 78 | +} |
| 79 | + |
| 80 | +static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) { |
| 81 | + mp_raise_ValueError(MP_ERROR_TEXT("not implemented")); |
| 82 | +} |
| 83 | + |
| 84 | +static mp_obj_t mp_machine_get_freq(void) { |
| 85 | + mp_raise_ValueError(MP_ERROR_TEXT("not implemented")); |
| 86 | +} |
| 87 | + |
| 88 | +static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) { |
| 89 | + mp_raise_ValueError(MP_ERROR_TEXT("not implemented")); |
| 90 | +} |
| 91 | + |
| 92 | +static mp_obj_t mp_machine_unique_id(void) { |
| 93 | + mp_raise_ValueError(MP_ERROR_TEXT("not implemented")); |
| 94 | +} |
0 commit comments