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

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

?? i2c.c

?? This is the free RTOS on PIC24.
?? 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 991 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.
//
//*****************************************************************************
#if defined(GROUP_masterinit) || defined(BUILD_ALL) || defined(DOXYGEN)
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;
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_slaveinit) || defined(BUILD_ALL) || defined(DOXYGEN)
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;
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_masterenable) || defined(BUILD_ALL) || defined(DOXYGEN)
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;
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_slaveenable) || defined(BUILD_ALL) || defined(DOXYGEN)
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;
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_masterdisable) || defined(BUILD_ALL) || defined(DOXYGEN)
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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_slavedisable) || defined(BUILD_ALL) || defined(DOXYGEN)
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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_intregister) || defined(BUILD_ALL) || defined(DOXYGEN)
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);
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_intunregister) || defined(BUILD_ALL) || defined(DOXYGEN)
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);
}
#endif

//*****************************************************************************
//
//! Enables the I2C Master interrupt.
//!
//! \param ulBase base address of the I2C Master module
//!
//! Enables the I2C Master interrupt source.
//!
//! \return None.
//
//*****************************************************************************
#if defined(GROUP_masterintenable) || defined(BUILD_ALL) || defined(DOXYGEN)
void
I2CMasterIntEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_MASTER_BASE);

    //
    // Enable the master interrupt.
    //
    HWREG(ulBase + I2C_MASTER_O_IMR) = 1;
}
#endif

//*****************************************************************************
//
//! Enables the I2C Slave interrupt.
//!
//! \param ulBase base address of the I2C Slave module
//!
//! Enables the I2C Slave interrupt source.
//!
//! \return None.
//
//*****************************************************************************
#if defined(GROUP_slaveintenable) || defined(BUILD_ALL) || defined(DOXYGEN)
void
I2CSlaveIntEnable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_SLAVE_BASE);

    //
    // Enable the slave interrupt.
    //
    HWREG(ulBase + I2C_SLAVE_O_IM) = 1;
}
#endif

//*****************************************************************************
//
//! Disables the I2C Master interrupt.
//!
//! \param ulBase base address of the I2C Master module
//!
//! Disables the I2C Master interrupt source.
//!
//! \return None.
//
//*****************************************************************************
#if defined(GROUP_masterintdisable) || defined(BUILD_ALL) || defined(DOXYGEN)
void
I2CMasterIntDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_MASTER_BASE);

    //
    // Disable the master interrupt.
    //
    HWREG(ulBase + I2C_MASTER_O_IMR) = 0;
}
#endif

//*****************************************************************************
//
//! Disables the I2C Slave interrupt.
//!
//! \param ulBase base address of the I2C Slave module
//!
//! Disables the I2C Slave interrupt source.
//!
//! \return None.
//
//*****************************************************************************
#if defined(GROUP_slaveintdisable) || defined(BUILD_ALL) || defined(DOXYGEN)
void
I2CSlaveIntDisable(unsigned long ulBase)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_SLAVE_BASE);

    //
    // Disable the slave interrupt.
    //
    HWREG(ulBase + I2C_SLAVE_O_IM) = 0;
}
#endif

