Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c04c10

Browse files
committed
rp2: Debug code for mp_machine_lightsleep.
Add some debug code that can be enabled to determine why lightsleep isreturning early.Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
1 parentb729cd4 commit0c04c10

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

‎ports/rp2/modmachine.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ static void mp_machine_idle(void) {
124124
staticvoidalarm_sleep_callback(uintalarm_id) {
125125
}
126126

127+
// Set this to 1 to enable some debug of the interrupt that woke the device
128+
#defineDEBUG_LIGHTSLEEP 0
129+
127130
staticvoidmp_machine_lightsleep(size_tn_args,constmp_obj_t*args) {
128131
mp_int_tdelay_ms=0;
129132
booluse_timer_alarm= false;
@@ -193,6 +196,14 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
193196
// Disable ROSC.
194197
rosc_hw->ctrl=ROSC_CTRL_ENABLE_VALUE_DISABLE <<ROSC_CTRL_ENABLE_LSB;
195198

199+
#ifDEBUG_LIGHTSLEEP
200+
#ifPICO_RP2040
201+
uint32_tpending_intr=0;
202+
#else
203+
uint32_tpending_intr[2]= {0 };
204+
#endif
205+
#endif
206+
196207
boolalarm_armed= false;
197208
if (n_args==0) {
198209
#ifMICROPY_PY_NETWORK_CYW43
@@ -248,6 +259,15 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
248259
// Go into low-power mode.
249260
if (alarm_armed) {
250261
__wfi();
262+
263+
#ifDEBUG_LIGHTSLEEP
264+
#ifPICO_RP2040
265+
pending_intr=nvic_hw->ispr;
266+
#else
267+
pending_intr[0]=nvic_hw->ispr[0];
268+
pending_intr[1]=nvic_hw->ispr[1];
269+
#endif
270+
#endif
251271
}
252272
clocks_hw->sleep_en0=save_sleep_en0;
253273
clocks_hw->sleep_en1=save_sleep_en1;
@@ -270,6 +290,19 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
270290
}
271291
hardware_alarm_set_callback(MICROPY_HW_LIGHTSLEEP_ALARM_NUM,NULL);
272292
hardware_alarm_unclaim(MICROPY_HW_LIGHTSLEEP_ALARM_NUM);
293+
294+
#ifDEBUG_LIGHTSLEEP
295+
// Check irq.h for the list of IRQ's
296+
// for rp2040 00000042: TIMER_IRQ_1 woke the device as expected
297+
// 00000020: USBCTRL_IRQ woke the device (probably early)
298+
// For rp2350 00000000:00000002: TIMER0_IRQ_1 woke the device as expected
299+
// 00000000:00004000: USBCTRL_IRQ woke the device (probably early)
300+
#ifPICO_RP2040
301+
mp_printf(MP_PYTHON_PRINTER,"lightsleep: pending_intr=%08lx\n",pending_intr);
302+
#else
303+
mp_printf(MP_PYTHON_PRINTER,"lightsleep: pending_intr=%08lx:%08lx\n",pending_intr[1],pending_intr[0]);
304+
#endif
305+
#endif
273306
}
274307
}
275308

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp