mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-04 20:05:25 +02:00
ulp-riscv: added lock API to provide mutual exclusion when sharing variables between the main CPU and the ULP.
This commit is contained in:
@@ -98,6 +98,18 @@ To access the ULP RISC-V program variables from the main program, the generated
|
||||
ulp_measurement_count = 64;
|
||||
}
|
||||
|
||||
Mutual Exclusion
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
If mutual exclusion is needed when accessing a variable shared between the main program and ULP then this can be achieved by using the ULP RISC-V lock API:
|
||||
|
||||
* :cpp:func:`ulp_riscv_lock_acquire`
|
||||
* :cpp:func:`ulp_riscv_lock_release`
|
||||
|
||||
The ULP does not have any hardware instructions to facilitate mutual exclusion so the lock API achieves this through a software algorithm (`Peterson's algorithm <https://en.wikipedia.org/wiki/Peterson%27s_algorithm>`_).
|
||||
|
||||
The locks are intended to only be called from a single thread in the main program, and will not provide mutual exclusion if used simultaneously from multiple threads.
|
||||
|
||||
Starting the ULP RISC-V Program
|
||||
-------------------------------
|
||||
|
||||
@@ -151,7 +163,6 @@ Keeping this in mind, here are some ways that may help you debug you ULP RISC-V
|
||||
* Trap signal: the ULP RISC-V has a hardware trap that will trigger under certain conditions, e.g. illegal instruction. This will cause the main CPU to be woken up with the wake-up cause :cpp:enumerator:`ESP_SLEEP_WAKEUP_COCPU_TRAP_TRIG`.
|
||||
|
||||
|
||||
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
@@ -163,3 +174,5 @@ API Reference
|
||||
-------------
|
||||
|
||||
.. include-build-file:: inc/ulp_riscv.inc
|
||||
.. include-build-file:: inc/ulp_riscv_lock_shared.inc
|
||||
.. include-build-file:: inc/ulp_riscv_lock.inc
|
||||
|
||||
Reference in New Issue
Block a user