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

📄 lin_dev.h

📁 针对日本瑞莎单片机r8c/23系列开发的LIN网络开发编程
💻 H
字号:
#ifndef  LIN_DEV_H
#define  LIN_DEV_H
/******************************************************************************
* 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.h

This file contains the user configurable defines 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 declared in this file are used for both Master and Slave
nodes.
    The specific values defined (enumerated) for various schedule, frame and signal
names are given as examples only.  Unless otherwise noted, the name definitions
in this file must be replaced with equivalent definitions as required by the
system 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_low_level.h"

/******************************************************************************
Typedef definitions
******************************************************************************/
/* The following enumerations associate numeric values with text names to
 * define schedule tables, Sporadic frame slots, frame names and signal names.  */

/* This enumeration assigns names and associated numerical values to the
 * various schedule tables that the Master node can be commanded to use.
 * The "LIN_L_NULL_SCHEDULE" table must always exist 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.  These names are used only in the schedule table declarations
 * in "lin_dev.c" and in calls to "l_sch_set()" made from the application
 * program.  The schedule tables listed in this enumeration MUST appear in the
 * same order in which they appear in "LIN_schedule_table[]" in "lin_dev.c".
 * Schedule tables are defined only for the Master node.  */
typedef enum master_schedule_tables
{
   LIN_L_NULL_SCHEDULE,    /* Schedule table 0.  */
   LIN_SCHEDULE
} master_schedule_table_type;

/* This enumeration assigns names and associated numerical values to the LIN
 * message frames that may be processed by a node.  These names are purely
 * optional and may be selected to fit the application.  The values enumerated
 * here serve as an index into "LIN_id_table[]".  The frames MUST be declared
 * in "LIN_id_table[]" in the file "lin_dev.c" in the same order in which they
 * are enumerated here.  Sporadic frames are not listed here or in "LIN_id_table[]"
 * since they are never sent as an actual frame.  It is allowed for the same
 * frame to be enumerated as a different value on various nodes in the LIN cluster.
 * All that matters is that the order of the frame names enumerated here agrees
 * with the order in which the frames appear in the node's "LIN_id_table[]".  */
typedef enum frame_names
{
    LIN_F1_REQ_NODE_A_AD,
    LIN_F2_REQ_NODE_A_SWITCH_AND_COUNTER,
    LIN_F3_CMD_SWITCH,
    LIN_F4_REQ_NODE_B_AD,
    LIN_F5_REQ_NODE_B_SWITCH_AND_COUNTER
} frame_name_type;

/* This enumeration assigns names and associated numerical values to the
 * various signals known to a node.  These names are purely optional
 * and may be defined to fit the application.  These same names must be
 * used in the signal name declarations made in the file "lin_dev.c".
 * These signal names must be used in the application when setting
 * new signal values to send or reading received signal values.  The
 * signals defined in "LIN_signal_table[]" in the file "lin_dev.c"
 * must be in the same order as the signals enumerated here.  It is
 * allowed for the same signal to be enumerated as a different value
 * on various nodes in the LIN cluster.  All that matters is that the
 * order of the signal names enumerated here agrees with the order in
 * which the signals appear in the node's "LIN_signal_table[]".  */
typedef enum signal_names
{
   LIN_SIG_NODE_A_AD,
   LIN_SIG_NODE_A_SWITCH,
   LIN_SIG_NODE_A_COUNTER,
   LIN_SIG_CMD_SWITCH,
   LIN_SIG_NODE_B_AD,
   LIN_SIG_NODE_B_SWITCH,
   LIN_SIG_NODE_B_COUNTER
} signal_name_type;


/******************************************************************************
Constant definitions
******************************************************************************/

/******************************************************************************
Macro definitions
******************************************************************************/
/* The following defines are used to control the compilation to include
 * specific code sections to modify the code functionality.  */

