User`s manual
RX62N Group, RX621 Group 5. Usage Examples
/* Read the status */
R_IIC_GetStatus(
SLAVE_CHANNEL,
&status_flags,
&tx_count,
&rx_count
);
/* Has the master just completed a write? */
if(rx_count != 0)
{
StoreData(rx_count);
/*Start monitoring again.*/
bStartMonitor = true;
}
/* Has the master just completed a read? */
else if(tx_count != 0)
{
/*Increment the current index by the amount the master read*/
data_storage_index += tx_count;
/*Start monitoring again.*/
bStartMonitor = true;
}
/* Is the master starting a read?
Check this by seeing if in transmit mode. */
else if(0 != (status_flags & BIT_6))
{
/* Send data to master based on current address */
R_IIC_SlaveSend(
SLAVE_CHANNEL,
&data_storage[data_storage_index],
(uint16_t)(STORAGE_SIZE - data_storage_index)
);
/* Don't start monitoring again until the R_IIC_SlaveSend completes. */
bStartMonitor = false;
}
if(true == bStartMonitor)
{
/* Continue monitoring */
R_IIC_SlaveMonitor(
SLAVE_CHANNEL,
PDL_NO_DATA,
Rx_Buffer,
RX_BUFFER_SIZE,
slave_callback,
7
);
}
}
/* The master has sent us data (now in the Rx_Buffer),
store it in the data_storage array. */
static void StoreData(uint16_t count)
{
uint16_t index = 0;
/* Update data_storage_index */
data_storage_index = Rx_Buffer[index];
count--;
index++;
R20UT0084EE0112 Rev.1.12 Page 5-60
July. 16, 2014