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

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

?? can.c

?? 從Luminary官方網站下載的LM3S6000系列的UCos+Tcp/IP的源碼, 經本人稍微修改后可直接在IAR6.2下編譯通過,里面包括了LM3S6000系列的所有外設UART, PWn....
?? C
?? 第 1 頁 / 共 4 頁
字號:
//*****************************************************************************
//
// can.c - Driver for the CAN module.
//
// Copyright (c) 2006-2007 Luminary Micro, Inc.  All rights reserved.
// 
// Software License Agreement
// 
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's microcontroller products.
// 
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  Any use in violation
// of the foregoing restrictions may subject the user to criminal sanctions
// under applicable laws, as well as to civil liability for the breach of the
// terms and conditions of this license.
// 
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 1234-conf of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup can_api
//! @{
//
//*****************************************************************************
#include "../hw_ints.h"
#include "../hw_memmap.h"
#include "../hw_types.h"
#include "../hw_nvic.h"
#include "../hw_can.h"
#include "debug.h"
#include "interrupt.h"
#include "sysctl.h"
#include "can.h"

//*****************************************************************************
//
// This is the maximum number that can be stored as an 11bit Message
// identifier
//
//*****************************************************************************
#define CAN_MAX_11BIT_MSG_ID    (0x7ff)

//*****************************************************************************
//
// This is used as the loop delay for accessing the CAN controller registers.
//
//*****************************************************************************
#define CAN_RW_DELAY            (5)

//*****************************************************************************
//
//! Reads a CAN controller register.
//!
//! \param ulRegAddress This holds the full address of the CAN register to be
//!     set.
//!
//! This function takes care of the synchronization necessary to read from a
//! CAN controller register.
//!
//! \note This call takes care of delay necessary so care should be taken
//!     when accessing the registers directly.
//!
//! \return The current value of the register that was requested by
//!     ulRegAddress.
//*****************************************************************************
unsigned long
CANReadReg(unsigned long ulRegAddress)
{
    volatile int iDelay;
    unsigned long ulRetVal;
    unsigned long ulIntNumber;
    unsigned long ulReenableInts;

    ulIntNumber = CANGetIntNumber(ulRegAddress & 0xfffff000);

    ASSERT(ulIntNumber != (unsigned long)-1);

    //
    // Remember current state so that we only reenable CAN interrupts if they
    // were already enabled.
    //
    ulReenableInts = HWREG(NVIC_DIS1) & (1 << (ulIntNumber - 48));

    if(ulReenableInts)
    {
        IntDisable(ulIntNumber);
    }

    //
    // Trigger the inital read to the CAN controller.  The value returned at
    // this point is not valid.
    //
    HWREG(ulRegAddress);

    for(iDelay = 0; iDelay < CAN_RW_DELAY; iDelay++)
    {
    }

    //
    // Do the final read that has the valid value of the register.
    //
    ulRetVal = HWREG(ulRegAddress);

    //
    // Reenable CAN interrupts if they were enabled before this call.
    //
    if(ulReenableInts)
    {
        IntEnable(ulIntNumber);
    }

    return(ulRetVal);
}

//*****************************************************************************
//
//! Writes a CAN controller register.
//!
//! \param ulRegAddress This holds the full address of the CAN register to be
//!     set.
//! \param ulRegValue This should be set to the value to write into the
//!     register specified by ulRegAddress.
//!
//! This function takes care of the synchronization necessary to write to a
//! CAN controller register.  The call overhead takes care of delay necessary
//! so care should be taken when accessing the registers directly.
//!
//! \note This call takes care of delay necessary so care should be taken
//!     when accessing the registers directly.
//!
//! \return None.
//*****************************************************************************
void
CANWriteReg(unsigned long ulRegAddress, unsigned long ulRegValue)
{
    volatile int iDelay;

    //
    // Trigger the inital write to the CAN controller.  The value will not make
    // it out to the CAN controller for CAN_RW_DELAY cycles.
    //
    HWREG(ulRegAddress) = ulRegValue;

    for(iDelay = 0; iDelay < CAN_RW_DELAY; iDelay++)
    {
    }
}

