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

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

?? i2c.c

?? 基于 Cortex-M3 (ARM) 內核使用之 uC/OS-II 作業系統,此例程可移植于 Cortex-M3 (ARM)內核的微處理器上的應用,于 Keil MDK 3.15b以上 工程編譯,而
?? 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一区二区三区免费野_久草精品视频
日韩一区二区免费在线电影| 精品少妇一区二区三区在线播放| 日韩黄色在线观看| 国产精品区一区二区三区| 欧美日韩精品是欧美日韩精品| 国产精品一区二区男女羞羞无遮挡 | 国产精品一区一区| 亚洲第四色夜色| 亚洲美女精品一区| 久久久综合视频| 宅男在线国产精品| 日本韩国一区二区三区视频| 国产毛片精品视频| 日韩av电影天堂| 亚洲影院免费观看| 国产精品国产馆在线真实露脸| 欧美久久久久久久久久| 一本一道综合狠狠老| 成人一级黄色片| 国产一区二区免费视频| 日本欧美加勒比视频| 亚洲一二三区在线观看| 亚洲精品一二三四区| 国产精品久久久久久久久免费桃花 | 国产一区二区在线视频| 日韩福利视频网| 亚洲第一综合色| 亚洲最新视频在线观看| 亚洲另类在线视频| 国产精品久久久久久久第一福利| 久久久久久影视| 久久天堂av综合合色蜜桃网| 久久亚洲春色中文字幕久久久| 日韩免费视频一区二区| 日韩欧美区一区二| 精品国产亚洲一区二区三区在线观看| 91精品视频网| 日韩欧美美女一区二区三区| 欧美一级淫片007| 精品久久久久久久人人人人传媒| 久久综合久久99| 久久久久久夜精品精品免费| 2023国产精品视频| 久久精品一区二区三区不卡牛牛| 久久午夜色播影院免费高清| 久久蜜桃香蕉精品一区二区三区| 久久这里只有精品首页| 欧美国产一区二区在线观看| 国产精品久久777777| 亚洲视频一二区| 亚洲一区二区三区视频在线| 日韩高清不卡一区二区三区| 久草中文综合在线| 国产成人在线网站| 91免费看片在线观看| 欧美在线不卡一区| 日韩三级伦理片妻子的秘密按摩| 精品国产制服丝袜高跟| 国产精品久久久久一区 | 亚洲国产精华液网站w| 亚洲欧美影音先锋| 亚洲亚洲人成综合网络| 久久国产生活片100| 成人免费毛片aaaaa**| 色婷婷亚洲精品| 欧美一区二区三区四区久久| 久久青草欧美一区二区三区| 亚洲欧美在线视频| 石原莉奈在线亚洲三区| 国产伦精一区二区三区| 91在线国内视频| 777a∨成人精品桃花网| 国产视频一区在线播放| 亚洲卡通动漫在线| 麻豆视频观看网址久久| 成人免费高清视频在线观看| 日本福利一区二区| 精品剧情在线观看| 亚洲欧美日韩在线| 精品亚洲免费视频| 色综合久久中文字幕综合网| 日韩三级视频中文字幕| 亚洲欧美一区二区三区孕妇| 美女在线视频一区| 91色九色蝌蚪| 久久色在线观看| 亚洲高清不卡在线| 福利视频网站一区二区三区| 欧美日韩国产精选| 日本一区二区成人在线| 青青草原综合久久大伊人精品优势| 不卡在线视频中文字幕| 日韩欧美国产wwwww| 亚洲精品视频在线观看网站| 韩国精品在线观看| 精品视频免费在线| 国产精品福利在线播放| 蓝色福利精品导航| 欧美精品免费视频| 亚洲人吸女人奶水| 国产成人精品网址| 欧美tickling挠脚心丨vk| 亚洲国产一二三| 色哟哟精品一区| 亚洲国产精品ⅴa在线观看| 美洲天堂一区二卡三卡四卡视频| 91麻豆国产福利在线观看| 久久久久久亚洲综合| 奇米一区二区三区| 欧美日韩一区二区在线观看| 亚洲欧洲日韩综合一区二区| 国产精品主播直播| 精品国产伦一区二区三区免费| 亚洲va天堂va国产va久| 色中色一区二区| 亚洲色图欧美偷拍| av高清久久久| 国产精品乱码久久久久久| 国产剧情一区二区三区| 日韩午夜在线影院| 日本不卡一区二区| 欧美日韩国产成人在线91| 亚洲精品成人天堂一二三| 99精品在线免费| 亚洲婷婷综合色高清在线| 粉嫩蜜臀av国产精品网站| 久久久久久亚洲综合| 国产毛片一区二区| 久久九九久久九九| 成人午夜电影小说| 国产精品萝li| 91蜜桃视频在线| 亚洲精品欧美激情| 欧美三区免费完整视频在线观看| 一级日本不卡的影视| 在线免费精品视频| 亚洲第一搞黄网站| 欧美一卡在线观看| 国产一区二区三区观看| 久久久久9999亚洲精品| 成人一区二区三区视频在线观看| 欧美韩国日本不卡| 91福利国产成人精品照片| 亚洲国产精品一区二区www| 欧美日韩国产123区| 热久久国产精品| 久久只精品国产| 波波电影院一区二区三区| 成人欧美一区二区三区小说| 91看片淫黄大片一级| 亚洲午夜精品在线| 欧美白人最猛性xxxxx69交| 国产乱理伦片在线观看夜一区| 国产精品久线观看视频| 91网站最新地址| 天天综合日日夜夜精品| 精品精品国产高清a毛片牛牛| 国产91色综合久久免费分享| 亚洲欧美自拍偷拍色图| 欧美日韩国产一级| 精品一区二区三区在线视频| 国产日产精品1区| 99免费精品在线| 日韩精品免费视频人成| 久久久久久免费| 91极品美女在线| 蜜臀久久久99精品久久久久久| 久久久午夜精品理论片中文字幕| 97久久精品人人做人人爽50路| 亚洲午夜精品在线| 久久久久青草大香线综合精品| 91麻豆swag| 麻豆精品久久久| 亚洲伦理在线免费看| 精品久久国产字幕高潮| 99麻豆久久久国产精品免费优播| 亚洲超丰满肉感bbw| 久久久欧美精品sm网站| 欧美日韩精品一区视频| 国产999精品久久久久久绿帽| 亚洲午夜精品17c| 中文字幕欧美三区| 91精品欧美久久久久久动漫| 成人综合日日夜夜| 天天影视色香欲综合网老头| 国产精品乱人伦| 欧美xxxx老人做受| 在线观看免费一区| 成人精品视频网站| 久久99国产精品免费网站| 伊人一区二区三区| 国产午夜精品一区二区三区嫩草| 欧美日本免费一区二区三区| 国产91丝袜在线播放0| 蜜臀99久久精品久久久久久软件| 亚洲激情av在线| 中文字幕第一区二区| 欧美哺乳videos| 91精品久久久久久久91蜜桃| 91亚洲国产成人精品一区二三|