The problem still persists. Here is the pertinent code
uint8_t FXASWriteByte(uint8_t regaddr, uint8_t u8data)
{
TWIStart();
if (TWIGetStatus() != 0x08){
return ERROR_START;
}
TWIWrite((FXAS_ADDR << 1));
if (TWIGetStatus() != 0x18){
return ERROR_TRANSMIT;
}
//send the register
TWIWrite(regaddr);
if (TWIGetStatus() != 0x28){
return ERROR_TRANSMIT;
}
//write byte to register
TWIWrite(u8data);
if (TWIGetStatus() != 0x28){
TWIStop();
return ERROR_TRANSMIT;
}
TWIStop();
return 0;
}
uint8_t FXASReadBytes(uint8_t regaddr, uint8_t *u8data, uint8_t len)
{
uint8_t count = 0;
TWIStart();
if (TWIGetStatus() != 0x08){
return ERROR_START;
}
TWIWrite((FXAS_ADDR << 1));
if (TWIGetStatus() != 0x18){
return ERROR_TRANSMIT;
}
//send the register
TWIWrite(regaddr);
if (TWIGetStatus() != 0x28){
return ERROR_TRANSMIT;
}
TWIStart();
if (TWIGetStatus() != 0x10){
return ERROR_RESTART;
}
//FXOS_address with 1 in the read portion
TWIWrite((FXAS_ADDR << 1)|1);
if (TWIGetStatus() != 0x40){
return ERROR_TRANSMIT;
}
while(count++ < len-1){
*u8data++ = TWIReadACK();
if (TWIGetStatus() != 0x50){
return ERROR_READ;
}
}
*u8data = TWIReadNACK();
if (TWIGetStatus() != 0x58){
return ERROR_READ;
}
TWIStop();
return SUCCESS;
}
uint8_t senddata[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int main(void){
FXASWriteByte(CTRL_REG1,0x03);
FXASReadBytes(FXAS21002_STATUS,senddata,8);
}
As I said in the previous post, the i2c communication seems to be working fine, just the data doesn't seem to be acquired. I'm wondering if this is more of a hardware/layout issue