i2c: stm32: add DMA callback stubs to avoid nullptr calls in ISR context
Add stub functions for the I2C DMA callbacks, which are invoked during or upon completion of DMA-based I2C transactions. Without these, NULL pointer calls occur on DMA transfer complete or error events, leading to faults within ISR context. Signed-off-by: Simon Gilbert <srdgilbert@gmail.com>
This commit is contained in:
parent
4348be608d
commit
5c04df9127
1 changed files with 27 additions and 0 deletions
|
@ -595,6 +595,32 @@ static void i2c_stm32_irq_config_func_##index(const struct device *dev) \
|
|||
(DT_INST_DMAS_CELL_BY_NAME(index, dir, channel)), (-1)),\
|
||||
},
|
||||
|
||||
void i2c_stm32_dma_tx_cb(const struct device *dma_dev, void *user_data,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
ARG_UNUSED(dma_dev);
|
||||
ARG_UNUSED(user_data);
|
||||
ARG_UNUSED(channel);
|
||||
|
||||
/* log DMA TX error */
|
||||
if (status != 0) {
|
||||
LOG_ERR("DMA error %d", status);
|
||||
}
|
||||
}
|
||||
|
||||
void i2c_stm32_dma_rx_cb(const struct device *dma_dev, void *user_data,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
ARG_UNUSED(dma_dev);
|
||||
ARG_UNUSED(user_data);
|
||||
ARG_UNUSED(channel);
|
||||
|
||||
/* log DMA RX error */
|
||||
if (status != 0) {
|
||||
LOG_ERR("DMA error %d", status);
|
||||
}
|
||||
}
|
||||
|
||||
#define I2C_DMA_DATA_INIT(index, dir, src, dest) \
|
||||
.dma_##dir##_cfg = { \
|
||||
.dma_slot = STM32_DMA_SLOT(index, dir, slot), \
|
||||
|
@ -610,6 +636,7 @@ static void i2c_stm32_irq_config_func_##index(const struct device *dev) \
|
|||
STM32_DMA_CHANNEL_CONFIG(index, dir)), \
|
||||
.source_burst_length = 1, \
|
||||
.dest_burst_length = 1, \
|
||||
.dma_callback = i2c_stm32_dma_##dir##_cb, \
|
||||
}, \
|
||||
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue