Content originally posted in LPCWare by Leji on Mon May 14 01:35:30 MST 2012 Hi,
I would like to embed some level of scripting functionality in my application to allow users some simple/fast customizations (for example, toggle a GPIO each time an I2C transaction is detected, or repeat a pattern of GPIOs toggling...)
I don't need a fully featured language, just something with IF, FOR and the ability to call native functions (for I2C, SPI etc...)
Content originally posted in LPCWare by Leji on Tue May 15 02:04:32 MST 2012 In case anyone's interesting, I chose Pawn (picoc was not as easy to port & use, Pawn has nice documentation + IDE), which compiled quite easily.
To use it, I: - imported amx, amxaux, amxcore and osdefs - build with AMX_NOPROPLIST and NDEBUG symbols (as a static lib) - Write a script in Quincy (Pawn IDE), build and dump the outputed amx file somewhere in LPC memory - In my LPC main application (bulkData is the address of the script):
AMX amx;
cell ret =0;
int result = 0;
memset(&amx, 0, sizeof(amx));
result = amx_Init(&amx,bulkData);
if (result != 0)
{
// handle error
}
result = amx_NativeInit(&amx);
if (result != 0)
{
// handle error
}
result = amx_Exec(&amx,&ret,AMX_EXEC_MAIN);
if (result != 0)
// handle error
else
{
// handle success !
// return ret
}
where amx_NativeInit is the function that initializes external functions calls, like: