⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lin_dev.c

📁 针对日本瑞莎单片机r8c/23系列开发的LIN网络开发编程
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************/
/*             Renesas Technology America, Inc. Legal Disclaimer              */
/******************************************************************************
* DISCLAIMER:                                                        
* The software supplied by Renesas Technology America Inc. is        
* intended and supplied for use on Renesas Technology products.      
* This software is owned by Renesas Technology America, Inc. or      
* Renesas Technology Corporation and is protected under applicable   
* copyright laws. All rights are reserved.                           
*                                                                    
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, 
* IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO IMPLIED         
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
* APPLY TO THIS SOFTWARE. RENESAS TECHNOLOGY AMERICA, INC. AND       
* AND RENESAS TECHNOLOGY CORPORATION RESERVE THE RIGHT, WITHOUT      
* NOTICE, TO MAKE CHANGES TO THIS SOFTWARE. NEITHER RENESAS          
* TECHNOLOGY AMERICA, INC. NOR RENESAS TECHNOLOGY CORPORATION SHALL, 
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR        
* CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER ARISING OUT OF THE 
* USE OR APPLICATION OF THIS SOFTWARE.                               
******************************************************************************

******************************************************************************
File: lin_dev.c

This file contains the user configurable system variable declarations for the 
LIN device.
    This is a template file to be customized for each project.  The structures
associated with schedule tables are required only for Master nodes and the
variables for NAD, Supplier ID , Function ID etc. are required only for
Slave nodes (in systems using Master controlled node configuration).  The
remaining elements defined in this file are used for both Master and Slave
nodes.
    Many of the structures associated with schedule tables are required only when
certain options have been enabled in "lin_dev.h".  For instance, the collision
resolution schedule tables are required only if ENABLE_EVENT_TRIGGERED has been
defined.  The tables associated with Sporadic frames are required only if
ENABLE_SPORADIC has been defined.
    The specific values shown in the various structures such as schedule tables,
"LIN_id_table[]" and "LIN_signal_table[]" are shown as examples only.  Unless
otherwise noted (the first entry in "LIN_schedule_table[]" and the last entry
for "LIN_id_table[]", for instance), the entries shown in this file must be
replaced with equivalent entries as required by the LIN device being designed.
 
tab space = 4 

Revision History  
21.05.2007 AE version 1.16r. Released to RTA CAN download page.
01.08.2007 AE version 1.17. id0x8 fix done in lin_low_level.c by Bob C.
15.08.2007 AE version 1.18. Linted.
******************************************************************************/

/******************************************************************************
System includes (Compiler Level Includes)
******************************************************************************/
//#include <xxxx.h>

/******************************************************************************
User includes (Project level includes)
******************************************************************************/
#include "lin_dev.h"

/**********************************************************************
 * Include User Header file
 *********************************************************************/

/******************************************************************************
Typedef definitions
******************************************************************************/


/* The following variable and constant declarations define the signals,
 frames and schedule tables needed to realize the LIN system. The most complex 
 level (schedule tables) to the most basic level (signal definitions).  
 Each of these variables and constants must be declared in "lin_dev.h".  
 Schedule tables are required only for the Master node.  */

/******************************************************************************
Global variables and functions exported
******************************************************************************/
#if ((LIN_MASTER_NODE != LIN_MY_NODE_NAME) && (defined USE_POWER_CONTROL))
/* The variable "LIN_sleep_timer" is used by a Slave node application to put the node
 * to sleep if the LIN bus has been inactive for more than 4 seconds.  The Slave node
 * application code should increment "LIN_sleep_timer" once every second.  The API
 * will reset "LIN_sleep_timer" to 0 every time some bus activity is detected.  If
 * "LIN_sleep_timer" ever reaches a count of 4, the Slave device will be put into
 * the SLEEP state.  The value of "LIN_sleep_timer" is checked in the "l_flg_tst()"
 * function.  */
static unsigned char LIN_sleep_timer = 0;
#endif   /* Slave node and USE_POWER_CONTROL is defined.  */

/* The following definitions initialize the signal data.  Byte 0 of each
 * signal holds the modification status of the signal.  A value of 0x00
 * indicates that the signal has not been updated, a value of 0x80 indicates
 * that the signal has been updated.  The remaining bytes in the signal
 * structure hold the signal data.  The signal names are declared in the
 * file "lin_dev.h".  */

