ulp_riscv_lock_shared.h 975 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**
  12. * @brief Enum representing which processor is allowed to enter the critical section
  13. *
  14. */
  15. typedef enum {
  16. ULP_RISCV_LOCK_TURN_ULP, /*!< ULP's turn to enter the critical section */
  17. ULP_RISCV_LOCK_TURN_MAIN_CPU, /*!< Main CPU's turn to enter the critical section */
  18. } ulp_riscv_lock_turn_t;
  19. /**
  20. * @brief Structure representing a lock shared between ULP and main CPU
  21. *
  22. */
  23. typedef struct {
  24. volatile bool critical_section_flag_ulp; /*!< ULP wants to enter the critical sections */
  25. volatile bool critical_section_flag_main_cpu; /*!< Main CPU wants to enter the critical sections */
  26. volatile ulp_riscv_lock_turn_t turn; /*!< Which CPU is allowed to enter the critical section */
  27. } ulp_riscv_lock_t;
  28. #ifdef __cplusplus
  29. }
  30. #endif