Other Parts Discussed in Thread: HALCOGEN
I'm implementing an I2C reset for a slave device, as described here: 
My processor is the RM48L952ZWT, which has I2C pins that can be used as GIO pins, and uses HalCoGen to generate the hardware abstraction code for that peripheral. I've written a function, and would like feedback as to whether I'm using the correct HalCoGen functions to achieve the I2C reset and then set the pins back into I2C mode.
Here is my function:
/**************************************************************************//**
* @brief Reset the I2C bus (in case SDA line is stuck low).
* @remarks Toggle SCL until SDA is high. Optionally, send START + STOP
* after. Alternatively, for SMB devices, reset by holding SCL
* low > 35ms.
* @retval true for success; false otherwise
*****************************************************************************/
static bool i2c_reset(void)
{
bool result = false; // pessimistic return value
uint8_t timeout = 9; // the most you should try is 9 bits
// Put SCL and SDA into GPIO mode.
i2cREG1->PFNC = 0x0001;
// Set SCL as output, SDA as input.
gioSetDirection(i2cPORT1, 0x0001);
// If SDA is stuck low (and timeout is greater than zero)...
while ((false == gioGetBit(i2cPORT1, 1)) && --timeout)
{
// Toggle SCL.
gioToggleBit(i2cPORT1, 0);
}
// If the timeout counter is not zero...
if (timeout != 0)
{
// We successfully reset the I2C bus, so status is pass.
result = true;
}
// Set SCL and SDA as I2C pins again.
i2cREG1->PFNC = 0x0000;
return result;
}
Thanks for your attention,
Adam J.