All Projects → szieke → embLua

szieke / embLua

Licence: other
Lua for microcontrollers

Programming Languages

c
50402 projects - #5 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to embLua

Nrf Hal
A Rust HAL for the nRF family of devices
Stars: ✭ 186 (+708.7%)
Mutual labels:  microcontroller, embedded
Embedded UKF Library
A compact Unscented Kalman Filter (UKF) library for Teensy4/Arduino system (or any real time embedded system in general)
Stars: ✭ 31 (+34.78%)
Mutual labels:  microcontroller, embedded
Littlefs
A little fail-safe filesystem designed for microcontrollers
Stars: ✭ 2,488 (+10717.39%)
Mutual labels:  microcontroller, embedded
Chino Os
A real time operating system for IoT written in C++
Stars: ✭ 139 (+504.35%)
Mutual labels:  microcontroller, embedded
circuitpython
CircuitPython - a Python implementation for teaching coding with microcontrollers
Stars: ✭ 3,097 (+13365.22%)
Mutual labels:  microcontroller, embedded
Lib Python
Blynk IoT library for Python and Micropython
Stars: ✭ 140 (+508.7%)
Mutual labels:  microcontroller, embedded
ewok-kernel
A secure and high performances microkernel for building secure MCU-based IoTs
Stars: ✭ 69 (+200%)
Mutual labels:  microcontroller, embedded
Sming
Sming - Open Source framework for high efficiency native ESP8266 development
Stars: ✭ 1,197 (+5104.35%)
Mutual labels:  microcontroller, embedded
xForth
Experimental Forth cross compiler for tiny devices
Stars: ✭ 53 (+130.43%)
Mutual labels:  microcontroller, embedded
lwjson
Lightweight JSON parser for embedded systems
Stars: ✭ 66 (+186.96%)
Mutual labels:  microcontroller, embedded
Tiny Json
The tiny-json is a versatile and easy to use json parser in C suitable for embedded systems. It is fast, robust and portable.
Stars: ✭ 127 (+452.17%)
Mutual labels:  microcontroller, embedded
mdepx
MDEPX — A BSD-style RTOS
Stars: ✭ 17 (-26.09%)
Mutual labels:  microcontroller, embedded
Utensor
TinyML AI inference library
Stars: ✭ 1,295 (+5530.43%)
Mutual labels:  microcontroller, embedded
Micropython
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Stars: ✭ 13,439 (+58330.43%)
Mutual labels:  microcontroller, embedded
Lv drivers
TFT and touch pad drivers for LVGL embedded GUI library
Stars: ✭ 84 (+265.22%)
Mutual labels:  microcontroller, embedded
Berry
A ultra-lightweight embedded scripting language optimized for microcontrollers.
Stars: ✭ 206 (+795.65%)
Mutual labels:  microcontroller, embedded
Daplink
Stars: ✭ 1,162 (+4952.17%)
Mutual labels:  microcontroller, embedded
Serial Studio
Multi-purpose serial data visualization & processing program
Stars: ✭ 1,168 (+4978.26%)
Mutual labels:  microcontroller, embedded
pumbaa
Python on Simba.
Stars: ✭ 61 (+165.22%)
Mutual labels:  microcontroller, embedded
nrf52832-pac
Peripheral Access Crate for the nRF52832 microcontroller
Stars: ✭ 21 (-8.7%)
Mutual labels:  microcontroller, embedded

embLua

The aim of embLua (includes the complete Lua 5.3.4 core) is to provide C/C++ developers the possibility to extend their microcontroller/embedded device with scripting functionality. The main focus of embLua is the fast/easy integration in custom projects and new platforms. Therefore only a subset of Lua modules and global functions are available:

  • table module
  • string module
  • math module
  • global functions: assert, collectgarbage, error, getmetatable, ipairs, next, pairs, pcall, print, rawequal, rawlen, rawget, rawset, select, setmetatable, tonumber, tostring, type, xpcall, loadstring, load

Note: The math module is only included if the define LUA_WITH_MATH is defined in luaProjectConfig.h.

embLua requirements

To run scripts which do something 'meaningful' embLua needs:

  • RAM: 1k Stack, 11k Heap
  • ROM (not optimized code): 120 on MSP430, 90k on Renesas
  • C-Library

Integrating embLua

To integrate embLua in a custom project:

  • copy the source files embLua/lua into your project
  • create the embLua config file luaInterface.h (an example can be found under embLua/examples/MSP430F6747A_FreeRTOS/luaProject)

luaProjectConfig.h

This file is used to configure embLua (an example can be found under embLua/examples/MSP430F6747A_FreeRTOS/luaProject).

Memory management

embLua can be configured to use the build in memory management functions (embLua/lua/helper/luaHeap.c) or to use project specific memory functions. To configure the memory management following defines are used:

  • LUA_HEAP_SIZE: The heap size if the build in memory management shall be used
  • LUA_MEM_ENTER_CRITICAL_SECTION and LUA_MEM_LEAVE_CRITICAL_SECTION: These defines are used protect the memory management calls if several Lua instance in different tasks are created
  • DONT_USE_LUA_HEAP_MANAGEMENT_FUNCTIONS: If the build in memory function shall not be used then this define must be set.
  • luaMallocFunction(size) and luaFreeFunction(pointer): These defines must be set if the build in memory management shall not be used (DONT_USE_LUA_HEAP_MANAGEMENT_FUNCTIONS)

Other configuration options

  • luaPointerSize_t: If the size of size_t is not the pointer size on the current platform then this define must be set (example: on the MSP430 the pointer size is 32Bit but size_t is only 16Bit)
  • LUA_DECIMAL_POINT: The "radix character" (decimal point) used by Lua is per default '.'. With this define this character can be changed.
  • LUA_WITH_MATH: If the math module shall be included then this define must be set.
  • WITH_PRECOMPILED_SCRIPTS: If Lua shall execute precompiled script (luac.exe) then this define must be set.

Embedding lua scripts

To execute a Lua script the function dostring (embLua/lua/helper/luaHelper.c) can be used. This function can execute scipts wich resides in the RAM or in the ROM.

Compiling a Lua script into ROM

For this purpose embLua/lua/convertToHeader.lua can be used. This script converts a Lua script into a header file. To run this script the header file must be included and dofile with the name of the header file must be called (an example can be found in embLua/examples/MSP430F6747A_FreeRTOS/main.c).

Under embLua/examples/MSP430F6747A_FreeRTOS/luaProject/Scripts a batch file can be found (convertToHeader.bat) which shows the usage of convertToHeader.lua.

Extending embLua

To extend embLua with custom module/functions the define LUA_INTERFACE_LIBS can be used. An example can be found under embLua/examples/MSP430F6747A_FreeRTOS/luaProject/luaInterface.h

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].