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

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

?? i2c.c

?? lm3s6916上keil編譯的"hello world"程序
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
//*****************************************************************************
//
// 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.

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆国产精品视频| 国产成人午夜99999| 久久综合九色综合97_久久久 | 国产剧情一区二区| 怡红院av一区二区三区| 久久免费的精品国产v∧| 欧美熟乱第一页| 成人午夜伦理影院| 久久国产精品无码网站| 亚洲精品国产一区二区精华液 | 色综合久久精品| 久久99国产精品久久99果冻传媒| 亚洲日本在线天堂| 国产欧美视频一区二区三区| 91精选在线观看| 在线亚洲+欧美+日本专区| 粉嫩av亚洲一区二区图片| 精一区二区三区| 天天综合网 天天综合色| 亚洲欧美激情插| 国产精品久久免费看| 久久精品亚洲精品国产欧美| 日韩精品一区二区三区在线观看| 欧美日韩aaaaaa| 欧美伊人精品成人久久综合97| 成人精品免费视频| 国产乱码精品一区二区三区忘忧草 | 色婷婷综合在线| 成人精品视频.| 国产suv精品一区二区883| 紧缚奴在线一区二区三区| 日本亚洲天堂网| 日本不卡一区二区| 午夜精品123| 午夜精彩视频在线观看不卡| 亚洲一区二区三区影院| 一区二区三区鲁丝不卡| 亚洲激情网站免费观看| 一区二区三区四区激情| 亚洲欧美国产77777| 亚洲日本在线观看| 亚洲激情综合网| 一区二区三区免费| 亚洲综合区在线| 亚洲一区二区美女| 亚洲va欧美va国产va天堂影院| 一区二区成人在线| 亚洲一区二区三区自拍| 午夜精品一区二区三区免费视频| 亚洲va欧美va人人爽午夜| 午夜影视日本亚洲欧洲精品| 日韩电影在线观看一区| 青青草97国产精品免费观看 | 91视频在线观看| 在线观看亚洲精品| 欧美日韩二区三区| 日韩午夜电影av| 国产视频视频一区| 国产精品国产三级国产普通话99 | 欧美精品一区二区三区蜜桃视频| 337p日本欧洲亚洲大胆精品| 久久先锋影音av鲁色资源网| 国产女人水真多18毛片18精品视频| 欧美国产综合一区二区| 亚洲免费av在线| 污片在线观看一区二区 | 色综合久久88色综合天天免费| 色八戒一区二区三区| 制服视频三区第一页精品| 久久久久9999亚洲精品| 综合久久久久久久| 日韩精品久久久久久| 国产一区二区三区在线观看免费 | 欧美一区午夜视频在线观看| 2021国产精品久久精品| 亚洲丝袜自拍清纯另类| 视频一区视频二区在线观看| 久草这里只有精品视频| 99久久亚洲一区二区三区青草| 欧美日韩精品欧美日韩精品一综合| 日韩久久久精品| 日韩久久一区二区| 久久不见久久见免费视频7| 成人免费精品视频| 欧美日韩国产区一| 中文幕一区二区三区久久蜜桃| 艳妇臀荡乳欲伦亚洲一区| 久热成人在线视频| 91蜜桃免费观看视频| 欧美大白屁股肥臀xxxxxx| 中文字幕在线一区免费| 蜜臀99久久精品久久久久久软件| 成人av电影免费观看| 91精品国产91热久久久做人人 | 日本不卡在线视频| 91亚洲资源网| 久久亚洲私人国产精品va媚药| 亚洲一区二三区| 成人综合在线网站| 日韩欧美亚洲国产另类| 一区二区免费在线播放| 粗大黑人巨茎大战欧美成人| 777午夜精品免费视频| 亚洲九九爱视频| 国产精品香蕉一区二区三区| 欧美日韩视频不卡| 亚洲人成7777| 国产91丝袜在线18| 欧美成人性福生活免费看| 亚洲成精国产精品女| 不卡av免费在线观看| 久久一区二区三区国产精品| 日韩av一级电影| 欧美中文字幕一区二区三区亚洲| 国产精品女同一区二区三区| 国模一区二区三区白浆| 51午夜精品国产| 亚洲国产精品一区二区久久| 91视频一区二区三区| 国产精品欧美一区二区三区| 国产一区二区在线视频| 91精品国产手机| 日韩福利电影在线观看| 在线观看区一区二| 亚洲免费在线观看视频| 不卡的av在线播放| 亚洲国产精品成人久久综合一区| 国产一区二区伦理片| 亚洲精品一线二线三线无人区| 奇米四色…亚洲| 91精品在线免费观看| 香蕉久久夜色精品国产使用方法| 欧美手机在线视频| 亚洲午夜视频在线观看| 欧美色图激情小说| 性欧美疯狂xxxxbbbb| 欧美精品日韩精品| 日韩va亚洲va欧美va久久| 欧美精品久久天天躁| 免费观看久久久4p| 欧美mv和日韩mv的网站| 久久成人精品无人区| 久久色.com| 成人的网站免费观看| 中文字幕一区二区三区不卡在线 | 97精品国产露脸对白| 最近日韩中文字幕| 91久久精品一区二区三| 亚洲精品乱码久久久久| 欧美美女黄视频| 久久精品久久综合| 久久久久9999亚洲精品| av激情成人网| 亚洲一区二区欧美日韩| 欧美一级xxx| 国产精品 欧美精品| 亚洲欧美日本韩国| 91麻豆精品国产91久久久久| 精品中文字幕一区二区小辣椒| 久久青草国产手机看片福利盒子| 成人av电影在线观看| 亚洲一区二区免费视频| 日韩欧美国产不卡| jlzzjlzz亚洲女人18| 亚洲成人中文在线| 久久亚区不卡日本| 色综合一区二区| 日韩va欧美va亚洲va久久| 久久午夜国产精品| 91在线精品秘密一区二区| 午夜精品福利久久久| 久久色.com| 欧美视频一区二| 国产精品一区二区久久不卡| 亚洲色图一区二区| 欧美成人精品3d动漫h| 成人爽a毛片一区二区免费| 一区二区三区自拍| 精品国产乱码久久久久久闺蜜| 成人一区二区三区视频在线观看| 亚洲国产精品久久一线不卡| 久久人人超碰精品| 欧美在线免费观看亚洲| 国产精品自在在线| 亚洲一二三四在线| 久久久久久99精品| 欧美日韩精品三区| 丁香婷婷综合五月| 日韩高清不卡一区| 亚洲欧美另类小说| 精品国产一区二区三区忘忧草 | 国产在线麻豆精品观看| 亚洲色图在线看| 久久精品亚洲乱码伦伦中文| 欧美日韩一区二区在线观看| 国产成人在线视频免费播放| 日日摸夜夜添夜夜添精品视频| 国产精品每日更新| 久久影院电视剧免费观看| 欧美精品在欧美一区二区少妇|