Initial check in
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
#ifndef FX2_IIC_H
|
||||
#define FX2_IIC_H
|
||||
|
||||
#include <fx2.h>
|
||||
|
||||
// I2C error codes
|
||||
// -----------------------------------------------------------------------------
|
||||
#define I2C_OK 0x00
|
||||
#define I2C_ERROR 0x80
|
||||
#define I2C_ABORT 0xFF
|
||||
#define SMB_ERROR 0xC0
|
||||
|
||||
|
||||
// I2C state machine states
|
||||
// -----------------------------------------------------------------------------
|
||||
#define I2C_IDLE 0x00
|
||||
#define I2C_SENDING 0x01
|
||||
#define I2C_RECEIVING 0x02
|
||||
#define I2C_PRIME 0x03
|
||||
#define I2C_BERROR 0x04
|
||||
#define I2C_NACK 0x05
|
||||
#define I2C_STOP 0x06
|
||||
#define I2C_WAITSTOP 0x07
|
||||
|
||||
|
||||
// I2C state machine states for read operation with repeated start condition
|
||||
// -----------------------------------------------------------------------------
|
||||
#define I2C_SUBADDR_HI 0x10 // sending HI(subaddr)
|
||||
#define I2C_SUBADDR_LO 0x11 // sending LO(subaddr)
|
||||
#define I2C_RESTART 0x12 //
|
||||
|
||||
|
||||
// SMBus state machine states
|
||||
// -----------------------------------------------------------------------------
|
||||
#define SMB_SENDING 0x40
|
||||
#define SMB_RECEIVING 0x41
|
||||
#define SMB_PRIME 0x43
|
||||
#define SMB_BERROR 0x44
|
||||
#define SMB_NACK 0x45
|
||||
#define SMB_STOP 0x46
|
||||
#define SMB_WAITSTOP 0x47
|
||||
#define SMB_PEC 0x48
|
||||
#define SMB_CMD_READWORD 0x50
|
||||
#define SMB_READWORD 0x51
|
||||
|
||||
|
||||
extern void fx2_i2c_init();
|
||||
|
||||
extern BYTE fx2_i2c_wait( BYTE addr);
|
||||
|
||||
extern BYTE fx2_i2c_read( BYTE addr,
|
||||
BYTE length,
|
||||
BYTE xdata *dat);
|
||||
|
||||
extern BYTE fx2_i2c_write( BYTE addr,
|
||||
BYTE length,
|
||||
BYTE xdata *dat);
|
||||
|
||||
extern BYTE fx2_i2c_read_rsw( BYTE addr,
|
||||
WORD subaddr,
|
||||
BYTE length,
|
||||
BYTE xdata *dat);
|
||||
|
||||
extern BYTE fx2_sm_readword( BYTE addr,
|
||||
BYTE command,
|
||||
BYTE xdata *dat);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user