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

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

?? can.c

?? ucos_ii/tcpip to lm3s6965
?? 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一区二区三区免费野_久草精品视频
麻豆精品在线观看| 成人黄色在线视频| 成人av电影免费在线播放| 欧美视频一区二| 国产欧美视频一区二区| 毛片av中文字幕一区二区| 91污片在线观看| 久久精品综合网| 日韩电影在线免费看| 91丝袜美女网| 国产精品美女一区二区在线观看| 午夜精品在线看| 91在线观看地址| 国产三级精品视频| 久久er99精品| 欧美一级二级三级蜜桃| 亚洲色图视频免费播放| 成人精品电影在线观看| 久久九九全国免费| 精品亚洲免费视频| 日韩亚洲电影在线| 五月天丁香久久| 欧美三区在线观看| 亚洲一线二线三线视频| 色综合天天狠狠| 1024亚洲合集| 99精品国产99久久久久久白柏| 国产亚洲美州欧州综合国| 精品一区二区日韩| 欧美mv和日韩mv国产网站| 免费黄网站欧美| 欧美一级黄色录像| 青草国产精品久久久久久| 在线电影院国产精品| 日韩在线播放一区二区| 91精品国产一区二区三区| 日一区二区三区| 911国产精品| 麻豆精品在线播放| 精品成人在线观看| 国产伦精品一区二区三区免费迷 | 成人深夜在线观看| 国产午夜精品福利| 国产不卡免费视频| 国产精品久久看| 一本一道波多野结衣一区二区| 亚洲欧洲制服丝袜| 日本精品裸体写真集在线观看| 亚洲精品日韩一| 欧美日韩视频在线观看一区二区三区| 亚洲精品福利视频网站| 欧美日韩国产首页| 免费在线观看一区二区三区| 欧美r级电影在线观看| 国产91精品免费| 一级精品视频在线观看宜春院| 欧美日韩一级二级| 精品在线观看免费| 国产精品无码永久免费888| 欧洲另类一二三四区| 免费久久精品视频| 亚洲欧洲美洲综合色网| 欧美日韩午夜影院| 国产一区二区三区国产| 亚洲欧美另类小说视频| 日韩精品中文字幕在线不卡尤物| 盗摄精品av一区二区三区| 亚洲精品国产无套在线观| 欧美一级日韩不卡播放免费| 风间由美中文字幕在线看视频国产欧美| 中文字幕色av一区二区三区| 宅男噜噜噜66一区二区66| 国产一区不卡视频| 五月激情综合网| 欧美国产精品专区| 在线观看91av| 色婷婷久久99综合精品jk白丝| 日本最新不卡在线| 亚洲欧美激情在线| 久久精品欧美一区二区三区不卡 | 亚洲综合图片区| 久久综合狠狠综合久久综合88| 色综合天天性综合| 精品亚洲免费视频| 日韩福利电影在线观看| 中文无字幕一区二区三区| 日本韩国欧美一区| 成人免费毛片app| 久久爱另类一区二区小说| 亚洲午夜久久久久| 国产欧美一区二区精品性| 欧美成人精精品一区二区频| 色偷偷久久一区二区三区| 国产老女人精品毛片久久| 亚洲国产成人高清精品| 亚洲欧美电影一区二区| 国产亚洲综合在线| 欧美一区二区视频在线观看2020 | 91麻豆免费看| 国产精品一区二区久激情瑜伽| 日日欢夜夜爽一区| 樱桃视频在线观看一区| 国产精品入口麻豆原神| 久久一夜天堂av一区二区三区| 欧美日本一区二区三区| 欧美亚洲一区二区在线观看| 91偷拍与自偷拍精品| 成人h版在线观看| 成人成人成人在线视频| 粉嫩欧美一区二区三区高清影视| 久久av中文字幕片| 激情五月激情综合网| 九一九一国产精品| 久久国产尿小便嘘嘘| 久久丁香综合五月国产三级网站| 亚洲成年人影院| 午夜视频一区在线观看| 免费一区二区视频| 久久精品国产亚洲aⅴ| 久久国产精品72免费观看| 精品一区二区国语对白| 国产伦精品一区二区三区在线观看| 韩国女主播成人在线观看| 国产真实精品久久二三区| 国产又粗又猛又爽又黄91精品| 国模冰冰炮一区二区| 国产99精品国产| 91网站在线播放| 欧美高清性hdvideosex| 日韩美女一区二区三区四区| 26uuu精品一区二区| 国产精品乱码一区二三区小蝌蚪| 亚洲欧美综合色| 亚洲国产日韩a在线播放| 亚洲成va人在线观看| 老司机免费视频一区二区三区| 国产一区视频网站| av高清久久久| 欧美高清视频在线高清观看mv色露露十八| 欧美一区二区三区精品| 欧美成人综合网站| 国产精品传媒视频| 日韩av一级电影| 国产成人免费在线视频| 91女神在线视频| 欧美一区二区黄色| 欧美激情一区在线观看| 亚洲高清免费观看| 国产麻豆精品久久一二三| 欧美性生交片4| 26uuuu精品一区二区| 亚洲柠檬福利资源导航| 麻豆91免费观看| 色婷婷久久99综合精品jk白丝| 日韩午夜在线播放| 亚洲天堂免费在线观看视频| 日韩精品三区四区| 播五月开心婷婷综合| 91精品久久久久久蜜臀| 国产精品成人一区二区三区夜夜夜 | 久久综合九色综合97_久久久| 亚洲欧美另类综合偷拍| 国产又黄又大久久| 欧美电影一区二区| 亚洲精品高清在线| 国产精品99久久久久久久女警 | 久久精品一二三| 亚洲成人免费在线观看| 成人综合婷婷国产精品久久 | 欧美日韩精品欧美日韩精品一综合| 精品噜噜噜噜久久久久久久久试看| 日韩理论在线观看| 麻豆传媒一区二区三区| 欧美三级电影在线看| 一区在线中文字幕| 精品一区二区三区在线观看| 欧美日韩一区成人| 亚洲精品国产a久久久久久 | 精品国产3级a| 亚洲va欧美va人人爽午夜| proumb性欧美在线观看| 26uuu亚洲| 精品中文字幕一区二区| 91精品国产免费| 香蕉成人伊视频在线观看| 99久久国产综合精品女不卡| 久久久久久亚洲综合影院红桃| 日本欧美肥老太交大片| 欧美日本精品一区二区三区| 亚洲一区中文日韩| 欧美唯美清纯偷拍| 亚洲一区欧美一区| 欧洲亚洲精品在线| 亚洲主播在线播放| 欧美日韩一本到| 洋洋成人永久网站入口| 精品视频在线免费| 亚洲大片精品永久免费| 欧美主播一区二区三区美女| 亚洲一区二区三区四区在线 |