drivers: dma: stm32: add get_status to dmamux driver

Add `get_status` function to dmamux driver api.
This uses the regular dma driver `get_status` function.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
This commit is contained in:
Shlomi Vaknin 2020-12-16 16:44:53 +02:00 committed by Anas Nashif
commit cad96852a2
3 changed files with 26 additions and 2 deletions

View file

@ -574,8 +574,8 @@ static int dma_stm32_init(const struct device *dev)
return 0;
}
static int dma_stm32_get_status(const struct device *dev, uint32_t id,
struct dma_status *stat)
DMA_STM32_EXPORT_API int dma_stm32_get_status(const struct device *dev,
uint32_t id, struct dma_status *stat)
{
const struct dma_stm32_config *config = dev->config;
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);

View file

@ -106,6 +106,8 @@ int dma_stm32_reload(const struct device *dev, uint32_t id,
uint32_t src, uint32_t dst, size_t size);
int dma_stm32_start(const struct device *dev, uint32_t id);
int dma_stm32_stop(const struct device *dev, uint32_t id);
int dma_stm32_get_status(const struct device *dev, uint32_t id,
struct dma_status *stat);
#else
#define DMA_STM32_EXPORT_API static
#endif /* CONFIG_DMAMUX_STM32 */

View file

@ -138,6 +138,27 @@ int dmamux_stm32_reload(const struct device *dev, uint32_t id,
return 0;
}
int dmamux_stm32_get_status(const struct device *dev, uint32_t id,
struct dma_status *stat)
{
const struct dmamux_stm32_config *dev_config = dev->config;
struct dmamux_stm32_data *data = dev->data;
/* check if this channel is valid */
if (id >= dev_config->channel_nb) {
LOG_ERR("channel ID %d is too big.", id);
return -EINVAL;
}
if (dma_stm32_get_status(data->mux_channels[id].dev_dma,
data->mux_channels[id].dma_id, stat) != 0) {
LOG_ERR("cannot get the status of dmamux channel %d.", id);
return -EINVAL;
}
return 0;
}
static int dmamux_stm32_init(const struct device *dev)
{
struct dmamux_stm32_data *data = dev->data;
@ -185,6 +206,7 @@ static const struct dma_driver_api dma_funcs = {
.config = dmamux_stm32_configure,
.start = dmamux_stm32_start,
.stop = dmamux_stm32_stop,
.get_status = dmamux_stm32_get_status,
};
#define DMAMUX_INIT(index) \