diff options
| author | Damien George <damien@micropython.org> | 2021-05-19 23:43:21 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-06-10 15:26:21 +1000 |
| commit | 71e3538a3274322ea845959d75283d1e96fefb6b (patch) | |
| tree | 1c0258d77d157d1c054c1147177f07ca2a98bb08 /docs/library/pyb.USB_VCP.rst | |
| parent | 8c02b94946c437ed841fe294442b1f0d2401c678 (diff) | |
stm32/usb: Add USB_VCP.irq method, to set a callback on USB data RX.
Usage:
usb = pyb.USB_VCP()
usb.irq(lambda u:print(u, u.read()), usb.IRQ_RX)
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/library/pyb.USB_VCP.rst')
| -rw-r--r-- | docs/library/pyb.USB_VCP.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/library/pyb.USB_VCP.rst b/docs/library/pyb.USB_VCP.rst index bbcbc0701..1e44e53fd 100644 --- a/docs/library/pyb.USB_VCP.rst +++ b/docs/library/pyb.USB_VCP.rst @@ -109,6 +109,16 @@ Methods Return value: number of bytes sent. +.. method:: USB_VCP.irq(handler=None, trigger=0, hard=False) + + Register *handler* to be called whenever an event specified by *trigger* + occurs. The *handler* function must take exactly one argument, which will + be the USB VCP object. Pass in ``None`` to disable the callback. + + Valid values for *trigger* are: + + - ``USB_VCP.IRQ_RX``: new data is available for reading from the USB VCP object. + Constants --------- @@ -117,3 +127,7 @@ Constants USB_VCP.CTS to select the flow control type. + +.. data:: USB_VCP.IRQ_RX + + IRQ trigger values for :meth:`USB_VCP.irq`. |
