?? iic.h
?? S3C4510b iic driver
?? H
字號:
??
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* iic.h KS32C50100 : version 1.0 */
/* */
/* COMPONENT */
/* */
/* */
/* DESCRIPTION */
/* */
/* I2C control function library header file. */
/* */
/* AUTHOR */
/* */
/* */
/* DATA STRUCTURES */
/* */
/* */
/* FUNCTIONS */
/* */
/* */
/* DEPENDENCIES */
/*************************************************************************/
#ifndef _IIC_H_
#define _IIC_H_
/*=====================================================================*/
/* */
/* IIC EEPROM ADDRESS MAP */
/* */
/* Case of Using 64Kbit(=8K bytes) IIC Serial EEPROM, */
/* The address range is 0x0 to 0x1fff */
/* */
/*=====================================================================*/
#define IIC_DEV_0 0xa0 //IIC device's slave address
#define S_WRITE 0x00 //Write IIC data for slave
#define S_READ 0x01 //Read IIC data for slave
/*=====================================================================*/
/* */
/* CONTROL REGISTERS */
/* */
/*=====================================================================*/
#define BF 0x01 //Buffer flag
#define IEN 0x02 //Interrupt enable
#define LRB 0x04 //Last bit received
//ACK not received
#define ACK 0x08 //Acknowlege enable
//Generate an ACK signal at 9th SCL
#define NOACK 0x00 //No more received data is required
//from the slave
#define START 0x10
#define STOP 0x20
#define RESTART 0x30
#define BUSY 0x40
#define IICRESET 0x80 //Reset the IIC-BUS controller
/*=====================================================================*/
/* */
/* USEFULL MACRO FUNCTIONS */
/* */
/*=====================================================================*/
#define Write_Cycle_ms(x) (x*0.001*fMCLK-1) /* IIC write cycle */
/* KS24L321/641=5ms*/
/*=====================================================================*/
/* */
/* IIC DATA TRANSFER STRUCTURES */
/* */
/*=====================================================================*/
#define StorageSize ((64*1024)/64) /* KS24L641:64Kbits(8192)*/
#define SizeOfPage 32 /* Writes up to 32 bytes of data */
/* in a single write cycle. */
/* Byte Slave transmitter and receive status flags */
#define iic_slave_addr 0x01 /* slave addr flag */
#define iic_byte_addr_msb 0x02 /* byte msb addr */
#define iic_byte_addr_lsb 0x04 /* byte lsb addr */
#define iic_page_tx_done 0x08 /* Page data transmit done */
#define iic_byte_rx_done 0x10 /* byte data receive done */
#define iic_repeat_start 0x20 /* flag for repeat start */
#define iic_multi_recv 0x40 /* recv multiple data */
#define iic_no_more_recv 0x80 /* no more recv from slave */
/* Data structure for multiple byte slave transmitter format */
typedef struct
{
volatile U32 FLAG;
volatile U32 BuffByteCnt; /* Page buffer byte counter */
volatile U32 WriteDataSize; /* Page buffer byte counter */
volatile U8 SLAVE_ADDR; /* Slave address */
volatile U8 BYTE_ADDR_MSB; /* Byte MSB address */
volatile U8 BYTE_ADDR_LSB; /* Byte LSB address */
volatile U8 PAGE_BUFFER[SizeOfPage+1]; /* IIC Page data buffer */
} IIC_DATA_TX_FORMAT;
/* Data structure for multiple byte slave receiver format */
typedef struct
{
volatile U32 FLAG;
volatile U32 ByteReadCnt;
volatile U32 ReadDataSize;
volatile U8 SLAVE_ADDR;
volatile U8 BYTE_ADDR_MSB;
volatile U8 BYTE_ADDR_LSB;
volatile U8 *RCV_BUFFER;
} IIC_DATA_RX_FORMAT;
/*=====================================================================*/
/* */
/* IIC SETUP ROUTINES (iic.c) */
/* */
/*=====================================================================*/
extern void IicSetup(void) ;
extern int SetPreScaler(int /*fSCL*/) ;
extern void config_iic(void);
/*=====================================================================*/
/* */
/* IIC INTERRUPT SERVICE ROUTINES */
/* (iic.c) */
/*=====================================================================*/
extern void IICWriteIsr(void) ;
extern void IICReadIsr(void) ;
/*=====================================================================*/
/* */
/* IIC LIBRARY FUNCTIONS FOR IIC READ & WRITE */
/* (iic.c) */
/*=====================================================================*/
extern void IICWriteInt(U8 /*SlaveAddr*/,U32 /*WriteAddr*/,U8 */*data*/,U32 /*SizeOfData*/);
extern void *IICReadInt(U8 /*SlaveAddr*/,U32 /*ReadAddr*/,U32 /*SizeOfData*/);
/*=====================================================================*/
/* */
/* IIC TEST FUNCTIONS USING IIC SERIAL EEPROM */
/* (iic_test.c) */
/*=====================================================================*/
#define IIC_DEV_0 0xa0 //IIC device's slave address
#define iMacAddrPtr 0x1000 //Storage area for MAC parameters
#define IICTestAddr 0x0 //IIC test start address
//#define IICTestSize 0x200 //Upto StorageSize of IIC serial EEPROM
//#define IICTestSize ((64*1024)/8) /* KS24L641:64Kbits(8192)*/
//#define IICTestSize ((64*1024)/64) /* KS24L641:64Kbits(8192)*/
//#define IICTestSize ((64*256)/(256)) /* KS24L641:64Kbits(8192)*/
#define IICTestSize 24//((64*256)/(256)) /* KS24L641:64Kbits(8192)*/
extern void IICWriteTest(void);
extern void IICReadTest(void);
extern void IICAutoTest(void);
extern int IICLoopBackTest(void);
extern void PrtIICStatus(int /*byte*/);
#endif /* end of the IIC header file */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -