8000 docs/library/machine: Add documentation for machine.time_pulse_us. · lapsule/micropython@93a9c2e · GitHub
[go: up one dir, main page]

Skip to content

Commit 93a9c2e

Browse files
committed
docs/library/machine: Add documentation for machine.time_pulse_us.
1 parent 4940bee commit 93a9c2e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/library/machine.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ Miscellaneous functions
101101
varies by hardware (so use substring of a full value if you expect a short
102102
ID). In some MicroPython ports, ID corresponds to the network MAC address.
103103

104+
.. function:: time_pulse_us(pin, pulse_level, timeout_us=1000000)
105+
106+
Time a pulse on the given `pin`, and return the duration of the pulse in
107+
microseconds. The `pulse_level` argument should be 0 to time a low pulse
108+
or 1 to time a high pulse.
109+
110+
The function first waits while the pin input is different to the `pulse_level`
111+
parameter, then times the duration that the pin is equal to `pulse_level`.
112+
If the pin is already equal to `pulse_level` then timing starts straight away.
113+
114+
The function will raise an OSError with ETIMEDOUT if either of the waits is
115+
longer than the given timeout value (which is in microseconds).
116+
104117
.. _machine_constants:
105118

106119
Constants

0 commit comments

Comments
 (0)
0