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

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

?? can.c

?? 基于TI公司Cortex-M3的uart超級通信開發
?? C
?? 第 1 頁 / 共 5 頁
字號:
//*****************************************************************************
//
// can.c - Driver for the CAN module.
//
// Copyright (c) 2006-2009 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.  You may not combine
// this software with "viral" open-source software in order to form a larger
// program.  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 5228 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup can_api
//! @{
//
//*****************************************************************************

#include "inc/hw_can.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/can.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.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)

//
// The maximum CAN bit timing divisor is 13.
//
#define CAN_MAX_BIT_DIVISOR     (13)

//
// The minimum CAN bit timing divisor is 5.
//
#define CAN_MIN_BIT_DIVISOR     (5)

//
// The maximum CAN pre-divisor is 1024.
//
#define CAN_MAX_PRE_DIVISOR     (1024)

//
// The minimum CAN pre-divisor is 1.
//
#define CAN_MIN_PRE_DIVISOR     (1)

//*****************************************************************************
//
// This table is used by the CANBitRateSet() API as the register defaults for
// the bit timing values.
//
//*****************************************************************************
static const unsigned short g_usCANBitValues[] =
{
    0x1100, // TSEG2 2, TSEG1 2, SJW 1, Divide 5
    0x1200, // TSEG2 2, TSEG1 3, SJW 1, Divide 6
    0x2240, // TSEG2 3, TSEG1 3, SJW 2, Divide 7
    0x2340, // TSEG2 3, TSEG1 4, SJW 2, Divide 8
    0x3340, // TSEG2 4, TSEG1 4, SJW 2, Divide 9
    0x3440, // TSEG2 4, TSEG1 5, SJW 2, Divide 10
    0x3540, // TSEG2 4, TSEG1 6, SJW 2, Divide 11
    0x3640, // TSEG2 4, TSEG1 7, SJW 2, Divide 12
    0x3740  // TSEG2 4, TSEG1 8, SJW 2, Divide 13
};

//*****************************************************************************
//
//! \internal
//! Checks a CAN base address.
//!
//! \param ulBase is the base address of the CAN controller.
//!
//! This function determines if a CAN controller base address is valid.
//!
//! \return Returns \b true if the base address is valid and \b false
//! otherwise.
//
//*****************************************************************************
#ifdef DEBUG
static tBoolean
CANBaseValid(unsigned long ulBase)
{
    return((ulBase == CAN0_BASE) || (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));
}
#endif

//*****************************************************************************
//
//! \internal
//!
//! Returns the CAN controller interrupt number.
//!
//! \param ulBase is the base address of the selected CAN controller
//!
//! Given a CAN controller base address, returns the corresponding interrupt
//! number.
//!
//! This function replaces the original CANGetIntNumber() API and performs the
//! same actions.  A macro is provided in <tt>can.h</tt> to map the original
//! API to this API.
//!
//! \return Returns a CAN interrupt number, or -1 if \e ulPort is invalid.
//
//*****************************************************************************
static long
CANIntNumberGet(unsigned long ulBase)
{
    long lIntNumber;

    //
    // Return the interrupt number for the given CAN controller.
    //
    switch(ulBase)
    {
        //
        // Return the interrupt number for CAN 0
        //
        case CAN0_BASE:
        {
            lIntNumber = INT_CAN0;
            break;
        }

        //
        // Return the interrupt number for CAN 1
        //
        case CAN1_BASE:
        {
            lIntNumber = INT_CAN1;
            break;
        }

        //
        // Return the interrupt number for CAN 2
        //
        case CAN2_BASE:
        {
            lIntNumber = INT_CAN2;
            break;
        }

        //
        // Return -1 to indicate a bad address was passed in.
        //
        default:
        {
            lIntNumber = -1;
        }
    }
    return(lIntNumber);
}

//*****************************************************************************
//
//! \internal
//!
//! Reads a CAN controller register.
//!
//! \param ulRegAddress is the full address of the CAN register to be read.
//!
//! This function performs the necessary synchronization to read from a CAN
//! controller register.
//!
//! This function replaces the original CANReadReg() API and performs the same
//! actions.  A macro is provided in <tt>can.h</tt> to map the original API to
//! this API.
//!
//! \note This function provides the delay required to access CAN registers.
//! This delay is required when accessing CAN registers directly.
//!
//! \return Returns the value read from the register.
//
//*****************************************************************************
static unsigned long
CANRegRead(unsigned long ulRegAddress)
{
    volatile int iDelay;
    unsigned long ulRetVal;
    unsigned long ulIntNumber;
    unsigned long ulReenableInts;

    //
    // Get the CAN interrupt number from the register base address.
    //
    ulIntNumber = CANIntNumberGet(ulRegAddress & 0xfffff000);

    //
    // Make sure that the CAN base address was valid.
    //
    ASSERT(ulIntNumber != (unsigned long)-1);

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

    //
    // If the CAN interrupt was enabled then disable it.
    //
    if(ulReenableInts)
    {
        IntDisable(ulIntNumber);
    }

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

    //
    // This delay is necessary for the CAN have the correct data on the bus.
    //
    for(iDelay = 0; iDelay < CAN_RW_DELAY; iDelay++)
    {
    }

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

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

    return(ulRetVal);
}

