From fb591e1a44b3df0db322360933fed39f17d06dd5 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Fri, 17 Dec 2021 17:33:33 -0800 Subject: [PATCH] Adding RMT support, compat with ESP32-S2-WROVER, version bump. --- ueforth/Makefile | 2 +- ueforth/esp32/bindings.fs | 18 +++++++++ ueforth/esp32/template.ino | 77 +++++++++++++++++++++++++++++++++--- ueforth/site/ESP32forth.html | 56 ++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 7 deletions(-) diff --git a/ueforth/Makefile b/ueforth/Makefile index da77fc5..7077279 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION=7.0.6.6 +VERSION=7.0.6.7 STABLE_VERSION=7.0.5.4 REVISION=$(shell git rev-parse HEAD) REVSHORT=$(shell echo $(REVISION) | head -c 7) diff --git a/ueforth/esp32/bindings.fs b/ueforth/esp32/bindings.fs index 523ddb3..5796e38 100644 --- a/ueforth/esp32/bindings.fs +++ b/ueforth/esp32/bindings.fs @@ -151,6 +151,24 @@ ESP_INTR_FLAG_DEFAULT gpio_install_isr_service drop forth definitions +vocabulary rmt rmt definitions +transfer{ + rmt_set_clk_div rmt_get_clk_div rmt_set_rx_idle_thresh rmt_get_rx_idle_thresh + rmt_set_mem_block_num rmt_get_mem_block_num rmt_set_tx_carrier + rmt_set_mem_pd rmt_get_mem_pd rmt_tx_start rmt_tx_stop rmt_rx_start rmt_rx_stop + rmt_tx_memory_reset rmt_rx_memory_reset rmt_set_memory_owner rmt_get_memory_owner + rmt_set_tx_loop_mode rmt_get_tx_loop_mode rmt_set_rx_filter + rmt_set_source_clk rmt_get_source_clk rmt_set_idle_level rmt_get_idle_level + rmt_get_status rmt_set_rx_intr_en rmt_set_err_intr_en rmt_set_tx_intr_en + rmt_set_tx_thr_intr_en + rmt_set_gpio rmt_config rmt_isr_register rmt_isr_deregister + rmt_fill_tx_items rmt_driver_install rmt_driver_uinstall + rmt_get_channel_status rmt_get_counter_clock rmt_write_items + rmt_wait_tx_done rmt_get_ringbuf_handle rmt_translator_init + rmt_translator_set_context rmt_translator_get_context rmt_write_sample +}transfer +forth definitions + vocabulary rtos rtos definitions transfer{ xPortGetCoreID xTaskCreatePinnedToCore vTaskDelete diff --git a/ueforth/esp32/template.ino b/ueforth/esp32/template.ino index 79b7597..fb613a2 100644 --- a/ueforth/esp32/template.ino +++ b/ueforth/esp32/template.ino @@ -32,6 +32,7 @@ #define ENABLE_SOCKETS_SUPPORT #define ENABLE_FREERTOS_SUPPORT #define ENABLE_INTERRUPTS_SUPPORT +#define ENABLE_RMT_SUPPORT // SD_MMC does not work on ESP32-S2 / ESP32-C3 #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) @@ -50,13 +51,17 @@ // Adafruit BusIO //#define ENABLE_OLED_SUPPORT -// For now assume only boards with PSRAM (ESP32-CAM) -// will want SerialBluetooth (very large) and camera support. -// Other boards can support these if they're set to a larger -// parition size. But it's unclear the best way to configure this. +// 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. +// Some boards (e.g. ESP32-S2-WROVER) don't seem to have +// built the serial library, so check if its enabled as well. #ifdef BOARD_HAS_PSRAM # define ENABLE_CAMERA_SUPPORT -# define ENABLE_SERIAL_BLUETOOTH_SUPPORT +# if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BLUEDROID_ENABLED) +# define ENABLE_SERIAL_BLUETOOTH_SUPPORT +# endif #endif #ifdef ENABLE_WEBSERVER_SUPPORT @@ -166,6 +171,7 @@ OPTIONAL_SOCKETS_SUPPORT \ OPTIONAL_FREERTOS_SUPPORT \ OPTIONAL_INTERRUPTS_SUPPORT \ + OPTIONAL_RMT_SUPPORT \ OPTIONAL_OLED_SUPPORT \ USER_WORDS @@ -198,7 +204,8 @@ # include "freertos/task.h" # define OPTIONAL_FREERTOS_SUPPORT \ Y(vTaskDelete, vTaskDelete((TaskHandle_t) n0); DROP) \ - Y(xTaskCreatePinnedToCore, n0 = xTaskCreatePinnedToCore((TaskFunction_t) a6, c5, n4, a3, (UBaseType_t) n2, (TaskHandle_t *) a1, (BaseType_t) n0); NIPn(6)) \ + Y(xTaskCreatePinnedToCore, n0 = xTaskCreatePinnedToCore((TaskFunction_t) a6, \ + c5, n4, a3, (UBaseType_t) n2, (TaskHandle_t *) a1, (BaseType_t) n0); NIPn(6)) \ Y(xPortGetCoreID, PUSH xPortGetCoreID()) #endif @@ -239,6 +246,64 @@ Y(timer_isr_register, n0 = TimerIsrRegister(n5, n4, n3, n2, n1, a0); NIPn(5)) #endif +#ifndef ENABLE_RMT_SUPPORT +# define OPTIONAL_RMT_SUPPORT +#else +# include "driver/rmt.h" +# define OPTIONAL_RMT_SUPPORT \ + Y(rmt_set_clk_div, n0 = rmt_set_clk_div((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_get_clk_div, n0 = rmt_get_clk_div((rmt_channel_t) n1, b0); NIP) \ + Y(rmt_set_rx_idle_thresh, n0 = rmt_set_rx_idle_thresh((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_get_rx_idle_thresh, \ + n0 = rmt_get_rx_idle_thresh((rmt_channel_t) n1, (uint16_t *) a0); NIP) \ + Y(rmt_set_mem_block_num, n0 = rmt_set_mem_block_num((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_get_mem_block_num, n0 = rmt_get_mem_block_num((rmt_channel_t) n1, b0); NIP) \ + Y(rmt_set_tx_carrier, n0 = rmt_set_tx_carrier((rmt_channel_t) n4, n3, n2, n1, \ + (rmt_carrier_level_t) n0); NIPn(4)) \ + Y(rmt_set_mem_pd, n0 = rmt_set_mem_pd((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_get_mem_pd, n0 = rmt_get_mem_pd((rmt_channel_t) n1, (bool *) a0); NIP) \ + Y(rmt_tx_start, n0 = rmt_tx_start((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_tx_stop, n0 = rmt_tx_stop((rmt_channel_t) n0)) \ + Y(rmt_rx_start, n0 = rmt_rx_start((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_rx_stop, n0 = rmt_rx_stop((rmt_channel_t) n0)) \ + Y(rmt_tx_memory_reset, n0 = rmt_tx_memory_reset((rmt_channel_t) n0)) \ + Y(rmt_rx_memory_reset, n0 = rmt_rx_memory_reset((rmt_channel_t) n0)) \ + Y(rmt_set_memory_owner, n0 = rmt_set_memory_owner((rmt_channel_t) n1, (rmt_mem_owner_t) n0); NIP) \ + Y(rmt_get_memory_owner, n0 = rmt_get_memory_owner((rmt_channel_t) n1, (rmt_mem_owner_t *) a0); NIP) \ + Y(rmt_set_tx_loop_mode, n0 = rmt_set_tx_loop_mode((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_get_tx_loop_mode, n0 = rmt_get_tx_loop_mode((rmt_channel_t) n1, (bool *) a0); NIP) \ + Y(rmt_set_rx_filter, n0 = rmt_set_rx_filter((rmt_channel_t) n2, n1, n0); NIPn(2)) \ + Y(rmt_set_source_clk, n0 = rmt_set_source_clk((rmt_channel_t) n1, (rmt_source_clk_t) n0); NIP) \ + Y(rmt_get_source_clk, n0 = rmt_get_source_clk((rmt_channel_t) n1, (rmt_source_clk_t * ) a0); NIP) \ + Y(rmt_set_idle_level, n0 = rmt_set_idle_level((rmt_channel_t) n2, n1, \ + (rmt_idle_level_t) n0); NIPn(2)) \ + Y(rmt_get_idle_level, n0 = rmt_get_idle_level((rmt_channel_t) n2, \ + (bool *) a1, (rmt_idle_level_t *) a0); NIPn(2)) \ + Y(rmt_get_status, n0 = rmt_get_status((rmt_channel_t) n1, (uint32_t *) a0); NIP) \ + Y(rmt_set_rx_intr_en, n0 = rmt_set_rx_intr_en((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_set_err_intr_en, n0 = rmt_set_err_intr_en((rmt_channel_t) n1, (rmt_mode_t) n0); NIP) \ + Y(rmt_set_tx_intr_en, n0 = rmt_set_tx_intr_en((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_set_tx_thr_intr_en, n0 = rmt_set_tx_thr_intr_en((rmt_channel_t) n2, n1, n0); NIPn(2)) \ + Y(rmt_set_gpio, n0 = rmt_set_gpio((rmt_channel_t) n3, (rmt_mode_t) n2, (gpio_num_t) n1, n0); NIPn(3)) \ + Y(rmt_config, n0 = rmt_config((const rmt_config_t *) a0)) \ + Y(rmt_isr_register, n0 = rmt_isr_register((void (*)(void*)) a3, a2, n1, \ + (rmt_isr_handle_t *) a0); NIPn(3)) \ + Y(rmt_isr_deregister, n0 = rmt_isr_deregister((rmt_isr_handle_t) n0)) \ + Y(rmt_fill_tx_items, n0 = rmt_fill_tx_items((rmt_channel_t) n3, \ + (rmt_item32_t *) a2, n1, n0); NIPn(3)) \ + Y(rmt_driver_install, n0 = rmt_driver_install((rmt_channel_t) n2, n1, n0); NIPn(2)) \ + Y(rmt_driver_uinstall, n0 = rmt_driver_uninstall((rmt_channel_t) n0)) \ + Y(rmt_get_channel_status, n0 = rmt_get_channel_status((rmt_channel_status_result_t *) a0)) \ + Y(rmt_get_counter_clock, n0 = rmt_get_counter_clock((rmt_channel_t) n1, (uint32_t *) a0); NIP) \ + Y(rmt_write_items, n0 = rmt_write_items((rmt_channel_t) n3, (rmt_item32_t *) a2, n1, n0); NIPn(3)) \ + Y(rmt_wait_tx_done, n0 = rmt_wait_tx_done((rmt_channel_t) n1, n0); NIP) \ + Y(rmt_get_ringbuf_handle, n0 = rmt_get_ringbuf_handle((rmt_channel_t) n1, (RingbufHandle_t *) a0); NIP) \ + Y(rmt_translator_init, n0 = rmt_translator_init((rmt_channel_t) n1, (sample_to_rmt_t) n0); NIP) \ + Y(rmt_translator_set_context, n0 = rmt_translator_set_context((rmt_channel_t) n1, a0); NIP) \ + Y(rmt_translator_get_context, n0 = rmt_translator_get_context((const size_t *) a1, (void **) a0); NIP) \ + Y(rmt_write_sample, n0 = rmt_write_sample((rmt_channel_t) n3, b2, n1, n0); NIPn(3)) +#endif + #ifndef ENABLE_CAMERA_SUPPORT # define OPTIONAL_CAMERA_SUPPORT #else diff --git a/ueforth/site/ESP32forth.html b/ueforth/site/ESP32forth.html index 511567a..b795cf7 100644 --- a/ueforth/site/ESP32forth.html +++ b/ueforth/site/ESP32forth.html @@ -442,6 +442,62 @@ esp_intr_free ( handle -- 0/err ) timer_isr_register ( group timer xt arg ret -- 0/err ) +
RMT
+These words are inside the RMT vocabulary. + +
+rmt_set_clk_div ( channel div8 -- err )
+rmt_get_clk_div ( channel @div8 -- err )
+rmt_set_rx_idle_thresh ( channel thresh16 -- err )
+rmt_get_rx_idle_thresh ( channel @thresh16 -- err )
+rmt_set_mem_block_num ( channel memnum8 -- err )
+rmt_get_mem_block_num ( channel @memnum8 -- err )
+rmt_set_tx_carrier ( channel enable highlev lowlev carrierlev -- err )
+rmt_set_mem_pd ( channel f -- err )
+rmt_get_mem_pd ( channel @f -- err )
+rmt_tx_start ( channel f -- err )
+rmt_tx_stop ( channel -- err )
+rmt_rx_start ( channel f -- err )
+rmt_rx_stop ( channel -- err )
+rmt_tx_memory_reset ( channel -- err )
+rmt_rx_memory_reset ( channel -- err )
+rmt_set_memory_owner ( channel owner -- err )
+rmt_get_memory_owner ( channel @owner -- err )
+rmt_set_tx_loop_mode ( channel f -- err )
+rmt_get_tx_loop_mode ( channel @f -- err )
+rmt_set_rx_filter ( channel enable thresh8 -- err )
+rmt_set_source_clk ( channel baseclk -- err )
+rmt_get_source_clk ( channel @baseclk -- err )
+rmt_set_idle_level ( channel enable level -- err )
+rmt_get_idle_level ( channel @enable @level -- err )
+rmt_get_status ( channel @status -- err )
+rmt_set_rx_intr_en ( channel enable -- err )
+rmt_set_err_intr_en ( channel enable -- err )
+rmt_set_tx_intr_en ( channel enable -- err )
+rmt_set_tx_thr_intr_en (channel enable thresh -- err )
+rmt_set_gpio ( channel mode gpio# invertsig -- err )
+rmt_config ( rmt_config_t* )
+rmt_isr_register ( fn arg allocflags handle -- err )
+rmt_isr_deregister ( handle -- err )
+rmt_fill_tx_items ( channel @items items# offset -- err )
+rmt_driver_install ( channel rxbufsize allocflags -- err )
+rmt_driver_uinstall ( channel -- err )
+rmt_get_channel_status ( channel @status -- err )
+rmt_get_counter_clock ( channel @clockhz -- err )
+rmt_write_items ( channel @items items# wait -- err )
+rmt_wait_tx_done ( channel time -- err )
+rmt_get_ringbuf_handle ( channel @handle -- err )
+rmt_translator_init ( channel fn -- err )
+rmt_translator_set_context ( channel @context -- err )
+rmt_translator_get_context ( channel @@context -- err )
+rmt_write_sample ( channel src src# wait -- err )
+rmt_register_tx_end_callback --- NOT SUPPORTED
+rmt_memory_rw_rst --- DEPRECATED USE rmt_tx_memory_reset or rmt_rx_memory_reset
+rmt_set_intr_enable_mask --- DEPRECATED interrupt handled by driver
+rmt_clr_intr_enable_mask --- DEPRECATED interrupt handled by driver
+rmt_set_pin --- DEPRECATED use rmt_set_gpio instead
+
+
Tasks
These words are inside the TASKS vocabulary.