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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美白人最猛性xxxxx69交| 91激情在线视频| 国产一区二区三区日韩| 国产99精品国产| 色综合久久中文字幕综合网| 在线一区二区三区四区五区| 欧美探花视频资源| 日韩美女一区二区三区四区| 国产偷国产偷亚洲高清人白洁| 中文字幕制服丝袜一区二区三区 | 久久99国内精品| 99re8在线精品视频免费播放| 韩国女主播成人在线| 日韩亚洲欧美中文三级| 久久99精品国产91久久来源| 成人av在线播放网站| 欧美在线视频日韩| 欧美三级乱人伦电影| 欧美成人一区二区三区片免费 | 国产欧美一区二区精品久导航| 国产亚洲精品免费| 自拍偷拍国产亚洲| 午夜精品久久久久久久99樱桃| 成a人片国产精品| 国产午夜精品一区二区 | 国产欧美视频一区二区| 亚洲五月六月丁香激情| 99国产精品视频免费观看| 精品久久久久久久久久久院品网 | 欧美三级乱人伦电影| 国产精品久久久久久久久快鸭 | 7777精品久久久大香线蕉| 美女精品自拍一二三四| 亚洲午夜精品17c| 久久亚洲精品国产精品紫薇| 一本高清dvd不卡在线观看| 蜜臀精品久久久久久蜜臀| 欧美一区二区在线看| 国产精品一二三区在线| 国产欧美精品一区二区三区四区| 成人精品免费网站| 一区二区三区中文字幕| 精品福利一二区| www.亚洲激情.com| 一个色综合网站| 欧美成人在线直播| 国产999精品久久久久久| 亚洲丰满少妇videoshd| 久久亚洲一区二区三区明星换脸 | 久久久精品人体av艺术| 国产福利一区在线| 亚洲精品成人在线| 7777精品伊人久久久大香线蕉| 九一久久久久久| 国产精品九色蝌蚪自拍| 91麻豆精品一区二区三区| 日韩精品一区第一页| 国产欧美一区二区三区网站| av不卡在线观看| 精品一区二区精品| 亚洲综合一二三区| 欧美韩国日本不卡| 欧美大黄免费观看| 91精品国产一区二区三区蜜臀| 91亚洲精华国产精华精华液| 成人av在线资源网站| 成人一区在线观看| 日本高清无吗v一区| 色偷偷久久人人79超碰人人澡 | 国产网站一区二区| 欧美精品一区二区三区在线播放| 欧美人牲a欧美精品| 欧美亚洲国产怡红院影院| 95精品视频在线| 91小视频免费观看| 99精品视频一区二区三区| 成人精品电影在线观看| 丰满放荡岳乱妇91ww| 成人激情小说乱人伦| 日韩写真欧美这视频| 欧美日韩一二区| 色先锋aa成人| 91豆麻精品91久久久久久| 成人精品小蝌蚪| 成人av在线电影| 色94色欧美sute亚洲13| 亚洲一区二区三区在线播放| 一区二区三区中文字幕在线观看| 一区二区三区久久| 日韩黄色在线观看| 国产专区综合网| 成人激情黄色小说| 一本在线高清不卡dvd| 欧美卡1卡2卡| 欧美国产一区在线| 亚洲成a人片在线不卡一二三区| 丝袜美腿亚洲一区二区图片| 久久成人免费网| 99精品欧美一区二区蜜桃免费| 欧美日韩三级在线| 欧美精品一区二区三区蜜桃视频 | 不卡的av电影在线观看| 日韩一级黄色大片| 中文字幕va一区二区三区| 一区二区三区.www| 久久精品国产免费| 97se亚洲国产综合自在线| 3d动漫精品啪啪1区2区免费| 日韩毛片视频在线看| 日韩高清一区在线| 色综合久久88色综合天天6| 精品免费视频一区二区| 国产在线日韩欧美| 精品1区2区3区| 亚洲色图视频网站| 高潮精品一区videoshd| 久久综合99re88久久爱| 欧美日韩免费高清一区色橹橹| 97国产一区二区| 中文字幕一区二区三区乱码在线| 久久国产乱子精品免费女| 欧美人动与zoxxxx乱| 亚洲国产欧美日韩另类综合| 成人av在线电影| 1000精品久久久久久久久| 国产一区二区三区日韩| 久久久久久久久蜜桃| 国产激情视频一区二区在线观看| 欧美成人a∨高清免费观看| 伦理电影国产精品| 26uuu欧美日本| 国产精品亚洲а∨天堂免在线| 久久一夜天堂av一区二区三区| 欧美mv日韩mv亚洲| 国产亚洲精品7777| 成人精品视频网站| 亚洲人成网站色在线观看| 91免费看视频| 日本不卡视频在线| 国产欧美一区二区精品婷婷| 91麻豆国产精品久久| 亚洲图片欧美色图| 日韩一区二区三区高清免费看看| 美女视频黄免费的久久 | 精彩视频一区二区| 亚洲欧洲无码一区二区三区| 欧美日本视频在线| kk眼镜猥琐国模调教系列一区二区 | 亚洲欧洲韩国日本视频| 欧美日韩高清一区| 国产裸体歌舞团一区二区| 亚洲麻豆国产自偷在线| 精品国产一区a| 国产一区二区伦理片| 欧美猛男gaygay网站| 极品销魂美女一区二区三区| 国产精品久久久久久久岛一牛影视| 在线一区二区三区做爰视频网站| 韩国一区二区视频| 欧美日韩免费一区二区三区视频 | 成人精品在线视频观看| 免费高清在线一区| 日韩激情在线观看| 亚洲成人手机在线| 亚洲乱码国产乱码精品精98午夜 | 欧美日韩精品一区二区| 精品成人私密视频| 韩国欧美国产1区| 日韩国产精品大片| 亚洲成人av资源| 亚洲久本草在线中文字幕| 国产精品无码永久免费888| 欧美videossexotv100| 3d动漫精品啪啪一区二区竹菊| 99re亚洲国产精品| 日本高清免费不卡视频| 99re热这里只有精品免费视频| 成人午夜在线播放| 91蝌蚪porny| 9191精品国产综合久久久久久| 欧美日韩免费一区二区三区视频| 日本丶国产丶欧美色综合| 欧美日韩国产高清一区| 日韩一二三区视频| 久久老女人爱爱| 亚洲久草在线视频| 久久66热偷产精品| 成人激情动漫在线观看| 欧美日韩精品电影| 国产欧美日韩在线看| 亚洲成a人在线观看| 国产精品12区| 欧美日韩日本视频| 国产精品乱码一区二三区小蝌蚪| 一区二区三区精品在线| 国产一区二区三区电影在线观看| 在线看日韩精品电影| www亚洲一区| 日本欧美一区二区三区乱码| 91在线一区二区|