亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? can.c

?? CAN_FIFO收發例程
?? C
?? 第 1 頁 / 共 5 頁
字號:

    //
    // Loop always copies 1 or 2 bytes per iteration.
    //
    for(iIdx = 0; iIdx < iSize; )
    {
        //
        // Read out the data 16 bits at a time since this is how the registers
        // are aligned in memory.
        //
        ulValue = CANRegRead((unsigned long)(pulRegister++));

        //
        // Store the first byte.
        //
        pucData[iIdx++] = (unsigned char)ulValue;

        //
        // Only read the second byte if needed.
        //
        if(iIdx < iSize)
        {
            pucData[iIdx++] = (unsigned char)(ulValue >> 8);
        }
    }
}

//*****************************************************************************
//
//! Initializes the CAN controller after reset.
//!
//! \param ulBase is the base address of the CAN controller.
//!
//! After reset, the CAN controller is left in the disabled state.  However,
//! the memory used for message objects contains undefined values and must be
//! cleared prior to enabling the CAN controller the first time.  This prevents
//! unwanted transmission or reception of data before the message objects are
//! configured.  This function must be called before enabling the controller
//! the first time.
//!
//! \return None.
//
//*****************************************************************************
void
CANInit(unsigned long ulBase)
{
    int iMsg;

    //
    // Check the arguments.
    //
    ASSERT(CANBaseValid(ulBase));

    //
    // Place CAN controller in init state, regardless of previous state.  This
    // will put controller in idle, and allow the message object RAM to be
    // programmed.
    //
    CANRegWrite(ulBase + CAN_O_CTL, CAN_CTL_INIT);

    //
    // Wait for busy bit to clear
    //
    while(CANRegRead(ulBase + CAN_O_IF1CRQ) & CAN_IF1CRQ_BUSY)
    {
    }

    //
    // Clear the message value bit in the arbitration register.  This indicates
    // the message is not valid and is a "safe" condition to leave the message
    // object.  The same arb reg is used to program all the message objects.
    //
    CANRegWrite(ulBase + CAN_O_IF1CMSK, CAN_IF1CMSK_WRNRD | CAN_IF1CMSK_ARB |
                CAN_IF1CMSK_CONTROL);
    CANRegWrite(ulBase + CAN_O_IF1ARB2, 0);
    CANRegWrite(ulBase + CAN_O_IF1MCTL, 0);

    //
    // Loop through to program all 32 message objects
    //
    for(iMsg = 1; iMsg <= 32; iMsg++)
    {
        //
        // Wait for busy bit to clear
        //
        while(CANRegRead(ulBase + CAN_O_IF1CRQ) & CAN_IF1CRQ_BUSY)
        {
        }

        //
        // Initiate programming the message object
        //
        CANRegWrite(ulBase + CAN_O_IF1CRQ, iMsg);
    }

    //
    // Make sure that the interrupt and new data flags are updated for the
    // message objects.
    //
    CANRegWrite(ulBase + CAN_O_IF1CMSK, CAN_IF1CMSK_NEWDAT |
                CAN_IF1CMSK_CLRINTPND);

    //
    // Loop through to program all 32 message objects
    //
    for(iMsg = 1; iMsg <= 32; iMsg++)
    {
        //
        // Wait for busy bit to clear.
        //
        while(CANRegRead(ulBase + CAN_O_IF1CRQ) & CAN_IF1CRQ_BUSY)
        {
        }

        //
        // Initiate programming the message object
        //
        CANRegWrite(ulBase + CAN_O_IF1CRQ, iMsg);
    }

    //
    // Acknowledge any pending status interrupts.
    //
    CANRegRead(ulBase + CAN_O_STS);
}

//*****************************************************************************
//
//! Enables the CAN controller.
//!
//! \param ulBase is the base address of the CAN controller to enable.
//!
//! Enables the CAN controller for message processing.  Once enabled, the
//! controller will automatically transmit any pending frames, and process any
//! received frames.  The controller can be stopped by calling CANDisable().
//! Prior to calling CANEnable(), CANInit() should have been called to
//! initialize the controller and the CAN bus clock should be configured by
//! calling CANBitTimingSet().
//!
//! \return None.
//
//*****************************************************************************
void
CANEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT(CANBaseValid(ulBase));

    //
    // Clear the init bit in the control register.
    //
    CANRegWrite(ulBase + CAN_O_CTL,
                CANRegRead(ulBase + CAN_O_CTL) & ~CAN_CTL_INIT);
}