//*****************************************************************************
//
//! \internal
//!
//! Writes a CAN controller register.
//!
//! \param ulRegAddress is the full address of the CAN register to be written.
//! \param ulRegValue is the value to write into the register specified by
//! \e ulRegAddress.
//!
//! This function takes care of the synchronization necessary to write to a
//! CAN controller register.
//!
//! This function replaces the original CANWriteReg() API and performs the same
//! actions.  A macro is provided in <tt>can.h</tt> to map the original API to
//! this API.
//!
//! \note The delays in this function are required when accessing CAN registers
//! directly.
//!
//! \return None.
//
//*****************************************************************************
static void
CANRegWrite(unsigned long ulRegAddress, unsigned long ulRegValue)
{
    volatile int iDelay;

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

    //
    // Delay to allow the CAN controller to receive the new data.
    //
    for(iDelay = 0; iDelay < CAN_RW_DELAY; iDelay++)
    {
    }
}

//*****************************************************************************
//
//! \internal
//!
//! Copies data from a buffer to the CAN Data registers.
//!
//! \param pucData is a pointer to the data to be written out to the CAN
//! controller's data registers.
//! \param pulRegister is an 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: \b CAN0_BASE \b +
//! \b CAN_O_IF1DA1.
//! \param iSize is 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.  This function is rarely used outside of the CANMessageSet()
//! function.
//!
//! This function replaces the original CANWriteDataReg() 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.
//
//*****************************************************************************
static void
CANDataRegWrite(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);
        }
        CANRegWrite((unsigned long)(pulRegister++), ulValue);
    }
}

