PreviousNext
DpaApiI2Cinit
Help > Custom DPA Handler > DPA API > DpaApiI2Cinit

void DpaApiI2Cinit( uns8 frequency )

 

This function initializes the I2C bus at master mode. The SCL line is available at GPIO RC3 and SDA line at RC4 respectively at devices based on D series IQRF transceivers. Make sure the pull-ups are connected to both these lines. The parameter frequency specifies the required I2C frequency. The parameter is prepared using the I2CcomputeFrequency macro.

 

The following example shows a typical use of I2C functions:

 

DpaApiI2Cinit( I2CcomputeFrequency( 100000 /* Hz */ ) );

 

_DpaApiI2Cstart( 0b1001011.0 /* MCP9802 8bit write address */ );

DpaApiI2Cwrite( 0 /* pointer: 0 = temperature */ );

_DpaApiI2Cstop();

 

_DpaApiI2Cstart( 0b1001011.1 /* MCP9802 8bit read address */ );

int16 temperature;

temperature.high8 = _DpaApiI2Cread( 1 );

temperature.low8 = _DpaApiI2Cread( 0 );

_DpaApiI2Cstop();

 

DpaApiI2Cshutdown();