luat_msgbus.h 737 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef LUAT_MSGBUS_H
  2. #define LUAT_MSGBUS_H
  3. #include "luat_base.h"
  4. #define MSG_TIMER 1
  5. #define MSG_GPIO 2
  6. #define MSG_UART_RX 3
  7. #define MSG_UART_TXDONE 4
  8. typedef int (*luat_msg_handler) (lua_State *L, void* ptr);
  9. typedef struct rtos_msg{
  10. luat_msg_handler handler;
  11. void* ptr;
  12. int arg1;
  13. int arg2;
  14. }rtos_msg_t;
  15. // 定义接口方法
  16. void luat_msgbus_init(void);
  17. //void* luat_msgbus_data();
  18. uint32_t luat_msgbus_put(rtos_msg_t* msg, size_t timeout);
  19. uint32_t luat_msgbus_get(rtos_msg_t* msg, size_t timeout);
  20. uint32_t luat_msgbus_freesize(void);
  21. #define luat_msgbug_put2(ABC1,ABC2,ABC3,ABC4,ABC5) {\
  22. rtos_msg_t _msg = {.handler=ABC1,.ptr=ABC2,.arg1=ABC3,.arg2=ABC4};\
  23. luat_msgbus_put(&_msg, ABC5);\
  24. }
  25. #endif