225 lines
10 KiB
C
225 lines
10 KiB
C
|
/*===========================================================================*/
|
||
|
/* Module : RLIN_driver_user.c */
|
||
|
/* Version: V1.00 */
|
||
|
/*===========================================================================*/
|
||
|
/* COPYRIGHT */
|
||
|
/*===========================================================================*/
|
||
|
/* Copyright (c) 2012 by Renesas Electronics Europe GmbH, */
|
||
|
/* a company of the Renesas Electronics Corporation */
|
||
|
/*===========================================================================*/
|
||
|
/* Purpose: main routine of QB-R5F10PMF-TB startup sample */
|
||
|
/* */
|
||
|
/*===========================================================================*/
|
||
|
/* In case of any question please do not hesitate to contact: */
|
||
|
/* */
|
||
|
/* Technical Product Support */
|
||
|
/* */
|
||
|
/* Renesas Electronics Europe GmbH */
|
||
|
/* Arcadiastrasse 10 */
|
||
|
/* D-40472 Duesseldorf, Germany */
|
||
|
/* */
|
||
|
/* e-mail: device_support.rl78-eu@lm.renesas.com */
|
||
|
/* FAX: +49 - (0)211 / 65 03 - 12 79 */
|
||
|
/* */
|
||
|
/*===========================================================================*/
|
||
|
/* Warranty Disclaimer */
|
||
|
/* */
|
||
|
/* Because the Product(s) is licensed free of charge, there is no warranty */
|
||
|
/* of any kind whatsoever and expressly disclaimed and excluded by Renesas, */
|
||
|
/* either expressed or implied, including but not limited to those for */
|
||
|
/* non-infringement of intellectual property, merchantability and/or */
|
||
|
/* fitness for the particular purpose. */
|
||
|
/* Renesas shall not have any obligation to maintain, service or provide bug */
|
||
|
/* fixes for the supplied Product(s) and/or the Application. */
|
||
|
/* */
|
||
|
/* Each User is solely responsible for determining the appropriateness of */
|
||
|
/* using the Product(s) and assumes all risks associated with its exercise */
|
||
|
/* of rights under this Agreement, including, but not limited to the risks */
|
||
|
/* and costs of program errors, compliance with applicable laws, damage to */
|
||
|
/* or loss of data, programs or equipment, and unavailability or */
|
||
|
/* interruption of operations. */
|
||
|
/* */
|
||
|
/* Limitation of Liability */
|
||
|
/* */
|
||
|
/* In no event shall Renesas be liable to the User for any incidental, */
|
||
|
/* consequential, indirect, or punitive damage (including but not limited */
|
||
|
/* to lost profits) regardless of whether such liability is based on breach */
|
||
|
/* of contract, tort, strict liability, breach of warranties, failure of */
|
||
|
/* essential purpose or otherwise and even if advised of the possibility of */
|
||
|
/* such damages. Renesas shall not be liable for any services or products */
|
||
|
/* provided by third party vendors, developers or consultants identified or */
|
||
|
/* referred to the User by Renesas in connection with the Product(s) and/or */
|
||
|
/* the Application. */
|
||
|
/* */
|
||
|
/*===========================================================================*/
|
||
|
/* Environment: */
|
||
|
/* Device: R5F10PMF */
|
||
|
/* Target Hardware: QB-R5F10PMF-TB */
|
||
|
/* IDE: IAR Systems */
|
||
|
/* Embedded Workbench for RL78 V1.20.x */
|
||
|
/* */
|
||
|
/*===========================================================================*/
|
||
|
/* History: */
|
||
|
/* V1.00: Initial version */
|
||
|
/* */
|
||
|
/*===========================================================================*/
|
||
|
|
||
|
/***********************************************************************************************************************
|
||
|
* File Name : RLIN_driver_user.c
|
||
|
* Device(s) : R5F10PMF
|
||
|
* Tool-Chain : IAR Systems iccrl78
|
||
|
* Description : This file implements device driver for Interrupt module.
|
||
|
* Creation Date: 02.08.2013
|
||
|
***********************************************************************************************************************/
|
||
|
|
||
|
#include "r_cg_macrodriver.h"
|
||
|
#include "RLIN_driver.h"
|
||
|
#include "r_cg_userdefine.h"
|
||
|
|
||
|
#pragma interrupt RLIN0_Transmission_interrupt(vect=INTLIN0TRM)
|
||
|
#pragma interrupt RLIN0_Reception_interrupt(vect=INTLIN0RVC)
|
||
|
#pragma interrupt RLIN0_Status_interrupt(vect=INTLIN0)
|
||
|
#pragma interrupt RLIN0_Wakeup_interrupt(vect=INTLIN0WUP)
|
||
|
|
||
|
|
||
|
uint8_t GetIDbuffer;
|
||
|
|
||
|
#ifdef RLIN_Slave
|
||
|
uint8_t Slave_RxData1[8]; /*reception data store array*/
|
||
|
uint8_t Slave_RxData2[8]; /*reception data store array*/
|
||
|
uint8_t Slave_RxData3[8]; /*reception data store array*/
|
||
|
uint8_t Slave_TxData[8]={0,0,0,0,0,0,0,0}; /*Transmission data store array*/
|
||
|
#endif
|
||
|
/*
|
||
|
uint8_t TestTxData[]={0x4a,0xF0,0x93,0xe5,0x05,0x05,0x07,0x08};
|
||
|
uint8_t TestTxData1[]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
|
||
|
*/
|
||
|
|
||
|
|
||
|
/***********************************************************************************************************************
|
||
|
* Function Name: RLIN0_Transmission_interrupt
|
||
|
* Description : This function is RLIN0 Transmission interrupt service routine.
|
||
|
* Arguments : None
|
||
|
* Return Value : None
|
||
|
***********************************************************************************************************************/
|
||
|
static void __near RLIN0_Transmission_interrupt(void)
|
||
|
{
|
||
|
#ifdef RLIN_Master
|
||
|
uint8_t transmit_header_flag;
|
||
|
uint8_t transmit_response_flag;
|
||
|
transmit_header_flag=LST0 & 0x80;
|
||
|
transmit_response_flag=LST0 & 0x01;
|
||
|
|
||
|
if(transmit_header_flag)
|
||
|
{
|
||
|
LIE0&=0xF7; /*Disable error detection interrupt*/
|
||
|
LST0&=0X7F; /*clear successful header reception flag */
|
||
|
LIE0|=0x80; /*enable header reception interrupt*/
|
||
|
}
|
||
|
|
||
|
if(transmit_response_flag)
|
||
|
{
|
||
|
LST0&=0xFE;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
|
||
|
#ifdef RLIN_Slave
|
||
|
LST0&=0xFE;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
|
||
|
/***********************************************************************************************************************
|
||
|
* Function Name: RLIN0_Reception_interrupt
|
||
|
* Description : This function is RLIN0 Reception interrupt service routine.
|
||
|
* Arguments : None
|
||
|
* Return Value : None
|
||
|
***********************************************************************************************************************/
|
||
|
static void __near RLIN0_Reception_interrupt(void)
|
||
|
{
|
||
|
|
||
|
#ifdef RLIN_Slave
|
||
|
|
||
|
uint8_t receive_header_flag;
|
||
|
uint8_t receive_reponse_flag;
|
||
|
receive_header_flag=LST0 & 0x80; /* get header reception flag */
|
||
|
receive_reponse_flag=LST0 & 0X02; /* get response rception flag*/
|
||
|
|
||
|
LIN_Data_Lost_count=0;
|
||
|
|
||
|
GetIDbuffer=LIDB0;
|
||
|
|
||
|
if(receive_header_flag) /* Header successful receive*/
|
||
|
{
|
||
|
LIE0&=0xF7; /*Disable header interrupt*/
|
||
|
LST0&=0X7F; /*clear successful header reception flag*/
|
||
|
|
||
|
switch(GetIDbuffer)
|
||
|
{
|
||
|
case 0xC1: RLIN_Slave_Receive(8);
|
||
|
break;
|
||
|
case 0x42:
|
||
|
EnrollToLIN();
|
||
|
RLIN_Slave_Transmit(Slave_TxData,8);
|
||
|
flagTxEnd = 1;
|
||
|
break;
|
||
|
default: RLIN_Slave_NoResponse();
|
||
|
break;
|
||
|
}
|
||
|
LIE0 |= 0x80; /*enable header reception interrupt*/
|
||
|
}
|
||
|
|
||
|
if(receive_reponse_flag)
|
||
|
{
|
||
|
LIE0 &= 0xFD; /* disable response reception interrupt*/
|
||
|
LST0 &= 0xFD; /* clear response reception successful flag*/
|
||
|
|
||
|
switch(GetIDbuffer)
|
||
|
{
|
||
|
case 0xC1: Get_reponse_RxData(Slave_RxData1);
|
||
|
break;
|
||
|
default: break;
|
||
|
}
|
||
|
|
||
|
LIE0|=0x02; /*enable reception interrupt*/
|
||
|
}
|
||
|
|
||
|
|
||
|
LTRC0=0x01; /*enabled header reception interrupt*/
|
||
|
|
||
|
#endif
|
||
|
|
||
|
#ifdef RLIN_Master
|
||
|
LST0&=0xFD; /*clear response reception successful flag*/
|
||
|
RLIN_Master_GetData(); /*get the reception data*/
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
/***********************************************************************************************************************
|
||
|
* Function Name: RLIN0_Status_interrupt
|
||
|
* Description : This function is RLIN0 Status interrupt service routine.
|
||
|
* Arguments : None
|
||
|
* Return Value : None
|
||
|
***********************************************************************************************************************/
|
||
|
static void __near RLIN0_Status_interrupt(void)
|
||
|
{
|
||
|
/*while(1U)
|
||
|
{
|
||
|
;
|
||
|
}*/
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/***********************************************************************************************************************
|
||
|
* Function Name: RLIN0_Wakeup_interrupt
|
||
|
* Description : This function is RLIN0 Wakeup interrupt service routine.
|
||
|
* Arguments : None
|
||
|
* Return Value : None
|
||
|
***********************************************************************************************************************/
|
||
|
static void __near RLIN0_Wakeup_interrupt(void)
|
||
|
{
|
||
|
LCUC0=0x03;
|
||
|
}
|