📄 sysi2cdrv.h
字号:
/* sysI2cDrv.h - I2C Driver Header Module *//* Copyright 1984-1999 Wind River Systems, Inc. *//* Copyright 1996,1997,1998,1999 Motorola, Inc. All Rights Reserved *//*modification history--------------------01c,12jun02,kab SPR 74987: cplusplus protection01b,28may99,dmw Updated to WindRiver coding standards.01a,18feb99,dmw created. Based on MCG's DVT group's sysI2cDrv.h *//*DESCRIPTIONI2C Driver Header Module*/#ifndef INCsysI2cDrvh#define INCsysI2cDrvh#ifdef __cplusplus extern "C" {#endif/* device types */#define I2C_DEVICE_TYPE_EEPROM 0/* driver device data template (os + driver-specifics) */typedef struct i2cDev { unsigned int deviceAddress; /* address of the I2C device */ int deviceType; /* device type: 0 = EEPROM, 1 = other */ unsigned int blockSize; /* logical block size in bytes */ unsigned int blockOffset; /* logical block offset from zero of start */ unsigned int blockTotal; /* number of logical blocks from offset */ unsigned int controlAddress; /* controller address */ unsigned int pageSize; /* page size in number of blocks */ unsigned int controlWord; /* control word */ unsigned int sysClkRate; /* system clock rate */ } i2cDev_t;/* driver command packet */typedef struct i2cCmdPckt { int command; /* command identifier */ int status; /* status (error code) */ unsigned int memoryAddress; /* memory address */ unsigned int blockNumber; /* block number */ unsigned int nBlocks; /* number of blocks (bytes) to transfer */ unsigned int eCount; /* expected data count */ unsigned int aCount; /* actual data count */ } i2cCmdPckt_t;/* command identifiers */#define I2C_READOP 0 /* read operation */#define I2C_WRITOP 1 /* write operation */#define I2C_FRMTOP 2 /* format operation */#define I2C_CHCKOP 3 /* check operation */#define I2C_BYTE_NUM_MASK 0x700#define I2C_BYTE_NUM_SHIFT 7/* controller specific function pointers table template */typedef struct i2cDrvRoutines { int (*pI2cCycleStart)(); /* start cycle */ int (*pI2cCycleStop)(); /* stop cycle */ int (*pI2cCycleRead)(); /* read cycle */ int (*pI2cCycleWrite)(); /* write cycle */ int (*pI2cCycleAckIn)(); /* acknowledge in cycle */ int (*pI2cCycleAckOut)(); /* acknowledge out cycle */ int (*pI2cKnownState)(); /* known state */ void (*pI2cDelay)(); /* delay routine */ } i2cDrvRoutines_t;/* routine call macros *//* * Note: this driver could dynamically assign function pointers * but ROM based switch statements are not permitted so the * function pointers are set here for the specific board BSP. */#ifndef MV2100#define I2C_CYCLE_ACKIN (pRoutine->pI2cCycleAckIn())#define I2C_CYCLE_ACKOUT (pRoutine->pI2cCycleAckOut())#define I2C_CYCLE_READ(ad) (pRoutine->pI2cCycleRead(ad))#define I2C_CYCLE_START (pRoutine->pI2cCycleStart())#define I2C_CYCLE_STOP (pRoutine->pI2cCycleStop())#define I2C_CYCLE_WRITE(wd) (pRoutine->pI2cCycleWrite(wd))#define I2C_KNOWN_STATE (pRoutine->pI2cKnownState())#define I2C_DELAY(d) (pRoutine->pI2cDelay(d))#else#define I2C_CYCLE_START i2cCycleKahluaStart()#define I2C_CYCLE_STOP i2cCycleKahluaStop()#define I2C_CYCLE_READ(ad) i2cCycleKahluaRead(ad)#define I2C_CYCLE_WRITE(wd) i2cCycleKahluaWrite(wd)#define I2C_CYCLE_ACKIN i2cCycleKahluaAckIn()#define I2C_CYCLE_ACKOUT i2cCycleKahluaAckOut()#define I2C_KNOWN_STATE i2cCycleKahluaKnownState()#define I2C_DELAY(d) i2cCycleKahluaDelay(d)#endif/* error codes */#define I2C_ERROR_CYCLE_START 1 /* start cycle */#define I2C_ERROR_CYCLE_STOP 2 /* stop cycle */#define I2C_ERROR_CYCLE_READ 3 /* read cycle */#define I2C_ERROR_CYCLE_WRITE 4 /* write cycle */#define I2C_ERROR_CYCLE_ACKIN 5 /* acknowledge in cycle */#define I2C_ERROR_CYCLE_ACKOUT 6 /* acknowledge out cycle */#define I2C_ERROR_KNOWN_STATE 7 /* known state */#define I2C_ERROR_CYCLE_TIMEOUT (1<<16) /* cycle timed out */#ifdef __cplusplus }#endif#endif /* INCsysI2cDrvh */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -