/******************************************************************************* * 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 * (c) 2014 Renesas Electronics Corporation All rights reserved. *******************************************************************************/ /****************************************************************************** * File Name : r_csig.c * Version : 1.0 * Device(s) : R7F701007 RH850/F1L * Tool-Chain : IAR Embedded Workbench 1.30.1 * Description : This file is a sample of the CSIG communication. * Operation : - ******************************************************************************* ******************************************************************************* * History : DD.MM.YYYY Version Description * : 20.03.2014 1.00 First Release ******************************************************************************/ #define __R_CSIG_C_ /****************************************************************************** Includes ******************************************************************************/ #include "r_typedefs.h" #include "iodefine.h" #ifdef __ghs__ #include "device.h" #endif #ifdef __IAR_SYSTEMS_ICC__ #include #endif #include "r_csig.h" /****************************************************************************** Imported global variables and functions (from other files) ******************************************************************************/ /****************************************************************************** Macro definitions ******************************************************************************/ typedef enum { CSIG_CH0 = 0, CSIG_CH1, CSIG_CH_MAX } CSIG_CH; typedef struct { CSIG_CALLBACK_POINTER fp_intr_ic; CSIG_CALLBACK_POINTER fp_intr_ir; CSIG_CALLBACK_POINTER fp_intr_ire; } CSIG_CALLBACK_INTP; /* define value for interrupt */ #define INTP_RF_BIT (0x1000) #define INTP_MK_BIT (0x0080) #define INTP_TB_BIT (0x0040) #define INTP_PRIORITY_VALUE (0x0007) #define INTP_ENABLE_VALUE ( INTP_TB_BIT | INTP_PRIORITY_VALUE ) /*0x0047*/ #define INTP_DISABLE_VALUE (INTP_MK_BIT | INTP_TB_BIT | INTP_PRIORITY_VALUE ) /*0x00C7*/ /****************************************************************************** Exported global variables and functions (to be accessed by other files) ******************************************************************************/ /****************************************************************************** Private global variables and functions ******************************************************************************/ static CSIG_CALLBACK_INTP stCSIG_CB[CSIG_CH_MAX]; /****************************************************************************** * Function Name : void R_csig0_master_transmission_initialize( void ) * Description : This function initializes the CSIG0. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_transmission_initialize( void ) { /* callback function pointer initializes */ stCSIG_CB[CSIG_CH0].fp_intr_ic = NULL; stCSIG_CB[CSIG_CH0].fp_intr_ir = NULL; stCSIG_CB[CSIG_CH0].fp_intr_ire = NULL; /* CSI setting */ CSIG0.CTL0.UINT8 = 0x00; CSIG0.CTL1 = 0x00010000; CSIG0.CTL2 = 0x0004; CSIG0.CFG0 = 0x00000000; CSIG0.BCTL0.UINT8 = 0x00; } /****************************************************************************** * Function Name : void R_csig0_master_transmission_enable( void ) * Description : This function enable transmission mode using the CSIG0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_transmission_enable( void ) { /* interrupt setting */ ICCSIG0IC = INTP_DISABLE_VALUE; ICCSIG0IR = INTP_DISABLE_VALUE; ICCSIG0IRE = INTP_DISABLE_VALUE; if( stCSIG_CB[CSIG_CH0].fp_intr_ic != NULL ) { ICCSIG0IC = INTP_ENABLE_VALUE; } if( stCSIG_CB[CSIG_CH0].fp_intr_ire != NULL ) { ICCSIG0IRE = INTP_ENABLE_VALUE; } /* transmission start */ CSIG0.CTL0.UINT8 = 0xC1; } /****************************************************************************** * Function Name : void R_csig0_master_transmission_disable( void ) * Description : This function disable transmission mode using the CSIG0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_transmission_disable( void ) { /* interrupt setting */ ICCSIG0IC = INTP_DISABLE_VALUE; ICCSIG0IR = INTP_DISABLE_VALUE; ICCSIG0IRE = INTP_DISABLE_VALUE; /* transmission stop */ CSIG0.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csig0_master_transmit( uint16_t uint16_tx ) * Description : This function transmits data using the CSIG0 in master mode. * Argument : uint16_t uint16_tx: transmission data * Return Value : none ******************************************************************************/ void R_csig0_master_transmit( uint16_t uint16_tx ) { CSIG0.TX0H = uint16_tx; } /****************************************************************************** * Function Name : void R_csig0_master_reception_initialize( void ) * Description : This function initializes the CSIG0. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_reception_initialize( void ) { /* callback function pointer initializes */ stCSIG_CB[CSIG_CH0].fp_intr_ic = NULL; stCSIG_CB[CSIG_CH0].fp_intr_ir = NULL; stCSIG_CB[CSIG_CH0].fp_intr_ire = NULL; /* CSI setting */ CSIG0.CTL0.UINT8 = 0x00; CSIG0.CTL1 = 0x00000002; CSIG0.CTL2 = 0x0004; CSIG0.CFG0 = 0x00000000; CSIG0.BCTL0.UINT8 = 0x00; } /****************************************************************************** * Function Name : void R_csig0_master_reception_enable( void ) * Description : This function enable reception mode using the CSIG0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_reception_enable( void ) { /* interrupt setting */ ICCSIG0IC = INTP_DISABLE_VALUE; ICCSIG0IR = INTP_DISABLE_VALUE; ICCSIG0IRE = INTP_DISABLE_VALUE; if( stCSIG_CB[CSIG_CH0].fp_intr_ir != NULL ) { ICCSIG0IR = INTP_ENABLE_VALUE; } if( stCSIG_CB[CSIG_CH0].fp_intr_ire != NULL ) { ICCSIG0IRE = INTP_ENABLE_VALUE; } /* reception start */ CSIG0.CTL0.UINT8 = 0xA1; } /****************************************************************************** * Function Name : void R_csig0_master_reception_disable( void ) * Description : This function disable reception mode using the CSIG0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_reception_disable( void ) { /* interrupt setting */ ICCSIG0IC = INTP_DISABLE_VALUE; ICCSIG0IR = INTP_DISABLE_VALUE; ICCSIG0IRE = INTP_DISABLE_VALUE; /* reception stop */ CSIG0.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csig0_master_receive( void ) * Description : This function receives data using the CSIG0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig0_master_receive( void ) { volatile uint16_t uint16_dummy; /* reception trigger */ CSIG0.BCTL0.UINT8 = 0x01; uint16_dummy = CSIG0.RX0; } /****************************************************************************** * Function Name : void R_csig0_interrupt_callback * Description : Callback function register. * Argument : CSIG_CALLBACK_POINTER p_intr_ic * CSIG_CALLBACK_POINTER p_intr_ir * CSIG_CALLBACK_POINTER p_intr_ire * Return Value : none ******************************************************************************/ void R_csig0_interrupt_callback( CSIG_CALLBACK_POINTER fp_intr_ic, CSIG_CALLBACK_POINTER fp_intr_ir, CSIG_CALLBACK_POINTER fp_intr_ire ) { /* callback function register */ stCSIG_CB[CSIG_CH0].fp_intr_ic = fp_intr_ic; stCSIG_CB[CSIG_CH0].fp_intr_ir = fp_intr_ir; stCSIG_CB[CSIG_CH0].fp_intr_ire = fp_intr_ire; } /****************************************************************************** * Function Name : void R_csig1_slave_transmission_initialize( void ) * Description : This function initializes the CSIG1. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_transmission_initialize( void ) { /* callback function pointer initializes */ stCSIG_CB[CSIG_CH1].fp_intr_ic = NULL; stCSIG_CB[CSIG_CH1].fp_intr_ir = NULL; stCSIG_CB[CSIG_CH1].fp_intr_ire = NULL; /* CSI setting */ CSIG1.CTL0.UINT8 = 0x00; CSIG1.CTL1 = 0x00010002; CSIG1.CTL2 = 0xE000; CSIG1.CFG0 = 0x00000000; CSIG1.BCTL0.UINT8 = 0x00; } /****************************************************************************** * Function Name : void R_csig1_slave_transmission_enable( void ) * Description : This function enable transmission mode using the CSIG1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_transmission_enable( void ) { /* interrupt setting */ ICCSIG1IC = INTP_DISABLE_VALUE; ICCSIG1IR = INTP_DISABLE_VALUE; ICCSIG1IRE = INTP_DISABLE_VALUE; if( stCSIG_CB[CSIG_CH1].fp_intr_ic != NULL ) { ICCSIG1IC = INTP_ENABLE_VALUE; } if( stCSIG_CB[CSIG_CH1].fp_intr_ire != NULL ) { ICCSIG1IRE = INTP_ENABLE_VALUE; } /* transmission start */ CSIG1.CTL0.UINT8 = 0xC1; } /****************************************************************************** * Function Name : void R_csig1_slave_transmission_disable( void ) * Description : This function disable transmission mode using the CSIG1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_transmission_disable( void ) { /* interrupt setting */ ICCSIG1IC = INTP_DISABLE_VALUE; ICCSIG1IR = INTP_DISABLE_VALUE; ICCSIG1IRE = INTP_DISABLE_VALUE; /* transmission stop */ CSIG1.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csig1_slave_transmit( uint16_t uint16_tx ) * Description : This function transmits data using the CSIG1 in slave mode. * Argument : uint16_t uint16_tx: transmission data * Return Value : none ******************************************************************************/ void R_csig1_slave_transmit( uint16_t uint16_tx ) { CSIG1.TX0H = uint16_tx; } /****************************************************************************** * Function Name : void R_csig1_slave_reception_initialize( void ) * Description : This function initializes the CSIG1. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_reception_initialize( void ) { /* callback function pointer initializes */ stCSIG_CB[CSIG_CH1].fp_intr_ic = NULL; stCSIG_CB[CSIG_CH1].fp_intr_ir = NULL; stCSIG_CB[CSIG_CH1].fp_intr_ire = NULL; /* CSI setting */ CSIG1.CTL0.UINT8 = 0x00; CSIG1.CTL1 = 0x00000000; CSIG1.CTL2 = 0xE000; CSIG1.CFG0 = 0x00000000; CSIG1.BCTL0.UINT8 = 0x00; } /****************************************************************************** * Function Name : void R_csig1_slave_reception_enable( void ) * Description : This function enable reception mode using the CSIG1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_reception_enable( void ) { /* interrupt setting */ ICCSIG1IC = INTP_DISABLE_VALUE; ICCSIG1IR = INTP_DISABLE_VALUE; ICCSIG1IRE = INTP_DISABLE_VALUE; if( stCSIG_CB[CSIG_CH1].fp_intr_ir != NULL ) { ICCSIG1IR = INTP_ENABLE_VALUE; } if( stCSIG_CB[CSIG_CH1].fp_intr_ire != NULL ) { ICCSIG1IRE = INTP_ENABLE_VALUE; } /* reception start */ CSIG1.CTL0.UINT8 = 0xA1; } /****************************************************************************** * Function Name : void R_csig1_slave_reception_disable( void ) * Description : This function disable reception mode using the CSIG1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_reception_disable( void ) { /* interrupt setting */ ICCSIG1IC = INTP_DISABLE_VALUE; ICCSIG1IR = INTP_DISABLE_VALUE; ICCSIG1IRE = INTP_DISABLE_VALUE; /* reception stop */ CSIG1.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csig1_slave_receive( void ) * Description : This function receives data using the CSIG1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csig1_slave_receive( void ) { } /****************************************************************************** * Function Name : void R_csig1_interrupt_callback * Description : Callback function register. * Argument : CSIG_CALLBACK_POINTER p_intr_ic * CSIG_CALLBACK_POINTER p_intr_ir * CSIG_CALLBACK_POINTER p_intr_ire * Return Value : none ******************************************************************************/ void R_csig1_interrupt_callback( CSIG_CALLBACK_POINTER fp_intr_ic, CSIG_CALLBACK_POINTER fp_intr_ir, CSIG_CALLBACK_POINTER fp_intr_ire ) { /* callback function register */ stCSIG_CB[CSIG_CH1].fp_intr_ic = fp_intr_ic; stCSIG_CB[CSIG_CH1].fp_intr_ir = fp_intr_ir; stCSIG_CB[CSIG_CH1].fp_intr_ire = fp_intr_ire; } /****************************************************************************** * Function Name : void intr_csig0ic_function( void ) * Description : This function is INTCSIG0IC interrupt processing. (table refer.) * : INTCSIG0IC * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csig0ic_function( enable=false , channel=19 , callt=false , fpu=false ) #endif void intr_csig0ic_function( void ) { if( stCSIG_CB[CSIG_CH0].fp_intr_ic != NULL ) { (stCSIG_CB[CSIG_CH0].fp_intr_ic)(); } } /****************************************************************************** * Function Name : void intr_csig0ir_function( void ) * Description : This function is INTCSIG0IR interrupt processing. (table refer.) * : INTCSIG0IR * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csig0ir_function( enable=false , channel=20 , callt=false , fpu=false ) #endif void intr_csig0ir_function( void ) { if( stCSIG_CB[CSIG_CH0].fp_intr_ir != NULL ) { (stCSIG_CB[CSIG_CH0].fp_intr_ir)(); } } /****************************************************************************** * Function Name : void intr_csig0ire_function( void ) * Description : This function is INTCSIG0IRE interrupt processing. (table refer.) * : INTCSIG0IRE * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csig0ire_function( enable=false , channel=49 , callt=false , fpu=false ) #endif void intr_csig0ire_function( void ) { if( stCSIG_CB[CSIG_CH0].fp_intr_ire != NULL ) { (stCSIG_CB[CSIG_CH0].fp_intr_ire)(); } } /****************************************************************************** * Function Name : void intr_csig1ic_function( void ) * Description : This function is INTCSIG1IC interrupt processing. (table refer.) * : INTCSIG1IC * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csig1ic_function( enable=false , channel=215 , callt=false , fpu=false ) #endif void intr_csig1ic_function( void ) { if( stCSIG_CB[CSIG_CH1].fp_intr_ic != NULL ) { (stCSIG_CB[CSIG_CH1].fp_intr_ic)(); } } /****************************************************************************** * Function Name : void intr_csig1ir_function( void ) * Description : This function is INTCSIG1IR interrupt processing. (table refer.) * : INTCSIG1IR * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csig1ir_function( enable=false , channel=216 , callt=false , fpu=false ) #endif void intr_csig1ir_function( void ) { if( stCSIG_CB[CSIG_CH1].fp_intr_ir != NULL ) { (stCSIG_CB[CSIG_CH1].fp_intr_ir)(); } } /****************************************************************************** * Function Name : void intr_csig1ire_function( void ) * Description : This function is INTCSIG1IRE interrupt processing. (table refer.) * : INTCSIG1IRE * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csig1ire_function( enable=false , channel=217 , callt=false , fpu=false ) #endif void intr_csig1ire_function( void ) { if( stCSIG_CB[CSIG_CH1].fp_intr_ire != NULL ) { (stCSIG_CB[CSIG_CH1].fp_intr_ire)(); } }