亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
中文字幕在线观看不卡| 日本视频在线一区| 日本伊人色综合网| 不卡免费追剧大全电视剧网站| 91麻豆精品91久久久久久清纯| 中文字幕+乱码+中文字幕一区| 另类小说一区二区三区| 欧美人狂配大交3d怪物一区| 亚洲日本乱码在线观看| 国产精品中文字幕欧美| 日韩三级视频中文字幕| 亚洲成人免费在线| 91福利在线观看| 国产精品第四页| 成人h动漫精品一区二区| 精品国产污污免费网站入口| 日本不卡中文字幕| 欧美日韩中文字幕一区| 亚洲国产日日夜夜| 日本韩国视频一区二区| 亚洲美女在线一区| 91麻豆视频网站| 亚洲日本免费电影| 91亚洲精品久久久蜜桃| 17c精品麻豆一区二区免费| 成人avav在线| 亚洲欧美日韩一区二区三区在线观看 | 国产欧美视频在线观看| 久久国产精品免费| 精品久久久网站| 精品一区二区免费在线观看| 欧美成人video| 精品一区二区三区久久| 国产欧美日本一区视频| 成人黄色777网| 成人欧美一区二区三区白人| 91丨九色丨蝌蚪丨老版| 亚洲免费高清视频在线| 欧美色手机在线观看| 丝袜国产日韩另类美女| 日韩美女在线视频| 国产精品69毛片高清亚洲| 国产精品网站在线观看| 色菇凉天天综合网| 午夜激情一区二区三区| 精品国产123| 93久久精品日日躁夜夜躁欧美| 亚洲蜜桃精久久久久久久| 精品视频色一区| 国产一区美女在线| 亚洲嫩草精品久久| 制服丝袜中文字幕亚洲| 国精产品一区一区三区mba桃花 | 日韩黄色片在线观看| 精品成人一区二区三区四区| 不卡一区二区在线| 午夜国产精品一区| 国产亚洲短视频| 欧美性大战久久久| 国模套图日韩精品一区二区 | 在线免费观看不卡av| 午夜精品福利一区二区蜜股av| 精品精品国产高清一毛片一天堂| 成人av电影免费在线播放| 亚洲成人手机在线| 国产欧美精品在线观看| 欧洲日韩一区二区三区| 国产乱对白刺激视频不卡| 一区二区三区色| 久久免费美女视频| 欧美网站一区二区| 成人丝袜视频网| 奇米影视一区二区三区| 亚洲丝袜精品丝袜在线| 精品成人免费观看| 欧美日韩精品一区二区天天拍小说| 韩日欧美一区二区三区| 亚洲v日本v欧美v久久精品| 欧美国产精品一区| 日韩欧美一区二区三区在线| 91国偷自产一区二区三区成为亚洲经典 | 精品99久久久久久| 欧美日韩成人综合在线一区二区| 国产电影精品久久禁18| 男男成人高潮片免费网站| 一区二区三区成人| 国产蜜臀97一区二区三区| 日韩视频永久免费| 欧美午夜精品理论片a级按摩| 成人久久18免费网站麻豆| 老司机午夜精品| 视频一区中文字幕国产| 一区二区三区在线免费观看| 国产精品青草久久| 久久精品一区四区| 久久亚洲二区三区| 日韩小视频在线观看专区| 欧美日韩精品电影| 在线视频观看一区| 色香色香欲天天天影视综合网| 波多野结衣中文字幕一区二区三区| 久久99热99| 久久国产尿小便嘘嘘| 日韩福利电影在线观看| 午夜精品福利久久久| 首页欧美精品中文字幕| 日韩成人dvd| 丝袜亚洲另类欧美综合| 亚洲va国产va欧美va观看| 一区av在线播放| 亚洲国产成人av| 亚洲成人av电影| 日韩中文字幕亚洲一区二区va在线 | 精品国产一区二区国模嫣然| 精品久久久三级丝袜| 久久精品一区四区| 久久精品无码一区二区三区| 久久精品人人做人人爽97| 欧美国产一区二区| 亚洲欧美中日韩| 一区二区三区.www| 婷婷综合五月天| 久久99精品国产.久久久久久| 国产美女主播视频一区| 高清免费成人av| 色综合久久天天| 欧美日韩一区二区三区在线| 88在线观看91蜜桃国自产| 日韩精品一区二区三区视频| 久久久亚洲精品一区二区三区| 国产女主播一区| 亚洲欧美日韩精品久久久久| 亚洲一区免费观看| 麻豆精品视频在线观看免费| 国产成人精品亚洲午夜麻豆| 91欧美一区二区| 91精品国产全国免费观看 | 欧美精品视频www在线观看| 欧美一区二区三区四区高清| 国产婷婷色一区二区三区四区| 国产精品久久久久久久久搜平片| 亚洲精品国产品国语在线app| 青青草成人在线观看| 粉嫩一区二区三区性色av| 欧美自拍偷拍一区| www精品美女久久久tv| 亚洲男人的天堂在线观看| 日韩精品高清不卡| proumb性欧美在线观看| 欧美乱妇20p| 国产精品人妖ts系列视频| 亚洲成人自拍偷拍| 成人午夜免费视频| 56国语精品自产拍在线观看| 亚洲国产激情av| 日韩国产精品久久久| 成人国产精品免费观看| 欧美一区二区三区在| 亚洲精品久久久蜜桃| 国产麻豆9l精品三级站| 欧美日韩一级片在线观看| 日本一区二区三区久久久久久久久不 | 偷偷要91色婷婷| 91丨porny丨户外露出| 精品88久久久久88久久久| 午夜一区二区三区视频| 成人性生交大合| 日韩精品一区二区三区三区免费| 亚洲黄色av一区| 99热99精品| 国产精品私人自拍| 精品一二三四在线| 欧美一区二区三区的| 亚洲在线中文字幕| 成人av电影免费观看| 精品动漫一区二区三区在线观看| 一二三四社区欧美黄| 99久久精品国产导航| 国产精品嫩草99a| 国产成人夜色高潮福利影视| 精品日韩一区二区三区| 亚洲成人在线观看视频| 欧美伊人久久久久久久久影院| 国产精品国产三级国产aⅴ原创| 国产自产v一区二区三区c| 日韩亚洲欧美在线| 日本中文字幕一区| 欧美二区三区的天堂| 午夜久久久久久久久| 欧美日韩国产一区| 午夜欧美一区二区三区在线播放| 在线一区二区三区做爰视频网站| 综合久久综合久久| 99久久综合精品| 亚洲天堂网中文字| 91视视频在线直接观看在线看网页在线看 | 久久久久久久综合| 国产一区二区三区在线观看免费| 精品久久久久久久久久久久久久久久久 | 精品不卡在线视频|