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

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

?? dev_i2c_main.c

?? i2c總線接口驅動程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*===========================================================================    Copyright 2000, 2001 Holley Communications. All rights reserved.*//***************************************************************************** * * DEV_I2C_MAIN.C - I2C Communication Interface: Main Driver * * PURPOSE: *    To provide a generic communication interface to devices on an *    'Inter-IC Communications' (I2C) bus. This file contains the *    communication service routines available to clients needing *    to talk to I2C devices attached to this bus via the CDMA+ processor. * *    In this implementation, this module assumes the role of the I2C Bus *    Master and provides read/write access to slave devices. Access to *    the underlying 3-wire I2C interface (clock, data and ground) is *    provided through functions in the file DEV_I2C_IO.C. * *    At the physical layer, two directional General-purpose I/O lines *    are used for the SDA and SDL signal paths. The signal directions *    are dynamically switched at the appropriate times to effect *    half-duplex communication with the slave devices (as opposed to using *    the traditional open-collector interface). * * HISTORY: * * GLOBAL FUNCTIONS: *    'dev_i2c_initialize'  - Initialize I2C Communication Interface *    'dev_i2c_write'       - Write Data to I2C Slave Device *    'dev_i2c_read'        - Read Data from I2C Slave Device * * LOCAL FUNCTIONS: *    None * * INTERNAL FUNCTIONS: *    'dev_i2c_txdevaddr'   - Transmit I2C Device Address *    'dev_i2c_busstate'    - Get I2C Bus State *    'dev_i2c_txdatabyte'  - Send Data Byte on I2C Bus *    'dev_i2c_txstartbit'  - Send Start Bit *    'dev_i2c_txstopbit'   - Send a Stop Bit *    'dev_i2c_txdatabit'   - Send Data Bit *    'dev_i2c_rxdatabyte'  - Receive Data Byte From I2C Slave *    'dev_i2c_rxdatabit'   - Receive Data Bit *    'dev_i2c_rxackbit'    - Receive Acknowledgement Bit *    'dev_i2c_wait4sclrls' - Wait for SCL Release * * NOTE: *    The basic timing functions are currently tied to the clock speed *    of the processor. Hence changes in clock speed will produce *    changes in I2C signal timing ! * *    Multiple bus mastering is not currently supported. * *    The I2C timing produced by this logic is for 'standard mode'. In *    this mode the maximum SCL Clock frequency is 100 KHz. This corresponds *    to a SCL Clock period of 10 us. All clock related timing is based *    on this clock period. * * *****************************************************************************//* ------------------ D e f i n i t i o n   F i l e s --------------------- */#include "main_system.h"            /* System Environment */#include "main_io_cdmap.h"#include "pub_PIO.h"/* I2C Module Definitions */#include "dev_I2c_Global.h"             /* Global */#include "dev_i2c_local.h"              /* Local */#include "dev_i2c_main.h"               /* Internal */#ifndef HOST_BUILD/* ------------------------ L o c a l   D a t a --------------------------- *//* --------------------- I n t e r n a l   D a t a ------------------------ *//***************************************************************************** * * DEV_I2C_INITIALIZE - Initialize I2C Communication Interface * * PURPOSE: *    To initialize the signalling I/O hardware and then analyze the state *    of the Inter-IC (I2C) bus to ensure that is viable and ready for use. * * PARAMETERS: *    'parm' is a 32-bit user defined parameter (not currently used) * * RETURNS: *    DEV_I2C_RETCODE_SUCCESS   => I2C bus is ready for use *    DEV_I2C_RETCODE_IOINITERR => I/O line initialization error *    DEV_I2C_RETCODE_BUSBUSY   => Error: bus is in use *                             (possible physical layer fault) * * NOTE: *    This function must be called before calling any other functions in *    this facility and before any of the modules that support I2C devices. * *****************************************************************************/#endifInt16 dev_i2c_initialize ( Long parm ){#ifndef HOST_BUILD   /* Initialize the signalling I/O hardware */   dev_i2c_io_initialize ();   /* If the I2c bus is not being driven (i.e. it's idle) */   if ( dev_i2c_busstate () == DEV_I2C_BUS_IDLE )   {      /* SUCCESS: Bus is free */      return ( DEV_I2C_RETCODE_SUCCESS );   }   else   {      /* ERROR: Bus is in use */      return ( DEV_I2C_RETCODE_BUSBUSY );   }#else   return DEV_I2C_RETCODE_SUCCESS;#endif}#ifndef HOST_BUILD#if !BOARD_PHOENIX/***************************************************************************** * * DEV_I2C_WRITE - Write Data to I2C Slave Device * * PURPOSE: *    To write a buffer of bytes to a specified slave device on *    the I2C bus. * * PARAMETERS: *    'deviceaddr' is the I2C slave device address *    'databufp' -> the data buffer to send *    'len' is the number of bytes in the buffer * * RETURNS: *    DEV_I2C_RETCODE_SUCCESS   => Data sent successfully *    DEV_I2C_RETCODE_BUSBUSY   => Error: bus is in use; data not sent *    DEV_I2C_RETCODE_NOADDRACK => Error: address byte not acknowledged *                             (device not present, address incorrect, *                              or physical layer fault) *    DEV_I2C_RETCODE_NODATAACK => Error: data byte not acknowledged *                             (possible physical layer fault) * * NOTE: *    A write request with a data length of zero can be used to determine *    whether the specified device is installed. * *    The I2C device write protocol is as follows: *        1) check for an idle bus *        2) send start bit *        3) send slave address byte with Read/Write* (R/W*) bit clear *        4) check for a ACK to the address byte *        5) send each data byte checking for ACK bit *        6) send stop bit * *****************************************************************************/Int16 dev_i2c_write ( Byte deviceaddr, Byte *databufp, Word len ){   Word i;   /* If could not deliver the address byte */   if ( dev_i2c_txdevaddr ( deviceaddr, DEV_I2C_WRITE ) < 0 )   {      /* ERROR: Address byte not acknowledged */      return ( DEV_I2C_RETCODE_NOADDRACK );   }   /* For each byte in the message */   for ( i = 0; i < len; i++ )   {      /* If the byte is sent but not acknowledged */      if ( dev_i2c_txdatabyte ( *databufp++ ) < 0 )      {         /* ERROR: Data byte not acknowledged */         return ( DEV_I2C_RETCODE_NODATAACK );      }   }   /* Send a stop bit */   dev_i2c_txstopbit ();   /* SUCCESS: Data transmitted */   return ( DEV_I2C_RETCODE_SUCCESS );}/***************************************************************************** * * DEV_I2C_TXDEVADDR - Transmit I2C Device Address * * PURPOSE: *    To transmit the device address preamble prior to performing a read *    or write operation to an I2C device. * *    This operation includes: *         1) checking that the bus is currently free *         2) transmitting the start bit *         3) transmitting the address byte with the device address *            properly positioned and the R/W* bit set or reset based *            on the subsequent bus operation to be performed * * PARAMETERS: *    'deviceaddr' is the device's DEV_I2C address *    'operation' is the subsequent bus operation to be performed *              DEV_I2C_READ  => read operation *              DEV_I2C_WRITE => write operation * * RETURNS: *    DEV_I2C_RETCODE_SUCCESS  => Device addressed *    DEV_I2C_RETCODE_BUSBUSY  => Error: bus is in use; data not sent *    DEV_I2C_RETCODE_NOACK    => Error: acknowledgement not received *                            (device not present, address incorrect, *                             or physical layer fault) *    DEV_I2C_RETCODE_SCLRLSTO => Error: Slave SCL release timeout error *                            (possible physical layer fault) *     * NOTE: *     *****************************************************************************/Int16 dev_i2c_txdevaddr ( Byte deviceaddr, Bool operation ){   Byte addrbyte;                   /* I2C address byte */   /* If the bus is currently in use */   if ( dev_i2c_busstate () == DEV_I2C_BUS_BUSY )   {      /* ERROR: Failed to acquire the bus */      return ( DEV_I2C_RETCODE_BUSBUSY );   }   /* Put the I2C device address in position in the address byte */   addrbyte = ( deviceaddr << 1 );   /* If this is a write operation */   if ( operation == DEV_I2C_WRITE )   {      /* Clear the Read/Write* (R/W*) bit */      addrbyte &= ~DEV_I2C_BIT_RDWRNOT;   }   else   {      /* Set the Read/Write* (R/W*) bit */      addrbyte |= DEV_I2C_BIT_RDWRNOT;   }    /* Send a start bit */     dev_i2c_txstartbit ();    /* Transmit the address byte, check for acknowledgement and return status */   return ( dev_i2c_txdatabyte ( addrbyte ) );}/***************************************************************************** * * DEV_I2C_TXDATABYTE - Send Data Byte on I2C Bus * * PURPOSE: *    To send an 8-bit data byte on the I2C bus and then monitor the *    slave device for the acknowledgement handshake. * * PARAMETERS: *    'data' is Byte to send to bus * * RETURNS: *    DEV_I2C_RETCODE_SUCCESS  => Byte sent successfully *    DEV_I2C_RETCODE_NOACK    => Error: acknowledgement not received *                            (device not present, address incorrect, *                             or physical layer fault) *    DEV_I2C_RETCODE_SCLRLSTO => Error: Slave SCL release timeout error *                            (possible physical layer fault) * * NOTE: *     A slow device may hold the SCL line low for a protracted period *     of time prior to delivering the ACK bit to achieve a quasi- *     'wait state' effect. * *****************************************************************************/Int16 dev_i2c_txdatabyte ( Byte data ){   Int16 retcode;                   /* Bit transmit return code */   Word i;   /* For each bit in the data byte */   for ( i = 0; i < 8; i++ )   {      /* Send the current data bit */      retcode = dev_i2c_txdatabit ( data & 0x80 );      /* If the bit was not successfully transmitted */      if ( retcode < 0 )      {         /* ERROR: Bit transmit error */         return ( retcode );      }      /* Shift the data */      data = data << 1;   }   /* Finally, receive the Ack bit and return status */   return ( dev_i2c_rxackbit () );}/***************************************************************************** * * DEV_I2C_TXSTARTBIT - Send Start Bit * * PURPOSE: *    To signal the start of a transmission by sending a start bit on *    the I2C bus. * * PARAMETERS: *    None * * RETURNS: *    Nothing * * NOTE: *    The I2C bus should by determined to be idle prior to calling *    this function. *     *    A start bit is signalled as follows: *       > drive       SDA low  for a 1/2 clock period (5.0 us) *       > drive       SCL low *     *****************************************************************************/void dev_i2c_txstartbit ( void ){   /* Drive the data line (SDA) low */   dev_i2c_io_sdalow ();   /* Drive the clock line (SCL) low */   dev_i2c_io_scllow ();}/***************************************************************************** * * DEV_I2C_TXSTOPBIT - Send a Stop Bit * * PURPOSE: *    To signal the end of a transmission by sending a stop bit on *    the I2C bus. * * PARAMETERS: *    None * * RETURNS: *    Nothing * * NOTE: *    The I2C bus should by determined to be idle prior to calling *    this function. *     *    A stop bit is signalled as follows: *       > drive       SCL low  for a 1/4 clock period (2.5 us) *       > drive       SDA low  for a 1/4 clock period (2.5 us) *       > tri-state   SCL high for a 1/2 clock period (5.0 us)  *       > tri-state   SDA high *     *****************************************************************************/void dev_i2c_txstopbit ( void ){   /* Drive the clock line (SCL) low */   dev_i2c_io_scllow ();   /* Drive the data line (SDA) low */   dev_i2c_io_sdalow ();   /* Tri-state the clock line (SCL) (it will be pulled high) */   dev_i2c_io_scltristate ();   /* Tri-state the data line (SDA) (it will be pulled high) */   dev_i2c_io_sdatristate ();}/***************************************************************************** * * DEV_I2C_TXDATABIT - Send Data Bit * * PURPOSE: *    To send a data bit to the currently addressed I2C slave device. * * PARAMETERS: *    'bit' is the bit value to send * * RETURNS: *    DEV_I2C_RETCODE_SUCCESS  => Data bit sent *    DEV_I2C_RETCODE_SCLRLSTO => Error: Slave SCL release timeout error *                            (possible physical layer fault) * * NOTE: *    When sending a '1' bit the SDA should not be driven. Instead tri- *    state the line and let the external pull-up signal a '1' to the *    slave. This technique is essential to correct signalling on I2C *    buses with voltage translation. * *    A data bit is transmitted as follows: *       > drive       SCL low  for a 1/4 clock period (2.5 us) *   '0' > drive       SDA low  for a 1/4 clock period (2.5 us), or, *   '1' > tri-state   SDA high for a 1/4 clock period (2.5 us)  *       > tri-state   SCL high *       > wait for    SCL high (slave release) *       > wait for    for a 1/2 clock period (5.0 us)  * *     A slow device may hold the SCL line low for a protracted period *     of time prior to accepting a data bit to achieve a quasi- *     'wait state' effect. * *****************************************************************************/Int16 dev_i2c_txdatabit ( Byte bit ){   Int16 retcode;                   /* SCL release return code */   /* Drive the clock line low */   dev_i2c_io_scllow ();   /* If the data bit is a 'high' */   if ( !bit )   {      /* Drive the data line (SDA) low */      dev_i2c_io_sdalow ();   }   else   {      /* Tri-state the data line (SDA) high (it is pulled high externally) */      dev_i2c_io_sdatristate ();   }   /* Tri-state the clock (SCL) line */   dev_i2c_io_scltristate ();   /* Wait for the slave to release the SCL signal */   retcode = dev_i2c_wait4sclrls ();   /* If SCL was not released */   if ( retcode < 0 )   {      /* ERROR: Slave failed to release SCL */      return ( retcode );   }   /* SUCCESS: Data bit transmitted */   return ( DEV_I2C_RETCODE_SUCCESS );}/***************************************************************************** * * DEV_I2C_RXACKBIT - Receive Acknowledgement Bit * * PURPOSE: *    To wait for an acknowledgement bit from the slave device on I2C bus. * * PARAMETERS: *    None * * RETURNS: *    DEV_I2C_RETCODE_SUCCESS  => Got the ACK bit *    DEV_I2C_RETCODE_NOACK    => Error: acknowledgement not received *                            (device not present, address incorrect, *                             or physical layer fault) *    DEV_I2C_RETCODE_SCLRLSTO => Error: Slave SCL release timeout error *                            (possible physical layer fault) * * NOTE: *    An ACK bit is received as follows: *       > drive       SCL low  for a 1/4 clock period (2.5 us) *       > tri-state   SDA high for a 1/4 clock period (2.5 us)  *       > tri-state   SCL high *       > wait for    SCL high (slave release) *       > wait for    for a 1/4 clock period (2.5 us)  *       > read SDA line *       > wait for    for a 1/4 clock period (2.5 us)  *       > '0'         SDA low  => ACK received *       > '1'         SDA high => no ACK * *     A slow device may hold the SCL line low for a protracted period *     of time prior to delivering the ACK bit to achieve a quasi- *     'wait state' effect. *     *****************************************************************************/Int16 dev_i2c_rxackbit ( void ){   Bool sdastate;                   /* SDA signal state */   Int16 retcode;                   /* Wait operation return code */   /* Set the clock line (SCL) low */   dev_i2c_io_scllow ();   /* Tri-state the data (SDA) line */   dev_i2c_io_sdatristate ();   /* Tri-state the clock (SCL) line */   dev_i2c_io_scltristate ();   /* Wait for the slave to release the SCL signal */   retcode = dev_i2c_wait4sclrls ();   /* If SCL was not released */   if ( retcode < 0 )

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人777| 国产成人夜色高潮福利影视| 国产成人aaa| 国产精品久久久久一区二区三区共 | 日本不卡的三区四区五区| 欧美日韩色一区| 国内成人自拍视频| 亚洲色图在线视频| 欧美三区在线观看| 国产麻豆日韩欧美久久| 亚洲美女屁股眼交3| 制服丝袜亚洲网站| 91年精品国产| 麻豆精品一区二区av白丝在线| 国产目拍亚洲精品99久久精品| 在线一区二区三区四区| 久久er99热精品一区二区| 亚洲视频一二三区| 精品国产乱码久久久久久免费| 91日韩精品一区| 久久国产免费看| 亚洲成人在线网站| 亚洲美女淫视频| 国产三级精品三级| 久久先锋影音av鲁色资源网| 欧美在线观看禁18| 99视频在线精品| www.av精品| 成人午夜电影网站| 成人在线综合网| 国产69精品久久777的优势| 精品一区二区三区av| 国产一区在线看| 精彩视频一区二区三区| 久久精品国产精品亚洲综合| 青青草国产成人av片免费| 午夜精品久久久久久久久久久 | 亚洲视频在线一区二区| 国产区在线观看成人精品| 久久综合资源网| 国产人久久人人人人爽| 欧美极品美女视频| 亚洲欧美一区二区三区久本道91| 国产精品久久久久影院| 亚洲精品菠萝久久久久久久| 亚洲国产三级在线| 久久国内精品视频| 国产高清视频一区| 成人激情动漫在线观看| 欧美日韩日日骚| 久久久噜噜噜久噜久久综合| 中文字幕成人网| 久久精品国产精品青草| 色综合久久综合网97色综合| 777xxx欧美| 亚洲国产精品麻豆| 波多野结衣在线aⅴ中文字幕不卡| 欧美久久免费观看| 1024成人网色www| 成人午夜碰碰视频| 日韩午夜av一区| 亚洲综合色网站| 91麻豆精东视频| 国产精品免费丝袜| 国产精品亚洲一区二区三区妖精| 91精品国产综合久久久久久久 | 国产成人在线观看| 26uuu另类欧美亚洲曰本| 首页国产欧美日韩丝袜| 欧美日韩精品系列| 夜夜嗨av一区二区三区网页 | 粉嫩aⅴ一区二区三区四区| 日韩精品一区二| 极品销魂美女一区二区三区| 欧美一卡二卡三卡四卡| 免费成人在线网站| 久久―日本道色综合久久| 另类小说视频一区二区| 精品国产凹凸成av人网站| 美美哒免费高清在线观看视频一区二区 | 日韩三级中文字幕| 国产伦精品一区二区三区在线观看| 精品卡一卡二卡三卡四在线| 国产精品香蕉一区二区三区| 成人免费在线观看入口| 欧美影院一区二区| 免费看欧美女人艹b| 久久久久高清精品| 欧美亚洲一区二区在线观看| 免费一区二区视频| 中文字幕精品在线不卡| 在线观看日韩精品| 国产精品996| 日韩一区精品视频| 国产欧美一区二区精品性| 91传媒视频在线播放| 久久精品国产一区二区三 | 日韩和欧美一区二区三区| 精品国产免费一区二区三区香蕉 | 国产一区二区不卡老阿姨| 国产欧美一区二区精品久导航| 色视频成人在线观看免| 国产一区二区91| 人人精品人人爱| 亚洲日本成人在线观看| 国产亚洲成av人在线观看导航| 91高清视频在线| 一本色道久久综合精品竹菊| 精品一区二区三区免费| 理论电影国产精品| 天天综合天天做天天综合| 一二三区精品福利视频| 亚洲日本va午夜在线影院| 国产精品成人免费精品自在线观看| 日韩午夜激情视频| 91精品国产一区二区人妖| 欧美丰满美乳xxx高潮www| 欧美日本视频在线| 5月丁香婷婷综合| 欧美电影免费观看高清完整版在线 | 一区二区三区在线免费播放| 亚洲欧美aⅴ...| 亚洲在线成人精品| 亚洲午夜电影在线| 日本欧美一区二区| 国产二区国产一区在线观看| 成人午夜av在线| 欧美日韩一级二级三级| 日韩免费观看2025年上映的电影| 久久综合久久鬼色中文字| 精品成人在线观看| 亚洲婷婷综合色高清在线| 亚洲大型综合色站| 国产成人aaaa| 欧美一级xxx| 亚洲天堂网中文字| 久久国产精品色| 一本色道综合亚洲| 国产欧美在线观看一区| 亚洲电影在线免费观看| 丁香五精品蜜臀久久久久99网站| 欧美性生活一区| 久久女同精品一区二区| 五月综合激情日本mⅴ| av电影在线观看不卡| 欧美一区二区免费观在线| 樱桃视频在线观看一区| 国产成人在线视频网站| 精品国产免费视频| 亚洲成人在线免费| 欧美色中文字幕| 亚洲精品一二三| 色婷婷久久综合| 亚洲人成精品久久久久久| 成人国产电影网| 国产精品人人做人人爽人人添| 蜜臀av性久久久久av蜜臀妖精| 欧美日韩黄色一区二区| 国产一区二区三区电影在线观看 | 欧美一卡二卡三卡| 亚洲狠狠爱一区二区三区| 一本大道av伊人久久综合| 中文字幕不卡在线| 波多野结衣亚洲| 亚洲精品国产成人久久av盗摄| 一本久久a久久免费精品不卡| 亚洲精品福利视频网站| 欧美日韩国产成人在线91| 精品一区二区在线播放| 国产欧美一区二区三区鸳鸯浴| 99re在线精品| 亚洲在线中文字幕| 精品区一区二区| 91在线国产福利| 青青草97国产精品免费观看 | 在线不卡欧美精品一区二区三区| 婷婷丁香激情综合| 成人久久18免费网站麻豆| 欧美一区二区三区色| 美女视频一区在线观看| 日韩免费观看高清完整版| 成人美女视频在线看| 亚洲永久精品大片| 久久亚洲精品国产精品紫薇| 一本大道久久a久久精品综合 | 日本视频一区二区三区| 国产日韩一级二级三级| 欧美精品久久一区| av亚洲产国偷v产偷v自拍| 久久99国产精品久久99| 天天影视色香欲综合网老头| 国产精品久久久久久久久快鸭 | 国产精品成人午夜| 久久久精品影视| 精品国产乱码久久久久久牛牛| 欧美日韩国产一区二区三区地区| 波多野结衣一区二区三区| 国产资源在线一区| 久久精品国产秦先生| 久久精品国产99|