//*****************************************************************************
//
//! \internal
//!
//! Copies data from a buffer to the CAN Data registers.
//!
//! \param pucData is a pointer to the location to store the data read from the
//! CAN controller's data registers.
//! \param pulRegister is an 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: \b CAN0_BASE \b +
//! \b CAN_O_IF1DA1.
//! \param iSize is 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.  This function is rarely used outside of the CANMessageGet()
//! function.
//!
//! This function replaces the original CANReadDataReg() 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.
//
//*****************************************************************************
static void

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色噜噜夜夜夜综合网| 国产91露脸合集magnet | 亚洲午夜国产一区99re久久| ww亚洲ww在线观看国产| 中文字幕一区二区在线观看| 国产亚洲va综合人人澡精品| 国产日韩欧美综合在线| 国产亚洲福利社区一区| 久久精品一区蜜桃臀影院| 久久久影视传媒| 国产欧美综合在线| 国产精品美女久久福利网站 | jiyouzz国产精品久久| 成人性生交大片免费看视频在线| 国产成人免费视频网站| 99视频精品在线| 91极品视觉盛宴| 欧美精品在线一区二区| 欧美成人欧美edvon| 欧美激情一区二区三区不卡| 17c精品麻豆一区二区免费| 亚洲精品国久久99热| 视频在线观看一区二区三区| 久久国产精品免费| 高清成人免费视频| 欧美日韩中文一区| xnxx国产精品| 亚洲一区二区三区精品在线| 香蕉成人啪国产精品视频综合网| 久久99精品视频| 99精品视频在线免费观看| 717成人午夜免费福利电影| 精品1区2区在线观看| 亚洲视频一区在线观看| 卡一卡二国产精品| 91在线观看免费视频| 日韩欧美的一区二区| 一色屋精品亚洲香蕉网站| 日本中文字幕一区二区有限公司| 国产成人一区二区精品非洲| 欧美在线视频日韩| 久久久精品人体av艺术| 亚洲线精品一区二区三区八戒| 国产一区二区三区综合| 欧美主播一区二区三区| 久久久影视传媒| 日韩成人免费看| 99国产精品久| 中文字幕免费一区| 麻豆国产精品一区二区三区| 91久久久免费一区二区| 日本一区二区三区在线观看| 蜜桃视频第一区免费观看| 一本久久精品一区二区| 国产色一区二区| 美腿丝袜亚洲三区| 911精品国产一区二区在线| 成人免费小视频| 国产精品538一区二区在线| 91精品国产综合久久蜜臀| 亚洲视频在线一区二区| 成人黄色777网| 国产区在线观看成人精品 | 久久精品一区二区三区av | 欧美va亚洲va香蕉在线| 国产精品一二三区在线| 日韩欧美色综合| 美女脱光内衣内裤视频久久网站 | 男人的天堂亚洲一区| 欧美综合一区二区三区| 亚洲天堂a在线| 97超碰欧美中文字幕| 国产精品少妇自拍| 成人激情动漫在线观看| 久久免费视频色| 国产一区啦啦啦在线观看| 欧美大片免费久久精品三p| 日韩av一级电影| 日韩午夜在线观看| 免费不卡在线观看| 欧美xxx久久| 国产综合成人久久大片91| 精品国产青草久久久久福利| 精品一区二区三区久久| 久久天天做天天爱综合色| 国产美女娇喘av呻吟久久| 久久精品欧美日韩精品| 亚洲国产综合91精品麻豆| 久久亚洲一区二区三区四区| 国产精品丝袜黑色高跟| www.欧美.com| 夜夜夜精品看看| 欧美久久久久久久久| 日韩免费福利电影在线观看| 国产一区二区免费视频| 亚洲国产wwwccc36天堂| 亚洲欧美成人一区二区三区| 精品国产一区二区在线观看| 欧美久久久久免费| 欧美三级三级三级| 日本久久电影网| 91网站在线观看视频| 国产suv精品一区二区883| 久久91精品国产91久久小草| 日韩av一区二区在线影视| 午夜精品福利视频网站| 一区二区三区在线免费视频| 最好看的中文字幕久久| 亚洲欧美在线另类| 国产精品毛片无遮挡高清| 国产精品美女久久久久久2018| 国产日韩欧美制服另类| 国产三级欧美三级日产三级99 | 91精品国产91久久综合桃花| 91成人在线观看喷潮| 91看片淫黄大片一级在线观看| 丁香婷婷综合激情五月色| 国产福利91精品一区二区三区| 国内成+人亚洲+欧美+综合在线| 伦理电影国产精品| 欧美96一区二区免费视频| 美国三级日本三级久久99| 美女视频免费一区| 国产一二精品视频| 成年人网站91| 在线观看国产一区二区| 欧美日韩午夜精品| 日韩欧美在线123| 久久久不卡网国产精品一区| 国产精品麻豆久久久| 亚洲欧美日韩国产综合在线| 一区二区三区美女视频| 日本人妖一区二区| 国产精品一二二区| 99国内精品久久| 欧美亚洲国产怡红院影院| 欧美精品成人一区二区三区四区| 欧美一区二区三区四区高清| 久久久久久久电影| 亚洲精品视频免费看| 日本最新不卡在线| 成人做爰69片免费看网站| 在线观看一区日韩| 日韩视频永久免费| 亚洲欧洲精品天堂一级| 亚洲不卡av一区二区三区| 国产麻豆成人精品| 色吊一区二区三区| 日韩精品一区二区三区视频在线观看 | 欧美丰满美乳xxx高潮www| 精品国产伦一区二区三区观看方式| 中文字幕免费不卡| 午夜精品久久久久影视| 高清不卡一区二区在线| 欧美日韩一级片在线观看| 国产欧美一区二区三区在线看蜜臀| 亚洲女性喷水在线观看一区| 看片网站欧美日韩| 在线欧美日韩精品| 中文字幕免费不卡| 开心九九激情九九欧美日韩精美视频电影| 成人激情图片网| 欧美r级在线观看| 亚洲精品v日韩精品| 韩国精品久久久| 欧美裸体一区二区三区| 中文字幕第一区综合| 三级影片在线观看欧美日韩一区二区| 国产在线精品一区二区| 欧美性生活影院| 国产精品乱码久久久久久| 美女在线一区二区| 色偷偷久久人人79超碰人人澡| www一区二区| 日韩激情av在线| 色综合天天综合在线视频| 国产香蕉久久精品综合网| 日韩国产在线一| 在线视频中文字幕一区二区| 国产精品免费观看视频| 久久国产三级精品| 欧美一区日韩一区| 一区二区在线电影| 波多野结衣91| 国产日韩av一区二区| 精品一区二区三区的国产在线播放| 欧美日韩一二区| 亚洲一本大道在线| 97久久超碰国产精品电影| 中文字幕精品综合| 国产福利一区二区三区视频在线| 日韩一区二区在线观看视频| 午夜精品久久久久久久久久 | 欧美精品一区二区三区四区| 亚洲超碰97人人做人人爱| 欧美日韩综合在线| 亚洲女人****多毛耸耸8| a亚洲天堂av| 亚洲免费观看高清完整版在线观看 | 福利一区福利二区|