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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? can.c

?? uCOS-II V2.84 LM3S6965 TCPIP Demo
?? C
?? 第 1 頁 / 共 4 頁
字號(hào):
//*****************************************************************************
//
// 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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品乱码免费| 中文乱码免费一区二区| 国产精品久久久久一区二区三区共| 亚洲综合精品自拍| 国产成人a级片| 欧美一区二区黄色| 亚洲另类春色校园小说| 国产大片一区二区| 日韩情涩欧美日韩视频| 亚洲一区欧美一区| 久久久激情视频| 香蕉成人伊视频在线观看| 91麻豆免费看片| 日本一区二区三区高清不卡| 日韩精品每日更新| 欧美在线一二三四区| 午夜av区久久| 欧美亚男人的天堂| 亚洲福中文字幕伊人影院| 日韩欧美在线观看一区二区三区| 亚洲欧美自拍偷拍色图| 免费成人结看片| 欧美日韩成人在线| 亚洲精品视频在线看| 懂色av一区二区三区免费看| 精品国产一区二区三区久久影院| 日韩av午夜在线观看| 欧美视频第二页| 亚洲狠狠丁香婷婷综合久久久| 成人av免费在线观看| 日本一区二区三区视频视频| 国产乱码精品1区2区3区| 欧美一区日韩一区| 亚洲图片欧美色图| 色噜噜狠狠成人网p站| 中文字幕色av一区二区三区| 从欧美一区二区三区| 中文在线一区二区| 国产成人精品三级| 中国av一区二区三区| 岛国一区二区在线观看| 日本一区二区高清| 不卡的av在线播放| 亚洲欧洲在线观看av| 日本福利一区二区| 亚洲一区二区影院| 欧美丝袜自拍制服另类| 一区二区三区在线播放| 91福利国产精品| 亚洲伊人伊色伊影伊综合网| 欧美亚洲国产bt| 五月婷婷色综合| 欧美一区二区视频免费观看| 青娱乐精品视频| 日韩久久免费av| 国产在线看一区| 中文字幕 久热精品 视频在线| 99国产精品久久久久| 亚洲黄色性网站| 欧美一级一级性生活免费录像| 蜜桃av噜噜一区| 国产欧美一区二区精品性色| 成人av动漫在线| 一区二区三区四区高清精品免费观看 | 色哟哟在线观看一区二区三区| 亚洲va欧美va国产va天堂影院| 久久99久久久欧美国产| 亚洲大尺度视频在线观看| 久久精品亚洲麻豆av一区二区| 555夜色666亚洲国产免| 国产色爱av资源综合区| 91精品国产综合久久福利| 色成人在线视频| 色老综合老女人久久久| 色悠悠亚洲一区二区| 香蕉久久夜色精品国产使用方法| 欧美高清一级片在线| 精品一区二区三区免费| 欧美国产精品专区| 欧美日韩中文精品| 裸体健美xxxx欧美裸体表演| 亚洲狠狠丁香婷婷综合久久久| 欧美精品一区二区三区四区| 欧美自拍丝袜亚洲| 欧美这里有精品| 欧美亚洲免费在线一区| 91蜜桃在线观看| 一本久久精品一区二区| 一本一本大道香蕉久在线精品| 色婷婷精品久久二区二区蜜臂av | 一区二区三区精品久久久| 欧美在线观看一区| 激情都市一区二区| 亚洲精品成人a在线观看| 日韩三级视频中文字幕| 99国产精品国产精品毛片| 亚洲成a人v欧美综合天堂| 色综合一区二区| 美女国产一区二区| 日韩一区有码在线| 欧美一区二区观看视频| aaa欧美日韩| 成年人国产精品| 国产精品久久久久久户外露出 | 午夜激情久久久| 老汉av免费一区二区三区| 国产一区欧美日韩| 一本久久a久久精品亚洲| 欧美日韩国产bt| 精品动漫一区二区三区在线观看| 亚洲欧洲日韩综合一区二区| 亚洲精品一二三| 经典三级一区二区| 99国产麻豆精品| 日韩欧美一级精品久久| 国产精品国产自产拍在线| 色婷婷狠狠综合| 午夜欧美2019年伦理| 亚洲欧洲色图综合| 久久久精品国产免大香伊| 欧美精品日日鲁夜夜添| 成人av网站在线| 国产河南妇女毛片精品久久久| 日韩经典一区二区| 一区二区三区在线观看动漫| 日韩欧美国产系列| 国产69精品一区二区亚洲孕妇| 日韩高清在线一区| 一区二区三区不卡视频| 日本少妇一区二区| 亚洲激情在线播放| 国产丝袜在线精品| 久久伊人中文字幕| 日韩免费在线观看| 欧美老女人在线| 欧美色图片你懂的| 在线观看成人小视频| 91色婷婷久久久久合中文| 国产精品性做久久久久久| 美腿丝袜亚洲综合| 免费成人深夜小野草| 日韩和的一区二区| 日韩综合小视频| 午夜精品福利视频网站| 一区二区三区中文字幕精品精品| 中文字幕一区二区在线观看| 欧美国产禁国产网站cc| 久久久久综合网| 久久久久久久久伊人| 精品国产在天天线2019| 欧美大度的电影原声| 欧美一级黄色录像| 日韩视频123| 日韩精品中文字幕在线不卡尤物 | 久久99精品视频| 国产精品亚洲人在线观看| 欧美福利视频一区| 亚洲高清一区二区三区| 国产精品一级黄| 国产精品久久久久久久第一福利 | 欧美日韩一区二区三区视频| 亚洲日本va午夜在线影院| 97国产一区二区| 亚洲高清不卡在线| 丝袜美腿亚洲色图| 5858s免费视频成人| 波多野结衣在线一区| 亚洲欧美日韩在线播放| 亚洲免费观看视频| 亚洲一区二区在线视频| 亚洲成人高清在线| 日本不卡在线视频| 国产一区91精品张津瑜| 国产馆精品极品| 97久久超碰国产精品电影| 色婷婷亚洲婷婷| 欧美性xxxxx极品少妇| 欧美精品 日韩| 精品人在线二区三区| 国产丝袜欧美中文另类| 国产精品福利av| 亚洲国产精品久久久久秋霞影院 | 日韩一区二区在线看片| 日韩精品中文字幕一区 | 欧美亚洲动漫另类| 91精品国产综合久久久久久漫画| 一区二区三区四区在线免费观看 | 久久久久久久久久美女| 久久精品夜色噜噜亚洲a∨| 欧美国产一区在线| 夜色激情一区二区| 免费观看一级欧美片| 国产精华液一区二区三区| 91麻豆国产香蕉久久精品| 欧美日韩国产综合久久| 精品少妇一区二区三区视频免付费 | 成人午夜精品在线| 91福利视频网站| 欧美不卡一区二区| 国产精品福利一区二区三区|