//*****************************************************************************
//
//! This function copies data from a buffer to the CAN Data registers.
//!
//! \param pucData
//!     This holds the pointer to the data to be written out to the CAN
//!     controller's data registers.
//! \param pulRegister
//!     This holds the unsigned long pointer to the first register of the CAN
//!     controller's data registers.  For example in order to use the IF1
//!     register set on CAN controller 0 the value would be: (CAN0_BASE
//!     + CAN_O_IF1DA1)
//! \param iSize
//!     This holds the number of bytes to copy into the CAN controller.
//!
//! This function takes the steps necessary to copy data from a contiguous
//! buffer in memory into the non-contiguous data registers used by the CAN
//! controller.
//!
//! \return None.
//*****************************************************************************
void
CANWriteDataReg(unsigned char *pucData, unsigned long *pulRegister,
             int iSize)
{
    int iIdx;
    unsigned long ulValue;

    //
    // Loop always copies 1 or 2 bytes per iteration.
    //
    for(iIdx = 0; iIdx < iSize; )
    {

        //
        // Write out the data 16 bits at a time since this is how the
        // registers are aligned in memory.
        //
        ulValue = pucData[iIdx++];

        //
        // Only write the second byte if needed otherwise it will be zero.
        //
        if(iIdx < iSize)
        {
            ulValue |= (pucData[iIdx++] << 8);
        }
        CANWriteReg((unsigned long)(pulRegister++), ulValue);
    }
}