//*****************************************************************************
//
//! Disables the CAN controller.
//!
//! \param ulBase is the base address of the CAN controller to disable.
//!
//! Disables the CAN controller for message processing.  When disabled, the
//! controller will no longer automatically process data on the CAN bus.  The
//! controller can be restarted by calling CANEnable().  The state of the CAN
//! controller and the message objects in the controller are left as they were
//! before this call was made.
//!
//! \return None.
//
//*****************************************************************************
void
CANDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT(CANBaseValid(ulBase));

    //
    // Set the init bit in the control register.
    //
    CANRegWrite(ulBase + CAN_O_CTL,
                CANRegRead(ulBase + CAN_O_CTL) | CAN_CTL_INIT);
}

//*****************************************************************************
//
//! Reads the current settings for the CAN controller bit timing.
//!
//! \param ulBase is the base address of the CAN controller.
//! \param pClkParms is a pointer to a structure to hold the timing parameters.
//!
//! This function reads the current configuration of the CAN controller bit
//! clock timing, and stores the resulting information in the structure
//! supplied by the caller.  Refer to CANBitTimingSet() for the meaning of the
//! values that are returned in the structure pointed to by \e pClkParms.
//!
//! This function replaces the original CANGetBitTiming() API and performs the
//! same actions.  A macro is provided in <tt>can.h</tt> to map the original
//! API to this API.
//!
//! \return None.
//
//*****************************************************************************
void
CANBitTimingGet(unsigned long ulBase, tCANBitClkParms *pClkParms)
{
    unsigned int uBitReg;

    //
    // Check the arguments.
    //
    ASSERT(CANBaseValid(ulBase));
    ASSERT(pClkParms != 0);

    //
    // Read out all the bit timing values from the CAN controller registers.
    //
    uBitReg = CANRegRead(ulBase + CAN_O_BIT);

    //
    // Set the phase 2 segment.
    //
    pClkParms->uPhase2Seg = ((uBitReg & CAN_BIT_TSEG2_M) >> 12) + 1;

    //
    // Set the phase 1 segment.
    //
    pClkParms->uSyncPropPhase1Seg = ((uBitReg & CAN_BIT_TSEG1_M) >> 8) + 1;

    //
    // Set the synchronous jump width.
    //
    pClkParms->uSJW = ((uBitReg & CAN_BIT_SJW_M) >> 6) + 1;

    //
    // Set the pre-divider for the CAN bus bit clock.
    //
    pClkParms->uQuantumPrescaler =
        ((uBitReg & CAN_BIT_BRP_M) |
         ((CANRegRead(ulBase + CAN_O_BRPE) & CAN_BRPE_BRPE_M) << 6)) + 1;
}

//*****************************************************************************
//
//! This function is used to set the CAN bit timing values to a nominal setting
//! based on a desired bit rate.
//!
//! \param ulBase is the base address of the CAN controller.
//! \param ulSourceClock is the system clock for the device in Hz.
//! \param ulBitRate is the desired bit rate.
//!
//! This function will set the CAN bit timing for the bit rate passed in the
//! \e ulBitRate parameter based on the \e ulSourceClock parameter.  Since the
//! CAN clock is based off of the system clock the calling function should pass
//! in the source clock rate either by retrieving it from SysCtlClockGet() or
//! using a specific value in Hz.  The CAN bit clock is calculated to be an
//! average timing value that should work for most systems.  If tighter timing
//! requirements are needed, then the CANBitTimingSet() function is available
//! for full customization of all of the CAN bit timing values.  Since not all
//! bit rates can be matched exactly, the bit rate is set to the value closest
//! to the desired bit rate without being higher than the \e ulBitRate value.
//!
//! \note On some devices the source clock is fixed at 8MHz so the
//! \e ulSourceClock should be set to 8000000.
//!
//! \return This function returns the bit rate that the CAN controller was
//! configured to use or it returns 0 to indicate that the bit rate was not
//! changed because the requested bit rate was not valid.
//!
//*****************************************************************************
unsigned long
CANBitRateSet(unsigned long ulBase, unsigned long ulSourceClock,
              unsigned long ulBitRate)
{
    unsigned long ulDesiredRatio;
    unsigned long ulCANBits;
    unsigned long ulPreDivide;
    unsigned long ulRegValue;
    unsigned short usCANCTL;

    ASSERT(ulBitRate != 0);

    //
    // Calculate the desired clock rate.
    //
    ulDesiredRatio = ulSourceClock / ulBitRate;

    //
    // If the ratio of CAN bit rate to processor clock is too small or too
    // large then return 0 indicating that no bit rate was set.
    //
    ASSERT(ulDesiredRatio <= (CAN_MAX_PRE_DIVISOR * CAN_MAX_BIT_DIVISOR));
    ASSERT(ulDesiredRatio >= (CAN_MIN_PRE_DIVISOR * CAN_MIN_BIT_DIVISOR));

    //
    // Make sure that the Desired Ratio is not too large.  This enforces the
    // requirement that the bit rate is larger than requested.
    //
    if((ulSourceClock / ulDesiredRatio) > ulBitRate)
    {
        ulDesiredRatio += 1;
    }

    //
    // Check all possible values to find a matching value.
    //
    while(ulDesiredRatio <= CAN_MAX_PRE_DIVISOR * CAN_MAX_BIT_DIVISOR)
    {
        //
        // Loop through all possible CAN bit divisors.
        //
        for(ulCANBits = CAN_MAX_BIT_DIVISOR; ulCANBits >= CAN_MIN_BIT_DIVISOR;
            ulCANBits--)
        {
            //
            // For a given CAN bit divisor save the pre divisor.
            //
            ulPreDivide = ulDesiredRatio / ulCANBits;

            //
            // If the calculated divisors match the desired clock ratio then
            // return these bit rate and set the CAN bit timing.
            //
            if((ulPreDivide * ulCANBits) == ulDesiredRatio)
            {
                //
                // Start building the bit timing value by adding the bit timing
                // in time quanta.
                //
                ulRegValue = g_usCANBitValues[ulCANBits - CAN_MIN_BIT_DIVISOR];

                //
                // To set the bit timing register, the controller must be placed
                // in init mode (if not already), and also configuration change
                // bit enabled.  The state of the register should be saved
                // so it can be restored.
                //
                usCANCTL = CANRegRead(ulBase + CAN_O_CTL);
                CANRegWrite(ulBase + CAN_O_CTL, usCANCTL | CAN_CTL_INIT |
                                                CAN_CTL_CCE);

                //
                // Now add in the pre-scalar on the bit rate.
                //
                ulRegValue |= ((ulPreDivide - 1)& CAN_BIT_BRP_M);

                //
                // Set the clock bits in the and the lower bits of the
                // pre-scalar.
                //
                CANRegWrite(ulBase + CAN_O_BIT, ulRegValue);

                //
                // Set the divider upper bits in the extension register.
                //
                CANRegWrite(ulBase + CAN_O_BRPE,
                            ((ulPreDivide - 1) >> 6) & CAN_BRPE_BRPE_M);

                //
                // Restore the saved CAN Control register.
                //
                CANRegWrite(ulBase + CAN_O_CTL, usCANCTL);

                //
                // Return the computed bit rate.
                //
                return(ulSourceClock / ( ulPreDivide * ulCANBits));
            }
        }

        //
        // Move the divisor up one and look again.  Only in rare cases are
        // more than 2 loops required to find the value.
        //
        ulDesiredRatio++;
    }
    return(0);
}

