📄 i2cdriver.h
字号:
/************************************************************** * I2C driver header file defines some macroes which are * values the driver may return. This file also declares the * headers of functions which can be called from outside */#ifndef _I2CDRIVERH#define _I2CDRIVERH/************************************************** * Macro defines */ #undef I2C_DEBUG#undef APP_USE_UP_I2C_BUF /* It should be defined, if the application doesnt want to do data copy */#ifndef I2CPRINT #define I2CPRINT printf#endif /* I2CPRINT */#define I2CSLAVE 0 /* the I2C mode: slave */#define I2CMASTER 1 /* the I2C mode: master */#define MPC860_I2C_MASTER_ADDR 0x77 /* base I2C device address(when acting as a master) */#define MPC860_I2C_SLAVE_ADDR 0x33 /* base I2C device address(when acting as a slave ) */#define I2COK OK#define I2CERROR ERROR#define I2CUNSATISFIED ERROR#define I2C_CRC_BYTES 4 /* how many bytes left for CRC */ /* now we use crc32() function to generate crc bytes */#define I2C_BUF_SZ_MAX 0x100 /* This is the max length of I2c receive & transmit buffer */#define I2C_DATA_SZ_MAX I2C_BUF_SZ_MAX - I2C_CRC_BYTES/********************************************************* * Global function headers. Can be called by applications *//******************************************************** * I2cDriverInit: to init I2C * parameters: * I2cMode = I2CMASTER --- init the I2C to master mode * I2CSLAVE --- init the I2C to slave mode * eventFunc --- an event handling function pointer * * returns: * OK --- init OK; * ERROR --- init failed; */STATUS I2cDriverInit(char mode, VOIDFUNCPTR eventFunc);/******************************************************** * I2cDriverWrite: transmit I2C data * NOTE: if mpc860 acts as an I2C master, the data * length should not be larger than (I2C_DATA_SZ_MAX - 1) * * parameters: * pData --- point to the data buffer containing the * data to be transmitted. * length --- the byte number of the data in the buffer * pData points to. * returns: * length --- success. * ERROR(-1) --- failed. */int I2cDriverWrite(char* pData, UINT16 length);#endif /* _I2CDRIVERH */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -