Skip to content

Commit a93d553

Browse files
Merge branch 'master' into picoadk-v2
2 parents 31c3b2b + 902f709 commit a93d553

File tree

10 files changed

+707
-159
lines changed

10 files changed

+707
-159
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Read the [Contributing Guide](https://github.com/earlephilhower/arduino-pico/blo
6868
* Newsan Archi
6969
* nullbits Bit-C PRO
7070
* Pimoroni PGA2040
71+
* Pimoroni Pico Plus 2
7172
* Pimoroni Plasma2040
7273
* Pimoroni Tiny2040
7374
* Pintronix PinMax

boards.txt

Lines changed: 327 additions & 0 deletions
Large diffs are not rendered by default.

docs/wire.rst

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,41 @@ being performed. For example, a game could send a full screen update out over I
3333
processing the next frame without waiting for the first one to be sent over I2C. DMA is used to handle
3434
the transfer to/from the I2C hardware freeing the CPU from bit-banging or busy waiting.
3535

36-
Note that asynchronous operations can not be intersped with normal, synchronous ones. Fully complete an
37-
asynchronous operation before attempting to do a normal ``Wire.beginTransaction()`` or ``Wire.requestFrom``.
38-
Also, all buffers need to be valid throughout the entire operation. Read data cannot be accessed until
39-
the transaction is completed and can't be "peeked" at while the operation is ongoing.
40-
41-
42-
bool writeAsync(uint8_t address, const void \*buffer, size_t bytes, bool sendStop)
43-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44-
Begins an I2C asynchronous write transaction. Writes to ``address`` of ``bytes`` from ``buffer`` and
45-
at the end will send an I2C stop if ``sendStop`` is ``true``.
46-
Check ``finishedAsync()`` to determine when the operation completes and conclude the transaction.
47-
This operation needs to allocate a buffer from heap equal to 2x ``bytes`` in size.
48-
49-
bool readAsync(uint8_t address, void \*buffer, size_t bytes, bool sendStop)
50-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51-
Begins an I2C asynchronous read transaction. Reads from ``address`` for ``bytes`` into ``buffer`` and
52-
at the end will send an I2C stop if ``sendStop`` is ``true``.
53-
Check ``finishedAsync()`` to determine when the operation completes and conclude the transaction.
54-
This operation needs to allocate a buffer from heap equal to 4x ``bytes`` in size.
36+
Note that asynchronous operations can not be intersped with normal, synchronous ones. Fully complete or
37+
abort an asynchronous operation before attempting to do a normal ``Wire.beginTransaction()`` or
38+
``Wire.requestFrom``.
39+
40+
41+
bool writeReadAsync(uint8_t address, const void \*wbuffer, size_t wbytes, const void \*rbuffer, size_t rbytes, bool sendStop)
42+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43+
Executes a master I2C asynchronous write/read transaction to I2C slave ``address``. First ``wbytes`` from
44+
``wbuffer`` are written to the I2C slave, followed by an I2C restart, then ``rbytes`` are read from the
45+
I2C slave into ``rbuffer``. The buffers need to be valid throughout the entire asynchronous operation.
46+
47+
At the end of the transaction an I2C stop is sent if ``sendStop`` is ``true``, and at the beginning of the
48+
transaction an I2C start is sent if the previous write/read had ``sendStop`` set to ``true``.
49+
50+
Check ``finishedAsync()`` to determine when the operation completes, or use ``onFinishedAsync()`` to set a
51+
callback.
52+
53+
Set ``rbytes`` to 0 to do a write-only operation, set ``wbytes`` to 0 to do a read-only operation. Or use:
54+
55+
``bool writeAsync(uint8_t address, const void \*buffer, size_t bytes, bool sendStop)``
56+
57+
``bool readAsync(uint8_t address, void \*buffer, size_t bytes, bool sendStop)``
58+
59+
The first call to an asynchronous write/read operation allocates the required DMA channels and internal
60+
buffer. If desired, call ``end()`` to free these resources.
5561

5662
bool finishedAsync()
5763
~~~~~~~~~~~~~~~~~~~~
58-
Call to check if the asynchronous operations is completed and the buffer passed in can be either read or
59-
reused. Frees the allocated memory and completes the asynchronous transaction.
64+
Call to check if the asynchronous operations is completed.
65+
66+
void onFinishedAsync(void(*function)(void))
67+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68+
Set a (optional) callback for async operation. The ``function`` will be called when the asynchronous
69+
operation finishes.
6070
6171
void abortAsync()
6272
~~~~~~~~~~~~~~~~~
63-
Cancels the outstanding asynchronous transaction and frees any allocated memory.
64-
73+
Cancels any outstanding asynchronous transaction.

libraries/Wire/keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ writeAsync KEYWORD2
2525
readAsync KEYWORD2
2626
finishedAsync KEYWORD2
2727
abortAsync KEYWORD2
28+
writeReadAsync KEYWORD2
29+
onFinishedAsync KEYWORD2
2830

2931
#######################################
3032
# Instances (KEYWORD2)

0 commit comments

Comments
 (0)