diff options
author | Damien George <damien.p.george@gmail.com> | 2016-05-31 14:06:33 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-05-31 14:06:33 +0100 |
commit | 93a9c2e840b760a132f57d254d74d543bdb13a3d (patch) | |
tree | be7343ef0764671346dfd492e2dded5e7a2e86e8 | |
parent | 4940bee62a636f7e2653a4d4eeac5071448addc0 (diff) | |
download | micropython-93a9c2e840b760a132f57d254d74d543bdb13a3d.tar.gz micropython-93a9c2e840b760a132f57d254d74d543bdb13a3d.zip |
docs/library/machine: Add documentation for machine.time_pulse_us.
-rw-r--r-- | docs/library/machine.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/library/machine.rst b/docs/library/machine.rst index 7bf73248f6..b103ec393d 100644 --- a/docs/library/machine.rst +++ b/docs/library/machine.rst @@ -101,6 +101,19 @@ Miscellaneous functions varies by hardware (so use substring of a full value if you expect a short ID). In some MicroPython ports, ID corresponds to the network MAC address. +.. function:: time_pulse_us(pin, pulse_level, timeout_us=1000000) + + Time a pulse on the given `pin`, and return the duration of the pulse in + microseconds. The `pulse_level` argument should be 0 to time a low pulse + or 1 to time a high pulse. + + The function first waits while the pin input is different to the `pulse_level` + parameter, then times the duration that the pin is equal to `pulse_level`. + If the pin is already equal to `pulse_level` then timing starts straight away. + + The function will raise an OSError with ETIMEDOUT if either of the waits is + longer than the given timeout value (which is in microseconds). + .. _machine_constants: Constants |