This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
基于home1.2版本的门锁例程
测试对E2PROM的读操作
初始化如下:
bspI2cInit();
引脚分配为:
/* I2C */
#define Board_I2C0_SDA0 IOID_7
#define Board_I2C0_SCL0 IOID_27
读操作如下,测量没有任何波形,是不是哪里配置不正确?
bspI2cSelect(0,0x50);//7位地址为0x50
sensorReadReg(0, &buf, 1);//读一个字节
bspI2cDeselect();
SensorTag里面的
void bspI2cInit(void) { Semaphore_Params semParamsMutex; // Create protection semaphore Semaphore_Params_init(&semParamsMutex); semParamsMutex.mode = Semaphore_Mode_BINARY; Semaphore_construct(&mutex, 1, &semParamsMutex); // Reset the I2C controller HapiResetPeripheral(PRCM_PERIPH_I2C0); I2C_init(); I2C_Params_init(&i2cParams); i2cParams.bitRate = I2C_100kHz; i2cHandle = I2C_open(Board_I2C, &i2cParams); // Initialise local variables slaveAddr = 0xFF; interface = BSP_I2C_INTERFACE_0; if (i2cHandle == NULL) { Task_exit(); } }
bool bspI2cWriteRead(uint8_t *wdata, uint8_t wlen, uint8_t *rdata, uint8_t rlen)
{
I2C_Transaction masterTransaction;
masterTransaction.writeCount = wlen;
masterTransaction.writeBuf = wdata;
masterTransaction.readCount = rlen;
masterTransaction.readBuf = rdata;
masterTransaction.slaveAddress = slaveAddr;
return I2C_transfer(i2cHandle, &masterTransaction) == TRUE;
}
如果用你说的I2C_open和I2C_transfer,参数怎么写?