亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
www日韩大片| 美女一区二区视频| 91精品婷婷国产综合久久| 日本高清不卡aⅴ免费网站| 成人av影院在线| 日本成人在线看| 国产视频一区在线观看| 91精彩视频在线观看| 精品写真视频在线观看| 国产三级精品视频| 在线视频一区二区三| 国产精品1024久久| 午夜成人免费视频| 中文字幕日韩一区| 精品久久一区二区三区| 99久久精品免费| www.性欧美| 一区二区在线观看免费视频播放| 91精品久久久久久蜜臀| 成人动漫视频在线| 久久国产精品99久久人人澡| 亚洲一二三级电影| 一区二区视频免费在线观看| 国产精品麻豆久久久| 日韩一卡二卡三卡| 欧美麻豆精品久久久久久| 99久久国产综合精品色伊| av激情亚洲男人天堂| 国产精品小仙女| 国产成人小视频| 国产福利精品导航| 国产成人自拍网| 国产成人午夜电影网| 激情综合网天天干| 国产在线日韩欧美| 国产综合色在线视频区| 国产精品伊人色| 国产乱淫av一区二区三区| 成人h动漫精品一区二| 国产成人av一区二区三区在线| 国产福利一区二区三区视频在线| 国产中文字幕一区| 99亚偷拍自图区亚洲| 日本久久一区二区三区| 制服.丝袜.亚洲.中文.综合| 51午夜精品国产| 久久免费电影网| 一色桃子久久精品亚洲| 日韩主播视频在线| 99精品久久久久久| 日韩欧美一区二区免费| 一区二区三区日韩欧美精品| 国产一区福利在线| 欧美精品久久久久久久多人混战| 国产精品女同互慰在线看| 韩国av一区二区三区在线观看| 欧美在线视频日韩| 亚洲黄色av一区| 成人天堂资源www在线| 不卡大黄网站免费看| 欧美一区二区二区| 日本欧美大码aⅴ在线播放| 不卡视频在线观看| 中文字幕不卡在线播放| 国产精品1024| 国产欧美视频一区二区| 韩国理伦片一区二区三区在线播放 | 色天使久久综合网天天| 中文字幕精品—区二区四季| 国产成人一级电影| 亚洲成人动漫在线免费观看| 久久精品久久99精品久久| 欧美日韩国产中文| 五月天激情小说综合| 欧美精品xxxxbbbb| 另类成人小视频在线| 26uuu亚洲婷婷狠狠天堂| 国产91对白在线观看九色| 亚洲欧美影音先锋| 欧美裸体一区二区三区| 国产资源在线一区| 国产精品传媒入口麻豆| 91毛片在线观看| 久久精品国产一区二区三| 日本一区二区三区在线不卡| 成人深夜视频在线观看| 亚洲美女偷拍久久| 精品精品国产高清a毛片牛牛| 国产精品18久久久久久久久 | 亚洲国产精品一区二区www| 欧美蜜桃一区二区三区| 高清在线成人网| 婷婷一区二区三区| 亚洲国产经典视频| 精品久久久久久久久久久院品网| 99国产精品国产精品久久| 精品一区二区在线看| 亚洲精品国产品国语在线app| 日韩午夜电影在线观看| 日本韩国精品在线| 国产成人免费视频| 另类中文字幕网| 一区二区国产视频| 一区二区三区日韩欧美| 中文字幕在线一区二区三区| 亚洲色图欧洲色图| 精品蜜桃在线看| 91精品国产欧美一区二区18 | 一区二区三区在线影院| 国产精品夫妻自拍| 中文字幕一区二区三区在线不卡 | 久久亚洲综合av| 欧美一级搡bbbb搡bbbb| 欧美日韩一区二区三区在线看| 国精产品一区一区三区mba桃花| 美女在线一区二区| 九九热在线视频观看这里只有精品| 亚洲欧美一区二区三区国产精品| 亚洲免费av网站| 午夜精品123| 激情综合一区二区三区| av在线播放一区二区三区| 丁香一区二区三区| 色综合欧美在线| 欧美巨大另类极品videosbest | 日本韩国一区二区| 欧美日韩成人一区二区| 欧美一区二区三区不卡| 精品欧美一区二区三区精品久久 | 成人免费在线观看入口| 亚洲自拍都市欧美小说| 加勒比av一区二区| 在线区一区二视频| 欧美xxxxx牲另类人与| 欧美国产一区视频在线观看| 精品一区二区三区在线观看| 国产寡妇亲子伦一区二区| 日本二三区不卡| 国产亚洲女人久久久久毛片| 天天亚洲美女在线视频| 丁香桃色午夜亚洲一区二区三区| 一本久道久久综合中文字幕| 精品不卡在线视频| 日韩国产精品久久久| 一本大道av伊人久久综合| 久久五月婷婷丁香社区| 午夜精品久久一牛影视| 色一情一乱一乱一91av| 亚洲国产精品99久久久久久久久| 久久99在线观看| 日韩视频一区二区| 亚洲男人的天堂一区二区| av中文字幕不卡| 亚洲精品美腿丝袜| 91国偷自产一区二区三区观看 | 国产亚洲制服色| 亚洲愉拍自拍另类高清精品| 欧洲色大大久久| 精品无人码麻豆乱码1区2区 | 国产.精品.日韩.另类.中文.在线.播放| 91精品综合久久久久久| 亚洲图片一区二区| 日韩一区二区不卡| 国产精品一区二区久激情瑜伽| 日韩亚洲电影在线| 国产剧情在线观看一区二区| 欧美国产激情二区三区| av电影天堂一区二区在线观看| 亚洲精品成人天堂一二三| 欧美美女一区二区三区| 男人操女人的视频在线观看欧美 | 欧美一区二区三区思思人| 韩国成人精品a∨在线观看| 亚洲欧洲www| 91精品国产乱| 91网站最新网址| 日韩高清不卡在线| 国产精品毛片久久久久久久| 久久网站最新地址| 91蜜桃在线免费视频| 久久99久久99小草精品免视看| 亚洲男人电影天堂| 欧美变态凌虐bdsm| 在线成人高清不卡| 色综合天天综合网天天狠天天| 天天av天天翘天天综合网色鬼国产| 成人91在线观看| 首页国产丝袜综合| 欧美高清精品3d| 在线观看日韩毛片| 国产精品资源网站| 日本不卡123| 午夜精品福利在线| 亚洲成av人**亚洲成av**| 中文字幕日韩精品一区| 亚洲国产成人一区二区三区| 精品国精品国产尤物美女| 久久久久国产精品麻豆| 久久女同互慰一区二区三区| 中文字幕成人网|