Skip to content

Commit

Permalink
Fixed v2.0.1 build and ESP32-C3 and ESP32-S2 compile.
Browse files Browse the repository at this point in the history
Note ESP32-C3 and ESP32-S2 not yet tested on hardware.
  • Loading branch information
flagxor committed Dec 11, 2021
1 parent 830e6b4 commit 7fcc04a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ueforth/Makefile
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions ueforth/esp32/bindings.fs
Expand Up @@ -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

Expand Down Expand Up @@ -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{
Expand Down
27 changes: 18 additions & 9 deletions ueforth/esp32/template.ino
Expand Up @@ -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
Expand Down Expand Up @@ -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)) \
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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

Expand Down
23 changes: 17 additions & 6 deletions ueforth/site/ESP32forth.html
Expand Up @@ -211,6 +211,10 @@ <h5>GPIO</h5>
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
</pre>

Available on devices other than ESP32-C3:
<pre>
dacWrite ( pin 0-255 -- ) Write to DAC (pin 25, 26)
</pre>

Expand Down Expand Up @@ -316,21 +320,27 @@ <h5>Wire</h5>
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 ( -- )
</pre>

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.
<pre>
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 )
</pre>

<h5>Camera</h5>
These words are inside the <code>camera</code> vocabulary.
<pre>
Expand All @@ -351,7 +361,8 @@ <h5>Camera Server</h5>
</pre>

<h5>SD_MMC</h5>
These words are inside the <code>SD_MMC</code> vocabulary.
These words are inside the <code>SD_MMC</code> vocabulary.<br/>
Note, SD_MMC is unavailable on ESP32-S2 and ESP32-C3.
<pre>
SD_MMC.begin ( mount mode1bit ) default mode1bit=false
SD_MMC.end ( -- )
Expand Down

1 comment on commit 7fcc04a

@guidol70
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does compile with ESP Core v2.0.1 and also does startup fine on my Deneyap mini (ESP32-S2)
Wifi login does start and telnetd 23 server is working.

Many Thanks :)

Please sign in to comment.