Skip to content

Commit 3294767

Browse files
authored
Fix compilation of GDMA and periph enable in IDF 6 (#816)
1 parent b3c2aa2 commit 3294767

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

target/esp32/ll_cam.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ static inline int gpio_ll_get_level(gpio_dev_t *hw, int gpio_num)
4545
#define gpio_matrix_in(a,b,c) esp_rom_gpio_connect_in_signal(a,b,c)
4646
#endif
4747

48+
#if (ESP_IDF_VERSION_MAJOR > 5)
49+
#include "soc/dport_access.h"
50+
#include "soc/dport_reg.h"
51+
#endif
52+
4853
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 2)
4954
#define ets_delay_us esp_rom_delay_us
5055
#endif
@@ -289,7 +294,12 @@ bool ll_cam_start(cam_obj_t *cam, int frame_pos)
289294
esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config)
290295
{
291296
// Enable and configure I2S peripheral
297+
#if ESP_IDF_VERSION_MAJOR > 5
298+
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
299+
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
300+
#else
292301
periph_module_enable(PERIPH_I2S0_MODULE);
302+
#endif
293303

294304
I2S0.conf.rx_reset = 1;
295305
I2S0.conf.rx_reset = 0;

target/esp32s2/ll_cam.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#define ets_delay_us(a) esp_rom_delay_us(a)
3434
#endif
3535

36+
#if (ESP_IDF_VERSION_MAJOR > 5)
37+
#include "soc/dport_access.h"
38+
#endif
39+
3640
static const char *TAG = "s2 ll_cam";
3741

3842
#define I2S_ISR_ENABLE(i) {I2S0.int_clr.i = 1;I2S0.int_ena.i = 1;}
@@ -136,7 +140,12 @@ esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config)
136140
if(err != ESP_OK) {
137141
return err;
138142
}
143+
#if ESP_IDF_VERSION_MAJOR > 5
144+
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
145+
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN0_REG, DPORT_I2S0_RST);
146+
#else
139147
periph_module_enable(PERIPH_I2S0_MODULE);
148+
#endif
140149
// Configure the clock
141150
I2S0.clkm_conf.clkm_div_num = 2; // 160MHz / 2 = 80MHz
142151
I2S0.clkm_conf.clkm_div_b = 0;

target/esp32s3/ll_cam.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "soc/lcd_cam_struct.h"
1919
#include "soc/lcd_cam_reg.h"
2020
#include "soc/gdma_struct.h"
21-
#include "soc/gdma_periph.h"
2221
#include "soc/gdma_reg.h"
2322
#include "hal/clk_gate_ll.h"
2423
#include "esp_private/gdma.h"
@@ -36,6 +35,12 @@
3635
#define ets_delay_us(a) esp_rom_delay_us(a)
3736
#endif
3837

38+
#if (ESP_IDF_VERSION_MAJOR > 5)
39+
#include "soc/dport_access.h"
40+
#else
41+
#include "soc/gdma_periph.h"
42+
#endif
43+
3944
#if !defined(SOC_GDMA_PAIRS_PER_GROUP) && defined(SOC_GDMA_PAIRS_PER_GROUP_MAX)
4045
#define SOC_GDMA_PAIRS_PER_GROUP SOC_GDMA_PAIRS_PER_GROUP_MAX
4146
#endif
@@ -235,16 +240,20 @@ static esp_err_t ll_cam_dma_init(cam_obj_t *cam)
235240
// }
236241
// }
237242

243+
#if ESP_IDF_VERSION_MAJOR > 5
244+
if (!(DPORT_REG_GET_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST) == 0 &&
245+
DPORT_REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN) != 0)) {
246+
DPORT_CLEAR_PERI_REG_MASK(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN);
247+
DPORT_SET_PERI_REG_MASK(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST);
248+
DPORT_SET_PERI_REG_MASK(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN);
249+
DPORT_CLEAR_PERI_REG_MASK(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST);
250+
}
251+
#else
238252
if (!periph_ll_periph_enabled(PERIPH_GDMA_MODULE)) {
239253
periph_ll_disable_clk_set_rst(PERIPH_GDMA_MODULE);
240254
periph_ll_enable_clk_clear_rst(PERIPH_GDMA_MODULE);
241255
}
242-
// if (REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN) == 0) {
243-
// REG_CLR_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN);
244-
// REG_SET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN);
245-
// REG_SET_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST);
246-
// REG_CLR_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST);
247-
// }
256+
#endif
248257
ll_cam_dma_reset(cam);
249258
return ESP_OK;
250259
}
@@ -405,7 +414,12 @@ esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config)
405414
esp_err_t ll_cam_init_isr(cam_obj_t *cam)
406415
{
407416
esp_err_t ret = ESP_OK;
408-
ret = esp_intr_alloc_intrstatus(gdma_periph_signals.groups[0].pairs[cam->dma_num].rx_irq_id,
417+
ret = esp_intr_alloc_intrstatus(
418+
#if (ESP_IDF_VERSION_MAJOR > 5)
419+
ETS_DMA_IN_CH0_INTR_SOURCE + cam->dma_num,
420+
#else
421+
gdma_periph_signals.groups[0].pairs[cam->dma_num].rx_irq_id,
422+
#endif
409423
ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | CAMERA_ISR_IRAM_FLAG,
410424
(uint32_t)&GDMA.channel[cam->dma_num].in.int_st, GDMA_IN_SUC_EOF_CH0_INT_ST_M,
411425
ll_cam_dma_isr, cam, &cam->dma_intr_handle);

0 commit comments

Comments
 (0)