Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid esp32-s3 compile error #243

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions driver/esp32/espidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,22 @@ void ili9xxx_flush(void *_disp_drv, const void *_area, void *_color_p)

ili9xxx_send_data_dma(disp_drv, color_p, size * color_size, dc, *spi_ptr);
}

#if CONFIG_IDF_TARGET_ESP32S3
// Cheat linker :)
// Related issue:
// https://github.com/espressif/esp-idf/issues/10203
// https://github.com/espressif/esp-idf/issues/10204
// https://github.com/espressif/esp-idf/issues/10205

uint32_t gpio_input_get_high(void) {
return 0;
}

void gpio_output_set_high(uint32_t set_mask, uint32_t clear_mask, uint32_t enable_mask, uint32_t disable_mask) {
}

esp_err_t rtc_gpio_force_hold_all(void) {
return ESP_OK;
}
#endif
11 changes: 11 additions & 0 deletions driver/esp32/espidf.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ void * memset ( void * ptr, int value, size_t num );

static inline void SPH0645_WORKAROUND(int i2s_num)
{
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
REG_SET_BIT( I2S_TIMING_REG(i2s_num), BIT(9));
REG_SET_BIT( I2S_CONF_REG(i2s_num), I2S_RX_MSB_SHIFT);
#elif CONFIG_IDF_TARGET_ESP32S3
REG_SET_BIT( I2S_RX_TIMING_REG(i2s_num), BIT(9));
REG_SET_BIT( I2S_RX_CONF_REG(i2s_num), I2S_RX_MSB_SHIFT);
#endif
}

/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -177,9 +182,15 @@ void ex_spi_post_cb_isr(spi_transaction_t *trans);
#if defined(ESP_IDF_VERSION_MAJOR) && ESP_IDF_VERSION_MAJOR >= 4
// SPI HOST enum was changed to macros on v4
enum {
#if CONFIG_IDF_TARGET_ESP32
ENUM_SPI_HOST = SPI_HOST,
ENUM_HSPI_HOST = HSPI_HOST,
ENUM_VSPI_HOST = VSPI_HOST,
#elif CONFIG_IDF_TARGET_ESP32S3
ENUM_SPI_HOST = SPI1_HOST,
ENUM_HSPI_HOST = SPI2_HOST,
ENUM_VSPI_HOST = SPI3_HOST,
#endif
};
#endif

Expand Down
3 changes: 2 additions & 1 deletion driver/esp32/ili9XXX.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def disp_spi_init(self):
esp.gpio_set_direction(self.mosi, esp.GPIO_MODE.OUTPUT)
esp.gpio_set_direction(self.clk, esp.GPIO_MODE.OUTPUT)

ret = esp.spi_bus_initialize(self.spihost, buscfg, 1)
# USE SPI_DMA_CH_AUTO
ret = esp.spi_bus_initialize(self.spihost, buscfg, 3)
if ret != 0: raise RuntimeError("Failed initializing SPI bus")

self.trans_buffer = esp.heap_caps_malloc(TRANS_BUFFER_LEN, esp.MALLOC_CAP.DMA)
Expand Down
28 changes: 28 additions & 0 deletions driver/esp32/modrtch.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ static const char TAG[] = "[RTCH]";
#endif

#define GPIO_TO_ADC_ELEMENT(x) [x] = CONCAT3(ADC1_GPIO, x, _CHANNEL)
#if CONFIG_IDF_TARGET_ESP32
// ESP32 ADC1 has 8 channels
static const int gpio_to_adc[] = {
GPIO_TO_ADC_ELEMENT(36),
GPIO_TO_ADC_ELEMENT(37),
Expand All @@ -67,6 +69,30 @@ static const int gpio_to_adc[] = {
GPIO_TO_ADC_ELEMENT(34),
GPIO_TO_ADC_ELEMENT(35),
};
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
// ESP32-C3 & ESP32-H2 ADC1 has 5 channels
static const int gpio_to_adc[] = {
GPIO_TO_ADC_ELEMENT(0),
GPIO_TO_ADC_ELEMENT(1),
GPIO_TO_ADC_ELEMENT(2),
GPIO_TO_ADC_ELEMENT(3),
GPIO_TO_ADC_ELEMENT(4),
};
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
// ESP32-S2 & ESP32-S3 ADC1 has 10 channels
static const int gpio_to_adc[] = {
GPIO_TO_ADC_ELEMENT(1),
GPIO_TO_ADC_ELEMENT(2),
GPIO_TO_ADC_ELEMENT(3),
GPIO_TO_ADC_ELEMENT(4),
GPIO_TO_ADC_ELEMENT(5),
GPIO_TO_ADC_ELEMENT(6),
GPIO_TO_ADC_ELEMENT(7),
GPIO_TO_ADC_ELEMENT(8),
GPIO_TO_ADC_ELEMENT(9),
GPIO_TO_ADC_ELEMENT(10),
};
#endif

//////////////////////////////////////////////////////////////////////////////
// Module definition
Expand Down Expand Up @@ -392,7 +418,9 @@ STATIC int measure_axis(

adc1_channel_t adc_channel = gpio_to_adc[measure];

#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
adc_gpio_init(ADC_UNIT_1, adc_channel);
#endif
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(adc_channel,ADC_ATTEN_DB_11);

Expand Down
2 changes: 1 addition & 1 deletion driver/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef struct mp_ptr_t

STATIC mp_int_t mp_ptr_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags)
{
mp_ptr_t *self = MP_OBJ_TO_PTR(self_in);
mp_ptr_t *self = (mp_ptr_t*)MP_OBJ_TO_PTR(self_in);

if (flags & MP_BUFFER_WRITE) {
// read-only ptr
Expand Down
19 changes: 19 additions & 0 deletions mkrules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ function(all_lv_bindings)
# ESPIDF bindings

if(ESP_PLATFORM)
if (IDF_TARGET STREQUAL "esp32s3")
# 1. not support Ethernet MAC Interface.
# 2. esp32s3.rom.ld not provide lldesc_xxx functions for now.
LIST(APPEND FILTER_HEADERS
esp_eth.h
esp_eth_phy.h
esp_eth_netif_glue.h
lldesc.h
)

if (IDF_VERSION_MAJOR EQUAL 4)
# xt_clock_freq was deprecated.
LIST(APPEND FILTER_HEADERS
FreeRTOSConfig_arch.h
)
endif(IDF_VERSION_MAJOR EQUAL 4)
endif(IDF_TARGET STREQUAL "esp32s3")

file(GLOB_RECURSE LV_ESPIDF_HEADERS ${IDF_PATH}/components/*.h ${LV_BINDINGS_DIR}/driver/esp32/*.h)
lv_bindings(
OUTPUT
Expand All @@ -128,6 +146,7 @@ function(all_lv_bindings)
soc/sens_struct.h
soc/rtc.h
driver/periph_ctrl.h
${FILTER_HEADERS}
)
endif(ESP_PLATFORM)

Expand Down