/* LIN_SIG_Node_A_AD (24-bit signal length).  */
unsigned char LIN_SIG_Node_A_AD_data[1 + 2] = {0, 0x12, 0x34};
/* LIN_SIG_Node_A_Switch (16-bit signal length).  */
unsigned char LIN_SIG_Node_A_Switch_data[1 + 1] = {0, 0x56};
/* LIN_SIG_Node_A_Counter (16-bit signal length).  */
unsigned char LIN_SIG_Node_A_Counter_data[1 + 1] = {0, 0x78};

/* LIN_SIG_Cmd_Switch  data (16-bit signal length). */
unsigned char LIN_SIG_Cmd_Switch_data[1 + 1] = {0, 0x89};

/* LIN_SIG_NodeB_AD (24-bit signal length).  */
unsigned char LIN_SIG_Node_B_AD_data[1 + 2] = {0, 0x12, 0x34};
/* LIN_SIG_NodeB_Switch (16-bit signal length).  */
unsigned char LIN_SIG_Node_B_Switch_data[1 + 1] = {0, 0x56};
/* LIN_SIG_NodeB_Counter (16-bit signal length).  */
unsigned char LIN_SIG_Node_B_Counter_data[1 + 1] = {0, 0x78};

/******************************************************************************
Constant definitions
******************************************************************************/
/* The "LIN_schedule_table" is a structure that lists all of the schedule
 * tables that the Master node can be commanded to make use of.  The
 * "LIN_L_NULL_SCHEDULE" table (does not actually exist) must always be
 * listed under this name as schedule table 0.  This is the "dummy" (empty)
 * schedule table that the Master node "uses" by default at initialization.
 * The remaining schedule tables are user defined and can be given any names
 * appropriate to the application.  The names used must also be declared in
 * "lin_dev.h".  These names are then used in calls to "l_sch_set()" made
 * from the application program.
 *
   typedef struct {
      unsigned char  num_slots;           Number of frame slots in the schedule table.
      unsigned char  *schedule_address;   Address of the schedule table.
   } SCHEDULE_TBL;
 *
 *    */
const SCHEDULE_TBL LIN_schedule_table[2] = {
   {0, (unsigned char  *)LIN_L_NULL_SCHEDULE},    /* LIN_L_NULL_SCHEDULE.  */
   {5, (unsigned char  *)&LIN_SCHEDULE_data[0].frame_type}/*,         * LIN_SCHEDULE.  Reduced schedule for single oven. *
   {3, &LIN_SCHEDULE2_data[0].frame_type},         * LIN_SCHEDULE2.  Added for encoder test.  *
   {4, &LIN_SCHEDULE3_data[0].frame_type}          * LIN_SCHEDULE3.  Added for relay test.  */
};

/* The following structures define the actual LIN schedule tables that the
 * Master node can be commanded to use.  The message frame types are defined
 * in "lin_low_level.h".  The frame names are defined (enumerated) in "lin_dev.h".
 * The "delay_time" is actually the slot time in ms allocated before the next
 * frame will be sent.  With each "tick" of the scheduler timer, this time will
 * be decremented by the value of "LIN_TIME_BASE" (defined in "lin_dev.h") and
 * the next frame will be sent only when the delay time decrements to (or past)
 * 0.  By setting "LIN_TIME_BASE" to some small number (such as 1), this allows
 * the schedule table to be implemented with variable slot times designed to
 * fit the actual data length of each frame.
 *
   typedef struct {
      unsigned char  frame_type;    Type of LIN message frame.
      unsigned char  frame_name;    Name (index number) of LIN message frame.
      int            delay_time;    Actual slot time in ms for the frame.
   } SCHEDULE_DATA;

 * This is a schedule table for a relatively simple LIN cluster that consists of 3 signals.
 	Signal data published by Slave A:
		o A-D value
		o Switch 1-3 data
		o 1 second counter
	Signal data published by master:
		o Switch 1-3 data
	This schedule table illustrates these signals using only UNCONDITIONAL message frames. */
const SCHEDULE_DATA  LIN_SCHEDULE_data[5] = {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -