📄 xllp_dmac.c
字号:
Function Name: XllpDmacDetachDesc
Description: XllpDmacDetachDesc detaches the specified descriptor to the
chained/linked descriptors. Users who want to detach 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, detach the descriptor, and then
restarted. Users can use XllpDmacGetChannelStatus to request
status of the channel, ensure that the current transfer completes
before detaching 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 detached. The pointer
cannot be null.
pPrevDesc: Holds the pointer to the descriptor in the chain that had the
"to be detached" descriptor pDesc as the next descriptor. That
is, pPrevDesc had pDesc as the next descriptor, but will now
have pNextDesc as its next descriptor in the chain. Before
executing the primitive pPrevDesc pointed to pDesc and pDesc
pointed to pNextDesc, after executing this function pPrevDesc
will be pointer to pNextDesc. Neither pointers can have a null.
pNextDesc: Holds the pointer to the descriptor in the chain that will be
the next descriptor to pPrevDesc. See description of pPrevDesc
for more details. The pointer cannot be null
pStartDesc: Descriptor to re-start DMA transfer from
aChannel: Specifies the DMA channel this chained descriptors are utilizing
for the transfer process. Valid values are 0-31.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacDetachDesc(
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;
/* Read Control & Status register, */
/* verify if transfer is in process. */
/* If so, stop the channel */
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;
}
/* Detach descriptor */
pPrevDesc->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
Function Name: XllpDmacGetChannelStatus
Description: XllpDmacGetChannelStatus returns the status of the DMA transfer
process for the specified channel. The function can return a
status or multiple status for a particular DMA channel.
Global Registers Modified:
None
Input Arguments:
aChannel: Specifies the DMA channel whose status to return. Valid values
are 0-31.
aStatus: Specifies the DMA channel status the caller is requesting. aStatus
could be an element of type XLLP_DMAC_CHANNEL_STATUS_T or multiple
elements of the said type.
Output Arguments:
pStatus: Holds the DMA channel status requested by the caller. pStatus may
contain one or multiple statuses depending on aStatus.
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacGetChannelStatus(
XLLP_DMAC_CHANNEL_T aChannel,
XLLP_DMAC_CHANNEL_STATUS_T aStatus,
P_XLLP_DMAC_CHANNEL_STATUS_T pStatus
)
{
/* IMPLEMENTION IS EXCLUDED BECAUSE IT IS A WRAPPER FUNCTION */
/* WILL BE ADDED IF THERE ARE USERS WHO WILL LIKE TO USE IT*/
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacClearChannelStatus
Description: XllpDmacClearChannelStatus clears the status of the DMA transfer
process for the specified channel. The function can clear one or
multiple statuses for a particular DMA channel.
Global Registers Modified:
DCSRx register, where x denotes the channel number.
Input Arguments:
aChannel: Specifies the DMA channel whose status to clear. Valid values
are 0-31.
aStatus: Specifies the DMA channel status(s) to clear. aStatus could be an
element of type XLLP_DMAC_CHANNEL_STATUS_T or multiple elements of
the said type.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacClearChannelStatus(
XLLP_DMAC_CHANNEL_T aChannel,
XLLP_DMAC_CHANNEL_STATUS_T aStatus
)
{
/* IMPLEMENTION IS EXCLUDED BECAUSE IT IS A WRAPPER FUNCTION */
/* WILL BE ADDED IF THERE ARE USERS WHO WILL LIKE TO USE IT*/
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacMapDeviceToChannel
Description: XllpDmacMapDeviceToChannel is used to map the specified device
to the specified DMA channel.
Global Registers Modified:
DRCMRx register, where x denotes the channel number.
Input Arguments:
aDeviceDrcmr: Specifies the device to be mapped to the DMA channel. Valid
parameters are values of type XLLP_DMAC_DRCMR_T, otherwise
invalid.
aChannel: Specifies the DMA channel to map the specified device to. Valid
channel values range from 0-31.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacMapDeviceToChannel(
XLLP_DMAC_DRCMR_T aDeviceDrcmr,
XLLP_DMAC_CHANNEL_T aChannel
)
{
if (aDeviceDrcmr < XLLP_DMAC_DRCMR1_NUM)
{
/* Enable device-to-channel mapping */
pDmacHandle->DRCMR1[aDeviceDrcmr] = (XLLP_DMAC_DRCMR_ENABLE + aChannel);
}
else
{
/* Enable device-to-channel mapping */
pDmacHandle->DRCMR2[aDeviceDrcmr-XLLP_DMAC_DRCMR1_NUM] = (XLLP_DMAC_DRCMR_ENABLE + aChannel);
}
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacUnMapDeviceToChannel
Description: XllpDmacUnMapDeviceToChannel is used to unmap the specified
device from the specified DMA channel.
Global Registers Modified:
DRCMRx register, where x denotes the channel number.
Input Arguments:
aDeviceDrcmr: Specifies the device to be unmapped from the DMA channel. Valid
parameters are values of type XLLP_DMAC_DRCMR_T, otherwise invalid.
aChannel: Specifies the DMA channel to unmap the specified device from.
Valid channel values range from 0-31.
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacUnMapDeviceToChannel(
XLLP_DMAC_DRCMR_T aDeviceDrcmr,
XLLP_DMAC_CHANNEL_T aChannel
)
{
if (aDeviceDrcmr < XLLP_DMAC_DRCMR1_NUM)
{
/* Disable device-to-channel mapping */
pDmacHandle->DRCMR1[aDeviceDrcmr] = (XLLP_DMAC_DRCMR_DISABLE + aChannel);
}
else
{
/* Disable device-to-channel mapping */
pDmacHandle->DRCMR2[aDeviceDrcmr-XLLP_DMAC_DRCMR1_NUM] = (XLLP_DMAC_DRCMR_DISABLE + aChannel);
}
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmacSetEor
Description: XllpDmacSetEor sets the stop on EOR functionality for the specified channel
Global Registers Modified:
DCSRx register, where x indicate the channel number
Input Arguments:
aChannel: Specifies the channel for which to set the stop on EOR functionality
Output Arguments:
None
Return Value:
None
XLLP_DOC_HDR_END
*******************************************************************************/
void XllpDmacSetEor( XLLP_DMAC_CHANNEL_T aChannel )
{
XLLP_VUINT32_T aTargetData;
aTargetData = pDmacHandle->DCSR[aChannel];
aTargetData |= XLLP_DMAC_DCSR_EOR_STOP_EN;
pDmacHandle->DCSR[aChannel] = aTargetData;
}
/******************************************************************************
XLLP_DOC_HDR_BEGIN
Function Name: XllpDmaAllocOneChannel
Description: XllpDmacAllocOneChannel is used to allocate a specific DMA channel in
the system. The channel that is allocated must then be used to
bind a service routine to the operating system such that all
interrupts that occur on the channel will be routed to the bound
service routine. Once the channel is done transferring data, it
can be freed by using XllpDmacFreeChannel.
Global Registers Modified: None
Input Arguments:
aChannel: Specifies the DMA channel to be assigned to the calling device
DMA channels range is from 0-31.
Output Arguments:
Return Value:
XLLP_STATUS_SUCCESS: Returned when specified channel is available and assigned to caller
XLLP_NO_DMA_CHANNELS_AVAILABLE: Returned when the specified channel is not available
XLLP_DOC_HDR_END
*******************************************************************************/
XLLP_STATUS_T XllpDmacAllocOneChannel(
XLLP_DMAC_CHANNEL_T aChannel
)
{
if (aChannel < XLLP_DMAC_CHANNEL_NUM)
{
if (pArrayChannel[aChannel] == 0)
{
pArrayChannel[aChannel] = 1;
return (XLLP_STATUS_SUCCESS);
}
}
return XLLP_STATUS_NO_DMA_CHANNEL_AVAILABLE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -