Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
Commit4bc14ee
committed
rp2,docs: Stop machine.idle() blocking indefinitely, update docs.
When rp2 port went tickless the behaviour of machine.idle() changed asthere is no longer a tick interrupt to wake it up every millisecond. On aquiet system it would now block indefinitely. No other port does this.A lot of existing code (i.e. micropython-lib lps22h, lcd160cr sensordrivers, lora sync_modem driver, usb-device-hid) call machine.idle() insidea tight loop that is polling some condition. This reduces the power usagecompared to constantly looping, but can be faster than calling a sleepfunction. However there's not always an interrupt before the condition theyare polling for, so it's difficult to restructure this code ifmachine.idle() doesn't have any upper limit on execution time.Also changes the machine module documentation to explain the new behaviourand recommended usage. I believe all ports will pause for at most 1ms now,and suggest this is good behaviour to stick with.Adds a test case for this. Test case fails on master, and also fails on rp2port without the fix for WFE that was found while testing this change.This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>1 parent557d31e commit4bc14ee
File tree
4 files changed
+49
-6
lines changed- docs/library
- ports/rp2
- tests/extmod
4 files changed
+49
-6
lines changedLines changed: 11 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
127 | 127 |
| |
128 | 128 |
| |
129 | 129 |
| |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
134 | 140 |
| |
135 | 141 |
| |
136 | 142 |
| |
137 |
| - | |
| 143 | + | |
138 | 144 |
| |
139 | 145 |
| |
140 | 146 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
106 |
| - | |
| 106 | + | |
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
|
Lines changed: 36 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + |
0 commit comments
Comments
(0)