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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? i2c.c

?? iar 安裝使用的方法。其中包括一些工程模板
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// i2c.c - Driver for Inter-IC (I2C) bus block.
//
// Copyright (c) 2005-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 i2c_api
//! @{
//
//*****************************************************************************

#include "../hw_i2c.h"
#include "../hw_ints.h"
#include "../hw_memmap.h"
#include "../hw_types.h"
#include "debug.h"
#include "i2c.h"
#include "interrupt.h"
#include "sysctl.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.
    //
    HWREG(ulBase + I2C_O_MIMR) = 1;
}

//*****************************************************************************
//
//! Enables the I2C Slave interrupt.
//!
//! \param ulBase is the base address of the I2C Slave module.
//!
//! Enables the I2C Slave interrupt source.
//!
//! \return None.
//
//*****************************************************************************
void
I2CSlaveIntEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_SLAVE_BASE) || (ulBase == I2C1_SLAVE_BASE));

    //
    // Enable the slave interrupt.
    //
    HWREG(ulBase + I2C_O_SIMR) = 1;
}

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

    //
    // Disable the master interrupt.
    //
    HWREG(ulBase + I2C_O_MIMR) = 0;
}

//*****************************************************************************
//
//! Disables the I2C Slave interrupt.
//!
//! \param ulBase is the base address of the I2C Slave module.
//!
//! Disables the I2C Slave interrupt source.
//!
//! \return None.
//
//*****************************************************************************
void
I2CSlaveIntDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_SLAVE_BASE) || (ulBase == I2C1_SLAVE_BASE));

    //
    // Disable the slave interrupt.
    //
    HWREG(ulBase + I2C_O_SIMR) = 0;
}

