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

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

?? can.c

?? iar 安裝使用的方法。其中包括一些工程模板
?? C
?? 第 1 頁 / 共 5 頁
字號:
//*****************************************************************************
//
// can.c - Driver for the CAN module.
//
// Copyright (c) 2006-2008 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 2752 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)

//*****************************************************************************
//
//! \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 inital 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);

    //
    // Reenable 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 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;

    //
    // 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;

    //
    // 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 = CANRegRead((unsigned long)(pulRegister++));

        //
        // Store the first byte.
        //
        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;

    //
    // Make sure that the address passed in is valid.
    //
    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.
    //
    CANRegWrite(ulBase + CAN_O_CTL, CAN_CTL_INIT);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品欧美久久久久久动漫| 一区二区在线观看不卡| 日韩欧美国产一区在线观看| 欧美男人的天堂一二区| 欧美午夜理伦三级在线观看| 欧美天堂亚洲电影院在线播放| 91蝌蚪国产九色| 日本精品裸体写真集在线观看| 一本大道综合伊人精品热热| 91丨porny丨中文| 日本乱人伦一区| 欧美午夜免费电影| 3d成人动漫网站| 欧美精品一区二区高清在线观看 | 337p日本欧洲亚洲大胆精品| 精品久久久久久久久久久久包黑料 | 亚洲影院免费观看| 亚洲综合一二三区| 午夜亚洲福利老司机| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产一区在线观看麻豆| 成人性视频免费网站| 91猫先生在线| 在线不卡a资源高清| 欧美刺激午夜性久久久久久久 | 伊人开心综合网| 视频一区国产视频| 激情图区综合网| 99精品国产热久久91蜜凸| 欧美三级欧美一级| 精品国产百合女同互慰| 中文字幕一区二区日韩精品绯色| 亚洲黄色免费网站| 免费精品视频最新在线| 国产成人精品免费网站| 色综合 综合色| 日韩网站在线看片你懂的| 久久天天做天天爱综合色| √…a在线天堂一区| 日本视频一区二区| 丰满岳乱妇一区二区三区| 欧美影院精品一区| 久久久久9999亚洲精品| 亚洲一区二区美女| 国内精品国产成人| 91久久线看在观草草青青| 精品理论电影在线| 亚洲一区中文日韩| 国产乱人伦偷精品视频免下载| 在线国产电影不卡| 国产亚洲精品中文字幕| 亚洲国产精品一区二区www在线| 国产高清无密码一区二区三区| 欧美在线观看视频在线| 久久人人爽爽爽人久久久| 亚洲一区自拍偷拍| 成人久久久精品乱码一区二区三区| 欧美狂野另类xxxxoooo| 国产精品第一页第二页第三页 | 欧美一区二区女人| 专区另类欧美日韩| 国产一区二区三区久久久| 欧美日韩视频不卡| 亚洲欧洲韩国日本视频| 久久爱www久久做| 色老头久久综合| 欧美精彩视频一区二区三区| 石原莉奈在线亚洲二区| 色综合天天综合网国产成人综合天| 精品国产成人系列| 日韩专区中文字幕一区二区| 91麻豆精品视频| 国产调教视频一区| 韩国av一区二区| 9191久久久久久久久久久| 亚洲日本在线观看| 国产高清精品网站| 精品久久国产老人久久综合| 日韩精品一级二级 | 久久午夜老司机| 美脚の诱脚舐め脚责91| 欧美伊人久久久久久久久影院 | 奇米影视在线99精品| 在线看一区二区| 亚洲美女视频在线观看| 成人黄页毛片网站| 国产喂奶挤奶一区二区三区| 国内精品不卡在线| 精品久久久久久久久久久久久久久 | 在线观看欧美日本| 亚洲乱码国产乱码精品精的特点 | 波多野结衣亚洲| 国产精品色呦呦| 国产a区久久久| 久久久久久亚洲综合影院红桃| 国内精品在线播放| 2022国产精品视频| 国产精品亚洲专一区二区三区| 日韩欧美国产一区二区在线播放| 蜜臀a∨国产成人精品| 欧美精选在线播放| 香蕉成人伊视频在线观看| 欧美性大战久久久| 午夜视频在线观看一区| 欧美日本一区二区三区| 舔着乳尖日韩一区| 制服丝袜亚洲网站| 久久精品国产99久久6| 日韩免费在线观看| 国产精品综合久久| 国产精品毛片久久久久久| 97se亚洲国产综合自在线观| 亚洲日本一区二区三区| 欧洲另类一二三四区| 午夜久久久影院| 精品奇米国产一区二区三区| 国模大尺度一区二区三区| 久久精品无码一区二区三区| 成人的网站免费观看| ●精品国产综合乱码久久久久| 91麻豆国产在线观看| 亚洲成人7777| 精品国产一区a| 成人免费av网站| 亚洲丰满少妇videoshd| 日韩视频不卡中文| 国产成人免费av在线| 中文字幕一区二区三区乱码在线| 91在线播放网址| 性欧美疯狂xxxxbbbb| 日韩精品综合一本久道在线视频| 国产另类ts人妖一区二区| 综合久久久久久| 在线播放一区二区三区| 加勒比av一区二区| 综合在线观看色| 欧美一区二区三区免费视频| 国产另类ts人妖一区二区| 亚洲婷婷国产精品电影人久久| 欧美日韩一区二区三区不卡 | 欧美mv日韩mv国产网站| 成人精品免费视频| 午夜电影网亚洲视频| 久久久综合网站| 在线这里只有精品| 久久精品国产色蜜蜜麻豆| 国产精品九色蝌蚪自拍| 欧美久久一二区| 99在线视频精品| 玖玖九九国产精品| 亚洲乱码国产乱码精品精可以看| 日韩一级视频免费观看在线| 99免费精品视频| 美女视频黄 久久| 一区二区在线观看免费视频播放 | 亚洲电影你懂得| 国产亚洲一区二区三区四区| 欧美亚洲国产bt| 国产成人免费视频网站 | 欧美色区777第一页| 国产99久久久久久免费看农村| 亚洲成a天堂v人片| 国产精品妹子av| 日韩欧美国产高清| 欧美最猛性xxxxx直播| 国产成人精品亚洲午夜麻豆| 日韩精品欧美成人高清一区二区| 国产精品蜜臀av| 精品国产乱码久久久久久蜜臀| 欧美伊人久久大香线蕉综合69 | www精品美女久久久tv| 欧美日韩国产一级二级| av电影在线观看完整版一区二区| 精品在线播放午夜| 亚洲成人资源在线| 亚洲日本在线视频观看| 国产亚洲欧美日韩俺去了| 日韩一区二区中文字幕| 色婷婷亚洲综合| 不卡av免费在线观看| 国内精品在线播放| 久久精品国产久精国产爱| 性久久久久久久| 亚洲一二三专区| 一级做a爱片久久| 亚洲欧美怡红院| 欧美高清在线视频| 国产色一区二区| 26uuuu精品一区二区| 日韩欧美国产午夜精品| 欧美日韩电影在线播放| 日本韩国欧美一区| 91欧美一区二区| av午夜一区麻豆| heyzo一本久久综合| 成人精品国产福利| 成人做爰69片免费看网站| 国产成人精品一区二区三区四区| 国产精品99久久久久久久女警| 国产精品77777|