platform_mutex.c 758 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2019-12-15 18:27:19
  5. * @LastEditTime : 2020-01-08 20:23:13
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #include "platform_mutex.h"
  9. int platform_mutex_init(platform_mutex_t* m)
  10. {
  11. return tos_mutex_create(&(m->mutex));
  12. }
  13. int platform_mutex_lock(platform_mutex_t* m)
  14. {
  15. return tos_mutex_pend(&(m->mutex));
  16. }
  17. int platform_mutex_trylock(platform_mutex_t* m)
  18. {
  19. return tos_mutex_pend_timed(&(m->mutex), 0);
  20. }
  21. int platform_mutex_unlock(platform_mutex_t* m)
  22. {
  23. return tos_mutex_post(&(m->mutex));
  24. }
  25. int platform_mutex_destroy(platform_mutex_t* m)
  26. {
  27. return tos_mutex_destroy(&(m->mutex));
  28. }