PK
ꭘO proj/PK
O
proj/413FW.X/PK
g*P proj/413FW.X/build/PK
ꭘO proj/413FW.X/debug/PK
ꭘO proj/413FW.X/debug/default/PK
b*P proj/413FW.X/dist/PK
ꭘO5
5
proj/413FW.X/Makefile#
# 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
PK
쭘O proj/413FW.X/nbproject/PK
l'Pw6 ) proj/413FW.X/nbproject/configurations.xml
../../src/413_adc.h
../../src/413_config.h
../../src/413_system.h
../../src/413_spi.h
../../src/413_timer_interrupt.h
../../src/413_pwm.h
../../src/413_mcp.h
../../src/413_clutch_gear.h
../../src/413_security.h
../../src/413_etc_control.h
../../src/413_steering_wheel.h
../../src/413_sensors.h
../../src/413_dashboard.h
../../src/413_global_variables.h
../../src/413_adc.c
../../src/413_main.c
../../src/413_system.c
../../src/413_spi.c
../../src/413_timer_interrupt.c
../../src/413_pwm.c
../../src/413_mcp.c
../../src/413_clutch_gear.c
../../src/413_security.c
../../src/413_etc_control.c
../../src/413_steering_wheel.c
../../src/413_sensors.c
../../src/413_dashboard.c
Makefile
../../src
../../include
Makefile
localhost
PIC18F67K40
Simulator
XC8
2.10
3
false
false
false
false
false
false
false
PK
l'P| | * proj/413FW.X/nbproject/Makefile-default.mk#
# 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 customized code.
#
# This makefile implements configuration specific macros and targets.
# Include project Makefile
ifeq "${IGNORE_LOCAL}" "TRUE"
# do not include local makefile. User is passing all local related variables already
else
include Makefile
# Include makefile containing local settings
ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk"
include nbproject/Makefile-local-default.mk
endif
endif
# Environment
MKDIR=gnumkdir -p
RM=rm -f
MV=mv
CP=cp
# Macros
CND_CONF=default
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
IMAGE_TYPE=debug
OUTPUT_SUFFIX=elf
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
else
IMAGE_TYPE=production
OUTPUT_SUFFIX=hex
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
endif
ifeq ($(COMPARE_BUILD), true)
COMPARISON_BUILD=-mafrlcsj
else
COMPARISON_BUILD=
endif
ifdef SUB_IMAGE_ADDRESS
else
SUB_IMAGE_ADDRESS_COMMAND=
endif
# Object Directory
OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
# Distribution Directory
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
# Source Files Quoted if spaced
SOURCEFILES_QUOTED_IF_SPACED=../../src/413_adc.c ../../src/413_main.c ../../src/413_system.c ../../src/413_spi.c ../../src/413_timer_interrupt.c ../../src/413_pwm.c ../../src/413_mcp.c ../../src/413_clutch_gear.c ../../src/413_security.c ../../src/413_etc_control.c ../../src/413_steering_wheel.c ../../src/413_sensors.c ../../src/413_dashboard.c
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/_ext/1445274692/413_adc.p1 ${OBJECTDIR}/_ext/1445274692/413_main.p1 ${OBJECTDIR}/_ext/1445274692/413_system.p1 ${OBJECTDIR}/_ext/1445274692/413_spi.p1 ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1 ${OBJECTDIR}/_ext/1445274692/413_pwm.p1 ${OBJECTDIR}/_ext/1445274692/413_mcp.p1 ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1 ${OBJECTDIR}/_ext/1445274692/413_security.p1 ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1 ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1 ${OBJECTDIR}/_ext/1445274692/413_sensors.p1 ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1
POSSIBLE_DEPFILES=${OBJECTDIR}/_ext/1445274692/413_adc.p1.d ${OBJECTDIR}/_ext/1445274692/413_main.p1.d ${OBJECTDIR}/_ext/1445274692/413_system.p1.d ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d ${OBJECTDIR}/_ext/1445274692/413_security.p1.d ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d
# Object Files
OBJECTFILES=${OBJECTDIR}/_ext/1445274692/413_adc.p1 ${OBJECTDIR}/_ext/1445274692/413_main.p1 ${OBJECTDIR}/_ext/1445274692/413_system.p1 ${OBJECTDIR}/_ext/1445274692/413_spi.p1 ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1 ${OBJECTDIR}/_ext/1445274692/413_pwm.p1 ${OBJECTDIR}/_ext/1445274692/413_mcp.p1 ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1 ${OBJECTDIR}/_ext/1445274692/413_security.p1 ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1 ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1 ${OBJECTDIR}/_ext/1445274692/413_sensors.p1 ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1
# Source Files
SOURCEFILES=../../src/413_adc.c ../../src/413_main.c ../../src/413_system.c ../../src/413_spi.c ../../src/413_timer_interrupt.c ../../src/413_pwm.c ../../src/413_mcp.c ../../src/413_clutch_gear.c ../../src/413_security.c ../../src/413_etc_control.c ../../src/413_steering_wheel.c ../../src/413_sensors.c ../../src/413_dashboard.c
CFLAGS=
ASFLAGS=
LDLIBSOPTIONS=
############# Tool locations ##########################################
# If you copy a project from one host to another, the path where the #
# compiler is installed may be different. #
# If you open this project with MPLAB X in the new host, this #
# makefile will be regenerated and the paths will be corrected. #
#######################################################################
# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build
FIXDEPS=fixDeps
.build-conf: ${BUILD_SUBPROJECTS}
ifneq ($(INFORMATION_MESSAGE), )
@echo $(INFORMATION_MESSAGE)
endif
${MAKE} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
MP_PROCESSOR_OPTION=18F67K40
# ------------------------------------------------------------------------------------
# Rules for buildStep: compile
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
${OBJECTDIR}/_ext/1445274692/413_adc.p1: ../../src/413_adc.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_adc.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_adc.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_adc.p1 ../../src/413_adc.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_adc.d ${OBJECTDIR}/_ext/1445274692/413_adc.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_adc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_main.p1: ../../src/413_main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_main.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_main.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_main.p1 ../../src/413_main.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_main.d ${OBJECTDIR}/_ext/1445274692/413_main.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_system.p1: ../../src/413_system.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_system.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_system.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_system.p1 ../../src/413_system.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_system.d ${OBJECTDIR}/_ext/1445274692/413_system.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_system.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_spi.p1: ../../src/413_spi.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_spi.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_spi.p1 ../../src/413_spi.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_spi.d ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1: ../../src/413_timer_interrupt.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1 ../../src/413_timer_interrupt.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.d ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_pwm.p1: ../../src/413_pwm.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_pwm.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_pwm.p1 ../../src/413_pwm.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_pwm.d ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_mcp.p1: ../../src/413_mcp.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_mcp.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_mcp.p1 ../../src/413_mcp.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_mcp.d ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1: ../../src/413_clutch_gear.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1 ../../src/413_clutch_gear.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.d ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_security.p1: ../../src/413_security.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_security.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_security.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_security.p1 ../../src/413_security.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_security.d ${OBJECTDIR}/_ext/1445274692/413_security.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_security.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_etc_control.p1: ../../src/413_etc_control.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1 ../../src/413_etc_control.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_etc_control.d ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1: ../../src/413_steering_wheel.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1 ../../src/413_steering_wheel.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.d ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_sensors.p1: ../../src/413_sensors.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_sensors.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_sensors.p1 ../../src/413_sensors.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_sensors.d ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_dashboard.p1: ../../src/413_dashboard.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1 ../../src/413_dashboard.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_dashboard.d ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
else
${OBJECTDIR}/_ext/1445274692/413_adc.p1: ../../src/413_adc.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_adc.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_adc.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_adc.p1 ../../src/413_adc.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_adc.d ${OBJECTDIR}/_ext/1445274692/413_adc.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_adc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_main.p1: ../../src/413_main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_main.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_main.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_main.p1 ../../src/413_main.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_main.d ${OBJECTDIR}/_ext/1445274692/413_main.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_system.p1: ../../src/413_system.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_system.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_system.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_system.p1 ../../src/413_system.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_system.d ${OBJECTDIR}/_ext/1445274692/413_system.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_system.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_spi.p1: ../../src/413_spi.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_spi.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_spi.p1 ../../src/413_spi.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_spi.d ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_spi.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1: ../../src/413_timer_interrupt.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1 ../../src/413_timer_interrupt.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.d ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_timer_interrupt.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_pwm.p1: ../../src/413_pwm.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_pwm.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_pwm.p1 ../../src/413_pwm.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_pwm.d ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_pwm.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_mcp.p1: ../../src/413_mcp.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_mcp.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_mcp.p1 ../../src/413_mcp.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_mcp.d ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_mcp.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1: ../../src/413_clutch_gear.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1 ../../src/413_clutch_gear.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.d ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_clutch_gear.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_security.p1: ../../src/413_security.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_security.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_security.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_security.p1 ../../src/413_security.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_security.d ${OBJECTDIR}/_ext/1445274692/413_security.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_security.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_etc_control.p1: ../../src/413_etc_control.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1 ../../src/413_etc_control.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_etc_control.d ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_etc_control.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1: ../../src/413_steering_wheel.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1 ../../src/413_steering_wheel.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.d ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_steering_wheel.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_sensors.p1: ../../src/413_sensors.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_sensors.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_sensors.p1 ../../src/413_sensors.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_sensors.d ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_sensors.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/_ext/1445274692/413_dashboard.p1: ../../src/413_dashboard.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} "${OBJECTDIR}/_ext/1445274692"
@${RM} ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d
@${RM} ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1
${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1 ../../src/413_dashboard.c
@-${MV} ${OBJECTDIR}/_ext/1445274692/413_dashboard.d ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d
@${FIXDEPS} ${OBJECTDIR}/_ext/1445274692/413_dashboard.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
endif
# ------------------------------------------------------------------------------------
# Rules for buildStep: assemble
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
else
endif
# ------------------------------------------------------------------------------------
# Rules for buildStep: assembleWithPreprocess
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
else
endif
# ------------------------------------------------------------------------------------
# Rules for buildStep: link
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.map -D__DEBUG=1 -DXPRJ_default=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto $(COMPARISON_BUILD) -Wl,--memorysummary,dist/${CND_CONF}/${IMAGE_TYPE}/memoryfile.xml -o dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
@${RM} dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.hex
else
dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CC} $(MP_EXTRA_LD_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -Wl,-Map=dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.map -DXPRJ_default=$(CND_CONF) -Wl,--defsym=__MPLAB_BUILD=1 -fno-short-double -fno-short-float -memi=wordwrite -O3 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto $(COMPARISON_BUILD) -Wl,--memorysummary,dist/${CND_CONF}/${IMAGE_TYPE}/memoryfile.xml -o dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
endif
# Subprojects
.build-subprojects:
# Subprojects
.clean-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r build/default
${RM} -r dist/default
# Enable dependency checking
.dep.inc: .depcheck-impl
DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES})
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
PK
l'PhP< < 2 proj/413FW.X/nbproject/Makefile-genesis.properties#
#Tue Jan 07 13:39:28 CET 2020
default.Pack.dfplocation=C\:\\Program Files (x86)\\Microchip\\MPLABX\\v5.25\\packs\\Microchip\\PIC18F-K_DFP\\1.1.58
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v2.10\\bin
configurations-xml=3954bbb6e4a8cfbeecacd8d5b324effd
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=6e453b0cf7f7da72a932cfdb2f655401
default.languagetoolchain.version=2.10
host.platform=windows
conf.ids=default
default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=23d12c447ed4f9462f01e2202bc2f36a
PK
l'P{_ ' proj/413FW.X/nbproject/Makefile-impl.mk#
# 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=413FW.X
# Active Configuration
DEFAULTCONF=default
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=default
# 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=default clean
# all
.all-impl: .all-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default 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
PK
l'P| 0 proj/413FW.X/nbproject/Makefile-local-default.mk#
# 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=C:/Program Files (x86)/Microchip/MPLABX/v5.25/mplab_platform/platform/../mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=C:/Program Files (x86)/Microchip/MPLABX/v5.25/mplab_platform/platform/../mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\v5.25\sys\java\jre1.8.0_181/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe"
# MP_CPPC is not defined
# MP_BC is not defined
MP_AS="C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe"
MP_LD="C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-cc.exe"
MP_AR="C:\Program Files (x86)\Microchip\xc8\v2.10\bin\xc8-ar.exe"
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/v5.25/mplab_platform/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="C:\Program Files (x86)\Microchip\xc8\v2.10\bin"
# MP_CPPC_DIR is not defined
# MP_BC_DIR is not defined
MP_AS_DIR="C:\Program Files (x86)\Microchip\xc8\v2.10\bin"
MP_LD_DIR="C:\Program Files (x86)\Microchip\xc8\v2.10\bin"
MP_AR_DIR="C:\Program Files (x86)\Microchip\xc8\v2.10\bin"
# MP_BC_DIR is not defined
PK
l'P! , proj/413FW.X/nbproject/Makefile-variables.mk#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
# default configuration
CND_ARTIFACT_DIR_default=dist/default/production
CND_ARTIFACT_NAME_default=413FW.X.production.hex
CND_ARTIFACT_PATH_default=dist/default/production/413FW.X.production.hex
CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package
CND_PACKAGE_NAME_default=413fw.x.tar
CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/413fw.x.tar
PK
l'PޞͳM M + proj/413FW.X/nbproject/Package-default.bash#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_CONF=default
CND_DISTDIR=dist
TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
OUTPUT_BASENAME=413FW.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
PACKAGE_TOP_DIR=413fw.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}/413fw.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/413fw.x.tar
cd ${TMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/413fw.x.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${TMPDIR}
PK
|O proj/413FW.X/nbproject/private/PK
l'Pg+ 1 proj/413FW.X/nbproject/private/configurations.xml
Makefile
0
platform-tool-sn
C:\Program Files (x86)\Microchip\xc8\v2.10\bin
place holder 1
place holder 2
true
0
0
0
PK
*PFq4 4 * proj/413FW.X/nbproject/private/private.xml
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_timer_interrupt.c
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_main.c
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_dashboard.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_system.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_global_variables.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_dashboard.c
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_clutch_gear.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_security.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_spi.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_sensors.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_etc_control.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_clutch_gear.c
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_config.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_sensors.c
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_adc.h
file:/C:/Users/trewl/Dropbox/Proyecto%20413/FW/src/413_steering_wheel.h
PK
;OD6 " proj/413FW.X/nbproject/project.xml
com.microchip.mplab.nbide.embedded.makeproject
413FW
1c23efa6-3f32-478a-906f-8f406d082a6d
0
c
h
ISO-8859-1
../../src
../../include
default
2
false
PK
/"P src/PK
pO"G:+ +
src/413_adc.c/*
* 413_adc.c
* ADC functions source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_adc.h"
/**
* This functions inits the ADC module of the microcontroller. The programmer
* must do this function before try an ADC conversion
*/
void init_ADC(void)
{
// Program the analog GPIOs
STEERING_WHEEL_CLUTCH_TRIS = INPUT;
STEERING_WHEEL_CLUTCH_ANSEL = ANALOG;
PLAUSABILITY_4_TRIS = INPUT;
PLAUSABILITY_4_ANSEL = ANALOG;
PLAUSABILITY_3_TRIS = INPUT;
PLAUSABILITY_3_ANSEL = ANALOG;
PLAUSABILITY_2_TRIS = INPUT;
PLAUSABILITY_2_ANSEL = ANALOG;
PLAUSABILITY_1_TRIS = INPUT;
PLAUSABILITY_1_ANSEL = ANALOG;
SUSPENSION_1_TRIS = INPUT;
SUSPENSION_1_ANSEL = ANALOG;
SUSPENSION_2_TRIS = INPUT;
SUSPENSION_2_ANSEL = ANALOG;
SUSPENSION_3_TRIS = INPUT;
SUSPENSION_3_ANSEL = ANALOG;
SUSPENSION_4_TRIS = INPUT;
SUSPENSION_4_ANSEL = ANALOG;
OIL_PRESSURE_TRIS = INPUT;
OIL_PRESSURE_ANSEL = ANALOG;
OIL_TEMPERATURE_TRIS = INPUT;
OIL_TEMPERATURE_ANSEL = ANALOG;
FUEL_TRIS = INPUT;
FUEL_ANSEL = ANALOG;
HYDRAULIC_TRIS = INPUT;
HYDRAULIC_ANSEL = ANALOG;
PRESS_TRIS = INPUT;
PRESS_ANSEL = ANALOG;
// ADC Lower Threshold LSB and ADC Lower Threshold MSB
// Set to 0. We won't use the utility of these registers
ADLTHL = 0x00;
ADLTHH = 0x00;
// ADC Upper Threshold LSB and ADC Upper Threshold MSB
// Set to 0. We won't use the utility of these registers
ADUTHL = 0x00;
ADUTHH = 0x00;
// ADC Threshold Setpoint Register
// Set to 0. We won't use the utility of these registers
ADSTPTL = 0x00;
ADSTPTH = 0x00;
// ADC Repeat Threshold bits
// We will only do a unique conversion each time
ADRPT = 0x00;
// ADC Positive Input Channel Selection bits
// We will use this register later. Is for select the ADC port
ADPCH = 0x00;
// Additional Sample Capacitor Selection Register
// We will deactivate the additional capacitance fort the sampling
ADCAP = 0x00;
// Previous ADC Result Most Significant bits
// We won't use this feature. Just set to 0
ADPRE = 0x00;
// ADC Control Register 1
// Bit 7 --> 0 <-- ADPPOL - Action During 1st Precharge Stage
// - ADPRE=0, so, this bit has no effect
// Bit 6 --> 0 <-- ADIPEN - A/D Inverted Precharge Enable bit
// - ADDSEN=0, so, this bit has no effect
// Bit 5 --> 0 <-- ADGPOL - Guard Ring Polarity Selection bit
// - ADC guard Ring outputs start as digital
// low during Precharge stage
// Bit 0 --> 0 <-- ADDSEN - Double-Sample Enable bit
// - The result is performed after every conversion
ADCON1 = 0x00;
// ADC Control Register 2
// Bit 7 --> 0 <-- ADPSIS - Previous Sample Input Select bits
// - We won't use this capabilities. Set to 0
// Bit 6,5,4 > 0 < ADCRS - Accumulated Calculation Right Shift Select bits
// - ADND = 0, so, this bits has no effect
// Bit 3 --> 0 <-- ADACLR - A/D Accumulator Clear Command bit
// - Bit cleared by hardware. Set to 0. No use
// Bit 2,1,0 > 0 < ADMD - ADC Operating Mode Selection bits
// - Basic mode
ADCON2 = 0x00;
// ADC Control Register 3
// Bit 6,5,4 > 0 < ADCALC - ADC Error Calculation Mode Select bits
// - Actual CVD result
// Bit 3 --> 0 <-- ADSOI - ADC Stop-on-Interrupt bit
// - ADCONT=0, so, this bit has no effect
// Bit 2,1,0 > 0 < ADTMD - Threshold Interrupt Mode Select bits
// - Never interrupt
ADCON3 = 0x00;
// ADC Status Register
// Read register. No effects.
ADSTAT = 0x00;
// ADC Reference Selection Register
// Bit 4 --> 4 <-- ADNREF - ADC Negative Voltage Reference Selection bit
// - Vref- is GND
// Bit 1,0 -> 0 <- ADPREF - ADC Positive Voltage Reference Selection bits
// - Vref+ is VCC
ADREF = 0x00;
// ADC AUTO Conversion Trigger Source Selection Register
// External trigger disabled
ADACT = 0x00;
// ADC Clock Selection Register
// Bit 5,4,3,2,1,0 >0x1F< - ADC Conversion Clock Select bits
// - Clock frequency = Fosc/64
ADCLK = 0x1F;
// ADC Control Register 0
// Bit 7 --> 1 <-- ADON - ADC Enable bit
// - Enable the ADC peripheral
// Bit 6 --> 0 <-- ADCONT - ADC Continuous Operation Enable bit
// - The ADC is cleared at start of each conversion
// Bit 4 --> 0 <-- ADCS - ADC Clock Selection bit
// - Clock supplied by Fosc
// Bit 2 --> 1 <-- ADFM - ADC results Format/aligment Selection
// - Sampled data will be right-justified
// Bit 0 --> 0 <-- ADGO - ADC Conversion Status bit
// - Don't start a conversion yet
ADCON0 = 0x84;
// ADC Acquisition Time Control Register
// Acquisiton time is not included in the data conversion cycle
ADACQ = 0x00;
}
/**
* This function returns the value of the selected input.
* Remember the ADC resolution is 10 bits.
*/
inline uint8_t getADCValue( uint8_t adNumber )
{
// Select the A/D channel
ADPCH = adNumber;
// Delay until capacitors are stabilized
for( uint8_t i = 0 ; i < 10 ; i++ )
asm("nop");
// Start the conversion
ADCON0bits.ADGO = 1;
// Wait until conversion finishes
while (ADCON0bits.ADGO);
// Return the result
return ((uint8_t)((ADRESH << 6) + (ADRESL >> 2)));
}
PK
Ҕ"P}Q
src/413_adc.h/*
* 413_adc.h
* ADC related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_ADC_H
#define _P413_ADC_H
#include "413_config.h"
/**
* Definition of the ADC registers by system
* Page 631 of PICs' datasheet
*/
#define P413_ADC_STEERING_WHEEL_CLUTCH 0b001000 // RB0
#define P413_ADC_PLAUSABILITY_4 0b001011 // RB3
#define P413_ADC_PLAUSABILITY_3 0b001100 // RB4
#define P413_ADC_PLAUSABILITY_2 0b001101 // RB5
#define P413_ADC_PLAUSABILITY_1 0b000111 // RA7
#define P413_ADC_SUSPENSION_1 0b000011 // RA3
#define P413_ADC_SUSPENSION_2 0b001111 // RB7
#define P413_ADC_SUSPENSION_3 0b001110 // RB6
#define P413_ADC_SUSPENSION_4 0b101000 // RF0
#define P413_ADC_OIL_PRESSURE 0b101100 // RF4
#define P413_ADC_OIL_TEMPERATURE 0b101011 // RF3
#define P413_ADC_FUEL 0b001010 // RB2
#define P413_ADC_HYDRAULIC 0b101001 // RF1
#define P413_ADC_AIR_PRESSURE 0b001001 // RB1
#define P413_ADC_ETC_SENSOR1 0b000101 // RA5
#define P413_ADC_ETC_SENSOR2 0b110110 // RG6
#define P413_ADC_TPS_SENSOR1 0b000100 // RA4
#define P413_ADC_TPS_SENSOR2 0b110111 // RG7
// Define of the GPIOs
#define STEERING_WHEEL_CLUTCH_TRIS TRISBbits.TRISB0
#define STEERING_WHEEL_CLUTCH_ANSEL ANSELBbits.ANSELB0
#define PLAUSABILITY_4_TRIS TRISBbits.TRISB3
#define PLAUSABILITY_4_ANSEL ANSELBbits.ANSELB3
#define PLAUSABILITY_3_TRIS TRISBbits.TRISB4
#define PLAUSABILITY_3_ANSEL ANSELBbits.ANSELB4
#define PLAUSABILITY_2_TRIS TRISBbits.TRISB5
#define PLAUSABILITY_2_ANSEL ANSELBbits.ANSELB5
#define PLAUSABILITY_1_TRIS TRISAbits.TRISA7
#define PLAUSABILITY_1_ANSEL ANSELAbits.ANSELA7
#define SUSPENSION_1_TRIS TRISAbits.TRISA3
#define SUSPENSION_1_ANSEL ANSELAbits.ANSELA3
#define SUSPENSION_2_TRIS TRISBbits.TRISB7
#define SUSPENSION_2_ANSEL ANSELBbits.ANSELB7
#define SUSPENSION_3_TRIS TRISBbits.TRISB6
#define SUSPENSION_3_ANSEL ANSELBbits.ANSELB6
#define SUSPENSION_4_TRIS TRISFbits.TRISF0
#define SUSPENSION_4_ANSEL ANSELFbits.ANSELF0
#define OIL_PRESSURE_TRIS TRISFbits.TRISF4
#define OIL_PRESSURE_ANSEL ANSELFbits.ANSELF4
#define OIL_TEMPERATURE_TRIS TRISFbits.TRISF3
#define OIL_TEMPERATURE_ANSEL ANSELFbits.ANSELF3
#define FUEL_TRIS TRISFbits.TRISF3
#define FUEL_ANSEL ANSELFbits.ANSELF3
#define HYDRAULIC_TRIS TRISFbits.TRISF1
#define HYDRAULIC_ANSEL ANSELFbits.ANSELF1
#define PRESS_TRIS TRISBbits.TRISB1
#define PRESS_ANSEL ANSELBbits.ANSELB1
/**
* This function inits the ADC module of the microcontroller. The programmer must
* do this function before try an ADC conversion
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_ADC(void);
/**
* This function returns the value of the selected input.
* Remember the ADC resolution is 10 bits but we receive 8 bits.
*
* Requires:
* - This function requires the number of an input
*
* Returns:
* - Returns a uint8_t number with the conversed input
*/
inline uint8_t getADCValue( uint8_t adNumber );
#endifPK
|ON src/413_clutch_gear.c/*
* 413_clutch_gear.c
* Clutch ang gear related functions source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_clutch_gear.h"
/**
* This function inits the clutch and gear system. We must do this function
* before do any work with this system
*/
void init_clutch_gear(void)
{
// Program the PWM system
init_pwm();
// Init cutoff
CUTOFF_TRIS = INPUT;
CUTOFF_WPU = 0;
// Program the outputs for change the gear
GEAR_UP_TRIS = OUTPUT;
GEAR_UP_LAT = 0;
GEAR_DOWN_TRIS = OUTPUT;
GEAR_DOWN_ANSEL = DIGITAL;
GEAR_DOWN_LAT = 0;
// Program the inputs for know if we changed the gear
GEAR_0_TRIS = INPUT;
GEAR_0_WPU = 1;
GEAR_2_TRIS = INPUT;
GEAR_2_WPU = 1;
GEAR_3_TRIS = INPUT;
GEAR_3_WPU = 1;
}
/**
* Set the power to the pneumatic valve to make air go out from system
*/
void clutchOut(uint8_t percent)
{
// Correct possible wrong function calls
if ( percent > 100)
percent = 100;
// Set the value to the PWM 6
setPwm6( percent << 1 );
}
/**
* Set the power to the pneumatic valve to put air into de system
*/
void clutchIn(uint8_t percent)
{
// Correct possible wrong function calls
if ( percent > 100)
percent = 100;
// Set the value to the PWM 7
setPwm7( percent << 1 );
}
/**
* Activate the normal preassure in the system for fast gear change
*/
void gearNormalPressure(void)
{
// Set the value to the PWM 1
setPwm1( FAST_GEAR_CHANGE );
}
/**
* Activate the reduced preassure in the system for slow gear change, and
* be able to reach the "No gear" position
*/
void gearNeutralPressure(void)
{
// Set the value to the PWM 1
setPwm1( SLOW_GEAR_CHANGE );
}
/**
* Stops the pressure for change the gear. Is used for stop the current and do
* not put hot the valve.
*/
void gearNoPressure(void)
{
// Set the value to the PWM 1
setPwm1( NO_GEAR_PRESSURE );
}
/**
* Put the gear valve in the position to increment one gear. Be careful with
* this function because there are not way to know if the movement was finish.
*/
void gearUp(void)
{
// Activate the gear up coil
GEAR_UP_LAT = 1;
// Deactivate the gear down coil
GEAR_DOWN_LAT = 0;
}
/**
* Put the gear valve in the position to decrement one gear. Be careful with
* this function because there are not way to know if the movement was finish.
*/
void gearDown(void)
{
// Deactivate the gear up coil
GEAR_UP_LAT = 0;
// Activate the gear down coil
GEAR_DOWN_LAT = 1;
}
/**
* Put the gear valve in the passive position. Be careful with
* this function because there are not way to know if the movement was finish.
*/
void gearMiddle(void)
{
// Deactivate the gear up coil
GEAR_UP_LAT = 0;
// Deactivate the gear down coil
GEAR_DOWN_LAT = 0;
}
/**
* This function check if the motor is detecting the no gear position
*/
uint8_t checkNoGear(void)
{
return (!GEAR_0_PORT);
}
/**
* This function check if the motor is detecting the second gear
*/
uint8_t checkSecondGear(void)
{
return (!GEAR_2_PORT);
}
/**
* This function check if the motor is detecting the third gear position
*/
uint8_t checkThirdGear(void)
{
return (!GEAR_3_PORT);
}
/**
* This function deactivte the cutoff. Is a way to increment gear without the
* clutch
*/
void deactivateCuttoff(void)
{
CUTOFF_TRIS = INPUT;
}
/**
* This function deactivte the cutoff. Is a way to increment gear without the
* clutch
*/
void activateCuttoff(void)
{
CUTOFF_TRIS = OUTPUT;
CUTOFF_LAT = 0;
}
PK
vOJ src/413_clutch_gear.h/*
* 413_clutch_gear.h
* Clutch and gear related functions header
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_CLUTCH_GEAR_H
#define _P413_CLUTCH_GEAR_H
#include "413_config.h"
#include "413_pwm.h"
// Define the PWM values for change the gear
#define FAST_GEAR_CHANGE 255
#define SLOW_GEAR_CHANGE 100
#define NO_GEAR_PRESSURE 0
// Define of the GPIOs
#define GEAR_UP_TRIS TRISHbits.TRISH2
#define GEAR_UP_LAT LATHbits.LATH2
#define GEAR_DOWN_TRIS TRISDbits.TRISD0
#define GEAR_DOWN_LAT LATDbits.LATD0
#define GEAR_DOWN_ANSEL ANSELDbits.ANSELD0
#define GEAR_0_TRIS TRISHbits.TRISH1
#define GEAR_0_PORT PORTHbits.RH1
#define GEAR_0_WPU WPUHbits.WPUH1
#define GEAR_2_TRIS TRISAbits.TRISA0
#define GEAR_2_PORT PORTAbits.RA0
#define GEAR_2_WPU WPUAbits.WPUA0
#define GEAR_3_TRIS TRISAbits.TRISA1
#define GEAR_3_PORT PORTAbits.RA1
#define GEAR_3_WPU WPUAbits.WPUA1
#define CUTOFF_TRIS TRISCbits.TRISC6
#define CUTOFF_LAT LATCbits.LATC6
#define CUTOFF_WPU WPUCbits.WPUC6
/**
* This function inits the clutch and gear system. We must do this function
* before do any work with this system
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_clutch_gear(void);
/**
* Set the power to the pneumatic valve to make air go out from system
*
* Requires:
* - A uint8_t variable with a number between 0 and 100 that means the
* % opened of the valve
*
* Returns:
* - This function doesn't return anything
*/
void clutchOut(uint8_t percent);
/**
* Set the power to the pneumatic valve to put air into de system
*
* Requires:
* - A uint8_t variable with a number between 0 and 100 that means the
* % opened of the valve
*
* Returns:
* - This function doesn't return anything
*/
void clutchIn(uint8_t percent);
/**
* Activate the normal preassure in the system for fast gear change
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void gearNormalPressure(void);
/**
* Activate the reduced preassure in the system for slow gear change, and
* be able to reach the "No gear" position
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void gearNeutralPressure(void);
/**
* Stops the pressure for change the gear. Is used for stop the current and do
* not put hot the valve.
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void gearNoPressure(void);
/**
* Put the gear valve in the position to increment one gear. Be careful with
* this function because there are not way to know if the movement was finish.
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void gearUp(void);
/**
* Put the gear valve in the position to decrement one gear. Be careful with
* this function because there are not way to know if the movement was finish.
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void gearDown(void);
/**
* Put the gear valve in the passive position. Be careful with
* this function because there are not way to know if the movement was finish.
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void gearMiddle(void);
/**
* This function check if the motor is detecting the no gear position
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function return TRUE if there is no gear in the motor.
* FALSE otherwise.
*/
uint8_t checkNoGear(void);
/**
* This function check if the motor is detecting the second gear
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function return TRUE if there is the second gear in the motor.
* FALSE otherwise.
*/
uint8_t checkSecondGear(void);
/**
* This function check if the motor is detecting the third gear position
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function return TRUE if there is the second gear in the motor.
* FALSE otherwise.
*/
uint8_t checkThirdGear(void);
/**
* This function deactivte the cutoff. Is a way to increment gear without the
* clutch
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void deactivateCuttoff(void);
/**
* This function deactivte the cutoff. Is a way to increment gear without the
* clutch
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void activateCuttoff(void);
#endifPK
}O src/413_config.h/*
* 413_config.h
* Configuration defines and includes related to the 413 project
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _413_CONFIG_H
#define _413_CONFIG_H
// Configuration bits
// CONFIG1L
#pragma config FEXTOSC = OFF // External Oscillator mode Selection bits->Oscillator not enabled
#pragma config RSTOSC = HFINTOSC_64MHZ // Power-up default value for COSC bits->HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
// CONFIG1H
#pragma config CLKOUTEN = OFF // Clock Out Enable bit->CLKOUT function is disabled
#pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit->Fail-Safe Clock Monitor enabled
// CONFIG2L
#pragma config MCLRE = EXTMCLR // Master Clear Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR
#pragma config PWRTE = OFF // Power-up Timer Enable bit->Power up timer disabled
#pragma config LPBOREN = OFF // Low-power BOR enable bit->ULPBOR disabled
#pragma config BOREN = SBORDIS // Brown-out Reset Enable bits->Brown-out Reset enabled , SBOREN bit is ignored
// CONFIG2H
#pragma config BORV = VBOR_2P45 // Brown Out Reset Voltage selection bits->Brown-out Reset Voltage (VBOR) set to 2.45V
#pragma config ZCD = OFF // ZCD Disable bit->ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
#pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit->PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit->Stack full/underflow will cause Reset
#pragma config DEBUG = OFF // Debugger Enable bit->Background debugger disabled
#pragma config XINST = OFF // Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled
// CONFIG3L
#pragma config WDTCPS = WDTCPS_31 // WDT Period Select bits->Divider ratio 1:65536; software control of WDTPS
#pragma config WDTE = OFF // WDT operating mode->WDT Disabled
// CONFIG3H
#pragma config WDTCWS = WDTCWS_7 // WDT Window Select bits->window always open (100%); software control; keyed access not required
#pragma config WDTCCS = SC // WDT input clock selector->Software Control
// CONFIG4L
#pragma config WRT0 = OFF // Write Protection Block 0->Block 0 (000800-003FFFh) not write-protected
#pragma config WRT1 = OFF // Write Protection Block 1->Block 1 (004000-007FFFh) not write-protected
#pragma config WRT2 = OFF // Write Protection Block 2->Block 2 (008000-00BFFFh) not write-protected
#pragma config WRT3 = OFF // Write Protection Block 3->Block 3 (00C000-00FFFFh) not write-protected
#pragma config WRT4 = OFF // Write Protection Block 3->Block 4 (010000-013FFFh) not write-protected
#pragma config WRT5 = OFF // Write Protection Block 3->Block 5 (014000-017FFFh) not write-protected
#pragma config WRT6 = OFF // Write Protection Block 3->Block 6 (018000-01BFFFh) not write-protected
#pragma config WRT7 = OFF // Write Protection Block 3->Block 7 (01C000-01FFFFh) not write-protected
// CONFIG4H
#pragma config WRTC = OFF // Configuration Register Write Protection bit->Configuration registers (300000-30000Bh) not write-protected
#pragma config WRTB = OFF // Boot Block Write Protection bit->Boot Block (000000-0007FFh) not write-protected
#pragma config WRTD = OFF // Data EEPROM Write Protection bit->Data EEPROM not write-protected
#pragma config SCANE = ON // Scanner Enable bit->Scanner module is available for use, SCANMD bit can control the module
#pragma config LVP = ON // Low Voltage Programming Enable bit->Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored
// CONFIG5L
#pragma config CP = OFF // UserNVM Program Memory Code Protection bit->UserNVM code protection disabled
#pragma config CPD = OFF // DataNVM Memory Code Protection bit->DataNVM code protection disabled
// CONFIG6L
#pragma config EBTR0 = OFF // Table Read Protection Block 0->Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
#pragma config EBTR1 = OFF // Table Read Protection Block 1->Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
#pragma config EBTR2 = OFF // Table Read Protection Block 2->Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
#pragma config EBTR3 = OFF // Table Read Protection Block 3->Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
#pragma config EBTR4 = OFF // Table Read Protection Block 4->Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
#pragma config EBTR5 = OFF // Table Read Protection Block 5->Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
#pragma config EBTR6 = OFF // Table Read Protection Block 6->Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
#pragma config EBTR7 = OFF // Table Read Protection Block 7->Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
// CONFIG6H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit->Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
// General includes for the project
#include
#include
#include
#include
// General defines for the project
#define TRUE 1
#define FALSE 0
#define INPUT 1
#define OUTPUT 0
#define DIGITAL 0
#define ANALOG 1
#define NO_ERROR 0
#define ERROR_DETECTED 1
#endifPK
u)PzUaz% z% src/413_dashboard.c/*
* 413_dashboard.c
* Dashboard functions source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_dashboard.h"
// Variables to save the status of the LEDs
/* Bit 0 - RPM1 and RPM2
* Bit 1 - RPM3
* Bit 2 - RPM4
* Bit 3 - RPM5
* Bit 4 - RPM9
* Bit 5 - RPM8
* Bit 6 - RPM7
* Bit 7 - RPM6
*/
static volatile uint8_t rpm_value = 0;
/*
* Bit 0 - A_Out
* Bit 1 - B_Out
* Bit 2 - C_Out
* Bit 3 - D_Out
* Bit 4 - DOT_Out
* Bit 5 - G_Out
* Bit 6 - F_Out
* Bit 7 - E_Out
* Bit 8 - Oil temp red LED
* Bit 9 - Fuel pump relay
* Bit 10 - Oil pressure red LED
* Bit 11 - Resv_orange
* Bit 12 - ETC_APPS
* Bit 13 - Fuel level red LED
* Bit 14 - Air pressure red LED
*/
static volatile uint16_t dashboard_value = 0;
/**
* This functions inits the serial to parallel circuit for handle the
* dashboard
*/
void init_dashboard(void)
{
// Configure the ports
RPM_A_TRIS = OUTPUT;
RPM_A_ANSEL = DIGITAL;
RPM_B_TRIS = OUTPUT;
RPM_B_ANSEL = DIGITAL;
RPM_CLR_TRIS = OUTPUT;
RPM_CLR_ANSEL = DIGITAL;
CLK_TRIS = DIGITAL;
CLK_ANSEL = DIGITAL;
DASHBOARD_A_TRIS = OUTPUT;
DASHBOARD_A_ANSEL = DIGITAL;
DASHBOARD_B_TRIS = OUTPUT;
DASHBOARD_B_ANSEL = DIGITAL;
DASHBOARD_CLR_TRIS = OUTPUT;
DASHBOARD_CLR_ANSEL = DIGITAL;
// Set the initial values
RPM_CLR_LAT = 1;
DASHBOARD_CLR_LAT = 1;
RPM_B_LAT = 1;
DASHBOARD_B_LAT = 1;
// Program the selection of each 7-segments
SEGMENTS_1_TRIS = OUTPUT;
SEGMENTS_2_TRIS = OUTPUT;
SEGMENTS_3_TRIS = OUTPUT;
SEGMENTS_4_TRIS = OUTPUT;
SEGMENTS_1_ANSEL = DIGITAL;
SEGMENTS_2_ANSEL = DIGITAL;
SEGMENTS_3_ANSEL = DIGITAL;
SEGMENTS_4_ANSEL = DIGITAL;
SEGMENTS_1_LAT = 0;
SEGMENTS_2_LAT = 0;
SEGMENTS_3_LAT = 0;
SEGMENTS_4_LAT = 0;
// Init the preload button ports
PRELOAD_BUTTON_TRIS = INPUT;
PRELOAD_BUTTON_ANSEL = DIGITAL;
PRELOAD_ACTIVATION_TRIS = OUTPUT;
PRELOAD_ACTIVATION_ANSEL = DIGITAL;
PRELOAD_ACTIVATION_LAT = 0;
// Update the dashboard with no values (No active LEDs)
updateDashboard();
}
/**
* This function updates the values of the dashboard information
* Uses the local variable "dashboard_value" and the "rpm_value"
*/
void updateDashboard(void)
{
// Send the saved information to the dashboard
uint8_t i, temp_rpm;
uint16_t temp_dashboard;
// Save the local variables
temp_rpm = rpm_value;
temp_dashboard = dashboard_value;
// Send the information to the dashboard
for ( i = 0 ; i < 16 ; i ++)
{
// Set to 0 the clock of the serial registers
CLK_LAT = 0;
// Check if the data we must send is a "0" or "1"
if ( temp_dashboard & 0x8000 )
DASHBOARD_A_LAT = 1;
else
DASHBOARD_A_LAT = 0;
// Update the rpm value in order
if ( i > 7 )
{
if ( temp_rpm & 0x80 )
RPM_A_LAT = 1;
else
RPM_A_LAT = 0;
}
// Input the values
CLK_LAT = 1;
// Rotate temporal variables
temp_dashboard <<= 1;
temp_rpm <<= 1;
}
}
/**
* This function sets the LED that indicates the state of the fuel pump
*/
void setFuelPump(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_FUEL_PUMP;
else
dashboard_value &= ~(DASHBOARD_FUEL_PUMP);
}
/**
* This function sets the LED that indicates the state of the oil temperature
*/
void setOilTemperature(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_OIL_TEMPERATURE;
else
dashboard_value &= ~(DASHBOARD_OIL_TEMPERATURE);
}
/**
* This function sets the LED that indicates the state of the oil pressure
*/
void setOilPressure(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_OIL_PRESSURE;
else
dashboard_value &= ~(DASHBOARD_OIL_PRESSURE);
}
/**
* This function sets the LED that indicates the state of the Resv system. If
* this system is not implemented, it will be an extra output to handle systems
*/
void setResvOrange(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_RESV_ORANGE;
else
dashboard_value &= ~(DASHBOARD_RESV_ORANGE);
}
/**
* This function sets the LED that indicates the state of the air pressure
*/
void setAirPressure(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_AIR_PRSSURE;
else
dashboard_value &= ~(DASHBOARD_AIR_PRSSURE);
}
/**
* This function sets the LED that indicates the state of the fuel level
*/
void setFuelLevel(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_FUEL_LEVEL;
else
dashboard_value &= ~(DASHBOARD_FUEL_LEVEL);
}
/**
* This function sets the LED that indicates the state of the security system
*/
void setEtcApps(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_ETC_APPS;
else
dashboard_value &= ~(DASHBOARD_ETC_APPS);
}
/**
* This function sets the LED that indicates the state of the water temperature
*/
void setWaterTemperature(uint8_t state)
{
// Activate or deactivate the LED in the internal register
if ( state )
dashboard_value |= DASHBOARD_WATER_TEMPERATURE;
else
dashboard_value &= ~(DASHBOARD_WATER_TEMPERATURE);
}
/**
* This function sets a number to send to the 7 segments
*/
void setNumberSegments(uint8_t number)
{
// Limit the maximum value we can send to this function
if ( number > 9 )
number = 9;
// Reset the segment number of the
dashboard_value &= 0xFF00;
// Depending of the number, set one different case
switch ( number )
{
case 0:
dashboard_value |= 0xCF;
break;
case 1:
dashboard_value |= 0x06;
break;
case 2:
dashboard_value |= 0xAB;
break;
case 3:
dashboard_value |= 0x2F;
break;
case 4:
dashboard_value |= 0x66;
break;
case 5:
dashboard_value |= 0x6D;
break;
case 6:
dashboard_value |= 0xEC;
break;
case 7:
dashboard_value |= 0x07;
break;
case 8:
dashboard_value |= 0xEF;
break;
case 9:
dashboard_value |= 0x67;
break;
default:
break;
}
}
/**
* Sets the rpm value
*/
void setRpm(uint8_t rpm)
{
// Limit the maximum value we can send to this function
if ( rpm > 7 )
rpm = 7;
// Depending of the number, set one different case
switch ( rpm )
{
case 0:
rpm_value = 0b00000001;
break;
case 1:
rpm_value = 0b00000011;
break;
case 2:
rpm_value = 0b00000111;
break;
case 3:
rpm_value = 0b00001111;
break;
case 4:
rpm_value = 0b10001111;
break;
case 5:
rpm_value = 0b11001111;
break;
case 6:
rpm_value = 0b11101111;
break;
case 7:
rpm_value = 0b11111111;
break;
default:
break;
}
}
/**
* Set the system to activate the gear 7 segments
*/
void setTrisLedOnGear(void)
{
SEGMENTS_1_LAT = 0;
SEGMENTS_2_LAT = 0;
SEGMENTS_3_LAT = 0;
SEGMENTS_4_LAT = 1;
}
/**
* Set the system to activate the lowest 7 segments of the motor temperature
*/
void setTrisLedTemperature1(void)
{
SEGMENTS_1_LAT = 1;
SEGMENTS_2_LAT = 0;
SEGMENTS_3_LAT = 0;
SEGMENTS_4_LAT = 0;
}
/**
* Set the system to activate the middlest 7 segments of the motor temperature
*/
void setTrisLedTemperature2(void)
{
SEGMENTS_1_LAT = 0;
SEGMENTS_2_LAT = 1;
SEGMENTS_3_LAT = 0;
SEGMENTS_4_LAT = 0;
}
/**
* Set the system to activate the highest 7 segments of the motor temperature
*/
void setTrisLedTemperature3(void)
{
SEGMENTS_1_LAT = 0;
SEGMENTS_2_LAT = 0;
SEGMENTS_3_LAT = 1;
SEGMENTS_4_LAT = 0;
}
/**
* Returns if the preload button is pressed
*/
uint8_t getPreloadButton(void)
{
return PORTDbits.RD1;
}
/**
* Activate the fuel preload
*/
void activatePreload(void)
{
setFuelPump( TRUE );
PRELOAD_ACTIVATION_LAT = 1;
}
/**
* Deactivate the fuel preload
*/
void deactivatePreload(void)
{
setFuelPump( FALSE );
PRELOAD_ACTIVATION_LAT = 0;
}PK
)P}U}# }# src/413_dashboard.h/*
* 413_dashboard.h
* Dashboard related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_DASHBOARD_H
#define _P413_DASHBOARD_H
#include "413_config.h"
// Ports definition
// RPM A
#define RPM_A_TRIS TRISEbits.TRISE0
#define RPM_A_LAT LATEbits.LATE0
#define RPM_A_PORT PORTEbits.RE0
#define RPM_A_ANSEL ANSELEbits.ANSELE0
// RPM B
#define RPM_B_TRIS TRISEbits.TRISE1
#define RPM_B_LAT LATEbits.LATE1
#define RPM_B_PORT PORTEbits.RE1
#define RPM_B_ANSEL ANSELEbits.ANSELE1
// RPM CLR
#define RPM_CLR_TRIS TRISEbits.TRISE2
#define RPM_CLR_LAT LATEbits.LATE2
#define RPM_CLR_PORT PORTEbits.RE2
#define RPM_CLR_ANSEL ANSELEbits.ANSELE2
// RPM CLk
#define CLK_TRIS TRISGbits.TRISG0
#define CLK_LAT LATGbits.LATG0
#define CLK_PORT PORTGbits.RG0
#define CLK_ANSEL ANSELGbits.ANSELG0
// Dashboard A
#define DASHBOARD_A_TRIS TRISGbits.TRISG3
#define DASHBOARD_A_LAT LATGbits.LATG3
#define DASHBOARD_A_PORT PORTGbits.RG3
#define DASHBOARD_A_ANSEL ANSELGbits.ANSELG3
// Dashboard B
#define DASHBOARD_B_TRIS TRISGbits.TRISG2
#define DASHBOARD_B_LAT LATGbits.LATG2
#define DASHBOARD_B_PORT PORTGbits.RG2
#define DASHBOARD_B_ANSEL ANSELGbits.ANSELG2
// Dashboard CLR
#define DASHBOARD_CLR_TRIS TRISGbits.TRISG1
#define DASHBOARD_CLR_LAT LATGbits.LATG1
#define DASHBOARD_CLR_PORT PORTGbits.RG1
#define DASHBOARD_CLR_ANSEL ANSELGbits.ANSELG1
// Segments 1
#define SEGMENTS_1_TRIS TRISFbits.TRISF5
#define SEGMENTS_1_LAT LATFbits.LATF5
#define SEGMENTS_1_PORT PORTFbits.RF5
#define SEGMENTS_1_ANSEL ANSELFbits.ANSELF5
// Segments 2
#define SEGMENTS_2_TRIS TRISFbits.TRISF6
#define SEGMENTS_2_LAT LATFbits.LATF6
#define SEGMENTS_2_PORT PORTFbits.RF6
#define SEGMENTS_2_ANSEL ANSELFbits.ANSELF6
// Segments 3
#define SEGMENTS_3_TRIS TRISFbits.TRISF7
#define SEGMENTS_3_LAT LATFbits.LATF7
#define SEGMENTS_3_PORT PORTFbits.RF7
#define SEGMENTS_3_ANSEL ANSELFbits.ANSELF7
// Segments 4
#define SEGMENTS_4_TRIS TRISGbits.TRISG7
#define SEGMENTS_4_LAT LATGbits.LATG4
#define SEGMENTS_4_PORT PORTGbits.RG7
#define SEGMENTS_4_ANSEL ANSELGbits.ANSELG7
#define OIL_TEMPERATURE_ERROR_VALUE 230
#define OIL_PRESSURE_ERROR_VALUE 210
#define AIR_PRESSURE_ERROR_VALUE 50
#define FUEL_ERROR_VALUE 100
#define WATER_TEMPERATURE_ERROR_VALUE 99
/**
* This functions inits the serial to parallel circuit for handle the
* dashboard
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_dashboard(void);
// Dashboard LED positoin defines
#define DASHBOARD_OIL_TEMPERATURE 0x0100
#define DASHBOARD_FUEL_PUMP 0x0200
#define DASHBOARD_OIL_PRESSURE 0x0400
#define DASHBOARD_RESV_ORANGE 0x0800
#define DASHBOARD_ETC_APPS 0x1000
#define DASHBOARD_FUEL_LEVEL 0x2000
#define DASHBOARD_AIR_PRSSURE 0x4000
#define DASHBOARD_WATER_TEMPERATURE 0x8000
// Preload button and system port defines
#define PRELOAD_BUTTON_TRIS TRISDbits.TRISD1
#define PRELOAD_BUTTON_ANSEL ANSELDbits.ANSELD1
#define PRELOAD_BUTTON_PORT PORTDbits.RD1
#define PRELOAD_ACTIVATION_TRIS TRISEbits.TRISE7
#define PRELOAD_ACTIVATION_ANSEL ANSELEbits.ANSELE7
#define PRELOAD_ACTIVATION_LAT LATEbits.LATE7
/**
* This function updates the values of the dashboard information
* Uses the local variable "dashboard_value" and the "rpm_value"
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void updateDashboard(void);
/**
* This function sets the LED that indicates the state of the fuel pump
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setFuelPump(uint8_t state);
/**
* This function sets the LED that indicates the state of the oil temperature
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setOilTemperature(uint8_t state);
/**
* This function sets the LED that indicates the state of the oil pressure
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setOilPressure(uint8_t state);
/**
* This function sets the LED that indicates the state of the Resv system. If
* this system is not implemented, it will be an extra output to handle systems
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setResvOrange(uint8_t state);
/**
* This function sets the LED that indicates the state of the air pressure
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setAirPressure(uint8_t state);
/**
* This function sets the LED that indicates the state of the fuel level
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setFuelLevel(uint8_t state);
/**
* This function sets the LED that indicates the state of the security system
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setEtcApps(uint8_t state);
/**
* This function sets the LED that indicates the state of the water temperature
*
* Requires:
* - A variable uint8_t with TRUE if the LED will be on, or FALSE if will
* - be off
*
* Returns:
* - This function doesn't return anything
*/
void setWaterTemperature(uint8_t state);
/**
* This function sets a number to send to the 7 segments
*
* Requires:
* - A uint8_t variable withnumber from the 0 to the 9 with the number
*
* Returns:
* - This function doesn't return anything
*/
void setNumberSegments(uint8_t number);
/**
* Sets the rpm value
*
* Requires:
* - A uint8_t varaible with anumber from the 0 to the 0 with the number of
* leds the program wants activate
*
*
* Returns:
* - This function doesn't return anything
*/
void setRpm(uint8_t rpm);
/**
* Set the system to activate the gear 7 segments
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - This function doesn't return anything
*/
void setTrisLedOnGear(void);
/**
* Set the system to activate the lowest 7 segments of the motor temperature
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - This function doesn't return anything
*/
void setTrisLedTemperature1(void);
/**
* Set the system to activate the middlest 7 segments of the motor temperature
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - This function doesn't return anything
*/
void setTrisLedTemperature2(void);
/**
* Set the system to activate the highest 7 segments of the motor temperature
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - This function doesn't return anything
*/
void setTrisLedTemperature3(void);
/**
* Returns if the preload button is pressed
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - A uint8_t variable with TRUE if the button is pressed. FALSE otherwise
*/
uint8_t getPreloadButton(void);
/**
* Activate the fuel preload
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - This function doesn't return anything
*/
void activatePreload(void);
/**
* Deactivate the fuel preload
*
* Requires:
* - This functions doesn't requires anything
*
*
* Returns:
* - This function doesn't return anything
*/
void deactivatePreload(void);
#endif
PK
k"P]q src/413_etc_control.c/*
* 413_pwm.c
* Pwm source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_etc_control.h"
/**
* This functions inits the ETC circuit for handle the ETC motor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_etcControl(void)
{
ETC_MOTOR_TRIS = OUTPUT;
ETC_MOTOR_ANSEL = DIGITAL;
}
/**
* This functions enables the motor of the ETC system
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
inline void etcMotorON(void)
{
ETC_MOTOR_LAT = 1;
}
/**
* This functions disables the motor of the ETC system
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
inline void etcMotorOFF(void)
{
ETC_MOTOR_LAT = 0;
}
PK
:k"POf} } src/413_etc_control.h/*
* 413_etc_control.h
* Pwm header file
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_ETC_CONTROL_H
#define _P413_ETC_CONTROL_H
#include "413_config.h"
// Defines for the control of the ETC
#define ETC_MOTOR_TRIS TRISEbits.TRISE5
#define ETC_MOTOR_ANSEL ANSELEbits.ANSELE5
#define ETC_MOTOR_LAT LATEbits.LATE5
/**
* This functions inits the ETC circuit for handle the ETC motor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_etcControl(void);
/**
* This functions enables the motor of the ETC system
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
inline void etcMotorON(void);
/**
* This functions disables the motor of the ETC system
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
inline void etcMotorOFF(void);
#endifPK
-#P o|H H src/413_global_variables.h/*
* 413_global_variables.h
* Global variables
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_GLOBAL_VARIABLES_H
#define _P413_GLOBAL_VARIABLES_H
volatile uint8_t global_steeringWheelClutch, global_plausability1,
global_plausability2, global_plausability3, global_plausability4,
global_suspension1, global_suspension2, global_suspension3,
global_suspension4, global_oilPressure, global_oilTemperature,
global_fuel, global_hydraulic, global_airPressure, global_etc1,
global_etc2, global_tps1, global_tps2, global_actual_gear = 0,
global_rpm, global_active_segments = 0, global_water_temperature,
global_wheel1, global_wheel2, global_wheel3, global_wheel4;
#endifPK
#P src/413_main.c/*
* 413_main.c
* Main source code of the 413 project
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_config.h"
#include "413_adc.h"
#include "413_system.h"
#include "413_mcp.h"
#include "413_timer_interrupt.h"
#include "413_clutch_gear.h"
#include "413_security.h"
#include "413_etc_control.h"
#include "413_global_variables.h"
/**
* Main bucle
*/
void main (void)
{
// CAN variables
uint8_t canFrame = 0, dataToSend[8], receivedData[8], receivedBytes;
// Initialize the oscillator system
init_OSC();
// Init the security relays of the car
init_security();
// Init the ETC motor control
init_etcControl();
// Initialize the clutch and gear system
init_clutch_gear();
// Init the ports to the steering wheel
init_steeringWheel();
// Init the sensors systems
init_sensors();
// Init dashboard
init_dashboard();
// Initialize the bus CAN
init_Mcp( P413_CAN_ADDRESS );
// Initialize the interrupt of 1 millisecond
init_timerInterrupt();
// Set the address data for the RF System
dataToSend[7] = P413_CAN_ADDRESS;
// General loop
while(1)
{
// Check if the send buffer of the MCP is free
if ( canWeSendCANMessage() )
{
// Select which frame we will send now
switch (canFrame)
{
case 0:
dataToSend[0] = global_steeringWheelClutch;
dataToSend[1] = global_plausability1;
dataToSend[2] = global_plausability2;
dataToSend[3] = global_plausability3;
dataToSend[4] = global_plausability4;
dataToSend[5] = global_suspension1;
break;
case 1:
dataToSend[0] = global_suspension2;
dataToSend[1] = global_suspension3;
dataToSend[2] = global_suspension4;
dataToSend[3] = global_oilPressure;
dataToSend[4] = global_oilTemperature;
dataToSend[5] = global_fuel;
break;
case 2:
dataToSend[0] = global_hydraulic;
dataToSend[1] = global_airPressure;
dataToSend[2] = global_etc1;
dataToSend[3] = global_etc2;
dataToSend[4] = global_tps1;
dataToSend[5] = global_tps2;
break;
case 3:
dataToSend[0] = global_wheel1;
dataToSend[1] = global_wheel2;
dataToSend[2] = global_wheel3;
dataToSend[3] = global_wheel4;
dataToSend[4] = global_rpm;
dataToSend[5] = global_water_temperature;
break;
default:
break;
}
// Identify the frame to the receiver
dataToSend[6] = canFrame;
// Send the information throught the CAN bus
send_CAN( dataToSend , 8 , RF_CAN_ADDRESS);
// Increment the canFrame variable to select next frame
if(++canFrame > 3)
canFrame = 0;
}
// Check if we received some message
if ( haveWeReceivedCANMessage() )
{
// Receive the information from the switchboard
receive_CAN( receivedData , &receivedBytes);
// Obtain the information
global_rpm = receivedData[0];
global_water_temperature = receivedData[1];
}
// Active segments process
uint8_t hundreds = global_water_temperature/100;
uint8_t tens = (global_water_temperature- (hundreds*100))/10;
uint8_t units = global_water_temperature-(hundreds*100 + tens*10 );
switch ( global_active_segments )
{
case 0:
setNumberSegments ( global_actual_gear );
setTrisLedOnGear();
break;
case 1:
setNumberSegments( units );
setTrisLedTemperature1();
break;
case 2:
setNumberSegments( tens );
setTrisLedTemperature2();
break;
case 3:
setNumberSegments( hundreds );
setTrisLedTemperature3();
break;
default:
break;
}
setRpm( global_rpm / 4);
// Update the dashboard
updateDashboard();
}
}PK
ho'Pl,
src/413_mcp.c/*
* 413_mcp.c
* MCP2515 related functions source file
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*/
#include "413_mcp.h"
/**
* This function writes a MCP register using the microcontroller SPI
*/
static
void writeRegister(uint8_t memoryPos, uint8_t data)
{
enable_CS();
send_SPI(MCP_WRITE);
send_SPI(memoryPos);
send_SPI(data);
disable_CS();
}
/**
* This function reads a MCP register using the microcontroller SPI
*/
static
void readRegister(uint8_t memoryPos, uint8_t* data)
{
enable_CS();
send_SPI(MCP_READ);
send_SPI(memoryPos);
read_SPI(data);
disable_CS();
}
/**
* This function resets the MCP
*/
static
void resetMCP(void)
{
enable_CS();
send_SPI(MCP_RESET);
disable_CS();
}
/**
* This function initialize the CAN system throught the MCP driver
*/
void init_Mcp(uint16_t direction)
{
uint8_t data;
uint8_t directionL, directionH;
// Program the inputs for the fast flags
MCP_RX_FLAG_TRIS = INPUT;
MCP_TX_FLAG_TRIS = INPUT;
MCP_RX_FLAG_WPU = TRUE;
MCP_TX_FLAG_WPU = TRUE;
//Init the SPI module
init_SPI();
// Set the variables for send the direction of the system
directionL = (uint8_t)(direction & 0b00000111) << 5;
directionH = (uint8_t)(direction >> 3);
//Configure initial register of MCP
resetMCP();
writeRegister(MCP_CNF1, 0b01000100);
writeRegister(MCP_CNF2, 0b11110010);
writeRegister(MCP_CNF3, 0b00000100);
writeRegister(MCP_RXF0SIDH, directionH);
writeRegister(MCP_RXF0SIDL, directionL);
writeRegister(MCP_RXF0EID8, 0b00000000);
writeRegister(MCP_RXF0EID0, 0b00000000);
writeRegister(MCP_RXM0SIDH, 0b11111111);
writeRegister(MCP_RXM0SIDL, 0b00000000);
writeRegister(MCP_RXM0EID8, 0b00000000);
writeRegister(MCP_RXM0EID0, 0b00000000);
writeRegister(MCP_RXB0CTRL, 0b00100000);
writeRegister(MCP_RXB0CTRL, 0b01100000);
writeRegister(MCP_BFPCTRL, 0b00000000);
writeRegister(MCP_TXB0SIDL, 0b00000000);
writeRegister(MCP_CANINTE, 0b00000101);
// Wait for MCP ready status
do
{
writeRegister(MCP_CANCTRL, 0b00000000);
readRegister(MCP_CANCTRL, &data);
}while(data != 0b00000000);
}
/**
* This functions returns if we can send a new message
*/
inline uint8_t canWeSendCANMessage(void)
{
return (!MCP_TX_FLAG_PORT);
}
/**
* This functions check if the MCP received a message
*/
inline uint8_t haveWeReceivedCANMessage(void)
{
return (!MCP_RX_FLAG_PORT);
}
/**
* This functions send information to the CAN bus. The maximum bytes to send
* are 8
*/
uint8_t send_CAN(uint8_t *dataToSend, uint8_t nBytes, uint16_t direction)
{
// Declare internal variables
uint8_t data;
uint16_t errTimes;
uint8_t directionL, directionH;
// Cancel the lasts transmissions
readRegister(MCP_TXB0CTRL, &data);
writeRegister(MCP_TXB0CTRL, data&~MCP_START_TRANSMIT);
// Clear all the flags
readRegister(MCP_CANINTF, &data);
writeRegister(MCP_CANINTF, data & MCP_IS_RECEIVE_BUFFER_FULL);
readRegister(MCP_CANCTRL, &data);
writeRegister(MCP_CANCTRL, data | MCP_CANCTRL_ABAT);
writeRegister(MCP_CANCTRL, data & ~MCP_CANCTRL_ABAT);
// Clear the sending bit flag
writeRegister(MCP_TXB0CTRL, 0);
// Load the objective address
directionL = (uint8_t)(direction & 0b00000111) << 5;
directionH = (uint8_t)(direction >> 3);
writeRegister(MCP_TXB0SIDH, directionH);
writeRegister(MCP_TXB0SIDL, directionL);
// Set the total bytes we will send
writeRegister(MCP_TXB0DLC, nBytes);
// Set all the data registers
for(uint8_t i=0; i < nBytes; i++)
{
writeRegister(MCP_TXB0D0+i, *(dataToSend++));
}
// Start the transmissin
writeRegister(MCP_TXB0CTRL, MCP_START_TRANSMIT);
// Wait until the transmission ends.
// We will try 4000 times this process
errTimes = 0;
do
{
readRegister(MCP_TXB0CTRL, &data);
if( errTimes++ > 4000)
{
// Return error
return ERROR_DETECTED;
}
} while((data & MCP_START_TRANSMIT) != MCP_TRANSMIT_DONE);
// Clear the TX flag
readRegister(MCP_CANINTF, &data);
writeRegister(MCP_CANINTF, data & 0b11111011);
// Return no error
return NO_ERROR;
}
/**
* This functions receive information to the CAN bus. The maximum bytes to send
* are 8
*/
uint8_t receive_CAN(uint8_t *dataToFill, uint8_t *nBytes)
{
// Declare internal variables
uint8_t data;
uint16_t tryTimes;
// Clear the registers before check if we received a message
readRegister(MCP_CANINTF, &data);
writeRegister(MCP_CANINTF, data & MCP_INTERRUPT_FLAGS_RX_TX);
// Check if we received a byte 4000 times
tryTimes = 0;
do
{
// Read the flag
readRegister(MCP_CANINTF, &data);
if(tryTimes++ > 4000)
{
return ERROR_DETECTED;
}
}while(( data & MCP_IS_RECEIVE_BUFFER_FULL ) == MCP_BUFFER_EMPTY);
// Read the number of bytes we have receive
readRegister(MCP_RXB0DLC, nBytes);
// Read the data
for(uint8_t i=0; i < *nBytes; i++)
{
readRegister(MCP_RXB0DM+i, dataToFill);
dataToFill++;
}
// Clear the flag to receive new interruptions
writeRegister(MCP_CANINTF, 0);
readRegister(MCP_CANINTF, &data);
writeRegister(MCP_CANINTF, (data & ~MCP_IS_RECEIVE_BUFFER_FULL));
// Clear the fast flag indicator
readRegister(MCP_CANINTF, &data);
writeRegister(MCP_CANINTF, data & 0b11111110);
// Return no error
return NO_ERROR;
}PK
"PT}
src/413_mcp.h/*
* 413_mcp.h
* MCP2515 related functions header
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*/
#ifndef HERMES_MCP_H
#define HERMES_MCP_H
#include "413_config.h"
#include "413_spi.h"
//Order defines
#define MCP_WRITE 0x02
#define MCP_READ 0x03
#define MCP_RESET 0xC0
#define MCP_READ_STATUS 0xA0
#define MCP_RX_STATUS 0xB0
#define MCP_BIT_MODIFY 0x0A
//Action-bits defines
#define MCP_START_TRANSMIT 0x08
#define MCP_TRANSMIT_DONE 0x00
#define MCP_IS_RECEIVE_BUFFER_FULL 0x01
#define MCP_INTERRUPT_FLAGS_RX_TX 0x05
#define MCP_BUFFER_EMPTY 0x00
#define MCP_TRANSMISSIONS_ABORTED 0x00
//Memory position defines
#define MCP_BFPCTRL 0x0C
#define MCP_TXRTSCTRL 0x0D
#define MCP_CANSTAT 0x0E
#define MCP_CANCTRL 0x0F
#define MCP_CANCTRL_ABAT 0x10
#define MCP_TEC 0x1C
#define MCP_REC 0x1D
#define MCP_CNF3 0x28
#define MCP_CNF2 0x29
#define MCP_CNF1 0x2A
#define MCP_CANINTE 0x2B
#define MCP_CANINTF 0x2C
#define MCP_EFLG 0x2D
#define MCP_TXB0CTRL 0x30
#define MCP_TXB1CTRL 0x40
#define MCP_TXB2CTRL 0x50
#define MCP_RXB0CTRL 0x60
#define MCP_RXB1CTRL 0x70
#define MCP_RXF0SIDH 0x00
#define MCP_RXF0SIDL 0x01
#define MCP_RXF0EID8 0x02
#define MCP_RXF0EID0 0x03
#define MCP_RXM0SIDH 0x20
#define MCP_RXM0SIDH 0x20
#define MCP_RXM0SIDL 0x21
#define MCP_RXM0EID8 0x22
#define MCP_RXM0EID0 0x23
#define MCP_TXB0CTRK 0x30
#define MCP_TXB0SIDH 0x31
#define MCP_TXB0SIDL 0x32
#define MCP_TXB0DLC 0x35
#define MCP_TXB0D0 0x36
#define MCP_RXB0SIDH 0x61
#define MCP_RXB0SIDL 0x62
#define MCP_RXB0DLC 0x65
#define MCP_RXB0DM 0x66
// Define the interrupt external pins
#define MCP_RX_FLAG_TRIS TRISCbits.TRISC7
#define MCP_RX_FLAG_PORT PORTCbits.RC7
#define MCP_RX_FLAG_WPU WPUCbits.WPUC7
#define MCP_TX_FLAG_TRIS TRISCbits.TRISC2
#define MCP_TX_FLAG_PORT PORTCbits.RC2
#define MCP_TX_FLAG_WPU WPUCbits.WPUC2
// Define the 413 CAN address
#define P413_CAN_ADDRESS 0xAB
// Define the RF CAN address
#define RF_CAN_ADDRESS 69
/**
* This function initialize the CAN system throught the MCP driver
*
* Requires:
* - This function doesn't need any parameter
*
* Returns:
* - This functions needs a uint8_t variable with the bus direction of
* the system
*/
void init_Mcp(uint16_t direction);
/**
* This functions check if the MCP can send a message
*
* Requires:
* - This function doesn't need any parameter
*
* Returns:
* - This functions returns a uint8_t variable with TRUE if the MCP is able
* to send. FALSE otherwise
*/
inline uint8_t canWeSendCANMessage(void);
/**
* This functions check if the MCP received a message
*
* Requires:
* - This function doesn't need any parameter
*
* Returns:
* - This functions returns a uint8_t variable with TRUE if the MCP
* received a message. FALSE otherwise
*/
inline uint8_t haveWeReceivedCANMessage(void);
/**
* This functions send information to the CAN bus. The maximum bytes to send
* are 8
*
* Requires:
* - uint8_t pointer with the information to send
* - uint8_t with the number of bytes you will send
* - uint16_t direction with the bus CAN direction you will send the
* information
*
* Returns:
* - This functions returns a uint8_t variable with TRUE if the MCP was
* succesfully sending. FALSE otherwise
*/
uint8_t send_CAN(uint8_t *dataToSend, uint8_t nBytes, uint16_t direction);
/**
* This functions receive information to the CAN bus. The maximum bytes to send
* are 8
*
* Requires:
* - uint8_t pointer where the function will replenish the information
* - uint8_t with the number of bytes we received
*
* Returns:
* - This functions returns a uint8_t variable with TRUE if the MCP was
* succesfully receiving. FALSE otherwise
*/
uint8_t receive_CAN(uint8_t *dataToFill, uint8_t *nBytes);
#endifPK
mOY
src/413_pwm.c/*
* 413_pwm.c
* Pwm source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_pwm.h"
/**
* Initialize the timer interrupt
* This function generate an interrupt each millisecond
*/
void init_pwm(void)
{
// Programming ports
CLUTCH_OUT_TRIS = OUTPUT;
CLUTCH_OUT_ANSEL = DIGITAL;
CLUTCH_IN_TRIS = OUTPUT;
CLUTCH_IN_ANSEL = DIGITAL;
GEAR_OUT_TRIS = OUTPUT;
GEAR_OUT_ANSEL = DIGITAL;
/*
* Set TMR2
*/
// Timer Clock Source Selection Register
// Clock source is Fosc/4
T2CLKCON = 0x01;
// Timer Hardware Limit Control Register
// Bit 7 --> 0 <-- PSYNC - Timer Prescaler Synchronization Enable bit
// - Timer Prescaler Output is not synchronize FOSC/4
// Bit 6 --> 0 <-- CPOL - Timer Clock Polarity Selection bit
// - Rising edge input clock clocks timer/prescaler
// Bit 5 --> 0 <-- CSYNC - Timer Clock Synchronization Enable bit
// - ON bit is not synchronized to timer clock input
// Bit 4,3,2,1,0 >0< MODE - Timer Hardware Limit Control Register
// - Software gate
T2HLT = 0x00;
// Timer External Reset Signal Selection Register
// Bit 3,2,1,0 >0< RSEL - Timer External Reset Signal Selection Register
// - Not used in ths application
T2RST = 0x00;
// Timer Period Register
// Set to 0xF9 for reach 1KHz timer
T2PR = 0xF9;
// Timer Counter Register
// When this number reachs T2PR value, timer resets
T2TMR = 0x00;
// Clearing IF flag
PIR5bits.TMR2IF = 0;
// Timer2 Control Register
// Bit 7 --> 1 <-- ON - Timer On bit
// - Timer is on
// Bit 6,4,3 >0xE0< CKPS - Timer Clock Prescale Select bits
// - 1:64 Prescaler
// Bit 3,2,1,0 >0< OUTPS - Timer Output Postscaler Select bits
// - 1:1 Postcaler
T2CON = 0xE0;
/*
* Set PWM6
*/
// PWM Control Register
// Bit 7 --> 1 <-- EN - PWM Module Enable bit
// - PWM mode is enabled
// Bit 6 --> 0 <-- OUT - PWM Module Output Level When Bit is Read
// - Set to 0
// Bit 5 --> 0 <-- POL - PWM Output Polarity Select bit
// - PWM output is normal
PWM6CON = 0x80;
// PWM duty value //0x7CC0 -> 50%
PWM6DCH = 0x7C;
PWM6DCL = 0xC0;
// CCP Timers Control Register
// Bit 5,4 -> 0 <- P7TSEL - PWM7 Timer Selection bits
// - PWM7 based on TMR2
// Bit 3,2 -> 0 <- P6TSEL - PWM6 Timer Selection bits
// - PWM6 based on TMR2
// Bit 1,0 -> 0 <- CCP5 - CCP5 Timer Selection bits
// - This bit has no effect in this application
CCPTMRS1 = 0x00;
// Redirect the PWM6 module to the RE6
RE6PPS = 0x0A;
/*
* Set PWM7
*/
// PWM Control Register
// Bit 7 --> 1 <-- EN - PWM Module Enable bit
// - PWM mode is enabled
// Bit 6 --> 0 <-- OUT - PWM Module Output Level When Bit is Read
// - Set to 0
// Bit 5 --> 0 <-- POL - PWM Output Polarity Select bit
// - PWM output is normal
PWM7CON = 0x80;
// PWM duty value
PWM7DCH = 0x7C;
PWM7DCL = 0xC0;
// Redirect the PWM7 module to the RE4
RE4PPS = 0x0B;
/*
* Set PWM1
*/
// CCP Control Register
// Bit 7 --> 1 <-- EN - CCP Module Enable bit
// - CCP is enabled
// Bit 5 --> 0 <-- OUT - CCP Output Data bit (read-only)
// - Read-only bit
// Bit 4 --> 0 <-- FMT - CCPW (pulse-width) Value Alignment bit
// - Right-aligned format
// Bit 3,2,1,0 >0xC< MODE - CCP Mode Select bits
// - PWM Mode
CCP1CON = 0x8C;
// CCP Capture/Compare Time Base
// Not used in our application
CCPR1H = 0x00;
CCPR1L = 0x00;
// Select Timer 2 as reference for CCP1
CCPTMRS0bits.C1TSEL = 0x0;
// Redirect the CCP1 module to the RE3
RE3PPS = 0x05;
CCP1PPS = 0b00100011;
}
/**
* Sets the value for the PMW1
*/
void setPwm1(uint16_t value)
{
value &= 0x03FF;
// Load duty cycle value
if(CCP1CONbits.FMT)
{
value <<= 6;
CCPR1H = value >> 8;
CCPR1L = value;
}
else
{
CCPR1H = value >> 8;
CCPR1L = value;
}
}
/**
* Sets the value for the PMW6
*/
void setPwm6(uint16_t value)
{
// Writing to 8 MSBs of PWM duty cycle in PWMDCH register
PWM6DCH = (value & 0x03FC)>>2;
// Writing to 2 LSBs of PWM duty cycle in PWMDCL register
PWM6DCL = (value & 0x0003)<<6;
}
/**
* Sets the value for the PMW7
*/
void setPwm7(uint16_t value)
{
// Writing to 8 MSBs of PWM duty cycle in PWMDCH register
PWM7DCH = (value & 0x03FC)>>2;
// Writing to 2 LSBs of PWM duty cycle in PWMDCL register
PWM7DCL = (value & 0x0003)<<6;
}
PK
Y"P
src/413_pwm.h/*
* 413_pwm.h
* Pwm header file
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_PWM_H
#define _P413_PWM_H
#include "413_config.h"
// Define the ports for work with the PWM systems
#define CLUTCH_OUT_TRIS TRISEbits.TRISE6
#define CLUTCH_OUT_ANSEL ANSELEbits.ANSELE6
#define CLUTCH_IN_TRIS TRISEbits.TRISE4
#define CLUTCH_IN_ANSEL ANSELEbits.ANSELE4
#define GEAR_OUT_TRIS TRISEbits.TRISE3
#define GEAR_OUT_ANSEL ANSELEbits.ANSELE3
/**
* Initialize the pwm systems
* This function makes three PWM
* - PWM 6 - Port RE6
* - PWM 7 - Port RE4
* - CCP1 - Port RE3
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_pwm(void);
/**
* Sets the value for the PMW1
*
* Requires:
* - A uint16_t variable with the duty cycle
*
* Returns:
* - This function doesn't return anything
*/
void setPwm1(uint16_t value);
/**
* Sets the value for the PMW6
*
* Requires:
* - A uint16_t variable with the duty cycle
*
* Returns:
* - This function doesn't return anything
*/
void setPwm6(uint16_t value);
/**
* Sets the value for the PMW7
*
* Requires:
* - A uint16_t variable with the duty cycle
*
* Returns:
* - This function doesn't return anything
*/
void setPwm7(uint16_t value);
#endifPK
"P< src/413_security.c/*
* 413_security.c
* Security functions source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_security.h"
/**
* This function initialize the security system
*/
void init_security(void)
{
// Program the ports that controls the security system of the car
MOTOR_SUPPLY_CONTROL_TRIS = OUTPUT;
MOTOR_SUPPLY_CONTROL_ANSEL = DIGITAL;
MOTOR_SUPPLY_CONTROL_LAT = 1;
POWER_SUPPLY_CONTROL_TRIS = OUTPUT;
POWER_SUPPLY_CONTROL_ANSEL = DIGITAL;
POWER_SUPPLY_CONTROL_LAT = 1;
}
/**
* Cuts the motor power, and stops the power of the ETC motor. Once called, the
* system must be restarted to start again work
*/
void cutMotorPower(void)
{
MOTOR_SUPPLY_CONTROL_LAT = 0;
}
/**
* Cuts the motor power, and stops the power of the main rele. Once called, the
* system must be restarted to start again work
*/
void cutPowerSupply(void)
{
POWER_SUPPLY_CONTROL_LAT = 0;
}PK
"Pz src/413_security.h/*
* 413_adc.h
* Security functions header file
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_SECURITY_H
#define _P413_SECURITY_H
#include "413_config.h"
// Define the ports for the security of the system
#define MOTOR_SUPPLY_CONTROL_TRIS TRISEbits.TRISE7
#define MOTOR_SUPPLY_CONTROL_ANSEL ANSELEbits.ANSELE7
#define MOTOR_SUPPLY_CONTROL_LAT LATEbits.LATE7
#define POWER_SUPPLY_CONTROL_TRIS TRISFbits.TRISF2
#define POWER_SUPPLY_CONTROL_ANSEL ANSELFbits.ANSELF2
#define POWER_SUPPLY_CONTROL_LAT LATFbits.LATF2
/**
* This function initialize the security system
*
* Requires:
* - This function doesn't need any parameter
*
* Returns:
* - This function doesn't return anything
*/
void init_security(void);
/**
* Cuts the motor power, and stops the power of the ETC motor. Once called, the
* system must be restarted to start again work
*
* Requires:
* - This function doesn't need any parameter
*
* Returns:
* - This function doesn't return anything
*/
void cutMotorPower(void);
/**
* Cuts the motor power, and stops the power of the main rele. Once called, the
* system must be restarted to start again work
*
* Requires:
* - This function doesn't need any parameter
*
* Returns:
* - This function doesn't return anything
*/
void cutPowerSupply(void);
#endifPK
#Pyߡ src/413_sensors.c/*
* 413_sensors.c
* Sensors source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_sensors.h"
/**
* This function inits the sensors system. Also we will start the ADC system
* for read the values of the analog inputs
*/
void init_sensors(void)
{
// Init the ADC module
init_ADC();
// Program the GPIOs
WHEEL1_TRIS = INPUT;
WHEEL2_TRIS = INPUT;
WHEEL3_TRIS = INPUT;
WHEEL3_ANSEL = DIGITAL;
WHEEL4_TRIS = INPUT;
WHEEL4_ANSEL = DIGITAL;
}
/**
* This function returns the value of the plausability 4 value
*/
inline uint8_t getPlaysability4Value(void)
{
return getADCValue( P413_ADC_PLAUSABILITY_4 );
}
/**
* This function returns the value of the plausability 3 value
*/
inline uint8_t getPlaysability3Value(void)
{
return getADCValue( P413_ADC_PLAUSABILITY_3 );
}
/**
* This function returns the value of the plausability 2 value
*/
inline uint8_t getPlaysability2Value(void)
{
return getADCValue( P413_ADC_PLAUSABILITY_2 );
}
/**
* This function returns the value of the plausability 1 value
*/
inline uint8_t getPlaysability1Value(void)
{
return getADCValue( P413_ADC_PLAUSABILITY_1 );
}
/**
* This function returns the value of the suspension 1 value
*/
inline uint8_t getSuspension1Value(void)
{
return getADCValue( P413_ADC_SUSPENSION_1 );
}
/**
* This function returns the value of the suspension 2 value
*/
inline uint8_t getSuspension2Value(void)
{
return getADCValue( P413_ADC_SUSPENSION_2 );
}
/**
* This function returns the value of the suspension 3 value
*/
inline uint8_t getSuspension3Value(void)
{
return getADCValue( P413_ADC_SUSPENSION_3 );
}
/**
* This function returns the value of the suspension 4 value
*/
inline uint8_t getSuspension4Value(void)
{
return getADCValue( P413_ADC_SUSPENSION_4 );
}
/**
* This function returns the value of the oil pressure value
*/
inline uint8_t getOilPressureValue(void)
{
return getADCValue( P413_ADC_OIL_PRESSURE );
}
/**
* This function returns the value of the oil temperature value
*/
inline uint8_t getOilTemperatureValue(void)
{
return getADCValue( P413_ADC_OIL_TEMPERATURE );
}
/**
* This function returns the value of the fuel level value
*/
inline uint8_t getFuelLevelValue(void)
{
return getADCValue( P413_ADC_FUEL );
}
/**
* This function returns the value of the hydraulic pressure value
*/
// Defines for calculadora the hydraulic pressure
#define AIR_PRESSURE_DEVIATION 65
#define AIR_PRESSURE_FACTOR 1.3
inline uint8_t getHydraulicPressureValue(void)
{
return (getADCValue( P413_ADC_HYDRAULIC ) - AIR_PRESSURE_DEVIATION) * AIR_PRESSURE_FACTOR;
}
/**
* This function returns the value of the hydraulic pressure value
*/
inline uint8_t getAirPressureValue(void)
{
return getADCValue( P413_ADC_AIR_PRESSURE );
}
/**
* This function returnsif we are detecting the wheel 1 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel1Sensor(void)
{
return WHEEL1_PORT;
}
/**
* This function returnsif we are detecting the wheel 2 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel2Sensor(void)
{
return WHEEL2_PORT;
}
/**
* This function returnsif we are detecting the wheel 3 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel3Sensor(void)
{
return WHEEL3_PORT;
}
/**
* This function returnsif we are detecting the wheel 4 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel4Sensor(void)
{
return WHEEL4_PORT;
}PK
#P̮t t src/413_sensors.h/*
* 413_sensors.h
* Sensors related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_SENSORS_H
#define _P413_SENSORS_H
#include "413_config.h"
#include "413_adc.h"
// Define of the GPIOs
#define WHEEL1_TRIS TRISCbits.TRISC1
#define WHEEL1_PORT PORTCbits.RC1
#define WHEEL2_TRIS TRISHbits.TRISH0
#define WHEEL2_PORT PORTHbits.RH0
#define WHEEL3_TRIS TRISAbits.TRISA2
#define WHEEL3_ANSEL ANSELAbits.ANSELA2
#define WHEEL3_PORT PORTAbits.RA2
#define WHEEL4_TRIS TRISAbits.TRISA3
#define WHEEL4_ANSEL ANSELAbits.ANSELA3
#define WHEEL4_PORT PORTAbits.RA3
/**
* This function inits the sensors system. Also we will start the ADC system
* for read the values of the analog inputs
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_sensors(void);
/**
* This function returns the value of the plausability 4 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* plausability4. Remember this functions is obtained by the ADC module
*/
inline uint8_t getPlaysability4Value(void);
/**
* This function returns the value of the plausability 3 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* plausability3. Remember this functions is obtained by the ADC module
*/
inline uint8_t getPlaysability3Value(void);
/**
* This function returns the value of the plausability 2 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* plausability2. Remember this functions is obtained by the ADC module
*/
inline uint8_t getPlaysability2Value(void);
/**
* This function returns the value of the plausability 1 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* plausability1. Remember this functions is obtained by the ADC module
*/
inline uint8_t getPlaysability1Value(void);
/**
* This function returns the value of the suspension 1 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* suspension1. Remember this functions is obtained by the ADC module
*/
inline uint8_t getSuspension1Value(void);
/**
* This function returns the value of the suspension 2 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* suspension2. Remember this functions is obtained by the ADC module
*/
inline uint8_t getSuspension2Value(void);
/**
* This function returns the value of the suspension 3 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* suspension3. Remember this functions is obtained by the ADC module
*/
inline uint8_t getSuspension3Value(void);
/**
* This function returns the value of the suspension 4 value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* suspension4. Remember this functions is obtained by the ADC module
*/
inline uint8_t getSuspension4Value(void);
/**
* This function returns the value of the oil pressure value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* oil pressure. Remember this functions is obtained by the ADC module
*/
inline uint8_t getOilPressureValue(void);
/**
* This function returns the value of the oil temperature value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* oil temperature. Remember this functions is obtained by the ADC module
*/
inline uint8_t getOilTemperatureValue(void);
/**
* This function returns the value of the fuel level value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* fuel level. Remember this functions is obtained by the ADC module
*/
inline uint8_t getFuelLevelValue(void);
/**
* This function returns the value of the hydraulic pressure value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* hydraulic pressure. Remember this functions is obtained by the ADC
* module
*/
inline uint8_t getHydraulicPressureValue(void);
/**
* This function returns the value of the hydraulic pressure value
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with the state of the
* hydraulic pressure. Remember this functions is obtained by the ADC
* module
*/
inline uint8_t getAirPressureValue(void);
/**
* This function returnsif we are detecting the wheel 1 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel1Sensor(void);
/**
* This function returnsif we are detecting the wheel 2 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel2Sensor(void);
/**
* This function returnsif we are detecting the wheel 3 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel3Sensor(void);
/**
* This function returnsif we are detecting the wheel 4 angle sensor
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function returns a uint8_t variable with TRUE if we have detected
* the sensor, and FALSE otherwise
*/
inline uint8_t getWheel4Sensor(void);
#endifPK
+O*>` `
src/413_spi.c/*
* 413_spi.c
* SPI source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_spi.h"
/**
* Initialize SPI peripheral
*/
void init_SPI(void)
{
// Peripheral Input Selection for SSP1 CLK
// PORTC -> 0b010 <--
// PIN 4 -> 0b100 <--
SSP1CLKPPS = 0b00010100;
// Peripheral Input Selection for SSP1 DAT IN
// PORTC -> 0b010 <--
// PIN 3 -> 0b011 <--
SSP1DATPPS = 0b00010011;
// Peripheral Input Selection for SSP1 DAT OUT
// PORTC -> 0b010 <--
// PIN 5 -> 0b101 <--
SSP1SSPPS = 0b00010101;
// Set RC4 Source selection as SCK
RC4PPS = 0x19;
// Set RC5 Source selection as SDO
RC5PPS = 0x1A;
// MSSP Status Register
// Bit 7 --> 0 <-- SMP - Slew Rate Control bit
// - Input data is sampled at the middle
// Bit 6 --> 1 <-- CKE - Clock select bit
// - Transmit active to Idle clock state
// Bit 5 --> 0 <-- D/A - Data/Address bit
// - No used for SPI communication
// Bit 4 --> 0 <-- P - Stop Bit
// - No used for SPI communication
// Bit 3 --> 0 <-- S - Start bit
// - No used for SPI communication
// Bit 2 --> 0 <-- R/W - Read/Write Information
// - No used for SPI communication
// Bit 1 --> 0 <-- UA - Update Address bit
// - No used for SPI communication
// Bit 0 --> 0 <-- BF - Buffer Full Status bit
// - Don't care, just a read register
SSP1STAT = 0x40;
// MSSP Control Register 1
// Bit 7 --> 0 <-- WCOL - Write Collision Detect bit
// - Input data is sampled at the middle
// Bit 6 --> 1 <-- SSPOV - Receive Overflow Indicator bitt
// - Don't care this bit
// Bit 5 --> 0 <-- SSPEN - Master Synchronous Serial Port Enable bit
// - Enables the serial port
// Bit 4 --> 0 <-- CKP - SCK Release Control bit
// - Idle state for the clock is a low level
// Bit 3,2,1,0 >0< SSPM - Master Synchronous Serial Port Mode Select bits
// - SPI Master mode: Clock = Fosc/64
SSP1CON1 = 0x02;
// MSSP Baud Rate Divider and Address Register
// Divide 16Mhz between 16 to set 1MHz
SSP1ADD = 16;
// Configure the ports
CS_TRIS = OUTPUT;
CS_ANSEL = DIGITAL;
CS_LAT = FALSE;
SO_TRIS = OUTPUT;
SI_TRIS = INPUT;
SCK_TRIS = OUTPUT;
}
/**
* SPI send byte function
* Be careful: is a block function. Returns when the transfer ends
*/
void send_SPI(uint8_t dataToSend)
{
// Clean the collision bit
SSP1CON1bits.WCOL = 0;
// Put the byte to send
SSP1BUF = dataToSend;
// Wait until we send the byte
while(!SSP1STATbits.BF);
}
/**
* SPI receive function
* Be careful: is a block function. Returns when the transfer ends
*/
void read_SPI(uint8_t *dataToFill)
{
uint8_t dummy;
// Clean the collision bit
SSP1CON1bits.WCOL = 0;
// Send a dummy info
SSP1BUF = dummy;
// Wait until we receive the byte
while(!SSP1STATbits.BF);
// Replenish the variable with the received byte
*dataToFill = SSP1BUF;
}
/**
* This function enables the CS of the target system (in this project there
* is only one extra system
*/
inline void enable_CS()
{
CS_LAT = TRUE;
}
/**
* This function disables the CS of the target system (in this project there
* is only one extra system
*/
inline void disable_CS()
{
CS_LAT = FALSE;
}
PK
&Og<
src/413_spi.h/*
* 413_spi.h
* SPI related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_SPI_H
#define _P413_SPI_H
#include "413_config.h"
// Ports definition
// Chip select
#define CS_TRIS TRISAbits.TRISA6
#define CS_PORT PORTAbits.RA6
#define CS_ANSEL ANSELAbits.ANSELA6
#define CS_LAT LATAbits.LATA6
// Data out
#define SO_TRIS TRISCbits.TRISC5
#define SO_PORT PORTCbits.RC5
#define SO_LAT LATCbits.LATC5
// Data in
#define SI_TRIS TRISCbits.TRISC3
#define SI_PORT PORTCbits.RC3
#define SI_LAT LATCbits.LATC3
// Clock
#define SCK_TRIS TRISCbits.TRISC4
#define SCK_PORT PORTCbits.RC4
#define SCK_LAT LATCbits.LATC4
/**
* Initialize SPI peripheral
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_SPI(void);
/**
* SPI send byte function
* Be careful: is a block function. Returns when the transfer ends
*
* Requires:
* - A uint8_t variable with the byte to send
*
* Returns:
* - This function doesn't return anything
*/
void send_SPI(uint8_t dataToSend);
/**
* SPI receive function
* Be careful: is a block function. Returns when the transfer ends
*
* Requires:
* - A pointer to a uint8_t variable with the information to fill
*
* Returns:
* - This function doesn't return anything
*/
void read_SPI(uint8_t *dataToFill);
/**
* This function enables the CS of the target system (in this project there
* is only one extra system
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
inline void enable_CS();
/**
* This function disables the CS of the target system (in this project there
* is only one extra system
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
inline void disable_CS();
#endifPK
|"PJW W src/413_steering_wheel.c/*
* 413_steering_wheel.c
* Functions related with the steering wheel
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_steering_wheel.h"
/**
* This function inits the steering wheel functions. With that we will be able
* to know which buttons are pressing the pilot. This functions must be called
* once before call the other functions of the steering wheel
*/
void init_steeringWheel(void)
{
BUTTON_1_TRIS = INPUT;
BUTTON_2_TRIS = INPUT;
BUTTON_2_ANSEL = DIGITAL;
BUTTON_3_TRIS = INPUT;
BUTTON_3_ANSEL = DIGITAL;
BUTTON_4_TRIS = INPUT;
BUTTON_4_ANSEL = DIGITAL;
BUTTON_UP_TRIS = INPUT;
BUTTON_UP_ANSEL = DIGITAL;
BUTTON_DOWN_TRIS = INPUT;
BUTTON_DOWN_ANSEL = DIGITAL;
}
/**
* This function returns the state of the button 1 of the steering wheel
*/
inline uint8_t getButton1(void)
{
return BUTTON_1_PORT;
}
/**
* This function returns the state of the button 2 of the steering wheel
*/
inline uint8_t getButton2(void)
{
return BUTTON_2_PORT;
}
/**
* This function returns the state of the button 3 of the steering wheel
*/
inline uint8_t getButton3(void)
{
return BUTTON_3_PORT;
}
/**
* This function returns the state of the button 4 of the steering wheel
*/
inline uint8_t getButton4(void)
{
return BUTTON_4_PORT;
}
/**
* This function returns the state of the gear up button of the steering wheel
*/
inline uint8_t getGearUpButton(void)
{
return BUTTON_UP_PORT;
}
/**
* This function returns the state of the gear down button of the steering wheel
*/
inline uint8_t getGearDownButton(void)
{
return BUTTON_DOWN_PORT;
}
/**
* This function returns the value of the clutch in the steering wheel
*/
// Defines for process the value of the clutch
#define CLUTCH_DEVIATION 50
#define CLUTCH_FACTOR 1.8
inline uint8_t getClutchValue(void)
{
return (getADCValue( P413_ADC_STEERING_WHEEL_CLUTCH ) - CLUTCH_DEVIATION) * CLUTCH_FACTOR;
}PK
qp'P
/u u src/413_steering_wheel.h/*
* 413_steering_wheel.h
* Steering wheel related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_STEERING_WHEEL_H
#define _P413_STEERING_WHEEL_H
#include "413_config.h"
#include "413_adc.h"
// Ports definition
#define BUTTON_1_TRIS TRISHbits.TRISH3
#define BUTTON_1_PORT PORTHbits.RH3
#define BUTTON_2_TRIS TRISDbits.TRISD2
#define BUTTON_2_ANSEL ANSELDbits.ANSELD2
#define BUTTON_2_PORT PORTDbits.RD2
#define BUTTON_3_TRIS TRISDbits.TRISD7
#define BUTTON_3_ANSEL ANSELDbits.ANSELD7
#define BUTTON_3_PORT PORTDbits.RD7
#define BUTTON_4_TRIS TRISDbits.TRISD4
#define BUTTON_4_ANSEL ANSELDbits.ANSELD4
#define BUTTON_4_PORT PORTDbits.RD4
#define BUTTON_UP_TRIS TRISDbits.TRISD5
#define BUTTON_UP_ANSEL ANSELDbits.ANSELD5
#define BUTTON_UP_PORT PORTDbits.RD5
#define BUTTON_DOWN_TRIS TRISDbits.TRISD6
#define BUTTON_DOWN_ANSEL ANSELDbits.ANSELD6
#define BUTTON_DOWN_PORT PORTDbits.RD6
// Time for the fuel preload
#define PRELOAD_TIME_MS 4000
/**
* This function inits the steering wheel functions. With that we will be able
* to know which buttons are pressing the pilot. This functions must be called
* once before call the other functions of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_steeringWheel(void);
/**
* This function returns the state of the button 1 of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns a uint8_t variable with TRUE if the button is pressed. FALSE
* otherwise
*/
inline uint8_t getButton1(void);
/**
* This function returns the state of the button 2 of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns a uint8_t variable with TRUE if the button is pressed. FALSE
* otherwise
*/
inline uint8_t getButton2(void);
/**
* This function returns the state of the button 3 of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns a uint8_t variable with TRUE if the button is pressed. FALSE
* otherwise
*/
inline uint8_t getButton3(void);
/**
* This function returns the state of the button 4 of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns a uint8_t variable with TRUE if the button is pressed. FALSE
* otherwise
*/
inline uint8_t getButton4(void);
/**
* This function returns the state of the gear up button of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns a uint8_t variable with TRUE if the button is pressed. FALSE
* otherwise
*/
inline uint8_t getGearUpButton(void);
/**
* This function returns the state of the gear down button of the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns a uint8_t variable with TRUE if the button is pressed. FALSE
* otherwise
*/
inline uint8_t getGearDownButton(void);
/**
* This function returns the value of the clutch in the steering wheel
*
* Requires:
* - This function no requires anything
*
* Returns:
* - Returns TRUE if the button is pressed. FALSE otherwise
*/
inline uint8_t getClutchValue(void);
#endifPK
{O G
src/413_system.c/*
* 413_adc.h
* System related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*/
#include "413_system.h"
/**
* This functions inits the ADC module of the microcontroller. The programmer must
* do this function before try an ADC conversion
*/
void init_OSC(void)
{
// Oscillator Control Register1
// Bit 6,5,4 ->0x4<- NOSC - New Oscillator Source Request bits
// - HFINTOSC
//Bit 3,2,1,0->0x0<- NDIV - New Divider Selection Request bits
// - No divider
OSCCON1 = 0x60;
// Oscillator Control Register 3
// Bit 7 --> 0 <-- CSWHOLD - Clock Switch Hold bit
// - Clock switch may proceed when the oscillator
// selected by NOSC is ready; when NOSCR
// becomes ?1?, the switch will occur
// Bit 6 --> 0 <-- SOSCPWR - Secondary Oscillator Power Mode Select bit
// - Secondary oscillator operating in Low-Power
// Bit 4 --> 0 <-- ORDY - Oscillator Ready bit
// - Read only bit. No used
// Bit 3 --> 0 <-- NOSCR - New Oscillator is Ready bit
// - Read only bit. No used
OSCCON3 = 0x00;
// Oscillator Manual Enable Register
// Bit 7 --> 0 <-- EXTOEN - External Oscillator Manual Request Enable bit
// - EXTOSC is enabled if requested by peripheral
// Bit 6 --> 0 <-- HFOEN - HFINTOSC Oscillator Manual Request Enable bit
// - HFINTOSC is enabled if requested by peripheral
// Bit 5 --> 0 <-- MFOEN - Oscillator Manual Request Enable bit
// - MFINTOSC is enabled if requested by peripheral
// Bit 4 --> 0 <-- LFOEN - Oscillator Manual Request Enable bit
// - LFINTOSC is enabled if requested by peripheral
// Bit 3 --> 0 <-- SOSCEN - Secondary Oscillator Manual Request Enable bit
// - Secondary Oscillator is enabled if requested
// Bit 2 --> 0 <-- ADOEN - ADC Oscillator Manual Request Enable bit
// - ADC oscillator is enabled if requested
OSCEN = 0x00;
// HFINTOSC Frequency Selection Register
// 64MHz selected
OSCFRQ = 0x08;
// HFINTOSC Tuning Register
// Default frequency value
OSCTUNE = 0x00;
}
PK
"P src/413_system.h/*
* 413_adc.h
* System configuration related functions
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_SYSTEM_H
#define _P413_SYSTEM_H
#include "413_config.h"
#include "413_dashboard.h"
/**
* This functions inits the oscillator of the microcontroller
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function don't return anything
*/
void init_OSC(void);
#endifPK
5)PuL uL src/413_timer_interrupt.c/*
* 413_timer_interrupt.c
* Timer interrupt source code
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#include "413_timer_interrupt.h"
/**
* ETC and TPS VALUES
*/
#define ETC_1_DEVIATION 50
#define ETC_1_FACTOR 1.2
#define ETC_2_DEVIATION 89
#define ETC_2_FACTOR 1.3
#define TPS_1_DEVIATION 12
#define TPS_1_FACTOR 1.7
#define TPS_2_DEVIATION 36
#define TPS_2_FACTOR 1.2
// Clutch defines
#define MINIMUM_CLUTCH_DEVIATION 4
#define CLUTCH_AT_MINIMUM 5
#define CLUTCH_AT_MAXIMUM 95
#define CLUTCH_MOVING_UP_VALUE 80
#define CLUTCH_MOVING_DOWN_VALUE 60
#define CLUTCH_STOP 0
#define CLUTCH_MAXIMUM 100
/**
* Initialize the timer interrupt
* This function generate an interrupt each millisecond
*/
void init_timerInterrupt(void)
{
// ADC Control Register 1
// Bit 7 --> 0 <-- GE - Timer Gate Enable bit
// - Timer is always counting
// Bit 6 --> 0 <-- GPOL - Timer Gate Polarity bit
// - No used in this application
// Bit 5 --> 0 <-- GTM - Timer Gate Toggle Mode bit
// - Disable Tiger Gate mode
// Bit 4 --> 0 <-- GSPM - Timer Gate Single Pulse Mode bit
// - Time Gate pulse is disabled
// Bit 3 --> 0 <--GGO/DONE- Timer Gate Single Pulse Acquisition Status bit
// - Not used in this application
// Bit 2 --> 0 <-- GVAL - Timer Gate Current State bit
// - Not used in this application
T1GCON = 0x00;
// Timer Gate Source Selection Register
// Not used in this application
T1GATE = 0x00;
// Timer Clock Source Selection Register
// Clock source is Fosc
T1CLK = 0x02;
// Set the registers to set 1 millisecond
TMR1H = 0x06;
TMR1L = 0x00;
// Clearing IF flag before enabling the interrupt.
PIR5bits.TMR1IF = 0;
// Enabling TMR1 interrupt.
PIE5bits.TMR1IE = 1;
// ADC Control Register 1
// Bit 5,4 --> 0 <-- CKPS - Timer Input Clock Prescale Select bits
// - 1:1 Prescale
// Bit 2 --> 0 <-- SYNC - Timer External Clock Input Synchro Control bit
// - Synchronize external clock with system clock
// Bit 1 --> 0 <-- RD16 - 16-Bit Read/Write Mode Enable bit
// - Two 8-bit operations
// Bit 0 --> 1 <-- ON - Timer On bit
// - Enables the timer
T1CON = 0x01;
}
/**
* Timer 1 ISR
* This function do all the work
*/
static void _TMR1_ISR()
{
// Dcleare the local variables
uint8_t steeringWheelClutch, plausability4,
plausability3, plausability2, plausability1,
suspension1, suspension2, suspension3, suspension4,
oilPressure, oilTemperature, fuel, hydraulic,
airPressure, etc1, etc2, tps1, tps2;
// Variable for know the difference of the clutch
uint8_t clutchDifference;
static volatile uint8_t etc_etc_error_counter = 0;
static volatile uint8_t etc_tps_error_counter = 0;
static volatile uint8_t tps_tps_error_counter = 0;
static volatile uint8_t short_circuit_error_counter = 0;
static volatile uint8_t gear_up_flag = FALSE, gear_down_flag = FALSE;
static volatile uint8_t accel_during_gear_flag = FALSE;
static volatile uint16_t gear_process_counter = 0, fuel_pump_process = 0;
static volatile uint8_t gear_down_counter = 0, gear_up_counter = 0;
static volatile uint8_t fuel_pump_counter = 0, active_segments_counter = 0;
static volatile uint8_t button1_counter=0;
static volatile uint8_t wheel_counter = 0;
static volatile uint8_t wheel1_last = 0, wheel2_last = 0,
wheel3_last = 0, wheel4_last = 0;
static volatile uint8_t wheel1_counter = 0, wheel2_counter = 0,
wheel3_counter = 0, wheel4_counter = 0;
static volatile uint16_t show_errors_init = 3000;
// Set the timer again to wait 1 millisecond
TMR1H = 0x06;
TMR1L = 0x00;
// Clear the TMR1 interrupt flag and start again the count
PIR5bits.TMR1IF = 0;
// Capture the AD values
steeringWheelClutch = getClutchValue();
plausability4 = getPlaysability4Value();
plausability3 = getPlaysability3Value();
plausability2 = getPlaysability2Value();
plausability1 = getPlaysability1Value();
suspension1 = getSuspension1Value();
suspension2 = getSuspension2Value();
suspension3 = getSuspension3Value();
suspension4 = getSuspension4Value();
oilPressure = getOilPressureValue();
oilTemperature = getOilTemperatureValue();
fuel = getFuelLevelValue();
hydraulic = getHydraulicPressureValue();
airPressure = getAirPressureValue();
// Read the values for the ETC values
etc1 = getADCValue( P413_ADC_ETC_SENSOR1 );
etc2 = getADCValue( P413_ADC_ETC_SENSOR2 );
tps1 = getADCValue( P413_ADC_TPS_SENSOR1 );
tps2 = getADCValue( P413_ADC_TPS_SENSOR2 );
// Set the global variables
global_steeringWheelClutch = ( global_steeringWheelClutch >> 1 ) +
( steeringWheelClutch >> 1);
global_plausability4 = ( global_plausability4 >> 1 ) +
( plausability4 >> 1 );
global_plausability3 = ( global_plausability3 >> 1 ) +
( plausability3 >> 1);
global_plausability2 = ( global_plausability2 >> 1 ) +
( plausability2 >> 1);
global_plausability1 = ( global_plausability1 >> 1 ) +
( plausability1 >> 1 );
global_suspension1 = ( global_suspension1 >> 1) +
( suspension1 >> 1);
global_suspension2 = ( global_suspension2 >> 1) +
( suspension2 >> 1);
global_suspension3 = ( global_suspension3 >> 1) +
( suspension3 >> 1);
global_suspension4 = ( global_suspension4 >> 1) +
( suspension4 >> 1);
global_oilPressure = ( global_oilPressure >> 1 ) +
( oilPressure >> 1 );
global_oilTemperature = ( global_oilTemperature >> 1 ) +
( oilTemperature >> 1 );
global_fuel = ( global_fuel >> 1 ) + ( fuel >> 1 );
global_hydraulic = ( global_hydraulic >> 1 ) +
( hydraulic >> 1);
global_airPressure = ( global_airPressure >> 1 ) +
( airPressure >> 1 );
global_etc1 = ( global_etc1 >> 1 ) + ( etc1 >> 1);
global_etc2 = ( global_etc2 >> 1 ) + ( etc2 >> 1);
global_tps1 = ( global_tps1 >> 1 ) + ( tps1 >> 1 );
global_tps2 = ( global_tps2 >> 1 ) + ( tps2 >> 1 );
// Check for errors
// Check for some value error
// Oil pressure check
if ( global_oilPressure > OIL_PRESSURE_ERROR_VALUE)
setOilPressure( TRUE );
else
setOilPressure( FALSE );
// Oil temperature check
if ( global_oilTemperature > OIL_TEMPERATURE_ERROR_VALUE)
setOilTemperature( TRUE );
else
setOilTemperature( FALSE );
// Air pressure check
if ( global_airPressure < AIR_PRESSURE_ERROR_VALUE )
setAirPressure( TRUE );
else
setAirPressure( FALSE );
// Fuel level check
if ( global_fuel < FUEL_ERROR_VALUE )
setFuelLevel( TRUE );
else
setFuelLevel( FALSE );
// Water temperature check
if ( global_water_temperature > WATER_TEMPERATURE_ERROR_VALUE)
setWaterTemperature( TRUE );
else
setWaterTemperature( FALSE );
// If we started the system recently
if( show_errors_init != 0)
{
setFuelLevel( TRUE );
setAirPressure( TRUE );
setOilTemperature( TRUE );
setOilPressure( TRUE );
show_errors_init--;
}
// Check the actual gear
if ( checkNoGear() )
global_actual_gear = 0;
else if ( checkSecondGear() )
global_actual_gear = 2;
else if ( checkThirdGear() )
global_actual_gear = 3;
/**
* ETC Process
*/
// We will convert all the values in "%"
etc1 = (etc1 - ETC_1_DEVIATION) * ETC_1_FACTOR;
etc2 = (etc2 - ETC_2_DEVIATION) * ETC_2_FACTOR;
tps1 = (tps1 - TPS_1_DEVIATION) * TPS_1_FACTOR;
tps2 = (tps2 - TPS_2_DEVIATION) * TPS_2_FACTOR;
tps2 = 100 - tps2;
// Check for errors
// Check if there is an error between the etc sensors
if (etc1 > etc2 + 10 || etc2 > etc1 + 10)
etc_etc_error_counter++;
else
etc_etc_error_counter = 0;
// Check error between tps sensors
if (tps1 > tps2 + 10 || tps2 > tps1 + 10)
tps_tps_error_counter++;
else
tps_tps_error_counter = 0;
// Check error between tps and etc sensors
if (tps1 > etc1 + 10 || etc1 > tps1 + 10)
etc_tps_error_counter++;
else
etc_tps_error_counter = 0;
// Read the critical signals for check some short circuit
if ( etc1 < 10 || etc1 > 245 || etc2 < 10 || etc2 > 245 ||
tps1 < 10 || tps1 > 245 || tps2 < 10 || tps2 > 245 ||
hydraulic < 10 || hydraulic > 245 ||
steeringWheelClutch < 10 || steeringWheelClutch > 245)
short_circuit_error_counter++;
// Check for errors
if ( etc_etc_error_counter > 100 || tps_tps_error_counter > 100 )
{
cutMotorPower();
setEtcApps( TRUE );
}
if( etc_tps_error_counter > 200 || short_circuit_error_counter > 100)
{
cutPowerSupply();
setEtcApps( TRUE );
}
/**
* Process for check if the team wants reset the system
*/
if ( getButton1() )
button1_counter++;
else
button1_counter = 0;
if (button1_counter == 200)
asm("reset");
/***********************************************/
/****************CHANGE GEAR PROCESS************/
/***********************************************/
// If we are changing down the gear do not use the pilot pointer for ETC
if ( !gear_down_flag || accel_during_gear_flag )
{
// Check if we reach or not the position
if ( tps1 > etc1 )
etcMotorON();
else
etcMotorOFF();
}
else
// If we are doing the gear down process, don't care the normal ETC
// system
etcMotorON();
// Check if we are in the process of change the gear
if ( gear_down_flag || gear_up_flag )
{
// Increment the counter for the gear check
gear_process_counter++;
// Check if we are in the second step of changing the gear
if( gear_process_counter < 250)
{
if( !global_actual_gear && gear_up_flag)
{
activateCuttoff();
}
else
{
clutchIn( CLUTCH_MAXIMUM );
clutchOut( CLUTCH_STOP );
}
}
// Check if we are in the third step of changing the gear
else if ( gear_process_counter < 450 )
{
if ( gear_up_flag )
gearUp();
else
gearDown();
}
// Check if we are in the fourth step of changing the gear
else if ( gear_process_counter < 500 )
{
accel_during_gear_flag = TRUE;
}
// Check if we are in the fifth step of changing the gear
else if ( gear_process_counter < 650 )
{
gearMiddle();
}
// Check if we are in the sixth step of changing the gear
else if ( gear_process_counter < 1000 )
{
// Be sure we deactivate the cutoff
deactivateCuttoff();
// Since now, the system will be accelerated by the pilot
accel_during_gear_flag = FALSE;
// Mark gear up or gear down
if( gear_up_flag )
global_actual_gear++;
else
global_actual_gear--;
// Reset flags
gear_up_flag = FALSE;
gear_down_flag = FALSE;
// Save energy stopping the pressure of the gear system
gearNoPressure();
}
}
else
{
/***********************************************/
/*****************CLUTCH PROCESS****************/
/***********************************************/
// Calculate the clutch difference betweens the real position and the
// pilot position
if ( global_steeringWheelClutch > global_hydraulic )
clutchDifference = global_steeringWheelClutch - global_hydraulic;
else
clutchDifference = global_hydraulic - global_steeringWheelClutch;
// Check if we must actuate
if ( clutchDifference > MINIMUM_CLUTCH_DEVIATION )
{
// Actuate the clutch to the correct direction
if ( global_steeringWheelClutch < CLUTCH_AT_MINIMUM )
{
// Put air inside the clutch at maximum value
clutchIn( CLUTCH_STOP );
clutchOut( CLUTCH_MAXIMUM );
}
else if ( global_steeringWheelClutch > CLUTCH_AT_MAXIMUM )
{
// Throw agaw the air inside the clutch at maximum value
clutchIn( CLUTCH_MAXIMUM );
clutchOut( CLUTCH_STOP );
}
else
{
// We will reach this position if the pilot clutch is in a
// position outside the minimum or maximum
if ( global_steeringWheelClutch > global_hydraulic )
{
// Throw agaw the air inside the clutch
clutchIn( CLUTCH_MOVING_UP_VALUE );
clutchOut( CLUTCH_STOP );
}
else
{
// Put air into the clutch
clutchIn( CLUTCH_STOP );
clutchOut( CLUTCH_MOVING_DOWN_VALUE );
}
}
}
else
{
// We are close to the correct position, stop the work with the
// pressure in the clutch
clutchIn( CLUTCH_STOP );
clutchOut( CLUTCH_STOP );
}
/***********************************************/
/****************GEAR UP PROCESS****************/
/***********************************************/
// Check if we press gear up
if ( getGearUpButton() )
{
if( gear_up_counter++ > 100 )
gearNormalPressure();
if( global_actual_gear == 0 )
{
gear_down_flag = TRUE;
}
else
gear_up_flag = TRUE;
}
else
gear_up_counter = 0;
/***********************************************/
/****************GEAR DOWN PROCESS**************/
/***********************************************/
// Check if we press gear up
// Block if we have pressed for 100ms the button
if ( getGearDownButton() && global_actual_gear )
{
if( gear_down_counter++ > 100 )
{
// If we are going to do a gear down process while we are in the
// first gear, change for a gear up process with slow gear
// change
if ( global_actual_gear == 1 )
{
gear_up_flag = TRUE;
gearNeutralPressure();
}
else
{
gear_down_flag = TRUE;
gearNormalPressure();
}
}
}
// Reset the counter if the button is not pressed
else
gear_down_counter = 0;
}
// If we press the button for at least 200ms, start 4 seconds preload
if ( getPreloadButton() )
{
if ( fuel_pump_counter++ > 200 )
{
activatePreload();
fuel_pump_process = PRELOAD_TIME_MS;
}
}
// If we reached the 0 value, stop the preload
if ( !(fuel_pump_process--) )
deactivatePreload();
// Process for select the 7 segments to update
if ( ++active_segments_counter == 8)
{
active_segments_counter = 0;
if ( ++global_active_segments == 4)
global_active_segments = 0;
}
// Wheels process
// Once each 64 interrupts
if ( ++wheel_counter == 32 )
{
// Check if the number changed
if( wheel1_last != getWheel1Sensor())
{
wheel1_counter ++;
if ( wheel1_last )
{
global_wheel1 = wheel1_counter;
wheel1_counter = 0;
}
wheel1_last ^= 1;
}
if( wheel2_last != getWheel2Sensor())
{
wheel2_counter ++;
if ( wheel2_last )
{
global_wheel2 = wheel2_counter;
wheel1_counter = 0;
}
wheel2_last ^= 1;
}
if( wheel3_last != getWheel3Sensor())
{
wheel3_counter ++;
if ( wheel3_last )
{
global_wheel3 = wheel3_counter;
wheel3_counter = 0;
}
wheel3_last ^= 1;
}
if( wheel4_last != getWheel4Sensor())
{
wheel4_counter ++;
if ( wheel4_last )
{
global_wheel4 = wheel4_counter;
wheel4_counter = 0;
}
wheel4_last ^= 1;
}
wheel_counter = 0;
}
}
/**
* Interrupt vector
* Once there are an interrupt, the firmware goes to this function
*/
void __interrupt() INTERRUPT_InterruptManager (void)
{
// Interrupt handler
if(INTCONbits.PEIE == 1)
{
// Check for Timer 1 interrupt
if(PIE5bits.TMR1IE == 1 && PIR5bits.TMR1IF == 1)
{
_TMR1_ISR();
}
}
}
PK
"P-h src/413_timer_interrupt.h/*
* 413_timer_interrupt.h
* Timer interrupt header file
*
* Team:
* Dynamics UPC Manresa
*
* University:
* EPSEM
*
* Author:
* David Martn Serrano
*
*/
#ifndef _P413_TIMER_INTERRUPT_H
#define _P413_TIMER_INTERRUPT_H
#include "413_config.h"
#include "413_adc.h"
#include "413_clutch_gear.h"
#include "413_security.h"
#include "413_dashboard.h"
#include "413_etc_control.h"
#include "413_steering_wheel.h"
#include "413_sensors.h"
#include "413_global_variables.h"
/**
* Initialize the timer interrupt
* This function generate an interrupt each millisecond
*
* Requires:
* - This function no requires anything
*
* Returns:
* - This function doesn't return anything
*/
void init_timerInterrupt(void);
#endifPK
ꭘO $ 0 proj/
KVKVEUPK
O
$ 0 # proj/413FW.X/
xxKVPK
g*P $ 0 N proj/413FW.X/build/
F0PK
ꭘO $ 0 proj/413FW.X/debug/
VVVPK
ꭘO $ 0 proj/413FW.X/debug/default/
VVVPK
b*P $ 0 proj/413FW.X/dist/
xPK
ꭘO5
5
$ proj/413FW.X/Makefile
HٷVHٷVLVPK
쭘O $ 0 proj/413FW.X/nbproject/
E|hXE|hXVPK
l'Pw6 ) $ proj/413FW.X/nbproject/configurations.xml
L|WL|W"WPK
l'P| | * $ ݣ proj/413FW.X/nbproject/Makefile-default.mk
LWLWtWPK
l'PhP< < 2 $ proj/413FW.X/nbproject/Makefile-genesis.properties
TW TWE|hXPK
l'P{_ ' $ F# proj/413FW.X/nbproject/Makefile-impl.mk
ݣWݣW WPK
l'P| 0 $ + proj/413FW.X/nbproject/Makefile-local-default.mk
nMWnMWWPK
l'P! , $ 4 proj/413FW.X/nbproject/Makefile-variables.mk
1NW1NWcXPK
l'PޞͳM M + $ 5 proj/413FW.X/nbproject/Package-default.bash
MWMWaXPK
|O $ 0 ; proj/413FW.X/nbproject/private/
\\WPK
l'Pg+ 1 $ ; proj/413FW.X/nbproject/private/configurations.xml
RWRWeWPK
*PFq4 4 * $ ? proj/413FW.X/nbproject/private/private.xml
FGFG\PK
;OD6 " $ G proj/413FW.X/nbproject/project.xml
2
2
VPK
/"P $ 0 L src/
d
PK
pO"G:+ +
$ ?L src/413_adc.c
HڿHڿpgܻPK
Ҕ"P}Q
$ e src/413_adc.h
9uv9uvPK
|ON $ ct src/413_clutch_gear.c
JKIJKIZ{PK
vOJ $ src/413_clutch_gear.h
0H0H~PK
}O $ ј src/413_config.h
<<PK
u)PzUaz% z% $ src/413_dashboard.c
b}b}7NPK
)P}U}# }# $ j src/413_dashboard.h
ss0NPK
k"P]q $ src/413_etc_control.c
0Eh0EhꉰO$PK
:k"POf} } $ K src/413_etc_control.h
)iNg)iNgO$PK
-#P o|H H $ src/413_global_variables.h
П
П
PK
#P $ { src/413_main.c
((XwܻPK
ho'Pl,
$ src/413_mcp.c
=DZ=DZh@NPK
"PT}
$ 3 src/413_mcp.h
pv
pv
,NPK
mOY
$ C src/413_pwm.c
jBjB\sPK
Y"P
$ Y src/413_pwm.h
||@sPK
"P< $ _ src/413_security.c
mmTrPK
"Pz $ c src/413_security.h
%"%"8rPK
#Pyߡ $ i src/413_sensors.c
4K4KXc-PK
#P̮t t $ { src/413_sensors.h
Xc-PK
+O*>` `
$ K src/413_spi.c
`3&ɐ`3&ɐQЮO̼PK
&Og<
$ ֦ src/413_spi.h
uĐuĐBO̼PK
|"PJW W $ src/413_steering_wheel.c
,q,q'PK
qp'P
/u u $ L src/413_steering_wheel.h
+Z+Zb'PK
{O G
$ src/413_system.c
4~PK
"P $ A src/413_system.h
X1FVX1FVE (wPK
5)PuL uL $ src/413_timer_interrupt.c
f@y/f@y/ PK
"P-h $ 2 src/413_timer_interrupt.h
55PK / / T #