使用例(スレーブ送信)

4Byteデータのスレーブ送信を行う

 

[GUI設定例]

シリアル

使用する

IICA0

使用する

転送モード

スレーブ

Slave0

カウント・クロック設定

fCLK/2

自局アドレス設定

0xA0

動作モード設定

標準

ウェイクアップ機能設定

オフ

通信完了割り込み優先順位(INTIICA0)

スレーブ送信完了(コールバック機能設定)

使用する

スレーブ受信完了(コールバック機能設定)

使用しない

スレーブ・エラー(コールバック機能設定)

使用しない

 

 

[API設定例]

r_main.c

/* Start user code for global. Do not edit comment generated here */

volatile uint8_t g_iica0_tx_buf[4] = { 'A', 'B', 'C', 'D' };

/* End user code. Do not edit comment generated here */

 

void main(void)

{

       R_MAIN_UserInit();

       /* Start user code. Do not edit comment generated here */

       /* Send data as slave mode */

       R_IICA0_Slave_Send((uint8_t *)g_iica0_tx_buf, 4U);

 

       while (1U)

       {

              ;

       }

       /* End user code. Do not edit comment generated here */

}

 

r_cg_serial_user.c

static void r_iica0_callback_slave_sendend(void)

{

       /* Start user code. Do not edit comment generated here */

       /* Stop IICA0 module operation */

       R_IICA0_Stop();

       /* End user code. Do not edit comment generated here */

}

 

 

Config_RIIC0_user.c

/* Start user code for global. Do not edit comment generated here */

volatile uint8_t g_riic0_tx_buf[2];

volatile uint8_t g_riic0_tx_cnt;

/* End user code. Do not edit comment generated here */

 

void R_Config_RIIC0_Create_UserInit(void)

{

       /* Start user code for user init. Do not edit comment generated here */

       g_riic0_tx_cnt = 0U;

       g_riic0_tx_buf[0] = g_riic0_tx_cnt;

       g_riic0_tx_buf[1] = 0x01;

      /* End user code. Do not edit comment generated here */

}

 

static void r_Config_RIIC0_callback_transmitend(void)

{

       /* Start user code for r_Config_RIIC0_callback_transmitend. Do not edit comment generated here */

       if ((++g_riic0_tx_cnt) < 4U)

       {

              g_riic0_tx_buf[0] = g_riic0_tx_cnt;

              g_riic0_tx_buf[1] += 0x01;

 

              /* Send RIIC0 data to slave device */

              R_Config_RIIC0_Master_Send(0x00A0, (uint8_t *)g_riic0_tx_buf, 2U);

       }

       else

       {

              /* Stop the RIIC0 Bus Interface */

              R_Config_RIIC0_Stop();

       }

       /* End user code. Do not edit comment generated here */

}