Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e36b2ec
commit 1df1902
Showing
13 changed files
with
746 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.DSYM | ||
tccalls.fth | ||
tdate.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Builds CForth for ESP8266 | ||
|
||
default: forth.elf | ||
|
||
TOPDIR=../.. | ||
|
||
# CONFIG += -DBITS32 -DT16 | ||
CONFIG += -DBITS32 | ||
|
||
CFLAGS += -m32 | ||
|
||
CC := gcc | ||
|
||
# Change these to reflect the locations of external stuff on your system, | ||
# either here or on the command line, e.g. COMPORT=COM27 make download | ||
XTGCCPATH ?= /c/msys32/opt/xtensa-esp32-elf/bin/ | ||
CROSS ?= $(XTGCCPATH)xtensa-esp32-elf- | ||
|
||
# ESP32 SDK | ||
IDF_PATH ?= $(TOPDIR)/../esp-idf | ||
IDF_TEMPLATE_PATH ?= $(TOPDIR)/../esp-idf-template | ||
|
||
COMPORT ?= COM27 | ||
|
||
include $(TOPDIR)/src/app/esp32/targets.mk | ||
|
||
forth.elf: app.o | ||
@IDF_PATH=$(IDF_PATH) make --no-print-directory -C sdk_build | ||
|
||
flash: app.o | ||
@IDF_PATH=$(IDF_PATH) make --no-print-directory -C sdk_build flash | ||
|
||
clean:: | ||
@rm -rf sdk_build/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
sdkconfig.old |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PROJECT_NAME := forth | ||
include $(IDF_PATH)/make/project.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# Main component makefile. | ||
|
||
# COMPONENT_OBJS := ../../../app.o main.o | ||
|
||
COMPONENT_OBJS := ../../../app.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
# | ||
# Automatically generated file; DO NOT EDIT. | ||
# Espressif IoT Development Framework Configuration | ||
# | ||
|
||
# | ||
# SDK tool configuration | ||
# | ||
CONFIG_TOOLPREFIX="xtensa-esp32-elf-" | ||
CONFIG_PYTHON="python" | ||
|
||
# | ||
# Bootloader config | ||
# | ||
# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set | ||
# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set | ||
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y | ||
# CONFIG_LOG_BOOTLOADER_LEVEL_INFO is not set | ||
# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set | ||
# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set | ||
CONFIG_LOG_BOOTLOADER_LEVEL=2 | ||
|
||
# | ||
# Security features | ||
# | ||
# CONFIG_SECURE_BOOT_ENABLED is not set | ||
# CONFIG_FLASH_ENCRYPTION_ENABLED is not set | ||
|
||
# | ||
# Serial flasher config | ||
# | ||
CONFIG_ESPTOOLPY_PORT="COM27" | ||
CONFIG_ESPTOOLPY_BAUD_115200B=y | ||
# CONFIG_ESPTOOLPY_BAUD_230400B is not set | ||
# CONFIG_ESPTOOLPY_BAUD_921600B is not set | ||
# CONFIG_ESPTOOLPY_BAUD_2MB is not set | ||
# CONFIG_ESPTOOLPY_BAUD_OTHER is not set | ||
CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 | ||
CONFIG_ESPTOOLPY_BAUD=115200 | ||
# CONFIG_ESPTOOLPY_COMPRESSED is not set | ||
# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set | ||
# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set | ||
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y | ||
# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set | ||
CONFIG_ESPTOOLPY_FLASHMODE="dio" | ||
# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set | ||
CONFIG_ESPTOOLPY_FLASHFREQ_40M=y | ||
# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set | ||
# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set | ||
CONFIG_ESPTOOLPY_FLASHFREQ="40m" | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set | ||
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set | ||
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set | ||
CONFIG_ESPTOOLPY_FLASHSIZE="2MB" | ||
|
||
# | ||
# Partition Table | ||
# | ||
CONFIG_PARTITION_TABLE_SINGLE_APP=y | ||
# CONFIG_PARTITION_TABLE_TWO_OTA is not set | ||
# CONFIG_PARTITION_TABLE_CUSTOM is not set | ||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" | ||
CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET=0x10000 | ||
CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" | ||
CONFIG_APP_OFFSET=0x10000 | ||
CONFIG_PHY_DATA_OFFSET=0xf000 | ||
CONFIG_OPTIMIZATION_LEVEL_DEBUG=y | ||
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set | ||
|
||
# | ||
# Component config | ||
# | ||
CONFIG_BTC_TASK_STACK_SIZE=3072 | ||
# CONFIG_BLUEDROID_MEM_DEBUG is not set | ||
CONFIG_BT_RESERVE_DRAM=0 | ||
|
||
# | ||
# ESP32-specific config | ||
# | ||
# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set | ||
# CONFIG_ESP32_DEFAULT_CPU_FREQ_160 is not set | ||
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y | ||
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240 | ||
CONFIG_ESP32_ENABLE_STACK_WIFI=y | ||
# CONFIG_ESP32_ENABLE_STACK_BT is not set | ||
CONFIG_MEMMAP_SMP=y | ||
# CONFIG_MEMMAP_TRACEMEM is not set | ||
CONFIG_TRACEMEM_RESERVE_DRAM=0x0 | ||
CONFIG_WIFI_ENABLED=y | ||
CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 | ||
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048 | ||
CONFIG_MAIN_TASK_STACK_SIZE=4096 | ||
# CONFIG_NEWLIB_STDOUT_ADDCR is not set | ||
# CONFIG_NEWLIB_NANO_FORMAT is not set | ||
# CONFIG_CONSOLE_UART_DEFAULT is not set | ||
CONFIG_CONSOLE_UART_CUSTOM=y | ||
# CONFIG_CONSOLE_UART_NONE is not set | ||
CONFIG_CONSOLE_UART_CUSTOM_NUM_0=y | ||
# CONFIG_CONSOLE_UART_CUSTOM_NUM_1 is not set | ||
CONFIG_CONSOLE_UART_NUM=0 | ||
CONFIG_CONSOLE_UART_TX_GPIO=1 | ||
CONFIG_CONSOLE_UART_RX_GPIO=3 | ||
CONFIG_CONSOLE_UART_BAUDRATE=115200 | ||
# CONFIG_ULP_COPROC_ENABLED is not set | ||
CONFIG_ULP_COPROC_RESERVE_MEM=0 | ||
# CONFIG_ESP32_PANIC_PRINT_HALT is not set | ||
CONFIG_ESP32_PANIC_PRINT_REBOOT=y | ||
# CONFIG_ESP32_PANIC_SILENT_REBOOT is not set | ||
# CONFIG_ESP32_PANIC_GDBSTUB is not set | ||
CONFIG_ESP32_DEBUG_OCDAWARE=y | ||
CONFIG_INT_WDT=y | ||
CONFIG_INT_WDT_TIMEOUT_MS=300 | ||
# CONFIG_TASK_WDT is not set | ||
# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set | ||
CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y | ||
# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set | ||
# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set | ||
CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y | ||
CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=0 | ||
CONFIG_ESP32_PHY_AUTO_INIT=y | ||
# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set | ||
CONFIG_ESP32_PHY_MAX_TX_POWER=20 | ||
# CONFIG_ETHERNET is not set | ||
|
||
# | ||
# FreeRTOS | ||
# | ||
CONFIG_FREERTOS_UNICORE=y | ||
CONFIG_FREERTOS_CORETIMER_0=y | ||
# CONFIG_FREERTOS_CORETIMER_1 is not set | ||
# CONFIG_FREERTOS_CORETIMER_2 is not set | ||
CONFIG_FREERTOS_HZ=1000 | ||
CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y | ||
# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set | ||
CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL=y | ||
# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY is not set | ||
CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=3 | ||
CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y | ||
# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set | ||
# CONFIG_FREERTOS_ASSERT_DISABLE is not set | ||
CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG=y | ||
# CONFIG_ENABLE_MEMORY_DEBUG is not set | ||
CONFIG_FREERTOS_ISR_STACKSIZE=1536 | ||
# CONFIG_FREERTOS_LEGACY_HOOKS is not set | ||
# CONFIG_FREERTOS_DEBUG_INTERNALS is not set | ||
|
||
# | ||
# Log output | ||
# | ||
# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set | ||
# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set | ||
# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set | ||
CONFIG_LOG_DEFAULT_LEVEL_INFO=y | ||
# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set | ||
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set | ||
CONFIG_LOG_DEFAULT_LEVEL=3 | ||
CONFIG_LOG_COLORS=y | ||
|
||
# | ||
# LWIP | ||
# | ||
# CONFIG_L2_TO_L3_COPY is not set | ||
CONFIG_LWIP_MAX_SOCKETS=4 | ||
CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX=0 | ||
# CONFIG_LWIP_SO_REUSE is not set | ||
CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 | ||
# CONFIG_LWIP_IP_FRAG is not set | ||
# CONFIG_LWIP_IP_REASSEMBLY is not set | ||
|
||
# | ||
# mbedTLS | ||
# | ||
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 | ||
# CONFIG_MBEDTLS_DEBUG is not set | ||
CONFIG_MBEDTLS_HARDWARE_AES=y | ||
CONFIG_MBEDTLS_HARDWARE_MPI=y | ||
CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y | ||
CONFIG_MBEDTLS_HARDWARE_SHA=y | ||
CONFIG_MBEDTLS_HAVE_TIME=y | ||
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set | ||
|
||
# | ||
# SPI Flash driver | ||
# | ||
# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
\ Load file for application-specific Forth extensions | ||
|
||
fl ../../lib/misc.fth | ||
fl ../../lib/dl.fth | ||
fl ../../lib/random.fth | ||
fl ../../lib/ilog2.fth | ||
fl ../../lib/tek.fth | ||
|
||
warning @ warning off | ||
: bye standalone? if restart then bye ; | ||
warning ! | ||
|
||
: .commit ( -- ) 'version cscount type ; | ||
|
||
: .built ( -- ) 'build-date cscount type ; | ||
|
||
: banner ( -- ) | ||
cr ." CForth built " .built | ||
." from " .commit | ||
cr | ||
; | ||
|
||
0 [if] | ||
\ Replace 'quit' to make CForth auto-run some application code | ||
\ instead of just going interactive. | ||
\ : app banner hex init-i2c showstack quit ; | ||
: interrupt? ( -- flag ) | ||
." Type a key within 2 seconds to interact" cr | ||
#20 0 do key? if key drop true unloop exit then #100 ms loop | ||
false | ||
; | ||
: load-startup-file ( -- ) " start" included ; | ||
[then] | ||
|
||
: app | ||
banner hex | ||
quit | ||
; | ||
|
||
alias id: \ | ||
|
||
" app.dic" save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Console I/O routines | ||
*/ | ||
|
||
#include "forth.h" | ||
#include "compiler.h" | ||
#include "stdlib.h" | ||
#include "driver/uart.h" | ||
|
||
int isinteractive() { return (1); } | ||
int isstandalone() { return (1); } | ||
|
||
void raw_emit(unsigned char c) | ||
{ | ||
uart_write_bytes(0, &c, 1); | ||
} | ||
|
||
void emit(u_char c, cell *up) | ||
{ | ||
if (c == '\n') | ||
raw_emit('\r'); | ||
raw_emit(c); | ||
} | ||
|
||
u_char key_is_avail = 0; | ||
u_char the_key; | ||
|
||
int key_avail(cell *up) | ||
{ | ||
if (key_is_avail) { | ||
return (cell)-1; | ||
} | ||
if(uart_read_bytes(0, &the_key, 1, 0)) { | ||
key_is_avail = 1; | ||
return (cell)-1; | ||
} | ||
return 0; | ||
} | ||
|
||
int key(cell *up) | ||
{ | ||
cell this_key; | ||
while (!key_avail(up)) {} | ||
key_is_avail = 0; | ||
return (cell)the_key; | ||
} | ||
|
||
static const char *TAG = "forth"; | ||
#define BUF_SIZE (1024) | ||
void uart_on(void) | ||
{ | ||
int uart_num = UART_NUM_0; | ||
uart_config_t uart_config = { | ||
.baud_rate = 115200, | ||
.data_bits = UART_DATA_8_BITS, | ||
.parity = UART_PARITY_DISABLE, | ||
.stop_bits = UART_STOP_BITS_1, | ||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, | ||
.rx_flow_ctrl_thresh = 122, | ||
}; | ||
//Set UART parameters | ||
uart_param_config(uart_num, &uart_config); | ||
//Set UART log level | ||
// esp_log_level_set(TAG, ESP_LOG_INFO); | ||
//Set UART pins,(-1: default pin, no change.) | ||
//For UART0, we can just use the default pins. | ||
//uart_set_pin(uart_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); | ||
//Install UART driver( We don't need an event queue here) | ||
//We don't even use a buffer for sending data. | ||
uart_driver_install(uart_num, BUF_SIZE * 2, 0, 0, NULL, 0); | ||
} | ||
|
||
void init_io(int argc, char **argv, cell *up) | ||
{ | ||
key_is_avail = 0; | ||
uart_on(); | ||
} | ||
|
||
int caccept(char *addr, cell count, cell *up) | ||
{ | ||
return lineedit(addr, count, up); | ||
} | ||
|
||
// Defines the resolution of c_puts | ||
void output_redirect(const char *str) { | ||
puts(str); | ||
} | ||
|
||
void alerror(char *str, int len, cell *up) | ||
{ | ||
while (len--) | ||
emit((u_char)*str++, up); | ||
|
||
/* Sequences of calls to error() eventually end with a newline */ | ||
V(NUM_OUT) = 0; | ||
} | ||
|
||
// moreinput() returns 0 when the console input stream has been closed for good | ||
int moreinput() { return (1); } | ||
|
||
char *getmem(u_cell nbytes, cell *up) | ||
{ | ||
return (char *)malloc(nbytes); | ||
} | ||
|
||
void memfree(char *ptr, cell *up) | ||
{ | ||
free(ptr); | ||
} | ||
char * memresize(char *ptr, u_cell nbytes, cell *up) | ||
{ | ||
return (char *)realloc(ptr, nbytes); | ||
} |
Oops, something went wrong.