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

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

?? can.c

?? Luminary coxter_M3 內核的遙控源代碼
?? 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.  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 1928 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 performs the necessary synchronization to read from a CAN
//! controller register.
//!
//! \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.
//
//*****************************************************************************
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
//! \e 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++)
    {
    }
}

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

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

    //
    // Wait for busy bit to clear
    //
    while(CANReadReg(ulBase + CAN_O_IF1CRQ) & CAN_IF1CRQ_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_IF1CMSK_WRNRD | CAN_IF1CMSK_ARB |
                CAN_IF1CMSK_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_IF1CRQ_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_IF1CMSK_NEWDAT |
                CAN_IF1CMSK_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_IF1CRQ_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)
{
    //
    // Make sure that the address passed in is valid.
    //
    ASSERT((ulBase == CAN0_BASE) ||
           (ulBase == CAN1_BASE) ||
           (ulBase == CAN2_BASE));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产高清亚洲一区| 成av人片一区二区| 精品一区二区综合| 日韩成人精品在线| 国产在线精品国自产拍免费| av不卡免费在线观看| 欧美亚一区二区| 欧美精品一区二区在线播放| 亚洲三级在线免费| 精品一区二区三区久久久| 99re在线精品| 日韩精品影音先锋| 亚洲精品成a人| 爽好多水快深点欧美视频| 精品一区二区三区免费毛片爱| 99re热这里只有精品免费视频| 欧美网站一区二区| 2021国产精品久久精品| 日韩视频一区二区三区| 水蜜桃久久夜色精品一区的特点| 卡一卡二国产精品| 日韩欧美成人激情| 91精品久久久久久久91蜜桃| 亚洲成人www| 国内不卡的二区三区中文字幕| 欧美激情在线一区二区三区| 东方aⅴ免费观看久久av| 中文字幕第一区综合| 欧美日韩第一区日日骚| 蜜桃视频第一区免费观看| 欧美成人a在线| 免费成人在线观看视频| 国产精品久久夜| 欧美在线观看一区| 久久精品国产精品亚洲综合| 欧美高清一级片在线观看| 91麻豆文化传媒在线观看| 亚洲一二三级电影| 国产欧美日韩在线视频| 色综合天天综合在线视频| 青青草成人在线观看| 欧美一区二区二区| 成人激情午夜影院| 污片在线观看一区二区| 2017欧美狠狠色| 欧美日韩视频在线第一区| 精品一区中文字幕| 亚洲精品视频自拍| 久久精品一区二区三区av| 在线观看视频91| 国内一区二区视频| 日韩免费福利电影在线观看| 一本一道久久a久久精品| 久久精品国产在热久久| 中文字幕亚洲一区二区av在线| 欧美第一区第二区| 色噜噜久久综合| 精品一二线国产| 亚洲精品国产a久久久久久| 久久综合久色欧美综合狠狠| 日本丶国产丶欧美色综合| 欧美aⅴ一区二区三区视频| 亚洲免费av高清| 日本一区二区三区电影| 欧美日韩国产色站一区二区三区| 成人动漫在线一区| 久久99精品国产| 亚洲综合一区二区| xvideos.蜜桃一区二区| 欧美一级高清大全免费观看| 91麻豆精东视频| 国产高清亚洲一区| 国产精品911| 美美哒免费高清在线观看视频一区二区| 亚洲免费视频成人| 亚洲视频精选在线| 国产精品网曝门| 精品国产一区二区精华| 欧美做爰猛烈大尺度电影无法无天| 国产乱一区二区| 精品一区二区三区在线播放视频| 国产精品色在线| 国产精品美女一区二区三区| 久久久精品天堂| 26uuu另类欧美| 国产亚洲精品超碰| 精品成人私密视频| 日韩免费在线观看| 精品成人a区在线观看| 日韩精品一区二区三区三区免费 | 亚洲综合丝袜美腿| 亚洲欧美日韩在线播放| 中文字幕一区二区三中文字幕| 久久久99免费| 久久久精品2019中文字幕之3| 欧美大片拔萝卜| 欧美一级黄色片| 欧美丝袜丝交足nylons| 久久久久久久国产精品影院| 日韩欧美一区二区视频| 欧美tickling挠脚心丨vk| 欧美一区二区三区系列电影| 欧美一级艳片视频免费观看| 精品视频在线看| 91精品午夜视频| 欧美成人一区二区三区片免费| 欧美高清视频www夜色资源网| 久久精品免费在线观看| 中文字幕乱码久久午夜不卡| 久久午夜国产精品| 国产精品国产自产拍高清av王其 | 亚洲天堂久久久久久久| 国产精品国产精品国产专区不片| 国产精品第一页第二页第三页| 亚洲欧美日本韩国| 日韩精品欧美精品| 精品一区二区三区免费毛片爱 | 日韩成人精品在线| 国产综合久久久久久鬼色| 免费一级欧美片在线观看| 成人黄色大片在线观看| 色就色 综合激情| 欧美一区二区三区日韩视频| 欧美国产视频在线| 一区2区3区在线看| 天天综合色天天综合| 高清国产一区二区| 欧美性受xxxx黑人xyx| 欧美一区二区三区婷婷月色| 国产精品久久毛片a| 亚洲国产成人av网| 久久99九九99精品| 国产乱人伦精品一区二区在线观看| 一本大道久久a久久综合| 欧美日韩国产首页在线观看| 久久久亚洲欧洲日产国码αv| 亚洲在线免费播放| 国产乱码精品一区二区三区忘忧草| 97精品久久久久中文字幕| 欧美日韩一区二区不卡| 日韩欧美一区二区不卡| 中文字幕一区在线观看| 日本不卡高清视频| 国产激情一区二区三区四区 | 亚洲精品久久嫩草网站秘色| 1024成人网| 国产精品1024| 欧美日韩精品一二三区| 国产精品美女久久久久久久久| 另类综合日韩欧美亚洲| 色综合 综合色| 久久日韩精品一区二区五区| 日韩电影在线看| 色欧美日韩亚洲| 国产午夜精品美女毛片视频| 极品美女销魂一区二区三区免费| 99免费精品在线| 欧美精品一区二区三区蜜桃| 日韩欧美在线不卡| 天天操天天干天天综合网| av电影天堂一区二区在线观看| 亚洲精品在线网站| 毛片av一区二区| 欧美日韩精品一区二区三区| 中文字幕一区二区三区视频| 成人小视频免费观看| 337p粉嫩大胆色噜噜噜噜亚洲| 天堂成人免费av电影一区| 在线视频欧美精品| 亚洲一卡二卡三卡四卡| 色婷婷久久99综合精品jk白丝 | 日韩精品在线网站| 日日夜夜精品视频天天综合网| 欧美日韩视频不卡| 日韩国产在线观看一区| 欧美性猛交xxxx黑人交| 一区二区三区电影在线播| 欧美曰成人黄网| 亚洲电影一区二区| 欧美一级片在线看| 免费人成网站在线观看欧美高清| 日韩视频一区二区在线观看| 久久99国产精品久久| 久久蜜桃av一区二区天堂| 成人美女视频在线看| 亚洲欧美日韩成人高清在线一区| 在线精品视频免费观看| 夜色激情一区二区| 欧美一区二区三区免费| 久久99最新地址| 国产精品乱人伦| 欧美私人免费视频| 男女性色大片免费观看一区二区 | 国产激情一区二区三区四区| 中日韩免费视频中文字幕| 日本道免费精品一区二区三区| 午夜免费欧美电影| 精品成a人在线观看| 91网站在线观看视频| 亚洲一区二区欧美|