⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezt8.h

📁 用于Slave I2C得读写,此代码针对特定得芯片,但对其他得芯片也有借鉴作用.
💻 H
字号:
/*
**********************************************************************************************
* Project:	T8Lib
* File:		ezt8.h
* Contents: 
*           The ezT8 lib interface for caller
*
* $Date: 10/13/05    Michal    T8R01LIB v0.1  initial
* $Date: 11/29/05    Michal    T8R01LIB v0.2  test finish  both 51 and MCF5249
* $Date: 11/30/05    Michal    T8R01LIB v0.3  make lib OK  on  MCF5249
* $Date: 12/01/05    Michal    T8R01LIB v0.4  Add HW_IIC ,HW_SPI macro	in this file
* $Date: 12/02/05    Michal    T8R01LIB v0.5  Add  function below 
*                 static void Doxx(BYTE* out ,BYTE* in,BYTE len,BOOL mode)
*                 static BOOL DoComunication(BYTE* array, BYTE len,BOOL mode)
*              
*
*                Moidfy some *Cmd Fuction and Reply() function
* $Date: 12/05/05    Michal    T8R02LIB v0.1  Add errcode1 to identify T8 off i2c bus state 
* $Date: 12/29/05 Michal T8R02LIB v0.2
	             Modify InitezT8(BOOL mode ) to BOOL  InitezT8Lib(BOOL ComMod,BYTE I2cSlvAdr,BOOL I2cIsHigh,BYTE SpiCLkMod,WORD SpiRate,BYTE *key);
                        void I2c_Init( ); void I2c_Sel( BYTE  SlvAdr, BOOL isHigh)  to void I2c_Init(BYTE  SlvAdr, BOOL isHigh);
                        void  Spi_Init();BOOL  Spi_ClkSel(BYTE mode, WORD rate);  To void  Spi_Init(BYTE mode, WORD rate);
                 Delete void SpiClkSelOpr(BYTE mode, WORD rate) ;
                        void I2c_Sel( BYTE  SlvAdr, BOOL isHigh);  
                        void SetXXKey(BYTE* key); 
* $Date: 12/29/05 Michal T8R02LIB v0.5 test communiction at 400khz speed  is OK  
* Copyright (c) 2005 Fameg, Inc. All rights reserved
***********************************************************************************************
*/



#ifndef ezT8_h
#define ezT8_h
                                   
/***********************************************
*            user config 
************************************************/

 #ifndef IMPORT_LIB
  #define IMPORT_LIB 1
 #endif

 #ifndef USER_CONFIG
  #define USER_CONFIG 0
 #endif


 #if IMPORT_LIB 
  #define EXT extern
 #else 
  #define EXT 
 #endif


  #define  BYTE          unsigned char         //data type define (depend on MCU)
  #define  WORD          unsigned short
  #define  BOOL          BYTE 
  #define  DWORD         unsigned long


  #define true  1
  #define false 0

  #define TRUE 	1
  #define FALSE	0

  #ifndef NULL
  #define NULL  (void *)0 
  #endif
  
  #define code 	 code
  #define data 	 data
  
 #define SW_IIC  1 //soft I2c
 #define SW_SPI  1
 
 #define HW_IIC  0  //hard I2c
 #define HW_SPI  0     //select one or both from SPI and IIC 

 #include <reg51.h>
                        
 sbit    SS_N =P2^6  ;
 sbit   SDOUT=P2^4  ;
 
 sbit   SCL  =P2^6  ;
 sbit   SDA  =P2^7  ;

 sbit RST =P2^5;



	  
 #define IIC_USED   SW_IIC||HW_IIC
 #define SPI_USED  SW_SPI||HW_SPI
 
 #if SW_IIC&HW_IIC
  #error " can not select  both (SW_IIC=1, HW_IIC=1) for i2c mode! ";
 #endif

 #if SW_SPI&HW_SPI
   #error "can not select  both (SW_SPI=1,HW_SPI=1) for spi mode! ";
 #endif

 #if (IIC_USED||SPI_USED)==0
  #error " must select  one mode : i2c or spi! ";
 #endif
  
  
#define COMENINT 0


 #if IMPORT_LIB          
   #if  USER_CONFIG

     const DWORD code CPUHZ =  15*1000000 ;   //15m hz      //cpu frequency

     void  Delay_0_5us(BYTE  cnt) ;         //for user to definition comunition delay for meet rate 
     void  Delay4_2ms(BYTE nCnt);

   #else  //!USER_CONFIG
   
     extern const DWORD code CPUHZ; 
 
   #endif //USER_CONFIG     
#endif //IMPORT_LIB


#endif  //ezT8_h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -