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

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

?? can.c

?? uCOS-II V2.84 LM3S6965 TCPIP Demo
?? C
?? 第 1 頁 / 共 5 頁
字號:
//*****************************************************************************
//
// can.c - Driver for the CAN module.
//
// Copyright (c) 2006-2007 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.  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 1392 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)

//*****************************************************************************
//
//! Reads a CAN controller register.
//!
//! \param ulRegAddress is the full address of the CAN register to be read.
//!
//! This function takes care of the synchronization necessary to read from a
//! CAN controller register.
//!
//! \note This function takes care of delay required to access CAN registers.
//! This delay is required when accessing CAN registers directly.
//!
//! \return The current value of the register that was requested by
//! ulRegAddress.
//
//*****************************************************************************
unsigned long
CANReadReg(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 = CANGetIntNumber(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);
}

//*****************************************************************************
//
//! 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
//! ulRegAddress.
//!
//! This function takes care of the synchronization necessary to write to a
//! CAN controller register.
//!
//! \note The delays in this function are required when accessing CAN registers
//! directly.
//!
//! \return None.
//
//*****************************************************************************
void
CANWriteReg(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++)
    {
    }
}

//*****************************************************************************
//
//! This function 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: (CAN0_BASE
//! + 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.
//!
//! \return None.
//
//*****************************************************************************
void
CANWriteDataReg(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);
        }
        CANWriteReg((unsigned long)(pulRegister++), ulValue);
    }
}

//*****************************************************************************
//
//! This function copies data from a buffer to the CAN Data registers.
//!
//! \param pucData is a pointer to 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: (CAN0_BASE
//! + 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.
//!
//! \return None.
//
//*****************************************************************************
void
CANReadDataReg(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 = CANReadReg((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));

    //
    // 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.
    //
    CANWriteReg(ulBase + CAN_O_CTL, CAN_CTL_INIT);

    //
    // Wait for busy bit to clear
    //
    while(CANReadReg(ulBase + CAN_O_IF1CRQ) & CAN_IFCRQ_BUSY)
    {
    }

    //
    // Clear the message value bit in the arbitration register.
    // This indicates the message is not valid and is a "safe"
    // condition to leave the message object.  The same arb reg
    // is used to program all the message objects.
    //
    CANWriteReg(ulBase + CAN_O_IF1CMSK, CAN_IFCMSK_WRNRD | CAN_IFCMSK_ARB |
                CAN_IFCMSK_CONTROL);
    CANWriteReg(ulBase + CAN_O_IF1ARB2, 0);
    CANWriteReg(ulBase + CAN_O_IF1MCTL, 0);

    //
    // Loop through to program all 32 message objects
    //
    for(iMsg = 1; iMsg <= 32; iMsg++)
    {
        //
        // Wait for busy bit to clear
        //
        while(CANReadReg(ulBase + CAN_O_IF1CRQ) & CAN_IFCRQ_BUSY)
        {
        }

        //
        // Initiate programming the message object
        //
        CANWriteReg(ulBase + CAN_O_IF1CRQ, iMsg);
    }

    //
    // Make sure that the interrupt and new data flags are updated for the
    // message objects.
    //
    CANWriteReg(ulBase + CAN_O_IF1CMSK, CAN_IFCMSK_NEWDAT |
                CAN_IFCMSK_CLRINTPND);

    //
    // Loop through to program all 32 message objects
    //
    for(iMsg = 1; iMsg <= 32; iMsg++)
    {
        //
        // Wait for busy bit to clear.
        //
        while(CANReadReg(ulBase + CAN_O_IF1CRQ) & CAN_IFCRQ_BUSY)
        {
        }

        //
        // Initiate programming the message object
        //
        CANWriteReg(ulBase + CAN_O_IF1CRQ, iMsg);
    }

    //
    // Acknowledge any pending status interrupts.
    //
    CANReadReg(ulBase + CAN_O_STS);
}

