/*********************************************************************************************************************** * 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: ***********************************************************************************************************************/ /*********************************************************************************************************************** Includes ***********************************************************************************************************************/ #include "r_cg_macrodriver.h" #include "r_cg_cgc.h" #include "r_cg_serial.h" #include "r_cg_adc.h" #include "r_cg_timer.h" #include "r_cg_dmac.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_AdResult[1024]; /* A/D変換結果DMA転送先 */ 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]; /* 送信データ・バッファ */ /* 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 */ { int count; long repeat; R_ADC_Set_OperationOn(); for (count = 0U ; count < 32U ; count++) /* Waiting for comparator stabilizing */ { NOP(); } printf( "\nHit Any Key...\n\n" ); getchar(); for (;;) { printf( "Start 100000 times loop\n" ); for (repeat = 0; repeat < 100000; repeat++) { R_DMAC0_UserInit(); /* --- Start TAU and A/D Convert and DMA --- */ R_DMAC0_Start(); /* Enable DMA : Start waiting DMA trigger */ R_ADC_Start(); /* Enable A/D : Start waiting A/D trigger */ R_TAU0_Channel1_Lower8bits_Start(); /* Start! */ /* --- A/D converting now --- */ NOP(); /* for breakpoint, start singnal input on Simulator GUI */ while (R_DMAC0_Is_Running()) { ; } NOP(); /* for breakpoint, check timing chart on Simulator GUI */ /* --- Stop TAU and A/D Convert and DMA --- */ R_TAU0_Channel1_Lower8bits_Stop(); R_ADC_Stop(); R_DMAC0_Stop(); } printf( "Last g_AdResult[100]=%d, %d, %d, ... %d\n\n", g_AdResult[0], g_AdResult[1], g_AdResult[2], g_AdResult[99] ); } } /* 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 */