diff --git a/.clang-format b/.clang-format index 9a81a43..497252c 100644 --- a/.clang-format +++ b/.clang-format @@ -10,6 +10,7 @@ StatementMacros: - M5_NIF_i2_v - M5_NIF_i3_i3u_v - M5_NIF_i3_v +- M5_NIF_ici2_v - M5_NIF_i4_i4u_v - M5_NIF_i4_v - M5_NIF_i5_i5u_v @@ -20,5 +21,6 @@ StatementMacros: - M5_NIF_v_b - M5_NIF_v_i - M5_NIF_v_i4 +- M5_NIF_i32o4_v - M5_NIF_v_u_v - M5_NIF_v_v diff --git a/CMakeLists.txt b/CMakeLists.txt index a88696c..7944f39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,9 @@ idf_component_register( PRIV_REQUIRES "libatomvm" "avm_sys" "main" "M5Unified" ) +target_compile_features(${COMPONENT_LIB} INTERFACE cxx_std_14) + idf_build_set_property( - LINK_OPTIONS "-Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/lib${COMPONENT_NAME}.a -Wl,--no-whole-archive" + LINK_OPTIONS "-Wl,--whole-archive;${CMAKE_CURRENT_BINARY_DIR}/lib${COMPONENT_NAME}.a;-Wl,--no-whole-archive" APPEND ) diff --git a/nifs/atomvm_m5_display.cc b/nifs/atomvm_m5_display.cc index bb00ed5..6a9acc5 100644 --- a/nifs/atomvm_m5_display.cc +++ b/nifs/atomvm_m5_display.cc @@ -167,10 +167,10 @@ M5_NIF_b_v(nif_display_set_auto_display, Display, setAutoDisplay) M5_NIF_v_i(nif_display_get_rotation, Display, getRotation) M5_NIF_i_v(nif_display_set_rotation, Display, setRotation) M5_NIF_i4_v(nif_display_set_clip_rect, Display, setClipRect) -M5_NIF_v_i4(nif_display_get_clip_rect, Display, getClipRect) +M5_NIF_i32o4_v(nif_display_get_clip_rect, Display, getClipRect) M5_NIF_v_v(nif_display_clear_clip_rect, Display, clearClipRect) M5_NIF_i4_v(nif_display_set_scroll_rect, Display, setScrollRect) -M5_NIF_v_i4(nif_display_get_scroll_rect, Display, getScrollRect) +M5_NIF_i32o4_v(nif_display_get_scroll_rect, Display, getScrollRect) M5_NIF_v_v(nif_display_clear_scroll_rect, Display, clearScrollRect) static term nif_display_get_cursor(Context* ctx, int argc, term argv[]) diff --git a/nifs/atomvm_m5_i2c.cc b/nifs/atomvm_m5_i2c.cc index b8d6da0..ae21dc1 100644 --- a/nifs/atomvm_m5_i2c.cc +++ b/nifs/atomvm_m5_i2c.cc @@ -25,7 +25,7 @@ #include #include #include -//#define ENABLE_TRACE +// #define ENABLE_TRACE #include #include "atomvm_m5_nifs.h" @@ -35,10 +35,10 @@ #define MAKE_ATOM(ctx, len, str) globalcontext_make_atom(ctx->global, ATOM_STR(len, str)) -M5_NIF_i3_v(nif_in_i2c_set_port, In_I2C, setPort) -M5_NIF_i3_v(nif_ex_i2c_set_port, Ex_I2C, setPort) -M5_NIF_i3_v(nif_in_i2c_begin, In_I2C, begin) -M5_NIF_i3_v(nif_ex_i2c_begin, Ex_I2C, begin) +M5_NIF_ici2_v(nif_in_i2c_set_port, In_I2C, setPort, i2c_port_t) +M5_NIF_ici2_v(nif_ex_i2c_set_port, Ex_I2C, setPort, i2c_port_t) +M5_NIF_ici2_v(nif_in_i2c_begin, In_I2C, begin, i2c_port_t) +M5_NIF_ici2_v(nif_ex_i2c_begin, Ex_I2C, begin, i2c_port_t) static constexpr std::array, 2> IN_NIFS = { { { "set_port/3", { { NIFFunctionType }, nif_in_i2c_set_port } }, diff --git a/nifs/atomvm_m5_nifs.h b/nifs/atomvm_m5_nifs.h index abad939..d092aea 100644 --- a/nifs/atomvm_m5_nifs.h +++ b/nifs/atomvm_m5_nifs.h @@ -111,6 +111,20 @@ return OK_ATOM; \ } +#define M5_NIF_ici2_v(name, module, api_func, t) \ + static term name(Context* ctx, int argc, term argv[]) \ + { \ + UNUSED(argc); \ + VALIDATE_VALUE(argv[0], term_is_integer); \ + VALIDATE_VALUE(argv[1], term_is_integer); \ + VALIDATE_VALUE(argv[2], term_is_integer); \ + M5.module.api_func( \ + (t)term_to_int(argv[0]), \ + term_to_int(argv[1]), \ + term_to_int(argv[2])); \ + return OK_ATOM; \ + } + #define M5_NIF_i4_v(name, module, api_func) \ static term name(Context* ctx, int argc, term argv[]) \ { \ @@ -126,12 +140,12 @@ return OK_ATOM; \ } -#define M5_NIF_v_i4(name, module, api_func) \ +#define M5_NIF_i32o4_v(name, module, api_func) \ static term name(Context* ctx, int argc, term argv[]) \ { \ UNUSED(argc); \ UNUSED(argv); \ - int x, y, w, h; \ + int32_t x, y, w, h; \ M5.module.api_func(&x, &y, &w, &h); \ if (memory_ensure_free_opt(ctx, TUPLE_SIZE(4), MEMORY_CAN_SHRINK) != MEMORY_GC_OK) { \ RAISE_ERROR(OUT_OF_MEMORY_ATOM); \