More module decomposition.
Needs much more on device testing.
This commit is contained in:
74
Makefile
74
Makefile
@ -278,8 +278,7 @@ ESP32_BOOT = $(COMMON_PHASE1) \
|
|||||||
esp32/platform.fs \
|
esp32/platform.fs \
|
||||||
posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \
|
posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \
|
||||||
esp32/registers.fs esp32/timers.fs \
|
esp32/registers.fs esp32/timers.fs \
|
||||||
esp32/bterm.fs posix/telnetd.fs \
|
posix/telnetd.fs \
|
||||||
esp32/camera.fs esp32/camera_server.fs \
|
|
||||||
esp32/optionals.fs \
|
esp32/optionals.fs \
|
||||||
esp32/autoboot.fs common/fini.fs
|
esp32/autoboot.fs common/fini.fs
|
||||||
$(GEN)/esp32_boot.h: tools/source_to_string.js $(ESP32_BOOT) | $(GEN)
|
$(GEN)/esp32_boot.h: tools/source_to_string.js $(ESP32_BOOT) | $(GEN)
|
||||||
@ -298,19 +297,40 @@ $(GEN)/esp32_riscv-assembler.h: \
|
|||||||
$< riscv_assembler_source $(VERSION) $(REVISION) \
|
$< riscv_assembler_source $(VERSION) $(REVISION) \
|
||||||
esp32/optional/assemblers/riscv-assembler.fs >$@
|
esp32/optional/assemblers/riscv-assembler.fs >$@
|
||||||
|
|
||||||
|
$(GEN)/esp32_camera.h: \
|
||||||
|
tools/source_to_string.js esp32/optional/camera/camera.fs | $(GEN)
|
||||||
|
$< camera_source $(VERSION) $(REVISION) \
|
||||||
|
esp32/optional/camera/camera.fs \
|
||||||
|
esp32/optional/camera/camera_server.fs >$@
|
||||||
|
|
||||||
|
$(GEN)/esp32_oled.h: \
|
||||||
|
tools/source_to_string.js esp32/optional/oled/oled.fs | $(GEN)
|
||||||
|
$< camera_source $(VERSION) $(REVISION) \
|
||||||
|
esp32/optional/oled/oled.fs >$@
|
||||||
|
|
||||||
|
$(GEN)/esp32_spi-flash.h: \
|
||||||
|
tools/source_to_string.js esp32/optional/spi-flash/spi-flash.fs | $(GEN)
|
||||||
|
$< spi_flash_source $(VERSION) $(REVISION) \
|
||||||
|
esp32/optional/spi-flash/spi-flash.fs >$@
|
||||||
|
|
||||||
|
$(GEN)/esp32_serial-bluetooth.h: \
|
||||||
|
tools/source_to_string.js esp32/optional/serial-bluetooth/bterm.fs | $(GEN)
|
||||||
|
$< bterm_source $(VERSION) $(REVISION) \
|
||||||
|
esp32/optional/serial-bluetooth/bterm.fs >$@
|
||||||
|
|
||||||
OPTIONAL_MODULES = \
|
OPTIONAL_MODULES = \
|
||||||
|
$(ESP32)/ESP32forth/assemblers.h \
|
||||||
|
$(ESP32)/ESP32forth/camera.h \
|
||||||
$(ESP32)/ESP32forth/oled.h \
|
$(ESP32)/ESP32forth/oled.h \
|
||||||
$(ESP32)/ESP32forth/assemblers.h
|
$(ESP32)/ESP32forth/serial-bluetooth.h \
|
||||||
|
$(ESP32)/ESP32forth/spi-flash.h
|
||||||
|
|
||||||
add-optional: $(OPTIONAL_MODULES)
|
add-optional: $(OPTIONAL_MODULES)
|
||||||
|
|
||||||
drop-optional:
|
drop-optional:
|
||||||
rm -f $(OPTIONAL_MODULES)
|
rm -f $(OPTIONAL_MODULES)
|
||||||
|
|
||||||
$(ESP32)/ESP32forth/assemblers.h: $(ESP32)/ESP32forth/optional/assemblers.h
|
$(ESP32)/ESP32forth/%.h: $(ESP32)/ESP32forth/optional/%.h
|
||||||
cp $< $@
|
|
||||||
|
|
||||||
$(ESP32)/ESP32forth/oled.h: $(ESP32)/ESP32forth/optional/oled.h
|
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
$(GEN)/dump_web_opcodes: \
|
$(GEN)/dump_web_opcodes: \
|
||||||
@ -595,11 +615,40 @@ $(ESP32)/ESP32forth/optional/assemblers.h: \
|
|||||||
riscv_assembler=@$(GEN)/esp32_riscv-assembler.h \
|
riscv_assembler=@$(GEN)/esp32_riscv-assembler.h \
|
||||||
>$@
|
>$@
|
||||||
|
|
||||||
$(ESP32)/ESP32forth/optional/oled.h: \
|
$(ESP32)/ESP32forth/optional/camera.h: \
|
||||||
esp32/optional/oled.h | $(ESP32)/ESP32forth/optional
|
esp32/optional/camera/camera.h \
|
||||||
cat esp32/optional/oled.h | tools/replace.js \
|
$(GEN)/esp32_camera.h | $(ESP32)/ESP32forth/optional
|
||||||
|
cat esp32/optional/camera/camera.h | tools/replace.js \
|
||||||
VERSION=$(VERSION) \
|
VERSION=$(VERSION) \
|
||||||
REVISION=$(REVISION) \
|
REVISION=$(REVISION) \
|
||||||
|
camera=@$(GEN)/esp32_camera.h \
|
||||||
|
>$@
|
||||||
|
|
||||||
|
$(ESP32)/ESP32forth/optional/oled.h: \
|
||||||
|
esp32/optional/oled/oled.h \
|
||||||
|
$(GEN)/esp32_oled.h | $(ESP32)/ESP32forth/optional
|
||||||
|
cat esp32/optional/oled/oled.h | tools/replace.js \
|
||||||
|
VERSION=$(VERSION) \
|
||||||
|
REVISION=$(REVISION) \
|
||||||
|
oled=@$(GEN)/esp32_oled.h \
|
||||||
|
>$@
|
||||||
|
|
||||||
|
$(ESP32)/ESP32forth/optional/serial-bluetooth.h: \
|
||||||
|
esp32/optional/serial-bluetooth/serial-bluetooth.h \
|
||||||
|
$(GEN)/esp32_serial-bluetooth.h | $(ESP32)/ESP32forth/optional
|
||||||
|
cat esp32/optional/serial-bluetooth/serial-bluetooth.h | tools/replace.js \
|
||||||
|
VERSION=$(VERSION) \
|
||||||
|
REVISION=$(REVISION) \
|
||||||
|
serial_bluetooth=@$(GEN)/esp32_serial-bluetooth.h \
|
||||||
|
>$@
|
||||||
|
|
||||||
|
$(ESP32)/ESP32forth/optional/spi-flash.h: \
|
||||||
|
esp32/optional/spi-flash/spi-flash.h \
|
||||||
|
$(GEN)/esp32_spi-flash.h | $(ESP32)/ESP32forth/optional
|
||||||
|
cat esp32/optional/spi-flash/spi-flash.h | tools/replace.js \
|
||||||
|
VERSION=$(VERSION) \
|
||||||
|
REVISION=$(REVISION) \
|
||||||
|
spi_flash=@$(GEN)/esp32_spi-flash.h \
|
||||||
>$@
|
>$@
|
||||||
|
|
||||||
# ---- ESP32 ARDUINO BUILD AND FLASH ----
|
# ---- ESP32 ARDUINO BUILD AND FLASH ----
|
||||||
@ -697,7 +746,10 @@ $(ESP32)/ESP32forth.zip: \
|
|||||||
$(ESP32)/ESP32forth/README.txt \
|
$(ESP32)/ESP32forth/README.txt \
|
||||||
$(ESP32)/ESP32forth/optional/README-optional.txt \
|
$(ESP32)/ESP32forth/optional/README-optional.txt \
|
||||||
$(ESP32)/ESP32forth/optional/assemblers.h \
|
$(ESP32)/ESP32forth/optional/assemblers.h \
|
||||||
$(ESP32)/ESP32forth/optional/oled.h
|
$(ESP32)/ESP32forth/optional/camera.h \
|
||||||
|
$(ESP32)/ESP32forth/optional/oled.h \
|
||||||
|
$(ESP32)/ESP32forth/optional/serial-bluetooth.h \
|
||||||
|
$(ESP32)/ESP32forth/optional/spi-flash.h
|
||||||
cd $(ESP32) && rm -f ESP32forth.zip && zip -r ESP32forth.zip ESP32forth
|
cd $(ESP32) && rm -f ESP32forth.zip && zip -r ESP32forth.zip ESP32forth
|
||||||
|
|
||||||
# ---- Publish to Archive ----
|
# ---- Publish to Archive ----
|
||||||
|
|||||||
@ -622,8 +622,6 @@ e: test-esp32-forth-voclist
|
|||||||
out: editor
|
out: editor
|
||||||
out: streams
|
out: streams
|
||||||
out: tasks
|
out: tasks
|
||||||
out: oled
|
|
||||||
out: bluetooth
|
|
||||||
out: rtos
|
out: rtos
|
||||||
out: rmt
|
out: rmt
|
||||||
out: interrupts
|
out: interrupts
|
||||||
@ -631,7 +629,6 @@ e: test-esp32-forth-voclist
|
|||||||
out: Serial
|
out: Serial
|
||||||
out: ledc
|
out: ledc
|
||||||
out: SPIFFS
|
out: SPIFFS
|
||||||
out: spi_flash
|
|
||||||
out: SD_MMC
|
out: SD_MMC
|
||||||
out: SD
|
out: SD
|
||||||
out: WiFi
|
out: WiFi
|
||||||
@ -685,8 +682,6 @@ e: check-esp32-builtins
|
|||||||
;e
|
;e
|
||||||
|
|
||||||
e: check-esp32-bindings
|
e: check-esp32-bindings
|
||||||
out: oled
|
|
||||||
out: bluetooth
|
|
||||||
out: rtos
|
out: rtos
|
||||||
out: rmt
|
out: rmt
|
||||||
out: interrupts
|
out: interrupts
|
||||||
@ -694,7 +689,6 @@ e: check-esp32-bindings
|
|||||||
out: Serial
|
out: Serial
|
||||||
out: ledc
|
out: ledc
|
||||||
out: SPIFFS
|
out: SPIFFS
|
||||||
out: spi_flash
|
|
||||||
out: SD_MMC
|
out: SD_MMC
|
||||||
out: SD
|
out: SD
|
||||||
out: WiFi
|
out: WiFi
|
||||||
@ -706,10 +700,7 @@ e: check-esp32-bindings
|
|||||||
e: test-esp32-forth-namespace
|
e: test-esp32-forth-namespace
|
||||||
' forth list-from
|
' forth list-from
|
||||||
out: FORTH
|
out: FORTH
|
||||||
out: camera-server
|
|
||||||
out: camera
|
|
||||||
out: telnetd
|
out: telnetd
|
||||||
out: bterm
|
|
||||||
out: timers
|
out: timers
|
||||||
out: registers
|
out: registers
|
||||||
out: webui
|
out: webui
|
||||||
|
|||||||
@ -43,38 +43,6 @@ vocabulary SD_MMC SD_MMC definitions
|
|||||||
transfer SD_MMC-builtins
|
transfer SD_MMC-builtins
|
||||||
forth definitions
|
forth definitions
|
||||||
|
|
||||||
vocabulary spi_flash spi_flash definitions
|
|
||||||
transfer spi_flash-builtins
|
|
||||||
DEFINED? spi_flash_init [IF]
|
|
||||||
0 constant SPI_PARTITION_TYPE_APP
|
|
||||||
1 constant SPI_PARTITION_TYPE_DATA
|
|
||||||
$ff constant SPI_PARTITION_SUBTYPE_ANY
|
|
||||||
|
|
||||||
also structures
|
|
||||||
struct esp_partition_t
|
|
||||||
( Work around changing struct layout )
|
|
||||||
esp_partition_t_size 40 >= [IF]
|
|
||||||
ptr field p>gap
|
|
||||||
[THEN]
|
|
||||||
ptr field p>type
|
|
||||||
ptr field p>subtype
|
|
||||||
ptr field p>address
|
|
||||||
ptr field p>size
|
|
||||||
ptr field p>label
|
|
||||||
|
|
||||||
: p. ( part -- )
|
|
||||||
base @ >r >r decimal
|
|
||||||
." TYPE: " r@ p>type @ . ." SUBTYPE: " r@ p>subtype @ .
|
|
||||||
." ADDR: " r@ hex p>address @ . ." SIZE: " r@ p>size @ .
|
|
||||||
." LABEL: " r> p>label @ z>s type cr r> base ! ;
|
|
||||||
: list-partition-type ( type -- )
|
|
||||||
SPI_PARTITION_SUBTYPE_ANY 0 esp_partition_find
|
|
||||||
begin dup esp_partition_get p. esp_partition_next dup 0= until drop ;
|
|
||||||
: list-partitions SPI_PARTITION_TYPE_APP list-partition-type
|
|
||||||
SPI_PARTITION_TYPE_DATA list-partition-type ;
|
|
||||||
[THEN]
|
|
||||||
only forth definitions
|
|
||||||
|
|
||||||
vocabulary SPIFFS SPIFFS definitions
|
vocabulary SPIFFS SPIFFS definitions
|
||||||
transfer SPIFFS-builtins
|
transfer SPIFFS-builtins
|
||||||
forth definitions
|
forth definitions
|
||||||
@ -143,40 +111,6 @@ vocabulary rtos rtos definitions
|
|||||||
transfer rtos-builtins
|
transfer rtos-builtins
|
||||||
forth definitions
|
forth definitions
|
||||||
|
|
||||||
DEFINED? SerialBT.new [IF]
|
|
||||||
vocabulary bluetooth bluetooth definitions
|
|
||||||
transfer bluetooth-builtins
|
|
||||||
forth definitions
|
|
||||||
[ELSE]
|
|
||||||
internals definitions
|
|
||||||
transfer bluetooth-builtins
|
|
||||||
forth definitions
|
|
||||||
[THEN]
|
|
||||||
|
|
||||||
vocabulary oled oled definitions
|
|
||||||
transfer oled-builtins
|
|
||||||
DEFINED? OledNew [IF]
|
|
||||||
128 constant WIDTH
|
|
||||||
64 constant HEIGHT
|
|
||||||
-1 constant OledReset
|
|
||||||
0 constant BLACK
|
|
||||||
1 constant WHITE
|
|
||||||
1 constant SSD1306_EXTERNALVCC
|
|
||||||
2 constant SSD1306_SWITCHCAPVCC
|
|
||||||
: OledInit
|
|
||||||
OledAddr @ 0= if
|
|
||||||
WIDTH HEIGHT OledReset OledNew
|
|
||||||
SSD1306_SWITCHCAPVCC $3C OledBegin drop
|
|
||||||
then
|
|
||||||
OledCLS
|
|
||||||
2 OledTextsize ( Draw 2x Scale Text )
|
|
||||||
WHITE OledTextc ( Draw white text )
|
|
||||||
0 0 OledSetCursor ( Start at top-left corner )
|
|
||||||
z" *Esp32forth*" OledPrintln OledDisplay
|
|
||||||
;
|
|
||||||
[THEN]
|
|
||||||
forth definitions
|
|
||||||
|
|
||||||
internals definitions
|
internals definitions
|
||||||
( Heap Capabilities )
|
( Heap Capabilities )
|
||||||
1 0 lshift constant MALLOC_CAP_EXEC
|
1 0 lshift constant MALLOC_CAP_EXEC
|
||||||
|
|||||||
151
esp32/builtins.h
151
esp32/builtins.h
@ -29,27 +29,52 @@
|
|||||||
# define USER_WORDS
|
# define USER_WORDS
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Hook to pull in words from optional assemblers.h
|
// Hook to pull in words from optional assemblers.
|
||||||
# if __has_include("assemblers.h")
|
# if __has_include("assemblers.h")
|
||||||
# include "assemblers.h"
|
# include "assemblers.h"
|
||||||
# else
|
# else
|
||||||
# define OPTIONAL_ASSEMBLERS_SUPPORT
|
# define OPTIONAL_ASSEMBLERS_SUPPORT
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Hook to pull in words from optional oled.h
|
// Hook to pull in words from optional Oled support.
|
||||||
# if __has_include("oled.h")
|
# if __has_include("oled.h")
|
||||||
# include "oled.h"
|
# include "oled.h"
|
||||||
# else
|
# else
|
||||||
|
# define OPTIONAL_OLED_VOCABULARY
|
||||||
# define OPTIONAL_OLED_SUPPORT
|
# define OPTIONAL_OLED_SUPPORT
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
// Hook to pull in words from optional ESP32-CAM camera support.
|
||||||
|
# if __has_include("camera.h")
|
||||||
|
# include "camera.h"
|
||||||
|
# else
|
||||||
|
# define OPTIONAL_CAMERA_VOCABULARY
|
||||||
|
# define OPTIONAL_CAMERA_SUPPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// Hook to pull in words from optional serial bluetooth support.
|
||||||
|
# if __has_include("serial-bluetooth.h")
|
||||||
|
# include "bluetooth-serial.h"
|
||||||
|
# else
|
||||||
|
# define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT
|
||||||
|
# define OPTIONAL_BLUETOOTH_VOCABULARY
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// Hook to pull in words from optional SPI flash support.
|
||||||
|
# if __has_include("spi-flash.h")
|
||||||
|
# include "spi-flash.h"
|
||||||
|
# else
|
||||||
|
# define OPTIONAL_SPI_FLASH_SUPPORT
|
||||||
|
# define OPTIONAL_SPI_FLASH_VOCABULARY
|
||||||
|
# endif
|
||||||
|
|
||||||
static cell_t ResizeFile(cell_t fd, cell_t size);
|
static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PLATFORM_OPCODE_LIST \
|
#define PLATFORM_OPCODE_LIST \
|
||||||
USER_WORDS \
|
USER_WORDS \
|
||||||
OPTIONAL_ASSEMBLERS_SUPPORT \
|
EXTERNAL_OPTIONAL_MODULE_SUPPORT \
|
||||||
REQUIRED_PLATFORM_SUPPORT \
|
REQUIRED_PLATFORM_SUPPORT \
|
||||||
REQUIRED_ESP_SUPPORT \
|
REQUIRED_ESP_SUPPORT \
|
||||||
REQUIRED_MEMORY_SUPPORT \
|
REQUIRED_MEMORY_SUPPORT \
|
||||||
@ -66,17 +91,20 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
|||||||
OPTIONAL_SD_SUPPORT \
|
OPTIONAL_SD_SUPPORT \
|
||||||
OPTIONAL_SD_MMC_SUPPORT \
|
OPTIONAL_SD_MMC_SUPPORT \
|
||||||
OPTIONAL_I2C_SUPPORT \
|
OPTIONAL_I2C_SUPPORT \
|
||||||
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
|
|
||||||
OPTIONAL_CAMERA_SUPPORT \
|
|
||||||
OPTIONAL_SOCKETS_SUPPORT \
|
OPTIONAL_SOCKETS_SUPPORT \
|
||||||
OPTIONAL_FREERTOS_SUPPORT \
|
OPTIONAL_FREERTOS_SUPPORT \
|
||||||
OPTIONAL_INTERRUPTS_SUPPORT \
|
OPTIONAL_INTERRUPTS_SUPPORT \
|
||||||
OPTIONAL_RMT_SUPPORT \
|
OPTIONAL_RMT_SUPPORT \
|
||||||
OPTIONAL_OLED_SUPPORT \
|
|
||||||
OPTIONAL_SPI_FLASH_SUPPORT \
|
|
||||||
CALLING_OPCODE_LIST \
|
CALLING_OPCODE_LIST \
|
||||||
FLOATING_POINT_LIST
|
FLOATING_POINT_LIST
|
||||||
|
|
||||||
|
#define EXTERNAL_OPTIONAL_MODULE_SUPPORT \
|
||||||
|
OPTIONAL_ASSEMBLERS_SUPPORT \
|
||||||
|
OPTIONAL_CAMERA_SUPPORT \
|
||||||
|
OPTIONAL_SPI_FLASH_SUPPORT \
|
||||||
|
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
|
||||||
|
OPTIONAL_OLED_SUPPORT \
|
||||||
|
|
||||||
#define REQUIRED_MEMORY_SUPPORT \
|
#define REQUIRED_MEMORY_SUPPORT \
|
||||||
YV(internals, MALLOC, SET malloc(n0)) \
|
YV(internals, MALLOC, SET malloc(n0)) \
|
||||||
YV(internals, SYSFREE, free(a0); DROP) \
|
YV(internals, SYSFREE, free(a0); DROP) \
|
||||||
@ -211,68 +239,6 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
|||||||
Y(dacWrite, dacWrite(n1, n0); DROPn(2))
|
Y(dacWrite, dacWrite(n1, n0); DROPn(2))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_SPI_FLASH_SUPPORT
|
|
||||||
# define OPTIONAL_SPI_FLASH_SUPPORT
|
|
||||||
#else
|
|
||||||
# ifndef SIM_PRINT_ONLY
|
|
||||||
# include "esp_spi_flash.h"
|
|
||||||
# include "esp_partition.h"
|
|
||||||
# endif
|
|
||||||
# define OPTIONAL_SPI_FLASH_SUPPORT \
|
|
||||||
YV(spi_flash, spi_flash_init, spi_flash_init()) \
|
|
||||||
YV(spi_flash, spi_flash_get_chip_size, PUSH spi_flash_get_chip_size()) \
|
|
||||||
YV(spi_flash, spi_flash_erase_sector, n0 = spi_flash_erase_sector(n0)) \
|
|
||||||
YV(spi_flash, spi_flash_erase_range, n0 = spi_flash_erase_range(n1, n0); DROP) \
|
|
||||||
YV(spi_flash, spi_flash_write, n0 = spi_flash_write(n2, a1, n0); NIPn(2)) \
|
|
||||||
YV(spi_flash, spi_flash_write_encrypted, n0 = spi_flash_write_encrypted(n2, a1, n0); NIPn(2)) \
|
|
||||||
YV(spi_flash, spi_flash_read, n0 = spi_flash_read(n2, a1, n0); NIPn(2)) \
|
|
||||||
YV(spi_flash, spi_flash_read_encrypted, n0 = spi_flash_read_encrypted(n2, a1, n0); NIPn(2)) \
|
|
||||||
YV(spi_flash, spi_flash_mmap, \
|
|
||||||
n0 = spi_flash_mmap(n4, n3, (spi_flash_mmap_memory_t) n2, \
|
|
||||||
(const void **) a1, (spi_flash_mmap_handle_t *) a0); NIPn(4)) \
|
|
||||||
YV(spi_flash, spi_flash_mmap_pages, \
|
|
||||||
n0 = spi_flash_mmap_pages((const int *) a4, n3, (spi_flash_mmap_memory_t) n2, \
|
|
||||||
(const void **) a1, (spi_flash_mmap_handle_t *) a0); NIPn(4)) \
|
|
||||||
YV(spi_flash, spi_flash_munmap, spi_flash_munmap((spi_flash_mmap_handle_t) a0); DROP) \
|
|
||||||
YV(spi_flash, spi_flash_mmap_dump, spi_flash_mmap_dump()) \
|
|
||||||
YV(spi_flash, spi_flash_mmap_get_free_pages, \
|
|
||||||
n0 = spi_flash_mmap_get_free_pages((spi_flash_mmap_memory_t) n0)) \
|
|
||||||
YV(spi_flash, spi_flash_cache2phys, n0 = spi_flash_cache2phys(a0)) \
|
|
||||||
YV(spi_flash, spi_flash_phys2cache, \
|
|
||||||
n0 = (cell_t) spi_flash_phys2cache(n1, (spi_flash_mmap_memory_t) n0); NIP) \
|
|
||||||
YV(spi_flash, spi_flash_cache_enabled, PUSH spi_flash_cache_enabled()) \
|
|
||||||
YV(spi_flash, esp_partition_find, \
|
|
||||||
n0 = (cell_t) esp_partition_find((esp_partition_type_t) n2, \
|
|
||||||
(esp_partition_subtype_t) n1, c0); NIPn(2)) \
|
|
||||||
YV(spi_flash, esp_partition_find_first, \
|
|
||||||
n0 = (cell_t) esp_partition_find_first((esp_partition_type_t) n2, \
|
|
||||||
(esp_partition_subtype_t) n1, c0); NIPn(2)) \
|
|
||||||
YV(spi_flash, esp_partition_t_size, PUSH sizeof(esp_partition_t)) \
|
|
||||||
YV(spi_flash, esp_partition_get, \
|
|
||||||
n0 = (cell_t) esp_partition_get((esp_partition_iterator_t) a0)) \
|
|
||||||
YV(spi_flash, esp_partition_next, \
|
|
||||||
n0 = (cell_t) esp_partition_next((esp_partition_iterator_t) a0)) \
|
|
||||||
YV(spi_flash, esp_partition_iterator_release, \
|
|
||||||
esp_partition_iterator_release((esp_partition_iterator_t) a0); DROP) \
|
|
||||||
YV(spi_flash, esp_partition_verify, n0 = (cell_t) esp_partition_verify((esp_partition_t *) a0)) \
|
|
||||||
YV(spi_flash, esp_partition_read, \
|
|
||||||
n0 = esp_partition_read((const esp_partition_t *) a3, n2, a1, n0); NIPn(3)) \
|
|
||||||
YV(spi_flash, esp_partition_write, \
|
|
||||||
n0 = esp_partition_write((const esp_partition_t *) a3, n2, a1, n0); NIPn(3)) \
|
|
||||||
YV(spi_flash, esp_partition_erase_range, \
|
|
||||||
n0 = esp_partition_erase_range((const esp_partition_t *) a2, n1, n0); NIPn(2)) \
|
|
||||||
YV(spi_flash, esp_partition_mmap, \
|
|
||||||
n0 = esp_partition_mmap((const esp_partition_t *) a5, n4, n3, \
|
|
||||||
(spi_flash_mmap_memory_t) n2, \
|
|
||||||
(const void **) a1, \
|
|
||||||
(spi_flash_mmap_handle_t *) a0); NIPn(5)) \
|
|
||||||
YV(spi_flash, esp_partition_get_sha256, \
|
|
||||||
n0 = esp_partition_get_sha256((const esp_partition_t *) a1, b0); NIP) \
|
|
||||||
YV(spi_flash, esp_partition_check_identity, \
|
|
||||||
n0 = esp_partition_check_identity((const esp_partition_t *) a1, \
|
|
||||||
(const esp_partition_t *) a0); NIP)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENABLE_SPIFFS_SUPPORT
|
#ifndef ENABLE_SPIFFS_SUPPORT
|
||||||
// Provide a default failing SPIFFS.begin
|
// Provide a default failing SPIFFS.begin
|
||||||
# define OPTIONAL_SPIFFS_SUPPORT \
|
# define OPTIONAL_SPIFFS_SUPPORT \
|
||||||
@ -443,22 +409,6 @@ static void TimerInitNull(cell_t group, cell_t timer);
|
|||||||
YV(rmt, rmt_write_sample, n0 = rmt_write_sample((rmt_channel_t) n3, b2, n1, n0); NIPn(3))
|
YV(rmt, rmt_write_sample, n0 = rmt_write_sample((rmt_channel_t) n3, b2, n1, n0); NIPn(3))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_CAMERA_SUPPORT
|
|
||||||
# define OPTIONAL_CAMERA_SUPPORT
|
|
||||||
#else
|
|
||||||
# ifndef SIM_PRINT_ONLY
|
|
||||||
# include "esp_camera.h"
|
|
||||||
# endif
|
|
||||||
# define OPTIONAL_CAMERA_SUPPORT \
|
|
||||||
YV(camera, esp_camera_init, n0 = esp_camera_init((camera_config_t *) a0)) \
|
|
||||||
YV(camera, esp_camera_deinit, PUSH esp_camera_deinit()) \
|
|
||||||
YV(camera, esp_camera_fb_get, PUSH esp_camera_fb_get()) \
|
|
||||||
YV(camera, esp_camera_fb_return, esp_camera_fb_return((camera_fb_t *) a0); DROP) \
|
|
||||||
YV(camera, esp_camera_sensor_get, PUSH esp_camera_sensor_get()) \
|
|
||||||
YV(camera, esp_camera_save_to_nvs, n0 = esp_camera_save_to_nvs(c0)) \
|
|
||||||
YV(camera, esp_camera_load_from_nvs, n0 = esp_camera_load_from_nvs(c0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENABLE_SOCKETS_SUPPORT
|
#ifndef ENABLE_SOCKETS_SUPPORT
|
||||||
# define OPTIONAL_SOCKETS_SUPPORT
|
# define OPTIONAL_SOCKETS_SUPPORT
|
||||||
#else
|
#else
|
||||||
@ -548,37 +498,6 @@ static void TimerInitNull(cell_t group, cell_t timer);
|
|||||||
XV(Wire, "Wire.flush", WIRE_FLUSH, Wire.flush())
|
XV(Wire, "Wire.flush", WIRE_FLUSH, Wire.flush())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_SERIAL_BLUETOOTH_SUPPORT
|
|
||||||
# define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT
|
|
||||||
#else
|
|
||||||
# ifndef SIM_PRINT_ONLY
|
|
||||||
# include "esp_bt_device.h"
|
|
||||||
# include "BluetoothSerial.h"
|
|
||||||
# define bt0 ((BluetoothSerial *) a0)
|
|
||||||
# endif
|
|
||||||
# define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
|
|
||||||
XV(bluetooth, "SerialBT.new", SERIALBT_NEW, PUSH new BluetoothSerial()) \
|
|
||||||
XV(bluetooth, "SerialBT.delete", SERIALBT_DELETE, delete bt0; DROP) \
|
|
||||||
XV(bluetooth, "SerialBT.begin", SERIALBT_BEGIN, n0 = bt0->begin(c2, n1); NIPn(2)) \
|
|
||||||
XV(bluetooth, "SerialBT.end", SERIALBT_END, bt0->end(); DROP) \
|
|
||||||
XV(bluetooth, "SerialBT.available", SERIALBT_AVAILABLE, n0 = bt0->available()) \
|
|
||||||
XV(bluetooth, "SerialBT.readBytes", SERIALBT_READ_BYTES, n0 = bt0->readBytes(b2, n1); NIPn(2)) \
|
|
||||||
XV(bluetooth, "SerialBT.write", SERIALBT_WRITE, n0 = bt0->write(b2, n1); NIPn(2)) \
|
|
||||||
XV(bluetooth, "SerialBT.flush", SERIALBT_FLUSH, bt0->flush(); DROP) \
|
|
||||||
XV(bluetooth, "SerialBT.hasClient", SERIALBT_HAS_CLIENT, n0 = bt0->hasClient()) \
|
|
||||||
XV(bluetooth, "SerialBT.enableSSP", SERIALBT_ENABLE_SSP, bt0->enableSSP(); DROP) \
|
|
||||||
XV(bluetooth, "SerialBT.setPin", SERIALBT_SET_PIN, n0 = bt0->setPin(c1); NIP) \
|
|
||||||
XV(bluetooth, "SerialBT.unpairDevice", SERIALBT_UNPAIR_DEVICE, \
|
|
||||||
n0 = bt0->unpairDevice(b1); NIP) \
|
|
||||||
XV(bluetooth, "SerialBT.connect", SERIALBT_CONNECT, n0 = bt0->connect(c1); NIP) \
|
|
||||||
XV(bluetooth, "SerialBT.connectAddr", SERIALBT_CONNECT_ADDR, n0 = bt0->connect(b1); NIP) \
|
|
||||||
XV(bluetooth, "SerialBT.disconnect", SERIALBT_DISCONNECT, n0 = bt0->disconnect()) \
|
|
||||||
XV(bluetooth, "SerialBT.connected", SERIALBT_CONNECTED, n0 = bt0->connected(n1); NIP) \
|
|
||||||
XV(bluetooth, "SerialBT.isReady", SERIALBT_IS_READY, n0 = bt0->isReady(n2, n1); NIPn(2)) \
|
|
||||||
/* Bluetooth */ \
|
|
||||||
YV(bluetooth, esp_bt_dev_get_address, PUSH esp_bt_dev_get_address())
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ENABLE_WIFI_SUPPORT
|
#ifndef ENABLE_WIFI_SUPPORT
|
||||||
# define OPTIONAL_WIFI_SUPPORT
|
# define OPTIONAL_WIFI_SUPPORT
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -10,6 +10,7 @@ into the parent directory, next to the ESPforth.ino file.
|
|||||||
|
|
||||||
These are the current optional modules:
|
These are the current optional modules:
|
||||||
* assemblers.h - Assemblers for ESP32 Xtensa and ESP32 RISC-V
|
* assemblers.h - Assemblers for ESP32 Xtensa and ESP32 RISC-V
|
||||||
|
* camera.h - Support for the ESP32-CAM camera
|
||||||
* oled.h - Support for the SSD1306 Oled
|
* oled.h - Support for the SSD1306 Oled
|
||||||
|
|
||||||
Initially ESP32forth focused on a minimal C kernel, with most functionality
|
Initially ESP32forth focused on a minimal C kernel, with most functionality
|
||||||
|
|||||||
35
esp32/optional/camera/camera.h
Normal file
35
esp32/optional/camera/camera.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2023 Bradley D. Nelson
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ESP32forth ESP32-CAM Camera v{{VERSION}}
|
||||||
|
* Revision: {{REVISION}}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIM_PRINT_ONLY
|
||||||
|
# include "esp_camera.h"
|
||||||
|
#endif
|
||||||
|
#define OPTIONAL_CAMERA_VOCABULARY V(camera)
|
||||||
|
#define OPTIONAL_CAMERA_SUPPORT \
|
||||||
|
XV(internals, "camera-source", CAMERA_SOURCE, \
|
||||||
|
PUSH camera_source; PUSH sizeof(camera_source) - 1) \
|
||||||
|
YV(camera, esp_camera_init, n0 = esp_camera_init((camera_config_t *) a0)) \
|
||||||
|
YV(camera, esp_camera_deinit, PUSH esp_camera_deinit()) \
|
||||||
|
YV(camera, esp_camera_fb_get, PUSH esp_camera_fb_get()) \
|
||||||
|
YV(camera, esp_camera_fb_return, esp_camera_fb_return((camera_fb_t *) a0); DROP) \
|
||||||
|
YV(camera, esp_camera_sensor_get, PUSH esp_camera_sensor_get()) \
|
||||||
|
YV(camera, esp_camera_save_to_nvs, n0 = esp_camera_save_to_nvs(c0)) \
|
||||||
|
YV(camera, esp_camera_load_from_nvs, n0 = esp_camera_load_from_nvs(c0))
|
||||||
|
|
||||||
|
{{camera}}
|
||||||
37
esp32/optional/oled/oled.fs
Normal file
37
esp32/optional/oled/oled.fs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
\ Copyright 2023 Bradley D. Nelson
|
||||||
|
\
|
||||||
|
\ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
\ you may not use this file except in compliance with the License.
|
||||||
|
\ You may obtain a copy of the License at
|
||||||
|
\
|
||||||
|
\ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
\
|
||||||
|
\ Unless required by applicable law or agreed to in writing, software
|
||||||
|
\ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
\ See the License for the specific language governing permissions and
|
||||||
|
\ limitations under the License.
|
||||||
|
|
||||||
|
vocabulary oled oled definitions
|
||||||
|
transfer oled-builtins
|
||||||
|
DEFINED? OledNew [IF]
|
||||||
|
128 constant WIDTH
|
||||||
|
64 constant HEIGHT
|
||||||
|
-1 constant OledReset
|
||||||
|
0 constant BLACK
|
||||||
|
1 constant WHITE
|
||||||
|
1 constant SSD1306_EXTERNALVCC
|
||||||
|
2 constant SSD1306_SWITCHCAPVCC
|
||||||
|
: OledInit
|
||||||
|
OledAddr @ 0= if
|
||||||
|
WIDTH HEIGHT OledReset OledNew
|
||||||
|
SSD1306_SWITCHCAPVCC $3C OledBegin drop
|
||||||
|
then
|
||||||
|
OledCLS
|
||||||
|
2 OledTextsize ( Draw 2x Scale Text )
|
||||||
|
WHITE OledTextc ( Draw white text )
|
||||||
|
0 0 OledSetCursor ( Start at top-left corner )
|
||||||
|
z" *Esp32forth*" OledPrintln OledDisplay
|
||||||
|
;
|
||||||
|
[THEN]
|
||||||
|
forth definitions
|
||||||
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ESP32forth Assemblers v{{VERSION}}
|
* ESP32forth Oled v{{VERSION}}
|
||||||
* Revision: {{REVISION}}
|
* Revision: {{REVISION}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -22,12 +22,15 @@
|
|||||||
// Adafruit GFX Library
|
// Adafruit GFX Library
|
||||||
// Adafruit BusIO
|
// Adafruit BusIO
|
||||||
|
|
||||||
# ifndef SIM_PRINT_ONLY
|
#ifndef SIM_PRINT_ONLY
|
||||||
# include <Adafruit_GFX.h>
|
# include <Adafruit_GFX.h>
|
||||||
# include <Adafruit_SSD1306.h>
|
# include <Adafruit_SSD1306.h>
|
||||||
static Adafruit_SSD1306 *oled_display = 0;
|
static Adafruit_SSD1306 *oled_display = 0;
|
||||||
# endif
|
#endif
|
||||||
# define OPTIONAL_OLED_SUPPORT \
|
#define OPTIONAL_OLED_VOCABULARY V(oled)
|
||||||
|
#define OPTIONAL_OLED_SUPPORT \
|
||||||
|
XV(internals, "oled-source", OLED_SOURCE, \
|
||||||
|
PUSH oled_source; PUSH sizeof(oled_source) - 1) \
|
||||||
YV(oled, OledAddr, PUSH &oled_display) \
|
YV(oled, OledAddr, PUSH &oled_display) \
|
||||||
YV(oled, OledNew, oled_display = new Adafruit_SSD1306(n2, n1, &Wire, n0); DROPn(3)) \
|
YV(oled, OledNew, oled_display = new Adafruit_SSD1306(n2, n1, &Wire, n0); DROPn(3)) \
|
||||||
YV(oled, OledDelete, delete oled_display) \
|
YV(oled, OledDelete, delete oled_display) \
|
||||||
@ -51,3 +54,5 @@ static Adafruit_SSD1306 *oled_display = 0;
|
|||||||
YV(oled, OledRectF, oled_display->fillRect(n4, n3, n2, n1, n0); DROPn(3)) \
|
YV(oled, OledRectF, oled_display->fillRect(n4, n3, n2, n1, n0); DROPn(3)) \
|
||||||
YV(oled, OledRectR, oled_display->drawRoundRect(n5, n4, n3, n2, n1, n0); DROPn(5)) \
|
YV(oled, OledRectR, oled_display->drawRoundRect(n5, n4, n3, n2, n1, n0); DROPn(5)) \
|
||||||
YV(oled, OledRectRF, oled_display->fillRoundRect(n5, n4, n3, n2, n1, n0 ); DROPn(5))
|
YV(oled, OledRectRF, oled_display->fillRoundRect(n5, n4, n3, n2, n1, n0 ); DROPn(5))
|
||||||
|
|
||||||
|
{{oled}}
|
||||||
23
esp32/optional/serial-bluetooth/serial-bluetooth.fs
Normal file
23
esp32/optional/serial-bluetooth/serial-bluetooth.fs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
\ Copyright 2023 Bradley D. Nelson
|
||||||
|
\
|
||||||
|
\ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
\ you may not use this file except in compliance with the License.
|
||||||
|
\ You may obtain a copy of the License at
|
||||||
|
\
|
||||||
|
\ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
\
|
||||||
|
\ Unless required by applicable law or agreed to in writing, software
|
||||||
|
\ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
\ See the License for the specific language governing permissions and
|
||||||
|
\ limitations under the License.
|
||||||
|
|
||||||
|
DEFINED? SerialBT.new [IF]
|
||||||
|
vocabulary bluetooth bluetooth definitions
|
||||||
|
transfer bluetooth-builtins
|
||||||
|
forth definitions
|
||||||
|
[ELSE]
|
||||||
|
internals definitions
|
||||||
|
transfer bluetooth-builtins
|
||||||
|
forth definitions
|
||||||
|
[THEN]
|
||||||
51
esp32/optional/serial-bluetooth/serial-bluetooth.h
Normal file
51
esp32/optional/serial-bluetooth/serial-bluetooth.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright 2022 Bradley D. Nelson
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ESP32forth Serial Bluetooth v{{VERSION}}
|
||||||
|
* Revision: {{REVISION}}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIM_PRINT_ONLY
|
||||||
|
# include "esp_bt_device.h"
|
||||||
|
# include "BluetoothSerial.h"
|
||||||
|
# define bt0 ((BluetoothSerial *) a0)
|
||||||
|
#endif
|
||||||
|
#define OPTIONAL_BLUETOOTH_VOCABULARY V(bluetooth)
|
||||||
|
#define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
|
||||||
|
XV(internals, "bterm-source", BTERM_SOURCE, \
|
||||||
|
PUSH bterm_source; PUSH sizeof(bterm_source) - 1) \
|
||||||
|
XV(bluetooth, "SerialBT.new", SERIALBT_NEW, PUSH new BluetoothSerial()) \
|
||||||
|
XV(bluetooth, "SerialBT.delete", SERIALBT_DELETE, delete bt0; DROP) \
|
||||||
|
XV(bluetooth, "SerialBT.begin", SERIALBT_BEGIN, n0 = bt0->begin(c2, n1); NIPn(2)) \
|
||||||
|
XV(bluetooth, "SerialBT.end", SERIALBT_END, bt0->end(); DROP) \
|
||||||
|
XV(bluetooth, "SerialBT.available", SERIALBT_AVAILABLE, n0 = bt0->available()) \
|
||||||
|
XV(bluetooth, "SerialBT.readBytes", SERIALBT_READ_BYTES, n0 = bt0->readBytes(b2, n1); NIPn(2)) \
|
||||||
|
XV(bluetooth, "SerialBT.write", SERIALBT_WRITE, n0 = bt0->write(b2, n1); NIPn(2)) \
|
||||||
|
XV(bluetooth, "SerialBT.flush", SERIALBT_FLUSH, bt0->flush(); DROP) \
|
||||||
|
XV(bluetooth, "SerialBT.hasClient", SERIALBT_HAS_CLIENT, n0 = bt0->hasClient()) \
|
||||||
|
XV(bluetooth, "SerialBT.enableSSP", SERIALBT_ENABLE_SSP, bt0->enableSSP(); DROP) \
|
||||||
|
XV(bluetooth, "SerialBT.setPin", SERIALBT_SET_PIN, n0 = bt0->setPin(c1); NIP) \
|
||||||
|
XV(bluetooth, "SerialBT.unpairDevice", SERIALBT_UNPAIR_DEVICE, \
|
||||||
|
n0 = bt0->unpairDevice(b1); NIP) \
|
||||||
|
XV(bluetooth, "SerialBT.connect", SERIALBT_CONNECT, n0 = bt0->connect(c1); NIP) \
|
||||||
|
XV(bluetooth, "SerialBT.connectAddr", SERIALBT_CONNECT_ADDR, n0 = bt0->connect(b1); NIP) \
|
||||||
|
XV(bluetooth, "SerialBT.disconnect", SERIALBT_DISCONNECT, n0 = bt0->disconnect()) \
|
||||||
|
XV(bluetooth, "SerialBT.connected", SERIALBT_CONNECTED, n0 = bt0->connected(n1); NIP) \
|
||||||
|
XV(bluetooth, "SerialBT.isReady", SERIALBT_IS_READY, n0 = bt0->isReady(n2, n1); NIPn(2)) \
|
||||||
|
/* Bluetooth */ \
|
||||||
|
YV(bluetooth, esp_bt_dev_get_address, PUSH esp_bt_dev_get_address())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{{serial_bluetooth}}
|
||||||
45
esp32/optional/spi-flash/spi-flash.fs
Normal file
45
esp32/optional/spi-flash/spi-flash.fs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
\ Copyright 2023 Bradley D. Nelson
|
||||||
|
\
|
||||||
|
\ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
\ you may not use this file except in compliance with the License.
|
||||||
|
\ You may obtain a copy of the License at
|
||||||
|
\
|
||||||
|
\ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
\
|
||||||
|
\ Unless required by applicable law or agreed to in writing, software
|
||||||
|
\ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
\ See the License for the specific language governing permissions and
|
||||||
|
\ limitations under the License.
|
||||||
|
|
||||||
|
vocabulary spi_flash spi_flash definitions
|
||||||
|
transfer spi_flash-builtins
|
||||||
|
DEFINED? spi_flash_init [IF]
|
||||||
|
0 constant SPI_PARTITION_TYPE_APP
|
||||||
|
1 constant SPI_PARTITION_TYPE_DATA
|
||||||
|
$ff constant SPI_PARTITION_SUBTYPE_ANY
|
||||||
|
|
||||||
|
also structures
|
||||||
|
struct esp_partition_t
|
||||||
|
( Work around changing struct layout )
|
||||||
|
esp_partition_t_size 40 >= [IF]
|
||||||
|
ptr field p>gap
|
||||||
|
[THEN]
|
||||||
|
ptr field p>type
|
||||||
|
ptr field p>subtype
|
||||||
|
ptr field p>address
|
||||||
|
ptr field p>size
|
||||||
|
ptr field p>label
|
||||||
|
|
||||||
|
: p. ( part -- )
|
||||||
|
base @ >r >r decimal
|
||||||
|
." TYPE: " r@ p>type @ . ." SUBTYPE: " r@ p>subtype @ .
|
||||||
|
." ADDR: " r@ hex p>address @ . ." SIZE: " r@ p>size @ .
|
||||||
|
." LABEL: " r> p>label @ z>s type cr r> base ! ;
|
||||||
|
: list-partition-type ( type -- )
|
||||||
|
SPI_PARTITION_SUBTYPE_ANY 0 esp_partition_find
|
||||||
|
begin dup esp_partition_get p. esp_partition_next dup 0= until drop ;
|
||||||
|
: list-partitions SPI_PARTITION_TYPE_APP list-partition-type
|
||||||
|
SPI_PARTITION_TYPE_DATA list-partition-type ;
|
||||||
|
[THEN]
|
||||||
|
only forth definitions
|
||||||
81
esp32/optional/spi-flash/spi-flash.h
Normal file
81
esp32/optional/spi-flash/spi-flash.h
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Copyright 2023 Bradley D. Nelson
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ESP32forth SPI Flash v{{VERSION}}
|
||||||
|
* Revision: {{REVISION}}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIM_PRINT_ONLY
|
||||||
|
# include "esp_spi_flash.h"
|
||||||
|
# include "esp_partition.h"
|
||||||
|
#endif
|
||||||
|
#define OPTIONAL_SPI_FLASH_VOCABULARY V(spi_flash)
|
||||||
|
#define OPTIONAL_SPI_FLASH_SUPPORT \
|
||||||
|
XV(internals, "spi_flash-source", SPI_FLASH_SOURCE, \
|
||||||
|
PUSH spi_flash_source; PUSH sizeof(spi_flash_source) - 1) \
|
||||||
|
YV(spi_flash, spi_flash_init, spi_flash_init()) \
|
||||||
|
YV(spi_flash, spi_flash_get_chip_size, PUSH spi_flash_get_chip_size()) \
|
||||||
|
YV(spi_flash, spi_flash_erase_sector, n0 = spi_flash_erase_sector(n0)) \
|
||||||
|
YV(spi_flash, spi_flash_erase_range, n0 = spi_flash_erase_range(n1, n0); DROP) \
|
||||||
|
YV(spi_flash, spi_flash_write, n0 = spi_flash_write(n2, a1, n0); NIPn(2)) \
|
||||||
|
YV(spi_flash, spi_flash_write_encrypted, n0 = spi_flash_write_encrypted(n2, a1, n0); NIPn(2)) \
|
||||||
|
YV(spi_flash, spi_flash_read, n0 = spi_flash_read(n2, a1, n0); NIPn(2)) \
|
||||||
|
YV(spi_flash, spi_flash_read_encrypted, n0 = spi_flash_read_encrypted(n2, a1, n0); NIPn(2)) \
|
||||||
|
YV(spi_flash, spi_flash_mmap, \
|
||||||
|
n0 = spi_flash_mmap(n4, n3, (spi_flash_mmap_memory_t) n2, \
|
||||||
|
(const void **) a1, (spi_flash_mmap_handle_t *) a0); NIPn(4)) \
|
||||||
|
YV(spi_flash, spi_flash_mmap_pages, \
|
||||||
|
n0 = spi_flash_mmap_pages((const int *) a4, n3, (spi_flash_mmap_memory_t) n2, \
|
||||||
|
(const void **) a1, (spi_flash_mmap_handle_t *) a0); NIPn(4)) \
|
||||||
|
YV(spi_flash, spi_flash_munmap, spi_flash_munmap((spi_flash_mmap_handle_t) a0); DROP) \
|
||||||
|
YV(spi_flash, spi_flash_mmap_dump, spi_flash_mmap_dump()) \
|
||||||
|
YV(spi_flash, spi_flash_mmap_get_free_pages, \
|
||||||
|
n0 = spi_flash_mmap_get_free_pages((spi_flash_mmap_memory_t) n0)) \
|
||||||
|
YV(spi_flash, spi_flash_cache2phys, n0 = spi_flash_cache2phys(a0)) \
|
||||||
|
YV(spi_flash, spi_flash_phys2cache, \
|
||||||
|
n0 = (cell_t) spi_flash_phys2cache(n1, (spi_flash_mmap_memory_t) n0); NIP) \
|
||||||
|
YV(spi_flash, spi_flash_cache_enabled, PUSH spi_flash_cache_enabled()) \
|
||||||
|
YV(spi_flash, esp_partition_find, \
|
||||||
|
n0 = (cell_t) esp_partition_find((esp_partition_type_t) n2, \
|
||||||
|
(esp_partition_subtype_t) n1, c0); NIPn(2)) \
|
||||||
|
YV(spi_flash, esp_partition_find_first, \
|
||||||
|
n0 = (cell_t) esp_partition_find_first((esp_partition_type_t) n2, \
|
||||||
|
(esp_partition_subtype_t) n1, c0); NIPn(2)) \
|
||||||
|
YV(spi_flash, esp_partition_t_size, PUSH sizeof(esp_partition_t)) \
|
||||||
|
YV(spi_flash, esp_partition_get, \
|
||||||
|
n0 = (cell_t) esp_partition_get((esp_partition_iterator_t) a0)) \
|
||||||
|
YV(spi_flash, esp_partition_next, \
|
||||||
|
n0 = (cell_t) esp_partition_next((esp_partition_iterator_t) a0)) \
|
||||||
|
YV(spi_flash, esp_partition_iterator_release, \
|
||||||
|
esp_partition_iterator_release((esp_partition_iterator_t) a0); DROP) \
|
||||||
|
YV(spi_flash, esp_partition_verify, n0 = (cell_t) esp_partition_verify((esp_partition_t *) a0)) \
|
||||||
|
YV(spi_flash, esp_partition_read, \
|
||||||
|
n0 = esp_partition_read((const esp_partition_t *) a3, n2, a1, n0); NIPn(3)) \
|
||||||
|
YV(spi_flash, esp_partition_write, \
|
||||||
|
n0 = esp_partition_write((const esp_partition_t *) a3, n2, a1, n0); NIPn(3)) \
|
||||||
|
YV(spi_flash, esp_partition_erase_range, \
|
||||||
|
n0 = esp_partition_erase_range((const esp_partition_t *) a2, n1, n0); NIPn(2)) \
|
||||||
|
YV(spi_flash, esp_partition_mmap, \
|
||||||
|
n0 = esp_partition_mmap((const esp_partition_t *) a5, n4, n3, \
|
||||||
|
(spi_flash_mmap_memory_t) n2, \
|
||||||
|
(const void **) a1, \
|
||||||
|
(spi_flash_mmap_handle_t *) a0); NIPn(5)) \
|
||||||
|
YV(spi_flash, esp_partition_get_sha256, \
|
||||||
|
n0 = esp_partition_get_sha256((const esp_partition_t *) a1, b0); NIP) \
|
||||||
|
YV(spi_flash, esp_partition_check_identity, \
|
||||||
|
n0 = esp_partition_check_identity((const esp_partition_t *) a1, \
|
||||||
|
(const esp_partition_t *) a0); NIP)
|
||||||
|
|
||||||
|
{{spi_flash}}
|
||||||
@ -21,3 +21,19 @@ internals DEFINED? xtensa-assembler-source [IF]
|
|||||||
internals DEFINED? riscv-assembler-source [IF]
|
internals DEFINED? riscv-assembler-source [IF]
|
||||||
riscv-assembler-source evaluate
|
riscv-assembler-source evaluate
|
||||||
[THEN] forth
|
[THEN] forth
|
||||||
|
|
||||||
|
internals DEFINED? camera-source [IF]
|
||||||
|
camera-source evaluate
|
||||||
|
[THEN] forth
|
||||||
|
|
||||||
|
internals DEFINED? oled-source [IF]
|
||||||
|
oled-source evaluate
|
||||||
|
[THEN] forth
|
||||||
|
|
||||||
|
internals DEFINED? serial-bluetooth-source [IF]
|
||||||
|
serial-bluetooth-source evaluate
|
||||||
|
[THEN] forth
|
||||||
|
|
||||||
|
internals DEFINED? spi-flash-source [IF]
|
||||||
|
spi-flash-source evaluate
|
||||||
|
[THEN] forth
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
#define ENABLE_INTERRUPTS_SUPPORT
|
#define ENABLE_INTERRUPTS_SUPPORT
|
||||||
#define ENABLE_LEDC_SUPPORT
|
#define ENABLE_LEDC_SUPPORT
|
||||||
#define ENABLE_SD_SUPPORT
|
#define ENABLE_SD_SUPPORT
|
||||||
#define ENABLE_SPI_FLASH_SUPPORT
|
|
||||||
#define ENABLE_ESP32_FORTH_FAULT_HANDLING
|
#define ENABLE_ESP32_FORTH_FAULT_HANDLING
|
||||||
|
|
||||||
// SD_MMC does not work on ESP32-S2 / ESP32-C3
|
// SD_MMC does not work on ESP32-S2 / ESP32-C3
|
||||||
@ -57,22 +56,6 @@
|
|||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3)
|
#if !defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For now assume only boards with PSRAM should enable
|
|
||||||
// camera support and BluetoothSerial.
|
|
||||||
// ESP32-CAM always have PSRAM, but so do WROVER boards,
|
|
||||||
// so this isn't an ideal indicator.
|
|
||||||
// Also limiting to ESP32 classic only, as these can't be ESP32-CAM.
|
|
||||||
// Some boards (e.g. ESP32-S2-WROVER) don't seem to have
|
|
||||||
// built the serial library, so check if its enabled as well.
|
|
||||||
#if (defined(CONFIG_IDF_TARGET_ESP32) && defined(BOARD_HAS_PSRAM)) || defined(SIM_PRINT_ONLY)
|
|
||||||
# define ENABLE_CAMERA_SUPPORT
|
|
||||||
# if (defined(CONFIG_BT_ENABLED) && \
|
|
||||||
defined(CONFIG_BLUEDROID_ENABLED)) || \
|
|
||||||
defined(SIM_PRINT_ONLY)
|
|
||||||
# define ENABLE_SERIAL_BLUETOOTH_SUPPORT
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(USER_VOCABULARIES)
|
#if !defined(USER_VOCABULARIES)
|
||||||
# define USER_VOCABULARIES
|
# define USER_VOCABULARIES
|
||||||
#endif
|
#endif
|
||||||
@ -116,6 +99,10 @@
|
|||||||
#define VOCABULARY_LIST \
|
#define VOCABULARY_LIST \
|
||||||
V(forth) V(internals) \
|
V(forth) V(internals) \
|
||||||
V(rtos) V(SPIFFS) V(serial) V(SD) V(SD_MMC) V(ESP) \
|
V(rtos) V(SPIFFS) V(serial) V(SD) V(SD_MMC) V(ESP) \
|
||||||
V(ledc) V(Wire) V(WiFi) V(bluetooth) V(sockets) V(oled) \
|
V(ledc) V(Wire) V(WiFi) V(sockets) \
|
||||||
V(rmt) V(interrupts) V(spi_flash) V(camera) V(timers) \
|
V(rmt) V(interrupts) V(timers) \
|
||||||
|
OPTIONAL_CAMERA_VOCABULARY \
|
||||||
|
OPTIONAL_BLUETOOTH_VOCABULARY \
|
||||||
|
OPTIONAL_OLED_VOCABULARY \
|
||||||
|
OPTIONAL_SPI_FLASH_VOCABULARY \
|
||||||
USER_VOCABULARIES
|
USER_VOCABULARIES
|
||||||
|
|||||||
@ -17,14 +17,24 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define SIM_PRINT_ONLY
|
#define SIM_PRINT_ONLY
|
||||||
#define ENABLE_OLED_SUPPORT
|
|
||||||
#include "esp32/platform.h"
|
#include "esp32/platform.h"
|
||||||
#include "esp32/options.h"
|
#include "esp32/options.h"
|
||||||
#define CALLING_OPCODE_LIST
|
#define CALLING_OPCODE_LIST
|
||||||
#define FLOATING_POINT_LIST
|
#define FLOATING_POINT_LIST
|
||||||
#define USER_WORDS
|
#define USER_WORDS
|
||||||
|
|
||||||
#define OPTIONAL_ASSEMBLERS_SUPPORT
|
#define OPTIONAL_ASSEMBLERS_SUPPORT
|
||||||
#define OPTIONAL_OLED_SUPPORT
|
#define OPTIONAL_OLED_SUPPORT
|
||||||
|
#define OPTIONAL_CAMERA_SUPPORT
|
||||||
|
#define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT
|
||||||
|
#define OPTIONAL_SPI_FLASH_SUPPORT
|
||||||
|
|
||||||
|
#define OPTIONAL_OLED_VOCABULARY
|
||||||
|
#define OPTIONAL_CAMERA_VOCABULARY
|
||||||
|
#define OPTIONAL_BLUETOOTH_VOCABULARY
|
||||||
|
#define OPTIONAL_SPI_FLASH_VOCABULARY
|
||||||
|
|
||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
|
|
||||||
#define XV(flags, name, op, code) Z(flags, name, op, code)
|
#define XV(flags, name, op, code) Z(flags, name, op, code)
|
||||||
|
|||||||
@ -22,6 +22,11 @@
|
|||||||
|
|
||||||
#define SIM_HEAP_SIZE (100 * 1024 + 1024 * 1024)
|
#define SIM_HEAP_SIZE (100 * 1024 + 1024 * 1024)
|
||||||
|
|
||||||
|
#define OPTIONAL_OLED_VOCABULARY
|
||||||
|
#define OPTIONAL_CAMERA_VOCABULARY
|
||||||
|
#define OPTIONAL_BLUETOOTH_VOCABULARY
|
||||||
|
#define OPTIONAL_SPI_FLASH_VOCABULARY
|
||||||
|
|
||||||
static cell_t *simulated(cell_t *sp, const char *op);
|
static cell_t *simulated(cell_t *sp, const char *op);
|
||||||
|
|
||||||
#define PLATFORM_OPCODE_LIST \
|
#define PLATFORM_OPCODE_LIST \
|
||||||
@ -157,9 +162,6 @@ static cell_t *simulated(cell_t *sp, const char *op) {
|
|||||||
} else if (op == STR_getMaxAllocHeap) {
|
} else if (op == STR_getMaxAllocHeap) {
|
||||||
*++sp = 80 * 1024;
|
*++sp = 80 * 1024;
|
||||||
return sp;
|
return sp;
|
||||||
} else if (op == STR_esp_partition_t_size) {
|
|
||||||
*++sp = 64;
|
|
||||||
return sp;
|
|
||||||
} else if (op == STR_IS_XTENSA) {
|
} else if (op == STR_IS_XTENSA) {
|
||||||
*++sp = -1;
|
*++sp = -1;
|
||||||
return sp;
|
return sp;
|
||||||
|
|||||||
Reference in New Issue
Block a user