sabra88
Newbie level 2
I really need to know what is wrong with my call back function??????
this is my DMA config :
void SetupDma(void)
{
CMU_ClockEnable(cmuClock_DMA, true);
/* Initialization structs */
DMA_Init_TypeDef dmaInit;
DMA_CfgChannel_TypeDef WriteChannelConfig;
DMA_CfgChannel_TypeDef ReadChannelConfig;
DMA_CfgDescr_TypeDef WriteDescriptorConfig;
DMA_CfgDescr_TypeDef ReadDescriptorConfig;
/* DMA callback structure */
DMA_CB_TypeDef SF_WriteCallBack;
/* Initializing the DMA */
dmaInit.hprot = 0;
dmaInit.controlBlock = dmaControlBlock; //Pointer to the controlblock in memory holding descriptors
DMA_Init(&dmaInit);
/* Setup WRITE call-back function */
SF_WriteCallBack.cbFunc = DmaWriteComplete;
SF_WriteCallBack.userPtr = NULL;
/* Setting up WRITE channel */
WriteChannelConfig.highPri = true;
WriteChannelConfig.enableInt = true;
WriteChannelConfig.select = 0;
WriteChannelConfig.cb = &SF_WriteCallBack;
DMA_CfgChannel(DMA_CHANNEL_WRITE, &WriteChannelConfig);
/* Setting up WRITE channel descriptor */
WriteDescriptorConfig.dstInc = dmaDataInc1;
WriteDescriptorConfig.srcInc = dmaDataInc1;
WriteDescriptorConfig.size = dmaDataSize1;
WriteDescriptorConfig.arbRate = dmaArbitrate1;
WriteDescriptorConfig.hprot = 0;
DMA_CfgDescr(DMA_CHANNEL_WRITE, true, &WriteDescriptorConfig);
/* Setting up READ channel */
ReadChannelConfig.highPri = false;
ReadChannelConfig.enableInt = true;
ReadChannelConfig.select = DMAREQ_USART1_TXBL;
ReadChannelConfig.cb = &SF_WriteCallBack;
DMA_CfgChannel(DMA_CHANNEL_READ, &ReadChannelConfig);
/* Setting up READ channel descriptor */
ReadDescriptorConfig.dstInc = dmaDataIncNone;
ReadDescriptorConfig.srcInc = dmaDataInc1;
ReadDescriptorConfig.size = dmaDataSize1;
ReadDescriptorConfig.arbRate = dmaArbitrate1;
ReadDescriptorConfig.hprot = 0;
DMA_CfgDescr(DMA_CHANNEL_READ, true, &ReadDescriptorConfig);
}
and this is my call-back function:
void DmaWriteComplete (unsigned int channel, bool primary, void *user)
{
(void) primary;
(void) user;
/* Clear flag to indicate complete transfer */
if (channel == DMA_CHANNEL_WRITE)
{
WriteTransferActive = false;
}
else if (channel == DMA_CHANNEL_READ)
{
ReadTransferActive = false;
}
}
this is my DMA config :
void SetupDma(void)
{
CMU_ClockEnable(cmuClock_DMA, true);
/* Initialization structs */
DMA_Init_TypeDef dmaInit;
DMA_CfgChannel_TypeDef WriteChannelConfig;
DMA_CfgChannel_TypeDef ReadChannelConfig;
DMA_CfgDescr_TypeDef WriteDescriptorConfig;
DMA_CfgDescr_TypeDef ReadDescriptorConfig;
/* DMA callback structure */
DMA_CB_TypeDef SF_WriteCallBack;
/* Initializing the DMA */
dmaInit.hprot = 0;
dmaInit.controlBlock = dmaControlBlock; //Pointer to the controlblock in memory holding descriptors
DMA_Init(&dmaInit);
/* Setup WRITE call-back function */
SF_WriteCallBack.cbFunc = DmaWriteComplete;
SF_WriteCallBack.userPtr = NULL;
/* Setting up WRITE channel */
WriteChannelConfig.highPri = true;
WriteChannelConfig.enableInt = true;
WriteChannelConfig.select = 0;
WriteChannelConfig.cb = &SF_WriteCallBack;
DMA_CfgChannel(DMA_CHANNEL_WRITE, &WriteChannelConfig);
/* Setting up WRITE channel descriptor */
WriteDescriptorConfig.dstInc = dmaDataInc1;
WriteDescriptorConfig.srcInc = dmaDataInc1;
WriteDescriptorConfig.size = dmaDataSize1;
WriteDescriptorConfig.arbRate = dmaArbitrate1;
WriteDescriptorConfig.hprot = 0;
DMA_CfgDescr(DMA_CHANNEL_WRITE, true, &WriteDescriptorConfig);
/* Setting up READ channel */
ReadChannelConfig.highPri = false;
ReadChannelConfig.enableInt = true;
ReadChannelConfig.select = DMAREQ_USART1_TXBL;
ReadChannelConfig.cb = &SF_WriteCallBack;
DMA_CfgChannel(DMA_CHANNEL_READ, &ReadChannelConfig);
/* Setting up READ channel descriptor */
ReadDescriptorConfig.dstInc = dmaDataIncNone;
ReadDescriptorConfig.srcInc = dmaDataInc1;
ReadDescriptorConfig.size = dmaDataSize1;
ReadDescriptorConfig.arbRate = dmaArbitrate1;
ReadDescriptorConfig.hprot = 0;
DMA_CfgDescr(DMA_CHANNEL_READ, true, &ReadDescriptorConfig);
}
and this is my call-back function:
void DmaWriteComplete (unsigned int channel, bool primary, void *user)
{
(void) primary;
(void) user;
/* Clear flag to indicate complete transfer */
if (channel == DMA_CHANNEL_WRITE)
{
WriteTransferActive = false;
}
else if (channel == DMA_CHANNEL_READ)
{
ReadTransferActive = false;
}
}