In JN-AN-1229,I want to be able to use I2C communication

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

In JN-AN-1229,I want to be able to use I2C communication

382 Views
377086561
Contributor II

I saw a case of JN-AN-1221 and then borrowed from the application.

bool i2c_BusWriteReg(uint8 u8Address, uint8 u8Command, uint8 u8Length, uint8* pu8Data)
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(bTraceI2c, "i2c_BusWriteReg: Enter\n");
#endif

// First write I2C address + WRITE BIT on I2C bus
vAHI_SiMasterWriteSlaveAddr(u8Address, /* bReadStatus */ FALSE);
if (!bAHI_SiMasterSetCmdReg(/* bSetSTA */ E_AHI_SI_START_BIT,
/* bSetSTO */ E_AHI_SI_NO_STOP_BIT,
/* bSetRD */ FALSE,
/* bSetWR */ TRUE,
/* bSetAckCtrl */ FALSE,
/* bSetIACK */ FALSE))
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(TRUE, "i2c_BusWriteReg: Exit 1\n");
#endif
return FALSE;
}

====================================》》》》》》   #1
while(bAHI_SiMasterPollTransferInProgress());

// Now write Command to I2C device
vAHI_SiMasterWriteData8(u8Command);

// Now write Data to I2C device
while (u8Length)
{
if (!bAHI_SiMasterSetCmdReg(/* bSetSTA */ E_AHI_SI_NO_START_BIT,
/* bSetSTO */ E_AHI_SI_NO_STOP_BIT,
/* bSetRD */ FALSE,
/* bSetWR */ TRUE,
/* bSetAckCtrl */ FALSE,
/* bSetIACK */ FALSE))
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(TRUE, "i2c_BusWriteReg: Exit 2\n");
#endif
return FALSE;
}
while(bAHI_SiMasterPollTransferInProgress());

================================================》#2

vAHI_SiMasterWriteData8(*pu8Data);
u8Length -= 1;
pu8Data++;
}
if (!bAHI_SiMasterSetCmdReg(/* bSetSTA */ E_AHI_SI_NO_START_BIT,
/* bSetSTO */ E_AHI_SI_STOP_BIT,
/* bSetRD */ FALSE,
/* bSetWR */ TRUE,
/* bSetAckCtrl */ FALSE,
/* bSetIACK */ FALSE))
{
#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(TRUE, "i2c_BusWriteReg: Exit 3\n");
#endif
return FALSE;
}
while(bAHI_SiMasterPollTransferInProgress());

#ifdef DEBUG_I2C_DRIVER
DBG_vPrintf(bTraceI2c, "i2c_BusWriteReg: Leave\n");
#endif
return TRUE;
}

0 Kudos
1 Reply

311 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi, 

I am answering in this community post.

https://community.nxp.com/thread/509594 

Regards,

Mario

0 Kudos