/*********************************************************************************************************************** * 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) 2022 Renesas Electronics Corporation. All rights reserved. ***********************************************************************************************************************/ /*********************************************************************************************************************** * File Name : Config_SCI1_user.c * Component Version: 1.12.0 * Device(s) : R5F5651EDxFP * Description : This file implements device driver for Config_SCI1. ***********************************************************************************************************************/ /*********************************************************************************************************************** Pragma directive ***********************************************************************************************************************/ /* Start user code for pragma. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ /*********************************************************************************************************************** Includes ***********************************************************************************************************************/ #include "r_cg_macrodriver.h" #include "Config_SCI1.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 ***********************************************************************************************************************/ extern volatile uint8_t * gp_sci1_rx_address; /* SCI1 receive buffer address */ extern volatile uint16_t g_sci1_rx_count; /* SCI1 receive data number */ extern volatile uint16_t g_sci1_rx_length; /* SCI1 receive data length */ /* Start user code for global. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ /*********************************************************************************************************************** * Function Name: R_Config_SCI1_Create_UserInit * Description : This function adds user code after initializing the SCI1 channel * Arguments : None * Return Value : None ***********************************************************************************************************************/ void R_Config_SCI1_Create_UserInit(void) { /* Start user code for user init. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_transmit_interrupt * Description : This function is TXI1 interrupt service routine * Arguments : None * Return Value : None ***********************************************************************************************************************/ #if FAST_INTERRUPT_VECTOR == VECT_SCI1_TXI1 #pragma interrupt r_Config_SCI1_transmit_interrupt(vect=VECT(SCI1,TXI1),fint) #else #pragma interrupt r_Config_SCI1_transmit_interrupt(vect=VECT(SCI1,TXI1)) #endif static void r_Config_SCI1_transmit_interrupt(void) { r_Config_SCI1_callback_transmitend(); } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_transmitend_interrupt * Description : This function is TEI1 interrupt service routine * Arguments : None * Return Value : None ***********************************************************************************************************************/ void r_Config_SCI1_transmitend_interrupt(void) { r_Config_SCI1_callback_transmitend(); } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_receive_interrupt * Description : This function is RXI1 interrupt service routine * Arguments : None * Return Value : None ***********************************************************************************************************************/ #if FAST_INTERRUPT_VECTOR == VECT_SCI1_RXI1 #pragma interrupt r_Config_SCI1_receive_interrupt(vect=VECT(SCI1,RXI1),fint) #else #pragma interrupt r_Config_SCI1_receive_interrupt(vect=VECT(SCI1,RXI1)) #endif static void r_Config_SCI1_receive_interrupt(void) { if (g_sci1_rx_length > g_sci1_rx_count) { *gp_sci1_rx_address = SCI1.RDR; gp_sci1_rx_address++; g_sci1_rx_count++; } if (g_sci1_rx_length <= g_sci1_rx_count) { /* All data received */ SCI1.SCR.BIT.RIE = 0U; SCI1.SCR.BIT.RE = 0U; r_Config_SCI1_callback_receiveend(); } } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_receiveerror_interrupt * Description : This function is ERI1 interrupt service routine * Arguments : None * Return Value : None ***********************************************************************************************************************/ void r_Config_SCI1_receiveerror_interrupt(void) { uint8_t err_type; r_Config_SCI1_callback_receiveerror(); /* Clear overrun, framing and parity error flags */ err_type = SCI1.SSR.BYTE; err_type &= 0xC7U; err_type |= 0xC0U; SCI1.SSR.BYTE = err_type; } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_callback_transmitend * Description : This function is a callback function when SCI1 finishes transmission * Arguments : None * Return Value : None ***********************************************************************************************************************/ static void r_Config_SCI1_callback_transmitend(void) { /* Start user code for r_Config_SCI1_callback_transmitend. Do not edit comment generated here */ //スマートコンフィグレータ生成関数では、TXIとTEIどちらの割り込みもココに来てしまう extern volatile int g_sci1_txi_flag; extern volatile int g_dmac4_flag; if (SCI1.SSR.BIT.TEND == 0) { //TXI割り込み SCI1.SCR.BYTE |= 0x04; //TEIE=1 } else { //TEI割り込み SCI1.SCR.BYTE &= ~0xA4; //TE=TIE=TEIE=0 g_sci1_txi_flag = 1; //TXI要求準備OK if (g_dmac4_flag == 1) { //DMACの準備が整っている場合は送出要求 SCI1.SCR.BYTE |= 0xA0; //TE=TIE g_sci1_txi_flag = 0; } } /* End user code. Do not edit comment generated here */ } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_callback_receiveend * Description : This function is a callback function when SCI1 finishes reception * Arguments : None * Return Value : None ***********************************************************************************************************************/ static void r_Config_SCI1_callback_receiveend(void) { /* Start user code for r_Config_SCI1_callback_receiveend. Do not edit comment generated here */ /* End user code. Do not edit comment generated here */ } /*********************************************************************************************************************** * Function Name: r_Config_SCI1_callback_receiveerror * Description : This function is a callback function when SCI1 reception encounters error * Arguments : None * Return Value : None ***********************************************************************************************************************/ static void r_Config_SCI1_callback_receiveerror(void) { /* Start user code for r_Config_SCI1_callback_receiveerror. Do not edit comment generated here */ /* 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 */