luat_base.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /******************************************************************************
  2. * LuatOS基础操作
  3. * @author wendal
  4. * @since 0.0.1
  5. *****************************************************************************/
  6. #ifndef LUAT_BASE_H
  7. #define LUAT_BASE_H
  8. /**LuatOS版本号*/
  9. #define LUAT_VERSION "22.10"
  10. #define LUAT_VERSION_BETA 0
  11. // 调试开关, 预留
  12. #define LUAT_DEBUG 0
  13. #define LUAT_WEAK __attribute__((weak))
  14. //-------------------------------
  15. // 通用头文件
  16. #include "lua.h"
  17. #include "lualib.h"
  18. #include "lauxlib.h"
  19. #include "lstate.h"
  20. #include "stdint.h"
  21. #include "string.h"
  22. #include "luat_types.h"
  23. /**
  24. * LuatOS主入口函数, 从这里开始就交由LuatOS控制了.
  25. * 集成时,该函数应在独立的thread/task中启动
  26. */
  27. int luat_main (void);
  28. /**
  29. * 加载库函数. 平台实现应该根据时间情况, 加载可用的标准库和扩展库.
  30. * 其中, 标准库定义为_G/table/io/os等lua原生库.
  31. * 扩展库为下述luaopen_XXXX及厂商自行扩展的库.
  32. */
  33. void luat_openlibs(lua_State *L);
  34. // luaopen_xxx 代表各种库, 2021.09.26起独立一个头文件
  35. #include "luat_libs.h"
  36. /** sprintf需要支持longlong值的打印, 提供平台无关的实现*/
  37. int l_sprintf(char *buf, size_t size, const char *fmt, ...);
  38. /** 重启设备 */
  39. void luat_os_reboot(int code);
  40. /** 设备进入待机模式 */
  41. void luat_os_standy(int timeout);
  42. /** 厂商/模块名字, 例如Air302, Air640W*/
  43. const char* luat_os_bsp(void);
  44. void luat_os_entry_cri(void);
  45. void luat_os_exit_cri(void);
  46. uint32_t luat_os_interrupt_disable(void);
  47. void luat_os_interrupt_enable(uint32_t level);
  48. void luat_os_irq_disable(uint8_t IRQ_Type);
  49. void luat_os_irq_enable(uint8_t IRQ_Type);
  50. /** 停止启动,当前仅rt-thread实现有这个设置*/
  51. void stopboot(void);
  52. void luat_timer_us_delay(size_t us);
  53. const char* luat_version_str(void);
  54. void luat_os_print_heapinfo(const char* tag);
  55. // 自定义扩展库的初始化入口, 可以自行注册lua库, 或其他初始化操作.
  56. void luat_custom_init(lua_State *L);
  57. //c等待接口
  58. uint64_t luat_pushcwait(lua_State *L);
  59. //c等待接口,直接向用户返回错误的对象
  60. void luat_pushcwait_error(lua_State *L, int arg_num);
  61. //c等待接口,对指定id进行回调响应,并携带返回参数
  62. int luat_cbcwait(lua_State *L, uint64_t id, int arg_num);
  63. //c等待接口,无参数的回调,可不传入lua栈
  64. void luat_cbcwait_noarg(uint64_t id);
  65. #endif