📄 xllp_dmac.c
字号:
/* Construct command value from pCmd */
XLLP_UINT32_T aCommand = (XLLP_UINT32_T)(
( pCmd->aLen) | ((pCmd->aWidth) << XLLP_BIT_FIELD_14)|
((pCmd->aSize) << XLLP_BIT_FIELD_16) |
((pCmd->aEndian) << XLLP_BIT_FIELD_18) |
((pCmd->aFlyByT) << XLLP_BIT_FIELD_19) |
((pCmd->aFlyByS) << XLLP_BIT_FIELD_20) |
((pCmd->aEndIrqEn) << XLLP_BIT_FIELD_21)|
((pCmd->aStartIrqEn) << XLLP_BIT_FIELD_22)|
((pCmd->aAddrMode) << XLLP_BIT_FIELD_23)|
((pCmd->aCmpEn) << XLLP_BIT_FIELD_25) |
((pCmd->aFlowTrg) << XLLP_BIT_FIELD_28) |
((pCmd->aFlowSrc) << XLLP_BIT_FIELD_29) |
((pCmd->aIncTrgAddr) << XLLP_BIT_FIELD_30)|
((pCmd->aIncSrcAddr) << XLLP_BIT_FIELD_31)
);
/* Clear reserved bit fields of DDADR */
XLLP_VUINT32_T aNextDesc = (XLLP_VUINT32_T)pNextDescPhyAddr;
aNextDesc = (XLLP_VUINT32_T)(aNextDesc & XLLP_DMAC_DDADR_RESERVED_MASK);
aTargetValue = (XLLP_VUINT32_T)(aNextDesc + (aBranch<<XLLP_BIT_FIELD_1) + aStopContinue);
/* Fill descriptor entries */
pDesc->DDADR = (XLLP_VUINT32_T)(aNextDesc) + (aBranch<<XLLP_BIT_FIELD_1) + aStopContinue;
pDesc->DSADR = (XLLP_VUINT32_T)aSrcAddr;
pDesc->DTADR = (XLLP_VUINT32_T)aTargetAddr;
pDesc->DCMD = (XLLP_VUINT32_T)aCommand;
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacCfgChannelDescTransfer
Description: XllpDmacCfgChannelDescTransfer configures the specified DMA
channel for a Descriptor Mode transfer operation. To configure
a channel for a no descriptor mode transfer, use the
XllpDmacCfgChannelNoDescTransfer primitive. It is expected that
the developer has already made calls to XllpDmacAllocChannel for
an available channel and bound it to a service routine for interrupt
that may occur on the channel, and XllpDmacFillLinkedDesc to
configure the descriptor before calling this primitives.
Global Registers Modified:
DDADRx, DRCMRx registers. DSADRx, DTADRx, and DCMDx register will be modified
when the descriptor is loaded. x indicates the channel number
Input Arguments:
pDesc: Hold the pointer to the descriptor to be used in configuring the
specified DMA channel. The pointer cannot be null.
aChannel: Specifies the channel to be configured for the DMA transfer.
aDeviceDrcmr: Specifies the device to be mapped to the DMA channel for the transfer
operation.
aLignment: Indicated whether to enable byte alignment for memory accesses
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacCfgChannelDescTransfer(
P_XLLP_DMAC_DESCRIPTOR_T pDesc,
XLLP_DMAC_CHANNEL_T aChannel,
//XLLP_DMAC_DRCMR_T aDeviceDrcmr,
XLLP_DMAC_DEVICE_T aDeviceDrcmr,
XLLP_DMAC_ALIGNMENT_T aLignment
)
{
XLLP_VUINT32_T aTargetData;
if (aLignment == XLLP_DMAC_ALIGNMENT_ON)
{
aTargetData = pDmacHandle->DALGN;
aTargetData |= (1 << aChannel);
pDmacHandle->DALGN = aTargetData;
}
/* Map device to channel */
/* No mapping required for mem2mem moves */
if (aDeviceDrcmr != XLLP_DMAC_MEM2MEM_MOVE)
{
XllpDmacMapDeviceToChannel(aDeviceDrcmr, aChannel);
}
pDmacHandle->DDG[aChannel].DDADR = (XLLP_VUINT32_T)pDesc;
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacCfgChannelNoDescTransfer
Description: XllpDmacCfgChannelNoDescTransfer configures the specified DMA
channel for a No Descriptor Mode transfer operation. To configure
a channel for a descriptor mode transfer, use the
XllpDmacCfgChannelDescTransfer primitive. It is expected that the
developer has already obtained an available channel using the
XllpDmacAllocChannel primitive and bound it to a service routine
for interrupt that may occur on the channel.
Global Registers Modified:
DRCMRx, DSADRx, DTADRx, DCSRx, and DCMDx registers, where x indicate the
channel number
Input Arguments:
aSourceAddr: Source address of the DMA transfer to be configured
aTargetAddr: Target address of the DMA transfer to be configured
pCmd: Commands for the channel to be configured. Users are required to
initialize the various fields of pCmd data structure before making this
call.
aChannel: Specifies the channel to be configured for the DMA transfer.
aDeviceDrcmr: Specifies the device to be mapped to the DMA channel for the transfer
operation.
aLignment: Indicated whether to enable byte alignment for memory accesses
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacCfgChannelNoDescTransfer(
XLLP_UINT32_T aSourceAddr,
XLLP_UINT32_T aTargetAddr,
XLLP_DMAC_COMMAND_T* pCmd,
XLLP_DMAC_CHANNEL_T aChannel,
XLLP_DMAC_DEVICE_T aDeviceDrcmr,
XLLP_DMAC_ALIGNMENT_T aLignment
)
{
XLLP_VUINT32_T aCommand, aTargetData;
if (aLignment == XLLP_DMAC_ALIGNMENT_ON)
{
aTargetData = pDmacHandle->DALGN;
aTargetData |= (1 << aChannel);
pDmacHandle->DALGN = aTargetData;
}
/* Map device to channel */
/* No mapping required for mem2mem moves */
if (aDeviceDrcmr != XLLP_DMAC_MEM2MEM_MOVE)
{
XllpDmacMapDeviceToChannel(aDeviceDrcmr, aChannel);
}
/* Set the No Descriptor Fetch bit in DCSR*/
aTargetData = pDmacHandle->DCSR[aChannel];
aTargetData |= XLLP_DMAC_DCSR_NO_DESC_FETCH;
pDmacHandle->DCSR[aChannel] = aTargetData;
/* Construct command value from pCmd */
aCommand = (
(pCmd->aLen) | ((pCmd->aWidth) << XLLP_BIT_FIELD_14)|
((pCmd->aSize) << XLLP_BIT_FIELD_16) |
((pCmd->aEndian) << XLLP_BIT_FIELD_18) |
((pCmd->aFlyByT) << XLLP_BIT_FIELD_19) |
((pCmd->aFlyByS) << XLLP_BIT_FIELD_20) |
((pCmd->aEndIrqEn) << XLLP_BIT_FIELD_21)|
((pCmd->aStartIrqEn) << XLLP_BIT_FIELD_22)|
((pCmd->aAddrMode) << XLLP_BIT_FIELD_23)|
((pCmd->aCmpEn) << XLLP_BIT_FIELD_25) |
((pCmd->aFlowTrg) << XLLP_BIT_FIELD_28) |
((pCmd->aFlowSrc) << XLLP_BIT_FIELD_29) |
((pCmd->aIncTrgAddr) << XLLP_BIT_FIELD_30)|
((pCmd->aIncSrcAddr) << XLLP_BIT_FIELD_31)
);
pDmacHandle->DDG[aChannel].DSADR = aSourceAddr;
pDmacHandle->DDG[aChannel].DTADR = aTargetAddr;
pDmacHandle->DDG[aChannel].DCMD = aCommand;
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacStartTransfer
Description: XllpDmacStartTransfer starts the DMA transfer process for the
specified channel.
Global Registers Modified:
DCSRx register, where x indicate the channel number
Input Arguments:
aChannel: Specifies the channel to start the DMA transfer on.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacStartTransfer( XLLP_DMAC_CHANNEL_T aChannel )
{
pDmacHandle->DCSR[aChannel] |= XLLP_DMAC_DCSR_RUN;
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacStopTransfer
Description: XllpDmacStopTransfer stops the DMA transfer process for the
specified channel.
Global Registers Modified:
DCSRx register, where x indicate the channel number
Input Arguments:
aChannel: Specifies the channel to stop the DMA transfer on.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacStopTransfer( XLLP_DMAC_CHANNEL_T aChannel )
{
pDmacHandle->DCSR[aChannel] &= ~XLLP_DMAC_DCSR_RUN;
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacAttachDesc
Description: XllpDmacAttachDesc attaches the specified descriptor to the
chained/linked descriptors. Users who want to attach a descriptor
on the fly can use this function. Note that if DMA transfers are
already in session for the specified channel, this transfer will
be stopped, attach the descriptor, and then restarted. Users can
use XllpDmacGetChannelStatus to request status of the channel,
ensure that the current transfer completes before attaching
additional descriptors.
Global Registers Modified:
DCSRx, and DDADRx registers, where x indicate the channel number
Input Arguments:
pDesc: Holds the pointer to the descriptor to be attached. The pointer
cannot be null.
pPrevDesc: Holds the pointer to the descriptor in the chain that is to have
the "to be attached" descriptor pDesc as the next descriptor.
That is, pPrevDesc will have pDesc as the next descriptor, and
pDesc will have pNextDesc as its next descriptor in the chain.
pPrevDesc points to pDesc and pDesc points to pNextDesc.
pNextDesc: Holds the pointer to the descriptor in the chain that will be
the next descriptor to pDesc. See description of pPrevDesc for
more details.
pStartDesc: Descriptor to re-start DMA transfer from
aChannel: Specifies the DMA channel the linked descriptors are utilizing
for the transfer process.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacAttachDesc(
P_XLLP_DMAC_DESCRIPTOR_T pDesc,
P_XLLP_DMAC_DESCRIPTOR_T pPrevDesc,
P_XLLP_DMAC_DESCRIPTOR_T pNextDesc,
P_XLLP_DMAC_DESCRIPTOR_T pStartDesc,
XLLP_DMAC_CHANNEL_T aChannel
)
{
XLLP_VUINT32_T aTargetValue;
XLLP_BOOL_T aChannelRunStatus = XLLP_FALSE;
aTargetValue = pDmacHandle->DCSR[aChannel];
if((aTargetValue & (XLLP_VUINT32_T)XLLP_DMAC_DCSR_RUN) == (XLLP_VUINT32_T)XLLP_DMAC_DCSR_RUN)
{
aTargetValue &= ~XLLP_DMAC_DCSR_RUN;
pDmacHandle->DCSR[aChannel] = aTargetValue;
aChannelRunStatus = XLLP_TRUE;
}
/* Attach the descriptor */
pPrevDesc->DDADR = (XLLP_VUINT32_T)pDesc;
pDesc->DDADR = (XLLP_VUINT32_T)pNextDesc;
pDmacHandle->DDG[aChannel].DDADR = (XLLP_VUINT32_T)pStartDesc;
/* If channel was running, restart it*/
if (aChannelRunStatus == XLLP_TRUE)
{
aTargetValue |= XLLP_DMAC_DCSR_RUN;
pDmacHandle->DCSR[aChannel] = aTargetValue;
}
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -