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

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

?? i2c.c

?? STM32+Grlib
?? C
?? 第 1 頁 / 共 3 頁
字號:
//*****************************************************************************
//
// i2c.c - Driver for Inter-IC (I2C) bus block.
//
// Copyright (c) 2005-2010 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// 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. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 5821 of the Stellaris Peripheral Driver Library.
//
//*****************************************************************************

//*****************************************************************************
//
//! \addtogroup i2c_api
//! @{
//
//*****************************************************************************

#include "inc/hw_i2c.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/i2c.h"
#include "driverlib/interrupt.h"

//*****************************************************************************
//
//! Initializes the I2C Master block.
//!
//! \param ulBase is the base address of the I2C Master module.
//! \param ulI2CClk is the rate of the clock supplied to the I2C 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 peripheral clock will be the same as the processor clock.  This will be
//! the value returned by SysCtlClockGet(), or it can be explicitly hard coded
//! if it is constant and known (to save the code/execution overhead of a call
//! to SysCtlClockGet()).
//!
//! This function replaces the original I2CMasterInit() API and performs the
//! same actions.  A macro is provided in <tt>i2c.h</tt> to map the original
//! API to this API.
//!
//! \return None.
//
//*****************************************************************************
void
I2CMasterInitExpClk(unsigned long ulBase, unsigned long ulI2CClk,
                    tBoolean bFast)
{
    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 desired SCL speed.
    //
    if(bFast == true)
    {
        ulSCLFreq = 400000;
    }
    else
    {
        ulSCLFreq = 100000;
    }

    //
    // Compute the clock divider that achieves the fastest speed less than or
    // equal to the desired speed.  The numerator is biased to favor a larger
    // clock divider so that the resulting clock is always less than or equal
    // to the desired clock, never greater.
    //
    ulTPR = ((ulI2CClk + (2 * 10 * ulSCLFreq) - 1) / (2 * 10 * ulSCLFreq)) - 1;
    HWREG(ulBase + I2C_O_MTPR) = ulTPR;
}

//*****************************************************************************
//
//! Initializes the I2C Slave block.
//!
//! \param ulBase is the 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_O_SOAR) = ucSlaveAddr;
}

//*****************************************************************************
//
//! Enables the I2C Master block.
//!
//! \param ulBase is the 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_O_MCR) |= I2C_MCR_MFE;
}

//*****************************************************************************
//
//! Enables the I2C Slave block.
//!
//! \param ulBase is the 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 - I2C0_SLAVE_BASE + I2C0_MASTER_BASE + I2C_O_MCR) |=
        I2C_MCR_SFE;

    //
    // Enable the slave.
    //
    HWREG(ulBase + I2C_O_SCSR) = I2C_SCSR_DA;
}

//*****************************************************************************
//
//! Disables the I2C master block.
//!
//! \param ulBase is the 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_O_MCR) &= ~(I2C_MCR_MFE);
}

//*****************************************************************************
//
//! Disables the I2C slave block.
//!
//! \param ulBase is the 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_O_SCSR) = 0;

    //
    // Disable the clock to the slave block.
    //
    HWREG(ulBase - I2C0_SLAVE_BASE + I2C0_MASTER_BASE + I2C_O_MCR) &=
        ~(I2C_MCR_SFE);
}

