From 7fcc04a3cc8b7179680a7ee0ad6155996b7b44ba Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 11 Dec 2021 10:52:30 -0800 Subject: [PATCH] Fixed v2.0.1 build and ESP32-C3 and ESP32-S2 compile. Note ESP32-C3 and ESP32-S2 not yet tested on hardware. --- ueforth/Makefile | 2 +- ueforth/esp32/bindings.fs | 13 ++++++------- ueforth/esp32/template.ino | 27 ++++++++++++++++++--------- ueforth/site/ESP32forth.html | 23 +++++++++++++++++------ 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/ueforth/Makefile b/ueforth/Makefile index 0103708..da77fc5 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION=7.0.6.5 +VERSION=7.0.6.6 STABLE_VERSION=7.0.5.4 REVISION=$(shell git rev-parse HEAD) REVSHORT=$(shell echo $(REVISION) | head -c 7) diff --git a/ueforth/esp32/bindings.fs b/ueforth/esp32/bindings.fs index d439119..523ddb3 100644 --- a/ueforth/esp32/bindings.fs +++ b/ueforth/esp32/bindings.fs @@ -18,12 +18,10 @@ vocabulary Wire Wire definitions transfer{ Wire.begin Wire.setClock Wire.getClock Wire.setTimeout Wire.getTimeout - Wire.lastError Wire.getErrorText Wire.beginTransmission Wire.endTransmission - Wire.requestFrom Wire.writeTransmission - Wire.readTransmission Wire.write + Wire.requestFrom Wire.write Wire.available Wire.read - Wire.peek Wire.busy Wire.flush + Wire.peek Wire.flush }transfer forth definitions @@ -58,14 +56,15 @@ transfer{ forth definitions +DEFINED? SD_MMC.begin [IF] vocabulary SD_MMC SD_MMC definitions -( SD_MMC.begin - TODO: causing issues pulled in ) transfer{ - SD_MMC.cardType - SD_MMC.end + SD_MMC.begin SD_MMC.end SD_MMC.totalBytes SD_MMC.usedBytes + SD_MMC.cardType }transfer forth definitions +[THEN] vocabulary SPIFFS SPIFFS definitions transfer{ diff --git a/ueforth/esp32/template.ino b/ueforth/esp32/template.ino index 838a013..79b7597 100644 --- a/ueforth/esp32/template.ino +++ b/ueforth/esp32/template.ino @@ -28,12 +28,21 @@ #define ENABLE_WIFI_SUPPORT #define ENABLE_MDNS_SUPPORT #define ENABLE_WEBSERVER_SUPPORT -#define ENABLE_SDCARD_SUPPORT #define ENABLE_I2C_SUPPORT #define ENABLE_SOCKETS_SUPPORT #define ENABLE_FREERTOS_SUPPORT #define ENABLE_INTERRUPTS_SUPPORT +// SD_MMC does not work on ESP32-S2 / ESP32-C3 +#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +# define ENABLE_SDCARD_SUPPORT +#endif + +// ESP32-C3 has no DACs. +#if !defined(CONFIG_IDF_TARGET_ESP32C3) +# define ENABLE_DAC_SUPPORT +#endif + // Uncomment this #define for OLED Support. // You will need to install these libraries from the Library Manager: // Adafruit SSD1306 @@ -103,7 +112,6 @@ Y(digitalRead, n0 = digitalRead(n0)) \ Y(analogRead, n0 = analogRead(n0)) \ Y(pulseIn, n0 = pulseIn(n2, n1, n0); NIPn(2)) \ - Y(dacWrite, dacWrite(n1, n0); DROPn(2)) \ Y(ledcSetup, \ n0 = (cell_t) (1000000 * ledcSetup(n2, n1 / 1000.0, n0)); NIPn(2)) \ Y(ledcAttachPin, ledcAttachPin(n1, n0); DROPn(2)) \ @@ -146,6 +154,7 @@ X("RESIZE-FILE", RESIZE_FILE, cell_t fd = n0; DROP; n0 = ResizeFile(fd, tos)) \ X("FILE-SIZE", FILE_SIZE, struct stat st; w = fstat(n0, &st); \ n0 = (cell_t) st.st_size; PUSH w < 0 ? errno : 0) \ + OPTIONAL_DAC_SUPPORT \ OPTIONAL_SPIFFS_SUPPORT \ OPTIONAL_WIFI_SUPPORT \ OPTIONAL_MDNS_SUPPORT \ @@ -160,6 +169,13 @@ OPTIONAL_OLED_SUPPORT \ USER_WORDS +#ifndef ENABLE_DAC_SUPPORT +# define OPTIONAL_DAC_SUPPORT +# else +# define OPTIONAL_DAC_SUPPORT \ + Y(dacWrite, dacWrite(n1, n0); DROPn(2)) +#endif + #ifndef ENABLE_SPIFFS_SUPPORT // Provide a default failing SPIFFS.begin # define OPTIONAL_SPIFFS_SUPPORT \ @@ -279,20 +295,13 @@ X("Wire.getClock", WIRE_GET_CLOCK, PUSH Wire.getClock()) \ X("Wire.setTimeout", WIRE_SET_TIMEOUT, Wire.setTimeout(n0); DROP) \ X("Wire.getTimeout", WIRE_GET_TIMEOUT, PUSH Wire.getTimeout()) \ - X("Wire.lastError", WIRE_LAST_ERROR, PUSH Wire.lastError()) \ - X("Wire.getErrorText", WIRE_GET_ERROR_TEXT, PUSH Wire.getErrorText(n0)) \ X("Wire.beginTransmission", WIRE_BEGIN_TRANSMISSION, Wire.beginTransmission(n0); DROP) \ X("Wire.endTransmission", WIRE_END_TRANSMISSION, SET Wire.endTransmission(n0)) \ X("Wire.requestFrom", WIRE_REQUEST_FROM, n0 = Wire.requestFrom(n2, n1, n0); NIPn(2)) \ - X("Wire.writeTransmission", WIRE_WRITE_TRANSMISSION, \ - n0 = Wire.writeTransmission(n3, b2, n1, n0); NIPn(3)) \ - X("Wire.readTransmission", WIRE_READ_TRANSMISSION, \ - n0 = Wire.readTransmission(n4, b3, n2, n1, (uint32_t *) a0); NIPn(4)) \ X("Wire.write", WIRE_WRITE, n0 = Wire.write(b1, n0); NIP) \ X("Wire.available", WIRE_AVAILABLE, PUSH Wire.available()) \ X("Wire.read", WIRE_READ, PUSH Wire.read()) \ X("Wire.peek", WIRE_PEEK, PUSH Wire.peek()) \ - X("Wire.busy", WIRE_BUSY, PUSH Wire.busy()) \ X("Wire.flush", WIRE_FLUSH, Wire.flush()) #endif diff --git a/ueforth/site/ESP32forth.html b/ueforth/site/ESP32forth.html index dcb7ab7..511567a 100644 --- a/ueforth/site/ESP32forth.html +++ b/ueforth/site/ESP32forth.html @@ -211,6 +211,10 @@
GPIO
digitalWrite ( pin value -- ) Set GPIO pin state analogRead ( pin -- n ) Analog read from 0-4095 pulseIn ( pin value usec -- usec/0 ) Wait for a pulse + + +Available on devices other than ESP32-C3: +
 dacWrite ( pin 0-255 -- )  Write to DAC (pin 25, 26)
 
@@ -316,21 +320,27 @@
Wire
Wire.getClock ( -- frequency ) Wire.setTimeout ( ms -- ) Default is 50ms Wire.getTimeout ( -- ms ) -Wire.lastError ( -- n ) -Wire.getErrorText ( n -- z ) Wire.beginTransmission ( n -- ) Wire.endTransmission ( sendstop -- f ) Default is true Wire.requestFrom ( address quantity sendstop -- n ) -Wire.writeTransmission ( addr a n sendstop -- err ) -Wire.readTransmission ( addr a n sendstop acount -- err ) Wire.write ( a n -- n ) Wire.available ( -- f ) Wire.read ( -- ch ) Wire.peek ( -- ch ) -Wire.busy ( -- f ) Wire.flush ( -- ) +These words were available in v7.0.6.5 and before, +but are now deprecated as the underlying Arduino functions +have gone away in the v2.0.1 ESP32 Arduino library. +
+Wire.lastError ( -- n )
+Wire.getErrorText ( n -- z )
+Wire.busy ( -- f )
+Wire.writeTransmission ( addr a n sendstop -- err )
+Wire.readTransmission ( addr a n sendstop acount -- err )
+
+
Camera
These words are inside the camera vocabulary.
@@ -351,7 +361,8 @@ 
Camera Server
SD_MMC
-These words are inside the SD_MMC vocabulary. +These words are inside the SD_MMC vocabulary.
+Note, SD_MMC is unavailable on ESP32-S2 and ESP32-C3.
 SD_MMC.begin ( mount mode1bit )   default mode1bit=false
 SD_MMC.end ( -- )