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

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

?? i2c.c

?? 基于TI公司Cortex-M3的uart超級通信開發
?? C
?? 第 1 頁 / 共 3 頁
字號:
//*****************************************************************************
//
// i2c.c - Driver for Inter-IC (I2C) bus block.
//
// Copyright (c) 2005-2009 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 5228 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup i2c_api
//! @{
//
//*****************************************************************************

#include "inc/hw_i2c.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/i2c.h"
#include "driverlib/interrupt.h"

//*****************************************************************************
//
//! Initializes the I2C Master block.
//!
//! \param ulBase is the base address of the I2C Master module.
//! \param ulI2CClk is the rate of the clock supplied to the I2C module.
//! \param bFast set up for fast data transfers
//!
//! This function initializes operation of the I2C Master block.  Upon
//! successful initialization of the I2C block, this function will have set the
//! bus speed for the master, and will have enabled the I2C Master block.
//!
//! If the parameter \e bFast is \b true, then the master block will be set up
//! to transfer data at 400 kbps; otherwise, it will be set up to transfer data
//! at 100 kbps.
//!
//! The peripheral clock will be the same as the processor clock.  This will be
//! the value returned by SysCtlClockGet(), or it can be explicitly hard coded
//! if it is constant and known (to save the code/execution overhead of a call
//! to SysCtlClockGet()).
//!
//! This function replaces the original I2CMasterInit() API and performs the
//! same actions.  A macro is provided in <tt>i2c.h</tt> to map the original
//! API to this API.
//!
//! \return None.
//
//*****************************************************************************
void
I2CMasterInitExpClk(unsigned long ulBase, unsigned long ulI2CClk,
                    tBoolean bFast)
{
    unsigned long ulSCLFreq;
    unsigned long ulTPR;

    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Must enable the device before doing anything else.
    //
    I2CMasterEnable(ulBase);

    //
    // Get the desired SCL speed.
    //
    if(bFast == true)
    {
        ulSCLFreq = 400000;
    }
    else
    {
        ulSCLFreq = 100000;
    }

    //
    // Compute the clock divider that achieves the fastest speed less than or
    // equal to the desired speed.  The numerator is biased to favor a larger
    // clock divider so that the resulting clock is always less than or equal
    // to the desired clock, never greater.
    //
    ulTPR = ((ulI2CClk + (2 * 10 * ulSCLFreq) - 1) / (2 * 10 * ulSCLFreq)) - 1;
    HWREG(ulBase + I2C_O_MTPR) = ulTPR;
}

//*****************************************************************************
//
//! Initializes the I2C Slave block.
//!
//! \param ulBase is the base address of the I2C Slave module.
//! \param ucSlaveAddr 7-bit slave address
//!
//! This function initializes operation of the I2C Slave block.  Upon
//! successful initialization of the I2C blocks, this function will have set
//! the slave address and have enabled the I2C Slave block.
//!
//! The parameter \e ucSlaveAddr is the value that will be compared against the
//! slave address sent by an I2C master.
//!
//! \return None.
//
//*****************************************************************************
void
I2CSlaveInit(unsigned long ulBase, unsigned char ucSlaveAddr)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_SLAVE_BASE) || (ulBase == I2C1_SLAVE_BASE));
    ASSERT(!(ucSlaveAddr & 0x80));

    //
    // Must enable the device before doing anything else.
    //
    I2CSlaveEnable(ulBase);

    //
    // Set up the slave address.
    //
    HWREG(ulBase + I2C_O_SOAR) = ucSlaveAddr;
}

//*****************************************************************************
//
//! Enables the I2C Master block.
//!
//! \param ulBase is the base address of the I2C Master module.
//!
//! This will enable operation of the I2C Master block.
//!
//! \return None.
//
//*****************************************************************************
void
I2CMasterEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Enable the master block.
    //
    HWREG(ulBase + I2C_O_MCR) |= I2C_MCR_MFE;
}

//*****************************************************************************
//
//! Enables the I2C Slave block.
//!
//! \param ulBase is the base address of the I2C Slave module.
//!
//! This will enable operation of the I2C Slave block.
//!
//! \return None.
//
//*****************************************************************************
void
I2CSlaveEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_SLAVE_BASE) || (ulBase == I2C1_SLAVE_BASE));

    //
    // Enable the clock to the slave block.
    //
    HWREG(ulBase - I2C0_SLAVE_BASE + I2C0_MASTER_BASE + I2C_O_MCR) |=
        I2C_MCR_SFE;

    //
    // Enable the slave.
    //
    HWREG(ulBase + I2C_O_SCSR) = I2C_SCSR_DA;
}

//*****************************************************************************
//
//! Disables the I2C master block.
//!
//! \param ulBase is the base address of the I2C Master module.
//!
//! This will disable operation of the I2C master block.
//!
//! \return None.
//
//*****************************************************************************
void
I2CMasterDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Disable the master block.
    //
    HWREG(ulBase + I2C_O_MCR) &= ~(I2C_MCR_MFE);
}

