1 选择 对应的芯片
2 Generate Code
3 Master transmission processing flow
#include "r_smc_entry.h"
static uint8_t tx_buf[10] = "0123456789";
volatile static uint8_t tx_flg;
void main(void);
void transmit_complete(void);
void main(void)
{
/* Start I2C Communication (Enable Interrupt) */
R_Config_RIIC0_Start();
/* Send I2C Data */
tx_flg = 0u;
R_Config_RIIC0_Master_Send(0x01, tx_buf, sizeof(tx_buf));
/* Waiting for transmission complete */
while (0u == tx_flg)
{
/* wait loop */
}
/* Stop I2C Communication (Disable Interrupt) */
R_Config_RIIC0_Stop();
}
void transmit_complete(void)
{
/* Set transmission complete flag */
tx_flg = 1u;
}
4 Master reception processing flow
#include "r_smc_entry.h"
static uint8_t rx_buf[10] = " ";
volatile static uint8_t rx_flg;
void main(void);
void receive_complete(void);
void main(void)
{
/* Start I2C Communication (Enable Interrupt) */
R_Config_RIIC0_Start();
/* Receive I2C Data */
rx_flg = 0u;
R_Config_RIIC0_Master_Receive(0x01, rx_buf, sizeof(rx_buf));
/* Waiting for reception complete */
while (0u == rx_flg)
{
/* wait loop */
}
/* Stop I2C Communication (Disable Interrupt) */
R_Config_RIIC0_Stop();
}
void receive_complete(void)
{
/* Set transmission complete flag */
rx_flg = 1u;
}