//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
#if defined(GROUP_masterintstatus) || defined(BUILD_ALL) || defined(DOXYGEN)
tBoolean
I2CMasterIntStatus(unsigned long ulBase, tBoolean bMasked)
{
    //
    // Check the arguments.
    //
    ASSERT(ulBase == I2C_MASTER_BASE);

    //
    // Return either the interrupt status or the raw interrupt status as
    // requested.
    //
    if(bMasked)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品水嫩水嫩| caoporm超碰国产精品| 亚洲成人免费看| 亚洲国产欧美日韩另类综合 | 日韩精品电影一区亚洲| 国产精品69毛片高清亚洲| 成人av资源下载| 91精品欧美福利在线观看 | 精品精品国产高清a毛片牛牛 | 国产精品久线观看视频| 亚洲va欧美va人人爽午夜| 欧美日韩一区二区三区视频| 欧美一级免费大片| 91麻豆精品国产综合久久久久久 | 久久国产免费看| 成人av第一页| 亚洲最大成人网4388xx| 国产精品白丝av| 亚洲欧洲成人精品av97| 高清不卡一区二区在线| 日韩欧美国产一区在线观看| 中文字幕人成不卡一区| 色婷婷精品大在线视频| 久久综合狠狠综合久久激情| 亚洲高清视频中文字幕| 欧美成人一区二区三区在线观看| 亚洲动漫第一页| 日韩精品专区在线影院重磅| 成人午夜在线视频| 国产精品久久久久久久裸模| 欧美日韩一区中文字幕| 国产精品一区在线观看你懂的| 亚洲三级视频在线观看| 色婷婷综合视频在线观看| 免费高清在线一区| 欧美大胆一级视频| 99国产精品久久久久久久久久 | 91精品欧美综合在线观看最新 | 欧美日韩免费观看一区二区三区| 国产欧美一区二区三区在线看蜜臀| 污片在线观看一区二区| 欧美午夜精品理论片a级按摩| 最新成人av在线| 欧美一区二区黄| 91蝌蚪国产九色| 一区二区三区在线高清| 久久网这里都是精品| 欧美日韩美女一区二区| 99久久久无码国产精品| 国产一区二区免费看| 国产丝袜欧美中文另类| 成人精品免费视频| 麻豆久久久久久| 国产精品日韩成人| 久久综合色综合88| 欧美日韩一区二区欧美激情| 波多野结衣91| 国产一区二区三区香蕉| 麻豆成人久久精品二区三区小说| 一区二区三区 在线观看视频| 国产精品欧美一区二区三区| 久久影音资源网| 91麻豆精品国产91| 欧美猛男男办公室激情| 欧美日韩成人一区| 精品视频一区 二区 三区| 91视频一区二区三区| 99re亚洲国产精品| 高清久久久久久| 国产成人av影院| 1区2区3区欧美| 国产精品久久久久四虎| 国产精品免费观看视频| 国产精品国产三级国产三级人妇 | 91视频一区二区三区| 国产精品456| 国产精品自拍一区| 国产精品伊人色| 国产高清不卡一区二区| 国产精品一区免费视频| 成人性视频免费网站| 成人免费视频免费观看| 成人精品一区二区三区四区| 成人a免费在线看| 成人精品免费网站| 日本黄色一区二区| 国产精品888| 成人黄色软件下载| 91麻豆国产福利在线观看| 91免费视频网| 欧美日韩一区二区三区在线| 日韩一卡二卡三卡| 精品噜噜噜噜久久久久久久久试看| 日韩美女在线视频| 久久人人超碰精品| 91精品国产综合久久精品麻豆| 欧美日韩国产综合久久 | 精品一区二区免费视频| 亚洲一区日韩精品中文字幕| 久久久久国产精品人| 国产欧美日韩中文久久| 亚洲欧美中日韩| 亚洲h精品动漫在线观看| 奇米777欧美一区二区| 国产成人亚洲精品狼色在线| 成人av网在线| 欧美久久久久久久久久| 色综合天天性综合| 国产99久久久精品| 一本一道久久a久久精品综合蜜臀| 在线观看三级视频欧美| 色爱区综合激月婷婷| 在线不卡的av| 国产网红主播福利一区二区| 亚洲综合精品久久| 国产资源在线一区| 极品销魂美女一区二区三区| 99久久婷婷国产综合精品电影 | 中文字幕精品综合| 午夜精品久久久久久久久久久| 蜜臀久久久久久久| 丁香一区二区三区| 69久久夜色精品国产69蝌蚪网| 久久久久国产精品厨房| 亚洲综合一二三区| 国产成人午夜99999| 欧美体内she精高潮| 欧美韩日一区二区三区四区| 亚洲成人激情综合网| 国产精品77777| 91精品国产黑色紧身裤美女| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | av亚洲精华国产精华| 欧美色涩在线第一页| 国产精品乱码人人做人人爱| 日韩成人一级大片| 日韩高清一区在线| 99精品欧美一区二区三区综合在线| 欧美肥妇毛茸茸| 亚洲色图另类专区| 国产成人一区在线| 91精品国产福利在线观看| 综合在线观看色| 成人手机电影网| 久久精品这里都是精品| 日韩精品91亚洲二区在线观看 | 婷婷开心激情综合| 97国产一区二区| 国产精品素人视频| 国产精品1区二区.| 久久综合久久综合久久| 天堂影院一区二区| 欧美日韩在线播| 亚洲黄色av一区| 日本最新不卡在线| 欧美丰满一区二区免费视频| 亚洲影视资源网| 在线观看亚洲专区| 亚洲精品中文字幕乱码三区| 成人免费看视频| 久久久国产精品麻豆| 国产经典欧美精品| 久久久99久久| 国产夫妻精品视频| 日本一区二区综合亚洲| 国产资源精品在线观看| 久久看人人爽人人| 国产乱妇无码大片在线观看| 久久久亚洲高清| 国产精品一区在线| 国产精品亲子伦对白| 国产宾馆实践打屁股91| 亚洲国产精品国自产拍av| 成人午夜短视频| 国产精品久久久久精k8| 一本一道久久a久久精品| 亚洲女同女同女同女同女同69| 人人超碰91尤物精品国产| 欧美日韩精品二区第二页| 亚洲成人在线免费| 欧美成人高清电影在线| 国产一区不卡视频| 欧美激情中文字幕| 91久久精品一区二区三| 亚洲午夜在线视频| 日韩一卡二卡三卡| 国产伦精一区二区三区| 国产精品黄色在线观看| 欧美怡红院视频| 美国毛片一区二区三区| 国产蜜臀97一区二区三区| 99久久婷婷国产| 丝袜a∨在线一区二区三区不卡| 日韩欧美一级在线播放| 国产精品99久久久| 有码一区二区三区| 日韩区在线观看| 成人黄色小视频| 婷婷开心激情综合| 国产欧美日韩中文久久|