/*********************************************************************************************************************** * DISCLAIMER * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. * No other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all * applicable laws, including copyright laws. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIESREGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED * OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY * LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE FOR ANY DIRECT, * INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR * ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability * of this software. By using this software, you agree to the additional terms and conditions found by accessing the * following link: * http://www.renesas.com/disclaimer * * Copyright (C) 2011, 2016 Renesas Electronics Corporation. All rights reserved. ***********************************************************************************************************************/ /*********************************************************************************************************************** * File Name : r_main.c * Version : CodeGenerator for RL78/G13 V2.03.04.01 [11 Nov 2016] * Device(s) : R5F100LG * Tool-Chain : CCRL * Description : This file implements main function. * Creation Date: 2017/03/15 ***********************************************************************************************************************/ /*********************************************************************************************************************** Includes ***********************************************************************************************************************/ #include "r_cg_macrodriver.h" #include "r_cg_cgc.h" #include "r_cg_serial.h" /* Start user code for include. Do not edit comment generated here */ #include "UART0.h" #include /* End user code. Do not edit comment generated here */ #include "r_cg_userdefine.h" /*********************************************************************************************************************** Pragma directive ***********************************************************************************************************************/ /* Start user code for pragma. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ /*********************************************************************************************************************** Global variables and functions ***********************************************************************************************************************/ /* Start user code for global. Do not edit comment generated here */ volatile uint8_t g_rx_ready_flag; /* 受信完了フラグ */ volatile uint8_t static g_rx_buff2[16]; /* 受信データ・バッファ */ volatile uint8_t g_tx_ready_flag; /* 送信可能フラグ */ volatile uint8_t static g_tx_buff[16]; /* 送信データ・バッファ */ volatile uint8_t static buff_work[20]; #if 0 static uint8_t const test_data[2][16] = { {0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, 0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F}, {0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, 0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F} }; #endif /* End user code. Do not edit comment generated here */ void R_MAIN_UserInit(void); /*********************************************************************************************************************** * Function Name: main * Description : This function implements main function. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void main(void) { R_MAIN_UserInit(); /* Start user code. Do not edit comment generated here */ { #if 1 char buff[80]; for(;;) { printf( "Hello!\r\nPlease enter a word or phrase:\n" ); scanf( "%[^\n]", (char __far *)buff ); printf( "Echo back:\n%s\n\n", (char __far *)buff ); } #elif 0 char buff[80]; for(;;) { puts( "Hello!\r\nPlease enter a word or phrase:" ); gets( buff ); puts( "Echo back:" ); puts( buff ); puts( "\n" ); } #elif 0 uint8_t const *pt_txdata; uint8_t work; while( 0x00 == g_tx_ready_flag ) /* 送信完了待ち */ { NOP(); } g_tx_ready_flag = 0x00; /* 送信完了フラグをクリア */ pt_txdata = &test_data[0][0]; /* 送信ポインタを設定 */ R_UART0_Send( (uint8_t *)pt_txdata, 0x10 ); /* データ送信処理開始 */ while( 0x00 == g_tx_ready_flag ) /* 送信完了待ち */ { NOP(); } work = chk_status(); /* リングバッファ状態確認 */ buff_work[0] = work; NOP(); work = get_blk( (uint8_t *)g_rx_buff2, 0x11 ); /* リングバッファから読み出し*/ buff_work[1] = work; NOP(); work = chk_status(); /* リングバッファ状態確認 */ buff_work[2] = work; pt_txdata = &test_data[1][0]; /* 送信ポインタを設定 */ g_tx_ready_flag = 0x00; /* 送信完了フラグをクリア */ R_UART0_Send( (uint8_t *)pt_txdata, 0x08 ); /* データ送信処理開始 */ while( 0x00 == g_tx_ready_flag ) /* 送信完了待ち */ { NOP(); } while ( 0x00 == chk_status() ); buff_work[3] = chk_status(); NOP(); work = get_data(); buff_work[4] = work; NOP(); g_tx_ready_flag = 0x00; /* 送信完了フラグをクリア */ pt_txdata = &test_data[1][8]; /* 送信ポインタを設定 */ R_UART0_Send( (uint8_t *)pt_txdata, 0x08 ); /* データ送信処理開始 */ while( 0x00 == g_tx_ready_flag ) /* 送信完了待ち */ { NOP(); } buff_work[5] = chk_status(); NOP(); while ( 0x00 == chk_status() ); NOP(); work = get_data(); buff_work[6] = work; NOP(); work = chk_status(); /* リングバッファ状態確認 */ buff_work[7] = work; work = get_blk( (uint8_t *)g_rx_buff2, work ); /* リングバッファから読み出し*/ NOP(); work = chk_status(); /* リングバッファ状態確認 */ buff_work[8] = work; NOP(); HALT(); NOP(); #endif } /* End user code. Do not edit comment generated here */ } /*********************************************************************************************************************** * Function Name: R_MAIN_UserInit * Description : This function adds user code before implementing main function. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_MAIN_UserInit(void) { /* Start user code. Do not edit comment generated here */ R_UART0_Start(); /* UART0動作起動 */ init_bf(); /* リングバッファを初期化 */ g_tx_ready_flag = 0x01; /* 送信完了フラグをセット */ EI(); /* End user code. Do not edit comment generated here */ } /* Start user code for adding. Do not edit comment generated here */ /*********************************************************************************************************************** * Function Name: putchar * Description : Low level layer for printf and puts ***********************************************************************************************************************/ int putchar(int c) { while( 0x00 == g_tx_ready_flag ) /* 送信完了待ち */ { NOP(); } g_tx_ready_flag = 0x00; /* 送信完了フラグをクリア */ R_UART0_Send( (uint8_t *)&c, 1 ); /* データ送信処理開始 */ return c; } /*********************************************************************************************************************** * Function Name: getchar * Description : Low level layer for scanf and gets ***********************************************************************************************************************/ int getchar(void) { while ( 0x00 == chk_status() ); NOP(); return get_data(); } /* End user code. Do not edit comment generated here */