Skip to content

Commit

Permalink
fix re-initialization for v6 board
Browse files Browse the repository at this point in the history
  • Loading branch information
vroland committed Feb 11, 2024
1 parent 73e9a74 commit 782b6a4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/board/epd_board_v6.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "driver/gpio.h"
#include "epd_board.h"

#include <esp_log.h>
Expand Down Expand Up @@ -144,8 +145,11 @@ static void epd_board_deinit() {
vTaskDelay(500);
pca9555_read_input(config_reg.port, 0);
pca9555_read_input(config_reg.port, 1);
ESP_LOGI("epdiy", "going to sleep.");
i2c_driver_delete(EPDIY_I2C_PORT);
gpio_isr_handler_remove(CFG_INTR);
gpio_uninstall_isr_service();
gpio_reset_pin(CFG_INTR);
gpio_reset_pin(V4_LATCH_ENABLE);
}

static void epd_board_set_ctrl(epd_ctrl_state_t *state, const epd_ctrl_state_t * const mask) {
Expand Down
2 changes: 2 additions & 0 deletions src/output_i2s/i2s_data_bus.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "i2s_data_bus.h"

#include "esp_intr_alloc.h"
#include "sdkconfig.h"

// the I2S driver is based on ESP32 registers and won't compile on the S3
Expand Down Expand Up @@ -301,6 +302,7 @@ void i2s_bus_init(i2s_bus_config *cfg, uint32_t epd_row_width) {
}

void i2s_bus_deinit() {
esp_intr_disable(gI2S_intr_handle);
esp_intr_free(gI2S_intr_handle);

free(i2s_state.buf_a);
Expand Down
1 change: 1 addition & 0 deletions src/output_i2s/render_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ void IRAM_ATTR i2s_fetch_frame_data(RenderContext_t *ctx, int thread_id) {
}

void i2s_deinit() {
rmt_pulse_deinit();
i2s_bus_deinit();
}

Expand Down
7 changes: 7 additions & 0 deletions src/output_i2s/rmt_pulse.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../output_common/render_method.h"
#include "esp_intr_alloc.h"

#ifdef RENDER_METHOD_I2S

Expand Down Expand Up @@ -60,6 +61,12 @@ void rmt_pulse_init(gpio_num_t pin) {
rmt_set_tx_intr_en(row_rmt_config.channel, true);
}


void rmt_pulse_deinit() {
esp_intr_disable(gRMT_intr_handle);
esp_intr_free(gRMT_intr_handle);
}

void IRAM_ATTR pulse_ckv_ticks(uint16_t high_time_ticks,
uint16_t low_time_ticks, bool wait) {
while (!rmt_tx_done) {
Expand Down
7 changes: 7 additions & 0 deletions src/output_i2s/rmt_pulse.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
*/
void rmt_pulse_init(gpio_num_t pin);


/**
* Resets the pin and RMT peripheral, frees associated resources.
*/
void rmt_pulse_deinit();

/**
* Outputs a single pulse (high -> low) on the configured pin.
* This function will always wait for a previous call to finish.
Expand All @@ -38,3 +44,4 @@ bool rmt_busy();
*/
void pulse_ckv_ticks(uint16_t high_time_us, uint16_t low_time_us,
bool wait);

22 changes: 12 additions & 10 deletions test/test_initialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
#include "epdiy.h"
#include "epd_display.h"

TEST_CASE("Mean of an empty array is zero", "[mean]")
{
const int values[] = { 0 };
TEST_ASSERT_EQUAL(1, 1);
}

TEST_CASE("V7 initialization and deinitialization works", "[epdiy]")
// choose the default demo board depending on the architecture
#ifdef CONFIG_IDF_TARGET_ESP32
#define TEST_BOARD epd_board_v6
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#define TEST_BOARD epd_board_v7
#endif

TEST_CASE("initialization and deinitialization works", "[epdiy]")
{
epd_init(&epd_board_v7, &ED097TC2, EPD_OPTIONS_DEFAULT);
epd_init(&TEST_BOARD, &ED097TC2, EPD_OPTIONS_DEFAULT);

epd_poweron();
vTaskDelay(2);
Expand All @@ -23,17 +25,17 @@ TEST_CASE("V7 initialization and deinitialization works", "[epdiy]")
epd_deinit();
}

TEST_CASE("V7 re-initialization works", "[epdiy]")
TEST_CASE("re-initialization works", "[epdiy]")
{
epd_init(&epd_board_v7, &ED097TC2, EPD_OPTIONS_DEFAULT);
epd_init(&TEST_BOARD, &ED097TC2, EPD_OPTIONS_DEFAULT);

epd_poweron();
vTaskDelay(2);
epd_poweroff();

epd_deinit();

epd_init(&epd_board_v7, &ED097TC2, EPD_OPTIONS_DEFAULT);
epd_init(&TEST_BOARD, &ED097TC2, EPD_OPTIONS_DEFAULT);

epd_poweron();
vTaskDelay(2);
Expand Down

0 comments on commit 782b6a4

Please sign in to comment.