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

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

?? can.c

?? CAN_FIFO收發例程
?? C
?? 第 1 頁 / 共 5 頁
字號:
//*****************************************************************************
//
// can.c - Driver for the CAN module.
//
// Copyright (c) 2006-2010 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// 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. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 5961 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
CANDataRegRead(unsigned char *pucData, unsigned long *pulRegister, int iSize)
{
    int iIdx;
    unsigned long ulValue;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品久久久久久久蜜桃app | 日韩色视频在线观看| 国产精品不卡一区| 色综合久久天天| 亚洲综合色视频| 欧美一区二区三区四区视频| 毛片av中文字幕一区二区| 欧美哺乳videos| 国产成人日日夜夜| 夜夜揉揉日日人人青青一国产精品 | 蜜臀精品一区二区三区在线观看| 精品欧美乱码久久久久久| 国产一区二区三区电影在线观看 | 久久99热国产| 久久久99免费| 99国产麻豆精品| 日韩中文字幕区一区有砖一区| 日韩精品专区在线影院重磅| 成人久久18免费网站麻豆| 亚洲第一搞黄网站| 国产亚洲欧美一区在线观看| 色综合色综合色综合色综合色综合| 亚洲精品视频在线看| 日韩免费高清视频| 日本道精品一区二区三区| 九九精品一区二区| 午夜欧美视频在线观看| 国产三级久久久| 欧美一区二区久久| 精品成人私密视频| 国产成人福利片| 青青草91视频| 99久久国产综合色|国产精品| 91精品欧美一区二区三区综合在| 最新国产成人在线观看| 欧美一区三区二区| 91国产精品成人| 国产精品亚洲人在线观看| 亚洲蜜臀av乱码久久精品| 精品福利av导航| 欧美日韩激情一区| 在线视频观看一区| 91美女精品福利| 粗大黑人巨茎大战欧美成人| 免费视频一区二区| 午夜天堂影视香蕉久久| 中文字幕在线不卡视频| 久久亚洲综合色一区二区三区| 欧美日韩一卡二卡| 色婷婷久久99综合精品jk白丝| 99视频国产精品| 成人免费福利片| 成人黄色av电影| 成人中文字幕合集| 国精产品一区一区三区mba桃花 | 色婷婷综合久久久中文字幕| 国产九九视频一区二区三区| 蜜臀精品一区二区三区在线观看| 午夜激情综合网| 日韩**一区毛片| 偷窥国产亚洲免费视频| 亚洲一区二区三区四区的| 亚洲欧美经典视频| 玉米视频成人免费看| 一区二区三区中文字幕精品精品 | 亚洲一区二区三区四区五区黄| 亚洲卡通动漫在线| 一个色妞综合视频在线观看| 亚洲国产wwwccc36天堂| 亚洲mv大片欧洲mv大片精品| 天堂va蜜桃一区二区三区漫画版| 午夜视频在线观看一区二区三区 | 欧美高清激情brazzers| 欧美日韩国产中文| 欧美大片免费久久精品三p| 日韩三级视频中文字幕| 欧美精品一区二区三区一线天视频| 精品久久久久久久人人人人传媒 | 99免费精品视频| 欧美中文字幕一二三区视频| 欧美精品乱码久久久久久| 91精品中文字幕一区二区三区| 日韩视频在线观看一区二区| 久久综合九色综合欧美98| 国产欧美日韩精品a在线观看| 国产精品久久久久一区 | 日韩一区二区免费高清| 国产亚洲综合性久久久影院| 国产精品国产三级国产a| 亚洲成人免费视| 国产乱码精品一区二区三区忘忧草 | 欧美日本乱大交xxxxx| 日韩精品中文字幕一区二区三区| 日本一区二区三区免费乱视频| 亚洲免费电影在线| 免费日韩伦理电影| 99精品国产视频| 日韩视频免费观看高清在线视频| 国产欧美综合在线| 天天综合日日夜夜精品| 福利91精品一区二区三区| 欧美在线影院一区二区| 国产欧美日韩视频一区二区| 亚洲成人久久影院| 成人开心网精品视频| 欧美一区二区三区喷汁尤物| 亚洲欧洲av另类| 激情久久久久久久久久久久久久久久| 99国产精品视频免费观看| 精品欧美一区二区三区精品久久| 一区二区成人在线视频| 国产高清成人在线| 日韩一区二区三区免费观看 | 日本高清视频一区二区| 国产亚洲精品免费| 日本vs亚洲vs韩国一区三区| 色哟哟一区二区在线观看 | 成人黄页毛片网站| 久久综合久久综合久久| 日韩福利电影在线观看| 色美美综合视频| 国产精品沙发午睡系列990531| 男女视频一区二区| 欧美日韩激情在线| 亚洲尤物视频在线| 91视频在线观看免费| 国产精品青草综合久久久久99| 美腿丝袜亚洲一区| 91精品久久久久久久久99蜜臂| 亚洲激情在线激情| 一本到高清视频免费精品| 欧美激情中文不卡| 成人app在线| 中文字幕亚洲电影| 91色婷婷久久久久合中文| 《视频一区视频二区| 不卡高清视频专区| 亚洲欧美一区二区在线观看| 成年人国产精品| 亚洲欧美日韩成人高清在线一区| 成人自拍视频在线| 亚洲欧美色图小说| 欧美自拍偷拍午夜视频| 亚洲一区二区三区视频在线播放| 91九色最新地址| 亚洲国产精品一区二区久久恐怖片| 欧美中文字幕一二三区视频| 一区二区三区蜜桃网| 欧美美女一区二区在线观看| 婷婷激情综合网| 欧美大尺度电影在线| 国产一区二区三区观看| 国产精品福利影院| 在线免费亚洲电影| 蜜臀国产一区二区三区在线播放| 精品日韩一区二区三区免费视频| 91在线视频播放地址| 国产精品久久久久久久久免费丝袜 | 日本在线观看不卡视频| 欧美大片一区二区三区| 国产成人综合亚洲网站| 国产精品成人免费精品自在线观看| 色综合婷婷久久| 日本91福利区| 国产精品国产成人国产三级 | 久久久激情视频| 色婷婷激情综合| 精品一区二区在线播放| 国产精品国产馆在线真实露脸 | 国产精品久久久久久亚洲伦| 91看片淫黄大片一级在线观看| 亚洲不卡一区二区三区| 精品美女一区二区| aaa亚洲精品| 免费在线观看日韩欧美| 国产精品久久久久婷婷| 欧美精品粉嫩高潮一区二区| 国产乱码精品一区二区三| 亚洲一区二区美女| 国产欧美一区二区在线观看| 欧美三级电影网| 成人高清视频在线| 麻豆成人91精品二区三区| 亚洲天堂精品在线观看| 久久亚洲一区二区三区四区| 欧美人妖巨大在线| 99精品视频一区二区三区| 精品中文字幕一区二区小辣椒| 亚洲天堂网中文字| 久久综合九色欧美综合狠狠 | 日韩视频中午一区| 在线免费观看成人短视频| 国产自产高清不卡| 天堂成人国产精品一区| 亚洲黄色片在线观看| 国产女人水真多18毛片18精品视频| 欧美精品久久天天躁| 91视频www| 菠萝蜜视频在线观看一区| 久久精品国产亚洲一区二区三区|