//*****************************************************************************
//
//! Configures the CAN controller bit timing.
//!
//! \param ulBase is the base address of the CAN controller.
//! \param pClkParms points to the structure with the clock parameters.
//!
//! Configures the various timing parameters for the CAN bus bit timing:
//! Propagation segment, Phase Buffer 1 segment, Phase Buffer 2 segment, and
//! the Synchronization Jump Width.  The values for Propagation and Phase

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美一区二区视频| 国产成人h网站| 一区二区三区在线影院| 欧美激情综合五月色丁香 | 久久久99久久| 精品粉嫩超白一线天av| 精品国产麻豆免费人成网站| 欧美一级日韩不卡播放免费| 91精品婷婷国产综合久久竹菊| 欧美日韩欧美一区二区| 欧美精品乱码久久久久久| 欧美日韩国产成人在线91| 555www色欧美视频| 欧美一级二级在线观看| 日韩免费看的电影| 久久在线观看免费| 国产日韩欧美一区二区三区综合| 久久久久国产免费免费| 欧美高清在线精品一区| 中文字幕在线免费不卡| 一区二区三区在线视频观看58| 亚洲精品成人少妇| 性做久久久久久免费观看 | 国产综合色视频| 国产麻豆精品theporn| 国产v日产∨综合v精品视频| 99精品视频免费在线观看| 欧洲av在线精品| 91麻豆精品国产91久久久使用方法| 欧美一区二区视频网站| 2014亚洲片线观看视频免费| 国产欧美中文在线| 一区二区三区在线看| 五月激情六月综合| 韩国av一区二区三区| caoporn国产一区二区| 在线免费不卡电影| 欧美mv和日韩mv国产网站| 久久久综合激的五月天| 综合久久久久综合| 日韩精品一卡二卡三卡四卡无卡| 麻豆成人久久精品二区三区红 | 日韩精品一区在线观看| 久久久精品中文字幕麻豆发布| 国产精品视频观看| 亚洲123区在线观看| 国产精品资源在线观看| 一本一道久久a久久精品| 欧美三级电影在线观看| 久久久久国产成人精品亚洲午夜| 亚洲激情自拍视频| 久久99久久久久| www.av亚洲| 欧美日韩国产区一| 欧美国产欧美综合| 亚洲成av人**亚洲成av**| 国产一二精品视频| 色天天综合久久久久综合片| 日韩欧美精品在线视频| 亚洲精品国产a久久久久久| 看国产成人h片视频| 91在线云播放| 久久蜜臀精品av| 三级成人在线视频| av亚洲精华国产精华| 7777女厕盗摄久久久| 国产精品久久久久久亚洲伦 | 欧美精品一级二级三级| 久久久久成人黄色影片| 午夜激情久久久| 99久久99久久久精品齐齐| 欧美一区二区视频网站| 一区二区三区在线不卡| 国产一区二区三区观看| 这里只有精品视频在线观看| 综合激情网...| 国产精品亚洲一区二区三区妖精| 欧美精品色一区二区三区| 国产精品福利影院| 精品一区精品二区高清| 欧美日韩日日摸| 亚洲日本护士毛茸茸| 国产老肥熟一区二区三区| 欧美精品久久一区二区三区| 亚洲精品国产精华液| av在线不卡免费看| 国产欧美日韩综合精品一区二区| 日本中文字幕一区二区有限公司| 色综合久久久网| 国产精品久久久久久亚洲毛片 | 色噜噜狠狠一区二区三区果冻| 国产女人水真多18毛片18精品视频| 日日摸夜夜添夜夜添国产精品 | 国产一区二区三区国产| 日韩欧美国产wwwww| 偷偷要91色婷婷| 欧美日韩在线三区| 亚洲一级电影视频| 色综合久久中文综合久久牛| 亚洲丝袜精品丝袜在线| 成人高清伦理免费影院在线观看| 久久久久国产一区二区三区四区 | 国产精品一二三四五| 欧美电视剧在线观看完整版| 日韩国产一二三区| 欧美精选一区二区| 日本视频中文字幕一区二区三区| 欧美色爱综合网| 午夜精品久久久久| 91麻豆精品国产自产在线观看一区 | 欧美一区二区国产| 日本不卡视频一二三区| 欧美日本一区二区| 日本欧美在线看| 日韩一区二区三| 美腿丝袜亚洲色图| 精品嫩草影院久久| 国产不卡视频在线观看| 国产精品区一区二区三| av午夜精品一区二区三区| 亚洲人吸女人奶水| 在线精品视频小说1| 午夜私人影院久久久久| 日韩中文欧美在线| 91精品国产美女浴室洗澡无遮挡| 日韩高清不卡一区| 日韩一二在线观看| 激情久久五月天| 欧美激情一区二区三区蜜桃视频| 国产成人精品一区二| 中文字幕日本乱码精品影院| 色婷婷综合久久久中文一区二区| 亚洲高清视频在线| 欧美第一区第二区| 成人免费视频国产在线观看| 亚洲欧美一区二区三区孕妇| 欧美亚州韩日在线看免费版国语版| 三级欧美在线一区| 久久久久久久免费视频了| www.欧美.com| 午夜精品在线看| 久久久精品国产99久久精品芒果| av在线不卡电影| 亚洲国产精品嫩草影院| 精品免费日韩av| 不卡一区二区三区四区| 天天色 色综合| 久久久综合视频| 91浏览器在线视频| 久久av老司机精品网站导航| 亚洲欧洲精品天堂一级 | 欧美日韩免费视频| 国产综合久久久久久久久久久久 | 亚洲成av人片在www色猫咪| 精品欧美一区二区三区精品久久 | 色94色欧美sute亚洲线路一ni | 91色九色蝌蚪| 久久精品国产一区二区三| 国产精品久久久久久久久久免费看 | 久久这里只有精品首页| 色噜噜夜夜夜综合网| 韩国成人精品a∨在线观看| 亚洲精品国产高清久久伦理二区| 精品国产免费人成电影在线观看四季| 99国产精品99久久久久久| 免费高清在线一区| 亚洲美女屁股眼交3| 精品国产伦理网| 欧美日韩精品一区二区三区 | 91在线小视频| 国产精品一区二区视频| 欧美主播一区二区三区| 国产一区二区0| 午夜精品久久久久久久久久| 国产精品网曝门| 日韩精品资源二区在线| 在线观看成人小视频| 成人自拍视频在线| 老司机免费视频一区二区三区| 亚洲一区二区三区四区五区中文 | 日产欧产美韩系列久久99| 亚洲欧洲中文日韩久久av乱码| 久久亚洲私人国产精品va媚药| 欧美日高清视频| 色av成人天堂桃色av| 成人av在线资源网| 韩国成人福利片在线播放| 日本网站在线观看一区二区三区 | 亚洲在线观看免费| 国产精品精品国产色婷婷| 欧美精品一区二区久久婷婷| 欧美日本不卡视频| 91国产成人在线| 99视频一区二区| 国产精品91xxx| 国内精品伊人久久久久av影院 | 色婷婷激情久久| 91在线云播放| 国产精品毛片高清在线完整版| 精品久久一区二区|