/* Uncomment the following line to include the power control functions
 * "l_ifc_goto_sleep()" and "l_ifc_wake_up()".  For Master nodes, the
 * Break detect input pin (also used for wakeup detect) will not be
 * used by the LIN interface if this define is commented out.  */
//#define USE_POWER_CONTROL


/* Uncomment the following line to allow sync width measurement and
 * automatic calibration of the Baud rate.  This define is used only
 * by Slave nodes and has no effect for Master nodes.  */
//#define SYNC_AUTO_MODE

/* Uncomment the following line to allow calculation of the Baud
 * rate generator divide value and the timer load values for the
 * break timer.  */
#define AUTO_CALCULATION

/* Uncomment the following line if event triggered LIN message frames
 * will be used.  */
//#define ENABLE_EVENT_TRIGGERED	Removed from LIN Starter Demo version!

/* Uncomment the following line if sporadic LIN message frames will
 * be used.  This define is used only by Master nodes and has no effect
 * for Slave nodes.  */
//#define ENABLE_SPORADIC		Removed from LIN Starter Demo version!

/* Uncomment the following line if signals with odd widths (not evenly
 * divisible by 8) will be used.  When  ENABLE_ODD_SIGNAL_WIDTHS is not
 * defined, the functions "l_u8_rd()", "l_u8_wr()", "l_16_rd()" and
 * "l_16_wr()" can process only 8-bit or 16-bit signals.  The functions
 * "l_bool_rd()" and "l_bool_wr()" are not available at all.  If the
 * design uses signals with an odd bit width (not evenly divisible by
 * 8), this line must be uncommented.  */
//#define ENABLE_ODD_SIGNAL_WIDTHS

/* Uncomment the following line if the LIN API functions "l_bytes_rd()"
 * and "l_bytes_wr()" will be used by the design.  */
//#define ENABLE_BYTE_ARRAYS

/* Uncomment the following line to make use of detailed error statistics
 * for LIN data transfers.  The available variables are:
 *   LIN_xmt_overrun_err
 *   LIN_xmt_framing_err
 *   LIN_xmt_checksum_err
 *   LIN_xmt_readback_err
 *   LIN_rcv_overrun_err
 *   LIN_rcv_framing_err
 *   LIN_rcv_checksum_err
 * These variables are all of type "unsigned char" and are simply incremented
 * by the API with each error.  The application should reset these counters
 * after reading non-zero status.  The API does not clear these counters and
 * will simply roll them over if the count exceeds 255.  Any C source file
 * that references these variables must include "lin_api.h".  */
#define EXTENDED_ERROR_STATS

/* The following defines are used to configure specific operating
 * parameters for the LIN interface.  */

/* Define the desired Baud rate (bps) of the LIN interface.  */
#define LIN_SPEED             19200ul

/* Define the tick interval (in ms) for the Master schedule timer.  The
 * delay value for each frame will be decremented by this value until 0,
 * at which time the LIN Master node will send the next message frame.  */
#define LIN_TIME_BASE         2//AE

/* The following define determines the number of times the Master node will
 * attempt to retry a failed message frame before moving on to the next frame
 * in the schedule table.  Legal values are 0 to 255.  */
#define LIN_NUM_RETRIES       1

/* The LIN interface must be "enumerated" to allow the desired interface
 * to be selected.  Actually, this software is written to support only a
 * single LIN interface, and this interface must always be "enumerated"
 * as interface 0.  */
#define LIN       0

