📄 lin_dev.c
字号:
/******************************************************************************
* 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 this
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"
/******************************************************************************
Typedef definitions
******************************************************************************/
/******************************************************************************
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. */
unsigned char LIN_sleep_timer = 0;
#endif /* Slave node and USE_POWER_CONTROL is defined. */
/* 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 s 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] = {
{UNCONDITION_FRAME, (unsigned char)LIN_F1_REQ_NODE_A_AD, 30},
{UNCONDITION_FRAME, (unsigned char)LIN_F2_REQ_NODE_A_SWITCH_AND_COUNTER, 30},
{UNCONDITION_FRAME, (unsigned char)LIN_F3_CMD_SWITCH, 30},
{UNCONDITION_FRAME, (unsigned char)LIN_F4_REQ_NODE_B_AD, 30},
{UNCONDITION_FRAME, (unsigned char)LIN_F5_REQ_NODE_B_SWITCH_AND_COUNTER, 30} }; */
/* 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};
/******************************************************************************
Constant definitions
******************************************************************************/
/* The following structures define each of the signals that are transported
* in a given frame. One such structure must exist for each frame defined in
* "LIN_id_table[]". The signal enums are defined in "lin_dev.h" and allocated
* below. The signal names are purely optional and may be chosen to fit the
* application.
*
typedef struct {
unsigned char signal_name; Signal name. Actually, an enumerated value, not a string.
unsigned char signal_offset; Bit offset of the signal data in the frame data field.
} FRAME_SIGNAL_TBL;
* */
const FRAME_SIGNAL_TBL LIN_F1_Sigtable_Req_Node_A_AD[1] = {
{(unsigned char)LIN_SIG_NODE_A_AD, 0}
};
const FRAME_SIGNAL_TBL LIN_F2_Sigtable_Req_Node_A_Switch_and_Counter[2] = {
{(unsigned char)LIN_SIG_NODE_A_SWITCH, 0},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -