dma: add error check on peripheral to peripheral

add dma direction check for dma_sam0

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This commit is contained in:
Hake Huang 2020-05-06 23:41:04 +08:00 committed by Maureen Helm
commit 999c59c1ec

View file

@ -149,10 +149,14 @@ static int dma_sam0_config(struct device *dev, uint32_t channel,
*/
chcfg->CHCTRLA.reg = DMAC_CHCTRLA_TRIGACT_TRANSACTION |
DMAC_CHCTRLA_TRIGSRC(config->dma_slot);
} else {
} else if ((config->channel_direction == MEMORY_TO_PERIPHERAL) ||
(config->channel_direction == PERIPHERAL_TO_MEMORY)) {
/* One peripheral trigger per beat */
chcfg->CHCTRLA.reg = DMAC_CHCTRLA_TRIGACT_BURST |
DMAC_CHCTRLA_TRIGSRC(config->dma_slot);
} else {
LOG_ERR("Direction error. %d", config->channel_direction);
goto inval;
}
/* Set the priority */