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

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

?? i2c.c

?? 基于 Luminary Micro 公司的 Cortex-M3 (ARM)內核使用之 uC/OS-II 作業系統,此例程是移植于 LM3S310 上的應用,于 Keil MDK 工程編譯,而 uC/O
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// i2c.c - Driver for Inter-IC (I2C) bus block.
//
// Copyright (c) 2005,2006 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 Stellaris Family of 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 852 of the Stellaris 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 == I2C_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 == I2C_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 == I2C_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 == I2C_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 == I2C_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 == I2C_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))
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_MASTER_BASE);

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

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

//*****************************************************************************
//
//! 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)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_MASTER_BASE);

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

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

//*****************************************************************************
//
//! 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 == I2C_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 == I2C_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 == I2C_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 == I2C_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.
    //
    ASSERT(ulBase == I2C_MASTER_BASE);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人精品亚洲日本在线桃色| 久久综合九色综合97婷婷| 日韩精品中午字幕| 亚洲激情一二三区| 国产成人精品亚洲午夜麻豆| 欧美精品欧美精品系列| 亚洲欧洲成人精品av97| 久久97超碰色| 91精品国产综合久久久久久久久久| 日本一区免费视频| 久久成人18免费观看| 欧美喷潮久久久xxxxx| 亚洲欧美怡红院| 丰满岳乱妇一区二区三区| 欧美一区二区三区精品| 亚洲宅男天堂在线观看无病毒| 大陆成人av片| 久久久精品国产免费观看同学| 日韩在线一区二区三区| 欧美日韩在线观看一区二区 | 91久久线看在观草草青青| 国产亚洲欧美在线| 国产在线视频不卡二| 日韩精品一区二区三区老鸭窝| 日韩黄色小视频| 欧美一个色资源| 蜜臀99久久精品久久久久久软件| 欧美美女黄视频| 青青草国产成人99久久| 欧美一区二区三区视频免费播放| 五月婷婷激情综合网| 欧美一级夜夜爽| 精品无码三级在线观看视频 | 蜜桃一区二区三区在线| 色综合久久中文字幕综合网| 亚洲美女在线国产| 欧美午夜精品电影| 天天综合色天天综合色h| 欧美精品aⅴ在线视频| 日本伊人精品一区二区三区观看方式 | 欧美色精品在线视频| 午夜精品久久久久久久| 欧美一区二区三区在线看| 精品在线一区二区| 国产日产欧美一区| 91啦中文在线观看| 亚洲成人av一区| 日韩欧美你懂的| 成人精品在线视频观看| 一级做a爱片久久| 日韩视频不卡中文| 成人h动漫精品一区二区| 一区二区三区中文字幕电影| 91精品国产综合久久国产大片| 激情偷乱视频一区二区三区| 国产精品国产自产拍高清av| 色婷婷av一区二区三区gif | 亚洲福利视频一区| 精品日韩av一区二区| hitomi一区二区三区精品| 洋洋成人永久网站入口| 精品久久久久99| 91丝袜美女网| 久久福利资源站| 亚洲欧美综合在线精品| 日韩午夜激情av| 99久久精品免费看国产| 免费高清不卡av| 亚洲欧美一区二区不卡| 2024国产精品视频| 欧美午夜片在线观看| 国产69精品久久777的优势| 亚洲一区在线电影| 国产精品理论片在线观看| 欧美一级免费观看| 日本韩国精品一区二区在线观看| 久久97超碰色| 亚洲chinese男男1069| 国产精品久99| 久久嫩草精品久久久久| 91麻豆精品国产91久久久久| 91亚洲精品一区二区乱码| 国产一区日韩二区欧美三区| 图片区小说区国产精品视频| 日韩一区在线看| 国产亚洲精品超碰| 日韩精品一区二区三区蜜臀 | 另类专区欧美蜜桃臀第一页| 亚洲精品久久久久久国产精华液| 精品久久久久一区| 制服丝袜日韩国产| 在线观看日韩一区| 色婷婷狠狠综合| 99久久综合99久久综合网站| 国产精品99久久久久久久女警 | 午夜精品久久久久久久久久| 国产精品乱码人人做人人爱| 久久久www成人免费毛片麻豆| 日韩一区二区免费在线电影| 欧美日韩在线播放| 在线看日韩精品电影| 91首页免费视频| 91麻豆福利精品推荐| 不卡电影一区二区三区| 成人av中文字幕| 99久精品国产| 色综合天天综合网国产成人综合天 | 欧美中文字幕亚洲一区二区va在线| 福利电影一区二区三区| 国产成人自拍网| 国产福利一区二区三区视频| 国产精品自在欧美一区| 国产精品18久久久久| 国产一区 二区 三区一级| 国产美女精品人人做人人爽| 国产麻豆视频一区二区| 国产91对白在线观看九色| 成人动漫av在线| 在线视频国内一区二区| 精品视频在线视频| 日韩欧美一级二级三级| 久久婷婷一区二区三区| 国产精品欧美一级免费| 亚洲美女一区二区三区| 亚洲成人精品一区| 蜜桃精品在线观看| 国产精品小仙女| eeuss鲁片一区二区三区在线看| 91免费版在线看| 欧美群妇大交群中文字幕| 日韩欧美一区二区在线视频| 久久欧美中文字幕| 亚洲另类在线一区| 免费成人在线观看视频| 国产电影精品久久禁18| 91福利精品第一导航| 91精品国产免费| 国产精品欧美精品| 午夜欧美一区二区三区在线播放| 麻豆高清免费国产一区| 99久久综合色| 日韩女优毛片在线| 中文字幕中文字幕中文字幕亚洲无线| 一区二区三区在线看| 精品综合免费视频观看| 91视频免费看| 欧美一级夜夜爽| 日韩一区中文字幕| 日本强好片久久久久久aaa| 丁香六月综合激情| 欧美日韩国产综合草草| 欧美激情一二三区| 日本aⅴ精品一区二区三区| 粉嫩久久99精品久久久久久夜| 欧美日韩免费电影| 国产精品黄色在线观看| 精品写真视频在线观看| 欧美日韩国产综合视频在线观看| 久久精品夜色噜噜亚洲aⅴ| 午夜久久久影院| 不卡一区二区在线| 精品福利av导航| 日韩精品一区第一页| 91丝袜美女网| 国产丝袜欧美中文另类| 日本va欧美va瓶| 在线看国产日韩| 成人免费在线视频观看| 国产精品一区二区在线播放| 欧美巨大另类极品videosbest| 亚洲色图视频网站| 国产精品一卡二卡在线观看| 91麻豆精品国产91久久久久久久久 | 国产亚洲成av人在线观看导航| 日本大胆欧美人术艺术动态 | 午夜精彩视频在线观看不卡| 成人理论电影网| 欧美精品一区二| 久久激五月天综合精品| 欧美福利视频一区| 亚洲国产成人va在线观看天堂| 成人小视频免费在线观看| 久久午夜国产精品| 极品瑜伽女神91| 91精品国产日韩91久久久久久| 亚洲在线中文字幕| 91福利视频网站| 一区二区三区国产精华| 色婷婷激情一区二区三区| 亚洲天堂a在线| 色综合色狠狠天天综合色| 中文字幕在线免费不卡| 99精品欧美一区二区三区小说| 国产欧美一区二区精品仙草咪| 国产伦精一区二区三区| 精品久久久久久久人人人人传媒 | 欧美影院一区二区三区| 亚洲麻豆国产自偷在线| 在线视频一区二区三| 亚洲高清视频中文字幕|