//*****************************************************************************
//
//! Enables the CAN controller.
//!
//! \param ulBase is the base address of the CAN controller to enable.
//!
//! Enables the CAN controller for message processing.  Once enabled, the
//! controller will automatically transmit any pending frames, and process
//! any received frames.  The controller can be stopped by calling
//! CANDisable().  Prior to calling CANEnable(), CANInit() should have been
//! called to initialize the controller and the CAN bus clock should be
//! configured by calling CANSetBitTiming().
//!
//! \return None.
//
//*****************************************************************************
void
CANEnable(unsigned long ulBase)
{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色香色香欲天天天影视综合网| jizzjizzjizz欧美| 欧美精品tushy高清| 欧美一区二区三区免费| 亚洲天天做日日做天天谢日日欢| 免费观看成人av| 欧美亚洲一区三区| 中文字幕一区二区三区不卡 | 亚洲丶国产丶欧美一区二区三区| 精品中文字幕一区二区小辣椒| 一本久久精品一区二区| 26uuu欧美| 日本中文字幕一区二区有限公司| 国产高清视频一区| 欧美精品一区二区三区蜜桃 | 久久精品国产免费| 欧美在线观看你懂的| 国产精品乱码一区二三区小蝌蚪| 久久国产精品区| 欧美精品亚洲二区| 亚洲影院理伦片| 色哟哟在线观看一区二区三区| 中文字幕成人在线观看| 国产成人在线网站| 久久久久高清精品| 国产精品影视网| 久久婷婷综合激情| 欧美裸体bbwbbwbbw| 亚洲亚洲人成综合网络| 91蜜桃在线免费视频| 国产精品网站在线播放| 国产不卡在线视频| 中文字幕精品—区二区四季| 国产成人精品影视| 国产精品少妇自拍| av电影天堂一区二区在线观看| 国产欧美日本一区二区三区| 国产成人精品免费看| 国产精品系列在线| 91免费观看在线| 亚洲bt欧美bt精品| 日韩一区二区三区av| 国产一区二区影院| 日本一区二区电影| 色一情一乱一乱一91av| 亚洲国产精品一区二区www| 欧美日韩你懂的| 久久精品国产99国产| 久久精品人人做人人综合| www.亚洲色图| 亚洲一区二区三区四区的| 911精品产国品一二三产区| 久久精品国产精品亚洲红杏| 国产欧美精品在线观看| 色爱区综合激月婷婷| 天天综合日日夜夜精品| 日韩一区二区麻豆国产| 国产成人99久久亚洲综合精品| 国产欧美一区二区精品秋霞影院| 99久久国产综合色|国产精品| 亚洲久本草在线中文字幕| 欧美日韩国产影片| 国产在线播精品第三| 日韩毛片一二三区| 欧美一区二区三区婷婷月色| 国产高清亚洲一区| 香蕉久久一区二区不卡无毒影院| 久久亚洲综合色| 国产午夜精品美女毛片视频| 9久草视频在线视频精品| 日日欢夜夜爽一区| 国产网站一区二区三区| 欧美军同video69gay| 国产风韵犹存在线视精品| 一区二区三国产精华液| 制服丝袜国产精品| av在线一区二区三区| 蜜桃91丨九色丨蝌蚪91桃色| 国产精品色眯眯| 欧美成人激情免费网| 在线免费观看成人短视频| 国内久久婷婷综合| 午夜伦欧美伦电影理论片| 欧美激情一区二区在线| 91精品国产一区二区人妖| 色综合天天综合狠狠| 国产一区二区精品久久99| 丝袜美腿亚洲一区| 亚洲美女在线国产| 国产精品第13页| 欧美mv和日韩mv国产网站| 欧美日韩精品一区二区三区四区| 国产91精品久久久久久久网曝门| 丝袜美腿一区二区三区| 一区二区三区四区不卡在线 | 欧美日韩视频在线观看一区二区三区| 国内外成人在线视频| 五月天亚洲精品| 亚洲乱码日产精品bd| 国产精品久久久久婷婷| www国产精品av| 欧美一级搡bbbb搡bbbb| 91福利资源站| 91久久人澡人人添人人爽欧美| 成人性生交大片免费看视频在线 | 欧美挠脚心视频网站| 色婷婷综合五月| 99这里都是精品| 岛国一区二区三区| 成人av在线电影| 粉嫩av一区二区三区粉嫩| 国模少妇一区二区三区| 久久99精品国产麻豆婷婷| 秋霞影院一区二区| 日本三级亚洲精品| 免费高清在线视频一区·| 奇米色一区二区| 精品一区二区在线播放| 韩日欧美一区二区三区| 国产在线一区二区综合免费视频| 国产一区在线精品| 国产91对白在线观看九色| 国产.欧美.日韩| 色一情一伦一子一伦一区| 欧美性感一类影片在线播放| 欧美精品在线视频| 精品国产乱码久久久久久久| www一区二区| 国产精品理伦片| 一级精品视频在线观看宜春院| 亚洲一区二区三区国产| 视频一区欧美精品| 国内外精品视频| 99re视频这里只有精品| 欧美日韩你懂的| www欧美成人18+| 亚洲婷婷国产精品电影人久久| 亚洲一区二区四区蜜桃| 天天操天天色综合| 精品一区二区三区在线播放视频| 国产九色sp调教91| 一本色道久久综合精品竹菊| 欧美精品高清视频| 久久综合成人精品亚洲另类欧美 | 国产欧美一区二区三区在线老狼| 久久人人爽人人爽| 天天影视网天天综合色在线播放| 日韩精品一二三区| 国产呦萝稀缺另类资源| jlzzjlzz亚洲日本少妇| 欧美精品丝袜久久久中文字幕| 久久综合精品国产一区二区三区| 国产精品福利一区| 青青国产91久久久久久| 处破女av一区二区| 7777精品久久久大香线蕉| 国产日韩欧美电影| 亚洲成a人片在线不卡一二三区| 激情综合网天天干| 日本高清不卡aⅴ免费网站| 亚洲精品在线观| 亚洲午夜羞羞片| 国产成人午夜精品5599| 91精品久久久久久久99蜜桃| 亚洲欧洲日韩av| 韩日av一区二区| 欧美理论电影在线| 亚洲精品久久7777| 国产精品一区二区你懂的| 欧美日韩精品二区第二页| 国产精品少妇自拍| 国内外成人在线视频| 欧美精品久久久久久久多人混战| 中文av一区二区| 国内精品国产成人国产三级粉色| 欧美午夜在线一二页| 中文字幕av一区二区三区免费看 | 欧美日韩一区国产| 日本一区二区高清| 国产在线日韩欧美| 欧美一卡2卡3卡4卡| 亚洲国产另类av| 欧美中文字幕一区二区三区| 国产日韩欧美综合一区| 精品在线观看视频| 日韩色在线观看| 天堂一区二区在线| 欧美日韩色综合| 亚洲影视在线播放| 欧美专区在线观看一区| 亚洲男同1069视频| 一本大道av伊人久久综合| 国产精品三级久久久久三级| 国产福利一区二区| 国产日韩欧美麻豆| 粉嫩av一区二区三区在线播放| 国产午夜亚洲精品羞羞网站| 免费成人在线网站| 1000部国产精品成人观看| 日韩精品一区二区三区中文精品 |