//*****************************************************************************
//
//! Registers an interrupt handler for the I2C module.
//!
//! \param ulBase is the base address of the I2C Master module.
//! \param pfnHandler is a pointer to the function to be called when the
//! I2C 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 is the base address of the I2C Master 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 is the 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_O_MIMR) = 1;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一区二区久久不卡| 日韩制服丝袜先锋影音| 欧美精品一区二区三区蜜桃| 91精品国产综合久久国产大片| 欧美性大战久久久久久久| 在线视频欧美精品| 欧美在线播放高清精品| 欧美性猛交xxxx乱大交退制版 | 91久久人澡人人添人人爽欧美| 风间由美性色一区二区三区| 盗摄精品av一区二区三区| 99麻豆久久久国产精品免费优播| 成人精品视频网站| 99精品久久只有精品| 91美女片黄在线| 欧美综合亚洲图片综合区| 欧美丝袜丝交足nylons图片| 欧美精品三级日韩久久| 日韩精品一区二区在线观看| www成人在线观看| 国产精品久久二区二区| 香蕉av福利精品导航| 秋霞电影网一区二区| 国产馆精品极品| 一本大道久久a久久综合| 8v天堂国产在线一区二区| 久久夜色精品国产欧美乱极品| 国产女人水真多18毛片18精品视频| 国产精品二三区| 亚洲国产一区二区视频| 激情欧美一区二区三区在线观看| 国产精品一区二区久久精品爱涩| 一本色道久久综合亚洲精品按摩| 欧美一区二区三区爱爱| 国产精品久久久久影视| 免费成人av在线播放| gogo大胆日本视频一区| 日韩欧美一区二区在线视频| 国产精品美女久久福利网站| 日韩高清在线电影| 99re这里只有精品首页| 欧美一级黄色大片| 亚洲另类中文字| 国产999精品久久| 91精品国产免费| 亚洲免费av观看| 国产一区二区三区在线观看精品| 欧美视频在线一区| 中文字幕不卡三区| 国产综合色产在线精品| 欧美日韩视频第一区| 国产精品麻豆网站| 国产综合久久久久久鬼色| 在线不卡中文字幕播放| 亚洲男人的天堂在线aⅴ视频| 久久国产精品露脸对白| 99视频有精品| 国产精品污www在线观看| 午夜精品久久久久久久| 99v久久综合狠狠综合久久| 久久精品视频在线免费观看 | 日韩女优视频免费观看| 午夜视频在线观看一区二区| zzijzzij亚洲日本少妇熟睡| 日韩欧美黄色影院| 日韩成人精品在线| heyzo一本久久综合| 欧美激情一区二区三区四区| 国产一区亚洲一区| 久久久久久影视| 国产自产视频一区二区三区| 日韩精品一区国产麻豆| 卡一卡二国产精品| 精品成人一区二区| 国产精一区二区三区| 久久综合五月天婷婷伊人| 日本在线观看不卡视频| 欧美高清视频在线高清观看mv色露露十八 | 天堂在线亚洲视频| 欧美日韩国产精选| 亚洲gay无套男同| 欧美一区二区三区色| 日本va欧美va欧美va精品| 欧美男女性生活在线直播观看| 亚洲一区二区三区在线| 欧美日韩国产影片| 日韩vs国产vs欧美| 国产婷婷色一区二区三区在线| 国产精品77777| 亚洲欧美精品午睡沙发| 91麻豆国产自产在线观看| 亚洲自拍偷拍九九九| 91精品国产福利在线观看| 日av在线不卡| 久久九九99视频| 92国产精品观看| 青青国产91久久久久久| 久久青草欧美一区二区三区| 99久久99久久精品免费观看| 亚洲一区二区三区四区在线观看| 在线综合+亚洲+欧美中文字幕| 麻豆91在线播放免费| 欧美国产精品久久| 欧美精品日韩一本| 国产一区二区三区观看| 亚洲一二三专区| 精品久久久久久综合日本欧美| 国产精品亚洲综合一区在线观看| 中文字幕在线视频一区| 69久久夜色精品国产69蝌蚪网 | 国产欧美日韩在线| 欧美亚洲一区二区在线| 久久精品国产一区二区| 国产精品理伦片| 6080国产精品一区二区| 成人一级视频在线观看| 亚洲v日本v欧美v久久精品| 国产午夜亚洲精品羞羞网站| 91福利精品视频| 国产剧情一区二区| 日本午夜精品一区二区三区电影| 国产精品久久久久影院色老大| 日韩一卡二卡三卡国产欧美| 色哟哟国产精品| 成人午夜av影视| 久久av老司机精品网站导航| 亚洲主播在线观看| 国产精品久久夜| 欧美va亚洲va| 91精品国产乱| 欧美高清激情brazzers| 色偷偷久久一区二区三区| 国产一区二区电影| 麻豆精品国产91久久久久久| 依依成人综合视频| 国产精品久久免费看| 久久综合国产精品| 日韩精品一区二区三区三区免费 | 91麻豆福利精品推荐| 成人精品视频一区二区三区 | 国产精品久久久久aaaa| 久久亚洲欧美国产精品乐播| 制服丝袜激情欧洲亚洲| 在线国产亚洲欧美| 91丨porny丨最新| 99免费精品视频| 99久久综合国产精品| 99国产精品久久久久久久久久久| 成人免费视频一区二区| 国产成人免费xxxxxxxx| 国产福利一区二区三区视频 | 国产精品欧美一级免费| 欧美国产丝袜视频| 欧美激情中文字幕一区二区| 国产农村妇女毛片精品久久麻豆 | 欧美亚洲国产一区二区三区va| 99精品欧美一区| 在线免费观看视频一区| 欧美制服丝袜第一页| 欧美综合天天夜夜久久| 欧美三级蜜桃2在线观看| 欧美丝袜丝交足nylons| 69p69国产精品| 精品国产污污免费网站入口| 久久―日本道色综合久久| 久久久不卡影院| 国产精品理论在线观看| 一区二区三区在线影院| 亚洲狠狠爱一区二区三区| 日韩av网站在线观看| 九九久久精品视频| 成人一道本在线| 欧美日韩一级片在线观看| 日韩欧美在线1卡| 国产精品超碰97尤物18| 亚洲地区一二三色| 国产乱子伦视频一区二区三区| 成人av网址在线观看| 91免费版在线| 日韩欧美一卡二卡| 久久久久久久久免费| 亚洲婷婷在线视频| 免费成人美女在线观看| 成人激情免费网站| 欧美日韩夫妻久久| 国产亚洲短视频| 亚洲成人中文在线| 国产99久久精品| 5566中文字幕一区二区电影| 国产欧美日韩激情| 亚洲国产视频一区| 高清免费成人av| 欧美一区二区三区公司| 亚洲国产成人自拍| 免费成人美女在线观看.| 成人av网站免费观看| 日韩免费观看高清完整版在线观看| 国产精品久久毛片a| 另类小说欧美激情| 欧美中文字幕一区二区三区|