//*****************************************************************************
//
//! This function copies data from a buffer to the CAN Data registers.
//!
//! \param pucData
//!     This holds the pointer to location to store the data read from the CAN
//!     controller's data registers.
//! \param pulRegister
//!     This holds the unsigned long pointer to the first register of the CAN
//!     controller's data registers.  For example in order to use the IF1
//!     register set on CAN controller 1 the value would be: (CAN0_BASE
//!     + CAN_O_IF1DA1)
//! \param iSize
//!     This holds the number of bytes to copy from the CAN controller.
//!
//! This function takes the steps necessary to copy data to a contiguous
//! buffer in memory from the non-contiguous data registers used by the CAN
//! controller.
//!
//! \return None.
//*****************************************************************************
void
CANReadDataReg(unsigned char *pucData, unsigned long *pulRegister,
             int iSize)
{
    int iIdx;
    unsigned long ulValue;

    //
    // 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 = CANReadReg((unsigned long)(pulRegister++));

        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;

    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));
    //
    // 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.
    //
    CANWriteReg(ulBase + CAN_O_CTL, CAN_CTL_INIT);

    //
    // Wait for busy bit to clear
    //
    while(CANReadReg(ulBase + CAN_O_IF1CRQ) & CAN_IFCRQ_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.
    //
    CANWriteReg(ulBase + CAN_O_IF1CMSK, CAN_IFCMSK_WRNRD | CAN_IFCMSK_ARB |
        CAN_IFCMSK_CONTROL);
    CANWriteReg(ulBase + CAN_O_IF1ARB2, 0);
    CANWriteReg(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(CANReadReg(ulBase + CAN_O_IF1CRQ) & CAN_IFCRQ_BUSY)
        {
        }

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

    CANWriteReg(ulBase + CAN_O_IF1CMSK, CAN_IFCMSK_NEWDAT |
        CAN_IFCMSK_CLRINTPND);

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

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

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

//*****************************************************************************
//
//! Enables the CAN controller.
//!
//! \param ulBase is the base address of the CAN controller.
//!
//! 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 CANSetBitTiming().
//!
//! \return None.
//
//*****************************************************************************
void
CANEnable(unsigned long ulBase)
{
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));
    //
    // Clear the init bit in the control register.
    //
    CANWriteReg(ulBase + CAN_O_CTL,
                CANReadReg(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 is left as it was before this call.
//!
//! \return None.
//
//*****************************************************************************
void
CANDisable(unsigned long ulBase)
{
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));
    //
    // Set the init bit in the control register.
    //
    CANWriteReg(ulBase + CAN_O_CTL,
                CANReadReg(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 points to a structure to hold the parameters
//!
//! Read the current configuration of the CAN controller bit clock timing,
//! and stores the resulting information in the structure supplied by the
//! caller.  Refer to CANSetBitTiming() for the meaning of the information
//! that is returned in the structure pointed to by \e pClkParms.
//!
//! \return None.
//
//*****************************************************************************
void
CANGetBitTiming(unsigned long ulBase,
                tCANBitClkParms *pClkParms)
{
    unsigned int uBitReg;

    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 = CANReadReg(ulBase + CAN_O_BIT);
    pClkParms->uPhase2Seg = ((uBitReg & CAN_BIT_TSEG2) >> 12) + 1;
    pClkParms->uSyncPropPhase1Seg = ((uBitReg & CAN_BIT_TSEG1) >> 8) + 1;
    pClkParms->uSJW = ((uBitReg & CAN_BIT_SJW) >> 6) + 1;
    pClkParms->uQuantumPrescaler = ((uBitReg & CAN_BIT_BRP) |
    ((CANReadReg(ulBase + CAN_O_BRPE) & CAN_BRPE_BRPE) << 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 parameter
//! \e pClkParms->uSyncPropPhase1Seg.  Phase Buffer 2 is determined from the
//! parameter \e pClkParms->uPhase2Seg.  These two parameters, along with

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99riav久久精品riav| 精品久久国产老人久久综合| 日韩午夜精品视频| 自拍偷自拍亚洲精品播放| 毛片不卡一区二区| 91久久人澡人人添人人爽欧美| 欧美精品一区二区三区一线天视频 | 国产一区二区三区蝌蚪| 欧美日韩你懂的| 亚洲视频资源在线| 国产成人在线免费观看| 制服.丝袜.亚洲.中文.综合| 亚洲美女偷拍久久| 成人黄色网址在线观看| www一区二区| 久久精品国产亚洲5555| 91精品婷婷国产综合久久| 亚洲线精品一区二区三区八戒| 成人av资源站| 中日韩免费视频中文字幕| 国产精品亚洲综合一区在线观看| 日韩一级免费观看| 青草av.久久免费一区| 欧美日韩国产乱码电影| 亚洲综合激情小说| 色婷婷av久久久久久久| 亚洲视频综合在线| 91丨九色丨蝌蚪丨老版| 亚洲欧美二区三区| 97久久超碰国产精品| 中文字幕佐山爱一区二区免费| 成人中文字幕电影| 国产精品久久久久国产精品日日| 国产盗摄视频一区二区三区| 国产无人区一区二区三区| 国产成人av网站| 中文字幕精品一区二区三区精品| 成人免费的视频| 中文字幕在线观看一区二区| 97精品超碰一区二区三区| 樱花影视一区二区| 正在播放一区二区| 狠狠色丁香久久婷婷综合丁香| 久久影院视频免费| 成人爱爱电影网址| 一区二区三区欧美| 欧美高清视频不卡网| 久久成人av少妇免费| 国产婷婷色一区二区三区| 97久久精品人人澡人人爽| 一区二区三区精品视频| 91精品国产免费久久综合| 韩国女主播一区| 国产精品亲子伦对白| 99久久婷婷国产综合精品电影| 一区二区久久久| 欧美成人三级电影在线| 成+人+亚洲+综合天堂| 一区二区日韩av| 精品久久免费看| 91在线视频免费91| 蜜臀久久99精品久久久久久9| 国产校园另类小说区| 日本乱码高清不卡字幕| 久草精品在线观看| 亚洲精品国产一区二区三区四区在线| 欧美日韩免费一区二区三区视频| 国产一区二区三区免费| 亚洲一区二区欧美激情| ww久久中文字幕| 欧美曰成人黄网| 国产乱子轮精品视频| 亚洲国产精品一区二区www在线 | 日本美女一区二区| 国产精品久久久久影院色老大 | 久久精品国产秦先生| 国产精品成人免费| 日韩女优制服丝袜电影| 99久久免费精品| 狠狠色丁香婷婷综合| 亚洲国产精品一区二区www在线| 国产亚洲综合性久久久影院| 欧美日本韩国一区| 成人国产精品免费观看动漫| 日产国产欧美视频一区精品| 亚洲色图第一区| 国产日韩精品一区二区浪潮av| 欧美日韩你懂得| 91久久久免费一区二区| 国产精品538一区二区在线| 天堂资源在线中文精品| 亚洲视频精选在线| 中文字幕av不卡| 久久免费午夜影院| 日韩视频在线永久播放| 欧美老女人在线| 欧美性猛交xxxx黑人交| 色一情一伦一子一伦一区| 国产91丝袜在线播放0| 久色婷婷小香蕉久久| 性久久久久久久久| 亚洲成人免费观看| 亚洲精品一卡二卡| 一区二区视频在线| 中文字幕一区二区三区视频| 亚洲国产成人午夜在线一区| 国产午夜精品在线观看| 欧美精品一区二区在线播放| 精品日韩一区二区| 欧美r级在线观看| 日韩一级视频免费观看在线| 欧美日韩国产综合一区二区| 欧美性色综合网| 精品视频色一区| 欧美精选一区二区| 91精品久久久久久久99蜜桃| 91精品国产综合久久精品麻豆 | 国产午夜精品一区二区| 26uuu另类欧美亚洲曰本| 久久综合丝袜日本网| 国产色一区二区| 国产精品萝li| 亚洲欧美日韩国产中文在线| 亚洲精品第1页| 首页综合国产亚洲丝袜| 日本欧美韩国一区三区| 韩国成人精品a∨在线观看| 国产一区在线视频| 国产东北露脸精品视频| 成人精品视频一区二区三区尤物| 99视频一区二区三区| 色综合久久久久网| 欧美日韩国产精选| 日韩手机在线导航| 国产精品视频麻豆| 亚洲最快最全在线视频| 日本视频一区二区| 国产经典欧美精品| 色偷偷成人一区二区三区91 | 欧美aⅴ一区二区三区视频| 精品一区二区三区不卡| 国产精品亚洲人在线观看| 99久久综合精品| 欧美日韩国产经典色站一区二区三区 | 亚洲国产成人午夜在线一区| 一区二区三区不卡视频| 蜜臀久久99精品久久久久久9| 国产成人夜色高潮福利影视| 色综合久久久网| 欧美成人性福生活免费看| 国产精品每日更新| 日韩影院在线观看| 成人性视频网站| 制服.丝袜.亚洲.中文.综合| 亚洲国产精品二十页| 亚洲成人免费在线观看| 国产高清精品网站| 欧美日韩另类一区| 国产日产欧产精品推荐色| 亚洲国产一区视频| 国产成人综合在线| 884aa四虎影成人精品一区| 欧美国产一区在线| 免费观看一级欧美片| 成人伦理片在线| 亚洲精品在线一区二区| 亚洲一区二区三区三| 丰满亚洲少妇av| 欧美成人在线直播| 亚洲高清在线视频| 99国产精品久久久久| 久久一二三国产| 日本免费在线视频不卡一不卡二| 色哟哟日韩精品| 中文字幕一区二区三区在线播放| 精品一区二区三区视频在线观看| 欧美主播一区二区三区美女| 国产精品视频看| 国产精品一区二区视频| 日韩欧美成人午夜| 调教+趴+乳夹+国产+精品| 99精品国产91久久久久久 | 亚洲激情图片一区| 不卡影院免费观看| 国产女同互慰高潮91漫画| 久久99精品久久久| 日韩你懂的在线观看| 性久久久久久久| 欧美日韩aaa| 亚洲成年人网站在线观看| 色婷婷亚洲一区二区三区| 最新日韩av在线| 97精品久久久久中文字幕| 国产精品传媒入口麻豆| 成人免费视频视频在线观看免费| 久久精品人人做人人综合| 国产99久久久国产精品潘金| 国产亚洲欧洲997久久综合| 国产在线精品一区二区不卡了| 欧美不卡一区二区三区|