fix shared peripheral interrupts causing hangs

custom
jacqueline 2 years ago
parent 1f903accd9
commit 7e96482087
  1. 9
      src/drivers/display.cpp
  2. 4
      src/drivers/spi.cpp

@ -17,6 +17,7 @@
#include "esp_attr.h" #include "esp_attr.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
#include "esp_intr_alloc.h"
#include "freertos/portable.h" #include "freertos/portable.h"
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#include "freertos/projdefs.h" #include "freertos/projdefs.h"
@ -126,7 +127,8 @@ auto Display::Create(GpioExpander* expander,
ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 0)); ESP_ERROR_CHECK(ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 0));
ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0)); ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0));
// ledc_fade_func_install(0); ledc_fade_func_install(ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED |
ESP_INTR_FLAG_IRAM);
// Next, init the SPI device // Next, init the SPI device
spi_device_interface_config_t spi_cfg = { spi_device_interface_config_t spi_cfg = {
@ -194,9 +196,8 @@ auto Display::SetDisplayOn(bool enabled) -> void {
display_on_ = enabled; display_on_ = enabled;
int new_duty = display_on_ ? brightness_ : 0; int new_duty = display_on_ ? brightness_ : 0;
// ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, new_duty, ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, new_duty, 250);
// 250); ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_NO_WAIT);
// LEDC_FADE_NO_WAIT);
} }
void Display::SendInitialisationSequence(const uint8_t* data) { void Display::SendInitialisationSequence(const uint8_t* data) {

@ -10,6 +10,7 @@
#include "driver/spi_common.h" #include "driver/spi_common.h"
#include "driver/spi_master.h" #include "driver/spi_master.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_intr_alloc.h"
#include "hal/spi_types.h" #include "hal/spi_types.h"
namespace drivers { namespace drivers {
@ -37,7 +38,8 @@ esp_err_t init_spi(void) {
// manages its down use of DMA-capable memory. // manages its down use of DMA-capable memory.
.max_transfer_sz = 128 * 16 * 2, // TODO: hmm .max_transfer_sz = 128 * 16 * 2, // TODO: hmm
.flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_IOMUX_PINS, .flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_IOMUX_PINS,
.intr_flags = 0, .intr_flags =
ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_IRAM,
}; };
if (esp_err_t err = spi_bus_initialize(kSpiHost, &config, SPI_DMA_CH_AUTO)) { if (esp_err_t err = spi_bus_initialize(kSpiHost, &config, SPI_DMA_CH_AUTO)) {

Loading…
Cancel
Save