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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99深爱久久99精品| 国产一区二区三区| 亚洲精品一区二区三区影院 | 精品一区二区三区免费播放| 国产午夜精品久久| 欧美日韩国产在线观看| 国产精品66部| 综合婷婷亚洲小说| 欧美日韩高清一区| 奇米精品一区二区三区在线观看| 精品福利在线导航| 日本韩国一区二区三区| 久久99国产精品麻豆| 亚洲天堂成人在线观看| 精品国产一区a| 91电影在线观看| 国产一区二区视频在线| 亚洲电影一级片| 亚洲欧洲日韩一区二区三区| 在线视频亚洲一区| 极品少妇xxxx精品少妇偷拍| 亚洲人快播电影网| 精品国产电影一区二区| 不卡的av在线播放| 激情综合色综合久久| 亚洲蜜桃精久久久久久久| 2020国产成人综合网| 91精品视频网| 欧美在线观看一区| av亚洲精华国产精华| 韩国中文字幕2020精品| 亚洲午夜久久久久久久久久久| 久久久综合九色合综国产精品| 制服丝袜中文字幕一区| 色婷婷综合久色| 国产伦理精品不卡| 一区二区激情小说| 国产精品高清亚洲| 欧美激情一区二区三区全黄| 精品久久久影院| 欧美一区二区三级| 欧美日韩亚洲综合在线 | 亚洲午夜久久久久久久久电影院 | 亚洲精品乱码久久久久久黑人| 精品国精品国产| 欧美吻胸吃奶大尺度电影| a4yy欧美一区二区三区| 成人av集中营| 成人黄色小视频| www.综合网.com| 99这里只有久久精品视频| 高清在线不卡av| 东方aⅴ免费观看久久av| 久久超级碰视频| 国产乱码字幕精品高清av| 久久aⅴ国产欧美74aaa| 视频一区中文字幕国产| 亚洲国产综合视频在线观看| 亚洲精品国产视频| 亚洲另类在线制服丝袜| 亚洲黄色小视频| 亚洲精品伦理在线| 亚洲国产精品影院| 亚洲bdsm女犯bdsm网站| 一区二区国产盗摄色噜噜| 最新日韩av在线| 亚洲天堂中文字幕| 亚洲一区二区欧美激情| 香蕉久久一区二区不卡无毒影院 | 久久美女艺术照精彩视频福利播放 | 精品无人码麻豆乱码1区2区| 日本一道高清亚洲日美韩| 免费看黄色91| 国产一区高清在线| 成人一区二区三区视频在线观看| 懂色av噜噜一区二区三区av| 99视频有精品| 欧美亚洲日本国产| 日韩欧美一区中文| 亚洲精品一区在线观看| 国产精品久久久久久久蜜臀| 一区二区三区中文字幕电影| 亚洲.国产.中文慕字在线| 日本v片在线高清不卡在线观看| 久久99精品一区二区三区三区| 国产成人亚洲综合a∨婷婷| 成人免费毛片嘿嘿连载视频| 在线观看一区不卡| 日韩欧美综合在线| 欧美极品xxx| 亚洲大片免费看| 国产一区二区在线影院| 97久久精品人人澡人人爽| 欧美日韩另类一区| 精品国产乱码久久久久久夜甘婷婷| 国产午夜一区二区三区| 亚洲欧美一区二区三区极速播放| 亚洲伊人色欲综合网| 日本不卡视频一二三区| 国产成人精品影院| 欧美丝袜丝交足nylons图片| 久久综合狠狠综合久久综合88| 国产欧美一区二区三区鸳鸯浴 | 91精品国产一区二区三区蜜臀| 欧美精品一区二区久久婷婷| 久久久亚洲精品石原莉奈| 韩国成人精品a∨在线观看| 色婷婷av一区二区三区之一色屋| 7777精品伊人久久久大香线蕉经典版下载 | 亚洲婷婷国产精品电影人久久| 日韩 欧美一区二区三区| 成人国产精品视频| 日韩一区二区免费视频| 国产精品人妖ts系列视频| 日本女优在线视频一区二区| 成年人网站91| 亚洲精品在线观看网站| 樱花影视一区二区| 国产成人福利片| 精品人在线二区三区| 一区二区在线观看视频在线观看| 国产一区欧美日韩| 欧美一级黄色录像| 亚洲女与黑人做爰| 国产成人精品1024| 亚洲精品在线一区二区| 性感美女久久精品| 91国产成人在线| 国产精品短视频| 国产电影一区在线| 欧美四级电影网| 国产精品欧美极品| 国产高清在线观看免费不卡| 精品国产乱码久久久久久老虎 | 欧美伦理影视网| 中文字幕中文乱码欧美一区二区| 久久av中文字幕片| 欧美日韩国产天堂| 亚洲国产综合在线| 99久久精品国产毛片| 久久新电视剧免费观看| 秋霞国产午夜精品免费视频| 欧美日韩在线三级| 亚洲成人在线网站| 色妞www精品视频| 成人免费小视频| 99久久精品国产导航| 国产精品女人毛片| 成人美女在线观看| 国产乱理伦片在线观看夜一区| 69堂成人精品免费视频| 男女性色大片免费观看一区二区 | 综合色中文字幕| 在线视频一区二区免费| 日韩福利视频网| 欧美精品一区二区久久久| 91香蕉视频在线| 亚洲午夜在线视频| 精品国精品国产尤物美女| 国产成人免费在线观看不卡| 亚洲麻豆国产自偷在线| 欧美美女bb生活片| 国产成人在线看| 亚洲综合视频在线观看| 日韩精品影音先锋| 国产·精品毛片| 一区二区视频在线| 日韩一区二区三区视频在线| 国产成人精品免费看| 亚洲一区二区三区四区不卡| 日韩欧美三级在线| av在线播放成人| 免费不卡在线观看| 17c精品麻豆一区二区免费| 337p亚洲精品色噜噜噜| 成人激情图片网| 亚洲成av人片观看| 国产精品天天看| 欧美精选在线播放| 成人av资源站| 日韩激情av在线| 国产精品久久久久久亚洲毛片| 欧美日韩国产系列| 亚洲国产激情av| 欧美日韩免费在线视频| 亚洲一二三级电影| 色婷婷av久久久久久久| 7799精品视频| 91麻豆国产精品久久| 激情五月婷婷综合网| 亚洲免费观看高清完整版在线 | 欧美性生交片4| 狠狠色丁香久久婷婷综合_中| 亚洲三级理论片| 久久综合久久综合亚洲| 欧洲色大大久久| 成人性生交大合| 黄色日韩三级电影| 亚洲一区二区偷拍精品| 国产精品久久久久久久蜜臀|