@@ -587,15 +587,35 @@ static void i2c_stm32_irq_config_func_##index(const struct device *dev) \
587
587
588
588
#ifdef CONFIG_I2C_STM32_V2_DMA
589
589
590
- #define I2C_DMA_INIT (index , dir ) \
591
- .dir##_dma = {.dev_dma = COND_CODE_1(DT_INST_DMAS_HAS_NAME(index, dir), \
592
- (DEVICE_DT_GET(STM32_DMA_CTLR(index, dir))), (NULL)), \
593
- .dma_channel = COND_CODE_1(DT_INST_DMAS_HAS_NAME(index, dir), \
594
- (DT_INST_DMAS_CELL_BY_NAME(index, dir, channel)), (-1))},
590
+ #define I2C_DMA_INIT (index , dir ) \
591
+ .dir##_dma = { \
592
+ .dev_dma = COND_CODE_1(DT_INST_DMAS_HAS_NAME(index, dir),\
593
+ (DEVICE_DT_GET(STM32_DMA_CTLR(index, dir))), (NULL)),\
594
+ .dma_channel = COND_CODE_1(DT_INST_DMAS_HAS_NAME(index, dir),\
595
+ (DT_INST_DMAS_CELL_BY_NAME(index, dir, channel)), (-1)),\
596
+ },
597
+
598
+ #define I2C_DMA_DATA_INIT (index , dir , src , dest ) \
599
+ .dma_##dir##_cfg = { \
600
+ .dma_slot = STM32_DMA_SLOT(index, dir, slot), \
601
+ .channel_direction = STM32_DMA_CONFIG_DIRECTION( \
602
+ STM32_DMA_CHANNEL_CONFIG(index, dir)),\
603
+ .cyclic = STM32_DMA_CONFIG_CYCLIC( \
604
+ STM32_DMA_CHANNEL_CONFIG(index, dir)), \
605
+ .channel_priority = STM32_DMA_CONFIG_PRIORITY( \
606
+ STM32_DMA_CHANNEL_CONFIG(index, dir)), \
607
+ .source_data_size = STM32_DMA_CONFIG_##src##_DATA_SIZE( \
608
+ STM32_DMA_CHANNEL_CONFIG(index, dir)),\
609
+ .dest_data_size = STM32_DMA_CONFIG_##dest##_DATA_SIZE( \
610
+ STM32_DMA_CHANNEL_CONFIG(index, dir)), \
611
+ .source_burst_length = 1, \
612
+ .dest_burst_length = 1, \
613
+ }, \
595
614
596
615
#else
597
616
598
617
#define I2C_DMA_INIT (index , dir )
618
+ #define I2C_DMA_DATA_INIT (index , dir , src , dest )
599
619
600
620
#endif /* CONFIG_I2C_STM32_V2_DMA */
601
621
@@ -624,11 +644,14 @@ static const struct i2c_stm32_config i2c_stm32_cfg_##index = { \
624
644
IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32_i2c_v2), \
625
645
(.timings = (const struct i2c_config_timing *) i2c_timings_##index,\
626
646
.n_timings = ARRAY_SIZE(i2c_timings_##index),)) \
627
- I2C_DMA_INIT(index, tx) \
628
- I2C_DMA_INIT(index, rx) \
647
+ I2C_DMA_INIT(index, tx) \
648
+ I2C_DMA_INIT(index, rx) \
629
649
}; \
630
650
\
631
- static struct i2c_stm32_data i2c_stm32_dev_data_##index; \
651
+ static struct i2c_stm32_data i2c_stm32_dev_data_##index = { \
652
+ I2C_DMA_DATA_INIT(index, tx, MEMORY, PERIPHERAL) \
653
+ I2C_DMA_DATA_INIT(index, rx, PERIPHERAL, MEMORY) \
654
+ }; \
632
655
\
633
656
PM_DEVICE_DT_INST_DEFINE(index, i2c_stm32_pm_action); \
634
657
\
0 commit comments