USER MANUAL RC188x-GPR
2019 Radiocrafts AS
RIIM User Manual (rev.1.2)
Page
16
of
23
8.7. I2C
The I2C module has functions needed for interfacing the I2C bus. It always operates as master, and support clock
stretching. It supports two speeds: 100KHz and 400KHz.
The following example demonstrates how the module is initialized and an example transmission towards a
Sensirion SHT35 Temperature/Humidity sensor.
Example : ICI code
static
void
ReadSensor
()
{
static
uint8_t
wbuf
[
2
];
static
uint8_t
rbuf
[
10
];
// The command 0x2C0D starts a Medium repeatibility measuring
// with clock stretching enabled. See Sensirion SHT35 datasheet.
wbuf
[
0
]=
0x2C
;
wbuf
[
1
]=
0x0D
;
I2C
.
transfer
(
0x44
,
wbuf
,
2
,
rbuf
,
7
);
.......
}
RIIM_SETUP
()
{
// Set up interface towards the SHT35-sensor
I2C
.
init
(
I2C_400KHZ
);
.........
return
UAPI_OK
;
}
Example 7 - I2C example code
The following functions are part of the I2C module.
Function
Description
init
(Speed)
Initializes the I2C driver with the chosen Speed
transfer
(SlaveAddress, WriteBuffer,
WriteLenth, ReadBuffer, ReadLength)
Transfers data both to and from the slave at bus address
SlaveAddress. Data is first written on bus, then read
read
(SlaveAddress, ReadBuffer,
ReadLength)
Perform only read on the I2C bus
write
(SlaveAddress, WriteBuffer,
WriteLength)
Perform only write on the I2C bus
Table 7 - I2C functions