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

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

?? 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.
    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人综合婷婷国产精品久久蜜臀| 日韩你懂的在线播放| 亚洲久草在线视频| 欧美精品乱码久久久久久 | 久久中文字幕电影| 成人国产精品视频| 久久精品72免费观看| 亚洲资源在线观看| av电影一区二区| 国产福利精品一区二区| 香蕉av福利精品导航| 亚洲综合视频在线观看| 国产精品免费视频观看| 精品奇米国产一区二区三区| 欧美精品乱码久久久久久按摩 | 国产精品亚洲第一区在线暖暖韩国 | 精品国精品国产尤物美女| 欧美视频一区二| 在线精品视频小说1| 国产aⅴ综合色| 国产剧情一区在线| 美女网站色91| 蜜桃视频在线观看一区二区| 亚洲电影欧美电影有声小说| 亚洲国产精品精华液网站| 亚洲va国产va欧美va观看| 亚洲一区影音先锋| 一区二区三区精品在线| 亚洲国产一二三| 日韩黄色免费电影| 亚洲欧美激情视频在线观看一区二区三区 | 色婷婷精品久久二区二区蜜臂av| 国产激情精品久久久第一区二区| 美女视频免费一区| 国产美女视频一区| 成人久久视频在线观看| av一区二区三区在线| 99国产精品国产精品毛片| 91一区在线观看| 欧美影院精品一区| 日韩女同互慰一区二区| 成人97人人超碰人人99| 日韩免费观看高清完整版| 91福利在线免费观看| 色综合久久中文字幕| 欧美三级乱人伦电影| 欧美日韩国产乱码电影| 欧美丝袜丝nylons| 日韩欧美亚洲国产精品字幕久久久 | 国产成人免费网站| 国产高清亚洲一区| 在线免费观看日韩欧美| 欧美精品久久99| 久久精品人人做| 亚洲乱码一区二区三区在线观看| 免费成人你懂的| 91在线视频免费91| 日韩一级片在线观看| 国产成人免费xxxxxxxx| 国产在线精品国自产拍免费| 国产综合一区二区| 国产毛片精品国产一区二区三区| 成人va在线观看| 精品免费视频.| 成年人午夜久久久| 看电影不卡的网站| 日韩欧美一区在线| 色综合一区二区三区| 国产精品白丝jk白祙喷水网站| 爽好久久久欧美精品| 亚洲日本va在线观看| 国产午夜一区二区三区| 欧美成人精品高清在线播放| 欧美男人的天堂一二区| 在线欧美小视频| 亚洲三级电影全部在线观看高清| 五月激情六月综合| 92国产精品观看| 久久蜜桃av一区精品变态类天堂| 亚洲激情五月婷婷| 不卡欧美aaaaa| 欧美一区二区三区在线电影 | 国产精品综合av一区二区国产馆| 色婷婷综合久久| 国产精品视频你懂的| 日本不卡视频一二三区| 日韩一区二区免费在线电影| 亚洲午夜av在线| 色综合久久综合网欧美综合网 | 91官网在线免费观看| 国产日产欧产精品推荐色 | 久久激情五月激情| 7777精品伊人久久久大香线蕉的| 亚洲国产成人porn| 在线一区二区视频| 亚洲一区二区精品3399| 国产精品456露脸| 亚洲欧美电影院| 99re亚洲国产精品| 欧美图区在线视频| 国产精品乱人伦中文| 国产成人av一区二区三区在线| 中文字幕中文在线不卡住| 欧美精品一区二区三区很污很色的| 欧洲精品一区二区| 午夜激情久久久| 天堂va蜜桃一区二区三区| 性久久久久久久久久久久| 亚洲成在人线免费| 午夜亚洲福利老司机| 日韩电影在线观看一区| 男男gaygay亚洲| 久久91精品国产91久久小草| 狠狠色丁香久久婷婷综| 国产成人精品一区二区三区网站观看| 国产精品一区二区黑丝| 不卡的电视剧免费网站有什么| 久久精品亚洲麻豆av一区二区| 国产成人在线观看免费网站| 亚洲日本一区二区| 欧美精选在线播放| 一区二区三区丝袜| 欧美一区二区福利在线| 国产一区二区免费在线| 国产精品乱码妇女bbbb| 欧美午夜寂寞影院| 91视频在线看| 欧美性色黄大片| 亚洲人成伊人成综合网小说| 在线成人高清不卡| 日韩一区二区影院| 精品国产电影一区二区| 国产精品三级电影| 亚洲三级在线免费| 亚洲成av人片一区二区梦乃| 蜜臀99久久精品久久久久久软件| 狠狠网亚洲精品| 成人免费视频一区| 欧美视频在线不卡| 亚洲精品在线一区二区| 最新成人av在线| 亚洲午夜久久久久中文字幕久| 日韩国产成人精品| 国产成人啪午夜精品网站男同| 色婷婷久久久综合中文字幕| 8x8x8国产精品| 久久久久久麻豆| 一区二区三区四区在线播放| 免费在线看成人av| av一区二区久久| 欧美片网站yy| 亚洲国产电影在线观看| 亚洲丰满少妇videoshd| 国产一区二区调教| 91猫先生在线| 日韩女优av电影| 日韩午夜电影av| 欧美视频一区二区三区在线观看 | 欧美日韩高清在线| 91在线视频18| 成人一级片在线观看| 精品中文av资源站在线观看| 日产精品久久久久久久性色| 亚洲综合在线观看视频| 亚洲三级免费电影| 韩国av一区二区三区四区| 欧美aaa在线| 青青国产91久久久久久| 国产精品成人午夜| 日韩国产精品久久| 99久久国产综合色|国产精品| 欧洲亚洲国产日韩| 欧美大片顶级少妇| 久久蜜桃香蕉精品一区二区三区| 亚洲女性喷水在线观看一区| 久久精品国产一区二区三区免费看 | 国产一区二区在线观看视频| 日韩一级黄色大片| 日韩在线观看一区二区| 99热精品一区二区| 欧美激情一区二区三区在线| 国产盗摄一区二区| 国产欧美精品一区二区色综合朱莉| 国产一区二区三区久久久| 日韩欧美一区电影| 老司机精品视频线观看86| 日韩欧美在线综合网| 奇米一区二区三区| 欧美不卡在线视频| 美女视频黄频大全不卡视频在线播放| 欧美精品xxxxbbbb| 亚洲观看高清完整版在线观看| 在线亚洲一区观看| 亚洲一级二级三级在线免费观看| 在线精品视频免费观看| 一区二区免费在线播放| 欧美在线视频不卡| 午夜国产精品一区| 91麻豆精品国产91久久久更新时间| 日韩制服丝袜先锋影音|