亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人精品免费网站| 亚洲一区二区三区四区五区黄| 久久蜜桃av一区二区天堂| 日韩黄色片在线观看| 欧美日韩精品一区二区在线播放| 亚洲最新在线观看| 6080国产精品一区二区| 日韩av电影天堂| 久久综合色鬼综合色| 大白屁股一区二区视频| 亚洲视频狠狠干| 欧美人妖巨大在线| 国产尤物一区二区| 1000精品久久久久久久久| 色婷婷综合久久久中文字幕| 亚洲成人777| 久久久久久久久久久久久女国产乱 | 麻豆国产一区二区| 欧美喷水一区二区| 国产精品1024| 一区二区免费视频| 精品区一区二区| 99久精品国产| 久久激情五月激情| 亚洲视频一区二区在线观看| 欧美日韩国产精品成人| 国产99久久久精品| 午夜久久久久久电影| 中文字幕va一区二区三区| 欧美综合天天夜夜久久| 精品一区二区免费在线观看| 亚洲日本韩国一区| 欧美精品一区二区久久婷婷 | 中文字幕一区二区日韩精品绯色| 欧美在线观看一区| 国产精品456| 日韩不卡一区二区| 国产精品免费看片| 日韩免费性生活视频播放| 91蝌蚪porny成人天涯| 精品在线亚洲视频| 亚洲国产欧美另类丝袜| 欧美国产综合一区二区| 日韩一二在线观看| 91精彩视频在线| 国产999精品久久久久久绿帽| 日韩激情视频网站| 亚洲综合色成人| 国产精品视频免费看| 日韩欧美色综合| 欧美性感一区二区三区| 成人国产精品免费观看| 精品在线视频一区| 免费成人在线网站| 亚洲一二三区视频在线观看| 中文字幕亚洲视频| 国产亚洲综合色| 精品福利一区二区三区| 欧美日韩三级在线| 91小视频在线| 成人黄色网址在线观看| 国产一区二区在线免费观看| 男女性色大片免费观看一区二区| 亚洲激情一二三区| 中文字幕在线不卡| 国产欧美日韩不卡| 国产欧美视频在线观看| 久久久精品国产免大香伊| 日韩精品一区二区三区在线播放 | 99久久婷婷国产综合精品| 国产福利一区二区| 国产成人av电影| 国产91对白在线观看九色| 韩国理伦片一区二区三区在线播放| 亚洲成人精品一区| 日本在线观看不卡视频| 男人的j进女人的j一区| 麻豆精品一二三| 麻豆精品在线播放| 国产在线国偷精品免费看| 麻豆精品视频在线观看视频| 老司机精品视频一区二区三区| 日本不卡中文字幕| 久久99精品久久久久| 精品一区二区三区久久久| 国产在线不卡一区| 国产成人免费视频精品含羞草妖精| 狠狠色狠狠色合久久伊人| 国产成人三级在线观看| 不卡的av在线| 色屁屁一区二区| 欧美色成人综合| 日韩欧美国产综合| 国产偷国产偷精品高清尤物| 国产精品午夜久久| 亚洲色图在线视频| 亚洲午夜电影在线观看| 免费在线视频一区| 国产高清视频一区| 色综合久久88色综合天天6| 欧洲国产伦久久久久久久| 91精品国产综合久久久久久 | 成人高清视频免费观看| 91丨porny丨在线| 欧美性极品少妇| 精品国产精品一区二区夜夜嗨| 国产亚洲精品精华液| 亚洲欧美日韩国产手机在线| 午夜精品福利一区二区三区av| 免费看精品久久片| 国产不卡一区视频| 欧美日免费三级在线| 欧美xfplay| 亚洲欧美国产高清| 美女在线视频一区| 国产99久久久久久免费看农村| 91成人免费在线视频| 日韩精品一区二区三区在线观看| 国产精品天美传媒| 天堂蜜桃一区二区三区| 风间由美一区二区三区在线观看 | 亚洲精品少妇30p| 美女免费视频一区| 欧美综合色免费| 久久精品夜色噜噜亚洲a∨| 一区二区三区中文在线| 国产精品一区三区| 8x8x8国产精品| 国产精品美女久久久久aⅴ国产馆| 亚洲午夜精品久久久久久久久| 国产高清精品久久久久| 在线成人高清不卡| 亚洲欧洲成人自拍| 国模少妇一区二区三区| 欧美亚洲愉拍一区二区| 亚洲国产精品t66y| 麻豆视频一区二区| 欧美男人的天堂一二区| 亚洲欧美在线高清| 国产乱码精品一区二区三| 91精品国产综合久久精品| 亚洲男同性视频| 国产不卡免费视频| 亚洲精品在线观| 蜜桃一区二区三区四区| 欧美精选一区二区| 一区二区高清免费观看影视大全| 国产高清精品久久久久| 欧美不卡一区二区三区| 日本视频免费一区| 欧美精品亚洲一区二区在线播放| 成人欧美一区二区三区白人| 国产成人aaaa| 国产亚洲精品中文字幕| 国产麻豆9l精品三级站| 26uuu亚洲婷婷狠狠天堂| 麻豆精品一区二区三区| 欧美一区二区啪啪| 日韩电影在线看| 9191久久久久久久久久久| 亚洲1区2区3区4区| 欧美日韩免费观看一区三区| 一区二区三区国产精品| 在线影院国内精品| 一区二区三区影院| 欧美日韩中文字幕精品| 亚洲一线二线三线视频| 欧美性做爰猛烈叫床潮| 亚洲国产日韩综合久久精品| 欧美午夜精品一区二区三区| 亚洲在线免费播放| 欧美精品乱码久久久久久| 日韩电影在线看| 欧美成人女星排行榜| 狠狠色丁香婷综合久久| 国产亲近乱来精品视频| www.欧美日韩国产在线| 亚洲区小说区图片区qvod| 色琪琪一区二区三区亚洲区| 亚洲国产aⅴ成人精品无吗| 在线免费亚洲电影| 亚洲va天堂va国产va久| 日韩一区二区在线观看视频| 久久精工是国产品牌吗| 国产亚洲一区字幕| 色欲综合视频天天天| 午夜精品一区在线观看| 2020国产精品| 97精品久久久久中文字幕| 一区二区三区高清不卡| 91精品在线观看入口| 国产自产高清不卡| 亚洲视频一区二区在线| 欧美人狂配大交3d怪物一区| 狠狠网亚洲精品| 一区二区在线免费| 日韩欧美久久久| 北条麻妃国产九九精品视频| 亚洲3atv精品一区二区三区| 精品国产不卡一区二区三区|