⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udma.c

📁 lm3s下lwip的udp
💻 C
📖 第 1 页 / 共 3 页
字号:
void
uDMAChannelRequest(unsigned long ulChannel)
{
    //
    // Check the arguments.
    //
    ASSERT(ulChannel < 32);

    //
    // Set the bit for this channel in the software uDMA request register.
    //
    HWREG(UDMA_SWREQ) = 1 << ulChannel;
}

//*****************************************************************************
//
//! Enables attributes of a uDMA channel.
//!
//! \param ulChannel is the channel to configure.
//! \param ulAttr is a combination of attributes for the channel.
//!
//! The \e ulChannel parameter must be one of the following:
//!
//! - \b UDMA_CHANNEL_UART0RX for UART 0 receive channel
//! - \b UDMA_CHANNEL_UART0TX for UART 0 transmit channel
//! - \b UDMA_CHANNEL_UART1RX for UART 1 receive channel
//! - \b UDMA_CHANNEL_UART1TX for UART 1 transmit channel
//! - \b UDMA_CHANNEL_SSI0RX for SSI 0 receive channel
//! - \b UDMA_CHANNEL_SSI0TX for SSI 0 transmit channel
//! - \b UDMA_CHANNEL_SSI1RX for SSI 1 receive channel
//! - \b UDMA_CHANNEL_SSI1TX for SSI 1 transmit channel
//! - \b UDMA_CHANNEL_SW for the software dedicated uDMA channel
//!
//! And for microcontrollers that have a USB peripheral:
//!
//! - \b UDMA_CHANNEL_USBEP1RX for USB endpoint 1 receive
//! - \b UDMA_CHANNEL_USBEP1TX for USB endpoint 1 transmit
//! - \b UDMA_CHANNEL_USBEP2RX for USB endpoint 2 receive
//! - \b UDMA_CHANNEL_USBEP2TX for USB endpoint 2 transmit
//! - \b UDMA_CHANNEL_USBEP3RX for USB endpoint 3 receive
//! - \b UDMA_CHANNEL_USBEP3TX for USB endpoint 3 transmit
//!
//! The \e ulAttr parameter is the logical OR of any of the following:
//!
//! - \b UDMA_ATTR_USEBURST is used to restrict transfers to use only a burst
//!   mode.
//! - \b UDMA_ATTR_ALTSELECT is used to select the alternate control structure
//!   for this channel.
//! - \b UDMA_ATTR_HIGH_PRIORITY is used to set this channel to high priority.
//! - \b UDMA_ATTR_REQMASK is used to mask the hardware request signal from the
//!   peripheral for this channel.
//!
//! \return None.
//
//*****************************************************************************
void
uDMAChannelAttributeEnable(unsigned long ulChannel, unsigned long ulAttr)
{
    //
    // Check the arguments.
    //
    ASSERT(ulChannel < 32);
    ASSERT((ulAttr & ~(UDMA_ATTR_USEBURST | UDMA_ATTR_ALTSELECT |
                       UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK)) == 0);

    //
    // Set the useburst bit for this channel if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_USEBURST)
    {
        HWREG(UDMA_USEBURSTSET) = 1 << ulChannel;
    }

    //
    // Set the alternate control select bit for this channel,
    // if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_ALTSELECT)
    {
        HWREG(UDMA_ALTSET) = 1 << ulChannel;
    }

    //
    // Set the high priority bit for this channel, if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_HIGH_PRIORITY)
    {
        HWREG(UDMA_PRIOSET) = 1 << ulChannel;
    }

    //
    // Set the request mask bit for this channel, if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_REQMASK)
    {
        HWREG(UDMA_REQMASKSET) = 1 << ulChannel;
    }
}

