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

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

?? i2c.c

?? lm3s6916上keil編譯的"hello world"程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// i2c.c - Driver for Inter-IC (I2C) bus block.
//
// Copyright (c) 2005-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 1234-conf 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 base address of the I2C Master 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 I2C clocking is dependent upon the system clock rate returned by
//! SysCtlClockGet(); if it does not return the correct system clock rate then
//! the I2C clock rate will be incorrect.
//!
//! \return None.
//
//*****************************************************************************
void
I2CMasterInit(unsigned long ulBase, tBoolean bFast)
{
    unsigned long ulSysClk;
    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 system clock speed.
    //
    ulSysClk = SysCtlClockGet();

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

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

//*****************************************************************************
//
//! Initializes the I2C Slave block.
//!
//! \param ulBase 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_SLAVE_O_OAR) = ucSlaveAddr;
}

//*****************************************************************************
//
//! Enables the I2C Master block.
//!
//! \param ulBase 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_MASTER_O_CR) |= I2C_MASTER_CR_MFE;
}

//*****************************************************************************
//
//! Enables the I2C Slave block.
//!
//! \param ulBase 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 - I2C_O_SLAVE + I2C_MASTER_O_CR) |= I2C_MASTER_CR_SFE;

    //
    // Enable the slave.
    //
    HWREG(ulBase + I2C_SLAVE_O_CSR) = I2C_SLAVE_CSR_DA;
}

//*****************************************************************************
//
//! Disables the I2C master block.
//!
//! \param ulBase 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_MASTER_O_CR) &= ~(I2C_MASTER_CR_MFE);
}

//*****************************************************************************
//
//! Disables the I2C slave block.
//!
//! \param ulBase 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_SLAVE_O_CSR) = 0;

    //
    // Disable the clock to the slave block.
    //
    HWREG(ulBase - I2C_O_SLAVE + I2C_MASTER_O_CR) &= ~(I2C_MASTER_CR_SFE);
}

//*****************************************************************************
//
//! Registers an interrupt handler for the I2C module
//!
//! \param ulBase base address of the I2C module
//! \param pfnHandler is a pointer to the function to be called when the
//! synchronous serial interface 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 base address of the I2C 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 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_MASTER_O_IMR) = 1;
}

//*****************************************************************************
//
//! Enables the I2C Slave interrupt.
//!
//! \param ulBase 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_SLAVE_O_IM) = 1;
}

//*****************************************************************************
//
//! Disables the I2C Master interrupt.
//!
//! \param ulBase 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_MASTER_O_IMR) = 0;
}

//*****************************************************************************
//
//! Disables the I2C Slave interrupt.
//!
//! \param ulBase 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_SLAVE_O_IM) = 0;
}

