/******************************************************************************* * 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_csih.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 CSIH communication. * Operation : - ******************************************************************************* ******************************************************************************* * History : DD.MM.YYYY Version Description * : 20.03.2014 1.00 First Release ******************************************************************************/ #define __R_CSIH_C_ /****************************************************************************** Includes ******************************************************************************/ #include "r_typedefs.h" #include "iodefine.h" #ifdef __ghs__ #include "device.h" #endif #ifdef __IAR_SYSTEMS_ICC__ #include #endif #include "r_csih.h" /****************************************************************************** Imported global variables and functions (from other files) ******************************************************************************/ /****************************************************************************** Macro definitions ******************************************************************************/ typedef enum { CSIH_CH0 = 0, CSIH_CH1, CSIH_CH_MAX } CSIH_CH; typedef struct { CSIH_CALLBACK_POINTER fp_intr_ic; CSIH_CALLBACK_POINTER fp_intr_ijc; CSIH_CALLBACK_POINTER fp_intr_ir; CSIH_CALLBACK_POINTER fp_intr_ire; } CSIH_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 CSIH_CALLBACK_INTP stCSIH_CB[CSIH_CH_MAX]; /****************************************************************************** * Function Name : void R_csih0_master_transmission_initialize( void ) * Description : This function initializes the CSIH0. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_transmission_initialize( void ) { /* callback function pointer initializes */ stCSIH_CB[CSIH_CH0].fp_intr_ic = NULL; stCSIH_CB[CSIH_CH0].fp_intr_ijc = NULL; stCSIH_CB[CSIH_CH0].fp_intr_ir = NULL; stCSIH_CB[CSIH_CH0].fp_intr_ire = NULL; /* CSI setting */ CSIH0.CTL0.UINT8 = 0x00; CSIH0.CTL1 = 0x00010000; CSIH0.CTL2 = 0x0000; CSIH0.BRS0 = 0x0004; CSIH0.CFG0 = 0x00000000; CSIH0.MCTL0 = 0x00; } /****************************************************************************** * Function Name : void R_csih0_master_transmission_enable( void ) * Description : This function enable transmission mode using the CSIH0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_transmission_enable( void ) { /* interrupt setting */ ICCSIH0IC = INTP_DISABLE_VALUE; ICCSIH0IJC = INTP_DISABLE_VALUE; ICCSIH0IR = INTP_DISABLE_VALUE; ICCSIH0IRE = INTP_DISABLE_VALUE; if( stCSIH_CB[CSIH_CH0].fp_intr_ic != NULL ) { ICCSIH0IC = INTP_ENABLE_VALUE; } if( stCSIH_CB[CSIH_CH0].fp_intr_ijc != NULL ) { ICCSIH0IJC = INTP_ENABLE_VALUE; } if( stCSIH_CB[CSIH_CH0].fp_intr_ire != NULL ) { ICCSIH0IRE = INTP_ENABLE_VALUE; } /* transmission start */ CSIH0.CTL0.UINT8 = 0xC1; } /****************************************************************************** * Function Name : void R_csih0_master_transmission_disable( void ) * Description : This function disable transmission mode using the CSIH0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_transmission_disable( void ) { /* interrupt setting */ ICCSIH0IC = INTP_DISABLE_VALUE; ICCSIH0IJC = INTP_DISABLE_VALUE; ICCSIH0IR = INTP_DISABLE_VALUE; ICCSIH0IRE = INTP_DISABLE_VALUE; /* transmission stop */ CSIH0.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csih0_master_transmit( uint16_t uint16_tx ) * Description : This function transmits data using the CSIH0 in master mode. * Argument : uint16_t uint16_tx: transmission data * Return Value : none ******************************************************************************/ void R_csih0_master_transmit( uint16_t uint16_tx ) { CSIH0.TX0H = uint16_tx; } /****************************************************************************** * Function Name : void R_csih0_master_reception_initialize( void ) * Description : This function initializes the CSIH0. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_reception_initialize( void ) { /* callback function pointer initializes */ stCSIH_CB[CSIH_CH0].fp_intr_ic = NULL; stCSIH_CB[CSIH_CH0].fp_intr_ijc = NULL; stCSIH_CB[CSIH_CH0].fp_intr_ir = NULL; stCSIH_CB[CSIH_CH0].fp_intr_ire = NULL; /* CSI setting */ CSIH0.CTL0.UINT8 = 0x00; CSIH0.CTL1 = 0x00000002; CSIH0.CTL2 = 0x0000; CSIH0.BRS0 = 0x0004; CSIH0.CFG0 = 0x00000000; CSIH0.MCTL0 = 0x00; } /****************************************************************************** * Function Name : void R_csih0_master_reception_enable( void ) * Description : This function enable reception mode using the CSIH0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_reception_enable( void ) { /* interrupt setting */ ICCSIH0IC = INTP_DISABLE_VALUE; ICCSIH0IJC = INTP_DISABLE_VALUE; ICCSIH0IR = INTP_DISABLE_VALUE; ICCSIH0IRE = INTP_DISABLE_VALUE; if( stCSIH_CB[CSIH_CH0].fp_intr_ir != NULL ) { ICCSIH0IR = INTP_ENABLE_VALUE; } if( stCSIH_CB[CSIH_CH0].fp_intr_ire != NULL ) { ICCSIH0IRE = INTP_ENABLE_VALUE; } /* reception start */ CSIH0.CTL0.UINT8 = 0xA1; } /****************************************************************************** * Function Name : void R_csih0_master_reception_disable( void ) * Description : This function disable reception mode using the CSIH0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_reception_disable( void ) { /* interrupt setting */ ICCSIH0IC = INTP_DISABLE_VALUE; ICCSIH0IJC = INTP_DISABLE_VALUE; ICCSIH0IR = INTP_DISABLE_VALUE; ICCSIH0IRE = INTP_DISABLE_VALUE; /* reception stop */ CSIH0.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csih0_master_receive( void ) * Description : This function receives data using the CSIH0 in master mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih0_master_receive( void ) { /* reception trigger */ CSIH0.TX0H = 0x00; } /****************************************************************************** * Function Name : void R_csih0_interrupt_callback * Description : Callback function register. * Argument : CSIH_CALLBACK_POINTER p_intr_ic * CSIH_CALLBACK_POINTER p_intr_ijc * CSIH_CALLBACK_POINTER p_intr_ir * CSIH_CALLBACK_POINTER p_intr_ire * Return Value : none ******************************************************************************/ void R_csih0_interrupt_callback( CSIH_CALLBACK_POINTER fp_intr_ic, CSIH_CALLBACK_POINTER fp_intr_ijc, CSIH_CALLBACK_POINTER fp_intr_ir, CSIH_CALLBACK_POINTER fp_intr_ire ) { /* callback function register */ stCSIH_CB[CSIH_CH0].fp_intr_ic = fp_intr_ic; stCSIH_CB[CSIH_CH0].fp_intr_ijc = fp_intr_ijc; stCSIH_CB[CSIH_CH0].fp_intr_ir = fp_intr_ir; stCSIH_CB[CSIH_CH0].fp_intr_ire = fp_intr_ire; } /****************************************************************************** * Function Name : void R_csih1_slave_transmission_initialize( void ) * Description : This function initializes the CSIH1. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_transmission_initialize( void ) { /* callback function pointer initializes */ stCSIH_CB[CSIH_CH1].fp_intr_ic = NULL; stCSIH_CB[CSIH_CH1].fp_intr_ijc = NULL; stCSIH_CB[CSIH_CH1].fp_intr_ir = NULL; stCSIH_CB[CSIH_CH1].fp_intr_ire = NULL; /* CSI setting */ CSIH1.CTL0.UINT8 = 0x00; CSIH1.CTL1 = 0x00010002; CSIH1.CTL2 = 0xE000; CSIH1.BRS0 = 0x0000; CSIH1.CFG0 = 0x00000000; CSIH1.MCTL0 = 0x00; } /****************************************************************************** * Function Name : void R_csih1_slave_transmission_enable( void ) * Description : This function enable transmission mode using the CSIH1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_transmission_enable( void ) { /* interrupt setting */ ICCSIH1IC = INTP_DISABLE_VALUE; ICCSIH1IJC = INTP_DISABLE_VALUE; ICCSIH1IR = INTP_DISABLE_VALUE; ICCSIH1IRE = INTP_DISABLE_VALUE; if( stCSIH_CB[CSIH_CH1].fp_intr_ic != NULL ) { ICCSIH1IC = INTP_ENABLE_VALUE; } if( stCSIH_CB[CSIH_CH1].fp_intr_ijc != NULL ) { ICCSIH1IJC = INTP_ENABLE_VALUE; } if( stCSIH_CB[CSIH_CH1].fp_intr_ire != NULL ) { ICCSIH1IRE = INTP_ENABLE_VALUE; } /* transmission start */ CSIH1.CTL0.UINT8 = 0xC1; } /****************************************************************************** * Function Name : void R_csih1_slave_transmission_disable( void ) * Description : This function disable transmission mode using the CSIH1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_transmission_disable( void ) { /* interrupt setting */ ICCSIH1IC = INTP_DISABLE_VALUE; ICCSIH1IJC = INTP_DISABLE_VALUE; ICCSIH1IR = INTP_DISABLE_VALUE; ICCSIH1IRE = INTP_DISABLE_VALUE; /* transmission stop */ CSIH1.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csih1_slave_transmit( uint16_t uint16_tx ) * Description : This function transmits data using the CSIH1 in slave mode. * Argument : uint16_t uint16_tx: transmission data * Return Value : none ******************************************************************************/ void R_csih1_slave_transmit( uint16_t uint16_tx ) { CSIH1.TX0H = uint16_tx; } /****************************************************************************** * Function Name : void R_csih1_slave_reception_initialize( void ) * Description : This function initializes the CSIH1. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_reception_initialize( void ) { /* callback function pointer initializes */ stCSIH_CB[CSIH_CH1].fp_intr_ic = NULL; stCSIH_CB[CSIH_CH1].fp_intr_ijc = NULL; stCSIH_CB[CSIH_CH1].fp_intr_ir = NULL; stCSIH_CB[CSIH_CH1].fp_intr_ire = NULL; /* CSI setting */ CSIH1.CTL0.UINT8 = 0x00; CSIH1.CTL1 = 0x00000000; CSIH1.CTL2 = 0xE000; CSIH1.BRS0 = 0x0000; CSIH1.CFG0 = 0x00000000; CSIH1.MCTL0 = 0x00; } /****************************************************************************** * Function Name : void R_csih1_slave_reception_enable( void ) * Description : This function enable reception mode using the CSIH1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_reception_enable( void ) { /* interrupt setting */ ICCSIH1IC = INTP_DISABLE_VALUE; ICCSIH1IJC = INTP_DISABLE_VALUE; ICCSIH1IR = INTP_DISABLE_VALUE; ICCSIH1IRE = INTP_DISABLE_VALUE; if( stCSIH_CB[CSIH_CH1].fp_intr_ir != NULL ) { ICCSIH1IR = INTP_ENABLE_VALUE; } if( stCSIH_CB[CSIH_CH1].fp_intr_ire != NULL ) { ICCSIH1IRE = INTP_ENABLE_VALUE; } /* reception start */ CSIH1.CTL0.UINT8 = 0xA1; } /****************************************************************************** * Function Name : void R_csih1_slave_reception_disable( void ) * Description : This function disable reception mode using the CSIH1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_reception_disable( void ) { /* interrupt setting */ ICCSIH1IC = INTP_DISABLE_VALUE; ICCSIH1IJC = INTP_DISABLE_VALUE; ICCSIH1IR = INTP_DISABLE_VALUE; ICCSIH1IRE = INTP_DISABLE_VALUE; /* reception stop */ CSIH1.CTL0.UINT8 = 0x01; } /****************************************************************************** * Function Name : void R_csih1_slave_receive( void ) * Description : This function receives data using the CSIH1 in slave mode. * Argument : none * Return Value : none ******************************************************************************/ void R_csih1_slave_receive( void ) { } /****************************************************************************** * Function Name : void R_csih1_interrupt_callback * Description : Callback function register. * Argument : CSIH_CALLBACK_POINTER p_intr_ic * CSIH_CALLBACK_POINTER p_intr_ijc * CSIH_CALLBACK_POINTER p_intr_ir * CSIH_CALLBACK_POINTER p_intr_ire * Return Value : none ******************************************************************************/ void R_csih1_interrupt_callback( CSIH_CALLBACK_POINTER fp_intr_ic, CSIH_CALLBACK_POINTER fp_intr_ijc, CSIH_CALLBACK_POINTER fp_intr_ir, CSIH_CALLBACK_POINTER fp_intr_ire ) { /* callback function register */ stCSIH_CB[CSIH_CH1].fp_intr_ic = fp_intr_ic; stCSIH_CB[CSIH_CH1].fp_intr_ijc = fp_intr_ijc; stCSIH_CB[CSIH_CH1].fp_intr_ir = fp_intr_ir; stCSIH_CB[CSIH_CH1].fp_intr_ire = fp_intr_ire; } /****************************************************************************** * Function Name : void intr_csih0ic_function( void ) * Description : This function is INTCSIH0IC interrupt processing. (table refer.) * : INTCSIH0IC * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih0ic_function( enable=false , channel=21 , callt=false , fpu=false ) #endif void intr_csih0ic_function( void ) { if( stCSIH_CB[CSIH_CH0].fp_intr_ic != NULL ) { (stCSIH_CB[CSIH_CH0].fp_intr_ic)(); } } #ifdef __ghs__ __interrupt void INTCSIH0IC(void) { intr_csih0ic_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x15 __interrupt void INTCSIH0IC(void) { intr_csih0ic_function(); } #endif /****************************************************************************** * Function Name : void intr_csih0ijc_function( void ) * Description : This function is INTCSIH0IJC interrupt processing. (table refer.) * : INTCSIH0IJC * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih0ijc_function( enable=false , channel=24 , callt=false , fpu=false ) #endif void intr_csih0ijc_function( void ) { if( stCSIH_CB[CSIH_CH0].fp_intr_ijc != NULL ) { (stCSIH_CB[CSIH_CH0].fp_intr_ijc)(); } } #ifdef __ghs__ __interrupt void INTCSIH0IJC(void) { intr_csih0ijc_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x18 __interrupt void INTCSIH0IJC(void) { intr_csih0ijc_function(); } #endif /****************************************************************************** * Function Name : void intr_csih0ir_function( void ) * Description : This function is INTCSIH0IR interrupt processing. (table refer.) * : INTCSIH0IR * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih0ir_function( enable=false , channel=22 , callt=false , fpu=false ) #endif void intr_csih0ir_function( void ) { if( stCSIH_CB[CSIH_CH0].fp_intr_ir != NULL ) { (stCSIH_CB[CSIH_CH0].fp_intr_ir)(); } } #ifdef __ghs__ __interrupt void INTCSIH0IR(void) { intr_csih0ir_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x16 __interrupt void INTCSIH0IR(void) { intr_csih0ir_function(); } #endif /****************************************************************************** * Function Name : void intr_csih0ire_function( void ) * Description : This function is INTCSIH0IRE interrupt processing. (table refer.) * : INTCSIH0IRE * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih0ire_function( enable=false , channel=23 , callt=false , fpu=false ) #endif void intr_csih0ire_function( void ) { if( stCSIH_CB[CSIH_CH0].fp_intr_ire != NULL ) { (stCSIH_CB[CSIH_CH0].fp_intr_ire)(); } } #ifdef __ghs__ __interrupt void INTCSIH0IRE(void) { intr_csih0ire_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x17 __interrupt void INTCSIH0IRE(void) { intr_csih0ire_function(); } #endif /****************************************************************************** * Function Name : void intr_csih1ic_function( void ) * Description : This function is INTCSIH1IC interrupt processing. (table refer.) * : INTCSIH1IC * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih1ic_function( enable=false , channel=108 , callt=false , fpu=false ) #endif void intr_csih1ic_function( void ) { if( stCSIH_CB[CSIH_CH1].fp_intr_ic != NULL ) { (stCSIH_CB[CSIH_CH1].fp_intr_ic)(); } } #ifdef __ghs__ __interrupt void INTCSIH1IC(void) { intr_csih1ic_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x6C __interrupt void INTCSIH1IC(void) { intr_csih1ic_function(); } #endif /****************************************************************************** * Function Name : void intr_csih1ijc_function( void ) * Description : This function is INTCSIH1IJC interrupt processing. (table refer.) * : INTCSIH1IJC * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih1ijc_function( enable=false , channel=111 , callt=false , fpu=false ) #endif void intr_csih1ijc_function( void ) { if( stCSIH_CB[CSIH_CH1].fp_intr_ijc != NULL ) { (stCSIH_CB[CSIH_CH1].fp_intr_ijc)(); } } #ifdef __ghs__ __interrupt void INTCSIH1IJC(void) { intr_csih1ijc_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x6F __interrupt void INTCSIH1IJC(void) { intr_csih1ijc_function(); } #endif /****************************************************************************** * Function Name : void intr_csih1ir_function( void ) * Description : This function is INTCSIH1IR interrupt processing. (table refer.) * : INTCSIH1IR * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih1ir_function( enable=false , channel=109 , callt=false , fpu=false ) #endif void intr_csih1ir_function( void ) { if( stCSIH_CB[CSIH_CH1].fp_intr_ir != NULL ) { (stCSIH_CB[CSIH_CH1].fp_intr_ir)(); } } #ifdef __ghs__ __interrupt void INTCSIH1IR(void) { intr_csih1ir_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x6D __interrupt void INTCSIH1IR(void) { intr_csih1ir_function(); } #endif /****************************************************************************** * Function Name : void intr_csih1ire_function( void ) * Description : This function is INTCSIH1IRE interrupt processing. (table refer.) * : INTCSIH1IRE * Argument : none * Return Value : none ******************************************************************************/ #if !defined(__IAR_SYSTEMS_ICC__) && !defined(__ghs__) #pragma interrupt intr_csih1ire_function( enable=false , channel=110 , callt=false , fpu=false ) #endif void intr_csih1ire_function( void ) { if( stCSIH_CB[CSIH_CH1].fp_intr_ire != NULL ) { (stCSIH_CB[CSIH_CH1].fp_intr_ire)(); } } #ifdef __ghs__ __interrupt void INTCSIH1IRE(void) { intr_csih1ire_function(); } #endif #ifdef __IAR_SYSTEMS_ICC__ #pragma vector = 0x6E __interrupt void INTCSIH1IRE(void) { intr_csih1ire_function(); } #endif