/*********************************************************************************************************************** * 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) 2012, 2021 Renesas Electronics Corporation. All rights reserved. ***********************************************************************************************************************/ /*********************************************************************************************************************** * File Name : r_cg_timer.c * Version : CodeGenerator for RL78/F13 V2.03.07.02 [08 Nov 2021] * Device(s) : R5F10AGF * Tool-Chain : CCRL * Description : This file implements device driver for TAU module. * Creation Date: 2023-11-24 ***********************************************************************************************************************/ /*********************************************************************************************************************** Includes ***********************************************************************************************************************/ #include "r_cg_macrodriver.h" #include "r_cg_timer.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" /*********************************************************************************************************************** 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 */ /* End user code. Do not edit comment generated here */ /*********************************************************************************************************************** * Function Name: R_TAU0_Create * Description : This function initializes the TAU0 module. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TAU0_Create(void) { TAU0EN = 1U; /* supplies input clock */ TPS0 = _0000_TAU_CKM0_FCLK_0 | _0000_TAU_CKM1_FCLK_0 | _0000_TAU_CKM2_FCLK_0 | _0000_TAU_CKM3_FCLK_0; /* Stop all channels */ TT0 = _0001_TAU_CH0_STOP_TRG_ON | _0002_TAU_CH1_STOP_TRG_ON | _0004_TAU_CH2_STOP_TRG_ON | _0008_TAU_CH3_STOP_TRG_ON | _0010_TAU_CH4_STOP_TRG_ON | _0020_TAU_CH5_STOP_TRG_ON | _0040_TAU_CH6_STOP_TRG_ON | _0080_TAU_CH7_STOP_TRG_ON | _0200_TAU_CH1_H8_STOP_TRG_ON | _0800_TAU_CH3_H8_STOP_TRG_ON; PWMDLY1 = _0000_TAU_PWM_DELAY_CLEAR; /* clear PWM output delay */ /* Mask channel 0 interrupt */ TMMK00 = 1U; /* disable INTTM00 interrupt */ TMIF00 = 0U; /* clear INTTM00 interrupt flag */ /* Mask channel 1 interrupt */ TMMK01 = 1U; /* disable INTTM01 interrupt */ TMIF01 = 0U; /* clear INTTM01 interrupt flag */ /* Mask channel 1 higher 8 bits interrupt */ TMMK01H = 1U; /* disable INTTM01H interrupt */ TMIF01H = 0U; /* clear INTTM01H interrupt flag */ /* Mask channel 2 interrupt */ TMMK02 = 1U; /* disable INTTM02 interrupt */ TMIF02 = 0U; /* clear INTTM02 interrupt flag */ /* Mask channel 3 interrupt */ TMMK03 = 1U; /* disable INTTM03 interrupt */ TMIF03 = 0U; /* clear INTTM03 interrupt flag */ /* Mask channel 3 higher 8 bits interrupt */ TMMK03H = 1U; /* disable INTTM03H interrupt */ TMIF03H = 0U; /* clear INTTM03H interrupt flag */ /* Mask channel 4 interrupt */ TMMK04 = 1U; /* disable INTTM04 interrupt */ TMIF04 = 0U; /* clear INTTM04 interrupt flag */ /* Mask channel 5 interrupt */ TMMK05 = 1U; /* disable INTTM05 interrupt */ TMIF05 = 0U; /* clear INTTM05 interrupt flag */ /* Mask channel 6 interrupt */ TMMK06 = 1U; /* disable INTTM06 interrupt */ TMIF06 = 0U; /* clear INTTM06 interrupt flag */ /* Mask channel 7 interrupt */ TMMK07 = 1U; /* disable INTTM07 interrupt */ TMIF07 = 0U; /* clear INTTM07 interrupt flag */ /* Set INTTM02 low priority */ TMPR102 = 1U; TMPR002 = 1U; /* Channel 0 is used as master channel for PWM output function */ TMR00 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_TRIGGER_SOFTWARE | _0001_TAU_MODE_PWM_MASTER; TDR00 = _3E7F_TAU_TDR00_VALUE; TO0 &= ~_0001_TAU_CH0_OUTPUT_VALUE_1; TOE0 &= ~_0001_TAU_CH0_OUTPUT_ENABLE; /* Channel 1 is used as slave channel for PWM output function */ TMR01 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; TDR01 = _0000_TAU_TDR01_VALUE; TOM0 |= _0002_TAU_CH1_OUTPUT_COMBIN; TOL0 &= ~_0002_TAU_CH1_OUTPUT_LEVEL_L; TO0 &= ~_0002_TAU_CH1_OUTPUT_VALUE_1; PWMDLY1 |= _0000_TO01_OUTPUT_DELAY_0; TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE; /* Channel 3 is used as slave channel for PWM output function */ TMR03 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; TDR03 = _0000_TAU_TDR03_VALUE; TOM0 |= _0008_TAU_CH3_OUTPUT_COMBIN; TOL0 &= ~_0008_TAU_CH3_OUTPUT_LEVEL_L; TO0 &= ~_0008_TAU_CH3_OUTPUT_VALUE_1; PWMDLY1 |= _0000_TO03_OUTPUT_DELAY_0; TOE0 |= _0008_TAU_CH3_OUTPUT_ENABLE; /* Channel 7 is used as slave channel for PWM output function */ TMR07 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | _0400_TAU_TRIGGER_MASTER_INT | _0009_TAU_MODE_PWM_SLAVE; TDR07 = _0000_TAU_TDR07_VALUE; TOM0 |= _0080_TAU_CH7_OUTPUT_COMBIN; TOL0 &= ~_0080_TAU_CH7_OUTPUT_LEVEL_L; TO0 &= ~_0080_TAU_CH7_OUTPUT_VALUE_1; PWMDLY1 |= _0000_TO07_OUTPUT_DELAY_0; TOE0 |= _0080_TAU_CH7_OUTPUT_ENABLE; /* Channel 2 used as interval timer */ TMR02 = _0000_TAU_CLOCK_SELECT_CKM0 | _0000_TAU_CLOCK_MODE_CKS | _0000_TAU_COMBINATION_SLAVE | _0000_TAU_TRIGGER_SOFTWARE | _0000_TAU_MODE_INTERVAL_TIMER | _0000_TAU_START_INT_UNUSED; TDR02 = _7CFF_TAU_TDR02_VALUE; TOM0 &= ~_0004_TAU_CH2_OUTPUT_COMBIN; TOL0 &= ~_0004_TAU_CH2_OUTPUT_LEVEL_L; TO0 &= ~_0004_TAU_CH2_OUTPUT_VALUE_1; TOE0 &= ~_0004_TAU_CH2_OUTPUT_ENABLE; /* Set TO01 pin */ P3 &= 0xFEU; PM3 &= 0xFEU; /* Set TO03 pin */ P12 &= 0xDFU; PM12 &= 0xDFU; /* Set TO07 pin */ POM12 &= 0xFEU; P12 &= 0xFEU; PM12 &= 0xFEU; } /*********************************************************************************************************************** * Function Name: R_TAU0_Channel0_Start * Description : This function starts TAU0 channel 0 counter. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TAU0_Channel0_Start(void) { TOE0 |= _0002_TAU_CH1_OUTPUT_ENABLE | _0008_TAU_CH3_OUTPUT_ENABLE | _0080_TAU_CH7_OUTPUT_ENABLE; TS0 |= _0001_TAU_CH0_START_TRG_ON | _0002_TAU_CH1_START_TRG_ON | _0008_TAU_CH3_START_TRG_ON | _0080_TAU_CH7_START_TRG_ON; } /*********************************************************************************************************************** * Function Name: R_TAU0_Channel0_Stop * Description : This function stops TAU0 channel 0 counter. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TAU0_Channel0_Stop(void) { TT0 |= _0001_TAU_CH0_STOP_TRG_ON | _0002_TAU_CH1_STOP_TRG_ON | _0008_TAU_CH3_STOP_TRG_ON | _0080_TAU_CH7_STOP_TRG_ON; TOE0 &= ~_0002_TAU_CH1_OUTPUT_ENABLE & ~_0008_TAU_CH3_OUTPUT_ENABLE & ~_0080_TAU_CH7_OUTPUT_ENABLE; } /*********************************************************************************************************************** * Function Name: R_TAU0_Channel2_Start * Description : This function starts TAU0 channel 2 counter. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TAU0_Channel2_Start(void) { TMIF02 = 0U; /* clear INTTM02 interrupt flag */ TMMK02 = 0U; /* enable INTTM02 interrupt */ TS0 |= _0004_TAU_CH2_START_TRG_ON; } /*********************************************************************************************************************** * Function Name: R_TAU0_Channel2_Stop * Description : This function stops TAU0 channel 2 counter. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TAU0_Channel2_Stop(void) { TT0 |= _0004_TAU_CH2_STOP_TRG_ON; /* Mask channel 2 interrupt */ TMMK02 = 1U; /* disable INTTM02 interrupt */ TMIF02 = 0U; /* clear INTTM02 interrupt flag */ } /*********************************************************************************************************************** * Function Name: R_TMR_RJ0_Create * Description : This function initializes the TMRJ0 module. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TMR_RJ0_Create(void) { TRJ0EN = 1U; /* enable input clock supply */ TRJCR0 &= (uint8_t)~_01_TMRJ_COUNT_START; /* disable TMRJ0 operation */ TRJMK0 = 1U; /* disable INTTRJ0 interrupt */ TRJIF0 = 0U; /* clear INTTRJ0 interrupt flag */ /* Set INTTRJ0 low priority */ TRJPR10 = 1U; TRJPR00 = 1U; TRJMR0 = _00_TMRJ_MODE_TIMER | _00_TMRJ_COUNT_SOURCE_FCLK; TRJIOC0 = _00_TMRJ_TRJIOC_INITIAL_VALUE; TRJ0 = _0C7F_TMRJ_TRJ0_VALUE; } /*********************************************************************************************************************** * Function Name: R_TMR_RJ0_Start * Description : This function starts TMRJ0 counter. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TMR_RJ0_Start(void) { TRJIF0 = 0U; /* clear INTTRJ0 interrupt flag */ TRJMK0 = 0U; /* enable INTTRJ0 interrupt */ TRJCR0 |= _01_TMRJ_COUNT_START; /* enable TMRJ operation */ } /*********************************************************************************************************************** * Function Name: R_TMR_RJ0_Stop * Description : This function stops TMRJ0 counter. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_TMR_RJ0_Stop(void) { TRJCR0 &= (uint8_t)~_01_TMRJ_COUNT_START; /* disable TMRJ operation */ TRJMK0 = 1U; /* disable INTTRJ0 interrupt */ TRJIF0 = 0U; /* clear INTTRJ0 interrupt flag */ } /* Start user code for adding. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */