@@ -179,3 +179,56 @@ Details on sleep modes
179179* ``machine.sleep() ``: 950uA (in WLAN STA mode). Wake sources are ``Pin ``, ``RTC ``
180180 and ``WLAN ``
181181* ``machine.deepsleep() ``: ~350uA. Wake sources are ``Pin `` and ``RTC ``.
182+
183+ Additional details for machine.Pin
184+ ----------------------------------
185+
186+ On the WiPy board the pins are identified by their string id::
187+
188+ from machine import Pin
189+ g = machine.Pin('GP9', mode=Pin.OUT, pull=None, drive=Pin.MED_POWER, alt=-1)
190+
191+ You can also configure the Pin to generate interrupts. For instance::
192+
193+ from machine import Pin
194+
195+ def pincb(pin):
196+ print(pin.id())
197+
198+ pin_int = Pin('GP10', mode=Pin.IN, pull=Pin.PULL_DOWN)
199+ pin_int.irq(trigger=Pin.IRQ_RISING, handler=pincb)
200+ # the callback can be triggered manually
201+ pin_int.irq()()
202+ # to disable the callback
203+ pin_int.irq().disable()
204+
205+ Now every time a falling edge is seen on the gpio pin, the callback will be
206+ executed. Caution: mechanical push buttons have "bounce" and pushing or
207+ releasing a switch will often generate multiple edges.
208+ See: http://www.eng.utah.edu/~cs5780/debouncing.pdf for a detailed
209+ explanation, along with various techniques for debouncing.
210+
211+ All pin objects go through the pin mapper to come up with one of the
212+ gpio pins.
213+
214+ For the ``drive `` parameter the strengths are:
215+
216+ - ``Pin.LOW_POWER `` - 2mA drive capability.
217+ - ``Pin.MED_POWER `` - 4mA drive capability.
218+ - ``Pin.HIGH_POWER `` - 6mA drive capability.
219+
220+ For the ``alt `` parameter please refer to the pinout and alternate functions
221+ table at <https://raw.githubusercontent.com/wipy/wipy/master/docs/PinOUT.png>`_
222+ for the specific alternate functions that each pin supports.
223+
224+ For interrupts, the ``priority `` can take values in the range 1-7. And the
225+ ``wake `` parameter has the following properties:
226+
227+ - If ``wake_from=machine.Sleep.ACTIVE `` any pin can wake the board.
228+ - If ``wake_from=machine.Sleep.SUSPENDED `` pins ``GP2 ``, ``GP4 ``, ``GP10 ``,
229+ ``GP11 ``, GP17`` or ``GP24 `` can wake the board. Note that only 1
230+ of this pins can be enabled as a wake source at the same time, so, only
231+ the last enabled pin as a ``machine.Sleep.SUSPENDED `` wake source will have effect.
232+ - If ``wake_from=machine.Sleep.SUSPENDED `` pins ``GP2 ``, ``GP4 ``, ``GP10 ``,
233+ ``GP11 ``, ``GP17 `` and ``GP24 `` can wake the board. In this case all of the
234+ 6 pins can be enabled as a ``machine.Sleep.HIBERNATE `` wake source at the same time.
0 commit comments