Skip to content

Commit

Permalink
fixes SPIBus invalid argument
Browse files Browse the repository at this point in the history
  • Loading branch information
kdschlosser committed May 11, 2024
1 parent 7a8f44b commit 9d55480
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions ext_mod/lcd_bus/esp32_include/spi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
lcd_panel_io_t panel_io_handle;
esp_lcd_panel_io_spi_config_t panel_io_config;
spi_bus_config_t bus_config;
esp_lcd_spi_bus_handle_t bus_handle;

int host;
spi_host_device_t bus_handle;

} mp_lcd_spi_bus_obj_t;

Expand Down
10 changes: 4 additions & 6 deletions ext_mod/lcd_bus/esp32_src/spi_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ STATIC mp_obj_t mp_lcd_spi_bus_make_new(const mp_obj_type_t *type, size_t n_args

int temp_host;

uint8_t miso_host = 5;
if (
mosi == SPI_IOMUX_PIN_NUM_MOSI &&
clk == SPI_IOMUX_PIN_NUM_CLK &&
Expand Down Expand Up @@ -154,8 +153,7 @@ STATIC mp_obj_t mp_lcd_spi_bus_make_new(const mp_obj_type_t *type, size_t n_args

self->callback = mp_const_none;

self->host = host;
self->bus_handle = (esp_lcd_spi_bus_handle_t)host;
self->bus_handle = (spi_host_device_t)host;

self->bus_config.sclk_io_num = clk;
self->bus_config.mosi_io_num = mosi;
Expand Down Expand Up @@ -199,7 +197,7 @@ mp_lcd_err_t spi_del(mp_obj_t obj)
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("%d(esp_lcd_panel_io_del)"), ret);
}

ret = spi_bus_free(self->host);
ret = spi_bus_free(self->bus_handle);
if (ret != 0) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("%d(spi_bus_free)"), ret);
}
Expand Down Expand Up @@ -254,12 +252,12 @@ mp_lcd_err_t spi_init(mp_obj_t obj, uint16_t width, uint16_t height, uint8_t bpp
self->panel_io_config.trans_queue_depth = 10;
}

mp_lcd_err_t ret = spi_bus_initialize(self->host, &self->bus_config, SPI_DMA_CH_AUTO);
mp_lcd_err_t ret = spi_bus_initialize(self->bus_handle, &self->bus_config, SPI_DMA_CH_AUTO);
if (ret != 0) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("%d(spi_bus_initialize)"), ret);
}

ret = esp_lcd_new_panel_io_spi(self->bus_handle, &self->panel_io_config, &self->panel_io_handle.panel_io);
ret = esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)self->bus_handle, &self->panel_io_config, &self->panel_io_handle.panel_io);
if (ret != 0) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("%d(esp_lcd_new_panel_io_spi)"), ret);
}
Expand Down

0 comments on commit 9d55480

Please sign in to comment.