diff options
| author | mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> | 2022-10-05 21:47:16 +0100 |
|---|---|---|
| committer | mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> | 2022-10-05 21:47:16 +0100 |
| commit | 69e75cde12f5c851a57390a100dabcfc279bfc47 (patch) | |
| tree | ee55fcab8492b371e7cc1844e4652c60a1e67af4 /src/platforms | |
| parent | f0a5d1ad5487276bffef92fcce224e32443c2955 (diff) | |
Cleanup
Consistent spelling of 'colour', double buffering works technically on S3.
Diffstat (limited to 'src/platforms')
| -rw-r--r-- | src/platforms/esp32/esp32_i2s_parallel_dma.cpp | 15 | ||||
| -rw-r--r-- | src/platforms/esp32/esp32_i2s_parallel_dma.hpp | 4 | ||||
| -rw-r--r-- | src/platforms/esp32s3/gdma_lcd_parallel16.cpp | 44 | ||||
| -rw-r--r-- | src/platforms/esp32s3/gdma_lcd_parallel16.hpp | 16 | ||||
| -rw-r--r-- | src/platforms/platform_detect.hpp | 2 |
5 files changed, 46 insertions, 35 deletions
diff --git a/src/platforms/esp32/esp32_i2s_parallel_dma.cpp b/src/platforms/esp32/esp32_i2s_parallel_dma.cpp index fb0905d..e4a8212 100644 --- a/src/platforms/esp32/esp32_i2s_parallel_dma.cpp +++ b/src/platforms/esp32/esp32_i2s_parallel_dma.cpp @@ -465,9 +465,12 @@ static void IRAM_ATTR irq_hndlr(void* arg) { // if we use I2S1 (default) ESP_LOGW(TAG, "Creating DMA descriptor which links to payload with size greater than MAX_DMA_LEN!"); } - if ( (_dmadesc_a_idx+1) > _dmadesc_count) { - ESP_LOGE(TAG, "Attempted to create more DMA descriptors than allocated memory for. Expecting a maximum of %d DMA descriptors", _dmadesc_count); - return; + if ( !dmadesc_b ) + { + if ( (_dmadesc_a_idx+1) > _dmadesc_count) { + ESP_LOGE(TAG, "Attempted to create more DMA descriptors than allocated memory for. Expecting a maximum of %d DMA descriptors", _dmadesc_count); + return; + } } volatile lldesc_t *dmadesc; @@ -550,11 +553,11 @@ static void IRAM_ATTR irq_hndlr(void* arg) { // if we use I2S1 (default) } // end - void Bus_Parallel16::flip_dma_output_buffer() + void Bus_Parallel16::set_dma_output_buffer(bool dmadesc_b) { if ( _double_dma_buffer == false) return; - if ( _dmadesc_a_active == true) // change across to everything 'b'' + if ( dmadesc_b == true) // change across to everything 'b'' { _dmadesc_a[_dmadesc_count-1].qe.stqe_next = &_dmadesc_b[0]; _dmadesc_b[_dmadesc_count-1].qe.stqe_next = &_dmadesc_b[0]; @@ -565,7 +568,7 @@ static void IRAM_ATTR irq_hndlr(void* arg) { // if we use I2S1 (default) _dmadesc_b[_dmadesc_count-1].qe.stqe_next = &_dmadesc_a[0]; } - _dmadesc_a_active ^= _dmadesc_a_active; + //_dmadesc_a_active ^= _dmadesc_a_active; } // end flip diff --git a/src/platforms/esp32/esp32_i2s_parallel_dma.hpp b/src/platforms/esp32/esp32_i2s_parallel_dma.hpp index 95664d8..7fae0e6 100644 --- a/src/platforms/esp32/esp32_i2s_parallel_dma.hpp +++ b/src/platforms/esp32/esp32_i2s_parallel_dma.hpp @@ -112,7 +112,7 @@ Contributors: void dma_transfer_start(); void dma_transfer_stop(); - void flip_dma_output_buffer(); + void set_dma_output_buffer(bool dmadesc_b = false); private: @@ -121,7 +121,7 @@ Contributors: config_t _cfg; bool _double_dma_buffer = false; - bool _dmadesc_a_active = true; + //bool _dmadesc_a_active = true; uint32_t _dmadesc_count = 0; // number of dma decriptors diff --git a/src/platforms/esp32s3/gdma_lcd_parallel16.cpp b/src/platforms/esp32s3/gdma_lcd_parallel16.cpp index 19a5865..87f4058 100644 --- a/src/platforms/esp32s3/gdma_lcd_parallel16.cpp +++ b/src/platforms/esp32s3/gdma_lcd_parallel16.cpp @@ -16,11 +16,17 @@ PLEASE SUPPORT THEM! */ +#if __has_include (<hal/lcd_ll.h>) +// Stop compile errors: /src/platforms/esp32s3/gdma_lcd_parallel16.hpp:64:10: fatal error: hal/lcd_ll.h: No such file or directory + #include <Arduino.h> #include "gdma_lcd_parallel16.hpp" static const char* TAG = "gdma_lcd_parallel16"; + static int _dmadesc_a_idx = 0; + static int _dmadesc_b_idx = 0; + dma_descriptor_t desc; // DMA descriptor for testing /* @@ -73,7 +79,7 @@ LCD_CAM.lcd_user.lcd_reset = 1; esp_rom_delay_us(100); - auto lcd_clkm_div_num = 160000000 / _cfg.bus_freq; + uint32_t lcd_clkm_div_num = ((160000000 + 1) / _cfg.bus_freq) / 2; ESP_LOGI(TAG, "Clock divider is %d", lcd_clkm_div_num); @@ -279,7 +285,8 @@ void Bus_Parallel16::enable_double_dma_desc(void) { - _double_dma_buffer = true; + ESP_LOGI(TAG, "Enabled support for secondary DMA buffer."); + _double_dma_buffer = true; } // Need this to work for double buffers etc. @@ -309,9 +316,9 @@ } } - - _dmadesc_a_idx = 0; - _dmadesc_b_idx = 0; + /// override static + _dmadesc_a_idx = 0; + _dmadesc_b_idx = 0; return true; @@ -321,20 +328,15 @@ { static constexpr size_t MAX_DMA_LEN = (4096-4); - if (size > MAX_DMA_LEN) - { + if (size > MAX_DMA_LEN) { size = MAX_DMA_LEN; ESP_LOGW(TAG, "Creating DMA descriptor which links to payload with size greater than MAX_DMA_LEN!"); } - if ( _dmadesc_a_idx >= _dmadesc_count) + if ( dmadesc_b == true) { - ESP_LOGE(TAG, "Attempted to create more DMA descriptors than allocated memory for. Expecting a maximum of %d DMA descriptors", _dmadesc_count); - return; - } - if (_double_dma_buffer == true && dmadesc_b == true) - { + // ESP_LOGI(TAG, "Creating dma desc B %d", _dmadesc_b_idx); _dmadesc_b[_dmadesc_b_idx].dw0.owner = DMA_DESCRIPTOR_BUFFER_OWNER_DMA; _dmadesc_b[_dmadesc_b_idx].dw0.suc_eof = 0; @@ -351,10 +353,16 @@ _dmadesc_b_idx++; - } else { + // ESP_LOGI(TAG, "Creating dma desc A %d", _dmadesc_a_idx); + + if ( _dmadesc_a_idx >= _dmadesc_count) + { + ESP_LOGE(TAG, "Attempted to create more DMA descriptors than allocated. Expecting max %d descriptors.", _dmadesc_count); + return; + } _dmadesc_a[_dmadesc_a_idx].dw0.owner = DMA_DESCRIPTOR_BUFFER_OWNER_DMA; _dmadesc_a[_dmadesc_a_idx].dw0.suc_eof = 0; @@ -394,12 +402,12 @@ } // end - void Bus_Parallel16::flip_dma_output_buffer() + void Bus_Parallel16::set_dma_output_buffer(bool dmadesc_b) { if ( _double_dma_buffer == false) return; - if ( _dmadesc_a_active == true) // change across to everything 'b'' + if ( dmadesc_b == true) // change across to everything 'b'' { _dmadesc_a[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_b[0]; _dmadesc_b[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_b[0]; @@ -410,10 +418,8 @@ _dmadesc_b[_dmadesc_count-1].next = (dma_descriptor_t *) &_dmadesc_a[0]; } - _dmadesc_a_active ^= _dmadesc_a_active; - - } // end flip +#endif
\ No newline at end of file diff --git a/src/platforms/esp32s3/gdma_lcd_parallel16.hpp b/src/platforms/esp32s3/gdma_lcd_parallel16.hpp index 2417626..aaff669 100644 --- a/src/platforms/esp32s3/gdma_lcd_parallel16.hpp +++ b/src/platforms/esp32s3/gdma_lcd_parallel16.hpp @@ -25,7 +25,7 @@ #pragma once -#if __has_include (<esp_lcd_panel_io.h>) +#if __has_include (<hal/lcd_ll.h>) #include <sdkconfig.h> #include <esp_lcd_panel_io.h> @@ -55,13 +55,16 @@ #else #include <driver/periph_ctrl.h> #endif + #include <esp_private/gdma.h> #include <esp_rom_gpio.h> #include <hal/dma_types.h> #include <hal/gpio_hal.h> + #include <hal/lcd_ll.h> #include <soc/lcd_cam_reg.h> #include <soc/lcd_cam_struct.h> + #include <esp_heap_caps.h> #include <esp_heap_caps_init.h> @@ -143,7 +146,7 @@ void dma_transfer_start(); void dma_transfer_stop(); - void flip_dma_output_buffer(); + void set_dma_output_buffer(bool dmadesc_b = false); private: @@ -153,15 +156,14 @@ gdma_channel_handle_t dma_chan; uint32_t _dmadesc_count = 0; // number of dma decriptors - uint32_t _dmadesc_a_idx = 0; + // uint32_t _dmadesc_a_idx = 0; + //uint32_t _dmadesc_b_idx = 0; HUB75_DMA_DESCRIPTOR_T* _dmadesc_a = nullptr; + HUB75_DMA_DESCRIPTOR_T* _dmadesc_b = nullptr; bool _double_dma_buffer = false; - bool _dmadesc_a_active = true; - uint32_t _dmadesc_b_idx = 0; - - HUB75_DMA_DESCRIPTOR_T* _dmadesc_b = nullptr; + //bool _dmadesc_a_active = true; esp_lcd_i80_bus_handle_t _i80_bus; diff --git a/src/platforms/platform_detect.hpp b/src/platforms/platform_detect.hpp index f660a5e..4373b37 100644 --- a/src/platforms/platform_detect.hpp +++ b/src/platforms/platform_detect.hpp @@ -39,7 +39,7 @@ Modified heavily for the ESP32 HUB75 DMA library by: #include "esp32s3/gdma_lcd_parallel16.hpp" #include "esp32s3/esp32s3-default-pins.hpp" - #else + #elif defined (CONFIG_IDF_TARGET_ESP32) // Assume an ESP32 (the original 2015 version) // Same include as ESP32S3 |