//*****************************************************************************
//
//! Disables the I2C slave block.
//!
//! \param ulBase is the base address of the I2C Slave module.
//!
//! This will disable operation of the I2C slave block.
//!
//! \return None.
//
//*****************************************************************************
void
I2CSlaveDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_SLAVE_BASE) || (ulBase == I2C1_SLAVE_BASE));

    //
    // Disable the slave.
    //
    HWREG(ulBase + I2C_O_SCSR) = 0;

    //
    // Disable the clock to the slave block.
    //
    HWREG(ulBase - I2C0_SLAVE_BASE + I2C0_MASTER_BASE + I2C_O_MCR) &=
        ~(I2C_MCR_SFE);
}

//*****************************************************************************
//
//! Registers an interrupt handler for the I2C module.
//!
//! \param ulBase is the base address of the I2C Master module.
//! \param pfnHandler is a pointer to the function to be called when the
//! I2C interrupt occurs.
//!
//! This sets the handler to be called when an I2C interrupt occurs.  This will
//! enable the global interrupt in the interrupt controller; specific I2C
//! interrupts must be enabled via I2CMasterIntEnable() and
//! I2CSlaveIntEnable().  If necessary, it is the interrupt handler's
//! responsibility to clear the interrupt source via I2CMasterIntClear() and
//! I2CSlaveIntClear().
//!
//! \sa IntRegister() for important information about registering interrupt
//! handlers.
//!
//! \return None.
//
//*****************************************************************************
void
I2CIntRegister(unsigned long ulBase, void (*pfnHandler)(void))
{
    unsigned long ulInt;

    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Determine the interrupt number based on the I2C port.
    //
    ulInt = (ulBase == I2C0_MASTER_BASE) ? INT_I2C0 : INT_I2C1;

    //
    // Register the interrupt handler, returning an error if an error occurs.
    //
    IntRegister(ulInt, pfnHandler);

    //
    // Enable the I2C interrupt.
    //
    IntEnable(ulInt);
}

//*****************************************************************************
//
//! Unregisters an interrupt handler for the I2C module.
//!
//! \param ulBase is the base address of the I2C Master module.
//!
//! This function will clear the handler to be called when an I2C interrupt
//! occurs.  This will also mask off the interrupt in the interrupt controller
//! so that the interrupt handler no longer is called.
//!
//! \sa IntRegister() for important information about registering interrupt
//! handlers.
//!
//! \return None.
//
//*****************************************************************************
void
I2CIntUnregister(unsigned long ulBase)
{
    unsigned long ulInt;

    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Determine the interrupt number based on the I2C port.
    //
    ulInt = (ulBase == I2C0_MASTER_BASE) ? INT_I2C0 : INT_I2C1;

    //
    // Disable the interrupt.
    //
    IntDisable(ulInt);

    //
    // Unregister the interrupt handler.
    //
    IntUnregister(ulInt);
}