//*****************************************************************************
//
//! Disables attributes of a uDMA channel.
//!
//! \param ulChannel is the channel to configure.
//! \param ulAttr is a combination of attributes for the channel.
//!
//! This function is used to disable attributes of a uDMA channel.
//!
//! The \e ulChannel parameter must be one of the following:
//!
//! - \b UDMA_CHANNEL_UART0RX for UART 0 receive channel
//! - \b UDMA_CHANNEL_UART0TX for UART 0 transmit channel
//! - \b UDMA_CHANNEL_UART1RX for UART 1 receive channel
//! - \b UDMA_CHANNEL_UART1TX for UART 1 transmit channel
//! - \b UDMA_CHANNEL_SSI0RX for SSI 0 receive channel
//! - \b UDMA_CHANNEL_SSI0TX for SSI 0 transmit channel
//! - \b UDMA_CHANNEL_SSI1RX for SSI 1 receive channel
//! - \b UDMA_CHANNEL_SSI1TX for SSI 1 transmit channel
//! - \b UDMA_CHANNEL_SW for the software dedicated uDMA channel
//!
//! And for microcontrollers that have a USB peripheral:
//!
//! - \b UDMA_CHANNEL_USBEP1RX for USB endpoint 1 receive
//! - \b UDMA_CHANNEL_USBEP1TX for USB endpoint 1 transmit
//! - \b UDMA_CHANNEL_USBEP2RX for USB endpoint 2 receive
//! - \b UDMA_CHANNEL_USBEP2TX for USB endpoint 2 transmit
//! - \b UDMA_CHANNEL_USBEP3RX for USB endpoint 3 receive
//! - \b UDMA_CHANNEL_USBEP3TX for USB endpoint 3 transmit
//!
//! The \e ulAttr parameter is the logical OR of any of the following:
//!
//! - \b UDMA_ATTR_USEBURST is used to restrict transfers to use only a burst
//!   mode.
//! - \b UDMA_ATTR_ALTSELECT is used to select the alternate control structure
//!   for this channel.
//! - \b UDMA_ATTR_HIGH_PRIORITY is used to set this channel to high priority.
//! - \b UDMA_ATTR_REQMASK is used to mask the hardware request signal from the
//!   peripheral for this channel.
//!
//! \return None.
//
//*****************************************************************************
void
uDMAChannelAttributeDisable(unsigned long ulChannel, unsigned long ulAttr)
{
    //
    // Check the arguments.
    //
    ASSERT(ulChannel < 32);
    ASSERT((ulAttr & ~(UDMA_ATTR_USEBURST | UDMA_ATTR_ALTSELECT |
                       UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK)) == 0);

    //
    // Clear the useburst bit for this channel if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_USEBURST)
    {
        HWREG(UDMA_USEBURSTCLR) = 1 << ulChannel;
    }

    //
    // Clear the alternate control select bit for this channel, if set in
    // ulConfig.
    //
    if(ulAttr & UDMA_ATTR_ALTSELECT)
    {
        HWREG(UDMA_ALTCLR) = 1 << ulChannel;
    }

    //
    // Clear the high priority bit for this channel, if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_HIGH_PRIORITY)
    {
        HWREG(UDMA_PRIOCLR) = 1 << ulChannel;
    }

    //
    // Clear the request mask bit for this channel, if set in ulConfig.
    //
    if(ulAttr & UDMA_ATTR_REQMASK)
    {
        HWREG(UDMA_REQMASKCLR) = 1 << ulChannel;
    }
}

//*****************************************************************************
//
//! Gets the enabled attributes of a uDMA channel.
//!
//! \param ulChannel is the channel to configure.
//!
//! This function returns a combination of flags representing the attributes of
//! the uDMA channel.
//!
//! The \e ulChannel parameter must be one of the following:
//!
//! - \b UDMA_CHANNEL_UART0RX for UART 0 receive channel
//! - \b UDMA_CHANNEL_UART0TX for UART 0 transmit channel
//! - \b UDMA_CHANNEL_UART1RX for UART 1 receive channel
//! - \b UDMA_CHANNEL_UART1TX for UART 1 transmit channel
//! - \b UDMA_CHANNEL_SSI0RX for SSI 0 receive channel
//! - \b UDMA_CHANNEL_SSI0TX for SSI 0 transmit channel
//! - \b UDMA_CHANNEL_SSI1RX for SSI 1 receive channel
//! - \b UDMA_CHANNEL_SSI1TX for SSI 1 transmit channel
//! - \b UDMA_CHANNEL_SW for the software dedicated uDMA channel
//!
//! And for microcontrollers that have a USB peripheral:
//!
//! - \b UDMA_CHANNEL_USBEP1RX for USB endpoint 1 receive
//! - \b UDMA_CHANNEL_USBEP1TX for USB endpoint 1 transmit
//! - \b UDMA_CHANNEL_USBEP2RX for USB endpoint 2 receive
//! - \b UDMA_CHANNEL_USBEP2TX for USB endpoint 2 transmit
//! - \b UDMA_CHANNEL_USBEP3RX for USB endpoint 3 receive
//! - \b UDMA_CHANNEL_USBEP3TX for USB endpoint 3 transmit
//!
//! \return Returns the logical OR of the attributes of the uDMA channel, which
//! can be any of the following:
//! - \b UDMA_ATTR_USEBURST is used to restrict transfers to use only a burst
//!   mode.
//! - \b UDMA_ATTR_ALTSELECT is used to select the alternate control structure
//!   for this channel.
//! - \b UDMA_ATTR_HIGH_PRIORITY is used to set this channel to high priority.
//! - \b UDMA_ATTR_REQMASK is used to mask the hardware request signal from the
//!   peripheral for this channel.
//
//*****************************************************************************
unsigned long
uDMAChannelAttributeGet(unsigned long ulChannel)
{
    unsigned long ulAttr = 0;

    //
    // Check the arguments.
    //
    ASSERT(ulChannel < 32);

    //
    // Check to see if useburst bit is set for this channel.
    //
    if(HWREG(UDMA_USEBURSTSET) & (1 << ulChannel))
    {
        ulAttr |= UDMA_ATTR_USEBURST;
    }

    //
    // Check to see if the alternate control bit is set for this channel.
    //
    if(HWREG(UDMA_ALTSET) & (1 << ulChannel))
    {
        ulAttr |= UDMA_ATTR_ALTSELECT;
    }

    //
    // Check to see if the high priority bit is set for this channel.
    //
    if(HWREG(UDMA_PRIOSET) & (1 << ulChannel))
    {
        ulAttr |= UDMA_ATTR_HIGH_PRIORITY;
    }

    //
    // Check to see if the request mask bit is set for this channel.
    //
    if(HWREG(UDMA_REQMASKSET) & (1 << ulChannel))
    {
        ulAttr |= UDMA_ATTR_REQMASK;
    }

    //
    // Return the configuration flags.
    //
    return(ulAttr);
}

