berry-lang / berry

A ultra-lightweight embedded scripting language optimized for microcontrollers.
https://berry-lang.github.io
MIT License
782 stars 95 forks source link

How can I call my own (native) function when I works with stm32. #436

Open msdarici opened 5 days ago

msdarici commented 5 days ago

How can I define and call native functions. BE_USE_PRECOMPILED_OBJECT macro is 1 and so

#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(attr_table) {
    be_native_module_function("setled", setled),
    be_native_module_function("setdac", setdac),
    be_native_module_function("play_sin", l_play_sin),
    be_native_module_function("play_rect", l_play_rect),
    be_native_module_function("play_tri", l_play_tri),
    be_native_module_function("play_stop", l_play_stop),
    be_native_module_function("reboot", l_reboot)
};

This macros make errors. İf I deactive BE_USE_PRECOMPILED_OBJECT macro, I get a lot of errors.

s-hadinger commented 5 days ago

It's all described here: https://berry.readthedocs.io/en/latest/source/en/Chapter-9.html#compile-time-construction-technology