//*****************************************************************************
//
//! Gets the current I2C Master interrupt status.
//!
//! \param ulBase is the base address of the I2C Master module.
//! \param bMasked is false if the raw interrupt status is requested and
//! true if the masked interrupt status is requested.
//!
//! This returns the interrupt status for the I2C Master module.  Either the
//! raw interrupt status or the status of interrupts that are allowed to
//! reflect to the processor can be returned.
//!
//! \return The current interrupt status, returned as \b true if active
//! or \b false if not active.
//
//*****************************************************************************
tBoolean
I2CMasterIntStatus(unsigned long ulBase, tBoolean bMasked)
{
    //
    // Check the arguments.
    //
    ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE));

    //
    // Return either the interrupt status or the raw interrupt status as
    // requested.
    //

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
性做久久久久久久免费看| 日韩欧美在线观看一区二区三区| 亚洲一级二级三级| 欧美不卡123| 在线免费不卡视频| 国产乱妇无码大片在线观看| 亚洲精品成人精品456| 2023国产一二三区日本精品2022| 91免费在线看| 国产一区二区三区四区五区美女| 亚洲成人激情综合网| 国产午夜精品理论片a级大结局| 欧美日韩国产成人在线91| 东方aⅴ免费观看久久av| 日本sm残虐另类| 亚洲视频综合在线| 久久先锋资源网| 91久久免费观看| 成人精品小蝌蚪| 国产一区二区按摩在线观看| 三级影片在线观看欧美日韩一区二区| 国产精品国产精品国产专区不蜜| 日韩免费电影一区| 7777精品伊人久久久大香线蕉完整版 | 99久久精品久久久久久清纯| 久久66热偷产精品| 日本免费新一区视频| 亚洲不卡在线观看| 亚洲综合丁香婷婷六月香| 国产精品毛片久久久久久久| 国产性色一区二区| 久久久久国产一区二区三区四区 | 91久久奴性调教| 一本大道久久a久久精品综合| 成人免费看片app下载| 国内精品久久久久影院一蜜桃| 日本伊人精品一区二区三区观看方式| 亚洲永久精品大片| 一区二区三区免费看视频| 日韩码欧中文字| 亚洲三级理论片| 中文字幕亚洲区| 国产精品电影一区二区| 久久影音资源网| 精品国产sm最大网站| 91精品国产91久久久久久一区二区| 色综合天天综合给合国产| 成人激情免费视频| 国产suv一区二区三区88区| 高清成人在线观看| 99久久国产综合精品女不卡| www.欧美日韩国产在线| 国产.精品.日韩.另类.中文.在线.播放 | 成人av网址在线观看| 国产成人免费视频一区| 经典一区二区三区| 狠狠网亚洲精品| 国产精品自拍一区| 国产精品亚洲第一| 国产精品一级二级三级| 丁香婷婷综合激情五月色| 国产99久久久国产精品潘金| 成人h版在线观看| 成人黄色一级视频| 在线观看视频一区| 欧美一区二区三区性视频| 久久色.com| **欧美大码日韩| 天天爽夜夜爽夜夜爽精品视频| 夜夜嗨av一区二区三区网页| 亚洲综合小说图片| 天堂精品中文字幕在线| 日本不卡123| 国内精品伊人久久久久av影院| 国产精品1024| 成人a区在线观看| 欧美性猛交xxxx乱大交退制版| 欧美自拍偷拍午夜视频| 日韩精品最新网址| 国产精品久久久久国产精品日日| 亚洲国产精品久久不卡毛片| 国产自产高清不卡| 色综合欧美在线| 日韩精品影音先锋| 一区二区三区在线观看国产| 久久超级碰视频| 91精品办公室少妇高潮对白| 精品国产一区二区三区忘忧草| 国产精品第一页第二页第三页| 免费高清视频精品| 色哟哟日韩精品| 精品国产一区二区三区忘忧草 | 国产丝袜欧美中文另类| 亚洲一区在线电影| 国产99久久久国产精品| 欧美电影影音先锋| 日韩毛片精品高清免费| 国产一区二区三区高清播放| 欧美图片一区二区三区| 欧美国产日韩a欧美在线观看 | 国产伦精品一区二区三区视频青涩| 91国偷自产一区二区三区观看| 日韩免费视频一区| 亚洲高清久久久| av在线播放不卡| 精品国产91乱码一区二区三区 | 日本一区二区动态图| 免费欧美高清视频| 在线观看www91| 国产精品久久久久久久久免费樱桃 | 777xxx欧美| 亚洲精品视频自拍| 成人网在线免费视频| 日韩精品一区二区三区在线| 亚洲第一在线综合网站| 一本久久a久久免费精品不卡| 国产夜色精品一区二区av| 蜜臀av性久久久久蜜臀av麻豆| 欧美性videosxxxxx| 亚洲同性同志一二三专区| 国产成人综合在线播放| 精品国产免费人成电影在线观看四季| 亚洲国产美女搞黄色| 色欧美88888久久久久久影院| 中文久久乱码一区二区| 国产福利一区二区三区视频在线| 91精品国产综合久久香蕉的特点| 亚洲福利电影网| 欧美在线观看视频在线| 亚洲欧美国产77777| av电影在线观看一区| 亚洲国产电影在线观看| 国产成人在线电影| 国产亚洲综合性久久久影院| 久久精品国产一区二区三 | 亚洲bdsm女犯bdsm网站| 日本丰满少妇一区二区三区| 欧美高清在线视频| 精品一区二区三区av| 精品毛片乱码1区2区3区| 免费人成在线不卡| 精品福利av导航| 国产精选一区二区三区| 国产精品区一区二区三| 成人国产精品视频| 亚洲天堂免费在线观看视频| 91久久精品一区二区| 亚洲成人免费电影| 欧美一区二区三区爱爱| 久久99精品久久久| 国产偷国产偷精品高清尤物| 成人夜色视频网站在线观看| 国产精品久久午夜夜伦鲁鲁| 91小视频免费看| 亚洲丰满少妇videoshd| 欧美日本一道本在线视频| 美女国产一区二区| 久久久久99精品一区| 99久精品国产| 视频一区中文字幕国产| 欧美成人a∨高清免费观看| 国产成人综合亚洲网站| 亚洲综合在线五月| 日韩午夜在线观看| 国产成人免费在线视频| 一区二区三区久久久| 日韩一区二区在线看| 国产mv日韩mv欧美| 亚洲国产精品麻豆| 久久久噜噜噜久久人人看| 91在线播放网址| 亚洲精品水蜜桃| 日韩一区二区影院| 国产福利一区二区三区视频| 一区二区三区在线不卡| 精品日韩一区二区三区免费视频| 国产mv日韩mv欧美| 日韩制服丝袜av| 中文字幕欧美国产| 欧美丰满一区二区免费视频 | 欧美日韩亚洲另类| 国产成人午夜高潮毛片| 一区二区成人在线视频| 7777精品伊人久久久大香线蕉的 | 国产一区二区三区国产| 亚洲一卡二卡三卡四卡五卡| 久久这里都是精品| 欧美日韩视频一区二区| 国产91在线看| 美女脱光内衣内裤视频久久影院| 国产精品欧美久久久久一区二区 | 亚洲欧美日韩国产一区二区三区| 日韩三级高清在线| 91久久精品一区二区三| 国产盗摄女厕一区二区三区| 日日夜夜精品视频天天综合网| 亚洲国产高清aⅴ视频| 日韩欧美不卡一区| 欧美日韩午夜在线| bt7086福利一区国产|