//*****************************************************************************
//
//! Gets the current I2C Master interrupt status.
//!
//! \param ulBase 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.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久电影| 亚洲成人自拍偷拍| 色8久久人人97超碰香蕉987| 亚洲第一主播视频| 中文字幕一区二区三区在线不卡| 欧美老人xxxx18| 不卡欧美aaaaa| 精品一区二区久久久| 亚洲欧美日韩电影| 国产亚洲成av人在线观看导航| 欧美日本视频在线| 成人激情图片网| 国内精品伊人久久久久影院对白| 亚洲综合在线免费观看| 国产丝袜美腿一区二区三区| 欧美一级高清片| 欧美日韩国产区一| 91久久精品国产91性色tv| 国产一区二区三区黄视频| 日本伊人色综合网| 一区二区三区欧美视频| 亚洲同性gay激情无套| 国产欧美视频一区二区| 欧美成人video| 欧美三级电影在线看| 91亚洲精品久久久蜜桃| 欧美精品乱码久久久久久| 色综合视频在线观看| 不卡av免费在线观看| 国产91高潮流白浆在线麻豆| 久久91精品久久久久久秒播| 免费在线欧美视频| 日日摸夜夜添夜夜添亚洲女人| 一区二区三区高清| 一区二区高清视频在线观看| 亚洲欧美激情插| 亚洲福利一二三区| 91麻豆精品91久久久久同性| 国产成人福利片| 久久九九久久九九| 国产麻豆一精品一av一免费| 日韩免费福利电影在线观看| 九色综合狠狠综合久久| 亚洲精选一二三| 日韩欧美在线网站| 欧美在线观看视频在线| 久久超碰97中文字幕| 欧美日韩亚洲综合| 一区二区三区免费在线观看| 欧美日韩日日夜夜| 国产精品正在播放| 美国毛片一区二区| 奇米777欧美一区二区| 国产人伦精品一区二区| 亚洲va欧美va人人爽| 久久久美女艺术照精彩视频福利播放| 亚洲bt欧美bt精品| 精品成人一区二区| 久久精品国产99国产| 久久久一区二区三区捆绑**| 欧美一区午夜精品| 欧美剧情片在线观看| 色综合视频一区二区三区高清| 国产盗摄精品一区二区三区在线| 久久99精品久久久久| 国产成人三级在线观看| 五月天丁香久久| 国产999精品久久久久久绿帽| 亚洲精品一线二线三线无人区| 91蝌蚪porny| 欧美日韩午夜在线| 精品久久国产字幕高潮| 国产精品国产自产拍高清av| 亚洲一区在线观看视频| 久热成人在线视频| 国产老肥熟一区二区三区| 91麻豆国产精品久久| 日韩欧美一级在线播放| 国产精品美女久久久久久久久| 亚洲国产精品视频| 国产美女一区二区三区| 日本韩国欧美三级| 久久亚洲一区二区三区四区| 中文字幕一区二区不卡| 日本不卡一区二区三区| 不卡的av中国片| 91精品国产综合久久久蜜臀粉嫩 | 一个色综合网站| 蜜臀av一级做a爰片久久| 成年人网站91| 日韩精品一区二区三区中文精品| 欧美国产成人精品| 日韩1区2区日韩1区2区| 99久久久精品免费观看国产蜜| 日韩亚洲欧美高清| 亚洲欧洲三级电影| 激情小说欧美图片| 欧美三区免费完整视频在线观看| 午夜视频在线观看一区二区三区| 日韩中文字幕av电影| 在线电影一区二区三区| 国产精品网站在线播放| 麻豆精品一区二区综合av| 欧美性受xxxx| 国产精品毛片大码女人| 捆绑变态av一区二区三区| 91视频一区二区| 欧美国产精品中文字幕| 久热成人在线视频| 欧美日韩美少妇| 在线看国产一区| 中文字幕一区免费在线观看| 国产一区欧美一区| 日韩一区二区免费高清| 亚洲午夜在线视频| 色婷婷久久99综合精品jk白丝| 国产拍揄自揄精品视频麻豆| 久久精品二区亚洲w码| 欧美日韩一区三区四区| 国产欧美一区二区精品性| 成人动漫一区二区| 亚瑟在线精品视频| 日韩欧美一卡二卡| 国产精品夜夜嗨| 中文字幕av一区二区三区高| 欧美性猛交一区二区三区精品| a美女胸又www黄视频久久| 欧美日韩视频在线一区二区 | 91美女精品福利| 国产美女主播视频一区| 国产日韩欧美综合在线| 岛国一区二区在线观看| 中文字幕一区二区三区在线播放| 成人av在线影院| 秋霞av亚洲一区二区三| 日韩欧美在线综合网| 国产.欧美.日韩| 国产欧美日韩在线观看| 99久久久无码国产精品| 日本大胆欧美人术艺术动态| 中文字幕制服丝袜成人av| www.在线成人| 欧美日韩一区二区三区在线| 亚洲国产精品欧美一二99| 欧美日韩中文国产| 美女免费视频一区| 亚洲精品一区二区在线观看| 国产精品18久久久久久vr| 久久综合资源网| www.色精品| 视频一区国产视频| 欧美大尺度电影在线| 国产成人亚洲综合色影视| 国产精品久久久久影院老司 | 国产成人免费视频网站 | 伊人性伊人情综合网| 五月综合激情日本mⅴ| 美女任你摸久久| 成人免费高清视频| 亚洲视频一区在线观看| 在线观看视频一区二区欧美日韩| 亚洲欧美一区二区三区极速播放| 不卡的电视剧免费网站有什么| 国产精品欧美久久久久一区二区| 成人久久视频在线观看| 久久久噜噜噜久噜久久综合| 97精品视频在线观看自产线路二| 综合婷婷亚洲小说| 欧美视频一二三区| 在线成人免费视频| 91在线观看污| 国产精品亚洲成人| 日韩不卡手机在线v区| 日韩高清在线一区| 久久久久久电影| 欧美精品欧美精品系列| 日韩欧美综合一区| 日韩欧美国产小视频| 亚洲大型综合色站| 欧美综合一区二区三区| 亚洲国产另类精品专区| 久久免费的精品国产v∧| 欧美在线一二三| 亚洲一区二区精品久久av| 欧美一区二区在线看| 不卡大黄网站免费看| 亚洲高清在线视频| 久久夜色精品国产噜噜av| 国产一区三区三区| 香蕉乱码成人久久天堂爱免费| 欧美一区二区在线看| 国产成人午夜精品影院观看视频 | 亚洲午夜久久久久久久久电影网 | 久久久亚洲国产美女国产盗摄| 成人动漫在线一区| 亚洲一二三四在线| 中文字幕二三区不卡| 欧美日韩综合在线| 丰满少妇在线播放bd日韩电影| 亚洲免费在线观看视频|