Cleanup build and macros.

This commit is contained in:
Brad Nelson
2021-12-27 22:41:04 -08:00
parent 056abdea90
commit 5a05a4ff37
5 changed files with 82 additions and 60 deletions

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION=7.0.6.8
VERSION=7.0.6.9
STABLE_VERSION=7.0.5.4
REVISION=$(shell git rev-parse HEAD)
REVSHORT=$(shell echo $(REVISION) | head -c 7)
@ -161,7 +161,7 @@ POSIX_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \
posix/autoboot.fs \
common/fini.fs
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
echo "ok" | cat $(POSIX_BOOT) - | cat | $< boot $(VERSION) $(REVISION) >$@
$< boot $(VERSION) $(REVISION) $(POSIX_BOOT) >$@
WINDOWS_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \
common/hide_calls.fs common/ansi.fs common/floats.fs \
@ -170,7 +170,7 @@ WINDOWS_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \
common/blocks.fs common/locals.fs \
common/fini.fs
$(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
echo "ok" | cat $(WINDOWS_BOOT) - | cat | $< boot $(VERSION) $(REVISION) >$@
$< boot $(VERSION) $(REVISION) $(WINDOWS_BOOT) >$@
ESP32_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \
common/tasks.fs esp32/platform.fs esp32/highlevel.fs \
@ -182,7 +182,7 @@ ESP32_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \
esp32/camera.fs esp32/camera_server.fs common/blocks.fs \
esp32/autoboot.fs common/fini.fs
$(GEN)/esp32_boot.h: common/source_to_string.js $(ESP32_BOOT) | $(GEN)
echo "ok" | cat $(ESP32_BOOT) - | cat | $< boot $(VERSION) $(REVISION) >$@
$< boot $(VERSION) $(REVISION) $(ESP32_BOOT) >$@
$(GEN)/dump_web_opcodes: web/dump_web_opcodes.c common/opcodes.h | $(GEN)
$(CC) $(CFLAGS) $< -o $@

View File

@ -19,3 +19,4 @@ transfer forth
saving-base 16 cells + 'heap !
forth
execute ( assumes an xt for autoboot is on the dstack )
ok

View File

@ -30,10 +30,13 @@ function DropCopyright(source) {
return cleaned.join('\n');
}
var source = DropCopyright(fs.readFileSync(process.stdin.fd).toString());
var name = process.argv[2];
var version = process.argv[3];
var revision = process.argv[4];
var source = '';
for (var i = 5; i < process.argv.length; i++) {
source += DropCopyright(fs.readFileSync(process.argv[i]).toString());
}
source = source.replace('{{VERSION}}', version);
source = source.replace('{{REVISION}}', revision);

View File

@ -86,6 +86,7 @@ transfer{
}transfer
forth definitions
DEFINED? ledcSetup [IF]
vocabulary ledc ledc definitions
transfer{
ledcSetup ledcAttachPin ledcDetachPin
@ -93,6 +94,7 @@ transfer{
ledcWrite ledcWriteTone ledcWriteNote
}transfer
forth definitions
[THEN]
vocabulary Serial Serial definitions
transfer{
@ -121,6 +123,7 @@ transfer{
forth definitions
DEFINED? gpio_config [IF]
vocabulary interrupts interrupts definitions
transfer{
gpio_config
@ -139,7 +142,6 @@ transfer{
gpio_set_drive_capability gpio_get_drive_capability
esp_intr_alloc esp_intr_free
}transfer
0 constant ESP_INTR_FLAG_DEFAULT
: ESP_INTR_FLAG_LEVELn ( n=1-6 -- n ) 1 swap lshift ;
1 7 lshift constant ESP_INTR_FLAG_NMI
@ -147,7 +149,6 @@ transfer{
1 9 lshift constant ESP_INTR_FLAG_EDGE
1 10 lshift constant ESP_INTR_FLAG_IRAM
1 11 lshift constant ESP_INTR_FLAG_INTRDISABLED
( Prefix these with # because GPIO_INTR_DISABLE conflicts with a function. )
0 constant #GPIO_INTR_DISABLE
1 constant #GPIO_INTR_POSEDGE
@ -155,13 +156,12 @@ transfer{
3 constant #GPIO_INTR_ANYEDGE
4 constant #GPIO_INTR_LOW_LEVEL
5 constant #GPIO_INTR_HIGH_LEVEL
( Easy word to trigger on any change to a pin )
ESP_INTR_FLAG_DEFAULT gpio_install_isr_service drop
: pinchange ( xt pin ) dup #GPIO_INTR_ANYEDGE gpio_set_intr_type throw
swap 0 gpio_isr_handler_add throw ;
forth definitions
[THEN]
DEFINED? rmt_set_clk_div [IF]
vocabulary rmt rmt definitions
@ -183,11 +183,13 @@ transfer{
forth definitions
[THEN]
DEFINED? xPortGetCoreID [IF]
vocabulary rtos rtos definitions
transfer{
xPortGetCoreID xTaskCreatePinnedToCore vTaskDelete
}transfer
forth definitions
[THEN]
DEFINED? SerialBT.new [IF]
vocabulary bluetooth bluetooth definitions
@ -255,4 +257,3 @@ binary
010000000000000 constant MALLOC_CAP_RETENTION
decimal
forth definitions

View File

@ -32,6 +32,7 @@
#define ENABLE_SOCKETS_SUPPORT
#define ENABLE_FREERTOS_SUPPORT
#define ENABLE_INTERRUPTS_SUPPORT
#define ENABLE_LEDC_SUPPORT
#define ENABLE_SD_SUPPORT
// SD_MMC does not work on ESP32-S2 / ESP32-C3
@ -82,16 +83,8 @@
#include <sys/stat.h>
#include <sys/select.h>
#if defined(ESP32)
# define HEAP_SIZE (100 * 1024)
# define STACK_SIZE 512
#elif defined(ESP8266)
# define HEAP_SIZE (40 * 1024)
# define STACK_SIZE 512
#else
# define HEAP_SIZE 2 * 1024
# define STACK_SIZE 32
#endif
#define HEAP_SIZE (100 * 1024)
#define STACK_SIZE 512
#define INTERRUPT_STACK_CELLS 64
// Optional hook to pull in words for userwords.h
@ -103,43 +96,59 @@
#define PLATFORM_OPCODE_LIST \
FLOATING_POINT_LIST \
/* Memory Allocation */ \
REQUIRED_MEMORY_SUPPORT \
REQUIRED_SERIAL_SUPPORT \
REQUIRED_ARDUINO_GPIO_SUPPORT \
REQUIRED_SYSTEM_SUPPORT \
REQUIRED_FILES_SUPPORT \
OPTIONAL_LEDC_SUPPORT \
OPTIONAL_DAC_SUPPORT \
OPTIONAL_SPIFFS_SUPPORT \
OPTIONAL_WIFI_SUPPORT \
OPTIONAL_MDNS_SUPPORT \
OPTIONAL_WEBSERVER_SUPPORT \
OPTIONAL_SD_SUPPORT \
OPTIONAL_SD_MMC_SUPPORT \
OPTIONAL_I2C_SUPPORT \
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
OPTIONAL_CAMERA_SUPPORT \
OPTIONAL_SOCKETS_SUPPORT \
OPTIONAL_FREERTOS_SUPPORT \
OPTIONAL_INTERRUPTS_SUPPORT \
OPTIONAL_RMT_SUPPORT \
OPTIONAL_OLED_SUPPORT \
USER_WORDS
#define REQUIRED_MEMORY_SUPPORT \
Y(MALLOC, SET malloc(n0)) \
Y(SYSFREE, free(a0); DROP) \
Y(REALLOC, SET realloc(a1, n0); NIP) \
Y(heap_caps_malloc, SET heap_caps_malloc(n1, n0); NIP) \
Y(heap_caps_free, heap_caps_free(a0); DROP) \
Y(heap_caps_realloc, \
tos = (cell_t) heap_caps_realloc(a2, n1, n0); NIPn(2)) \
/* Serial */ \
tos = (cell_t) heap_caps_realloc(a2, n1, n0); NIPn(2))
#define REQUIRED_SYSTEM_SUPPORT \
X("MS-TICKS", MS_TICKS, PUSH millis()) \
X("RAW-YIELD", RAW_YIELD, yield()) \
Y(TERMINATE, exit(n0))
#define REQUIRED_SERIAL_SUPPORT \
X("Serial.begin", SERIAL_BEGIN, Serial.begin(tos); DROP) \
X("Serial.end", SERIAL_END, Serial.end()) \
X("Serial.available", SERIAL_AVAILABLE, PUSH Serial.available()) \
X("Serial.readBytes", SERIAL_READ_BYTES, n0 = Serial.readBytes(b1, n0); NIP) \
X("Serial.write", SERIAL_WRITE, n0 = Serial.write(b1, n0); NIP) \
X("Serial.flush", SERIAL_FLUSH, Serial.flush()) \
/* Pins and PWM */ \
X("Serial.flush", SERIAL_FLUSH, Serial.flush())
#define REQUIRED_ARDUINO_GPIO_SUPPORT \
Y(pinMode, pinMode(n1, n0); DROPn(2)) \
Y(digitalWrite, digitalWrite(n1, n0); DROPn(2)) \
Y(digitalRead, n0 = digitalRead(n0)) \
Y(analogRead, n0 = analogRead(n0)) \
Y(pulseIn, n0 = pulseIn(n2, n1, n0); NIPn(2)) \
Y(ledcSetup, \
n0 = (cell_t) (1000000 * ledcSetup(n2, n1 / 1000.0, n0)); NIPn(2)) \
Y(ledcAttachPin, ledcAttachPin(n1, n0); DROPn(2)) \
Y(ledcDetachPin, ledcDetachPin(n0); DROP) \
Y(ledcRead, n0 = ledcRead(n0)) \
Y(ledcReadFreq, n0 = (cell_t) (1000000 * ledcReadFreq(n0))) \
Y(ledcWrite, ledcWrite(n1, n0); DROPn(2)) \
Y(ledcWriteTone, \
n0 = (cell_t) (1000000 * ledcWriteTone(n1, n0 / 1000.0)); NIP) \
Y(ledcWriteNote, \
tos = (cell_t) (1000000 * ledcWriteNote(n2, (note_t) n1, n0)); NIPn(2)) \
/* General System */ \
X("MS-TICKS", MS_TICKS, PUSH millis()) \
X("RAW-YIELD", RAW_YIELD, yield()) \
Y(TERMINATE, exit(n0)) \
/* File words */ \
Y(pulseIn, n0 = pulseIn(n2, n1, n0); NIPn(2))
#define REQUIRED_FILES_SUPPORT \
X("R/O", R_O, PUSH O_RDONLY) \
X("R/W", R_W, PUSH O_RDWR) \
X("W/O", W_O, PUSH O_WRONLY) \
@ -165,23 +174,24 @@
n0 = (cell_t) lseek(fd, tos, SEEK_SET); n0 = n0 < 0 ? errno : 0) \
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 \
OPTIONAL_WEBSERVER_SUPPORT \
OPTIONAL_SD_SUPPORT \
OPTIONAL_SD_MMC_SUPPORT \
OPTIONAL_I2C_SUPPORT \
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
OPTIONAL_CAMERA_SUPPORT \
OPTIONAL_SOCKETS_SUPPORT \
OPTIONAL_FREERTOS_SUPPORT \
OPTIONAL_INTERRUPTS_SUPPORT \
OPTIONAL_RMT_SUPPORT \
OPTIONAL_OLED_SUPPORT \
USER_WORDS
n0 = (cell_t) st.st_size; PUSH w < 0 ? errno : 0)
#ifndef ENABLE_LEDC_SUPPORT
# define OPTIONAL_LEDC_SUPPORT
#else
# define OPTIONAL_LEDC_SUPPORT \
Y(ledcSetup, \
n0 = (cell_t) (1000000 * ledcSetup(n2, n1 / 1000.0, n0)); NIPn(2)) \
Y(ledcAttachPin, ledcAttachPin(n1, n0); DROPn(2)) \
Y(ledcDetachPin, ledcDetachPin(n0); DROP) \
Y(ledcRead, n0 = ledcRead(n0)) \
Y(ledcReadFreq, n0 = (cell_t) (1000000 * ledcReadFreq(n0))) \
Y(ledcWrite, ledcWrite(n1, n0); DROPn(2)) \
Y(ledcWriteTone, \
n0 = (cell_t) (1000000 * ledcWriteTone(n1, n0 / 1000.0)); NIP) \
Y(ledcWriteNote, \
tos = (cell_t) (1000000 * ledcWriteNote(n2, (note_t) n1, n0)); NIPn(2))
#endif
#ifndef ENABLE_DAC_SUPPORT
# define OPTIONAL_DAC_SUPPORT
@ -535,11 +545,16 @@ static Adafruit_SSD1306 *oled_display = 0;
#endif
static char filename[PATH_MAX];
static String string_value;
#ifdef ENABLE_WEBSERVER_SUPPORT
static String string_value;
#endif
#ifdef ENABLE_INTERRUPTS_SUPPORT
static cell_t EspIntrAlloc(cell_t source, cell_t flags, cell_t xt, cell_t arg, cell_t *ret);
static cell_t GpioIsrHandlerAdd(cell_t pin, cell_t xt, cell_t arg);
static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg, void *ret);
#endif
{{core}}
{{interp}}
@ -592,6 +607,7 @@ static void InvokeWebServerOn(WebServer *ws, const char *url, cell_t xt) {
}
#endif
#ifdef ENABLE_INTERRUPTS_SUPPORT
struct handle_interrupt_args {
cell_t xt;
cell_t arg;
@ -634,6 +650,7 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg
args->arg = arg;
return timer_isr_register((timer_group_t) group, (timer_idx_t) timer, HandleInterrupt, args, flags, (timer_isr_handle_t *) ret);
}
#endif
void setup() {
cell_t *heap = (cell_t *) malloc(HEAP_SIZE);