luat_rtos_legacy_to_std.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "luat_base.h"
  2. #include "luat_rtos.h"
  3. #include "luat_rtos_legacy.h"
  4. LUAT_WEAK void luat_rtos_task_suspend_all(void)
  5. {
  6. luat_task_suspend_all();
  7. }
  8. LUAT_WEAK void luat_rtos_task_resume_all(void)
  9. {
  10. luat_task_resume_all();
  11. }
  12. luat_rtos_task_handle luat_rtos_get_current_handle(void)
  13. {
  14. return luat_get_current_task();
  15. }
  16. LUAT_WEAK int luat_rtos_event_send(luat_rtos_task_handle task_handle, uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t timeout)
  17. {
  18. if (!task_handle) return -1;
  19. return luat_send_event_to_task(task_handle, id, param1, param2, param3);
  20. }
  21. LUAT_WEAK int luat_rtos_event_recv(luat_rtos_task_handle task_handle, uint32_t wait_event_id, luat_event_t *out_event, luat_rtos_event_wait_callback_t *callback_fun, uint32_t timeout)
  22. {
  23. if (!task_handle) return -1;
  24. return luat_wait_event_from_task(task_handle, wait_event_id, out_event, callback_fun, timeout);
  25. }
  26. LUAT_WEAK int luat_rtos_message_send(luat_rtos_task_handle task_handle, uint32_t message_id, void *p_message)
  27. {
  28. if (!task_handle) return -1;
  29. return luat_send_event_to_task(task_handle, message_id, (uint32_t)p_message, 0, 0);
  30. }
  31. LUAT_WEAK int luat_rtos_message_recv(luat_rtos_task_handle task_handle, uint32_t *message_id, void **p_p_message, uint32_t timeout)
  32. {
  33. if (!task_handle) return -1;
  34. luat_event_t event;
  35. int result = luat_wait_event_from_task(task_handle, 0, &event, 0, timeout);
  36. if (!result)
  37. {
  38. *message_id = event.id;
  39. *p_p_message = (void *)event.param1;
  40. }
  41. return result;
  42. }
  43. LUAT_WEAK int luat_rtos_timer_create(luat_rtos_timer_t *timer_handle)
  44. {
  45. if (!timer_handle) return -1;
  46. *timer_handle = luat_create_rtos_timer(NULL, NULL, NULL);
  47. return (*timer_handle)?0:-1;
  48. }
  49. LUAT_WEAK int luat_rtos_timer_stop(luat_rtos_timer_t timer_handle)
  50. {
  51. if (!timer_handle) return -1;
  52. luat_stop_rtos_timer(timer_handle);
  53. return 0;
  54. }
  55. LUAT_WEAK int luat_rtos_timer_delete(luat_rtos_timer_t timer_handle)
  56. {
  57. if (!timer_handle) return -1;
  58. luat_release_rtos_timer(timer_handle);
  59. return 0;
  60. }