/* Each LIN node must be assigned a numerical value to serve as a "name".
 * The Master node MUST have a unique value assigned to each node that may
 * be connected into the LIN cluster.  A Slave node must have a value
 * assigned only to its own "name" (plus the two default names "LIN_ANY_SLV"
 * and "LIN_MST_OFF") and this value may be different from the value assigned
 * to the node on the Master node.  All that matters is that the names assigned
 * here agree with the names used in the "node_name" fields of the node's
 * "LIN_id_table[]"  This value is treated as type unsigned char, but just to
 * be on the safe side, 127 is a good maximum number to use.  The actual
 * text names defined below are used only in the files "lin_dev.c" and
 * "lin_dev.h", so any desired names can be substituted for the names
 * suggested below.  The names must not be in any particular order and the
 * associated numerical values must not be in an unbroken sequence.  However,
 * no two named nodes may be "enumerated" to have the same value.  If the
 * device implements a LIN slave node, the value assigned to "LIN_MASTER_NODE"
 * (below in this file) should be set to "LIN_MST_OFF".  */
#define LIN_MST               	0#define LIN_SLV_A      			1#define LIN_SLV_B	            2#define LIN_SLV_C	            3

/* The following two names and numerical equivalents are fixed and must be
 * defined for every LIN node.  */
#define LIN_ANY_SLV 126 /* Used only for Event Triggered frames.  */
#define LIN_MST_OFF             127 /* Used only for "LIN_master_node" on Slave nodes.  */

/* Set the value of LIN_MY_NODE_NAME to one of the node names defined above
 * as appropriate for the node being implemented.  */
#define LIN_MY_NODE_NAME      	LIN_MST

/* Set the value LIN_MASTER_NODE to some node name, even for slave nodes.
 * LIN_MASTER_NODE" is compared to the value defined for LIN_MY_NODE_NAME
 * above.  If the device implements a LIN Slave node, set LIN_MASTER_NODE
 * to "LIN_MST_OFF".  */
#define LIN_MASTER_NODE       	LIN_MST

/******************************************************************************
Global variables and functions imported
******************************************************************************/
/* Declarations of schedule table, frame and signal data arrays.  Some
 * of these declarations are required elements of the API and may not
 * be edited or deleted.  Others are optional, or are project specific.  */

/* Required element, Master nodes.  */
extern const SCHEDULE_TBL LIN_schedule_table[];
/* User defined, project specific element (Master node only).  */
extern const SCHEDULE_DATA LIN_SCHEDULE_data[];
/* User defined, project specific element (Master node only).  */
//extern const SCHEDULE_DATA LIN_SCHEDULE2_data[];

/* Required element, Master and Slave nodes.  */
extern const FRAME_ID_TBL  LIN_id_table[];

/* User defined, project specific element.  */
extern const FRAME_SIGNAL_TBL  LIN_F1_Sigtable_Req_Node_A_AD[];
extern const FRAME_SIGNAL_TBL  LIN_F2_Sigtable_Req_Node_A_Switch_and_Counter[];
extern const FRAME_SIGNAL_TBL  LIN_F3_Sigtable_Cmd_Switch[];
extern const FRAME_SIGNAL_TBL  LIN_F4_Sigtable_Req_Node_B_AD[];
extern const FRAME_SIGNAL_TBL  LIN_F5_Sigtable_Req_Node_B_Switch_and_Counter[];

/* Required element, Master and Slave nodes.  */
extern const SIGNAL_TBL LIN_signal_table[];

/* User defined, project specific elements.  */
extern unsigned char LIN_SIG_Node_A_AD_data[];
extern unsigned char LIN_SIG_Node_A_Switch_data[];
extern unsigned char LIN_SIG_Node_A_Counter_data[];
extern unsigned char LIN_SIG_Cmd_Switch_data[];
extern unsigned char LIN_SIG_Node_B_AD_data[];
extern unsigned char LIN_SIG_Node_B_Switch_data[];
extern unsigned char LIN_SIG_Node_B_Counter_data[];

/**********************************************************************
 *
 * Modification Record
 *
 **********************************************************************
 *
 *    Version 1.1 16 Mar 2006   Bob Chamberlain
 *    Version 1.2 14 Sep 2006   Demo for AE, Carl Stenquist 
 *********************************************************************/

#endif   /* LIN_DEV_H  */

⌨️ 快捷键说明

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