//*****************************************************************************
//
//! Sets the control parameters for a uDMA channel.
//!
//! \param ulChannel is the logical OR of the uDMA channel number with
//! \b UDMA_PRI_SELECT or \b UDMA_ALT_SELECT.
//! \param ulControl is logical OR of several control values to set the control
//! parameters for the channel.
//!
//! This function is used to set control parameters for a uDMA transfer.  These
//! are typically parameters that are not changed often.
//!
//! The \e ulChannel parameter is one of the choices documented in the
//! uDMAChannelEnable() function.  It should be the logical OR of the channel
//! with one of \b UDMA_PRI_SELECT or \b UDMA_ALT_SELECT to choose whether
//! the primary or alternate data structure is used.
//!
//! The \e ulControl parameter is the logical OR of five values: the data size,
//! the source address increment, the destination address increment, the
//! arbitration size, and the use burst flag.  The choices available for each
//! of these values is described below.
//!
//! Choose the data size from one of \b UDMA_SIZE_8, \b UDMA_SIZE_16, or
//! \b UDMA_SIZE_32 to select a data size of 8, 16, or 32 bits.
//!
//! Choose the source address increment from one of \b UDMA_SRC_INC_8,
//! \b UDMA_SRC_INC_16, \b UDMA_SRC_INC_32, or \b UDMA_SRC_INC_NONE to select
//! an address increment of 8-bit bytes, 16-bit halfwords, 32-bit words, or
//! to select non-incrementing.
//!
//! Choose the destination address increment from one of \b UDMA_DST_INC_8,
//! \b UDMA_DST_INC_16, \b UDMA_DST_INC_32, or \b UDMA_DST_INC_NONE to select
//! an address increment of 8-bit bytes, 16-bit halfwords, 32-bit words, or
//! to select non-incrementing.
//!
//! The arbitration size determines how many items are transferred before
//! the uDMA controller re-arbitrates for the bus.  Choose the arbitration size
//! from one of \b UDMA_ARB_1, \b UDMA_ARB_2, \b UDMA_ARB_4, \b UDMA_ARB_8,
//! through \b UDMA_ARB_1024 to select the arbitration size from 1 to 1024
//! items, in powers of 2.
//!
//! The value \b UDMA_NEXT_USEBURST is used to force the channel to only
//! respond to burst requests at the tail end of a scatter-gather transfer.
//!
//! \note The address increment cannot be smaller than the data size.
//!
//! \return None.
//
//*****************************************************************************
void
uDMAChannelControlSet(unsigned long ulChannel, unsigned long ulControl)
{
    tDMAControlTable *pCtl;

    //
    // Check the arguments.
    //
    ASSERT(ulChannel < 64);
    ASSERT(HWREG(UDMA_CTLBASE) != 0);

    //
    // Get the base address of the control table.
    //
    pCtl = (tDMAControlTable *)HWREG(UDMA_CTLBASE);

    //
    // Get the current control word value and mask off the fields to be
    // changed, then OR in the new settings.
    //
    pCtl[ulChannel].ulControl = ((pCtl[ulChannel].ulControl &
                                  ~(UDMA_CHCTL_DSTINC_M |
                                    UDMA_CHCTL_DSTSIZE_M |
                                    UDMA_CHCTL_SRCINC_M |
                                    UDMA_CHCTL_SRCSIZE_M |
                                    UDMA_CHCTL_ARBSIZE_M |
                                    UDMA_CHCTL_NXTUSEBURST)) |
                                 ulControl);
}

//*****************************************************************************
//
//! Sets the transfer parameters for a uDMA channel.
//!
//! \param ulChannel is the logical or of the uDMA channel number with either
//! \b UDMA_PRI_SELECT or \b UDMA_ALT_SELECT.
//! \param ulMode is the type of uDMA transfer.
//! \param pvSrcAddr is the source address for the transfer.
//! \param pvDstAddr is the destination address for the transfer.
//! \param ulTransferSize is the number of data items to transfer.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -