亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
精品欧美一区二区在线观看| 国产精品欧美经典| 久久久不卡影院| 亚洲午夜久久久久久久久电影网| 国产激情一区二区三区四区| 欧洲激情一区二区| 国产精品久久看| 精品一区二区三区在线视频| 精品视频在线视频| 亚洲免费大片在线观看| 成人免费毛片a| 久久综合网色—综合色88| 日韩黄色免费电影| 欧美日韩性生活| 亚洲一区二区av电影| 一本大道久久a久久综合| 国产精品热久久久久夜色精品三区 | 久久无码av三级| 午夜婷婷国产麻豆精品| 一本色道久久综合亚洲91| 国产精品乱码一区二区三区软件 | 亚洲成人av资源| 色综合天天综合网国产成人综合天 | 大白屁股一区二区视频| 欧美丰满少妇xxxxx高潮对白| 一区二区三区四区在线播放| 91丨九色porny丨蝌蚪| 综合久久久久久久| 97se亚洲国产综合自在线观| 国产精品国产三级国产普通话三级| 国产成人av电影在线观看| 久久久久久久久久久99999| 国产精品亚洲一区二区三区妖精| 26uuu国产电影一区二区| 国产精品一区在线观看乱码| 国产三级一区二区三区| 懂色av中文字幕一区二区三区| 国产色产综合色产在线视频| 不卡视频一二三| 亚洲久草在线视频| 欧美三级中文字| 蜜桃久久精品一区二区| 久久久久久久综合日本| 成人av在线资源| 亚洲一区二区av电影| 91精品啪在线观看国产60岁| 国产麻豆一精品一av一免费| 国产拍揄自揄精品视频麻豆| av电影在线观看完整版一区二区| 亚洲欧美日韩成人高清在线一区| 欧日韩精品视频| 乱一区二区av| 国产精品三级久久久久三级| 欧美专区亚洲专区| 久久丁香综合五月国产三级网站| 久久久777精品电影网影网| av色综合久久天堂av综合| 天天射综合影视| 国产欧美精品一区aⅴ影院| 欧洲生活片亚洲生活在线观看| 日韩电影免费在线观看网站| 国产亚洲欧洲一区高清在线观看| 99久久99久久久精品齐齐| 亚洲成人av一区| 日本一区二区三区dvd视频在线| 在线影院国内精品| 国产一区二区精品久久99| 亚洲蜜桃精久久久久久久| 欧美一二三区在线| 色网站国产精品| 狠狠色伊人亚洲综合成人| 亚洲蜜臀av乱码久久精品蜜桃| 精品伦理精品一区| 91久久精品一区二区三区| 激情六月婷婷久久| 午夜视频一区二区| 亚洲日本一区二区| 日韩欧美高清dvd碟片| 91视频你懂的| 国产不卡在线一区| 久久福利资源站| 亚洲超碰97人人做人人爱| 久久精品视频一区二区| 91精品国产手机| 欧美亚洲愉拍一区二区| 成人高清在线视频| 国产一区二区视频在线| 午夜不卡av免费| 亚洲品质自拍视频| 国产精品区一区二区三区| 日韩欧美国产精品一区| 欧美日韩高清一区二区三区| 91免费在线视频观看| 精品一区二区三区影院在线午夜 | 日韩欧美色综合| 欧美日本在线播放| 色综合久久66| 99精品欧美一区二区三区综合在线| 国产在线不卡一卡二卡三卡四卡| 天堂在线一区二区| 亚洲成人tv网| 亚洲123区在线观看| 亚洲最大的成人av| 亚洲欧美日韩国产综合在线| 成人欧美一区二区三区1314| 久久精品在这里| 久久久国产精品午夜一区ai换脸| 日韩一级二级三级| 日韩欧美国产小视频| 日韩精品一区二区三区蜜臀| 欧美一区二区久久| 日韩亚洲国产中文字幕欧美| 日韩视频国产视频| 精品日韩在线一区| 精品国产成人在线影院| 久久久精品欧美丰满| 国产性色一区二区| 日本一区二区三区在线观看| 国产精品国产三级国产aⅴ入口 | 男男gaygay亚洲| 日本欧美一区二区| 精品亚洲欧美一区| 国产成人精品综合在线观看| 成人一区二区在线观看| 91亚洲精品久久久蜜桃网站| 欧美综合视频在线观看| 欧美一区二区三区影视| 日韩三区在线观看| 中文字幕av一区二区三区 | 欧美高清在线一区| 国产精品短视频| 亚洲黄一区二区三区| 亚洲国产中文字幕| 国内成人免费视频| 91原创在线视频| 在线播放亚洲一区| 久久久久久久久一| 亚洲欧洲日产国码二区| 亚洲h精品动漫在线观看| 男女性色大片免费观看一区二区 | 国产精品无码永久免费888| 亚洲欧洲日本在线| 日韩在线一区二区| 国产福利一区在线| 在线免费不卡视频| 精品少妇一区二区三区免费观看 | 亚洲一区二区三区四区不卡| 奇米影视在线99精品| 国产91在线看| 6080国产精品一区二区| 欧美国产日韩一二三区| 一个色综合av| 国产美女娇喘av呻吟久久| 欧美亚洲免费在线一区| 精品盗摄一区二区三区| 亚洲美女免费在线| 国产中文字幕精品| 欧美色倩网站大全免费| 久久久久久毛片| 丝袜国产日韩另类美女| 99久久er热在这里只有精品66| 91 com成人网| 亚洲欧美日韩一区| 国产揄拍国内精品对白| 欧美日韩成人高清| 亚洲三级在线免费| 国产成人午夜精品影院观看视频 | 亚洲激情第一区| 激情综合色播五月| 欧美性欧美巨大黑白大战| 欧美激情在线观看视频免费| 麻豆成人在线观看| 欧美日韩一级二级| 最近中文字幕一区二区三区| 国产一区二区三区久久悠悠色av| 欧美精品1区2区3区| 一区二区在线观看av| 国产成人在线观看| 精品三级av在线| 美国十次综合导航| 欧美一区二区三区的| 亚洲国产精品久久人人爱蜜臀| k8久久久一区二区三区| 久久伊99综合婷婷久久伊| 蜜臀av国产精品久久久久| 欧美午夜影院一区| 亚洲精品乱码久久久久| 91视频在线观看| 亚洲欧美偷拍另类a∨色屁股| av在线一区二区| 国产精品久久久久aaaa樱花| 成人激情校园春色| 国产精品国产三级国产| 91网址在线看| 亚洲图片欧美一区| 欧美三级视频在线播放| 一区二区三区四区在线免费观看| 91精品91久久久中77777| 亚洲色图都市小说| 欧亚一区二区三区|