Other Parts Discussed in Thread: CC1310, CC1350STK,
Tool/software: TI-RTOS
Hello,
I try to change CC1310 example i2ctmp007 code to read bmp280 data.
I've already the slaveAddress from tmp007(0x40) to 0x77, but I still can't get any data.
The function i2c_transfer() return bool is always false.
Is there anything I need to do?
Thank you in advance,
Best Regards,
youyun
Below are my code.
#define BMP280_ADDR 0x77 #define BMP280_REG_PRESSURE 0xF5
/* Create I2C for usage */ I2C_Params_init(&i2cParams); i2cParams.bitRate = I2C_400kHz; //i2cParams.transferMode =I2C_MODE_CALLBACK; //I2C_MODE_CALLBACK I2C_MODE_BLOCKING //i2cParams.transferCallbackFxn = NULL; i2c = I2C_open(0, &i2cParams); //(0,&i2cParams) if (i2c == NULL) { puts("Error Initializing I2C"); while (1); } else{ puts("i2c open"); } while(1){ //I2C read //BMP280 //txBuffer[0]=BMP280_REG_ID; i2cTransaction.writeBuf = NULL; i2cTransaction.writeCount = 0; i2cTransaction.readBuf = rxBuffer; i2cTransaction.readCount = 1; i2cTransaction.slaveAddress = Board_BMP_ADDR; if (I2C_transfer(i2c, &i2cTransaction)){ //bmpValue = sensorBmp280Convert(rxBuffer); puts("I2C Function work"); //sprintf(bmpData,"%f",bmpValue); //puts(bmpData); } else{ puts("I2C Function Failed."); } }
Here is the reslut.
