Added ESP words.
This commit is contained in:
@ -235,10 +235,11 @@ static cell_t *evaluate1(cell_t *sp, float **fp) {
|
||||
|
||||
static cell_t *forth_run(cell_t *initrp);
|
||||
|
||||
static void forth_init(int argc, char *argv[], void *heap,
|
||||
static void forth_init(int argc, char *argv[],
|
||||
void *heap, cell_t heap_size,
|
||||
const char *src, cell_t src_len) {
|
||||
g_sys.heap_start = (cell_t *) heap;
|
||||
g_sys.heap_size = HEAP_SIZE;
|
||||
g_sys.heap_size = heap_size;
|
||||
g_sys.stack_cells = STACK_CELLS;
|
||||
g_sys.boot = src;
|
||||
g_sys.boot_size = src_len;
|
||||
|
||||
@ -547,6 +547,7 @@ e: test-esp32-forth-namespace
|
||||
out: SD
|
||||
out: WiFi
|
||||
out: Wire
|
||||
out: ESP
|
||||
out: editor
|
||||
out: streams
|
||||
out: tasks
|
||||
@ -610,6 +611,7 @@ e: test-esp32-forth-namespace
|
||||
out: SD
|
||||
out: WiFi
|
||||
out: Wire
|
||||
out: ESP
|
||||
out: ok
|
||||
check-esp32-basics
|
||||
out: default-key?
|
||||
|
||||
@ -14,6 +14,10 @@
|
||||
|
||||
( Migrate various words to separate vocabularies, and constants )
|
||||
|
||||
vocabulary ESP ESP definitions
|
||||
transfer ESP-builtins
|
||||
forth definitions
|
||||
|
||||
vocabulary Wire Wire definitions
|
||||
transfer wire-builtins
|
||||
forth definitions
|
||||
|
||||
@ -34,6 +34,7 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
|
||||
#define PLATFORM_OPCODE_LIST \
|
||||
USER_WORDS \
|
||||
REQUIRED_ESP_SUPPORT \
|
||||
REQUIRED_MEMORY_SUPPORT \
|
||||
REQUIRED_SERIAL_SUPPORT \
|
||||
REQUIRED_ARDUINO_GPIO_SUPPORT \
|
||||
@ -66,6 +67,17 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
YV(internals, heap_caps_realloc, \
|
||||
tos = (cell_t) heap_caps_realloc(a2, n1, n0); NIPn(2))
|
||||
|
||||
#define REQUIRED_ESP_SUPPORT \
|
||||
YV(ESP, getHeapSize, PUSH ESP.getHeapSize()) \
|
||||
YV(ESP, getFreeHeap, PUSH ESP.getFreeHeap()) \
|
||||
YV(ESP, getMaxAllocHeap, PUSH ESP.getMaxAllocHeap()) \
|
||||
YV(ESP, getChipModel, PUSH ESP.getChipModel()) \
|
||||
YV(ESP, getChipCores, PUSH ESP.getChipCores()) \
|
||||
YV(ESP, getFlashChipSize, PUSH ESP.getFlashChipSize()) \
|
||||
YV(ESP, getCPUFreqMHz, PUSH ESP.getCPUFreqMHz()) \
|
||||
YV(ESP, getSketchSize, PUSH ESP.getSketchSize()) \
|
||||
YV(ESP, deepSleep, ESP.deepSleep(tos); DROP)
|
||||
|
||||
#define REQUIRED_SYSTEM_SUPPORT \
|
||||
X("MS-TICKS", MS_TICKS, PUSH millis()) \
|
||||
XV(internals, "RAW-YIELD", RAW_YIELD, yield()) \
|
||||
|
||||
@ -12,6 +12,5 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#define HEAP_SIZE (100 * 1024)
|
||||
#define STACK_CELLS 512
|
||||
#define INTERRUPT_STACK_CELLS 64
|
||||
|
||||
@ -13,8 +13,9 @@
|
||||
// limitations under the License.
|
||||
|
||||
void setup() {
|
||||
cell_t *heap = (cell_t *) malloc(HEAP_SIZE);
|
||||
forth_init(0, 0, heap, boot, sizeof(boot));
|
||||
cell_t hs = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL);
|
||||
cell_t *heap = (cell_t *) malloc(hs);
|
||||
forth_init(0, 0, heap, hs, boot, sizeof(boot));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
@ -67,6 +67,6 @@
|
||||
|
||||
#define VOCABULARY_LIST \
|
||||
V(forth) V(internals) \
|
||||
V(rtos) V(SPIFFS) V(serial) V(SD) V(SD_MMC) \
|
||||
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(rmt) V(interrupts) V(spi_flash) V(camera) V(timers)
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#define HEAP_SIZE (100 * 1024 + 1024 * 1024)
|
||||
#define SIM_HEAP_SIZE (100 * 1024 + 1024 * 1024)
|
||||
#define STACK_CELLS 512
|
||||
|
||||
#include "esp32/options.h"
|
||||
@ -33,6 +33,9 @@ static cell_t *simulated(cell_t *sp, const char *op);
|
||||
PLATFORM_SIMULATED_OPCODE_LIST
|
||||
#undef XV
|
||||
|
||||
#define MALLOC_CAP_INTERNAL SIM_HEAP_SIZE
|
||||
#define heap_caps_get_largest_free_block(x) (x)
|
||||
|
||||
#include "common/core.h"
|
||||
#include "common/interp.h"
|
||||
#include "gen/esp32_boot.h"
|
||||
|
||||
@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
|
||||
void *heap = mmap(
|
||||
(void *) 0x8000000, HEAP_SIZE,
|
||||
PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
forth_init(argc, argv, heap, boot, sizeof(boot));
|
||||
forth_init(argc, argv, heap, HEAP_SIZE, boot, sizeof(boot));
|
||||
for (;;) { g_sys.rp = forth_run(g_sys.rp); }
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show) {
|
||||
void *heap = VirtualAlloc(
|
||||
(void *) 0x8000000, HEAP_SIZE,
|
||||
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
forth_init(0, 0, heap, boot, sizeof(boot));
|
||||
forth_init(0, 0, heap, HEAP_SIZE, boot, sizeof(boot));
|
||||
for (;;) { g_sys.rp = forth_run(g_sys.rp); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user