synchronization_util.c 727 B

1234567891011121314151617181920212223242526
  1. // Copyright 2022 Stefan Kerkmann
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "synchronization_util.h"
  4. #include "ch.h"
  5. #if defined(SPLIT_KEYBOARD)
  6. static MUTEX_DECL(SPLIT_SHARED_MEMORY_MUTEX);
  7. /**
  8. * @brief Acquire exclusive access to the split keyboard shared memory, by
  9. * locking the mutex guarding it. If the mutex is already held, the calling
  10. * thread will be suspended until the mutex currently owning thread releases the
  11. * mutex again.
  12. */
  13. void split_shared_memory_lock(void) {
  14. chMtxLock(&SPLIT_SHARED_MEMORY_MUTEX);
  15. }
  16. /**
  17. * @brief Release the split shared memory mutex that has been acquired before.
  18. */
  19. void split_shared_memory_unlock(void) {
  20. chMtxUnlock(&SPLIT_SHARED_MEMORY_MUTEX);
  21. }
  22. #endif