luat_rtos_legacy.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef LUAT_RTOS_LEGACY_H
  2. #define LUAT_RTOS_LEGACY_H
  3. #include "luat_base.h"
  4. typedef struct
  5. {
  6. uint32_t id;
  7. uint32_t param1;
  8. uint32_t param2;
  9. uint32_t param3;
  10. }luat_event_t;
  11. //定时器回调函数需要定义成 LUAT_RT_RET_TYPE fun_name(LUAT_RT_CB_PARAM)
  12. //定时器回调函数退出时需要, return LUAT_RT_RET;
  13. #ifndef LUAT_RT_RET_TYPE
  14. #define LUAT_RT_RET_TYPE void
  15. #endif
  16. #ifndef LUAT_RT_RET
  17. #define LUAT_RT_RET
  18. #endif
  19. #ifndef LUAT_RT_CB_PARAM
  20. #define LUAT_RT_CB_PARAM void
  21. //#define LUAT_RT_CB_PARAM void *param
  22. //#define LUAT_RT_CB_PARAM void *pdata, void *param
  23. #endif
  24. /* ----------------------------------- thread ----------------------------------- */
  25. LUAT_RET luat_send_event_to_task(void *task_handle, uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3);
  26. LUAT_RET luat_wait_event_from_task(void *task_handle, uint32_t wait_event_id, luat_event_t *out_event, void *call_back, uint32_t ms);
  27. void *luat_get_current_task(void);
  28. /* -----------------------------------信号量模拟互斥锁,可以在中断中unlock-------------------------------*/
  29. void *luat_mutex_create(void);
  30. LUAT_RET luat_mutex_lock(void *mutex);
  31. LUAT_RET luat_mutex_unlock(void *mutex);
  32. void luat_mutex_release(void *mutex);
  33. /* ----------------------------------- timer ----------------------------------- */
  34. void *luat_create_rtos_timer(void *cb, void *param, void *task_handle);
  35. int luat_start_rtos_timer(void *timer, uint32_t ms, uint8_t is_repeat);
  36. int luat_start_rtos_timer_v2(void *timer, uint64_t tick, uint8_t is_repeat, uint8_t is_cb_in_irq);
  37. int luat_start_rtos_timer_us(void *timer, uint32_t us);
  38. void luat_stop_rtos_timer(void *timer);
  39. void luat_release_rtos_timer(void *timer);
  40. void luat_task_suspend_all(void);
  41. void luat_task_resume_all(void);
  42. #endif