luat_msgbus.h 809 B

123456789101112131415161718192021222324252627282930313233343536
  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. uint8_t luat_msgbus_is_empty(void);
  22. uint8_t luat_msgbus_is_ready(void);
  23. #define luat_msgbug_put2(ABC1,ABC2,ABC3,ABC4,ABC5) {\
  24. rtos_msg_t _msg = {.handler=ABC1,.ptr=ABC2,.arg1=ABC3,.arg2=ABC4};\
  25. luat_msgbus_put(&_msg, ABC5);\
  26. }
  27. #endif