//*****************************************************************************
//
//! Enables the I2C Master interrupt.
//!
//! \param ulBase is the base address of the I2C Master module.
//!
//! Enables the I2C Master interrupt source.
//!
//! \return None.
//
//*****************************************************************************
void
I2CMasterIntEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Enable the master interrupt.
    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲h在线观看| 男女视频一区二区| 91精品久久久久久久99蜜桃| 国产一区日韩二区欧美三区| 亚洲美女屁股眼交3| 欧美xxxxx裸体时装秀| 色悠悠亚洲一区二区| 精品一区二区三区视频在线观看 | 国产精品传媒入口麻豆| 欧美日韩精品欧美日韩精品一| 国产老妇另类xxxxx| 亚洲高清视频中文字幕| 国产精品美女一区二区| 欧美成人激情免费网| 欧美性色黄大片| 成人午夜在线播放| 免费观看在线色综合| 亚洲国产综合人成综合网站| 中文字幕av一区二区三区免费看| 91精品国产一区二区人妖| 色噜噜狠狠成人网p站| 国产91在线观看| 国产一区二区在线视频| 日本不卡1234视频| 亚洲国产欧美另类丝袜| 亚洲欧美一区二区不卡| 国产精品私房写真福利视频| 精品日韩一区二区三区| 欧美日本在线播放| 欧美优质美女网站| 一本到一区二区三区| 9人人澡人人爽人人精品| 国产成人精品在线看| 精品一区二区国语对白| 美女一区二区视频| 五月婷婷激情综合| 亚洲一区二区三区中文字幕在线 | 麻豆精品在线播放| 五月婷婷久久丁香| 午夜久久福利影院| 午夜av电影一区| 青青草国产成人av片免费| 五月婷婷欧美视频| 蜜芽一区二区三区| 久国产精品韩国三级视频| 毛片一区二区三区| 美女高潮久久久| 国产精品一区二区三区四区| 国产米奇在线777精品观看| 国产麻豆精品视频| 国产精品77777| 丰满少妇久久久久久久| 国产suv精品一区二区883| 成人手机电影网| 99久久精品99国产精品| 一本大道久久a久久综合婷婷| 一本久道久久综合中文字幕| 精品视频全国免费看| 欧美一区二区免费视频| 精品国产乱码久久| 国产农村妇女精品| 亚洲欧美日韩中文字幕一区二区三区| 亚洲免费观看高清完整版在线观看熊 | 精品欧美乱码久久久久久1区2区| 日韩精品一区国产麻豆| 国产清纯在线一区二区www| 亚洲欧美综合色| 亚洲国产精品久久一线不卡| 婷婷综合五月天| 国产在线精品免费| 成人国产精品免费观看视频| 在线中文字幕不卡| 91精品国产欧美一区二区| 久久丝袜美腿综合| 亚洲人妖av一区二区| 亚洲不卡在线观看| 国内外成人在线| 91丨porny丨户外露出| 欧美一区二区在线播放| 欧美激情一区二区三区| 亚洲最新视频在线播放| 久久电影网站中文字幕| 成人aaaa免费全部观看| 678五月天丁香亚洲综合网| 精品国产三级电影在线观看| 日韩一区在线免费观看| 日本亚洲欧美天堂免费| 成人久久18免费网站麻豆| 欧美性大战xxxxx久久久| 精品国产91乱码一区二区三区| 亚洲视频一区在线| 五月天国产精品| 波多野结衣视频一区| 日韩欧美综合在线| 亚洲欧美激情视频在线观看一区二区三区| 日日夜夜精品视频免费| 成人午夜av电影| 日韩一本二本av| 亚洲人成网站影音先锋播放| 激情深爱一区二区| 欧美无砖砖区免费| 欧美激情一区三区| 秋霞影院一区二区| 91久久精品一区二区三区| 精品电影一区二区三区| 午夜视频久久久久久| 色婷婷综合久久久久中文一区二区| 精品伦理精品一区| 偷偷要91色婷婷| 91丨porny丨蝌蚪视频| 亚洲国产精品激情在线观看| 乱一区二区av| 欧美日韩www| 亚洲国产视频网站| 色视频一区二区| 国产精品欧美久久久久一区二区| 久久成人久久鬼色| 欧美一区二区女人| 丝袜脚交一区二区| 欧美一a一片一级一片| 亚洲图片激情小说| 成人亚洲一区二区一| 久久一夜天堂av一区二区三区| 无码av中文一区二区三区桃花岛| 欧美在线你懂得| 亚洲视频在线观看一区| av一二三不卡影片| 亚洲国产精品成人综合| 国产精品影视在线| 久久免费电影网| 国产一区二区影院| 精品国偷自产国产一区| 毛片av中文字幕一区二区| 欧美成人精品福利| 久久激情综合网| 亚洲精品在线一区二区| 国产在线精品不卡| 久久久国产一区二区三区四区小说 | 日韩欧美一区二区三区在线| 天天综合天天综合色| 欧美精品久久久久久久久老牛影院| 一区二区成人在线| 在线精品视频一区二区三四| 亚洲一区在线观看视频| 欧美三级在线播放| 婷婷久久综合九色综合伊人色| 欧美色男人天堂| 免费一级欧美片在线观看| 日韩一级欧美一级| 国产综合久久久久影院| 久久影院电视剧免费观看| 成人性生交大片免费看视频在线| 国产精品夫妻自拍| 色婷婷香蕉在线一区二区| 亚洲一线二线三线视频| 9191国产精品| 精品午夜久久福利影院| 26uuu成人网一区二区三区| 国产成人鲁色资源国产91色综| 国产精品国产自产拍高清av | 国产精品三级av在线播放| 99久免费精品视频在线观看| 亚洲欧美一区二区三区国产精品 | 国产99精品在线观看| 亚洲婷婷综合久久一本伊一区 | 欧美激情一二三区| 91在线观看成人| 婷婷久久综合九色综合伊人色| 欧美刺激午夜性久久久久久久| 国产精品一区二区三区网站| 中文字幕字幕中文在线中不卡视频| 欧美色视频一区| 国产精品一区二区久激情瑜伽| |精品福利一区二区三区| 欧美日韩三级在线| 国产高清不卡一区二区| 亚洲欧美视频一区| 精品国内二区三区| 色综合久久综合| 久久国产福利国产秒拍| 亚洲精品ww久久久久久p站| 91精品欧美一区二区三区综合在 | 久久久精品国产免大香伊| 色婷婷亚洲综合| 国产一区二区三区精品欧美日韩一区二区三区| 欧美激情在线一区二区| 6080国产精品一区二区| 不卡的av网站| 蜜臀av性久久久久蜜臀aⅴ流畅| 中文字幕在线不卡国产视频| 制服.丝袜.亚洲.中文.综合| 成人免费福利片| 美女被吸乳得到大胸91| 一区二区三区视频在线观看| 久久久久成人黄色影片| 91精品国产色综合久久| 色婷婷av久久久久久久| 风流少妇一区二区| 狠狠色丁香婷婷综合久久片| 亚洲综合精品久久|