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

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

?? can.c

?? iar 安裝使用的方法。其中包括一些工程模板
?? C
?? 第 1 頁 / 共 5 頁
字號:
    //
    // 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)
{
    //
    // Make sure that the address passed in is valid.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));

    //
    // 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)
{
    //
    // Make sure that the address passed in is valid.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));

    //
    // 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;

    //
    // Make sure that the address passed in is valid and the pointer is not
    // NULL.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));
    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 sychronous 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;
}

//*****************************************************************************
//
//! 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
//! Buffer 1 segments are derived from the combination
//! \e pClkParms->uSyncPropPhase1Seg parameter.  Phase Buffer 2 is determined
//! from the \e pClkParms->uPhase2Seg parameter.  These two parameters, along
//! with \e pClkParms->uSJW are based in units of bit time quanta.  The actual
//! quantum time is determined by the \e pClkParms->uQuantumPrescaler value,
//! which specifies the divisor for the CAN module clock.
//!
//! The total bit time, in quanta, will be the sum of the two Seg parameters,
//! as follows:
//!
//! bit_time_q = uSyncPropPhase1Seg + uPhase2Seg + 1
//!
//! Note that the Sync_Seg is always one quantum in duration, and will be added
//! to derive the correct duration of Prop_Seg and Phase1_Seg.
//!
//! The equation to determine the actual bit rate is as follows:
//!
//! CAN Clock /
//! ((\e uSyncPropPhase1Seg + \e uPhase2Seg + 1) * (\e uQuantumPrescaler))
//!
//! This means that with \e uSyncPropPhase1Seg = 4, \e uPhase2Seg = 1,
//! \e uQuantumPrescaler = 2 and an 8 MHz CAN clock, that the bit rate will be
//! (8 MHz) / ((5 + 2 + 1) * 2) or 500 Kbit/sec.
//!
//! This function replaces the original CANSetBitTiming() 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
CANBitTimingSet(unsigned long ulBase, tCANBitClkParms *pClkParms)
{
    unsigned int uBitReg;
    unsigned int uSavedInit;

    //
    // Make sure that the address passed in is valid and the pClkParms is not
    // NULL.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));
    ASSERT(pClkParms != 0);

    //
    // The phase 1 segment must be in the range from 2 to 16.
    //
    ASSERT((pClkParms->uSyncPropPhase1Seg >= 2) &&
           (pClkParms->uSyncPropPhase1Seg <= 16));

    //
    // The phase 2 segment must be in the range from 1 to 8.
    //
    ASSERT((pClkParms->uPhase2Seg >= 1) && (pClkParms->uPhase2Seg <= 8));

    //
    // The synchronous jump windows must be in the range from 1 to 4.
    //
    ASSERT((pClkParms->uSJW >= 1) && (pClkParms->uSJW <= 4));

    //
    // The CAN clock pre-divider must be in the range from 1 to 1024.
    //
    ASSERT((pClkParms->uQuantumPrescaler <= 1024) &&
           (pClkParms->uQuantumPrescaler >= 1));

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

    //
    // Set the bit fields of the bit timing register according to the parms.
    //
    uBitReg = ((pClkParms->uPhase2Seg - 1) << 12) & CAN_BIT_TSEG2_M;
    uBitReg |= ((pClkParms->uSyncPropPhase1Seg - 1) << 8) & CAN_BIT_TSEG1_M;
    uBitReg |= ((pClkParms->uSJW - 1) << 6) & CAN_BIT_SJW_M;
    uBitReg |= (pClkParms->uQuantumPrescaler - 1) & CAN_BIT_BRP_M;
    CANRegWrite(ulBase + CAN_O_BIT, uBitReg);

    //
    // Set the divider upper bits in the extension register.
    //
    CANRegWrite(ulBase + CAN_O_BRPE,
                ((pClkParms->uQuantumPrescaler - 1) >> 6) & CAN_BRPE_BRPE_M);
    //
    // Clear the config change bit, and restore the init bit.
    //
    uSavedInit &= ~CAN_CTL_CCE;

    //
    // If Init was not set before, then clear it.
    //
    if(uSavedInit & CAN_CTL_INIT)
    {
        uSavedInit &= ~CAN_CTL_INIT;
    }
    CANRegWrite(ulBase + CAN_O_CTL, uSavedInit);
}

//*****************************************************************************
//
//! Registers an interrupt handler for the CAN controller.
//!
//! \param ulBase is the base address of the CAN controller.
//! \param pfnHandler is a pointer to the function to be called when the
//! enabled CAN interrupts occur.
//!
//! This function registers the interrupt handler in the interrupt vector
//! table, and enables CAN interrupts on the interrupt controller; specific CAN
//! interrupt sources must be enabled using CANIntEnable().  The interrupt
//! handler being registered must clear the source of the interrupt using
//! CANIntClear().
//!
//! If the application is using a static interrupt vector table stored in
//! flash, then it is not necessary to register the interrupt handler this way.
//! Instead, IntEnable() should be used to enable CAN interrupts on the
//! interrupt controller.
//!
//! \sa IntRegister() for important information about registering interrupt
//! handlers.
//!
//! \return None.
//
//*****************************************************************************
void
CANIntRegister(unsigned long ulBase, void (*pfnHandler)(void))
{
    unsigned long ulIntNumber;

    //
    // Make sure that the address passed in is valid.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));

    //
    // Get the actual interrupt number for this CAN controller.
    //
    ulIntNumber = CANIntNumberGet(ulBase);

    //
    // Register the interrupt handler.
    //
    IntRegister(ulIntNumber, pfnHandler);

    //
    // Enable the Ethernet interrupt.
    //
    IntEnable(ulIntNumber);
}

//*****************************************************************************
//
//! Unregisters an interrupt handler for the CAN controller.
//!
//! \param ulBase is the base address of the controller.
//!
//! This function unregisters the previously registered interrupt handler and
//! disables the interrupt on the interrupt controller.
//!
//! \sa IntRegister() for important information about registering interrupt
//! handlers.
//!
//! \return None.
//
//*****************************************************************************
void
CANIntUnregister(unsigned long ulBase)
{
    unsigned long ulIntNumber;

    //
    // Check the arguments.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));

    //
    // Get the actual interrupt number for this CAN controller.
    //
    ulIntNumber = CANIntNumberGet(ulBase);

    //
    // Register the interrupt handler.
    //
    IntUnregister(ulIntNumber);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
狠狠色综合播放一区二区| 成人免费视频视频在线观看免费| 国产精品理论在线观看| 欧美久久久一区| 在线不卡一区二区| 欧美第一区第二区| 欧美精品一区二区三区在线播放| 日韩免费观看高清完整版在线观看| 91麻豆精品国产91久久久久久久久 | 欧美日韩亚洲国产综合| 欧美图区在线视频| 欧美日韩一区二区三区不卡| 欧美三级视频在线| 欧美一区二区三区在线| 精品久久久久久久久久久久久久久久久| 91久久精品日日躁夜夜躁欧美| 在线观看网站黄不卡| 成人小视频免费观看| va亚洲va日韩不卡在线观看| 高清成人在线观看| 国产精品系列在线播放| 麻豆精品一区二区三区| 九色|91porny| 91亚洲国产成人精品一区二三| 欧美日韩免费高清一区色橹橹| 欧美日本在线播放| 欧美一区二区三区视频免费 | 日本一区二区视频在线观看| 综合在线观看色| 亚洲动漫第一页| 国产伦精品一区二区三区视频青涩| 国产成+人+日韩+欧美+亚洲| 欧美午夜在线观看| 国产女人18水真多18精品一级做| 亚洲国产精品一区二区久久| 91蜜桃在线免费视频| 精品视频免费在线| 国产亚洲精品福利| 视频在线观看一区二区三区| 国产乱码精品一品二品| 欧美视频精品在线观看| 国产欧美日韩不卡免费| 亚洲一本大道在线| 日韩精品成人一区二区三区| 激情综合色综合久久综合| 99久久777色| 欧美一级高清片在线观看| 久久综合九色综合欧美98| 夜夜亚洲天天久久| 美女视频黄免费的久久| 国产aⅴ综合色| 欧美视频完全免费看| 日韩欧美中文一区| 国产精品系列在线| 亚洲美腿欧美偷拍| 国产精品99精品久久免费| 欧美精品成人一区二区三区四区| 国产精品久久久久久久久久免费看| 日韩二区在线观看| 成人免费视频caoporn| 2020国产精品自拍| 免费欧美日韩国产三级电影| 色婷婷亚洲综合| 自拍偷拍欧美激情| 99r国产精品| www欧美成人18+| www.欧美.com| 国产精品乱码妇女bbbb| 国产精品乡下勾搭老头1| 精品区一区二区| 麻豆精品久久精品色综合| 99精品视频在线观看免费| 久久看人人爽人人| 久久99久久精品欧美| 日韩精品一区二区三区swag| 亚洲女同女同女同女同女同69| 国产白丝精品91爽爽久久 | 久久精品亚洲乱码伦伦中文| 韩国女主播成人在线观看| 欧美xxxx在线观看| 国产乱码精品一区二区三区av| 久久久久久久久久美女| 国产成人在线观看免费网站| 国产人成一区二区三区影院| 高清成人在线观看| 中文字幕亚洲区| 日本福利一区二区| 偷窥国产亚洲免费视频| 日韩一级二级三级| 国产一区在线精品| 久久久av毛片精品| 丰满少妇在线播放bd日韩电影| 国产欧美日韩在线观看| 91丨国产丨九色丨pron| 中文字幕不卡在线播放| 国产成人久久精品77777最新版本| 欧美激情艳妇裸体舞| 91亚洲永久精品| 午夜精品久久久久久久99樱桃| 欧美女孩性生活视频| 免费成人性网站| 久久久久国色av免费看影院| 成人黄色在线视频| 亚洲午夜久久久久久久久电影院 | 欧美日韩一区二区三区在线看| 免费在线观看一区二区三区| 亚洲aⅴ怡春院| 日韩欧美国产综合在线一区二区三区| 精品一区二区国语对白| 樱花草国产18久久久久| 在线成人免费视频| 99re视频这里只有精品| 日av在线不卡| 亚洲精品乱码久久久久| 欧美精品一区二区久久婷婷 | 日本韩国欧美一区| 久久爱www久久做| 欧美国产欧美综合| 欧美一区二区三区免费在线看| 国产精品一级片| 麻豆久久久久久久| 伊人性伊人情综合网| 欧美xingq一区二区| aaa欧美色吧激情视频| 午夜不卡av在线| 欧美成人综合网站| 在线看国产日韩| 国产综合色产在线精品| 欧美激情综合五月色丁香| 91精品国产欧美日韩| 国产一区二区在线免费观看| 亚洲人成7777| 日韩一级片在线观看| 欧美色图免费看| 成人av一区二区三区| 免费在线视频一区| 亚洲欧美日韩系列| 国产日韩欧美电影| 精品欧美一区二区久久| 欧美蜜桃一区二区三区| 在线一区二区三区| 91免费版pro下载短视频| 99免费精品在线| 岛国精品一区二区| 国产成人av一区二区| 精品一二线国产| 精品一二三四在线| 国产一二精品视频| 国产一区二区三区四区五区入口| 免费美女久久99| 美女任你摸久久| 蜜乳av一区二区三区| 午夜免费久久看| 日韩影视精彩在线| 免费av网站大全久久| 另类小说视频一区二区| 精品一区二区三区香蕉蜜桃| 国模大尺度一区二区三区| 久久国产婷婷国产香蕉| 国产一区欧美二区| 国产精品99久| 91婷婷韩国欧美一区二区| 欧洲精品在线观看| 欧美日韩成人一区| 日韩欧美国产一区二区在线播放| 中文一区二区在线观看| 中文字幕中文字幕中文字幕亚洲无线| 亚洲日本一区二区| 亚洲1区2区3区4区| 久久丁香综合五月国产三级网站| 另类人妖一区二区av| 国产精品一区一区三区| 99精品欧美一区二区三区综合在线| jizzjizzjizz欧美| 欧美日韩三级一区| 欧美一区二区三区免费视频| 精品免费一区二区三区| 国产精品免费丝袜| 亚洲在线一区二区三区| 日本亚洲天堂网| 国产成都精品91一区二区三| 91国偷自产一区二区三区成为亚洲经典| 色综合中文字幕| 欧美另类变人与禽xxxxx| 久久香蕉国产线看观看99| 亚洲九九爱视频| 日本成人在线一区| av成人老司机| 日韩欧美在线一区二区三区| 中文字幕在线一区免费| 天堂久久久久va久久久久| 国产精品夜夜嗨| 欧美日韩国产在线观看| 国产人伦精品一区二区| 日韩主播视频在线| 国产精品资源在线看| 欧美日本国产一区| 国产精品入口麻豆九色| 青青草视频一区| 一本大道久久精品懂色aⅴ|