Example #1
0
void SkI2cStop(
SK_IOC	IoC)	/* I/O Context */
{
	/* Init data and Clock to output lines */
	/* Set Data low */
	I2C_DATA_OUT(IoC);
	I2C_DATA_LOW(IoC);

	SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT));

	/* Set Clock high */
	I2C_CLK_HIGH(IoC);

	SkDgWaitTime(IoC, NS2BCLK(T_STOP_SETUP));

	/*
	 * Set Data High:	Do it by setting the Data Line to Input.
	 *			Because of a pull up resistor the Data Line
	 *			floods to high.
	 */
	I2C_DATA_IN(IoC);

	/*
	 *	When I2C activity is stopped
	 *	 o	DATA should be set to input and
	 *	 o	CLOCK should be set to high!
	 */
	SkDgWaitTime(IoC, NS2BCLK(T_BUS_IDLE));
}	/* SkI2cStop */
Example #2
0
/*
 * Receive just one bit via the I2C bus.
 *
 * Note:	Clock must be set to LOW before calling this function.
 *
 * Returns The received bit.
 */
int SkI2cRcvBit(
    SK_IOC	IoC)	/* I/O Context */
{
    int	Bit;
    SK_U8	I2cSwCtrl;

    /* Init data as input line */
    I2C_DATA_IN(IoC);

    SkDgWaitTime(IoC, NS2BCLK(T_CLK_2_DATA_OUT));

    I2C_CLK_HIGH(IoC);

    SkDgWaitTime(IoC, NS2BCLK(T_CLK_HIGH));

    SK_I2C_GET_SW(IoC, &I2cSwCtrl);
    if (I2cSwCtrl & I2C_DATA) {
        Bit = 1;
    } else {
        Bit = 0;
    }

    I2C_CLK_LOW(IoC);
    SkDgWaitTime(IoC, NS2BCLK(T_CLK_LOW-T_CLK_2_DATA_OUT));

    return(Bit);
}	/* SkI2cRcvBit */