This commit is contained in:
sunbeam 2024-07-03 23:12:55 +08:00
commit 2ffb33aadd
416 changed files with 120425 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/firmware/p417_SWTL.X/dist
/firmware/p417_SWTL.X/debug
/firmware/p417_SWTL.X/build
/firmware/p417_SWTL.X/.generated_files

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"files.associations": {
"rte.h": "c"
}
}

View File

@ -0,0 +1,113 @@
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
RANLIB=ranlib
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
# WARNING: the IDE does not call this target since it takes a long time to
# simply run make. Instead, the IDE removes the configuration directories
# under build and dist directly without calling make.
# This target is left here so people can do a clean when running a clean
# outside the IDE.
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk

View File

@ -0,0 +1,14 @@
#
#Thu May 11 22:34:01 CST 2023
mcal.com-microchip-mplab-nbide-toolchain-xc32-XC32LanguageToolchain.md5=e4472a864cace3fb7127149b7c727f38
mcal.com-microchip-mplab-mdbcore-JLink-JLinkImpl.md5=8332ec366749fd298fb19bb5f792dea3
conf.ids=mcal
mcal.languagetoolchain.version=4.10
host.id=1f09-swyu-sw
configurations-xml=7f1faa81d1c335e9c1b1f8164a16c902
mcal.Pack.dfplocation=D\:\\MPLABX\\v6.00\\packs\\Microchip\\SAME51_DFP\\3.5.104
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=6e02ca5e9f5042ffd365b42ab82d3a9b
user-defined-mime-resolver-xml=none
proj.dir=G\:\\WorkSpace\\Ongoing\\XY_Modification\\20230508\\P417_SWTL\\firmware\\p417_SWTL.X
mcal.languagetoolchain.dir=D\:\\Microchip_xc32\\v4.10\\bin
host.platform=windows

View File

@ -0,0 +1,69 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=p417_SWTL.X
# Active Configuration
DEFAULTCONF=mcal
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=mcal
# build
.build-impl: .build-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=mcal clean
# all
.all-impl: .all-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=mcal build
# dependency checking support
.depcheck-impl:
# @echo "# This code depends on make tool being used" >.dep.inc
# @if [ -n "${MAKE_VERSION}" ]; then \
# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
# echo "include \$${DEPFILES}" >>.dep.inc; \
# echo "endif" >>.dep.inc; \
# else \
# echo ".KEEP_STATE:" >>.dep.inc; \
# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
# fi

View File

@ -0,0 +1,39 @@
#
# Generated Makefile - do not edit!
#
#
# This file contains information about the location of compilers and other tools.
# If you commmit this file into your revision control server, you will be able to
# to checkout the project and build it from the command line with make. However,
# if more than one person works on the same project, then this file might show
# conflicts since different users are bound to have compilers in different places.
# In that case you might choose to not commit this file and let MPLAB X recreate this file
# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
# least once so the file gets created and the project can be built. Finally, you can also
# avoid using this file at all if you are only building from the command line with make.
# You can invoke make with the values of the macros:
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
SHELL=cmd.exe
PATH_TO_IDE_BIN=E:/Program Files/Microchip/MPLABX/v6.00/mplab_platform/platform/../mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=E:/Program Files/Microchip/MPLABX/v6.00/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="E:\Program Files\Microchip\MPLABX\v6.00\sys\java\zulu8.54.0.21-ca-fx-jre8.0.292-win_x64/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="E:\Program Files\Microchip\xc32\v4.10\bin\xc32-gcc.exe"
MP_CPPC="E:\Program Files\Microchip\xc32\v4.10\bin\xc32-g++.exe"
# MP_BC is not defined
MP_AS="E:\Program Files\Microchip\xc32\v4.10\bin\xc32-as.exe"
MP_LD="E:\Program Files\Microchip\xc32\v4.10\bin\xc32-ld.exe"
MP_AR="E:\Program Files\Microchip\xc32\v4.10\bin\xc32-ar.exe"
DEP_GEN=${MP_JAVA_PATH}java -jar "E:/Program Files/Microchip/MPLABX/v6.00/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="E:\Program Files\Microchip\xc32\v4.10\bin"
MP_CPPC_DIR="E:\Program Files\Microchip\xc32\v4.10\bin"
# MP_BC_DIR is not defined
MP_AS_DIR="E:\Program Files\Microchip\xc32\v4.10\bin"
MP_LD_DIR="E:\Program Files\Microchip\xc32\v4.10\bin"
MP_AR_DIR="E:\Program Files\Microchip\xc32\v4.10\bin"
# MP_BC_DIR is not defined
CMSIS_DIR=E:/Program Files/Microchip/MPLABX/v6.00/packs/arm/CMSIS/5.4.0
DFP_DIR=E:/Program Files/Microchip/MPLABX/v6.00/packs/Microchip/SAME51_DFP/3.5.104

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
# mcal configuration
CND_ARTIFACT_DIR_mcal=dist/mcal/production
CND_ARTIFACT_NAME_mcal=p417_SWTL.X.production.hex
CND_ARTIFACT_PATH_mcal=dist/mcal/production/p417_SWTL.X.production.hex

View File

@ -0,0 +1,73 @@
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_CONF=mcal
CND_DISTDIR=dist
TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/p417_SWTL.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
OUTPUT_BASENAME=p417_SWTL.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
PACKAGE_TOP_DIR=p417swtl.x/
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/package
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory ${TMPDIR}/p417swtl.x/bin
copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/package/p417swtl.x.tar
cd ${TMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/p417swtl.x.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${TMPDIR}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="65">
<projectmakefile>Makefile</projectmakefile>
<defaultConf>0</defaultConf>
<confs>
<conf name="mcal" type="2">
<platformToolSN>noToolString</platformToolSN>
<languageToolchainDir>E:\Program Files\Microchip\xc32\v4.10\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>
</mdbdebugger>
<runprofile version="6">
<args></args>
<rundir></rundir>
<buildfirst>true</buildfirst>
<console-type>0</console-type>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/F:/FCB_project/P417/CODE/20240523/MCC_TEST/P417_SWTL/firmware/src/FunctionState/FunctionState.c</file>
<file>file:/F:/FCB_project/P417/CODE/20240523/MCC_TEST/P417_SWTL/firmware/src/config/mcal/touch/touch.c</file>
</group>
</open-files>
</project-private>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>p417_SWTL</name>
<creation-uuid>e54023e9-3948-44ef-bf6f-29d8b223e555</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions>h</header-extensions>
<asminc-extensions/>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects/>
<sourceRootList>
<sourceRootElem>../src</sourceRootElem>
</sourceRootList>
<confList>
<confElem>
<name>mcal</name>
<type>2</type>
</confElem>
</confList>
<formatting>
<project-formatting-style>false</project-formatting-style>
</formatting>
</data>
</configuration>
</project>

View File

@ -0,0 +1,100 @@
#include "calib_public.h"
#include "calib_private.h"
int8_t Calib_Init(void)
{
int8_t ret = 0;
uint8_t i = 0;
for(i=0; i<total_data; i++)
{
CalibDataCtl[i].index = 0;
CalibDataCtl[i].status = 0;
CalibDataCtl[i].addr = i*8;
Calib_Read(CalibDataCtl[i].addr, CalibDataCtl[i].data.byte, Calib_Data_Size);
if((CalibDataCtl[i].data.def.sign) != Calib_Data_Sign)
{
CalibDataCtl[i].data.def.value = 0;
}
}
return ret;
}
uint16 Calib_GetData(uint8_t index)
{
return CalibDataCtl[index].data.def.value;
}
void Calib_Task(void)
{
static uint8_t delay = 0;
uint8_t i = 0;
if(delay++ < 25) return;
delay = 0;
for(i=0; i<total_data; i++)
{
if((CalibDataCtl[i].status&Calib_RequestBit) == Calib_RequestBit)
{
CalibDataCtl[i].buffer[CalibDataCtl[i].index] = Calib_GetData4Save();
CalibDataCtl[i].index ++;
if(CalibDataCtl[i].index >= Calib_Buffer_size)
{
CalibDataCtl[i].data.def.value = Calib_FilterData(CalibDataCtl[i].buffer);
CalibDataCtl[i].data.def.sign = Calib_Data_Sign;
Calib_Write(CalibDataCtl[i].addr, CalibDataCtl[i].data.byte, Calib_Data_Size);
CalibDataCtl[i].status &= ~Calib_RequestBit;
CalibDataCtl[i].status |= Calib_FinishedBit;
CalibDataCtl[i].index = 0;
}
}
}
}
int8_t Calib_Trigger(uint8_t index, uint16_t data)
{
int8_t ret = 0;
if(data > 0)
{
CalibDataCtl[index].data.def.value = data;
CalibDataCtl[index].data.def.sign = Calib_Data_Sign;
Calib_Write(CalibDataCtl[index].addr, CalibDataCtl[index].data.byte, Calib_Data_Size);
}else
{
CalibDataCtl[index].status |= Calib_RequestBit;
}
return ret;
}
int8_t Calib_FinishCheck(uint8_t index)
{
int8_t ret = -1;
if((CalibDataCtl[index].status&Calib_FinishedBit) == Calib_FinishedBit)
{
CalibDataCtl[index].status = 0;
ret = 0;
}
return ret;
}
uint16_t Calib_FilterData(uint16_t * data)
{
uint32_t Sum = 0;
uint8_t i = 0;
for(i=0; i<Calib_Buffer_size; i++)
{
Sum += *(data+i);
}
return Sum/Calib_Buffer_size;
}

View File

@ -0,0 +1,35 @@
#ifndef _CALIB_CALLOUT_H
#define _CALIB_CALLOUT_H
#include "Std_Types.h"
#include "smartee.h"
#include "forcedetect.h"
#define CALIBRATION_BASE_ADDRESS 0x700
#define CALIBRATION_SPACE_SIZE 128
int8_t Calib_Write(uint16_t addr, uint8_t *data, uint8_t len)
{
int8_t ret = 0;
ret = SmartEE_Write(addr+CALIBRATION_BASE_ADDRESS, data, len);
return ret;
}
int8_t Calib_Read(uint16_t addr, uint8_t *data, uint8_t len)
{
int8_t ret = 0;
ret = SmartEE_Read(addr+CALIBRATION_BASE_ADDRESS, data, len);
return ret;
}
uint16_t Calib_GetData4Save(void)
{
return Get_forcedetect_force_value();
}
#endif

View File

@ -0,0 +1,44 @@
#ifndef _CALIB_PRIVATE_H
#define _CALIB_PRIVATE_H
#include "Std_Types.h"
#include "calib_public.h"
#include "calib_callout.h"
enum CalibStatus
{
Calib_RequestBit = 1,
Calib_FinishedBit = 2,
};
#define Calib_Data_Sign 0x55
#define Calib_Buffer_size 5
#define Calib_Data_Size 8
typedef union
{
uint8_t byte[Calib_Data_Size];
struct
{
uint8_t sign;
uint16_t value;
uint8_t reserved0;
uint8_t reserved1;
uint16_t reserved2;
uint8_t reserved3;
}def;
}Data_Un;
typedef struct
{
uint8_t status;
uint16_t addr;
Data_Un data;
uint16_t buffer[Calib_Buffer_size];
uint8_t index;
}CalibData_St;
CalibData_St CalibDataCtl[total_data];
uint16_t Calib_FilterData(uint16_t * data);
#endif

View File

@ -0,0 +1,36 @@
#ifndef _CALIB_PUBLIC_H
#define _CALIB_PUBLIC_H
#include "Std_Types.h"
enum CalibIndex
{
data0 = 0,
data1,
data2,
data3,
data4,
data5,
data6,
data7,
total_data,
};
/* Calibration module init, call it at initialize phase*/
sint8 Calib_Init(void);
/* Get calibraion data */
uint16 Calib_GetData(uint8 index);
/* calibration task called every 2ms */
void Calib_Task(void);
/* trigger calibration in $31 start */
sint8 Calib_Trigger(uint8 index, uint16 data);
/* check calibration finish*/
sint8 Calib_FinishCheck(uint8 index);
#endif

View File

@ -0,0 +1,424 @@
/************ Copyright FICOSA International All Rights Reserved ***********
| Language: | MISRA C
| Controller: | Independent based on FICOSA Hardware Abstraction Layer
| Spec. Document: | none
|------------------------------------------------------------------------------
| Codification Date: | 24/7/2012
| Date - Coder - Description
| 24/07/12 OC Creation of the file.
| 14/08/12 OC Added the ERR_CTRL_NOTIF callback
| 31/08/12 OQ Remove dual compiler conditional interface (always can handler)
| 27/03/15 FPR Adapted to RENESAS RH850F1L
|------------------------------------------------------------------------------
| DESCRIPTION:
| Wrapper between FicOsekComm and the EB Autosat CAN Driver.
| Tested on MPC5604P and MPC5604B/C MCALs
| Tested on Renesas RH850F1L MCAL
|------------------------------------------------------------------------------
| GENERAL CONSIDERATIONS:
| The configuration parameters defined in this file are dependent on the
| corresponding AUTOSAR CAN driver configuration.
|
****************************** END OF HEADER *****************************/
#ifndef __FICOSARCAN_H
#define __FICOSARCAN_H
/* ------------------------------ Includes ---------------------------------- */
#include "Std_Types.h"
//#include "Can.h"
#include "plib_can1.h"
#include "DiagnosticL/_configurations/FicosarCfg.h"
#include "OsekCom/OsekCom.h"
/*-------------------------------- Defines -------------------------------*/
/* Macros that define in FicosarCfg.h if the CAN peripheral are enabled */
#define CAN_ENABLED (1)
#define CAN_DISABLED (0)
/* Macros to set if the driver has to filter automatically all the extended frames or not */
#define CAN_EXTENDED_FRAMES_FILTERED (1)
#define CAN_EXTENDED_FRAMES_NOTIFIED (2)
#define CAN_ID_EXTENDED_MASK ((UI_32)0x1FFFFFFF)
#define CAN_ID_EXTENDED_FLAG ((UI_32)0x80000000)
#define CAN_ID_REMOTE_FLAG ((UI_32)0x40000000)
#define CAN_ID_EXTENDED_REMOTE_FLAG ((UI_32)0xC0000000)
/* ------------------------------ Data Types -------------------------------- */
/* CAN buffer handler */
typedef UI_8 t_can_buf_hdl;
/* CAN message */
typedef UI_8 t_can_data[8];
#if (CAN_EXTENDED_FRAMES == CAN_EXTENDED_FRAMES_NOTIFIED)
typedef UI_32 t_idtp; /* Identifier type in case that the driver */
/* works with extended frames */
#else
typedef UI_16 t_idtp; /* Identifier type in case that the driver */
/* works with standard frames */
#endif
/* CAN handlers definition */
//typedef enum {
// CAN1_HANDLER = 0x00, /* CAN1 handler */
// CAN2_HANDLER = 0x01, /* CAN2 handler */
// CAN_HANDLER_UNKNOWN = 0xFF
//}t_can_handler;
/* CAN wrapper logical states*/
typedef enum {
CAN_STATUS_NOINIT = 0x00, /* Driver not initialized */
CAN_STATUS_ONLINE = 0x01, /* Driver on line */
CAN_STATUS_OFFLINE_PENDING = 0x02, /* Driver going to off line */
CAN_STATUS_OFFLINE = 0x03, /* Driver off line */
CAN_STATUS_BUSOFF = 0x04, /* Driver in bus off */
CAN_STATUS_SLEEP = 0x05 /* Driver in sleep mode */
} t_can_status;
/* CAN buffer object structure for each channel */
//typedef struct {
//Can_PduType stTxBuffer0; /*Can_PduType elements: id, swPduHandle, length, sdu */
//BOOL Tx0Nofif;
//Can_PduType stTxBuffer1;
// BOOL Tx1Nofif;
// Can_PduType stRxBuffer;
//} t_Can_BufferObject;
/* ------------------------------ Functions --------------------------------- */
/*****************************************************************************
| Macro: CAN_CALC_STD_ID
|----------------------------------------------------------------------------
| Operations contract:
| * Computing idtp macro for a standard ordinary frame. This macro is thought
| to be solved during the compiling time to a constant value.
|---------------------------------------------------------------------------
| Parameters explanation:
| id: is the standard ordinary frame id
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
//#define CAN_CALC_STD_ID(id) ((t_idtp)(id))
/*****************************************************************************
| Macro: CAN_CALC_STD_REMOTE_ID
|----------------------------------------------------------------------------
| Operations contract:
| * Computing idtp macro for a standard remote frame. This macro is thought
| to be solved during the compiling time to a constant value.
|---------------------------------------------------------------------------
| Parameters explanation:
| id: is the standard remote frame id
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#define CAN_CALC_STD_REMOTE_ID(id) ((t_idtp)((t_idtp)(id) | CAN_ID_REMOTE_FLAG))
/*****************************************************************************
| Macro: CAN_CALC_EXT_ID
|----------------------------------------------------------------------------
| Operations contract:
| * Computing idtp macro for a extended ordinary frame. This macro is thought
| to be solved during the compiling time to a constant value.
|---------------------------------------------------------------------------
| Parameters explanation:
| id: is the extended ordinary frame id
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#if (CAN_EXTENDED_FRAMES == CAN_EXTENDED_FRAMES_NOTIFIED)
#define CAN_CALC_EXT_ID(id) ((t_idtp)((t_idtp)(id) | CAN_ID_EXTENDED_FLAG))
#endif
/*****************************************************************************
| Macro: CAN_CALC_EXT_REMOTE_ID
|----------------------------------------------------------------------------
| Operations contract:
| * Computing idtp macro for a extended remote frame. This macro is thought
| to be solved during the compiling time to a constant value.
|---------------------------------------------------------------------------
| Parameters explanation:
| id: is the extended remote frame id
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#if (CAN_EXTENDED_FRAMES == CAN_EXTENDED_FRAMES_NOTIFIED)
#define CAN_CALC_EXT_REMOTE_ID(id) ((t_idtp)((t_idtp)(id) | CAN_ID_EXTENDED_REMOTE_FLAG))
#endif
/*---------------------- prototips de funcions ---------------------------*/
/*****************************************************************************
| Routine: CanInit
|----------------------------------------------------------------------------
| Operations contract:
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
//void CanInit(t_can_handler can_handler, const Can_ConfigType *CanConfigType);
/*****************************************************************************
| Routine: CanReinit
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to initialize again the CAN peripheral going from any state to
| normal mode.
| * After calling this routine the driver will be in OffLine mode.
| * Before calling this routine the peripheral must be initialized with the
| CanInit routine.
| * Before calling this routine the user must be sure that the peripheral
| doesn't have any TX pending frame. A way to do that is verifying
| that the driver is in OffLine mode.
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void CanReinit(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanSleep
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to put the CAN peripheral in a low consumption mode.
| * Before calling this routine the peripheral must be initialized with the
| CanInit routine.
| * Before calling this routine the user must be sure that the peripheral
| doesn't have any TX pending frame. A way to do that is verifying
| that the driver is in OffLine mode.
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void CanSleep(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanStop
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to put the CAN peripheral into a non initialized state.
| * The state after calling this routine will be the same as before calling
| * the CanInit routine.
| * Before calling this routine the user must be sure that the peripheral
| doesn't have any TX pending frame. A way to do that is verifying
| that the driver is in OffLine mode.
| * To use the driver again follow the init sequence.
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void CanStop(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanOnLine
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to open the CAN communications
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void CanOnLine(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanOffLine
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to close the CAN communications
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void CanOffLine(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanBufQueryIdtp
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to get a buffer idtp. The idtp identify an unique frame defined
| by his id and his type.
|---------------------------------------------------------------------------
| Parameters explanation:
| bhdl: Buffer hardware handler from which the information will be got
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
//t_idtp CanBufQueryIdTp(t_can_handler can_handler, t_can_buf_hdl bhdl);
/*****************************************************************************
| Routine: CanTxRequest
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to ask for a free hardware buffer to transmit a CAN frame.
| * This routine will active the callback TX mechanism if that wasn't
| activated before.
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void CanTxRequest(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanTx
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to transmit a CAN frame.
|---------------------------------------------------------------------------
| Parameters explanation:
| notif: Boolean that tells the driver if a transmission notification is
| required
| TRUE -> a notification is required
| FALSE -> no notification requiered
| idtp: Idtp of the frame that will be transmited
| len: Data bytes length of the frame
| can_data: Adress of the variable that have the data to be transmited. If
| no data is wanted to be transmited, the user can put a 0 in the
| len parameter and a NULL in the can_data parameter.
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
//void CanTx(t_can_handler can_handler, BOOL notif, t_idtp idtp, UI_8 len,t_can_data can_data);
/*****************************************************************************
| Routine: CanReadStatus
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to check the current CAN driver state
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_can_status CanReadStatus(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanBufQueryDataLen
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to get the hw buffer status.
|---------------------------------------------------------------------------
| Parameters explanation:
| can_handler: Identifier of CAN handler
| result: TRUE - buffer free
| FALSE - buffer full
/---------------------------------------------------------------------------*/
BOOL CanQueryTxBufEmpty(t_can_handler can_handler);
/*****************************************************************************
| Routine: CanBufQueryDataLen
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to get a hardware buffer data length.
|---------------------------------------------------------------------------
| Parameters explanation:
| bhdl: buffer hardware handler from which the information is required
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#define CAN_BUF_QUERY_DATA_LEN(HwCtl, bhdl) (CanBufQueryDataLen(HwCtl, bhdl))
UI_8 CanBufQueryDataLen(t_can_handler can_handler, t_can_buf_hdl bhdl);
/*****************************************************************************
| Routine: CanBufQueryDataByte
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to get a hardware buffer data bytes.
|---------------------------------------------------------------------------
| Parameters explanation:
| bhdl: buffer hardware handler from which the information is required
| byte: data byte index required [0..7]
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: TBD cpu cycles | O(n): CTE
| Tmax Int En : TBD cpu cycles | O(n): CTE
| Tmax Total : TBD cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
//#define CAN_BUF_QUERY_DATA_BYTE(HwCtl, bhdl, byte) (CanBufQueryDataByte(HwCtl, bhdl, byte))
//UI_8 CanBufQueryDataByte(t_can_handler can_handler, t_can_buf_hdl bhdl, UI_8 index);
/*****************************************************************************
| Routine: CanQueryRxActivity
|----------------------------------------------------------------------------
| Operations contract:
| * Routine that says if there was CAN activity since last check
|---------------------------------------------------------------------------
| Parameters explanation:
| return: TRUE if has been CAN activity since last check
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL CanQueryRxActivity(t_can_handler can_handler);
#endif

View File

@ -0,0 +1,367 @@
/* ------------------------------ Includes ---------------------------------- */
//#include "Global.h"
#include "Std_Types.h"
//#include "Gpt.h"
#include "P417_SWTL_App_ert_rtw/P417_SWTL_App.h"
#include "Timer.h"
/* ------------------------------ Constants --------------------------------- */
#if (TIMER_TIME_UNIT == U_SECONDS)
#if ((TIMER_TIME_TICK < 1) || (TIMER_TIME_TICK > 1625))
#error "Value not supported for TIMER_TIME_TICK"
#else
#define TIMER_VALOR ((UI_16)(TIMER_TIME_TICK*FACTOR_CONVERSIO_FCY_US))
#endif
#elif (TIMER_TIME_UNIT == M_SECONDS)
#if ((TIMER_TIME_TICK < 1) || (TIMER_TIME_TICK > 104))
#error "Value not supported for TIMER_TIME_TICK"
#else
#define TIMER_VALOR ((UI_16)(((UI_16)TIMER_TIME_TICK)*((UI_16)(FACTOR_CONVERSIO_FCY_MS))))
#endif
#else
#error "Time unit not defined."
#endif /* TIMER_TIME_UNIT */
/* Timer time max value definition */
#if(T_TIMER_TIME_SIZE == T_TIMER_TIME_1_BYTE)
#define T_TIMER_TICK_MAX_VALUE ((UI_8)0xFF)
#elif(T_TIMER_TIME_SIZE == T_TIMER_TIME_2_BYTE)
#define T_TIMER_TICK_MAX_VALUE ((UI_16)0xFFFF)
#elif(T_TIMER_TIME_SIZE == T_TIMER_TIME_4_BYTE)
#define T_TIMER_TICK_MAX_VALUE ((UI_32)0xFFFFFFFF)
#else
#error "Size definition for t_timer_time is missing in FicosarCfg.h"
#endif
/* --------------------------- Global Variables ----------------------------- */
/* Variable that contain current tick */
static volatile t_timer_tick current_tick = (t_timer_tick)0;
/* Variable to control last cycle tick synchronized */
static volatile t_timer_tick cycle_tick = (t_timer_tick)0;
/* ------------------------------ Functions --------------------------------- */
#ifdef TIMER_TICK_CALLBACK
void TIMER_TICK_CALLBACK (void);
#endif
/******************************************************************************
| Routine: TimerInit
| ----------------------------------------------------------------------------
| Operations contract:
| This routine initializes the AUTOSAR GPT module to control the time according
| to the parameters given and permit to synchronize the main program cycle
| at each required point.
|-----------------------------------------------------------------------------
| Parameters explanation:
| All the configuration parameters are defined in FicoTimeWrapper.h
/---------------------------------------------------------------------------*/
void TimerInit(void)
{
// UI_32 value;
/* Initialization of tick counters */
current_tick = (t_timer_tick)0;
cycle_tick = (t_timer_tick)0;
/* Value calculation to load counter register */
#if (TIMER_TIME_UNIT == U_SECONDS)
value=(TIMER_TIME_TICK * FREQ_SYS_CLOCK) - ((UI_8)1);
#elif (TIMER_TIME_UNIT == M_SECONDS)
// value=(TIMER_TIME_TICK * ((UI_32)1000) * FREQ_SYS_CLOCK)- ((UI_8)1);
#endif
/* Initialization of the GPT Driver */
//Gpt_Init(GPT_CONFIG_SET_0);
/* Enabling the Notification */
//Gpt_EnableNotification(GPT_CONFIG_CHANNEL_0);
/* Starting the Timer */
//Gpt_StartTimer(GPT_CONFIG_CHANNEL_0, value);
} /* TimerInit */
/******************************************************************************
| Routine: TimerReset
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine reinitialize the actual tick counter.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
/---------------------------------------------------------------------------*/
void TimerReset(void)
{
//UI_32 value;
/* Value calculation to load counter register */
#if (TIMER_TIME_UNIT == U_SECONDS)
value=(TIMER_TIME_TICK * FREQ_SYS_CLOCK) - ((UI_8)1);
#elif (TIMER_TIME_UNIT == M_SECONDS)
// value=(TIMER_TIME_TICK * ((UI_32)1000) * FREQ_SYS_CLOCK)- ((UI_8)1);
#endif
/* Disabling the Notification */
//Gpt_DisableNotification(GPT_CONFIG_CHANNEL_0);
/* Stopping the Timer */
//Gpt_StopTimer(GPT_CONFIG_CHANNEL_0);
/* Enabling the Notification */
// Gpt_EnableNotification(GPT_CONFIG_CHANNEL_0);
/* Starting the Timer */
//Gpt_StartTimer(GPT_CONFIG_CHANNEL_0, value);
} /* TimerReset */
/******************************************************************************
| Routine: TimerSyncTick
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine is optional and only have to be called from the main program
| cycle
| * This routine is used to make an active wait to synchronize the main
| program cycle with a tick chosen between one of the number of ticks in
| which the main cycle has been divided
| * The user must be sure that if he makes different synchronizations inside
| the main program cycle, he increments the num_tick parameter given in
| each of the call.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| num_tick: number of tick in which the user want to synchronize the main
| program cycle. This parameter must be inside the range
| [1..TIMER_TICKS_CICLE-1]
| num_ticks = TIMER_TICKS_CICLE is reserved to TimerSyncCycle
| result: ERROR_OK if the timer didn't reach the synchronization point
| num_tick before the call
| ERROR_GENERIC if the timer reached the synchronization point
| num_tick before the call
/---------------------------------------------------------------------------*/
t_error TimerSyncTick(t_timer_tick num_tick)
{
t_error resultat = ERROR_OK;
BOOL synchronized;
t_timer_tick enter_loop_tick = 0;
/* Case in which next cycle tick overflows the ticks variable */
if(cycle_tick > (T_TIMER_TICK_MAX_VALUE - num_tick)) {
/* Mutex to avoid that RSI could modify the value during the calculation */
// DISABLE_INTERRUPTS();
synchronized = (current_tick < cycle_tick) && (current_tick >= ((t_timer_tick) (cycle_tick + num_tick)));
//ENABLE_INTERRUPTS();
/* Check if next tick to synchronize is already reached*/
if (synchronized == TRUE) {
/* Notify that cycle was already expired, the current main loop */
/* path was larger than expected by design */
resultat = ERROR_GENERIC;
}
else {
/* Active waiting to synchronize to given tick */
while (synchronized == FALSE) {
/* Mutex to avoid that RSI could modify the value during the calculation */
// DISABLE_INTERRUPTS();
synchronized = (current_tick < cycle_tick) && (current_tick >= ((t_timer_tick) (cycle_tick + num_tick)));
// ENABLE_INTERRUPTS();
}
}
}
/* Case in which next cycle tick does not overflow the ticks variable */
else {
/* Mutex to avoid that RSI could modify the value during the calculation */
// DISABLE_INTERRUPTS();
synchronized = (current_tick >= ((t_timer_tick) (cycle_tick + num_tick)));
//ENABLE_INTERRUPTS();
/* Check if next tick to synchronize is already reached */
if (synchronized == TRUE) {
/* Notify that cycle was already expired, the current main loop */
/* path was larger than expected by design */
resultat = ERROR_GENERIC;
}
else {
//DISABLE_INTERRUPTS();
enter_loop_tick = current_tick;
//ENABLE_INTERRUPTS();
/* Active waiting to synchronize to given tick */
while (synchronized == FALSE) {
/* Mutex to avoid that RSI could modify the value during the calculation */
// DISABLE_INTERRUPTS();
if(current_tick >= enter_loop_tick) {
synchronized = (current_tick >= ((t_timer_tick) (cycle_tick + num_tick)));
}else{
synchronized = TRUE;
}
//ENABLE_INTERRUPTS();
}
}
}
return resultat;
}
/******************************************************************************
| Routine: TimerSyncCicle
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine is mandatory in critical real time clock systems, and must
| be called one time at the end of the main program cycle.
| * This routine is used to make an active wait to synchronize the main
| program cycle with the cycle number of ticks configured
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| result: ERROR_OK if the time didn't expired the synchronization point
| of the last tick
| ERROR_GENERIC if the time expired the synchronization point
| of the last tick
/---------------------------------------------------------------------------*/
t_error TimerSyncCicle(void)
{
t_error resultat;
/* Synchronize with configured ticks cycle */
resultat = TimerSyncTick(TIMER_TICKS_CICLE);
/* Case which synchronization cycle was correctly performed */
if(resultat == ERROR_OK) {
/* Set next cycle initial tick as current cycle initial tick plus
the number ticks of a cycle */
cycle_tick += TIMER_TICKS_CICLE;
}
/* Case which synchronization point was already reached so the main loop */
/* path was larger than what was expected by design */
else {
/* Set next cycle initial tick as next current tick to assure next cycle
will have a complete TIMER_TICKS_CICLE ticks */
/* Mutex to avoid that RSI could modify the value during the calculation */
//DISABLE_INTERRUPTS();
cycle_tick = current_tick + (UI_8)1;
//ENABLE_INTERRUPTS();
}
return resultat;
}
/*****************************************************************************
| Routine: TimerGetCurrentTick
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to request the current tick at one point inside the main program
| cycle.
| * This routine shall be called when any FSM or function wants to start
| using a timer. At the timer initialization, the tick should be taken
| using this routine. Then with the TimerDeltaTime function the timer
| will be increased at each FSM or function execution and the tick will be
| directly updated by the TimerDeltaTime routine.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| result: current tick
/---------------------------------------------------------------------------*/
t_timer_tick TimerGetCurrentTick(void)
{
t_timer_tick aux_tick;
/* Mutex to avoid that RSI could modify the value during the calculation */
//DISABLE_INTERRUPTS();
aux_tick = current_tick;
//ENABLE_INTERRUPTS();
return aux_tick;
}
/*****************************************************************************
| Routine: TimerDeltaTime
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to compute the spent time between a tick given from the last task
| execution and the current tick at the moment of the call.
| * The precision is one clock tick.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| old_tick: Input/output parameter.
| As input, certain time tick obtained on the previous or current program
| cycle with the routine TimerGetCurrentTick or with the last
| call of TimerDeltaTime.
| As output return the current tick.
| result: spend time between the old_tick and the current tick.
| The units are in ticks.
| The equivalence between one tick and time is defined in HalCfg.
/---------------------------------------------------------------------------*/
t_timer_time TimerDeltaTime(t_timer_tick *old_tick)
{
t_timer_time time_diff;
t_timer_tick aux_tick;
/* Mutex to avoid that RSI could modify the value during the calculation */
//DISABLE_INTERRUPTS();
aux_tick = current_tick;
//ENABLE_INTERRUPTS();
/* Case in which current tick overflows the maximum tick*/
if(aux_tick < (*old_tick)){
time_diff = (T_TIMER_TIME_MAX_VALUE - (*old_tick)) + aux_tick + (UI_8)1;
}
/* Case in which current tick does not overflow the maximum tick*/
else{
/* Get the difference between given tick with current tick*/
time_diff = (t_timer_time)(aux_tick - (*old_tick));
}
/* Return the new tick */
*old_tick = aux_tick;
/* Return the difference of current tick compared to initial tick */
return time_diff;
}
/*****************************************************************************
| Routine: TimerIncrTime
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to increase the timer current tick time with a specific amount
| of time. This routine shall be called due to an operation which normally
| freezes the CPU and makes that the normal timer interrupt is not raised
| during some amount of time. Examples:
| - Execution of erasing or programming operations where CPU freezes
| - Usage of sleep functions or CPU low power operation modes where
| timer interrupt is not working
| * The precision is one clock tick.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| incr_time: time in which the timer shall increase its internal tick due to
| an external operation that avoids the normal counting of timer.
| This parameter shall be given using one of the macros:
| TIMER_MS_TO_TIME(x) or TIMER_US_TO_TIME(x)
/---------------------------------------------------------------------------*/
void TimerIncrTime(t_timer_time incr_time)
{
/* Mutex to avoid that RSI could modify the value during the calculation */
//DISABLE_INTERRUPTS();
current_tick += incr_time;
cycle_tick += incr_time;
//ENABLE_INTERRUPTS();
}
void SystemTimerGPT_callback(void)
{
/* Increase tick counter */
current_tick++;
#ifdef TIMER_TICK_CALLBACK
TIMER_TICK_CALLBACK();
#endif
}

View File

@ -0,0 +1,450 @@
#ifndef TIMER_H_
#define TIMER_H_
/* Allowed values for TIMER_TIME_UNIT */
#define M_SECONDS (1)
#define U_SECONDS (2)
/* ------------------------------ Includes ---------------------------------- */
//#include "Global.h"
#include "Std_Types.h"
#include "DiagnosticL/_configurations/FicosarCfg.h"
/* ------------------------------ Constants --------------------------------- */
/* Allowed956 values for T_TIMER_TIME_SIZE */
#define T_TIMER_TIME_1_BYTE (1)
#define T_TIMER_TIME_2_BYTE (2)
#define T_TIMER_TIME_4_BYTE (3)
/* Timer time max value definition */
#if(T_TIMER_TIME_SIZE == T_TIMER_TIME_1_BYTE)
#define T_TIMER_TIME_MAX_VALUE ((UI_8)0xFF)
#elif(T_TIMER_TIME_SIZE == T_TIMER_TIME_2_BYTE)
#define T_TIMER_TIME_MAX_VALUE ((UI_16)0xFFFF)
#elif(T_TIMER_TIME_SIZE == T_TIMER_TIME_4_BYTE)
#define T_TIMER_TIME_MAX_VALUE ((UI_32)0xFFFFFFFF)
#else
#error "Size definition for t_timer_time is missing in FicosarCfg.h"
#endif
/* ------------------------------- Macros ---------------------------------- */
/*****************************************************************************
| Macro: TIMER_MS_TO_TIME
|----------------------------------------------------------------------------
| Operations contract:
| * This macro converts a time value in milliseconds to time in the units of
| internal Timer clock according to the configuration selected.
| * The result value is rounded to the most near natural value.
| * This macro is used if the requested time has to be approximately accomplished.
| For example, with request 100ms the time could expire at 100ms+/-(x ms),
| where x is the error that it could be happen due to tick minimum configuration.
| * With this macro the time may not be reached exactly according of the timer
| configuration or cycle time
| * This macro is thought to be solved during compiling time
|---------------------------------------------------------------------------
| Parameters explanation:
| t: time period in milliseconds
| result: nearest internal timer time units of t miliseconds.
| The return type is a t_timer_time type
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#if (TIMER_TIME_UNIT == M_SECONDS)
#if (TIMER_TIME_TICK>1)
#if ( (t % TIMER_TIME_TICK) >= TIMER_TIME_TICK/2)
#define TIMER_MS_TO_TIME(t) (t_timer_time)(((UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)1)
#else
#define TIMER_MS_TO_TIME(t) (t_timer_time)(((UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)0)
#endif
#else
#define TIMER_MS_TO_TIME(t) ( (t_timer_time) (t) )
#endif
#elif (TIMER_TIME_UNIT == U_SECONDS)
#if (TIMER_TIME_TICK>1)
#if ( ((1000*(t)) % (TIMER_TIME_TICK) ) > 0 )
#define TIMER_MS_TO_TIME(t) (t_timer_time)((1000*(UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)1)
#else
#define TIMER_MS_TO_TIME(t) (t_timer_time)((1000*(UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)0)
#endif
#else
#define TIMER_MS_TO_TIME(t) ( (t_timer_time) (1000 * (UI_32)(t)) )
#endif
#endif
/*****************************************************************************
| Macro: TIMER_MS_TO_TIME_RESTRICTIVE
|----------------------------------------------------------------------------
| Operations contract:
| * This macro converts a time value in milliseconds to time in the units of
| internal Timer clock according to the configuration selected.
| * This macro is used if requested time always has to be accomplished
| With this macro the time will always be reached and according configuration
| timer may be exceeded until in 2 timer ticks.
| * For example, with request 100ms the time could expire at 100ms+(x*2 ms),
| where x is the error that it could be happen due to tick minimum configuration.
| * The configured time will always be accomplished
| * This macro is thought to be solved during compiling time
|---------------------------------------------------------------------------
| Parameters explanation:
| t: time period in milliseconds.
| result: internal timer time units of at least t miliseconds.
| The return type is a t_timer_time type
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#if (TIMER_TIME_UNIT == M_SECONDS)
#if (TIMER_TIME_TICK>1)
#if ( (t % TIMER_TIME_TICK) >= (TIMER_TIME_TICK / 2))
#define TIMER_MS_TO_TIME_RESTRICTIVE(t) (t_timer_time)(((UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)2)
#else
#define TIMER_MS_TO_TIME_RESTRICTIVE(t) (t_timer_time)(((UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)1)
#endif
#else
#define TIMER_MS_TO_TIME_RESTRICTIVE(t) ( (t_timer_time) ((t)+(UI_8)1) )
#endif
#elif (TIMER_TIME_UNIT == U_SECONDS)
#if (TIMER_TIME_TICK>1)
#if ( ((1000*(t)) % (TIMER_TIME_TICK) ) >= (TIMER_TIME_TICK / 2) )
#define TIMER_MS_TO_TIME_RESTRICTIVE(t) (t_timer_time)((1000*(UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)2)
#else
#define TIMER_MS_TO_TIME_RESTRICTIVE(t) (t_timer_time)((1000*(UI_32)(t))/((UI_8)TIMER_TIME_TICK) + (UI_8)1)
#endif
#else
#define TIMER_MS_TO_TIME_RESTRICTIVE(t) ( (t_timer_time) (1000 * (UI_32)((t)+(UI_8)1)) )
#endif
#endif
/*****************************************************************************
| Macro: TIMER_US_TO_TIME
|----------------------------------------------------------------------------
| Operations contract:
| * This macro converts a time value in microseconds to time in the units of
| internal Timer clock according to the configuration selected.
| * The result value is rounded to the most near natural value.
| * This macro is used if the requested time has to be approximately accomplished.
| For example, with request 100us the time could expire at 100us+/-(x us),
| where x is the error that it could be happen due to tick minimum configuration.
| * With this macro the time may not be reached exactly according of the timer
| configuration or cycle time
| * This macro is thought to be solved during compiling time
|---------------------------------------------------------------------------
| Parameters explanation:
| t: time period in microseconds.
| result: nearest internal timer time units of t microseconds.
| The return type is a t_timer_time type
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#if (TIMER_TIME_UNIT == M_SECONDS)
#define TIMER_US_TO_TIME(t) \
((t_timer_time)((((UI_32)(t))/((UI_8)TIMER_TIME_TICK * (UI_16)1000)) + \
(((((UI_32)(t))%((UI_8)TIMER_TIME_TICK * (UI_16)1000)) >= ((UI_8)TIMER_TIME_TICK * (UI_16)500)) ? \
(UI_8)1 : (UI_8)0)))
#elif (TIMER_TIME_UNIT == U_SECONDS)
#define TIMER_US_TO_TIME(t) \
(((UI_8)TIMER_TIME_TICK > (UI_8)1) ? \
((t_timer_time)((((UI_32)(t))/((UI_8)TIMER_TIME_TICK)) + \
(((((UI_32)(t))%((UI_8)TIMER_TIME_TICK)) >= (((UI_8)TIMER_TIME_TICK/(UI_8)2))) ? (UI_8)1 : (UI_8)0))) : \
((t_timer_time)(t)))
#endif
/*****************************************************************************
| Macro: TIMER_US_TO_TIME_RESTRICTIVE
|----------------------------------------------------------------------------
| Operations contract:
| * This macro converts a time value in microseconds to time in the units of
| internal Timer clock according to the configuration selected.
| * This macro is used if requested time always has to be accomplished
| With this macro the time will always be reached and according configuration
| timer may be exceeded until in 2 timer ticks.
| * For example, with request 100us the time could expire at 100us+(x*2 us),
| where x is the error that it could be happen due to tick minimum configuration.
| * The configured time will always be accomplished
| * This macro is thought to be solved during compiling time
|---------------------------------------------------------------------------
| Parameters explanation:
| t: time period in microseconds.
| result: internal timer time units of at least t microseconds.
| The return type is a t_timer_time type
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#if (TIMER_TIME_UNIT == M_SECONDS)
#define TIMER_US_TO_TIME_RESTRICTIVE(t) \
((t_timer_time)((((UI_32)(t))/((UI_8)TIMER_TIME_TICK * (UI_16)1000)) + (UI_8)1 + \
(((((UI_32)(t))%((UI_8)TIMER_TIME_TICK * (UI_16)1000)) >= ((UI_8)TIMER_TIME_TICK * (UI_16)500)) ? \
(UI_8)1 : (UI_8)0)))
#elif (TIMER_TIME_UNIT == U_SECONDS)
#define TIMER_US_TO_TIME_RESTRICTIVE(t) \
(((UI_8)TIMER_TIME_TICK > (UI_8)1) ? \
((t_timer_time)((((UI_32)(t))/((UI_8)TIMER_TIME_TICK)) + (UI_8)1 + \
(((((UI_32)(t))%((UI_8)TIMER_TIME_TICK)) >= (((UI_8)TIMER_TIME_TICK/(UI_8)2))) ? (UI_8)1 : (UI_8)0))) : \
((t_timer_time)((t) + (UI_8)1)))
#endif
/*****************************************************************************
| Macro: TIMER_1SEG_TO_TIME
|----------------------------------------------------------------------------
| Operations contract:
| * This macro converts 1 second to time in the units of internal Timer
| clock according to the configuration selected.
| * The result value is rounded to the most near natural value.
| * This macro is thought to be solved during compiling time
|---------------------------------------------------------------------------
| Parameters explanation:
| result: internal timer time of 1 second. The return type is a t_timer_time
| type
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#define TIMER_1SEG_TO_TIME() (TIMER_MS_TO_TIME((UI_16)1000))
/*****************************************************************************
| Macro: TIMER_1MIN_TO_TIME
|----------------------------------------------------------------------------
| Operations contract:
| * This macro converts 1 minute to time in the units of internal Timer
| clock according to the configuration selected.
| * The result value is rounded to the most near natural value.
| * This macro is thought to be solved during compiling time
|---------------------------------------------------------------------------
| Parameters explanation:
| result: internal timer time of 1 second. The return type is a t_timer_time
| type
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: 0 cpu cycles | O(n): CTE
| Tmax Int En : 0 cpu cycles | O(n): CTE
| Tmax Total : 0 cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#define TIMER_1MIN_TO_TIME() (TIMER_MS_TO_TIME((UI_16)60000))
/* ------------------------------ Data Types -------------------------------- */
/* Timer tick and time types definition */
#if(T_TIMER_TIME_SIZE == T_TIMER_TIME_1_BYTE)
typedef UI_8 t_timer_time;
typedef UI_8 t_timer_tick;
#elif(T_TIMER_TIME_SIZE == T_TIMER_TIME_2_BYTE)
typedef UI_16 t_timer_time;
typedef UI_16 t_timer_tick;
#elif(T_TIMER_TIME_SIZE == T_TIMER_TIME_4_BYTE)
typedef UI_32 t_timer_time;
typedef UI_32 t_timer_tick;
#else
#error "Size definition for t_timer_time is missing in HalCFG"
#endif
/* ------------------------------ Functions --------------------------------- */
/******************************************************************************
| Routine: TimerInit
| ----------------------------------------------------------------------------
| Operations contract:
| This routine initializes the TIM peripheral to control the time according
| to the parameters given and permit to synchronize the main program cycle
| at each required point.
|-----------------------------------------------------------------------------
| Parameters explanation:
| All the configuration parameters are defined in HalCFG.h
|-----------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TimerInit(void);
/******************************************************************************
| Routine: TimerReset
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine reinitialize the actual tick counter.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TimerReset(void);
/******************************************************************************
| Routine: TimerSyncTick
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine is optional and only have to be called from the main program
| cycle
| * This routine is used to make an active wait to synchronize the main
| program cycle with a tick chosen between one of the number of ticks in
| which the main cycle has been divided
| * The user must be sure that if he makes different synchronizations inside
| the main program cycle, he increments the num_tick parameter given in
| each of the call.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| num_tick: number of tick in which the user want to synchronize the main
| program cycle. This parameter must be inside the range
| [1..TIMER_TICKS_CICLE-1]
| result: ERROR_OK if the time didn't expired the synchronization point
| given as a parameter
| ERROR_GENERIC if the time expired the synchronization point
| given as a parameter
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_error TimerSyncTick(t_timer_tick num_tick);
/******************************************************************************
| Routine: TimerSyncCicle
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine is mandatory in critical real time clock systems, and must
| be called one time at the end of the main program cycle.
| * This routine is used to make an active wait to synchronize the main
| program cycle with the cycle number of ticks configured
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| result: ERROR_OK if the time didn't expired the synchronization point
| of the last tick
| ERROR_GENERIC if the time expired the synchronization point
| of the last tick
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_error TimerSyncCicle(void);
/*****************************************************************************
| Routine: TimerGetCurrentTick
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to request the current tick at one point inside the main program
| cycle.
| * This routine shall be called when any FSM or function wants to start
| using a timer. At the timer initialization, the tick should be taken
| using this routine. Then with the TimerDeltaTime function the timer
| will be increased at each FSM or function execution and the tick will be
| directly updated by the TimerDeltaTime routine.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| result: current tick
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_timer_tick TimerGetCurrentTick(void);
/*****************************************************************************
| Routine: TimerDeltaTime
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to compute the spent time between a tick given from the last task
| execution and the current tick at the moment of the call.
| * The precision is one clock tick.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| ini_tick: certain time tick obtained on the previous or current program
| cycle with the routine TimerGetCurrentTick or with the last
| call of TimerDeltaTime
| result: spend time between the ini_tick tick and the current tick. The
| units are the ones configured in the TimerInit call.
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_timer_time TimerDeltaTime(t_timer_tick *old_tick);
/*****************************************************************************
| Routine: TimerIncrTime
|----------------------------------------------------------------------------
| Operations contract:
| * Routine to increase the timer current tick time with a specific amount
| of time. This routine shall be called due to an operation which normally
| freezes the CPU and makes that the normal timer interrupt is not raised
| during some amount of time. Examples:
| - Execution of erasing or programming operations where CPU freezes
| - Usage of sleep functions or CPU low power operation modes where
| timer interrupt is not working
| * The precision is one clock tick.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
| incr_time: time in which the timer shall increase its internal tick due to
| an external operation that avoids the normal counting of timer.
| This parameter shall be given using one of the macros:
| TIMER_MS_TO_TIME(x) or TIMER_US_TO_TIME(x)
|---------------------------------------------------------------------------
| Execution time:
| Tmax Int Dis: ??? cpu cycles | O(n): CTE
| Tmax Int En : ??? cpu cycles | O(n): CTE
| Tmax Total : ??? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TimerIncrTime(t_timer_time incr_time);
/******************************************************************************
| Routine: SystemTimerGPT_callback
| ----------------------------------------------------------------------------
| Operations contract:
| * This routine is the callback routine of AUTOSAR GPT (Timer) and it is called
| every tick of the clock.
| * This routine reinitialize the actual tick counter.
| * Before calling this routine, the driver must have been initialized with
| the TimerInit routine.
|---------------------------------------------------------------------------
| Parameters explanation:
|---------------------------------------------------------------------------
| Execution time:
|
/---------------------------------------------------------------------------*/
void SystemTimerGPT_callback(void);
//ACF deprecated
typedef t_timer_time t_clock;
#define TIMER_US_TO_TICKS(t) (TIMER_US_TO_TIME((t)))
#define TIMER_MS_TO_TICKS(t) (TIMER_MS_TO_TIME((t)))
#define TIMER_1SEG_TO_TICKS() (TIMER_1SEG_TO_TIME())
#define TIMER_1MIN_TO_TICKS() (TIMER_1MIN_TO_TIME())
#define TimerDeltaCicleConsulta() ((UI_16)(TIMER_TICKS_CICLE))
#define T_CLOCK_MAX_VALUE (T_TIMER_TIME_MAX_VALUE)
#endif /* FICOSARTIMER_H_ */

View File

@ -0,0 +1,291 @@
/*************** COPYRIGHT (c) 2002-2007 FICOSA INTERNATIONAL **************
| Language: | MISRA C
| Controller: | Generic
| Spec. Document: | ISO15765-2-E.pdf
|-----------------|------------------------------------------------------------
| Project: | ISO15765-2
| Reference: |
|------------------------------------------------------------------------------
| Date - Cod. - Rev. - App. - Description
| 12/09/02 AM Implementation of the kwp2000 for PSA.
| 19/08/04 DT Split ISO15765_2 protocol from the KWP2000
| because they are different modules.
| 24/04/09 DC Modification to guarantee the requirements SR1431,
| SR1438, SR1681.
| 15/12/10 AC Converted ISO15765_2 protocol to multi-instance.
| 13/11/11 AC Converted ISO15765_2 to full-duplex
| 09/01/12 AC Changed file, routines and variable naming to
| make it a standard component improving his
| comprehension and having a similar naming style
| with MPDT.
|------------------------------------------------------------------------------
| DESCRIPTION:
| User interface for the transport protocol ISO15765_2 on CAN.
| ISO15765_2 protocol is a transport protocol that permits the sending and
| reception of frames until 4096 bytes on a network protocol with frames of
| lower size. The original frame is segemented and sent with flow control
| data that allows to the reception node to mount again the original frame.
| GENERAL CONSIDERATIONS
| - This implementation allows full duplex communications.
| - This implementation allows for each instance a communication channel
| with physical address in which both transmission and receptions could
| be done and a funcional address for only receptions.
| - The functional address channel only supports frames with less than
| 8 bytes of data.
| - This header must be included by the application as it contains the
| definitions of the ISO15765_2 shared structures that allow the ISO15765_2
| and the application to communicate and interact.
******************************************************************************/
#ifndef __TP_H
#define __TP_H
/*----------------------------- INCLUDES ---------------------------------*/
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#include "DiagnosticL/FicOsek/FicOsekCom.h"
#include "OsekCom/OsekCom.h"
//#include "Global.h"
#include "Std_Types.h"
/*----------------------------- DEFINES ----------------------------------*/
/* Macro to calculate the size of the buffer that must allocate the */
/* transport protocol frame */
#define SIZE_ALLOC_BUFFER(val) \
(((val) <= 7) ? (7) : \
((val) + (((((val) - 6) % 7) > 0) ? (7 - (((val) - 6) % 7)) : (0))))
/*-------------------------- DATA TYPES ----------------------------------*/
/* List of the possible types of flow controls */
typedef enum {
TP_FLOW_STS_CTS = 0, /* Clear to Send */
TP_FLOW_STS_WT = 1, /* Wait */
TP_FLOW_STS_OVFLW = 2 /* Buffer Overflow */
} t_tp_flow_sts;
/* List of the possible status for transmiting */
typedef enum {
TP_TX_REQUESTED = 0, /* Transmission requested */
TP_TX_ON_GOING = 1, /* Transmission ongoing */
TP_TX_CONFIRMED = 2, /* Transmission confirmed */
TP_TX_ERROR = 3 /* Transmission error */
} t_tp_tx_sts;
/* List of the possible types of transport protocol received frames */
typedef enum {
TP_RX_SF = 0, /* Received Single Frame (SF) */
TP_RX_FF = 1, /* Received First Frame (FF) */
TP_RX_CF = 2, /* Received Consecutive Frame (CF) */
TP_RX_NO_FRM = 3 /* No recognized frame received */
} t_tp_rx_frm;
/* List of the possible status of flow control */
typedef enum {
TP_FC = 0, /* Received Flow Control Frame (FC) */
TP_NO_FC_FRM = 1 /* No recognized FC received */
} t_tp_fc_frm;
/* List of the possible status of reception */
typedef enum {
TP_FRM_RX_IDLE = 0, /* Idle status of RX, nothing new */
TP_FRM_RX_IN_PRG = 1, /* Reception in progress */
TP_FRM_RX_NOTIF = 2, /* Notification to higher layer of a full reception */
TP_FRM_RX_ERR_NOTIF = 3, /* Notification to higher layer of error during a reception */
TP_FRM_RX_FINISHED = 4, /* CF reception finished and pending to be notified to higher layer */
TP_FRM_RX_ERR_FINISHED = 5 /* Error reception finished and pending to be notified to higher layer */
} t_tp_frm_sts_rx;
/* List of the possible status of transmission */
typedef enum {
TP_FRM_TX_IDLE = 0, /* No TX in progress and last TX OK */
TP_FRM_TX_REQ = 1, /* Transmission requested and pending */
TP_FRM_TX_ERR_NOTIF = 2, /* Error occurred during last transmission */
TP_FRM_TX_PENDING = 3 /* Transmission needed pending to be given */
} t_tp_frm_sts_tx;
/* Types of frame that TP have pending to send */
typedef enum {
TP_TX_TYPE_NONE = 0, /* TP do not have any frame to be sent */
TP_TX_TYPE_FC = 1, /* TP is going to send a FC */
TP_TX_TYPE_SF_FF_CF = 2 /* TP is going to send a SF, FF or CF */
} t_tp_tx_type;
/* Structure that contains all the information for the physical reception and transmission */
typedef struct {
UI_8* data_tx; /* Pointer to the buffer that will be transmitted when requested */
UI_8* data_rx; /* Pointer to the physical reception buffer */
UI_16 size_tx; /* Size of the transmission requested */
UI_16 size_rx; /* Size of the last reception */
t_tp_frm_sts_tx sts_tx; /* Status of the transmission */
t_tp_frm_sts_rx sts_rx; /* Status of the phyisical reception */
BOOL unblock_after_tx; /* Flag to unblock the ISO15765_2 reception at the end of the current transmission */
BOOL iso15765_2_block_rx; /* Flag to block the reception of new frames. To be used for example in diagnostics where a */
/* request must always be answered before receiving another request */
BOOL iso15765_2_block_tx; /* Flag that blocks the transmission of diagnostics on the ISO15765_2. To be used for example */
/* when the TCU is acting as a UDS client and is doing autodiagnostics */
} t_tp_frm;
/* Structure that contains the functional reception frame information */
typedef struct {
UI_8 *data_rx; /* Pointer to the physical reception buffer */
UI_8 size; /* Size of the received functional data */
t_tp_frm_sts_rx sts_rx; /* Status of the functional reception */
} t_tp_fun_frm;
/* Structure that must be used to initialize an instance of the ISO15765_2 module. This structure must */
/* be defined in the stack in a ISO15765_2 callback routine inside the application space that must be */
/* named Iso15765_2_DynamicParametersInitCallback and will be directly called by the */
/* InicialitzaIso15765_2Task routine that must be the only one called from the initializations in main. */
typedef struct {
UI_16 max_frm_size; /* Maximum size allowed for the TP RX buffer. The protocol allows */
/* frames until 4096 bytes. The buffer must be reserved having into */
/* account the MACRO "SIZE_ALLOC_BUFFER" to avoid overflows. */
BOOL frm_size_fixed; /* Flag to configure fixed or variable length in the CAN frames TX */
/* Allowed values: */
/* TRUE -> all the TP frames are sent with 8 bytes and the non useful */
/* ones are padded with the value tx_padding_value */
/* FALSE -> all the TP frames are sent only with the length needed to */
/* send all the valid data */
BOOL rx_padding_sensitive; /* Flag to be taken into account if frm_size_fixed is defined as TRUE. */
/* Allowed values: */
/* TRUE -> RX TP frames with less than 8 bytes are ignored */
/* FALSE -> RX TP frames with less than 8 bytes are processed */
/* correctly if the frame has a correct TP format */
UI_8 tx_padding_value; /* Padding value for the non valid bytes in case that */
/* np_can_frm_size_fixed is configured to TRUE */
UI_16 cr_timer; /* Maximum timeout measured in ms between Consecutive frames before */
/* aborting the reception due to time out */
UI_16 bs_timer; /* Time in ms between the first frame and the firs flow control or */
/* between the last consecutive frame of a block and the flow control */
/* before aborting the transmission due to timeout */
UI_16 stmin_timer; /* Time in ms between consecutive frames of the transmitter to allow */
/* ourself to process the received frames without losing anyone */
/* If the block size if different from 1, this time must be minimum the */
/* cycle frequency, otherwise if this is 1 the stmin could be 0 */
UI_8 block_size; /* Number of consecutive frames that the ECU will send without waiting */
/* for a flow control before continuing. If the block size is set to 0 */
/* means that only one flow control is needed after receiving the first */
/* frame */
UI_8 max_fc_wait; /* Maximum FC wait that TP can handle in a row */
UI_8 * tx_phy_buffer; /* Pointer to the TX physical buffer. Must be declared with the size to */
/* hold the maximum trasmission length */
UI_8 * rx_phy_buffer; /* Pointer to the RX physical buffer. Must be declared with the size to */
/* hold the maximum reception length */
UI_8 * rx_fun_buffer; /* Pointer to the RX functional buffer. The size of the buffer must be 7 */
t_can_handler can_handler; //ACF must be called OsekCom_Handler
t_symbolic_name sig_np_rx_phy; /* OSEKCOM signal to get the RX physical frame */
t_symbolic_name sig_np_tx_phy; /* OSEKCOM signal to request the transmission of the TX */
/* physical frame */
t_symbolic_name sig_np_rx_fun; /* OSEKCOM signal to get the RX functional frame */
} t_tp_init;
/*--------------------------- GLOBAL VARIABLES --------------------------*/
/* Declaration of the tp_frm phisical structures. This structure is declared extern because will be the */
/* input and output structure between the application and the ISO15765_2 transport protocol */
extern t_tp_frm tp_frm[TP_NUM_INSTANCES];
/* Declaration of the tp_frm functional structures. This structure is declared extern because will be */
/* the input and output structure between the application and the ISO15765_2 transport protocol */
extern t_tp_fun_frm tp_fun_frm[TP_NUM_INSTANCES];
/*---------------------------- ROUTINE PROTOTYPES --------------------------*/
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to initialize one ISO15765_2 transport protocol instance. This
| routine should be called once in the main initializations and will call
| to the Iso15765_2_DynamicParametersInitCallback callback routine to
| configure dynamically the transport protocol instance with the parameters
| needed by the application.
| This routine should be called once for each ISO15765_2 instance defined.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler of the instance that will be initialized.
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void InicialitzaTPTask(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Task that must be executed once in each main cycle and that will trigger
| all the tasks needed to assure the transport protocol correct functionality.
| This routine should be called once for each ISO15765_2 instance defined.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPTask(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to initialize an ISO15765_2 instance with the configuration
| parameters needed by the application.
| This routine must be called from the callback routine in which the user
| must configure the dynamic parameters that must be called
| TPDynamicParametersInitCallback
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| init_data: ISO15765_2 configuration parameters to be taken by the
| given handler
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPInitData(UI_8 tp_hdl, t_tp_init * init_data);
#ifdef ENABLE_INCREMENT_EXTERNAL_TIMERS
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to increment the timers used in the RX task. This routine should be called
| in case of a known desviation of the main program cycle which the user know that
| all the timers should be incremented additionally with a certain value.
|---------------------------------------------------------------------------
| Parameters Explanation:
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPRxIncrTimers(UI_8 tp_hdl, UI_16 ticks);
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to increment the timers used in the TX task. This routine should be called
| in case of a known desviation of the main program cycle which the user know that
| all the timers should be incremented additionally with a certain value.
|---------------------------------------------------------------------------
| Parameters Explanation:
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPTxIncrTimers(UI_8 tp_hdl, UI_16 ticks);
#endif /* #ifdef ENABLE_INCREMENT_EXTERNAL_TIMERS */
#endif

View File

@ -0,0 +1,195 @@
/************ Copyright 2004-2009 FICOSA CORPORATIVE ELECTRONICS ************
| Language: | MISRA C
| Controller: | dsPIC33
| Requirements:
|-------------|------------------------------------------------------------
| Project: | 082_TCU01_F1_TCU_EMU_RSA
|------------------------------------------------------------------------------
| HISTORY OF MODIFICATIONS
| Date - Coder - Description
| 07/02/10 AC Creation of the file.
|------------------------------------------------------------------------------
| FILE DESCRIPTION:
| Configuration source file of the transport protocol (ISO15765_2) layer.
| This source file must contain the transport protocol callback routine
| TPDynamicParametersInitCallback to initialize the dynamic configuration
| parameters for each TP instance defined in TP_CFG.h.
******************************************************************************/
/* -------------------------------- Includes -------------------------------- */
#include "Global.h"
#include "ProjectCFG.h"
#include "TP.h"
#include "TP_CFG.h"
#include "FicOsekCom.h"
#include "Iso15765_3_CFG.h"
#include "Iso15765_3.h"
/* -------------------------------- Defines --------------------------------- */
/* Size of the buffer that must store the largest frame for the */
/* MPDT TX and RX instances */
/* The size of the buffer must be declared using the macro */
/* SIZE_ALLOC_BUFFER to assure that no overflows will happen during */
/* transmission or reception of frames larger than single frames */
#define TP_MPDT_TX_LEN (SIZE_ALLOC_BUFFER(30))
#define TP_MPDT_RX_LEN (SIZE_ALLOC_BUFFER(30))
/* For diagnostics TP instance I have the length of the buffers already */
/* defined in the Iso15765_3 layer */
/* ------------------------------- Data Types ------------------------------- */
/* ---------------------------- Global Variables ---------------------------- */
/* Definition of the buffer to allocate functional frames. As functional */
/* frames are not needed in any of my TP instances I declare it as a dummy */
/* buffer. The size of the functional buffer must be always of 7 bytes */
/* because this is the maximum length that could be send in a SF */
static UI_8 dummy_buf[7] = { 0,0,0,0,0,0,0 };
/* Definition of the transmission and reception TP buffers for MPDT */
static UI_8 tp_mpdt_tx_buf[TP_MPDT_TX_LEN];
static UI_8 tp_mpdt_rx_buf[TP_MPDT_RX_LEN];
/* For diagnostics TP instance I have the buffers already defined in the */
/* Iso15765_3 layer */
/* --------------------------- Routine prototypes --------------------------- */
/* -------------------------------- Routines -------------------------------- */
/*****************************************************************************
| Portability: General
|----------------------------------------------------------------------------
| Routine description:
| * It is responsability of the user to declare this routine.
| * This routine is a callback routine that will be called each time that the
| InicialitzaTPTask is executed. This InicialitzaTPTask must be called at
| the initializations in main and must be called once for each instance
| defined in the TP_CFG.h.
| * Routine to initializate dynamically the parameters of each defined
| transport protocol instance. The way to configure each transport protocol
| instance is using the structure t_tp_init which must be given as a pointer
| to TPInitData routine.
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void TPDynamicParametersInitCallback(UI_8 tp_hdl)
{
/* Declare the initialization ISO15765_2 structure as a local variable */
/* in order to not use space in the stack */
t_tp_init tp_init;
/* Switch for each instance of ISO15765_2 declared (TP_NUM_INSTANCES) */
switch(tp_hdl) {
/* Initialize the user configuration parameters of the transport protocol instance used for diagnostics */
case ISO15765_2_DIAGONCAN_HANDLER:
/* Maximum size allowed for the diagnostics RX buffer. */
/* The buffer must be reserved having into account the MACRO "SIZE_ALLOC_BUFFER" to avoid overflows */
tp_init.max_frm_size = (UI_16)TP_DIAG_RX_TX_LEN;
/* Flag to configure fixed or variable length in the CAN frames TX */
/* Diagnostics frm_size_fixed = TRUE: Defined in the renault document 36-02-031--A_Gb.pdf, page 9, chapter 6 */
tp_init.frm_size_fixed = TRUE;
/* Flag to configure if TP RX frames are sensitive to have a fixed length. TRUE indicates that we will ignore TP RX frames */
/* that have less than 8 bytes */
tp_init.rx_padding_sensitive = TRUE;
/* Special value 0x50 is requiered in the padding value for diagnostics TX (only cares if frame size is configured as fixed) */
/* Defined in the renault document CRS_TCU_NT65612_2009_80_v1.1DRAFT.pdf page 6 */
tp_init.tx_padding_value = 0x50;
/* Maximum timeout in ms between Consecutive frames before aborting the reception due to time out */
/* Diagnostics CR timer: Defined in the renault document 36-02-031--A_Gb.pdf, pages 7 and 17 */
tp_init.cr_timer = (UI_16)1000;
/* Time in ms between the first frame and the firs flow control or between the last consecutive frame of a block */
/* and the flow control before aborting the transmission due to timeout */
/* Diagnostics BS timer: Defined in the renault document 36-02-031--A_Gb.pdf, pages 7 and 17 */
tp_init.bs_timer = (UI_16)1000;
/* Time in ms between consecutive frames of the transmitter to allow ourself to process the received frames */
/* without losing anyone. If the block size if different from 1, this time must be minimum the cycle frequency, */
/* otherwise if this is 1 the stmin could be 0 */
/* For diagnostics this requirement is defined in the renault document 36-02-031--A_Gb.pdf, page 7 as 0 */
tp_init.stmin_timer = (UI_16)0;
/* Number of consecutive frames that the diagnostics TP will send without waiting for a flow control before continuing. */
/* If the block size is set to 0 means that only one flow control is needed after receiving the first */
tp_init.block_size = (UI_8)1;
/* Number of FC wait the TP can handle before rising directly an error during the transmission when a FC wait is received */
tp_init.max_fc_wait = (UI_8) 0xFF;
/* Initialize the buffer pointer where the diagnostics TX positive response physical information is set */
tp_init.tx_phy_buffer = diag_tx_buf;
/* Initialize the buffer pointer where the diagnostics RX physical request information is set */
tp_init.rx_phy_buffer = diag_rx_buf;
/* Initialize the buffer pointer where the diagnostics RX functional request information is set */
tp_init.rx_fun_buffer = dummy_buf;
/* Initialize the pointer of the diagnostics OSEKCOM routine that notifies the reception of the physical frame */
tp_init.np_get_rx_phy_notif = &ReadFlagRxSigDToolToTcu;
/* Initialize the pointer of the diagnostics OSEKCOM routine that notifies the transmission of the physical frame */
tp_init.np_get_tx_phy_notif = &ReadFlagTxSigTcuToDTool;
/* Initialize the pointer of the diagnostics OSEKCOM routine that notifies the timeout error of the TX physical frame. */
/* This OSEKCOM routine will be created when the TX notification error is requested and the timeout for this must be */
/* set to the AR/AS timeout. For diagnostics we have a timeout of 1000 ms for AR/AS configured in the CAN database. */
tp_init.np_err_tx_phy_notif = &ReadFlagTxErrorSigTcuToDTool;
/* Set the OSEKCOM diagnostics signal to get the RX physical frame */
tp_init.sig_np_rx_phy = SIG_DTOOLTOTCU;
/* Set the OSEKCOM signal to request the transmission of the diagnostics TX physical frame */
tp_init.sig_np_tx_phy = SIG_TCUTODTOOL;
/* Initialize the diagnostics RX functional notification routine to NULL because we must not receive functional frames */
tp_init.np_get_rx_fun_notif = NULL;
/* Initialize the signal of the diagnostics RX functional frame to DUMMY signal becuase we must not receive functional frames */
tp_init.sig_np_rx_fun = SIGDUMMY;
/* Call the ISO15765_2 configuration routine to initialize the diagnostics instance with the configured parameters */
TPInitData(tp_hdl, &tp_init);
break;
/* Initialize the user configuration parameters of the transport protocol instance used for MPDT */
case ISO15765_2_MPDT_HANDLER:
/* Maximum size allowed for the MDPT buffer. */
/* The buffer must be reserved having into account the MACRO "SIZE_ALLOC_BUFFER" to avoid overflows */
tp_init.max_frm_size = TP_MPDT_RX_LEN; //ACF optimitzar rps=30, tps=20 DOC: CRS
/* Flag to configure fixed or variable length in the CAN frames TX */
/* MPDT frm_size_fixed = TRUE: Defined in the renault document CRS */
tp_init.frm_size_fixed = TRUE;
/* Special value 0xFF is requiered in the padding value of MPDT, defined in the renault document CRS */
tp_init.tx_padding_value = 0xFF;
/* Maximum timeout in ms between Consecutive frames before aborting the reception due to time out */
/* MPDT CR timer: Defined in the renault document CRS, pages 7 and 17 */
tp_init.cr_timer = (UI_16)500;
/* Time in ms between the first frame and the firs flow control or between the last consecutive frame of a block */
/* and the flow control before aborting the transmission due to timeout */
/* MPDT BS timer: Defined in the renault document CRS, pages 7 and 17 */
tp_init.bs_timer = (UI_16)500;
/* Time in ms between consecutive frames of the transmitter to allow ourself to process the received frames */
/* without losing anyone. If the block size if different from 1, this time must be minimum the cycle frequency, */
/* otherwise if this is 1 the stmin could be 0 */
/* For MDPT this requirement is defined in the renault document CRS */
tp_init.stmin_timer = (UI_16)10;
/* Number of consecutive frames that the MPDT TP will send without waiting for a flow control before continuing. */
/* If the block size is set to 0 means that only one flow control is needed after receiving the first */
tp_init.block_size = (UI_8)0;
/* Initialize the buffer pointer where the MPDT TX positive response physical information is set */
tp_init.tx_phy_buffer = tp_mpdt_tx_buf;
/* Initialize the buffer pointer where the MPDT RX physical request information is set */
tp_init.rx_phy_buffer = tp_mpdt_rx_buf;
/* Initialize the buffer pointer where the MPDT RX functional request information is set */
tp_init.rx_fun_buffer = dummy_buf;
/* Initialize the pointer of the MPDT OSEKCOM routine that notifies the reception of the physical frame */
tp_init.np_get_rx_phy_notif = &ReadFlagRxSigTcuRxMpdt;
/* Initialize the pointer of the MPDT OSEKCOM routine that notifies the transmission of the physical frame */
tp_init.np_get_tx_phy_notif = &ReadFlagTxSigTcuTxMpdt;
/* Initialize the pointer of the MPDT OSEKCOM routine that notifies the timeout error of the TX physical frame */
/* This OSEKCOM routine will be created when the TX notification error is requested and the timeout for this must be */
/* set to the AR/AS timeout. For MPDT we have a timeout of 50 ms for AR/AS configured in the CAN database. */
tp_init.np_err_tx_phy_notif = &ReadFlagTxErrorSigTcuTxMpdt;
/* Set the MPDT OSEKCOM signal to get the RX physical frame */
tp_init.sig_np_rx_phy = SIG_TCURXMPDT;
/* Set the OSEKCOM signal to request the MPDT transmission of the TX physical frame */
tp_init.sig_np_tx_phy = SIG_TCUTXMPDT;
/* Initialize the MPDT RX functional notification routine to NULL because we must not receive functional frames */
tp_init.np_get_rx_fun_notif = NULL;
/* Initialize the signal of the MPDT RX functional frame to DUMMY signal becuase we must not receive functional frames */
tp_init.sig_np_rx_fun = SIGDUMMY;
/* Call the ISO15765_2 configuration routine to initialize the MPDT instance with the configured parameters */
TPInitData(tp_hdl, &tp_init);
break;
default:
break;
}
}

View File

@ -0,0 +1,73 @@
/************ Copyright 2004-2009 FICOSA CORPORATIVE ELECTRONICS ************
| Language: | MISRA C
| Controller: | dsPIC33
| Requirements:
|-------------|------------------------------------------------------------
| Project: | 082_TCU01_F1_TCU_EMU_RSA
|------------------------------------------------------------------------------
| HISTORY OF MODIFICATIONS
| Date - Coder - Description
| 07/02/10 AC Creation of the file.
|------------------------------------------------------------------------------
| FILE DESCRIPTION:
| Configuration header file of the transport protocol (ISO15765_2) layer.
| This header must define if the transport protocol used is FULL or LITE which
| implies if frames till 4096 bytes can be send or only single frames till 7
| bytes can be send.
| This header must configure the number of transport protocol instances that
| the application need.
| This header must also contain the declaration of the callback routine to
| initialize the transport protocol dynamic configuration parameters which must
| be called TPDynamicParametersInitCallback
******************************************************************************/
#ifndef __TP_CFG_H
#define __TP_CFG_H
/*---------------------------- includes ----------------------------------*/
#include "ProjectCFG.h"
/*----------------------------- defines ----------------------------------*/
/* Select the mode of ISO15765_2 used. This will apply for all the */
/* transport protocol instances defined */
/* TP_MODE_LITE -> Only single frames can be sent and received */
/* TP_MODE_FULL -> Frames till 4096 bytes can be sent and received */
#define TP_MODE_FULL
/* Number of Transport Protocol instances that will be defined. One */
/* instance must be defined for example for each of the following upper */
/* layters: */
/* - Diagnostics client */
/* - Diagnostics server */
/* - MPDT */
#define TP_NUM_INSTANCES ((UI_8)2)
#define ISO15765_2_REPROGONCAN_HANDLER ((UI_8)0)
/* Ticks between task periodic calls */
#define TP_TASK_TICKS ((t_timer_time)1)
/* Minimum length of a flow control frame to be accepted */
#define CAN_FRM_FC_SIZE ((UI_8)8)
/*------------------------- prototips de funcions ------------------------*/
/*****************************************************************************
| Portability: General
|----------------------------------------------------------------------------
| Routine description:
| * It is responsability of the user to declare this routine.
| * This routine is a callback routine that will be called each time that the
| InicialitzaTPTask is executed. This InicialitzaTPTask must be called at
| the initializations in main and must be called once for each instance
| defined in the TP_CFG.h.
| * Routine to initializate dynamically the parameters of each defined
| transport protocol instance. The way to configure each transport protocol
| instance is using the structure t_tp_init which must be given as a pointer
| to TPInitData routine.
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void TPDynamicParametersInitCallback(UI_8 tp_hdl);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,648 @@
/*************** COPYRIGHT (c) 2002-2007 FICOSA INTERNATIONAL **************
| Language: | MISRA C
| Controller: | Generic
| Spec. Document: | ISO15765-2-E.pdf
|-----------------|------------------------------------------------------------
| Project: | ISO15765-2
| Reference: |
|------------------------------------------------------------------------------
| Date - Cod. - Rev. - App. - Description
| 12/09/02 AM Implementation of the kwp2000 for PSA.
| 19/08/04 DT Split ISO15765_2 protocol from the KWP2000
| because they are different modules.
| 24/04/09 DC Modification to guarantee the requirements SR1431,
| SR1438, SR1681.
| 15/07/09 AC Corrected bug in ReadCF because it didn't count
| correctly the blocks
| 15/12/10 AC Converted ISO15765_2 protocol to multi-instance.
| 13/11/11 AC Converted ISO15765_2 to full-duplex
| 09/01/11 AC Changed file, routines and variable naming to
| make it a standard component and to have a
| similar naming style with MPDT.
| 07/05/15 FPR Removed TIMER_MS_TO_TICKS_R_UP macro. Now new macro
| TIMER_MS_TO_TIME_RESTRICTIVE is used instead.
| New macro implemented in HAL DSPIC (Timer.h).
|------------------------------------------------------------------------------
| DESCRIPTION:
| User interface for the transport protocol ISO15765_2 on CAN.
| ISO15765_2 protocol is a transport protocol that permits the sending and
| reception of frames until 4096 bytes on a network protocol with frames of
| lower size. The original frame is segemented and sent with flow control
| data that allows to the reception node to mount again the original frame.
| GENERAL CONSIDERATIONS
| - This implementation allows full duplex communications.
| - This implementation allows for each instance a communication channel
| with physical address in which both transmission and receptions could
| be done and a funcional address for only receptions.
| - The functional address channel only supports frames with less than
| 8 bytes of data.
| - This header must only be included in the ISO15765_2 transport protocol
| source files but is forbidden to be included by the application as it
| contains the private data of the ISO15765_2 module.
******************************************************************************/
#ifndef _TP_FUNCTIONS_H
#define _TP_FUNCTIONS_H
/*----------------------------- INCLUDES ---------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP.h"
/*----------------------------- MACROS ---------------------------------*/
/*----------------------------- DEFINES ----------------------------------*/
/* Maximum data bytes that a CAN frame can allocate */
#define NP_SF_MAX_SIZE ((UI_8)7)
/* Maximum useful data size that a Single Frame can allocate in bytes */
#define CAN_FRM_MAX_SIZE ((UI_8)8)
/* Maximum useful data size that a Consecutive Frame can allocate in bytes */
#define CF_DATA_LEN ((UI_8)7)
/*-------------------------- DATA TYEPS ----------------------------------*/
/* Interface between FICOSEKCOM and TP for physical frames */
typedef struct {
t_can_handler can_handler; //ACF must be called OsekCom_Handler
t_symbolic_name sig_np_rx; /* OSEKCOM signal to receive the physical frame */
t_symbolic_name sig_np_tx; /* OSEKCOM signal to request the sending of the phisical frame */
} t_tp_can_phy_interface;
/* Interface between FICOSEKCOM and TP for functional frames */
typedef struct {
t_symbolic_name sig_np_rx; /* OSEKCOM signal to receive the functional frame */
} t_tp_can_fun_interface;
/* States of the TX PHYSICAL FRAME FSM */
typedef enum {
ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_WAITINGTXCONFIRMATION = 1,
ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_READYTOSEND = 2,
ESTAT_0_TP_NETWORKLAYERLOWERINTERFACE_TX = 0
} t_estat_tp_networklayerlowerinterface_tx;
/* If the ISO15765_2 is defined in full mode, define all the structures */
/* that allow transport protocol communications with more than 7 data */
/* bytes (one single frame) */
#ifdef TP_MODE_FULL
/* States of the RX FULL PHYSICAL FSM */
typedef enum {
ESTAT_TP_RX_FULL_INICIO = 1,
ESTAT_TP_RX_FULL_RXCF = 2,
ESTAT_TP_RX_FULL_CONFIRMAFC = 3,
ESTAT_0_TP_RX_FULL = 0
} t_estat_tp_rx_full;
/* States of the TX FULL PHYSICAL FSM */
typedef enum {
ESTAT_TP_TX_FULL_INICI = 1,
ESTAT_TP_TX_FULL_ESPERAFC = 2,
ESTAT_TP_TX_FULL_CONFIRMATX = 3,
ESTAT_0_TP_TX_FULL = 0
} t_estat_tp_tx_full;
/* Configuration parameters of the TP FULL */
typedef struct {
UI_16 np_max_frm_size; /* Maximum size allowed for the diagnostics buffer. The protocol allows */
/* frames until 4096 bytes. The buffer must be reserved having into */
/* account the MACRO "SIZE_ALLOC_BUFFER" to avoid overflows. */
BOOL np_can_frm_size_fixed; /* Flag to configure fixed or variable length in the CAN frames */
/* Allowed values: */
/* TRUE -> Totes les trames Tx s'envien amb 8 bytes amb els bytes no */
/* utils a valor de padding configurat amb el parametre */
/* np_tx_padding_value. Les trames Rx de menys de 8 bytes son */
/* ignorades */
/* FALSE -> Totes les trames s'envien i es reben amb la mida en funcio */
/* dels bytes utils que contenen */
BOOL np_rx_padding_sensitive;/* Flag to be taken into account if frm_size_fixed is defined as TRUE. */
/* Allowed values: */
/* TRUE -> RX TP frames with less than 8 bytes are ignored */
/* FALSE -> RX TP frames with less than 8 bytes are processed */
/* correctly if the frame has a correct TP format */
UI_8 np_tx_padding_value; /* Padding value for the non valid bytes in case that */
/* np_can_frm_size_fixed is configured to TRUE */
UI_16 n_cr_max; /* Maximum timeout measured in ms between Consecutive frames before */
/* aborting the reception due to time out */
UI_16 n_bs_max; /* Time in ms between the first frame and the firs flow control or */
/* between the last consecutive frame of a block and the flow control */
/* before aborting the transmission due to timeout */
UI_16 stmin; /* Time in ms between consecutive frames of the transmitter to allow */
/* ourself to process the received frames without losing anyone */
/* If the block size if different from 1, this time must be minimum the */
/* cycle frequency, otherwise if this is 1 the stmin could be 0 */
UI_8 block_size; /* Number of consecutive frames that the ECU will send without waiting */
/* for a flow control before continuing. If the block size is set to 0 */
/* means that only one flow control is needed after receiving the first */
/* frame */
UI_8 n_wftmax; /* Maximum number of FC wait that TP can handle in a row */
} t_tp_cfg_full;
/* Parameters to manage the Flow Controls in multiple frames */
typedef struct {
t_tp_flow_sts flow_status; /* Flow control type */
UI_8 rx_bs; /* Block size received from the other part that we must guarantee in a TX */
UI_8 stmin; /* Stmin received from the other part that we must garantee between CF */
BOOL first_fc; /* Flag that indicates if this is the first FC after a FF */
BOOL fc_rx; /* Flag that notifies of the reception of a flow control */
UI_8 block_size_cnt; /* Counter of the consecutive frames sent before waiting a FC */
UI_8 num_fc_wait; /* Counter of the FC wait received */
} t_tp_fc_data;
/* Parameters to manage the TP FULL reception */
typedef struct {
UI_8 next_segm_num_rx; /* Counter to manage the number of receive consecutive segments. */
UI_16 byte_actual_rx; /* Counter to manage the number of received bytes. */
UI_16 num_frames_before_fc; /* Number of consecutive frames received since last FC sent, in order to be */
/* aware when another FC must be sent */
t_tp_rx_frm frame_rx_type; /* Type of the last received CAN frame */
UI_8 frame_rx_data[8]; /* Last RX frame received */
UI_8 frame_rx_len; /* Last RX length */
t_tp_fc_frm frame_fc_type; /* Type of the last received FC frame */
UI_8 frame_rx_fc_data[8]; /* Last FC frame received */
UI_8 frame_rx_fc_len; /* Last FC length */
} t_tp_rx_status_full;
/* Parameters to manage the TP FULL transmission */
typedef struct {
BOOL ack_tx; /* Flag that notifies if the CAN layer has notified the TX of the last frame */
UI_8 next_segm_num_tx; /* Counter to manage the number of sent consecutive segments. */
UI_16 byte_actual_tx; /* Counter to manage the number of transmitted bytes. */
t_tp_tx_sts frame_tx_sts; /* Flag that notifies the status of a TX data frame */
UI_8 frame_tx_data[8]; /* TX frame data required */
UI_8 frame_tx_len; /* TX length required */
t_tp_tx_sts frame_tx_fc_sts;/* Flag that notifies the status of a FC data frame */
UI_8 frame_tx_fc_data[8]; /* FC frame data required */
UI_8 frame_tx_fc_len; /* FC length required */
} t_tp_tx_status_full;
/* Timers to control the TP FULL timeouts */
typedef struct {
t_clock n_cr; /* Timer variable that controls the TP CR timeout */
t_clock n_ar; /* Timer variable that controls the TP AR timeout */
t_clock n_bs; /* Timer variable that controls the TP BS timeout */
t_clock n_cs; /* Timer variable that controls the TP CS timeout */
t_clock n_as; /* Timer variable that controls the TP AS timeout */
} t_tp_timers_full;
/* Structure that contains all the data needed for an TP FULL instance */
typedef struct {
t_estat_tp_tx_full state_tx; /* State of the TP TX PHYSICAL FSM */
t_estat_tp_rx_full state_rx; /* State of the TP RX PHYSICAL FSM */
t_estat_tp_networklayerlowerinterface_tx state_can_phy_tx; /* State of the TP Network layer lower inteface FSM */
t_tp_can_phy_interface can_phy; /* Interface with the network protocoal physical CAN structure */
t_tp_can_fun_interface can_fun; /* Interface with the network protocoal functional CAN structure */
t_tp_cfg_full cfg; /* Configuration of the TP */
t_tp_fc_data fc_data; /* Estructura de dades de gestio del control de fluxe */
t_tp_rx_status_full rx_st; /* Status of the TP transmission/reception */
t_tp_tx_status_full tx_st; /* Status of the TP transmission/reception */
t_tp_timers_full timers; /* Timers to control and assure the expected TP managment */
} t_tp_data;
/* If the ISO15765_2 is defined in lite mode, define all the structures */
/* simplified that allow transport protocol communications equal or */
/* less than 7 data bytes (only single frames) */
#else
/* States of the TX LITE PHYSICAL FSM */
typedef enum {
ESTAT_TP_TX_LITE_INIT = 1,
ESTAT_TP_TX_LITE_CONFIRMTX = 2,
ESTAT_0_TP_TX_LITE = 0
} t_estat_tp_tx_lite;
/* Configuration parameters of the TP LITE */
typedef struct {
BOOL np_can_frm_size_fixed; /* Flag to configure fixed or variable length in the CAN frames */
/* Allowed values: */
/* TRUE -> Totes les trames Tx s'envien amb 8 bytes amb els bytes no */
/* utils a valor de padding configurat amb el parametre */
/* np_tx_padding_value. Les trames Rx de menys de 8 bytes son */
/* ignorades */
/* FALSE -> Totes les trames s'envien i es reben amb la mida en funcio */
/* dels bytes utils que contenen */
BOOL np_rx_padding_sensitive;/* Flag to be taken into account if frm_size_fixed is defined as TRUE. */
/* Allowed values: */
/* TRUE -> RX TP frames with less than 8 bytes are ignored */
/* FALSE -> RX TP frames with less than 8 bytes are processed */
/* correctly if the frame has a correct TP format */
UI_8 np_tx_padding_value; /* Padding value for the non valid bytes in case that */
/* np_can_frm_size_fixed is configured to TRUE */
} t_tp_cfg_lite;
/* Parameters to manage the TP LITE reception */
typedef struct {
t_tp_rx_frm frame_rx_type; /* Type of the last received CAN frame */
UI_8 frame_rx_data[8]; /* Last RX frame received */
UI_8 frame_rx_len; /* Last RX length */
} t_tp_rx_status_lite;
/* Parameters to manage the TP LITE transmission */
typedef struct {
BOOL ack_tx; /* Flag that notifies if the CAN layer has notified the TX of the last frame */
t_tp_tx_sts frame_tx_sts; /* Flag that notifies the status of a TX data frame */
UI_8 frame_tx_data[8]; /* TX frame data required */
UI_8 frame_tx_len; /* TX length required */
} t_tp_tx_status_lite;
/* Timers to control the TP LITE timeouts */
typedef struct {
t_clock n_as; /* Timer variable that controls the TP AS timeout */
} t_tp_timers_lite;
/* Structure that contains all the data needed for an TP LITE instance */
typedef struct {
t_estat_tp_tx_lite state_tx; /* State of the TP TX PHYSICAL FSM */
t_estat_tp_networklayerlowerinterface_tx state_can_phy_tx;
t_tp_can_phy_interface can_phy; /* Interface with the network protocoal physical CAN structure */
t_tp_can_fun_interface can_fun; /* Interface with the network protocoal functional CAN structure */
t_tp_cfg_lite cfg; /* Configuration of the TP */
t_tp_rx_status_lite rx_st; /* Status of the TP reception */
t_tp_tx_status_lite tx_st; /* Status of the TP transmission */
t_tp_timers_lite timers; /* Timers to control and assure the expected TP managment */
} t_tp_data;
#endif
/*--------------------------- GLOBAL VARIABLES ---------------------------*/
/* Declaration of the tp_frm phisical and functional defined structures */
extern t_tp_data tp_data[TP_NUM_INSTANCES];
/*--------------------------- ROUTINE PROTOTYPES ------------------------*/
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to process the last received physical CAN frame. This routine
| will get the data bytes, the length and the type of transport protocol
| frame using the CAN interfaces.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPProcessRxCanPhyFrame(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine that checks if any of the possible pending transport protocol
| transmission frames are pending to be transmitted.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| result: boolean that indicates if transmission is pending
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPCheckTxCanFrame(UI_8 tp_hdl, t_tp_tx_type *tp_tx_type);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine that triggers the sending of a transport protocol frame (SF, FF, CF
| or flow control). The priority of the transmission frames will be given by
| the order of checking each of the flags in the IF condition.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPProcessTxCanFrame(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine that checks if Osekcom notified the transmission of the TX last
| frame
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| result: TRUE if transmission has been confirmed, FALSE otherwise
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPCheckCanFrameConfirmation(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine that checks if for a given transmission frame (which could be
| a "Flow Control", a "First Frame, a "Consecutive Frame" or a "Single Frame")
| his transmission has been confirmed.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| tx_sts: current transmission status of the requested frame
| result: TRUE if transmission has been confirmed, FALSE otherwise
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPCheckTxConfirmed(UI_8 tp_hdl, t_tp_tx_sts tx_sts);
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to notify a new transmission frame status for a transmission
| which still has his status as ongoing
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| tx_sts: new status to be set instead of ongoing
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPNotifyCanFrmTx(UI_8 tp_hdl, t_tp_tx_sts tx_sts);
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine that checks if there are still more frames pending to be sent.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| result: TRUE if there are not more pending frames to be sent.
| FALSE if there are still more pending frames to be sent
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPTestEndFrame(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to request the sending of a single frame. Remember that a SF is
| used only to sent network frames with equal ore less than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPSendSF(UI_8 tp_hdl);
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to request the sending of a first frame. Remember that a first
| frame is used to send the initial network frame with more than 8 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPSendFF(UI_8 tp_hdl);
#endif
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to request the sending of a consecutive frame. Remember that CF
| are used after sending a FF when the network frame has more than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPSendCF(UI_8 tp_hdl);
#endif
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to read a CAN frame of the type "Single Frame" with physical
| address. Remember that a SF is a frame with equal or less than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPReadSF(UI_8 tp_hdl);
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to read a CAN frame of the type "First Frame" and request directly
| the sending of a Flow Control as always after receiving a FF a FC must
| be sent by protocol. Remember that a FF is a frame with more than 7
| bytes. Remember that a FC is used to control the flow of the reception
| of a frame with more than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPReadFFSendFC(UI_8 tp_hdl);
#endif
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to request the sending of a flow control. Remember that a FC is
| used to control the flow of the reception of a frame with more than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| flow_control_type: type of the flow control that must be sent
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPSendFC(UI_8 tp_hdl, t_tp_flow_sts flow_control_type);
#endif
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to read a CAN frame of the type "Consecutive Frame". Remember
| that consecutive frames are received after receiving the first frame
| with network frames with more than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPReadCF(UI_8 tp_hdl);
#endif
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to read a CAN frame of the type "Consecutive Frame". Remember
| that consecutive frames are received after receiving the first frame
| with network frames with more than 7 bytes. This routine in case that
| the received frame is consistent and has the correct format will request
| the sending of a flow control.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPReadCFSendFC(UI_8 tp_hdl);
#endif
#ifdef TP_MODE_FULL
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to read a CAN frame of the type "Flow Control" and request
| the sending of a "Consecutive Frame". Remember that "Flow Control" frames
| are used to control the flow of the transmission in case of network
| frames with more than 7 bytes.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
/---------------------------------------------------------------------------*/
void TPReadFCSendCF(UI_8 tp_hdl);
#endif
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to read a functional CAN frame. Remember that in functional
| channel any frame with a type different from SF will be ignored as the
| maximum allowed size for this channel is 7.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void TPReadFunFrm(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to check if the timeout of the transmission frame has been notfied.
| Remember that this timeout must be configured in the OSEKCOM database with
| the specified AX timeout defined.
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| return: TRUE if timeout has been confirmed, FALSE otherwise
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPCheckAxTimeout(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to check that all the physical interface routines with OSEKCOM layer
| are correctly initialized
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| return: TRUE if configuration is correct, FALSE otherwise
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPCheckPhyCfgData(UI_8 tp_hdl);
/*****************************************************************************
| Portability: Generica
|----------------------------------------------------------------------------
| Functionalities Contract Description:
| Routine to check that all the functional interface routines with OSEKCOM layer
| are correctly initialized
|---------------------------------------------------------------------------
| Parameters Explanation:
| tp_hdl: ISO15765_2 handler to be used
| return: TRUE if configuration is correct, FALSE otherwise
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? CPU cycles | O(n): CTE
| Tmax Int En : ? CPU cycles | O(n): CTE
| Tmax Total : ? CPU cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL TPCheckFunCfgData(UI_8 tp_hdl);
#endif

View File

@ -0,0 +1,108 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_NetworkLayerLowerInterface_Rx.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | Iso15765_2_Full
| System: | Iso15765_2_Task_Full
| Diagram: | TP_NetworkLayerLowerInterface_Rx
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 14/11/2011
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 1
| Numero de transicions: 0
| Estats inicials: 0
|
| Variables d'entrada:
| Variables de sortida:
| Variables d'entrada/sortida:
| Variables locals:
|
| ++++ Descripcio del proces implementat ++++
|
| Task responsible of notifying the CAN Frame Rx type
to upper layers.
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task.h"
#include "TP_Functions.h"
/*------------------------------ user code --------------------------------*/
/*-------------------------------- macros ---------------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------------ funcions ---------------------------------*/
void TP_NetworkLayerLowerInterface_RxInicialitza(UI_8 tp_hdl)
{
/* -- no hi ha inicialitzacio a les funcions simples -- */
}
/****************************************************************************
| Nom de la funcio: TP_NetworkLayerLowerInterface_Rx
|----------------------------------------------------------------------------
| Funcionalitat:
| Diagrama d'un sol estat d'un model Edi.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| Sortides:
****************************************************************************/
void TP_NetworkLayerLowerInterface_Rx(UI_8 tp_hdl)
{
t_flag_value received_frame = 0;
/* Check that the RX notif routine has been configured */
if (TPCheckPhyCfgData(tp_hdl) == TRUE) {
/* Get the RX flag from OsekCom */
received_frame = ReadFlagRxSig(tp_data[tp_hdl].can_phy.sig_np_rx);
if(received_frame == 0)
{
}
else
{
}
/* Case a new frame has been received */
if (received_frame == COM_TRUE) {
TPProcessRxCanPhyFrame(tp_hdl);
}
else {
/* Do nothing */
}
}
else {
/* Do nothing */
}
} /* TP_NetworkLayerLowerInterface_Rx */
/********************************** FI **************************************/

View File

@ -0,0 +1,258 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_NetworkLayerLowerInterface_Tx.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | Iso15765_2_Full
| System: | Iso15765_2_Task_Full
| Diagram: | TP_NetworkLayerLowerInterface_Tx
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 14/11/2011
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 2
| Numero de transicions: 4
| Estats inicials: 1
|
| Variables d'entrada:
| Variables de sortida:
| Variables d'entrada/sortida:
| Variables locals:
|
| ++++ Descripcio del proces implementat ++++
|
| Task responsible of assuring TTmin time between 2 Tx Can
frames.
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task.h"
#include "TP_Functions.h"
/*------------------------------ user code --------------------------------*/
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------- capcaleres de funcions ------------------------*/
static void TP_NetworkLayerLowerInterface_Tx0(UI_8 tp_hdl);
static void WaitingTxConfirmation(UI_8 tp_hdl);
static void ReadyToSend(UI_8 tp_hdl);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats TP_NetworkLayerLowerInterface_Tx
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
| estat_tp_networklayerlowerinterface_tx
|
****************************************************************************/
void TP_NetworkLayerLowerInterface_TxInicialitza(UI_8 tp_hdl)
{
/* Inicialitzacio de la variable d estat */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_0_TP_NETWORKLAYERLOWERINTERFACE_TX;
/* Execucio del cicle inicial de la maquina d estats */
TP_NetworkLayerLowerInterface_Tx(tp_hdl);
}
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats TP_NetworkLayerLowerInterface_Tx.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_tp_networklayerlowerinterface_tx
|
| Sortides:
| estat_tp_networklayerlowerinterface_tx
|
****************************************************************************/
void TP_NetworkLayerLowerInterface_Tx(UI_8 tp_hdl)
{
//<<Always enter here>>
/* Estudi per casos del estat actual */
switch (tp_data[tp_hdl].state_can_phy_tx){
case ESTAT_0_TP_NETWORKLAYERLOWERINTERFACE_TX:
TP_NetworkLayerLowerInterface_Tx0(tp_hdl);
//<<AutoOnceTime-->tp_data[tp_hdl].state_can_phy_tx TO 002 REDAYTOSEND>>
break;
case ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_WAITINGTXCONFIRMATION:
WaitingTxConfirmation(tp_hdl);
break;
case ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_READYTOSEND:
ReadyToSend(tp_hdl);
//<<AlwaysHere02READAYTOSEND>>
break;
default:
tp_data[tp_hdl].state_can_phy_tx = ESTAT_0_TP_NETWORKLAYERLOWERINTERFACE_TX;
break;
}
}
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces TP_NetworkLayerLowerInterface_Tx
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void TP_NetworkLayerLowerInterface_Tx0(UI_8 tp_hdl)
{
if (TPCheckPhyCfgData(tp_hdl) == TRUE) {
/* Avaluem condicio de start del estat ReadyToSend */
/* Canviem l estat inicial */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_READYTOSEND;
}
else {
/* No s ha activat cap condicio inicial: ens quedem a l estat actual */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_0_TP_NETWORKLAYERLOWERINTERFACE_TX;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat WaitingTxConfirmation.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_tp_networklayerlowerinterface_tx
|
| Sortides:
| estat_tp_networklayerlowerinterface_tx
|
****************************************************************************/
static void WaitingTxConfirmation(UI_8 tp_hdl)
{
/* -- codi de l estat actual -- */
BOOL tx_confirmation, ax_timeout;
BOOL tx_requested = FALSE;
t_tp_tx_type tp_tx_type;
// uint8 index_1;
/* Check if CAN transmission has been confirmed */
tx_confirmation = TPCheckCanFrameConfirmation(tp_hdl);
/* Check if the TX timeout error has been confirmed */
ax_timeout = TPCheckAxTimeout(tp_hdl);
//<<ManyTimesHere>>//
/* Case in which transmission is confirmed */
if(tx_confirmation == TRUE) {
//<<NeverHere>>/
/* Notify the TX confirmation */
TPNotifyCanFrmTx(tp_hdl, TP_TX_CONFIRMED);
/* Check if another TX is pending */
tx_requested = TPCheckTxCanFrame(tp_hdl, &tp_tx_type);
}
else {
/* Do nothing */
}
if ((tx_confirmation == TRUE) && (tx_requested == FALSE)) {
/* Cas en que executem la transicio */
/* -- canviem l estat -- */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_READYTOSEND;
}
else if ((ax_timeout == TRUE) && (tx_confirmation == FALSE)) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
TPNotifyCanFrmTx(tp_hdl, TP_TX_ERROR);
/* -- canviem l estat -- */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_READYTOSEND;
}
else if ((tx_confirmation == TRUE) && (tx_requested == TRUE)) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
TPProcessTxCanFrame(tp_hdl);
/* -- canviem l estat -- */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_WAITINGTXCONFIRMATION;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_WAITINGTXCONFIRMATION;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat ReadyToSend.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_tp_networklayerlowerinterface_tx
|
| Sortides:
| estat_tp_networklayerlowerinterface_tx
|
****************************************************************************/
static void ReadyToSend(UI_8 tp_hdl)
{
/* -- codi de l estat actual -- */
BOOL tx_requested;
t_tp_tx_type tp_tx_type;
// uint8 index_2;
tx_requested = TPCheckTxCanFrame(tp_hdl, &tp_tx_type);
if (tx_requested == TRUE) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
TPProcessTxCanFrame(tp_hdl);
/* -- canviem l estat -- */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_WAITINGTXCONFIRMATION;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_can_phy_tx = ESTAT_TP_NETWORKLAYERLOWERINTERFACE_TX_READYTOSEND;
}
}
/********************************** FI **************************************/

View File

@ -0,0 +1,53 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | Iso15765_2_Rx.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | Iso15765_2
| System: | Iso15765_2_Task
| Diagram: | Iso15765_2_Rx
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 18/5/2009
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 1
| Numero de transicions: 3
| Estats inicials: 1
|
| Variables d'entrada:
| NP_CAN_RX_NOTIF (BOOL)
| NP_CAN_RX_SIZE (UI_8)
| NP_CAN_RX_DATA (UI_8)
| Variables de sortida:
| tp_frm (t_tp_frm)
| Variables d'entrada/sortida:
| Variables locals:
| timer_n_cr (t_clock)
|
| ++++ Descripcio del proces implementat ++++
|
| Maquina 0x1
ISO 15765: CAN -> KWP
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#ifdef TP_MODE_FULL
//#include "TP_Rx_Full.c"
#else
#include "TP_Rx_Lite.c"
#endif
/********************************** FI **************************************/

View File

@ -0,0 +1,95 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_RxFun.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | TP_Full
| System: | TP_Task_Full
| Diagram: | TP_RxFun
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 28/2/2011
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 1
| Numero de transicions: 0
| Estats inicials: 0
|
| Variables d'entrada:
| Variables de sortida:
| Variables d'entrada/sortida:
| Variables locals:
|
| ++++ Descripcio del proces implementat ++++
|
|
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task.h"
/*------------------------------ user code --------------------------------*/
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#include "TP_Functions.h"
/*-------------------------------- macros ---------------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------------ funcions ---------------------------------*/
void TP_RxFunInicialitza(UI_8 tp_hdl)
{
/* -- no hi ha inicialitzacio a les funcions simples -- */
}
/****************************************************************************
| Nom de la funcio: TP_RxFun
|----------------------------------------------------------------------------
| Funcionalitat:
| Diagrama d'un sol estat d'un model Edi.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| Sortides:
****************************************************************************/
void TP_RxFun(UI_8 tp_hdl)
{
t_flag_value received_frame;
/* Check that the functional RX notif routine has been configured */
if(TPCheckFunCfgData(tp_hdl) == TRUE) {
/* Get the RX flag from OsekCom */
received_frame = ReadFlagRxSig(tp_data[tp_hdl].can_fun.sig_np_rx);
if (received_frame == COM_TRUE) {
TPReadFunFrm(tp_hdl);
}
else {
/* Do nothing */
}
}
else {
/* Do nothing */
}
} /* TP_RxFun */
/********************************** FI **************************************/

View File

@ -0,0 +1,432 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_Rx.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | TP_FULL
| System: | TP_Task
| Diagram: | TP_Rx
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 18/10/2010
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 3
| Numero de transicions: 14
| Estats inicials: 1
|
| Variables d'entrada:
| NP_CAN_RX_NOTIF (BOOL)
| NP_CAN_RX_SIZE (UI_8)
| NP_CAN_RX_DATA (UI_8)
| Variables de sortida:
| tp_frm (t_tp_frm)
| Variables d'entrada/sortida:
| Variables locals:
| timer_n_cr (t_clock)
| num_frames_before_fc (UI_16)
| timer_n_ar (t_clock)
|
| ++++ Descripcio del proces implementat ++++
|
| Maquina 0x1
ISO 15765: CAN -> KWP
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task.h"
/*------------------------------ user code --------------------------------*/
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#include "TP_Functions.h"
#include "DiagnosticL/Comp_ISO_15765_2/TP.h"
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------- capcaleres de funcions ------------------------*/
static void TP_Rx_Full0(UI_8 tp_hdl);
static void Inicio(UI_8 tp_hdl);
static void RxCF(UI_8 tp_hdl);
static void ConfirmaFC(UI_8 tp_hdl);
//<<
//void TP_Rx_FullInicialitza(UI_8 iso2_hdl);
//void TP_Rx_Full(UI_8 iso2_hdl);
//>>
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats TP_Rx
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
|
| tp_frm
****************************************************************************/
#if 1
void TP_Rx_FullInicialitza(UI_8 tp_hdl)
{
/* Inicialitzacio de la variable d estat */
tp_data[tp_hdl].state_rx = ESTAT_0_TP_RX_FULL;
/* Execucio del cicle inicial de la maquina d estats */
TP_Rx_Full(tp_hdl);
}
#endif
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats TP_Rx.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| NP_CAN_RX_NOTIF
| NP_CAN_RX_SIZE
| NP_CAN_RX_DATA
| Sortides:
|
| tp_frm
****************************************************************************/
#if 1
void TP_Rx_Full(UI_8 tp_hdl)
{
/* Estudi per casos del estat actual */
switch (tp_data[tp_hdl].state_rx){
case ESTAT_0_TP_RX_FULL:
TP_Rx_Full0(tp_hdl);
break;
case ESTAT_TP_RX_FULL_INICIO:
Inicio(tp_hdl);
break;
case ESTAT_TP_RX_FULL_RXCF:
RxCF(tp_hdl);
break;
case ESTAT_TP_RX_FULL_CONFIRMAFC:
ConfirmaFC(tp_hdl);
break;
default:
tp_data[tp_hdl].state_rx = ESTAT_0_TP_RX_FULL;
break;
}
/* Increment del temps de cicle als timers */
if (tp_data[tp_hdl].timers.n_cr < MAX_COMPTADOR_TEMPS) {
tp_data[tp_hdl].timers.n_cr += TP_TASK_TICKS;
}
}
#endif
#ifdef ENABLE_INCREMENT_EXTERNAL_TIMERS
void TPRxIncrTimers(UI_8 tp_hdl, UI_16 ticks)
{
if (tp_data[tp_hdl].timers.n_cr < MAX_COMPTADOR_TEMPS) {
tp_data[tp_hdl].timers.n_cr += ticks;
}
}
#endif
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces TP_Rx
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void TP_Rx_Full0(UI_8 tp_hdl)
{
/* -- reset dels timers t_clock -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
if (TPCheckPhyCfgData(tp_hdl) == TRUE) {
/* Canviem l estat inicial */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else {
/* No s ha activat cap condicio inicial: ens quedem a l estat actual */
tp_data[tp_hdl].state_rx = ESTAT_0_TP_RX_FULL;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Inicio.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| NP_CAN_RX_NOTIF
| NP_CAN_RX_SIZE
| NP_CAN_RX_DATA
| Sortides:
|
| tp_frm
****************************************************************************/
static void Inicio(UI_8 tp_hdl)
{
if ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_SF) &&
((tp_frm[tp_hdl].sts_rx == TP_FRM_RX_IDLE) || (tp_frm[tp_hdl].sts_rx == TP_FRM_RX_ERR_NOTIF))) {
/* Cas en que executem la transicio RxSF */
/* -- action de la transicio -- */
if(tp_frm[tp_hdl].iso15765_2_block_rx == FALSE ) {
TPReadSF(tp_hdl);
}
else {
/* Reset the frame reception type */
tp_data[tp_hdl].rx_st.frame_rx_type = TP_RX_NO_FRM;
}
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_FF) && (tp_frm[tp_hdl].iso15765_2_block_rx == TRUE)) {
/* Cas en que executem la transicio RxFFTxFCBlocked */
/* -- action de la transicio -- */
/* Reset the frame reception type */
tp_data[tp_hdl].rx_st.frame_rx_type = TP_RX_NO_FRM;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_FF) && (tp_frm[tp_hdl].iso15765_2_block_rx == FALSE) && ((tp_frm[tp_hdl].sts_rx == TP_FRM_RX_IDLE) || (tp_frm[tp_hdl].sts_rx == TP_FRM_RX_ERR_NOTIF))) {
/* Cas en que executem la transicio RxFFTxFCNotBlocked */
/* -- action de la transicio -- */
TPReadFFSendFC(tp_hdl);
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_CONFIRMAFC;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat RxCF.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| NP_CAN_RX_NOTIF
| NP_CAN_RX_SIZE
| NP_CAN_RX_DATA
| Sortides:
|
| tp_frm
****************************************************************************/
static void RxCF(UI_8 tp_hdl)
{
if ((tp_data[tp_hdl].timers.n_cr > TIMER_MS_TO_TICKS(tp_data[tp_hdl].cfg.n_cr_max) ) && (tp_frm[tp_hdl].sts_rx != TP_FRM_RX_FINISHED)) {
/* Cas en que executem la transicio TimeOutSigSegmento */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_rx = TP_FRM_RX_ERR_NOTIF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if (tp_frm[tp_hdl].sts_rx == TP_FRM_RX_ERR_FINISHED) {
/* Cas en que executem la transicio ErrorCF */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_rx = TP_FRM_RX_ERR_NOTIF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if ((tp_frm[tp_hdl].sts_rx != TP_FRM_RX_FINISHED) && ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_SF) || (tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_FF))) {
/* Cas en que executem la transicio UnexpectedFForSF */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_rx = TP_FRM_RX_ERR_NOTIF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if ((tp_frm[tp_hdl].sts_rx == TP_FRM_RX_FINISHED)) {
/* Cas en que executem la transicio RxAcabada */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_rx = TP_FRM_RX_NOTIF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_CF) && (tp_data[tp_hdl].cfg.block_size > (UI_8)0) && (tp_data[tp_hdl].rx_st.num_frames_before_fc >= (tp_data[tp_hdl].cfg.block_size - (UI_8)1)) && (tp_data[tp_hdl].rx_st.byte_actual_rx < (tp_frm[tp_hdl].size_rx - CF_DATA_LEN))) {
/* Cas en que executem la transicio TPSendFC */
/* -- action de la transicio -- */
TPReadCFSendFC(tp_hdl);
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_CONFIRMAFC;
}
else if ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_CF) && ((tp_data[tp_hdl].cfg.block_size == (UI_8)0) || (tp_data[tp_hdl].rx_st.num_frames_before_fc < (tp_data[tp_hdl].cfg.block_size - (UI_8)1)) || (tp_data[tp_hdl].rx_st.byte_actual_rx >= (tp_frm[tp_hdl].size_rx - CF_DATA_LEN)))) {
/* Cas en que executem la transicio ReceivedCFNoFC */
/* -- action de la transicio -- */
TPReadCF(tp_hdl);
tp_data[tp_hdl].rx_st.num_frames_before_fc++;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_RXCF;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_RXCF;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat ConfirmaFC.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| NP_CAN_RX_NOTIF
| NP_CAN_RX_SIZE
| NP_CAN_RX_DATA
| Sortides:
|
| tp_frm
****************************************************************************/
static void ConfirmaFC(UI_8 tp_hdl)
{
BOOL tx_confirmed;
/* Check if the transmission has been confirmed */
tx_confirmed = TPCheckTxConfirmed(tp_hdl, tp_data[tp_hdl].tx_st.frame_tx_fc_sts);
if ((tx_confirmed == TRUE) && (tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_NO_FRM)) {
/* Cas en que executem la transicio ConfirmatFCNoReceivedCF */
/* -- action de la transicio -- */
tp_data[tp_hdl].rx_st.num_frames_before_fc = (UI_16)0;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_RXCF;
}
else if (tp_data[tp_hdl].tx_st.frame_tx_fc_sts == TP_TX_ERROR) {
/* Cas en que executem la transicio TimeOutAr */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_rx = TP_FRM_RX_ERR_NOTIF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else if ((tx_confirmed == TRUE) && (tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_CF) && (tp_data[tp_hdl].cfg.block_size == (UI_8)1) && (tp_data[tp_hdl].rx_st.byte_actual_rx < (tp_frm[tp_hdl].size_rx - CF_DATA_LEN))) {
/* Cas en que executem la transicio ConfirmatFCReceivedCFSendFC */
/* -- action de la transicio -- */
TPReadCFSendFC(tp_hdl);
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_CONFIRMAFC;
}
else if ((tx_confirmed == TRUE) && (tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_CF) && ((tp_data[tp_hdl].cfg.block_size != (UI_8)1) || (tp_data[tp_hdl].rx_st.byte_actual_rx >= (tp_frm[tp_hdl].size_rx - CF_DATA_LEN)))) {
/* Cas en que executem la transicio ConfirmatFCReceivedCFNotSendFC */
/* -- action de la transicio -- */
TPReadCF(tp_hdl);
tp_data[tp_hdl].rx_st.num_frames_before_fc = (UI_16)1;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_RXCF;
}
else if ((tp_frm[tp_hdl].sts_rx != TP_FRM_RX_FINISHED) && ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_SF) || (tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_FF))) {
/* Cas en que executem la transicio UnexpectedSForFF */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_rx = TP_FRM_RX_ERR_NOTIF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_cr = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_INICIO;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_rx = ESTAT_TP_RX_FULL_CONFIRMAFC;
}
}
/********************************** FI **************************************/

View File

@ -0,0 +1,94 @@
/************************* FICOSA INTERNATIONAL ****************************
| File: | TP_Rx_Lite.c
|-----------------------------------------------------------------------------
| Author: | Abel Casas
|-----------------------------------------------------------------------------
| Project: | TP_Lite
| System: | TP_Task_Lite
| Diagram: | TP_Rx_Lite
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 10/1/2012
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 1
| Numero de transicions: 0
| Estats inicials: 0
|
| Variables d'entrada:
| Variables de sortida:
| tp_frm (t_tp_frm)
| Variables d'entrada/sortida:
| Variables locals:
|
| ++++ Descripcio del proces implementat ++++
|
| Task responsible of controlling all the flow of a reception of
a transport protocol frame. This task is responsible of checking
the correct reception of SF and sending the FC
when is needed according to the configuration of the
ISO15765_2. Finally this task will notify to the application when
a new complete RX frame is available.
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task_Lite.h"
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#include "TP_Functions.h"
#include "TP.h"
/*-------------------------------- defines ---------------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------------ user code --------------------------------*/
/*------------------------------ functions ---------------------------------*/
void TP_Rx_LiteInicialitza(UI_8 tp_hdl)
{
/* -- no hi ha inicialitzacio a les funcions simples -- */
}
/****************************************************************************
| Nom de la funcio: TP_Rx_Lite
|----------------------------------------------------------------------------
| Funcionalitat:
| Diagrama d'un sol estat d'un model Edi.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| Sortides: tp_frm
****************************************************************************/
void TP_Rx_Lite(UI_8 tp_hdl)
{
/* Check if a new SF has been received */
if ((tp_data[tp_hdl].rx_st.frame_rx_type == TP_RX_SF) &&
((tp_frm[tp_hdl].sts_rx == TP_FRM_RX_IDLE) || (tp_frm[tp_hdl].sts_rx == TP_FRM_RX_ERR_NOTIF)) &&
(tp_frm[tp_hdl].iso15765_2_block_rx == FALSE)) {
TPReadSF(tp_hdl);
}
else {
/* Reset the frame reception type */
tp_data[tp_hdl].rx_st.frame_rx_type = TP_RX_NO_FRM;
}
} /* TP_Rx_Lite */
/********************************** FI **************************************/

View File

@ -0,0 +1,61 @@
/*************** COPYRIGHT (c) 2002-2007 FICOSA INTERNATIONAL **************
| Language: | MISRA C
| Controller: | Generic
| Spec. Document: | ISO15765-2-E.pdf
|-----------------|------------------------------------------------------------
| Project: | ISO15765-2
| Reference: |
|------------------------------------------------------------------------------
| Date - Cod. - Rev. - App. - Description
| 12/09/02 AM Implementation of the kwp2000 for PSA.
| 19/08/04 DT Split ISO15765_2 protocol from the KWP2000
| because they are different modules.
| 24/04/09 DC Modification to guarantee the requirements SR1431,
| SR1438, SR1681.
| 15/12/10 AC Converted ISO15765_2 protocol to multi-instance.
| 13/11/11 AC Converted ISO15765_2 to full-duplex
| 09/01/12 AC Changed file, routines and variable naming to
| make it a standard component improving his
| comprehension and having a similar naming style
| with MPDT.
|------------------------------------------------------------------------------
| DESCRIPTION:
| User interface for the transport protocol ISO15765_2 on CAN.
| ISO15765_2 protocol is a transport protocol that permits the sending and
| reception of frames until 4096 bytes on a network protocol with frames of
| lower size. The original frame is segemented and sent with flow control
| data that allows to the reception node to mount again the original frame.
| GENERAL CONSIDERATIONS
| - This implementation allows full duplex communications.
| - This implementation allows for each instance a communication channel
| with physical address in which both transmission and receptions could
| be done and a funcional address for only receptions.
| - The functional address channel only supports frames with less than
| 8 bytes of data.
| - This header must be included by the application as it contains the
| definitions of the tasks to send and receive transport protocol frames.
******************************************************************************/
#ifndef _TP_TASK_H
#define _TP_TASK_H
/*----------------------------- INCLUDES ---------------------------------*/
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#ifdef TP_MODE_FULL
#include "TP_Task_Full.h"
#else
#include "TP_Task_Lite.h"
#endif
/*----------------------------- DEFINES ----------------------------------*/
/*-------------------------- DATA TYEPS ----------------------------------*/
/*--------------------------- GLOBAL VARIABLES ---------------------------*/
/*--------------------------- ROUTINE PROTOTYPES ------------------------*/
/********************************** FI **************************************/
#endif

View File

@ -0,0 +1,57 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_Task_Lite.h
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | TP_Lite
| System: | TP_Task_Lite
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeH Version: | 1.01
| Codification Date: | 28/2/2011
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un sistema Edi
|
|
|
************************** FI DE LA CAPCALERA ****************************/
#ifndef _TPTASKFULL_H
#define _TPTASKFULL_H
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
/*----------------------------- user includes -----------------------------*/
/*---------------- estructura de les variables del sistema ----------------*/
/*------------------------ capcaleres de funcions -------------------------*/
void TP_Rx_FullInicialitza(UI_8 iso2_hdl);
void TP_Rx_Full(UI_8 iso2_hdl);
void TP_Tx_FullInicialitza(UI_8 iso2_hdl);
void TP_Tx_Full(UI_8 iso2_hdl);
void TP_RxFunInicialitza(UI_8 iso2_hdl);
void TP_RxFun(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_TxInicialitza(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_Tx(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_RxInicialitza(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_Rx(UI_8 iso2_hdl);
/*------------------------ function-like macros ----------------------------*/
/********************************** FI **************************************/
#endif

View File

@ -0,0 +1,56 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_Task_Lite.h
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | TP_Lite
| System: | TP_Task_Lite
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeH Version: | 1.01
| Codification Date: | 28/2/2011
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un sistema Edi
|
|
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
/*----------------------------- user includes -----------------------------*/
/*---------------- estructura de les variables del sistema ----------------*/
/*------------------------ capcaleres de funcions -------------------------*/
void TP_Rx_LiteInicialitza(UI_8 iso2_hdl);
void TP_Rx_Lite(UI_8 iso2_hdl);
void TP_Tx_LiteInicialitza(UI_8 iso2_hdl);
void TP_Tx_Lite(UI_8 iso2_hdl);
void TP_RxFunInicialitza(UI_8 iso2_hdl);
void TP_RxFun(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_TxInicialitza(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_Tx(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_RxInicialitza(UI_8 iso2_hdl);
void TP_NetworkLayerLowerInterface_Rx(UI_8 iso2_hdl);
/*------------------------ function-like macros ----------------------------*/
/********************************** FI **************************************/

View File

@ -0,0 +1,55 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | Iso15765_2_Tx.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | Iso15765_2
| System: | Iso15765_2_Task
| Diagram: | Iso15765_2_Tx
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 18/5/2009
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 1
| Numero de transicions: 1
| Estats inicials: 1
|
| Variables d'entrada:
| tp_frm (t_tp_frm)
| Variables de sortida:
| NP_CAN_TX_DATA (UI_8)
| NP_CAN_TX_SIZE (UI_8)
| Variables d'entrada/sortida:
| Variables locals:
| block_size (UI_8)
| fc_data (t_fc_data)
| timer_n_bs (t_clock)
| timer_n_cs (t_clock)
| fc_rx (BOOL)
|
| ++++ Descripcio del proces implementat ++++
|
| Maquina 0x2
ISO 15765: KWP -> CAN
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#ifdef TP_MODE_FULL
//#include "TP_Tx_Full.c"
#else
#include "TP_Tx_Lite.c"
#endif
/********************************** FI **************************************/

View File

@ -0,0 +1,442 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | TP_Tx.c
|-----------------------------------------------------------------------------
| Author: | Author
|-----------------------------------------------------------------------------
| Project: | TP
| System: | TP_Task
| Diagram: | TP_Tx
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 18/10/2010
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 3
| Numero de transicions: 12
| Estats inicials: 1
|
| Variables d'entrada:
| tp_frm (t_tp_frm)
| fc_data (t_fc_data)
| Variables de sortida:
| NP_CAN_TX_DATA (UI_8)
| NP_CAN_TX_SIZE (UI_8)
| Variables d'entrada/sortida:
| Variables locals:
| block_size (UI_8)
| timer_n_bs (t_clock)
| timer_n_cs (t_clock)
| timer_n_as (t_clock)
| ack_tx (BOOL)
|
| ++++ Descripcio del proces implementat ++++
|
| Maquina 0x2
ISO 15765: KWP -> CAN
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task.h"
#include "TP.h"
/*------------------------------ user code --------------------------------*/
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#include "TP_Functions.h"
#include "DiagnosticL/FicOsek/FicOsekCom.h"
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------- capcaleres de funcions ------------------------*/
static void TP_Tx_Full0(UI_8 tp_hdl);
static void Inici(UI_8 tp_hdl);
static void EsperaFC(UI_8 tp_hdl);
static void ConfirmaTx(UI_8 tp_hdl);
void TP_Tx_Full(UI_8 tp_hdl);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats TP_Tx
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
|
| NP_CAN_TX_DATA
| NP_CAN_TX_SIZE
****************************************************************************/
#if 1
void TP_Tx_FullInicialitza(UI_8 tp_hdl)
{
/* Inicialitzacio de la variable d estat */
tp_data[tp_hdl].state_tx = ESTAT_0_TP_TX_FULL;
/* Execucio del cicle inicial de la maquina d estats */
TP_Tx_Full(tp_hdl);
}
#endif
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats TP_Tx.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| tp_frm
| fc_data
| Sortides:
|
| NP_CAN_TX_DATA
| NP_CAN_TX_SIZE
****************************************************************************/
void TP_Tx_Full(UI_8 tp_hdl)
{
/* Estudi per casos del estat actual */
switch (tp_data[tp_hdl].state_tx){
case ESTAT_0_TP_TX_FULL:
TP_Tx_Full0(tp_hdl);
break;
case ESTAT_TP_TX_FULL_INICI:
Inici(tp_hdl);
break;
case ESTAT_TP_TX_FULL_ESPERAFC:
EsperaFC(tp_hdl);
break;
case ESTAT_TP_TX_FULL_CONFIRMATX:
ConfirmaTx(tp_hdl);
break;
default:
tp_data[tp_hdl].state_tx = ESTAT_0_TP_TX_FULL;
break;
}
/* Increment del temps de cicle als timers */
if (tp_data[tp_hdl].timers.n_bs < MAX_COMPTADOR_TEMPS) {
tp_data[tp_hdl].timers.n_bs += TP_TASK_TICKS;
}
if (tp_data[tp_hdl].timers.n_cs < MAX_COMPTADOR_TEMPS) {
tp_data[tp_hdl].timers.n_cs += TP_TASK_TICKS;
}
}
#ifdef ENABLE_INCREMENT_EXTERNAL_TIMERS
void TPTxIncrTimers(UI_8 tp_hdl, UI_16 ticks)
{
if (tp_data[tp_hdl].timers.n_bs < MAX_COMPTADOR_TEMPS) {
tp_data[tp_hdl].timers.n_bs += ticks;
}
if (tp_data[tp_hdl].timers.n_cs < MAX_COMPTADOR_TEMPS) {
tp_data[tp_hdl].timers.n_cs += ticks;
}
}
#endif
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces TP_Tx
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void TP_Tx_Full0(UI_8 tp_hdl)
{
/* -- reset dels timers t_clock -- */
tp_data[tp_hdl].timers.n_bs= (t_clock)0;
tp_data[tp_hdl].timers.n_cs= (t_clock)0;
if (TPCheckPhyCfgData(tp_hdl) == TRUE) {
/* Canviem l estat inicial */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
else {
/* No s ha activat cap condicio inicial: ens quedem a l estat actual */
tp_data[tp_hdl].state_tx = ESTAT_0_TP_TX_FULL;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Inici.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| tp_frm
| fc_data
| Sortides:
|
| NP_CAN_TX_DATA
| NP_CAN_TX_SIZE
****************************************************************************/
static void Inici(UI_8 tp_hdl)
{
if ((tp_frm[tp_hdl].sts_tx == TP_FRM_TX_REQ) && (tp_frm[tp_hdl].size_tx <= NP_SF_MAX_SIZE) && (tp_frm[tp_hdl].iso15765_2_block_tx == FALSE)) {
/* Cas en que executem la transicio TxSF */
/* -- action de la transicio -- */
TPSendSF(tp_hdl);
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_CONFIRMATX;
}
else if ((tp_frm[tp_hdl].sts_tx == TP_FRM_TX_REQ) && (tp_frm[tp_hdl].size_tx > NP_SF_MAX_SIZE) && (tp_frm[tp_hdl].iso15765_2_block_tx == FALSE)) {
/* Cas en que executem la transicio TxFF */
/* -- action de la transicio -- */
TPSendFF(tp_hdl);
tp_data[tp_hdl].fc_data.first_fc = TRUE;
tp_data[tp_hdl].fc_data.block_size_cnt = 0xFF;
tp_data[tp_hdl].fc_data.rx_bs = 0xFF;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_CONFIRMATX;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat EsperaFC.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| tp_frm
| fc_data
| Sortides:
|
| NP_CAN_TX_DATA
| NP_CAN_TX_SIZE
****************************************************************************/
static void EsperaFC(UI_8 tp_hdl)
{
/* -- codi de l estat actual -- */
if (tp_data[tp_hdl].rx_st.frame_fc_type == TP_FC) {
TPReadFCSendCF(tp_hdl);
}
else {
/* Do nothing */
}
if ((tp_data[tp_hdl].fc_data.fc_rx == TRUE) && (tp_data[tp_hdl].fc_data.flow_status == TP_FLOW_STS_WT) && (tp_data[tp_hdl].fc_data.num_fc_wait < tp_data[tp_hdl].cfg.n_wftmax)) {
/* Cas en que executem la transicio ArribaFCWaitAccepted */
/* -- action de la transicio -- */
/* Reset the FC reception flag */
tp_data[tp_hdl].fc_data.fc_rx = FALSE;
/* Increment number of FC wait received */
tp_data[tp_hdl].fc_data.num_fc_wait++;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_ESPERAFC;
}
else if ((tp_data[tp_hdl].fc_data.fc_rx == TRUE) && (tp_data[tp_hdl].fc_data.flow_status == TP_FLOW_STS_WT) && (tp_data[tp_hdl].fc_data.num_fc_wait >= tp_data[tp_hdl].cfg.n_wftmax)) {
/* Cas en que executem la transicio ArribaFCWaitRejected */
/* -- action de la transicio -- */
tp_data[tp_hdl].fc_data.fc_rx = FALSE;
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_ERR_NOTIF;
tp_frm[tp_hdl].iso15765_2_block_rx = FALSE;
tp_data[tp_hdl].fc_data.num_fc_wait = 0;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
else if ((tp_data[tp_hdl].fc_data.fc_rx == FALSE) && (tp_data[tp_hdl].timers.n_bs >= TIMER_MS_TO_TICKS(tp_data[tp_hdl].cfg.n_bs_max) )) {
/* Cas en que executem la transicio TimeOutFC */
/* -- action de la transicio -- */
tp_data[tp_hdl].fc_data.fc_rx = FALSE;
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_ERR_NOTIF;
tp_frm[tp_hdl].iso15765_2_block_rx = FALSE;
tp_data[tp_hdl].fc_data.num_fc_wait = 0;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
else if ((tp_data[tp_hdl].fc_data.fc_rx == TRUE) && (tp_data[tp_hdl].fc_data.flow_status != TP_FLOW_STS_WT) && (tp_data[tp_hdl].fc_data.flow_status != TP_FLOW_STS_CTS)) {
/* Cas en que executem la transicio ArribaFCError */
/* -- action de la transicio -- */
tp_data[tp_hdl].fc_data.fc_rx = FALSE;
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_ERR_NOTIF;
tp_frm[tp_hdl].iso15765_2_block_rx = FALSE;
tp_data[tp_hdl].fc_data.num_fc_wait = 0;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
else if ((tp_data[tp_hdl].fc_data.fc_rx == TRUE) && (tp_data[tp_hdl].fc_data.flow_status == TP_FLOW_STS_CTS)) {
/* Cas en que executem la transicio TxPrimerCF */
/* -- action de la transicio -- */
tp_data[tp_hdl].fc_data.block_size_cnt = (UI_8)1;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_CONFIRMATX;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_ESPERAFC;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat ConfirmaTx.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
|
| tp_frm
| fc_data
| Sortides:
|
| NP_CAN_TX_DATA
| NP_CAN_TX_SIZE
****************************************************************************/
static void ConfirmaTx(UI_8 tp_hdl)
{
BOOL tx_confirmed, end_frame;
/* Check if the transmission has been confirmed */
tx_confirmed = TPCheckTxConfirmed(tp_hdl, tp_data[tp_hdl].tx_st.frame_tx_sts);
/* -- codi de l estat actual -- */
if (tx_confirmed == TRUE) {
tp_data[tp_hdl].tx_st.ack_tx = TRUE;
}
else {
tp_data[tp_hdl].tx_st.ack_tx = FALSE;
tp_data[tp_hdl].timers.n_cs = 0;
}
/* Check if the TX is finished */
end_frame = TPTestEndFrame(tp_hdl);
if ((tp_data[tp_hdl].tx_st.ack_tx == FALSE) && (tp_data[tp_hdl].tx_st.frame_tx_sts == TP_TX_ERROR)) {
/* Cas en que executem la transicio TimeOutTxCF */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_ERR_NOTIF;
tp_frm[tp_hdl].iso15765_2_block_rx = FALSE;
tp_data[tp_hdl].fc_data.num_fc_wait = 0;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
else if ((tp_data[tp_hdl].tx_st.ack_tx == TRUE) && (end_frame == TRUE)) {
/* Cas en que executem la transicio TxAcabada */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_IDLE;
tp_data[tp_hdl].fc_data.num_fc_wait = 0;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_INICI;
}
else if ((tp_data[tp_hdl].tx_st.ack_tx == TRUE) && (end_frame == FALSE) && (tp_data[tp_hdl].fc_data.rx_bs > (UI_8)0) && (tp_data[tp_hdl].fc_data.block_size_cnt >= tp_data[tp_hdl].fc_data.rx_bs)) {
/* Cas en que executem la transicio EndBlockSize */
/* -- action de la transicio -- */
tp_data[tp_hdl].fc_data.fc_rx = FALSE;
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_ESPERAFC;
}
else if ((tp_data[tp_hdl].tx_st.ack_tx == TRUE) && (end_frame == FALSE) && (tp_data[tp_hdl].timers.n_cs >= TIMER_MS_TO_TIME_RESTRICTIVE((t_clock)(tp_data[tp_hdl].fc_data.stmin))) && ((tp_data[tp_hdl].fc_data.block_size_cnt < tp_data[tp_hdl].fc_data.rx_bs) || (tp_data[tp_hdl].fc_data.rx_bs == 0))) {
/* Cas en que executem la transicio TxSeguentCF */
/* -- action de la transicio -- */
tp_data[tp_hdl].fc_data.block_size_cnt++;
TPSendCF(tp_hdl);
/* -- reset del timer -- */
tp_data[tp_hdl].timers.n_bs = (t_clock)0;
tp_data[tp_hdl].timers.n_cs = (t_clock)0;
/* -- canviem l estat -- */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_CONFIRMATX;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
tp_data[tp_hdl].state_tx = ESTAT_TP_TX_FULL_CONFIRMATX;
}
}
/********************************** FI **************************************/

View File

@ -0,0 +1,249 @@
/************************* FICOSA INTERNATIONAL ****************************
| File: | TP_Tx_Lite.c
|-----------------------------------------------------------------------------
| Author: | Abel Casas
|-----------------------------------------------------------------------------
| Project: | TP_Lite
| System: | TP_Task_Lite
| Diagram: | TP_Tx_Lite
| Model Version: | 1.0
| Model Date: | Thursday, February 26, 2009 - 14:47:56
|-----------------------------------------------------------------------------
| CodeC Version: | 1.0
| Codification Date: | 10/1/2012
|-----------------------------------------------------------------------------
| Description:
| Codificacio automatica d'un diagrama d'estats
|
| ++++ Informacio del Diagrama d'Estats +++++
|
| Numero d'estats: 2
| Numero de transicions: 3
| Estats inicials: 1
|
| Variables d'entrada:
| Variables de sortida:
| tp_frm (t_tp_frm)
| Variables d'entrada/sortida:
| Variables locals:
|
| ++++ Descripcio del proces implementat ++++
|
| Task responsible of controlling all the flow of a transmission of
a transport protocol frame. This task is responsible of sending
correctly SF.
|
************************** FI DE LA CAPCALERA ****************************/
/*------------------------------- includes --------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "TP_Task_Lite.h"
#include "DiagnosticL/UDS/Iso15765_layer2/TP_CFG.h"
#include "TP_Functions.h"
/*-------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
/*------------------------------ variables --------------------------------*/
/*------------------------------ user code --------------------------------*/
/*------------------------- capcaleres de funcions ------------------------*/
//static void TP_Tx_Lite0(UI_8 tp_hdl);
//static void Init(UI_8 tp_hdl);
//static void ConfirmTx(UI_8 tp_hdl);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats TP_Tx_Lite
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
| tp_data[tp_hdl].state_tx
|
| tp_frm
****************************************************************************/
void TP_Tx_LiteInicialitza(UI_8 tp_hdl)
{
/* Inicialitzacio de la variable d estat */
// tp_data[tp_hdl].state_tx = ESTAT_0_TP_TX_LITE;
/* Execucio del cicle inicial de la maquina d estats */
//TP_Tx_Lite(tp_hdl);
}
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats TP_Tx_Lite.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| tp_data[tp_hdl].state_tx
|
| Sortides:
| tp_data[tp_hdl].state_tx
|
| tp_frm
****************************************************************************/
void TP_Tx_Lite(UI_8 tp_hdl)
{
#if 0
/* Estudi per casos del estat actual */
switch (tp_data[tp_hdl].state_tx){
case ESTAT_0_TP_TX_LITE:
TP_Tx_Lite0(tp_hdl);
break;
case ESTAT_TP_TX_LITE_INIT:
Init(tp_hdl);
break;
case ESTAT_TP_TX_LITE_CONFIRMTX:
ConfirmTx(tp_hdl);
break;
default:
tp_data[tp_hdl].state_tx = ESTAT_0_TP_TX_LITE;
break;
}
#endif
}
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces TP_Tx_Lite
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
#if 0
static void TP_Tx_Lite0(UI_8 tp_hdl)
{
if (TPCheckPhyCfgData(tp_hdl) == TRUE) {
/* Avaluem condicio de start del estat Init */
/* Canviem l estat inicial */
// tp_data[tp_hdl].state_tx = ESTAT_TP_TX_LITE_INIT;
}
else {
/* No s ha activat cap condicio inicial: ens quedem a l estat actual */
// tp_data[tp_hdl].state_tx = ESTAT_0_TP_TX_LITE;
}
}
#endif
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Init.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| tp_data[tp_hdl].state_tx
|
| Sortides:
| tp_data[tp_hdl].state_tx
|
| tp_frm
****************************************************************************/
#if 0
static void Init(UI_8 tp_hdl)
{
if ((tp_frm[tp_hdl].sts_tx == TP_FRM_TX_REQ) && (tp_frm[tp_hdl].size_tx <= NP_SF_MAX_SIZE) && (tp_frm[tp_hdl].iso15765_2_block_tx == FALSE)) {
/* Cas en que executem la transicio TxSF */
/* -- action de la transicio -- */
TPSendSF(tp_hdl);
/* -- canviem l estat -- */
// tp_data[tp_hdl].state_tx = ESTAT_TP_TX_LITE_CONFIRMTX;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
// tp_data[tp_hdl].state_tx = ESTAT_TP_TX_LITE_INIT;
}
}
#endif
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat ConfirmTx.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| tp_data[tp_hdl].state_tx
|
| Sortides:
| tp_data[tp_hdl].state_tx
|
| tp_frm
****************************************************************************/
#if 0
static void ConfirmTx(UI_8 tp_hdl)
{
/* -- codi de l estat actual -- */
BOOL tx_confirmed, end_frame;
/* Check if the transmission has been confirmed */
tx_confirmed = TPCheckTxConfirmed(tp_hdl, tp_data[tp_hdl].tx_st.frame_tx_sts);
/* -- codi de l estat actual -- */
if (tx_confirmed == TRUE) {
tp_data[tp_hdl].tx_st.ack_tx = TRUE;
}
else {
tp_data[tp_hdl].tx_st.ack_tx = FALSE;
}
/* Check if the TX is finished */
end_frame = TPTestEndFrame(tp_hdl);
if ((tp_data[tp_hdl].tx_st.ack_tx == FALSE) && (tp_data[tp_hdl].tx_st.frame_tx_sts == TP_TX_ERROR)) {
/* Cas en que executem la transicio TimeOutTxCF */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_ERR_NOTIF;
tp_frm[tp_hdl].iso15765_2_block_rx = FALSE;
/* -- canviem l estat -- */
// tp_data[tp_hdl].state_tx = ESTAT_TP_TX_LITE_INIT;
}
else if ((tp_data[tp_hdl].tx_st.ack_tx == TRUE) && (end_frame == TRUE)) {
/* Cas en que executem la transicio TxFinished */
/* -- action de la transicio -- */
tp_frm[tp_hdl].sts_tx = TP_FRM_TX_IDLE;
/* -- canviem l estat -- */
//tp_data[tp_hdl].state_tx = ESTAT_TP_TX_LITE_INIT;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
// tp_data[tp_hdl].state_tx = ESTAT_TP_TX_LITE_CONFIRMTX;
}
}
#endif
/********************************** FI **************************************/

View File

@ -0,0 +1,23 @@
#!python -u
#-------------------------------------------------------------------------------
# Purpose: Waf build script.
#
# Author: F59AMD0
#
# Copyright: (c) FICOSA 2015
# Licence: <your licence>
#-------------------------------------------------------------------------------
def build(bld):
bld.env.RINCLUDES += [
"." ,
]
bld.env.RSOURCES += [
("TP_Functions.c", {}),
("TP_NetworkLayerLowerInterface_Rx.c", {}),
("TP_NetworkLayerLowerInterface_Tx.c", {}),
("TP_Rx.c", {}),
("TP_RxFun.c", {}),
("TP_Tx.c", {}),
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,591 @@
#ifndef _ISO15765_3_CFG_H_
#define _ISO15765_3_CFG_H_
/* ISO15765_3 VARIANTS */
#define ISO15765_3_UDS (0x00)
#define ISO15765_3_RSA (0x01)
#define ISO15765_3_FIAT (0x02)
#define ISO15765_3_VARIANT (ISO15765_3_UDS)
/* ISO15765_3 MODE */
#define ISO15765_3_APP (0x00)
#define ISO15765_3_BL (0x01)
#define ISO_3_MODE (ISO15765_3_BL)
/* FICOSA_SYSTEM_SUPPLIER_SESSION */
/* 0x60 - 0x7E systemSupplierSpecific: this range of values is reserved for system-supplier-specific use.*/
/* ISO 14229-1:2006(E) pag 39 */
#define UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID ((UI_8)0x60)
/* Size of the buffer that must store the largest frame for the */
/* diagnostic server instance (ISO15765_3) */
/* The size of the buffer must be declared using the macro */
/* SIZE_ALLOC_BUFFER to assure that no overflows will happen during */
/* transmission or reception of frames larger than single frames */
//DMP: It cannot be integrated with the current ISO 2
//#define FUN_DIAG_DISABLED (0x00)
//#define FUN_DIAG_ENABLED (0x01)
//#define FUN_DIAG_STATUS (FUN_DIAG_ENABLED)
//#if (FUN_DIAG_STATUS == FUN_DIAG_ENABLED)
#define TP_DIAG_FUN_RX_LEN (SIZE_ALLOC_BUFFER(8))
//#endif
//NO ES POT ENGANCHAR AMB ISO_2
#define TP_DIAG_RX_LEN (SIZE_ALLOC_BUFFER(4096))
#define TP_DIAG_TX_LEN (SIZE_ALLOC_BUFFER(4096))
/* Used ISO15765_2 stack in order to send and receive */
/* the diagnostics */
#define DIAG_ISO15765_2_HDL (ISO15765_2_REPROGONCAN_HANDLER)
/*****************************************************************************/
/* TIMING */
/*****************************************************************************/
/* Max time allowed to answer a request. In milliseconds */
#define P2_MAX ((UI_16)50)
/* Max time between a UDS_ERR_RESPONSE_PENDING and the next answer. In ms */
#define P2_EXT_MAX ((UI_16)1000)
/* Max counter between a UDS_ERR_RESPONSE_PENDING and the next answer. */
#define P2_EXT_MAX_COUNTER ((UI_16)5)
/* Session Expiration Timeout. In ms */
#define S3_MAX ((UI_16)5000)
/*****************************************************************************/
/* DATA TYPES */
/*****************************************************************************/
/* Specify the Download Addresses size: */
/* Possible values: ISO3_16BIT_ADDRESS, ISO3_32BIT_ADDRESS */
#define DOWNLOAD_ADDRESS_SIZE (ISO3_32BIT_ADDRESS)
/*****************************************************************************/
/* UDS SERVICES */
/*****************************************************************************/
/* SECURITY ACCESS ENABLED/DISABLED */
#define SERVICE_DISABLED (0x00)
#define SERVICE_ENABLED (0x01)
#define LIN_ASSIGN_FRAME_IDENTIFIER_STATUS (SERVICE_ENABLED)
#define LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_STATUS (SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define LIN_READ_BY_IDENTIFIER_STATUS (SERVICE_ENABLED)
#define LIN_ASSIGN_NAD_STATUS (SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define LIN_CONDITIONAL_CHANGE_NAD_STATUS (SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define UDS_SERVICE_SESSION_CONTROL_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_ECU_RESET_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_SECURITY_ACCESS_STATUS (SERVICE_DISABLED)
#define UDS_SERVICE_TESTER_PRESENT_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_CONTROL_DTC_SETTING_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS_STATUS (SERVICE_DISABLED)//NOT IMPLEMENTED YET
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_STATUS (SERVICE_DISABLED)//NOT IMPLEMENTED YET
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_DTC_INFORMATION_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_IO_CTRL_BY_ID_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_ROUTINE_CONTROL_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_REQUEST_DOWNLOAD_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_TRANSFER_DATA_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_REQUEST_TRANSFER_EXIT_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_COMMUNICATION_CONTROL_STATUS (SERVICE_ENABLED)
#if (LIN_ASSIGN_FRAME_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* ASSIGN FRAME IDENTIFIER (0xB7)
*****************************************************************************
* This service IS ONLY VALID in LIN version 2.0
* CALLBACKS:
* LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK(UI_8 supplierID_LSB, UI_8 supplierID_MSB, UI_8 messageID_LSB, UI_8 messageID_MSB, UI_8 new_pid):
* 'supplierID' defines the product vendor identifier.
* 'messageID' defines the message identifier as in <Configurable frames> section in Lin Description File.
* 'new_pid' defines the new pid to identify the frame with the selected messageID.
* A response shall be sent if the assignation is successful.
****************************************************************************/
#define LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK (LinAssignFrameId)
#endif
#if (LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* ASSIGN FRAME IDENTIFIER RANGE (0xB7)
*****************************************************************************
* This service IS MANDATORY in all three LIN diagnostics classes
* (See 4.2.5.5 on LIN Spec 2.2)
* CALLBACKS:
* LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK(UI_8 index, const UI_8* new_pid_list):
* 'index' defines the protected identifier (pid) start from the pid list available.
* 'new_pid_lis' defines a buffer where are specified the four new pids for change
* counting from index.
* - 0x00: Disable service.
* - 0xFF: Do not change PID.
* - 0xXX: Change pid.
* The system shall only response if NAD matched.
****************************************************************************/
#define LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER_RANGE (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK (LinAssignFrameIdRange)
#endif
#if (LIN_READ_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ BY IDENTIFIER (0xB2)
*****************************************************************************
* This service IS MANDATORY in all three LIN diagnostics classes for ID = 0x00
* The rest of identifier are optional.
* (See 4.2.6.1 on LIN Spec 2.2)
* CALLBACKS:
* LIN_READ_BY_IDENTIFIER_CALLBACK(UI_8 id):
* 'id' defines the identifier requested.
* - 0x00: LIN Product identification: SupplierID, FunctionID & Variant.
* - 0x01: Serial Number.
* - 0x32-0x63: User defined.
* - The rest of identifiers are reserved.
* The system shall accordingly to each request. (See 4.2.6.1 on LIN Spec 2.2)
****************************************************************************/
#define LIN_SERVICE_READ_BY_IDENTIFIER (UDS_DEFAULT_SESSION_MASK)
#define LIN_READ_BY_IDENTIFIER_CALLBACK (LinReadByID)
#endif
#if (LIN_ASSIGN_NAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* LIN ASSIGN NAD (0xB0)
*****************************************************************************
* This service CAN be enabled/disabled
* (See 4.2.5.1 on LIN Spec 2.2)
* CALLBACKS:
* LIN_ASSIGN_NAD_CALLBACK(UI_16 supplierId, UI_16 functionId, UI_8 new_nad):
* - 'supplierId' and 'functionId' must be the same as defined in the system,
* otherwise the NAD won't be assigned.
* - 'new_nad' is the new NAD to be assigned
* The system shall response with the initial NAD to confirm the change.
****************************************************************************/
#define LIN_SERVICE_ASSIGN_NAD (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_NAD_CALLBACK (LinAssignNAD)
#endif
#if (LIN_CONDITIONAL_CHANGE_NAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* LIN CONDITIONAL CHANGE NAD (0xB3)
*****************************************************************************
* This service CAN be enabled/disabled
* (See 4.2.5.2 on LIN Spec 2.2)
* CALLBACKS:
* LIN_CONDITIONAL_CHANGE_NAD_CALLBACK(UI_8 id, UI_8 byte, UI_8 mask, UI_8 invert, UI_8 new_nad):
* 1. 'id' Get the identifier specified by the function LinReadByID.
* 2. Extract the data byte selected by Byte (Byte = 1 corresponds to the first byte, D1).
* 3. Do a bitwise XOR with Invert.
* 4. Do a bitwise AND with Mask.
* 5. If the final result is zero then change the NAD to New NAD.
* The system shall response with the new NAD to confirm the change.
****************************************************************************/
#define LIN_SERVICE_CONDITIONAL_CHANGE_NAD (UDS_DEFAULT_SESSION_MASK)
#define LIN_CONDITIONAL_CHANGE_NAD_CALLBACK (LinConditionalChangeNAD)
#endif
#if (UDS_SERVICE_SESSION_CONTROL_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* DIAGNOSTICS SESSION CONTROL (0x10)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* .- UDS_INI_SESSION_CALLBACK: The user MAY implement this callback.
* Called when layer 3 changes session
* DEFINES:
* .- UDS_USER_DEFINED_SESSION. Valid User Defined Session ID
****************************************************************************/
#define UDS_SERVICE_SESSION_CONTROL (UDS_ALL_SESSION_MASK)
#define UDS_USER_DEFINED_SESSION (UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID)
#define UDS_INI_SESSION_CALLBACK (UdsIniSession)
#endif
#if (UDS_SERVICE_ECU_RESET_STATUS == SERVICE_ENABLED)
/****************************************************************************
* ECU RESET (0x11)
****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* BOOL CHECK_RESET_POSSIBLE(UI_8 reset_type):
* Asks the user if this reset type is allowed at this point in time.
* Return TRUE if yes
* void EXECUTE_RESET(UI_8 reset_type):
* Execute the reset type requested
****************************************************************************/
#define UDS_SERVICE_ECU_RESET (UDS_PROGRAMMING_SESSION_MASK | UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define CHECK_RESET_POSSIBLE (UdsCheckResetIsPossible)
#define EXECUTE_RESET (UdsExecuteResetNow)
#endif
#if (UDS_SERVICE_SECURITY_ACCESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* SECURITY ACCESS(0x27)
****************************************************************************
* This service can be enabled/disabled
* CALLBACKS:
* void UDS_SECURITY_REQUEST_SEED_CALLBACK(UI_8* p_local_seed):
* Generate a Random Seed and place it in p_local_seed (4 bytes)
* BOOL UDS_SECURITY_CHECK_KEY_CALLBACK(UI_8* p_local_seed, UI_8* p_tool_key):
* Check the key returned by the tool. Return TRUE is ok
* DEFINES
* UDS_SERVICE_SECURITY_ACCESS: set the session which accepts this service.
* SECURITY_INIT_DELAY: Set to SECURITY_DELAY, to introduce 10 secs
* delay after Reset, before accepting security resets. Set to
* SECURITY_NO_DELAY if no delay is wanted.
* MAX_SECURITY_ATTEMPTS: Number of failed attempts before starting the penalty
* SECURITY_PENALTY_TIME: Time to wait before next attempt.
* SECURITY_SEED_SIZE: Number of bytes of the security seed (max = 4)
* SECURITY_KEY_SIZE: Number of bytes of the security seed (max = 4)
* UDS_SECURITY_COUNTER_NVM_CALLBACK: Callback to store a new value of the counter in NVM.
* - Signature: void UDS_SECURITY_COUNTER_NVM_CALLBACK(UI_8 *value)
* - (legacy) If not defined, then value will not be stored in NVM.
* UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK: Callback to retrieve the value of the counter from NVM, tipically
* at the beginning of the execution.
* - Signature: UI_8 UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK(void)
* - (legacy) If not defined, then value will be loaded as zero (check startup strategy for penalty delay
* using SECURITY_INIT_DELAY).
****************************************************************************/
****************************************************************************/
#define UDS_SERVICE_SECURITY_ACCESS (UDS_EXT_DIAG_SESSION_MASK)
#define UDS_SECURITY_REQUEST_SEED_CALLBACK (UdsSecurityGetSeed)
#define UDS_SECURITY_CHECK_KEY_CALLBACK (UdsSecurityCheckKey)
#define SECURITY_INIT_DELAY (SECURITY_NO_DELAY)
#define MAX_SECURITY_ATTEMPTS ((UI_8) 2)
#define SECURITY_PENALTY_TIME ((UI_16) 10000)
#define SECURITY_SEED_SIZE ((UI_8) 4)
#define SECURITY_KEY_SIZE ((UI_8) 4)
#define UDS_SECURITY_COUNTER_NVM_CALLBACK ()
#define UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK ()
#endif
#if (UDS_SERVICE_TESTER_PRESENT_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* TESTER PRESENT (0x3E)
*****************************************************************************
* This service CAN be enabled/disabled
* No User CALLBACK Needed
****************************************************************************/
#define UDS_SERVICE_TESTER_PRESENT (UDS_ALL_SESSION_MASK)
#endif
#if (UDS_SERVICE_READ_DATA_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ DATA BY ID(0x22)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK(UI_8 id_high,
* UI_8 id_low): Pass the ID to the user to
* process the request. The user is responsible for checking the security
* status for each parameter, and to send the appropiate response.
*****************************************************************************/
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK (UdsReadDataByIdentifier)
#endif
#if (UDS_SERVICE_READ_MEMORY_BY_ADDRESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ MEMORY BY ADDRESS(0x23)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK(UI_8 mem_size_len,
* UI_8 mem_addr_len, UI_8* mem_addr, UI_8* mem_size): The user must
* retrieve the requested memory address buffer and return it to the host
*****************************************************************************/
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS (UDS_DEFAULT_SESSION_MASK)
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK (UdsReadMemoryByAddress)
#endif
#if (UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* WRITE DATA BY IDENTIFIER(0x2E)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UI_16 id,
* UI_8* p_buf, UI_16 size): This callback is
* responsible for starting the writting process to get the data written
* in the apporpiate memory position / device and to
* return the command that must be sent back to the tool
* id: The id to modify
* p_buf: Id data as sent by the diagnostics tool
* size: Amount of ID data bytes received
*****************************************************************************/
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UdsWriteDataByIdentifier)
#endif
#if (UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* WRITE MEMORY BY ADDRES(0x3D)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UI_8 id_high,
* UI_8 id_low, UI_8* p_buf, UI_16 size):
* This callback is used by the user to write the data identified with id
* in the appropiate mamory / device. The data sent by the host is passed
* in p_buf/size
*****************************************************************************/
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS (UDS_DEFAULT_SESSION_MASK)
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_CALLBACK (UdsWriteMemoryByAddr)
#endif
#if (UDS_SERVICE_CONTROL_DTC_SETTING_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* CONTROL DTC SETTING (0x85)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK(UI_8 dtc_setting_mode,
* UI_8* buf_data_rx, I_16 size):
* size: size of the dtc option record received
* buf_data_rx: pointer to the dtc option record received
* This callback is responsible for sending the appropiate response
****************************************************************************/
#define UDS_SERVICE_CONTROL_DTC_SETTING (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK (UdsControlDtcSetting)
#endif
#if (UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* CLEAR DTC INFORMATION(0x14)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK(UI_8* p_dtc_group)
* Clear all DTC codes identified by the p_dtc_group reference
*****************************************************************************/
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK (UdsClearDtc)
#endif
#if (UDS_SERVICE_READ_DTC_INFORMATION_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ DTC INFORMATION(0x19)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK (UI_16 id,
* UI_8* p_buf, UI_16 size):
* Retrieve and send the Diagnostics Info identified by id.
*****************************************************************************/
#define UDS_SERVICE_READ_DTC_INFORMATION (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK (UdsReadDtc)
#endif
#if (UDS_SERVICE_IO_CTRL_BY_ID_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* I/O CONTROL BY ID(0x2F)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_INPUT_OUTPUT_CONTROL_BY_ID(UI_8 *data_buffer, UI_8 size)
*****************************************************************************/
#define UDS_SERVICE_IO_CTRL_BY_ID (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_IO_CTRL_BY_ID_CALLBACK (UdsInputOutputControlByIdentifier)
#endif
#if (UDS_SERVICE_ROUTINE_CONTROL_STATUS == SERVICE_ENABLED)
/****************************************************************************
* ROUTINE CONTROL(0x31)
****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_ROUTINE_CONTROL_START_CALLBACK(UI_8 id_high, UI_8 id_low,
* UI_16 size, UI_8 *data_buffer);
* Host wants to start a control routine.
* User is responsible for returning the appropiate response code.
****************************************************************************/
#define UDS_SERVICE_ROUTINE_CONTROL (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_ROUTINE_CONTROL_CALLBACK (UdsControlRoutine)
#endif
#if (UDS_SERVICE_REQUEST_DOWNLOAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* REQUEST DOWNLOAD(0x34)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACK:
* UI_8 DEVICE_0_REQUEST_DOWNLOAD_CALLBACK(t_addr base_addr, t_addr last_addr)
* The host wnats to start a download from address dl_base with a size
* of dl_size in bytes. Calculate if this is possible. And give an answer
* Define one callback for each device in the system that may receive
* data through a downlonad.
****************************************************************************/
#define UDS_SERVICE_REQUEST_DOWNLOAD (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_REQUEST_DOWNLOAD_CALLBACK (UdsPlm2BLRequestDownload)*/
#endif
#if (UDS_SERVICE_TRANSFER_DATA_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* TRANSFER DATA(0x36)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS
* UI_8 DEVICE_0_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size)
* A data block is sent by the host, program it in the right memory.
* The right destination address is responsability of the user callback
* Define one callback per each device that can receive the data
****************************************************************************/
#define UDS_SERVICE_TRANSFER_DATA (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_TRANSFER_DATA_CALLBACK (UdsPlm2BLTransferData)*/
#endif
#if (UDS_SERVICE_REQUEST_TRANSFER_EXIT_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* TRANSFER EXIT(0x37)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACK:
* UI_8 DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size)
* The host informs us that the download process is finished
****************************************************************************/
#define UDS_SERVICE_REQUEST_TRANSFER_EXIT (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK (UdsPlm2BLTransferExit)*/
#endif
#if (UDS_SERVICE_COMMUNICATION_CONTROL_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* COMMUNICATION CONTROL (0x28)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* .- UDS_COMMUNICATION_CONTROL_CALLBACK: The user MAY implement this callback.
* DEFINES:
* .- UDS_COMMUNICATION_CONTROL. Session in which the service will be supported
****************************************************************************/
#define UDS_SERVICE_COMMUNICATION_CONTROL (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_COMMUNICATION_CONTROL_CALLBACK (UdsCommunicationControl)
#endif
/*************** Extra services configuration *************/
/** In order to allow new services to be developed, proceed to configure them as follows
** In this example, we have added an extra service B01 called GEELY_ECHO */
#define UDS_SERVICE_GEELY_ECHO_STATUS (SERVICE_DISABLED) /*!< Geely custom echo test service -SR2372*/
#if (UDS_SERVICE_GEELY_ECHO_STATUS == SERVICE_ENABLED)
typedef struct {
UI_8 buffer_dades[(TP_DIAG_TX_LEN - (UI_8)1)];
} * tp_uds_geely_echo_resp;
/** Mechansim to allow the creation of new services */
#define UDS_EXTRA_SERVICES
#define UDS_EXTRA_SERVICES_CALLBACK (UdsExtraServices)
/*****************************************************************************
* Custom service Geely TEST ECHO (0xB0)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* .- UDS_SERVICE_GEELY_ECHO_CALLBACK: The user MAY implement this callback.
* DEFINES:
* .- UDS_SERVICE_GEELY_ECHO. Session in which the service will be supported
****************************************************************************/
#define UDS_GEELY_ECHO ((UI_8)0xB0)
#define UDS_SERVICE_GEELY_ECHO (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_GEELY_ECHO_CALLBACK (UdsGeelyEcho)
#endif
/*****************************************************************************
* Security attempts counter section
*****************************************************************************
* The security attempts counters can be unique or level dependent.
* Increment and decrement values and maximum security attempts can be configured.
* Allows definition of NVM callbacks to store the counter in flash.
* If this section is NOT configured (previous CFG files):
* - the increment will be 1
* - the decrement will be MAX_SECURITY_ATTEMPTS (clear the counter)
* - there is only one counter for whole system
* - threshold will be equal to MAX_SECURITY_ATTEMPTS
* - Leaves the NVM callbacks undefined (no NVM support).
* ... in order to keep backwards compatibility
****************************************************************************/
/*** BEGIN Example of configuration
- Uses (or not) counters by level.
- Maximum counter is equaled to MAX_SECURITY_ATTEMPTS.
- The count is exceeded when equal to MAX_SECURITY_ATTEMPTS
- Increments 1
- Decrements MAX_SECURITY_ATTEMPTS (so after waiting penalty time will clear the count).
If no SECURITY_ATTEMPT_COUNTERS_BY_LEVEL defined, this configuration is same than before introducing this feature, but allowing NVM storage of the counter.
****
#ifdef SECURITY_ATTEMPT_COUNTERS_BY_LEVEL
#define UDS_NUMBER_OF_SECURITY_LEVELS ((UI_8)3) /*< Number of different security levels
#define UDS_SESSION_IDENTIFIERS_VECTOR {UDS_ECU_UNLOCKED_LEVEL1, UDS_ECU_UNLOCKED_LEVEL11, UDS_ECU_UNLOCKED_LEVEL61} /*< Identifiers of the security level (index table)
#define UDS_SECURITY_ACCESS_MAX_VECTOR {MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS} /*< Maximum values for each counter
#define UDS_SECURITY_ACCESS_INCR_VECTOR {((UI_8)1),((UI_8)1),((UI_8)1)} /*< Increment delta for counting
#define UDS_SECURITY_ACCESS_DECR_VECTOR {MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS} /*< Decrement delta for counting
#define UDS_SECURITY_ACCESS_THRESHOLD_VECTOR {MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS} /*< Threshold to determine if the number of attempts has been exceeded for each counter
#else
#define UDS_SECURITY_ACCESS_INCR ((UI_8)1) /*< Value to increment on each wrong access
#define UDS_SECURITY_ACCESS_DECR ((UI_8)1) /*< Value to decrement when penalty delay is done
#define UDS_SECURITY_ACCESS_PENALTY_THRESHOLD MAX_SECURITY_ATTEMPTS /*< Value to decide if the penalty delay must be applied
#endif
#define UDS_SECURITY_COUNTER_NVM_CALLBACK (UdsSecurityCounterNvmCallback) /*< Callback to perform NVM storage of the counter
#define UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK (UdsSecurityCounterNvmLoadCallback) /*< Callback to retrieve the counter from EEPROM
********** END Example of configuration ***************/
/* #define SECURITY_ATTEMPT_COUNTERS_BY_LEVEL */ /* Uncomment to activate different security access failed attempt counters per security level */
#ifdef SECURITY_ATTEMPT_COUNTERS_BY_LEVEL
#define UDS_NUMBER_OF_SECURITY_LEVELS ((UI_8)3) /*< Number of different security levels
#define UDS_SESSION_IDENTIFIERS_VECTOR {UDS_ECU_UNLOCKED_LEVEL1, UDS_ECU_UNLOCKED_LEVEL11, UDS_ECU_UNLOCKED_LEVEL61} /*< Identifiers of the security level (index table)
#define UDS_SECURITY_ACCESS_MAX_VECTOR {MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS} /*< Maximum values for each counter
#define UDS_SECURITY_ACCESS_INCR_VECTOR {((UI_8)1),((UI_8)1),((UI_8)1)} /*< Increment delta for counting
#define UDS_SECURITY_ACCESS_DECR_VECTOR {((UI_8)1),((UI_8)1),((UI_8)1)} /*< Decrement delta for counting
#define UDS_SECURITY_ACCESS_THRESHOLD_VECTOR {MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS,MAX_SECURITY_ATTEMPTS} /*< Threshold to determine if the number of attempts has been exceeded for each counter
#else
#define UDS_SECURITY_ACCESS_INCR ((UI_8)1) /*< Value to increment on each wrong access
#define UDS_SECURITY_ACCESS_DECR ((UI_8)1) /*< Value to decrement when penalty delay is done
#define UDS_SECURITY_ACCESS_PENALTY_THRESHOLD MAX_SECURITY_ATTEMPTS /*< Value to decide if the penalty delay must be applied
#endif
#define UDS_SECURITY_COUNTER_NVM_CALLBACK () /*< Callback to perform NVM storage of the counter
#define UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK () /*< Callback to retrieve the counter from EEPROM
#endif

View File

@ -0,0 +1,338 @@
/*------------------------------- includes --------------------------------*/
//#include "Global.h"
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3_Task.h"
/*------------------------------ user code --------------------------------*/
#include "Iso15765_3.h"
#define RESET_NO_REQUEST ((UI_8)0)
#define RESET_REQUESTED ((UI_8)1)
#define RESET_REQUESTED_PENDING ((UI_8)2)
#define TIMEOUT_RESET ((UI_16) 5000)
static UI_8 reset_request;
static UI_8 reset_type;
void UDSResetRequest(UI_8 req_reset_type, UI_8 size)
{
if(CHECK_RESET_TYPE(req_reset_type) == TRUE){
if(size == 1){
reset_type=req_reset_type;
reset_request=RESET_REQUESTED;
}
else{
Iso15765_3SendResponse(UDS_ERR_INVALID_FORMAT);
}
}
else{
Iso15765_3SendResponse(UDS_ERR_SUBFUNCTION_NOT_SUPPORTED);
}
}
static void SendResetResponse(UI_8 err)
{
tp_uds_ecu_reset_resp resp;
resp=ISO15765_3_GET_RESP_DATA(tp_uds_ecu_reset_resp);
if(err == ISO15765_3_POSITIVE_RESPONSE){
resp->reset_mode = reset_type;
Iso15765_3IncrementResponseSize(1);
}
Iso15765_3SendResponse(err);
}
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
typedef enum {
ESTAT_ISO15765_3_ECURESETTASK_WAITING_FOR_RESET = 1,
ESTAT_ISO15765_3_ECURESETTASK_ANSWERING_RESET = 2,
ESTAT_ISO15765_3_ECURESETTASK_RESET_EXECUTE = 3,
ESTAT_ISO15765_3_ECURESETTASK_WAITINGTODORESET = 4,
ESTAT_0_ISO15765_3_ECURESETTASK = 0
} t_estat_iso15765_3_ecuresettask;
/*------------------------------ variables --------------------------------*/
/* Variables d estat */
static t_estat_iso15765_3_ecuresettask estat_iso15765_3_ecuresettask = ESTAT_0_ISO15765_3_ECURESETTASK;
/* Timers implicits */
static t_clock temps_iso15765_3_ecuresettask = (t_clock)0;
/*------------------------- capcaleres de funcions ------------------------*/
static void Iso15765_3_EcuResetTask0(void);
static void Waiting_For_Reset(void);
static void Answering_Reset(void);
static void Reset_Execute(void);
static void WaitingToDoReset(void);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats Iso15765_3_EcuResetTask
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
****************************************************************************/
void Iso15765_3_EcuResetTaskInicialitza(void)
{
/* Inicialitzacio de la variable d estat */
estat_iso15765_3_ecuresettask = ESTAT_0_ISO15765_3_ECURESETTASK;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* Execucio del cicle inicial de la maquina d estats */
Iso15765_3_EcuResetTask();
}
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats Iso15765_3_EcuResetTask.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
| Sortides:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
****************************************************************************/
void Iso15765_3_EcuResetTask(void)
{
/* Estudi per casos del estat actual */
switch (estat_iso15765_3_ecuresettask){
case ESTAT_0_ISO15765_3_ECURESETTASK:
Iso15765_3_EcuResetTask0();
break;
case ESTAT_ISO15765_3_ECURESETTASK_WAITING_FOR_RESET:
Waiting_For_Reset();
break;
case ESTAT_ISO15765_3_ECURESETTASK_ANSWERING_RESET:
Answering_Reset();
break;
case ESTAT_ISO15765_3_ECURESETTASK_RESET_EXECUTE:
Reset_Execute();
break;
case ESTAT_ISO15765_3_ECURESETTASK_WAITINGTODORESET:
WaitingToDoReset();
break;
default:
estat_iso15765_3_ecuresettask = ESTAT_0_ISO15765_3_ECURESETTASK;
break;
}
/* Increment del temps de cicle al timer implicit */
if (temps_iso15765_3_ecuresettask < MAX_COMPTADOR_TEMPS) {
temps_iso15765_3_ecuresettask += TimerDeltaCicleConsulta();
}
}
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces Iso15765_3_EcuResetTask
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void Iso15765_3_EcuResetTask0(void)
{
/* Transicio per defecte */
/* -- entry de l estat -- */
reset_request = RESET_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* Canviem l estat inicial */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_WAITING_FOR_RESET;
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Waiting_For_Reset.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
| Sortides:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
****************************************************************************/
static void Waiting_For_Reset(void)
{
if (((reset_request == RESET_REQUESTED) || (reset_request == RESET_REQUESTED_PENDING)) && (CHECK_RESET_POSSIBLE(reset_type)==TRUE) && (CHECK_RESET_TYPE(reset_type)==TRUE)) {
/* Cas en que executem la transicio Check_Reset_Possible */
/* -- action de la transicio -- */
SendResetResponse(ISO15765_3_POSITIVE_RESPONSE);
/* -- entry de l estat Answering_Reset -- */
reset_request = RESET_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_ANSWERING_RESET;
}
else if (((reset_request == RESET_REQUESTED) || (reset_request == RESET_REQUESTED_PENDING)) && (CHECK_RESET_TYPE(reset_type)==TRUE) && (CHECK_RESET_POSSIBLE(reset_type)==FALSE)) {
/* Cas en que executem la transicio Reset_Not_Possible_Now */
/* -- action de la transicio -- */
SendResetResponse(UDS_ERR_RESPONSE_PENDING);
reset_request = RESET_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_WAITINGTODORESET;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_WAITING_FOR_RESET;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Answering_Reset.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
| Sortides:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
****************************************************************************/
static void Answering_Reset(void)
{
if ((tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_IDLE ) && (pending_response == FALSE)) {
/* Cas en que executem la transicio Wait_answer_sent */
/* -- entry de l estat Reset_Execute -- */
EXECUTE_RESET(reset_type);
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_RESET_EXECUTE;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_ANSWERING_RESET;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Reset_Execute.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
| Sortides:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
****************************************************************************/
static void Reset_Execute(void)
{
/* Aquest es un estat pou. Ja no es canviara d estat */
/* Per redundancia es reassigna el mateix estat */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_RESET_EXECUTE;
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat WaitingToDoReset.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
| Sortides:
| estat_iso15765_3_ecuresettask
| temps_iso15765_3_ecuresettask
****************************************************************************/
static void WaitingToDoReset(void)
{
if ((CHECK_RESET_POSSIBLE(reset_type)==TRUE)) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
SendResetResponse(ISO15765_3_POSITIVE_RESPONSE);
/* -- entry de l estat Answering_Reset -- */
reset_request = RESET_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_ANSWERING_RESET;
}
else if (temps_iso15765_3_ecuresettask >= TIMER_MS_TO_TICKS(TIMEOUT_RESET)) {
/* Cas en que executem la transicio TimeoutReset */
/* -- action de la transicio -- */
SendResetResponse(UDS_ERR_BUSY_REPEAT_REQUEST);
reset_request = RESET_NO_REQUEST;
/* -- entry de l estat Waiting_For_Reset -- */
reset_request = RESET_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_ecuresettask= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_WAITING_FOR_RESET;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_ecuresettask = ESTAT_ISO15765_3_ECURESETTASK_WAITINGTODORESET;
}
}
/********************************** FI **************************************/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,480 @@
/*------------------------------- includes --------------------------------*/
//#include "Global.h"
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3_Task.h"
/*------------------------------ user code --------------------------------*/
#include "DiagnosticL/Comp_ISO_15765_2/TP.h"
#include "DiagnosticL/UDS/Iso15765_layer3/Iso15765_3_CFG.h"
#include "Iso15765_3.h"
#define MAX_TIME_ACTION ((UI_16)10000)
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
typedef enum {
ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST = 1,
ESTAT_ISO15765_3_REQUESTRESPONDCTRL_REQUESTINPROGRES = 2,
ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING = 3,
ESTAT_ISO15765_3_REQUESTRESPONDCTRL_EXTTIMERESPOND = 4,
ESTAT_0_ISO15765_3_REQUESTRESPONDCTRL = 0
} t_estat_iso15765_3_requestrespondctrl;
/*------------------------------ variables --------------------------------*/
/* Variables d estat */
static t_estat_iso15765_3_requestrespondctrl estat_iso15765_3_requestrespondctrl = ESTAT_0_ISO15765_3_REQUESTRESPONDCTRL;
/* Timers implicits */
static t_clock temps_iso15765_3_requestrespondctrl = (t_clock)0;
static UI_8 p2extcounter = 0;
static BOOL response_sent = 0;
/*------------------------- capcaleres de funcions ------------------------*/
static void Iso15765_3_RequestRespondCtrl0(void);
static void WaitingRequest(void);
static void RequestInProgres(void);
static void Responding(void);
static void ExtTimeRespond(void);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats Iso15765_3_RequestRespondCtrl
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| session_expired
****************************************************************************/
void Iso15765_3_RequestRespondCtrlInicialitza(void)
{
/* Inicialitzacio de la variable d estat */
estat_iso15765_3_requestrespondctrl = ESTAT_0_ISO15765_3_REQUESTRESPONDCTRL;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* Execucio del cicle inicial de la maquina d estats */
Iso15765_3_RequestRespondCtrl();
}
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats Iso15765_3_RequestRespondCtrl.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| Sortides:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| session_expired
****************************************************************************/
void Iso15765_3_RequestRespondCtrl(void)
{
/* Estudi per casos del estat actual */
switch (estat_iso15765_3_requestrespondctrl){
case ESTAT_0_ISO15765_3_REQUESTRESPONDCTRL:
Iso15765_3_RequestRespondCtrl0();
break;
case ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST:
WaitingRequest();
break;
case ESTAT_ISO15765_3_REQUESTRESPONDCTRL_REQUESTINPROGRES:
RequestInProgres();
break;
case ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING:
Responding();
break;
case ESTAT_ISO15765_3_REQUESTRESPONDCTRL_EXTTIMERESPOND:
ExtTimeRespond();
break;
default:
estat_iso15765_3_requestrespondctrl = ESTAT_0_ISO15765_3_REQUESTRESPONDCTRL;
break;
}
/* Increment del temps de cicle al timer implicit */
if (temps_iso15765_3_requestrespondctrl < MAX_COMPTADOR_TEMPS) {
temps_iso15765_3_requestrespondctrl += TimerDeltaCicleConsulta();
}
}
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces Iso15765_3_RequestRespondCtrl
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void Iso15765_3_RequestRespondCtrl0(void)
{
/* Transicio per defecte */
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* Canviem l estat inicial */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat WaitingRequest.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| Sortides:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| session_expired
****************************************************************************/
static void WaitingRequest(void)
{
if ((tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_IN_PRG)) {
/* Cas en que executem la transicio ReqInProgNotif1 */
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_REQUESTINPROGRES;
}
else if ((tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF) || (tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF)) {
/* Cas en que executem la transicio ReqNotif1 */
/* -- action de la transicio -- */
Iso15765_3Servicios();
response_sent = FALSE;
/* -- entry de l estat Responding -- */
if(tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; } if(tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; }
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING;
}
else if (temps_iso15765_3_requestrespondctrl >= TIMER_MS_TO_TICKS(S3_MAX)) {
/* Cas en que executem la transicio SessionExpired */
/* -- action de la transicio -- */
session_expired = TRUE;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else if (force_response > (UI_8)0x00) {
/* Cas en que executem la transicio ForceResponse */
/* -- action de la transicio -- */
tp_frm[DIAG_ISO15765_2_HDL].data_rx[0] = force_response;
iso15765_3_current_service = force_response;
iso15765_3_request_mode = ISO15765_3_PHY_REQUEST;
tp_frm[DIAG_ISO15765_2_HDL].data_tx[0]= force_response + UDS_POS_RESP_CODE;
Iso15765_3IncrementResponseSize((UI_8)1);
force_response = (UI_8)0x00;
response_sent = FALSE;
/* -- entry de l estat Responding -- */
if(tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; } if(tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; }
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat RequestInProgres.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| Sortides:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| session_expired
****************************************************************************/
static void RequestInProgres(void)
{
if ((tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_ERR_NOTIF)) {
/* Cas en que executem la transicio RxError */
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else if ((tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF)) {
/* Cas en que executem la transicio ReqNotif2 */
/* -- action de la transicio -- */
Iso15765_3Servicios();
response_sent = FALSE;
/* -- entry de l estat Responding -- */
if(tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; } if(tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; }
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING;
}
else if (temps_iso15765_3_requestrespondctrl >= TIMER_MS_TO_TICKS(MAX_TIME_ACTION)) {
/* Cas en que executem la transicio UnknowProblem */
/* -- action de la transicio -- */
Iso15765_3AbortResponse();
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_REQUESTINPROGRES;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Responding.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| Sortides:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| session_expired
****************************************************************************/
static void Responding(void)
{
/* -- during de l estat actual -- */
if ((pending_response == TRUE) && (pending_response_mode != UDS_ERR_RESPONSE_PENDING) &&
((tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_ERR_NOTIF) || (tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_IDLE))) {
Iso15765_3SendResponseSync(pending_response_mode);
response_sent = TRUE;
}
if (((Iso15765_3QueryRequestMode()==ISO15765_3_PHY_REQUEST) && (response_sent == TRUE) && ((tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_IDLE) || (tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_ERR_NOTIF)))) {
/* Cas en que executem la transicio PhyRespondEnd */
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else if ((pending_response == TRUE) && (pending_response_mode == UDS_ERR_RESPONSE_PENDING) && ((tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_ERR_NOTIF) || (tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_IDLE))) {
/* Cas en que executem la transicio NegRespExtTime */
/* -- action de la transicio -- */
Iso15765_3SendResponseSync(pending_response_mode);
p2extcounter = 0;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_EXTTIMERESPOND;
}
else if (((Iso15765_3QueryRequestMode()==ISO15765_3_FUN_REQUEST) && (response_sent == TRUE) && ((tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_IDLE) || (tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_ERR_NOTIF)) && (tp_frm[DIAG_ISO15765_2_HDL].sts_tx != TP_FRM_TX_REQ))) {
/* Cas en que executem la transicio FunRequestEnd */
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else if ((tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_IN_PRG)) {
/* Cas en que executem la transicio RxInprogressWhilewaiting for TxConfirmation */
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_REQUESTINPROGRES;
}
else if ((pending_response == FALSE) && ( (tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF) )) {
/* Cas en que executem la transicio RxOKWhileWaitingTxConfirmation */
/* -- action de la transicio -- */
Iso15765_3Servicios();
response_sent = FALSE;
/* -- entry de l estat Responding -- */
if(tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; } if(tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; }
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING;
}
else if (temps_iso15765_3_requestrespondctrl >= TIMER_MS_TO_TICKS(MAX_TIME_ACTION)) {
/* Cas en que executem la transicio UnknowProblem */
/* -- action de la transicio -- */
Iso15765_3AbortResponse();
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else if ((pending_response == FALSE) && (tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_ERR_NOTIF)) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
Iso15765_3AbortResponse();
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat ExtTimeRespond.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| Sortides:
| estat_iso15765_3_requestrespondctrl
| temps_iso15765_3_requestrespondctrl
| tp_frm
| session_expired
****************************************************************************/
static void ExtTimeRespond(void)
{
if ((temps_iso15765_3_requestrespondctrl >= TIMER_MS_TO_TICKS(P2_EXT_MAX*10)) &&
((pending_response == FALSE) && ((tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_ERR_NOTIF) || (tp_frm[DIAG_ISO15765_2_HDL].sts_tx == TP_FRM_TX_IDLE)))) {
/* Cas en que executem la transicio TimerP2TimeOut */
/* -- action de la transicio -- */
Iso15765_3SendResponseSync(UDS_ERR_RESPONSE_PENDING);
p2extcounter++;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_EXTTIMERESPOND;
}
else if ((pending_response == TRUE) && (tp_frm[DIAG_ISO15765_2_HDL].sts_tx != TP_FRM_TX_REQ) && (pending_response_mode != UDS_ERR_RESPONSE_PENDING)) {
/* Cas en que executem la transicio FinalResponseAfterExtTime */
/* -- action de la transicio -- */
response_sent = FALSE;
/* -- entry de l estat Responding -- */
if(tp_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; } if(tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx == TP_FRM_RX_NOTIF){ tp_fun_frm[DIAG_ISO15765_2_HDL].sts_rx = TP_FRM_RX_IDLE; }
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_RESPONDING;
}
else if (p2extcounter > P2_EXT_MAX_COUNTER) {
/* Cas en que executem la transicio p2ExtTimesExhausted */
/* -- action de la transicio -- */
Iso15765_3AbortResponse();
/* Inicialitzacio del timer implicit */
temps_iso15765_3_requestrespondctrl= (t_clock)0;
/* -- canviem l estat -- */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_WAITINGREQUEST;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_requestrespondctrl = ESTAT_ISO15765_3_REQUESTRESPONDCTRL_EXTTIMERESPOND;
}
}
/********************************** FI **************************************/

View File

@ -0,0 +1,8 @@
#ifndef ISO15765_3_REQUESTRESPONDCTRL_H_
#define ISO15765_3_REQUESTRESPONDCTRL_H_
void Iso15765_3_RequestRespondCtrl(void);
#endif /* ISO15765_3_REQUESTRESPONDCTRL_H_ */

View File

@ -0,0 +1,805 @@
/*------------------------------- includes --------------------------------*/
//#include "Global.h"
#include "Std_Types.h"
//#include "Timer.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "Iso15765_3_Task.h"
#include "Iso15765_3.h"
//#include "Iso15765_3_CFG.h"
#include "DiagnosticL/UDS/Iso15765_layer3/Iso15765_3_CFG.h"
#define SECURED_DIAGNOSTICS_ENABLED ((UI_8)0x34)
#define SEC_NO_REQUEST ((UI_8)0)
#define SEC_REQUEST_SEED ((UI_8)1)
#define SEC_CHECK_KEY ((UI_8)2)
#define SEC_SESSION_CHANGED ((UI_8)3)
static UI_8 security_status = UDS_ECU_LOCKED;
static UI_8 force_unlock = UDS_ECU_LOCKED;
static UI_8 sec_request = SEC_NO_REQUEST;
static UI_8 key_type = 0;
static UI_8 seed_type = 0;
static BOOL key_ok = FALSE;
static BOOL consecutive_seed_requests = FALSE;
/*------------------------------ user code --------------------------------*/
UI_8 UdsSecurityTaskQueryAccessStatus(void)
{
return security_status;
}
BOOL UdsSecurityTaskQueryIfConsecutiveRequestSeed(void)
{
return consecutive_seed_requests;
}
static void SendZeroSeed(void)
{
UI_8 i;
tp_uds_security_access_seed_resp resp;
if (Iso15765_3QueryRequestSize() == (UI_16) 2) {
#ifdef ISO15765_3_GEELY
/* Check positive-response-not-requested flag,
* Suppress bit not supported in Geely */
if (iso15765_3_supress_pos_resp == FALSE) {
#endif
resp = ISO15765_3_GET_RESP_DATA(tp_uds_security_access_seed_resp);
resp->access_mode = seed_type;
for (i = 0; i < SECURITY_SEED_SIZE; i++) {
resp->seed[i] = (UI_8) 0;
}
Iso15765_3IncrementResponseSize((UI_8) 1 + SECURITY_SEED_SIZE);
Iso15765_3SendResponse(ISO15765_3_POSITIVE_RESPONSE);
#ifdef ISO15765_3_GEELY
} else {
/* Check positive-response-not-requested flag,
* Suppress bit not supported in Geely */
Iso15765_3SendResponse(UDS_ERR_REQUEST_OUT_OF_RANGE);
}
#endif
} else {
Iso15765_3SendResponse(UDS_ERR_INVALID_FORMAT);
}
}
void UdsSecurityTaskRequestSeed(UI_8 level)
{
/* Requesting seed */
sec_request = SEC_REQUEST_SEED;
/* Save the level to match with the correct send key level */
seed_type = level;
key_type = 0;
}
void UdsSecurityTaskCheckKey(UI_8 level, UI_8* key)
{
UI_8 i;
/* Send Key */
sec_request = SEC_CHECK_KEY;
key_type = level;
for (i = 0; i < SECURITY_KEY_SIZE; i++) {
security_control.host_key[i] = key[i];
}
}
void UDSSecurityTaskNotifySessionChanged(void)
{
sec_request = SEC_SESSION_CHANGED;
}
void UdsSecurityTaskForceLockState(UI_8 state)
{
force_unlock = state;
security_status = state;
}
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
typedef enum {
ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST = 1,
ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY = 2,
ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY = 3,
ESTAT_ISO15765_3_SECURITYTASK_UNLOCK = 4,
ESTAT_ISO15765_3_SECURITYTASK_CHECKKEY = 5,
ESTAT_ISO15765_3_SECURITYTASK_GETSEED = 6,
ESTAT_0_ISO15765_3_SECURITYTASK = 0
} t_estat_iso15765_3_securitytask;
/*------------------------------ variables --------------------------------*/
/* Variables d estat */
static t_estat_iso15765_3_securitytask estat_iso15765_3_securitytask = ESTAT_0_ISO15765_3_SECURITYTASK;
/* Timers implicits */
static t_clock temps_iso15765_3_securitytask = (t_clock) 0;
static UI_8 response = 0;
/*------------------------- capcaleres de funcions ------------------------*/
static void Iso15765_3_SecurityTask0(void);
static void Wait_Seed_Request(void);
static void Penalty_Delay(void);
static void Wait_Tool_Key(void);
static void Unlock(void);
static void Checkkey(void);
static void GetSeed(void);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats Iso15765_3_SecurityTask
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
void Iso15765_3_SecurityTaskInicialitza(void)
{
/* Inicialitzacio de la variable d estat */
estat_iso15765_3_securitytask = ESTAT_0_ISO15765_3_SECURITYTASK;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* Execucio del cicle inicial de la maquina d estats */
Iso15765_3_SecurityTask();
}
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats Iso15765_3_SecurityTask.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
void Iso15765_3_SecurityTask(void)
{
/* Estudi per casos del estat actual */
switch (estat_iso15765_3_securitytask) {
case ESTAT_0_ISO15765_3_SECURITYTASK:
Iso15765_3_SecurityTask0();
break;
case ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST:
Wait_Seed_Request();
break;
case ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY:
Penalty_Delay();
break;
case ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY:
Wait_Tool_Key();
break;
case ESTAT_ISO15765_3_SECURITYTASK_UNLOCK:
Unlock();
break;
case ESTAT_ISO15765_3_SECURITYTASK_CHECKKEY:
Checkkey();
break;
case ESTAT_ISO15765_3_SECURITYTASK_GETSEED:
GetSeed();
break;
default:
estat_iso15765_3_securitytask = ESTAT_0_ISO15765_3_SECURITYTASK;
break;
}
/* Increment del temps de cicle al timer implicit */
if (temps_iso15765_3_securitytask < MAX_COMPTADOR_TEMPS) {
temps_iso15765_3_securitytask += TimerDeltaCicleConsulta();
}
}
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces Iso15765_3_SecurityTask
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void Iso15765_3_SecurityTask0(void)
{
if (SECURITY_INIT_DELAY == SECURITY_NO_DELAY) {
/* Avaluem condicio de start del estat Wait_Seed_Request */
/* -- action de la transicio inicial -- */
seed_type = (UI_8) 0;
key_type = (UI_8) 0;
sec_request = SEC_NO_REQUEST;
Iso15765_3SecurityAttemptsInitialize();
force_unlock = UDS_ECU_LOCKED;
/* -- entry de l estat -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* Canviem l estat inicial */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if (SECURITY_INIT_DELAY == SECURITY_DELAY) {
/* Avaluem condicio de start del estat Penalty_Delay */
/* -- action de la transicio inicial -- */
seed_type = (UI_8) 0;
key_type = (UI_8) 0;
sec_request = SEC_NO_REQUEST;
Iso15765_3SecurityAttemptsInitialize();
/* -- entry de l estat -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* Canviem l estat inicial */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY;
} else {
/* No s ha activat cap condicio inicial: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_0_ISO15765_3_SECURITYTASK;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Wait_Seed_Request.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
static void Wait_Seed_Request(void)
{
/* -- during de l estat actual -- */
security_status = UDS_ECU_LOCKED;
if ((Iso15765_3SecurityAttemptsExceeded() == FALSE) && (sec_request == SEC_CHECK_KEY)) {
/* Cas en que executem la transicio Asking_Key_Wrong_State */
/* -- action de la transicio -- */
Iso15765_3SendResponse(UDS_ERR_REQUEST_SEQUENCE_ERROR);
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if ((Iso15765_3SecurityAttemptsExceeded() == FALSE) && (sec_request == SEC_REQUEST_SEED)) {
/* Cas en que executem la transicio Seed request */
/* -- action de la transicio -- */
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat GetSeed -- */
consecutive_seed_requests = FALSE;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_GETSEED;
} else if ((Iso15765_3SecurityAttemptsExceeded() == FALSE) && sec_request == SEC_SESSION_CHANGED) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if ((Iso15765_3SecurityAttemptsExceeded() == FALSE) && force_unlock != UDS_ECU_LOCKED) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
security_status = seed_type;
/* -- entry de l estat Unlock -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
} else if ((Iso15765_3SecurityAttemptsExceeded() == TRUE)) {
/* Cas en que executem la transicio */
/* -- entry de l estat Penalty_Delay -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY;
} else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Penalty_Delay.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
static void Penalty_Delay(void)
{
/* -- during de l estat actual -- */
if (sec_request != SEC_NO_REQUEST) {
if (sec_request != SEC_SESSION_CHANGED) {
if (sec_request == SEC_REQUEST_SEED) {
Iso15765_3SendResponse(UDS_ERR_REQUIRED_TIME_DELAY_NOT_EXPIRED);
} else {
/* Send key received */
Iso15765_3SendResponse(UDS_ERR_REQUEST_SEQUENCE_ERROR);
}
}
consecutive_seed_requests = FALSE;
sec_request = SEC_NO_REQUEST;
}
if (temps_iso15765_3_securitytask >= TIMER_MS_TO_TICKS(SECURITY_PENALTY_TIME)) {
/* Cas en que executem la transicio Penalty_Ended */
/* -- action de la transicio -- */
Iso15765_3SecurityAttemptsDecrement();
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Wait_Tool_Key.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
static void Wait_Tool_Key(void)
{
if ((Iso15765_3VariantConsecutiveSeedIncrAttempt() == TRUE) && (sec_request == SEC_REQUEST_SEED) && (Iso15765_3SecurityAttemptsReached() == FALSE) && (sec_request != SEC_SESSION_CHANGED)) {
/* Cas en que executem la transicio Asking_Seed_Wrong_State */
/* -- action de la transicio -- */
/* NRC does not apply, request seed to application again */
/* Parameter signals consectutive */
consecutive_seed_requests = TRUE;
response = UDS_SECURITY_REQUEST_SEED_CALLBACK(seed_type, security_control.local_seed);
Iso15765_3SecurityAttemptsIncrement();
Iso15765_3SendResponse(response);
/* -- entry de l estat Wait_Tool_Key -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY;
} else if (sec_request == SEC_SESSION_CHANGED) {
/* Cas en que executem la transicio Locked_due_to_session_change */
/* -- action de la transicio -- */
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if ((sec_request == SEC_CHECK_KEY) && (Iso15765_3QueryRequestSize() >= ((UI_16) 2 + SECURITY_KEY_SIZE)) && (sec_request != SEC_SESSION_CHANGED)) {
/* Cas en que executem la transicio Key Received */
/* -- action de la transicio -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_CHECKKEY;
} else if ((sec_request == SEC_CHECK_KEY) && (Iso15765_3QueryRequestSize() < ((UI_16) 2 + SECURITY_KEY_SIZE)) && (sec_request != SEC_SESSION_CHANGED)) {
/* Cas en que executem la transicio Key Received with wrong size */
/* -- action de la transicio -- */
Iso15765_3SendResponse(UDS_ERR_INVALID_FORMAT);
/* -- entry de l estat Wait_Tool_Key -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY;
} else if ((Iso15765_3VariantConsecutiveSeedIncrAttempt() == TRUE) && (sec_request == SEC_REQUEST_SEED) && (Iso15765_3SecurityAttemptsReached() == TRUE) && (sec_request != SEC_SESSION_CHANGED)) {
/* Cas en que executem la transicio AskingConsecutiveSeedCausesCounterToExceed */
/* -- action de la transicio -- */
/* NRC does not apply, request seed to application again */
/* Parameter signals consectutive */
consecutive_seed_requests = TRUE;
Iso15765_3SecurityAttemptsIncrement();
Iso15765_3SendResponse(UDS_ERR_REQUIRED_TIME_DELAY_NOT_EXPIRED);
/* -- entry de l estat Penalty_Delay -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY;
} else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Unlock.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
static void Unlock(void)
{
if (sec_request == SEC_SESSION_CHANGED) {
/* Cas en que executem la transicio Locked_due_to_session_change */
/* -- action de la transicio -- */
sec_request = SEC_NO_REQUEST;
force_unlock = UDS_ECU_LOCKED;
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if ((sec_request == SEC_REQUEST_SEED) && (seed_type == security_status)) {
/* Cas en que executem la transicio Seed_requested */
/* -- action de la transicio -- */
SendZeroSeed();
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat Unlock -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
} else if ((sec_request == SEC_CHECK_KEY)) {
/* Cas en que executem la transicio Send Key Unlocked */
/* -- action de la transicio -- */
Iso15765_3SendResponse(UDS_ERR_REQUEST_SEQUENCE_ERROR);
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat Unlock -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
} else if ((sec_request == SEC_REQUEST_SEED) && (seed_type != security_status)) {
/* Cas en que executem la transicio Another level required */
/* -- action de la transicio -- */
sec_request = SEC_NO_REQUEST;
/* -- entry de l estat GetSeed -- */
consecutive_seed_requests = FALSE;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_GETSEED;
} else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat Checkkey.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
static void Checkkey(void)
{
/* -- codi de l estat actual -- */
key_ok = UDS_SECURITY_CHECK_KEY_CALLBACK(key_type, security_control.local_seed,
security_control.host_key, &response);
if ((key_ok == TRUE) && ((response == ISO15765_3_POSITIVE_RESPONSE) || (response == UDS_ERR_RESPONSE_PENDING))) {
/* Cas en que executem la transicio Key Valid */
/* -- action de la transicio -- */
Iso15765_3SendResponse(response);
sec_request = SEC_NO_REQUEST;
Iso15765_3SecurityAttemptsClear();
security_status = seed_type;
/* -- entry de l estat Unlock -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
} else if ((security_status == UDS_ECU_LOCKED) && (key_ok == FALSE) && (Iso15765_3SecurityAttemptsReached() == FALSE)) {
/* Cas en que executem la transicio Key Invalid && ECU locked */
/* -- action de la transicio -- */
Iso15765_3SecurityAttemptsIncrement();
Iso15765_3SendResponse(UDS_ERR_INVALID_KEY);
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if ((key_ok == FALSE) && (Iso15765_3SecurityAttemptsReached() == TRUE)) {
/* Cas en que executem la transicio Key Invalid, max attempts reached */
/* -- action de la transicio -- */
Iso15765_3SecurityAttemptsIncrement();
Iso15765_3SendResponse(UDS_ERR_EXCEEDED_NUMBER_OF_ATTEMPTS);
/* -- entry de l estat Penalty_Delay -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_PENALTY_DELAY;
} else if ((response != ISO15765_3_POSITIVE_RESPONSE) && (response != UDS_ERR_INVALID_KEY) && (response != UDS_ERR_RESPONSE_PENDING) && (Iso15765_3SecurityAttemptsReached() == FALSE)) {
/* Cas en que executem la transicio Invalid key type */
/* -- action de la transicio -- */
Iso15765_3SendResponse(response);
/* -- entry de l estat Wait_Tool_Key -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY;
} else if ((security_status != UDS_ECU_LOCKED) && (key_ok == FALSE) && (Iso15765_3SecurityAttemptsReached() == FALSE)) {
/* Cas en que executem la transicio Key failed && ecu unlocked */
/* -- action de la transicio -- */
Iso15765_3SecurityAttemptsIncrement();
Iso15765_3SendResponse(response);
sec_request = SEC_NO_REQUEST;
seed_type = security_status;
/* -- entry de l estat Unlock -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
} else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_CHECKKEY;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat GetSeed.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| tool_key
| access_mode
| security_failed_attempts
| Sortides:
| estat_iso15765_3_securitytask
| temps_iso15765_3_securitytask
| local_seed
| security_failed_attempts
****************************************************************************/
static void GetSeed(void)
{
/* -- during de l estat actual -- */
response = UDS_SECURITY_REQUEST_SEED_CALLBACK(seed_type, security_control.local_seed);
if ((response == ISO15765_3_POSITIVE_RESPONSE) || (response == UDS_ERR_RESPONSE_PENDING)) {
/* Cas en que executem la transicio */
/* -- action de la transicio -- */
Iso15765_3SendResponse(response);
/* -- entry de l estat Wait_Tool_Key -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_TOOL_KEY;
} else if ((response != ISO15765_3_POSITIVE_RESPONSE) && (response != UDS_ERR_RESPONSE_PENDING) && (security_status == UDS_ECU_LOCKED)) {
/* Cas en que executem la transicio Wrong seed type */
/* -- action de la transicio -- */
Iso15765_3SendResponse(response);
/* -- entry de l estat Wait_Seed_Request -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_WAIT_SEED_REQUEST;
} else if ((response != ISO15765_3_POSITIVE_RESPONSE) && (response != UDS_ERR_RESPONSE_PENDING) && (security_status != UDS_ECU_LOCKED)) {
/* Cas en que executem la transicio Wrong seed access when unlocked */
/* -- action de la transicio -- */
Iso15765_3SendResponse(response);
/* -- entry de l estat Unlock -- */
sec_request = SEC_NO_REQUEST;
/* Inicialitzacio del timer implicit */
temps_iso15765_3_securitytask = (t_clock) 0;
/* -- canviem l estat -- */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_UNLOCK;
} else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_securitytask = ESTAT_ISO15765_3_SECURITYTASK_GETSEED;
}
}
/********************************** FI **************************************/

View File

@ -0,0 +1,299 @@
/*------------------------------- includes --------------------------------*/
//#include "Global.h"
#include "Std_Types.h"
//#include "Timer.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/Timer.h"
#include "Iso15765_3_Task.h"
#include "Iso15765_3.h"
#define SESSION_NO_REQUEST ((UI_8)0)
#define SESSION_DEFAULT ((UI_8)1)
#define SESSION_NOT_DEFAULT ((UI_8)2)
BOOL session_expired;
static UI_8 active_session;
static UI_8 active_session_mask;
static UI_8 session_request;
/*------------------------------ user code --------------------------------*/
UI_8 Iso15765_3QueryActiveSessionMask(void)
{
switch(active_session){
case UDS_DEFAULT_SESSION:
active_session_mask = UDS_DEFAULT_SESSION_MASK;
break;
case UDS_PROGRAMMING_SESSION:
active_session_mask = UDS_PROGRAMMING_SESSION_MASK;
break;
case UDS_EXT_DIAG_SESSION:
active_session_mask = UDS_EXT_DIAG_SESSION_MASK;
break;
case UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID:
active_session_mask = UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK;
break;
default:
active_session_mask = 0x00;/* There is an error in the session control */
break;
}
return active_session_mask;
}
void Iso15765_3ChangeActiveSession(UI_8 session_change)
{
active_session = session_change;
if ((session_change & UDS_SUBFUNCTION_MASK) != UDS_DEFAULT_SESSION)
{
session_request = SESSION_NOT_DEFAULT;
} else
{
session_request = UDS_DEFAULT_SESSION;
}
}
UI_8 Iso15765_3QueryActiveSession(void)
{
return active_session;
}
/*-------------------------------- macros ---------------------------------*/
/*------------------------------- defines ---------------------------------*/
/* Maxim valor del compteig del temps */
#define MAX_COMPTADOR_TEMPS ((UI_16)65000)
/*---------------------------- tipus de dades -----------------------------*/
typedef enum {
ESTAT_ISO15765_3_SESSIONCTRLTASK_DEFAULTSESSION = 1,
ESTAT_ISO15765_3_SESSIONCTRLTASK_NONDEFAULTSESSION = 2,
ESTAT_0_ISO15765_3_SESSIONCTRLTASK = 0
} t_estat_iso15765_3_sessionctrltask;
/*------------------------------ variables --------------------------------*/
/* Variables d estat */
static t_estat_iso15765_3_sessionctrltask estat_iso15765_3_sessionctrltask = ESTAT_0_ISO15765_3_SESSIONCTRLTASK;
/*------------------------- capcaleres de funcions ------------------------*/
static void Iso15765_3_SessionCtrlTask0(void);
static void DefaultSession(void);
static void NonDefaultSession(void);
/*----------------------- funcions d'inicialitzacio -----------------------*/
/****************************************************************************
| Funcionalitat:
| Inicialitzacio del diagrama d estats Iso15765_3_SessionCtrlTask
|----------------------------------------------------------------------------
| Interficie:
| Entrades: -
| Sortides:
| estat_iso15765_3_sessionctrltask
|
****************************************************************************/
void Iso15765_3_SessionCtrlTaskInicialitza(void)
{
/* Inicialitzacio de la variable d estat */
estat_iso15765_3_sessionctrltask = ESTAT_0_ISO15765_3_SESSIONCTRLTASK;
/* Execucio del cicle inicial de la maquina d estats */
Iso15765_3_SessionCtrlTask();
}
/*------------------------- rutines principals ---------------------------*/
/****************************************************************************
| Funcionalitat:
| Rutina principal del diagrama d estats Iso15765_3_SessionCtrlTask.
| Invoca a la funcio corresponent a l estat actual.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_sessionctrltask
|
| session_expired
| Sortides:
| estat_iso15765_3_sessionctrltask
|
****************************************************************************/
void Iso15765_3_SessionCtrlTask(void)
{
/* Estudi per casos del estat actual */
switch (estat_iso15765_3_sessionctrltask){
case ESTAT_0_ISO15765_3_SESSIONCTRLTASK:
Iso15765_3_SessionCtrlTask0();
break;
case ESTAT_ISO15765_3_SESSIONCTRLTASK_DEFAULTSESSION:
DefaultSession();
break;
case ESTAT_ISO15765_3_SESSIONCTRLTASK_NONDEFAULTSESSION:
NonDefaultSession();
break;
default:
estat_iso15765_3_sessionctrltask = ESTAT_0_ISO15765_3_SESSIONCTRLTASK;
break;
}
}
/*------------------------- funcions d'estats -----------------------------*/
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat inicial del proces Iso15765_3_SessionCtrlTask
|----------------------------------------------------------------------------
| Interficie: -
****************************************************************************/
static void Iso15765_3_SessionCtrlTask0(void)
{
/* Transicio per defecte */
/* -- entry de l estat -- */
session_expired = FALSE;
session_request = SESSION_NO_REQUEST;
active_session = UDS_DEFAULT_SESSION;
/* User Callback: Session being Initialized */
#ifdef UDS_INI_SESSION_CALLBACK
UDS_INI_SESSION_CALLBACK();
#endif
#ifdef UDS_SERVICE_SECURITY_ACCESS
//UDSSecurityTaskNotifySessionChanged();
#endif
/* Canviem l estat inicial */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_DEFAULTSESSION;
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat DefaultSession.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_sessionctrltask
|
| session_expired
| Sortides:
| estat_iso15765_3_sessionctrltask
|
****************************************************************************/
static void DefaultSession(void)
{
if (session_request == SESSION_NOT_DEFAULT) {
/* Cas en que executem la transicio ChangeToNonDefSession */
/* -- entry de l estat NonDefaultSession -- */
session_expired = FALSE;
session_request = SESSION_NO_REQUEST;
/* User Callback: Session being Initialized */
#ifdef UDS_INI_SESSION_CALLBACK
UDS_INI_SESSION_CALLBACK();
#endif
#ifdef UDS_SERVICE_SECURITY_ACCESS
//UDSSecurityTaskNotifySessionChanged();
#endif
/* -- canviem l estat -- */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_NONDEFAULTSESSION;
}
else if (session_request == SESSION_DEFAULT) {
/* Cas en que executem la transicio ReIniDefSession */
/* -- entry de l estat DefaultSession -- */
session_expired = FALSE;
session_request = SESSION_NO_REQUEST;
active_session = UDS_DEFAULT_SESSION;
/* User Callback: Session being Initialized */
#ifdef UDS_INI_SESSION_CALLBACK
UDS_INI_SESSION_CALLBACK();
#endif
#ifdef UDS_SERVICE_SECURITY_ACCESS
//UDSSecurityTaskNotifySessionChanged();
#endif
/* -- canviem l estat -- */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_DEFAULTSESSION;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_DEFAULTSESSION;
}
}
/****************************************************************************
| Funcionalitat:
| Funcio corresponent a l estat NonDefaultSession.
|----------------------------------------------------------------------------
| Interficie:
| Entrades:
| estat_iso15765_3_sessionctrltask
|
| session_expired
| Sortides:
| estat_iso15765_3_sessionctrltask
|
****************************************************************************/
static void NonDefaultSession(void)
{
if ((session_expired == TRUE) || (session_request == SESSION_DEFAULT)) {
/* Cas en que executem la transicio ChangeToDefSession */
/* -- entry de l estat DefaultSession -- */
session_expired = FALSE;
session_request = SESSION_NO_REQUEST;
active_session = UDS_DEFAULT_SESSION;
/* User Callback: Session being Initialized */
#ifdef UDS_INI_SESSION_CALLBACK
UDS_INI_SESSION_CALLBACK();
#endif
#ifdef UDS_SERVICE_SECURITY_ACCESS
//UDSSecurityTaskNotifySessionChanged();
#endif
/* -- canviem l estat -- */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_DEFAULTSESSION;
}
else if (session_request == SESSION_NOT_DEFAULT) {
/* Cas en que executem la transicio ChangeBetweenNonDefSessions */
/* -- entry de l estat NonDefaultSession -- */
session_expired = FALSE;
session_request = SESSION_NO_REQUEST;
/* User Callback: Session being Initialized */
#ifdef UDS_INI_SESSION_CALLBACK
UDS_INI_SESSION_CALLBACK();
#endif
#ifdef UDS_SERVICE_SECURITY_ACCESS
//UDSSecurityTaskNotifySessionChanged();
#endif
/* -- canviem l estat -- */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_NONDEFAULTSESSION;
}
else {
/* No s ha activat cap transicio: ens quedem a l estat actual */
estat_iso15765_3_sessionctrltask = ESTAT_ISO15765_3_SESSIONCTRLTASK_NONDEFAULTSESSION;
}
}
/********************************** FI **************************************/

View File

@ -0,0 +1,216 @@
#ifndef ISO15765_3_TASK_H_
#define ISO15765_3_TASK_H_
/*----------------------------- Icludes ----------------------------------*/
//#include "Global.h"
#include "Std_Types.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
/*----------------------------- Defines ----------------------------------*/
#if(UDS_SERVICE_SECURITY_ACCESS_STATUS==SERVICE_ENABLED)
/* Security Control */
#define SECURITY_DELAY ((UI_8)0)
#define SECURITY_NO_DELAY ((UI_8)1)
#endif
/*----------------------------- Globals ----------------------------------*/
extern BOOL session_expired;
/*-------------------------- Function Prototypes -------------------------*/
/* Response Control */
void Iso15765_3_RequestRespondCtrlInicialitza(void);
void Iso15765_3_RequestRespondCtrl(void);
void SessionChangeRequest(UI_8 session_change);
/* Session Control */
#ifdef UDS_SERVICE_SESSION_CONTROL
void Iso15765_3_SessionCtrlTaskInicialitza(void);
void Iso15765_3_SessionCtrlTask(void);
void UDSSecuritySessionChanged(void);
#endif
#ifdef UDS_SERVICE_ECU_RESET
void Iso15765_3_EcuResetTaskInicialitza(void);
void UDSResetRequest(UI_8 req_reset_type, UI_8 size);
#endif
/* Security Access */
#ifdef UDS_SERVICE_SECURITY_ACCESS
void Iso15765_3_SecurityTaskInicialitza(void);
void Iso15765_3_SecurityTask(void);
void UDSSecurityRequest(UI_8 req_acces_mode, UI_8* sec_buf);
void UDSSecuritySessionChanged(void);
void UdsSecurityTaskRequestSeed(UI_8 level);
void UdsSecurityTaskCheckKey(UI_8 level, UI_8* key);
void UDSSecurityTaskNotifySessionChanged(void);
void UdsSecurityTaskForceLockState(UI_8 state);
#endif
/* Reset Control */
#ifdef UDS_SERVICE_ECU_RESET
void Iso15765_3_SEcuResetTaskInicialitza(void);
void Iso15765_3_EcuResetTask(void);
void Iso15765_3_ResetRequest(UI_8 req_reset_type);
#endif
/*---------------- Configurable LIN Services Prototypes -------------------*/
#ifdef LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER
void LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK(UI_8 supplierID_LSB, UI_8 supplierID_MSB, UI_8 messageID_LSB, UI_8 messageID_MSB, UI_8 new_pid);
#endif
#ifdef LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER_RANGE
void LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK(UI_8 index, const UI_8* new_pid_list);
#endif
#ifdef LIN_SERVICE_READ_BY_IDENTIFIER
void LIN_READ_BY_IDENTIFIER_CALLBACK(UI_8 id);
#endif
#ifdef LIN_SERVICE_ASSIGN_NAD
void LIN_ASSIGN_NAD_CALLBACK(UI_16 supplierId, UI_16 functionId, UI_8 new_nad);
#endif
#ifdef LIN_SERVICE_CONDITIONAL_CHANGE_NAD
void LIN_CONDITIONAL_CHANGE_NAD_CALLBACK(UI_8 id, UI_8 byte, UI_8 mask, UI_8 invert, UI_8 new_nad);
#endif
/*---------------- Configurable UDS Services Prototypes -------------------*/
#ifdef UDS_INI_SESSION_CALLBACK
void UDS_INI_SESSION_CALLBACK(void);
#endif
#ifdef UDS_SERVICE_ECU_RESET
BOOL CHECK_RESET_POSSIBLE(UI_8 reset_type);
BOOL CHECK_RESET_TYPE(UI_8 reset_type);
void EXECUTE_RESET(UI_8 reset_type);
#endif
#ifdef UDS_SERVICE_SECURITY_ACCESS
UI_8 UDS_SECURITY_REQUEST_SEED_CALLBACK(UI_8 seed_type, UI_8* p_local_seed);
BOOL UDS_SECURITY_CHECK_KEY_CALLBACK(UI_8 key_type, UI_8* p_local_seed, UI_8* p_tool_key, UI_8* response);
#endif
#ifdef UDS_SERVICE_CONTROL_DTC_SETTING
void UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK(UI_8 dtc_setting_type, UI_8* buf_data_rx, UI_16 size);
#endif
#ifdef UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION
void UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK(UI_8 groupOfDTCHighByte, UI_8 groupOfDTCMiddleByte, UI_8 groupOfDTCLowByte);
#endif
#ifdef UDS_SERVICE_READ_DTC_INFORMATION
void UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK(UI_8 id, UI_8 *data, UI_16 size);
#endif
#ifdef UDS_SERVICE_READ_MEMORY_BY_ADDRESS
void UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK(UI_8 mem_size_len,
UI_8 mem_addr_len, UI_8* mem_addr, UI_8* mem_size);
#endif
#ifdef UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER
void UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK(UI_8 id_high, UI_8 id_low, UI_8* buf_data_rx, UI_16 size);
#endif
#ifdef UDS_SERVICE_READ_DATA_BY_IDENTIFIER
UI_8 UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK(UI_8 id_high, UI_8 id_low);
#endif
#ifdef UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS
void UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_CALLBACK(UI_8 data_len_format,
UI_8* p_buf, UI_16 size);
#endif
#ifdef UDS_SERVICE_IO_CTRL_BY_ID
void UdsInputOutputControlByIdentifier(UI_8 id_h, UI_8 id_l, UI_8 io_ctrl_type, UI_8* buf_data_rx, UI_16 size);
#endif
#ifdef UDS_SERVICE_ROUTINE_CONTROL
void UDS_SERVICE_ROUTINE_CONTROL_CALLBACK(UI_8 routine_ctrl_type, UI_8 id_high, UI_8 id_low, UI_8 *routine_entry_option, UI_16 size);
#endif
#ifdef UDS_SERVICE_COMMUNICATION_CONTROL
#ifndef ISO15765_3_GEELY
void UDS_COMMUNICATION_CONTROL_CALLBACK(UI_8 ctrl_type, UI_8 com_type);
#else
void UDS_COMMUNICATION_CONTROL_CALLBACK(UI_8 ctrl_type, UI_8 com_type, UI_8 size);
#endif
#endif
#ifdef UDS_REQUEST_DOWNLOAD_DEVICE_READY
BOOL UDS_REQUEST_DOWNLOAD_DEVICE_READY(UI_8 dev);
#endif
#ifdef UDS_REQUEST_DOWNLOAD_ERROR_CALLBACK
UI_8 UDS_REQUEST_DOWNLOAD_ERROR_CALLBACK(UI_8 error_code);
#endif
#ifdef DEVICE_0_REQUEST_DOWNLOAD_CALLBACK
UI_8 DEVICE_0_REQUEST_DOWNLOAD_CALLBACK(t_iso3_addr base_addr, t_iso3_addr last_addr);
#endif
#ifdef DEVICE_1_REQUEST_DOWNLOAD_CALLBACK
UI_8 DEVICE_1_REQUEST_DOWNLOAD_CALLBACK(t_iso3_addr base_addr, t_iso3_addr last_addr);
#endif
#ifdef DEVICE_2_REQUEST_DOWNLOAD_CALLBACK
UI_8 DEVICE_2_REQUEST_DOWNLOAD_CALLBACK(t_iso3_addr base_addr, t_iso3_addr last_addr);
#endif
#ifdef DEVICE_3_REQUEST_DOWNLOAD_CALLBACK
UI_8 DEVICE_3_REQUEST_DOWNLOAD_CALLBACK(t_iso3_addr base_addr, t_iso3_addr last_addr);
#endif
#ifdef DEVICE_0_TRANSFER_DATA_CALLBACK
UI_8 DEVICE_0_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef DEVICE_1_TRANSFER_DATA_CALLBACK
UI_8 DEVICE_1_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef DEVICE_2_TRANSFER_DATA_CALLBACK
UI_8 DEVICE_2_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef DEVICE_3_TRANSFER_DATA_CALLBACK
UI_8 DEVICE_3_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef UDS_TRANSFER_DATA_ERROR_CALLBACK
UI_8 UDS_TRANSFER_DATA_ERROR_CALLBACK(UI_8 error_code);
#endif
#ifdef DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK
UI_8 DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef DEVICE_1_REQUEST_TRANSFER_EXIT_CALLBACK
UI_8 DEVICE_1_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef DEVICE_2_REQUEST_TRANSFER_EXIT_CALLBACK
UI_8 DEVICE_2_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size);
#endif
#ifdef DEVICE_3_REQUEST_TRANSFER_EXIT_CALLBACK
UI_8 DEVICE_3_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size);
#endif
/*****************************************************************************
* Security attempts counter section
*****************************************************************************/
void Iso15765_3SecurityAttemptsIncrement(void); /*!< Function that increments the attempts counter */
void Iso15765_3SecurityAttemptsDecrement(void); /*!< Function that decrements the attempts counter, f.i. when penalty time expires */
BOOL Iso15765_3SecurityAttemptsExceeded(void); /*!< Function to determine if the allowed attempts have been exceeded */
BOOL Iso15765_3SecurityAttemptsReached(void); /*!< Function to determine if the allowed attempts have been reached (about to be exceeded on next try) */
void Iso15765_3SecurityAttemptsClear(void); /*!< Function to clear the attempt counter, f.i. when successful attempt is done */
void Iso15765_3SecurityAttemptsInitialize(void); /*!< Function to initialize the counter structure, loading (if defined) the NVM counter */
UI_8 Iso15765_3SecurityAttemptsGet(void); /*!< Accessor getter function for the counter */
/****************************************************************************
* Variant section
*****************************************************************************/
BOOL Iso15765_3VariantConsecutiveSeedIncrAttempt(void); /*!< Function to know if the UDS variant considers consecutive seed requests as failed security attempts */
#endif

View File

@ -0,0 +1,464 @@
/*************** COPYRIGHT (c) 2007-2011 FICOSA INTERNATIONAL **************
| Language: | MISRA C
| Controller: |
| Spec. Document: | ISO15765_3 ISO14229
|-----------------|------------------------------------------------------------
| Project: | Unified Diagnostics Services Layer
| Reference: |
|------------------------------------------------------------------------------
| HISTORY OF MODIFICATIONS
| Date - Coder - Description
| 25/02/10 AC File creation
| 21/06/12 DM Integrated with TP tag 20120530.
|------------------------------------------------------------------------------
| FILE DESCRIPTION:
| Implementacio dels serveis de diagnostics segons el standard ISO 15765-3
******************************************************************************/
#ifndef __UDSSERVERCALLBACKS_H
#define __UDSSERVERCALLBACKS_H
/* ------------------------------ Includes --------------------------------- */
#include "Global.h"
#include "Iso15765_3_CFG.h"
#include "ProjectCFG.h"
/* --------------------------- Type Definitions ---------------------------- */
/* ------------------------------- Defines --------------------------------- */
/* POSSIBLE START ROUTINE BY LOCAL ID TYPES */
#define START_ROUTINE_CONTROL ((UI_8)0x00)
#define REQUEST_ROUTINE_CONTROL ((UI_8)0x01)
/* POSSIBLE START ROUTINE BY LOCAL ID RESPONSE STATUS */
#define ROUTINE_IN_PROGRESS ((UI_8)1)
#define ROUTINE_COMPLETED_AND_OK ((UI_8)2)
#define ROUTINE_COMPLETED_AND_NO_OK ((UI_8)3)
#define ROUTINE_TO_BE_ANSWERED_BY_TELEM ((UI_8)4)
/* Reset types accepted with the EcuReset diagnostic service */
#define RESET_ALL_HW ((UI_8)0x01)
#define RESET_KEY_ON_OFF ((UI_8)0x02)
#define RESET_CONFIGURATION_PARAMETERS ((UI_8)0x40)
#define RESET_TEST_PARAMETERS ((UI_8)0x41)
#define RESET_TELEM ((UI_8)0x60)
#define RESET_PMC ((UI_8)0x61)
#define RESET_RTC ((UI_8)0x62)
#define RESET_WIFI ((UI_8)0x63)
/* SUPPORTED LOCAL DATA IDENTIFIERS FOR READDATABYLOCALID AND WRITEDATABYLOCAL SERVICES */
#define USER_COLLATION_R_ID ((UI_8)0x01)
/* LENGTH OF LOCAL DATA IDENTIFIERS FOR READDATABYID AND WRITEDATABYID SERVICES */
#define USER_COLLATION_R_LEN ((UI_8)100)
/* SUPPORTED DATA IDENTIFIERS FOR READDATABYID AND WRITEDATABYID SERVICES */
#define CURRENT_AND_VOLTAGE_STATUS_ID ((UI_16)0x0100)
#define TIP_HALL_SENSORS_STATUS_ID ((UI_16)0x0101)
#define DUAL_DIE_MELEXIS_ANGLE_STATUS_ID ((UI_16)0x0102)
#define PARKING_SWITCH_VOLTAGE_STATUS_ID ((UI_16)0x0103)
#define SHIFT_LOCK_FAIL_STATUS_ID ((UI_16)0x0104)
/* LENGTH OF DATA IDENTIFIERS FOR READDATABYID AND WRITEDATABYID SERVICES */
#define CURRENT_AND_VOLTAGE_STATUS_LEN ((UI_8)34)
#define TIP_HALL_SENSORS_STATUS_LEN ((UI_8)8)
#define DUAL_DIE_MELEXIS_ANGLE_STATUS_LEN ((UI_8)16)
#define PARKING_SWITCH_VOLTAGE_STATUS_LEN ((UI_8)4)
#define SHIFT_LOCK_FAIL_STATUS_LEN ((UI_8)1)
/* SUPPORTED LOCAL IDENTIFIERS FOR INPUTOUTPUTCONTROLBYLOCALID SERVICE */
#define SHIFTLOCK_ACTIVATION_IOCTRL_ID ((UI_8)0x01)
#define LED_M_ACTIVATION_IOCTRL_ID ((UI_8)0x02)
#define LED_D_ACTIVATION_IOCTRL_ID ((UI_8)0x03)
#define LED_N_ACTIVATION_IOCTRL_ID ((UI_8)0x04)
#define LED_R_ACTIVATION_IOCTRL_ID ((UI_8)0x05)
#define LED_P_ACTIVATION_IOCTRL_ID ((UI_8)0x06)
#define BACKLIGHT_ACTIVATION_IOCTRL_ID ((UI_8)0x07)
#define OVERLIGHT_ACTIVATION_IOCTRL_ID ((UI_8)0x08)
/* LENGTH OF LOCAL IDENTIFIERS FOR INPUTOUTPUTCONTROLBYLOCALID SERVICE */
#define SHIFTLOCK_IOCTRL_LEN ((UI_8)1)
#define LED_M_ACTIVATION_IOCTRL_LEN ((UI_8)1)
#define LED_D_ACTIVATION_IOCTRL_LEN ((UI_8)1)
#define LED_N_ACTIVATION_IOCTRL_LEN ((UI_8)1)
#define LED_R_ACTIVATION_IOCTRL_LEN ((UI_8)1)
#define LED_P_ACTIVATION_IOCTRL_LEN ((UI_8)1)
#define BACKLIGHT_ACTIVATION_IOCTRL_LEN ((UI_8)1)
#define OVERLIGHT_ACTIVATION_IOCTRL_LEN ((UI_8)1)
/* SUPPORTED LOCAL IDENTIFIERS FOR STARTROUTINEBYLOCALID SERVICE */
#define GLOBAL_CHECK_CONNECTION_SRBLID_ID ((UI_8)0x02)
/* LENGTH OF LOCAL IDENTIFIERS FOR STARTROUTINEBYLOCALID SERVICE */
#define GLOBAL_CHECK_CONNECTION_SRBLID_LEN ((UI_8)0)
/*--------------------------- Global variables ---------------------------- */
/* ------------------------- Function prototypes --------------------------- */
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands all the ReadDataByIdentifier diagnostics and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - id_h: higher byte of the identifier requested
| - id_h: lower byte of the identifier requested
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsReadDataByIdentifier(UI_8 id_h, UI_8 id_l);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands all the WriteDataByIdentifier diagnostics and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - id_h: higher byte of the identifier requested
| - id_h: lower byte of the identifier requested
| - data_buffer: data pointer of the received parameters for the write
| - size: length of the parameters received for the write
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsWriteDataByIdentifier(UI_8 id_h, UI_8 id_l, UI_8 *data_buffer, UI_16 size);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands all the RoutineControl diagnostics and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - routine_ctrl_type: type of the routine control requested. Can be a start,
| a stop or a request results
| - id: identifier requested
| - size: length of the parameters received for the write
| - routine_entry_option: data pointer of the received parameters for the write
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void StartRoutineByLocalId(UI_8 routine_ctrl_type, UI_8 id,
UI_16 size, UI_8 *routine_entry_option);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands UdsStopRoutineByLocalId diagnostic service and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - id: identifier of the DTC requested
| - size: length of the data received
| - data: data pointer to the buffer of the requested information
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void StopRoutineByLocalId(UI_8 id, UI_16 size, UI_8 *data);
/*****************************************************************************
| Portability:
|----------------------------------------------------------------------------
| Description:
| * Routine that updates Routine status.
|---------------------------------------------------------------------------
| Arguments:
| - id: identifier requested
| - status: status of the routine, allowed values:
| * ROUTINE_IN_PROGRESS
| * ROUTINE_COMPLETED_AND_OK
| * ROUTINE_COMPLETED_AND_NO_OK
| * ROUTINE_TO_BE_ANSWERED_BY_TELEM
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void StartRoutineUpdateStatusByLocalId(UI_8 id,UI_8 status);
/*****************************************************************************
| Portability:
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the ClearDiagnosticInfo diagnostic service and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - dtc_hb: higher byte of the requested clear dignostic type received
| - dtc_mb: medium byte of the requested clear dignostic type received
| - dtc_lb: lower byte of the requested clear dignostic type received
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsClearDiagnosticInformation(UI_8 dtc_hb, UI_8 dtc_mb, UI_8 dtc_lb);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsReadMemoryByAddress diagnostic service
| and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - mem_size_len: length of the requested size in bytes
| - mem_addr_len: length of the requested address in bytes
| - mem_addr: data pointer to the requested initial memory address to be read
| - mem_size: data pointer to the requested memory size to be read
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsReadMemoryByAddress(UI_8 mem_size_len, UI_8 mem_addr_len,
UI_8 *mem_addr, UI_8 *mem_size);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsWriteMemoryByAddress diagnostic service
| and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - addr_data_size: the first four bits cointains the data size length in
| bytes and the last four bits contains the address size
| length in bytes
| - data_buffer: data pointer where to find the requested initial write
| address, the requested write length and the values to write
| in memory
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsWriteMemoryByAddress(UI_8 addr_data_size, UI_8 *data_buffer);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Configured callback routine to be notified about the expiration of the
| previous non default session. This routine must undo all the special
| diagnostic features done during the especial session
|---------------------------------------------------------------------------
| Arguments:
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsReturnToDefaultSession(UI_8 old_session, UI_8 new_session);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsTesterPresent diagnostic service and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - tp_type: tester present type requested
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsTesterPresent(UI_8 tp_type);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsDiagnosticSessionControl diagnostic
| service and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - session: requested new session
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsDiagnosticSessionControl(UI_8 session);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the ReadDataByLocalIdentifier diagnostic
| service and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - id: identifier requested to read his data
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsRsaReadDataByLocalId(UI_8 id);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the WriteByLocalIdentifier diagnostic
| service and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - id: identifier of the data to be written
| - data: data pointer to the received parameters to be written
| - size: length of the data to be written
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsRsaWriteDataByLocalId(UI_8 id, UI_8 *data, UI_16 size);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the EcuReset diagnostic service and is responsible
| for giving the final answer to ISO_3 layer before performing the reset
|---------------------------------------------------------------------------
| Arguments:
| - reset_mode: type of reset requested
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsEcuReset(UI_8 reset_mode);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the InputOutputControlByLocalId diagnostic
| service and is responsible for giving the final answer to ISO_3 layer
|---------------------------------------------------------------------------
| Arguments:
| - id: identifier of the requested input output control
| - ctr_type: requested control type for the received id
| - size: length of the data received to control
| - data: data pointer to the received control data
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsInputOutputControlByIdentifier(UI_16 id, UI_8 ctr_type, UI_16 size, UI_8 *data);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * UdServices diagnostic initialitzation task. This routine should only
| be called one time at the microcontroller initialization
|---------------------------------------------------------------------------
| Arguments:
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsServerCallbacksInit(void);
/*****************************************************************************
| Portability: TCU Project
|----------------------------------------------------------------------------
| Description:
| * UdServices diagnostic task executed in every main cycle
|---------------------------------------------------------------------------
| Arguments:
|---------------------------------------------------------------------------
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsServerCallbacksTask(void);
/*************** Extra services example of implementation ******************/
#if (UDS_SERVICE_GEELY_ECHO_STATUS == SERVICE_ENABLED)
/**
* Extra services dispatcher. Will be executed in case of unrecognized service
* @param service current unrecognized service
* @param subfunction current unrecognized subfunction
* @param buf_data_rx rx data buffer with the request
* @param size size of the request
*/
void UdsExtraServices(UI_8 service,UI_8 subfunction,UI_8 *buf_data_rx, UI_8 size);
/**
* Geely ECHO service. It returns same data has received from the request
* @param data buffer data with the request
* @param size size of the request
* @return response mode
*/
UI_8 UdsGeelyEcho(UI_8 *data, UI_8 size);
#endif
#endif

View File

@ -0,0 +1,45 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef CALIBRATIONDATA_H_
#define CALIBRATIONDATA_H_
//#include "Calibration_Settings.h"
#ifdef CALIBRATION_ENABLED
/* Section data from linker script. */
extern char __CALIB_RAM_START;
extern char __CALIB_RAM_END;
extern char __CALIB_ROM_START;
#ifdef __CWCC__
#pragma section RW ".calibration_data" ".calibration"
#define ARC_DECLARE_CALIB(type, name) __declspec(section ".calibration_data") type name
#else
#define ARC_DECLARE_CALIB(type, name) type __attribute__((section (".calibration"))) name
#define ARC_DECLARE_CALIB_SHARED(type, name) type __attribute__((section (".calib_shared"))) name
#define ARC_DECLARE_CALIB_EXTERN(type, name) extern type name
#define ARC_DECLARE_CALIB_COMPONENT(type, name) type __attribute__((section (".calib_component"))) name
#endif/* __CWCC__ */
#else
#define ARC_DECLARE_CALIB(type, name) type name
#define ARC_DECLARE_CALIB_SHARED(type, name) type name
#define ARC_DECLARE_CALIB_EXTERN(type, name) extern type name
#define ARC_DECLARE_CALIB_COMPONENT(type, name) type name
#endif /* CALIBRATION_ENABLED */
#endif /* CALIBRATIONDATA_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,240 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef DEM_H_
#define DEM_H_
//#include "Modules.h"
/* @req DEM628 */
#define DEM_MODULE_ID MODULE_ID_DEM
#define DEM_VENDOR_ID VENDOR_ID_ARCCORE
#define DEM_AR_RELEASE_MAJOR_VERSION 4u
#define DEM_AR_RELEASE_MINOR_VERSION 0u
#define DEM_AR_RELEASE_REVISION_VERSION 3u
#define DEM_SW_MAJOR_VERSION 5u
#define DEM_SW_MINOR_VERSION 14u
#define DEM_SW_PATCH_VERSION 0u
#define DEM_AR_MAJOR_VERSION DEM_AR_RELEASE_MAJOR_VERSION
#define DEM_AR_MINOR_VERSION DEM_AR_RELEASE_MINOR_VERSION
#define DEM_AR_PATCH_VERSION DEM_AR_RELEASE_REVISION_VERSION
#include "Dem_Types.h"
#include "DiagnosticL/Dem/Dem_Cfg.h"
#include "DiagnosticL/Dem/Dem_Lcfg.h"
#include "DiagnosticL/Dem/Dem_IntErrId.h" /** @req DEM115 */
#include "DiagnosticL/Dem/Dem_IntEvtId.h"
#include "DiagnosticL/rte/Rte_Dem_Type.h"
//#include "Dem_EnableCondId.h"
#include <limits.h>
/** @req DEM153 */ /** @req DEM154 */ /* Realized in Dem_IntErrId.h and Dem_IntEvtId.h */
// #include "Rte_Dem.h"
#if (DEM_DEV_ERROR_DETECT == STD_ON)
// Error codes reported by this module defined by AUTOSAR /** @req DEM116 */ /** @req DEM173 */
#define DEM_E_PARAM_CONFIG 0x10u
#define DEM_E_PARAM_POINTER 0x11u
#define DEM_E_PARAM_DATA 0x12u
#define DEM_E_PARAM_LENGTH 0x13u
#define DEM_E_UNINIT 0x20u
#define DEM_E_NODATAAVAILABLE 0x30u
#define DEM_E_WRONG_CONDITION 0x40u
// Other error codes reported by this module
#define DEM_E_CONFIG_PTR_INVALID 0x50u
#define DEM_E_EXT_DATA_TOO_BIG 0x52u
#define DEM_E_PRE_INIT_EXT_DATA_BUFF_FULL 0x53u
#define DEM_E_MEM_EVENT_BUFF_FULL 0x54u
#define DEM_E_MEM_EXT_DATA_BUFF_FULL 0x55u
#define DEM_E_FF_TOO_BIG 0x56u
#define DEM_E_PRE_INIT_FF_DATA_BUFF_FULL 0x57u
#define DEM_E_MEM_FF_DATA_BUFF_FULL 0x58u
#define DEM_E_OBD_NOT_ALLOWED_IN_SEC_MEM 0x59u
#define DEM_E_MEMORY_CORRUPT 0x5Au
#define DEM_E_SEQUENCE_ERROR 0xfdu
#define DEM_E_UNEXPECTED_EXECUTION 0xfeu
#define DEM_E_NOT_IMPLEMENTED_YET 0xffu
// Service ID in this module
#define DEM_PREINIT_ID 0x01u
#define DEM_INIT_ID 0x02u
#define DEM_SHUTDOWN_ID 0x03u
#define DEM_SETEVENTSTATUS_ID 0x04u
#define DEM_RESETEVENTSTATUS_ID 0x05u
#define DEM_SETOPERATIONCYCLESTATE_ID 0x08u
#define DEM_GETEVENTSTATUS_ID 0x0Au
#define DEM_GETEVENTFAILED_ID 0x0Bu
#define DEM_GETEVENTTESTED_ID 0x0Cu
#define DEM_GETDTCOFEVENT_ID 0x0Du
#define DEM_GETSEVERITYOFDTC_ID 0x0Eu
#define DEM_REPORTERRORSTATUS_ID 0x0Fu
#define DEM_SETDTCFILTER_ID 0x13u
#define DEM_GETSTATUSOFDTC_ID 0x15u
#define DEM_GETDTCSTATUSAVAILABILITYMASK_ID 0x16u
#define DEM_GETNUMBEROFFILTEREDDTC_ID 0x17u
#define DEM_GETNEXTFILTEREDDTC_ID 0x18u
#define DEM_DISABLEDTCRECORDUPDATE_ID 0x1Au
#define DEM_ENABLEDTCRECORDUPDATE_ID 0x1Bu
#define DEM_GETFREEZEFRAMEDATABYDTC_ID 0x1Du
#define DEM_GETSIZEOFFREEZEFRAMEBYDTC_ID 0x1Fu
#define DEM_GETEXTENDEDDATARECORDBYDTC_ID 0x20u
#define DEM_GETSIZEOFEXTENDEDDATARECORDBYDTC_ID 0x21u
#define DEM_CLEARDTC_ID 0x22u
#define DEM_DISABLEDTCSETTING_ID 0x24u
#define DEM_ENABLEDTCSETTING_ID 0x25u
#define DEM_GETINDICATORSTATUS_ID 0x29u
#define DEM_GETEVENTEXTENDEDDATARECORD_ID 0x30u
#define DEM_GETEVENTFREEZEFRAMEDATA_ID 0x31u
#define DEM_GETEVENTMEMORYOVERFLOW_ID 0x32u
#define DEM_SETDTCSUPPRESSION_ID 0x33u
#define DEM_SETEVENTAVAILABLE_ID 0x37u /* ASR 4.2.2 API */
#define DEM_GETNEXTFILTEREDRECORD_ID 0x3au
#define DEM_GETTRANSLATIONTYPE_ID 0x3cu
#define DEM_SETENABLECONDITION_ID 0x39u
#define DEM_GETFAULTDETECTIONCOUNTER_ID 0x3Eu
#define DEM_SETFREEZEFRAMERECORDFILTER_ID 0x3Fu
#define DEM_DLTGETALLEXTENDEDDATARECORDS_ID 0x40u
#define DEM_DLTGETMOSTRECENTFREEZEFRAMERECORDDATA_ID 0x41u
#define DEM_READDATAOFOBDFREEZEFRAME_ID 0X52u
#define DEM_GETDTCOFOBDFREEZEFRAME_ID 0x53u
#define DEM_MAINFUNCTION_ID 0x55u
#define DEM_UPDATE_EVENT_STATUS_ID 0x80u
#define DEM_MERGE_EVENT_STATUS_ID 0x81u
#define DEM_GET_EXTENDED_DATA_ID 0x82u
#define DEM_STORE_EXT_DATA_PRE_INIT_ID 0x83u
#define DEM_STORE_EVENT_MEM_ID 0x84u
#define DEM_STORE_EXT_DATA_MEM_ID 0x85u
#define DEM_PREDEBOUNCE_NONE_ID 0x86u
#define DEM_PREDEBOUNCE_COUNTER_BASED_ID 0x87u
#define DEM_GET_FREEZEFRAME_ID 0x88u
#define DEM_STORE_FF_DATA_PRE_INIT_ID 0x89u
#define DEM_STORE_FF_DATA_MEM_ID 0x90u
#define DEM_DSP_DID_USE_PORT_IS_TRUE 0x91u
#define DEM_READ_DATA_LENGTH_FAILED 0x92u
#define DEM_GLOBAL_ID 0xffu
#endif
#define DEM_MAX_TIMESTAMP_FOR_REARRANGEMENT UINT32_MAX //when timestamp up to the max value,rearrangement starts.
#define DEM_MAX_TIMESTAMP_FOR_PRE_INIT (uint32)(UINT32_MAX/2)
/*
* Interface for upper layer modules
*/
#if ( DEM_VERSION_INFO_API == STD_ON ) /** @req DEM111 */
#define Dem_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,DEM) /** @req DEM177 */ /** @req DEM110 */
#endif /* DEM_VERSION_INFO_API */
/*
* Interface ECU State Manager <-> DEM
*/
void Dem_PreInit( const Dem_ConfigType *ConfigPtr ); /** @req DEM179 */
void Dem_Init( void ); /** @req DEM181 */
void Dem_Shutdown( void ); /** @req DEM182 */
/*
* Interface for basic software scheduler
*/
void Dem_MainFunction( void ); /** @req DEM266 */
/*
* Interface BSW modules/SW-Components via RTE <-> DEM
*/
void Dem_ReportErrorStatus(Dem_EventIdType eventId ,Dem_EventStatusType eventStatus); /** @req DEM206 */
#if !defined(USE_RTE)
Std_ReturnType Dem_SetEventStatus(Dem_EventIdType eventId, Dem_EventStatusType eventStatus);
Std_ReturnType Dem_ResetEventStatus(Dem_EventIdType eventId);
#endif
Std_ReturnType Dem_SetOperationCycleState(Dem_OperationCycleIdType operationCycleId, Dem_OperationCycleStateType cycleState); /** @req DEM194 */
Std_ReturnType Dem_GetEventStatus(Dem_EventIdType eventId, Dem_EventStatusExtendedType *eventStatusExtended); /** @req DEM195 */
Std_ReturnType Dem_GetEventFailed(Dem_EventIdType eventId, boolean *eventFailed); /** @req DEM196 */
Std_ReturnType Dem_GetEventTested(Dem_EventIdType eventId, boolean *eventTested); /** @req DEM197 */
Std_ReturnType Dem_GetDTCOfEvent(Dem_EventIdType eventId, Dem_DTCFormatType dtcFormat, uint32* dtcOfEvent); /** @req DEM198 */
#if (DEM_ENABLE_CONDITION_SUPPORT == STD_ON)
Std_ReturnType Dem_SetEnableCondition(uint8 EnableConditionID, boolean ConditionFulfilled); /** @req DEM201*/
#endif
Std_ReturnType Dem_GetFaultDetectionCounter(Dem_EventIdType eventId, sint8 *counter); /** @req DEM203 */
Std_ReturnType Dem_GetIndicatorStatus( uint8 IndicatorId, Dem_IndicatorStatusType* IndicatorStatus ); /* @req DEM205 */
Std_ReturnType Dem_GetEventFreezeFrameData(Dem_EventIdType EventId, uint8 RecordNumber, boolean ReportTotalRecord, uint16 DataId, uint8* DestBuffer);/* @req DEM558 */
Std_ReturnType Dem_GetEventExtendedDataRecord(Dem_EventIdType EventId, uint8 RecordNumber, uint8* DestBuffer);/* @req DEM557 */
Std_ReturnType Dem_GetEventMemoryOverflow(Dem_DTCOriginType DTCOrigin, boolean *OverflowIndication); /* @req DEM559 */
#if (DEM_DTC_SUPPRESSION_SUPPORT == STD_ON)
Std_ReturnType Dem_SetDTCSuppression(uint32 DTC, Dem_DTCFormatType DTCFormat, boolean SuppressionStatus);/* @req 4.2.2/SWS_Dem_01047 *//* @req DEM583 */
#endif
Std_ReturnType Dem_SetEventAvailable(Dem_EventIdType EventId, boolean AvailableStatus);/* @req 4.2.2/SWS_Dem_01080 */
/*
* Interface DCM <-> DEM
*/
/* Access DTCs and status information */
Dem_ReturnSetFilterType Dem_SetDTCFilter(uint8 dtcStatusMask, Dem_DTCKindType dtcKind, Dem_DTCFormatType dtcFormat, Dem_DTCOriginType dtcOrigin, Dem_FilterWithSeverityType filterWithSeverity, Dem_DTCSeverityType dtcSeverityMask, Dem_FilterForFDCType filterForFaultDetectionCounter); /** @req DEM208 */
Dem_ReturnSetFilterType Dem_SetFreezeFrameRecordFilter(Dem_DTCFormatType dtcFormat, uint16 *NumberOfFilteredRecords);/* @req DEM209 */
Dem_ReturnGetStatusOfDTCType Dem_GetStatusOfDTC(uint32 dtc, Dem_DTCOriginType dtcOrigin, Dem_EventStatusExtendedType* status); /** @req DEM212 */
Std_ReturnType Dem_GetDTCStatusAvailabilityMask(uint8 *dtcStatusMask); /** @req DEM213 */
Dem_ReturnGetNumberOfFilteredDTCType Dem_GetNumberOfFilteredDtc(uint16* numberOfFilteredDTC); /** @req DEM214 */
Dem_ReturnGetNextFilteredDTCType Dem_GetNextFilteredDTC(uint32* dtc, Dem_EventStatusExtendedType* dtcStatus); /** @req DEM215 */
Dem_ReturnGetNextFilteredDTCType Dem_GetNextFilteredRecord(uint32 *DTC, uint8 *RecordNumber); /* @req DEM224 */
Dem_DTCTranslationFormatType Dem_GetTranslationType(void); /** @req DEM230 */
Dem_ReturnGetSeverityOfDTCType Dem_GetSeverityOfDTC(uint32 DTC, Dem_DTCSeverityType* DTCSeverity);/** @req DEM232 */
/* Access extended data records and FreezeFrame data */
Dem_ReturnDisableDTCRecordUpdateType Dem_DisableDTCRecordUpdate(uint32 DTC, Dem_DTCOriginType DTCOrigin);/* @req DEM233 */
Std_ReturnType Dem_EnableDTCRecordUpdate(void);/* @req DEM234 */
Dem_ReturnGetFreezeFrameDataByDTCType Dem_GetFreezeFrameDataByDTC(uint32 dtc, Dem_DTCOriginType dtcOrigin,uint8 recordNumber, uint8* destBuffer, uint16* bufSize);/** @req DEM236 */
Dem_ReturnGetSizeOfFreezeFrameType Dem_GetSizeOfFreezeFrameByDTC(uint32 dtc, Dem_DTCOriginType dtcOrigin, uint8 recordNumber, uint16* sizeOfFreezeFrame);/** @req DEM238 */
Dem_ReturnGetExtendedDataRecordByDTCType Dem_GetExtendedDataRecordByDTC(uint32 dtc, Dem_DTCOriginType dtcOrigin, uint8 extendedDataNumber, uint8 *destBuffer, uint16 *bufSize); /** @req DEM239 */
Dem_ReturnGetSizeOfExtendedDataRecordByDTCType Dem_GetSizeOfExtendedDataRecordByDTC(uint32 dtc, Dem_DTCOriginType dtcOrigin, uint8 extendedDataNumber, uint16 *sizeOfExtendedDataRecord); /** @req DEM240 */
/* DTC storage */
#if !defined(USE_RTE)
Dem_ReturnClearDTCType Dem_ClearDTC(uint32 dtc, Dem_DTCFormatType dtcFormat, Dem_DTCOriginType dtcOrigin); /** @req DEM241 */
#endif
Dem_ReturnControlDTCStorageType Dem_DisableDTCSetting(Dem_DTCGroupType dtcGroup, Dem_DTCKindType dtcKind); /** @req DEM242 */
Dem_ReturnControlDTCStorageType Dem_EnableDTCSetting(Dem_DTCGroupType dtcGroup, Dem_DTCKindType dtcKind); /** @req DEM243 */
/*
* OBD-specific Interfaces
*/
Std_ReturnType Dem_ReadDataOfOBDFreezeFrame(uint8 PID, uint8 DataElementIndexOfPid, uint8* DestBuffer, uint8* BufSize);/* @req DEM327 */
Std_ReturnType Dem_GetDTCOfOBDFreezeFrame(uint8 FrameNumber, uint32* DTC );/* @req DEM624 */
/*
* Interface DLT <-> DEM
*/
#if (DEM_TRIGGER_DLT_REPORTS == STD_ON)
Std_ReturnType Dem_DltGetAllExtendedDataRecords(Dem_EventIdType EventId, uint8* DestBuffer, uint8* BufSize); /** @req DEM637 */
Std_ReturnType Dem_DltGetMostRecentFreezeFrameRecordData(Dem_EventIdType EventId, uint8* DestBuffer, uint8* BufSize);/** @req DEM636 */
#endif
#endif /*DEM_H_*/

View File

@ -0,0 +1,9 @@
#Dem
obj-$(USE_DEM) += Dem.o
ifeq ($(filter Dem_Extension.o,$(obj-y)),)
obj-$(USE_DEM_EXTENSION) += Dem_Extension.o
endif
obj-$(USE_DEM) += Dem_Debounce.o
obj-$(USE_DEM) += Dem_LCfg.o
inc-$(USE_DEM) += $(ROOTDIR)/diagnostic/Dem
vpath-$(USE_DEM) += $(ROOTDIR)/diagnostic/Dem

View File

@ -0,0 +1,254 @@
/*
* Generator version: 5.14.0
* AUTOSAR version: 4.0.3
*/
#include "DiagnosticL/ProjectCfg.h"
#if !(((DEM_SW_MAJOR_VERSION == 5) && (DEM_SW_MINOR_VERSION == 14)) )
//#error Dem: Configuration file expected BSW module version to be 5.14.*
#endif
#if !(((DEM_AR_RELEASE_MAJOR_VERSION == 4) && (DEM_AR_RELEASE_MINOR_VERSION == 0)) )
//#error DEM: Configuration file expected AUTOSAR version to be 4.0.*
#endif
#ifndef DEM_CFG_H_
#define DEM_CFG_H_
#define DEM_VERSION_INFO_API STD_OFF
#define DEM_DEV_ERROR_DETECT STD_ON
#define DEM_TRIGGER_DLT_REPORTS STD_OFF
#define DEM_OBD_SUPPORT STD_OFF
#define DEM_PTO_SUPPORT STD_OFF
#define DEM_TYPE_OF_DTC_SUPPORTED DEM_DTC_TRANSLATION_ISO14229_1
#define DEM_CLEAR_ALL_EVENTS STD_OFF
#define DEM_USE_NVM STD_ON
#define DEM_MAX_NUMBER_EVENT_ENTRY_MIR 0u
#define DEM_MAX_NUMBER_EVENT_ENTRY_PER 0u
#define DEM_MAX_NUMBER_EVENT_ENTRY_PRI 40u
#define DEM_MAX_NUMBER_EVENT_ENTRY_SEC 1u
#define DEM_MAX_NUMBER_EVENT_ENTRY MAX(DEM_MAX_NUMBER_EVENT_ENTRY_PRI, DEM_MAX_NUMBER_EVENT_ENTRY_SEC)
#define DEM_USE_PRIMARY_MEMORY_SUPPORT STD_ON
#define DEM_USE_SECONDARY_MEMORY_SUPPORT STD_OFF
#define DEM_MAX_NUMBER_PRESTORED_FF 0u /* Max nr of prestored FreezeFrames. 0=Not supported. */
#define DEM_DTC_STATUS_AVAILABILITY_MASK 127
#define DEM_TEST_FAILED_STORAGE STD_ON
#define DEM_NUM_ENABLECONDITIONS 0u
/* @req DEM444 */
#define DEM_ENABLE_CONDITION_SUPPORT STD_OFF
/* @req DEM401 */
#define DEM_EVENT_DISPLACEMENT_SUPPORT STD_OFF
#define DEM_STORE_UDS_STATUS_BIT_SUBSET_FOR_ALL_EVENTS STD_OFF
#define DEM_DTC_SUPPRESSION_SUPPORT STD_ON
#define DEM_NOF_DTCS 16u
#define DEM_SET_EVENT_AVAILABLE_PREINIT STD_OFF
/* Freeze frame capture *//* @req DEM461 */
#define DEM_FREEZE_FRAME_CAPTURE_TESTFAILED
/* Extended data capture *//* @req DEM467 */
#define DEM_EXTENDED_DATA_CAPTURE_TESTFAILED
/*
* Size limitations of the types derived from DemGeneral
*/
#define DEM_MAX_NR_OF_RECORDS_IN_EXTENDED_DATA 5u /* 0..253 according to Autosar */
#define DEM_MAX_NR_OF_EVENT_DESTINATION 1u /* 0..4 according to Autosar */
#define DEM_MAX_NR_OF_DIDS_IN_FREEZEFRAME_DATA 5u /* Maximum number of dids referred by one freeze frame */
#define DEM_MAX_NR_OF_PIDS_IN_FREEZEFRAME_DATA 0u
/*
* Size limitations of storage area
*/
/* Maximum number of freeze frame record numbers one event may have */
#define DEM_MAX_RECORD_NUMBERS_IN_FF_REC_NUM_CLASS 2
#define DEM_MAX_SIZE_FF_DATA 18u /* Max number of bytes in one freeze frame */
#define DEM_MAX_SIZE_EXT_DATA 5u /* Max number of bytes in one extended data record */
#define DEM_MAX_NUMBER_EVENT 22u /* Max number of events to keep status on */
#define DEM_MAX_NUMBER_FF_DATA_PRE_INIT 2u /* Max number of freeze frames to store before init */
#define DEM_MAX_NUMBER_EXT_DATA_PRE_INIT 16u /* Max number of extended data to store before init */
/* Primary Memory */
/* @req DEM162 */
#define DEM_MAX_NUMBER_EVENT_PRI_MEM (DEM_MAX_NUMBER_EVENT_ENTRY_PRI) /* Max number of events status to store in primary memory */
#define DEM_PRI_MEM_EVENT_BUFFER_SIZE 328u /* Size of priMemEventBuffer */
#define DEM_MAX_NUMBER_FF_DATA_PRI_MEM 32u /* Maximum number of freeze frame records to store in primary memory */
#define DEM_PRI_MEM_FREEZEFRAME_BUFFER_SIZE 768u /* Size of priMemFreezeFrameBuffer */
#define DEM_MAX_NUMBER_EXT_DATA_PRI_MEM 40u /* Max number of extended data to store in primary memory */
#define DEM_PRI_MEM_EXTDATA_BUFFER_SIZE 320u /* Size of priMemExtDataBuffer */
/* Secondary memory */
#define DEM_MAX_NUMBER_EVENT_SEC_MEM (DEM_MAX_NUMBER_EVENT_ENTRY_SEC) /* Max number of events status to store in secondary memory */
#define DEM_SEC_MEM_EVENT_BUFFER_SIZE 8u /* Size of secMemEventBufferBuffer */
#define DEM_MAX_NUMBER_FF_DATA_SEC_MEM 0u /* Maximum number of freeze frame records to store in secondary memory */
#define DEM_SEC_MEM_FREEZEFRAME_BUFFER_SIZE 0u /* Size of secMemFreezeFrameBuffer */
#define DEM_MAX_NUMBER_EXT_DATA_SEC_MEM 1u /* Max number of extended data to store in secondary memory */
#define DEM_SEC_MEM_EXTDATA_BUFFER_SIZE 8u /* Size of secMemExtDataBuffer */
#define DEM_FREEZEFRAME_DEFAULT_VALUE 0xFFu
#define DEM_DID_IDENTIFIER_SIZE_OF_BYTES 2u
#define DEM_FREEZEFRAME_RECORD_NUMBER_EOL 0xFFu
#define DEM_HIGHEST_EXT_DATA_REC_NUM 5u
#define DEM_HIGHEST_FF_REC_NUM 2u
/* Indicators */
#define DEM_NOF_INDICATORS 0u
#define DEM_MIL_INIDICATOR_ID DEM_INVALID_INDICATOR
#define DEM_NOF_EVENT_INDICATORS 0u
#define DEM_INVALID_INDICATOR_INDEX DEM_NOF_EVENT_INDICATORS
#define DEM_MEM_INDICATOR_BUFFER_SIZE 0u
/* NvM handles and blocks sizes*/
#define DEM_EVENT_PRIMARY_NVM_BLOCK_SIZE 328
//#define DEM_EVENT_PRIMARY_NVM_BLOCK_HANDLE NVM_DemPriEventBlock_HANDLE
#if (DEM_EVENT_PRIMARY_NVM_BLOCK_SIZE != DEM_PRI_MEM_EVENT_BUFFER_SIZE)
#error Dem: Configured NvM block (DemPriEventBlock) does not match size of priMemEventBuffer
#endif
#define DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_SIZE 768
//#define DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_HANDLE NVM_DemPriFreezeFrameBlock_HANDLE
#if (DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_SIZE != DEM_PRI_MEM_FREEZEFRAME_BUFFER_SIZE)
#error Dem: Configured NvM block (DemPriFreezeFrameBlock) does not match size of priMemFreezeFrameBuffer
#endif
#define DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_SIZE 320
#define DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_HANDLE NVM_DemPriExtendedDataBlock_HANDLE
#if (DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_SIZE != DEM_PRI_MEM_EXTDATA_BUFFER_SIZE)
#error Dem: Configured NvM block (DemPriExtendedDataBlock) does not match size of priMemExtDataBuffer
#endif
#ifndef DEM_EVENT_PRIMARY_NVM_BLOCK_SIZE
#define DEM_EVENT_PRIMARY_NVM_BLOCK_SIZE 0u
#endif
#ifndef DEM_EVENT_SECONDARY_NVM_BLOCK_SIZE
#define DEM_EVENT_SECONDARY_NVM_BLOCK_SIZE 0u
#endif
#ifndef DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_SIZE
#define DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_SIZE 0u
#endif
#ifndef DEM_FREEZE_FRAME_SECONDARY_NVM_BLOCK_SIZE
#define DEM_FREEZE_FRAME_SECONDARY_NVM_BLOCK_SIZE 0u
#endif
#ifndef DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_SIZE
#define DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_SIZE 0u
#endif
#ifndef DEM_EXTENDED_DATA_SECONDARY_NVM_BLOCK_SIZE
#define DEM_EXTENDED_DATA_SECONDARY_NVM_BLOCK_SIZE 0u
#endif
#ifndef DEM_EVENT_PRIMARY_NVM_BLOCK_HANDLE
#define DEM_EVENT_PRIMARY_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_EVENT_SECONDARY_NVM_BLOCK_HANDLE
#define DEM_EVENT_SECONDARY_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_HANDLE
#define DEM_FREEZE_FRAME_PRIMARY_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_FREEZE_FRAME_SECONDARY_NVM_BLOCK_HANDLE
#define DEM_FREEZE_FRAME_SECONDARY_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_HANDLE
#define DEM_EXTENDED_DATA_PRIMARY_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_EXTENDED_DATA_SECONDARY_NVM_BLOCK_HANDLE
#define DEM_EXTENDED_DATA_SECONDARY_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_INDICATOR_NVM_BLOCK_HANDLE
#define DEM_INDICATOR_NVM_BLOCK_HANDLE 0u
#endif
#ifndef DEM_STATUSBIT_NVM_BLOCK_HANDLE
#define DEM_STATUSBIT_NVM_BLOCK_HANDLE 0u
#endif
#define DEM_DISPLACEMENT_PROCESSING_DEM_INTERNAL
#define DEM_AGING_PROCESSING_DEM_INTERNAL
#define DEM_FAILURE_PROCESSING_DEM_INTERNAL
#define DEM_AGING_COUNTER_CLEAR_ON_FAIL_DURING_FAILURE_CYCLE
#define DEM_HEALING_COUNTER_CLEAR_ON_FAIL_DURING_FAILURE_CYCLE
#define DEM_NO_DTC 0xFFFFFFFFuL
typedef struct {
uint32 UDSDTC;
uint32 OBDDTC;
boolean DTCUsed;
} Arc_Dem_DTC;
typedef struct {
boolean JumpUp;/* @req DEM422 */
boolean JumpDown;/* @req DEM424 */
uint16 IncrementStepSize;
uint16 DecrementStepSize;
sint16 JumpDownValue;
sint16 JumpUpValue;
sint16 FailedThreshold;/* @req DEM416 */
sint16 PassedThreshold;/* @req DEM417 */
} Dem_PreDebounceCounterBasedType;
#define DEM_GENERAL_EVENT_DATA_CB STD_OFF
#define DEM_GENERAL_EVENT_STATUS_CB STD_OFF
#define DEM_NOF_TIME_BASE_PREDEB 0
#define DEM_TASK_TIME 10UL
/* DTC indexes (for dem internal use) */
//#define DEM_DTC_P123312_PButton2NotOK_INDEX 0u
//#define DEM_DTC_U010100_TCULost_INDEX 1u
#define DEM_DTC_C07300_BusOff_INDEX 0u
#define DEM_DTC_A06800_MorErr_INDEX 1u
#define DEM_DTC_A06700_PressErr_INDEX 2u
#define DEM_DTC_F00616_LowVoltage_INDEX 3u
#define DEM_DTC_F00617_HighVoltage_INDEX 4u
#define DEM_DTC_A06600_TouErr_INDEX 5u
//#define DEM_DTC_U014600_GWBCMLost_INDEX 8u
//#define DEM_DTC_P123311_PButton1NotOK_INDEX 9u
//#define DEM_DTC_P123313_PButton3NotOK_INDEX 10u
//#define DEM_DTC_P271F54_CalibrationFault_INDEX 11u
//#define DEM_DTC_P123411_LButton1NotOK_INDEX 12u
//#define DEM_DTC_P123412_LButton2NotOK_INDEX 13u
//#define DEM_DTC_P123511_LButton1Stucl_INDEX 14u
//#define DEM_DTC_P123512_LButton2Stuck_INDEX 15u
/* FF indexes (for dem internal use) */
#define DEM_FF_DemFreezeFrameClass_INDEX 0u
/* DID indexes (for dem internal use) */
#define DEM_DID_DID_ADCInformation_INDEX 0u
#define DEM_DID_DID_ActuatorPosInformation_INDEX 1u
#define DEM_DID_DID_BreakStatus_INDEX 2u
#define DEM_DID_DID_IgnitionStatus_INDEX 3u
#define DEM_DID_DID_Mlx_Die2_Val_INDEX 4u
#define DEM_DID_DID_ShiftPosInformation_INDEX 5u
#define DEM_DID_DID_TCUCurrentPosInformation_INDEX 6u
#define DEM_DID_DID_Mlx_Die1_Val_INDEX 7u
#define DEM_DID_DID_ShiftMechPosInformation_INDEX 8u
#define DEM_DID_DID_PbuttonStatus_INDEX 9u
#define DEM_DID_DID_OpDr_AutoP_Status_INDEX 10u
#define DEM_DID_DID_PowerSupply_INDEX 11u
/* Ext data rec class indexes (for dem internal use) */
#define DEM_EXT_DATA_REC_CLASS_FaultDetectionsNumber_Class_INDEX 0u
#define DEM_EXT_DATA_REC_CLASS_AgeingCounter_Class_INDEX 1u
#define DEM_EXT_DATA_REC_CLASS_FaultDetectionCounter_Class_INDEX 2u
#define DEM_EXT_DATA_REC_CLASS_UncompledTestCNT_class_INDEX 3u
#define DEM_EXT_DATA_REC_CLASS_DTC_OccurrenceCounter_Class_INDEX 4u
/* Enable condition indexes (for dem internal use) */
/* DTC Groups */
#endif /*DEM_CFG_H_*/

View File

@ -0,0 +1,451 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "Dem.h"
#include "Dem_Types.h"
#include "Dem_Lcfg.h"
#include "DiagnosticL/Dem/Dem_Internal.h"
#include "DiagnosticL/ProjectCfg.h"
#if defined(USE_DEM_EXTENSION)
#include "Dem_Extension.h"
#endif
/* Local defines */
#define DEM_UDS_TEST_FAILED_TRESHOLD (sint32)127
#define DEM_UDS_TEST_PASSED_TRESHOLD (sint32)(-128)
#define DEM_UDS_FDC_RANGE (sint32)(DEM_UDS_TEST_FAILED_TRESHOLD - (DEM_UDS_TEST_PASSED_TRESHOLD))
/* Local variables */
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
/* Buffer for time based debounce */
static TimeBaseStatusType DemTimeBaseBuffer[DEM_NOF_TIME_BASE_PREDEB];
#endif
/* Local functions */
/**
* Translates internal FDC to external FDC
* @param fdcInternal
* @param pdVars
* @return FDC
*/
static sint8 fdcInternalToUDSFdc(sint16 fdcInternal, const Dem_PreDebounceCounterBasedType* pdVars)
{
/* Map the internal counter to the corresponding UDS fdc. I.e. map from [FailedThreshold, PassedThreshold] to [-128, 127]. */
sint32 pdRange = (sint32)((sint32)pdVars->FailedThreshold - (sint32)pdVars->PassedThreshold);
sint32 temp = (DEM_UDS_FDC_RANGE*((sint32)((sint32)fdcInternal - (sint32)pdVars->PassedThreshold))) + (DEM_UDS_TEST_PASSED_TRESHOLD*pdRange);
return (sint8)(temp/pdRange);
}
/*
* Procedure: preDebounceNone
* Description: Returns the result of the debouncing.
*/
static Dem_EventStatusType preDebounceNone(const Dem_EventStatusType reportedStatus) {
/* @req DEM437 */
Dem_EventStatusType returnCode;
switch (reportedStatus) {
case DEM_EVENT_STATUS_FAILED:
case DEM_EVENT_STATUS_PASSED:
// Already debounced, do nothing.
break;
default:
// NOTE: What to do with PREFAIL and PREPASSED on no debouncing?
// DET_REPORTERROR(MODULE_ID_DEM, 0, DEM_PREDEBOUNCE_NONE_ID, DEM_E_PARAM_DATA);
break;
}
returnCode = reportedStatus;
return returnCode;
}
/*
* Procedure: preDebounceCounterBased
* Description: Returns the result of the debouncing.
*/
static Dem_EventStatusType preDebounceCounterBased(Dem_EventStatusType reportedStatus, EventStatusRecType* statusRecord) {
Dem_EventStatusType returnCode;
const Dem_PreDebounceCounterBasedType* pdVars = statusRecord->eventParamRef->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceCounterBased;
switch (reportedStatus) {
case DEM_EVENT_STATUS_PREFAILED:
if (statusRecord->fdcInternal < pdVars->FailedThreshold) {
if ((pdVars->JumpUp ==TRUE) && (statusRecord->fdcInternal < pdVars->JumpUpValue)) {
statusRecord->fdcInternal = pdVars->JumpUpValue;/* @req 4.2.2/SWS_DEM_00423 */
}
if (((sint32)statusRecord->fdcInternal + (sint32)pdVars->IncrementStepSize) < pdVars->FailedThreshold) {
statusRecord->fdcInternal += pdVars->IncrementStepSize;/*lint !e734 OK since we check above that it will not overflow*/ /* @req DEM418 */
} else {
statusRecord->fdcInternal = pdVars->FailedThreshold;
}
}
break;
case DEM_EVENT_STATUS_PREPASSED:
if (statusRecord->fdcInternal > pdVars->PassedThreshold) {
if ((pdVars->JumpDown==TRUE) && (statusRecord->fdcInternal > pdVars->JumpDownValue)) {
statusRecord->fdcInternal = pdVars->JumpDownValue;/* @req 4.2.2/SWS_DEM_00425 */
}
if (((sint32)statusRecord->fdcInternal - (sint32)pdVars->DecrementStepSize) > pdVars->PassedThreshold) {
statusRecord->fdcInternal -= pdVars->DecrementStepSize;/*lint !e734 OK since we check above that it will not overflow*/ /* @req DEM419 */
} else {
statusRecord->fdcInternal = pdVars->PassedThreshold;
}
}
break;
case DEM_EVENT_STATUS_FAILED:
statusRecord->fdcInternal = pdVars->FailedThreshold; /* @req DEM420 */
break;
case DEM_EVENT_STATUS_PASSED:
statusRecord->fdcInternal = pdVars->PassedThreshold; /* @req DEM421 */
break;
default:
// DET_REPORTERROR(MODULE_ID_DEM, 0, DEM_PREDEBOUNCE_COUNTER_BASED_ID, DEM_E_PARAM_DATA);
break;
}
#if defined(USE_DEM_EXTENSION)
Dem_Extension_PostPreDebounceCounterBased(reportedStatus, statusRecord);
#endif
if( statusRecord->fdcInternal >= pdVars->FailedThreshold ) {
returnCode = DEM_EVENT_STATUS_FAILED;
} else if( statusRecord->fdcInternal <= pdVars->PassedThreshold ) {
returnCode = DEM_EVENT_STATUS_PASSED;
} else {
returnCode = reportedStatus;
}
/* @req DEM415 */
statusRecord->UDSFdc = fdcInternalToUDSFdc(statusRecord->fdcInternal, pdVars);
statusRecord->maxUDSFdc = MAX(statusRecord->maxUDSFdc, statusRecord->UDSFdc);
return returnCode;
}
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
/**
* Calculates FDC based on timer
* @param debounceTimer
* @param pdVars
* @return FDC
*/
static sint8 getTimeBasedFDC(const TimeBaseStatusType *debounceTimer, const Dem_PreDebounceTimeBasedType *pdVars)
{
/* @req DEM427 */
sint8 FDC = 0;
sint64 temp;
if( TRUE == debounceTimer->started ) {
if( TRUE == debounceTimer->failureCounting ) {
/* 0 - pdVars->TimeFailedThreshold -> 0 - 127*/
if( 0UL != pdVars->TimeFailedThreshold ) {
temp = ((sint64)debounceTimer->debounceTime * DEM_UDS_TEST_FAILED_TRESHOLD) / pdVars->TimeFailedThreshold;
temp = MIN(temp, DEM_UDS_TEST_FAILED_TRESHOLD);
FDC = (sint8)temp;
} else {
FDC = (sint8)DEM_UDS_TEST_FAILED_TRESHOLD;
}
} else {
/* 0 - pdVars->TimePassedThreshold -> 0 - -128*/
if(0UL != pdVars->TimePassedThreshold) {
temp = ((sint64)debounceTimer->debounceTime * DEM_UDS_TEST_PASSED_TRESHOLD) / pdVars->TimePassedThreshold;
temp = MAX(temp, DEM_UDS_TEST_PASSED_TRESHOLD);
FDC = (sint8)temp;
} else {
FDC = (sint8)DEM_UDS_TEST_PASSED_TRESHOLD;
}
}
}
return FDC;
}
/**
* Handles starting time based debouncing
* @param reportedStatus
* @param eventParam
* @return
*/
static Dem_EventStatusType preDebounceTimeBased(Dem_EventStatusType reportedStatus, const Dem_EventParameterType *eventParam)
{
Dem_EventStatusType ret = reportedStatus;
const Dem_PreDebounceTimeBasedType* pdVars = eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased;
DemTimeBaseBuffer[pdVars->Index].EventId = eventParam->EventID;
switch (reportedStatus) {
case DEM_EVENT_STATUS_FAILED:
case DEM_EVENT_STATUS_PREFAILED:
/* @req DEM428 */
/* @req DEM429 */
if( (FALSE == DemTimeBaseBuffer[pdVars->Index].started) || (FALSE == DemTimeBaseBuffer[pdVars->Index].failureCounting) ) {
DemTimeBaseBuffer[pdVars->Index].started = TRUE;
DemTimeBaseBuffer[pdVars->Index].failureCounting = TRUE;
if( (DEM_EVENT_STATUS_FAILED == reportedStatus) || (0UL == pdVars->TimeFailedThreshold) ) {
/* @req DEM431 */
DemTimeBaseBuffer[pdVars->Index].debounceTime = pdVars->TimeFailedThreshold;
DemTimeBaseBuffer[pdVars->Index].errorReported = TRUE;
DemTimeBaseBuffer[pdVars->Index].counterReset = FALSE;
ret = DEM_EVENT_STATUS_FAILED;
} else {
DemTimeBaseBuffer[pdVars->Index].debounceTime = 0;
DemTimeBaseBuffer[pdVars->Index].errorReported = FALSE;
DemTimeBaseBuffer[pdVars->Index].counterReset = TRUE;
}
}
break;
case DEM_EVENT_STATUS_PASSED:
case DEM_EVENT_STATUS_PREPASSED:
/* @req DEM432 */
/* @req DEM433 */
if( (FALSE == DemTimeBaseBuffer[pdVars->Index].started) || (TRUE == DemTimeBaseBuffer[pdVars->Index].failureCounting) ) {
DemTimeBaseBuffer[pdVars->Index].started = TRUE;
DemTimeBaseBuffer[pdVars->Index].failureCounting = FALSE;
if( (DEM_EVENT_STATUS_PASSED == reportedStatus) || (0UL == pdVars->TimePassedThreshold) ) {
/* @req DEM435 */
DemTimeBaseBuffer[pdVars->Index].debounceTime = pdVars->TimePassedThreshold;
DemTimeBaseBuffer[pdVars->Index].errorReported = TRUE;
DemTimeBaseBuffer[pdVars->Index].counterReset = FALSE;
ret = DEM_EVENT_STATUS_PASSED;
} else {
DemTimeBaseBuffer[pdVars->Index].debounceTime = 0;
DemTimeBaseBuffer[pdVars->Index].errorReported = FALSE;
DemTimeBaseBuffer[pdVars->Index].counterReset = TRUE;
}
}
break;
default:
//DET_REPORTERROR(MODULE_ID_DEM, 0, DEM_PREDEBOUNCE_COUNTER_BASED_ID, DEM_E_PARAM_DATA);
break;
}
return ret;
}
#endif
/* Exported functions */
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
/**
* Main function for time based predebounce
*/
void TimeBasedDebounceMainFunction(void)
{
/* Handle time based predebounce */
/* @req DEM426 */
const Dem_EventParameterType *eventParam;
EventStatusRecType *eventStatusRec;
for( uint16 idx = 0; idx < DEM_NOF_TIME_BASE_PREDEB; idx++ ) {
eventParam = NULL;
eventStatusRec = NULL;
lookupEventIdParameter(DemTimeBaseBuffer[idx].EventId, &eventParam); /*lint !e934 eventParam only used in this function */
lookupEventStatusRec(DemTimeBaseBuffer[idx].EventId, &eventStatusRec); /*lint !e934 eventStatusRec only used in this function */
if( (NULL != eventParam) && (NULL != eventStatusRec) &&
(NULL != eventParam->EventClass->PreDebounceAlgorithmClass) &&
(DEM_PRE_DEBOUNCE_TIME_BASED == eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceName)) {
const Dem_PreDebounceTimeBasedType* pdVars = eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased;
if( TRUE == operationCycleIsStarted(eventParam->EventClass->OperationCycleRef) ) {
if( TRUE == DemTimeBaseBuffer[idx].started ) {
if(FALSE == DemTimeBaseBuffer[idx].counterReset) {
if( TRUE == DemTimeBaseBuffer[idx].failureCounting ) {
if( DemTimeBaseBuffer[idx].debounceTime < pdVars->TimeFailedThreshold ) {
DemTimeBaseBuffer[idx].debounceTime += DEM_TASK_TIME;
}
/* @req DEM430 */
if( DemTimeBaseBuffer[idx].debounceTime >= pdVars->TimeFailedThreshold ) {
/* FAILED! */
if(E_OK == handleEvent(DemTimeBaseBuffer[idx].EventId, DEM_EVENT_STATUS_FAILED) ) {
DemTimeBaseBuffer[idx].errorReported = TRUE;
}
}
} else {
if( DemTimeBaseBuffer[idx].debounceTime < pdVars->TimePassedThreshold ) {
DemTimeBaseBuffer[idx].debounceTime += DEM_TASK_TIME;
}
/* @req DEM434 */
if( DemTimeBaseBuffer[idx].debounceTime >= pdVars->TimePassedThreshold ) {
/* PASSED! */
if( E_OK == handleEvent(DemTimeBaseBuffer[idx].EventId, DEM_EVENT_STATUS_PASSED) ) {
DemTimeBaseBuffer[idx].errorReported = TRUE;
}
}
}
} else {
DemTimeBaseBuffer[idx].counterReset = FALSE;
}
eventStatusRec->UDSFdc = getTimeBasedFDC(&DemTimeBaseBuffer[idx], pdVars);
eventStatusRec->maxUDSFdc = MAX(eventStatusRec->UDSFdc, eventStatusRec->maxUDSFdc);
}
} else {
/* Operation cycle is not started.
* Cancel timer. */
DemTimeBaseBuffer[idx].started = FALSE;
DemTimeBaseBuffer[idx].errorReported = FALSE;
}
}
}
}
#endif
/**
* Resets debounce counter of event
* @param eventStatusRec
*/
void resetDebounceCounter(EventStatusRecType *eventStatusRec)
{
sint8 startFDC = getDefaultUDSFdc(eventStatusRec->eventId);
eventStatusRec->UDSFdc = startFDC;/* @req DEM344 */
eventStatusRec->maxUDSFdc = startFDC;
eventStatusRec->fdcInternal = 0;
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
const Dem_EventParameterType *eventParam = NULL;
lookupEventIdParameter(eventStatusRec->eventId, &eventParam); /*lint !e934 eventParam only used in this function */
if( NULL != eventParam ) {
if( (NULL != eventParam->EventClass->PreDebounceAlgorithmClass) &&
(DEM_PRE_DEBOUNCE_TIME_BASED == eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceName) ) {
DemTimeBaseBuffer[eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased->Index].started = FALSE;
DemTimeBaseBuffer[eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased->Index].errorReported = FALSE;
DemTimeBaseBuffer[eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased->Index].debounceTime = 0UL;
}
}
#endif
}
/*
* Procedure: getFaultDetectionCounter
* Description: Returns pre debounce counter of "eventId" in "counter" and return value E_OK if
* the counter was available else E_NOT_OK.
*/
Std_ReturnType getFaultDetectionCounter(Dem_EventIdType eventId, sint8 *counter)
{
Std_ReturnType returnCode = E_NOT_OK;
const Dem_EventParameterType *eventParam;
EventStatusRecType *eventStatusRec = NULL;
lookupEventStatusRec(eventId, &eventStatusRec); /*lint !e934 eventStatusRec only used in this function */
lookupEventIdParameter(eventId, &eventParam); /*lint !e934 eventParam only used in this function */
if ((eventParam != NULL) && (NULL != eventStatusRec) && (TRUE == eventStatusRec->isAvailable)) {
if (eventParam->EventClass->PreDebounceAlgorithmClass != NULL) {
switch (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceName)
{
case DEM_NO_PRE_DEBOUNCE:
if (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceMonitorInternal != NULL) {
if (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceMonitorInternal->CallbackGetFDCntFnc != NULL) {
/* @req DEM204 None */
/* @req DEM264 */
/* @req DEM439 */
returnCode = eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceMonitorInternal->CallbackGetFDCntFnc(counter);
}
}
break;
case DEM_PRE_DEBOUNCE_COUNTER_BASED:
*counter = eventStatusRec->UDSFdc; /* @req DEM204 Counter */
returnCode = E_OK;
break;
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
case DEM_PRE_DEBOUNCE_TIME_BASED:
/* Map timer to FDC */
*counter = getTimeBasedFDC(&DemTimeBaseBuffer[eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased->Index],
eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceTimeBased);
returnCode = E_OK;
break;
#endif
default:
//DET_REPORTERROR(MODULE_ID_DEM, 0, DEM_GETFAULTDETECTIONCOUNTER_ID, DEM_E_PARAM_DATA);
break;
}
}
}
return returnCode;
}
/**
* Initializes time based debounce buffer
*/
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
void InitTimeBasedDebounce(void)
{
for( uint16 idx = 0; idx < DEM_NOF_TIME_BASE_PREDEB; idx++ ) {
DemTimeBaseBuffer[idx].EventId = DEM_EVENT_ID_NULL;
DemTimeBaseBuffer[idx].started = FALSE;
}
}
#endif
/**
* Gets the default UDS fdc
* @param eventId
* @return
*/
sint8 getDefaultUDSFdc(Dem_EventIdType eventId)
{
sint8 udsFdc = 0;
const Dem_EventParameterType *eventParam = NULL;
lookupEventIdParameter(eventId, &eventParam); /*lint !e934 eventParam only used in this function */
if( NULL != eventParam ) {
if (eventParam->EventClass->PreDebounceAlgorithmClass != NULL) {
switch (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceName) {
case DEM_PRE_DEBOUNCE_COUNTER_BASED:
udsFdc = fdcInternalToUDSFdc(0, eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceCounterBased);
break;
default:
break;
}
}
}
return udsFdc;
}
/**
* Runs predebounce for event
* @param reportedEventStatus
* @param eventStatusRecPtr
* @param eventParam
* @return calculated eventStatus
*/
Dem_EventStatusType RunPredebounce(Dem_EventStatusType reportedEventStatus, EventStatusRecType *eventStatusRecPtr, const Dem_EventParameterType *eventParam)
{
Dem_EventStatusType eventStatus = reportedEventStatus;
if (eventParam->EventClass->PreDebounceAlgorithmClass != NULL) {
switch (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceName) {
case DEM_NO_PRE_DEBOUNCE:
eventStatus = preDebounceNone(reportedEventStatus);
break;
case DEM_PRE_DEBOUNCE_COUNTER_BASED:
eventStatus = preDebounceCounterBased(reportedEventStatus, eventStatusRecPtr);
break;
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
case DEM_PRE_DEBOUNCE_TIME_BASED:
eventStatus = preDebounceTimeBased(reportedEventStatus, eventParam);
break;
#endif
default:
// DET_REPORTERROR(MODULE_ID_DEM, 0, DEM_UPDATE_EVENT_STATUS_ID, DEM_E_NOT_IMPLEMENTED_YET);
break;
}
}
return eventStatus;
}

View File

@ -0,0 +1,142 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#include "Dem_Extension.h"
#include "Dem.h"
#include "Std_Types.h"
void Dem_Extension_MainFunction(void)
{
}
void Dem_Extension_ClearEvent(const Dem_EventParameterType *eventParam)
{
(void)eventParam;
}
void Dem_Extension_UpdateEventstatus(EventStatusRecType *eventStatusRecPtr, uint8 eventStatusExtendedBeforeUpdate, Dem_EventStatusType eventStatus)
{
(void)eventStatusRecPtr;
(void)eventStatusExtendedBeforeUpdate;
(void)eventStatus;
}
void Dem_Extension_OperationCycleStart(Dem_OperationCycleIdType operationCycleId, EventStatusRecType *eventStatusRecPtr)
{
(void)operationCycleId;
(void)eventStatusRecPtr;
}
void Dem_Extension_OperationCycleEnd(Dem_OperationCycleIdType operationCycleId, EventStatusRecType *eventStatusRecPtr)
{
(void)operationCycleId;
(void)eventStatusRecPtr;
}
void Dem_Extension_PreInit(const Dem_ConfigType *ConfigPtr)
{
(void)ConfigPtr;
}
void Dem_Extension_Init_PostEventMerge(Dem_DTCOriginType origin)
{
}
void Dem_Extension_Init_Complete(void)
{
}
void Dem_Extension_Shutdown(void)
{
}
void Dem_Extension_GetExtendedDataInternalElement(Dem_EventIdType eventId, Dem_InternalDataElementType internalElement, uint8 *dataBuf, uint16 size)
{
(void)eventId;
(void)internalElement;
(void)dataBuf;
(void)size;
}
void Dem_Extension_PostPreDebounceCounterBased(Dem_EventStatusType reportedStatus, EventStatusRecType* statusRecord)
{
(void)reportedStatus;
(void)statusRecord;
}
void Dem_Extension_HealedEvent(Dem_EventIdType eventId)
{
(void)eventId;
}
#if defined(DEM_DISPLACEMENT_PROCESSING_DEM_EXTENSION)
void Dem_Extension_GetExtDataEventForDisplacement(const Dem_EventParameterType *eventParam, const ExtDataRecType *extDataBuffer, uint32 bufferSize, Dem_EventIdType *eventToRemove)
{
(void)eventParam;
(void)extDataBuffer;
(void)bufferSize;
(void)eventParam;
}
void Dem_Extension_GetEventForDisplacement(const Dem_EventParameterType *eventParam, const EventRecType *eventRecordBuffer, uint32 bufferSize, Dem_EventIdType *eventToRemove)
{
(void)eventParam;
(void)eventRecordBuffer;
(void)bufferSize;
(void)eventParam;
}
void Dem_Extension_GetFFEventForDisplacement(const Dem_EventParameterType *eventParam, const FreezeFrameRecType *ffBuffer, uint32 bufferSize, Dem_EventIdType *eventToRemove)
{
(void)eventParam;
(void)ffBuffer;
(void)bufferSize;
(void)eventParam;
}
#endif
void Dem_Extension_EventDataDisplaced(Dem_EventIdType eventId)
{
(void)eventId;
}
void Dem_Extension_EventExtendedDataDisplaced(Dem_EventIdType eventId)
{
(void)eventId;
}
void Dem_Extension_EventFreezeFrameDataDisplaced(Dem_EventIdType eventId)
{
(void)eventId;
}
void Dem_Extension_PreMergeExtendedData(Dem_EventIdType eventId, boolean *UpdateAllData)
{
(void)eventId;
(void)UpdateAllData;
}
void Dem_Extension_PreTransferPreInitFreezeFrames(Dem_EventIdType eventId, boolean *removeOldRecords, Dem_DTCOriginType origin)
{
(void)eventId;
(void)removeOldRecords;
(void)origin;
}

View File

@ -0,0 +1,54 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef DEM_EXTENSION_H_
#define DEM_EXTENSION_H_
#include "Dem.h"
#include "Dem_Internal.h"
#define DEM_EXTENSION_UPDATE_EVENT_STATUS_ID 0xA0
#define DEM_EXTENSION_INIT_ID 0xA1
#define DEM_EXTENSION_PRE_INIT_ID 0xA2
#define DEM_EXTENSION_EVENT_DATA_DISPLACED_ID 0xA3
/* Errors only used in the extension module */
#define DEM_E_EXTENSION_PRE_INIT_BUFFER_FULL 0x60
#define DEM_E_EXTENSION_EVENT_BUFF_FULL 0x61
void Dem_Extension_MainFunction(void);
void Dem_Extension_ClearEvent(const Dem_EventParameterType *eventParam);
void Dem_Extension_UpdateEventstatus(EventStatusRecType *eventStatusRecPtr, uint8 eventStatusExtendedBeforeUpdate, Dem_EventStatusType eventStatus);
void Dem_Extension_OperationCycleStart(Dem_OperationCycleIdType operationCycleId, EventStatusRecType *eventStatusRecPtr);
void Dem_Extension_OperationCycleEnd(Dem_OperationCycleIdType operationCycleId, EventStatusRecType *eventStatusRecPtr);
void Dem_Extension_PreInit(const Dem_ConfigType *ConfigPtr);
void Dem_Extension_Init_PostEventMerge(Dem_DTCOriginType origin);
void Dem_Extension_Init_Complete(void);
void Dem_Extension_Shutdown(void);
void Dem_Extension_GetExtendedDataInternalElement(Dem_EventIdType eventId, Dem_InternalDataElementType internalElement, uint8 *dataBuf, uint16 size);
void Dem_Extension_PostPreDebounceCounterBased(Dem_EventStatusType reportedStatus, EventStatusRecType* statusRecord);
void Dem_Extension_HealedEvent(Dem_EventIdType eventId);
#if defined(DEM_DISPLACEMENT_PROCESSING_DEM_EXTENSION)
void Dem_Extension_GetExtDataEventForDisplacement(const Dem_EventParameterType *eventParam, const ExtDataRecType *extDataBuffer, uint32 bufferSize, Dem_EventIdType *eventToRemove);
void Dem_Extension_GetEventForDisplacement(const Dem_EventParameterType *eventParam, const EventRecType *eventRecordBuffer, uint32 bufferSize, Dem_EventIdType *eventToRemove); /*lint !e9018 'eventRecordBuffer' with union based type 'EventRecType */
void Dem_Extension_GetFFEventForDisplacement(const Dem_EventParameterType *eventParam, const FreezeFrameRecType *ffBuffer, uint32 bufferSize, Dem_EventIdType *eventToRemove);
#endif
void Dem_Extension_EventDataDisplaced(Dem_EventIdType eventId);
void Dem_Extension_EventExtendedDataDisplaced(Dem_EventIdType eventId);
void Dem_Extension_EventFreezeFrameDataDisplaced(Dem_EventIdType eventId);
void Dem_Extension_PreMergeExtendedData(Dem_EventIdType eventId, boolean *UpdateAllData);
void Dem_Extension_PreTransferPreInitFreezeFrames(Dem_EventIdType eventId, boolean *removeOldRecords, Dem_DTCOriginType origin);
#endif /* DEM_EXTENSION_H_ */

View File

@ -0,0 +1,83 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
//#warning "This default file may only be used as an example!"
#ifndef DEM_INTERRID_H_
#define DEM_INTERRID_H_
#endif /*DEM_INTERRID_H_*/
/*
* Definition of event IDs used by BSW
* NB! Must be unique for each event!
*/
enum {
// Event IDs from DEM module
DEM_EVENT_ID_NULL = 0, // Do not change this entry!!!
// Event IDs from MCU
MCU_E_CLOCK_FAILURE,
// Event IDs from CAN
CANTRCV_E_NO_TRCV_CONTROL,
CANTP_E_OPER_NOT_SUPPORTED,
CANTP_E_COMM,
CANNM_E_CANIF_TRANSMIT_ERROR,
CANNM_E_NETWORK_TIMEOUT,
CANIF_TRCV_E_TRANSCEIVER,
CANIF_E_INVALID_DLC,
CANIF_STOPPED,
CANIF_E_FULL_TX_BUFFER,
CAN_E_TIMEOUT,
// Event IDs from EEPROM
EEP_E_COM_FAILURE,
// Event IDs from flash
FLS_E_ERASE_FAILED,
FLS_E_WRITE_FAILED,
FLS_E_READ_FAILED,
FLS_E_COMPARE_FAILED,
FLS_E_UNEXPECTED_FLASH_ID,
// Event IDs from LIN
LIN_E_TIMEOUT,
// Event IDs from ECU
ECUM_E_RAM_CHECK_FAILED,
ECUM_E_ALL_RUN_REQUESTS_KILLED,
ECUM_E_CONFIGURATION_DATA_INCONSISTENT,
// Event IDs from COM
// COMM_E_NET_START_IND_CHANNEL_<X>,
// Event IDs from PDUR
PDUR_E_PDU_INSTANCE_LOST,
PDUR_E_INIT_FAILED,
// Event IDs from WDGM
WDGM_E_ALIVE_SUPERVISION,
WDGM_E_SET_MODE,
// DEM last event id for BSW
DEM_EVENT_ID_LAST_FOR_BSW
};

View File

@ -0,0 +1,38 @@
/*
* Generator version: 5.14.0
* AUTOSAR version: 4.0.3
*/
#if !(((DEM_SW_MAJOR_VERSION == 5) && (DEM_SW_MINOR_VERSION == 14)) )
#error Dem: Configuration file expected BSW module version to be 5.14.*
#endif
#if !(((DEM_AR_RELEASE_MAJOR_VERSION == 4) && (DEM_AR_RELEASE_MINOR_VERSION == 0)) )
#error DEM: Configuration file expected AUTOSAR version to be 4.0.*
#endif
#ifndef DEMINTEVTID_H_
#define DEMINTEVTID_H_
#define DEM_EVENT_ID_SWC_START (Dem_EventIdType)7u
//#define DemConf_DemEventParameter_P123312_P_BUTTON2_NOT_OK (Dem_EventIdType)10u
//#define DemConf_DemEventParameter_P123311_P_BUTTON1_NOT_OK (Dem_EventIdType)11u
//#define DemConf_DemEventParameter_P123313_P_BUTTON3_NOT_OK (Dem_EventIdType)12u
//#define DemConf_DemEventParameter_U014600_GW_BCM_LOST (Dem_EventIdType)13u
//#define DemConf_DemEventParameter_U010100_TCU_LOST (Dem_EventIdType)16u
#define DemConf_DemEventParameter_C07300_BUS_OFF (Dem_EventIdType)0u
#define DemConf_DemEventParameter_A06800_MorErr (Dem_EventIdType)1u
#define DemConf_DemEventParameter_A06700_PressErr (Dem_EventIdType)2u
#define DemConf_DemEventParameter_F00616_LOW_VOLTAGE (Dem_EventIdType)3u
#define DemConf_DemEventParameter_F00617_HIGH_VOLTAGE (Dem_EventIdType)4u
#define DemConf_DemEventParameter_A06600_TouErr (Dem_EventIdType)5u
//#define DemConf_DemEventParameter_P271F54_Calibration_Fault (Dem_EventIdType)18u
//#define DemConf_DemEventParameter_P123411_L_BUTTON1_NOT_OK (Dem_EventIdType)19u
//#define DemConf_DemEventParameter_P123412_L_BUTTON2_NOT_OK (Dem_EventIdType)20u
//#define DemConf_DemEventParameter_P123511_L_BUTTON1_STUCK (Dem_EventIdType)21u
//#define DemConf_DemEventParameter_P123512_L_BUTTON2_STUCK (Dem_EventIdType)22u
#define DEM_EVENT_ID_LAST_FOR_SWC (Dem_EventIdType)6u
#define DEM_EVENT_ID_LAST_VALID_ID DEM_EVENT_ID_LAST_FOR_SWC
#endif /*DEMINTEVTID_H_*/

View File

@ -0,0 +1,133 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef DEM_INTERNAL_H_
#define DEM_INTERNAL_H_
#if defined(DEM_FREEZE_FRAME_CAPTURE_EXTENSION)
#define DEM_EXT_STORE_FF_BIT (uint8)(1u<<0u)
#define DEM_EXT_CLEAR_BEFORE_STORE_FF_BIT (uint8)(1u<<1u)
#endif
#if defined(DEM_EXTENDED_DATA_CAPTURE_EXTENSION)
#define DEM_EXT_STORE_EXT_DATA_BIT (uint8)(1u<<2u)
#define DEM_EXT_CLEAR_BEFORE_STORE_EXT_DATA_BIT (uint8)(1u<<3u)
#endif
#include "Dem.h"
#if ( DEM_DEV_ERROR_DETECT == STD_ON )
#if defined(USE_DET)
#include "Det.h"
#endif
/** @req DEM117 */
//#define DET_REPORTERROR(_x,_y,_z,_q) (void)Det_ReportError(_x, _y, _z, _q)
#else
#define DET_REPORTERROR(_x,_y,_z,_q)
#endif
#if (DEM_NOF_TIME_BASE_PREDEB > 0)
#define DEM_USE_TIME_BASE_PREDEBOUNCE
#endif
// For keeping track of the events status
/* NOTE: Do not change EventStatusRecType without also changing generation of measurement tags */
typedef struct {
const Dem_EventParameterType *eventParamRef;
uint32 timeStamp;
Dem_EventIdType eventId;
uint16 occurrence; /** @req DEM011 */
sint16 fdcInternal; /** @req DEM414 */
sint8 UDSFdc;
sint8 maxUDSFdc;
uint8 failureCounter;
uint8 agingCounter;
Dem_EventStatusExtendedType eventStatusExtended; /** @req DEM006 */
uint8 extensionDataStoreBitfield;
boolean failedDuringAgingCycle:1; /*lint !e46 *//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean passedDuringAgingCycle:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean failedDuringFailureCycle:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean passedDuringFailureCycle:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean errorStatusChanged:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean extensionDataChanged:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean indicatorDataChanged:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean isAvailable:1; /*lint !e46 *//*structure must remain the same,field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
} EventStatusRecType;
// Types for storing different event data on event memory
/* ******************************************************************************************************
* WARNING: DO NOT CHANGE THESE STRUCTURES WITHOUT UPDATED THE DEM GENERATOR!!
* ******************************************************************************************************/
typedef union {
struct {
#if (DEM_EVENT_DISPLACEMENT_SUPPORT == STD_ON) && defined(DEM_DISPLACEMENT_PROCESSING_DEM_INTERNAL)
uint32 timeStamp;
#endif
Dem_EventIdType eventId;
uint16 occurrence;
Dem_EventStatusExtendedType eventStatusExtended;
#if defined(DEM_FAILURE_PROCESSING_DEM_INTERNAL)
uint8 failureCounter;
#endif
#if defined(DEM_AGING_PROCESSING_DEM_INTERNAL)
uint8 agingCounter;/* @req DEM492 */
#endif
}EventData;
struct {
/* NOTE: This must be kept smaller than the event data */
uint16 magic;
boolean overflow;
}AdminData;
} EventRecType;
typedef struct {
#if (DEM_EVENT_DISPLACEMENT_SUPPORT == STD_ON) && defined(DEM_DISPLACEMENT_PROCESSING_DEM_INTERNAL)
uint32 timeStamp;
#endif
Dem_EventIdType eventId;
uint8 data[DEM_MAX_SIZE_EXT_DATA];
} ExtDataRecType;
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
typedef struct {
uint32 debounceTime;
Dem_EventIdType EventId;
boolean started:1;/*lint !e46 *//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean failureCounting:1;/*lint !e46 *//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean errorReported:1;/*lint !e46 *//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
boolean counterReset:1;/*lint !e46 *//*structure must remain the same, field type should be _Bool, unsigned int or signed int [MISRA 2004 6.4, 2012 6.1]*/
}TimeBaseStatusType;
#endif
void lookupEventStatusRec(Dem_EventIdType eventId, EventStatusRecType **const eventStatusRec);
boolean operationCycleIsStarted(Dem_OperationCycleIdType opCycle);
#if (DEM_UNIT_TEST == STD_ON)
void demZeroPriMemBuffers(void);
void demZeroSecMemBuffers(void);
#endif
void lookupEventIdParameter(Dem_EventIdType eventId, const Dem_EventParameterType **const eventIdParam);
Std_ReturnType handleEvent(Dem_EventIdType eventId, Dem_EventStatusType eventStatus);
/* Debouncing functions */
void resetDebounceCounter(EventStatusRecType *eventStatusRec);
Std_ReturnType getFaultDetectionCounter(Dem_EventIdType eventId, sint8 *counter);
sint8 getDefaultUDSFdc(Dem_EventIdType eventId);
Dem_EventStatusType RunPredebounce(Dem_EventStatusType reportedEventStatus, EventStatusRecType *eventStatusRecPtr, const Dem_EventParameterType *eventParam);
#if defined(DEM_USE_TIME_BASE_PREDEBOUNCE)
void InitTimeBasedDebounce(void);
void TimeBasedDebounceMainFunction(void);
#endif
#endif /* DEM_INTERNAL_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,313 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef DEM_LCFG_H_
#define DEM_LCFG_H_
#include "Dem_Types.h"
#include "DiagnosticL/rte/Rte_Dem_Type.h"
#include "DiagnosticL/Dem/Dem_Cfg.h"
#if defined(USE_DCM)
#include "Dcm_Types.h" /** @req DEM176.Dcm */
#endif
/*
* Callback function prototypes
*/
// ClearEventAllowed
typedef Std_ReturnType (*Dem_CallbackClearEventAllowedFncType)(boolean *Allowed); /* @req DEM563 */
// EventDataChanged
typedef Std_ReturnType (*Dem_CallbackEventDataChangedFncTypeWithId)(Dem_EventIdType EventId);/* @req DEM562 */
typedef Std_ReturnType (*Dem_CallbackEventDataChangedFncTypeWithoutId)(void);
typedef union {
Dem_CallbackEventDataChangedFncTypeWithId eventDataChangedWithId;
Dem_CallbackEventDataChangedFncTypeWithoutId eventDataChangedWithoutId;
}Dem_CallbackEventDataChangedFncType;
typedef struct {
boolean UsePort;
Dem_CallbackEventDataChangedFncType CallbackEventDataChangedFnc;
}Dem_CallbackEventDataChangedType;
// InitMonitorForEvent
typedef Std_ReturnType (*Dem_CallbackInitMonitorForEventFncType)(Dem_InitMonitorReasonType InitMonitorReason); /** @req DEM256 *//** @req DEM376 *//** @req DEM003 */
// InitMonitorForFunction
typedef Std_ReturnType (*Dem_CallbackInitMonitorForFunctionFncType)(void); /** !req DEM258 */
// EventStatusChanged
typedef Std_ReturnType (*Dem_CallbackEventStatusChangedFncTypeWithId)(Dem_EventIdType EventId, Dem_EventStatusExtendedType EventStatusOld, Dem_EventStatusExtendedType EventStatusNew); /** @req DEM259 */
typedef Std_ReturnType (*Dem_CallbackEventStatusChangedFncTypeWithoutId)(Dem_EventStatusExtendedType EventStatusOld, Dem_EventStatusExtendedType EventStatusNew); /** @req DEM259 */
typedef union {
Dem_CallbackEventStatusChangedFncTypeWithId eventStatusChangedWithId;
Dem_CallbackEventStatusChangedFncTypeWithoutId eventStatusChangedWithoutId;
}Dem_CallbackEventStatusChangedFncType;
// DTCStatusChanged
typedef Std_ReturnType (*Dem_CallbackDTCStatusChangedFncType)(uint8 DTCStatusOld, uint8 DTCStatusNew); /** !req DEM260 */
// DIDServices /** @req DEM261 *//* */
typedef Std_ReturnType (*Dem_CallbackReadDataFncType)(uint8 *Data);/* @req DEM564 */
// GetFaultDetectionCounter
typedef Std_ReturnType (*Dem_CallbackGetFaultDetectionCounterFncType)(sint8 *EventIdFaultDetectionCounter); /** @req DEM263 */
typedef uint8 Dem_InternalDataElementType;
#define DEM_NO_ELEMENT 0u
#define DEM_OCCCTR 1u
#define DEM_FAULTDETCTR 2u
#define DEM_MAXFAULTDETCTR 3u
#define DEM_CONFIRMATIONCNTR 4u
#define DEM_AGINGCTR 5u
#define DEM_OVFLIND 6u
typedef enum {
DEM_UPDATE_RECORD_NO,
DEM_UPDATE_RECORD_YES,
DEM_UPDATE_RECORD_VOLATILE,
} Dem_UpdateRuleType;
/*
* DemGeneral types
*/
// 10.2.25 DemEnableCondition
typedef struct {
boolean EnableConditionStatus; //
uint8 EnableConditionID; // Optional
} Dem_EnableConditionType;
typedef struct {
uint8 nofEnableConditions;
const Dem_EnableConditionType * const *EnableCondition;
}Dem_EnableConditionGroupType;
// 10.2.30 DemExtendedDataRecordClass
typedef struct {
uint8 RecordNumber; // (1)
uint16 DataSize; // (1)
Dem_UpdateRuleType UpdateRule; /* @req DEM466 */
Dem_CallbackReadDataFncType CallbackGetExtDataRecord; // (1)
Dem_InternalDataElementType InternalDataElement; /* @req DEM469 */
} Dem_ExtendedDataRecordClassType;
// 10.2.13 DemExtendedDataClass
typedef struct {
const Dem_ExtendedDataRecordClassType *const ExtendedDataRecordClassRef[DEM_MAX_NR_OF_RECORDS_IN_EXTENDED_DATA+1]; // (1..253)
} Dem_ExtendedDataClassType;
// 10.2.8 DemPidOrDid
typedef struct {
const uint16 DidIdentifier; // (0..1)
Dem_CallbackReadDataFncType DidReadFnc; // (0..1)
const uint8 PidIdentifier; // (0..1)
uint8 PidOrDidSize; // (1)
boolean PidOrDidUsePort; // (1) Not used in current implementation
Dem_CallbackReadDataFncType PidReadFnc; // (0..1)
boolean Arc_EOL;
} Dem_PidOrDidType;
// 10.2.18 DemFreezeFrameClass
typedef struct {
Dem_FreezeFrameKindType FFKind; // (1)
const Dem_PidOrDidType * const * FFIdClassRef; // (1..255)/** @req DEM039 *//** @req DEM040 */
} Dem_FreezeFrameClassType;
/*
* DemConfigSetType types
*/
// 10.2.6 DemCallbackDTCStatusChanged
typedef struct {
Dem_CallbackDTCStatusChangedFncType CallbackDTCStatusChangedFnc; // (0..1)
} Dem_CallbackDTCStatusChangedType;
// 10.2.26 DemCallbackInitMForF
typedef struct {
Dem_CallbackInitMonitorForFunctionFncType CallbackInitMForF; // (0..1)
} Dem_CallbackInitMForFType;
// 10.2.17 DemDTCClass
typedef struct {
#if defined(HOST_TEST)
Arc_Dem_DTC *DTCRef; // (1)
#else
const Arc_Dem_DTC *DTCRef; // (1)
#endif
#if (DEM_DTC_SUPPRESSION_SUPPORT == STD_ON)
uint16 DTCIndex; // Index of the DTC
const Dem_EventIdType *Events; // List of events referencing DTC
uint16 NofEvents; // Number of events referencing DTC
#endif
Dem_DTCKindType DTCKind; // (1)
// const Dem_CallbackDTCStatusChangedType *CallbackDTCStatusChanged; // (0..*)
// const Dem_CallbackInitMForFType *CallbackInitMForF; // (0..*)
Dem_DTCSeverityType DTCSeverity; // (0..1) Optional /* @req DEM033 */
boolean Arc_EOL;
} Dem_DTCClassType;
// 10.2.5 DemCallbackEventStatusChanged
typedef struct {
Dem_CallbackEventStatusChangedFncType CallbackEventStatusChangedFnc; // (0..1)
boolean UsePort;
boolean Arc_EOL;
} Dem_CallbackEventStatusChangedType;
typedef enum {
DEM_FAILURE_CYCLE_EVENT = 0,
DEM_FAILURE_CYCLE_INDICATOR
}DemIndicatorFailureSourceType;
typedef struct {
uint16 IndicatorBufferIndex;
uint8 IndicatorId;
Dem_IndicatorStatusType IndicatorBehaviour;/* @req DEM511 */
uint8 IndicatorFailureCycleThreshold;/* @req DEM500 */
Dem_OperationCycleStateType IndicatorFailureCycle;/* @req DEM504 */
uint8 IndicatorHealingCycleThreshold;
Dem_OperationCycleStateType IndicatorHealingCycle;
DemIndicatorFailureSourceType IndicatorFailureCycleSource;
boolean Arc_EOL;
} Dem_IndicatorAttributeType;
// 10.2.23 DemPreDebounceMonitorInternal
typedef struct {
Dem_CallbackGetFaultDetectionCounterFncType CallbackGetFDCntFnc; // (1)
} Dem_PreDebounceMonitorInternalType;
// 10.2.22 DemPreDebounceFrequencyBased
typedef uint8 Dem_PreDebounceFrequencyBasedType;
// 10.2.24 DemPreDebounceTimeBased
typedef struct{
uint32 TimeFailedThreshold;
uint32 TimePassedThreshold;
uint16 Index;
}Dem_PreDebounceTimeBasedType;
// 10.2.20
typedef struct {
Dem_PreDebounceNameType PreDebounceName; // (1)
union {
const Dem_PreDebounceMonitorInternalType *PreDebounceMonitorInternal; // (0..1)
const Dem_PreDebounceCounterBasedType *PreDebounceCounterBased; // (0..1)
const Dem_PreDebounceFrequencyBasedType *PreDebounceFrequencyBased; // (0..1)
const Dem_PreDebounceTimeBasedType *PreDebounceTimeBased; // (0..1)
} PreDebounceAlgorithm;
} Dem_PreDebounceAlgorithmClassType;
typedef struct {
uint8 Threshold;
} Arc_FailureCycleCounterThreshold;
// 10.2.14 DemEventClass
typedef struct {
const Arc_FailureCycleCounterThreshold *FailureCycleCounterThresholdRef; // (1) /* @req DEM529 */
const Dem_EnableConditionGroupType *EnableConditionGroupRef; // (0..*) Optional /* @req DEM446 */
const Dem_PreDebounceAlgorithmClassType *PreDebounceAlgorithmClass; // (0..255) (Only 0..1 supported) /* @req DEM413 */
const Dem_IndicatorAttributeType *IndicatorAttribute; // (0..255)
const boolean *EventAvailableByCalibration;
boolean ConsiderPtoStatus; // (1)
Dem_DTCOriginType EventDestination; // (1 Arccore specific)
uint8 EventPriority; // (1) /* @req DEM382 */
boolean FFPrestorageSupported; // (1)
boolean AgingAllowed; // (1)
Dem_OperationCycleIdType OperationCycleRef; // (1)
Dem_OperationCycleIdType AgingCycleRef; // (1) /* @req DEM494 */
Dem_OperationCycleIdType FailureCycleRef; // (1) /* @req DEM528 */
uint8 AgingCycleCounterThreshold; // (0..1) Optional /* @req DEM493 */
// Dem_OEMSPecific
} Dem_EventClassType;
typedef struct
{
uint8 FreezeFrameRecordNumber[DEM_MAX_RECORD_NUMBERS_IN_FF_REC_NUM_CLASS + 1];
}Dem_FreezeFrameRecNumClass;
// 10.2.12 DemEventParameter
typedef struct {
uint16 EventID; // (1)
Dem_EventKindType EventKind; // (1)
uint8 MaxNumberFreezeFrameRecords; // (1) /* @req DEM337 *//* @req DEM582 */
const Dem_EventClassType *EventClass; // (1)
const Dem_ExtendedDataClassType *ExtendedDataClassRef; // (0..1) /* @req DEM460 */
const Dem_FreezeFrameClassType *FreezeFrameClassRef; // (0..1) /* @req DEM460 */
const Dem_CallbackInitMonitorForEventFncType CallbackInitMforE; // (0..1)
const Dem_CallbackEventStatusChangedType *CallbackEventStatusChanged; // (0..)
const Dem_CallbackClearEventAllowedFncType CallbackClearEventAllowed; // (0..1)
const Dem_CallbackEventDataChangedType *CallbackEventDataChanged; // (0..1)
const Dem_DTCClassType *DTCClassRef; // (0..1)
const Dem_FreezeFrameRecNumClass *FreezeFrameRecNumClassRef; // (1)
boolean Arc_EOL;
} Dem_EventParameterType;
typedef struct {
uint8 EventListSize;
const Dem_EventIdType *EventList;
}Dem_IndicatorType;
// 10.2.19 DemGroupOfDTC
typedef struct {
uint32 DemGroupDTCs;
boolean Arc_EOL;
}Dem_GroupOfDtcType;
// 10.2.9 DemConfigSet
typedef struct {
const Dem_EventParameterType *EventParameter; // (0..65535)
const Dem_DTCClassType *DTCClass; // (1..16777214)
const Dem_GroupOfDtcType *GroupOfDtc;
const Dem_EnableConditionType *EnableCondition;
const Dem_FreezeFrameClassType *GlobalOBDFreezeFrameClassRef;/* @req DEM291 */
const Dem_IndicatorType *Indicators;
} Dem_ConfigSetType;
// 10.2.2 Dem
typedef struct {
const Dem_ConfigSetType *ConfigSet; // (1)
} Dem_ConfigType;
/* ******************************************************************************************************
* WARNING: DO NOT CHANGE THESE STRUCTURES WITHOUT UPDATED THE DEM GENERATOR!!
* ******************************************************************************************************/
typedef struct {
#if (DEM_EVENT_DISPLACEMENT_SUPPORT == STD_ON) && defined(DEM_DISPLACEMENT_PROCESSING_DEM_INTERNAL)
uint32 timeStamp;
#endif
uint16 dataSize;
Dem_EventIdType eventId;
Dem_FreezeFrameKindType kind;
uint8 recordNumber;
uint8 data[DEM_MAX_SIZE_FF_DATA];
} FreezeFrameRecType;
// Types for storing different event aging counter
typedef struct {
Dem_EventIdType eventId;
uint8 agingCounter;/** @req Dem019 */
} HealingRecType;
/* ******************************************************************************************************
*
* ******************************************************************************************************/
/*
* Make the DEM_Config visible for others.
*/
extern const Dem_ConfigType DEM_Config;
#endif /*DEM_LCFG_H_*/

View File

@ -0,0 +1,419 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef DEM_TYPES_H_
#define DEM_TYPES_H_
#include "Std_Types.h" /** @req DEM176.Std */
//#include "Rte_Dem_Type.h"
/** Enum literals for Dem_DTCFormatType */
#ifndef DEM_DTC_FORMAT_OBD
#define DEM_DTC_FORMAT_OBD 0U
#endif /* DEM_DTC_FORMAT_OBD */
#ifndef DEM_DTC_FORMAT_UDS
#define DEM_DTC_FORMAT_UDS 1U
#endif /* DEM_DTC_FORMAT_UDS */
/** Enum literals for Dem_DTCOriginType */
#ifndef DEM_DTC_ORIGIN_NOT_USED
#define DEM_DTC_ORIGIN_NOT_USED 0U
#endif /* DEM_DTC_ORIGIN_NOT_USED */
#ifndef DEM_DTC_ORIGIN_PRIMARY_MEMORY
#define DEM_DTC_ORIGIN_PRIMARY_MEMORY 1U
#endif /* DEM_DTC_ORIGIN_PRIMARY_MEMORY */
#ifndef DEM_DTC_ORIGIN_MIRROR_MEMORY
#define DEM_DTC_ORIGIN_MIRROR_MEMORY 2U
#endif /* DEM_DTC_ORIGIN_MIRROR_MEMORY */
#ifndef DEM_DTC_ORIGIN_PERMANENT_MEMORY
#define DEM_DTC_ORIGIN_PERMANENT_MEMORY 3U
#endif /* DEM_DTC_ORIGIN_PERMANENT_MEMORY */
#ifndef DEM_DTC_ORIGIN_SECONDARY_MEMORY
#define DEM_DTC_ORIGIN_SECONDARY_MEMORY 4U
#endif /* DEM_DTC_ORIGIN_SECONDARY_MEMORY */
/** Enum literals for Dem_EventStatusExtendedType */
#ifndef DEM_TEST_FAILED
#define DEM_TEST_FAILED 1U
#endif /* DEM_TEST_FAILED */
#ifndef DEM_TEST_FAILED_THIS_OPERATION_CYCLE
#define DEM_TEST_FAILED_THIS_OPERATION_CYCLE 2U
#endif /* DEM_TEST_FAILED_THIS_OPERATION_CYCLE */
#ifndef DEM_PENDING_DTC
#define DEM_PENDING_DTC 4U
#endif /* DEM_PENDING_DTC */
#ifndef DEM_CONFIRMED_DTC
#define DEM_CONFIRMED_DTC 8U
#endif /* DEM_CONFIRMED_DTC */
#ifndef DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR
#define DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR 16U
#endif /* DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR */
#ifndef DEM_TEST_FAILED_SINCE_LAST_CLEAR
#define DEM_TEST_FAILED_SINCE_LAST_CLEAR 32U
#endif /* DEM_TEST_FAILED_SINCE_LAST_CLEAR */
#ifndef DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE
#define DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE 64U
#endif /* DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE */
#ifndef DEM_WARNING_INDICATOR_REQUESTED
#define DEM_WARNING_INDICATOR_REQUESTED 128U
#endif /* DEM_WARNING_INDICATOR_REQUESTED */
/** Enum literals for Dem_EventStatusType */
#ifndef DEM_EVENT_STATUS_PASSED
#define DEM_EVENT_STATUS_PASSED 0U
#endif /* DEM_EVENT_STATUS_PASSED */
#ifndef DEM_EVENT_STATUS_FAILED
#define DEM_EVENT_STATUS_FAILED 1U
#endif /* DEM_EVENT_STATUS_FAILED */
#ifndef DEM_EVENT_STATUS_PREPASSED
#define DEM_EVENT_STATUS_PREPASSED 2U
#endif /* DEM_EVENT_STATUS_PREPASSED */
#ifndef DEM_EVENT_STATUS_PREFAILED
#define DEM_EVENT_STATUS_PREFAILED 3U
#endif /* DEM_EVENT_STATUS_PREFAILED */
/** Enum literals for Dem_OperationCycleStateType */
#ifndef DEM_CYCLE_STATE_START
#define DEM_CYCLE_STATE_START 0U
#endif /* DEM_CYCLE_STATE_START */
#ifndef DEM_CYCLE_STATE_END
#define DEM_CYCLE_STATE_END 1U
#endif /* DEM_CYCLE_STATE_END */
/** Enum literals for Dem_ReturnClearDTCType */
#ifndef DEM_CLEAR_OK
#define DEM_CLEAR_OK 0U
#endif /* DEM_CLEAR_OK */
#ifndef DEM_CLEAR_WRONG_DTC
#define DEM_CLEAR_WRONG_DTC 1U
#endif /* DEM_CLEAR_WRONG_DTC */
#ifndef DEM_CLEAR_WRONG_DTCORIGIN
#define DEM_CLEAR_WRONG_DTCORIGIN 2U
#endif /* DEM_CLEAR_WRONG_DTCORIGIN */
#ifndef DEM_CLEAR_WRONG_DTCKIND
#define DEM_CLEAR_WRONG_DTCKIND 3U
#endif /* DEM_CLEAR_WRONG_DTCKIND */
#ifndef DEM_CLEAR_FAILED
#define DEM_CLEAR_FAILED 4U
#endif /* DEM_CLEAR_FAILED */
#ifndef DEM_DTC_PENDING
#define DEM_DTC_PENDING 5U
#endif /* DEM_DTC_PENDING */
#define DEM_EVENT_DESTINATION_END_OF_LIST 0
/*
* DTC storage types
*/
typedef uint8 Dem_DTCTranslationFormatType;
#define DEM_DTC_TRANSLATION_ISO15031_6 0x00
#define DEM_DTC_TRANSLATION_ISO14229_1 0x01
#define DEM_DTC_TRANSLATION_SAEJ1939_73 0x02
#define DEM_DTC_TRANSLATION_ISO11992_4 0x03
/*
* Dem_DTCGroupType
*/
typedef uint32 Dem_DTCGroupType;
#define DEM_DTC_GROUP_EMISSION_REL_DTCS (Dem_DTCGroupType)0x0
#define DEM_DTC_GROUP_ALL_DTCS (Dem_DTCGroupType)0xffffff
/*
* Dem status type
*/
#define DEM_DTC_STATUS_MASK_ALL (uint8)0x00
/*
* Dem_FreezeFrameKindType
*/
typedef uint8 Dem_FreezeFrameKindType; // NOTE: Check type and values
#define DEM_FREEZE_FRAME_NON_OBD (Dem_FreezeFrameKindType)0x01
#define DEM_FREEZE_FRAME_OBD (Dem_FreezeFrameKindType)0x02
/*
* Dem_EventKindType
*/
typedef uint8 Dem_EventKindType; // NOTE: Check type and values
#define DEM_EVENT_KIND_BSW (Dem_EventKindType)0x01
#define DEM_EVENT_KIND_SWC (Dem_EventKindType)0x02
/*
* Dem_PreDebounceNameType
*/
typedef uint8 Dem_PreDebounceNameType;
enum {
DEM_NO_PRE_DEBOUNCE,
DEM_PRE_DEBOUNCE_COUNTER_BASED,
DEM_PRE_DEBOUNCE_TIME_BASED
};
/*
* Dem_FilterWithSeverityType
*/
typedef uint8 Dem_FilterWithSeverityType;
#define DEM_FILTER_WITH_SEVERITY_YES (Dem_FilterWithSeverityType)0x00
#define DEM_FILTER_WITH_SEVERITY_NO (Dem_FilterWithSeverityType)0x01
/*
* Dem_FilterForFDCType
*/
typedef uint8 Dem_FilterForFDCType;
#define DEM_FILTER_FOR_FDC_YES (Dem_FilterForFDCType)0x00
#define DEM_FILTER_FOR_FDC_NO (Dem_FilterForFDCType)0x01
/*
* Dem_DTCSeverityType
*/
typedef uint8 Dem_DTCSeverityType;
#define DEM_SEVERITY_NO_SEVERITY 0x00u /* No severity information available */
#define DEM_SEVERITY_MAINTENANCE_ONLY 0x20u
#define DEM_SEVERITY_CHECK_AT_NEXT_HALT 0x40u
#define DEM_SEVERITY_CHECK_IMMEDIATELY 0x80u
/*
* Dem_ReturnSetDTCFilterType
*/
typedef uint8 Dem_ReturnSetFilterType;
#define DEM_FILTER_ACCEPTED (Dem_ReturnSetFilterType)0x00
#define DEM_WRONG_FILTER (Dem_ReturnSetFilterType)0x01
/*
* Dem_ReturnGetStatusOfDTCType
*/
typedef uint8 Dem_ReturnGetStatusOfDTCType;
#define DEM_STATUS_OK (Dem_ReturnGetStatusOfDTCType)0x00
#define DEM_STATUS_WRONG_DTC (Dem_ReturnGetStatusOfDTCType)0x01
#define DEM_STATUS_WRONG_DTCORIGIN (Dem_ReturnGetStatusOfDTCType)0x02
#define DEM_STATUS_FAILED (Dem_ReturnGetStatusOfDTCType)0x04
#define DEM_STATUS_WRONG_DTCKIND (Dem_ReturnGetStatusOfDTCType)0x03
/*
* Dem_ReturnGetNextFilteredDTCType
*/
typedef uint8 Dem_ReturnGetNextFilteredDTCType;
#define DEM_FILTERED_OK (Dem_ReturnGetNextFilteredDTCType)0x00
#define DEM_FILTERED_NO_MATCHING_DTC (Dem_ReturnGetNextFilteredDTCType)0x01
#define DEM_FILTERED_WRONG_DTCKIND (Dem_ReturnGetNextFilteredDTCType)0x02
#define DEM_FILTERED_PENDING (Dem_ReturnGetNextFilteredDTCType)0x03
/*
* Dem_ReturnGetNumberOfFilteredDTCType
*/
typedef uint8 Dem_ReturnGetNumberOfFilteredDTCType;
#define DEM_NUMBER_OK (Dem_ReturnGetNumberOfFilteredDTCType)0x00
#define DEM_NUMBER_FAILED (Dem_ReturnGetNumberOfFilteredDTCType)0x01
#define DEM_NUMBER_PENDING (Dem_ReturnGetNumberOfFilteredDTCType)0x02
/*
* Dem_ReturnControlDTCStorageType
*/
typedef uint8 Dem_ReturnControlDTCStorageType;
#define DEM_CONTROL_DTC_STORAGE_OK (Dem_ReturnControlDTCStorageType)0x00
#define DEM_CONTROL_DTC_STORAGE_N_OK (Dem_ReturnControlDTCStorageType)0x01
#define DEM_CONTROL_DTC_WRONG_DTCGROUP (Dem_ReturnControlDTCStorageType)0x02
/*
* Dem_ReturnControlEventUpdateType
*/
typedef uint8 Dem_ReturnControlEventUpdateType;
#define DEM_CONTROL_EVENT_UPDATE_OK (Dem_ReturnControlEventUpdateType)0x00
#define DEM_CONTROL_EVENT_N_OK (Dem_ReturnControlEventUpdateType)0x01
#define DEM_CONTROL_EVENT_WRONG_DTCGROUP (Dem_ReturnControlEventUpdateType)0x02
/*
* Dem_ReturnGetExtendedDataRecordByDTCType
*/
typedef uint8 Dem_ReturnGetExtendedDataRecordByDTCType;
#define DEM_RECORD_OK (Dem_ReturnGetExtendedDataRecordByDTCType)0x00
#define DEM_RECORD_WRONG_DTC (Dem_ReturnGetExtendedDataRecordByDTCType)0x01
#define DEM_RECORD_WRONG_DTCORIGIN (Dem_ReturnGetExtendedDataRecordByDTCType)0x02
#define DEM_RECORD_DTCKIND (Dem_ReturnGetExtendedDataRecordByDTCType)0x03
#define DEM_RECORD_NUMBER (Dem_ReturnGetExtendedDataRecordByDTCType)0x04
#define DEM_RECORD_BUFFERSIZE (Dem_ReturnGetExtendedDataRecordByDTCType)0x05
#define DEM_RECORD_PENDING (Dem_ReturnGetExtendedDataRecordByDTCType)0x06
/*
* Dem_ReturnGetDTCByOccurenceTimeType
*/
typedef uint8 Dem_ReturnGetDTCByOccurenceTimeType;
#define DEM_OCCURR_OK (Dem_ReturnGetDTCByOccurenceTimeType)0x00
#define DEM_OCCURR_WRONG_DTCKIND (Dem_ReturnGetDTCByOccurenceTimeType)0x01
#define DEM_OCCURR_FAILED (Dem_ReturnGetDTCByOccurenceTimeType)0x02
/*
* Dem_ReturnGetFreezeFrameDataByDTCType
*/
typedef uint8 Dem_ReturnGetFreezeFrameDataByDTCType;
#define DEM_GET_FFDATABYDTC_OK (Dem_ReturnGetFreezeFrameDataByDTCType)0x00
#define DEM_GET_FFDATABYDTC_WRONG_DTC (Dem_ReturnGetFreezeFrameDataByDTCType)0x01
#define DEM_GET_FFDATABYDTC_WRONG_DTCORIGIN (Dem_ReturnGetFreezeFrameDataByDTCType)0x02
#define DEM_GET_FFDATABYDTC_WRONG_DTCKIND (Dem_ReturnGetFreezeFrameDataByDTCType)0x03
#define DEM_GET_FFDATABYDTC_RECORDNUMBER (Dem_ReturnGetFreezeFrameDataByDTCType)0x04
#define DEM_GET_FFDATABYDTC_WRONG_DATAID (Dem_ReturnGetFreezeFrameDataByDTCType)0x05
#define DEM_GET_FFDATABYDTC_BUFFERSIZE (Dem_ReturnGetFreezeFrameDataByDTCType)0x06
#define DEM_GET_ID_PENDING (Dem_ReturnGetFreezeFrameDataByDTCType)0x07
/*
* Dem_ReturnGetSizeOfExtendedDataRecordByDTCType
*/
typedef uint8 Dem_ReturnGetSizeOfExtendedDataRecordByDTCType;
#define DEM_GET_SIZEOFEDRBYDTC_OK (Dem_ReturnGetSizeOfExtendedDataRecordByDTCType)0x00
#define DEM_GET_SIZEOFEDRBYDTC_W_DTC (Dem_ReturnGetSizeOfExtendedDataRecordByDTCType)0x01
#define DEM_GET_SIZEOFEDRBYDTC_W_DTCOR (Dem_ReturnGetSizeOfExtendedDataRecordByDTCType)0x02
#define DEM_GET_SIZEOFEDRBYDTC_W_DTCKI (Dem_ReturnGetSizeOfExtendedDataRecordByDTCType)0x03
#define DEM_GET_SIZEOFEDRBYDTC_W_RNUM (Dem_ReturnGetSizeOfExtendedDataRecordByDTCType)0x04
#define DEM_GET_SIZEOFEDRBYDTC_PENDING (Dem_ReturnGetSizeOfExtendedDataRecordByDTCType)0x05
/*
* Dem_ReturnGetSizeOfFreezeFrameType
*/
typedef uint8 Dem_ReturnGetSizeOfFreezeFrameType;
#define DEM_GET_SIZEOFFF_OK (Dem_ReturnGetSizeOfFreezeFrameType)0x00
#define DEM_GET_SIZEOFFF_WRONG_DTC (Dem_ReturnGetSizeOfFreezeFrameType)0x01
#define DEM_GET_SIZEOFFF_WRONG_DTCOR (Dem_ReturnGetSizeOfFreezeFrameType)0x02
#define DEM_GET_SIZEOFFF_WRONG_DTCKIND (Dem_ReturnGetSizeOfFreezeFrameType)0x03
#define DEM_GET_SIZEOFFF_WRONG_RNUM (Dem_ReturnGetSizeOfFreezeFrameType)0x04
#define DEM_GET_SIZEOFFF_PENDING (Dem_ReturnGetSizeOfFreezeFrameType)0x05
/*******************************************************
* Definitions where the type is declared in Rte_Dem.h *
*******************************************************/
/*
* DemDTCKindType definitions
*/
typedef uint8 Dem_DTCKindType;
#ifndef DEM_DTC_KIND_ALL_DTCS
#define DEM_DTC_KIND_ALL_DTCS (Dem_DTCKindType)0x01
#endif /* DEM_DTC_KIND_ALL_DTCS */
#ifndef DEM_DTC_KIND_EMISSION_REL_DTCS
#define DEM_DTC_KIND_EMISSION_REL_DTCS (Dem_DTCKindType)0x02
#endif /* DEM_DTC_KIND_EMISSION_REL_DTCS */
/*
* Dem_InitMonitorKindType definitions
*/
#ifndef DEM_INIT_MONITOR_CLEAR
#define DEM_INIT_MONITOR_CLEAR (Dem_InitMonitorReasonType)1
#endif /* DEM_INIT_MONITOR_CLEAR */
#ifndef DEM_INIT_MONITOR_RESTART
#define DEM_INIT_MONITOR_RESTART (Dem_InitMonitorReasonType)2
#endif /* DEM_INIT_MONITOR_RESTART */
/*
* Dem_IndicatorStatusType definitions
*/
#ifndef DEM_INDICATOR_OFF
#define DEM_INDICATOR_OFF 0U
#endif /* DEM_INDICATOR_OFF */
#ifndef DEM_INDICATOR_CONTINUOUS
#define DEM_INDICATOR_CONTINUOUS 1U
#endif /* DEM_INDICATOR_CONTINUOUS */
#ifndef DEM_INDICATOR_BLINKING
#define DEM_INDICATOR_BLINKING 2U
#endif /* DEM_INDICATOR_BLINKING */
#ifndef DEM_INDICATOR_BLINK_CONT
#define DEM_INDICATOR_BLINK_CONT 3U
#endif /* DEM_INDICATOR_BLINK_CONT */
/*
* DemOperationCycleType definitions
*/
enum {
DEM_ACTIVE, // Started by DEM on Dem_PreInit and stopped on Dem_Shutdown
DEM_POWER, // Power ON/OFF Cycle
DEM_IGNITION, // Ignition ON/OF Cycle
DEM_WARMUP, // OBD Warm up Cycle
DEM_OBD_DCY, // OBD Driving Cycle
DEM_OPERATION_CYCLE_ID_ENDMARK
};/** @req DEM480 */
/*
* Dem_ReturnGetSeverityOfDTCType
*/
typedef uint8 Dem_ReturnGetSeverityOfDTCType;
#define DEM_GET_SEVERITYOFDTC_OK (Dem_ReturnGetSeverityOfDTCType)0x00
#define DEM_GET_SEVERITYOFDTC_WRONG_DTC (Dem_ReturnGetSeverityOfDTCType)0x01
#define DEM_GET_SEVERITYOFDTC_NOSEVERITY (Dem_ReturnGetSeverityOfDTCType)0x02
#define DEM_GET_SEVERITYOFDTC_PENDING (Dem_ReturnGetSeverityOfDTCType)0x03
/*
* Dem_ReturnDisableDTCRecordUpdateType
*/
typedef uint8 Dem_ReturnDisableDTCRecordUpdateType;
#define DEM_DISABLE_DTCRECUP_OK (Dem_ReturnDisableDTCRecordUpdateType)0x00
#define DEM_DISABLE_DTCRECUP_WRONG_DTC (Dem_ReturnDisableDTCRecordUpdateType)0x01
#define DEM_DISABLE_DTCRECUP_WRONG_DTCORIGIN (Dem_ReturnDisableDTCRecordUpdateType)0x02
#define DEM_DISABLE_DTCRECUP_PENDING (Dem_ReturnDisableDTCRecordUpdateType)0x03
/*
* Dem_ReturnGetSizeOfFreezeFrameByDTCType
*/
typedef uint8 Dem_ReturnGetSizeOfFreezeFrameByDTCType;
//conflict in type check
//#define DEM_GET_SIZEOFFF_OK (Dem_ReturnGetSizeOfFreezeFrameByDTCType)0x00
//#define DEM_GET_SIZEOFFF_WRONG_DTC (Dem_ReturnGetSizeOfFreezeFrameByDTCType)0x01
//#define DEM_GET_SIZEOFFF_WRONG_DTCOR (Dem_ReturnGetSizeOfFreezeFrameByDTCType)0x02
//#define DEM_GET_SIZEOFFF_WRONG_RNUM (Dem_ReturnGetSizeOfFreezeFrameByDTCType)0x03
//#define DEM_GET_SIZEOFFF_PENDING (Dem_ReturnGetSizeOfFreezeFrameByDTCType)0x04
/*
* Dem_ReturnGetFreezeFrameDataByDTCType
*/
//typedef uint8 Dem_ReturnGetFreezeFrameDataByDTCType;
//#define DEM_GET_FFDATABYDTC_OK (Dem_ReturnGetFreezeFrameDataByDTCType)0x00
//#define DEM_GET_FFDATABYDTC_WRONG_DTC (Dem_ReturnGetFreezeFrameDataByDTCType)0x01
//#define DEM_GET_FFDATABYDTC_WRONG_DTCORIGIN (Dem_ReturnGetFreezeFrameDataByDTCType)0x02
//#define DEM_GET_FFDATABYDTC_WRONG_RECORDNUMBER (Dem_ReturnGetFreezeFrameDataByDTCType)0x03
//#define DEM_GET_FFDATABYDTC_WRONG_BUFFERSIZE (Dem_ReturnGetFreezeFrameDataByDTCType)0x04
#define DEM_GET_FFDATABYDTC_PENDING (Dem_ReturnGetFreezeFrameDataByDTCType)0x05
#define DEM_RECORD_WRONG_NUMBER (Dem_ReturnGetExtendedDataRecordByDTCType)0x03
#endif /*DEM_TYPES_H_*/

View File

@ -0,0 +1,451 @@
#ifndef __FICOSEKCOM_H
#define __FICOSEKCOM_H
/*-------------------------------- Includes ------------------------------*/
#include "Std_Types.h"
#include "DiagnosticL/Comp_HAL_Autosar_Wrappers/FicosarCAN.h"
#include "OsekCom/OsekCom.h"
/*-------------------------------- Defines -------------------------------*/
/*----------------------------- Data Types -------------------------------*/
typedef UI_8 t_sig_diagnosticreqprndl[8];
typedef UI_8 t_sig_diagnosticfuncaddrreq[8];
#ifndef _FICOSEKCOM_H
#define _FICOSEKCOM_H
/* Type definition of the symbolic names for signals */
typedef UI_16 t_symbolic_name;
typedef UI_16 t_symbolic_frm_name;
/* Return type of the calls OSEK COM */
typedef UI_8 t_status_type;
/* Structure of data type passed by reference in */
/* the calls of OSEK COM */
typedef void *t_application_data_ref;
typedef void *t_length_ref;
/* Flag types of OSEK COM */
//typedef enum {
//COM_FALSE = 0x00, /* Flag down */
// COM_TRUE = 0x01 /* Flag up */
//} t_flag_value;
/* Stop mode of OSEK COM */
//typedef enum {
// COM_SHUTDOWN_IMMEDIATE = 0 /* Apagat immediat */
//} t_com_shutdown_mode_type;
/* Initialize mode of OSEK COM */
//typedef enum {
// COM_NORMAL_MODE = 0 /* No es processen trames de COM de Debug */
//} t_com_application_mode_type;
#endif
/*--------------------------- Global Variables ---------------------------*/
/*----------- Prototypes of Callback Function Provided by User ----------*/
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Notification Callbacks provided by user for class 1 (RxNotif), 3 (RxErrorNotif)
| 2 (TxNotif) and 4 (TxErrorNotif)
| ---------------------------------------------------------------------------
| Parameters description:
/ ------------------------------------------------- -------------------------- */
#define COMCallback(CallbackRoutineName) void CallbackRoutineName(void)
//COMCallback(VCU_RX_Timeout_Callback);
//COMCallback(CGW_BCM_Status1_Timeout_Callback);
COMCallback(SHIFT_Tx_Callback);
COMCallback(SHIFT_Tx_Error_Callback);
/* --------------------------- Routine Prototypes --------------------------- */
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Reception of a new frame notification callback
| * This callback must be launched by the lower COM driver upon the reception
| of a new frame.
|---------------------------------------------------------------------------
| Parameters description:
| bhdl: Handler of the buffer where the received frame is stored.
/---------------------------------------------------------------------------*/
void OsekComRxNotifCallbackPRNDL(t_com_buf_hdl bhdl);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Available transmission buffer notification callback
| * This callback must be launched by the lower COM driver upon a transmission
| buffer will become available after requesting one to perform a transmission.
|---------------------------------------------------------------------------
| Parameters description:
| return: TRUE in case that after current transmission lower COM driver should
| call again this callback to transmit a new frame.
| FALSE otherwise.
/---------------------------------------------------------------------------*/
BOOL OsekComTxReqCallbackPRNDL(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Frame transmission confirmation notifying callback
| * This callback must be launched by the lower COM driver upon the completion
| of a frame transmission for which transmission confirmation has been requested
|---------------------------------------------------------------------------
| Parameters description:
| bhdl: Handler of the buffer where the transmitted frame is stored.
/---------------------------------------------------------------------------*/
void OsekComTxNotifCallbackPRNDL(t_com_buf_hdl bhdl);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to initialize OsekCom stack
|
| ------------------------------------------------- --------------------------
| Parameters description:
| app_mode: OsekCom initialization mode (See t_com_application_mode_type)
| return: E_OK in case of no errors
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
//t_status_type StartCom(t_com_application_mode_type app_mode);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to inquiry in which mode OsekCom has been initialized.
| * If this service is called before initializing the communications stack
| a random mode will be returned.
| ---------------------------------------------------------------------------
| Parameters description:
| return: OsekCom initialization mode(See t_com_application_mode_type)
/ --------------------------------------------------------------------------- */
//t_com_application_mode_type GetComApplicationMode(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to close the OsekCom stack.
| * This service stops the transmission of periodic frames.
| * After calling this service communications could be re-established
| calling again service StartCom.
| * This service does not change the state of any lower COM driver.
| ---------------------------------------------------------------------------
| Parameters description:
| shtdwn_mode: OsekCom stop mode (See t_com_shutdown_mode_type)
| return: E_OK in case of no errors
| Other (see t_status_type).
/ --------------------------------------------------------------------------- */
//t_status_type StopCom(t_com_shutdown_mode_type shtdwn_mode);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to start the transmission of periodic or mixed frames.
| * If this service is re-executed then transmission timers will be re-started.
|---------------------------------------------------------------------------
| Parameters description:
| return: E_OK in case of no errors
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type StartPeriodic(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to stop the transmission of periodic or mixed frames.
| * To re-start the transmission of periodic or mixed frames service
| StartPeriodic must be called.
|---------------------------------------------------------------------------
| Parameters description:
| return: E_OK in case of no errors
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type StopPeriodic(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates the application variable referenced by >data_ref< with
| the data stored in the internal stack for the object identified by >message<.
| * This service will reset the class 1 (RxNotif) and 3 (RxErrorNotif) flags
| associated to >message<
| * If >message< is an enqueued signal the service will return the data
| stored in the internal stack (initial value / last received value / last value
| set with InitMessage)
| If >message< is a queued signal the service will return the first value
| available in the queue or error if the queue is empty. (Mode not supported)
| * The user is responsible of granting that the parameter >data_ref<
| points to a variable correctly allocated and compatible in size with the
| received signal type
| * Usage example:
| t_vehicle_speed vehicle_speed;
| (void)ReceiveMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal to be retrieved.
| data_ref: Pointer to a variable where to store the requested signal.
| return:
| E_OK in case of no errors
| E_COM_ID in case the parameter >message< is out of range or if it refers
| to signal that is sent, dynamic length or zero-length
| E_COM_NOMSG in case the queued signal identified by >message< is empty.
| E_COM_LIMIT in case an overflow of the queue of the signal identified by >message<
| occurred since the last call to ReceiveMessage for >message<.
| E_COM_LIMIT indicates that at least one message has been discarded
| since the message queue filled. Nevertheless the service is
| performed and a message is returned. The service ReceiveMessage
| clears the overflow condition for >message<.
| other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type ReceiveMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates the application variable referenced by >data_ref< with
| the data stored in the internal stack for the object identified by >message<.
| * The length of the received signal data will be placed in the variable
| referenced by >length_ref<.
| * This service will reset the class 1 (RxNotif) and 3 (RxErrorNotif) flags
| associated to >message<
| * This service could be used with enqueued messages only. This service is
| provided for external communication only.
| * The service will return the data stored in the internal stack
| (initial value / last received value / last value set with InitMessage)
| * The user is responsible of granting that the parameters >data_ref<
| and >lenght_ref< point to variables correctly allocated and compatible in
| size with the received signal type
| * Usage example:
| t_vehicle_speed vehicle_speed;
| t_length_ref length_ref;
| (void)ReceiveDynamicMessage(SIG_VEHICLE_SPEED,&vehicle_speed,&length_ref);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal to be retrieved.
| data_ref: Pointer to a variable where to store the requested signal.
| lenght_ref: Pointer to a variable where to store the retrieved signal size.
| return:
| E_OK in case of no errors
| E_COM_ID in case the parameter >message< is out of range or if it refers
| to a message that is sent, a queued message, a static-length
| message or a zero-length message.
| other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type ReceiveDynamicMessage(t_symbolic_name message,
t_application_data_ref data_ref,
t_length_ref length_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates OsekCom internal data structure of the signal
| identified by >message< with the data referenced by the variable
| referenced by >data_ref< parameter.
| * This service will reset the class 2 (TxNotif) and 4 (TxErrorNotif) flags
| associated to >message<
| * If >message< has the Triggered Transfer Property, the update will be
| followed by immediate transmission of the I-PDU associated with the signal except
| when the signal is packed into an I-PDU with Periodic Transmission Mode.
| In this case, no transmission is initiated by the call to this service.
| * If >message< has the Pending Transfer Property, no transmission is
| triggered by the usage of this service.
| * The user is responsible of granting that the parameter >data_ref<
| points to a variable correctly allocated and compatible in size with the
| transmitted signal type.
| * Usage example:
| t_vehicle_speed vehicle_speed = 20;
| (void)SendMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal to be transmitted.
| data_ref: Pointer to a variable containing the data to be transmitted.
| return:
| E_OK in case of no errors
| E_COM_ID is case the parameter >message< is out of range or if it refers
| to a message that is received or to a dynamic-length or
| zero-length message.
| other (see t_status_type).
/---------------------------------------------------------------------------*/
#define OSEK_SENDMESSAGE
t_status_type SendMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates OsekCom internal data structure of the signal
| identified by >message< with the data referenced by variables
| referenced by >data_ref< and >lenght_ref<
| * This service will reset the class 2 (TxNotif) and 4 (TxErrorNotif) flags
| associated to >message<
| * If >message< has the Triggered Transfer Property, the update is followed
| by immediate transmission of the I-PDU associated with the signal except
| when the signal is packed into an I-PDU with Periodic Transmission Mode.
| In this case, no transmission is initiated by the call to this service.
| * If >message< has the Pending Transfer Property, no transmission is
| caused by the usage of this service.
| * This service can be used with enqueued messages only. This service is
| provided for external communication only.
| * The user is responsible of granting that the parameters >data_ref<
| and >lenght_ref< points to variables correctly allocated and
| compatible in size with the transmitted signal type.
| * Usage example:
| t_vehicle_speed vehicle_speed = 20;
| t_length_ref length_ref = 1;
| (void)SendDynamicMessage(SIG_VEHICLE_SPEED, &vehicle_speed, &length_ref);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal to be transmitted.
| data_ref: Pointer to a variable containing the data to be transmitted.
| lenght_ref: Pointer to a variable containing the size of the signal
| to be transmitted.
| return:
| E_OK in case of no errors
| E_COM_ID in case the parameter >message< is out of range or if it refers
| to a received signal, a static-length signal or a zero-length signal.
| E_COM_LENGTH in case the value to which >length_ref< points is not within
| the range 0 to the maximum length defined for >message<.
| other (see t_status_type).
/---------------------------------------------------------------------------*/
#define OSEK_SENDDYNAMICMESSAGE
t_status_type SendDynamicMessage(t_symbolic_name message,
t_application_data_ref data_ref,
t_length_ref length_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates OsekCom internal data structure of the signal
| identified by >message< with the data referenced by the variable
| referenced by >data_ref<
| * This service will not reset any class flags associated to >message<
| * This service will not initiate any transmission.
| * The user is responsible of granting that the parameter 'data_ref'
| points to an address correctly allocated and compatible in size with the
| transmitted signal type.
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal.
| data_ref: Pointer to a variable containing the data.
| return:
| E_OK in case of no errors
| E_COM_ID if the message or signal to initialize don't exist
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type InitMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Consult service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| COM_FALSE if has not been detected any communication activity since
| last clear
| COM_TRUE if has been detected communication activity since last clear
/---------------------------------------------------------------------------*/
t_flag_value ReadFlagComTrafficPRNDL(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Reset service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void ResetFlagComTrafficPRNDL(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Consult service to retrieve the state of class 1 (RxNotif),
| class 3 (Rx_ErrorNotif), class 2 (TxNotif) and class 4 (Tx_ErrorNotif) flags
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal.
| return:
| COM_FALSE if the flag is down
| COM_TRUE if the flag is up
/---------------------------------------------------------------------------*/
t_flag_value ReadFlagRxSig(t_symbolic_name message);
t_flag_value ReadFlagTxSig(t_symbolic_name message);
t_flag_value ReadFlagTxSigDiagnosticRespPRNDL(void);
t_flag_value ReadFlagTxErrorSig(t_symbolic_name message);
t_flag_value ReadFlagTxErrorSigDiagnosticRespPRNDL(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Consult service to enable tx message flag
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void EnableTxFrm_diag_physresp_prndl(void);
void DisableTxFrm_diag_physresp_prndl(void);
void EnableTxFrm_shiftselectposition(void);
void DisableTxFrm_shiftselectposition(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Reset service for the notify class 1 (RxNotif) class 3 (RxErrorNotif)
| class 2 (TxNotif) and class 4 (TxErrorNotif)
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal.
/---------------------------------------------------------------------------*/
void ResetFlagRxSig(t_symbolic_name message);
//void ResetFlagRxSigDiagnosticReqSWTL(void);
void ResetFlagRxSigDiagnosticFuncAddrReq(void);
void ResetFlagTxSig(t_symbolic_name message);
void ResetFlagTxErrorSig(t_symbolic_name message);
void ResetFlagTxErrorSigDiagnosticRespSWTL(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Main runnable of the OsekCom stack intended to be called periodically by
| the system scheduler with a period equal to FICOSEK_COM_TASK_TICKS
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void OsekComTask(void);
#endif

View File

@ -0,0 +1,597 @@
#ifndef _Internal_FICOSEKCOM_H
#define _Internal_FICOSEKCOM_H
/*-------------------------------- includes ------------------------------*/
#include "Global.h"
#include "SpiFrameWrapper.h"
/*-------------------------------- defines -------------------------------*/
/* Return type of the calls OSEK COM */
#ifndef STD_TYPES_H
#define E_OK ((UI_8)0x00) /* Service call has succeeded */
#endif
#define E_COM_ID ((UI_8)0x01) /* Given message or mode identifier */
/* is out of range or invalid */
#define E_COM_LENGTH ((UI_8)0x02) /* Given data length is out of range */
#define E_COM_LIMIT ((UI_8)0x03) /* Overflow of message queue */
#define E_COM_NOMSG ((UI_8)0x04) /* Message queue is empty */
#define E_COM_SYS_NOINIT ((UI_8)0x05) /* User defined E_COM_SYS_?? */
/* Node id */
#define NODE_ID_MASK ((UI_16) 0xF000) /* Mask to get nodes id */
#define NODE_ID_MMC (((UI_16) 0x1000) & NODE_ID_MASK) /* Symbolic name of the node MMC */
/* Symbolic names for Tx signals with static length */
/* First tx signal */
#define INTERNALFIRST_TX_STA_LEN_SIGNAL_SYMBOLIC_NAME ((~NODE_ID_MASK) & SIG_MMC_ACTU_UDS_MODE)
#define SIG_MMC_ACTU_UDS_MODE (((UI_16) 1) | NODE_ID_MMC) /* Symbolic name of the signal MMC_ACTU_uds_mode */
#define SIG_MMC_APPLICATION_MODE (((UI_16) 2) | NODE_ID_MMC) /* Symbolic name of the signal MMC_application_mode */
#define SIG_MMC_CLOCK_ATCU_A112 (((UI_16) 3) | NODE_ID_MMC) /* Symbolic name of the signal MMC_Clock_ATCU_A112 */
#define SIG_MMC_CRC_ATCU_A112 (((UI_16) 4) | NODE_ID_MMC) /* Symbolic name of the signal MMC_CRC_ATCU_A112 */
#define SIG_MMC_D_LOCK_UDS_OFFSET (((UI_16) 5) | NODE_ID_MMC) /* Symbolic name of the signal MMC_d_lock_uds_offset */
#define SIG_MMC_D_N_UDS_OFFSET (((UI_16) 6) | NODE_ID_MMC) /* Symbolic name of the signal MMC_d_n_uds_offset */
#define SIG_MMC_D_OUT_UDS_OFFSET (((UI_16) 7) | NODE_ID_MMC) /* Symbolic name of the signal MMC_d_out_uds_offset */
#define SIG_MMC_D_UDS_DIE1_SETPOINT (((UI_16) 8) | NODE_ID_MMC) /* Symbolic name of the signal MMC_d_uds_die1_setpoint */
#define SIG_MMC_D_UDS_DIE2_SETPOINT (((UI_16) 9) | NODE_ID_MMC) /* Symbolic name of the signal MMC_d_uds_die2_setpoint */
#define SIG_MMC_GEARLEVERPOSITIONEXTENDED_V2 (((UI_16) 10) | NODE_ID_MMC) /* Symbolic name of the signal MMC_GearLeverPositionExtended_v2 */
#define SIG_MMC_IGNITIONSUPPLYCONFIRMATION (((UI_16) 11) | NODE_ID_MMC) /* Symbolic name of the signal MMC_IgnitionSupplyConfirmation */
#define SIG_MMC_MELEXIS_VIRTUAL_DIE1 (((UI_16) 12) | NODE_ID_MMC) /* Symbolic name of the signal MMC_melexis_virtual_die1 */
#define SIG_MMC_MELEXIS_VIRTUAL_DIE2 (((UI_16) 13) | NODE_ID_MMC) /* Symbolic name of the signal MMC_melexis_virtual_die2 */
#define SIG_MMC_MLX_POSITION (((UI_16) 14) | NODE_ID_MMC) /* Symbolic name of the signal MMC_mlx_position */
#define SIG_MMC_N_D_UDS_OFFSET (((UI_16) 15) | NODE_ID_MMC) /* Symbolic name of the signal MMC_n_d_uds_offset */
#define SIG_MMC_N_R_UDS_OFFSET (((UI_16) 16) | NODE_ID_MMC) /* Symbolic name of the signal MMC_n_r_uds_offset */
#define SIG_MMC_N_UDS_DIE1_SETPOINT (((UI_16) 17) | NODE_ID_MMC) /* Symbolic name of the signal MMC_n_uds_die1_setpoint */
#define SIG_MMC_N_UDS_DIE2_SETPOINT (((UI_16) 18) | NODE_ID_MMC) /* Symbolic name of the signal MMC_n_uds_die2_setpoint */
#define SIG_MMC_P_LOCK_UDS_OFFSET (((UI_16) 19) | NODE_ID_MMC) /* Symbolic name of the signal MMC_p_lock_uds_offset */
#define SIG_MMC_P_OUT_UDS_OFFSET (((UI_16) 20) | NODE_ID_MMC) /* Symbolic name of the signal MMC_p_out_uds_offset */
#define SIG_MMC_P_R_UDS_OFFSET (((UI_16) 21) | NODE_ID_MMC) /* Symbolic name of the signal MMC_p_r_uds_offset */
#define SIG_MMC_P_UDS_DIE1_SETPOINT (((UI_16) 22) | NODE_ID_MMC) /* Symbolic name of the signal MMC_p_uds_die1_setpoint */
#define SIG_MMC_P_UDS_DIE2_SETPOINT (((UI_16) 23) | NODE_ID_MMC) /* Symbolic name of the signal MMC_p_uds_die2_setpoint */
#define SIG_MMC_RELAY_SELFCHECK_REQUEST (((UI_16) 24) | NODE_ID_MMC) /* Symbolic name of the signal MMC_relay_selfcheck_request */
#define SIG_MMC_R_N_UDS_OFFSET (((UI_16) 25) | NODE_ID_MMC) /* Symbolic name of the signal MMC_r_n_uds_offset */
#define SIG_MMC_R_P_UDS_OFFSET (((UI_16) 26) | NODE_ID_MMC) /* Symbolic name of the signal MMC_r_p_uds_offset */
#define SIG_MMC_R_UDS_DIE1_SETPOINT (((UI_16) 27) | NODE_ID_MMC) /* Symbolic name of the signal MMC_r_uds_die1_setpoint */
#define SIG_MMC_R_UDS_DIE2_SETPOINT (((UI_16) 28) | NODE_ID_MMC) /* Symbolic name of the signal MMC_r_uds_die2_setpoint */
#define SIG_MMC_SCU_GEARBOXPOSITIONTARGET (((UI_16) 29) | NODE_ID_MMC) /* Symbolic name of the signal MMC_SCU_GearboxPositionTarget */
#define SIG_MMC_UDS_SETPOINTS_CRC (((UI_16) 30) | NODE_ID_MMC) /* Symbolic name of the signal MMC_uds_setpoints_crc */
#define SIG_MMC_UDS_SETPOINTS_RC (((UI_16) 31) | NODE_ID_MMC) /* Symbolic name of the signal MMC_uds_setpoints_rc */
/* Last tx signal */
#define INTERNALLAST_TX_STA_LEN_SIGNAL_SYMBOLIC_NAME ((~NODE_ID_MASK) & SIG_MMC_UDS_SETPOINTS_RC)
/* Symbolic names for Rx signals */
#define SIG_SMC_BMAR_SNS (((UI_16) 32) | NODE_ID_MMC) /* Symbolic name of the signal SMC_bmar_sns */
#define SIG_SMC_CALIBRATION_NOP (((UI_16) 33) | NODE_ID_MMC) /* Symbolic name of the signal SMC_calibration_NOP */
#define SIG_SMC_FW_VERSION (((UI_16) 34) | NODE_ID_MMC) /* Symbolic name of the signal SMC_fw_version */
#define SIG_SMC_MELEXIS_DIAGNOSTICS (((UI_16) 35) | NODE_ID_MMC) /* Symbolic name of the signal SMC_melexis_diagnostics */
#define SIG_SMC_MLX_COOK_DIE1 (((UI_16) 36) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_cook_die1 */
#define SIG_SMC_MLX_COOK_DIE2 (((UI_16) 37) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_cook_die2 */
#define SIG_SMC_MLX_CURRENT_POSITION (((UI_16) 38) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_current_position */
#define SIG_SMC_MLX_RAW_DIE1 (((UI_16) 39) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_raw_die1 */
#define SIG_SMC_MLX_RAW_DIE2 (((UI_16) 40) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_raw_die2 */
#define SIG_SMC_MLX_TEMPERATURE_DIE1 (((UI_16) 41) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_temperature_die1 */
#define SIG_SMC_MLX_TEMPERATURE_DIE2 (((UI_16) 42) | NODE_ID_MMC) /* Symbolic name of the signal SMC_MLX_temperature_die2 */
#define SIG_SMC_MODE_CONTOLER (((UI_16) 43) | NODE_ID_MMC) /* Symbolic name of the signal SMC_mode_contoler */
#define SIG_SMC_RELAY_STATUS (((UI_16) 44) | NODE_ID_MMC) /* Symbolic name of the signal SMC_relay_status */
#define SIG_SMC_VBAT_MOTOR_SUP_SNS (((UI_16) 45) | NODE_ID_MMC) /* Symbolic name of the signal SMC_vbat_motor_sup_sns */
/* Symbolic names for Dummy signal */
#define INTERNALSIGDUMMY ((UI_16)0x0FFF) /* Symbolic name of the signal SIGDUMMY */
/*----------------------------- data types -------------------------------*/
/* Type definition of internal signals */
typedef SI_16 t_sig_mmc_p_uds_die1_setpoint;
typedef SI_16 t_sig_mmc_r_uds_die1_setpoint;
typedef SI_16 t_sig_mmc_n_uds_die1_setpoint;
typedef SI_16 t_sig_mmc_d_uds_die1_setpoint;
typedef SI_16 t_sig_mmc_p_uds_die2_setpoint;
typedef SI_16 t_sig_mmc_r_uds_die2_setpoint;
typedef SI_16 t_sig_mmc_n_uds_die2_setpoint;
typedef SI_16 t_sig_mmc_d_uds_die2_setpoint;
typedef UI_8 t_sig_mmc_p_lock_uds_offset;
typedef UI_8 t_sig_mmc_p_r_uds_offset;
typedef UI_8 t_sig_mmc_r_p_uds_offset;
typedef UI_8 t_sig_mmc_r_n_uds_offset;
typedef UI_8 t_sig_mmc_n_r_uds_offset;
typedef UI_8 t_sig_mmc_n_d_uds_offset;
typedef UI_8 t_sig_mmc_d_n_uds_offset;
typedef UI_8 t_sig_mmc_d_lock_uds_offset;
typedef SI_16 t_sig_mmc_uds_setpoints_rc;
typedef SI_8 t_sig_mmc_uds_setpoints_crc;
typedef UI_8 t_sig_mmc_p_out_uds_offset;
typedef UI_8 t_sig_mmc_d_out_uds_offset;
typedef UI_8 t_sig_mmc_scu_gearboxpositiontarget;
typedef UI_8 t_sig_mmc_gearleverpositionextended_v2;
typedef UI_8 t_sig_mmc_clock_atcu_a112;
typedef UI_8 t_sig_mmc_crc_atcu_a112;
typedef UI_8 t_sig_mmc_ignitionsupplyconfirmation;
typedef UI_8 t_sig_mmc_actu_uds_mode;
typedef UI_8 t_sig_mmc_mlx_position;
typedef SI_16 t_sig_mmc_melexis_virtual_die1;
typedef SI_16 t_sig_mmc_melexis_virtual_die2;
typedef UI_8 t_sig_mmc_relay_selfcheck_request;
typedef UI_8 t_sig_mmc_application_mode;
typedef SI_16 t_sig_smc_mlx_cook_die1;
typedef SI_16 t_sig_smc_mlx_cook_die2;
typedef UI_8 t_sig_smc_mode_contoler;
typedef SI_8 t_sig_smc_mlx_current_position;
typedef UI_16 t_sig_smc_vbat_motor_sup_sns;
typedef UI_16 t_sig_smc_bmar_sns;
typedef SI_16 t_sig_smc_mlx_raw_die1;
typedef SI_16 t_sig_smc_mlx_raw_die2;
typedef UI_8 t_sig_smc_mlx_temperature_die1;
typedef UI_8 t_sig_smc_mlx_temperature_die2;
typedef UI_8 t_sig_smc_fw_version;
typedef UI_8 t_sig_smc_melexis_diagnostics;
typedef UI_8 t_sig_smc_relay_status;
typedef UI_8 t_sig_smc_calibration_nop[8];
#ifndef _FICOSEKCOM_H
#define _FICOSEKCOM_H
/* Type definition of the symbolic names for signals */
typedef UI_16 t_symbolic_name;
typedef UI_16 t_symbolic_frm_name;
/* Return type of the calls OSEK COM */
typedef UI_8 t_status_type;
/* Structure of data type passed by reference in */
/* the calls of OSEK COM */
typedef void *t_application_data_ref;
typedef void *t_length_ref;
/* Flag types of OSEK COM */
typedef enum {
COM_FALSE = 0x00, /* Flag down */
COM_TRUE = 0x01 /* Flag up */
} t_flag_value;
/* Stop mode of OSEK COM */
typedef enum {
COM_SHUTDOWN_IMMEDIATE = 0 /* Apagat immediat */
} t_com_shutdown_mode_type;
/* Initialize mode of OSEK COM */
typedef enum {
COM_NORMAL_MODE = 0 /* No es processen trames de COM de Debug */
} t_com_application_mode_type;
#endif
/*--------------------------- global variables ---------------------------*/
/*------------------------- prototips de funcions ------------------------*/
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Reception callback Routine of COM frames
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void InternalOsekComRxNotifCallbackMMC(t_com_buf_hdl bhdl);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Transmission callback Routine of COM frames
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL InternalOsekComTxReqCallbackMMC(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Notifying transmission callback Routine of COM frames
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void InternalOsekComTxNotifCallbackMMC(t_com_buf_hdl bhdl);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Initialize service of OSEK COM in the selected mode
|
| ------------------------------------------------- --------------------------
| Explanation of arguments:
| App_mode: activation model of communications.
| Result: if all goes well E_OK
| Another code (see t_status_type) if an error occurs.
|---------------------------------------------------------------------------
| Temporitzacio:
| Tmax: ?? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type InternalStartCom(t_com_application_mode_type app_mode);
/*****************************************************************************
| Portability: Generic
| ----------------------------------------------------------------------------
| Contract transactions:
| * Service inquiry mode in which communications are initialized
| COM.
| * If this service is called before initializing the communications
| Random mode will be returned.
| ---------------------------------------------------------------------------
| Explanation of arguments:
| Result: how they have been enabled communications
| (See t_com_application_mode_type)
| ---------------------------------------------------------------------------
| Timing:
| Tmax: 15 cpu cycles | O (n): CTE
/ --------------------------------------------------------------------------- */
t_com_application_mode_type InternalGetComApplicationMode(void);
/*****************************************************************************
| Portability: Generic
| ----------------------------------------------------------------------------
| Contract transactions:
| * Service stopped the activity of OSEK COM communications.
| * This service stops the transmission of messages periodically.
| * After calling this service communications can be reestablished
| Calling service StartCom. (At no time this service modifies the state
| COM driver).
| ---------------------------------------------------------------------------
| Explanation of arguments:
| App_mode: Stop mode communications.
| Result: if all goes well E_OK
| Another code (see t_status_type) if an error occurs.
| ---------------------------------------------------------------------------
| Timing:
| Tmax:? cpu cycles | O (n): CTE
/ --------------------------------------------------------------------------- */
t_status_type InternalStopCom(t_com_shutdown_mode_type shtdwn_mode);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Initialize service transmission of periodic or mix frames.
| * If the transmission of periodic or mix frames is initialized, this service
| reboot the communication.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| E_OK in case of no errors
| Other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type InternalStartPeriodic(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Stop service transmission of periodic or mix frames.
| * If the transmission of periodic or mix frames is stopped, you can restart
| it calling the StartPeriodic service.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| E_OK in case of no errors
| Other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type InternalStopPeriodic(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * This service updates the application signal referenced by >data_ref< with
| the data in the internal object identified by >message<.
| * This service will reset the class 1 and 3 flags associated to >message<
| * If >message< is an unqueued signal the service will return the last value
| received.
| If >message< is a queued signal the service will return the first value
| available in the queue or error if the queue is empty. (Mode not suported)
| * The software engineer is resposible of granting that the parameter >data_ref<
| points to an address correctly allocated and compatible in size with the
| received signal type
| * Usage example:
| t_vehicle_speed vehicle_speed;
| (void)ReceiveMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the received signal.
| data_ref: Pointer to the application area where to store the received signal.
| return:
| E_OK in case of no errors
| E_COM_ID in case the parameter >message< is out of range or if it refers
| to signal that is sent or to a dynamiclength or zero-length signal
| E_COM_NOMSG in case the queued signal identified by >message< is empty.
| E_COM_LIMIT in case an overflow of the signal queue identified by >message<
| occurred since the last call to ReceiveMessage for >message<.
| E_COM_LIMIT indicates that at least one message has been discarded
| since the message queue filled. Nevertheless the service is
| performed and a message is returned. The service ReceiveMessage
| clears the overflow condition for >message<.
| other (see t_status_type).
|---------------------------------------------------------------------------
| CPU resources data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type InternalReceiveMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * This service updates the internal signal object identified by >message<
| with the application signal referenced by the >data_ref< parameter.
| * This service will reset the class 2 and 4 flags associated to >message<
| * If >message< has the Triggered Transfer Property, the update is followed
| by immediate transmission of the I-PDU associated with the signal except
| when the signal is packed into an I-PDU with Periodic Transmission Mode;
| in this case, no transmission is initiated by the call to this service.
| * If >message< has the Pending Transfer Property, no transmission is
| caused by the update.
| * The software engineer is resposible of granting that the parameter >data_ref<
| points to an address correctly allocated and compatible in size with the
| transmited signal type
| * Usage example:
| t_vehicle_speed vehicle_speed = 20;
| (void)SendMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the transmited signal.
| data_ref: Pointer to the application signal where is the value to be transmited.
| return:
| E_OK in case of no errors
| E_COM_ID is case the parameter >message< is out of range or if it refers
| to a message that is received or to a dynamic-length or
| zero-length message.
| other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#define OSEK_INTERNALSENDMESSAGE
t_status_type InternalSendMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Initialize service message with a different value than configuration.
| * The software engineer is responsible of garanting that the parameter 'data_ref'
| points to an address correctly allocated and compatible in size with the
| transmitted signal type.
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the received signal.
| data_ref: Pointer to the application area where to store the received signal.
| return:
| E_OK in case of no errors
| E_COM_ID if the message or signal to initialize don't exist
| Other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type InternalInitMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Consult service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| COM_FALSE if the flag is down
| COM_TRUE if the flag is up
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_flag_value InternalReadFlagComTrafficMMC(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Reset service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void InternalResetFlagComTrafficMMC(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Consult service for the notify Rx Rx_Error Tx Tx_Error
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal flag.
| return:
| COM_FALSE if the flag is down
| COM_TRUE if the flag is up
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_flag_value InternalReadFlagRxSig(t_symbolic_name message);
t_flag_value InternalReadFlagRxSigSMC_MLX_cook_die1(void);
t_flag_value InternalReadFlagRxSigSMC_MLX_cook_die2(void);
t_flag_value InternalReadFlagRxSigSMC_mode_contoler(void);
t_flag_value InternalReadFlagRxSigSMC_MLX_current_position(void);
t_flag_value InternalReadFlagRxSigSMC_vbat_motor_sup_sns(void);
t_flag_value InternalReadFlagRxSigSMC_bmar_sns(void);
t_flag_value InternalReadFlagRxSigSMC_MLX_raw_die1(void);
t_flag_value InternalReadFlagRxSigSMC_MLX_raw_die2(void);
t_flag_value InternalReadFlagRxSigSMC_MLX_temperature_die1(void);
t_flag_value InternalReadFlagRxSigSMC_MLX_temperature_die2(void);
t_flag_value InternalReadFlagRxSigSMC_fw_version(void);
t_flag_value InternalReadFlagRxSigSMC_melexis_diagnostics(void);
t_flag_value InternalReadFlagRxSigSMC_relay_status(void);
t_flag_value InternalReadFlagRxSigSMC_calibration_NOP(void);
t_flag_value InternalReadFlagRxErrorSig(t_symbolic_name message);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_cook_die1(void);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_cook_die2(void);
t_flag_value InternalReadFlagRxErrorSigSMC_mode_contoler(void);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_current_position(void);
t_flag_value InternalReadFlagRxErrorSigSMC_vbat_motor_sup_sns(void);
t_flag_value InternalReadFlagRxErrorSigSMC_bmar_sns(void);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_raw_die1(void);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_raw_die2(void);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_temperature_die1(void);
t_flag_value InternalReadFlagRxErrorSigSMC_MLX_temperature_die2(void);
t_flag_value InternalReadFlagRxErrorSigSMC_fw_version(void);
t_flag_value InternalReadFlagRxErrorSigSMC_melexis_diagnostics(void);
t_flag_value InternalReadFlagRxErrorSigSMC_relay_status(void);
t_flag_value InternalReadFlagRxErrorSigSMC_calibration_NOP(void);
t_flag_value InternalReadFlagTxSig(t_symbolic_name message);
t_flag_value InternalReadFlagTxSigMMC_p_uds_die1_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_r_uds_die1_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_n_uds_die1_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_d_uds_die1_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_p_uds_die2_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_r_uds_die2_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_n_uds_die2_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_d_uds_die2_setpoint(void);
t_flag_value InternalReadFlagTxSigMMC_p_lock_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_p_r_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_r_p_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_r_n_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_n_r_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_n_d_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_d_n_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_d_lock_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_uds_setpoints_rc(void);
t_flag_value InternalReadFlagTxSigMMC_uds_setpoints_crc(void);
t_flag_value InternalReadFlagTxSigMMC_p_out_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_d_out_uds_offset(void);
t_flag_value InternalReadFlagTxSigMMC_SCU_GearboxPositionTarget(void);
t_flag_value InternalReadFlagTxSigMMC_GearLeverPositionExtended_v2(void);
t_flag_value InternalReadFlagTxSigMMC_Clock_ATCU_A112(void);
t_flag_value InternalReadFlagTxSigMMC_CRC_ATCU_A112(void);
t_flag_value InternalReadFlagTxSigMMC_IgnitionSupplyConfirmation(void);
t_flag_value InternalReadFlagTxSigMMC_ACTU_uds_mode(void);
t_flag_value InternalReadFlagTxSigMMC_mlx_position(void);
t_flag_value InternalReadFlagTxSigMMC_melexis_virtual_die1(void);
t_flag_value InternalReadFlagTxSigMMC_melexis_virtual_die2(void);
t_flag_value InternalReadFlagTxSigMMC_relay_selfcheck_request(void);
t_flag_value InternalReadFlagTxSigMMC_application_mode(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Reset service for the notify Rx Rx_Error Tx Tx_Error
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal flag.
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void InternalResetFlagRxSig(t_symbolic_name message);
void InternalResetFlagRxSigSMC_MLX_cook_die1(void);
void InternalResetFlagRxSigSMC_MLX_cook_die2(void);
void InternalResetFlagRxSigSMC_mode_contoler(void);
void InternalResetFlagRxSigSMC_MLX_current_position(void);
void InternalResetFlagRxSigSMC_vbat_motor_sup_sns(void);
void InternalResetFlagRxSigSMC_bmar_sns(void);
void InternalResetFlagRxSigSMC_MLX_raw_die1(void);
void InternalResetFlagRxSigSMC_MLX_raw_die2(void);
void InternalResetFlagRxSigSMC_MLX_temperature_die1(void);
void InternalResetFlagRxSigSMC_MLX_temperature_die2(void);
void InternalResetFlagRxSigSMC_fw_version(void);
void InternalResetFlagRxSigSMC_melexis_diagnostics(void);
void InternalResetFlagRxSigSMC_relay_status(void);
void InternalResetFlagRxSigSMC_calibration_NOP(void);
void InternalResetFlagRxErrorSig(t_symbolic_name message);
void InternalResetFlagRxErrorSigSMC_MLX_cook_die1(void);
void InternalResetFlagRxErrorSigSMC_MLX_cook_die2(void);
void InternalResetFlagRxErrorSigSMC_mode_contoler(void);
void InternalResetFlagRxErrorSigSMC_MLX_current_position(void);
void InternalResetFlagRxErrorSigSMC_vbat_motor_sup_sns(void);
void InternalResetFlagRxErrorSigSMC_bmar_sns(void);
void InternalResetFlagRxErrorSigSMC_MLX_raw_die1(void);
void InternalResetFlagRxErrorSigSMC_MLX_raw_die2(void);
void InternalResetFlagRxErrorSigSMC_MLX_temperature_die1(void);
void InternalResetFlagRxErrorSigSMC_MLX_temperature_die2(void);
void InternalResetFlagRxErrorSigSMC_fw_version(void);
void InternalResetFlagRxErrorSigSMC_melexis_diagnostics(void);
void InternalResetFlagRxErrorSigSMC_relay_status(void);
void InternalResetFlagRxErrorSigSMC_calibration_NOP(void);
void InternalResetFlagTxSig(t_symbolic_name message);
void InternalResetFlagTxSigMMC_p_uds_die1_setpoint(void);
void InternalResetFlagTxSigMMC_r_uds_die1_setpoint(void);
void InternalResetFlagTxSigMMC_n_uds_die1_setpoint(void);
void InternalResetFlagTxSigMMC_d_uds_die1_setpoint(void);
void InternalResetFlagTxSigMMC_p_uds_die2_setpoint(void);
void InternalResetFlagTxSigMMC_r_uds_die2_setpoint(void);
void InternalResetFlagTxSigMMC_n_uds_die2_setpoint(void);
void InternalResetFlagTxSigMMC_d_uds_die2_setpoint(void);
void InternalResetFlagTxSigMMC_p_lock_uds_offset(void);
void InternalResetFlagTxSigMMC_p_r_uds_offset(void);
void InternalResetFlagTxSigMMC_r_p_uds_offset(void);
void InternalResetFlagTxSigMMC_r_n_uds_offset(void);
void InternalResetFlagTxSigMMC_n_r_uds_offset(void);
void InternalResetFlagTxSigMMC_n_d_uds_offset(void);
void InternalResetFlagTxSigMMC_d_n_uds_offset(void);
void InternalResetFlagTxSigMMC_d_lock_uds_offset(void);
void InternalResetFlagTxSigMMC_uds_setpoints_rc(void);
void InternalResetFlagTxSigMMC_uds_setpoints_crc(void);
void InternalResetFlagTxSigMMC_p_out_uds_offset(void);
void InternalResetFlagTxSigMMC_d_out_uds_offset(void);
void InternalResetFlagTxSigMMC_SCU_GearboxPositionTarget(void);
void InternalResetFlagTxSigMMC_GearLeverPositionExtended_v2(void);
void InternalResetFlagTxSigMMC_Clock_ATCU_A112(void);
void InternalResetFlagTxSigMMC_CRC_ATCU_A112(void);
void InternalResetFlagTxSigMMC_IgnitionSupplyConfirmation(void);
void InternalResetFlagTxSigMMC_ACTU_uds_mode(void);
void InternalResetFlagTxSigMMC_mlx_position(void);
void InternalResetFlagTxSigMMC_melexis_virtual_die1(void);
void InternalResetFlagTxSigMMC_melexis_virtual_die2(void);
void InternalResetFlagTxSigMMC_relay_selfcheck_request(void);
void InternalResetFlagTxSigMMC_application_mode(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Main task of OSEK/COM that must be called periodically in
| the main loop of the program.
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void InternalOsekComTask(void);
#endif

View File

@ -0,0 +1,316 @@
#ifndef _Sent_FICOSEKCOM_H
#define _Sent_FICOSEKCOM_H
/*-------------------------------- Includes ------------------------------*/
#include "Global.h"
#include "SentDriver.h"
/*-------------------------------- Defines -------------------------------*/
/* Theoretical time between two consecutive executions of FicOsekCom task */
#define SENTFICOSEK_COM_TASK_TICKS ((t_timer_time)2)
/* Return type of the calls OSEK COM */
#ifndef STD_TYPES_H
#define E_OK ((UI_8)0x00) /* Service call has succeeded */
#endif
#define E_COM_ID ((UI_8)0x01) /* Given message or mode identifier */
/* is out of range or invalid */
#define E_COM_LENGTH ((UI_8)0x02) /* Given data length is out of range */
#define E_COM_LIMIT ((UI_8)0x03) /* Overflow of message queue */
#define E_COM_NOMSG ((UI_8)0x04) /* Message queue is empty */
#define E_COM_SYS_NOINIT ((UI_8)0x05) /* User defined E_COM_SYS_?? */
/* Node id */
#define NODE_ID_MASK ((UI_16) 0xF000U) /* Mask to get nodes id */
#define NODE_ID_DEFC_SENT (((UI_16) 0x1000U) & NODE_ID_MASK) /* Symbolic name of the node DEFC_SENT */
/* Symbolic names for Rx signals */
#define SIG_MLX_DIE1_ANGLE (((UI_16) 1) | NODE_ID_DEFC_SENT) /* Symbolic name of the signal MLX_DIE1_ANGLE */
#define SIG_MLX_DIE1_RC (((UI_16) 2) | NODE_ID_DEFC_SENT) /* Symbolic name of the signal MLX_DIE1_RC */
#define SIG_MLX_DIE1_ST (((UI_16) 3) | NODE_ID_DEFC_SENT) /* Symbolic name of the signal MLX_DIE1_ST */
#define SIG_MLX_DIE2_ANGLE (((UI_16) 4) | NODE_ID_DEFC_SENT) /* Symbolic name of the signal MLX_DIE2_ANGLE */
#define SIG_MLX_DIE2_RC (((UI_16) 5) | NODE_ID_DEFC_SENT) /* Symbolic name of the signal MLX_DIE2_RC */
#define SIG_MLX_DIE2_ST (((UI_16) 6) | NODE_ID_DEFC_SENT) /* Symbolic name of the signal MLX_DIE2_ST */
/* Last Rx signal */
#define SENTLAST_RX_STA_LEN_SIGNAL_SYMBOLIC_NAME ((~NODE_ID_MASK) & SIG_MLX_DIE2_ST)
/* Last OsekCom signal */
#define SENTLAST_OSEK_COM_SIGNAL_SYMBOLIC_NAME ((UI_16) 6)
/* Symbolic names for Dummy signal */
#define SENTSIGDUMMY ((UI_16)0x0FFF) /* Symbolic name of the signal SIGDUMMY */
/*----------------------------- Data Types -------------------------------*/
/* Type definition of internal signals */
typedef UI_16 t_sig_mlx_die1_angle;
typedef UI_8 t_sig_mlx_die1_st;
typedef UI_8 t_sig_mlx_die1_rc;
typedef UI_16 t_sig_mlx_die2_angle;
typedef UI_8 t_sig_mlx_die2_rc;
typedef UI_8 t_sig_mlx_die2_st;
#ifndef _FICOSEKCOM_H
#define _FICOSEKCOM_H
/* Type definition of the symbolic names for signals */
typedef UI_16 t_symbolic_name;
typedef UI_16 t_symbolic_frm_name;
/* Return type of the calls OSEK COM */
typedef UI_8 t_status_type;
/* Structure of data type passed by reference in */
/* the calls of OSEK COM */
typedef void *t_application_data_ref;
typedef void *t_length_ref;
/* Flag types of OSEK COM */
typedef enum {
COM_FALSE = 0x00, /* Flag down */
COM_TRUE = 0x01 /* Flag up */
} t_flag_value;
/* Stop mode of OSEK COM */
typedef enum {
COM_SHUTDOWN_IMMEDIATE = 0 /* Apagat immediat */
} t_com_shutdown_mode_type;
/* Initialize mode of OSEK COM */
typedef enum {
COM_NORMAL_MODE = 0 /* No es processen trames de COM de Debug */
} t_com_application_mode_type;
#endif
/*--------------------------- Global Variables ---------------------------*/
/* --------------------------- Routine Prototypes --------------------------- */
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Reception of a new frame notification callback
| * This callback must be launched by the lower COM driver upon the reception
| of a new frame.
|---------------------------------------------------------------------------
| Parameters description:
| bhdl: Handler of the buffer where the received frame is stored.
/---------------------------------------------------------------------------*/
void SentOsekComRxNotifCallbackDEFC_SENT(t_com_buf_hdl bhdl);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to initialize OsekCom stack
|
| ------------------------------------------------- --------------------------
| Parameters description:
| app_mode: OsekCom initialization mode (See t_com_application_mode_type)
| return: E_OK in case of no errors
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type SentStartCom(t_com_application_mode_type app_mode);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to inquiry in which mode OsekCom has been initialized.
| * If this service is called before initializing the communications stack
| a random mode will be returned.
| ---------------------------------------------------------------------------
| Parameters description:
| return: OsekCom initialization mode(See t_com_application_mode_type)
/ --------------------------------------------------------------------------- */
t_com_application_mode_type SentGetComApplicationMode(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to close the OsekCom stack.
| * This service stops the transmission of periodic frames.
| * After calling this service communications could be re-established
| calling again service StartCom.
| * This service does not change the state of any lower COM driver.
| ---------------------------------------------------------------------------
| Parameters description:
| shtdwn_mode: OsekCom stop mode (See t_com_shutdown_mode_type)
| return: E_OK in case of no errors
| Other (see t_status_type).
/ --------------------------------------------------------------------------- */
t_status_type SentStopCom(t_com_shutdown_mode_type shtdwn_mode);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to start the transmission of periodic or mixed frames.
| * If this service is re-executed then transmission timers will be re-started.
|---------------------------------------------------------------------------
| Parameters description:
| return: E_OK in case of no errors
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type SentStartPeriodic(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Service to stop the transmission of periodic or mixed frames.
| * To re-start the transmission of periodic or mixed frames service
| StartPeriodic must be called.
|---------------------------------------------------------------------------
| Parameters description:
| return: E_OK in case of no errors
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type SentStopPeriodic(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates the application variable referenced by >data_ref< with
| the data stored in the internal stack for the object identified by >message<.
| * This service will reset the class 1 (RxNotif) and 3 (RxErrorNotif) flags
| associated to >message<
| * If >message< is an enqueued signal the service will return the data
| stored in the internal stack (initial value / last received value / last value
| set with InitMessage)
| If >message< is a queued signal the service will return the first value
| available in the queue or error if the queue is empty. (Mode not supported)
| * The user is responsible of granting that the parameter >data_ref<
| points to a variable correctly allocated and compatible in size with the
| received signal type
| * Usage example:
| t_vehicle_speed vehicle_speed;
| (void)ReceiveMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal to be retrieved.
| data_ref: Pointer to a variable where to store the requested signal.
| return:
| E_OK in case of no errors
| E_COM_ID in case the parameter >message< is out of range or if it refers
| to signal that is sent, dynamic length or zero-length
| E_COM_NOMSG in case the queued signal identified by >message< is empty.
| E_COM_LIMIT in case an overflow of the queue of the signal identified by >message<
| occurred since the last call to ReceiveMessage for >message<.
| E_COM_LIMIT indicates that at least one message has been discarded
| since the message queue filled. Nevertheless the service is
| performed and a message is returned. The service ReceiveMessage
| clears the overflow condition for >message<.
| other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type SentReceiveMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * This service updates OsekCom internal data structure of the signal
| identified by >message< with the data referenced by the variable
| referenced by >data_ref<
| * This service will not reset any class flags associated to >message<
| * This service will not initiate any transmission.
| * The user is responsible of granting that the parameter 'data_ref'
| points to an address correctly allocated and compatible in size with the
| transmitted signal type.
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal.
| data_ref: Pointer to a variable containing the data.
| return:
| E_OK in case of no errors
| E_COM_ID if the message or signal to initialize don't exist
| Other (see t_status_type).
/---------------------------------------------------------------------------*/
t_status_type SentInitMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Consult service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| COM_FALSE if has not been detected any communication activity since
| last clear
| COM_TRUE if has been detected communication activity since last clear
/---------------------------------------------------------------------------*/
t_flag_value SentReadFlagComTrafficDEFC_SENT(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Reset service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void SentResetFlagComTrafficDEFC_SENT(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Consult service to retrieve the state of class 1 (RxNotif),
| class 3 (Rx_ErrorNotif), class 2 (TxNotif) and class 4 (Tx_ErrorNotif) flags
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal.
| return:
| COM_FALSE if the flag is down
| COM_TRUE if the flag is up
/---------------------------------------------------------------------------*/
t_flag_value SentReadFlagRxSig(t_symbolic_name message);
t_flag_value SentReadFlagRxSigMLX_DIE1_ANGLE(void);
t_flag_value SentReadFlagRxSigMLX_DIE2_ANGLE(void);
t_flag_value SentReadFlagRxErrorSig(t_symbolic_name message);
t_flag_value SentReadFlagRxErrorSigMLX_DIE1_ANGLE(void);
t_flag_value SentReadFlagRxErrorSigMLX_DIE2_ANGLE(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Reset service for the notify class 1 (RxNotif) class 3 (RxErrorNotif)
| class 2 (TxNotif) and class 4 (TxErrorNotif)
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal.
/---------------------------------------------------------------------------*/
void SentResetFlagRxSig(t_symbolic_name message);
void SentResetFlagRxSigMLX_DIE1_ANGLE(void);
void SentResetFlagRxSigMLX_DIE2_ANGLE(void);
void SentResetFlagRxErrorSig(t_symbolic_name message);
void SentResetFlagRxErrorSigMLX_DIE1_ANGLE(void);
void SentResetFlagRxErrorSigMLX_DIE2_ANGLE(void);
/*---------------------------------------------------------------------------
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine description:
| * Main runnable of the OsekCom stack intended to be called periodically by
| the system scheduler with a period equal to SENTFICOSEK_COM_TASK_TICKS
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void SentOsekComTask(void);
#endif

View File

@ -0,0 +1,550 @@
#ifndef _Spi_FICOSEKCOM_H
#define _Spi_FICOSEKCOM_H
/*-------------------------------- includes ------------------------------*/
#include "Global.h"
#include "SpiFrameWrapper.h"
/*-------------------------------- defines -------------------------------*/
/* Return type of the calls OSEK COM */
#ifndef STD_TYPES_H
#define E_OK ((UI_8)0x00) /* Service call has succeeded */
#endif
#define E_COM_ID ((UI_8)0x01) /* Given message or mode identifier */
/* is out of range or invalid */
#define E_COM_LENGTH ((UI_8)0x02) /* Given data length is out of range */
#define E_COM_LIMIT ((UI_8)0x03) /* Overflow of message queue */
#define E_COM_NOMSG ((UI_8)0x04) /* Message queue is empty */
#define E_COM_SYS_NOINIT ((UI_8)0x05) /* User defined E_COM_SYS_?? */
/* Valors admisibles pel senyal sig_DIE1_M0_DIAG */
#define SIG_DIE1_M0_DIAG_F_DIAG_SEQUENCE_NOT_FINISHED ((t_sig_die1_m0_diag) 0)
#define SIG_DIE1_M0_DIAG_DIAG_FAIL ((t_sig_die1_m0_diag) 1)
#define SIG_DIE1_M0_DIAG_DIAGC_PASS_(PREVIOUS_CYCLE) ((t_sig_die1_m0_diag) 2)
#define SIG_DIE1_M0_DIAG_DIAG_PASS_NEW_CYCLE_COMPLETED ((t_sig_die1_m0_diag) 3)
/* Valors admisibles pel senyal sig_DIE1_M1_DIAG */
#define SIG_DIE1_M1_DIAG_F_DIAG_SEQUENCE_NOT_FINISHED ((t_sig_die1_m1_diag) 0)
#define SIG_DIE1_M1_DIAG_DIAG_FAIL ((t_sig_die1_m1_diag) 1)
#define SIG_DIE1_M1_DIAG_DIAGC_PASS_(PREVIOUS_CYCLE) ((t_sig_die1_m1_diag) 2)
#define SIG_DIE1_M1_DIAG_DIAG_PASS_NEW_CYCLE_COMPLETED ((t_sig_die1_m1_diag) 3)
/* Valors admisibles pel senyal sig_DIE2_M0_DIAG */
#define SIG_DIE2_M0_DIAG_F_DIAG_SEQUENCE_NOT_FINISHED ((t_sig_die2_m0_diag) 0)
#define SIG_DIE2_M0_DIAG_DIAG_FAIL ((t_sig_die2_m0_diag) 1)
#define SIG_DIE2_M0_DIAG_DIAGC_PASS_(PREVIOUS_CYCLE) ((t_sig_die2_m0_diag) 2)
#define SIG_DIE2_M0_DIAG_DIAG_PASS_NEW_CYCLE_COMPLETED ((t_sig_die2_m0_diag) 3)
/* Valors admisibles pel senyal sig_DIE2_M1_DIAG */
#define SIG_DIE2_M1_DIAG_F_DIAG_SEQUENCE_NOT_FINISHED ((t_sig_die2_m1_diag) 0)
#define SIG_DIE2_M1_DIAG_DIAG_FAIL ((t_sig_die2_m1_diag) 1)
#define SIG_DIE2_M1_DIAG_DIAGC_PASS_(PREVIOUS_CYCLE) ((t_sig_die2_m1_diag) 2)
#define SIG_DIE2_M1_DIAG_DIAG_PASS_NEW_CYCLE_COMPLETED ((t_sig_die2_m1_diag) 3)
/* Node id */
#define NODE_ID_MASK ((UI_16) 0xF000) /* Mask to get nodes id */
#define NODE_ID_ECU_LITE (((UI_16) 0x1000) & NODE_ID_MASK) /* Symbolic name of the node ECU_Lite */
/* Symbolic names for Tx signals with static length */
/* First tx signal */
#define SPIFIRST_TX_STA_LEN_SIGNAL_SYMBOLIC_NAME ((~NODE_ID_MASK) & SIG_MASTER_M0_RST_DIE1)
#define SIG_MASTER_M0_RST_DIE1 (((UI_16) 1) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M0_RST_DIE1 */
#define SIG_MASTER_M0_RST_DIE2 (((UI_16) 2) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M0_RST_DIE2 */
#define SIG_MASTER_M0_TIMEOUT_VALUE_DIE1 (((UI_16) 3) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M0_TIMEOUT_VALUE_DIE1 */
#define SIG_MASTER_M0_TIMEOUT_VALUE_DIE2 (((UI_16) 4) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M0_TIMEOUT_VALUE_DIE2 */
#define SIG_MASTER_M3_ADD0_DIE1 (((UI_16) 5) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M3_ADD0_DIE1 */
#define SIG_MASTER_M3_ADD0_DIE2 (((UI_16) 6) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M3_ADD0_DIE2 */
#define SIG_MASTER_M3_ADD1_DIE1 (((UI_16) 7) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M3_ADD1_DIE1 */
#define SIG_MASTER_M3_ADD1_DIE2 (((UI_16) 8) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M3_ADD1_DIE2 */
#define SIG_MASTER_M7_KEY_DIE1 (((UI_16) 9) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M7_KEY_DIE1 */
#define SIG_MASTER_M7_KEY_DIE2 (((UI_16) 10) | NODE_ID_ECU_LITE) /* Symbolic name of the signal MASTER_M7_KEY_DIE2 */
/* Last tx signal */
#define SPILAST_TX_STA_LEN_SIGNAL_SYMBOLIC_NAME ((~NODE_ID_MASK) & SIG_MASTER_M7_KEY_DIE2)
/* Symbolic names for Rx signals */
#define SIG_DIE1_M0_ALPHA (((UI_16) 11) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M0_ALPHA */
#define SIG_DIE1_M0_DIAG (((UI_16) 12) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M0_DIAG */
#define SIG_DIE1_M0_VG (((UI_16) 13) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M0_VG */
#define SIG_DIE1_M1_ALPHA (((UI_16) 14) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M1_ALPHA */
#define SIG_DIE1_M1_BETA (((UI_16) 15) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M1_BETA */
#define SIG_DIE1_M1_DIAG (((UI_16) 16) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M1_DIAG */
#define SIG_DIE1_M1_VG (((UI_16) 17) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M1_VG */
#define SIG_DIE1_M4_DATA_AT_ADD0 (((UI_16) 18) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M4_DATA_AT_ADD0 */
#define SIG_DIE1_M4_DATA_AT_ADD1 (((UI_16) 19) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M4_DATA_AT_ADD1 */
#define SIG_DIE1_M8_INVERTED_KEY_ECHO (((UI_16) 20) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M8_INVERTED_KEY_ECHO */
#define SIG_DIE1_M8_KEY_ECHO (((UI_16) 21) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE1_M8_KEY_ECHO */
#define SIG_DIE2_M0_ALPHA (((UI_16) 22) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M0_ALPHA */
#define SIG_DIE2_M0_DIAG (((UI_16) 23) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M0_DIAG */
#define SIG_DIE2_M0_VG (((UI_16) 24) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M0_VG */
#define SIG_DIE2_M1_ALPHA (((UI_16) 25) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M1_ALPHA */
#define SIG_DIE2_M1_BETA (((UI_16) 26) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M1_BETA */
#define SIG_DIE2_M1_DIAG (((UI_16) 27) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M1_DIAG */
#define SIG_DIE2_M1_VG (((UI_16) 28) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M1_VG */
#define SIG_DIE2_M4_DATA_AT_ADD0 (((UI_16) 29) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M4_DATA_AT_ADD0 */
#define SIG_DIE2_M4_DATA_AT_ADD1 (((UI_16) 30) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M4_DATA_AT_ADD1 */
#define SIG_DIE2_M8_INVERTED_KEY_ECHO (((UI_16) 31) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M8_INVERTED_KEY_ECHO */
#define SIG_DIE2_M8_KEY_ECHO (((UI_16) 32) | NODE_ID_ECU_LITE) /* Symbolic name of the signal DIE2_M8_KEY_ECHO */
/* Last Rx signal */
#define SPILAST_RX_STA_LEN_SIGNAL_SYMBOLIC_NAME ((~NODE_ID_MASK) & SIG_DIE2_M8_KEY_ECHO)
/* Symbolic names for Dummy signal */
#define SPISIGDUMMY ((UI_16)0x0FFF) /* Symbolic name of the signal SIGDUMMY */
/*----------------------------- data types -------------------------------*/
/* Type definition of internal signals */
typedef UI_16 t_sig_die1_m0_alpha;
typedef UI_8 t_sig_die1_m0_vg;
typedef UI_8 t_sig_die1_m0_diag;
typedef UI_16 t_sig_die1_m1_alpha;
typedef UI_16 t_sig_die1_m1_beta;
typedef UI_8 t_sig_die1_m1_diag;
typedef UI_8 t_sig_die1_m1_vg;
typedef UI_16 t_sig_die1_m4_data_at_add0;
typedef UI_16 t_sig_die1_m4_data_at_add1;
typedef UI_16 t_sig_die1_m8_key_echo;
typedef UI_16 t_sig_die1_m8_inverted_key_echo;
typedef UI_16 t_sig_die2_m0_alpha;
typedef UI_8 t_sig_die2_m0_diag;
typedef UI_8 t_sig_die2_m0_vg;
typedef UI_16 t_sig_die2_m1_alpha;
typedef UI_16 t_sig_die2_m1_beta;
typedef UI_8 t_sig_die2_m1_diag;
typedef UI_8 t_sig_die2_m1_vg;
typedef UI_16 t_sig_die2_m4_data_at_add0;
typedef UI_16 t_sig_die2_m4_data_at_add1;
typedef UI_16 t_sig_die2_m8_key_echo;
typedef UI_16 t_sig_die2_m8_inverted_key_echo;
typedef UI_8 t_sig_master_m0_rst_die1;
typedef UI_16 t_sig_master_m0_timeout_value_die1;
typedef UI_16 t_sig_master_m7_key_die1;
typedef UI_16 t_sig_master_m3_add0_die1;
typedef UI_16 t_sig_master_m3_add1_die1;
typedef UI_8 t_sig_master_m0_rst_die2;
typedef UI_16 t_sig_master_m0_timeout_value_die2;
typedef UI_16 t_sig_master_m3_add0_die2;
typedef UI_16 t_sig_master_m3_add1_die2;
typedef UI_16 t_sig_master_m7_key_die2;
#ifndef _FICOSEKCOM_H
#define _FICOSEKCOM_H
/* Type definition of the symbolic names for signals */
typedef UI_16 t_symbolic_name;
typedef UI_16 t_symbolic_frm_name;
/* Return type of the calls OSEK COM */
typedef UI_8 t_status_type;
/* Structure of data type passed by reference in */
/* the calls of OSEK COM */
typedef void *t_application_data_ref;
typedef void *t_length_ref;
/* Flag types of OSEK COM */
typedef enum {
COM_FALSE = 0x00, /* Flag down */
COM_TRUE = 0x01 /* Flag up */
} t_flag_value;
/* Stop mode of OSEK COM */
typedef enum {
COM_SHUTDOWN_IMMEDIATE = 0 /* Apagat immediat */
} t_com_shutdown_mode_type;
/* Initialize mode of OSEK COM */
typedef enum {
COM_NORMAL_MODE = 0 /* No es processen trames de COM de Debug */
} t_com_application_mode_type;
#endif
/*--------------------------- global variables ---------------------------*/
/*------------------------- prototips de funcions ------------------------*/
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Reception callback Routine of COM frames
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void SpiOsekComRxNotifCallbackECU_Lite(t_com_buf_hdl bhdl);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Transmission callback Routine of COM frames
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL SpiOsekComTxReqCallbackECU_Lite(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Notifying transmission callback Routine of COM frames
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void SpiOsekComTxNotifCallbackECU_Lite(t_com_buf_hdl bhdl);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Initialize service of OSEK COM in the selected mode
|
| ------------------------------------------------- --------------------------
| Explanation of arguments:
| App_mode: activation model of communications.
| Result: if all goes well E_OK
| Another code (see t_status_type) if an error occurs.
|---------------------------------------------------------------------------
| Temporitzacio:
| Tmax: ?? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type SpiStartCom(t_com_application_mode_type app_mode);
/*****************************************************************************
| Portability: Generic
| ----------------------------------------------------------------------------
| Contract transactions:
| * Service inquiry mode in which communications are initialized
| COM.
| * If this service is called before initializing the communications
| Random mode will be returned.
| ---------------------------------------------------------------------------
| Explanation of arguments:
| Result: how they have been enabled communications
| (See t_com_application_mode_type)
| ---------------------------------------------------------------------------
| Timing:
| Tmax: 15 cpu cycles | O (n): CTE
/ --------------------------------------------------------------------------- */
t_com_application_mode_type SpiGetComApplicationMode(void);
/*****************************************************************************
| Portability: Generic
| ----------------------------------------------------------------------------
| Contract transactions:
| * Service stopped the activity of OSEK COM communications.
| * This service stops the transmission of messages periodically.
| * After calling this service communications can be reestablished
| Calling service StartCom. (At no time this service modifies the state
| COM driver).
| ---------------------------------------------------------------------------
| Explanation of arguments:
| App_mode: Stop mode communications.
| Result: if all goes well E_OK
| Another code (see t_status_type) if an error occurs.
| ---------------------------------------------------------------------------
| Timing:
| Tmax:? cpu cycles | O (n): CTE
/ --------------------------------------------------------------------------- */
t_status_type SpiStopCom(t_com_shutdown_mode_type shtdwn_mode);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Initialize service transmission of periodic or mix frames.
| * If the transmission of periodic or mix frames is initialized, this service
| reboot the communication.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| E_OK in case of no errors
| Other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type SpiStartPeriodic(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Stop service transmission of periodic or mix frames.
| * If the transmission of periodic or mix frames is stopped, you can restart
| it calling the StartPeriodic service.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| E_OK in case of no errors
| Other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type SpiStopPeriodic(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * This service updates the application signal referenced by >data_ref< with
| the data in the internal object identified by >message<.
| * This service will reset the class 1 and 3 flags associated to >message<
| * If >message< is an unqueued signal the service will return the last value
| received.
| If >message< is a queued signal the service will return the first value
| available in the queue or error if the queue is empty. (Mode not suported)
| * The software engineer is resposible of granting that the parameter >data_ref<
| points to an address correctly allocated and compatible in size with the
| received signal type
| * Usage example:
| t_vehicle_speed vehicle_speed;
| (void)ReceiveMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the received signal.
| data_ref: Pointer to the application area where to store the received signal.
| return:
| E_OK in case of no errors
| E_COM_ID in case the parameter >message< is out of range or if it refers
| to signal that is sent or to a dynamiclength or zero-length signal
| E_COM_NOMSG in case the queued signal identified by >message< is empty.
| E_COM_LIMIT in case an overflow of the signal queue identified by >message<
| occurred since the last call to ReceiveMessage for >message<.
| E_COM_LIMIT indicates that at least one message has been discarded
| since the message queue filled. Nevertheless the service is
| performed and a message is returned. The service ReceiveMessage
| clears the overflow condition for >message<.
| other (see t_status_type).
|---------------------------------------------------------------------------
| CPU resources data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type SpiReceiveMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * This service updates the internal signal object identified by >message<
| with the application signal referenced by the >data_ref< parameter.
| * This service will reset the class 2 and 4 flags associated to >message<
| * If >message< has the Triggered Transfer Property, the update is followed
| by immediate transmission of the I-PDU associated with the signal except
| when the signal is packed into an I-PDU with Periodic Transmission Mode;
| in this case, no transmission is initiated by the call to this service.
| * If >message< has the Pending Transfer Property, no transmission is
| caused by the update.
| * The software engineer is resposible of granting that the parameter >data_ref<
| points to an address correctly allocated and compatible in size with the
| transmited signal type
| * Usage example:
| t_vehicle_speed vehicle_speed = 20;
| (void)SendMessage(SIG_VEHICLE_SPEED,&vehicle_speed);
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the transmited signal.
| data_ref: Pointer to the application signal where is the value to be transmited.
| return:
| E_OK in case of no errors
| E_COM_ID is case the parameter >message< is out of range or if it refers
| to a message that is received or to a dynamic-length or
| zero-length message.
| other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
#define OSEK_SPISENDMESSAGE
t_status_type SpiSendMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Initialize service message with a different value than configuration.
| * The software engineer is responsible of garanting that the parameter 'data_ref'
| points to an address correctly allocated and compatible in size with the
| transmitted signal type.
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the received signal.
| data_ref: Pointer to the application area where to store the received signal.
| return:
| E_OK in case of no errors
| E_COM_ID if the message or signal to initialize don't exist
| Other (see t_status_type).
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_status_type SpiInitMessage(t_symbolic_name message,
t_application_data_ref data_ref);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Consult service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
| return:
| COM_FALSE if the flag is down
| COM_TRUE if the flag is up
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_flag_value SpiReadFlagComTrafficECU_Lite(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Reset service for the flag of COM traffic.
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void SpiResetFlagComTrafficECU_Lite(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Consult service for the notify Rx Rx_Error Tx Tx_Error
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal flag.
| return:
| COM_FALSE if the flag is down
| COM_TRUE if the flag is up
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
t_flag_value SpiReadFlagRxSig(t_symbolic_name message);
t_flag_value SpiReadFlagRxSigDIE1_M0_ALPHA(void);
t_flag_value SpiReadFlagRxSigDIE1_M0_VG(void);
t_flag_value SpiReadFlagRxSigDIE1_M0_DIAG(void);
t_flag_value SpiReadFlagRxSigDIE1_M1_ALPHA(void);
t_flag_value SpiReadFlagRxSigDIE1_M1_BETA(void);
t_flag_value SpiReadFlagRxSigDIE1_M1_DIAG(void);
t_flag_value SpiReadFlagRxSigDIE1_M1_VG(void);
t_flag_value SpiReadFlagRxSigDIE1_M4_DATA_AT_ADD0(void);
t_flag_value SpiReadFlagRxSigDIE1_M4_DATA_AT_ADD1(void);
t_flag_value SpiReadFlagRxSigDIE1_M8_KEY_ECHO(void);
t_flag_value SpiReadFlagRxSigDIE1_M8_INVERTED_KEY_ECHO(void);
t_flag_value SpiReadFlagRxSigDIE2_M0_ALPHA(void);
t_flag_value SpiReadFlagRxSigDIE2_M0_DIAG(void);
t_flag_value SpiReadFlagRxSigDIE2_M0_VG(void);
t_flag_value SpiReadFlagRxSigDIE2_M1_ALPHA(void);
t_flag_value SpiReadFlagRxSigDIE2_M1_BETA(void);
t_flag_value SpiReadFlagRxSigDIE2_M1_DIAG(void);
t_flag_value SpiReadFlagRxSigDIE2_M1_VG(void);
t_flag_value SpiReadFlagRxSigDIE2_M4_DATA_AT_ADD0(void);
t_flag_value SpiReadFlagRxSigDIE2_M4_DATA_AT_ADD1(void);
t_flag_value SpiReadFlagRxSigDIE2_M8_KEY_ECHO(void);
t_flag_value SpiReadFlagRxSigDIE2_M8_INVERTED_KEY_ECHO(void);
t_flag_value SpiReadFlagRxErrorSig(t_symbolic_name message);
t_flag_value SpiReadFlagRxErrorSigDIE1_M0_ALPHA(void);
t_flag_value SpiReadFlagRxErrorSigDIE1_M4_DATA_AT_ADD0(void);
t_flag_value SpiReadFlagRxErrorSigDIE2_M0_ALPHA(void);
t_flag_value SpiReadFlagTxSig(t_symbolic_name message);
t_flag_value SpiReadFlagTxSigMASTER_M0_RST_DIE1(void);
t_flag_value SpiReadFlagTxSigMASTER_M0_TIMEOUT_VALUE_DIE1(void);
t_flag_value SpiReadFlagTxSigMASTER_M7_KEY_DIE1(void);
t_flag_value SpiReadFlagTxSigMASTER_M3_ADD0_DIE1(void);
t_flag_value SpiReadFlagTxSigMASTER_M3_ADD1_DIE1(void);
t_flag_value SpiReadFlagTxSigMASTER_M0_RST_DIE2(void);
t_flag_value SpiReadFlagTxSigMASTER_M0_TIMEOUT_VALUE_DIE2(void);
t_flag_value SpiReadFlagTxSigMASTER_M3_ADD0_DIE2(void);
t_flag_value SpiReadFlagTxSigMASTER_M3_ADD1_DIE2(void);
t_flag_value SpiReadFlagTxSigMASTER_M7_KEY_DIE2(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Reset service for the notify Rx Rx_Error Tx Tx_Error
|---------------------------------------------------------------------------
| Parameters description:
| message: Identification of the signal flag.
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void SpiResetFlagRxSig(t_symbolic_name message);
void SpiResetFlagRxSigDIE1_M0_ALPHA(void);
void SpiResetFlagRxSigDIE1_M0_VG(void);
void SpiResetFlagRxSigDIE1_M0_DIAG(void);
void SpiResetFlagRxSigDIE1_M1_ALPHA(void);
void SpiResetFlagRxSigDIE1_M1_BETA(void);
void SpiResetFlagRxSigDIE1_M1_DIAG(void);
void SpiResetFlagRxSigDIE1_M1_VG(void);
void SpiResetFlagRxSigDIE1_M4_DATA_AT_ADD0(void);
void SpiResetFlagRxSigDIE1_M4_DATA_AT_ADD1(void);
void SpiResetFlagRxSigDIE1_M8_KEY_ECHO(void);
void SpiResetFlagRxSigDIE1_M8_INVERTED_KEY_ECHO(void);
void SpiResetFlagRxSigDIE2_M0_ALPHA(void);
void SpiResetFlagRxSigDIE2_M0_DIAG(void);
void SpiResetFlagRxSigDIE2_M0_VG(void);
void SpiResetFlagRxSigDIE2_M1_ALPHA(void);
void SpiResetFlagRxSigDIE2_M1_BETA(void);
void SpiResetFlagRxSigDIE2_M1_DIAG(void);
void SpiResetFlagRxSigDIE2_M1_VG(void);
void SpiResetFlagRxSigDIE2_M4_DATA_AT_ADD0(void);
void SpiResetFlagRxSigDIE2_M4_DATA_AT_ADD1(void);
void SpiResetFlagRxSigDIE2_M8_KEY_ECHO(void);
void SpiResetFlagRxSigDIE2_M8_INVERTED_KEY_ECHO(void);
void SpiResetFlagRxErrorSig(t_symbolic_name message);
void SpiResetFlagRxErrorSigDIE1_M0_ALPHA(void);
void SpiResetFlagRxErrorSigDIE1_M4_DATA_AT_ADD0(void);
void SpiResetFlagRxErrorSigDIE2_M0_ALPHA(void);
void SpiResetFlagTxSig(t_symbolic_name message);
void SpiResetFlagTxSigMASTER_M0_RST_DIE1(void);
void SpiResetFlagTxSigMASTER_M0_TIMEOUT_VALUE_DIE1(void);
void SpiResetFlagTxSigMASTER_M7_KEY_DIE1(void);
void SpiResetFlagTxSigMASTER_M3_ADD0_DIE1(void);
void SpiResetFlagTxSigMASTER_M3_ADD1_DIE1(void);
void SpiResetFlagTxSigMASTER_M0_RST_DIE2(void);
void SpiResetFlagTxSigMASTER_M0_TIMEOUT_VALUE_DIE2(void);
void SpiResetFlagTxSigMASTER_M3_ADD0_DIE2(void);
void SpiResetFlagTxSigMASTER_M3_ADD1_DIE2(void);
void SpiResetFlagTxSigMASTER_M7_KEY_DIE2(void);
/*****************************************************************************
| Portability: Target platform independent
|----------------------------------------------------------------------------
| Routine specification:
| * Main task of OSEK/COM that must be called periodically in
| the main loop of the program.
|---------------------------------------------------------------------------
| Parameters description:
|---------------------------------------------------------------------------
| CPU requirements data:
| Tmax: ?? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
void SpiOsekComTask(void);
#endif

View File

@ -0,0 +1,15 @@
#ifndef _FICOSEKOS_H
#define _FICOSEKOS_H
/*----------------------------- includes ---------------------------------*/
#include "Global.h"
/*-------------------------- tipus de dades ------------------------------*/
/*----------------------------- defines ----------------------------------*/
#define ResumeAllInterrupts ENABLE_INTERRUPT
#define SuspendAllInterrupts DISABLE_INTERRUPT
#define InitFicOsekInterrupts()
/*---------------------- variables externes -----------------------------*/
#endif

View File

@ -0,0 +1,55 @@
/************** FICOSA COMMAND AND CONTROL SYSTEMS DIVISION ****************
| File: | Crc.h
| Init Date: |
| Rev. Date.: |
|-----------------|------------------------------------------------------------
| Language: | MISRA C
| Spec. Document: |
|-----------------|------------------------------------------------------------
| Project: | ARCGEN BSW
| Reference: |
| Version: | -
|------------------------------------------------------------------------------
| Date - Cod. - Description
|
| 17/07/14 ATo Document Creation
|------------------------------------------------------------------------------
| DESCRIPTION:
| CRC Service following Autosar 3.2 defined in:
| http://www.autosar.org/fileadmin/files/releases/3-2/software-architecture/system-services/standard/AUTOSAR_SWS_CRC_Routines.pdf
************************** FI DE LA CAPCALERA *****************************/
#ifndef _FICOCOMCRC_H
#define _FICOCOMCRC_H
/* -------------------------------- Includes -------------------------------- */
#include "Std_Types.h"
#include "Global.h"
/* -------------------------------- Defines --------------------------------- */
/* ------------------------------- Data Types ------------------------------- */
/* ---------------------------- Global Variables ---------------------------- */
/* ------------------------------- Prototypes ------------------------------ */
/*****************************************************************************
| Portability: Generic
|----------------------------------------------------------------------------
| Operations: This service makes a CRC for Melexis SPI.
|---------------------------------------------------------------------------
| Arguments:
| Message: Pointer to start address of data block to be calculated.
|---------------------------------------------------------------------------
| Return: 32 bit result of CRC calculation.
|---------------------------------------------------------------------------
| Timing:
| Tmax: ? cpu cycles | O(n): CTE
/---------------------------------------------------------------------------*/
UI_8 cba_256_calc_crc(UI_8 *message);
/*** Routines for SSU ***/
UI_16 CalcByteCrc(UI_16 crc, UI_8 new_byte);
UI_16 CalcCompleteCrc(UI_8 * buffer, UI_16 len);
#endif /* _FICOCOMCRC_H */

View File

@ -0,0 +1,136 @@
#ifndef PROJECT_CFG_H
#define PROJECT_CFG_H
/* -------------------------------- Includes -------------------------------- */
/* -------------------------------- Defines --------------------------------- */
#define MAX_SECURITY_ATTEMPTS 3
//#define SW_VERSION ((UI_16)0x0101)
///*#define HW_VERSION ((UI_8)0x01)*/
/* Return the absolut value of the given parameter */
#define ABS(x) (((x)>=0)?(x):(-(x)))
/* Return the minimum parameter from the two parameters given */
#define MIN(x,y) (((x)>=(y))?(y):(x))
/* Return the maximum parameter from the two parameters given */
#define MAX(x,y) (((x)>=(y))?(x):(y))
/******* PWM *******/
//#define UC_PWM PwmConf_PwmChannel_PwmChannel1//PwmConf_PwmChannel_UC_PWM
//#define PWM_DUTY_0 ((UI_16)0x0000)
//#define PWM_DUTY_25 ((UI_16)0x2000)
//#define PWM_DUTY_50 ((UI_16)0x4000)
//#define PWM_DUTY_75 ((UI_16)0x6000)
//#define PWM_DUTY_100 ((UI_16)0x8000)
//#define PERCENT_0 ((UI_8)0)
//#define PERCENT_100 ((UI_8)1000)
//#define PWM_DUTY_X(X) ((UI_16)(((UI_32)(X*PWM_DUTY_100))/PERCENT_100))
//#define PWM_X_DUTY(X) ((UI_8)((UI_32)((X*PERCENT_100))/PWM_DUTY_100))
/******* DIO *******/
/* Defined at Dio_Cfg.h, DIO Channel Configuration Handles */
/******* ADC *******/
/* Defined at Adc_Cfg.h, ADC Group Handles */
/******* ATX GA *******/
/* GAC ECU Identifier */
#define GAC_ECU_SW_VERSION_NUMBER {'0','B','0','0','0','9'}
#define GAC_ECU_APP_VERSION_NUMBER {'1','2','8'}
#define GAC_ECU_CALIBRATION_VERSION {'3','0','2','0','0','1','3','A','M','V','0','3','C','.','0','0','0'}
#define GAC_ECU_REPAIR_SHOP_CODE {0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f}
#define GAC_ECUINSTALL_DATE_DEFAULT_VAL {0,0,0,0}
#define GAC_APP_SW_FINGER_INFO {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#define GAC_DCID_VALUE {0x0D,0x00,0x00}
#define GAC_DIAG_PARAM_TABLE {0x0,0x0,0x0,0x0}
#define GAC_VIN_DEFAULT_VALUE {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x30,0x30,0x30,0x30,0x30,0x30}
#define GAC_CLIBRATION_DATE_DEFAULT_VALUE {0x05,0x31,0x20,0x21}
#define GAC_APP_DATAID_DEFAULT_VALUE {0x00,0x00,0x00}
#define GAC_MANUF_ECUHWNUM_DEFAULT_VALUE {'A','K','C','G','-','0','0','3','-','A','A'}
#define GAC_ECU_SN_DEFAULT_VALUE {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}
#define GAC_APP_SW_LOGICAL_ID {}
#define GAC_BOOT_ID_DEFAULT_VALUE {'4','5','0'}
#define GAC_ECUSW_VERSION_DEFAULT_VALUE {'S','W','0','3','0','2',' ',' ',' ',0x20,0x20,0x20,0x20,0x20,0x20,0x20}
#define GAC_APP_SUPPLIER_ID {0x46,0x49,0x43,0x4F,0x53,0x41,0x20,0x49,0x4E,0x54,0x45,0x52,0x4e};
/* ------------------------------- Data Types ------------------------------- */
//typedef signed char int8_t;
//typedef unsigned char uint8_t;
typedef volatile signed char vint8_t;
typedef volatile unsigned char vuint8_t;
//typedef signed short int16_t;
//typedef unsigned short uint16_t;
typedef volatile signed short vint16_t;
typedef volatile unsigned short vuint16_t;
//typedef signed int int32_t;
//typedef unsigned int uint32_t;
typedef volatile signed int vint32_t;
typedef volatile unsigned int vuint32_t;
typedef enum {
SYS_STARTUP = 0,
SYS_FAILSAFE = 1,
SYS_RUN = 2,
SYS_SHUTDOWN = 3,
SYS_SLEEP = 4,
SYS_MCAL = 5,
}e_Sys_Status;
#define ISO15765_2_REPROGONCAN_HANDLER ((UI_8)0)
#define DEBUG_ENABLE
/* ---------------------------- Global Variables ---------------------------- */
//extern Mcu_ResetType last_reset_cause;
//extern t_error cycle_violation;
/* --------------------------- Routine prototypes --------------------------- */
/* -------------------------------- Routines -------------------------------- */
//void OS_getFreezeRecordReset(UI_8 *pFreezeRecord);
//void OS_getFreezeRecordScheduler(UI_8 *pFreezeRecord);
/* IDs for Safety events. Must be consecutive numbers from 0 to NUM_SAFETY_EVENTS-1 */
#define SAFETY_EVENT_CAN_SPEED_LOST ((uint16)0)
#define SAFETY_EVENT_CAN_BRAKE_LOST ((uint16)1)
#define SAFETY_EVENT_ACT_SENSOR_1_NOK ((uint16)2)
#define SAFETY_EVENT_ACT_SENSOR_2_NOK ((uint16)3)
#define SAFETY_EVENT_ACT_SENSOR_ALL_NOK ((uint16)4)
#define SAFETY_EVENT_ACT_CAL_NVM_KO ((uint16)5)
#define SAFETY_EVENT_ACT_SENSOR_1_NO_PLAUSIBLE ((uint16)6)
#define SAFETY_EVENT_ACT_SENSOR_2_NO_PLAUSIBLE ((uint16)7)
#define SAFETY_EVENT_ACT_POSITION_COMB_NO_PLAUSIBLE ((uint16)8)
#define SAFETY_EVENT_ACT_POSITION_INVALID ((uint16)9)
#define SAFETY_EVENT_ROT_SENSOR_1_NOK ((uint16)10)
#define SAFETY_EVENT_ROT_SENSOR_2_NOK ((uint16)11)
#define SAFETY_EVENT_ROT_SENSOR_ALL_NOK ((uint16)12)
#define SAFETY_EVENT_ROT_CAL_NVM_KO ((uint16)13)
#define SAFETY_EVENT_ROT_SENSOR_1_NO_PLAUSIBLE ((uint16)14)
#define SAFETY_EVENT_ROT_SENSOR_2_NO_PLAUSIBLE ((uint16)15)
#define SAFETY_EVENT_ROT_POSITION_COMB_NO_PLAUSIBLE ((uint16)16)
#define SAFETY_EVENT_PBUTTON_1_NOK ((uint16)17)
#define SAFETY_EVENT_PBUTTON_2_NOK ((uint16)18)
#define SAFETY_EVENT_PBUTTON_ALL_NOK ((uint16)19)
#define SAFETY_EVENT_SSU_SFTY_WARNING ((uint16)20)
#define SAFETY_EVENT_SSU_NOK ((uint16)21)
#define SAFETY_EVENT_INT_RAM_NOK ((uint16)22)
#define SAFETY_EVENT_INT_ROM_NOK ((uint16)23)
#define SAFETY_EVENT_INT_ADC_NOK ((uint16)24)
#define SAFETY_EVENT_INT_STACK_NOK ((uint16)25)
#define SAFETY_EVENT_INT_2E2_NOK ((uint16)26)
#define SAFETY_EVENT_INT_CPU_NOK ((uint16)27)
#define SAFETY_EVENT_CAN_SPEED_INVALID ((uint16)28)
#define SAFETY_EVENT_CAN_BRAKE_INVALID ((uint16)29)
#define SAFETY_EVENT_EPB_STS_LOST ((uint16)30)
#define SAFETY_EVENT_EPB_STS_INVALID ((uint16)31)
#endif /* PROJECT_CFG_H */

View File

@ -0,0 +1,163 @@
#include "SysDiagDetect.h"
#include "FunctionState.h"
#include "OsekCom/OsekCom.h"
#include "RTE.h"
#include "forcedetect.h"
#include "forceSnsr.h"
static uint8 Bat_Rng = 0;
static void Battery_Volt_Diag_Task(void)
{
if (Fuction_State != Function_State_A)
{
Bat_Rng = Bat_Out_Range;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLCMNFLTSTS, &Bat_Rng);
}
else
{
Bat_Rng = Bat_In_Range;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLCMNFLTSTS, &Bat_Rng);
}
}
uint8 Force_Sens_Err = 0;
static void Force_Sensor_Diag_Task(void)
{
uint16 Diag_Press_baseline;
sint16 Diag_Convert_baseline;
uint16 CurrentDiag_Press_signal;
static uint16 LastDiag_Press_signal = 0;
static uint16 Press_NoChange_Count = 0;
// basline + - convert
Diag_Press_baseline = Get_forcedetect_basline_value();
if ((Diag_Press_baseline >> 11) == 1)
{
Diag_Convert_baseline = Diag_Press_baseline - 4096;
}
else
{
Diag_Convert_baseline = Diag_Press_baseline;
}
CurrentDiag_Press_signal = Get_forcedetect_force_value();
// Force sensor Diag start
if (forcesnsr_i2c_process_state_u8 == 1)
{
Force_Sens_Err = 1;
}
else
{
Force_Sens_Err = 0;
if (CurrentDiag_Press_signal == LastDiag_Press_signal)
{
Press_NoChange_Count++;
if (Press_NoChange_Count >= 800) // 4 seconds
{
Force_Sens_Err = 1;
Press_NoChange_Count = 800;
}
}
else
{
Press_NoChange_Count = 0;
}
if (Diag_Convert_baseline < -2040 || Diag_Convert_baseline > 1000)
{
Force_Sens_Err = 1;
}
}
// Force_Sens_Err = 1; //just for test,to set sensor error
LastDiag_Press_signal = CurrentDiag_Press_signal;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLSNSRFLTSTS, &Force_Sens_Err);
}
// Touch_Sensor_Sts00;
static uint8 Touch_Sensor_Fault = 0;
static void Touch_Sensor_Diag_Task(void)
{
static uint16_t fault_count = 0, fault_count2 = 0;
uint16 CurrentDiag_Press_signal;
if (Touch_Sensor_Sts00 < 50 && Touch_Sensor_Sts01 < 50 && Touch_Sensor_Sts02 < 50 && Touch_Sensor_Sts13 < 50 && Touch_Sensor_Sts14 < 50 && Touch_Sensor_Sts15 < 50
&& Touch_Sensor_Sts03 < 80 && Touch_Sensor_Sts04 < 80 && Touch_Sensor_Sts05 < 80 && Touch_Sensor_Sts06 < 80 && Touch_Sensor_Sts07 < 80
&& Touch_Sensor_Sts08 < 80 && Touch_Sensor_Sts09 < 80 && Touch_Sensor_Sts10 < 80 && Touch_Sensor_Sts11 < 80 && Touch_Sensor_Sts12 < 80)
{
Touch_Sensor_Fault = Touch_NoFault;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLTOUCHDFLTSTS, &Touch_Sensor_Fault);
fault_count = 0;
}
else
{
Touch_Sensor_Fault = Touch_Out_Range;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLTOUCHDFLTSTS, &Touch_Sensor_Fault);
fault_count++;
if (fault_count > 200)
{
fault_count = 0;
//touch_init();
}
}
CurrentDiag_Press_signal = Get_forcedetect_force_value();
if (CurrentDiag_Press_signal < 50)
{
if (Touch_Sensor_Sts00 > 10 || Touch_Sensor_Sts01 > 10 || Touch_Sensor_Sts02 > 10 || Touch_Sensor_Sts13 > 10 || Touch_Sensor_Sts14 > 10 || Touch_Sensor_Sts15 > 10
|| Touch_Sensor_Sts03 > 20 || Touch_Sensor_Sts04 > 20 || Touch_Sensor_Sts05 > 20 || Touch_Sensor_Sts06 > 20 || Touch_Sensor_Sts07 > 20
|| Touch_Sensor_Sts08 > 20 || Touch_Sensor_Sts09 > 20 || Touch_Sensor_Sts10 > 20 || Touch_Sensor_Sts11 > 20 || Touch_Sensor_Sts12 > 20)
{
fault_count2++;
if (fault_count2 > 200)
{
fault_count2 = 0;
//touch_init();
}
}
else
{
fault_count2 = 0;
}
}
else
{
fault_count2 = 0;
}
}
static uint8 Vibra_Fault = 0;
static void Vibration_Diag_Task(void)
{
// AD_data=voltage * 4096/3.3V normal:0-0.01(15) short: 0.15(185)-0.36(448) 0.6(742)-0.7(870) 0.95(1177)-1.05(1305) 1.27(1575)-1.39(1727) open:1.55(1921) - 1.72(2136)
Vibra_Fault = Vibration_Normal;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLVIBRATIONFLTSTS, &Vibra_Fault);
/*
if(LD_AD_Val>=0 && LD_AD_Val<=15) //normal
{
Vibra_Fault = Vibration_Normal;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLVIBRATIONFLTSTS, &Vibra_Fault);
}
else if((LD_AD_Val>=185 && LD_AD_Val<=448)||(LD_AD_Val>=742 && LD_AD_Val<=870)||(LD_AD_Val>=1177 && LD_AD_Val<=1305)||(LD_AD_Val>=1575 && LD_AD_Val<=1727))
{
Vibra_Fault = Vibration_Short;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLVIBRATIONFLTSTS, &Vibra_Fault);
}
else if(LD_AD_Val>=1921 && LD_AD_Val<=2136)
{
Vibra_Fault = Vibration_open;
InitMessage(SIG_DIAGCFAILRTOUCHPANSWTLVIBRATIONFLTSTS, &Vibra_Fault);
}
*/
}
void Sys_Diag_Detcet_Task(void)
{
Battery_Volt_Diag_Task();
if (Bat_Rng == Bat_In_Range)
{
Force_Sensor_Diag_Task();
Touch_Sensor_Diag_Task();
Vibration_Diag_Task();
}
}

View File

@ -0,0 +1,26 @@
#ifndef __SysDiagDetect_H__
#define __SysDiagDetect_H__
#include "Std_Types.h"
#define Bat_In_Range 0
#define Bat_Out_Range 1
#define Touch_NoFault 0
#define Touch_Out_Range 1
#define Vibration_Normal 0
#define Vibration_Short 1
#define Vibration_open 2
extern uint8 Force_Sens_Err;
//extern uint8 Fuction_State ;
//extern uint8 Control_SDZ ;
extern void Sys_Diag_Detcet_Task(void);
#endif

View File

@ -0,0 +1,138 @@
/************ Copyright 2004-2009 FICOSA CORPORATIVE ELECTRONICS ************
| Language: | MISRA C
| Controller: | dsPIC33
| Requirements:
|-------------|------------------------------------------------------------
| Project: | 082_TCU01_F1_TCU_EMU_RSA
|------------------------------------------------------------------------------
| HISTORY OF MODIFICATIONS
| Date - Coder - Description
| 07/02/10 AC Creation of the file.
|------------------------------------------------------------------------------
| FILE DESCRIPTION:
| Configuration source file of the transport protocol (ISO15765_2) layer.
| This source file must contain the transport protocol callback routine
| TPDynamicParametersInitCallback to initialize the dynamic configuration
| parameters for each TP instance defined in TP_CFG.h.
******************************************************************************/
/* -------------------------------- Includes -------------------------------- */
#include "Std_Types.h"
#include "DiagnosticL/Comp_ISO_15765_2/TP.h"
#include "DiagnosticL/ProjectCfg.h"
#include "TP_CFG.h"
#include "DiagnosticL/FicOsek/FicOsekCom.h"
#include "DiagnosticL/UDS\Iso15765_layer3/Iso15765_3_CFG.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
/* -------------------------------- Defines --------------------------------- */
/* Size of the buffer that must store the largest frame for the */
/* MPDT TX and RX instances */
/* The size of the buffer must be declared using the macro */
/* SIZE_ALLOC_BUFFER to assure that no overflows will happen during */
/* transmission or reception of frames larger than single frames */
#define TP_MPDT_TX_LEN (SIZE_ALLOC_BUFFER(30))
#define TP_MPDT_RX_LEN (SIZE_ALLOC_BUFFER(30))
/* For diagnostics TP instance I have the length of the buffers already */
/* defined in the Iso15765_3 layer */
/* ------------------------------- Data Types ------------------------------- */
/* ---------------------------- Global Variables ---------------------------- */
/* Definition of the buffer to allocate functional frames. As functional */
/* frames are not needed in any of my TP instances I declare it as a dummy */
/* buffer. The size of the functional buffer must be always of 7 bytes */
/* because this is the maximum length that could be send in a SF */
//static UI_8 diag_rx_fun_dummy_buf[7] = { 0,0,0,0,0,0,0 };
/* Definition of the transmission and reception TP buffers for MPDT */
//static UI_8 tp_mpdt_tx_buf[TP_MPDT_TX_LEN];
//static UI_8 tp_mpdt_rx_buf[TP_MPDT_RX_LEN];
/* For diagnostics TP instance I have the buffers already defined in the */
/* Iso15765_3 layer */
/* --------------------------- Routine prototypes --------------------------- */
/* -------------------------------- Routines -------------------------------- */
/*****************************************************************************
| Portability: General
|----------------------------------------------------------------------------
| Routine description:
| * It is responsability of the user to declare this routine.
| * This routine is a callback routine that will be called each time that the
| InicialitzaTPTask is executed. This InicialitzaTPTask must be called at
| the initializations in main and must be called once for each instance
| defined in the TP_CFG.h.
| * Routine to initializate dynamically the parameters of each defined
| transport protocol instance. The way to configure each transport protocol
| instance is using the structure t_tp_init which must be given as a pointer
| to TPInitData routine.
|---------------------------------------------------------------------------
| Parameters description:
/---------------------------------------------------------------------------*/
void TPDynamicParametersInitCallback(UI_8 tp_hdl)
{
/* Declare the initialization ISO15765_2 structure as a local variable */
/* in order to not use space in the stack */
t_tp_init tp_init = {0}; /* MISRA wants all variables to be initialized. */
/* Switch for each instance of ISO15765_2 declared (TP_NUM_INSTANCES) */
switch(tp_hdl) {
/* Initialize the user configuration parameters of the transport protocol instance used for diagnostics */
case ISO15765_2_REPROGONCAN_HANDLER:
/* Maximum size allowed for the diagnostics RX buffer. */
/* The buffer must be reserved having into account the MACRO "SIZE_ALLOC_BUFFER" to avoid overflows */
tp_init.max_frm_size = (UI_16)(MAX(TP_DIAG_RX_LEN,TP_DIAG_TX_LEN));
/* Flag to configure fixed or variable length in the CAN frames TX */
/* Diagnostics frm_size_fixed = TRUE: Defined in the renault document 36-02-031--A_Gb.pdf, page 9, chapter 6 */
tp_init.frm_size_fixed = TRUE;
/* Flag to configure if TP RX frames are sensitive to have a fixed length. TRUE indicates that we will ignore TP RX frames */
/* that have less than 8 bytes */
tp_init.rx_padding_sensitive = TRUE;
/* Special value 0x50 is requiered in the padding value for diagnostics TX (only cares if frame size is configured as fixed) */
/* Defined in the renault document CRS_TCU_NT65612_2009_80_v1.1DRAFT.pdf page 6 */
tp_init.tx_padding_value = 0xAA;
/* Maximum timeout in ms between Consecutive frames before aborting the reception due to time out */
/* Diagnostics CR timer: Defined in the renault document 36-02-031--A_Gb.pdf, pages 7 and 17 */
tp_init.cr_timer = (UI_16)150;
/* Time in ms between the first frame and the firs flow control or between the last consecutive frame of a block */
/* and the flow control before aborting the transmission due to timeout */
/* Diagnostics BS timer: Defined in the renault document 36-02-031--A_Gb.pdf, pages 7 and 17 */
tp_init.bs_timer = (UI_16)150;
/* Time in ms between consecutive frames of the transmitter to allow ourself to process the received frames */
/* without losing anyone. If the block size if different from 1, this time must be minimum the cycle frequency, */
/* otherwise if this is 1 the stmin could be 0 */
/* For diagnostics this requirement is defined in the renault document 36-02-031--A_Gb.pdf, page 7 as 0 */
tp_init.stmin_timer = (UI_16)20;
/* Number of consecutive frames that the diagnostics TP will send without waiting for a flow control before continuing. */
/* If the block size is set to 0 means that only one flow control is needed after receiving the first */
tp_init.block_size = (UI_8)0;
/* Number of FC w can handle before rising directly an error during the transmission when a FC wait is received */
tp_init.max_fc_wait = (UI_8) 0;
/* Initialize the buffer pointer where the diagnostics TX positive response physical information is set */
tp_init.tx_phy_buffer = diag_tx_buf;
/* Initialize the buffer pointer where the diagnostics RX physical request information is set */
tp_init.rx_phy_buffer = diag_phy_rx_buf;
/* Initialize the buffer pointer where the diagnostics RX functional request information is set */
tp_init.rx_fun_buffer = diag_fun_rx_buf;
/* Set the OSEKCOM diagnostics signal to get the RX physical frame */
tp_init.sig_np_rx_phy = SIG_DIAGNOSTICREQSWTL; //SIG_DIAGNOSTICREQPRNDL
/* Set the OSEKCOM signal to request the transmission of the diagnostics TX physical frame */
tp_init.sig_np_tx_phy = SIG_DIAGNOSTICRESPSWTL; //SIG_DIAGNOSTICRESPSWTR
/* Initialize the diagnostics RX functional notification routine to NULL because we must not receive functional frames */
//tp_init.np_get_rx_fun_notif = NULL;
/* Initialize the signal of the diagnostics RX functional frame to DUMMY signal becuase we must not receive functional frames */
tp_init.sig_np_rx_fun = SIG_DIAGNOSTICFUNCADDRREQ;
/* Call the ISO15765_2 configuration routine to initialize the diagnostics instance with the configured parameters */
TPInitData(tp_hdl, &tp_init);
break;
default:
break;
}
}

View File

@ -0,0 +1,74 @@
/*************** COPYRIGHT (c) 2012 IDNEO INTERNATIONAL ******************
| Language: | MISRA C
| Controller: | dsPIC33
| Requirements: |
|-----------------|-----------------------------------------------------------
| Project: | 082_TCU01_F1_TCU_EMU_RSA
|------------------------------------------------------------------------------
| Date - Cod. - Rev. - App. - Description
| 07/02/10 AC Creation of the file.
|------------------------------------------------------------------------------
| FILE DESCRIPTION: Configuration header file of the transport protocol
| (ISO15765_2) layer. This header must define if the transport
| protocol used is FULL or LITE which implies if frames till
| 4096 bytes can be send or only single frames till 7 bytes can
| be send. This header must configure the number of transport
| protocol instances that the application need.This header must
| also contain the declaration of the callback routine to
| initialize the transport protocol dynamic configuration
| parameters which must be called TPDynamicParametersInitCallback
******************************************************************************/
#ifndef __TP_CFG_H
#define __TP_CFG_H
/*---------------------------- includes ----------------------------------*/
//#include "FicosarCfg.h"
/*----------------------------- defines ----------------------------------*/
/* Select the mode of ISO15765_2 used. This will apply for all the */
/* transport protocol instances defined */
/* TP_MODE_LITE -> Only single frames can be sent and received */
/* TP_MODE_FULL -> Frames till 4096 bytes can be sent and received */
#define TP_MODE_FULL
/* Number of Transport Protocol instances that will be defined. One */
/* instance must be defined for example for each of the following upper */
/* layters: */
/* - Diagnostics client */
/* - Diagnostics server */
/* - MPDT */
#define TP_NUM_INSTANCES ((UI_8)1)
/*************************** ISO15765_2 HANDLERS USAGE BEGIN****************************/
#define ISO15765_2_REPROGONCAN_HANDLER ((UI_8)0)
/*************************** ISO15765_2 HANDLERS USAGE END ****************************/
/* Ticks between task periodic calls */
#define TP_TASK_TICKS ((t_timer_time)2)
/* Minimum length of a flow control frame to be accepted */
#define CAN_FRM_FC_SIZE ((UI_8)8)
/*------------------------- prototips de funcions ------------------------*/
/*****************************************************************************
| Portability: General
|----------------------------------------------------------------------------
| Routine description:
| * It is responsability of the user to declare this routine.
| * This routine is a callback routine that will be called each time that the
| InicialitzaTPTask is executed. This InicialitzaTPTask must be called at
| the initializations in main and must be called once for each instance
| defined in the TP_CFG.h.
| * Routine to initializate dynamically the parameters of each defined
| transport protocol instance. The way to configure each transport protocol
| instance is using the structure t_tp_init which must be given as a pointer
| to TPInitData routine.
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 tp_hdl : ...
| result none : ...
/---------------------------------------------------------------------------*/
void TPDynamicParametersInitCallback(UI_8 tp_hdl);
#endif

View File

@ -0,0 +1,503 @@
#ifndef _ISO15765_3_CFG_H_
#define _ISO15765_3_CFG_H_
// TODO XXX FIXME: this should probably go to ISO15765_3.H
//#include "Timer.h"
//#include "ProjectCfg.h"
#include "DiagnosticL/UDS/UDS_CoreServices_CB.h"
/* ISO15765_3 VARIANTS */
/* Pure UDS Standard */
#define ISO15765_3_UDS (0x00)
/* RSA Variant*/
#define ISO15765_3_RSA (0x01)
/* Fiat customizations */
#define ISO15765_3_FIAT (0x02)
#define ISO15765_3_GAC (0x03)
#define ISO15765_3_VARIANT (ISO15765_3_UDS)
/* ISO15765_3 MODE */
#define ISO15765_3_APP (0x00)
#define ISO15765_3_BL (0x01)
#define ISO_3_MODE (ISO15765_3_APP)
/* FICOSA_SYSTEM_SUPPLIER_SESSION */
/* 0x60 - 0x7E systemSupplierSpecific: this range of values is reserved for system-supplier-specific use.*/
/* ISO 14229-1:2006(E) pag 39 */
#define UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID ((UI_8)0x60)
/* Size of the buffer that must store the largest frame for the */
/* diagnostic server instance (ISO15765_3) */
/* The size of the buffer must be declared using the macro */
/* SIZE_ALLOC_BUFFER to assure that no overflows will happen during */
/* transmission or reception of frames larger than single frames */
/* Defined Candela A68_GSM_Ficosa.75.cdd -> ECU Information -> Supported Interfaces -> Diagnose CAN */
#define TP_DIAG_FUN_RX_BUFFER ((UI_16)(8))
#define TP_DIAG_RX_BUFFER ((UI_16)(4096))
#define TP_DIAG_TX_BUFFER ((UI_16)(4096))
#define TP_DIAG_FUN_RX_LEN (SIZE_ALLOC_BUFFER(TP_DIAG_FUN_RX_BUFFER))
#define TP_DIAG_RX_LEN (SIZE_ALLOC_BUFFER(TP_DIAG_RX_BUFFER))
#define TP_DIAG_TX_LEN (SIZE_ALLOC_BUFFER(TP_DIAG_TX_BUFFER))
/*
* ISO15765_3_MIN_ADDRESS_LENGTH_MULTIDEVICE:
* Addresses with less bytes will be considered directed to DEVICE_0.
*/
#define ISO15765_3_MIN_ADDRESS_LENGTH_MULTIDEVICE ((UI_8)4)
/* Used ISO15765_2 stack in order to send and receive */
/* the diagnostics */
#define DIAG_ISO15765_2_HDL (ISO15765_2_REPROGONCAN_HANDLER)
/*****************************************************************************/
/* TIMING */
/*****************************************************************************/
/* Max time allowed to answer a request. In milliseconds */
#define P2_MAX ((UI_16)50)
/* Max time between a UDS_ERR_RESPONSE_PENDING and the next answer. In ms */
#define P2_EXT_MAX ((UI_16)200)
/* Max counter between a UDS_ERR_RESPONSE_PENDING and the next answer. */
#define P2_EXT_MAX_COUNTER ((UI_16)150)
/* Session Expiration Timeout. In ms */
#define S3_MAX ((UI_16)5000)
/*****************************************************************************/
/* DATA TYPES */
/*****************************************************************************/
/* Specify the Download Addresses size: */
/* Possible values: ISO3_16BIT_ADDRESS, ISO3_32BIT_ADDRESS */
#define DOWNLOAD_ADDRESS_SIZE (ISO3_32BIT_ADDRESS)
/*****************************************************************************/
/* UDS SERVICES */
/*****************************************************************************/
/* SECURITY ACCESS ENABLED/DISABLED */
#define SERVICE_DISABLED (0x00)
#define SERVICE_ENABLED (0x01)
#define LIN_ASSIGN_FRAME_IDENTIFIER_STATUS (SERVICE_DISABLED)
#define LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_STATUS (SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define LIN_READ_BY_IDENTIFIER_STATUS (SERVICE_DISABLED)
#define LIN_ASSIGN_NAD_STATUS (SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define LIN_CONDITIONAL_CHANGE_NAD_STATUS (SERVICE_DISABLED) /*NOT IMPLEMENTED YET */
#define UDS_SERVICE_SESSION_CONTROL_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_ECU_RESET_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_SECURITY_ACCESS_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_TESTER_PRESENT_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_CONTROL_DTC_SETTING_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS_STATUS (SERVICE_DISABLED)//NOT IMPLEMENTED YET
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_STATUS (SERVICE_DISABLED)//NOT IMPLEMENTED YET
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_READ_DTC_INFORMATION_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_IO_CTRL_BY_ID_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_ROUTINE_CONTROL_STATUS (SERVICE_ENABLED)
#define UDS_SERVICE_REQUEST_DOWNLOAD_STATUS (SERVICE_DISABLED)
#define UDS_SERVICE_TRANSFER_DATA_STATUS (SERVICE_DISABLED)
#define UDS_SERVICE_REQUEST_TRANSFER_EXIT_STATUS (SERVICE_DISABLED)
#define UDS_SERVICE_COMMUNICATION_CONTROL_STATUS (SERVICE_ENABLED)
#if (LIN_ASSIGN_FRAME_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* ASSIGN FRAME IDENTIFIER (0xB7)
*****************************************************************************
* This service IS ONLY VALID in LIN version 2.0
* CALLBACKS:
* LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK(UI_8 supplierID_LSB, UI_8 supplierID_MSB, UI_8 messageID_LSB, UI_8 messageID_MSB, UI_8 new_pid):
* 'supplierID' defines the product vendor identifier.
* 'messageID' defines the message identifier as in <Configurable frames> section in Lin Description File.
* 'new_pid' defines the new pid to identify the frame with the selected messageID.
* A response shall be sent if the assignation is successful.
****************************************************************************/
#define LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_FRAME_IDENTIFIER_CALLBACK (LinAssignFrameId)
#endif
#if (LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* ASSIGN FRAME IDENTIFIER RANGE (0xB7)
*****************************************************************************
* This service IS MANDATORY in all three LIN diagnostics classes
* (See 4.2.5.5 on LIN Spec 2.2)
* CALLBACKS:
* LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK(UI_8 index, const UI_8* new_pid_list):
* 'index' defines the protected identifier (pid) start from the pid list available.
* 'new_pid_lis' defines a buffer where are specified the four new pids for change
* counting from index.
* - 0x00: Disable service.
* - 0xFF: Do not change PID.
* - 0xXX: Change pid.
* The system shall only response if NAD matched.
****************************************************************************/
#define LIN_SERVICE_ASSIGN_FRAME_IDENTIFIER_RANGE (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_FRAME_IDENTIFIER_RANGE_CALLBACK (LinAssignFrameIdRange)
#endif
#if (LIN_READ_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ BY IDENTIFIER (0xB2)
*****************************************************************************
* This service IS MANDATORY in all three LIN diagnostics classes for ID = 0x00
* The rest of identifier are optional.
* (See 4.2.6.1 on LIN Spec 2.2)
* CALLBACKS:
* LIN_READ_BY_IDENTIFIER_CALLBACK(UI_8 id):
* 'id' defines the identifier requested.
* - 0x00: LIN Product identification: SupplierID, FunctionID & Variant.
* - 0x01: Serial Number.
* - 0x32-0x63: User defined.
* - The rest of identifiers are reserved.
* The system shall accordingly to each request. (See 4.2.6.1 on LIN Spec 2.2)
****************************************************************************/
#define LIN_SERVICE_READ_BY_IDENTIFIER (UDS_DEFAULT_SESSION_MASK)
#define LIN_READ_BY_IDENTIFIER_CALLBACK (LinReadByID)
#endif
#if (LIN_ASSIGN_NAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* LIN ASSIGN NAD (0xB0)
*****************************************************************************
* This service CAN be enabled/disabled
* (See 4.2.5.1 on LIN Spec 2.2)
* CALLBACKS:
* LIN_ASSIGN_NAD_CALLBACK(UI_16 supplierId, UI_16 functionId, UI_8 new_nad):
* - 'supplierId' and 'functionId' must be the same as defined in the system,
* otherwise the NAD won't be assigned.
* - 'new_nad' is the new NAD to be assigned
* The system shall response with the initial NAD to confirm the change.
****************************************************************************/
#define LIN_SERVICE_ASSIGN_NAD (UDS_DEFAULT_SESSION_MASK)
#define LIN_ASSIGN_NAD_CALLBACK (LinAssignNAD)
#endif
#if (LIN_CONDITIONAL_CHANGE_NAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* LIN CONDITIONAL CHANGE NAD (0xB3)
*****************************************************************************
* This service CAN be enabled/disabled
* (See 4.2.5.2 on LIN Spec 2.2)
* CALLBACKS:
* LIN_CONDITIONAL_CHANGE_NAD_CALLBACK(UI_8 id, UI_8 byte, UI_8 mask, UI_8 invert, UI_8 new_nad):
* 1. 'id' Get the identifier specified by the function LinReadByID.
* 2. Extract the data byte selected by Byte (Byte = 1 corresponds to the first byte, D1).
* 3. Do a bitwise XOR with Invert.
* 4. Do a bitwise AND with Mask.
* 5. If the final result is zero then change the NAD to New NAD.
* The system shall response with the new NAD to confirm the change.
****************************************************************************/
#define LIN_SERVICE_CONDITIONAL_CHANGE_NAD (UDS_DEFAULT_SESSION_MASK)
#define LIN_CONDITIONAL_CHANGE_NAD_CALLBACK (LinConditionalChangeNAD)
#endif
#if (UDS_SERVICE_SESSION_CONTROL_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* DIAGNOSTICS SESSION CONTROL (0x10)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* .- UDS_INI_SESSION_CALLBACK: The user MAY implement this callback.
* Called when layer 3 changes session
* DEFINES:
* .- UDS_USER_DEFINED_SESSION. Valid User Defined Session ID
****************************************************************************/
#define UDS_SERVICE_SESSION_CONTROL (UDS_ALL_SESSION_MASK)
//TODO: Check allowed session
//#define UDS_USER_DEFINED_SESSION (UDS_DEFAULT_SESSION)
#define UDS_USER_DEFINED_SESSION (UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID)
#define UDS_INI_SESSION_CALLBACK (UdsIniSession)
#endif
#if (UDS_SERVICE_ECU_RESET_STATUS == SERVICE_ENABLED)
/****************************************************************************
* ECU RESET (0x11)
****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* BOOL CHECK_RESET_POSSIBLE(UI_8 reset_type):
* Asks the user if this reset type is allowed at this point in time.
* Return TRUE if yes
* void EXECUTE_RESET(UI_8 reset_type):
* Execute the reset type requested
****************************************************************************/
#define UDS_SERVICE_ECU_RESET (UDS_DEFAULT_SESSION_MASK | UDS_EXT_DIAG_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define CHECK_RESET_POSSIBLE (UdsCheckResetIsPossible)
#define EXECUTE_RESET (UdsExecuteResetNow)
#endif
#if (UDS_SERVICE_SECURITY_ACCESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* SECURITY ACCESS(0x27)
****************************************************************************
* This service can be enabled/disabled
* CALLBACKS:
* void UDS_SECURITY_REQUEST_SEED_CALLBACK(UI_8* p_local_seed):
* Generate a Random Seed and place it in p_local_seed (4 bytes)
* BOOL UDS_SECURITY_CHECK_KEY_CALLBACK(UI_8* p_local_seed, UI_8* p_tool_key):
* Check the key returned by the tool. Return TRUE is ok
* DEFINES
* UDS_SERVICE_SECURITY_ACCESS: set the session which accepts this service.
* SECURITY_INIT_DELAY: Set to SECURITY_DELAY, to introduce 10 secs
* delay after Reset, before accepting security resets. Set to
* SECURITY_NO_DELAY if no delay is wanted.
* MAX_SECURITY_ATTEMPTS: Number of failed attempts before starting the penalty
* SECURITY_PENALTY_TIME: Time to wait before next attempt.
* SECURITY_SEED_SIZE: Number of bytes of the security seed (max = 4)
* SECURITY_KEY_SIZE: Number of bytes of the security seed (max = 4)
* UDS_SECURITY_COUNTER_NVM_CALLBACK: Callback to store a new value of the counter in NVM.
* - Signature: void UDS_SECURITY_COUNTER_NVM_CALLBACK(UI_8 *value)
* - (legacy) If not defined, then value will not be stored in NVM.
* UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK: Callback to retrieve the value of the counter from NVM, tipically
* at the beginning of the execution.
* - Signature: UI_8 UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK(void)
* - (legacy) If not defined, then value will be loaded as zero (check startup strategy for penalty delay
* using SECURITY_INIT_DELAY).
****************************************************************************/
//#define UDS_SERVICE_SECURITY_ACCESS (UDS_EXT_DIAG_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
////#define UDS_SECURITY_REQUEST_SEED_CALLBACK (UdsSecurityGetSeed)
//#define UDS_SECURITY_CHECK_KEY_CALLBACK (UdsSecurityCheckKey)
#define SECURITY_INIT_DELAY (SECURITY_DELAY)
//#define MAX_SECURITY_ATTEMPTS ((UI_8) 3)
#define SECURITY_PENALTY_TIME ((UI_16) 20000)
#define SECURITY_SEED_SIZE ((UI_8) 16)
#define SECURITY_KEY_SIZE ((UI_8) 16)
#define UDS_SECURITY_COUNTER_NVM_CALLBACK (UdsSecurityNvmCallback)
#define UDS_SECURITY_COUNTER_NVM_LOAD_CALLBACK (UdsSecurityLoadNvmCallback)
#endif
#if (UDS_SERVICE_TESTER_PRESENT_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* TESTER PRESENT (0x3E)
*****************************************************************************
* This service CAN be enabled/disabled
* No User CALLBACK Needed
****************************************************************************/
#define UDS_SERVICE_TESTER_PRESENT (UDS_ALL_SESSION_MASK)
#endif
#if (UDS_SERVICE_READ_DATA_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ DATA BY ID(0x22)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK(UI_8 id_high,
* UI_8 id_low): Pass the ID to the user to
* process the request. The user is responsible for checking the security
* status for each parameter, and to send the appropiate response.
*****************************************************************************/
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_READ_DATA_BY_IDENTIFIER_CALLBACK (UdsReadDataByIdentifier)
#endif
#if (UDS_SERVICE_READ_MEMORY_BY_ADDRESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ MEMORY BY ADDRESS(0x23)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK(UI_8 mem_size_len,
* UI_8 mem_addr_len, UI_8* mem_addr, UI_8* mem_size): The user must
* retrieve the requested memory address buffer and return it to the host
*****************************************************************************/
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS (UDS_DEFAULT_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_EXT_DIAG_SESSION_MASK)
#define UDS_SERVICE_READ_MEMORY_BY_ADDRESS_CALLBACK (UdsReadMemoryByAddress)
#endif
#if (UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* WRITE DATA BY IDENTIFIER(0x2E)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UI_16 id,
* UI_8* p_buf, UI_16 size): This callback is
* responsible for starting the writting process to get the data written
* in the apporpiate memory position / device and to
* return the command that must be sent back to the tool
* id: The id to modify
* p_buf: Id data as sent by the diagnostics tool
* size: Amount of ID data bytes received
*****************************************************************************/
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UdsWriteDataByIdentifier)
#endif
#if (UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* WRITE MEMORY BY ADDRES(0x3D)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_WRITE_DATA_BY_IDENTIFIER_CALLBACK (UI_8 id_high,
* UI_8 id_low, UI_8* p_buf, UI_16 size):
* This callback is used by the user to write the data identified with id
* in the appropiate mamory / device. The data sent by the host is passed
* in p_buf/size
*****************************************************************************/
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS (UDS_DEFAULT_SESSION_MASK | UDS_PROGRAMMING_SESSION_MASK | UDS_EXT_DIAG_SESSION_MASK)
#define UDS_SERVICE_WRITE_MEMORY_BY_ADDRESS_CALLBACK (UdsWriteMemoryByAddr)
#endif
#if (UDS_SERVICE_CONTROL_DTC_SETTING_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* CONTROL DTC SETTING (0x85)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK(UI_8 dtc_setting_mode,
* UI_8* buf_data_rx, I_16 size):
* size: size of the dtc option record received
* buf_data_rx: pointer to the dtc option record received
* This callback is responsible for sending the appropiate response
****************************************************************************/
//#define UDS_SERVICE_CONTROL_DTC_SETTING (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_CONTROL_DTC_SETTING_CALLBACK (UdsControlDtcSetting)
#endif
#if (UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* CLEAR DTC INFORMATION(0x14)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* void UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK(UI_8* p_dtc_group)
* Clear all DTC codes identified by the p_dtc_group reference
*****************************************************************************/
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_CLEAR_DIAGNOSTIC_INFORMATION_CALLBACK (UdsClearDtc)
#endif
#if (UDS_SERVICE_READ_DTC_INFORMATION_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* READ DTC INFORMATION(0x19)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK (UI_16 id,
* UI_8* p_buf, UI_16 size):
* Retrieve and send the Diagnostics Info identified by id.
*****************************************************************************/
#define UDS_SERVICE_READ_DTC_INFORMATION (UDS_ALL_SESSION_MASK)
#define UDS_SERVICE_READ_DTC_INFORMATION_CALLBACK (UdsReadDtc)
#endif
#if (UDS_SERVICE_IO_CTRL_BY_ID_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* I/O CONTROL BY ID(0x2F)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_INPUT_OUTPUT_CONTROL_BY_ID(UI_8 *data_buffer, UI_8 size)
*****************************************************************************/
#define UDS_SERVICE_IO_CTRL_BY_ID (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_IO_CTRL_BY_ID_CALLBACK (UdsInputOutputControlByIdentifier)
#endif
#if (UDS_SERVICE_ROUTINE_CONTROL_STATUS == SERVICE_ENABLED)
/****************************************************************************
* ROUTINE CONTROL(0x31)
****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* UI_8 UDS_SERVICE_ROUTINE_CONTROL_START_CALLBACK(UI_8 id_high, UI_8 id_low,
* UI_16 size, UI_8 *data_buffer);
* Host wants to start a control routine.
* User is responsible for returning the appropiate response code.
****************************************************************************/
#define UDS_SERVICE_ROUTINE_CONTROL (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_SERVICE_ROUTINE_CONTROL_CALLBACK (UdsControlRoutine)
#endif
#if (UDS_SERVICE_REQUEST_DOWNLOAD_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* REQUEST DOWNLOAD(0x34)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACK:
* UI_8 DEVICE_0_REQUEST_DOWNLOAD_CALLBACK(t_addr base_addr, t_addr last_addr)
* The host wnats to start a download from address dl_base with a size
* of dl_size in bytes. Calculate if this is possible. And give an answer
* Define one callback for each device in the system that may receive
* data through a downlonad.
****************************************************************************/
#define UDS_SERVICE_REQUEST_DOWNLOAD (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_REQUEST_DOWNLOAD_CALLBACK (UdsPlm2BLRequestDownload)*/
#endif
#if (UDS_SERVICE_TRANSFER_DATA_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* TRANSFER DATA(0x36)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS
* UI_8 DEVICE_0_TRANSFER_DATA_CALLBACK(UI_8* pData, UI_16 size)
* A data block is sent by the host, program it in the right memory.
* The right destination address is responsability of the user callback
* Define one callback per each device that can receive the data
****************************************************************************/
#define UDS_SERVICE_TRANSFER_DATA (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_TRANSFER_DATA_CALLBACK (UdsPlm2BLTransferData)*/
#endif
#if (UDS_SERVICE_REQUEST_TRANSFER_EXIT_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* TRANSFER EXIT(0x37)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACK:
* UI_8 DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK(UI_8* pData, UI_16 size)
* The host informs us that the download process is finished
****************************************************************************/
#define UDS_SERVICE_REQUEST_TRANSFER_EXIT (UDS_PROGRAMMING_SESSION_MASK)
/*#define DEVICE_0_REQUEST_TRANSFER_EXIT_CALLBACK (UdsPlm2BLTransferExit)*/
#endif
#if (UDS_SERVICE_COMMUNICATION_CONTROL_STATUS == SERVICE_ENABLED)
/*****************************************************************************
* COMMUNICATION CONTROL (0x28)
*****************************************************************************
* This service CAN be enabled/disabled
* CALLBACKS:
* .- UDS_COMMUNICATION_CONTROL_CALLBACK: The user MAY implement this callback.
* DEFINES:
* .- UDS_COMMUNICATION_CONTROL. Session in which the service will be supported
****************************************************************************/
#define UDS_SERVICE_COMMUNICATION_CONTROL (UDS_EXT_DIAG_SESSION_MASK|UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_MASK)
#define UDS_COMMUNICATION_CONTROL_CALLBACK (UdsCommunicationControl)
#endif
#endif

View File

@ -0,0 +1,25 @@
/* ------------------------------ Includes --------------------------------- */
#include "Std_Types.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
#include "UdsServerCallbacks_H61L.h"
#include "DiagnosticL/ProjectCfg.h"
//#include "FicoHwAbsADC.h"
//#include "ficoNVM_wrapper_dcm.h"
//#include "Dem.h"
//#include "QMGateway.h"
/* --------------------------- Type Definitions ---------------------------- */
/* ------------------------------- Defines --------------------------------- */
#define DTC_NUM_SUBFUNC ((uint8)0x16)
#define VALUE_IS_NOT_USED ((uint8)0x00)
#define BYTES_TO_DTC(hb, mb, lb) (((uint32)(hb) << 16) | ((uint32)(mb) << 8) | (uint32)(lb))
#define DTC_HIGH_BYTE(dtc) (((uint32)(dtc) >> 16) & 0xFFu)
#define DTC_MID_BYTE(dtc) (((uint32)(dtc) >> 8) & 0xFFu)
#define DTC_LOW_BYTE(dtc) ((uint32)(dtc) & 0xFFu)

View File

@ -0,0 +1,86 @@
#ifndef __UDSSERVERCALLBACKS_GM_H
#define __UDSSERVERCALLBACKS_GM_H
/* ------------------------------ Includes --------------------------------- */
#include "Global.h"
#include "Iso15765_3_CFG.h"
/* --------------------------- Type Definitions ---------------------------- */
/* ------------------------------- Defines --------------------------------- */
#define START_DOWNLOAD_VALUE (0xABC1) /* Memory value to indicate to the bootloader that a reprogramming session is requested */
/************************* DATA IDENTIFIERS ***********************************/
/*** SUPPORTED DATA IDENTIFIERS FOR READDATABYID AND WRITEDATABYID SERVICES ***/
#define DID_DIO_HALL_SENSOR_VALUES ((uint16)0xB000)
#define DID_DIO_ST ((uint16)0xB001)
#define DID_DIO_HOLD ((uint16)0xB002)
#define DID_DIO_SNS_ENA ((uint16)0xB003)
#define DID_DIO_HALL_ENA_1 ((uint16)0xB004)
#define DID_DIO_HALL_SNS_2 ((uint16)0xB005)
#define DID_DIO_STR_RLY_CTRL ((uint16)0xB006)
#define DID_DIO_REV_LMP_CTRL ((uint16)0xB007)
#define DID_DIO_RESET_TO_SUPERVISOR ((uint16)0xB008)
#define DID_ADC_IGN_SNS ((uint16)0xB100)
#define DID_ADC_BAT_12V_SNS ((uint16)0xB101)
#define DID_ADC_PWR_OR_SNS ((uint16)0xB102)
#define DID_ADC_2V5REFA ((uint16)0xB103)
#define DID_ADC_VCC_B_SNS ((uint16)0xB104)
#define DID_ADC_VCC_C_SNS ((uint16)0xB105)
#define DID_ADC_VCC_HALL_A_SNS ((uint16)0xB106)
#define DID_ADC_VCC_HALL_B_SNS ((uint16)0xB107)
#define DID_ADC_HW_VERSION ((uint16)0xB108)
#define DID_ADC_REV_LMP_SNS ((uint16)0xB109)
#define DID_ADC_STR_RLY_SNS ((uint16)0xB110)
#define DID_COLUMN_SHIFTER_DETECTION ((uint16)0xB020)
/* Routine Control */
#define DID_Periodic_ID ((uint16)0xF005)/* Same than NEVs */
#define DID_UDS_Resp_ID ((uint16)0xF006)/* Same than NEVs */
#define DID_UDS_Req_ID ((uint16)0xF007)/* Same than NEVs */
/* IO Control */
#define DID_HS_Control ((uint16)0xF100)
#define DID_SR_Control ((uint16)0xF101)
#define DID_RLR_Control ((uint16)0xF102)
/* Logistic data */
#define DID_FICOSA_HW_ID ((UI_16)0xF192)
#define DID_FICOSA_SW_ID ((UI_16)0xF194)
#define DID_PP_DIO_HALL_SENSOR_VALUES ((uint16)0xFD00)
#define DID_PP_DIO_ST ((uint16)0xFD01)
#define DID_PP_DIO_HOLD ((uint16)0xFD02)
#define DID_PP_DIO_SNS_ENA ((uint16)0xFD03)
#define DID_PP_DIO_HALL_ENA_1 ((uint16)0xFD04)
#define DID_PP_DIO_HALL_SNS_2 ((uint16)0xFD05)
#define DID_PP_DIO_STR_RLY_CTRL ((uint16)0xFD06)
#define DID_PP_DIO_REV_LMP_CTRL ((uint16)0xFD07)
#define DID_PP_DIO_RESET_TO_SUPERVISOR ((uint16)0xFD08)
#define DID_PP_ADC_IGN_SNS ((uint16)0xFD20)
#define DID_PP_ADC_BAT_12V_SNS ((uint16)0xFD21)
#define DID_PP_ADC_PWR_OR_SNS ((uint16)0xFD22)
#define DID_PP_ADC_2V5REFA ((uint16)0xFD23)
#define DID_PP_ADC_VCC_B_SNS ((uint16)0xFD24)
#define DID_PP_ADC_VCC_C_SNS ((uint16)0xFD25)
#define DID_PP_ADC_VCC_HALL_A_SNS ((uint16)0xFD26)
#define DID_PP_ADC_VCC_HALL_B_SNS ((uint16)0xFD27)
#define DID_PP_ADC_HW_VERSION ((uint16)0xFD28)
#define DID_PP_ADC_REV_LMP_SNS ((uint16)0xFD29)
#define DID_PP_ADC_STR_RLY_SNS ((uint16)0xFD30)
#define DID_PP_PRODUCTION_DATA ((uint16)0xFE00)
#define DID_PP_UDS_SESSION_CHECK ((uint16)0xFE01)
#define DID_PP_START_UP_HS_CHECK ((uint16)0xFE02)
/* Logistic data */
#define DID_PP_FICOSA_HW_ID ((UI_16)0xFE92)
#define DID_PP_FICOSA_SW_ID ((UI_16)0xFE94)
/* Definitions needed for the Read/WriteMemoryByAddress UDS services */
#define FIXED_ADDR_LEN ((UI_8)4)
#define MAX_ADDR_SIZE ((UI_8)4)
#define MAX_SIZE_LEN ((UI_8)0xFF)
#define DIAG_TX_RX_BUF_LEN ((UI_8)0xFF)
#define MAX_DATA_SIZE ((UI_8)4)
#endif

View File

@ -0,0 +1,136 @@
/**
* Copyright (c) 2018
*
* @file
* Common Macros and Constants Non Platform Related
*/
#ifndef COMMON_H_
#define COMMON_H_
/* ---------------------------------------------------------------------------
* Includes
*/
//#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define CLI
/* ---------------------------------------------------------------------------
* Printing
*/
#define PRINTF(...) printf(__VA_ARGS__)
#define TRACE_PRINT(...) printf(__VA_ARGS__)
/* ---------------------------------------------------------------------------
* Exported Constants
*/
#define PROMPT "\n# "
#define SUCCESS 0
#define ERROR 1
//#define TRUE 1
//#define FALSE 0
/* ---------------------------------------------------------------------------
* Exported Macros
*/
/* ---------------------------------------------------------------------------
* Variadic macro argument helpers
*/
/**
* Expand first argument in variadic list.
*/
#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway)
#define FIRST_HELPER(first, ...) first
/**
* Expand to "," and subsequent arguments in variadic list if any, else empty.
*
* Arbitrary limit of 9 arguments.
*/
#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__)
#define REST_HELPER(qty, ...) REST_HELPER2(qty, __VA_ARGS__)
#define REST_HELPER2(qty, ...) REST_HELPER_##qty(__VA_ARGS__)
#define REST_HELPER_ONE(first)
#define REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__
#define NUM(...) SELECT_10TH(__VA_ARGS__, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\
TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway)
#define SELECT_10TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10
/**
* Stringify a token
*
* #define foo 4
* STR(foo) -> "foo"
*/
#define STR(s) #s
/**
* Expand, then stringify a token
*
* #define foo 4
* XSTR(foo) -> "4"
*/
#define XSTR(s) STR(s)
#define COUNTOF(a) (sizeof(a)/sizeof(*(a)))
#define NOOF(a) (sizeof(a)/sizeof(a[0]))
#define UNUSED(x) (void)x
/** 1st dimension of fixed-size array */
#define ARRAY_DIM(a) (sizeof(a) / sizeof((a)[0]))
/** Pointer to 1st element of fixed-size array - used to start iterations */
#define ARRAY_START(a) (&(a)[0])
/** Pointer to last element + 1 of fixed-size array - used to terminate iterations */
#define ARRAY_STOP(a) (ARRAY_START(a) + ARRAY_DIM(a))
#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1]
// token pasting madness:
#define COMPILE_TIME_ASSERT3(X,L) STATIC_ASSERT(X,static_assertion_at_line_##L)
#define COMPILE_TIME_ASSERT2(X,L) COMPILE_TIME_ASSERT3(X,L)
#define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X,__LINE__)
#define LINK_SECTION(name) __attribute__((section(#name)))
/**
* Tag a static variable to force compiler not to optimise it away.
*
* E.g. a variable in shared ram that is only read.
*
* Prefer to "volatile" for this purpose (only) as volatile changes the type.
*/
#define COMPILER_KEEP __attribute__((__used__))
/**
* Tag XCP diagnostic variable (read only).
*/
#define XCP_DIAGNOSTIC LINK_SECTION(.xcp.diag)
/**
* Tag XCP calibration variable (read/write).
*/
#define XCP_CALIBRATION LINK_SECTION(.xcp.cal)
/* ---------------------------------------------------------------------------
* Exported Types
*/
/* ---------------------------------------------------------------------------
* Exported Variables
*/
/* ---------------------------------------------------------------------------
* Exported Functions
*/
#endif /* COMMON_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,587 @@
#ifndef __UDSSERVERCALLBACKS_GM_H
#define __UDSSERVERCALLBACKS_GM_H
/* ------------------------------ Includes --------------------------------- */
//#include "Global.h"
//#include "ISO15765_3_CFG.h"
//<<Wang
#include "Std_Types.h"
typedef unsigned char UI_8;
//Wang>>
/* --------------------------- Type Definitions ---------------------------- */
/* ------------------------------- Defines --------------------------------- */
#define START_DOWNLOAD_VALUE (0xABC1) /* Memory value to indicate to the bootloader that a reprogramming session is requested */
/************************* DATA IDENTIFIERS ***********************************/
/*** SUPPORTED DATA IDENTIFIERS FOR READDATABYID AND WRITEDATABYID SERVICES ***/
/* FICOSA DIDs */
/* DIAGNOSTICS ACTIVE */
#define DID_DIAGNOSTICS_ACTIVE ((UI_16)0x08) //ACT: 0x7CA, 0x03, 0x2F, 0x08, 0x01, 0x50, 0x50, 0x50, 0x50
//FREE: 0x7CA, 0x03, 0x2F, 0x08, 0xFF, 0x50, 0x50, 0x50, 0x50
/* CAN IDS MANAGEMENT */
#define DID_CAN_IDS_MANAGEMENT_SEED ((UI_16)0x001) // 0x7CA, 0x04, 0x2E, 0x00, 0x01, 0xSD, 0x50, 0x50, 0x50
/* SYSTEM SHUTDOWN NOTIF */
#define DID_SYSTEM_SHUTDOWN_NOTIF ((UI_16)0x002) // 0x7CA, 0x04, 0x2E, 0x00, 0x02, 0xSS, 0x50, 0x50, 0x50
/* LENGTH OF DATA IDENTIFIERS FOR READDATABYID AND WRITEDATABYID SERVICES */
/*** SUPPORTED LOCAL IDENTIFIERS FOR INPUTOUTPUTCONTROLBYLOCALID SERVICE ***/
/* FICOSA DIDs */
/* MOTOR DRIVING DRIVING AND MONITORING */
#define DID_MOTOR_DRIVING ((UI_16)0x01)
#define IO_CTL_LED_STATUS ((UI_16)0xFA00)
#define IO_CTL_ACT_MOV_SUB_RETURN_CONTOL ((UI_8)0x00)
#define IO_CTL_ACT_MOV_SUB_RESET ((UI_8)0x01)
#define IO_CTL_ACT_MOV_SUB_FREEZE ((UI_8)0x02)
#define IO_CTL_ACT_MOV_SUB_CONTROL ((UI_8)0x03)
/*** SUPPORTED LOCAL IDENTIFIERS FOR ROUTINE CONTROL SERVICE ***/
/* FICOSA DIDs */
#define ROUTINE_CTL_N_CAL_DEMO ((UI_16)0xF1C1)
#define ROUTINE_CTL_CALIBRATION_MODE ((UI_16)0xF1C0)
#define ROUTINE_CTL_UNCALIBRATION_MODE ((UI_16)0x1800)
#define ROUTINE_CTL_PROGRAM_PRECONDITION ((UI_16)0x0203)
#define ROUTINE_CTL_CALI_IDLE_START ((UI_16)0x0100)
#define ROUTINE_CTL_CALI_F1_START ((UI_16)0x0101)
#define ROUTINE_CTL_CALI_F2_START ((UI_16)0x0102)
#define ROUTINE_CTL_CALI_B1_START ((UI_16)0x0103)
#define ROUTINE_CTL_CALI_B2_START ((UI_16)0x0104)
/* Definitions needed for the Read/WriteMemoryByAddress UDS services */
#define FIXED_ADDR_LEN ((UI_8)4)
#define MAX_ADDR_SIZE ((UI_8)4)
#define MAX_SIZE_LEN ((UI_8)0xFF)
#define DIAG_TX_RX_BUF_LEN ((UI_8)0xFF)
#define MAX_DATA_SIZE ((UI_8)4)
/** New DID's **/
/* Logistic data */
#define DID_FICOSA_HW_ID ((UI_16)0xF192)
#define DID_FICOSA_SW_ID ((UI_16)0xF194)
#define DID_CD_SYSID_DIAGNOSTIC_SPEC ((UI_16)0xF10D)
#define DID_CD_SYSID_ECU_HW_VER_NUMBER ((UI_16)0xF193)
#define DID_CD_SYSID_ECU_SW_VER_NUMBER ((UI_16)0xF195)
#define DID_CD_SYSID_BOOT_ID ((UI_16)0xF180)
#define DID_CD_SYSID_APP_SW_ID ((UI_16)0xF181)
#define DID_CD_SYSID_APP_SW_FINGERPRINT ((UI_16)0xF184)
#define DID_CD_SYSID_ACTIVE_DIAG_SESSION ((UI_16)0xF186)
#define DID_CD_SYSID_SPARE_PART_NUMBER ((UI_16)0xF187)
#define DID_CD_SYSID_ECU_SW_VERSION ((UI_16)0xF189)
#define DID_CD_SYSID_SYSTEMSUPPLIER_ID ((UI_16)0xF18A)
#define DID_CD_SYSID_KIT_ASSEMLY_PART_NUMBER ((UI_16)0xF18E)
#define DID_CD_SYSID_REPAIR_SHOP_CODE ((UI_16)0xF198)
#define DID_CD_SYSID_UDS_PROTOCOL_VERSION ((UI_16)0xF100)
#define DID_CD_SYSID_REPROGRAMING_DATE ((UI_16)0xF199)
#define DID_CD_SYSID_BOOT_VERSION ((UI_16)0xF101)
#define DID_CD_SYSID_DIAGNOSTIC_TABLE_VERSION ((UI_16)0xF10B)
#define DID_CD_SYSID_ECU_NAME ((UI_16)0xF197)
#define DID_CD_SYSID_CALIBRATION_SW_VERSION ((UI_16)0xF1B2)
#define DID_CD_SYSID_SHARED_KEY ((UI_16)0xF16A)
#define DID_FUN1 ((UI_16)0x9020)
#define DID_FUN2 ((UI_16)0x9021)
#define DID_FUN3 ((UI_16)0x9022)
#define DID_UP ((UI_16)0x9023)
#define DID_DOWN ((UI_16)0x9024)
#define DID_LEFT ((UI_16)0x9025)
#define DID_RIGHT ((UI_16)0x9026)
#define DID_OK ((UI_16)0x9027)
#define DID_Trigger_Vibration ((UI_16)0x9001)
#define DID_DAC_Ref_Voltage ((UI_16)0x9002)
#define DID_Vibration_Gain ((UI_16)0x9003)
#define DID_DAC_Timer_Period ((UI_16)0x9004)
#define DID_Measure_Frame_Switch ((UI_16)0xA001)
#define DID_CD_SYSID_INDEXSRVDATA ((UI_16)0xF011)
#define DID_CD_SYSID_OPERATIONALREF ((UI_16)0xF012)
#define DID_CD_SYSID_ECU_MANUFAC_DATE ((UI_16)0xF18B)
#define DID_CD_SYSID_ECUSNDATAID ((UI_16)0xF18C)
#define DID_CD_SYSID_VIN ((UI_16)0xF190)
#define DID_CD_SYSID_CALIBRATION_DATA ((UI_16)0xF19B)
#define DID_CD_SYSID_BOOT_VERSION ((UI_16)0xF101)
#define DID_CD_SYSID_MANUF_ECUHWNUM ((UI_16)0xF191)
#define DID_CD_SYSID_ECU_INSTALL_DATE ((UI_16)0xF19D)
#define DID_CD_SYSID_VEH_POWERMODE ((UI_16)0xFD08)
/** Dynamic **/
#define DID_READ_MELEXIS_SPI_DATA ((UI_16)0xFD00)
#define DID_READ_BATTERY_ADC ((UI_16)0x1000)
#define DID_READ_INTERNAL_ADC ((UI_16)0xFD01)
#define DID_READ_PADDLE_ADC ((UI_16)0x1001)
#define DID_READ_PARK_SWITCH_ADC ((UI_16)0x1002)
#define DID_READ_ECO_SWITCH_ADC ((UI_16)0x1004)
#define DID_READ_SHIFT_POSITION ((UI_16)0x2100)
#define DID_READ_ACTUATOR_POSITION ((UI_16)0x2103)
#define DID_READ_ILLUMINATION_DUTY ((UI_16)0x2002)
#define DID_READ_TCU_POSITION ((UI_16)0x2102)
#define DID_READ_BCS_SPEED ((UI_16)0x0500)
#define DID_READ_BRAKE_STATE ((UI_16)0x0501)
#define DID_READ_BCM_KEY_STS ((UI_16)0x1202)
#define DID_READ_SHIFT_DISABLE_CONDITION ((UI_16)0x1204)
#define DID_READ_REPROGRAMMING_COUNTER ((UI_16)0x0200)
#define DID_READ_REPROGRAMMING_ATTEMPT_COUNTER ((UI_16)0x0201)
#define DID_READ_SHIFT_LEVER_POS ((UI_16)0x2104)
#define DID_READ_POW_SUP_VOLTAGE ((UI_16)0xB001)
#define DID_READ_SYS_MEC_POSITION ((UI_16)0xB003)
#define DID_READ_P_BUT_STATUS ((UI_16)0xB004)
#define DID_READ_MLX_DIE1_VAL ((UI_16)0xB005)
#define DID_READ_MLX_DIE2_VAL ((UI_16)0xB006)
#define DID_READ_DTC_OCCURENCE_CNT ((UI_16)0xB101)
#define DID_READ_FAULT_DET_CNT ((UI_16)0xB102)
#define DID_READ_UNCOMPLETE_TES_CNT ((UI_16)0xB103)
#define DID_READ_FAULT_OCCUENCE_CNT ((UI_16)0xB104)
#define DID_READ_DTC_AGEING_CNT ((UI_16)0xB105)
#define DID_READ_ALLDTC_EXT_REC ((UI_16)0xB106)
/** FICOSA **/
#define DID_FICOSA_CALI_STABLE_POSTION ((UI_16)0xFD02)
#define DID_FICOSA_CALI_F2_POSTION ((UI_16)0xFD06)
#define DID_FICOSA_CALI_B2_POSTION ((UI_16)0xFD05)
#define DID_FICOSA_CALI_F1_POSTION ((UI_16)0xFD03)
#define DID_FICOSA_CALI_B1_POSTION ((UI_16)0xFD04)
#define DID_SHIFT_PADDLE_CONFKGURE ((UI_16)0xFD10)
#define DID_FICOSA_SHIELD_ATP ((UI_16)0x0600)
#define DID_FICOSA_DRIVE_MODE_CONFIGURE ((UI_16)0x0102)
#define DID_FICOSA_SHIFT_FAILURE_REASON ((UI_16)0x1204)
#define DID_FICOSA_SHIFT_RESET_REASON ((UI_16)0x1205)
#define DID_FICOSA_MLX_OPERATION_MODE ((UI_16)0xFD07)
/* GAC */
#define DID_GAC_MANUFACTORY_MODE ((UI_16)0x0110)
#define DID_GAC_DTC_SETTING_CONTROL_STATE ((UI_16)0x0120)
#define DID_GAC_TRANSPORTATION_MODE ((UI_16)0x0140)
#define IO_CTL_LED_STATUS_MS_MASK ((UI_16)0x08)
#define IO_CTL_LED_STATUS_D_MASK ((UI_16)0x10)
#define IO_CTL_LED_STATUS_N_MASK ((UI_16)0x20)
#define IO_CTL_LED_STATUS_R_MASK ((UI_16)0x40)
#define IO_CTL_LED_STATUS_P_MASK ((UI_16)0x80)
#define IO_STS_LED_STATUS_D_MASK ((UI_16)0x10)
#define IO_STS_LED_STATUS_N_MASK ((UI_16)0x20)
#define IO_STS_LED_STATUS_R_MASK ((UI_16)0x40)
#define IO_STS_LED_STATUS_P_MASK ((UI_16)0x80)
/*Applicaiton*/
#define DID_TOUCH_SEN1_BASE_LINE ((UI_16)0x7000)
#define DID_TOUCH_SEN2_BASE_LINE ((UI_16)0x7001)
#define DID_TOUCH_SEN3_BASE_LINE ((UI_16)0x7002)
#define DID_TOUCH_SEN4_BASE_LINE ((UI_16)0x7003)
#define DID_TOUCH_SEN5_BASE_LINE ((UI_16)0x7004)
#define DID_TOUCH_SEN6_BASE_LINE ((UI_16)0x7005)
#define DID_TOUCH_SEN7_BASE_LINE ((UI_16)0x7006)
#define DID_TOUCH_SEN8_BASE_LINE ((UI_16)0x7007)
#define DID_TOUCH_SEN9_BASE_LINE ((UI_16)0x7008)
#define DID_TOUCH_SEN10_BASE_LINE ((UI_16)0x7009)
#define DID_TOUCH_SEN11_BASE_LINE ((UI_16)0x700A)
#define DID_TOUCH_SEN12_BASE_LINE ((UI_16)0x700B)
#define DID_TOUCH_SEN13_BASE_LINE ((UI_16)0x700C)
#define DID_TOUCH_SEN14_BASE_LINE ((UI_16)0x700D)
#define DID_TOUCH_SEN15_BASE_LINE ((UI_16)0x700E)
#define DID_TOUCH_SEN1_SIGNAL ((UI_16)0x7010)
#define DID_TOUCH_SEN2_SIGNAL ((UI_16)0x7011)
#define DID_TOUCH_SEN3_SIGNAL ((UI_16)0x7012)
#define DID_TOUCH_SEN4_SIGNAL ((UI_16)0x7013)
#define DID_TOUCH_SEN5_SIGNAL ((UI_16)0x7014)
#define DID_TOUCH_SEN6_SIGNAL ((UI_16)0x7015)
#define DID_TOUCH_SEN7_SIGNAL ((UI_16)0x7016)
#define DID_TOUCH_SEN8_SIGNAL ((UI_16)0x7017)
#define DID_TOUCH_SEN9_SIGNAL ((UI_16)0x7018)
#define DID_TOUCH_SEN10_SIGNAL ((UI_16)0x7019)
#define DID_TOUCH_SEN11_SIGNAL ((UI_16)0x701A)
#define DID_TOUCH_SEN12_SIGNAL ((UI_16)0x701B)
#define DID_TOUCH_SEN13_SIGNAL ((UI_16)0x701C)
#define DID_TOUCH_SEN14_SIGNAL ((UI_16)0x701D)
#define DID_TOUCH_SEN15_SIGNAL ((UI_16)0x701E)
#define DID_PRESEE_SEN_BASELINE ((UI_16)0x7020)
#define DID_PRESEE_SEN_SIGNAL ((UI_16)0x7021)
#define DID_PRESEE_SEN_PRE_VAL ((UI_16)0x7022)
/*--------------------------- Global variables ---------------------------- */
//#pragma push
//#pragma section data_type ".sect_shr_var_ram" ".sect_shr_var_ram"
/* Variable to enable directly a download session after a SW reset. This variable */
/* will be set by the application before reset only in the case that a reprog */
/* session is requested. */
/* This variable is declared here in main to make it clear for everybody that it */
/* is shared between bootloader and application. */
//extern UI_16 start_download;
//
///* Bootloader variable that tells if bootloader must respond or not to the session
//change when coming from application (supress positive response) */
//extern UI_16 start_download_response;
//
///* Variable shared between bootloader and application in which application says to */
///* bootloader to perform a memory selfcheck because it has detected some problems */
///* This variable is declared here in main to make it clear for everybody that it */
///* is shared between bootloader and application */
//extern UI_16 check_app;
//
///* Bootloader variable that tells if bootloader must give control to the app */
//extern UI_16 bootloader_active;
//
////#pragma pop
extern uint8 security_faa_flag;
extern UI_8 manufactory_mode;
extern BOOL uds_control_led;
extern BOOL uds_control_led_lmc;
extern uint8 uds_control_led_conbyte;
extern BOOL uds_control_led_p;
extern BOOL uds_control_led_r;
extern BOOL uds_control_led_n;
extern BOOL uds_control_led_d;
//extern BOOL dtc_setting;
/* ------------------------- Function prototypes --------------------------- */
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsTesterPresent diagnostic service and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 tp_type : tester present type requested
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsTesterPresent(UI_8 tp_type);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands all the ReadDataByIdentifier diagnostics and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 id_h : higher byte of the identifier requested
| UI_8 id_l : lower byte of the identifier requested
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
UI_8 UdsReadDataByIdentifier(UI_8 id_h, UI_8 id_l);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands all the WriteDataByIdentifier diagnostics and is
| responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 id_h : higher byte of the identifier requested
| UI_8 id_l : lower byte of the identifier requested
| UI_8 *data_buffer: data pointer of the received parameters for the write
| UI_16 size: length of the parameters received for the write
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsWriteDataByIdentifier(UI_8 id_h, UI_8 id_l, UI_8 *buf_data_rx, UI_16 size);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsReadMemoryByAddress diagnostic service
| and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 mem_size_len: length of the requested size in bytes
| UI_8 mem_addr_len: length of the requested address in bytes
| UI_8 *mem_addr: data pointer to the requested initial memory address to be read
| UI_8 *mem_size: data pointer to the requested memory size to be read
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsReadMemoryByAddress(UI_8 mem_size_len, UI_8 mem_addr_len,
UI_8 *mem_addr, UI_8 *mem_size);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsWriteMemoryByAddress diagnostic service
| and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 addr_data_size: The first four bits cointains the data size length in
| bytes and the last four bits contains the address size
| length in bytes
| UI_8 *data_buffer: Data pointer where to find the requested initial write
| address, the requested write length and the values to write
| in memory
| UI_16 size: ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsWriteMemoryByAddr(UI_8 addr_data_size, UI_8 *data_buffer, UI_16 size);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the InputOutputControlByLocalId diagnostic
| service and is responsible for giving the final answer to ISO_3 layer
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 *data_buffer: data pointer to the received control data
| UI_8 size: length of the data received to control
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsInputOutputControlByIdentifier(UI_8 id_h, UI_8 id_l, UI_8 io_ctrl_type, UI_8* buf_data_rx, UI_16 size);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * Routine that commands the TcuUdsDiagnosticSessionControl diagnostic
| service and is responsible for giving the final answer to ISO_3 layer.
|---------------------------------------------------------------------------
| Arguments:
| - session: requested new session
|---------------------------------------------------------------------------
| Parameters description:
| UI_8 session: requested new session
| result none : ..
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsDiagnosticSessionControl(UI_8 session);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * UdServices diagnostic initialitzation task. This routine should only
| be called one time at the microcontroller initialization
|---------------------------------------------------------------------------
| Parameters description:
| void: ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsServerCallbacksInit(void);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| * UdServices diagnostic task executed in every main cycle
|---------------------------------------------------------------------------
| Parameters description:
| void: ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsServerCallbacksTask(void);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsIniSession(void);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
BOOL UdsCheckResetIsPossible(UI_8 reset_type);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsExecuteResetNow(UI_8 reset_type);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
UI_8 UdsControlRoutineCallback(UI_8 id_high, UI_8 id_low, UI_8* routine_entry_option, UI_16 size);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
//UI_8 UdsSecurityGetSeed(UI_8 seed_type, UI_8 * seed);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
//BOOL UdsSecurityCheckKey(UI_8 key_type, UI_8 * seed, UI_8 * key, UI_8 * response_mode);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsCommunicationControl(UI_8 subfunction, UI_8 comtype);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
void UdsSecurityNvmCallback(UI_8 *counter);
/*****************************************************************************
| Portability: DEFC Project
|----------------------------------------------------------------------------
| Description:
| *
|---------------------------------------------------------------------------
| Parameters description:
| param : ...
| result none : ...
| Timing:
| Tmax Int Dis: ? cicles cpu | O(n): CTE
| Tmax Int En : ? cicles cpu | O(n): CTE
| Tmax Total : ? cicles cpu | O(n): CTE
/---------------------------------------------------------------------------*/
UI_8 UdsSecurityLoadNvmCallback(void);
#define STORAGE_FAA_CALLBACK (StorageFaaFlag)
void StorageFaaFlag(void);
void QMGatewayDEMTask(void);
#endif

View File

@ -0,0 +1,843 @@
/* ----------------------------------------------------------------------------
* Implements
*/
#include "UDS_Services_Common.h"
/* ----------------------------------------------------------------------------
* Uses
*/
#include "ModelsInterfaces/CommonMacros.h"
//#include "Platform_Types.h"
#include "DiagnosticL/ProjectCfg.h"
#include "Std_Types.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
#include "UDS_Services_Common.h"
#include "UDS_CoreServices_CB.h"
//#include "ficoNVM.h"
//#include "GearShiftStrategy_If.h"
//#include "DriveModeSwitch_If.h"
//#include "PaddleStatus_If.h"
#include "smartee.h"
/* ----------------------------------------------------------------------------
* Private defines
*/
#define DLC_DID_ECU_SN 24U
#define DLC_DID_CD_VIN 17U
#define DLC_DID_CD_MANFAC_SN 16U
#define DLC_DID_CD_APP_DATAID 3U
#define DLC_DID_CD_MANUF_ECUHWNUM 11U
#define DLC_DID_DTC_SETTING 12U
#define DLC_DID_MTOC 17U
#define DLC_DID_SHEILD_AUTOPARK 1U
#define DLC_DID_TRANSPORTATION_MODE 1U
#define DLC_DID_REPROGRAMMING_COUNTER 2U
#define DLC_DID_REPROGRAMMING_DATE 4U
#define DLC_DID_APPSW_FINGER_PRINT 26U
#define DLC_DID_ECUMANUFACTURE_DATE 6U
#define DLC_DID_ECUINSTALLATION_DATE 6U
#define DLC_DID_DCID 3U
#define DLC_GAC_DIAG_SPEC_VERSION 3U
#define DLC_GAC_HW_VERSION 16U
#define DLC_GAC_ECU_SW_VERSION 16U
#define DLC_GAC_SPARE_NUMBER 14U
#define DLC_SYSTEM_SUPPLIER_ID 6U
#define DLC_GAC_KIT_PART_NUMBER 14U
#define DLC_SYSTEM_NAME 20U
#define DLC_UDS_PROTOL_VERSION 2U
#define DLC_BOOT_SW_VERSION 6U
#define DLC_REPAIR_SHOP_CODE 16U
#define DLC_BOOT_SW_ID 3U
/* ----------------------------------------------------------------------------
* Private types
*/
typedef struct{
UI_8 gac_diagnostic_version[DLC_GAC_DIAG_SPEC_VERSION];
UI_8 gac_hardware_version[DLC_GAC_HW_VERSION];
UI_8 gac_spare_number[DLC_GAC_SPARE_NUMBER];
UI_8 system_supplier_id[DLC_SYSTEM_SUPPLIER_ID];
UI_8 gac_kit_assembly_part_number[DLC_GAC_KIT_PART_NUMBER];
UI_8 system_name[DLC_SYSTEM_NAME];
UI_8 uds_protol_version[DLC_UDS_PROTOL_VERSION];
UI_8 boot_version[DLC_BOOT_SW_VERSION];
}t_logical_did;
/* ----------------------------------------------------------------------------
* Private macros
*/
/* ----------------------------------------------------------------------------
* Forward declarations
*/
/* ----------------------------------------------------------------------------
* Private variables
*/
const UI_8 NVM_DID_CD_VIN[DLC_DID_CD_VIN] = GAC_VIN_DEFAULT_VALUE;
const UI_8 NVM_Reprogramming_Date_App[DLC_DID_REPROGRAMMING_DATE] = {0x20,0x24,0x06,0x24};
const UI_8 NVM_DID_CD_SUPPLIER_ID[DLC_SYSTEM_SUPPLIER_ID] = {'2','4','0','6','2','4'};
const UI_8 NVM_Repair_Shop_Code[DLC_REPAIR_SHOP_CODE] = GAC_ECU_REPAIR_SHOP_CODE;
const UI_8 NVM_DID_CD_HW_VERSION[DLC_GAC_HW_VERSION] = {'H','W','0','5',0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};
static uint8 RAM_DID_CD_VIN[DLC_DID_CD_VIN];
static uint8 RAM_DID_CD_REPROGRAMMING_DATE[DLC_DID_REPROGRAMMING_DATE];
static uint8 RAM_DID_CD_SUPPLIER_ID[DLC_SYSTEM_SUPPLIER_ID];
static uint8 RAM_DID_REPAIR_SHOP_CODE[DLC_REPAIR_SHOP_CODE];
static uint8 RAM_DID_CD_HW_VERSION[DLC_GAC_HW_VERSION];
#if 0
#pragma ghs startdata
#pragma ghs section rodata=".nvm_sn"
const UI_8 NVM_DID_CD_ECU_SN[DLC_DID_ECU_SN] = GAC_ECU_SN_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_sheild_auto_park"
const UI_8 NVM_DID_CD_SHEILD_AutoPark[DLC_DID_SHEILD_AUTOPARK] = {0x0};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_vin"
const UI_8 NVM_DID_CD_VIN[DLC_DID_CD_VIN] = GAC_VIN_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_manfac_sn"
const UI_8 NVM_DID_CD_MANFAC_SN[DLC_DID_CD_MANFAC_SN] = GAC_MANFAC_SN_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
//<0610
#pragma ghs startdata
#pragma ghs section rodata=".nvm_boot_id"
const UI_8 NVM_DID_CD_BOOT_ID[DLC_BOOT_SW_ID] = GAC_BOOT_ID_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_ecusw_version"
const UI_8 NVM_DID_CD_ECUSW_VERSION[DLC_GAC_ECU_SW_VERSION] = GAC_ECUSW_VERSION_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
//0610>
#pragma ghs startdata
#pragma ghs section rodata=".nvm_app_dataid"
const UI_8 NVM_DID_CD_APP_DATAID[DLC_DID_CD_APP_DATAID] = GAC_APP_DATAID_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_vehiclemanuf_ecuhwnum_sn"
const UI_8 NVM_DID_CD_MANUF_ECUHWNUM[DLC_DID_CD_MANUF_ECUHWNUM] = GAC_MANUF_ECUHWNUM_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_dtc_setting"
const UI_8 NVM_DID_CD_DTC_SETTING[DLC_DID_DTC_SETTING] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_transportation_mode"
const UI_8 NVM_DID_CD_TRANSPORTATION_MODEG[DLC_DID_TRANSPORTATION_MODE]= {0x0};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_mtoc"
const UI_8 NVM_DID_CD_MTOC[DLC_DID_MTOC]= GAC_MTOC_DEFAULT_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_faa_flag"
const UI_8 NVM_Faa_Flag = 0x0;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_reprogramming_counter"
const UI_8 NVM_Reprogramming_Counter[DLC_DID_REPROGRAMMING_COUNTER] = {0x0};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_reprogramming_attempt_counter"
const UI_8 NVM_Reprogramming_Attempt_Counter[DLC_DID_REPROGRAMMING_COUNTER] = {0x0};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_reprogramming_date"
const UI_8 NVM_Reprogramming_Date[DLC_DID_REPROGRAMMING_DATE] = {3,1,0,5,2,1};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_reprogramming_date_app"
const UI_8 NVM_Reprogramming_Date_App[DLC_DID_REPROGRAMMING_DATE] = {3,1,0,5,2,1};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_ecumanufacture_date"
const UI_8 NVM_Ecumanufacture_Date[DLC_DID_ECUMANUFACTURE_DATE] = {3,1,0,5,2,1};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_ecuinstallation_date"
const UI_8 NVM_Ecuinstallation_Date[DLC_DID_ECUINSTALLATION_DATE] = {3,1,0,5,2,1};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_bootsw_version"
const UI_8 NVM_DID_CD_BOOTSW_VERSION[DLC_BOOT_SW_VERSION] = {'0','A','0','0','0','1'};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_hw_version"
const UI_8 NVM_DID_CD_HW_VERSION[DLC_GAC_HW_VERSION] = {0x41,0x30,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_supplier_id"
const UI_8 NVM_DID_CD_SUPPLIER_ID[DLC_SYSTEM_SUPPLIER_ID] = GAC_APP_SUPPLIER_ID;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_app_finger_print"
const UI_8 NVM_App_SW_Finger_Print[DLC_DID_APPSW_FINGER_PRINT] = GAC_APP_SW_FINGER_INFO;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_app_finger_print_app"
const UI_8 NVM_App_SW_Finger_Print_App[DLC_DID_APPSW_FINGER_PRINT] = GAC_APP_SW_FINGER_INFO;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_manufactory_mode"
const UI_8 NVM_Manufactory_Mode = 0xFF;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_logical_did"
const t_logical_did nvm_logical_id;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_dcid"
const uint8 nvm_dcid[DLC_DID_DCID] = GAC_DCID_VALUE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_drive_mode"
const UI_8 NVM_Drive_Mode = 0x0;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_paddle_active"
const UI_8 NVM_Paddle_Configure = 0xAA;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_drive_mode_storage"
const UI_8 NVM_Drive_Storage = 0x39;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_repair_shop_code"
const UI_8 NVM_Repair_Shop_Code[DLC_REPAIR_SHOP_CODE] = GAC_ECU_REPAIR_SHOP_CODE;
#pragma ghs section data=default
#pragma ghs enddata
#pragma ghs startdata
#pragma ghs section rodata=".nvm_last_position"
const UI_8 NVM_Last_Pos_Req = 1;
#pragma ghs section data=default
#pragma ghs enddata
static uint8 RAM_DID_ECU_SN[DLC_DID_ECU_SN];
static uint8 RAM_DID_CD_VIN[DLC_DID_CD_VIN];
static uint8 RAM_DID_CD_MANFAC_SN[DLC_DID_CD_MANFAC_SN];
static uint8 RAM_DID_CD_APP_DATAID[DLC_DID_CD_APP_DATAID];
static uint8 RAM_DID_CD_MANUF_ECUHWNUM[DLC_DID_CD_MANUF_ECUHWNUM];
static uint8 RAM_DID_CD_DTC_SETTING[DLC_DID_DTC_SETTING];
static uint8 RAM_DID_CD_TRANSPORTATION_MODEG[DLC_DID_TRANSPORTATION_MODE];
static uint8 RAM_DID_CD_MTOC[DLC_DID_MTOC];
static uint8 RAM_DID_CD_REPROGRAMMING_COUNTER[DLC_DID_REPROGRAMMING_COUNTER];
static uint8 RAM_DID_CD_REPROGRAMMING_ATTEMPT_COUNTER[DLC_DID_REPROGRAMMING_COUNTER];
static uint8 RAM_DID_CD_ECUMANUFACTURE_DATE[DLC_DID_ECUMANUFACTURE_DATE];
static uint8 RAM_DID_CD_ECUINSTALLATION_DATE[DLC_DID_ECUINSTALLATION_DATE];
//<0610
static uint8 RAM_DID_CD_BOOT_ID[DLC_BOOT_SW_ID];
static uint8 RAM_DID_CD_ECUSW_VERSION[DLC_GAC_ECU_SW_VERSION];
static uint8 RAM_DID_CD_BOOTSW_VERSION[DLC_BOOT_SW_VERSION];
//0610>
static uint8 RAM_DID_CD_APPSW_FINGER_PRINT[DLC_DID_APPSW_FINGER_PRINT];
static uint8 RAM_DRIVE_MODE;
static uint8 RAM_PADDLE_CONFIGURE;
static uint8 RAM_EOL_CONFIGURE;
static t_logical_did RAM_LOGICAL_DID;
static uint8 RAM_DCID[DLC_DID_DCID];
static uint8 RAM_LAST_POSITION = 0;
static uint8 RAM_ATP = 0;
static uint8 RAM_FAA_FLAG = 0;
static uint8 RAM_Manufactory_Mode = 0;
#endif
/* ----------------------------------------------------------------------------
* Public variables
*/
/* ----------------------------------------------------------------------------
* Public functions
*/
void UDS_DID_initNVM(void)
{
memcpy(RAM_DID_CD_VIN, NVM_DID_CD_VIN, DLC_DID_CD_VIN);
memcpy(RAM_DID_CD_REPROGRAMMING_DATE, NVM_Reprogramming_Date_App,DLC_DID_REPROGRAMMING_DATE);
memcpy(RAM_DID_CD_SUPPLIER_ID, NVM_DID_CD_SUPPLIER_ID,DLC_SYSTEM_SUPPLIER_ID);
memcpy(RAM_DID_REPAIR_SHOP_CODE,NVM_Repair_Shop_Code,sizeof(NVM_Repair_Shop_Code));
memcpy(RAM_DID_CD_HW_VERSION, NVM_DID_CD_HW_VERSION,DLC_GAC_HW_VERSION);
}
//static void onWriteFinished(BOOL ret)
//{
/* Do Nothing */
//}
t_UDS_ERR Get_DID_ECU_SN(uint8 *data)
{
//memcpy(data, RAM_DID_ECU_SN, sizeof(RAM_DID_ECU_SN));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_ECU_SN(uint8 *data)
{
//memcpy(RAM_DID_ECU_SN, data, sizeof(RAM_DID_ECU_SN));
//ficoNVM_Write_Serial_Number(RAM_DID_ECU_SN, onWriteFinished);
return TRUE;
}
t_UDS_ERR Get_DID_CD_SYSID_VIN(uint8 *data)
{
//memcpy(data, RAM_DID_CD_VIN, sizeof(RAM_DID_CD_VIN));
SmartEE_Read(0x500, data, 17);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_CD_VIN(uint8 *data)
{
//memcpy(RAM_DID_CD_VIN, data, sizeof(RAM_DID_CD_VIN));
//ficoNVM_Write_VIN(RAM_DID_CD_VIN, onWriteFinished);
SmartEE_Write(0x500, data, 17);
return TRUE;
}
t_UDS_ERR Get_DID_TouchSen1_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][0],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen2_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][1],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen3_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][2],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen4_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][3],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen5_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][4],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen6_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][5],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen7_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][6],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen8_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][7],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen9_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][8],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen10_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][9],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen11_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][10],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen12_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][11],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen13_BaseLine(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[0][12],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen1_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][0],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen2_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][1],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen3_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][2],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen4_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][3],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen5_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][4],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen6_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][5],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen7_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][6],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen8_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][7],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen9_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][8],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen10_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][9],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen11_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][10],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen12_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][11],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_TouchSen13_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[1][12],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_PressSen_Baseline(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[2][0],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_PressSen_Signal(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[2][1],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Pre_Value(uint8 *data)
{
memcpy(data,&g16_DiagTouchPressSenRes[2][2],2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Reprogramming_Date(uint8 *data)
{
//memcpy(data, RAM_DID_CD_REPROGRAMMING_DATE, sizeof(RAM_DID_CD_REPROGRAMMING_DATE));
SmartEE_Read(0x517, data, 4);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_Reprogramming_Date(uint8 *data)
{
//memcpy(RAM_DID_CD_REPROGRAMMING_DATE, data, sizeof(RAM_DID_CD_REPROGRAMMING_DATE));
//ficoNVM_Write_REPROGRAME_DATE(RAM_DID_CD_REPROGRAMMING_DATE, onWriteFinished);
SmartEE_Write(0x517, data, 4);
return TRUE;
}
t_UDS_ERR Set_DID_CD_APP_SW_FINGERPRINT(uint8 *data)
{
//memcpy(RAM_DID_CD_APPSW_FINGER_PRINT, data, sizeof(RAM_DID_CD_APPSW_FINGER_PRINT));
//ficoNVM_Write_App_FigrPriApp(RAM_DID_CD_APPSW_FINGER_PRINT, onWriteFinished);
return TRUE;
}
t_UDS_ERR Get_DID_CD_SYSID_MANFAC_SN(uint8 *data)
{
//memcpy(data, RAM_DID_CD_MANFAC_SN, sizeof(RAM_DID_CD_MANFAC_SN));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_CD_MANFAC_SN(uint8 *data)
{
//memcpy(RAM_DID_CD_MANFAC_SN, data, sizeof(RAM_DID_CD_MANFAC_SN));
//ficoNVM_Write_MANFAC_SN(RAM_DID_CD_MANFAC_SN, onWriteFinished);
return TRUE;
}
t_UDS_ERR Get_DID_CD_SYSID_APP_DATAID(uint8 *data)
{
//memcpy(data, RAM_DID_CD_APP_DATAID, sizeof(RAM_DID_CD_APP_DATAID));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_CD_APP_DATAID(uint8 *data)
{
//memcpy(RAM_DID_CD_APP_DATAID, data, sizeof(RAM_DID_CD_APP_DATAID));
//ficoNVM_Write_APP_DATAID(RAM_DID_CD_APP_DATAID, onWriteFinished);
return TRUE;
}
t_UDS_ERR Get_DID_CD_SYSID_MANUF_ECUHWNUM(uint8 *data)
{
//memcpy(data, RAM_DID_CD_MANUF_ECUHWNUM, sizeof(RAM_DID_CD_MANUF_ECUHWNUM));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_CD_MANUF_ECUHWNUM(uint8 *data)
{
//memcpy(RAM_DID_CD_MANUF_ECUHWNUM, data, sizeof(RAM_DID_CD_MANUF_ECUHWNUM));
//ficoNVM_Write_MANUF_ECUHWNUM(RAM_DID_CD_MANUF_ECUHWNUM, onWriteFinished);
return TRUE;
}
t_UDS_ERR Get_DID_Dtc_Setting(uint8 *data)
{
//memcpy(data, RAM_DID_CD_DTC_SETTING, sizeof(RAM_DID_CD_DTC_SETTING));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Set_DID_Dtc_Setting(uint8 *data)
{
//memcpy(RAM_DID_CD_DTC_SETTING, data, sizeof(RAM_DID_CD_DTC_SETTING));
//ficoNVM_Write_Dtc_Setting_Flag(RAM_DID_CD_DTC_SETTING, onWriteFinished);
return TRUE;
}
t_UDS_ERR Set_DID_Shield_Atp(uint8 *data)
{
if(data[0] <= 1)
{
// shield_atp = data[0];
// ficoNVM_Write_Shield_ATP_Flag(&shield_atp, onWriteFinished);
}else{
return FALSE;
}
return TRUE;
}
t_UDS_ERR Set_DID_Repair_Shop_Code(uint8 *data)
{
//memcpy(RAM_DID_REPAIR_SHOP_CODE,data,sizeof(RAM_DID_REPAIR_SHOP_CODE));
//ficoNVM_Write_Repair_Shop_Code_Flag(RAM_DID_REPAIR_SHOP_CODE, onWriteFinished);
SmartEE_Write(0x51B, data, 16);
return TRUE;
}
t_UDS_ERR Get_DID_Reprogramming_Counter(uint8 *data)
{
//memcpy(data, RAM_DID_CD_REPROGRAMMING_COUNTER, sizeof(RAM_DID_CD_REPROGRAMMING_COUNTER));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Reprogramming_Attempt_Counter(uint8 *data)
{
//memcpy(data, RAM_DID_CD_REPROGRAMMING_ATTEMPT_COUNTER, sizeof(RAM_DID_CD_REPROGRAMMING_ATTEMPT_COUNTER));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_EcuManufacture_Date(uint8 *data)
{
//memcpy(data, RAM_DID_CD_ECUMANUFACTURE_DATE, sizeof(RAM_DID_CD_ECUMANUFACTURE_DATE));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_EcuInstallation_Date(uint8 *data)
{
//memcpy(data, RAM_DID_CD_ECUINSTALLATION_DATE, sizeof(RAM_DID_CD_ECUINSTALLATION_DATE));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_App_Sw_Finger_Print(uint8 *data)
{
//memcpy(data, RAM_DID_CD_APPSW_FINGER_PRINT, sizeof(RAM_DID_CD_APPSW_FINGER_PRINT));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Gac_Hw_Version(uint8 *data)
{
memcpy(data, RAM_DID_CD_HW_VERSION,DLC_GAC_HW_VERSION);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Gac_Ecusw_Version(uint8 *data)
{
UI_8 sw_num[DLC_GAC_ECU_SW_VERSION] = GAC_ECUSW_VERSION_DEFAULT_VALUE;
memcpy(data,sw_num,DLC_GAC_ECU_SW_VERSION);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Gac_Spare_Number(uint8 *data)
{
data[0] = 'A';
data[1] = 'B';
data[2] = 'C';
data[3] = 'D';
data[4] = 'E';
data[5] = 'F';
data[6] = '0';
data[7] = '1';
data[8] = '2';
data[9] = '3';
data[10] = '4';
data[11] = '5';
data[12] = '6';
data[13] = '7';
data[14] = '8';
data[15] = '9';
data[16] = 'A';
data[17] = 'B';
data[18] = 'C';
data[19] = 'D';
data[20] = 'E';
// memcpy(data, RAM_LOGICAL_DID.gac_spare_number,DLC_GAC_SPARE_NUMBER);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_System_Supplier_Id(uint8 *data)
{
memcpy(data, RAM_DID_CD_SUPPLIER_ID,DLC_SYSTEM_SUPPLIER_ID);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Gac_Kit_Part_Number(uint8 *data)
{
data[0] = 'A';
data[1] = 'K';
data[2] = 'C';
data[3] = 'G';
data[4] = '-';
data[5] = '0';
data[6] = '0';
data[7] = '7';
data[8] = 'X';
data[9] = '-';
data[10] = 'A';
data[11] = '1';
data[12] = ' ';
data[13] = ' ';
// memcpy(data, RAM_LOGICAL_DID.gac_kit_assembly_part_number,DLC_GAC_KIT_PART_NUMBER);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_System_Name(uint8 *data)
{
//memcpy(data, RAM_LOGICAL_DID.system_name,DLC_SYSTEM_NAME);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Uds_Protol_Version(uint8 *data)
{
//memcpy(data, RAM_LOGICAL_DID.uds_protol_version,DLC_UDS_PROTOL_VERSION);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Boot_Version(uint8 *data)
{
//memcpy(data, RAM_DID_CD_BOOTSW_VERSION,DLC_BOOT_SW_VERSION);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Boot_ID(uint8 *data)
{
//memcpy(data, RAM_DID_CD_BOOT_ID,sizeof(RAM_DID_CD_BOOT_ID));
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_DCID(uint8 *data)
{
//memcpy(data, RAM_DCID,DLC_DID_DCID);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Shield_Atp(uint8 *data)
{
// data[0] = shield_atp;
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_GAC_Repair_Shop_Id(uint8 *data)
{
//memcpy(data, RAM_DID_REPAIR_SHOP_CODE,DLC_REPAIR_SHOP_CODE);
SmartEE_Read(0x51B, data, 16);
return ISO15765_3_POSITIVE_RESPONSE;
}
//t_UDS_ERR Set_DID_CD_Drive_Mode_Configure(uint8 *data)
//{
// EOL_config = *((st_eol_config *)data);
// paddle_active = EOL_config.paddle_config;
//
// ficoNVM_Write_Drive_Mode_Configure((uint8*)(&EOL_config), onFinishedDriveConfig);
//
// return TRUE;
//}
//uint8 GetLastPosition(void)
//{
//return RAM_LAST_POSITION;
//}
//uint8* GetNvmDtcSetting(void)
//{
//return RAM_DID_CD_DTC_SETTING;
//}
/* ----------------------------------------------------------------------------
* Private functions
*/

View File

@ -0,0 +1,412 @@
/* ----------------------------------------------------------------------------
* Implements
*/
#include "UDS_Services_Common.h"
/* ----------------------------------------------------------------------------
* Uses
*/
//#include "CommonMacros.h"
//#include "Platform_Types.h"
//#include "ProjectCfg.h"
//#include "Global.h"
#include "UDS_CoreServices_CB.h"
#include "DiagnosticL/UDS/UDS_Services_Common.h"
#include <string.h>
#include "TouchPanel.h"
//#include "TouchPanel_Cfg.h"
#include "Std_Types.h"
#include "device.h"
#include "touch/touch.h"
#include "math.h"
#include "stdlib.h"
#include <stddef.h> // Defines NULL
#include <stdbool.h> // Defines true
#include <stdlib.h> // Defines EXIT_FAILURE
#include "definitions.h" // SYS function prototypes
#include "OsekCom/OsekCom.h"
#include "Speaker/Speaker.h"
#include "P417_SWTL_App_ert_rtw/P417_SWTL_App.h"
#include "TouchPanel/TouchPanel.h"
#include "forceSnsr/forcedetect.h"
#include "TLE9263/TLE926x_Main.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
#include "ModelsInterfaces/CommonMacros.h"
#include "calib_public.h"
#include "smartee.h"
/* ----------------------------------------------------------------------------
* Private defines
*/
/* ----------------------------------------------------------------------------
* Private types
*/
//typedef struct {
// uint16 did;
// uint8 size;
// t_UDS_Session allowed_session;
// t_UDS_ERR (*Getter)(uint8 * buf_data_rx);
//} t_UDSReadDidSubCommands;
extern UI_8 frm_diag_physresp_swtl[8];
/* ----------------------------------------------------------------------------
* Private macros
*/
/********************* MACRO for support DID read *****************************/
#define SUPPORT_ID_FOR_22_SERVICE ((uint8)0xDF)
#define SUPPORT_ID_FOR_2E_SERVICE ((uint8)0xEC)
#define SUPPORT_ID_FOR_2F_SERVICE ((uint8)0xED)
#define SUPPORT_ID_FOR_31_SERVICE ((uint8)0xEE)
#define BAT_MODE_A ((uint8)0)
#define BAT_MODE_B ((uint8)1)
#define BAT_MODE_C ((uint8)2)
/* ----------------------------------------------------------------------------
* Forward declarations
*/
UI_16 g16_DiagTouchPressSenRes[3][15] = {0};
#if 1
//static void SupportIDCheckFor_22(uint8 * resp, uint8 id_l);
//static boolean isSessionALlowed(t_UDS_Session did_session);
static t_UDS_ERR Get_DID_GAC_Active_Diagnostic_session(uint8 *data);
t_UDS_ERR Get_DID_Fun1(uint8 *data)
{
data[0] = Calib_GetData(data0)>>8;
data[1] = Calib_GetData(data0);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Fun2(uint8 *data)
{
data[0] = Calib_GetData(data1)>>8;
data[1] = Calib_GetData(data1);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_Fun3(uint8 *data)
{
data[0] = Calib_GetData(data2)>>8;
data[1] = Calib_GetData(data2);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_UP(uint8 *data)
{
data[0] = Calib_GetData(data3)>>8;
data[1] = Calib_GetData(data3);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_DOWN(uint8 *data)
{
data[0] = Calib_GetData(data4)>>8;
data[1] = Calib_GetData(data4);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_LEFT(uint8 *data)
{
data[0] = Calib_GetData(data5)>>8;
data[1] = Calib_GetData(data5);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_RIGHT(uint8 *data)
{
data[0] = Calib_GetData(data6)>>8;
data[1] = Calib_GetData(data6);
return ISO15765_3_POSITIVE_RESPONSE;
}
t_UDS_ERR Get_DID_OK(uint8 *data)
{
data[0] = Calib_GetData(data7)>>8;
data[1] = Calib_GetData(data7);
return ISO15765_3_POSITIVE_RESPONSE;
}
extern uint8 UDS_DAC_Ref_Voltage;
t_UDS_ERR Get_DID_DAC_Ref_Voltage(uint8 *data)
{
*data = UDS_DAC_Ref_Voltage;
return ISO15765_3_POSITIVE_RESPONSE;
}
extern uint8 UDS_Vibration_Gain;
t_UDS_ERR Get_DID_Vibration_Gain(uint8 *data)
{
*data = UDS_Vibration_Gain;
return ISO15765_3_POSITIVE_RESPONSE;
}
//extern uint8 Measure_Frame_Switch;
t_UDS_ERR Get_DID_Measure_Frame_Switch(uint8 *data)
{
// uint8_t temp=0;
SmartEE_Read(0x783, data, 1);
//*data=*temp;
return ISO15765_3_POSITIVE_RESPONSE;
}
//Get_DID_Measure_Frame_Switch
/******************************************************************************
*
* DIDs
*
*/
/** Dynamic **/
/** Company **/
/* ----------------------------------------------------------------------------
* Private variables
*/
void * memcpy( void * dest, void const * src, size_t len)
{
uint8_t* dst8 = (uint8_t*)dest;
uint8_t* src8 = (uint8_t*)src;
while (len--) {
*dst8++ = *src8++;
}
return dest;
}
t_UDSReadDidSubCommands uds_did_read_commands[] =
{
/** ECU Identification ***********************************************************************************/
{ DID_CD_SYSID_ACTIVE_DIAG_SESSION, 1, UDS_DEFAULT_SESSION, Get_DID_GAC_Active_Diagnostic_session },
{ DID_CD_SYSID_VIN, 17, UDS_DEFAULT_SESSION, Get_DID_CD_SYSID_VIN },
{ DID_CD_SYSID_REPROGRAMING_DATE , 4, UDS_DEFAULT_SESSION, Get_DID_Reprogramming_Date },
{ DID_CD_SYSID_SYSTEMSUPPLIER_ID, 6 , UDS_DEFAULT_SESSION, Get_DID_System_Supplier_Id },
{ DID_CD_SYSID_SPARE_PART_NUMBER, 21, UDS_DEFAULT_SESSION, Get_DID_Gac_Spare_Number },
{ DID_CD_SYSID_REPAIR_SHOP_CODE, 16, UDS_DEFAULT_SESSION, Get_DID_GAC_Repair_Shop_Id },
{ DID_CD_SYSID_ECU_HW_VER_NUMBER, 16, UDS_DEFAULT_SESSION, Get_DID_Gac_Hw_Version },
{ DID_CD_SYSID_ECU_SW_VER_NUMBER , 16, UDS_DEFAULT_SESSION, Get_DID_Gac_Ecusw_Version },
/*Application*/
{ DID_TOUCH_SEN1_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen1_BaseLine },
{ DID_TOUCH_SEN2_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen2_BaseLine },
{ DID_TOUCH_SEN3_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen3_BaseLine },
{ DID_TOUCH_SEN4_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen4_BaseLine },
{ DID_TOUCH_SEN5_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen5_BaseLine },
{ DID_TOUCH_SEN6_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen6_BaseLine },
{ DID_TOUCH_SEN7_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen7_BaseLine },
{ DID_TOUCH_SEN8_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen8_BaseLine },
{ DID_TOUCH_SEN9_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen9_BaseLine },
{ DID_TOUCH_SEN10_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen10_BaseLine },
{ DID_TOUCH_SEN11_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen11_BaseLine },
{ DID_TOUCH_SEN12_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen12_BaseLine },
{ DID_TOUCH_SEN13_BASE_LINE , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen13_BaseLine },
{ DID_TOUCH_SEN1_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen1_Signal },
{ DID_TOUCH_SEN2_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen2_Signal },
{ DID_TOUCH_SEN3_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen3_Signal },
{ DID_TOUCH_SEN4_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen4_Signal },
{ DID_TOUCH_SEN5_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen5_Signal },
{ DID_TOUCH_SEN6_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen6_Signal },
{ DID_TOUCH_SEN7_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen7_Signal },
{ DID_TOUCH_SEN8_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen8_Signal },
{ DID_TOUCH_SEN9_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen9_Signal },
{ DID_TOUCH_SEN10_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen10_Signal },
{ DID_TOUCH_SEN11_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen11_Signal },
{ DID_TOUCH_SEN12_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen12_Signal },
{ DID_TOUCH_SEN13_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_TouchSen13_Signal },
{ DID_PRESEE_SEN_BASELINE , 2, UDS_DEFAULT_SESSION, Get_DID_PressSen_Baseline },
{ DID_PRESEE_SEN_SIGNAL , 2, UDS_DEFAULT_SESSION, Get_DID_PressSen_Signal },
{ DID_PRESEE_SEN_PRE_VAL , 2, UDS_DEFAULT_SESSION, Get_DID_Pre_Value },
{DID_FUN1, 2, UDS_DEFAULT_SESSION, Get_DID_Fun1},
{DID_FUN2, 2, UDS_DEFAULT_SESSION, Get_DID_Fun2},
{DID_FUN3, 2, UDS_DEFAULT_SESSION, Get_DID_Fun3},
{DID_UP, 2, UDS_DEFAULT_SESSION, Get_DID_UP},
{DID_DOWN, 2, UDS_DEFAULT_SESSION, Get_DID_DOWN},
{DID_LEFT, 2, UDS_DEFAULT_SESSION, Get_DID_LEFT},
{DID_RIGHT, 2, UDS_DEFAULT_SESSION, Get_DID_RIGHT},
{DID_OK, 2, UDS_DEFAULT_SESSION, Get_DID_OK},
{DID_DAC_Ref_Voltage, 1, UDS_DEFAULT_SESSION, Get_DID_DAC_Ref_Voltage},
{DID_Vibration_Gain, 1, UDS_DEFAULT_SESSION, Get_DID_Vibration_Gain},
{DID_Measure_Frame_Switch, 1, UDS_DEFAULT_SESSION, Get_DID_Measure_Frame_Switch},
//DID_Measure_Frame_Switch
};
/* ----------------------------------------------------------------------------
* Public variables
*/
/* ----------------------------------------------------------------------------
* Public functions
*/
//uint8 UDS_ReadDiD_CB(uint8 id_h, uint8 id_l)
//{
// uint16 requested_id;
// uint16 resp_pos;
// tp_uds_read_data_by_identifier_resp resp;
// t_UDS_ERR response_mode = UDS_ERR_REQUEST_OUT_OF_RANGE;
// boolean id_data_read;
// uint8 *buf_data_rx = NULL;
// uint16 did_index = 0;
// static uint16 last_resp_pos = 0;
//
// resp_pos = 0;//( - (UI_16) 1);
// id_data_read = FALSE;
// buf_data_rx = &tp_frm[DIAG_ISO15765_2_HDL].data_rx[0];
//
// for(did_index = 1;did_index< 4096;did_index+=2)
// {
// if((buf_data_rx[did_index]==id_h)&&(buf_data_rx[did_index+1] == id_l))
// {
// if(did_index != 1)
// {
// resp_pos = last_resp_pos;
// }else{
// last_resp_pos = 0;
// }
// break;
// }
// }
// resp = ISO15765_3_GET_RESP_DATA(tp_uds_read_data_by_identifier_resp);
// /* Send correct Ids */
// resp->buffer_dades[resp_pos + 0] = id_h;
// resp->buffer_dades[resp_pos + 1] = id_l;
//
// resp_pos = resp_pos + 2;
//
// /* Support DID read check
// * DID(MSB) Service
// * $DF $22
// * $EC $2E
// * $ED $2F
// * $EE $31 */
// switch (id_h) {
// case SUPPORT_ID_FOR_22_SERVICE:
// SupportIDCheckFor_22((t_UDS_ERR*)&resp->buffer_dades[resp_pos], id_l);
// Iso15765_3IncrementResponseSize((UI_16) 32);
// response_mode = ISO15765_3_POSITIVE_RESPONSE;
// break;
// case SUPPORT_ID_FOR_2E_SERVICE:
// SupportIDCheckFor_2E((t_UDS_ERR*)&resp->buffer_dades[resp_pos], id_l);
// Iso15765_3IncrementResponseSize((UI_16) 32);
// response_mode = ISO15765_3_POSITIVE_RESPONSE;
// break;
// case SUPPORT_ID_FOR_2F_SERVICE:
// // SupportIDCheckFor_2F((t_UDS_ERR*)&resp->buffer_dades[resp_pos], id_l);
// Iso15765_3IncrementResponseSize((UI_16) 32);
// response_mode = ISO15765_3_POSITIVE_RESPONSE;
// break;
// case SUPPORT_ID_FOR_31_SERVICE:
// // SupportIDCheckFor_31((t_UDS_ERR*)&resp->buffer_dades[resp_pos], id_l);
// Iso15765_3IncrementResponseSize((UI_16) 32);
// response_mode = ISO15765_3_POSITIVE_RESPONSE;
// break;
// default:
// id_data_read = TRUE;
// break;
// }
// if (id_data_read == TRUE) {
// /* Get the complete id */
// requested_id = ((uint16) id_h) << 8;
// requested_id = requested_id | (uint16) id_l;
//
// for (uint8 idx = 0; idx < NOOF(uds_did_read_commands); idx++) {
//
// if (requested_id == uds_did_read_commands[idx].did) {
//
// if (TRUE == isSessionALlowed(uds_did_read_commands[idx].allowed_session)) {
//
// (void)uds_did_read_commands[idx].Getter((t_UDS_ERR*)&resp->buffer_dades[resp_pos]);
// Iso15765_3IncrementResponseSize(uds_did_read_commands[idx].size);
// /* assuming no errors reading */
// response_mode = ISO15765_3_POSITIVE_RESPONSE;
// last_resp_pos += uds_did_read_commands[idx].size + 2;
//
// }
// else {
// response_mode = UDS_ERR_SERVICE_NOT_SUPORTED_IN_ACTIVE_SESSION;
// }
// break;
// }
// }
// }
//
// /* Finally, in case of positive response, we set the identifier in the response */
// if (response_mode == ISO15765_3_POSITIVE_RESPONSE) {
// Iso15765_3IncrementResponseSize((uint8) 2);
// } else {
//
// /* Do nothing */
// }
//
// /* Send the response to ISO_3 layer */
// return (uint8)(response_mode);
//}
/* ----------------------------------------------------------------------------
* Private functions
*/
//static void SupportIDCheckFor_22(uint8 * resp, uint8 id_l)
//{
// uint8 idmsb;
// uint8 idlsb;
// uint8 bytepos;
// uint8 bitpos;
//
// memset(resp, (uint8) 0, (uint8) 32);
//
// if ((id_l == 0xDF) || (id_l == 0xEC) || (id_l == 0xED) || (id_l == 0xEE)) {
// /* DID MSB Support Check */
// for (uint8 idx = 0; idx < NOOF(uds_did_read_commands) ; idx++) {
// idmsb = uds_did_read_commands[idx].did >> (uint8) 8;
// bytepos = idmsb / (uint8) 8;
// bitpos = idmsb % (uint8) 8;
// resp[bytepos] |= ((uint8) 1 << (7 - bitpos));
// }
// } else {
// /* DID LSM Support Check for Assigned MSB */
// idmsb = id_l;
// for (uint8 idx = 0; idx < NOOF(uds_did_read_commands) ; idx++) {
// if (idmsb == uds_did_read_commands[idx].did >> (uint8) 8) {
// idlsb = ((uint8) uds_did_read_commands[idx].did);
// bytepos = idlsb / (uint8) 8;
// bitpos = idlsb % (uint8) 8;
// resp[bytepos] |= ((uint8) 1 << (7 - bitpos));
// }
// }
// }
//}
/* ----------------------------------------------------------------------------
* Private functions
*/
//static boolean isSessionALlowed(t_UDS_Session did_session)
//{
// return TRUE;
//}
/* ----------------------------------------------------------------------------
* Private functions
*/
static t_UDS_ERR Get_DID_GAC_Active_Diagnostic_session(uint8 *data)
{
data[0] = Iso15765_3QueryActiveSession();
return ISO15765_3_POSITIVE_RESPONSE;
}
/* ----------------------------------------------------------------------------
* PUBLIC functions
*/
uint8 GetReadDidServiceNumber(void)
{
return NOOF(uds_did_read_commands);
}
#endif

View File

@ -0,0 +1,320 @@
/* ----------------------------------------------------------------------------
* Implements
*/
//#include "UDS_Services_Common.h"
/* ----------------------------------------------------------------------------
* Uses
*/
#include "ModelsInterfaces/CommonMacros.h"
#include "DiagnosticL/ProjectCfg.h"
#include "Std_Types.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
#include "UDS_CoreServices_CB.h"
//#include "SafetyHwAbsDIO.h"
//#include "PaddleStatus_If.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3_Task.h"
#include "DiagnosticL/UDS/UDS_Services_Common.h"
#include "calib_public.h"
#include "smartee.h"
#include "Speaker.h"
/* ----------------------------------------------------------------------------
* Private defines
*/
#define NO_MESSAGE 0xFFFF
/* ----------------------------------------------------------------------------
* Private types
*/
//typedef struct {
// uint16 did;
// uint8 size;
// t_UDS_Session allowed_session;
// // t_UDS_ERR (*Setter)(const uint8 * buf_data_rx);
// t_UDS_ERR (*Setter)(uint8 * buf_data_rx);
//
//} t_UDSWriteDiDSubCommandsReference;
/* ----------------------------------------------------------------------------
* Private macros
*/
uint8* p_dtc_setting = NULL;
/* ----------------------------------------------------------------------------
* Forward declarations
*/
//static boolean isSessionAllowed(t_UDS_Session did_session);
//static t_UDS_ERR Set_DID_GAC_Manufactory_Mode(uint8 *data);
t_UDS_ERR CalibFun1(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data0, value);
return TRUE;
}
t_UDS_ERR CalibFun2(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data1, value);
return TRUE;
}
t_UDS_ERR CalibFun3(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data2, value);
return TRUE;
}
t_UDS_ERR CalibUp(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data3, value);
return TRUE;
}
t_UDS_ERR CalibDown(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data4, value);
return TRUE;
}
t_UDS_ERR CalibLeft(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data5, value);
return TRUE;
}
t_UDS_ERR CalibRight(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data6, value);
return TRUE;
}
t_UDS_ERR CalibOk(uint8 *data)
{
uint16 value = data[0]<<8 | data[1];
Calib_Trigger(data7, value);
return TRUE;
}
extern uint8 UDS_Vibration_Gain;
t_UDS_ERR Trigger_Vibration(uint8 *data)
{
speeker_Tig_Once(49, UDS_Vibration_Gain);
return TRUE;
}
extern uint8 UDS_DAC_Ref_Voltage;
t_UDS_ERR DAC_Ref_Voltage(uint8 *data)
{
t_UDS_ERR rtn = FALSE;
if(*data < 8)
{
UDS_DAC_Ref_Voltage = *data;
SmartEE_Write(0x781, data, 1);
SUPC_REGS->SUPC_VREF = SUPC_VREF_SEL(UDS_DAC_Ref_Voltage);
rtn = TRUE;
}
return rtn;
}
t_UDS_ERR Vibration_Gain(uint8 *data)
{
t_UDS_ERR rtn = FALSE;
if(*data < 4)
{
UDS_Vibration_Gain = *data;
SmartEE_Write(0x780, data, 1);
rtn = TRUE;
}
return rtn;
}
extern uint8 UDS_DAC_Timer_Period;
t_UDS_ERR DAC_Timer_Period(uint8 *data)
{
t_UDS_ERR rtn = FALSE;
if(*data <= 255 && *data >= 40)
{
UDS_DAC_Timer_Period = *data;
TC2_REGS->COUNT16.TC_CC[0U] = UDS_DAC_Timer_Period;
SmartEE_Write(0x782, data, 1);
rtn = TRUE;
}
return rtn;
}
t_UDS_ERR Measure_Frame_Switch(uint8 *data)
{
t_UDS_ERR rtn = FALSE;
if(*data == 1 || *data == 0)
{
SmartEE_Write(0x783, data, 1);
rtn = TRUE;
}
return rtn;
}
/* ----------------------------------------------------------------------------
* Private variables
*/
t_UDSWriteDiDSubCommandsReference uds_did_write_commands_by_reference[] =
{
{ DID_CD_SYSID_VIN, 17, UDS_EXT_DIAG_SESSION, 1,Set_DID_CD_VIN },
{ DID_CD_SYSID_REPROGRAMING_DATE, 4, UDS_EXT_DIAG_SESSION, 1,Set_DID_Reprogramming_Date },
{ DID_CD_SYSID_REPAIR_SHOP_CODE, 16, UDS_EXT_DIAG_SESSION, 1,Set_DID_Repair_Shop_Code },
{DID_FUN1, 2, UDS_EXT_DIAG_SESSION, 1, CalibFun1},
{DID_FUN2, 2, UDS_EXT_DIAG_SESSION, 1, CalibFun2},
{DID_FUN3, 2, UDS_EXT_DIAG_SESSION, 1, CalibFun3},
{DID_UP, 2, UDS_EXT_DIAG_SESSION, 1, CalibUp},
{DID_DOWN, 2, UDS_EXT_DIAG_SESSION, 1, CalibDown},
{DID_LEFT, 2, UDS_EXT_DIAG_SESSION, 1, CalibLeft},
{DID_RIGHT, 2, UDS_EXT_DIAG_SESSION, 1, CalibRight},
{DID_OK, 2, UDS_EXT_DIAG_SESSION, 1, CalibOk},
{DID_Trigger_Vibration, 1, UDS_EXT_DIAG_SESSION, 1, Trigger_Vibration},
{DID_DAC_Ref_Voltage, 1, UDS_EXT_DIAG_SESSION, 1, DAC_Ref_Voltage},
{DID_Vibration_Gain, 1, UDS_EXT_DIAG_SESSION, 1, Vibration_Gain},
{DID_DAC_Timer_Period, 1, UDS_EXT_DIAG_SESSION, 1, DAC_Timer_Period},
{DID_Measure_Frame_Switch, 1, UDS_EXT_DIAG_SESSION, 1, Measure_Frame_Switch},
};
/* ----------------------------------------------------------------------------
* Public variables
*/
/* ----------------------------------------------------------------------------
* Public functions
*/
//uint8 UDS_WriteDiD_CB(uint8 id_h, uint8 id_l, uint8 *buf_data_rx, uint16 size)
//{
// uint16 requested_id;
// tp_uds_write_data_by_identifier resp;
// t_UDS_ERR response_mode = UDS_ERR_REQUEST_OUT_OF_RANGE;
//
// resp = ISO15765_3_GET_RESP_DATA(tp_uds_write_data_by_identifier);
//
// /* Get the complete id */
// requested_id = ((((uint16) (id_h)) << 8) | ((uint16) (id_l)));
//
// for (uint8 idx = 0; idx < NOOF(uds_did_write_commands_by_reference); idx++) {
// if (requested_id == uds_did_write_commands_by_reference[idx].did) {
//
// if (TRUE == isSessionAllowed(uds_did_write_commands_by_reference[idx].allowed_session)) {
//
// if (NULL != uds_did_write_commands_by_reference[idx].Setter) {
//
// if(size == uds_did_write_commands_by_reference[idx].size) {
//
// //if(UdsSecurityTaskQueryAccessStatus() != UDS_ECU_LOCKED) {
//
// if (TRUE == uds_did_write_commands_by_reference[idx].Setter(buf_data_rx)) {
// response_mode = ISO15765_3_POSITIVE_RESPONSE;
// }
// else {
// /** Callback returned error **/
// response_mode = UDS_ERR_CONDITIONS_NOT_CORRECT;
// }
// //}
// //else
// //{
// /* Security is not correct*/
// //response_mode = UDS_ERR_SECURITY_ACCESS_DENIED;
// //}
// }
// else {
// /** Wrong size **/
// response_mode = UDS_ERR_INVALID_FORMAT;
// }
//
// }
// else {
// /** Callback not implemented **/
// response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
// }
//
// }
// else {
// /** Wrong Session **/
// response_mode = UDS_ERR_SERVICE_NOT_SUPORTED_IN_ACTIVE_SESSION;
// }
// break;
// }
// }
//
// /* Finally in case of positive response we set the identifier in the response */
// if (response_mode == ISO15765_3_POSITIVE_RESPONSE) {
// resp->id_high = id_h;
// resp->id_low = id_l;
// Iso15765_3IncrementResponseSize((UI_8) 2);
//
// } else {
//
// /* Do nothing */
// }
//
// /* Send the response to ISO_3 layer */
// Iso15765_3SendResponse(response_mode);
//
// return response_mode;
//}
/* ----------------------------------------------------------------------------
* Private functions
*/
//static boolean isSessionAllowed(t_UDS_Session did_session)
//{
// boolean result = FALSE;
//
// if (did_session == Iso15765_3QueryActiveSession()) {
// result = TRUE;
// }
// else{
// result = FALSE;
// }
//
// return result;
//}
//#include "ASILB_Common_Lib.h"
//#include "ReactionManager.h"
//#include "SafetyExceptions.h"
//void SupportIDCheckFor_2E(uint8 * resp, uint8 id_l)
//{
// uint8 idmsb;
// uint8 idlsb;
// uint8 bytepos;
// uint8 bitpos;
//
// memset(resp, (UI_8) 0, (UI_8) 32);
//
// if ((id_l == 0xDF) || (id_l == 0xEC) || (id_l == 0xED) || (id_l == 0xEE)) {
// /* DID MSB Support Check */
// for (uint8 idx = 0; idx < NOOF(uds_did_write_commands_by_reference) ; idx++) {
// idmsb = uds_did_write_commands_by_reference[idx].did >> (UI_8) 8;
// bytepos = idmsb / (UI_8) 8;
// bitpos = idmsb % (UI_8) 8;
// resp[bytepos] |= ((UI_8) 1 << (7 - bitpos));
// }
// } else {
// /* DID LSM Support Check for Assigned MSB */
// idmsb = id_l;
// for (uint8 idx = 0; idx < NOOF(uds_did_write_commands_by_reference) ; idx++) {
// if (idmsb == uds_did_write_commands_by_reference[idx].did >> (UI_8) 8) {
// idlsb = ((UI_8) uds_did_write_commands_by_reference[idx].did);
// bytepos = idlsb / (UI_8) 8;
// bitpos = idlsb % (UI_8) 8;
// resp[bytepos] |= ((UI_8) 1 << (7 - bitpos));
// }
// }
// }
//}
//static void onWriteFinished(BOOL ret)
//{
/* Do Nothing */
//}
uint8 GetWriteDidServiceNumber(void)
{
return NOOF(uds_did_write_commands_by_reference);
}

View File

@ -0,0 +1,135 @@
/*
*
* Copyright (C) 2020-2022 Qing.zhou
*
*
*/
/* -------------------------------- Includes -------------------------------- */
/* external head files */
/* internal head files */
#include "UDS_ServicesType.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
#include "calib_public.h"
#define NOOF(a) (sizeof(a)/sizeof(a[0]))
/* -------------------------------- Defines --------------------------------- */
/* -------------------------------- Macros ---------------------------------- */
/* ------------------------------- Data Types ------------------------------- */
/* -------------------------- Function declaration -------------------------- */
static t_UDS_ERR Calib_KeyUp(void);
static t_UDS_ERR Calib_KeyDown(void);
static t_UDS_ERR Calib_KeyLeft(void);
static t_UDS_ERR Calib_KeyRight(void);
static t_UDS_ERR Calib_KeyOK(void);
static t_UDS_ERR Calib_KeyFun1(void);
static t_UDS_ERR Calib_KeyFun2(void);
static t_UDS_ERR Calib_KeyFun3(void);
/* ----------------------------- Local Variables ---------------------------- */
/* ---------------------------- Global Variables ---------------------------- */
t_UDSIOControlSubCommands uds_io_control_commands[] =
{
/* DID Service legth Session support Security {ReturnControl , Default, Freeze, Adjustment} */
{ 0xD101 , 1 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {NULL, NULL, NULL, NULL} },
};
t_UDSRoutineControlCommands uds_routine_control_commands[] =
{
/* DID Service legth Session support Security {Start Stop Request } */
{ 0xAE00 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyUp, NULL, NULL} },
{ 0xAE01 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyDown, NULL, NULL} },
{ 0xAE02 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyLeft, NULL, NULL} },
{ 0xAE03 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyRight, NULL, NULL} },
{ 0xAE04 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyOK, NULL, NULL} },
{ 0xAE05 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyFun1, NULL, NULL} },
{ 0xAE06 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyFun2, NULL, NULL} },
{ 0xAE07 , 0 , UDS_EXT_DIAG_SESSION , UDS_ECU_LOCKED, {Calib_KeyFun3, NULL, NULL} },
};
/* --------------------------- Private Variables ---------------------------- */
/* --------------------------- Private Functions ---------------------------- */
static t_UDS_ERR Calib_KeyUp(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data0,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyDown(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data1,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyLeft(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data2,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyRight(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data3,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyOK(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data4,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyFun1(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data5,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyFun2(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data6,0);
return response_mode;
}
static t_UDS_ERR Calib_KeyFun3(void) {
t_UDS_ERR response_mode = ISO15765_3_POSITIVE_RESPONSE;
/* implementation */
Calib_Trigger(data7,0);
return response_mode;
}
/* ---------------------------- Public Functions ---------------------------- */
uint8 GetIoControlServiceNumber(void){
return NOOF(uds_io_control_commands);
}
uint8 GetRoutineServiceNumber(void){
return NOOF(uds_routine_control_commands);
}

View File

@ -0,0 +1,83 @@
/*
*
* Copyright (C) 2020-2022 Qing.zhou
*
*
*/
#ifndef __UDS_SERVICETYPE_H__
#define __UDS_SERVICETYPE_H__
/* -------------------------------- Includes -------------------------------- */
/* external head files */
//#include "Global.h"
#include "Std_Types.h"
/* internal head files */
/* -------------------------------- Defines --------------------------------- */
/* -------------------------------- Macros ---------------------------------- */
/* ------------------------------- Data Types ------------------------------- */
typedef uint8 t_UDS_ERR;
typedef uint8 t_UDS_Session;
#ifndef uint8_t
typedef unsigned char uint8_t;
#endif
#ifndef uint16_t
typedef unsigned short uint16_t;
#endif
typedef struct{
t_UDS_ERR (*ImplReturn)(uint8 * buf_data_rx); /*return control to ECU implement*/
t_UDS_ERR (*ImplDefault)(uint8 * buf_data_rx); /*reset to default implement*/
t_UDS_ERR (*ImplFreeze)(uint8 * buf_data_rx); /*freeze current state implement*/
t_UDS_ERR (*ImplControl)(uint8 * buf_data_rx); /*Short term adjustment implement*/
}t_UDSIOcontrolParameter;
typedef struct{
t_UDS_ERR (*ImplStart)(void); /*start routine implement*/
t_UDS_ERR (*ImplStop)(void); /*stop routine implement*/
t_UDS_ERR (*ImplReq)(void); /*request resuolt routine implement*/
}t_UDSRoutineControlParameter;
typedef struct {
uint16_t did;
uint16_t size; /* size is the control status record without io control type */
t_UDS_Session allowed_session;
uint8 security; /*Security access level of each did*/
t_UDSIOcontrolParameter func_impl;
} t_UDSIOControlSubCommands;
typedef struct {
uint16_t did;
uint16_t size; /* size is the */
t_UDS_Session allowed_session;
uint8 security; /*Security access level of each did*/
t_UDSRoutineControlParameter func_impl;
} t_UDSRoutineControlCommands;
typedef struct {
uint16_t did;
uint16_t size;
t_UDS_Session allowed_session;
t_UDS_ERR (*Getter)(uint8 * buf_data_rx);
} t_UDSReadDidSubCommands;
typedef struct {
uint16 did;
uint16 size;
t_UDS_Session allowed_session;
uint8 security; /*Security access level of each did*/
t_UDS_ERR (*Setter)(uint8 * buf_data_rx);
} t_UDSWriteDiDSubCommandsReference;
/* ---------------------------- Global Variables ---------------------------- */
/* -------------------------- Function declaration -------------------------- */
#endif /* __UDS_SERVICETYPE_H */

View File

@ -0,0 +1,359 @@
/*
*
* Copyright (C) 2020-2022 Qing.zhou
*
*
*/
/* -------------------------------- Includes -------------------------------- */
/* external head files */
/* internal head files */
#include "UDS_Services_Common.h"
#include "DiagnosticL/Comp_ISO_15765_3/Iso15765_3.h"
/* -------------------------------- Defines --------------------------------- */
/* -------------------------------- Macros ---------------------------------- */
/* ------------------------------- Data Types ------------------------------- */
/* -------------------------- Function declaration -------------------------- */
static BOOL isSessionAllowed(t_UDS_Session did_session);
static boolean UDS_isSecurityUnlocked(uint8 did_security_level);
/* ----------------------------- Local Variables ---------------------------- */
/* ---------------------------- Global Variables ---------------------------- */
/* --------------------------- Private Variables ---------------------------- */
/* --------------------------- Private Functions ---------------------------- */
static BOOL isSessionAllowed(t_UDS_Session did_session)
{
UI_8 curr_session;
BOOL ret = FALSE;
curr_session = Iso15765_3QueryActiveSession();
ret = ((curr_session & did_session) == curr_session) ? TRUE : FALSE;
return ret;
}
static boolean UDS_isSecurityUnlocked(uint8 did_security_level)
{
boolean result = FALSE;
if (UDS_ECU_LOCKED == did_security_level) {
if (UDS_ECU_LOCKED == UdsSecurityTaskQueryAccessStatus()) {
result = FALSE;
}
else{
result = TRUE;
}
}
else {
result = TRUE;
}
result = TRUE;
return result;
}
/* ---------------------------- Public Functions ---------------------------- */
uint8 UDS_ReadDiD_CB(uint8 id_h, uint8 id_l)
{
uint16_t requested_id;
uint16_t resp_pos;
tp_uds_read_data_by_identifier_resp resp;
t_UDS_ERR response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
resp_pos = 0;//( - (UI_16) 1);
resp = ISO15765_3_GET_RESP_DATA(tp_uds_read_data_by_identifier_resp);
/* Send correct Ids */
resp->buffer_dades[resp_pos + 0] = id_h;
resp->buffer_dades[resp_pos + 1] = id_l;
resp_pos = resp_pos + 2;
/* Get the complete id */
requested_id = ((uint16_t) id_h) << 8;
requested_id = requested_id | (uint16_t) id_l;
for (uint8 idx = 0; idx < GetReadDidServiceNumber(); idx++) {
if (requested_id == uds_did_read_commands[idx].did) {
if (TRUE == isSessionAllowed(uds_did_read_commands[idx].allowed_session)) {
(void)uds_did_read_commands[idx].Getter((t_UDS_ERR*)&resp->buffer_dades[resp_pos]);
Iso15765_3IncrementResponseSize(uds_did_read_commands[idx].size);
/* assuming no errors reading */
response_mode = ISO15765_3_POSITIVE_RESPONSE;
}
else {
response_mode = UDS_ERR_REQUEST_OUT_OF_RANGE;
}
break;
}
}
/* Finally, in case of positive response, we set the identifier in the response */
if (response_mode == ISO15765_3_POSITIVE_RESPONSE) {
Iso15765_3IncrementResponseSize((UI_8) 2);
} else {
/* Do nothing */
}
/* Send the response to ISO_3 layer */
return (uint8)(response_mode);
}
uint8 UDS_WriteDiD_CB(uint8 id_h, uint8 id_l, uint8 *buf_data_rx, uint16_t size)
{
uint16_t requested_id;
tp_uds_write_data_by_identifier resp;
t_UDS_ERR response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
resp = ISO15765_3_GET_RESP_DATA(tp_uds_write_data_by_identifier);
/* Get the complete id */
requested_id = ((((uint16_t) (id_h)) << 8) | ((uint16_t) (id_l)));
for (uint8 idx = 0; idx < GetWriteDidServiceNumber(); idx++) {
if (requested_id == uds_did_write_commands_by_reference[idx].did) {
if (TRUE == isSessionAllowed(uds_did_write_commands_by_reference[idx].allowed_session)) {
if (TRUE == UDS_isSecurityUnlocked(uds_did_write_commands_by_reference[idx].security)) {
if (NULL != uds_did_write_commands_by_reference[idx].Setter) {
if(size == uds_did_write_commands_by_reference[idx].size) {
response_mode = uds_did_write_commands_by_reference[idx].Setter(buf_data_rx);
}
else {
/** Wrong size **/
response_mode = UDS_ERR_INVALID_FORMAT;
}
}
else {
/** Callback not implemented **/
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
}
else {
/** Security is not unlocked **/
response_mode = UDS_ERR_SECURITY_ACCESS_DENIED;
}
}
else {
/** Wrong Session **/
response_mode = UDS_ERR_SERVICE_NOT_SUPORTED_IN_ACTIVE_SESSION;
}
break;
}
}
/* Finally in case of positive response we set the identifier in the response */
if (response_mode == ISO15765_3_POSITIVE_RESPONSE) {
resp->id_high = id_h;
resp->id_low = id_l;
Iso15765_3IncrementResponseSize((UI_8) 2);
} else {
/* Do nothing */
}
/* Send the response to ISO_3 layer */
Iso15765_3SendResponse(response_mode);
return response_mode;
}
/*!
* @brief Routine functional unit
*
* @param[in] routine_ctrl_type: routineControlType
* @param[in] id_high: ID MSB
* @param[in] id_low: ID LSB
* @param[in] routine_entry_option: routineControlOption
* @param[in] size: data size
* @return None
*/
void UDS_RoutineControl_CB(uint8 routine_ctrl_type, uint8 id_high, uint8 id_low, uint8 *routine_entry_option, uint16 size)
{
tp_uds_control_routine resp;
uint8 response_mode = ISO15765_3_POSITIVE_RESPONSE;
uint16 id;
resp = ISO15765_3_GET_RESP_DATA(tp_uds_control_routine);
/* Get the complete id */
id = ((uint16) id_high << 8) | (uint16) id_low;
for (uint8 idx =0; idx < GetRoutineServiceNumber(); idx++){
if (id == uds_routine_control_commands[idx].did){
if (size == uds_routine_control_commands[idx].size){
if (TRUE == isSessionAllowed(uds_routine_control_commands[idx].allowed_session)){
if (TRUE == UDS_isSecurityUnlocked(uds_routine_control_commands[idx].security)){
switch(routine_ctrl_type){
case UDS_CTRL_ROUTINE_START: //DamonChange 20230117 0 replace NULL
if (0 != uds_routine_control_commands[idx].func_impl.ImplStart()){
response_mode = uds_routine_control_commands[idx].func_impl.ImplStart();
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
case UDS_CTRL_ROUTINE_STOP: //DamonChange 20230117 0 replace NULL
if (0 != uds_routine_control_commands[idx].func_impl.ImplStop()){
response_mode = uds_routine_control_commands[idx].func_impl.ImplStop();
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
case UDS_CTRL_ROUTINE_RESULTS: //DamonChange 20230117 0 replace NULL
if (0 != uds_routine_control_commands[idx].func_impl.ImplReq()){
response_mode = uds_routine_control_commands[idx].func_impl.ImplReq();
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
default:
response_mode = UDS_ERR_INVALID_FORMAT;
break;
}
}
else{
/** Security is not unlocked **/
response_mode = UDS_ERR_SECURITY_ACCESS_DENIED;
}
}
else{
/** Wrong Session **/
response_mode = UDS_ERR_SERVICE_NOT_SUPORTED_IN_ACTIVE_SESSION;
}
}
else{
/** Wrong size **/
response_mode = UDS_ERR_INVALID_FORMAT;
}
break;
}
}
/* Finally in case of positive response we set the identifier in the response */
if (ISO15765_3_POSITIVE_RESPONSE == response_mode) {
resp->routine_ctrl_type = routine_ctrl_type;
resp->routine_id_high = id_high;
resp->routine_id_low = id_low;
Iso15765_3IncrementResponseSize(3);
}
/* Send the response to ISO_3 layer */
Iso15765_3SendResponse(response_mode);
}
/*!
* @brief InputOutput Control functional unit
*
* @param[in] id_h: ID MSB
* @param[in] id_l: ID LSB
* @param[in] io_ctrl_type: iocontrol type
* @param[in] buf_data_rx: controlOptionRecord
* @param[in] size: data size of buf_data_rx
* @return None
*/
void UDS_IOControl_CB(uint8 id_h, uint8 id_l, uint8 io_ctrl_type, uint8* buf_data_rx, uint16 size)
{
uint16 io_ctl_id;
tp_uds_input_output_control_by_id resp;
t_UDS_ERR response_mode = UDS_ERR_REQUEST_OUT_OF_RANGE;
resp = ISO15765_3_GET_RESP_DATA(tp_uds_input_output_control_by_id);
/* Get the complete id */
io_ctl_id = ((((uint16) (id_h)) << 8) | ((uint16) (id_l)));
for (uint8 idx = 0; idx < GetIoControlServiceNumber(); idx++) {
if (io_ctl_id == uds_io_control_commands[idx].did) {
if (size == uds_io_control_commands[idx].size){
if (TRUE == isSessionAllowed(uds_io_control_commands[idx].allowed_session)) {
if (TRUE == UDS_isSecurityUnlocked(uds_io_control_commands[idx].security)) {
switch (io_ctrl_type){
case IO_CTL_RETURN_CONTOL: //DamonChange 20230117 0 replace NULL
if (0 != uds_io_control_commands[idx].func_impl.ImplReturn(buf_data_rx)){
response_mode = uds_io_control_commands[idx].func_impl.ImplReturn(buf_data_rx);
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
case IO_CTL_RESET: //DamonChange 20230117 0 replace NULL
if (0 != uds_io_control_commands[idx].func_impl.ImplDefault(buf_data_rx)){
response_mode = uds_io_control_commands[idx].func_impl.ImplDefault(buf_data_rx);
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
case IO_CTL_FREEZE: //DamonChange 20230117 0 replace NULL
if (0 != uds_io_control_commands[idx].func_impl.ImplFreeze(buf_data_rx)){
response_mode = uds_io_control_commands[idx].func_impl.ImplFreeze(buf_data_rx);
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
case IO_CTL_CONTROL: //DamonChange 20230117 0 replace NULL
if (0 != uds_io_control_commands[idx].func_impl.ImplControl(buf_data_rx)){
response_mode = uds_io_control_commands[idx].func_impl.ImplControl(buf_data_rx);
}
else{
response_mode = UDS_ERR_SUBFUNCTION_NOT_SUPPORTED;
}
break;
default:
response_mode = UDS_ERR_INVALID_FORMAT;
break;
}
}
else{
/** Security is not unlocked **/
response_mode = UDS_ERR_SECURITY_ACCESS_DENIED;
}
}
else{
/** Wrong Session **/
response_mode = UDS_ERR_SERVICE_NOT_SUPORTED_IN_ACTIVE_SESSION;
}
}
else{
/** Wrong size **/
response_mode = UDS_ERR_INVALID_FORMAT;
}
break;
}
}
/* Finally in case of positive response we set the identifier in the response */
if (response_mode == ISO15765_3_POSITIVE_RESPONSE) {
resp->id_high = id_h;
resp->id_low = id_l;
resp->io_ctrl_type = io_ctrl_type;
Iso15765_3IncrementResponseSize((UI_8) 3);
} else {
/* Do nothing */
}
/* Send the response to ISO_3 layer */
Iso15765_3SendResponse(response_mode);
}

View File

@ -0,0 +1,232 @@
#ifndef _UDS_SERVICES_COMMON_H_
#define _UDS_SERVICES_COMMON_H_
//<<Wang
#include "Std_Types.h"
//Wang>>
#include "UDS_ServicesType.h"
/* ---------------------------------------------------------------------------
* Includes
*/
//#include "Platform_Types.h"
/* ---------------------------------------------------------------------------
* Exported Constants
*/
#define UDS_FICOSA_SESSION UDS_SYSTEM_SUPPLIER_SPECIFIC_SESSION_ID
/** Redefine project_config.mk imports for:
* - IDE indexing consistency
* - Defaults set
*/
#ifndef ECU_HW_ID
#define ECU_HW_ID "000A00"
//#warning "Using default ECU_HW_ID"
#endif
#ifndef ECU_SW_ID
#define ECU_SW_ID "A00RC3"
//#warning "Using default ECU_SW_ID"
#endif
#define FICOSA_DEBUG
/** End of project_config redefines **/
#define IO_CTL_RETURN_CONTOL ((UI_8)0x00)
#define IO_CTL_RESET ((UI_8)0x01)
#define IO_CTL_FREEZE ((UI_8)0x02)
#define IO_CTL_CONTROL ((UI_8)0x03)
/* ---------------------------------------------------------------------------
* Exported Macros
*/
#define DTC_SETTING_HIGH_VOLTAGE_NUM ((uint8)0)
#define DTC_SETTING_LOW_VOLTAGE_NUM ((uint8)1)
#define DTC_SETTING_INVALID_TCU_NUM ((uint8)2)
#define DTC_SETTING_INVALID_EMS_NUM ((uint8)3)
#define DTC_SETTING_INVALID_PEDAL_NUM ((uint8)30)
#define DTC_SETTING_INVALID_BCS_NUM ((uint8)4)
#define DTC_SETTING_INVALID_SPEED_NUM ((uint8)17)
#define DTC_SETTING_LOST_APA_NUM ((uint8)5)
#define DTC_SETTING_INVALID_APA_NUM ((uint8)6)
#define DTC_SETTING_LOST_BCM_NUM ((uint8)7)
#define DTC_SETTING_LOST_ICM_NUM ((uint8)9)
#define DTC_SETTING_INVALID_ICM_NUM ((uint8)10)
#define DTC_SETTING_LOST_EMS_NUM ((uint8)11)
//#define DTC_SETTING_LOST_TCU_NUM ((uint8)12)
#define DTC_SETTING_LOST_VCU_NUM ((uint8)12)
#define DTC_SETTING_LOST_BCS_NUM ((uint8)13)
#define DTC_SETTING_LOST_SRS_NUM ((uint8)15)
#define DTC_SETTING_BUS_OFF_NUM ((uint8)16)
#define DTC_SETTING_SENSOR_DIE1_FAULT_NUM ((uint8)18)
#define DTC_SETTING_SENSOR_DIE2_FAULT_NUM ((uint8)19)
#define DTC_SETTING_SENSOR_HEAVY_FAULT_NUM ((uint8)20)
#define DTC_SETTING_SWITCH_HEAVY_FAULT_NUM ((uint8)21)
#define DTC_SETTING_SWITCH1_OC_FAULT_NUM ((uint8)22)
#define DTC_SETTING_SWITCH1_GND_FAULT_NUM ((uint8)23)
#define DTC_SETTING_SWITCH1_VCC_FAULT_NUM ((uint8)24)
#define DTC_SETTING_SWITCH1_PRESSED_FAULT_NUM ((uint8)25)
#define DTC_SETTING_SWITCH2_OC_FAULT_NUM ((uint8)26)
#define DTC_SETTING_SWITCH2_GND_FAULT_NUM ((uint8)27)
#define DTC_SETTING_SWITCH2_VCC_FAULT_NUM ((uint8)28)
#define DTC_SETTING_SWITCH2_PRESSED_FAULT_NUM ((uint8)29)
#define DTC_SETTING_PADDLE_OC_FAULT_NUM ((uint8)32)
#define DTC_SETTING_PADDLE_GND_FAULT_NUM ((uint8)33)
#define DTC_SETTING_PADDLE_VCC_FAULT_NUM ((uint8)34)
#define DTC_SETTING_PADDLE_PRESSED_FAULT_NUM ((uint8)35)
#define DTC_SETTING_OL_GND_FAULT_NUM ((uint8)46)
#define DTC_SETTING_OL_VCC_FAULT_NUM ((uint8)47)
#define DTC_SETTING_ECO_OC_FAULT_NUM ((uint8)49)
#define DTC_SETTING_ECO_GND_FAULT_NUM ((uint8)50)
#define DTC_SETTING_ECO_VCC_FAULT_NUM ((uint8)51)
#define DTC_SETTING_ECO_PRESSED_FAULT_NUM ((uint8)48)
#define DTC_SETTING_LOST_ACM_NUM ((uint8)53)
#define DTC_SETTING_INVALID_ACM_NUM ((uint8)54)
#define DTC_SETTING_ACM_FAULT_NUM ((uint8)55)
#define DTC_SETTING_GSS_FAULT_NUM ((uint8)56)
#define DTC_SETTING_SHIFT_STUCKED_FAULT_NUM ((uint8)57)
#define DTC_SETTING_SHIFT_CALIB_FAULT_NUM ((uint8)58)
#define TEST_DTC_SETTING_ENABLE(v) ((((p_dtc_setting[v/8]>>(v%8))&0x01) > 0)?1:0)
/* ---------------------------------------------------------------------------
* Exported Types
*/
typedef uint8 t_UDS_ERR;
typedef uint8 t_UDS_Session;
extern uint8* p_dtc_setting;
extern boolean clear_dtc_flag;
extern UI_16 g16_DiagTouchPressSenRes[3][15];
/* ---------------------------------------------------------------------------
* Exported Variables
*/
extern t_UDSIOControlSubCommands uds_io_control_commands[];
extern t_UDSRoutineControlCommands uds_routine_control_commands[];
extern t_UDSReadDidSubCommands uds_did_read_commands[];
extern t_UDSWriteDiDSubCommandsReference uds_did_write_commands_by_reference[];
extern uint8 GetRoutineServiceNumber(void);
extern uint8 GetIoControlServiceNumber(void);
extern uint8 GetWriteDidServiceNumber(void);
extern uint8 GetReadDidServiceNumber(void);
/* ---------------------------------------------------------------------------
* Exported Functions
*/
uint8 UDS_ReadDiD_CB(uint8 id_h, uint8 id_l);
uint8 UDS_WriteDiD_CB(uint8 id_h, uint8 id_l, uint8 *buf_data_rx, uint16 size);
uint8 UDS_ReadMCAL_CB(uint16 requested_id, uint16 resp_pos);
void UDS_RoutineControl_CB(uint8 routine_ctrl_type, uint8 id_high, uint8 id_low, uint8 *routine_entry_option, uint16 size);
void UDS_IOControl_CB(uint8 id_h, uint8 id_l, uint8 io_ctrl_type, uint8* buf_data_rx, uint16 size);
void UDS_DTCSetting_CB(uint8 sub_function, uint8 *buf_data_rx, uint16 size);
/* NVM DIDs */
t_UDS_ERR Get_DID_ECU_SN(uint8 *data);
t_UDS_ERR Set_DID_ECU_SN(uint8 *data);
t_UDS_ERR Get_DID_CD_SYSID_VIN(uint8 *data);
t_UDS_ERR Set_DID_CD_VIN(uint8 *data);
t_UDS_ERR Get_DID_TouchSen1_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen2_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen3_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen4_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen5_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen6_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen7_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen8_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen9_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen10_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen11_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen12_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen13_BaseLine(uint8 *data);
t_UDS_ERR Get_DID_TouchSen1_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen2_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen3_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen4_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen5_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen6_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen7_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen8_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen9_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen10_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen11_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen12_Signal(uint8 *data);
t_UDS_ERR Get_DID_TouchSen13_Signal(uint8 *data);
t_UDS_ERR Get_DID_PressSen_Baseline(uint8 *data);
t_UDS_ERR Get_DID_PressSen_Signal(uint8 *data);
t_UDS_ERR Get_DID_Pre_Value(uint8 *data);
t_UDS_ERR Get_DID_CD_SYSID_CALIRATION_DATE(uint8 *data);
t_UDS_ERR Set_DID_CD_CALIRATION_DATE(uint8 *data);
t_UDS_ERR Get_DID_CD_SYSID_MANUF_ECUHWNUM(uint8 *data);
t_UDS_ERR Set_DID_CD_MANUF_ECUHWNUM(uint8 *data);
t_UDS_ERR Get_DID_Dtc_Setting(uint8 *data);
t_UDS_ERR Set_DID_Dtc_Setting(uint8 *data);
t_UDS_ERR Get_DID_Transportation_Mode(uint8 *data);
t_UDS_ERR Set_DID_Transportation_Mode(uint8 *data);
t_UDS_ERR Get_DID_Reprogramming_Counter(uint8 *data);
t_UDS_ERR Get_DID_Reprogramming_Attempt_Counter(uint8 *data);
t_UDS_ERR Get_DID_Reprogramming_Date(uint8 *data);
t_UDS_ERR Set_DID_Manufacture_Date(uint8 *data);
t_UDS_ERR Set_DID_Reprogramming_Date(uint8 *data);
t_UDS_ERR Get_DID_EcuManufacture_Date(uint8 *data);
t_UDS_ERR Get_DID_EcuInstallation_Date(uint8 *data);
t_UDS_ERR Set_DID_EcuInstallation_Date(uint8 *data);
t_UDS_ERR Get_DID_App_Sw_Finger_Print(uint8 *data);
t_UDS_ERR Set_DID_CD_APP_SW_FINGERPRINT(uint8 *data);
t_UDS_ERR Get_DID_Gac_Diagnostic_Version(uint8 *data);
t_UDS_ERR Get_DID_GAC_Repair_Shop_Id(uint8 *data);
t_UDS_ERR Set_DID_Repair_Shop_Code(uint8 *data);
t_UDS_ERR Get_DID_Gac_Hw_Version(uint8 *data);
t_UDS_ERR Get_DID_Gac_Ecusw_Version(uint8 *data);
t_UDS_ERR Get_DID_Gac_Spare_Number(uint8 *data);
t_UDS_ERR Get_DID_System_Supplier_Id(uint8 *data);
t_UDS_ERR Get_DID_Gac_Kit_Part_Number(uint8 *data);
t_UDS_ERR Get_DID_System_Name(uint8 *data);
t_UDS_ERR Get_DID_Uds_Protol_Version(uint8 *data);
t_UDS_ERR Get_DID_Boot_Version(uint8 *data);
t_UDS_ERR Get_DID_DCID(uint8 *data);
t_UDS_ERR Get_DID_Boot_ID(uint8 *data);
t_UDS_ERR Set_DID_Shield_Atp(uint8 *data);
t_UDS_ERR Get_DID_Shield_Atp(uint8 *data);
t_UDS_ERR Set_DID_CD_Shared_key(uint8 *data);
void UDS_DID_initNVM(void);
uint8 Get_Drive_Mode(void);
void Set_RAM_Drive_Mode(uint8 mode);
uint8 GetNvmFaa(void);
uint8 GetNvmManufactoryMode(void);
uint8 GetNvmEolConfig(void);
uint8* GetNvmDtcSetting(void);
boolean doReset(void);
/* Enable Engineering Mode */
boolean isXCPEnabled(void);
boolean isWriteDriversAccessEnabled(void);
uint8 Get_FC_DevMode(uint8 *data);
uint8 Set_FC_DevMode(const uint8 *data);
//t_UDS_ERR Set_DID_CD_Drive_Mode_Configure(uint8 *data);
t_UDS_ERR Get_DID_Drive_Mode_Configure(uint8 *data);
void SupportIDCheckFor_2E(uint8 * resp, uint8 id_l);
t_UDS_ERR UDS_ReadSBCResetReason (uint8* data);
uint8 GetLastPosition(void);
#endif /* _UDS_SERVICES_COMMON_H_ */

View File

@ -0,0 +1,135 @@
#ifndef FICOSARCFG_H_
#define FICOSARCFG_H_
/*----------------------------- MICROCONTROLLER -----------------------------*/
/* Definition of over which micro the code will be running. Allowed Values: */
#define MPC5604 (0)
#define RH850F1L (1)
#define MICROCONTROLLER (RH850F1L)
/*----------------------------- CONFIG VERSION -----------------------------*/
/* Iteration of the configuration. Updated every time the config API changes */
#define HAL_FICOSAR_CFG_VERSION 5
///* AUTOSAR defines different prototypes for CanIf_RxIndication. */
//#define VARIANT_4_0 0
//#define VARIANT_4_2 1
//
//#define AUTOSAR_VARIANT VARIANT_4_0
/*--------------------- CAN COMMUNICATIONS CONFIGURATION --------------------*/
/*Name of the external data structure containing the overall initialization */
/*data for the CAN driver and affecting all controllers. */
#define CAN_CONFIG_SET_0 (&Can_RSCAN_GstConfigType[0])
/* Extended CAN frames filter flag. Allowed values: */
/* CAN_EXTENDED_FRAMES_NOTIFIED: Extended frames aren't filtered by HW */
/* CAN_EXTENDED_FRAMES_FILTERED: Extended frames are filtered by HW */
/* Extended frames reception is incompatible with recording via CAN. */
#define CAN_EXTENDED_FRAMES (CAN_EXTENDED_FRAMES_FILTERED)
/* Define here the number of CAN controllers used (1 or 2) */
#define NO_OF_CAN_CONTROLLERS ((UI_8)1)
/* Configuration parameter of CANn enabling. */
/* Allowed values: CAN_ENABLED, CAN_DISABLED. */
#define CAN1_MODE (CAN_ENABLED)
#define CAN2_MODE (CAN_DISABLED)
/* Define which controller uses each CAN logical channel */
#define CAN1_CONTROLLER ((UI_8) 0x01)
#define CAN2_CONTROLLER ((UI_8) 0x02)
/* Define here the number of TX HW buffers configured for each CAN Controller
* Current maximum hw buffers number supported is 2. */
#define NO_OF_TX_CAN_BUFFERS (1)
/* Configuration set for CAN1 */
#define CAN_1_RX_HW_OBJECT0 (CanConf_CanHardwareObject_Ctrl_0_Rx_0) /* RECEIVE object of Can Controller ID = 0 */
#define CAN_1_TX_HW_OBJECT0 (CanConf_CanHardwareObject_Ctrl_0_Tx_0) /* TRANSMIT object 1 of Can Controller ID = 0 */
//#define CAN_1_TX_HW_OBJECT1
/* Configuration set for CAN2 */
//#define CAN_2_RX_HW_OBJECT0 (CanConf_CanHardwareObject_CanHardwareObject1) /* RECEIVE object of Can Controller ID = 1 */
//#define CAN_2_TX_HW_OBJECT0 (CanConf_CanHardwareObject_CanHardwareObject3) /* TRANSMIT object 1 of Can Controller ID = 1 */
//#define CAN_2_TX_HW_OBJECT1
/* Callback Routines */
/* The prototype of the function is void ((* func) (t_can_buf_hdl bhdl)) for */
/* Rx and Tx. */
/* The prototype of the function is void ((BOOL)(* func) (void)) for TxReq. */
/* If you don't want to use any callback function, you should not define */
/* this parameter. */
#define CAN1_RX_CALLBACK (OsekComRxNotifCallbackSWTL)
#define CAN1_TXREQ_CALLBACK (OsekComTxReqCallbackSWTL)
#define CAN1_TX_CALLBACK (OsekComTxNotifCallbackSWTL)
//#define CAN2_RX_CALLBACK (Can2_Rx_Cb)
//#define CAN2_TXREQ_CALLBACK (Can2_TxReq_Cb)
//#define CAN2_TX_CALLBACK (Can2_TxNotif_Cb)
/*------------------------ TIMER CONFIGURATION --------------------------*/
/* Definition of GPT Configuration Set 0 handler */
#define GPT_CONFIG_SET_0 (&Gpt_GstConfiguration[0])
/* Definition of GPT Configuration Channel 0 handler */
#define GPT_CONFIG_CHANNEL_0 (GptConf_GptChannelConfiguration_GptChannelConfiguration0)
/* Definition of clock frequency for the system timer(set in ECU SPECTRUM) */
#define FREQ_SYS_CLOCK (40) /* SYS_CLOCK = 40MHz */
/* Time units configuration parameter which TIMER_TIME_TICK parameter is */
/* expressed. Allowed Values: */
/* M_SECONDS if you pass a value in miliseconds */
/* U_SECONDS if you pass a value in microseconds */
#define TIMER_TIME_UNIT (M_SECONDS)
/* Period between clock ticks configuration parameter. */
/* Allowable Values when FREQ_CLOCK_MHZ is 8: */
/* - If TIMER_TIME_UNIT is M_SECONDS: any in the range [1-63] */
/* - If TIMER_TIME_UNIT is U_SECONDS: any in the range [1-255], */
/* and the tick will be 125 x TIMER_TIME_TICK microseconds. */
/* Example: TIMER_TIME_TICK = 2 --> tick of 250 microseconds */
/* Allowable Values when FREQ_CLOCK_MHZ is 5: */
/* - If TIMER_TIME_UNIT is M_SECONDS: any in the range [1-51] */
/* - If TIMER_TIME_UNIT is U_SECONDS: any in the range [1-255], */
/* and the tick will be 200 x TIMER_TIME_TICK microseconds. */
/* Example: TIMER_TIME_TICK = 2 --> tick of 400 microseconds */
/* Allowable Values when FREQ_CLOCK_MHZ is 12: */
/* - If TIMER_TIME_UNIT is M_SECONDS: any in the range [1-42] */
/* - If TIMER_TIME_UNIT is U_SECONDS: any in the range [1-255], */
/* and the tick will be 166,666... x TIMER_TIME_TICK microseconds. */
/* Example: TIMER_TIME_TICK = 3 --> tick of 500 microseconds */
#define TIMER_TIME_TICK (1)
/* Configuration parameter of the number of clock ticks that the main */
/* program cycle works. Admisible Values: [1-127]. This value is obtained */
/* by dividing the time of the program cycle period between the ticks. */
/* For example, if you have a period of 250 microseconds between ticks */
/* and we want a cycle of 5 ms, we have to set TIMER_TICKS_CICLE to: */
/* 5000/250 = 20 */
#define TIMER_TICKS_CICLE (2)
/* Definition of the t_timer_time size that will be used in every FSM and */
/* generated code. */
/* Allowed values for TIMER_T_CLOCK_SIZE */
/* T_TIMER_TIME_1_BYTE (1) */
/* T_TIMER_TIME_2_BYTE (2) */
/* T_TIMER_TIME_4_BYTE (3) */
#define T_TIMER_TIME_SIZE (T_TIMER_TIME_4_BYTE)
/* Name of the auxiliar callback function to execute each clock tick. */
/* The prototype of the function is void (* func) (void)). If you don't want */
/* to use any callback function, you should not define this parameter. The */
/* user is responsible to calculate the increased cost in execution time */
/* that the call of this function may cause. */
#define TIMER_TICK_CALLBACK (SystemTick_callback)
#endif /* FICOSARCFG_H_ */

View File

@ -0,0 +1,24 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef DEM_MEMMAP_H_
#define DEM_MEMMAP_H_
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with Dcm service component.
#endif
#endif /* DEM_MEMMAP_H_ */

View File

@ -0,0 +1,33 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_COMM_TYPE_H_
#define RTE_COMM_TYPE_H_
#define COMMM_NOT_SERVICE_COMPONENT
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with ComM service component.
#include "Rte_Type.h"
#else
/** Current mode of the Communication Manager (main state of the state machine). */
/** @req COMM879 */
typedef uint8 ComM_ModeType; /** @req COMM867 @req COMM868 */
/** Inhibition status of ComM. */
typedef uint8 ComM_InhibitionStatusType;
typedef uint8 ComM_UserHandleType;
#endif
#endif // RTE_COMM_TYPE_H_

View File

@ -0,0 +1,100 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_DCM_TYPE_H_
#define RTE_DCM_TYPE_H_
#if !defined(DCM_UNIT_TEST) || (DCM_UNIT_TEST == STD_OFF)
#define DCM_NOT_SERVICE_COMPONENT
#endif
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with Dcm service component.
#include "Rte_Type.h"
#define DCM_RES_POS_OK ((Dcm_ConfirmationStatusType)0x00)
#define DCM_RES_POS_NOT_OK ((Dcm_ConfirmationStatusType)0x01)
#define DCM_RES_NEG_OK ((Dcm_ConfirmationStatusType)0x02)
#define DCM_RES_NEG_NOT_OK ((Dcm_ConfirmationStatusType)0x03)
/*
* Dcm_SesCtrlType
*/
#ifndef DCM_DEFAULT_SESSION
#define DCM_DEFAULT_SESSION ((Dcm_SesCtrlType)0x01)
#endif
#ifndef DCM_PROGRAMMING_SESSION
#define DCM_PROGRAMMING_SESSION ((Dcm_SesCtrlType)0x02)
#endif
#ifndef DCM_EXTENDED_DIAGNOSTIC_SESSION
#define DCM_EXTENDED_DIAGNOSTIC_SESSION ((Dcm_SesCtrlType)0x03)
#endif
#ifndef DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION
#define DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION ((Dcm_SesCtrlType)0x04)
#endif
#ifndef DCM_OBD_SESSION
#define DCM_OBD_SESSION ((Dcm_SesCtrlType)0x05)//only used for OBD diagnostic
#endif
#ifndef DCM_ALL_SESSION_LEVEL
#define DCM_ALL_SESSION_LEVEL ((Dcm_SesCtrlType)0xFF)
#endif
#else
typedef uint8 Dcm_ConfirmationStatusType;
#define DCM_RES_POS_OK ((Dcm_ConfirmationStatusType)0x00)
#define DCM_RES_POS_NOT_OK ((Dcm_ConfirmationStatusType)0x01)
#define DCM_RES_NEG_OK ((Dcm_ConfirmationStatusType)0x02)
#define DCM_RES_NEG_NOT_OK ((Dcm_ConfirmationStatusType)0x03)
typedef uint8 Dcm_NegativeResponseCodeType;
typedef uint8 Dcm_OpStatusType;
typedef uint8 Dcm_ProtocolType;
typedef uint8 Dcm_SesCtrlType;
/*
* Dcm_SesCtrlType
*/
#ifndef DCM_DEFAULT_SESSION
#define DCM_DEFAULT_SESSION ((Dcm_SesCtrlType)0x01)
#endif
#ifndef DCM_PROGRAMMING_SESSION
#define DCM_PROGRAMMING_SESSION ((Dcm_SesCtrlType)0x02)
#endif
#ifndef DCM_EXTENDED_DIAGNOSTIC_SESSION
#define DCM_EXTENDED_DIAGNOSTIC_SESSION ((Dcm_SesCtrlType)0x03)
#endif
#ifndef DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION
#define DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION ((Dcm_SesCtrlType)0x04)
#endif
#ifndef DCM_OBD_SESSION
#define DCM_OBD_SESSION ((Dcm_SesCtrlType)0x05)//only used for OBD diagnostic
#endif
#ifndef DCM_ALL_SESSION_LEVEL
#define DCM_ALL_SESSION_LEVEL ((Dcm_SesCtrlType)0xFF)
#endif
typedef uint8 Dcm_SecLevelType;
typedef uint8 Dcm_RoeStateType;
typedef uint8 DTRStatusType;
#endif
#endif /*RTE_DCM_TYPE_H_*/

View File

@ -0,0 +1,38 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_DEM_TYPE_H_
#define RTE_DEM_TYPE_H_
#define DEM_NOT_SERVICE_COMPONENT
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with Dem service component.
#include "Rte_Type.h"
typedef uint32 Dem_DTCType;
typedef sint8 Dem_FaultDetectionCounterType;
#else
typedef uint32 Dem_DTCType;
typedef uint16 Dem_EventIdType;
typedef sint8 Dem_FaultDetectionCounterType;
typedef uint8 Dem_IndicatorStatusType;
typedef uint8 Dem_InitMonitorReasonType;
typedef uint8 Dem_OperationCycleIdType;
typedef uint8 Dem_OperationCycleStateType;
typedef uint8 Dem_EventStatusType;
typedef uint8 Dem_EventStatusExtendedType;
typedef uint8 Dem_DTCFormatType;
typedef uint8 Dem_DTCOriginType;
typedef uint8 Dem_ReturnClearDTCType;
#endif
#endif /* RTE_DEM_TYPE_H_ */

View File

@ -0,0 +1,173 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_DLT_TYPE_H_
#define RTE_DLT_TYPE_H_
#define DLT_NOT_SERVICE_COMPONENT
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with Dlt Service Component.
#include "Rte_Type.h"
/* @req SWS_Dlt_00230 */
/* @req SWS_Dlt_00010 */
/** Enum literals for Dlt_MessageLogLevelType */
#ifndef DLT_LOG_OFF
#define DLT_LOG_OFF 0U
#endif /* DLT_LOG_OFF */
#ifndef DLT_LOG_FATAL
#define DLT_LOG_FATAL 1U
#endif /* DLT_LOG_FATAL */
#ifndef DLT_LOG_ERROR
#define DLT_LOG_ERROR 2U
#endif /* DLT_LOG_ERROR */
#ifndef DLT_LOG_WARN
#define DLT_LOG_WARN 3U
#endif /* DLT_LOG_WARN */
#ifndef DLT_LOG_INFO
#define DLT_LOG_INFO 4U
#endif /* DLT_LOG_INFO */
#ifndef DLT_LOG_DEBUG
#define DLT_LOG_DEBUG 5U
#endif /* DLT_LOG_DEBUG */
#ifndef DLT_LOG_VERBOSE
#define DLT_LOG_VERBOSE 6U
#endif /* DLT_LOG_VERBOSE */
/** Enum literals for Dlt_MessageTraceType */
#ifndef DLT_TRACE_VARIABLE
#define DLT_TRACE_VARIABLE 1U
#endif /* DLT_TRACE_VARIABLE */
#ifndef DLT_TRACE_FUNCTION_IN
#define DLT_TRACE_FUNCTION_IN 2U
#endif /* DLT_TRACE_FUNCTION_IN */
#ifndef DLT_TRACE_FUNCTION_OUT
#define DLT_TRACE_FUNCTION_OUT 3U
#endif /* DLT_TRACE_FUNCTION_OUT */
#ifndef DLT_TRACE_STATE
#define DLT_TRACE_STATE 4U
#endif /* DLT_TRACE_STATE */
#ifndef DLT_TRACE_VFB
#define DLT_TRACE_VFB 5U
#endif /* DLT_TRACE_VFB */
#else
/* @req SWS_Dlt_00225 */
typedef uint32 Dlt_SessionIDType;
/* @req SWS_Dlt_00226 *//* @req SWS_Dlt_00127 *//* @req SWS_Dlt_00312 */
typedef uint8 Dlt_ApplicationIDType[4];
/* @req SWS_Dlt_00227 *//* @req SWS_Dlt_00128 *//* @req SWS_Dlt_00313 */
typedef uint8 Dlt_ContextIDType[4];
/* @req SWS_Dlt_00228 */
typedef uint32 Dlt_MessageIDType;
/* @req SWS_Dlt_00229 */
typedef uint8 Dlt_MessageOptionsType;
/* @req SWS_Dlt_00235 */
typedef uint16 Dlt_MessageArgumentCount;
typedef uint8 Dlt_MessageLogLevelType;
/* @req SWS_Dlt_00236 */
typedef struct {
Dlt_MessageArgumentCount arg_count;
Dlt_MessageLogLevelType log_level;
Dlt_MessageOptionsType options;
Dlt_ContextIDType context_id;
Dlt_ApplicationIDType app_id;
} Dlt_MessageLogInfoType;
/* @req SWS_Dlt_00230 */
/* @req SWS_Dlt_00010 */
/** Enum literals for Dlt_MessageLogLevelType */
#ifndef DLT_LOG_OFF
#define DLT_LOG_OFF 0U
#endif /* DLT_LOG_OFF */
#ifndef DLT_LOG_FATAL
#define DLT_LOG_FATAL 1U
#endif /* DLT_LOG_FATAL */
#ifndef DLT_LOG_ERROR
#define DLT_LOG_ERROR 2U
#endif /* DLT_LOG_ERROR */
#ifndef DLT_LOG_WARN
#define DLT_LOG_WARN 3U
#endif /* DLT_LOG_WARN */
#ifndef DLT_LOG_INFO
#define DLT_LOG_INFO 4U
#endif /* DLT_LOG_INFO */
#ifndef DLT_LOG_DEBUG
#define DLT_LOG_DEBUG 5U
#endif /* DLT_LOG_DEBUG */
#ifndef DLT_LOG_VERBOSE
#define DLT_LOG_VERBOSE 6U
#endif /* DLT_LOG_VERBOSE */
typedef uint8 Dlt_MessageTraceType;
/* @req SWS_Dlt_00237 */
typedef struct {
Dlt_MessageTraceType trace_info;
Dlt_MessageOptionsType options;
Dlt_ContextIDType context;
Dlt_ApplicationIDType app_id;
} Dlt_MessageTraceInfoType;
/** Enum literals for Dlt_MessageTraceType */
#ifndef DLT_TRACE_VARIABLE
#define DLT_TRACE_VARIABLE 1U
#endif /* DLT_TRACE_VARIABLE */
#ifndef DLT_TRACE_FUNCTION_IN
#define DLT_TRACE_FUNCTION_IN 2U
#endif /* DLT_TRACE_FUNCTION_IN */
#ifndef DLT_TRACE_FUNCTION_OUT
#define DLT_TRACE_FUNCTION_OUT 3U
#endif /* DLT_TRACE_FUNCTION_OUT */
#ifndef DLT_TRACE_STATE
#define DLT_TRACE_STATE 4U
#endif /* DLT_TRACE_STATE */
#ifndef DLT_TRACE_VFB
#define DLT_TRACE_VFB 5U
#endif /* DLT_TRACE_VFB */
typedef uint8 Dlt_ReturnType;
#endif /* USE_RTE */
#endif /* RTE_DLT_TYPE_H_ */

View File

@ -0,0 +1,31 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_ECUM_TYPE_H_
#define RTE_ECUM_TYPE_H_
#define ECUM_NOT_SERVICE_COMPONENT
#ifdef USE_RTE
#warning This file should only be used when NOT using an EcuM Service Component.
#include "Rte_Type.h"
#else
/* @req EcuM2664 */
/* @req EcuM507 */ /* @req EcuM4039 */
typedef uint8 EcuM_StateType;
/* @req EcuM4067 */
typedef uint8 EcuM_UserType;
/* @req EcuM4042 */
typedef uint8 EcuM_BootTargetType;
#endif
#endif /* RTE_ECUM_TYPE_H_ */

View File

@ -0,0 +1,25 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_MAIN_H_
#define RTE_MAIN_H_
#ifdef USE_RTE
#warning This file should only be used when not using an RTE.
#endif
Std_ReturnType Rte_Start( void );
Std_ReturnType Rte_Stop( void );
#endif /*RTE_MAIN_H_*/

View File

@ -0,0 +1,52 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
/** @reqSettings DEFAULT_SPECIFICATION_REVISION=4.0.3 */
#ifndef RTE_NVM_TYPE_H_
#define RTE_NVM_TYPE_H_
#define NVM_NOT_SERVICE_COMPONENT
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with NvM Service Component.
#include "Rte_Type.h"
#define NVM_REQ_OK 0x00
#define NVM_REQ_NOT_OK 0x01
#define NVM_REQ_PENDING 0x02
#define NVM_REQ_INTEGRITY_FAILED 0x03
#define NVM_REQ_BLOCK_SKIPPED 0x04
#define NVM_REQ_NV_INVALIDATED 0x05
#define NVM_REQ_CANCELLED 0x06
#define NVM_MULTI_BLOCK_REQUEST_ID 0
#define NVM_REDUNDANT_BLOCK_FOR_CONFIG_ID 1
#else
typedef uint8 NvM_RequestResultType; /** @req NVM470 */
#define NVM_REQ_OK 0x00
#define NVM_REQ_NOT_OK 0x01
#define NVM_REQ_PENDING 0x02
#define NVM_REQ_INTEGRITY_FAILED 0x03
#define NVM_REQ_BLOCK_SKIPPED 0x04
#define NVM_REQ_NV_INVALIDATED 0x05
#define NVM_REQ_CANCELLED 0x06
/** @req NVM471 */
/* 0 and 1 is reserved, sequential order */
typedef uint16 NvM_BlockIdType;
#define NVM_MULTI_BLOCK_REQUEST_ID 0
#define NVM_REDUNDANT_BLOCK_FOR_CONFIG_ID 1
#endif
#endif /* RTE_ECUM_TYPE_H_ */

View File

@ -0,0 +1,52 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_STBM_TYPE_H_
#define RTE_STBM_TYPE_H_
#ifdef USE_RTE
#warning This file should only be used when not using an RTE with StbM service component.
#include "Rte_Type.h"
#else
/* @req 4.2.2/SWS_StbM_00239 */
typedef uint8 StbM_TimeBaseStatusType;
/* @req 4.2.2/SWS_StbM_00241 */
typedef struct{
StbM_TimeBaseStatusType timeBaseStatus; /* Status of the Time Base */
uint32 nanoseconds; /* Nanoseconds part of the time */
uint32 seconds; /* 32 bit LSB of the 48 bits Seconds part of the time */
uint16 secondsHi; /* 16 bit MSB of the 48 bits Seconds part of the time*/
}StbM_TimeStampType;
/* @req 4.2.2/SWS_StbM_00242 */
typedef struct{
StbM_TimeBaseStatusType timeBaseStatus; /* Status of the Time Base */
uint32 nanoseconds; /* Nanoseconds part of the time */
uint64 seconds; /* 48 bit Seconds part of the time */
}StbM_TimeStampExtendedType;
/* @req 4.2.2/SWS_StbM_00243 */
typedef struct{
uint8 userDataLength; /* User Data Length in bytes */
uint8 userByte0;
uint8 userByte1;
uint8 userByte2;
}StbM_UserDataType;
#endif
#endif

View File

@ -0,0 +1,41 @@
/*-------------------------------- Arctic Core ------------------------------
* Copyright (C) 2013, ArcCore AB, Sweden, www.arccore.com.
* Contact: <contact@arccore.com>
*
* You may ONLY use this file:
* 1)if you have a valid commercial ArcCore license and then in accordance with
* the terms contained in the written license agreement between you and ArcCore,
* or alternatively
* 2)if you follow the terms found in GNU General Public License version 2 as
* published by the Free Software Foundation and appearing in the file
* LICENSE.GPL included in the packaging of this file or here
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>
*-------------------------------- Arctic Core -----------------------------*/
#ifndef RTE_WDGM_TYPE_H_
#define RTE_WDGM_TYPE_H_
#define WDGM_NOT_SERVICE_COMPONENT
#ifdef USE_RTE
#warning This file should only be used when NOT using an EcuM Service Component.
#include "Rte_Type.h"
#else
typedef uint8 WdgM_LocalStatusType;
typedef uint8 WdgM_GlobalStatusType;
typedef uint8 WdgM_ModeType;
/* NOTE: datatype depends on the maximal configured amount of supervised entities
* currently we assume that 16bit are necessary (alternative would be 8)
*/
typedef uint16 WdgM_SupervisedEntityIdType;
/* NOTE: datatype depends on the maximal configured amount of supervised entities
* currently we assume that 16bit are necessary (alternative would be 8)
*/
typedef uint16 WdgM_CheckpointIdType;
#endif
#endif /* RTE_WDGM_TYPE_H_ */

View File

@ -0,0 +1,96 @@
#include "FunctionState.h"
#include "plib_port.h"
extern uint16 adc[2] ;
uint8 Fuction_State = 1 ;
uint8 Control_SDZ = 1 ;
uint16 LD_AD_Val;
void FunctionState_Task(void)
{
static uint16 Into_A_count = 0;
static uint16 Into_B_count = 0;
static uint16 Into_C_count = 0;
LD_AD_Val = adc[1];
switch(Fuction_State)
{
case Function_State_A:
Into_A_count = 0;
//if((adc[0]>649 && adc[0]<874) || (adc[0]>1777 && adc[0]<2003)) //A switch to B
if((adc[0]>581 && adc[0]<862) || (adc[0]>1788 && adc[0]<2014))
{
Into_B_count++;
if(Into_B_count >= 800) //4000ms
{
Fuction_State = Function_State_B;
}
}
else if(adc[0]<581 || adc[0]>2014) //A switch to C
{
Into_C_count++;
if(Into_C_count >= 200) //1000ms
{
Fuction_State = Function_State_C;
}
}
break;
case Function_State_B:
Into_B_count = 0;
if(adc[0]>897&&adc[0]<1754) //B switch to A
{
Into_A_count++;
if(Into_A_count >= 100) //500ms
{
Fuction_State = Function_State_A;
}
}
else if(adc[0]<581 || adc[0]>2014) //B switch to C
{
Into_C_count++;
if(Into_C_count >= 200) //1000ms
{
Fuction_State = Function_State_C;
}
}
break;
case Function_State_C:
Into_C_count = 0;
if((adc[0]>614 && adc[0]<897) || (adc[0]>1754 && adc[0]<1979)) //C switch to B
{
Into_B_count++;
if(Into_B_count >= 800) //4000ms
{
Fuction_State = Function_State_B;
}
}
//else if(adc[0]>931&&adc[0]<1721) //C switch to A
else if(adc[0]>897&&adc[0]<1754) //8.25->7.95 15.25->15.55
{
Into_A_count++;
if(Into_A_count >= 100) //500ms
{
Fuction_State = Function_State_A;
}
}
break;
default:
break;
}
}

View File

@ -0,0 +1,22 @@
#ifndef __FunctionState_H__
#define __FunctionState_H__
#include "Std_Types.h"
#define Function_State_A 1
#define Function_State_B 2
#define Function_State_C 3
extern uint16 LD_AD_Val;
extern uint8 Fuction_State ;
extern uint8 Control_SDZ ;
extern void FunctionState_Task(void);
#endif

Some files were not shown because too many files have changed in this diff Show More