ulp_riscv_lock.h 886 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include "ulp_riscv_lock_shared.h"
  11. /**
  12. * @brief Locks are based on the Peterson's algorithm, https://en.wikipedia.org/wiki/Peterson%27s_algorithm
  13. *
  14. */
  15. /**
  16. * @brief Acquire the lock, preventing the ULP from taking until released. Spins until lock is acquired.
  17. *
  18. * @note The lock is only designed for being used by a single thread on the main CPU,
  19. * it is not safe to try to acquire it from multiple threads.
  20. *
  21. * @param lock Pointer to lock struct, shared with ULP
  22. */
  23. void ulp_riscv_lock_acquire(ulp_riscv_lock_t *lock);
  24. /**
  25. * @brief Release the lock
  26. *
  27. * @param lock Pointer to lock struct, shared with ULP
  28. */
  29. void ulp_riscv_lock_release(ulp_riscv_lock_t *lock);
  30. #ifdef __cplusplus
  31. }
  32. #endif