www.pudn.com > Bit1611_demo_code.rar > I2C.H


/*  *********************************************************************** 
 
         Copyright (c) 2002-2006 Beyond Innovation Technology Co., Ltd 
 
        All rights are reserved. Reproduction in whole or in parts is 
    prohibited without the prior written consent of the copyright owner. 
   ---------------------------------------------------------------------- 
 
    Module: I2C.H 
 
    Purpose: Interface of I2C module. 
 
    Version: 0.01                                   07:23PM  2005/05/13 
 
    Compiler: Keil 8051 C Compiler v8.01 
 
    Reference: 
 
   ---------------------------------------------------------------------- 
    Modification: 
 
    R0.01 07:23PM  2005/05/13 Jeffrey Chang 
    Reason: 
        1. Original. 
    Solution: 
 
   *********************************************************************** */ 
 
#ifndef _I2C_H_ 
#define _I2C_H_ 
 
 
/* ------------------------------------ 
    Header Files 
   ------------------------------------ */ 
#include "platform.h" 
 
 
/* ------------------------------------ 
    Macro Definition 
   ------------------------------------ */ 
#undef  EXTERN 
 
#ifdef  _I2C_C_ 
    #define EXTERN 
#else 
    #define EXTERN extern 
#endif 
 
 
/* :::::::::::::::::::::::::::::::::::: 
    I2C Mode Configuration 
   :::::::::::::::::::::::::::::::::::: */ 
#define I2C_MODE_SLOW               1           // < 100 kbit/s 
#define I2C_MODE_STANDARD           2           // 100 kbit/s       108K Hz for CLK HIGH interval 
#define I2C_MODE_FAST               3           // 400 kbit/s       400K Hz for CLK HIGH interval 
#define I2C_MODE_HIGHSPEED          4           // 3.4 Mbit/s       1.19M Hz for CLK HIGH interval 
 
#define I2C_MODE_CFG                I2C_MODE_STANDARD 
//#define I2C_MODE_CFG                I2C_MODE_SLOW 
 
 
 
/* :::::::::::::::::::::::::::::::::::: 
    I2C Configuration 
   :::::::::::::::::::::::::::::::::::: */ 
 
#if (VP_IF_CFG == VP_IF_I2C) 
 
    #if (PROJECT == DMO01010101) 
 
        #define I2C_RX_BURST        OFF 
        #define I2C_RX_BYTE         ON 
        #define I2C_RX_WORD         OFF 
 
        #define I2C_TX_BURST        ON 
        #define I2C_TX_BYTE         ON 
        #define I2C_TX_WORD         ON 
 
    #else 
 
        #define I2C_RX_BURST        OFF 
        #define I2C_RX_BYTE         ON 
        #define I2C_RX_WORD         OFF 
 
        #define I2C_TX_BURST        ON 
        #define I2C_TX_BYTE         ON 
        #define I2C_TX_WORD         OFF 
 
    #endif 
 
 
#else 
 
    #if (PLATFORM_CFG == PLATFORM_01_DMO1611A0) 
        // (01)VID540-100-027/BIT1611B0  (v1.00 2005/10/14 BIT1611B0 Demo Board) 
 
        #define I2C_RX_BURST        OFF 
        #define I2C_RX_BYTE         OFF 
        #define I2C_RX_WORD         OFF 
 
        #define I2C_TX_BURST        OFF 
        #define I2C_TX_BYTE         ON 
        #define I2C_TX_WORD         OFF 
 
    #elif (PLATFORM_CFG == PLATFORM_04_DMO1611S0) 
        // (04)PLATFORM_04_DMO1611S0 (VID502-002-031,BIT1611BS0) 
 
        #define I2C_RX_BURST        OFF 
        #define I2C_RX_BYTE         OFF 
        #define I2C_RX_WORD         OFF 
 
        #define I2C_TX_BURST        OFF 
        #define I2C_TX_BYTE         ON 
        #define I2C_TX_WORD         OFF 
 
    #elif (PLATFORM_CFG == PLATFORM_06_VTX0501) 
        // (06)PLATFORM_06_VTX0501 (BMW HS 2.1) 
 
        #define I2C_RX_BURST        OFF 
        #define I2C_RX_BYTE         OFF 
        #define I2C_RX_WORD         OFF 
 
        #define I2C_TX_BURST        OFF 
        #define I2C_TX_BYTE         ON 
        #define I2C_TX_WORD         OFF 
 
    #else 
        #error I2C.H - Invalid PROJECT ! 
 
    #endif /* PROJECT */ 
 
#endif 
 
/* ------------------------------------ 
    Type Definitions 
   ------------------------------------ */ 
 
/* ------------------------------------ 
    Variables Definitions/Declarations 
   ------------------------------------ */ 
 
 
/* ------------------------------------ 
    Function Prototypes 
   ------------------------------------ */ 
EXTERN BOOL I2C_GetACK(void); 
EXTERN void I2C_Init(void); 
 
 
#if (I2C_RX_BURST) 
EXTERN void I2C_RxBurst(UB8 bSLA, UB8 bREG, UB8 bCNT, UB8 *pbDATA); 
#endif 
 
#if (I2C_RX_BYTE) 
EXTERN UB8  I2C_RxByte(UB8 bSLA, UB8 bREG); 
#endif 
 
EXTERN UB8  I2C_RxData(void); 
 
#if (I2C_RX_WORD) 
EXTERN UW16 I2C_RxWord(UB8 bSLA, UB8 bREG); 
#endif 
 
 
EXTERN void I2C_SetACK(void); 
EXTERN void I2C_SetNAK(void); 
 
EXTERN void I2C_Start(void); 
EXTERN void I2C_Stop(void); 
 
 
#if (I2C_TX_BURST) 
EXTERN void I2C_TxBurst(UB8 bSLA, UB8 bREG, UB8 bCNT, UB8 *pbDATA); 
#endif 
 
#if (I2C_TX_BYTE) 
EXTERN void I2C_TxByte(UB8 bSLA, UB8 bREG, UB8 bDATA); 
#endif 
 
EXTERN void I2C_TxData(UB8 bData); 
 
#if (I2C_TX_WORD) 
EXTERN void I2C_TxWord(UB8 bSLA, UB8 bREG, UW16 wDATA); 
#endif 
 
 
#endif /* _I2C_H_ */ 
 
 
/* ********************************************************************** 
 
    Description: 
 
   ********************************************************************** */ 
 
/* %% End Of File %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */