diff --git a/ueforth/Makefile b/ueforth/Makefile index 7349bff..dffadff 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -128,7 +128,7 @@ $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN) ARDUINO_BOOT = common/boot.fs common/vocabulary.fs \ arduino/arduino.fs arduino/arduino_highlevel.fs \ - arduino/hide_io.fs common/highlevel.fs \ + arduino/bindings.fs common/highlevel.fs \ common/filetools.fs common/utils.fs \ common/tasks.fs common/streams.fs arduino/arduino_server.fs \ arduino/esp_camera.fs common/blocks.fs \ diff --git a/ueforth/arduino/arduino.fs b/ueforth/arduino/arduino.fs index ba89dc7..5b78bc4 100644 --- a/ueforth/arduino/arduino.fs +++ b/ueforth/arduino/arduino.fs @@ -24,12 +24,6 @@ forth definitions 2 constant OUTPUT 2 constant LED -( WiFi Modes ) -0 constant WIFI_MODE_NULL -1 constant WIFI_MODE_STA -2 constant WIFI_MODE_AP -3 constant WIFI_MODE_APSTA - ( Startup Setup ) -1 echo ! 115200 Serial.begin diff --git a/ueforth/arduino/arduino.template.ino b/ueforth/arduino/arduino.template.ino index 24ca27b..8e058db 100644 --- a/ueforth/arduino/arduino.template.ino +++ b/ueforth/arduino/arduino.template.ino @@ -42,10 +42,14 @@ #define PUSH(v) (DUP, tos = (cell_t) (v)) #define PLATFORM_OPCODE_LIST \ - /* Allocation and Strings */ \ + /* Memory Allocation */ \ X("MALLOC", MALLOC, tos = (cell_t) malloc(tos)) \ X("SYSFREE", FREE, free((void *) tos); DROP) \ X("REALLOC", REALLOC, tos = (cell_t) realloc((void *) *sp, tos); --sp) \ + X("heap_caps_malloc", HEAP_CAPS_MALLOC, tos = (cell_t) heap_caps_malloc(*sp, tos); --sp) \ + X("heap_caps_free", HEAP_CAPS_FREE, heap_caps_free((void *) tos); DROP) \ + X("heap_caps_realloc", HEAP_CAPS_REALLOC, \ + tos = (cell_t) heap_caps_realloc((void *) sp[-1], *sp, tos); sp -= 2) \ /* Serial */ \ X("Serial.begin", SERIAL_BEGIN, Serial.begin(tos); DROP) \ X("Serial.end", SERIAL_END, Serial.end()) \ diff --git a/ueforth/arduino/arduino_server.fs b/ueforth/arduino/arduino_server.fs index 00ce52f..4452c99 100644 --- a/ueforth/arduino/arduino_server.fs +++ b/ueforth/arduino/arduino_server.fs @@ -102,7 +102,7 @@ window.onload = function() { variable webserver 20000 constant out-size 200 stream input-stream -out-size dup stream output-stream +out-size stream output-stream create out-string out-size 1+ allot align : handle-index diff --git a/ueforth/arduino/hide_io.fs b/ueforth/arduino/bindings.fs similarity index 76% rename from ueforth/arduino/hide_io.fs rename to ueforth/arduino/bindings.fs index a964df8..359f6de 100644 --- a/ueforth/arduino/hide_io.fs +++ b/ueforth/arduino/bindings.fs @@ -1,4 +1,5 @@ -( Migrate various words to separate vocabularies ) +( Migrate various words to separate vocabularies, and constants ) + vocabulary Wire Wire definitions transfer{ Wire.begin Wire.setClock Wire.getClock @@ -25,6 +26,7 @@ transfer{ forth definitions vocabulary WiFi WiFi definitions + transfer{ WiFi.config WiFi.begin WiFi.disconnect @@ -32,8 +34,14 @@ transfer{ WiFi.macAddress WiFi.localIP WiFi.mode WiFi.setTxPower WiFi.getTxPower - WIFI_MODE_APSTA WIFI_MODE_AP WIFI_MODE_STA WIFI_MODE_NULL }transfer + +( WiFi Modes ) +0 constant WIFI_MODE_NULL +1 constant WIFI_MODE_STA +2 constant WIFI_MODE_AP +3 constant WIFI_MODE_APSTA + forth definitions vocabulary SD_MMC SD_MMC definitions @@ -92,6 +100,21 @@ forth definitions internals definitions transfer{ malloc sysfree realloc + heap_caps_malloc heap_caps_free heap_caps_realloc }transfer + +( Heap Capabilities ) +binary +0001 constant MALLOC_CAP_EXEC +0010 constant MALLOC_CAP_32BIT +0100 constant MALLOC_CAP_8BIT +1000 constant MALLOC_CAP_DMA +: MALLOC_CAP_PID ( n -- ) 10000 over 11 ( 3 ) - for 2* next ; +000010000000000 constant MALLOC_CAP_SPIRAM +000100000000000 constant MALLOC_CAP_INTERNAL +001000000000000 constant MALLOC_CAP_DEFAULT +010000000000000 constant MALLOC_CAP_IRAM_8BIT +010000000000000 constant MALLOC_CAP_RETENTION +decimal forth definitions