title

◎温度湿度計 r_cg_rtc_user.c

r_cg_rtc_user.c リストを示します。 E2studioのタブとブラウザのタブ位置が異なり見づらいですがご了承下さい。 /* Start user code ~から /* End user code の間だけに記述します。
/***********************************************************************************************************************
    * 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 WARRANTIES REGARDING 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, 2021 Renesas Electronics Corporation. All rights reserved.
    ***********************************************************************************************************************/
    
    /***********************************************************************************************************************
    * File Name    : r_cg_rtc_user.c
    * Version      : CodeGenerator for RL78/G13 V2.05.06.02 [08 Nov 2021]
    * Device(s)    : R5F100LG
    * Tool-Chain   : GCCRL78
    * Description  : This file implements device driver for RTC module.
    * Creation Date: 2023/01/13
    ***********************************************************************************************************************/
    
    /***********************************************************************************************************************
    Includes
    ***********************************************************************************************************************/
    #include "r_cg_macrodriver.h"
    #include "r_cg_rtc.h"
    /* Start user code for include. Do not edit comment generated here */
    /* End user code. Do not edit comment generated here */
    #include "r_cg_userdefine.h"
    
    /***********************************************************************************************************************
    Global variables and functions
    ***********************************************************************************************************************/
    /* Start user code for global. Do not edit comment generated here */
    extern uint8_t one_min_flug;
    extern uint8_t five_sec_flug;
    extern uint8_t cnt_60;
    /* End user code. Do not edit comment generated here */
    
    /***********************************************************************************************************************
    * Function Name: r_rtc_interrupt
    * Description  : This function is INTRTC interrupt service routine.
    * Arguments    : None
    * Return Value : None
    ***********************************************************************************************************************/
    void r_rtc_interrupt(void)
    {
        if (1U == RIFG)
        {
            RTCC1 &= (uint8_t)~_08_RTC_INTC_GENERATE_FLAG;    /* clear RIFG */
            r_rtc_callback_constperiod();
        }
    }
    
    /***********************************************************************************************************************
    * Function Name: r_rtc_callback_constperiod
    * Description  : This function is real-time clock constant-period interrupt service handler.
    * Arguments    : None
    * Return Value : None
    ***********************************************************************************************************************/
    static void r_rtc_callback_constperiod(void)
    {
        /* Start user code. Do not edit comment generated here */
    
        static int cnt_5 =0;
    
    //	P7_bit.no1 = ~P7_bit.no1;			//動作確認用
        if(cnt_5 < 5){
            cnt_5++;
            }
    
        else{
            cnt_5 = 0;
            five_sec_flug = 1;
        }
    
        if(cnt_60 < 59){
            cnt_60++;
            }
    
        else{
            cnt_60 = 0;
            one_min_flug = 1;
        }
        /* End user code. Do not edit comment generated here */
    }
    
    /* Start user code for adding. Do not edit comment generated here */
    /* End user code. Do not edit comment generated here */
    

static void r_rtc_callback_constperiod(void)1秒ごとに起動される(初期設定の画面で1秒毎に割り込み設定しています)関数です。 2つのグローバル変数(フラグ)を扱います。一つは5秒毎に1になるfive_sec_flugともう一つは60秒毎に1になるone_min_flugです。 main関数内でフラグを読んで5秒毎の温度湿度の更新を60秒毎に時計の更新を行います。それぞれのフラグは表示更新時にmain関数内でクリアされます。

プログラムについて