diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000000..81bae9acd6
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,7 @@
+version: 2
+
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/build-android.yaml b/.github/workflows/build-android.yaml
index 316faa0c2b..6a781ea42c 100644
--- a/.github/workflows/build-android.yaml
+++ b/.github/workflows/build-android.yaml
@@ -7,11 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'zulu'
java-version: '8'
- name: Test Compiler
@@ -24,7 +25,7 @@ jobs:
- name: Build Native Unit Tests as shared library
working-directory: ./unit_tests/
# we have a unit test of JNI thus we need to build shared library
- run: make -j4
+ run: make -j4 SANITIZE=no build/lib_rusefi_test
- name: Build Android
env:
@@ -34,19 +35,19 @@ jobs:
if [ "${{github.event_name}}" == "push" ]; then
bash ./gradlew build
else
- bash ./gradlew bundleDebug
+ bash ./gradlew bundleDebug test
fi
- name: Upload APK - release
if: ${{ github.event_name == 'push' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusEFI-release
path: ./android/app/build/outputs/apk/release/rusEFI-release.apk
- name: Upload APK - unsigned
if: ${{ github.event_name != 'push' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusEFI-release-unsigned
path: ./android/app/build/outputs/bundle/debug/rusEFI-debug.aab
diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml
index ce705e7ee9..db20f4fb32 100644
--- a/.github/workflows/build-firmware.yaml
+++ b/.github/workflows/build-firmware.yaml
@@ -23,6 +23,7 @@ jobs:
hellen72,
hellen81,
hellen88bmw,
+ hellen88bmw_avr,
hellen-nb1,
hellen-gm-e67,
hellenNA8_96,
@@ -81,7 +82,10 @@ jobs:
- build-target: hellen88bmw
folder: hellen/hellen88bmw
ini-file: rusefi_hellen88bmw.ini
- skip-rate: 90
+
+ - build-target: hellen88bmw_avr
+ folder: hellen/hellen88bmw
+ ini-file: rusefi_hellen88bmw.ini
- build-target: hellen-nb1
folder: hellen/hellen-nb1
@@ -244,14 +248,15 @@ jobs:
if: ${{ matrix.skip-rate && github.event_name != 'workflow_dispatch' }}
run: if (($(($RANDOM % 100)) < ${{ matrix.skip-rate }})); then echo "skip=true" >> $GITHUB_ENV; fi
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
if: ${{ env.skip != 'true' }}
with:
submodules: recursive
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
if: ${{ env.skip != 'true' }}
with:
+ distribution: 'zulu'
java-version: '8'
- name: Install multilib, mingw, sshpass and mtools
@@ -346,37 +351,44 @@ jobs:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && env.skip != 'true' }}
run: bash misc/jenkins/compile_other_versions/prepare_bundle.sh ${{matrix.build-target}} ${{matrix.ini-file}}
+ - name: Upload build elf
+ if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' && env.skip != 'true' }}
+ uses: actions/upload-artifact@v3
+ with:
+ name: rusefi_${{matrix.build-target}}.elf
+ path: ./firmware/build/rusefi.elf
+
- name: Upload build bin
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' && env.skip != 'true' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_${{matrix.build-target}}.bin
path: ./firmware/deliver/rusefi*.bin
- name: Upload build hex
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' && env.skip != 'true' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_${{matrix.build-target}}.hex
path: ./firmware/deliver/rusefi*.hex
- name: Upload build dfu
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' && env.skip != 'true' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_${{matrix.build-target}}.dfu
path: ./firmware/deliver/rusefi*.dfu
- name: Upload bundle
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && env.skip != 'true' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_bundle_${{matrix.build-target}}.zip
path: ./artifacts/rusefi_bundle*.zip
- name: Upload autoupdate bundle
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && env.skip != 'true' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_bundle_${{matrix.build-target}}_autoupdate.zip
path: ./artifacts/rusefi_bundle_${{matrix.build-target}}_autoupdate.zip
@@ -385,11 +397,12 @@ jobs:
build-primary-bundle:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
with:
submodules: recursive
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'zulu'
java-version: '8'
- name: Install multilib, mingw, and sshpass
@@ -442,14 +455,14 @@ jobs:
- name: Attach console junit results
if: always()
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: console primary junit
path: ./java_console/build/*.txt
- name: Upload primary bundle
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_bundle.zip
path: ./artifacts/rusefi_bundle.zip
diff --git a/.github/workflows/build-rusEFI-console.yaml b/.github/workflows/build-rusEFI-console.yaml
index 8fad26c64f..c1ae914022 100644
--- a/.github/workflows/build-rusEFI-console.yaml
+++ b/.github/workflows/build-rusEFI-console.yaml
@@ -7,12 +7,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'zulu'
java-version: '8'
- name: Test Compiler
@@ -22,8 +23,8 @@ jobs:
run: sudo apt-get install sshpass
- name: Generate Java (Antlr)
- working-directory: ./java_tools/configuration_definition
- run: ant antlr
+ working-directory: ./android
+ run: ./gradlew :config_definition:generateGrammarSource
- name: Print GCC version
working-directory: .
@@ -31,8 +32,8 @@ jobs:
- name: Build Native Unit Tests as shared library
working-directory: ./unit_tests/
-# we have a unit test of JNI thus we need to build shared library
- run: make -j4
+ # we have a unit test of JNI thus we need to build shared library
+ run: make -j4 SANITIZE=no build/lib_rusefi_test
- name: Test console
# at the moment 'jar' task does not depend on tests?! maybe because tests take some time?
@@ -45,7 +46,7 @@ jobs:
- name: Attach console junit results
if: always()
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: console junit
path: ./java_console/build/*.txt
diff --git a/.github/workflows/build-simulator.yaml b/.github/workflows/build-simulator.yaml
index 96598d90d3..b0505e212b 100644
--- a/.github/workflows/build-simulator.yaml
+++ b/.github/workflows/build-simulator.yaml
@@ -8,11 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
with:
submodules: recursive
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'zulu'
java-version: '8'
- name: Install multilib
@@ -43,11 +44,11 @@ jobs:
run: ./build/rusefi_simulator 10
- name: Upload built simulator
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: rusefi_simulator_linux
path: ./simulator/build/rusefi_simulator
- name: Configuration Definition CI, without pushing new .jar
- working-directory: ./java_tools/configuration_definition
- run: ant
+ working-directory: ./android
+ run: ./gradlew :config_definition:shadowJar
diff --git a/.github/workflows/build-tsplugin-body.yaml b/.github/workflows/build-tsplugin-body.yaml
index f525af201f..c9248f11ac 100644
--- a/.github/workflows/build-tsplugin-body.yaml
+++ b/.github/workflows/build-tsplugin-body.yaml
@@ -7,11 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'zulu'
java-version: '8'
- name: Test Compiler
diff --git a/.github/workflows/build-unit-tests.yaml b/.github/workflows/build-unit-tests.yaml
index 984d82c8f1..a51f2c9b56 100644
--- a/.github/workflows/build-unit-tests.yaml
+++ b/.github/workflows/build-unit-tests.yaml
@@ -11,7 +11,7 @@ jobs:
os: [ubuntu-20.04, macos-latest]
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
diff --git a/.github/workflows/gen-configs.yaml b/.github/workflows/gen-configs.yaml
index 0e6c90b6c4..fd8c5f684e 100644
--- a/.github/workflows/gen-configs.yaml
+++ b/.github/workflows/gen-configs.yaml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
diff --git a/.github/workflows/gen-diffs.yaml b/.github/workflows/gen-diffs.yaml
index 663f4d4af0..69c7dff60e 100644
--- a/.github/workflows/gen-diffs.yaml
+++ b/.github/workflows/gen-diffs.yaml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
diff --git a/.github/workflows/gen-docs.yaml b/.github/workflows/gen-docs.yaml
index ca70e759b1..8d90de1b59 100644
--- a/.github/workflows/gen-docs.yaml
+++ b/.github/workflows/gen-docs.yaml
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
diff --git a/.github/workflows/gen-ibom.yaml b/.github/workflows/gen-ibom.yaml
index 88e0735bf6..1f01c6962c 100644
--- a/.github/workflows/gen-ibom.yaml
+++ b/.github/workflows/gen-ibom.yaml
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
diff --git a/.github/workflows/gen-pinouts.yaml b/.github/workflows/gen-pinouts.yaml
index 658f2c351c..b7c7be1c04 100644
--- a/.github/workflows/gen-pinouts.yaml
+++ b/.github/workflows/gen-pinouts.yaml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
diff --git a/.github/workflows/hardware-ci.yaml b/.github/workflows/hardware-ci.yaml
index 8ccb47f376..7a87657b3d 100644
--- a/.github/workflows/hardware-ci.yaml
+++ b/.github/workflows/hardware-ci.yaml
@@ -28,7 +28,7 @@ jobs:
runs-on: ${{matrix.runs-on}}
steps:
- - uses: actions/checkout@v1
+ - uses: actions/checkout@v3
with:
submodules: recursive
@@ -74,8 +74,8 @@ jobs:
run: openocd -f "interface/stlink.cfg" -f "target/stm32f4x.cfg" -c init -c targets -c "reset halt" -c "flash erase_sector 0 0 11" -c "flash write_image "deliver/rusefi.bin" 0x08000000" -c "reset run" -c "shutdown"
- name: Generate Java (Antlr)
- working-directory: ./java_tools/configuration_definition
- run: ant antlr
+ working-directory: ./android
+ run: ./gradlew :config_definition:generateGrammarSource
# This both compiles and runs HW CI tests
- name: Run Hardware CI
diff --git a/.github/workflows/set-date.yaml b/.github/workflows/set-date.yaml
index 1d92fe369e..3e0a5935dc 100644
--- a/.github/workflows/set-date.yaml
+++ b/.github/workflows/set-date.yaml
@@ -17,7 +17,7 @@ jobs:
if: ${{ github.repository == 'rusefi/rusefi' }}
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
diff --git a/.github/workflows/sync-wiki.yaml b/.github/workflows/sync-wiki.yaml
index e171823a9f..70686c6136 100644
--- a/.github/workflows/sync-wiki.yaml
+++ b/.github/workflows/sync-wiki.yaml
@@ -25,7 +25,7 @@ jobs:
steps:
- name: Check out docs repo
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
fetch-depth: 0
repository: rusefi/rusefi_documentation
diff --git a/.gitmodules b/.gitmodules
index 3f4c53676e..380740fbec 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -45,3 +45,6 @@
path = java_console/luaformatter
url = https://github.com/rusefi/luaformatter
branch = prod
+[submodule "firmware/libfirmware"]
+ path = firmware/libfirmware
+ url = https://github.com/rusefi/libfirmware.git
diff --git a/README.md b/README.md
index 8317a57673..a6b0335403 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
+
GPL open-source DIY ECU
diff --git a/android/app/src/main/java/com/rusefi/app/DfuUpload.java b/android/app/src/main/java/com/rusefi/app/DfuUpload.java
index b2e4cf5a56..914f736772 100644
--- a/android/app/src/main/java/com/rusefi/app/DfuUpload.java
+++ b/android/app/src/main/java/com/rusefi/app/DfuUpload.java
@@ -50,7 +50,7 @@ public class DfuUpload {
mResultView.post(() -> mResultView.append("Downloaded! " + "\n"));
uncompressFile(localFullFile, localFolder, localDfuImageFileName, mResultView);
- } catch (IOException | KeyManagementException | NoSuchAlgorithmException e) {
+ } catch (IOException e) {
mResultView.post(() -> mResultView.append("Error downloading " + e + "\n"));
}
}
diff --git a/android/build.gradle b/android/build.gradle
index acfd9e6510..fb5d4f309e 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,10 +1,10 @@
buildscript {
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.0.0'
+ classpath 'com.android.tools.build:gradle:4.2.2'
}
}
@@ -13,7 +13,7 @@ apply from: 'dependencies.gradle'
allprojects {
repositories {
google()
- jcenter()
+ mavenCentral()
maven { url 'https://jitpack.io' }
}
@@ -27,4 +27,9 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
-}
\ No newline at end of file
+}
+
+// gradlew allDeps
+subprojects {
+ task allDeps(type: DependencyReportTask) {}
+}
diff --git a/android/dependencies.gradle b/android/dependencies.gradle
index 71534f85b7..538b7eccaf 100644
--- a/android/dependencies.gradle
+++ b/android/dependencies.gradle
@@ -1,11 +1,14 @@
ext {
libs = [
junit : "junit:junit:4.13",
+ mockito : "org.mockito:mockito-all:1.10.19",
annotations : "org.jetbrains:annotations:16.0.1",
javaxJson : "javax.json:javax.json-api:1.1.4",
snakeyaml : "org.yaml:snakeyaml:1.26",
jsr305 : "com.google.code.findbugs:jsr305:3.0.2",
- commons_logging: "commons-logging:commons-logging:1.2"
+ commons_logging: "commons-logging:commons-logging:1.2",
+ antlr : "org.antlr:antlr4:4.9.3", // use ANTLR version 4
+ json : "com.googlecode.json-simple:json-simple:1.1.1",
]
ts_plugin_libs = [
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e..f3d88b1c2f 100644
Binary files a/android/gradle/wrapper/gradle-wrapper.jar and b/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index a4debda318..2ec77e51a9 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Wed Jun 24 16:34:05 EDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/android/gradlew b/android/gradlew
index 9d82f78915..2fe81a7d95 100755
--- a/android/gradlew
+++ b/android/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,42 +22,6 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -60,6 +40,46 @@ cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -85,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -105,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -134,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ i=`expr $i + 1`
done
case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=`save "$@"`
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/android/gradlew.bat b/android/gradlew.bat
index 8a0b282aa6..9618d8d960 100644
--- a/android/gradlew.bat
+++ b/android/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +62,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +75,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/android/settings.gradle b/android/settings.gradle
index b116e02248..7299c0bb3d 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,6 +1,8 @@
include ':app'
include ':shared_io'
project(':shared_io').projectDir = new File('../java_console/shared_io')
+include ':shared_ui'
+project(':shared_ui').projectDir = new File('../java_console/shared_ui')
include ':ecu_io'
project(':ecu_io').projectDir = new File('../java_console/io')
include ':logging'
@@ -23,7 +25,9 @@ include ':enum_to_string'
project(':enum_to_string').projectDir = new File('../java_tools/enum_to_string')
include ':bin2header'
project(':bin2header').projectDir = new File('../java_tools/bin2header')
-// todo: uncomment me once works include ':config_definition'
-// todo: uncomment me once works project(':config_definition').projectDir = new File('../java_tools/configuration_definition')
+include ':config_definition'
+project(':config_definition').projectDir = new File('../java_tools/configuration_definition')
include ':ts_plugin_launcher'
-project(':ts_plugin_launcher').projectDir = new File('../java_tools/ts_plugin_launcher')
\ No newline at end of file
+project(':ts_plugin_launcher').projectDir = new File('../java_tools/ts_plugin_launcher')
+include ':ts_plugin'
+project(':ts_plugin').projectDir = new File('../java_tools/ts_plugin')
diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md
index 65ed6bc85c..7b7db6a8bd 100644
--- a/firmware/CHANGELOG.md
+++ b/firmware/CHANGELOG.md
@@ -23,9 +23,36 @@ Release template (copy/paste this for new release):
# Changelog
+## Unreleased
+
+### Added
+ - raw voltage gauges for Lua script aux analog inputs #4346
+ - microRusEFI and Proteus F4 have CAN OpenBLT bootloader #4199 #4230
+ - counter-noise measure for custom skipped trigger wheels #4375
+ - Write hard faults to backup ram, print on next boot #4324
+ - Many more options for Lua CAN rx filters/callbacks #4387
+ - Password protection against tune access #4243
+ - Additional CAN messages #4401
+
+### Fixed
+ - Lua CAN reception fixed for 11-bit IDs where the frame would be received, but a corrupt ID was passed to the handler function. #4321
+ - Many drop downs menues are now sorted #4339
+ - rusEFI TS plugin launcher fixed
+ - Console autoupdate error dialogs #4352
+ - custom skipped wheel could be located on camshaft #4377
+ - it's impossible to receive AcceleratorPedal sensor via CAN/Lua #4369
+ - MRE stepper disables LS2 control #4381
+
+### Removed
+ - ICU trigger input logic since it is unused in any current ECU #639
+ - Idle PID "offset" field, as this role is filled more effectively by the various open loop parameters.
+
+## July 2022 Release - "Day 130"
+
### Added
- verbose trigger sync should reuse engineSnifferRpmThreshold #4259
- Subaru EZ30 variation of 36/2/2/2 trigger
+ - Linux version of rusEFI simulator SocketCAN integration (#4312)
### Fixed
- Improved logic used to disambiguate trigger sync using cam/VVT information. Engine now runs in wasted spark until cam sync is achieved, at which point it switches to fully sequential. #4099
@@ -41,7 +68,6 @@ Release template (copy/paste this for new release):
- Advanced Trigger option: require engine phase synchronization in sequential mode #4151
- Maintainability: frequency sensors need a simple event counter in the logs #4173
- TS bench test commands are now configurable #4192
- - microRusEFI and Proteus F4 have CAN OpenBLT bootloader #4199
- microRusEFI can now use more pins for Cam position sensor #3032
- hard requirement for console version match #4187
diff --git a/firmware/ChibiOS b/firmware/ChibiOS
index 4a81e00519..cf74388693 160000
--- a/firmware/ChibiOS
+++ b/firmware/ChibiOS
@@ -1 +1 @@
-Subproject commit 4a81e00519e4b592176d974c37abc6249ab5294b
+Subproject commit cf743886935c39cbf2ca711e54e9e64238da6e57
diff --git a/firmware/Makefile b/firmware/Makefile
index 48c4d717f6..9c29458893 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -9,6 +9,10 @@ CHIBIOS = ChibiOS
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
RULESFILE = $(RULESPATH)/rules.mk
+ifneq ("$(wildcard $(../.git))","")
+$(error ../.git not found. We expect source code to be cloned not downloaded as zip file.")
+endif
+
include rusefi_rules.mk
# Define project name here
@@ -23,6 +27,10 @@ PCHSUB = firmware
# Imported source files and paths
CHIBIOS_CONTRIB = ChibiOS-Contrib
+# Configure libfirmware Paths/Includes
+RUSEFI_LIB = $(PROJECT_DIR)/libfirmware
+include $(RUSEFI_LIB)/util/util.mk
+
include rusefi.mk
# by default EXTRA_PARAMS is empty and we create 'debug' version of the firmware with additional assertions and statistics
@@ -209,6 +217,7 @@ endif
ifeq ($(USE_OPENBLT),yes)
# Reserve start of flash for OpenBLT
USE_OPT += -Wl,--defsym=BOOTLOADER=1
+ DDEFS += -DEFI_USE_OPENBLT=TRUE
endif
$(info PROJECT_BOARD: $(PROJECT_BOARD))
@@ -241,7 +250,8 @@ CPPSRC = \
$(HW_LAYER_DRIVERS_CORE_CPP) \
$(HW_LAYER_DRIVERS_CPP) \
$(CONSOLE_SRC_CPP) \
-rusefi.cpp \
+ $(RUSEFI_LIB_CPP) \
+ rusefi.cpp \
main.cpp
# C sources to be compiled in ARM mode regardless of the global setting.
@@ -266,7 +276,8 @@ TCPPSRC =
# List ASM source files here
ASMXSRC = $(ALLXASMSRC) \
- $(RUSEFIASM)
+ $(RUSEFIASM) \
+ main_hardfault_asm.S
#
# WARNING! order of variables is important here - for instance cypress own folders should go before default folders
@@ -279,6 +290,7 @@ INCDIR = \
$(BOOTLOADERINC) \
$(CHIBIOS)/os/various \
$(CHIBIOS)/os/hal/lib/peripherals/sensors \
+ $(RUSEFI_LIB_INC) \
$(CONFDIR) \
ext \
$(PROJECT_DIR)/hw_layer/mass_storage \
diff --git a/firmware/bootloader/src/Makefile b/firmware/bootloader/src/Makefile
index 22aacbfc44..cb450119aa 100644
--- a/firmware/bootloader/src/Makefile
+++ b/firmware/bootloader/src/Makefile
@@ -130,6 +130,10 @@ CHIBIOS = $(PROJECT_DIR)/ChibiOS
# todo: looks like 'CHIBIOS_CONTRIB' path is universal shall we defined it only once?
CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
+# Configure libfirmware Paths/Includes
+RUSEFI_LIB = $(PROJECT_DIR)/libfirmware
+include $(RUSEFI_LIB)/util/util.mk
+
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
RULESFILE = $(RULESPATH)/rules.mk
@@ -187,6 +191,7 @@ CPPSRC = $(ALLCPPSRC) \
$(PROJECT_DIR)/hw_layer/io_pins.cpp \
$(PROJECT_DIR)/util/efilib.cpp \
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
+ $(RUSEFI_LIB_CPP) \
src/rusefi_stubs.cpp \
src/dfu.cpp \
src/main.cpp
@@ -251,6 +256,7 @@ INCDIR = $(ALLINC) \
$(CONTROLLERS_INC) \
$(PROJECT_DIR)/controllers/sensors \
$(PROJECT_DIR)/init \
+ $(RUSEFI_LIB_INC) \
config
BUILDDIR=blbuild
diff --git a/firmware/config/boards/48way/board.h b/firmware/config/boards/48way/board.h
index 588a55bdcb..2e6d31f3aa 100755
--- a/firmware/config/boards/48way/board.h
+++ b/firmware/config/boards/48way/board.h
@@ -39,9 +39,6 @@
#undef EFI_CONSOLE_RX_BRAIN_PIN
#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::A10
-#undef EFI_USE_OSC
-#define EFI_USE_OSC TRUE
-
#undef EFI_CAN_SUPPORT
#define EFI_CAN_SUPPORT TRUE
diff --git a/firmware/config/boards/core8/board.h b/firmware/config/boards/core8/board.h
index 9d0f0758ce..b04202d280 100644
--- a/firmware/config/boards/core8/board.h
+++ b/firmware/config/boards/core8/board.h
@@ -39,9 +39,6 @@
#undef EFI_CONSOLE_RX_BRAIN_PIN
#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::A10
-#undef EFI_USE_OSC
-#define EFI_USE_OSC TRUE
-
#undef EFI_CAN_SUPPORT
#define EFI_CAN_SUPPORT TRUE
diff --git a/firmware/config/boards/hellen/alphax-2chan/readme.md b/firmware/config/boards/hellen/alphax-2chan/readme.md
new file mode 100644
index 0000000000..623f0c0d34
--- /dev/null
+++ b/firmware/config/boards/hellen/alphax-2chan/readme.md
@@ -0,0 +1 @@
+https://github.com/rusefi/alphax-2chan/
diff --git a/firmware/config/boards/hellen/alphax-4chan/readme.md b/firmware/config/boards/hellen/alphax-4chan/readme.md
new file mode 100644
index 0000000000..3576d841a4
--- /dev/null
+++ b/firmware/config/boards/hellen/alphax-4chan/readme.md
@@ -0,0 +1 @@
+https://github.com/rusefi/alphax-4chan/
diff --git a/firmware/config/boards/hellen/alphax-8chan/readme.md b/firmware/config/boards/hellen/alphax-8chan/readme.md
new file mode 100644
index 0000000000..e6d0ff2045
--- /dev/null
+++ b/firmware/config/boards/hellen/alphax-8chan/readme.md
@@ -0,0 +1 @@
+https://github.com/rusefi/alphax-8chan/
diff --git a/firmware/config/boards/hellen/compile_cypress.sh b/firmware/config/boards/hellen/compile_cypress.sh
index ed09fd22d9..85c69bbe3d 100644
--- a/firmware/config/boards/hellen/compile_cypress.sh
+++ b/firmware/config/boards/hellen/compile_cypress.sh
@@ -12,8 +12,6 @@ export EXTRA_PARAMS="-DDUMMY -D__USE_CMSIS\
-DCH_DBG_THREADS_PROFILING=FALSE\
"
-TRIGGER_USE_ADC = yes
-
export BUILDDIR="build"
export USE_FATFS="no"
export USE_BOOTLOADER="no"
diff --git a/firmware/config/boards/hellen/harley81/board.mk b/firmware/config/boards/hellen/harley81/board.mk
index 0fa0f2fdaa..2ea472ef45 100644
--- a/firmware/config/boards/hellen/harley81/board.mk
+++ b/firmware/config/boards/hellen/harley81/board.mk
@@ -12,7 +12,7 @@ DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE
DDEFS += -DFIRMWARE_ID=\"hellen81hd\"
DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
-DDEFS += -DSTM32_PWM_USE_TIM3=TRUE -DHAL_USE_ICU=FALSE
+DDEFS += -DSTM32_PWM_USE_TIM3=TRUE
include $(BOARDS_DIR)/hellen/hellen-common144.mk
diff --git a/firmware/config/boards/hellen/hellen-common.mk b/firmware/config/boards/hellen/hellen-common.mk
index 73208867c2..cd5518fcf9 100644
--- a/firmware/config/boards/hellen/hellen-common.mk
+++ b/firmware/config/boards/hellen/hellen-common.mk
@@ -11,6 +11,5 @@ DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
# We are running on Hellen-One hardware!
DDEFS += -DHW_HELLEN=1
-DDEFS += -DEFI_USE_OSC=TRUE
DDEFS += -DTS_NO_SECONDARY=TRUE
diff --git a/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp b/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp
index d427f79f64..5c4317bc30 100644
--- a/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp
+++ b/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp
@@ -94,6 +94,11 @@ void setBoardConfigOverrides() {
setupVbatt();
setHellenSdCardSpi3();
+ engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM7;
+ engineConfiguration->etbIo[0].directionPin2 = H144_OUT_PWM6;
+ engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1
+ engineConfiguration->etb_use_two_wires = true;
+
engineConfiguration->clt.config.bias_resistor = 4700;
engineConfiguration->iat.config.bias_resistor = 4700;
}
@@ -126,10 +131,6 @@ void setBoardDefaultConfiguration() {
// "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs();
- engineConfiguration->etbIo[0].directionPin1 = Gpio::D15; // out_pwm7
- engineConfiguration->etbIo[0].directionPin2 = Gpio::D14; // out_pwm6
- engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1
- engineConfiguration->etb_use_two_wires = true;
// Some sensible defaults for other options
setCrankOperationMode();
diff --git a/firmware/config/boards/hellen/hellen128/connectors/generated_ts_name_by_pin.cpp b/firmware/config/boards/hellen/hellen128/connectors/generated_ts_name_by_pin.cpp
index 6e7e948d7a..0b896d4353 100644
--- a/firmware/config/boards/hellen/hellen128/connectors/generated_ts_name_by_pin.cpp
+++ b/firmware/config/boards/hellen/hellen128/connectors/generated_ts_name_by_pin.cpp
@@ -6,9 +6,13 @@
// see comments at declaration in pin_repository.h
const char * getBoardSpecificPinName(brain_pin_e brainPin) {
switch(brainPin) {
+ case Gpio::A0: return "P36_IN_O2S";
+ case Gpio::A1: return "P32_IN_O2S2";
+ case Gpio::A2: return "P40_IN_MAP3";
case Gpio::A3: return "C24 - PPS1";
case Gpio::A4: return "E31 - TPS1";
case Gpio::A6: return "E40 - IN_CAM";
+ case Gpio::A7: return "P30_IN_AUX4";
case Gpio::A8: return "P18_OUT_PP2";
case Gpio::B0: return "E34 - TPS2";
case Gpio::B1: return "E37 - Crank Input";
@@ -17,6 +21,7 @@ const char * getBoardSpecificPinName(brain_pin_e brainPin) {
case Gpio::C2: return "E29 - Coolant Temp";
case Gpio::C3: return "E45 - IAT";
case Gpio::C4: return "C25 - PPS2";
+ case Gpio::C5: return "P41_IN_AUX3";
case Gpio::C9: return "P33_PWM5";
case Gpio::D10: return "E4 - LS4/VVT";
case Gpio::D11: return "E3 - LS3";
diff --git a/firmware/config/boards/hellen/hellen128/connectors/main.yaml b/firmware/config/boards/hellen/hellen128/connectors/main.yaml
index 2cef858246..0ec058425d 100644
--- a/firmware/config/boards/hellen/hellen128/connectors/main.yaml
+++ b/firmware/config/boards/hellen/hellen128/connectors/main.yaml
@@ -4,30 +4,33 @@ pins:
#extansion pins
#Analog inputs (via Test Points)
- pin: P30
- id: EFI_ADC_7
- class: analog_inputs
+ #PA7
+ id: [A7, EFI_ADC_7]
+ class: [switch_inputs, analog_inputs]
ts_name: P30_IN_AUX4
- pin: P32
- id: EFI_ADC_1
- class: analog_inputs
+ #PA1
+ id: [A1, EFI_ADC_1]
+ class: [switch_inputs, analog_inputs]
ts_name: P32_IN_O2S2
- pin: P36
- id: EFI_ADC_0
- class: analog_inputs
+ #PA0
+ id: [A0, EFI_ADC_0]
+ class: [switch_inputs, analog_inputs]
ts_name: P36_IN_O2S
- pin: P40
# H144_IN_MAP3 AIN15 A15 PA2
- id: EFI_ADC_2
- class: analog_inputs
+ id: [A2, EFI_ADC_2]
+ class: [switch_inputs, analog_inputs]
ts_name: P40_IN_MAP3
- pin: P41
# H144_IN_AUX3 AIN22 PC5
- id: EFI_ADC_15
- class: analog_inputs
+ id: [C5, EFI_ADC_15]
+ class: [switch_inputs, analog_inputs]
ts_name: P41_IN_AUX3
#Outputs (via Test Points)
diff --git a/firmware/config/boards/hellen/hellen154hyundai/readme.md b/firmware/config/boards/hellen/hellen154hyundai/readme.md
index a60741415c..4424c9d911 100644
--- a/firmware/config/boards/hellen/hellen154hyundai/readme.md
+++ b/firmware/config/boards/hellen/hellen154hyundai/readme.md
@@ -1 +1 @@
-https://rusefi.com/s/hellen121nissan
+https://rusefi.com/s/hellen154hyundai
diff --git a/firmware/config/boards/hellen/hellen72/board_configuration.cpp b/firmware/config/boards/hellen/hellen72/board_configuration.cpp
index 63fe9618af..2d636bee0e 100644
--- a/firmware/config/boards/hellen/hellen72/board_configuration.cpp
+++ b/firmware/config/boards/hellen/hellen72/board_configuration.cpp
@@ -101,9 +101,10 @@ void setBoardConfigOverrides() {
setHellenSdCardSpi2();
}
- engineConfiguration->etbIo[0].directionPin1 = Gpio::C7; // out_pwm3
- engineConfiguration->etbIo[0].directionPin2 = Gpio::C8; // out_pwm4
- engineConfiguration->etbIo[0].controlPin = Gpio::C6; // ETB_EN out_pwm2
+ // NB2 still uses L6205PD
+ engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM3; // ETB+
+ engineConfiguration->etbIo[0].directionPin2 = H144_OUT_PWM4; // ETB-
+ engineConfiguration->etbIo[0].controlPin = H144_OUT_PWM2; // ETB_EN
engineConfiguration->etb_use_two_wires = true;
engineConfiguration->clt.config.bias_resistor = 4700;
diff --git a/firmware/config/boards/hellen/hellen81/board.mk b/firmware/config/boards/hellen/hellen81/board.mk
index fcd82d59b8..5afcce58d5 100644
--- a/firmware/config/boards/hellen/hellen81/board.mk
+++ b/firmware/config/boards/hellen/hellen81/board.mk
@@ -9,24 +9,24 @@ DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE
# Disable serial ports on this board as UART3 causes a DMA conflict with the SD card
DDEFS += -DTS_NO_PRIMARY
DDEFS += -DEFI_CAN_SERIAL=TRUE
-# todo debug:
-DDEFS += -DDISABLE_CAN_UPDATE_DASH=TRUE
# Add them all together
DDEFS += -DFIRMWARE_ID=\"hellen81\"
#DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
DDEFS += -DHAL_TRIGGER_USE_ADC=TRUE
-
-
-TRIGGER_USE_ADC = yes
-
# we need fast ADC for software trigger detector
-#DDEFS += -DEFI_OVERRIDE_FAST_ADC_FOR_STM32H7=TRUE -DADC_FAST_DEVICE=ADCD1 -DADC_SLOW_DEVICE=ADCD3 -DSTM32_ADC_USE_ADC3=TRUE
+#DDEFS += -DADC_FAST_DEVICE=ADCD1 -DADC_SLOW_DEVICE=ADCD3 -DSTM32_ADC_USE_ADC3=TRUE
#DDEFS += -DADC_SLOW_DEVICE=ADCD3 -DSTM32_ADC_USE_ADC3=TRUE
-DDEFS += -DEFI_OVERRIDE_FAST_ADC_FOR_STM32H7=TRUE -DADC_FAST_DEVICE=ADCD1 -DEFI_USE_ONLY_FAST_ADC=TRUE -DEFI_FASTER_UNIFORM_ADC=TRUE -DADC_MAX_CHANNELS_COUNT=16 -DADC_BUF_DEPTH_FAST=1 -DADC_BUF_NUM_AVG=1
-#DDEFS += -DADC_SLOW_DEVICE=ADCD1
+# we probably do not need this DDEFS += -DADC_FAST_DEVICE=ADCD1
+
+
+# implementation not in master as of today DDEFS += -DEFI_FASTER_UNIFORM_ADC=TRUE
+# for analog VR we want to access un-averaged most raw data
+# DDEFS += -DADC_BUF_DEPTH_FAST=1
+# DDEFS += -DADC_BUF_NUM_AVG=1
+
DDEFS += -DSHORT_BOARD_NAME=hellen81
diff --git a/firmware/config/boards/hellen/hellen88bmw/board.mk b/firmware/config/boards/hellen/hellen88bmw/board.mk
index d4f2625939..01856e1e06 100644
--- a/firmware/config/boards/hellen/hellen88bmw/board.mk
+++ b/firmware/config/boards/hellen/hellen88bmw/board.mk
@@ -17,7 +17,6 @@ DDEFS += -DTS_NO_PRIMARY=1
# Add them all together
DDEFS += -DFIRMWARE_ID=\"hellen88bmw\" $(VAR_DEF_ENGINE_TYPE)
-DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
DDEFS += -DSHORT_BOARD_NAME=hellen88bmw
diff --git a/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp b/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp
index d08a551e8f..a7d9c31baf 100644
--- a/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp
+++ b/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp
@@ -89,10 +89,16 @@ void setBoardConfigOverrides() {
setHellen144LedPins();
setupVbatt();
+ // hellen88bmw uses L6205PD
+ engineConfiguration->etbIo[0].directionPin1 = H144_OUT_PWM2; // ETB+
+ engineConfiguration->etbIo[0].directionPin2 = H144_OUT_PWM3; // ETB-
+ engineConfiguration->etbIo[0].controlPin = H144_OUT_PWM1; // ETB_EN
+ engineConfiguration->etb_use_two_wires = true;
+
setHellenSdCardSpi3();
- engineConfiguration->clt.config.bias_resistor = 4700;
- engineConfiguration->iat.config.bias_resistor = 4700;
+ engineConfiguration->clt.config.bias_resistor = 2700;
+ engineConfiguration->iat.config.bias_resistor = 2700;
}
/**
@@ -124,10 +130,6 @@ void setBoardDefaultConfiguration() {
// "required" hardware is done - set some reasonable defaults
setupDefaultSensorInputs();
- engineConfiguration->etbIo[0].directionPin1 = Gpio::D15; // out_pwm7
- engineConfiguration->etbIo[0].directionPin2 = Gpio::D14; // out_pwm6
- engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1
- engineConfiguration->etb_use_two_wires = true;
// Some sensible defaults for other options
setCrankOperationMode();
diff --git a/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh b/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh
index 57179cd70c..48d5be0547 100755
--- a/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh
+++ b/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw.sh
@@ -1,4 +1,9 @@
#!/bin/bash
cd ..
+
+export EXTRA_PARAMS="-DDUMMY \
+-DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE \
+"
+
bash ../common_make.sh hellen/hellen88bmw ARCH_STM32F4
diff --git a/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw_avr.sh b/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw_avr.sh
new file mode 100644
index 0000000000..151140bc33
--- /dev/null
+++ b/firmware/config/boards/hellen/hellen88bmw/compile_hellen88bmw_avr.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+cd ..
+
+export EXTRA_PARAMS="-DDUMMY \
+-DEFI_SOFTWARE_KNOCK=FALSE \
+-DHAL_TRIGGER_USE_ADC=TRUE \
+-DSTM32_ADC_USE_ADC3=TRUE \
+"
+
+
+bash ../common_make.sh hellen/hellen88bmw ARCH_STM32F4
diff --git a/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml b/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml
index c03742f7c6..00da0f8dee 100644
--- a/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml
+++ b/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml
@@ -1,6 +1,30 @@
# https://github.com/rusefi/rusefi/blob/master/firmware/config/boards/hellen/hellen_meta.h
pins:
+ - pin: PPS1
+ # H144_IN_PPS
+ id: EFI_ADC_3
+ class: analog_inputs
+ ts_name: PPS1
+
+ - pin: Aux PPS2
+# H144_IN_AUX2
+ id: EFI_ADC_14
+ class: analog_inputs
+ ts_name: Aux PPS2
+
+ - pin: Aux TPS2
+# H144_IN_AUX1
+ id: EFI_ADC_8
+ class: analog_inputs
+ ts_name: Aux TPS2
+
+ - pin: Aux TPS3
+# H144_IN_AUX3
+ id: EFI_ADC_15
+ class: analog_inputs
+ ts_name: Aux TPS3
+
- pin: 1
id: G14
class: outputs
@@ -152,6 +176,11 @@ pins:
function: Coil 3
type: ign
+ - pin: 56
+ id: EFI_ADC_5
+ class: analog_inputs
+ ts_name: 56 - Battery Sense
+
- pin: 73
id: EFI_ADC_4
class: analog_inputs
diff --git a/firmware/config/boards/hellen/hellen88bmw/prepend.txt b/firmware/config/boards/hellen/hellen88bmw/prepend.txt
index 468ee37158..b7a620b657 100644
--- a/firmware/config/boards/hellen/hellen88bmw/prepend.txt
+++ b/firmware/config/boards/hellen/hellen88bmw/prepend.txt
@@ -1,4 +1,4 @@
-#define MAIN_HELP_URL "https://rusefi.com/s/hellen121nissan"
+#define MAIN_HELP_URL "https://rusefi.com/s/hellen88bmw"
#define ts_show_hip9011 false
#define ts_show_cj125 false
@@ -22,6 +22,7 @@
#define ts_show_sd_pins false
#define ts_show_injectionPinMode false
#define ts_show_ignitionPinMode false
+#define ts_show_vbatt false
#define show_test_presets false
#define show_Frankenso_presets false
diff --git a/firmware/config/boards/microrusefi/board.mk b/firmware/config/boards/microrusefi/board.mk
index 85a1f40a83..6123490721 100644
--- a/firmware/config/boards/microrusefi/board.mk
+++ b/firmware/config/boards/microrusefi/board.mk
@@ -13,23 +13,28 @@ else
endif
# see also openblt/board.mk STATUS_LED
-LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3
+DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3
# *TEMPORARY* breaking TTL thus breaking Bluetooth for microRusEFI in order to enable SPI3 for SD card
# *TODO* need to give people the horrible choice between Bluetooth via TTL or SD card via SPI :( horrible choice
-EFI_CONSOLE_TTL_PINS = -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::B10 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::B11
+# PB10/PB11 uses UART3 peripheral and J12/J13 on MRE
+# we also have PC10/PC11 exposed on J4 but that's same UART3
+DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::B10 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::B11
# on MRE 0.6.0 we have SD card on SPI2 which shared channel 3 with USART3
# todo: enable serial which would not DMA thus not conflict?
DDEFS += -DSTM32_UART_USE_USART3=FALSE -DHAL_USE_UART=FALSE
DDEFS += -DEFI_USE_UART_DMA=FALSE -DTS_NO_PRIMARY=TRUE
+# maybe a way to disable SPI2 privately
+#DDEFS += -DSTM32_SPI_USE_SPI2=FALSE
+
DDEFS += -DEFI_CAN_SERIAL=TRUE
DDEFS += -DEFI_CJ125=FALSE -DBOARD_L9779_COUNT=0 -DEFI_HD44780_LCD=FALSE -DEFI_LCD=FALSE
-# Add them all together
-DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"microRusEFI\" $(LED_CRITICAL_ERROR_BRAIN_PIN) $(EFI_CONSOLE_TTL_PINS) -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
+DDEFS += -DFIRMWARE_ID=\"microRusEFI\"
+DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
DDEFS += $(VAR_DEF_ENGINE_TYPE)
# We are running on microRusEFI hardware!
diff --git a/firmware/config/boards/microrusefi/compile_mre_f4.sh b/firmware/config/boards/microrusefi/compile_mre_f4.sh
index 6f00bea0b5..23c9368811 100755
--- a/firmware/config/boards/microrusefi/compile_mre_f4.sh
+++ b/firmware/config/boards/microrusefi/compile_mre_f4.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# export USE_OPENBLT=yes
+export USE_OPENBLT=yes
bash ../common_make.sh microrusefi ARCH_STM32F4
diff --git a/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh b/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh
index 8622148aeb..b9e1e48af9 100644
--- a/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh
+++ b/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh
@@ -5,8 +5,11 @@
SCRIPT_NAME="compile_nucleo_f767.sh"
echo "Entering $SCRIPT_NAME"
+# Nucleo boards use MCO signal from St-Link and NOT oscillator - these need STM32_HSE_BYPASS
+
export EXTRA_PARAMS="-DDUMMY -DSTM32F767xx \
-DEFI_INJECTOR_PIN3=Gpio::Unassigned \
+ -DSTM32_HSE_BYPASS=TRUE \
-DFIRMWARE_ID=\\\"nucleo767\\\" \
-DEFI_COMMUNICATION_PIN=Gpio::B7 \
-DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14 \
diff --git a/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh b/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh
index 5ba6d4657c..9cdd40bdea 100644
--- a/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh
+++ b/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh
@@ -8,7 +8,6 @@ export EXTRA_PARAMS="-DDUMMY -DSTM32F767xx \
-DEFI_COMMUNICATION_PIN=Gpio::B7 \
-DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14 \
-DEFI_ENABLE_ASSERTS=FALSE \
- -DEFI_USE_OSC=TRUE \
-DCH_DBG_ENABLE_CHECKS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE"
# Do not forget to comment out following line if looking to debug!
diff --git a/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh b/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh
index ed74884890..cfc6679dc2 100644
--- a/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh
+++ b/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh
@@ -5,8 +5,11 @@
SCRIPT_NAME="compile_nucleo_h743.sh"
echo "Entering $SCRIPT_NAME"
+# Nucleo boards use MCO signal from St-Link and NOT oscillator - these need STM32_HSE_BYPASS
+
export EXTRA_PARAMS="-DDUMMY \
-DEFI_INJECTOR_PIN3=Gpio::Unassigned \
+ -DSTM32_HSE_BYPASS=TRUE \
-DFIRMWARE_ID=\\\"nucleoH743\\\" \
-DEFI_COMMUNICATION_PIN=Gpio::B7 \
-DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14"
diff --git a/firmware/config/boards/proteus/board.mk b/firmware/config/boards/proteus/board.mk
index 63642d6399..6983f49940 100644
--- a/firmware/config/boards/proteus/board.mk
+++ b/firmware/config/boards/proteus/board.mk
@@ -8,7 +8,6 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F4)
IS_STM32F429 = yes
endif
-DDEFS += -DEFI_USE_OSC=TRUE
# see also openblt/board.mk STATUS_LED
DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3
DDEFS += -DFIRMWARE_ID=\"proteus\"
diff --git a/firmware/config/boards/proteus/compile_proteus_f4.sh b/firmware/config/boards/proteus/compile_proteus_f4.sh
index 1bb87675e1..8f27747219 100755
--- a/firmware/config/boards/proteus/compile_proteus_f4.sh
+++ b/firmware/config/boards/proteus/compile_proteus_f4.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# export USE_OPENBLT=yes
+export USE_OPENBLT=yes
bash ../common_make.sh proteus ARCH_STM32F4
diff --git a/firmware/config/boards/proteus/compile_proteus_f7.sh b/firmware/config/boards/proteus/compile_proteus_f7.sh
index dcb2bfdab1..a44e2e724c 100755
--- a/firmware/config/boards/proteus/compile_proteus_f7.sh
+++ b/firmware/config/boards/proteus/compile_proteus_f7.sh
@@ -1,5 +1,6 @@
#!/bin/bash
+# does not fit into 512K flash, and we use 512K because of st DFU client bug :(
# export USE_OPENBLT=yes
bash ../common_make.sh proteus ARCH_STM32F7
diff --git a/firmware/config/boards/proteus/compile_proteus_h7.sh b/firmware/config/boards/proteus/compile_proteus_h7.sh
index d8f983d5cf..f3c317668b 100755
--- a/firmware/config/boards/proteus/compile_proteus_h7.sh
+++ b/firmware/config/boards/proteus/compile_proteus_h7.sh
@@ -1,3 +1,5 @@
#!/bin/bash
+# export USE_OPENBLT=yes
+
bash ../common_make.sh proteus ARCH_STM32H7
diff --git a/firmware/config/boards/subaru_eg33/mcuconf.h b/firmware/config/boards/subaru_eg33/mcuconf.h
index 8f067c8293..df382ef274 100644
--- a/firmware/config/boards/subaru_eg33/mcuconf.h
+++ b/firmware/config/boards/subaru_eg33/mcuconf.h
@@ -71,9 +71,6 @@
/* To remove futher possible conflict */
#undef STM32_SPI_SPI6_RX_DMA_STREAM
-#undef STM32_ICU_USE_TIM3
-#define STM32_ICU_USE_TIM3 TRUE
-
#undef STM32_CAN_USE_CAN2
#define STM32_CAN_USE_CAN2 FALSE
diff --git a/firmware/config/boards/subaru_eg33/readme.txt b/firmware/config/boards/subaru_eg33/readme.md
similarity index 100%
rename from firmware/config/boards/subaru_eg33/readme.txt
rename to firmware/config/boards/subaru_eg33/readme.md
diff --git a/firmware/config/engines/bmw_n73.cpp b/firmware/config/engines/bmw_n73.cpp
index 88231f0834..afade0af29 100644
--- a/firmware/config/engines/bmw_n73.cpp
+++ b/firmware/config/engines/bmw_n73.cpp
@@ -5,6 +5,8 @@
* @author Andrey Belomutskiy, (c) 2012-2021
*/
+#include "pch.h"
+
#include "bmw_n73.h"
void setEngineProteusBMW_N73_GDI() {
@@ -68,6 +70,7 @@ E90_GEAR_SELECTOR = 0x192
E90_DSC_STATUS = 0x19E
E90_DSC_SPEED = 0x1A0
E90_COOLANT = 0x1D0
+E90_GEAR_SELECTOR = 0x198
E90_LOCKING = 0x2FC
E90_MSA = 0x308
E90_DASH_ON = 0x332
diff --git a/firmware/config/engines/bmw_n73.h b/firmware/config/engines/bmw_n73.h
index a154da9d3b..8b70a0e479 100644
--- a/firmware/config/engines/bmw_n73.h
+++ b/firmware/config/engines/bmw_n73.h
@@ -7,8 +7,6 @@
#pragma once
-#include "engine_configuration.h"
-
void setEngineProteusBMW_N73_GDI();
void setEngineProteusGearboxManInTheMiddle();
diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp
index 9e52c98db1..6d3de7d45d 100644
--- a/firmware/config/engines/custom_engine.cpp
+++ b/firmware/config/engines/custom_engine.cpp
@@ -788,10 +788,11 @@ void setBoschHDEV_5_injectors() {
engineConfiguration->mc33_i_boost = 13000;
engineConfiguration->mc33_i_peak = 9400;
engineConfiguration->mc33_i_hold = 3700;
- engineConfiguration->mc33_t_max_boost = 470;
+ engineConfiguration->mc33_t_min_boost = 100;
+ engineConfiguration->mc33_t_max_boost = 400;
engineConfiguration->mc33_t_peak_off = 10;
engineConfiguration->mc33_t_peak_tot = 700;
- engineConfiguration->mc33_t_bypass = 15;
+ engineConfiguration->mc33_t_bypass = 10;
engineConfiguration->mc33_t_hold_off = 60;
engineConfiguration->mc33_t_hold_tot = 10000;
diff --git a/firmware/config/engines/hyundai.cpp b/firmware/config/engines/hyundai.cpp
index 5e9006a4a5..a4a40a8d86 100644
--- a/firmware/config/engines/hyundai.cpp
+++ b/firmware/config/engines/hyundai.cpp
@@ -5,8 +5,9 @@
* @author Andrey Belomutskiy, (c) 2012-2021
*/
+#include "pch.h"
+
#include "hyundai.h"
-#include "map.h"
static void commonGenesisCoupe() {
strncpy(config->luaScript, R"(
diff --git a/firmware/config/engines/hyundai.h b/firmware/config/engines/hyundai.h
index b73a12097a..3148eb4cfd 100644
--- a/firmware/config/engines/hyundai.h
+++ b/firmware/config/engines/hyundai.h
@@ -7,8 +7,5 @@
#pragma once
-#include "engine_configuration.h"
-
void setGenesisCoupeBK1();
-
void setGenesisCoupeBK2();
diff --git a/firmware/config/engines/mazda_miata_1_6.cpp b/firmware/config/engines/mazda_miata_1_6.cpp
index 458d3b1f9b..5e2b8d25ba 100644
--- a/firmware/config/engines/mazda_miata_1_6.cpp
+++ b/firmware/config/engines/mazda_miata_1_6.cpp
@@ -358,7 +358,6 @@ void setMiataNA6_MAP_MRE() {
engineConfiguration->idle_derivativeFilterLoss = 0.1;
engineConfiguration->idle_antiwindupFreq = 0.1;
engineConfiguration->idleRpmPid.dFactor = 0.002;
- engineConfiguration->idleRpmPid.offset = 0;
engineConfiguration->acIdleExtraOffset = 14;
engineConfiguration->idleRpmPid.minValue = -7;
engineConfiguration->idleRpmPid.maxValue = 35;
diff --git a/firmware/config/engines/mazda_miata_na8.cpp b/firmware/config/engines/mazda_miata_na8.cpp
index 36eeddc06d..12a94c03ad 100644
--- a/firmware/config/engines/mazda_miata_na8.cpp
+++ b/firmware/config/engines/mazda_miata_na8.cpp
@@ -30,7 +30,6 @@ static void commonNA8() {
engineConfiguration->idle_derivativeFilterLoss = 0.08;
engineConfiguration->idle_antiwindupFreq = 0.03;
engineConfiguration->idleRpmPid.dFactor = 0.002;
- engineConfiguration->idleRpmPid.offset = 9;
engineConfiguration->idleRpmPid.minValue = 76;
engineConfiguration->idlerpmpid_iTermMin = -15;
engineConfiguration->idlerpmpid_iTermMax = 30;
diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp
index 43b0c4e583..752e906710 100644
--- a/firmware/config/engines/mazda_miata_vvt.cpp
+++ b/firmware/config/engines/mazda_miata_vvt.cpp
@@ -343,7 +343,6 @@ static void setCommonMazdaNB() {
engineConfiguration->idle_derivativeFilterLoss = 0.08;
engineConfiguration->idle_antiwindupFreq = 0.03;
engineConfiguration->idleRpmPid.dFactor = 0.002;
- engineConfiguration->idleRpmPid.offset = 9;
engineConfiguration->idleRpmPid.minValue = -8;
engineConfiguration->idleRpmPid.minValue = 76;
engineConfiguration->idlerpmpid_iTermMin = -15;
diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp
index 1a046b828a..67658a757c 100644
--- a/firmware/config/engines/vw_b6.cpp
+++ b/firmware/config/engines/vw_b6.cpp
@@ -160,9 +160,14 @@ void setProteusVwPassatB6() {
strncpy(config->luaScript, R"(
AIRBAG = 0x050
MOTOR_1 = 0x280
+MOTOR_3 = 0x380
+GRA = 0x388
TCU_1 = 0x440
TCU_2 = 0x540
BRAKE_2 = 0x5A0
+MOTOR_INFO = 0x580
+MOTOR_5 = 0x480
+MOTOR_6 = 0x488
MOTOR_7 = 0x588
canRxAdd(AIRBAG)
@@ -181,8 +186,7 @@ shallSleep = Timer.new()
hadIgnitionEvent = false
function onCanRx(bus, id, dlc, data)
- id11 = id % 2048
- if id11 == AIRBAG then
+ if id == AIRBAG then
-- looks like we have ignition key do not sleep!
shallSleep : reset()
hadIgnitionEvent = true
@@ -203,8 +207,9 @@ function xorChecksum(data)
return data[1] ~ data[2] ~ data[3] ~ data[4] ~ data[5] ~ data[6] ~ data[7]
end
-canMotor1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
-canMotor7 = { 0x1A, 0x66, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 }
+canMotor1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+canMotorInfo = { 0x00, 0x00, 0x00, 0x14, 0x1C, 0x93, 0x48, 0x14 }
+canMotor7 = { 0x1A, 0x66, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 }
setTickRate(100)
diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h
index ab31efd24c..d08acd08c1 100644
--- a/firmware/config/stm32f4ems/efifeatures.h
+++ b/firmware/config/stm32f4ems/efifeatures.h
@@ -69,10 +69,6 @@
#define EFI_LOGIC_ANALYZER TRUE
#endif
-#ifndef EFI_ICU_INPUTS
-#define EFI_ICU_INPUTS FALSE
-#endif
-
#ifndef HAL_TRIGGER_USE_PAL
#define HAL_TRIGGER_USE_PAL TRUE
#endif /* HAL_TRIGGER_USE_PAL */
@@ -175,6 +171,10 @@
#define BOARD_MC33810_COUNT 0
#endif
+#ifndef BOARD_TLE9104_COUNT
+#define BOARD_TLE9104_COUNT 0
+#endif
+
#define EFI_ANALOG_SENSORS TRUE
#ifndef EFI_MAX_31855
diff --git a/firmware/config/stm32h7ems/efifeatures.h b/firmware/config/stm32h7ems/efifeatures.h
index a9cb0440f2..5461d11dd9 100644
--- a/firmware/config/stm32h7ems/efifeatures.h
+++ b/firmware/config/stm32h7ems/efifeatures.h
@@ -38,8 +38,5 @@
// H7 runs faster "slow" ADC to make up for reduced oversampling
#define SLOW_ADC_RATE 1000
-#undef EFI_ICU_INPUTS
-#define EFI_ICU_INPUTS FALSE
-
#undef LUA_USER_HEAP
#define LUA_USER_HEAP 100000
diff --git a/firmware/console/binary/FragmentEntry.cpp b/firmware/console/binary/FragmentEntry.cpp
deleted file mode 100644
index ab1e8136fa..0000000000
--- a/firmware/console/binary/FragmentEntry.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * FragmentEntry.cpp
- *
- * Created on: Jan 5, 2022
- * @author Andrey Belomutskiy, (c) 2012-2022
- */
-
-#include "pch.h"
-#include "FragmentEntry.h"
-
-void copyRange(uint8_t* destination, FragmentList src, size_t skip, size_t size) {
- int fragmentIndex = 0;
-
- // Find which fragment to start - skip any full fragments smaller than `skip` parameter
- while (skip > src.fragments[fragmentIndex].size && fragmentIndex <= src.count) {
- skip -= src.fragments[fragmentIndex].size;
- fragmentIndex++;
- }
-
- int destinationIndex = 0;
-
- while (size > 0) {
- if (fragmentIndex >= src.count) {
- // somehow we are past the end of fragments - fill with zeros
- memset(destination + destinationIndex, 0, size);
- return;
- }
-
- int copyNowSize = minI(size, src.fragments[fragmentIndex].size - skip);
- const uint8_t* fromBase = src.fragments[fragmentIndex].data;
- if (!fromBase) {
- // we have no buffer for this fragment - fill with zeroes
- memset(destination + destinationIndex, 0, copyNowSize);
- } else {
- memcpy(destination + destinationIndex, fromBase + skip, copyNowSize);
- }
- destinationIndex += copyNowSize;
- skip = 0;
- size -= copyNowSize;
- fragmentIndex++;
- }
-}
diff --git a/firmware/console/binary/FragmentEntry.h b/firmware/console/binary/FragmentEntry.h
deleted file mode 100644
index 05227488e9..0000000000
--- a/firmware/console/binary/FragmentEntry.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * FragmentEntry.h
- *
- * Created on: Jan 5, 2022
- * @author Andrey Belomutskiy, (c) 2012-2022
- */
-
-#pragma once
-
-struct FragmentEntry {
- template
- FragmentEntry(const TData* data)
- : data(reinterpret_cast(data))
- , size(sizeof(TData))
- {
- }
-
- const uint8_t* const data;
- const size_t size;
-};
-
-struct FragmentList {
- const FragmentEntry* fragments;
- const size_t count;
-};
-
-// copy `size` of fragmented outputs in to destination, skipping the first `skip` bytes
-void copyRange(uint8_t* destination, FragmentList src, size_t skip, size_t size);
diff --git a/firmware/console/binary/live_data.cpp b/firmware/console/binary/live_data.cpp
index 97443232ab..b0729ec43b 100644
--- a/firmware/console/binary/live_data.cpp
+++ b/firmware/console/binary/live_data.cpp
@@ -4,6 +4,8 @@
#include "tunerstudio.h"
#include "wideband_state_generated.h"
+#include "electronic_throttle_generated.h"
+#include "knock_controller_generated.h"
template<>
const output_channels_s* getLiveDataAddr() {
diff --git a/firmware/console/binary/live_data.h b/firmware/console/binary/live_data.h
index 41d237e1fc..985a3b36a4 100644
--- a/firmware/console/binary/live_data.h
+++ b/firmware/console/binary/live_data.h
@@ -1,6 +1,6 @@
#pragma once
-#include "FragmentEntry.h"
+#include
template
const TStruct* getLiveDataAddr();
diff --git a/firmware/console/binary/output_channels.txt b/firmware/console/binary/output_channels.txt
index 3bc99b4b86..ed68c3b0ce 100644
--- a/firmware/console/binary/output_channels.txt
+++ b/firmware/console/binary/output_channels.txt
@@ -240,7 +240,9 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 5, 0
int8_t[4 iterate] autoscale vvtTargets;;"deg",1, 0, 0, 0, 0
uint16_t turboSpeed;@@GAUGE_NAME_TURBO_SPEED@@;"hz",1, 0, 0, 0, 0
+! fun fact: we have a separate pid_state.txt file for a bit of a different structure huh?
struct pid_status_s
+ float autoscale pTerm;;"", 1, 0, -50000, 50000, 2
int16_t autoscale iTerm;;"", 0.01, 0, -327, 327, 2
int16_t autoscale dTerm;;"", 0.01, 0, -327, 327, 2
int16_t autoscale output;;"", 0.01, 0, -327, 327, 2
@@ -334,5 +336,8 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 5, 0
uint16_t autoscale ISSValue;@@GAUGE_NAME_ISS@@;"RPM",1, 0, 0, 8000, 0
- uint8_t[78 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
+ int16_t[AUX_ANALOG_INPUT_COUNT iterate] autoscale rawAnalogInput;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3
+ uint8_t[4 iterate] autoscale gppwmOutput;GPPWM Output;"%", 0.5, 0, 0, 100, 2
+
+ uint8_t[58] unusedAtTheEnd;;"",1, 0, 0, 0, 0
end_struct
diff --git a/firmware/console/binary/output_channels_generated.h b/firmware/console/binary/output_channels_generated.h
index d3bf805352..bfaa73bbcf 100644
--- a/firmware/console/binary/output_channels_generated.h
+++ b/firmware/console/binary/output_channels_generated.h
@@ -1,4 +1,4 @@
-// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jun 29 03:16:45 EDT 2022
+// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jul 27 09:37:52 UTC 2022
// by class com.rusefi.output.CHeaderConsumer
// begin
#pragma once
@@ -8,25 +8,29 @@ struct pid_status_s {
/**
* offset 0
*/
- scaled_channel iTerm = (int16_t)0;
- /**
- * offset 2
- */
- scaled_channel dTerm = (int16_t)0;
+ scaled_channel pTerm = (float)0;
/**
* offset 4
*/
- scaled_channel output = (int16_t)0;
+ scaled_channel iTerm = (int16_t)0;
/**
* offset 6
*/
- scaled_channel error = (int16_t)0;
+ scaled_channel dTerm = (int16_t)0;
/**
* offset 8
*/
+ scaled_channel output = (int16_t)0;
+ /**
+ * offset 10
+ */
+ scaled_channel error = (int16_t)0;
+ /**
+ * offset 12
+ */
uint32_t resetCounter = (uint32_t)0;
};
-static_assert(sizeof(pid_status_s) == 12);
+static_assert(sizeof(pid_status_s) == 16);
// start of output_channels_s
struct output_channels_s {
@@ -1253,41 +1257,52 @@ struct output_channels_s {
*/
pid_status_s alternatorStatus;
/**
- * offset 452
+ * offset 456
*/
pid_status_s idleStatus;
/**
- * offset 464
+ * offset 472
*/
pid_status_s etbStatus;
/**
- * offset 476
+ * offset 488
*/
pid_status_s boostStatus;
/**
* aux speed 1
s
- * offset 488
+ * offset 504
*/
uint16_t auxSpeed1 = (uint16_t)0;
/**
* aux speed 2
s
- * offset 490
+ * offset 506
*/
uint16_t auxSpeed2 = (uint16_t)0;
/**
* @@GAUGE_NAME_ISS@@
RPM
- * offset 492
+ * offset 508
*/
scaled_channel ISSValue = (uint16_t)0;
/**
- * offset 494
+ V
+ * offset 510
*/
- uint8_t unusedAtTheEnd[78];
+ scaled_channel rawAnalogInput[AUX_ANALOG_INPUT_COUNT];
+ /**
+ * GPPWM Output
+ %
+ * offset 526
+ */
+ scaled_channel gppwmOutput[4];
+ /**
+ * offset 530
+ */
+ uint8_t unusedAtTheEnd[58];
};
-static_assert(sizeof(output_channels_s) == 572);
+static_assert(sizeof(output_channels_s) == 588);
// end
-// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jun 29 03:16:45 EDT 2022
+// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jul 27 09:37:52 UTC 2022
diff --git a/firmware/console/binary/serial_can.cpp b/firmware/console/binary/serial_can.cpp
index bce7a1bf0d..8fdb88bbf1 100644
--- a/firmware/console/binary/serial_can.cpp
+++ b/firmware/console/binary/serial_can.cpp
@@ -12,7 +12,6 @@
#include "pch.h"
#include "os_access.h"
-#include "crc.h"
#if EFI_UNIT_TEST
#define PRINT printf
@@ -70,6 +69,9 @@ int CanStreamerState::sendFrame(const IsoTpFrameHeader & header, const uint8_t *
offset = 3;
maxNumBytes = 0; // no data is sent with 'flow control' frame
break;
+ default:
+ // bad frame type
+ return 0;
}
int numBytes = minI(maxNumBytes, num);
@@ -119,6 +121,9 @@ int CanStreamerState::receiveFrame(CANRxFrame *rxmsg, uint8_t *buf, int num, can
case ISO_TP_FRAME_FLOW_CONTROL:
// todo: currently we just ignore the FC frame
return 0;
+ default:
+ // bad frame type
+ return 0;
}
#if defined(TS_CAN_DEVICE_SHORT_PACKETS_IN_ONE_FRAME)
diff --git a/firmware/console/binary/tooth_logger.cpp b/firmware/console/binary/tooth_logger.cpp
index 7b5096164e..1f2f238ec6 100644
--- a/firmware/console/binary/tooth_logger.cpp
+++ b/firmware/console/binary/tooth_logger.cpp
@@ -31,12 +31,10 @@ typedef struct __attribute__ ((packed)) {
* Engine idles around 20Hz and revs up to 140Hz, at 60/2 and 8 cylinders we have about 20Khz events
* If we can read buffer at 50Hz we want buffer to be about 400 elements.
*/
-static composite_logger_s buffer[COMPOSITE_PACKET_COUNT] CCM_OPTIONAL;
-static composite_logger_s *ptr_buffer_first = &buffer[0];
-static composite_logger_s *ptr_buffer_second = &buffer[(COMPOSITE_PACKET_COUNT/2)-1];
-static size_t NextIdx = 0;
+
+static_assert(sizeof(composite_logger_s) == COMPOSITE_PACKET_SIZE, "composite packet size");
+
static volatile bool ToothLoggerEnabled = false;
-static volatile bool firstBuffer = true;
static uint32_t lastEdgeTimestamp = 0;
static bool currentTrigger1 = false;
@@ -47,28 +45,54 @@ static bool currentCoilState = false;
// same about injectors
static bool currentInjectorState = false;
-int getCompositeRecordCount() {
- return NextIdx;
-}
-
-
#if EFI_UNIT_TEST
#include "logicdata.h"
-int copyCompositeEvents(CompositeEvent *events) {
- for (size_t i = 0; i < NextIdx; i++) {
- CompositeEvent *event = &events[i];
- event->timestamp = SWAP_UINT32(buffer[i].timestamp);
- event->primaryTrigger = buffer[i].priLevel;
- event->secondaryTrigger = buffer[i].secLevel;
- event->isTDC = buffer[i].trigger;
- event->sync = buffer[i].sync;
- event->coil = buffer[i].coil;
- event->injector = buffer[i].injector;
- }
- return NextIdx;
+
+static std::vector events;
+
+const std::vector& getCompositeEvents() {
+ return events;
}
-#endif // EFI_UNIT_TEST
+void SetNextCompositeEntry(efitick_t timestamp) {
+ CompositeEvent event;
+
+ event.timestamp = timestamp;
+ event.primaryTrigger = currentTrigger1;
+ event.secondaryTrigger = currentTrigger2;
+ event.isTDC = currentTdc;
+ event.sync = engine->triggerCentral.triggerState.getShaftSynchronized();
+ event.coil = currentCoilState;
+ event.injector = currentInjectorState;
+
+ events.push_back(event);
+}
+
+void EnableToothLogger() {
+ ToothLoggerEnabled = true;
+ events.clear();
+}
+
+void DisableToothLogger() {
+ ToothLoggerEnabled = false;
+}
+
+#else // not EFI_UNIT_TEST
+
+static constexpr size_t bufferCount = 4;
+static constexpr size_t entriesPerBuffer = COMPOSITE_PACKET_COUNT / bufferCount;
+
+struct CompositeBuffer {
+ composite_logger_s buffer[entriesPerBuffer];
+ size_t nextIdx;
+ Timer startTime;
+};
+
+static CompositeBuffer buffers[bufferCount] CCM_OPTIONAL;
+static chibios_rt::Mailbox freeBuffers CCM_OPTIONAL;
+static chibios_rt::Mailbox filledBuffers CCM_OPTIONAL;
+
+static CompositeBuffer* currentBuffer = nullptr;
static void setToothLogReady(bool value) {
#if EFI_TUNER_STUDIO && (EFI_PROD_CODE || EFI_SIMULATOR)
@@ -76,36 +100,137 @@ static void setToothLogReady(bool value) {
#endif // EFI_TUNER_STUDIO
}
-static void SetNextCompositeEntry(efitick_t timestamp) {
- uint32_t nowUs = NT2US(timestamp);
-
- // TS uses big endian, grumble
- buffer[NextIdx].timestamp = SWAP_UINT32(nowUs);
- buffer[NextIdx].priLevel = currentTrigger1;
- buffer[NextIdx].secLevel = currentTrigger2;
- buffer[NextIdx].trigger = currentTdc;
- buffer[NextIdx].sync = engine->triggerCentral.triggerState.getShaftSynchronized();
- buffer[NextIdx].coil = currentCoilState;
- buffer[NextIdx].injector = currentInjectorState;
+void EnableToothLogger() {
+ chibios_rt::CriticalSectionLocker csl;
- NextIdx++;
-
- static_assert(sizeof(composite_logger_s) == COMPOSITE_PACKET_SIZE, "composite packet size");
-
- //If we hit the end, loop
- if ((firstBuffer) && (NextIdx >= (COMPOSITE_PACKET_COUNT/2))) {
- /* first half is full */
- setToothLogReady(true);
- firstBuffer = false;
- }
- if ((!firstBuffer) && (NextIdx >= sizeof(buffer) / sizeof(buffer[0]))) {
- setToothLogReady(true);
- NextIdx = 0;
- firstBuffer = true;
+ // Reset all buffers
+ for (size_t i = 0; i < efi::size(buffers); i++) {
+ buffers[i].nextIdx = 0;
}
+ // Reset state
+ currentBuffer = nullptr;
+
+ // Empty the filled buffer list
+ CompositeBuffer* dummy;
+ while (MSG_TIMEOUT != filledBuffers.fetchI(&dummy)) ;
+
+ // Put all buffers in the free list
+ for (size_t i = 0; i < efi::size(buffers); i++) {
+ freeBuffers.postI(&buffers[i]);
+ }
+
+ // Reset the last edge to now - this prevents the first edge logged from being bogus
+ lastEdgeTimestamp = getTimeNowUs();
+
+ // Enable logging of edges as they come
+ ToothLoggerEnabled = true;
+
+ setToothLogReady(false);
}
+void DisableToothLogger() {
+ ToothLoggerEnabled = false;
+ setToothLogReady(false);
+}
+
+expected GetToothLoggerBuffer() {
+ chibios_rt::CriticalSectionLocker csl;
+
+ CompositeBuffer* buffer;
+ msg_t msg = filledBuffers.fetchI(&buffer);
+
+ if (msg == MSG_TIMEOUT) {
+ setToothLogReady(false);
+ return unexpected;
+ }
+
+ if (msg != MSG_OK) {
+ // What even happened if we didn't get timeout, but also didn't get OK?
+ return unexpected;
+ }
+
+ size_t entryCount = buffer->nextIdx;
+ buffer->nextIdx = 0;
+
+ // Return this buffer to the free list
+ msg = freeBuffers.postI(buffer);
+ efiAssert(OBD_PCM_Processor_Fault, msg == MSG_OK, "Composite logger post to free buffer fail", unexpected);
+
+ // If the used list is empty, clear the ready flag
+ if (filledBuffers.getUsedCountI() == 0) {
+ setToothLogReady(false);
+ }
+
+ return ToothLoggerBuffer{ reinterpret_cast(buffer->buffer), entryCount * sizeof(composite_logger_s)};
+}
+
+static CompositeBuffer* findBuffer(efitick_t timestamp) {
+ CompositeBuffer* buffer;
+
+ if (!currentBuffer) {
+ // try and find a buffer, if none available, we can't log
+ if (MSG_OK != freeBuffers.fetchI(&buffer)) {
+ return nullptr;
+ }
+
+ // Record the time of the last buffer swap so we can force a swap after a minimum period of time
+ // This ensures the user sees *something* even if they don't have enough trigger events
+ // to fill the buffer.
+ buffer->startTime.reset(timestamp);
+
+ currentBuffer = buffer;
+ }
+
+ return currentBuffer;
+}
+
+static void SetNextCompositeEntry(efitick_t timestamp) {
+ // This is called from multiple interrupts/threads, so we need a lock.
+ chibios_rt::CriticalSectionLocker csl;
+
+ CompositeBuffer* buffer = findBuffer(timestamp);
+
+ if (!buffer) {
+ // All buffers are full, nothing to do here.
+ return;
+ }
+
+ composite_logger_s* entry = &buffer->buffer[buffer->nextIdx];
+
+ uint32_t nowUs = NT2US(timestamp);
+
+ // TS uses big endian, grumble
+ entry->timestamp = SWAP_UINT32(nowUs);
+ entry->priLevel = currentTrigger1;
+ entry->secLevel = currentTrigger2;
+ entry->trigger = currentTdc;
+ entry->sync = engine->triggerCentral.triggerState.getShaftSynchronized();
+ entry->coil = currentCoilState;
+ entry->injector = currentInjectorState;
+
+ buffer->nextIdx++;
+
+ // if the buffer is full...
+ bool bufferFull = buffer->nextIdx >= efi::size(buffer->buffer);
+ // ... or it's been too long since the last flush
+ bool bufferTimedOut = buffer->startTime.hasElapsedSec(5);
+
+ // Then cycle buffers and set the ready flag.
+ if (bufferFull || bufferTimedOut) {
+ // Post to the output queue
+ filledBuffers.postI(buffer);
+
+ // Null the current buffer so we get a new one next time
+ currentBuffer = nullptr;
+
+ // Flag that we are ready
+ setToothLogReady(true);
+ }
+}
+
+#endif // EFI_UNIT_TEST
+
void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) {
// bail if we aren't enabled
if (!ToothLoggerEnabled) {
@@ -184,43 +309,10 @@ void LogTriggerInjectorState(efitick_t timestamp, bool state) {
//SetNextCompositeEntry(timestamp, trigger1, trigger2, trigger);
}
-void EnableToothLogger() {
- // Clear the buffer
- memset(buffer, 0, sizeof(buffer));
-
- // Reset the last edge to now - this prevents the first edge logged from being bogus
- lastEdgeTimestamp = getTimeNowUs();
-
- // Reset write index
- NextIdx = 0;
-
- // Enable logging of edges as they come
- ToothLoggerEnabled = true;
-
-
- setToothLogReady(false);
-}
-
void EnableToothLoggerIfNotEnabled() {
if (!ToothLoggerEnabled) {
EnableToothLogger();
}
}
-void DisableToothLogger() {
- ToothLoggerEnabled = false;
- setToothLogReady(false);
-}
-
-ToothLoggerBuffer GetToothLoggerBuffer() {
- // tell TS that we do not have data until we have data again
- setToothLogReady(false);
- if (firstBuffer) {
- return { reinterpret_cast(ptr_buffer_second), (sizeof(buffer)/2) };
- } else {
- return { reinterpret_cast(ptr_buffer_first), (sizeof(buffer)/2) };
- }
-}
-
-
#endif /* EFI_TOOTH_LOGGER */
diff --git a/firmware/console/binary/tooth_logger.h b/firmware/console/binary/tooth_logger.h
index ee868728ff..e889919a6a 100644
--- a/firmware/console/binary/tooth_logger.h
+++ b/firmware/console/binary/tooth_logger.h
@@ -11,11 +11,9 @@
#if EFI_UNIT_TEST
#include "logicdata.h"
-int copyCompositeEvents(CompositeEvent *events);
+const std::vector& getCompositeEvents();
#endif // EFI_UNIT_TEST
-int getCompositeRecordCount();
-
void EnableToothLoggerIfNotEnabled();
// Enable the tooth logger - this clears the buffer starts logging
@@ -40,4 +38,5 @@ struct ToothLoggerBuffer
};
// Get a reference to the buffer
-ToothLoggerBuffer GetToothLoggerBuffer();
+// Returns unexpected if no buffer is available
+expected GetToothLoggerBuffer();
diff --git a/firmware/console/binary/ts_can_channel.cpp b/firmware/console/binary/ts_can_channel.cpp
index 278637d1d5..f3a357e06b 100644
--- a/firmware/console/binary/ts_can_channel.cpp
+++ b/firmware/console/binary/ts_can_channel.cpp
@@ -102,7 +102,7 @@ struct CanTsThread : public TunerstudioThread {
static CanTsThread canTsThread;
void startCanConsole() {
- canTsThread.Start();
+ canTsThread.start();
canStreamInit();
}
diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp
index 75eed9c9bf..bf92fce150 100644
--- a/firmware/console/binary/tunerstudio.cpp
+++ b/firmware/console/binary/tunerstudio.cpp
@@ -71,7 +71,6 @@
#include "tunerstudio_io.h"
#include "malfunction_central.h"
#include "console_io.h"
-#include "crc.h"
#include "bluetooth.h"
#include "tunerstudio_io.h"
#include "tooth_logger.h"
@@ -101,6 +100,8 @@ static void printErrorCounters() {
/* 1S */
#define TS_COMMUNICATION_TIMEOUT TIME_MS2I(1000)
+/* 10mS when receiving byte by byte */
+#define TS_COMMUNICATION_TIMEOUT_SHORT TIME_MS2I(10)
static efitimems_t previousWriteReportMs = 0;
@@ -173,6 +174,10 @@ extern bool rebootForPresetPending;
void TunerStudio::handleWriteChunkCommand(TsChannelBase* tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count,
void *content) {
tsState.writeChunkCommandCounter++;
+ if (isLockedFromUser()) {
+ sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND);
+ return;
+ }
efiPrintf("WRITE CHUNK mode=%d o=%d s=%d", mode, offset, count);
@@ -214,6 +219,10 @@ void TunerStudio::handleWriteValueCommand(TsChannelBase* tsChannel, ts_response_
UNUSED(mode);
tsState.writeValueCommandCounter++;
+ if (isLockedFromUser()) {
+ sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND);
+ return;
+ }
tunerStudioDebug(tsChannel, "got W (Write)"); // we can get a lot of these
@@ -249,7 +258,14 @@ void TunerStudio::handlePageReadCommand(TsChannelBase* tsChannel, ts_response_fo
return;
}
- const uint8_t* addr = getWorkingPageAddr() + offset;
+ uint8_t* addr;
+ if (isLockedFromUser()) {
+ // to have rusEFI console happy just send all zeros within a valid packet
+ addr = (uint8_t*)&tsChannel->scratchBuffer + SCRATCH_BUFFER_PREFIX_SIZE;
+ memset(addr, 0, count);
+ } else {
+ addr = getWorkingPageAddr() + offset;
+ }
tsChannel->sendResponse(mode, addr, count);
#if EFI_TUNER_STUDIO_VERBOSE
// efiPrintf("Sending %d done", count);
@@ -405,7 +421,7 @@ static int tsProcessOne(TsChannelBase* tsChannel) {
tsState.totalCounter++;
uint8_t firstByte;
- int received = tsChannel->readTimeout(&firstByte, 1, TS_COMMUNICATION_TIMEOUT);
+ size_t received = tsChannel->readTimeout(&firstByte, 1, TS_COMMUNICATION_TIMEOUT);
#if EFI_SIMULATOR
logMsg("received %d\r\n", received);
#endif
@@ -417,6 +433,7 @@ static int tsProcessOne(TsChannelBase* tsChannel) {
// assume there's connection loss and notify the bluetooth init code
bluetoothSoftwareDisconnectNotify();
#endif /* EFI_BLUETOOTH_SETUP */
+ tsChannel->in_sync = false;
return -1;
}
@@ -425,66 +442,93 @@ static int tsProcessOne(TsChannelBase* tsChannel) {
}
uint8_t secondByte;
- received = tsChannel->readTimeout(&secondByte, 1, TS_COMMUNICATION_TIMEOUT);
+ /* second byte should be received within minimal delay */
+ received = tsChannel->readTimeout(&secondByte, 1, TS_COMMUNICATION_TIMEOUT_SHORT);
if (received != 1) {
tunerStudioError(tsChannel, "TS: ERROR: no second byte");
+ tsChannel->in_sync = false;
return -1;
}
uint16_t incomingPacketSize = firstByte << 8 | secondByte;
+ size_t expectedSize = incomingPacketSize + CRC_VALUE_SIZE;
- if (incomingPacketSize == 0 || incomingPacketSize > (sizeof(tsChannel->scratchBuffer) - CRC_WRAPPING_SIZE)) {
- efiPrintf("process_ts: channel=%s invalid size: %d", tsChannel->name, incomingPacketSize);
- tunerStudioError(tsChannel, "process_ts: ERROR: CRC header size");
- sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
+ if (incomingPacketSize == 0 || expectedSize > sizeof(tsChannel->scratchBuffer)) {
+ if (tsChannel->in_sync) {
+ efiPrintf("process_ts: channel=%s invalid size: %d", tsChannel->name, incomingPacketSize);
+ tunerStudioError(tsChannel, "process_ts: ERROR: CRC header size");
+ /* send error only if previously we were in sync */
+ sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
+ }
+ tsChannel->in_sync = false;
return -1;
}
- received = tsChannel->readTimeout((uint8_t* )tsChannel->scratchBuffer, 1, TS_COMMUNICATION_TIMEOUT);
- if (received != 1) {
- tunerStudioError(tsChannel, "ERROR: did not receive command");
- sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
- return -1;
- }
+ char command;
+ if (tsChannel->in_sync) {
+ /* we are in sync state, packet size should be correct so lets receive full packet and then check if command is supported
+ * otherwise (if abort reception in middle of packet) it will break syncronization and cause error on next packet */
+ received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer), expectedSize, TS_COMMUNICATION_TIMEOUT);
+ command = tsChannel->scratchBuffer[0];
- char command = tsChannel->scratchBuffer[0];
- if (!isKnownCommand(command)) {
- efiPrintf("unexpected command %x", command);
- sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND);
- return -1;
+ if (received != expectedSize) {
+ /* print and send error as we were in sync */
+ efiPrintf("Got only %d bytes while expecting %d for command %c", received,
+ expectedSize, command);
+ tunerStudioError(tsChannel, "ERROR: not enough bytes in stream");
+ sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
+ tsChannel->in_sync = false;
+ return -1;
+ }
+
+ if (!isKnownCommand(command)) {
+ /* print and send error as we were in sync */
+ efiPrintf("unexpected command %x", command);
+ sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND);
+ tsChannel->in_sync = false;
+ return -1;
+ }
+ } else {
+ /* receive only command byte to check if it is supported */
+ received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer), 1, TS_COMMUNICATION_TIMEOUT_SHORT);
+ command = tsChannel->scratchBuffer[0];
+
+ if (!isKnownCommand(command)) {
+ /* do not report any error as we are not in sync */
+ return -1;
+ }
+
+ received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer) + 1, expectedSize - 1, TS_COMMUNICATION_TIMEOUT);
+ if (received != expectedSize - 1) {
+ /* do not report any error as we are not in sync */
+ return -1;
+ }
}
#if EFI_SIMULATOR
- logMsg("command %c\r\n", command);
+ logMsg("command %c\r\n", command);
#endif
- int expectedSize = incomingPacketSize + CRC_VALUE_SIZE - 1;
- received = tsChannel->readTimeout((uint8_t*)(tsChannel->scratchBuffer + 1), expectedSize, TS_COMMUNICATION_TIMEOUT);
- if (received != expectedSize) {
- efiPrintf("Got only %d bytes while expecting %d for command %c", received,
- expectedSize, command);
- tunerStudioError(tsChannel, "ERROR: not enough bytes in stream");
- sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
- return -1;
- }
-
uint32_t expectedCrc = *(uint32_t*) (tsChannel->scratchBuffer + incomingPacketSize);
expectedCrc = SWAP_UINT32(expectedCrc);
uint32_t actualCrc = crc32(tsChannel->scratchBuffer, incomingPacketSize);
if (actualCrc != expectedCrc) {
- efiPrintf("TunerStudio: CRC %x %x %x %x", tsChannel->scratchBuffer[incomingPacketSize + 0],
- tsChannel->scratchBuffer[incomingPacketSize + 1], tsChannel->scratchBuffer[incomingPacketSize + 2],
- tsChannel->scratchBuffer[incomingPacketSize + 3]);
-
- efiPrintf("TunerStudio: command %c actual CRC %x/expected %x", tsChannel->scratchBuffer[0],
- actualCrc, expectedCrc);
- tunerStudioError(tsChannel, "ERROR: CRC issue");
- sendErrorCode(tsChannel, TS_RESPONSE_CRC_FAILURE);
+ /* send error only if previously we were in sync */
+ if (tsChannel->in_sync) {
+ efiPrintf("TunerStudio: command %c actual CRC %x/expected %x", tsChannel->scratchBuffer[0],
+ actualCrc, expectedCrc);
+ tunerStudioError(tsChannel, "ERROR: CRC issue");
+ sendErrorCode(tsChannel, TS_RESPONSE_CRC_FAILURE);
+ tsChannel->in_sync = false;
+ }
return -1;
}
+ /* we were able to receive known command with correct crc and size! */
+ tsChannel->in_sync = true;
+
int success = tsInstance.handleCrcCommand(tsChannel, tsChannel->scratchBuffer, incomingPacketSize);
if (!success) {
@@ -565,8 +609,6 @@ void TunerStudio::handleExecuteCommand(TsChannelBase* tsChannel, char *data, int
tsChannel->writeCrcPacket(TS_RESPONSE_COMMAND_OK, nullptr, 0);
}
-static int transmitted = 0;
-
int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, int incomingPacketSize) {
ScopePerf perf(PE::TunerStudioHandleCrcCommand);
@@ -658,41 +700,19 @@ int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, int inco
sendOkResponse(tsChannel, TS_CRC);
break;
- case TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY:
-
- {
- EnableToothLoggerIfNotEnabled();
- const uint8_t* const buffer = GetToothLoggerBuffer().Buffer;
-
- const uint8_t* const start = buffer + COMPOSITE_PACKET_SIZE * transmitted;
-
- int currentEnd = getCompositeRecordCount();
-
- // set debug_mode 40
- if (engineConfiguration->debugMode == DBG_COMPOSITE_LOG) {
- engine->outputChannels.debugIntField1 = currentEnd;
- engine->outputChannels.debugIntField2 = transmitted;
-
- }
-
- if (currentEnd > transmitted) {
- // more normal case - tail after head
- tsChannel->sendResponse(TS_CRC, start, COMPOSITE_PACKET_SIZE * (currentEnd - transmitted), true);
- transmitted = currentEnd;
- } else if (currentEnd == transmitted) {
- tsChannel->sendResponse(TS_CRC, start, 0);
- } else {
- // we are here if tail of buffer has reached the end of buffer and re-started from the start of buffer
- // sending end of the buffer, next transmission would take care of the rest
- tsChannel->sendResponse(TS_CRC, start, COMPOSITE_PACKET_SIZE * (COMPOSITE_PACKET_COUNT - transmitted), true);
- transmitted = 0;
- }
- }
- break;
+ case TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY:
+ EnableToothLoggerIfNotEnabled();
+ // falls through
case TS_GET_LOGGER_GET_BUFFER:
{
auto toothBuffer = GetToothLoggerBuffer();
- tsChannel->sendResponse(TS_CRC, toothBuffer.Buffer, toothBuffer.Length, true);
+
+ if (toothBuffer) {
+ tsChannel->sendResponse(TS_CRC, toothBuffer.Value.Buffer, toothBuffer.Value.Length, true);
+ } else {
+ // TS asked for a tooth logger buffer, but we don't have one to give it.
+ sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
+ }
}
break;
diff --git a/firmware/console/binary/tunerstudio.h b/firmware/console/binary/tunerstudio.h
index c644615982..d9b5e8b72b 100644
--- a/firmware/console/binary/tunerstudio.h
+++ b/firmware/console/binary/tunerstudio.h
@@ -8,9 +8,6 @@
#pragma once
#include "global.h"
#include "tunerstudio_io.h"
-#include "electronic_throttle_generated.h"
-#include "knock_controller_generated.h"
-#include "FragmentEntry.h"
typedef struct {
int queryCommandCounter;
@@ -44,18 +41,7 @@ void requestBurn(void);
void startTunerStudioConnectivity(void);
-#if defined __GNUC__
-// GCC
-#define pre_packed
-#define post_packed __attribute__((packed))
-#else
-// IAR
-#define pre_packed __packed
-#define post_packed
-#endif
-
-typedef pre_packed struct
-post_packed {
+typedef struct {
short int offset;
short int count;
} TunerStudioWriteChunkRequest;
diff --git a/firmware/console/binary/tunerstudio.mk b/firmware/console/binary/tunerstudio.mk
index bcc035661e..45e7866d29 100644
--- a/firmware/console/binary/tunerstudio.mk
+++ b/firmware/console/binary/tunerstudio.mk
@@ -6,7 +6,6 @@ TUNERSTUDIO_SRC_CPP = $(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
$(PROJECT_DIR)/console/binary/ts_can_channel.cpp \
$(PROJECT_DIR)/console/binary/serial_can.cpp \
$(PROJECT_DIR)/console/binary/tunerstudio.cpp \
- $(PROJECT_DIR)/console/binary/FragmentEntry.cpp \
$(PROJECT_DIR)/console/binary/tunerstudio_commands.cpp \
$(PROJECT_DIR)/console/binary/bluetooth.cpp \
$(PROJECT_DIR)/console/binary/signature.cpp
diff --git a/firmware/console/binary/tunerstudio_impl.h b/firmware/console/binary/tunerstudio_impl.h
index 939c380d46..51d0e3047c 100644
--- a/firmware/console/binary/tunerstudio_impl.h
+++ b/firmware/console/binary/tunerstudio_impl.h
@@ -26,8 +26,12 @@ public:
bool handlePlainCommand(TsChannelBase* tsChannel, uint8_t command);
void cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, uint16_t count) override;
+ /**
+ * this command is part of protocol initialization
+ */
void handleQueryCommand(TsChannelBase* tsChannel, ts_response_format_e mode);
void handleExecuteCommand(TsChannelBase* tsChannel, char *data, int incomingPacketSize);
+ // does more or less nothing, we only handle the command to make frontend application happy
void handlePageSelectCommand(TsChannelBase *tsChannel, ts_response_format_e mode);
void handleWriteChunkCommand(TsChannelBase* tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count,
void *content);
diff --git a/firmware/console/binary/tunerstudio_io.cpp b/firmware/console/binary/tunerstudio_io.cpp
index 6c216f1fae..e637d71c0b 100644
--- a/firmware/console/binary/tunerstudio_io.cpp
+++ b/firmware/console/binary/tunerstudio_io.cpp
@@ -22,8 +22,6 @@ size_t TsChannelBase::read(uint8_t* buffer, size_t size) {
#define isBigPacket(size) ((size) > BLOCKING_FACTOR + 7)
void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size) {
- auto scratchBuffer = this->scratchBuffer;
-
// don't transmit too large a buffer
efiAssertVoid(OBD_PCM_Processor_Fault, !isBigPacket(size), "copyAndWriteSmallCrcPacket tried to transmit too large a packet")
@@ -32,7 +30,7 @@ void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8
// tsOutputChannels) during the CRC computation. Instead compute the CRC on our
// local buffer that nobody else will write.
if (size) {
- memcpy(scratchBuffer + 3, buf, size);
+ memcpy(scratchBuffer + SCRATCH_BUFFER_PREFIX_SIZE, buf, size);
}
crcAndWriteBuffer(responseCode, size);
@@ -41,7 +39,6 @@ void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8
void TsChannelBase::crcAndWriteBuffer(uint8_t responseCode, size_t size) {
efiAssertVoid(OBD_PCM_Processor_Fault, !isBigPacket(size), "crcAndWriteBuffer tried to transmit too large a packet")
- auto scratchBuffer = this->scratchBuffer;
// Index 0/1 = packet size (big endian)
*(uint16_t*)scratchBuffer = SWAP_UINT16(size + 1);
// Index 2 = response code
@@ -51,7 +48,7 @@ void TsChannelBase::crcAndWriteBuffer(uint8_t responseCode, size_t size) {
uint32_t crc = crc32(&scratchBuffer[2], size + 1); // command part of CRC
// Place the CRC at the end
- *reinterpret_cast(&scratchBuffer[size + 3]) = SWAP_UINT32(crc);
+ *reinterpret_cast(&scratchBuffer[size + SCRATCH_BUFFER_PREFIX_SIZE]) = SWAP_UINT32(crc);
// Write to the underlying stream
write(reinterpret_cast(scratchBuffer), size + 7, true);
diff --git a/firmware/console/binary/tunerstudio_io.h b/firmware/console/binary/tunerstudio_io.h
index 8debb66b2b..c4b30fa1b5 100644
--- a/firmware/console/binary/tunerstudio_io.h
+++ b/firmware/console/binary/tunerstudio_io.h
@@ -30,6 +30,8 @@
#include "pin_repository.h"
#endif
+#define SCRATCH_BUFFER_PREFIX_SIZE 3
+
class TsChannelBase {
public:
TsChannelBase(const char *name);
@@ -62,6 +64,18 @@ public:
void crcAndWriteBuffer(uint8_t responseCode, size_t size);
void copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size);
+ /* When TsChannel is in "not in sync" state tsProcessOne will silently try to find
+ * begining of packet.
+ * As soon as tsProcessOne was able to receive valid packet with valid size and crc
+ * TsChannel becomes "in sync". That means it will react on any futher errors: it will
+ * emit packet with error code and switch back to "not in sync" mode.
+ * This insures that RE will send only one error message after lost of syncronization
+ * with TS.
+ * Also while in "not in sync" state - tsProcessOne will not try to receive whole packet
+ * by one read. Instead after getting packet size it will try to receive one byte of
+ * command and check if it is supported. */
+ bool in_sync = false;
+
private:
void writeCrcPacketLarge(uint8_t responseCode, const uint8_t* buf, size_t size);
};
diff --git a/firmware/console/binary/tunerstudio_io_serial_ports.cpp b/firmware/console/binary/tunerstudio_io_serial_ports.cpp
index 35243dfbca..2245bc4d5d 100644
--- a/firmware/console/binary/tunerstudio_io_serial_ports.cpp
+++ b/firmware/console/binary/tunerstudio_io_serial_ports.cpp
@@ -93,12 +93,12 @@ void startSerialChannels() {
#if HAS_PRIMARY
// todo: invert setting one day?
if (!engineConfiguration->disablePrimaryUart) {
- primaryChannelThread.Start();
+ primaryChannelThread.start();
}
#endif
#if HAS_SECONDARY
- secondaryChannelThread.Start();
+ secondaryChannelThread.start();
#endif
}
diff --git a/firmware/console/binary_log/binary_logging.cpp b/firmware/console/binary_log/binary_logging.cpp
index 396c6c803f..4779477f6f 100644
--- a/firmware/console/binary_log/binary_logging.cpp
+++ b/firmware/console/binary_log/binary_logging.cpp
@@ -7,7 +7,6 @@
#include "binary_logging.h"
#include "log_field.h"
-#include "crc.h"
#include "buffered_writer.h"
#define TIME_PRECISION 1000
diff --git a/firmware/console/binary_log/log_fields_generated.h b/firmware/console/binary_log/log_fields_generated.h
index 7e91cdf5f0..54ef92a223 100644
--- a/firmware/console/binary_log/log_fields_generated.h
+++ b/firmware/console/binary_log/log_fields_generated.h
@@ -110,4 +110,8 @@ static constexpr LogField fields[] = {
{engine->outputChannels.auxLinear2, GAUGE_NAME_AUX_LINEAR_2, "", 2},
{engine->outputChannels.boostControllerOutput, GAUGE_NAME_BOOST_OUTPUT, "%", 1},
{engine->outputChannels.boostControllerOpenLoopPart, GAUGE_NAME_BOOST_OPEN_LOOP, "%", 1},
+ {engine->outputChannels.gppwmOutput[0], "GPPWM Output 1", "%", 1},
+ {engine->outputChannels.gppwmOutput[1], "GPPWM Output 2", "%", 1},
+ {engine->outputChannels.gppwmOutput[2], "GPPWM Output 3", "%", 1},
+ {engine->outputChannels.gppwmOutput[3], "GPPWM Output 4", "%", 1},
};
diff --git a/firmware/console/ethernet_console.cpp b/firmware/console/ethernet_console.cpp
index 8c0957908c..f734a3f5de 100644
--- a/firmware/console/ethernet_console.cpp
+++ b/firmware/console/ethernet_console.cpp
@@ -98,7 +98,7 @@ void startEthernetConsole() {
efiSetPadMode("ethernet", Gpio::G14, PAL_MODE_ALTERNATE(0xb));
#endif // STM32H7
- ethernetConsole.Start();
+ ethernetConsole.start();
}
#endif // EFI_ETHERNET
diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp
index 87f99b5986..6d8618cc32 100644
--- a/firmware/console/status_loop.cpp
+++ b/firmware/console/status_loop.cpp
@@ -67,8 +67,6 @@ extern bool main_loop_started;
#include "max31855.h"
#include "single_timer_executor.h"
#include "periodic_task.h"
-extern int icuRisingCallbackCounter;
-extern int icuFallingCallbackCounter;
#endif /* EFI_PROD_CODE */
#if EFI_CJ125
@@ -114,7 +112,7 @@ static void setWarningEnabled(int value) {
#if EFI_FILE_LOGGING
// this one needs to be in main ram so that SD card SPI DMA works fine
-static NO_CACHE char sdLogBuffer[220];
+static NO_CACHE char sdLogBuffer[250];
static uint64_t binaryLogCount = 0;
void writeLogLine(Writer& buffer) {
@@ -475,33 +473,33 @@ extern HIP9011 instance;
static void updateTempSensors() {
SensorResult clt = Sensor::get(SensorType::Clt);
- engine->outputChannels.coolant = clt.Value;
+ engine->outputChannels.coolant = clt.value_or(0);
engine->outputChannels.isCltError = !clt.Valid;
SensorResult iat = Sensor::get(SensorType::Iat);
- engine->outputChannels.intake = iat.Value;
+ engine->outputChannels.intake = iat.value_or(0);
engine->outputChannels.isIatError = !iat.Valid;
SensorResult auxTemp1 = Sensor::get(SensorType::AuxTemp1);
- engine->outputChannels.auxTemp1 = auxTemp1.Value;
+ engine->outputChannels.auxTemp1 = auxTemp1.value_or(0);
SensorResult auxTemp2 = Sensor::get(SensorType::AuxTemp2);
- engine->outputChannels.auxTemp2 = auxTemp2.Value;
+ engine->outputChannels.auxTemp2 = auxTemp2.value_or(0);
}
static void updateThrottles() {
SensorResult tps1 = Sensor::get(SensorType::Tps1);
- engine->outputChannels.TPSValue = tps1.Value;
+ engine->outputChannels.TPSValue = tps1.value_or(0);
engine->outputChannels.isTpsError = !tps1.Valid;
engine->outputChannels.tpsADC = convertVoltageTo10bitADC(Sensor::getRaw(SensorType::Tps1Primary));
SensorResult tps2 = Sensor::get(SensorType::Tps2);
- engine->outputChannels.TPS2Value = tps2.Value;
+ engine->outputChannels.TPS2Value = tps2.value_or(0);
// If we don't have a TPS2 at all, don't turn on the failure light
engine->outputChannels.isTps2Error = !tps2.Valid && Sensor::hasSensor(SensorType::Tps2Primary);
SensorResult pedal = Sensor::get(SensorType::AcceleratorPedal);
- engine->outputChannels.throttlePedalPosition = pedal.Value;
+ engine->outputChannels.throttlePedalPosition = pedal.value_or(0);
// Only report fail if you have one (many people don't)
engine->outputChannels.isPedalError = !pedal.Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
@@ -527,11 +525,11 @@ static void updateLambda() {
static void updateFuelSensors() {
// Low pressure is directly in kpa
- engine->outputChannels.lowFuelPressure = Sensor::get(SensorType::FuelPressureLow).Value;
+ engine->outputChannels.lowFuelPressure = Sensor::getOrZero(SensorType::FuelPressureLow);
// High pressure is in bar, aka 100 kpa
- engine->outputChannels.highFuelPressure = KPA2BAR(Sensor::get(SensorType::FuelPressureHigh).Value);
+ engine->outputChannels.highFuelPressure = KPA2BAR(Sensor::getOrZero(SensorType::FuelPressureHigh));
- engine->outputChannels.flexPercent = Sensor::get(SensorType::FuelEthanolPercent).Value;
+ engine->outputChannels.flexPercent = Sensor::getOrZero(SensorType::FuelEthanolPercent);
engine->outputChannels.fuelTankLevel = Sensor::getOrZero(SensorType::FuelLevel);
}
@@ -571,16 +569,23 @@ static void updateRawSensors() {
engine->outputChannels.rawWastegatePosition = Sensor::getRaw(SensorType::WastegatePosition);
engine->outputChannels.rawIdlePositionSensor = Sensor::getRaw(SensorType::IdlePosition);
+ for (int i = 0;iauxAnalogInputs[i];
+ if (ch != EFI_ADC_NONE) {
+ engine->outputChannels.rawAnalogInput[i] = getVoltageDivided("raw aux", ch);
+ }
+ }
+
// TODO: transition AFR to new sensor model
engine->outputChannels.rawAfr = (engineConfiguration->afr.hwChannel == EFI_ADC_NONE) ? 0 : getVoltageDivided("ego", engineConfiguration->afr.hwChannel);
}
static void updatePressures() {
engine->outputChannels.baroPressure = Sensor::getOrZero(SensorType::BarometricPressure);
engine->outputChannels.MAPValue = Sensor::getOrZero(SensorType::Map);
- engine->outputChannels.oilPressure = Sensor::get(SensorType::OilPressure).Value;
+ engine->outputChannels.oilPressure = Sensor::getOrZero(SensorType::OilPressure);
- engine->outputChannels.auxLinear1 = Sensor::get(SensorType::AuxLinear1).Value;
- engine->outputChannels.auxLinear2 = Sensor::get(SensorType::AuxLinear2).Value;
+ engine->outputChannels.auxLinear1 = Sensor::getOrZero(SensorType::AuxLinear1);
+ engine->outputChannels.auxLinear2 = Sensor::getOrZero(SensorType::AuxLinear2);
}
static void updateMiscSensors() {
@@ -710,7 +715,7 @@ static void updateTpsDebug() {
void updateTunerStudioState() {
TunerStudioOutputChannels *tsOutputChannels = &engine->outputChannels;
#if EFI_SHAFT_POSITION_INPUT
- int rpm = Sensor::get(SensorType::Rpm).Value;
+ int rpm = Sensor::get(SensorType::Rpm).value_or(0);
#else /* EFI_SHAFT_POSITION_INPUT */
int rpm = 0;
#endif /* EFI_SHAFT_POSITION_INPUT */
@@ -853,9 +858,6 @@ void updateTunerStudioState() {
break;
}
case DBG_TRIGGER_COUNTERS:
-#if EFI_PROD_CODE && HAL_USE_ICU == TRUE
- tsOutputChannels->debugFloatField3 = icuRisingCallbackCounter + icuFallingCallbackCounter;
-#endif /* EFI_PROD_CODE */
#if EFI_SHAFT_POSITION_INPUT
tsOutputChannels->debugIntField4 = engine->triggerCentral.triggerState.currentCycle.eventCount[0];
@@ -932,10 +934,10 @@ void startStatusThreads(void) {
// todo: refactoring needed, this file should probably be split into pieces
#if EFI_PROD_CODE
initStatusLeds();
- communicationsBlinkingTask.Start();
+ communicationsBlinkingTask.start();
#endif /* EFI_PROD_CODE */
#if EFI_LCD
- lcdInstance.Start();
+ lcdInstance.start();
#endif /* EFI_LCD */
}
diff --git a/firmware/console/usb_console.cpp b/firmware/console/usb_console.cpp
index 7b6fa32d4e..cc57b85de4 100644
--- a/firmware/console/usb_console.cpp
+++ b/firmware/console/usb_console.cpp
@@ -51,7 +51,7 @@ struct UsbThread : public TunerstudioThread {
static UsbThread usbConsole;
void startUsbConsole() {
- usbConsole.Start();
+ usbConsole.start();
}
#endif // EFI_USB_SERIAL
diff --git a/firmware/controllers/actuators/boost_control.cpp b/firmware/controllers/actuators/boost_control.cpp
index 4155143802..b8f237c359 100644
--- a/firmware/controllers/actuators/boost_control.cpp
+++ b/firmware/controllers/actuators/boost_control.cpp
@@ -28,6 +28,12 @@ void BoostController::init(IPwm* pwm, const ValueProvider3D* openLoopMap, const
m_closedLoopTargetMap = closedLoopTargetMap;
m_pid.initPidClass(pidParams);
+ resetLua();
+}
+
+void BoostController::resetLua() {
+ luaTargetAdd = 0;
+ luaTargetMult = 1;
}
void BoostController::onConfigurationChange(pid_s* previousConfiguration) {
@@ -60,7 +66,7 @@ expected BoostController::getSetpoint() {
efiAssert(OBD_PCM_Processor_Fault, m_closedLoopTargetMap != nullptr, "boost closed loop target", unexpected);
- return m_closedLoopTargetMap->getValue(rpm, tps.Value);
+ return m_closedLoopTargetMap->getValue(rpm, tps.Value) * luaTargetMult + luaTargetAdd;
}
expected BoostController::getOpenLoop(float target) {
@@ -152,7 +158,16 @@ void BoostController::update() {
m_pid.iTermMin = -50;
m_pid.iTermMax = 50;
- ClosedLoopController::update();
+ bool rpmTooLow = Sensor::getOrZero(SensorType::Rpm) < engineConfiguration->boostControlMinRpm;
+ bool tpsTooLow = Sensor::getOrZero(SensorType::Tps1) < engineConfiguration->boostControlMinTps;
+ bool mapTooLow = Sensor::getOrZero(SensorType::Map) < engineConfiguration->boostControlMinMap;
+
+ if (rpmTooLow || tpsTooLow || mapTooLow) {
+ // Passing unexpected will use the safe duty cycle configured by the user
+ setOutput(unexpected);
+ } else {
+ ClosedLoopController::update();
+ }
}
static bool hasInitBoost = false;
diff --git a/firmware/controllers/actuators/boost_control.h b/firmware/controllers/actuators/boost_control.h
index 19bdd90461..d80f96470f 100644
--- a/firmware/controllers/actuators/boost_control.h
+++ b/firmware/controllers/actuators/boost_control.h
@@ -17,6 +17,7 @@ class BoostController : public boost_control_s, public ClosedLoopController EtbController::getSetpointEtb() {
// 100% target from table -> 100% target position
idlePosition = interpolateClamped(0, etbIdleAddition, 100, 100, etbCurrentTarget);
- percent_t targetPosition = idlePosition + luaAdjustment;
+ percent_t targetPosition = idlePosition + getLuaAdjustment();
// Apply any adjustment that this throttle alone needs
// Clamped to +-10 to prevent anything too wild
trim = clampF(-10, getThrottleTrim(rpm, targetPosition), 10);
targetPosition += trim;
+ // Clamp before rev limiter to avoid ineffective rev limit due to crazy out of range position target
+ targetPosition = clampF(0, targetPosition, 100);
+
// Lastly, apply ETB rev limiter
auto etbRpmLimit = engineConfiguration->etbRevLimitStart;
if (etbRpmLimit != 0) {
@@ -361,6 +364,21 @@ expected EtbController::getSetpointEtb() {
return targetPosition;
}
+void EtbController::setLuaAdjustment(float adjustment) {
+ luaAdjustment = adjustment;
+ m_luaAdjustmentTimer.reset();
+}
+
+float EtbController::getLuaAdjustment() const {
+ // If the lua position hasn't been set in 0.2 second, don't adjust!
+ // This avoids a stuck throttle due to hung/rogue/etc Lua script
+ if (m_luaAdjustmentTimer.getElapsedSeconds() > 0.2f) {
+ return 0;
+ } else {
+ return luaAdjustment;
+ }
+}
+
percent_t EtbController2::getThrottleTrim(float /*rpm*/, percent_t /*targetPosition*/) const {
// TODO: implement me #3680
return 0;
@@ -632,7 +650,7 @@ struct EtbImpl final : public TBase {
// Check that the calibrate actually moved the throttle
if (absF(primaryMax - primaryMin) < 0.5f) {
- firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", primaryMin, primaryMax);
+ firmwareError(OBD_TPS_Configuration, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", primaryMin, primaryMax);
TBase::m_isAutocal = false;
return;
}
@@ -668,7 +686,7 @@ static EtbImpl etb1;
static EtbImpl etb2;
static_assert(ETB_COUNT == 2);
-EtbController* etbControllers[] = { &etb1, &etb2 };
+static EtbController* etbControllers[] = { &etb1, &etb2 };
struct EtbThread final : public PeriodicController<512> {
EtbThread() : PeriodicController("ETB", PRIO_ETB, ETB_LOOP_FREQUENCY) {}
@@ -990,7 +1008,7 @@ void doInitElectronicThrottle() {
#endif /* EFI_UNIT_TEST */
#if !EFI_UNIT_TEST
- etbThread.Start();
+ etbThread.start();
#endif
}
@@ -1029,6 +1047,14 @@ void setEtbWastegatePosition(percent_t pos) {
}
}
+void setEtbLuaAdjustment(percent_t pos) {
+ for (int i = 0; i < ETB_COUNT; i++) {
+ if (auto etb = engine->etbControllers[i]) {
+ etb->setLuaAdjustment(pos);
+ }
+ }
+}
+
void set18919_AM810_pedal_position_sensor() {
engineConfiguration->throttlePedalUpVoltage = 0.1;
engineConfiguration->throttlePedalWOTVoltage = 4.5;
diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h
index 7f8bfcbf26..531f71c916 100644
--- a/firmware/controllers/actuators/electronic_throttle.h
+++ b/firmware/controllers/actuators/electronic_throttle.h
@@ -15,6 +15,7 @@ void doInitElectronicThrottle();
void setEtbIdlePosition(percent_t pos);
void setEtbWastegatePosition(percent_t pos);
+void setEtbLuaAdjustment(percent_t adjustment);
void setHitachiEtbCalibration();
// these two sensors use same plug but have different calibrations and even rotate in different directions
@@ -54,4 +55,6 @@ public:
virtual void autoCalibrateTps() = 0;
virtual const pid_state_s* getPidState() const = 0;
+
+ virtual void setLuaAdjustment(percent_t adjustment) = 0;
};
diff --git a/firmware/controllers/actuators/electronic_throttle_impl.h b/firmware/controllers/actuators/electronic_throttle_impl.h
index 2ff062958f..4fba3b16a4 100644
--- a/firmware/controllers/actuators/electronic_throttle_impl.h
+++ b/firmware/controllers/actuators/electronic_throttle_impl.h
@@ -66,6 +66,10 @@ public:
return 0;
}
+ // Lua throttle adjustment
+ void setLuaAdjustment(percent_t adjustment) override;
+ float getLuaAdjustment() const;
+
protected:
// This is set if an automatic TPS calibration should be run
bool m_isAutocal = false;
@@ -103,6 +107,8 @@ private:
uint8_t m_autotuneCounter = 0;
uint8_t m_autotuneCurrentParam = 0;
+
+ Timer m_luaAdjustmentTimer;
};
class EtbController1 : public EtbController { };
diff --git a/firmware/controllers/actuators/fan_control.cpp b/firmware/controllers/actuators/fan_control.cpp
index be85ee2942..5dcf950486 100644
--- a/firmware/controllers/actuators/fan_control.cpp
+++ b/firmware/controllers/actuators/fan_control.cpp
@@ -5,16 +5,16 @@
#include "bench_test.h"
bool FanController::getState(bool acActive, bool lastState) {
- auto [cltValid, clt] = Sensor::get(SensorType::Clt);
+ auto clt = Sensor::get(SensorType::Clt);
cranking = engine->rpmCalculator.isCranking();
notRunning = !engine->rpmCalculator.isRunning();
disabledWhileEngineStopped = notRunning && disableWhenStopped();
- brokenClt = !cltValid;
+ brokenClt = !clt;
enabledForAc = enableWithAc() && acActive;
- hot = clt > getFanOnTemp();
- cold = clt < getFanOffTemp();
+ hot = clt.value_or(0) > getFanOnTemp();
+ cold = clt.value_or(0) < getFanOffTemp();
if (cranking) {
// Inhibit while cranking
diff --git a/firmware/controllers/actuators/gppwm/gppwm.cpp b/firmware/controllers/actuators/gppwm/gppwm.cpp
index dc0f2770a1..3fd6eb9797 100644
--- a/firmware/controllers/actuators/gppwm/gppwm.cpp
+++ b/firmware/controllers/actuators/gppwm/gppwm.cpp
@@ -53,11 +53,6 @@ void updateGppwm() {
for (size_t i = 0; i < efi::size(channels); i++) {
float result = channels[i].update();
-#ifdef EFI_TUNER_STUDIO
- if (engineConfiguration->debugMode == DBG_GPPWM) {
- scaled_channel* debugFloats = &engine->outputChannels.debugFloatField1;
- debugFloats[i] = result;
- }
-#endif
+ engine->outputChannels.gppwmOutput[i] = result;
}
}
diff --git a/firmware/controllers/actuators/idle_state.txt b/firmware/controllers/actuators/idle_state.txt
index 850c7b2138..f53e2a5900 100644
--- a/firmware/controllers/actuators/idle_state.txt
+++ b/firmware/controllers/actuators/idle_state.txt
@@ -5,21 +5,21 @@ custom idle_state_e 4 bits, S32, @OFFSET@, [0:2], "not important"
custom percent_t 4 scalar, F32, @OFFSET@, "", 1, 0, 0, 100, 2
- percent_t currentIdlePosition;that's current position with CLT and IAT corrections
- percent_t baseIdlePosition;current position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration)
- percent_t iacByTpsTaper;iacByTpsTaper portion of idle
+ percent_t currentIdlePosition;"idle: current position\nthat's current position with CLT and IAT corrections"
+ percent_t baseIdlePosition;"idle: base value\ncurrent position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration)"
+ percent_t iacByTpsTaper;idle: iacByTpsTaper portion of idle
int throttlePedalUpState;true in IDLE throttle pedal state, false if driver is touching the pedal\ntodo: better name for this field?
bit mightResetPid;The idea of 'mightResetPid' is to reset PID only once - each time when TPS > idlePidDeactivationTpsThreshold.\nThe throttle pedal can be pressed for a long time, making the PID data obsolete (thus the reset is required).\nWe set 'mightResetPid' to true only if PID was actually used (i.e. idlePid.getOutput() was called) to save some CPU resources.\nSee automaticIdleController().
-bit shouldResetPid;
-bit wasResetPid;This is needed to slowly turn on the PID back after it was reset.
-bit mustResetPid;This is used when the PID configuration is changed, to guarantee the reset
-bit isCoasting
+bit shouldResetPid;idle: shouldResetPid
+bit wasResetPid;idle: wasResetPid\nThis is needed to slowly turn on the PID back after it was reset.
+bit mustResetPid;idle: mustResetPid\nThis is used when the PID configuration is changed, to guarantee the reset
+bit isCoasting;idle: coasting
bit useIacTableForCoasting
bit notIdling
-bit needReset
-bit isInDeadZone
+bit needReset;idle: reset
+bit isInDeadZone;idle: dead zone
bit isBlipping
bit useClosedLoop
bit badTps
@@ -30,8 +30,8 @@ bit useInstantRpmForIdle
bit isVerboseIAC
-int targetRpmByClt
-int targetRpmAcBump
+int targetRpmByClt;idle: target by CLT
+int targetRpmAcBump;idle: A/C bump
! end of idle_state_s structure definition
end_struct
diff --git a/firmware/controllers/actuators/idle_state_generated.h b/firmware/controllers/actuators/idle_state_generated.h
index 67c6e2fd3b..8659ce8cc5 100644
--- a/firmware/controllers/actuators/idle_state_generated.h
+++ b/firmware/controllers/actuators/idle_state_generated.h
@@ -1,4 +1,4 @@
-// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Sun Apr 17 20:27:25 UTC 2022
+// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Fri Jul 08 05:13:11 UTC 2022
// by class com.rusefi.output.CHeaderConsumer
// begin
#pragma once
@@ -10,17 +10,19 @@ struct idle_state_s {
*/
idle_state_e idleState = (idle_state_e)0;
/**
- * that's current position with CLT and IAT corrections
+ * "idle: current position
+ * that's current position with CLT and IAT corrections"
* offset 4
*/
percent_t currentIdlePosition = (percent_t)0;
/**
- * current position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration)
+ * "idle: base value
+ * current position without adjustments (iacByTpsTaper, afterCrankingIACtaperDuration)"
* offset 8
*/
percent_t baseIdlePosition = (percent_t)0;
/**
- * iacByTpsTaper portion of idle
+ * idle: iacByTpsTaper portion of idle
* offset 12
*/
percent_t iacByTpsTaper = (percent_t)0;
@@ -38,17 +40,21 @@ struct idle_state_s {
offset 20 bit 0 */
bool mightResetPid : 1 {};
/**
+ * idle: shouldResetPid
offset 20 bit 1 */
bool shouldResetPid : 1 {};
/**
+ * idle: wasResetPid
* This is needed to slowly turn on the PID back after it was reset.
offset 20 bit 2 */
bool wasResetPid : 1 {};
/**
+ * idle: mustResetPid
* This is used when the PID configuration is changed, to guarantee the reset
offset 20 bit 3 */
bool mustResetPid : 1 {};
/**
+ * idle: coasting
offset 20 bit 4 */
bool isCoasting : 1 {};
/**
@@ -58,9 +64,11 @@ struct idle_state_s {
offset 20 bit 6 */
bool notIdling : 1 {};
/**
+ * idle: reset
offset 20 bit 7 */
bool needReset : 1 {};
/**
+ * idle: dead zone
offset 20 bit 8 */
bool isInDeadZone : 1 {};
/**
@@ -133,10 +141,12 @@ struct idle_state_s {
offset 20 bit 31 */
bool unusedBit_22_31 : 1 {};
/**
+ * idle: target by CLT
* offset 24
*/
int targetRpmByClt = (int)0;
/**
+ * idle: A/C bump
* offset 28
*/
int targetRpmAcBump = (int)0;
@@ -144,4 +154,4 @@ struct idle_state_s {
static_assert(sizeof(idle_state_s) == 32);
// end
-// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Sun Apr 17 20:27:25 UTC 2022
+// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/idle_state.txt Fri Jul 08 05:13:11 UTC 2022
diff --git a/firmware/controllers/actuators/idle_thread.h b/firmware/controllers/actuators/idle_thread.h
index 6e2a7b3278..e88e2c1ee3 100644
--- a/firmware/controllers/actuators/idle_thread.h
+++ b/firmware/controllers/actuators/idle_thread.h
@@ -105,7 +105,6 @@ void setManualIdleValvePosition(int positionPercent);
void startIdleThread();
void setDefaultIdleParameters();
void startIdleBench(void);
-void setIdleOffset(float value);
void setIdlePFactor(float value);
void setIdleIFactor(float value);
void setIdleDFactor(float value);
diff --git a/firmware/controllers/actuators/idle_thread_io.cpp b/firmware/controllers/actuators/idle_thread_io.cpp
index d7ed364b12..b04e686722 100644
--- a/firmware/controllers/actuators/idle_thread_io.cpp
+++ b/firmware/controllers/actuators/idle_thread_io.cpp
@@ -139,11 +139,6 @@ void setTargetIdleRpm(int value) {
showIdleInfo();
}
-void setIdleOffset(float value) {
- engineConfiguration->idleRpmPid.offset = value;
- showIdleInfo();
-}
-
void setIdlePFactor(float value) {
engineConfiguration->idleRpmPid.pFactor = value;
applyPidSettings();
@@ -213,6 +208,9 @@ static void blipIdle(int idlePosition, int durationMs) {
}
void startIdleThread() {
+ // Force the idle controller to use 0 offset, as this is handled by the open loop table instead.
+ engineConfiguration->idleRpmPid.offset = 0;
+
engine->module().unmock().init();
#if ! EFI_UNIT_TEST
diff --git a/firmware/controllers/actuators/vvt.cpp b/firmware/controllers/actuators/vvt.cpp
index 95be6a7d7d..4ecd760e48 100644
--- a/firmware/controllers/actuators/vvt.cpp
+++ b/firmware/controllers/actuators/vvt.cpp
@@ -156,7 +156,7 @@ void initAuxPid() {
startVvtControlPins();
for (int i = 0;i < CAM_INPUTS_COUNT;i++) {
- instances[i].Start();
+ instances[i].start();
}
}
diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp
index 27f407a51c..a8bb4922d9 100644
--- a/firmware/controllers/algo/advance_map.cpp
+++ b/firmware/controllers/algo/advance_map.cpp
@@ -55,10 +55,10 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) {
engine->module()->isIdlingOrTaper()) {
float idleAdvance = interpolate2d(rpm, config->idleAdvanceBins, config->idleAdvance);
- auto [valid, tps] = Sensor::get(SensorType::DriverThrottleIntent);
- if (valid) {
+ auto tps = Sensor::get(SensorType::DriverThrottleIntent);
+ if (tps) {
// interpolate between idle table and normal (running) table using TPS threshold
- advanceAngle = interpolateClamped(0.0f, idleAdvance, engineConfiguration->idlePidDeactivationTpsThreshold, advanceAngle, tps);
+ advanceAngle = interpolateClamped(0.0f, idleAdvance, engineConfiguration->idlePidDeactivationTpsThreshold, advanceAngle, tps.Value);
}
}
@@ -66,10 +66,10 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) {
if (engine->launchController.isLaunchCondition && engineConfiguration->enableLaunchRetard) {
if (engineConfiguration->launchSmoothRetard) {
float launchAngle = engineConfiguration->launchTimingRetard;
- int launchAdvanceRpmRange = engineConfiguration->launchTimingRpmRange;
int launchRpm = engineConfiguration->launchRpm;
+ int launchRpmWithTimingRange = launchRpm + engineConfiguration->launchTimingRpmRange;
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm + launchTimingRpmRange
- return interpolateClamped(launchRpm, advanceAngle, (launchRpm + launchAdvanceRpmRange), launchAngle, rpm);
+ return interpolateClamped(launchRpm, advanceAngle, launchRpmWithTimingRange, launchAngle, rpm);
} else {
return engineConfiguration->launchTimingRetard;
}
@@ -80,14 +80,14 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) {
}
angle_t getAdvanceCorrections(int rpm) {
- const auto [iatValid, iat] = Sensor::get(SensorType::Iat);
+ auto iat = Sensor::get(SensorType::Iat);
- if (!iatValid) {
+ if (!iat) {
engine->engineState.timingIatCorrection = 0;
} else {
engine->engineState.timingIatCorrection = interpolate3d(
config->ignitionIatCorrTable,
- config->ignitionIatCorrLoadBins, iat,
+ config->ignitionIatCorrLoadBins, iat.Value,
config->ignitionIatCorrRpmBins, rpm
);
}
diff --git a/firmware/controllers/algo/advance_map.h b/firmware/controllers/algo/advance_map.h
index 52f0077c47..7421b5edb8 100644
--- a/firmware/controllers/algo/advance_map.h
+++ b/firmware/controllers/algo/advance_map.h
@@ -18,9 +18,5 @@ size_t getMultiSparkCount(int rpm);
class IgnitionState : public ignition_state_s {
public:
- IgnitionState() {
- // todo https://github.com/rusefi/rusefi/issues/4308
- luaTimingMult = 1;
- }
floatms_t getSparkDwell(int rpm);
};
diff --git a/firmware/controllers/algo/auto_generated_enginetypes.cpp b/firmware/controllers/algo/auto_generated_enginetypes.cpp
index 9d4395c3fe..1f5de641c5 100644
--- a/firmware/controllers/algo/auto_generated_enginetypes.cpp
+++ b/firmware/controllers/algo/auto_generated_enginetypes.cpp
@@ -1,6 +1,6 @@
#include "global.h"
#include "engine_types.h"
-// was generated automatically by rusEFI tool from engine_types.h // by enum2string.jar tool on Fri Jun 24 00:17:24 UTC 2022
+// was generated automatically by rusEFI tool from engine_types.h // by enum2string.jar tool on Wed Jul 27 09:37:50 UTC 2022
// see also gen_config_and_enums.bat
@@ -50,6 +50,8 @@ case DBG_11:
return "DBG_11";
case DBG_16:
return "DBG_16";
+case DBG_2:
+ return "DBG_2";
case DBG_20:
return "DBG_20";
case DBG_24:
@@ -98,10 +100,6 @@ case DBG_ETB_AUTOTUNE:
return "DBG_ETB_AUTOTUNE";
case DBG_EXECUTOR:
return "DBG_EXECUTOR";
-case DBG_GPPWM:
- return "DBG_GPPWM";
-case DBG_IDLE_CONTROL:
- return "DBG_IDLE_CONTROL";
case DBG_INSTANT_RPM:
return "DBG_INSTANT_RPM";
case DBG_ION:
@@ -122,6 +120,8 @@ case DBG_SOFT_SPARK_CUT:
return "DBG_SOFT_SPARK_CUT";
case DBG_SR5_PROTOCOL:
return "DBG_SR5_PROTOCOL";
+case DBG_STEPPER_IDLE_CONTROL:
+ return "DBG_STEPPER_IDLE_CONTROL";
case DBG_TCU:
return "DBG_TCU";
case DBG_TLE8888:
diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp
index 0bc010371e..33bc040065 100644
--- a/firmware/controllers/algo/engine.cpp
+++ b/firmware/controllers/algo/engine.cpp
@@ -311,11 +311,16 @@ void Engine::updateSwitchInputs() {
if (isBrainPinValid(engineConfiguration->clutchDownPin)) {
engine->engineState.clutchDownState = engineConfiguration->clutchDownPinInverted ^ efiReadPin(engineConfiguration->clutchDownPin);
}
- if (hasAcToggle()) {
- bool result = getAcToggle();
+ {
+ bool currentState;
+ if (hasAcToggle()) {
+ currentState = getAcToggle();
+ } else {
+ currentState = engine->engineState.lua.acRequestState;
+ }
AcController & acController = engine->module().unmock();
- if (acController.acButtonState != result) {
- acController.acButtonState = result;
+ if (acController.acButtonState != currentState) {
+ acController.acButtonState = currentState;
acController.acSwitchLastChangeTimeMs = US2MS(getTimeNowUs());
}
}
@@ -348,8 +353,19 @@ void Engine::reset() {
*/
engineCycle = getEngineCycle(FOUR_STROKE_CRANK_SENSOR);
memset(&ignitionPin, 0, sizeof(ignitionPin));
+ resetLua();
}
+void Engine::resetLua() {
+ // todo: https://github.com/rusefi/rusefi/issues/4308
+ engineState.lua = {};
+ engineState.lua.fuelMult = 1;
+#if EFI_BOOST_CONTROL
+ boostController.resetLua();
+#endif // EFI_BOOST_CONTROL
+ ignitionState.luaTimingAdd = 0;
+ ignitionState.luaTimingMult = 1;
+}
/**
* Here we have a bunch of stuff which should invoked after configuration change
@@ -369,24 +385,20 @@ void Engine::preCalculate() {
#if EFI_SHAFT_POSITION_INPUT
void Engine::OnTriggerStateDecodingError() {
- warning(CUSTOM_SYNC_COUNT_MISMATCH, "trigger not happy current %d/%d/%d expected %d/%d/%d",
+ warning(CUSTOM_SYNC_COUNT_MISMATCH, "trigger not happy current %d/%d expected %d/%d",
triggerCentral.triggerState.currentCycle.eventCount[0],
triggerCentral.triggerState.currentCycle.eventCount[1],
- triggerCentral.triggerState.currentCycle.eventCount[2],
TRIGGER_WAVEFORM(getExpectedEventCount(0)),
- TRIGGER_WAVEFORM(getExpectedEventCount(1)),
- TRIGGER_WAVEFORM(getExpectedEventCount(2)));
+ TRIGGER_WAVEFORM(getExpectedEventCount(1)));
if (engineConfiguration->verboseTriggerSynchDetails || (triggerCentral.triggerState.someSortOfTriggerError() && !engineConfiguration->silentTriggerError)) {
#if EFI_PROD_CODE
- efiPrintf("error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d",
+ efiPrintf("error: synchronizationPoint @ index %d expected %d/%d got %d/%d",
triggerCentral.triggerState.currentCycle.current_index,
TRIGGER_WAVEFORM(getExpectedEventCount(0)),
TRIGGER_WAVEFORM(getExpectedEventCount(1)),
- TRIGGER_WAVEFORM(getExpectedEventCount(2)),
triggerCentral.triggerState.currentCycle.eventCount[0],
- triggerCentral.triggerState.currentCycle.eventCount[1],
- triggerCentral.triggerState.currentCycle.eventCount[2]);
+ triggerCentral.triggerState.currentCycle.eventCount[1]);
#endif /* EFI_PROD_CODE */
}
@@ -426,13 +438,11 @@ void Engine::OnTriggerSyncronization(bool wasSynchronized, bool isDecodingError)
engine->triggerErrorDetection.add(isDecodingError);
if (triggerCentral.isTriggerDecoderError()) {
- warning(CUSTOM_OBD_TRG_DECODING, "trigger decoding issue. expected %d/%d/%d got %d/%d/%d",
+ warning(CUSTOM_OBD_TRG_DECODING, "trigger decoding issue. expected %d/%d got %d/%d",
TRIGGER_WAVEFORM(getExpectedEventCount(0)),
TRIGGER_WAVEFORM(getExpectedEventCount(1)),
- TRIGGER_WAVEFORM(getExpectedEventCount(2)),
triggerCentral.triggerState.currentCycle.eventCount[0],
- triggerCentral.triggerState.currentCycle.eventCount[1],
- triggerCentral.triggerState.currentCycle.eventCount[2]);
+ triggerCentral.triggerState.currentCycle.eventCount[1]);
}
}
diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h
index 5213a5ca63..639724d534 100644
--- a/firmware/controllers/algo/engine.h
+++ b/firmware/controllers/algo/engine.h
@@ -40,6 +40,7 @@
#include "gear_detector.h"
#include "advance_map.h"
#include "fan_control.h"
+#include "sensor_checker.h"
#ifndef EFI_UNIT_TEST
#error EFI_UNIT_TEST must be defined!
@@ -192,6 +193,7 @@ public:
GearDetector,
#endif // EFI_VEHICLE_SPEED
KnockController,
+ SensorChecker,
EngineModule // dummy placeholder so the previous entries can all have commas
> engineModules;
@@ -219,11 +221,11 @@ public:
#endif // EFI_BOOST_CONTROL
IgnitionState ignitionState;
+ void resetLua();
FanControl1 fan1;
FanControl2 fan2;
-
efitick_t mostRecentSparkEvent;
efitick_t mostRecentTimeBetweenSparkEvents;
efitick_t mostRecentIgnitionEvent;
@@ -468,6 +470,9 @@ void prepareOutputSignals();
void validateConfiguration();
void doScheduleStopEngine();
+void scheduleReboot();
+bool isLockedFromUser();
+void unlockEcu(int password);
#define HW_CHECK_RPM 200
diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp
index 561bafe769..43eda22baf 100644
--- a/firmware/controllers/algo/engine2.cpp
+++ b/firmware/controllers/algo/engine2.cpp
@@ -17,6 +17,7 @@
#include "closed_loop_fuel.h"
#include "launch_control.h"
#include "injector_model.h"
+#include "tunerstudio.h"
#if EFI_PROD_CODE
#include "svnversion.h"
@@ -79,8 +80,6 @@ float FuelConsumptionState::getConsumptionGramPerSecond() const {
EngineState::EngineState() {
timeSinceLastTChargeK = getTimeNowNt();
- // todo: https://github.com/rusefi/rusefi/issues/4308
- lua.fuelMult = 1;
}
void EngineState::updateSlowSensors() {
@@ -224,3 +223,25 @@ trigger_config_s VvtTriggerConfiguration::getType() const {
bool VvtTriggerConfiguration::isVerboseTriggerSynchDetails() const {
return engineConfiguration->verboseVVTDecoding;
}
+
+bool isLockedFromUser() {
+ int lock = engineConfiguration->tuneHidingKey;
+ bool isLocked = lock > 0;
+ if (isLocked) {
+ firmwareError(OBD_PCM_Processor_Fault, "password protected");
+ }
+ return isLocked;
+}
+
+void unlockEcu(int password) {
+ if (password != engineConfiguration->tuneHidingKey) {
+ efiPrintf("Nope rebooting...");
+#if EFI_PROD_CODE
+ scheduleReboot();
+#endif // EFI_PROD_CODE
+ } else {
+ efiPrintf("Unlocked! Burning...");
+ engineConfiguration->tuneHidingKey = 0;
+ requestBurn();
+ }
+}
diff --git a/firmware/controllers/algo/engine_state.txt b/firmware/controllers/algo/engine_state.txt
index e4078af7b7..43a4c69cad 100644
--- a/firmware/controllers/algo/engine_state.txt
+++ b/firmware/controllers/algo/engine_state.txt
@@ -8,6 +8,7 @@ struct LuaAdjustments
bit clutchUpState
bit brakePedalState
+ bit acRequestState
end_struct
diff --git a/firmware/controllers/algo/engine_state_generated.h b/firmware/controllers/algo/engine_state_generated.h
index 55be3e96f4..145a7a4b9a 100644
--- a/firmware/controllers/algo/engine_state_generated.h
+++ b/firmware/controllers/algo/engine_state_generated.h
@@ -1,4 +1,4 @@
-// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Thu Jun 30 17:52:53 UTC 2022
+// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Fri Jul 08 04:44:35 UTC 2022
// by class com.rusefi.output.CHeaderConsumer
// begin
#pragma once
@@ -21,94 +21,94 @@ struct LuaAdjustments {
bool brakePedalState : 1 {};
/**
offset 8 bit 2 */
- bool unusedBit_4_2 : 1 {};
+ bool acRequestState : 1 {};
/**
offset 8 bit 3 */
- bool unusedBit_4_3 : 1 {};
+ bool unusedBit_5_3 : 1 {};
/**
offset 8 bit 4 */
- bool unusedBit_4_4 : 1 {};
+ bool unusedBit_5_4 : 1 {};
/**
offset 8 bit 5 */
- bool unusedBit_4_5 : 1 {};
+ bool unusedBit_5_5 : 1 {};
/**
offset 8 bit 6 */
- bool unusedBit_4_6 : 1 {};
+ bool unusedBit_5_6 : 1 {};
/**
offset 8 bit 7 */
- bool unusedBit_4_7 : 1 {};
+ bool unusedBit_5_7 : 1 {};
/**
offset 8 bit 8 */
- bool unusedBit_4_8 : 1 {};
+ bool unusedBit_5_8 : 1 {};
/**
offset 8 bit 9 */
- bool unusedBit_4_9 : 1 {};
+ bool unusedBit_5_9 : 1 {};
/**
offset 8 bit 10 */
- bool unusedBit_4_10 : 1 {};
+ bool unusedBit_5_10 : 1 {};
/**
offset 8 bit 11 */
- bool unusedBit_4_11 : 1 {};
+ bool unusedBit_5_11 : 1 {};
/**
offset 8 bit 12 */
- bool unusedBit_4_12 : 1 {};
+ bool unusedBit_5_12 : 1 {};
/**
offset 8 bit 13 */
- bool unusedBit_4_13 : 1 {};
+ bool unusedBit_5_13 : 1 {};
/**
offset 8 bit 14 */
- bool unusedBit_4_14 : 1 {};
+ bool unusedBit_5_14 : 1 {};
/**
offset 8 bit 15 */
- bool unusedBit_4_15 : 1 {};
+ bool unusedBit_5_15 : 1 {};
/**
offset 8 bit 16 */
- bool unusedBit_4_16 : 1 {};
+ bool unusedBit_5_16 : 1 {};
/**
offset 8 bit 17 */
- bool unusedBit_4_17 : 1 {};
+ bool unusedBit_5_17 : 1 {};
/**
offset 8 bit 18 */
- bool unusedBit_4_18 : 1 {};
+ bool unusedBit_5_18 : 1 {};
/**
offset 8 bit 19 */
- bool unusedBit_4_19 : 1 {};
+ bool unusedBit_5_19 : 1 {};
/**
offset 8 bit 20 */
- bool unusedBit_4_20 : 1 {};
+ bool unusedBit_5_20 : 1 {};
/**
offset 8 bit 21 */
- bool unusedBit_4_21 : 1 {};
+ bool unusedBit_5_21 : 1 {};
/**
offset 8 bit 22 */
- bool unusedBit_4_22 : 1 {};
+ bool unusedBit_5_22 : 1 {};
/**
offset 8 bit 23 */
- bool unusedBit_4_23 : 1 {};
+ bool unusedBit_5_23 : 1 {};
/**
offset 8 bit 24 */
- bool unusedBit_4_24 : 1 {};
+ bool unusedBit_5_24 : 1 {};
/**
offset 8 bit 25 */
- bool unusedBit_4_25 : 1 {};
+ bool unusedBit_5_25 : 1 {};
/**
offset 8 bit 26 */
- bool unusedBit_4_26 : 1 {};
+ bool unusedBit_5_26 : 1 {};
/**
offset 8 bit 27 */
- bool unusedBit_4_27 : 1 {};
+ bool unusedBit_5_27 : 1 {};
/**
offset 8 bit 28 */
- bool unusedBit_4_28 : 1 {};
+ bool unusedBit_5_28 : 1 {};
/**
offset 8 bit 29 */
- bool unusedBit_4_29 : 1 {};
+ bool unusedBit_5_29 : 1 {};
/**
offset 8 bit 30 */
- bool unusedBit_4_30 : 1 {};
+ bool unusedBit_5_30 : 1 {};
/**
offset 8 bit 31 */
- bool unusedBit_4_31 : 1 {};
+ bool unusedBit_5_31 : 1 {};
};
static_assert(sizeof(LuaAdjustments) == 12);
@@ -496,4 +496,4 @@ struct engine_state_s {
static_assert(sizeof(engine_state_s) == 140);
// end
-// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Thu Jun 30 17:52:53 UTC 2022
+// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Fri Jul 08 04:44:35 UTC 2022
diff --git a/firmware/controllers/algo/engine_types.h b/firmware/controllers/algo/engine_types.h
index d25059a83a..a66bf7821c 100644
--- a/firmware/controllers/algo/engine_types.h
+++ b/firmware/controllers/algo/engine_types.h
@@ -238,8 +238,8 @@ typedef enum __attribute__ ((__packed__)) {
typedef enum __attribute__ ((__packed__)) {
DBG_0 = 0,
DBG_TPS_ACCEL = 1,
- DBG_GPPWM = 2,
- DBG_IDLE_CONTROL = 3,
+ DBG_2 = 2,
+ DBG_STEPPER_IDLE_CONTROL = 3,
DBG_EL_ACCEL = 4,
DBG_TRIGGER_COUNTERS = 5,
DBG_SOFT_SPARK_CUT = 6,
diff --git a/firmware/controllers/algo/fuel/dfco.cpp b/firmware/controllers/algo/fuel/dfco.cpp
index 8b9bcbd4db..8b4183e507 100644
--- a/firmware/controllers/algo/fuel/dfco.cpp
+++ b/firmware/controllers/algo/fuel/dfco.cpp
@@ -5,21 +5,21 @@ bool DfcoController::getState() const {
return false;
}
- const auto [tpsValid, tpsPos] = Sensor::get(SensorType::DriverThrottleIntent);
- const auto [cltValid, clt] = Sensor::get(SensorType::Clt);
- const auto [mapValid, map] = Sensor::get(SensorType::Map);
+ const auto tps = Sensor::get(SensorType::DriverThrottleIntent);
+ const auto clt = Sensor::get(SensorType::Clt);
+ const auto map = Sensor::get(SensorType::Map);
// If some sensor is broken, inhibit DFCO
- if (!tpsValid || !cltValid || !mapValid) {
+ if (!tps || !clt || !map) {
return false;
}
float rpm = Sensor::getOrZero(SensorType::Rpm);
float vss = Sensor::getOrZero(SensorType::VehicleSpeed);
- bool mapActivate = map < engineConfiguration->coastingFuelCutMap;
- bool tpsActivate = tpsPos < engineConfiguration->coastingFuelCutTps;
- bool cltActivate = clt > engineConfiguration->coastingFuelCutClt;
+ bool mapActivate = map.Value < engineConfiguration->coastingFuelCutMap;
+ bool tpsActivate = tps.Value < engineConfiguration->coastingFuelCutTps;
+ bool cltActivate = clt.Value > engineConfiguration->coastingFuelCutClt;
// True if throttle, MAP, and CLT are all acceptable for DFCO to occur
bool dfcoAllowed = mapActivate && tpsActivate && cltActivate;
diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp
index ddaa3687d2..7031bd1286 100644
--- a/firmware/controllers/algo/fuel_math.cpp
+++ b/firmware/controllers/algo/fuel_math.cpp
@@ -344,30 +344,30 @@ void initFuelMap() {
* @brief Engine warm-up fuel correction.
*/
float getCltFuelCorrection() {
- const auto [valid, clt] = Sensor::get(SensorType::Clt);
+ const auto clt = Sensor::get(SensorType::Clt);
- if (!valid)
+ if (!clt)
return 1; // this error should be already reported somewhere else, let's just handle it
- return interpolate2d(clt, config->cltFuelCorrBins, config->cltFuelCorr);
+ return interpolate2d(clt.Value, config->cltFuelCorrBins, config->cltFuelCorr);
}
angle_t getCltTimingCorrection() {
- const auto [valid, clt] = Sensor::get(SensorType::Clt);
+ const auto clt = Sensor::get(SensorType::Clt);
- if (!valid)
+ if (!clt)
return 0; // this error should be already reported somewhere else, let's just handle it
- return interpolate2d(clt, config->cltTimingBins, config->cltTimingExtra);
+ return interpolate2d(clt.Value, config->cltTimingBins, config->cltTimingExtra);
}
float getIatFuelCorrection() {
- const auto [valid, iat] = Sensor::get(SensorType::Iat);
+ const auto iat = Sensor::get(SensorType::Iat);
- if (!valid)
+ if (!iat)
return 1; // this error should be already reported somewhere else, let's just handle it
- return interpolate2d(iat, config->iatFuelCorrBins, config->iatFuelCorr);
+ return interpolate2d(iat.Value, config->iatFuelCorrBins, config->iatFuelCorr);
}
float getBaroCorrection() {
diff --git a/firmware/controllers/algo/gear_detector.cpp b/firmware/controllers/algo/gear_detector.cpp
index 179f144139..ab5412b182 100644
--- a/firmware/controllers/algo/gear_detector.cpp
+++ b/firmware/controllers/algo/gear_detector.cpp
@@ -77,7 +77,7 @@ size_t GearDetector::determineGearFromRatio(float ratio) const {
return currentGear;
}
-float GearDetector::computeGearboxRatio() const {
+float GearDetector::getDriveshaftRpm() const {
auto vssKph = Sensor::getOrZero(SensorType::VehicleSpeed);
if (vssKph < 5) {
@@ -85,6 +85,23 @@ float GearDetector::computeGearboxRatio() const {
return 0;
}
+ // Convert to wheel RPM
+ // km rev 1 hr
+ // ------ * ------------ * __________
+ // hr km 60 min
+ float wheelRpm = vssKph * engineConfiguration->driveWheelRevPerKm * (1 / 60.0f);
+
+ // Convert to driveshaft RPM
+ return wheelRpm * engineConfiguration->finalGearRatio;
+}
+
+float GearDetector::computeGearboxRatio() const {
+ float driveshaftRpm = getDriveshaftRpm();
+
+ if (driveshaftRpm == 0) {
+ return 0;
+ }
+
float engineRpm;
if (Sensor::hasSensor(SensorType::InputShaftSpeed)) {
engineRpm = Sensor::getOrZero(SensorType::InputShaftSpeed);
@@ -92,18 +109,18 @@ float GearDetector::computeGearboxRatio() const {
engineRpm = Sensor::getOrZero(SensorType::Rpm);
}
- // Convert to wheel RPM
- // km rev 1 hr
- // ------ * ------------ * __________
- // hr km 60 min
- float wheelRpm = vssKph * engineConfiguration->driveWheelRevPerKm * (1 / 60.0f);
-
- // Convert to driveshaft RPM
- auto driveshaftRpm = wheelRpm * engineConfiguration->finalGearRatio;
-
return engineRpm / driveshaftRpm;
}
+float GearDetector::getRpmInGear(size_t gear) const {
+ if (gear <= 0 || gear > engineConfiguration->totalGearsCount) {
+ return 0;
+ }
+
+ // Ideal engine RPM is driveshaft speed times gear
+ return getDriveshaftRpm() * engineConfiguration->gearRatio[gear - 1];
+}
+
float GearDetector::getGearboxRatio() const {
return m_gearboxRatio;
}
diff --git a/firmware/controllers/algo/gear_detector.h b/firmware/controllers/algo/gear_detector.h
index 19927072c5..0761279121 100644
--- a/firmware/controllers/algo/gear_detector.h
+++ b/firmware/controllers/algo/gear_detector.h
@@ -1,3 +1,4 @@
+#pragma once
class GearDetector : public EngineModule {
public:
@@ -11,8 +12,11 @@ public:
size_t determineGearFromRatio(float ratio) const;
+ float getRpmInGear(size_t gear) const;
+
private:
float computeGearboxRatio() const;
+ float getDriveshaftRpm() const;
float m_gearboxRatio = 0;
size_t m_currentGear = 0;
diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp
index 1841b8dc31..283b979df4 100644
--- a/firmware/controllers/algo/launch_control.cpp
+++ b/firmware/controllers/algo/launch_control.cpp
@@ -67,7 +67,8 @@ bool LaunchControlBase::isInsideTpsCondition() const {
return false;
}
- return engineConfiguration->launchTpsTreshold < tps.Value;
+ // todo: should this be 'launchTpsThreshold <= tps.Value' so that nicely calibrated TPS of zero does not prevent launch?
+ return engineConfiguration->launchTpsThreshold < tps.Value;
}
/**
@@ -102,8 +103,13 @@ void LaunchControlBase::update() {
combinedConditions = isLaunchConditionMet(rpm);
//and still recalculate in case user changed the values
- retardThresholdRpm = engineConfiguration->launchRpm + (engineConfiguration->enableLaunchRetard ?
- engineConfiguration->launchAdvanceRpmRange : 0) + engineConfiguration->hardCutRpmRange;
+ retardThresholdRpm = engineConfiguration->launchRpm
+ /*
+ we never had UI for 'launchAdvanceRpmRange' so it was always zero. are we supposed to forget about this dead line
+ or it is supposed to be referencing 'launchTimingRpmRange'?
+ + (engineConfiguration->enableLaunchRetard ? engineConfiguration->launchAdvanceRpmRange : 0)
+*/
+ + engineConfiguration->hardCutRpmRange;
if (!combinedConditions) {
// conditions not met, reset timer
diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h
index 62d79680fc..5094c787ef 100644
--- a/firmware/controllers/algo/obd_error_codes.h
+++ b/firmware/controllers/algo/obd_error_codes.h
@@ -18,6 +18,7 @@ extern "C"
#endif /* __cplusplus */
typedef enum {
+ OBD_None = 0,
//P0001 Fuel Volume Regulator Control Circuit/Open
//P0002 Fuel Volume Regulator Control Circuit Range/Performance
//P0003 Fuel Volume Regulator Control Circuit Low
@@ -129,30 +130,39 @@ typedef enum {
//P0104 Mass or Volume Air Flow Circuit Intermittent
OBD_Manifold_Absolute_Pressure_Circuit_Malfunction = 105,
//P0106 Manifold Absolute Pressure/Barometric Pressure Circuit Range/Performance Problem
+
+ OBD_Map_Timeout = 106,
+ OBD_Map_Low = 107,
+ OBD_Map_High = 108,
+
//P0107 Manifold Absolute Pressure/Barometric Pressure Circuit Low Input
//P0108 Manifold Absolute Pressure/Barometric Pressure Circuit High Input
//P0109 Manifold Absolute Pressure/Barometric Pressure Circuit Intermittent
- /**
- * We raise intake error code if IAT is calculated below -50C or above +100C
- */
- OBD_Intake_Air_Temperature_Circuit_Malfunction = 110,
+
+ OBD_ThermistorConfig = 111,
+
+ OBD_Iat_Timeout = 110,
+ OBD_Iat_Low = 112,
+ OBD_Iat_High = 113,
+
//P0111 Intake Air Temperature Circuit Range/Performance Problem
//P0112 Intake Air Temperature Circuit Low Input
//P0113 Intake Air Temperature Circuit High Input
//P0114 Intake Air Temperature Circuit Intermittent
- OBD_Engine_Coolant_Temperature_Circuit_Malfunction = 115,
+ OBD_Clt_Timeout = 115,
+ OBD_Clt_Low = 117,
+ OBD_Clt_High = 118,
//P0116 Engine Coolant Temperature Circuit Range/Performance Problem
//P0117 Engine Coolant Temperature Circuit Low Input
//P0118 Engine Coolant Temperature Circuit High Input
//P0119 Engine Coolant Temperature Circuit Intermittent
- /**
- * See also tpsErrorDetectionTooLow
- */
- OBD_Throttle_Position_Sensor_Circuit_Malfunction = 120,
- /**
- * See also tpsErrorDetectionTooHigh
- */
- OBD_Throttle_Position_Sensor_Range_Performance_Problem = 121,
+
+ OBD_TPS_Configuration = 121,
+
+ OBD_TPS1_Primary_Timeout = 120,
+ OBD_TPS1_Primary_Low = 122,
+ OBD_TPS1_Primary_High = 123,
+
//P0122 Throttle Position Sensor/Switch A Circuit Low Input
//P0123 Throttle Position Sensor/Switch A Circuit High Input
//P0124 Throttle Position Sensor/Switch A Circuit Intermittent
@@ -201,6 +211,11 @@ typedef enum {
//P0173 Fuel Trim Malfunction (Bank 2)
//P0174 System too Lean (Bank 2)
//P0175 System too Rich (Bank 2)
+
+ OBD_FlexSensor_Timeout = 176,
+ OBD_FlexSensor_Low = 178,
+ OBD_FlexSensor_High = 179,
+
//P0176 Fuel Composition Sensor Circuit Malfunction
//P0177 Fuel Composition Sensor Circuit Range/Performance
//P0178 Fuel Composition Sensor Circuit Low Input
@@ -227,18 +242,18 @@ typedef enum {
//P0199 Engine Oil Temperature Sensor Intermittent
//DTC Codes - P0200-P0299 - Fuel and Air Metering (Injector Circuit)
//P0200 Injector Circuit Malfunction
- //P0201 Injector Circuit Malfunction - Cylinder 1
- //P0202 Injector Circuit Malfunction - Cylinder 2
- //P0203 Injector Circuit Malfunction - Cylinder 3
- //P0204 Injector Circuit Malfunction - Cylinder 4
- //P0205 Injector Circuit Malfunction - Cylinder 5
- //P0206 Injector Circuit Malfunction - Cylinder 6
- //P0207 Injector Circuit Malfunction - Cylinder 7
- //P0208 Injector Circuit Malfunction - Cylinder 8
- //P0209 Injector Circuit Malfunction - Cylinder 9
- //P0210 Injector Circuit Malfunction - Cylinder 10
- //P0211 Injector Circuit Malfunction - Cylinder 11
- //P0212 Injector Circuit Malfunction - Cylinder 12
+ OBD_Injector_Circuit_1 = 201,
+ OBD_Injector_Circuit_2 = 202,
+ OBD_Injector_Circuit_3 = 203,
+ OBD_Injector_Circuit_4 = 204,
+ OBD_Injector_Circuit_5 = 205,
+ OBD_Injector_Circuit_6 = 206,
+ OBD_Injector_Circuit_7 = 207,
+ OBD_Injector_Circuit_8 = 208,
+ OBD_Injector_Circuit_9 = 209,
+ OBD_Injector_Circuit_10 = 210,
+ OBD_Injector_Circuit_11 = 211,
+ OBD_Injector_Circuit_12 = 212,
//P0213 Cold Start Injector 1 Malfunction
//P0214 Cold Start Injector 2 Malfunction
//P0215 Engine Shutoff Solenoid Malfunction
@@ -248,6 +263,15 @@ typedef enum {
//P0219 Engine Overspeed Condition
//P0220 Throttle/Petal Position Sensor/Switch B Circuit Malfunction
//P0221 Throttle/Petal Position Sensor/Switch B Circuit Range/Performance Problem
+
+ OBD_TPS1_Secondary_Timeout = 220,
+ OBD_TPS1_Secondary_Low = 222,
+ OBD_TPS1_Secondary_High = 223,
+
+ OBD_TPS2_Primary_Timeout = 225,
+ OBD_TPS2_Primary_Low = 227,
+ OBD_TPS2_Primary_High = 228,
+
//P0222 Throttle/Petal Position Sensor/Switch B Circuit Low Input
//P0223 Throttle/Petal Position Sensor/Switch B Circuit High Input
//P0224 Throttle/Petal Position Sensor/Switch B Circuit Intermittent
@@ -377,18 +401,18 @@ typedef enum {
//P0348 Camshaft Position Sensor A Circuit High Input (Bank 2)
//P0349 Camshaft Position Sensor A Circuit Intermittent (Bank 2)
//P0350 Ignition Coil Primary/Secondary Circuit Malfunction
- //P0351 Ignition Coil A Primary/Secondary Circuit Malfunction
- //P0352 Ignition Coil B Primary/Secondary Circuit Malfunction
- //P0353 Ignition Coil C Primary/Secondary Circuit Malfunction
- //P0354 Ignition Coil D Primary/Secondary Circuit Malfunction
- //P0355 Ignition Coil E Primary/Secondary Circuit Malfunction
- //P0356 Ignition Coil F Primary/Secondary Circuit Malfunction
- //P0357 Ignition Coil G Primary/Secondary Circuit Malfunction
- //P0358 Ignition Coil H Primary/Secondary Circuit Malfunction
- //P0359 Ignition Coil I Primary/Secondary Circuit Malfunction
- //P0360 Ignition Coil J Primary/Secondary Circuit Malfunction
- //P0361 Ignition Coil K Primary/Secondary Circuit Malfunction
- //P0362 Ignition Coil L Primary/Secondary Circuit Malfunction
+ OBD_Ignition_Circuit_1 = 351,
+ OBD_Ignition_Circuit_2 = 352,
+ OBD_Ignition_Circuit_3 = 353,
+ OBD_Ignition_Circuit_4 = 354,
+ OBD_Ignition_Circuit_5 = 355,
+ OBD_Ignition_Circuit_6 = 356,
+ OBD_Ignition_Circuit_7 = 357,
+ OBD_Ignition_Circuit_8 = 358,
+ OBD_Ignition_Circuit_9 = 359,
+ OBD_Ignition_Circuit_10 = 360,
+ OBD_Ignition_Circuit_11 = 361,
+ OBD_Ignition_Circuit_12 = 362,
//P0363 Misfire Detected - Fueling Disabled
//P0364 Reserved
//P0365 Camshaft Position Sensor "B" Circuit (Bank 1)
@@ -1044,6 +1068,19 @@ typedef enum {
//P2117 Throttle/Pedal Pos Sensor F Minimum Stop Perf
//P2118 Throttle Actuator Ctrl Motor Current Range/Perf
//P2119 Throttle Actuator Ctrl Throttle Body Range/Perf
+
+ OBD_TPS2_Secondary_Timeout = 2120,
+ OBD_TPS2_Secondary_Low = 2122,
+ OBD_TPS2_Secondary_High = 2123,
+
+ OBD_PPS_Primary_Timeout = 2125,
+ OBD_PPS_Primary_Low = 2127,
+ OBD_PPS_Primary_High = 2128,
+
+ OBD_PPS_Secondary_Timeout = 2130,
+ OBD_PPS_Secondary_Low = 2132,
+ OBD_PPS_Secondary_High = 2133,
+
//P2120 Throttle/Pedal Pos Sensor/Switch D Circ
//P2121 Throttle/Pedal Pos Sensor/Switch D Circ Range/Perf
//P2122 Throttle/Pedal Pos Sensor/Switch D Circ Low Input
@@ -1059,6 +1096,9 @@ typedef enum {
//P2132 Throttle/Pedal Pos Sensor/Switch F Circ Low Input
//P2133 Throttle/Pedal Pos Sensor/Switch F Circ High Input
//P2134 Throttle/Pedal Pos Sensor/Switch F Circ Interm
+ OBD_TPS1_Correlation = 2135,
+ OBD_TPS2_Correlation = 2136,
+ OBD_PPS_Correlation = 2136,
//P2135 Throttle/Pedal Pos Sensor/Switch A / B Voltage Correlation
//P2136 Throttle/Pedal Pos Sensor/Switch A / C Voltage Correlation
//P2137 Throttle/Pedal Pos Sensor/Switch B / C Voltage Correlation
@@ -1822,7 +1862,7 @@ typedef enum {
CUSTOM_ERR_UNKNOWN_PORT = 6132,
CUSTOM_ERR_PIN_ALREADY_USED_1 = 6133,
CUSTOM_ERR_PIN_ALREADY_USED_2 = 6134,
- CUSTOM_ERR_ICU_STATE = 6135,
+ CUSTOM_ERR_6135 = 6135,
CUSTOM_ERR_TCHARGE_NOT_READY = 6136,
CUSTOM_ERR_TRIGGER_WAVEFORM_TOO_LONG = 6137,
CUSTOM_ERR_FUEL_TABLE_NOT_READY = 6138,
@@ -1858,10 +1898,10 @@ typedef enum {
CUSTOM_ERR_ADC_USED = 6517,
CUSTOM_ERR_ADC_DEPTH_SLOW = 6518,
CUSTOM_ERR_ADC_DEPTH_FAST = 6519,
- CUSTOM_ERR_ICU = 6520,
- CUSTOM_ERR_ICU_AF = 6521,
- CUSTOM_ERR_ICU_DRIVER = 6522,
- CUSTOM_ERR_ICU_PIN = 6523,
+ CUSTOM_ERR_6520 = 6520,
+ CUSTOM_ERR_6521 = 6521,
+ CUSTOM_ERR_6522 = 6522,
+ CUSTOM_ERR_6523 = 6523,
CUSTOM_ERR_UNEXPECTED_SPI = 6524,
CUSTOM_ERR_EXT_MODE = 6525,
CUSTOM_ERR_TIMER_OVERFLOW = 6526,
@@ -1953,8 +1993,8 @@ typedef enum {
CUSTOM_ERR_6605 = 6605,
CUSTOM_ERR_6606 = 6606,
CUSTOM_APPEND_STACK = 6607,
- CUSTOM_RM_STACK_1 = 6608,
- CUSTOM_RM_STACK = 6609,
+ CUSTOM_ERR_6608 = 6608,
+ CUSTOM_ERR_6609 = 6609,
CUSTOM_ERR_6610 = 6610,
CUSTOM_ERR_6611 = 6611,
@@ -2024,14 +2064,14 @@ typedef enum {
CUSTOM_ERR_6670 = 6670,
CUSTOM_STACK_ADC_6671 = 6671,
- CUSTOM_ICU_DRIVER = 6672,
- CUSTOM_ICU_DRIVER_STATE = 6673,
+ CUSTOM_ERR_6672 = 6672,
+ CUSTOM_ERR_6673 = 6673,
CUSTOM_STACK_SPI = 6674,
CUSTOM_VVT_SYNC_POSITION = 6675,
CUSTOM_STACK_ADC = 6676,
CUSTOM_IH_STACK = 6677,
CUSTOM_EC_NULL = 6678,
- CUSTOM_ERROR_ICU = 6679,
+ CUSTOM_ERR6679 = 6679,
CUSTOM_ERR_ANGLE_CR = 6680,
CUSTOM_DELTA_NOT_POSITIVE = 6681,
@@ -2054,7 +2094,7 @@ typedef enum {
CUSTOM_PWM_CYCLE_START = 6697,
CUSTOM_ERR_ARRAY_IS_FULL = 6698,
CUSTOM_ERR_ARRAY_REMOVE_ERROR = 6699,
- CUSTOM_ERR_INVALID_INPUT_ICU_PIN = 6700,
+ CUSTOM_ERR_6700 = 6700,
CUSTOM_CJ125_0 = 6700,
CUSTOM_CJ125_1 = 6701,
diff --git a/firmware/controllers/algo/persistent_configuration.h b/firmware/controllers/algo/persistent_configuration.h
index 74dbac5ec2..c09d4daabb 100644
--- a/firmware/controllers/algo/persistent_configuration.h
+++ b/firmware/controllers/algo/persistent_configuration.h
@@ -8,7 +8,6 @@
#pragma once
#include "globalaccess.h"
-#include "crc.h"
#include "engine_configuration_generated_structures.h"
typedef struct {
diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp
index 91386814bc..d4c7689701 100644
--- a/firmware/controllers/bench_test.cpp
+++ b/firmware/controllers/bench_test.cpp
@@ -37,7 +37,6 @@
#include "malfunction_central.h"
#include "trigger_emulator_algo.h"
#include "microsecond_timer.h"
-#include "gpio_ext.h"
#if EFI_WIDEBAND_FIRMWARE_UPDATE
#include "rusefi_wideband.h"
@@ -69,7 +68,7 @@ static char pin_error[64];
static void benchOff(OutputPin* output) {
#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
- brain_pin_diag_e diag = gpiochips_getDiag(output->brainPin);
+ brain_pin_diag_e diag = output->getDiag();
if (diag == PIN_INVALID) {
efiPrintf("No Diag on this pin");
} else {
@@ -529,6 +528,14 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
rebootNow();
#endif /* EFI_PROD_CODE */
break;
+
+#if EFI_USE_OPENBLT
+ case 0xbc:
+ /* Jump to OpenBLT if present */
+ jump_to_openblt();
+ break;
+#endif
+
default:
firmwareError(OBD_PCM_Processor_Fault, "Unexpected bench subsystem %d %d", subsystem, index);
}
@@ -574,7 +581,7 @@ void initBenchTest() {
addConsoleActionFFFFF("luabench2", luaOutBench2);
instance.setPeriod(200 /*ms*/);
- instance.Start();
+ instance.start();
onConfigurationChangeBenchTest();
}
diff --git a/firmware/controllers/can/can_rx.cpp b/firmware/controllers/can/can_rx.cpp
index bb49048762..c4280b07f0 100644
--- a/firmware/controllers/can/can_rx.cpp
+++ b/firmware/controllers/can/can_rx.cpp
@@ -217,7 +217,7 @@ void processCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick
} else
#endif
{
- obdOnCanPacketRx(frame);
+ obdOnCanPacketRx(frame, busIndex);
}
#if EFI_WIDEBAND_FIRMWARE_UPDATE
diff --git a/firmware/controllers/can/can_tx.cpp b/firmware/controllers/can/can_tx.cpp
index f37045624e..463ad5b4b1 100644
--- a/firmware/controllers/can/can_tx.cpp
+++ b/firmware/controllers/can/can_tx.cpp
@@ -52,9 +52,7 @@ void CanWrite::PeriodicTask(efitime_t nowNt) {
cycleCount = 0;
}
-#ifndef DISABLE_CAN_UPDATE_DASH
updateDash(cycle);
-#endif /* DISABLE_CAN_UPDATE_DASH */
#if EFI_WIDEBAND_FIRMWARE_UPDATE
if (engineConfiguration->enableAemXSeries && cycle.isInterval(CI::_50ms)) {
diff --git a/firmware/controllers/can/can_verbose.cpp b/firmware/controllers/can/can_verbose.cpp
index 3bb740ff2e..e8d8a6a271 100644
--- a/firmware/controllers/can/can_verbose.cpp
+++ b/firmware/controllers/can/can_verbose.cpp
@@ -49,7 +49,7 @@ struct Speeds {
scaled_channel injDuty;
scaled_channel coilDuty;
scaled_channel vssKph;
- uint8_t pad[1];
+ uint8_t EthanolPercent;
};
static void populateFrame(Speeds& msg) {
@@ -63,6 +63,8 @@ static void populateFrame(Speeds& msg) {
msg.coilDuty = getCoilDutyCycle(rpm);
msg.vssKph = Sensor::getOrZero(SensorType::VehicleSpeed);
+
+ msg.EthanolPercent = Sensor::getOrZero(SensorType::FuelEthanolPercent);
}
struct PedalAndTps {
@@ -106,9 +108,9 @@ static void populateFrame(Sensors1& msg) {
}
struct Sensors2 {
- scaled_afr afr;
+ scaled_afr afr; // deprecated
scaled_pressure oilPressure;
- scaled_angle vvtPos;
+ scaled_angle vvtPos; // deprecated
scaled_voltage vbatt;
};
@@ -150,6 +152,44 @@ static void populateFrame(Fueling2& msg) {
}
}
+struct Fueling3 {
+ scaled_channel Lambda;
+ scaled_channel Lambda2;
+ scaled_channel FuelPressureLow;
+ scaled_channel FuelPressureHigh;
+};
+
+static void populateFrame(Fueling3& msg) {
+ msg.Lambda = Sensor::getOrZero(SensorType::Lambda1);
+ msg.Lambda2 = Sensor::getOrZero(SensorType::Lambda2);
+ msg.FuelPressureLow = Sensor::getOrZero(SensorType::FuelPressureLow);
+ msg.FuelPressureHigh = KPA2BAR(Sensor::getOrZero(SensorType::FuelPressureHigh));
+}
+
+struct Cams {
+ int8_t Bank1IntakeActual;
+ int8_t Bank1IntakeTarget;
+ int8_t Bank1ExhaustActual;
+ int8_t Bank1ExhaustTarget;
+ int8_t Bank2IntakeActual;
+ int8_t Bank2IntakeTarget;
+ int8_t Bank2ExhaustActual;
+ int8_t Bank2ExhaustTarget;
+};
+
+static void populateFrame(Cams& msg) {
+ msg.Bank1IntakeActual = engine->triggerCentral.getVVTPosition(0, 0);
+ msg.Bank1ExhaustActual = engine->triggerCentral.getVVTPosition(0, 1);
+ msg.Bank2IntakeActual = engine->triggerCentral.getVVTPosition(1, 0);
+ msg.Bank2ExhaustActual = engine->triggerCentral.getVVTPosition(1, 1);
+
+ // TODO: maybe don't rely on outputChannels here
+ msg.Bank1IntakeTarget = engine->outputChannels.vvtTargets[0];
+ msg.Bank1ExhaustTarget = engine->outputChannels.vvtTargets[1];
+ msg.Bank2IntakeTarget = engine->outputChannels.vvtTargets[2];
+ msg.Bank2ExhaustTarget = engine->outputChannels.vvtTargets[3];
+}
+
void sendCanVerbose() {
auto base = engineConfiguration->verboseCanBaseAddress;
auto isExt = engineConfiguration->rusefiVerbose29b;
@@ -161,6 +201,8 @@ void sendCanVerbose() {
transmitStruct (CanCategory::VERBOSE, base + 4, isExt);
transmitStruct (CanCategory::VERBOSE, base + 5, isExt);
transmitStruct (CanCategory::VERBOSE, base + 6, isExt);
+ transmitStruct (CanCategory::VERBOSE, base + 7, isExt);
+ transmitStruct (CanCategory::VERBOSE, base + 8, isExt);
}
#endif // EFI_CAN_SUPPORT
diff --git a/firmware/controllers/can/obd2.cpp b/firmware/controllers/can/obd2.cpp
index 0b15a20594..cddae3007f 100644
--- a/firmware/controllers/can/obd2.cpp
+++ b/firmware/controllers/can/obd2.cpp
@@ -56,9 +56,12 @@ static const int16_t supportedPids4160[] = {
-1
};
-static void obdSendPacket(int mode, int PID, int numBytes, uint32_t iValue) {
+static void obdSendPacket(int mode, int PID, int numBytes, uint32_t iValue, size_t busIndex) {
CanTxMessage resp(CanCategory::OBD, OBD_TEST_RESPONSE);
+ // Respond on the same bus we got the request from
+ resp.busIndex = busIndex;
+
// write number of bytes
resp[0] = (uint8_t)(2 + numBytes);
// write 2 bytes of header
@@ -72,18 +75,18 @@ static void obdSendPacket(int mode, int PID, int numBytes, uint32_t iValue) {
#define _1_MODE 1
-static void obdSendValue(int mode, int PID, int numBytes, float value) {
+static void obdSendValue(int mode, int PID, int numBytes, float value, size_t busIndex) {
efiAssertVoid(CUSTOM_ERR_6662, numBytes <= 2, "invalid numBytes");
int iValue = (int)efiRound(value, 1.0f);
// clamp to uint8_t (0..255) or uint16_t (0..65535)
iValue = maxI(minI(iValue, (numBytes == 1) ? 255 : 65535), 0);
- obdSendPacket(mode, PID, numBytes, iValue);
+ obdSendPacket(mode, PID, numBytes, iValue, busIndex);
}
//#define MOCK_SUPPORTED_PIDS 0xffffffff
-static void obdWriteSupportedPids(int PID, int bitOffset, const int16_t *supportedPids) {
+static void obdWriteSupportedPids(int PID, int bitOffset, const int16_t *supportedPids, size_t busIndex) {
uint32_t value = 0;
// gather all 32 bit fields
for (int i = 0; i < 32 && supportedPids[i] > 0; i++)
@@ -94,63 +97,63 @@ static void obdWriteSupportedPids(int PID, int bitOffset, const int16_t *support
value = MOCK_SUPPORTED_PIDS;
#endif
- obdSendPacket(1, PID, 4, value);
+ obdSendPacket(1, PID, 4, value, busIndex);
}
-static void handleGetDataRequest(const CANRxFrame& rx) {
+static void handleGetDataRequest(const CANRxFrame& rx, size_t busIndex) {
int pid = rx.data8[2];
switch (pid) {
case PID_SUPPORTED_PIDS_REQUEST_01_20:
- obdWriteSupportedPids(pid, 1, supportedPids0120);
+ obdWriteSupportedPids(pid, 1, supportedPids0120, busIndex);
break;
case PID_SUPPORTED_PIDS_REQUEST_21_40:
- obdWriteSupportedPids(pid, 21, supportedPids2140);
+ obdWriteSupportedPids(pid, 21, supportedPids2140, busIndex);
break;
case PID_SUPPORTED_PIDS_REQUEST_41_60:
- obdWriteSupportedPids(pid, 41, supportedPids4160);
+ obdWriteSupportedPids(pid, 41, supportedPids4160, busIndex);
break;
case PID_MONITOR_STATUS:
- obdSendPacket(1, pid, 4, 0); // todo: add statuses
+ obdSendPacket(1, pid, 4, 0, busIndex); // todo: add statuses
break;
case PID_FUEL_SYSTEM_STATUS:
// todo: add statuses
- obdSendValue(_1_MODE, pid, 2, (2<<8)|(0)); // 2 = "Closed loop, using oxygen sensor feedback to determine fuel mix"
+ obdSendValue(_1_MODE, pid, 2, (2<<8)|(0), busIndex); // 2 = "Closed loop, using oxygen sensor feedback to determine fuel mix"
break;
case PID_ENGINE_LOAD:
- obdSendValue(_1_MODE, pid, 1, getFuelingLoad() * ODB_TPS_BYTE_PERCENT);
+ obdSendValue(_1_MODE, pid, 1, getFuelingLoad() * ODB_TPS_BYTE_PERCENT, busIndex);
break;
case PID_COOLANT_TEMP:
- obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Clt) + ODB_TEMP_EXTRA);
+ obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Clt) + ODB_TEMP_EXTRA, busIndex);
break;
case PID_STFT_BANK1:
- obdSendValue(_1_MODE, pid, 1, 128 * engine->stftCorrection[0]);
+ obdSendValue(_1_MODE, pid, 1, 128 * engine->stftCorrection[0], busIndex);
break;
case PID_STFT_BANK2:
- obdSendValue(_1_MODE, pid, 1, 128 * engine->stftCorrection[1]);
+ obdSendValue(_1_MODE, pid, 1, 128 * engine->stftCorrection[1], busIndex);
break;
case PID_INTAKE_MAP:
- obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Map));
+ obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Map), busIndex);
break;
case PID_RPM:
- obdSendValue(_1_MODE, pid, 2, Sensor::getOrZero(SensorType::Rpm) * ODB_RPM_MULT); // rotation/min. (A*256+B)/4
+ obdSendValue(_1_MODE, pid, 2, Sensor::getOrZero(SensorType::Rpm) * ODB_RPM_MULT, busIndex); // rotation/min. (A*256+B)/4
break;
case PID_SPEED:
- obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::VehicleSpeed));
+ obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::VehicleSpeed), busIndex);
break;
case PID_TIMING_ADVANCE: {
float timing = engine->engineState.timingAdvance[0];
timing = (timing > 360.0f) ? (timing - 720.0f) : timing;
- obdSendValue(_1_MODE, pid, 1, (timing + 64.0f) * 2.0f); // angle before TDC. (A/2)-64
+ obdSendValue(_1_MODE, pid, 1, (timing + 64.0f) * 2.0f, busIndex); // angle before TDC. (A/2)-64
break;
}
case PID_INTAKE_TEMP:
- obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Iat) + ODB_TEMP_EXTRA);
+ obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Iat) + ODB_TEMP_EXTRA, busIndex);
break;
case PID_INTAKE_MAF:
- obdSendValue(_1_MODE, pid, 2, Sensor::getOrZero(SensorType::Maf) * 100.0f); // grams/sec (A*256+B)/100
+ obdSendValue(_1_MODE, pid, 2, Sensor::getOrZero(SensorType::Maf) * 100.0f, busIndex); // grams/sec (A*256+B)/100
break;
case PID_THROTTLE:
- obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Tps1) * ODB_TPS_BYTE_PERCENT); // (A*100/255)
+ obdSendValue(_1_MODE, pid, 1, Sensor::getOrZero(SensorType::Tps1) * ODB_TPS_BYTE_PERCENT, busIndex); // (A*100/255)
break;
case PID_FUEL_AIR_RATIO_1: {
float lambda = Sensor::getOrZero(SensorType::Lambda1);
@@ -159,13 +162,13 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
uint16_t scaled = phi * 32768;
- obdSendPacket(1, pid, 4, scaled << 16);
+ obdSendPacket(1, pid, 4, scaled << 16, busIndex);
break;
} case PID_FUEL_RATE: {
float gPerSecond = engine->engineState.fuelConsumption.getConsumptionGramPerSecond();
float gPerHour = gPerSecond * 3600;
float literPerHour = gPerHour * 0.00139f;
- obdSendValue(_1_MODE, pid, 2, literPerHour * 20.0f); // L/h. (A*256+B)/20
+ obdSendValue(_1_MODE, pid, 2, literPerHour * 20.0f, busIndex); // L/h. (A*256+B)/20
break;
} default:
// ignore unhandled PIDs
@@ -188,13 +191,13 @@ static void handleDtcRequest(int numCodes, int *dtcCode) {
}
#if HAL_USE_CAN
-void obdOnCanPacketRx(const CANRxFrame& rx) {
+void obdOnCanPacketRx(const CANRxFrame& rx, size_t busIndex) {
if (CAN_SID(rx) != OBD_TEST_REQUEST) {
return;
}
if (rx.data8[0] == _OBD_2 && rx.data8[1] == OBD_CURRENT_DATA) {
- handleGetDataRequest(rx);
+ handleGetDataRequest(rx, busIndex);
} else if (rx.data8[0] == 1 && rx.data8[1] == OBD_STORED_DIAGNOSTIC_TROUBLE_CODES) {
// todo: implement stored/pending difference?
handleDtcRequest(1, &engine->engineState.warnings.lastErrorCode);
diff --git a/firmware/controllers/can/obd2.h b/firmware/controllers/can/obd2.h
index 931f36b9a0..b512834f11 100644
--- a/firmware/controllers/can/obd2.h
+++ b/firmware/controllers/can/obd2.h
@@ -16,6 +16,8 @@
#define OBD_STORED_DIAGNOSTIC_TROUBLE_CODES 3
#define OBD_PENDING_DIAGNOSTIC_TROUBLE_CODES 7
+// https://en.wikipedia.org/wiki/OBD-II_PIDs
+
#define PID_SUPPORTED_PIDS_REQUEST_01_20 0x00
#define PID_MONITOR_STATUS 0x01
#define PID_FUEL_SYSTEM_STATUS 0x03
@@ -36,10 +38,15 @@
#define PID_FUEL_AIR_RATIO_1 0x24
#define PID_SUPPORTED_PIDS_REQUEST_41_60 0x40
+//todo#define PID_CONTROL_UNIT_VOLTAGE 0x42
+//todo#define PID_ETHANOL 0x52
+//todo#define PID_OIL_TEMPERATURE 0x5C
+//todo#define PID_FUEL_TIMING 0x5D
#define PID_FUEL_RATE 0x5E
+//todo#define PID_TURBO_RPM 0x74
#if HAL_USE_CAN
-void obdOnCanPacketRx(const CANRxFrame& rx);
+void obdOnCanPacketRx(const CANRxFrame& rx, size_t busIndex);
#endif /* HAL_USE_CAN */
#define ODB_RPM_MULT 4
diff --git a/firmware/controllers/core/core.mk b/firmware/controllers/core/core.mk
index 15216b93fc..67fddd7643 100644
--- a/firmware/controllers/core/core.mk
+++ b/firmware/controllers/core/core.mk
@@ -1,5 +1,4 @@
CONTROLLERS_CORE_SRC_CPP = \
$(PROJECT_DIR)/controllers/core/state_sequence.cpp \
- $(PROJECT_DIR)/controllers/core/fsio_impl.cpp \
diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp
index fbcc61a658..77af22288f 100644
--- a/firmware/controllers/core/error_handling.cpp
+++ b/firmware/controllers/core/error_handling.cpp
@@ -7,6 +7,7 @@
#include "pch.h"
#include "os_access.h"
+#include "backup_ram.h"
static critical_msg_t warningBuffer;
static critical_msg_t criticalErrorMessageBuffer;
@@ -27,24 +28,63 @@ const char* getCriticalErrorMessage(void) {
}
#if EFI_PROD_CODE
+void checkLastBootError() {
+ auto sramState = getBackupSram();
+
+ switch (sramState->Cookie) {
+ case ErrorCookie::FirmwareError:
+ efiPrintf("Last boot had firmware error: %s", sramState->ErrorString);
+ break;
+ case ErrorCookie::HardFault: {
+ efiPrintf("Last boot had hard fault type: %x addr: %x CSFR: %x", sramState->FaultType, sramState->FaultAddress, sramState->Csfr);
+
+ // Print out the context as a sequence of uintptr
+ uintptr_t* data = reinterpret_cast(&sramState->FaultCtx);
+ for (size_t i = 0; i < sizeof(port_extctx) / sizeof(uintptr_t); i++) {
+ efiPrintf("Fault ctx %d: %x", i, data[i]);
+ }
+
+ break;
+ }
+ default:
+ // No cookie stored or invalid cookie (ie, backup RAM contains random garbage)
+ break;
+ }
+
+ // Reset cookie so we don't print it again.
+ sramState->Cookie = ErrorCookie::None;
+
+ if (sramState->BootCountCookie != 0xdeadbeef) {
+ sramState->BootCountCookie = 0xdeadbeef;
+ sramState->BootCount = 0;
+ }
+
+ efiPrintf("Power cycle count: %d", sramState->BootCount);
+ sramState->BootCount++;
+}
+
+void logHardFault(uint32_t type, uintptr_t faultAddress, port_extctx* ctx, uint32_t csfr) {
+ auto sramState = getBackupSram();
+ sramState->Cookie = ErrorCookie::HardFault;
+ sramState->FaultType = type;
+ sramState->FaultAddress = faultAddress;
+ sramState->Csfr = csfr;
+ memcpy(&sramState->FaultCtx, ctx, sizeof(port_extctx));
+}
extern ioportid_t criticalErrorLedPort;
extern ioportmask_t criticalErrorLedPin;
extern uint8_t criticalErrorLedState;
-
-/**
- * low-level function is used here to reduce stack usage
- */
-
-#define ON_CRITICAL_ERROR() \
- palWritePad(criticalErrorLedPort, criticalErrorLedPin, criticalErrorLedState); \
- turnAllPinsOff(); \
- enginePins.communicationLedPin.setValue(1);
#endif /* EFI_PROD_CODE */
#if EFI_SIMULATOR || EFI_PROD_CODE
void chDbgPanic3(const char *msg, const char * file, int line) {
+#if EFI_PROD_CODE
+ // Attempt to break in to the debugger, if attached
+ __asm volatile("BKPT #0\n");
+#endif
+
if (hasOsPanicError())
return;
dbg_panic_file = file;
@@ -53,12 +93,10 @@ void chDbgPanic3(const char *msg, const char * file, int line) {
ch.dbg.panic_msg = msg;
#endif /* CH_DBG_SYSTEM_STATE_CHECK */
-#if EFI_PROD_CODE
- ON_CRITICAL_ERROR();
-#else
+#if !EFI_PROD_CODE
printf("chDbgPanic3 %s %s%d", msg, file, line);
exit(-1);
-#endif
+#else // EFI_PROD_CODE
#if EFI_HD44780_LCD
lcdShowPanicMessage((char *) msg);
@@ -66,20 +104,25 @@ void chDbgPanic3(const char *msg, const char * file, int line) {
firmwareError(OBD_PCM_Processor_Fault, "assert fail %s %s:%d", msg, file, line);
- // Force unlock, since we may be throwing-under-lock
- chSysUnconditionalUnlock();
-
- // there was a port_disable in chSysHalt, reenable interrupts so USB works
- port_enable();
-
// If on the main thread, longjmp back to the init process so we can keep USB alive
if (chThdGetSelfX()->threadId == 0) {
- void onAssertionFailure();
+ // Force unlock, since we may be throwing-under-lock
+ chSysUnconditionalUnlock();
+
+ // there was a port_disable in chSysHalt, reenable interrupts so USB works
+ port_enable();
+
+ __NO_RETURN void onAssertionFailure();
onAssertionFailure();
} else {
- // Not the main thread, simply try to terminate ourselves and let other threads continue living (so the user can diagnose, etc)
- chThdTerminate(chThdGetSelfX());
+ // Not the main thread.
+ // All hope is now lost.
+
+ // Reboot!
+ NVIC_SystemReset();
}
+
+#endif // EFI_PROD_CODE
}
#else
@@ -201,8 +244,10 @@ void firmwareError(obd_code_e code, const char *fmt, ...) {
chvsnprintf(warningBuffer, sizeof(warningBuffer), fmt, ap);
va_end(ap);
#endif
- ON_CRITICAL_ERROR()
- ;
+ palWritePad(criticalErrorLedPort, criticalErrorLedPin, criticalErrorLedState);
+ turnAllPinsOff();
+ enginePins.communicationLedPin.setValue(1);
+
hasFirmwareErrorFlag = true;
if (indexOf(fmt, '%') == -1) {
/**
@@ -226,6 +271,9 @@ void firmwareError(obd_code_e code, const char *fmt, ...) {
strcpy((char*)(criticalErrorMessageBuffer) + errorMessageSize, versionBuffer);
}
+ auto sramState = getBackupSram();
+ strncpy(sramState->ErrorString, criticalErrorMessageBuffer, efi::size(sramState->ErrorString));
+ sramState->Cookie = ErrorCookie::FirmwareError;
#else
char errorBuffer[200];
@@ -242,4 +290,3 @@ void firmwareError(obd_code_e code, const char *fmt, ...) {
#endif /* EFI_SIMULATOR */
#endif
}
-
diff --git a/firmware/controllers/core/error_handling.h b/firmware/controllers/core/error_handling.h
index 9776c5e4d8..22ecd6c8e6 100644
--- a/firmware/controllers/core/error_handling.h
+++ b/firmware/controllers/core/error_handling.h
@@ -8,6 +8,7 @@
#pragma once
#include "obd_error_codes.h"
+#include
#ifdef __cplusplus
extern "C"
@@ -22,7 +23,7 @@ extern "C"
*/
bool warning(obd_code_e code, const char *fmt, ...);
-typedef char critical_msg_t[ERROR_BUFFER_SIZE];
+using critical_msg_t = char[ERROR_BUFFER_SIZE];
/**
* Something really bad had happened - firmware cannot function, we cannot run the engine
@@ -51,6 +52,14 @@ int getRusEfiVersion(void);
#define efiAssertVoid(code, condition, message) { }
#endif /* EFI_ENABLE_ASSERTS */
+#if EFI_PROD_CODE
+#include
+
+// If there was an error on the last boot, print out information about it now and reset state.
+void checkLastBootError();
+void logHardFault(uint32_t type, uintptr_t faultAddress, port_extctx* ctx, uint32_t csfr);
+#endif // EFI_PROD_CODE
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/firmware/controllers/date_stamp.h b/firmware/controllers/date_stamp.h
index 1b646bad5e..3c8e9d554e 100644
--- a/firmware/controllers/date_stamp.h
+++ b/firmware/controllers/date_stamp.h
@@ -1,2 +1,2 @@
#pragma once
-#define VCS_DATE 20220703
+#define VCS_DATE 20220805
diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp
index 4d5977b5cc..889d9f3209 100644
--- a/firmware/controllers/engine_controller.cpp
+++ b/firmware/controllers/engine_controller.cpp
@@ -25,7 +25,7 @@
#include "os_access.h"
#include "trigger_central.h"
-#include "fsio_impl.h"
+#include "script_impl.h"
#include "idle_thread.h"
#include "advance_map.h"
#include "main_trigger_callback.h"
@@ -145,7 +145,6 @@ class EngineStateBlinkingTask : public PeriodicTimerController {
}
void PeriodicTask() override {
- counter++;
#if EFI_SHAFT_POSITION_INPUT
bool is_running = engine->rpmCalculator.isRunning();
#else
@@ -154,14 +153,12 @@ class EngineStateBlinkingTask : public PeriodicTimerController {
if (is_running) {
// blink in running mode
- enginePins.runningLedPin.setValue(counter % 2);
+ enginePins.runningLedPin.toggle();
} else {
int is_cranking = engine->rpmCalculator.isCranking();
enginePins.runningLedPin.setValue(is_cranking);
}
}
-private:
- int counter = 0;
};
static EngineStateBlinkingTask engineStateBlinkingTask;
@@ -237,8 +234,8 @@ static void doPeriodicSlowCallback() {
}
void initPeriodicEvents() {
- slowController.Start();
- fastController.Start();
+ slowController.start();
+ fastController.start();
}
char * getPinNameByAdcChannel(const char *msg, adc_channel_e hwChannel, char *buffer) {
@@ -507,8 +504,7 @@ void commonInitEngineController() {
initAccelEnrichment();
- // TODO: rename
- initFsioImpl();
+ initScriptImpl();
initGpPwm();
@@ -698,7 +694,7 @@ void initEngineContoller() {
return;
}
- engineStateBlinkingTask.Start();
+ engineStateBlinkingTask.start();
initVrPwm();
diff --git a/firmware/controllers/engine_cycle/aux_valves.cpp b/firmware/controllers/engine_cycle/aux_valves.cpp
index feec6ae885..198e9c8adc 100644
--- a/firmware/controllers/engine_cycle/aux_valves.cpp
+++ b/firmware/controllers/engine_cycle/aux_valves.cpp
@@ -81,17 +81,17 @@ void recalculateAuxValveTiming() {
return;
}
- auto [valid, tps] = Sensor::get(SensorType::DriverThrottleIntent);
- if (!valid) {
+ auto tps = Sensor::get(SensorType::DriverThrottleIntent);
+ if (!tps) {
// error should be already reported by now
return;
}
- engine->engineState.auxValveStart = interpolate2d(tps,
+ engine->engineState.auxValveStart = interpolate2d(tps.Value,
config->scriptCurve1Bins,
config->scriptCurve1);
- engine->engineState.auxValveEnd = interpolate2d(tps,
+ engine->engineState.auxValveEnd = interpolate2d(tps.Value,
config->scriptCurve2Bins,
config->scriptCurve2);
diff --git a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp
index d8d9e0ed53..f63692a9df 100644
--- a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp
+++ b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.cpp
@@ -81,11 +81,16 @@ float HpfpQuantity::calcPI(int rpm, float calc_fuel_percent) {
m_pressureTarget_kPa - (engineConfiguration->hpfpTargetDecay *
(FAST_CALLBACK_PERIOD_MS / 1000.)),
interpolate3d(engineConfiguration->hpfpTarget,
- engineConfiguration->hpfpTargetLoadBins, Sensor::get(SensorType::Map).Value, // TODO: allow other load axis, like we claim to
+ engineConfiguration->hpfpTargetLoadBins, Sensor::get(SensorType::Map).value_or(0), // TODO: allow other load axis, like we claim to
engineConfiguration->hpfpTargetRpmBins, rpm));
+ auto fuelPressure = Sensor::get(SensorType::FuelPressureHigh);
+ if (!fuelPressure) {
+ return 0;
+ }
+
float pressureError_kPa =
- m_pressureTarget_kPa - Sensor::get(SensorType::FuelPressureHigh).Value;
+ m_pressureTarget_kPa - fuelPressure.Value;
float p_control_percent = pressureError_kPa * engineConfiguration->hpfpPidP;
float i_factor_divisor =
diff --git a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h
index 6e01625b6c..e75ec18800 100644
--- a/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h
+++ b/firmware/controllers/engine_cycle/high_pressure_fuel_pump.h
@@ -35,6 +35,7 @@ class HpfpController;
class HpfpQuantity {
public:
+// todo: shall we move into high_pressure_fuel_pump.txt and reduce OOP elegance or create a separate live data just for these ones?
float m_I_sum_percent = 0;
float m_pressureTarget_kPa = 0;
diff --git a/firmware/controllers/gauges/malfunction_indicator.cpp b/firmware/controllers/gauges/malfunction_indicator.cpp
index fcf3fbacf2..572b5ecce7 100644
--- a/firmware/controllers/gauges/malfunction_indicator.cpp
+++ b/firmware/controllers/gauges/malfunction_indicator.cpp
@@ -122,7 +122,7 @@ void initMalfunctionIndicator(void) {
return;
}
instance.setPeriod(10 /*ms*/);
- instance.Start();
+ instance.start();
#if TEST_MIL_CODE
addConsoleAction("testmil", testMil);
diff --git a/firmware/controllers/generated/signature_48way.h b/firmware/controllers/generated/signature_48way.h
index dc22657d29..fe01fb51f6 100644
--- a/firmware/controllers/generated/signature_48way.h
+++ b/firmware/controllers/generated/signature_48way.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 776259275
-#define TS_SIGNATURE "rusEFI 2022.07.03.48way.776259275"
+#define SIGNATURE_HASH 2232529279
+#define TS_SIGNATURE "rusEFI 2022.08.05.48way.2232529279"
diff --git a/firmware/controllers/generated/signature_all.h b/firmware/controllers/generated/signature_all.h
index a9d2d61c41..30acc33a81 100644
--- a/firmware/controllers/generated/signature_all.h
+++ b/firmware/controllers/generated/signature_all.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 962842244
-#define TS_SIGNATURE "rusEFI 2022.07.03.all.962842244"
+#define SIGNATURE_HASH 2453059888
+#define TS_SIGNATURE "rusEFI 2022.08.05.all.2453059888"
diff --git a/firmware/controllers/generated/signature_alphax-2chan.h b/firmware/controllers/generated/signature_alphax-2chan.h
index 6a729d27e8..9ee5846766 100644
--- a/firmware/controllers/generated/signature_alphax-2chan.h
+++ b/firmware/controllers/generated/signature_alphax-2chan.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 191976424
-#define TS_SIGNATURE "rusEFI 2022.07.03.alphax-2chan.191976424"
+#define SIGNATURE_HASH 2686723164
+#define TS_SIGNATURE "rusEFI 2022.08.05.alphax-2chan.2686723164"
diff --git a/firmware/controllers/generated/signature_alphax-4chan.h b/firmware/controllers/generated/signature_alphax-4chan.h
index e99f3942ef..e8fd2110b2 100644
--- a/firmware/controllers/generated/signature_alphax-4chan.h
+++ b/firmware/controllers/generated/signature_alphax-4chan.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 451879367
-#define TS_SIGNATURE "rusEFI 2022.07.03.alphax-4chan.451879367"
+#define SIGNATURE_HASH 2981779059
+#define TS_SIGNATURE "rusEFI 2022.08.05.alphax-4chan.2981779059"
diff --git a/firmware/controllers/generated/signature_atlas.h b/firmware/controllers/generated/signature_atlas.h
index 34618b20c5..da01828f86 100644
--- a/firmware/controllers/generated/signature_atlas.h
+++ b/firmware/controllers/generated/signature_atlas.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 631847843
-#define TS_SIGNATURE "rusEFI 2022.07.03.atlas.631847843"
+#define SIGNATURE_HASH 2398899223
+#define TS_SIGNATURE "rusEFI 2022.08.05.atlas.2398899223"
diff --git a/firmware/controllers/generated/signature_core8.h b/firmware/controllers/generated/signature_core8.h
index fa0d03a18e..527c91251c 100644
--- a/firmware/controllers/generated/signature_core8.h
+++ b/firmware/controllers/generated/signature_core8.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 3482296189
-#define TS_SIGNATURE "rusEFI 2022.07.03.core8.3482296189"
+#define SIGNATURE_HASH 1692068041
+#define TS_SIGNATURE "rusEFI 2022.08.05.core8.1692068041"
diff --git a/firmware/controllers/generated/signature_f407-discovery.h b/firmware/controllers/generated/signature_f407-discovery.h
index 1106580ead..0977444a7a 100644
--- a/firmware/controllers/generated/signature_f407-discovery.h
+++ b/firmware/controllers/generated/signature_f407-discovery.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 962842244
-#define TS_SIGNATURE "rusEFI 2022.07.03.f407-discovery.962842244"
+#define SIGNATURE_HASH 2453059888
+#define TS_SIGNATURE "rusEFI 2022.08.05.f407-discovery.2453059888"
diff --git a/firmware/controllers/generated/signature_f429-discovery.h b/firmware/controllers/generated/signature_f429-discovery.h
index 2455c367d5..51a40ae69c 100644
--- a/firmware/controllers/generated/signature_f429-discovery.h
+++ b/firmware/controllers/generated/signature_f429-discovery.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 962842244
-#define TS_SIGNATURE "rusEFI 2022.07.03.f429-discovery.962842244"
+#define SIGNATURE_HASH 2453059888
+#define TS_SIGNATURE "rusEFI 2022.08.05.f429-discovery.2453059888"
diff --git a/firmware/controllers/generated/signature_frankenso_na6.h b/firmware/controllers/generated/signature_frankenso_na6.h
index e57142b373..8fde97294c 100644
--- a/firmware/controllers/generated/signature_frankenso_na6.h
+++ b/firmware/controllers/generated/signature_frankenso_na6.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2064593472
-#define TS_SIGNATURE "rusEFI 2022.07.03.frankenso_na6.2064593472"
+#define SIGNATURE_HASH 3495577076
+#define TS_SIGNATURE "rusEFI 2022.08.05.frankenso_na6.3495577076"
diff --git a/firmware/controllers/generated/signature_harley81.h b/firmware/controllers/generated/signature_harley81.h
index a02b3238cf..6355a2eb18 100644
--- a/firmware/controllers/generated/signature_harley81.h
+++ b/firmware/controllers/generated/signature_harley81.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1301254651
-#define TS_SIGNATURE "rusEFI 2022.07.03.harley81.1301254651"
+#define SIGNATURE_HASH 3873105487
+#define TS_SIGNATURE "rusEFI 2022.08.05.harley81.3873105487"
diff --git a/firmware/controllers/generated/signature_hellen-gm-e67.h b/firmware/controllers/generated/signature_hellen-gm-e67.h
index 976c9b047a..398af6fcfb 100644
--- a/firmware/controllers/generated/signature_hellen-gm-e67.h
+++ b/firmware/controllers/generated/signature_hellen-gm-e67.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 409788385
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen-gm-e67.409788385"
+#define SIGNATURE_HASH 3006900309
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen-gm-e67.3006900309"
diff --git a/firmware/controllers/generated/signature_hellen-nb1.h b/firmware/controllers/generated/signature_hellen-nb1.h
index db2793df5f..856073b301 100644
--- a/firmware/controllers/generated/signature_hellen-nb1.h
+++ b/firmware/controllers/generated/signature_hellen-nb1.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 3773366088
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen-nb1.3773366088"
+#define SIGNATURE_HASH 1270712572
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen-nb1.1270712572"
diff --git a/firmware/controllers/generated/signature_hellen121nissan.h b/firmware/controllers/generated/signature_hellen121nissan.h
index 66cda03610..7f4635baf9 100644
--- a/firmware/controllers/generated/signature_hellen121nissan.h
+++ b/firmware/controllers/generated/signature_hellen121nissan.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2981983854
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen121nissan.2981983854"
+#define SIGNATURE_HASH 451412442
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen121nissan.451412442"
diff --git a/firmware/controllers/generated/signature_hellen121vag.h b/firmware/controllers/generated/signature_hellen121vag.h
index 6aaa02ce40..99728d5722 100644
--- a/firmware/controllers/generated/signature_hellen121vag.h
+++ b/firmware/controllers/generated/signature_hellen121vag.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1229065726
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen121vag.1229065726"
+#define SIGNATURE_HASH 3793189450
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen121vag.3793189450"
diff --git a/firmware/controllers/generated/signature_hellen128.h b/firmware/controllers/generated/signature_hellen128.h
index a61f992167..fe3b05f7d9 100644
--- a/firmware/controllers/generated/signature_hellen128.h
+++ b/firmware/controllers/generated/signature_hellen128.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1464341077
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen128.1464341077"
+#define SIGNATURE_HASH 1825080334
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen128.1825080334"
diff --git a/firmware/controllers/generated/signature_hellen154hyundai.h b/firmware/controllers/generated/signature_hellen154hyundai.h
index 3efa29ccb2..a00c2452e9 100644
--- a/firmware/controllers/generated/signature_hellen154hyundai.h
+++ b/firmware/controllers/generated/signature_hellen154hyundai.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2704063488
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen154hyundai.2704063488"
+#define SIGNATURE_HASH 175754164
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen154hyundai.175754164"
diff --git a/firmware/controllers/generated/signature_hellen72.h b/firmware/controllers/generated/signature_hellen72.h
index 3de178f4bc..95a1934352 100644
--- a/firmware/controllers/generated/signature_hellen72.h
+++ b/firmware/controllers/generated/signature_hellen72.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 3411863424
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen72.3411863424"
+#define SIGNATURE_HASH 1611239476
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen72.1611239476"
diff --git a/firmware/controllers/generated/signature_hellen81.h b/firmware/controllers/generated/signature_hellen81.h
index 6aceab8376..4cd4593673 100644
--- a/firmware/controllers/generated/signature_hellen81.h
+++ b/firmware/controllers/generated/signature_hellen81.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 467015310
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen81.467015310"
+#define SIGNATURE_HASH 2961400122
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen81.2961400122"
diff --git a/firmware/controllers/generated/signature_hellen88bmw.h b/firmware/controllers/generated/signature_hellen88bmw.h
index 1fbe3efd1f..45024117ae 100644
--- a/firmware/controllers/generated/signature_hellen88bmw.h
+++ b/firmware/controllers/generated/signature_hellen88bmw.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1710491680
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen88bmw.1710491680"
+#define SIGNATURE_HASH 2071392711
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen88bmw.2071392711"
diff --git a/firmware/controllers/generated/signature_hellenNA6.h b/firmware/controllers/generated/signature_hellenNA6.h
index 3866dba5e4..6966f36119 100644
--- a/firmware/controllers/generated/signature_hellenNA6.h
+++ b/firmware/controllers/generated/signature_hellenNA6.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 3152560100
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellenNA6.3152560100"
+#define SIGNATURE_HASH 280840272
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellenNA6.280840272"
diff --git a/firmware/controllers/generated/signature_hellenNA8_96.h b/firmware/controllers/generated/signature_hellenNA8_96.h
index f924aae69f..b185c6b0ad 100644
--- a/firmware/controllers/generated/signature_hellenNA8_96.h
+++ b/firmware/controllers/generated/signature_hellenNA8_96.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1004147892
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellenNA8_96.1004147892"
+#define SIGNATURE_HASH 2425316096
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellenNA8_96.2425316096"
diff --git a/firmware/controllers/generated/signature_hellen_cypress.h b/firmware/controllers/generated/signature_hellen_cypress.h
index 61363970ad..d2ed4cf8b3 100644
--- a/firmware/controllers/generated/signature_hellen_cypress.h
+++ b/firmware/controllers/generated/signature_hellen_cypress.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on hellen_cypress_gen_config.bat null
//
-#define SIGNATURE_HASH 2085585038
-#define TS_SIGNATURE "rusEFI 2022.07.03.hellen_cypress.2085585038"
+#define SIGNATURE_HASH 3608868666
+#define TS_SIGNATURE "rusEFI 2022.08.05.hellen_cypress.3608868666"
diff --git a/firmware/controllers/generated/signature_kin.h b/firmware/controllers/generated/signature_kin.h
index f12de80f98..2b36902c48 100644
--- a/firmware/controllers/generated/signature_kin.h
+++ b/firmware/controllers/generated/signature_kin.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on kinetis_gen_config.bat null
//
-#define SIGNATURE_HASH 571270915
-#define TS_SIGNATURE "rusEFI 2022.07.03.kin.571270915"
+#define SIGNATURE_HASH 2304348343
+#define TS_SIGNATURE "rusEFI 2022.08.05.kin.2304348343"
diff --git a/firmware/controllers/generated/signature_mre_f4.h b/firmware/controllers/generated/signature_mre_f4.h
index b0923b2d9e..429a156d7f 100644
--- a/firmware/controllers/generated/signature_mre_f4.h
+++ b/firmware/controllers/generated/signature_mre_f4.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 4139074162
-#define TS_SIGNATURE "rusEFI 2022.07.03.mre_f4.4139074162"
+#define SIGNATURE_HASH 1574974918
+#define TS_SIGNATURE "rusEFI 2022.08.05.mre_f4.1574974918"
diff --git a/firmware/controllers/generated/signature_mre_f7.h b/firmware/controllers/generated/signature_mre_f7.h
index a6c286cf73..4fa3dcd54f 100644
--- a/firmware/controllers/generated/signature_mre_f7.h
+++ b/firmware/controllers/generated/signature_mre_f7.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 4139074162
-#define TS_SIGNATURE "rusEFI 2022.07.03.mre_f7.4139074162"
+#define SIGNATURE_HASH 1574974918
+#define TS_SIGNATURE "rusEFI 2022.08.05.mre_f7.1574974918"
diff --git a/firmware/controllers/generated/signature_prometheus_405.h b/firmware/controllers/generated/signature_prometheus_405.h
index 0d264f6dd4..18b6d6b188 100644
--- a/firmware/controllers/generated/signature_prometheus_405.h
+++ b/firmware/controllers/generated/signature_prometheus_405.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1770592098
-#define TS_SIGNATURE "rusEFI 2022.07.03.prometheus_405.1770592098"
+#define SIGNATURE_HASH 3269222614
+#define TS_SIGNATURE "rusEFI 2022.08.05.prometheus_405.3269222614"
diff --git a/firmware/controllers/generated/signature_prometheus_469.h b/firmware/controllers/generated/signature_prometheus_469.h
index aba55f0096..f953016d68 100644
--- a/firmware/controllers/generated/signature_prometheus_469.h
+++ b/firmware/controllers/generated/signature_prometheus_469.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 1770592098
-#define TS_SIGNATURE "rusEFI 2022.07.03.prometheus_469.1770592098"
+#define SIGNATURE_HASH 3269222614
+#define TS_SIGNATURE "rusEFI 2022.08.05.prometheus_469.3269222614"
diff --git a/firmware/controllers/generated/signature_proteus_f4.h b/firmware/controllers/generated/signature_proteus_f4.h
index 77b2ba22c2..d162728170 100644
--- a/firmware/controllers/generated/signature_proteus_f4.h
+++ b/firmware/controllers/generated/signature_proteus_f4.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2628651506
-#define TS_SIGNATURE "rusEFI 2022.07.03.proteus_f4.2628651506"
+#define SIGNATURE_HASH 939228742
+#define TS_SIGNATURE "rusEFI 2022.08.05.proteus_f4.939228742"
diff --git a/firmware/controllers/generated/signature_proteus_f7.h b/firmware/controllers/generated/signature_proteus_f7.h
index 2a19d6646a..e85cec6e04 100644
--- a/firmware/controllers/generated/signature_proteus_f7.h
+++ b/firmware/controllers/generated/signature_proteus_f7.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2628651506
-#define TS_SIGNATURE "rusEFI 2022.07.03.proteus_f7.2628651506"
+#define SIGNATURE_HASH 939228742
+#define TS_SIGNATURE "rusEFI 2022.08.05.proteus_f7.939228742"
diff --git a/firmware/controllers/generated/signature_proteus_h7.h b/firmware/controllers/generated/signature_proteus_h7.h
index 29f9c0dfe0..e3ff8df348 100644
--- a/firmware/controllers/generated/signature_proteus_h7.h
+++ b/firmware/controllers/generated/signature_proteus_h7.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2628651506
-#define TS_SIGNATURE "rusEFI 2022.07.03.proteus_h7.2628651506"
+#define SIGNATURE_HASH 939228742
+#define TS_SIGNATURE "rusEFI 2022.08.05.proteus_h7.939228742"
diff --git a/firmware/controllers/generated/signature_subaru_eg33_f7.h b/firmware/controllers/generated/signature_subaru_eg33_f7.h
index feab3df69e..f9b166791d 100644
--- a/firmware/controllers/generated/signature_subaru_eg33_f7.h
+++ b/firmware/controllers/generated/signature_subaru_eg33_f7.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on config/boards/subaru_eg33/config/gen_subaru_config.sh null
//
-#define SIGNATURE_HASH 846346038
-#define TS_SIGNATURE "rusEFI 2022.07.03.subaru_eg33_f7.846346038"
+#define SIGNATURE_HASH 2569486466
+#define TS_SIGNATURE "rusEFI 2022.08.05.subaru_eg33_f7.2569486466"
diff --git a/firmware/controllers/generated/signature_tdg-pdm8.h b/firmware/controllers/generated/signature_tdg-pdm8.h
index 5027c455dc..23fca0e664 100644
--- a/firmware/controllers/generated/signature_tdg-pdm8.h
+++ b/firmware/controllers/generated/signature_tdg-pdm8.h
@@ -2,5 +2,5 @@
// was generated automatically by rusEFI tool ConfigDefinition.jar based on gen_config.sh null
//
-#define SIGNATURE_HASH 2473263312
-#define TS_SIGNATURE "rusEFI 2022.07.03.tdg-pdm8.2473263312"
+#define SIGNATURE_HASH 943617892
+#define TS_SIGNATURE "rusEFI 2022.08.05.tdg-pdm8.943617892"
diff --git a/firmware/controllers/lua/examples/350z-ac.txt b/firmware/controllers/lua/examples/350z-ac.txt
new file mode 100644
index 0000000000..44d6de0183
--- /dev/null
+++ b/firmware/controllers/lua/examples/350z-ac.txt
@@ -0,0 +1,79 @@
+canRxAdd(0x35d)
+
+setTickRate(100)
+t = Timer.new()
+t : reset()
+
+globalAcOut = 0
+
+function onTick()
+ local RPMread = math.floor(getSensor("RPM") + 0.5) / 3.15
+ local RPMhi = RPMread / 256
+ local RPMlo = RPMread
+ local CLTread = math.floor(getSensor("CLT") + 0.5)
+
+ --print('ac out = ' ..globalAcOut)
+ if globalAcOut == 1 and RPMread >80 then
+ fanPayloadOff = { 0x88, 0x00 }
+ fanPayloadLo = { 0x88, 0x00 }
+ fanPayloadHi = { 0x88, 0x00 }
+ else
+ --print('ac off payload')
+ fanPayloadOff = { 0x00, 0x00 }
+ fanPayloadLo = { 0x40, 0x00 }
+ fanPayloadHi = { 0x80, 0x00 }
+ end
+
+ cltGauge = 0x00
+ -- acOut = {0x32, 0x80, 0x00, 0x10, 0x00, 0x00}
+ -- txCan(1, 0x625, 0,acOut)
+
+ -- clt gauge stuff
+ if CLTread < 115 then
+ -- txCan(1, 0x608, 0, canCLTpayloadNo)
+ cltGauge = math.floor(CLTread * 1.5 + 0.5)
+ elseif CLTread >= 115 then
+ -- txCan(1, 0x608, 0, canCLTpayloadHi)
+ cltGauge = 0xF0
+ end
+ -- print('clt gauge = '..cltGauge)
+ -- rpm fun stuff
+ if t : getElapsedSeconds() < 2 then
+ CLTandRPM = { 0x00, 0x18, 0x0C, 0x01, 0x0A, 0x87, 0xFF, 0xFF }
+ else
+ CLTandRPM = { 0x00, 0x18, 0x0c, RPMlo, RPMhi, 0x87, 0xFF, cltGauge }
+ end
+
+ txCan(1, 0x23D, 0, CLTandRPM) -- transmit CLT and RPM
+
+
+
+ if RPMread > 80 then
+ if CLTread <= 80 then
+ txCan(1, 0x1F9, 0, fanPayloadOff)
+ elseif CLTread >= 85 and CLTread < 90 then
+ txCan(1, 0x1F9, 0, fanPayloadLo)
+ elseif CLTread >= 90 then
+ txCan(1, 0x1F9, 0, fanPayloadHi)
+ end
+ else
+ txCan(1, 0x1F9, 0, fanPayloadOff)
+ end
+ -- print('CLT temp' ..CLTread)
+end
+
+
+function onCanRx(bus, id, dlc, data)
+ --print('got CAN id=' ..id ..' dlc=' ..dlc)
+ --print('ac value is= '..data[1])
+ if data[1] == 193 then
+ setAcRequestState(true)
+ globalAcOut = 1
+ --print('ac is on')
+ else
+ setAcRequestState(false)
+ globalAcOut = 0
+ --print('ac is off')
+ end
+
+end
\ No newline at end of file
diff --git a/firmware/controllers/lua/examples/bmw-idrive.txt b/firmware/controllers/lua/examples/bmw-idrive.txt
index 2cb75da301..6d2b7d9a78 100644
--- a/firmware/controllers/lua/examples/bmw-idrive.txt
+++ b/firmware/controllers/lua/examples/bmw-idrive.txt
@@ -12,7 +12,6 @@ canRxAdd(CAN_BUTTONS) -- buttons
setTickRate(5) -- set tick rate to 5hz
function onCanRx(bus, id, dlc, data)
- id = id % 2048
-- print('got CAN id=' ..id ..' dlc=' ..dlc)
if id == CAN_BUTTONS then
diff --git a/firmware/controllers/lua/examples/can-adc-server.txt b/firmware/controllers/lua/examples/can-adc-server.txt
new file mode 100644
index 0000000000..799ce1497f
--- /dev/null
+++ b/firmware/controllers/lua/examples/can-adc-server.txt
@@ -0,0 +1,18 @@
+txPayload = {}
+function onTick()
+ auxV = getAuxAnalog(0)
+ print('Hello analog ' .. auxV )
+ -- first byte: integer part, would be autoboxed to int
+ txPayload[1] = auxV
+ -- second byte: fractional part, would be autoboxed to int, overflow would be ignored
+ txPayload[2] = auxV * 256;
+ auxV = getAuxAnalog(1)
+ print('Hello analog ' .. auxV )
+ txPayload[3] = auxV
+ txPayload[4] = auxV * 256;
+ auxV = getAuxAnalog(2)
+ print('Hello analog ' .. auxV )
+ txPayload[5] = auxV
+ txPayload[6] = auxV * 256;
+ txCan(1, 0x600, 1, txPayload)
+end
\ No newline at end of file
diff --git a/firmware/controllers/lua/examples/can-client-dc-pid.txt b/firmware/controllers/lua/examples/can-client-dc-pid.txt
new file mode 100644
index 0000000000..a80a3aae1c
--- /dev/null
+++ b/firmware/controllers/lua/examples/can-client-dc-pid.txt
@@ -0,0 +1,51 @@
+startPwm(0, 800, 0.1)
+-- direction
+startPwm(1, 80, 1.0)
+-- disable
+startPwm(2, 80, 0.0)
+
+-- p, i, d, min, max
+pid = Pid.new(2, 0, 0, -100, 100)
+
+biasCurveIndex = findCurveIndex("bias")
+
+canRxAdd(0x600)
+
+voltageFromCan = 0
+
+function onCanRx(bus, id, dlc, data)
+ print('got CAN id=' .. id .. ' dlc=' .. dlc)
+ voltageFromCan = data[2] / 256.0 + data[1]
+end
+
+function onTick()
+ local targetVoltage = getAuxAnalog(0)
+
+-- local target = interpolate(1, 0, 3.5, 100, targetVoltage)
+ local target = interpolate(1, 0, 3.5, 100, voltageFromCan)
+-- clamp 0 to 100
+ target = math.max(0, target)
+ target = math.min(100, target)
+
+ print('Decoded target: ' .. target)
+
+ local tps = getSensor("TPS1")
+ tps = (tps == nil and 'invalid TPS' or tps)
+ print('Tps ' .. tps)
+
+ local output = pid:get(target, tps)
+
+ local bias = curve(biasCurveIndex, target)
+ print('bias ' .. bias)
+
+ local duty = (bias + output) / 100
+ isPositive = duty > 0;
+ pwmValue = isPositive and duty or -duty
+ setPwmDuty(0, pwmValue)
+
+ dirValue = isPositive and 1 or 0;
+ setPwmDuty(1, dirValue)
+
+ print('pwm ' .. pwmValue .. ' dir ' .. dirValue)
+ print('')
+end
\ No newline at end of file
diff --git a/firmware/controllers/lua/examples/custom-launch-control.txt b/firmware/controllers/lua/examples/custom-launch-control.txt
new file mode 100644
index 0000000000..2a7467889c
--- /dev/null
+++ b/firmware/controllers/lua/examples/custom-launch-control.txt
@@ -0,0 +1,59 @@
+-- analog knob controls desired launch RPM and boost
+desiredRpmCurve = findCurveIndex("desired_rpm")
+desiredBoostCurve = findCurveIndex("desired_boost")
+-- we lookup initial torque reduction based on desired RPM and boost
+initialTorqueReductionTable = findTableIndex("torque_red")
+-- we have tables for spark skip ratio and spark retard based on desired torque reduction
+sparkCutByTorqueCurve = findCurveIndex("spark_cut")
+sparkRetardByTorqueCurve = findCurveIndex("spark_retard")
+
+previousLaunchButtonState = 0
+
+-- 50Hz
+setTickRate(50)
+
+-- we PID torque reduction TODO hard code better PID settings?
+-- p, i, d, min, max
+pid = Pid.new(2, 0, 0, -100, 100)
+
+function onTick()
+ launchButtonState = getAuxAnalog(0) > 1.5
+ launchStrength = getAuxAnalog(1)
+
+ if previousLaunchButtonState == 1 and launchButtonState == 0 then
+ print "Exiting LC"
+ elseif previousLaunchButtonState == 0 and launchButtonState == 1 then
+ desiredRPM = curve(desiredRpmCurve, launchStrength)
+ desiredBoost = curve(desiredBoostCurve, launchStrength)
+
+ initialTorqueReduction = table3d(initialTorqueReductionTable, desiredRPM, desiredBoost)
+ pid : setOffset(initialTorqueReduction)a
+
+
+ print ("Running LC " ..desiredRPM .." boost=" ..desiredBoost ..' t=' ..initialTorqueReduction)
+
+ elseif launchButtonState == 1 then
+ print ("Running LC desired " ..desiredRPM .." boost=" ..desiredBoost)
+
+ rpm = getSensor("RPM")
+ -- handle nil RPM, todo: change firmware to avoid nil RPM
+ rpm = (rpm == nil and 0 or rpm)
+
+ print ("Running current " ..rpm .." boost=" ..desiredBoost)
+
+ torqueReduction = pid : get(desiredRPM, rpm)
+ sparkCut = curve(sparkCutByTorqueCurve, torqueReduction)
+ sparkRetard = curve(sparkRetardByTorqueCurve, torqueReduction)
+
+ setTimingAdd(sparkRetard)
+ setSparkSkipRatio(sparkRetard)
+ print ("Setting current " ..sparkRetard .." boost=" ..sparkRetard)
+
+ else
+ print "Not running LC"
+ setTimingAdd(0)
+ setSparkSkipRatio(0)
+ end
+
+end
+
diff --git a/firmware/controllers/lua/examples/ford-focus-ii-pps.txt b/firmware/controllers/lua/examples/ford-focus-ii-pps.txt
new file mode 100644
index 0000000000..82f0dd6b3f
--- /dev/null
+++ b/firmware/controllers/lua/examples/ford-focus-ii-pps.txt
@@ -0,0 +1,30 @@
+
+-- https://sourceforge.net/p/ecu/wiki/canbus/
+-- todo: CAN ID 430h, period 50ms, produced by SJB. Byte 7: Bit2 A/C request (button pressed).
+
+canRxAdd(0x201)
+setTickRate(20)
+
+ppsSensor = Sensor.new("AcceleratorPedal")
+
+function getTwoBytesMSB(data, offset, factor)
+ return (data[offset + 1] * 256 + data[offset + 2]) * factor
+end
+
+function onCanRx(bus, id, dlc, data)
+ packet = getTwoBytesMSB(data, 6, 1)
+ if packet < 0x7f or packet > 0xC8FF then
+ ppsSensor : invalidate()
+ else
+ ppsSensor : set(packet / 512)
+ end
+end
+
+function onTick()
+ ppsValue = getSensor("AcceleratorPedal")
+ if ppsValue == nil then
+ print ("PPS not defined")
+ else
+ print ("PPS " ..ppsValue)
+ end
+end
diff --git a/firmware/controllers/lua/examples/ms11bit.txt b/firmware/controllers/lua/examples/ms11bit.txt
new file mode 100644
index 0000000000..3ef8a67b19
--- /dev/null
+++ b/firmware/controllers/lua/examples/ms11bit.txt
@@ -0,0 +1,34 @@
+-- 11 bit MS protocol for TCM integration please select "listen to CAN broadcast" in "Use CAN for TPS/RPM/CLT"
+-- TPS MAP CLT RPM
+-- http://www.msextra.com/doc/pdf/Megasquirt_CAN_Broadcast.pdf
+
+packetALL = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+setTickRate(66)
+every100msTimer = Timer.new()
+function onTick()
+ rpm = getSensor("RPM")
+ rpm = (rpm == nil and 0 or rpm)
+ packetALL[3] = rpm / 256
+ packetALL[4] = rpm
+ tps = getSensor("Tps1")
+ tps = (tps == nil and 0 or tps)
+ tps = tps * 10
+ packetALL[7] = tps / 256
+ packetALL[8] = tps
+ clt = getSensor("Clt")
+ clt = (clt == nil and 0 or clt)
+ clt = clt * 1.8
+ clt = clt + 32
+ clt = clt * 10
+ packetALL[5] = clt / 256
+ packetALL[6] = clt
+ MAP = getSensor("Map")
+ MAP = (MAP == nil and 0 or MAP)
+ MAP = MAP * 10
+ packetALL[1] = MAP / 256
+ packetALL[2] = MAP
+ if every100msTimer:getElapsedSeconds() > 0.1 then
+ every100msTimer:reset()
+ txCan(1, 0x5E8, 0, packetALL)
+ end
+end
\ No newline at end of file
diff --git a/firmware/controllers/lua/examples/ms29bit.txt b/firmware/controllers/lua/examples/ms29bit.txt
new file mode 100644
index 0000000000..d288e2e916
--- /dev/null
+++ b/firmware/controllers/lua/examples/ms29bit.txt
@@ -0,0 +1,61 @@
+-- in the 29 bit protocol we hard-code magic areas based on data point location within MS outputs structure
+-- http://www.megamanual.com/com/CAN.htm
+
+--TPS MAP CLT RPM
+packetRPM = {0x00, 0x00}
+packetCLT = {0x00, 0x00} --BIT 3 AND 4 MAP(0.1/KPA) & BIT 7 AND 8 CLT (0.1/F)
+packetTPS = {0x00, 0x00} -- BIT 1 AND 2 TPS (0.1/%)
+packetMAP = {0x00, 0x00}
+
+setTickRate(66)
+
+canRxAdd(0x18B838)
+canRxAdd(0x58B838)
+canRxAdd(0x60B838)
+canRxAdd(0x48B838)
+
+
+function onCanRx(bus, id, dlc, data)
+ id11 = id % 2048
+ if id11 == 0x18B838 then -- RPM
+ txCan(1, 0x903B8, 1, packetRPM) -- Reply with RPM
+ end
+ if id11 == 0x58B838 then -- CLT
+ txCan(1, 0x5903B8, 1, packetCLT) -- Reply with RPM
+ end
+ if id11 == 0x60B838 then -- TPS
+ txCan(1, 0x6103B8, 1, packetTPS) -- Reply with RPM
+ end
+ if id11 == 0x48B838 then -- MAP
+ txCan(1, 0x4903B8, 1, packetMAP) -- Reply with MAP - HOW MANY BYTESS????
+ end
+
+end
+
+
+
+function onTick()
+
+ rpm = getSensor("RPM")
+ rpm = (rpm == nil and 0 or rpm)
+ packetRPM[1] = rpm / 256
+ packetRPM[2] = rpm
+
+ tps = getSensor("TPS")
+ tps = (tps == nil and 0 or tps)
+ tps = tps * 10
+ packetTPS[1] = tps / 256
+ packetTPS[2] = tps
+
+ clt = getSensor("Clt")
+ clt = (clt == nil and 0 or clt)
+ clt = clt * 1.8 + 134.2
+ packetCLT[1] = clt / 256
+ packetCLT[2] = clt
+
+ MAP = getSensor("MAP")
+ MAP = (MAP == nil and 0 or MAP)
+ MAP = MAP * 10
+ packetMAP[1] = map / 256
+ packetMAP[2] = map
+end
diff --git a/firmware/controllers/lua/generated/output_lookup_generated.cpp b/firmware/controllers/lua/generated/output_lookup_generated.cpp
index dda9ceff92..2137172ae2 100644
--- a/firmware/controllers/lua/generated/output_lookup_generated.cpp
+++ b/firmware/controllers/lua/generated/output_lookup_generated.cpp
@@ -395,6 +395,8 @@ float getOutputValueByName(const char *name) {
return engine->outputChannels.injectorFlowPressureRatio;
if (strEqualCaseInsensitive(name, "injectorFlowPressureDelta"))
return engine->outputChannels.injectorFlowPressureDelta;
+ if (strEqualCaseInsensitive(name, "alternatorStatus.pTerm"))
+ return engine->outputChannels.alternatorStatus.pTerm;
if (strEqualCaseInsensitive(name, "alternatorStatus.iTerm"))
return engine->outputChannels.alternatorStatus.iTerm;
if (strEqualCaseInsensitive(name, "alternatorStatus.dTerm"))
@@ -405,6 +407,8 @@ float getOutputValueByName(const char *name) {
return engine->outputChannels.alternatorStatus.error;
if (strEqualCaseInsensitive(name, "alternatorStatus.resetCounter"))
return engine->outputChannels.alternatorStatus.resetCounter;
+ if (strEqualCaseInsensitive(name, "idleStatus.pTerm"))
+ return engine->outputChannels.idleStatus.pTerm;
if (strEqualCaseInsensitive(name, "idleStatus.iTerm"))
return engine->outputChannels.idleStatus.iTerm;
if (strEqualCaseInsensitive(name, "idleStatus.dTerm"))
@@ -415,6 +419,8 @@ float getOutputValueByName(const char *name) {
return engine->outputChannels.idleStatus.error;
if (strEqualCaseInsensitive(name, "idleStatus.resetCounter"))
return engine->outputChannels.idleStatus.resetCounter;
+ if (strEqualCaseInsensitive(name, "etbStatus.pTerm"))
+ return engine->outputChannels.etbStatus.pTerm;
if (strEqualCaseInsensitive(name, "etbStatus.iTerm"))
return engine->outputChannels.etbStatus.iTerm;
if (strEqualCaseInsensitive(name, "etbStatus.dTerm"))
@@ -425,6 +431,8 @@ float getOutputValueByName(const char *name) {
return engine->outputChannels.etbStatus.error;
if (strEqualCaseInsensitive(name, "etbStatus.resetCounter"))
return engine->outputChannels.etbStatus.resetCounter;
+ if (strEqualCaseInsensitive(name, "boostStatus.pTerm"))
+ return engine->outputChannels.boostStatus.pTerm;
if (strEqualCaseInsensitive(name, "boostStatus.iTerm"))
return engine->outputChannels.boostStatus.iTerm;
if (strEqualCaseInsensitive(name, "boostStatus.dTerm"))
diff --git a/firmware/controllers/lua/generated/value_lookup_generated.cpp b/firmware/controllers/lua/generated/value_lookup_generated.cpp
index 8f8b1b6804..6a2057f66d 100644
--- a/firmware/controllers/lua/generated/value_lookup_generated.cpp
+++ b/firmware/controllers/lua/generated/value_lookup_generated.cpp
@@ -263,6 +263,12 @@ float getConfigValueByName(const char *name) {
return engineConfiguration->hip9011PrescalerAndSDO;
if (strEqualCaseInsensitive(name, "specs.cylindersCount"))
return engineConfiguration->specs.cylindersCount;
+ if (strEqualCaseInsensitive(name, "boostControlMinRpm"))
+ return engineConfiguration->boostControlMinRpm;
+ if (strEqualCaseInsensitive(name, "boostControlMinTps"))
+ return engineConfiguration->boostControlMinTps;
+ if (strEqualCaseInsensitive(name, "boostControlMinMap"))
+ return engineConfiguration->boostControlMinMap;
if (strEqualCaseInsensitive(name, "gapTrackingLengthOverride"))
return engineConfiguration->gapTrackingLengthOverride;
if (strEqualCaseInsensitive(name, "maxIdleVss"))
@@ -303,6 +309,8 @@ float getConfigValueByName(const char *name) {
return engineConfiguration->vssToothCount;
if (strEqualCaseInsensitive(name, "triggerSimulatorFrequency"))
return engineConfiguration->triggerSimulatorFrequency;
+ if (strEqualCaseInsensitive(name, "mc33_t_min_boost"))
+ return engineConfiguration->mc33_t_min_boost;
if (strEqualCaseInsensitive(name, "acIdleExtraOffset"))
return engineConfiguration->acIdleExtraOffset;
if (strEqualCaseInsensitive(name, "finalGearRatio"))
@@ -499,10 +507,8 @@ float getConfigValueByName(const char *name) {
return engineConfiguration->launchBoostDuty;
if (strEqualCaseInsensitive(name, "hardCutRpmRange"))
return engineConfiguration->hardCutRpmRange;
- if (strEqualCaseInsensitive(name, "launchAdvanceRpmRange"))
- return engineConfiguration->launchAdvanceRpmRange;
- if (strEqualCaseInsensitive(name, "launchTpsTreshold"))
- return engineConfiguration->launchTpsTreshold;
+ if (strEqualCaseInsensitive(name, "launchTpsThreshold"))
+ return engineConfiguration->launchTpsThreshold;
if (strEqualCaseInsensitive(name, "stft.maxIdleRegionRpm"))
return engineConfiguration->stft.maxIdleRegionRpm;
if (strEqualCaseInsensitive(name, "stft.maxOverrunLoad"))
@@ -533,6 +539,8 @@ float getConfigValueByName(const char *name) {
return engineConfiguration->boardUseTachPullUp;
if (strEqualCaseInsensitive(name, "boardUseTempPullUp"))
return engineConfiguration->boardUseTempPullUp;
+ if (strEqualCaseInsensitive(name, "yesUnderstandLocking"))
+ return engineConfiguration->yesUnderstandLocking;
if (strEqualCaseInsensitive(name, "silentTriggerError"))
return engineConfiguration->silentTriggerError;
if (strEqualCaseInsensitive(name, "useLinearCltSensor"))
@@ -575,10 +583,6 @@ float getConfigValueByName(const char *name) {
return engineConfiguration->boardUseD4PullDown;
if (strEqualCaseInsensitive(name, "boardUseD5PullDown"))
return engineConfiguration->boardUseD5PullDown;
- if (strEqualCaseInsensitive(name, "useFSIO5ForCriticalIssueEngineStop"))
- return engineConfiguration->useFSIO5ForCriticalIssueEngineStop;
- if (strEqualCaseInsensitive(name, "useFSIO4ForSeriousEngineWarning"))
- return engineConfiguration->useFSIO4ForSeriousEngineWarning;
if (strEqualCaseInsensitive(name, "launchActivateInverted"))
return engineConfiguration->launchActivateInverted;
if (strEqualCaseInsensitive(name, "twoStroke"))
@@ -839,6 +843,8 @@ float getConfigValueByName(const char *name) {
return engineConfiguration->hpfpTargetDecay;
if (strEqualCaseInsensitive(name, "vvtActivationDelayMs"))
return engineConfiguration->vvtActivationDelayMs;
+ if (strEqualCaseInsensitive(name, "tuneHidingKey"))
+ return engineConfiguration->tuneHidingKey;
return EFI_ERROR_CODE;
}
void setConfigValueByName(const char *name, float value) {
@@ -1104,6 +1110,21 @@ void setConfigValueByName(const char *name, float value) {
engineConfiguration->specs.cylindersCount = (int)value;
return;
}
+ if (strEqualCaseInsensitive(name, "boostControlMinRpm"))
+ {
+ engineConfiguration->boostControlMinRpm = (int)value;
+ return;
+ }
+ if (strEqualCaseInsensitive(name, "boostControlMinTps"))
+ {
+ engineConfiguration->boostControlMinTps = (int)value;
+ return;
+ }
+ if (strEqualCaseInsensitive(name, "boostControlMinMap"))
+ {
+ engineConfiguration->boostControlMinMap = (int)value;
+ return;
+ }
if (strEqualCaseInsensitive(name, "gapTrackingLengthOverride"))
{
engineConfiguration->gapTrackingLengthOverride = (int)value;
@@ -1204,6 +1225,11 @@ void setConfigValueByName(const char *name, float value) {
engineConfiguration->triggerSimulatorFrequency = (int)value;
return;
}
+ if (strEqualCaseInsensitive(name, "mc33_t_min_boost"))
+ {
+ engineConfiguration->mc33_t_min_boost = (int)value;
+ return;
+ }
if (strEqualCaseInsensitive(name, "acIdleExtraOffset"))
{
engineConfiguration->acIdleExtraOffset = (int)value;
@@ -1694,14 +1720,9 @@ void setConfigValueByName(const char *name, float value) {
engineConfiguration->hardCutRpmRange = (int)value;
return;
}
- if (strEqualCaseInsensitive(name, "launchAdvanceRpmRange"))
+ if (strEqualCaseInsensitive(name, "launchTpsThreshold"))
{
- engineConfiguration->launchAdvanceRpmRange = (int)value;
- return;
- }
- if (strEqualCaseInsensitive(name, "launchTpsTreshold"))
- {
- engineConfiguration->launchTpsTreshold = (int)value;
+ engineConfiguration->launchTpsThreshold = (int)value;
return;
}
if (strEqualCaseInsensitive(name, "stft.maxIdleRegionRpm"))
@@ -1779,6 +1800,11 @@ void setConfigValueByName(const char *name, float value) {
engineConfiguration->boardUseTempPullUp = (int)value;
return;
}
+ if (strEqualCaseInsensitive(name, "yesUnderstandLocking"))
+ {
+ engineConfiguration->yesUnderstandLocking = (int)value;
+ return;
+ }
if (strEqualCaseInsensitive(name, "silentTriggerError"))
{
engineConfiguration->silentTriggerError = (int)value;
@@ -1884,16 +1910,6 @@ void setConfigValueByName(const char *name, float value) {
engineConfiguration->boardUseD5PullDown = (int)value;
return;
}
- if (strEqualCaseInsensitive(name, "useFSIO5ForCriticalIssueEngineStop"))
- {
- engineConfiguration->useFSIO5ForCriticalIssueEngineStop = (int)value;
- return;
- }
- if (strEqualCaseInsensitive(name, "useFSIO4ForSeriousEngineWarning"))
- {
- engineConfiguration->useFSIO4ForSeriousEngineWarning = (int)value;
- return;
- }
if (strEqualCaseInsensitive(name, "launchActivateInverted"))
{
engineConfiguration->launchActivateInverted = (int)value;
@@ -2544,4 +2560,9 @@ void setConfigValueByName(const char *name, float value) {
engineConfiguration->vvtActivationDelayMs = (int)value;
return;
}
+ if (strEqualCaseInsensitive(name, "tuneHidingKey"))
+ {
+ engineConfiguration->tuneHidingKey = (int)value;
+ return;
+ }
}
diff --git a/firmware/controllers/lua/lua.cpp b/firmware/controllers/lua/lua.cpp
index d18404107a..b6c4ccab0e 100644
--- a/firmware/controllers/lua/lua.cpp
+++ b/firmware/controllers/lua/lua.cpp
@@ -149,6 +149,15 @@ static LuaHandle setupLuaState(lua_Alloc alloc) {
return nullptr;
}
+ lua_atpanic(ls, [](lua_State* l) {
+ firmwareError(OBD_PCM_Processor_Fault, "Lua panic: %s", lua_tostring(l, -1));
+
+ // hang the lua thread
+ while (true) ;
+
+ return 0;
+ });
+
// Load Lua's own libraries
loadLibraries(ls);
@@ -310,7 +319,7 @@ void LuaThread::ThreadTask() {
bool wasOk = runOneLua(myAlloc, config->luaScript);
// Reset any lua adjustments the script made
- // todo https://github.com/rusefi/rusefi/issues/4308 engine->engineState.luaAdjustments = {};
+ engine->resetLua();
if (!wasOk) {
// Something went wrong executing the script, spin
@@ -343,7 +352,7 @@ void startLua() {
initLuaCanRx();
#endif // EFI_CAN_SUPPORT
- luaThread.Start();
+ luaThread.start();
addConsoleActionS("lua", [](const char* str){
if (interactivePending) {
diff --git a/firmware/controllers/lua/lua.mk b/firmware/controllers/lua/lua.mk
index 6daa02f259..76f27ba576 100644
--- a/firmware/controllers/lua/lua.mk
+++ b/firmware/controllers/lua/lua.mk
@@ -4,6 +4,7 @@ LUA_EXT=$(PROJECT_DIR)/ext/lua
ALLCPPSRC += $(LUA_DIR)/lua.cpp \
$(LUA_DIR)/lua_hooks.cpp \
$(LUA_DIR)/lua_hooks_util.cpp \
+ $(LUA_DIR)/script_impl.cpp \
$(LUA_DIR)/generated/output_lookup_generated.cpp \
$(LUA_DIR)/generated/value_lookup_generated.cpp \
$(LUA_DIR)/lua_can_rx.cpp \
diff --git a/firmware/controllers/lua/lua_can_rx.cpp b/firmware/controllers/lua/lua_can_rx.cpp
index ab82a9d699..a8daf84750 100644
--- a/firmware/controllers/lua/lua_can_rx.cpp
+++ b/firmware/controllers/lua/lua_can_rx.cpp
@@ -6,23 +6,35 @@
static constexpr size_t maxFilterCount = 48;
-size_t filterCount = 0;
-int32_t luaCanRxIds[maxFilterCount] = {0};
+struct Filter {
+ int32_t Id;
+ int32_t Mask;
-static bool shouldRxCanFrame(const CANRxFrame& frame) {
+ int Bus;
+ int Callback;
+};
+
+size_t filterCount = 0;
+Filter filters[maxFilterCount];
+
+static Filter* getFilterForFrame(size_t busIndex, const CANRxFrame& frame) {
for (size_t i = 0; i < filterCount; i++) {
- int32_t id = luaCanRxIds[i];
- if (CAN_SID(frame) == id || CAN_EID(frame) == id) {
- return true;
+ auto& filter = filters[i];
+
+ if ((CAN_ID(frame) & filter.Mask) == filter.Id) {
+ if (filter.Bus == -1 || filter.Bus == busIndex) {
+ return &filter;
+ }
}
}
- return false;
+ return nullptr;
}
// Stores information about one received CAN frame: which bus, plus the actual frame
struct CanFrameData {
uint8_t BusIndex;
+ int Callback;
CANRxFrame Frame;
};
@@ -34,8 +46,10 @@ chibios_rt::Mailbox freeBuffers;
chibios_rt::Mailbox filledBuffers;
void processLuaCan(const size_t busIndex, const CANRxFrame& frame) {
+ auto filter = getFilterForFrame(busIndex, frame);
+
// Filter the frame if we aren't listening for it
- if (!shouldRxCanFrame(frame)) {
+ if (!filter) {
return;
}
@@ -57,6 +71,7 @@ void processLuaCan(const size_t busIndex, const CANRxFrame& frame) {
// Copy the frame in to the buffer
frameBuffer->BusIndex = busIndex;
frameBuffer->Frame = frame;
+ frameBuffer->Callback = filter->Callback;
{
// Push the frame in to the queue under lock
@@ -66,7 +81,14 @@ void processLuaCan(const size_t busIndex, const CANRxFrame& frame) {
}
static void handleCanFrame(LuaHandle& ls, CanFrameData* data) {
- lua_getglobal(ls, "onCanRx");
+ if (data->Callback == -1) {
+ // No callback, use catch-all function
+ lua_getglobal(ls, "onCanRx");
+ } else {
+ // Push the specified callback on to the stack
+ lua_rawgeti(ls, LUA_REGISTRYINDEX, data->Callback);
+ }
+
if (lua_isnil(ls, -1)) {
// no rx function, ignore
efiPrintf("LUA CAN rx missing function onCanRx");
@@ -78,7 +100,7 @@ static void handleCanFrame(LuaHandle& ls, CanFrameData* data) {
// Push bus, ID and DLC
lua_pushinteger(ls, data->BusIndex); // TODO: support multiple busses!
- lua_pushinteger(ls, CAN_EID(data->Frame));
+ lua_pushinteger(ls, CAN_ID(data->Frame));
lua_pushinteger(ls, dlc);
// Build table for data
@@ -144,18 +166,21 @@ void initLuaCanRx() {
void resetLuaCanRx() {
// Clear all lua filters - reloading the script will reinit them
- memset(luaCanRxIds, 0, sizeof(luaCanRxIds));
filterCount = 0;
}
-void addLuaCanRxFilter(int32_t eid) {
+void addLuaCanRxFilter(int32_t eid, uint32_t mask, int bus, int callback) {
if (filterCount >= maxFilterCount) {
firmwareError(OBD_PCM_Processor_Fault, "Too many Lua CAN RX filters");
}
- efiPrintf("Added Lua CAN RX filter: %d", eid);
+ efiPrintf("Added Lua CAN RX filter id 0x%x mask 0x%x with%s custom function", eid, mask, (callback == -1 ? "out" : ""));
+
+ filters[filterCount].Id = eid;
+ filters[filterCount].Mask = mask;
+ filters[filterCount].Bus = bus;
+ filters[filterCount].Callback = callback;
- luaCanRxIds[filterCount] = eid;
filterCount++;
}
diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp
index 3c5d868cce..8d8f76649c 100644
--- a/firmware/controllers/lua/lua_hooks.cpp
+++ b/firmware/controllers/lua/lua_hooks.cpp
@@ -10,7 +10,6 @@
#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
#include "can_msg_tx.h"
#endif // EFI_CAN_SUPPORT
-#include "crc.h"
#include "settings.h"
#include
@@ -20,8 +19,7 @@
#include "lua_hooks_util.h"
using namespace luaaa;
-// Some functions lean on existing FSIO implementation
-#include "fsio_impl.h"
+#include "script_impl.h"
#if EFI_PROD_CODE
#include "electronic_throttle_impl.h"
@@ -70,9 +68,19 @@ static int lua_getSensorByIndex(lua_State* l) {
return getSensor(l, static_cast(zeroBasedSensorIndex));
}
+static SensorType findSensorByName(lua_State* l, const char* name) {
+ SensorType type = findSensorTypeByName(name);
+
+ if (l && type == SensorType::Invalid) {
+ luaL_error(l, "Invalid sensor type: %s", name);
+ }
+
+ return type;
+}
+
static int lua_getSensorByName(lua_State* l) {
auto sensorName = luaL_checklstring(l, 1, nullptr);
- SensorType type = findSensorTypeByName(sensorName);
+ SensorType type = findSensorByName(l, sensorName);
return getSensor(l, type);
}
@@ -91,41 +99,9 @@ static int lua_hasSensor(lua_State* l) {
return 1;
}
-static int lua_table3d(lua_State* l) {
- auto humanTableIdx = luaL_checkinteger(l, 1);
- auto x = luaL_checknumber(l, 2);
- auto y = luaL_checknumber(l, 3);
-
- // index table, compute table lookup
- auto result = getscriptTable(humanTableIdx - HUMAN_OFFSET)->getValue(x, y);
-
- lua_pushnumber(l, result);
- return 1;
-}
-
-static int lua_curve2d(lua_State* l) {
- // index starting from 1
- auto humanCurveIdx = luaL_checkinteger(l, 1);
- auto x = luaL_checknumber(l, 2);
-
- auto result = getCurveValue(humanCurveIdx - HUMAN_OFFSET, x);
-
- lua_pushnumber(l, result);
- return 1;
-}
-
-static int lua_findCurveIndex(lua_State* l) {
- auto name = luaL_checklstring(l, 1, nullptr);
- auto result = getCurveIndexByName(name);
- if (result == EFI_ERROR_CODE) {
- lua_pushnil(l);
- } else {
- // TS counts curve from 1 so convert indexing here
- lua_pushnumber(l, result + HUMAN_OFFSET);
- }
- return 1;
-}
-
+/**
+ * @return number of elements
+ */
static uint32_t getArray(lua_State* l, int paramIndex, uint8_t *data, uint32_t size) {
uint32_t result = 0;
@@ -374,17 +350,46 @@ static int lua_setAirmass(lua_State* l) {
#endif // EFI_UNIT_TEST
+// TODO: PR this back in to https://github.com/gengyong/luaaa
+namespace LUAAA_NS {
+ template
+ struct PlacementConstructorCaller
+ {
+ // this speciailization passes the Lua state to the constructor as first argument, as it shouldn't
+ // participate in the index generation as it's not a normal parameter passed via the Lua stack.
+
+ static TCLASS * Invoke(lua_State * state, void * mem)
+ {
+ return InvokeImpl(state, mem, typename make_indices::type());
+ }
+
+ private:
+ template
+ static TCLASS * InvokeImpl(lua_State * state, void * mem, indices)
+ {
+ (void)state;
+ return new(mem) TCLASS(state, LuaStack::get(state, Ns + 1)...);
+ }
+ };
+}
+
struct LuaSensor final : public StoredValueSensor {
- LuaSensor() : LuaSensor("Invalid") { }
+ LuaSensor() : LuaSensor(nullptr, "Invalid") { }
~LuaSensor() {
unregister();
}
- LuaSensor(const char* name)
- : StoredValueSensor(findSensorTypeByName(name), MS2NT(100))
+ LuaSensor(lua_State* l, const char* name)
+ : StoredValueSensor(findSensorByName(l, name), MS2NT(100))
{
- Register();
+ // do a soft collision check to avoid a fatal error from the hard check in Register()
+ if (l && Sensor::hasSensor(type())) {
+ luaL_error(l, "Tried to create a Lua sensor of type %s, but one was already registered.", getSensorName());
+ } else {
+ Register();
+ efiPrintf("LUA registered sensor of type %s", getSensorName());
+ }
}
void set(float value) {
@@ -428,6 +433,11 @@ struct LuaPid final {
return m_pid.getOutput(target, input, dt);
}
+ void setOffset(float offset) {
+ m_params.offset = offset;
+ reset();
+ }
+
void reset() {
m_pid.reset();
}
@@ -438,6 +448,113 @@ private:
pid_s m_params;
};
+static bool isFunction(lua_State* l, int idx) {
+ return lua_type(l, idx) == LUA_TFUNCTION;
+}
+
+int getLuaFunc(lua_State* l) {
+ if (!isFunction(l, 1)) {
+ return luaL_error(l, "expected function");
+ } else {
+ return luaL_ref(l, LUA_REGISTRYINDEX);
+ }
+}
+
+#if EFI_CAN_SUPPORT
+int lua_canRxAdd(lua_State* l) {
+ uint32_t eid;
+
+ // defaults if not passed
+ int bus = -1;
+ int callback = -1;
+
+ switch (lua_gettop(l)) {
+ case 1:
+ // handle canRxAdd(id)
+ eid = luaL_checkinteger(l, 1);
+ break;
+
+ case 2:
+ if (isFunction(l, 2)) {
+ // handle canRxAdd(id, callback)
+ eid = luaL_checkinteger(l, 1);
+ lua_remove(l, 1);
+ callback = getLuaFunc(l);
+ } else {
+ // handle canRxAdd(bus, id)
+ bus = luaL_checkinteger(l, 1);
+ eid = luaL_checkinteger(l, 2);
+ }
+
+ break;
+ case 3:
+ // handle canRxAdd(bus, id, callback)
+ bus = luaL_checkinteger(l, 1);
+ eid = luaL_checkinteger(l, 2);
+ lua_remove(l, 1);
+ lua_remove(l, 1);
+ callback = getLuaFunc(l);
+ break;
+ default:
+ return luaL_error(l, "Wrong number of arguments to canRxAdd. Got %d, expected 1, 2, or 3.");
+ }
+
+ addLuaCanRxFilter(eid, 0x1FFFFFFF, bus, callback);
+
+ return 0;
+}
+
+int lua_canRxAddMask(lua_State* l) {
+ uint32_t eid;
+ uint32_t mask;
+
+ // defaults if not passed
+ int bus = -1;
+ int callback = -1;
+
+ switch (lua_gettop(l)) {
+ case 2:
+ // handle canRxAddMask(id, mask)
+ eid = luaL_checkinteger(l, 1);
+ mask = luaL_checkinteger(l, 2);
+ break;
+
+ case 3:
+ if (isFunction(l, 3)) {
+ // handle canRxAddMask(id, mask, callback)
+ eid = luaL_checkinteger(l, 1);
+ mask = luaL_checkinteger(l, 2);
+ lua_remove(l, 1);
+ lua_remove(l, 1);
+ callback = getLuaFunc(l);
+ } else {
+ // handle canRxAddMask(bus, id, mask)
+ bus = luaL_checkinteger(l, 1);
+ eid = luaL_checkinteger(l, 2);
+ mask = luaL_checkinteger(l, 3);
+ }
+
+ break;
+ case 4:
+ // handle canRxAddMask(bus, id, mask, callback)
+ bus = luaL_checkinteger(l, 1);
+ eid = luaL_checkinteger(l, 2);
+ mask = luaL_checkinteger(l, 3);
+ lua_remove(l, 1);
+ lua_remove(l, 1);
+ lua_remove(l, 1);
+ callback = getLuaFunc(l);
+ break;
+ default:
+ return luaL_error(l, "Wrong number of arguments to canRxAddMask. Got %d, expected 2, 3, or 4.");
+ }
+
+ addLuaCanRxFilter(eid, mask, bus, callback);
+
+ return 0;
+}
+#endif // EFI_CAN_SUPPORT
+
void configureRusefiLuaHooks(lua_State* l) {
LuaClass luaTimer(l, "Timer");
luaTimer
@@ -447,7 +564,7 @@ void configureRusefiLuaHooks(lua_State* l) {
LuaClass luaSensor(l, "Sensor");
luaSensor
- .ctor()
+ .ctor()
.fun("set", &LuaSensor::set)
.fun("invalidate", &LuaSensor::invalidate);
@@ -455,6 +572,7 @@ void configureRusefiLuaHooks(lua_State* l) {
luaPid
.ctor()
.fun("get", &LuaPid::get)
+ .fun("setOffset", &LuaPid::setOffset)
.fun("reset", &LuaPid::reset);
configureRusefiLuaUtilHooks(l);
@@ -465,9 +583,40 @@ void configureRusefiLuaHooks(lua_State* l) {
lua_register(l, "getSensor", lua_getSensorByName);
lua_register(l, "getSensorRaw", lua_getSensorRaw);
lua_register(l, "hasSensor", lua_hasSensor);
- lua_register(l, "table3d", lua_table3d);
- lua_register(l, "curve", lua_curve2d);
- lua_register(l, "findCurveIndex", lua_findCurveIndex);
+ lua_register(l, "table3d", [](lua_State* l) {
+ auto humanTableIdx = luaL_checkinteger(l, 1);
+ auto x = luaL_checknumber(l, 2);
+ auto y = luaL_checknumber(l, 3);
+
+ // index table, compute table lookup
+ auto result = getscriptTable(humanTableIdx - HUMAN_OFFSET)->getValue(x, y);
+
+ lua_pushnumber(l, result);
+ return 1;
+ });
+
+ lua_register(l, "curve", [](lua_State* l) {
+ // index starting from 1
+ auto humanCurveIdx = luaL_checkinteger(l, 1);
+ auto x = luaL_checknumber(l, 2);
+
+ auto result = getCurveValue(humanCurveIdx - HUMAN_OFFSET, x);
+
+ lua_pushnumber(l, result);
+ return 1;
+ });
+
+ lua_register(l, "findCurveIndex", [](lua_State* l) {
+ auto name = luaL_checklstring(l, 1, nullptr);
+ auto result = getCurveIndexByName(name);
+ if (result == EFI_ERROR_CODE) {
+ lua_pushnil(l);
+ } else {
+ // TS counts curve from 1 so convert indexing here
+ lua_pushnumber(l, result + HUMAN_OFFSET);
+ }
+ return 1;
+ });
#if EFI_CAN_SUPPORT || EFI_UNIT_TEST
lua_register(l, "txCan", lua_txCan);
@@ -524,7 +673,20 @@ void configureRusefiLuaHooks(lua_State* l) {
return 1;
});
-
+#if EFI_BOOST_CONTROL
+ lua_register(l, "setBoostAdd", [](lua_State* l) {
+ engine->boostController.luaTargetAdd = luaL_checknumber(l, 1);
+ return 0;
+ });
+ lua_register(l, "setBoostMult", [](lua_State* l) {
+ engine->boostController.luaTargetMult = luaL_checknumber(l, 1);
+ return 0;
+ });
+#endif // EFI_BOOST_CONTROL
+ lua_register(l, "setTimingAdd", [](lua_State* l) {
+ engine->ignitionState.luaTimingAdd = luaL_checknumber(l, 1);
+ return 0;
+ });
lua_register(l, "setTimingMult", [](lua_State* l) {
engine->ignitionState.luaTimingMult = luaL_checknumber(l, 1);
return 0;
@@ -540,10 +702,9 @@ void configureRusefiLuaHooks(lua_State* l) {
#if EFI_PROD_CODE
lua_register(l, "setEtbAdd", [](lua_State* l) {
auto luaAdjustment = luaL_checknumber(l, 1);
- for (int i = 0 ; i < ETB_COUNT; i++) {
- extern EtbController* etbControllers[];
- etbControllers[i]->luaAdjustment = luaAdjustment;
- }
+
+ setEtbLuaAdjustment(luaAdjustment);
+
return 0;
});
#endif // EFI_PROD_CODE
@@ -558,6 +719,11 @@ void configureRusefiLuaHooks(lua_State* l) {
return 0;
});
+ lua_register(l, "setAcRequestState", [](lua_State* l) {
+ engine->engineState.lua.acRequestState = lua_toboolean(l, 1);
+ return 0;
+ });
+
lua_register(l, "getCalibration", [](lua_State* l) {
auto propertyName = luaL_checklstring(l, 1, nullptr);
auto result = getConfigValueByName(propertyName);
@@ -611,11 +777,19 @@ void configureRusefiLuaHooks(lua_State* l) {
return 1;
});
- lua_register(l, "setTimingAdd", [](lua_State* l) {
- engine->ignitionState.luaTimingAdd = luaL_checknumber(l, 1);
- return 0;
+#if EFI_VEHICLE_SPEED
+ lua_register(l, "getCurrentGear", [](lua_State* l) {
+ lua_pushinteger(l, engine->module()->getCurrentGear());
+ return 1;
});
+ lua_register(l, "getRpmInGear", [](lua_State* l) {
+ auto idx = luaL_checkinteger(l, 1);
+ lua_pushinteger(l, engine->module()->getRpmInGear(idx));
+ return 1;
+ });
+#endif // EFI_VEHICLE_SPEED
+
#if !EFI_UNIT_TEST
lua_register(l, "startPwm", lua_startPwm);
lua_register(l, "setPwmDuty", lua_setPwmDuty);
@@ -640,12 +814,8 @@ void configureRusefiLuaHooks(lua_State* l) {
#if EFI_CAN_SUPPORT
- lua_register(l, "canRxAdd", [](lua_State* l) {
- auto eid = luaL_checkinteger(l, 1);
- addLuaCanRxFilter(eid);
-
- return 0;
- });
+ lua_register(l, "canRxAdd", lua_canRxAdd);
+ lua_register(l, "canRxAddMask", lua_canRxAddMask);
#endif // EFI_CAN_SUPPORT
#endif // not EFI_UNIT_TEST
}
diff --git a/firmware/controllers/lua/rusefi_lua.h b/firmware/controllers/lua/rusefi_lua.h
index cb056e4365..e50f7d2a64 100644
--- a/firmware/controllers/lua/rusefi_lua.h
+++ b/firmware/controllers/lua/rusefi_lua.h
@@ -61,7 +61,8 @@ void initLuaCanRx();
// Called when the user script is unloaded, resets any CAN rx filters
void resetLuaCanRx();
// Adds a frame ID to listen to
-void addLuaCanRxFilter(int32_t eid);
+void addLuaCanRxFilter(int32_t eid, uint32_t mask, int bus, int callback);
+
// Called from the Lua loop to process any pending CAN frames
void doLuaCanRx(LuaHandle& ls);
// Called from the CAN RX thread to queue a frame for Lua consumption
diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/lua/script_impl.cpp
similarity index 97%
rename from firmware/controllers/core/fsio_impl.cpp
rename to firmware/controllers/lua/script_impl.cpp
index 0e0222511e..ec71f76545 100644
--- a/firmware/controllers/core/fsio_impl.cpp
+++ b/firmware/controllers/lua/script_impl.cpp
@@ -10,7 +10,7 @@
#include "pch.h"
-#include "fsio_impl.h"
+#include "script_impl.h"
static fsio8_Map3D_f32t scriptTable1;
static fsio8_Map3D_u8t scriptTable2;
@@ -79,8 +79,7 @@ float getCurveValue(int index, float key) {
}
}
-// TODO: rename
-void initFsioImpl() {
+void initScriptImpl() {
scriptTable1.init(config->scriptTable1, config->scriptTable1LoadBins,
config->scriptTable1RpmBins);
scriptTable2.init(config->scriptTable2, config->scriptTable2LoadBins,
diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/lua/script_impl.h
similarity index 96%
rename from firmware/controllers/core/fsio_impl.h
rename to firmware/controllers/lua/script_impl.h
index a17ad731f5..113df42754 100644
--- a/firmware/controllers/core/fsio_impl.h
+++ b/firmware/controllers/lua/script_impl.h
@@ -13,7 +13,7 @@
typedef Map3D fsio8_Map3D_f32t;
typedef Map3D fsio8_Map3D_u8t;
-void initFsioImpl();
+void initScriptImpl();
float getCurveValue(int index, float key);
int getCurveIndexByName(const char *name);
diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp
index ee8df43fcc..6065f2e94d 100644
--- a/firmware/controllers/math/speed_density.cpp
+++ b/firmware/controllers/math/speed_density.cpp
@@ -71,14 +71,14 @@ temperature_t getTCharge(int rpm, float tps) {
const auto clt = Sensor::get(SensorType::Clt);
const auto iat = Sensor::get(SensorType::Iat);
- float airTemp = 0;
+ float airTemp;
// Without either valid, return 0C. It's wrong, but it'll pretend to be nice and dense, so at least you won't go lean.
if (!iat && !clt) {
return 0;
} else if (!clt && iat) {
// Intake temperature will almost always be colder (richer) than CLT - use that
- return airTemp;
+ return iat.Value;
} else if (!iat && clt) {
// Without valid intake temperature, assume intake temp is 0C, and interpolate anyway
airTemp = 0;
diff --git a/firmware/controllers/sensors/allsensors.cpp b/firmware/controllers/sensors/allsensors.cpp
index ad4343c5a8..9c9b0f1407 100644
--- a/firmware/controllers/sensors/allsensors.cpp
+++ b/firmware/controllers/sensors/allsensors.cpp
@@ -21,5 +21,5 @@ bool getAcToggle() {
}
bool hasAcToggle() {
- return (isBrainPinValid(engineConfiguration->acSwitch));
+ return isBrainPinValid(engineConfiguration->acSwitch);
}
diff --git a/firmware/controllers/sensors/converters/flex_sensor.h b/firmware/controllers/sensors/converters/flex_sensor.h
index a23655fd24..7842906a3e 100644
--- a/firmware/controllers/sensors/converters/flex_sensor.h
+++ b/firmware/controllers/sensors/converters/flex_sensor.h
@@ -12,13 +12,17 @@ public:
SensorResult convert(float frequency) const override {
// Sensor should only report 50-150hz, significantly outside that range indicates a problem
// it changes to 200hz+ to indicate methanol "contamination"
- if (frequency > 45 && frequency < 155) {
- float flexPct = clampF(0, frequency - 50, 100);
-
- return m_filter.filter(flexPct);
- } else {
- return unexpected;
+ if (frequency < 45) {
+ return UnexpectedCode::Low;
}
+
+ if (frequency > 155) {
+ return UnexpectedCode::High;
+ }
+
+ float flexPct = clampF(0, frequency - 50, 100);
+
+ return m_filter.filter(flexPct);
}
private:
diff --git a/firmware/controllers/sensors/converters/linear_func.cpp b/firmware/controllers/sensors/converters/linear_func.cpp
index afff57f5a0..5e42d11ad7 100644
--- a/firmware/controllers/sensors/converters/linear_func.cpp
+++ b/firmware/controllers/sensors/converters/linear_func.cpp
@@ -16,11 +16,15 @@ void LinearFunc::configure(float in1, float out1, float in2, float out2, float m
SensorResult LinearFunc::convert(float inputValue) const {
float result = m_a * inputValue + m_b;
- // Bounds check
- bool isValid = result <= m_maxOutput && result >= m_minOutput;
+ // Bounds checks
+ // Flipped error codes in case of m_a < 0 so that they indicate whether the input
+ // voltage is high/low, instead of the output high/low
+ if (result > m_maxOutput) {
+ return m_a > 0 ? UnexpectedCode::High : UnexpectedCode::Low;
+ }
- if (!isValid) {
- return unexpected;
+ if (result < m_minOutput) {
+ return m_a > 0 ? UnexpectedCode::Low : UnexpectedCode::High;
}
return result;
diff --git a/firmware/controllers/sensors/converters/resistance_func.cpp b/firmware/controllers/sensors/converters/resistance_func.cpp
index 8a26921a20..e7d2e16e2b 100644
--- a/firmware/controllers/sensors/converters/resistance_func.cpp
+++ b/firmware/controllers/sensors/converters/resistance_func.cpp
@@ -12,12 +12,12 @@ void ResistanceFunc::configure(float supplyVoltage, float pullupResistor) {
SensorResult ResistanceFunc::convert(float raw) const {
// If the voltage is very low, the sensor is a dead short.
if (raw < 0.05f) {
- return unexpected;
+ return UnexpectedCode::Low;
}
// If the voltage is very high (98% VCC), the sensor is open circuit.
if (raw > (m_supplyVoltage * 0.98f)) {
- return unexpected;
+ return UnexpectedCode::High;
}
// Voltage is in a sensible range - convert
diff --git a/firmware/controllers/sensors/converters/table_func.h b/firmware/controllers/sensors/converters/table_func.h
index cd646969a8..7893e42681 100644
--- a/firmware/controllers/sensors/converters/table_func.h
+++ b/firmware/controllers/sensors/converters/table_func.h
@@ -7,9 +7,10 @@
#pragma once
#include "sensor_converter_func.h"
-#include "interpolation.h"
#include "efi_ratio.h"
+#include
+
template >
class TableFunc final : public SensorConverter {
public:
diff --git a/firmware/controllers/sensors/converters/thermistor_func.cpp b/firmware/controllers/sensors/converters/thermistor_func.cpp
index d62f99321a..558b9d6bd5 100644
--- a/firmware/controllers/sensors/converters/thermistor_func.cpp
+++ b/firmware/controllers/sensors/converters/thermistor_func.cpp
@@ -12,7 +12,7 @@ SensorResult ThermistorFunc::convert(float ohms) const {
// This resistance should have already been validated - only
// thing we can check is that it's non-negative
if (ohms <= 0) {
- return unexpected;
+ return UnexpectedCode::Low;
}
float lnR = logf(ohms);
@@ -26,9 +26,14 @@ SensorResult ThermistorFunc::convert(float ohms) const {
float celsius = convertKelvinToCelcius(kelvin);
// bounds check result - please don't try to run rusEfi when colder than -50C
- // high end limit is required as this could be an oil temp sensor
- if (celsius < -50 || celsius > 250) {
- return unexpected;
+ // high end limit is required as this could be an oil temp sensor on an
+ // air cooled engine
+ if (celsius < -50) {
+ return UnexpectedCode::Low;
+ }
+
+ if (celsius > 250) {
+ return UnexpectedCode::High;
}
return celsius;
diff --git a/firmware/controllers/sensors/functional_sensor.cpp b/firmware/controllers/sensors/functional_sensor.cpp
index 3215e294f9..01338a9d51 100644
--- a/firmware/controllers/sensors/functional_sensor.cpp
+++ b/firmware/controllers/sensors/functional_sensor.cpp
@@ -7,7 +7,7 @@
void FunctionalSensor::postRawValue(float inputValue, efitick_t timestamp) {
// If no function is set, this sensor isn't valid.
if (!m_function) {
- invalidate();
+ invalidate(UnexpectedCode::Configuration);
return;
}
@@ -21,6 +21,6 @@ void FunctionalSensor::postRawValue(float inputValue, efitick_t timestamp) {
if (r.Valid) {
setValidValue(r.Value, timestamp);
} else {
- invalidate();
+ invalidate(r.Code);
}
}
diff --git a/firmware/controllers/sensors/redundant_ford_tps.cpp b/firmware/controllers/sensors/redundant_ford_tps.cpp
index 9861753c55..f357735825 100644
--- a/firmware/controllers/sensors/redundant_ford_tps.cpp
+++ b/firmware/controllers/sensors/redundant_ford_tps.cpp
@@ -23,7 +23,7 @@ SensorResult RedundantFordTps::get() const {
// If either result is invalid, return invalid.
if (!tps1 || !tps2) {
- return unexpected;
+ return UnexpectedCode::Inconsistent;
}
// The "actual" position resolved by the second throttle - this tops out at m_secondaryMaximum instead of 100%
@@ -37,7 +37,7 @@ SensorResult RedundantFordTps::get() const {
// Check that the resolved positions are close
float delta = absF(tps1.Value - tps2Actual);
if (delta > m_maxDifference) {
- return unexpected;
+ return UnexpectedCode::Inconsistent;
}
return (tps1.Value + tps2Actual) / 2;
@@ -49,5 +49,5 @@ SensorResult RedundantFordTps::get() const {
}
// Any other condition indicates an mismatch, and therefore an error
- return unexpected;
+ return UnexpectedCode::Inconsistent;
}
diff --git a/firmware/controllers/sensors/redundant_sensor.cpp b/firmware/controllers/sensors/redundant_sensor.cpp
index 86198e30f1..44dabb6fa9 100644
--- a/firmware/controllers/sensors/redundant_sensor.cpp
+++ b/firmware/controllers/sensors/redundant_sensor.cpp
@@ -26,13 +26,13 @@ SensorResult RedundantSensor::get() const {
// If either result is invalid, return invalid.
if (!result1.Valid || !result2.Valid) {
- return unexpected;
+ return UnexpectedCode::Inconsistent;
}
// If both are valid, check that they're near one another
float delta = absF(result1.Value - result2.Value);
if (delta > m_maxDifference) {
- return unexpected;
+ return UnexpectedCode::Inconsistent;
}
// Both sensors are valid, and their readings are close. All is well.
diff --git a/firmware/controllers/sensors/sensor.cpp b/firmware/controllers/sensors/sensor.cpp
index e88fc7e366..6639ed5b31 100644
--- a/firmware/controllers/sensors/sensor.cpp
+++ b/firmware/controllers/sensors/sensor.cpp
@@ -55,7 +55,7 @@ public:
if (s) {
// If this sensor says it doesn't exist, return unexpected
if (!s->hasSensor()) {
- return unexpected;
+ return UnexpectedCode::Configuration;
}
// If we found the sensor, ask it for a result.
@@ -63,7 +63,7 @@ public:
}
// We've exhausted all valid ways to return something - sensor not found.
- return unexpected;
+ return UnexpectedCode::Configuration;
}
void showInfo(const char* sensorName) const {
@@ -145,17 +145,23 @@ void Sensor::unregister() {
return &s_sensorRegistry[index];
}
+#if EFI_UNIT_TEST
+// scary nullable return result thus you probably do not need this in production code
/*static*/ const Sensor *Sensor::getSensorOfType(SensorType type) {
auto entry = getEntryForType(type);
return entry ? entry->getSensor() : nullptr;
}
+#endif // EFI_UNIT_TEST
+/**
+ * @returns NotNull: sensor result or UnexpectedCode::Configuration if sensor is not registered
+ */
/*static*/ SensorResult Sensor::get(SensorType type) {
const auto entry = getEntryForType(type);
// Check if this is a valid sensor entry
if (!entry) {
- return unexpected;
+ return UnexpectedCode::Configuration;
}
return entry->get();
@@ -245,12 +251,13 @@ void Sensor::unregister() {
* todo: some sort of hashmap in the future?
*/
SensorType findSensorTypeByName(const char *name) {
- for (int i = 0;i<(int)SensorType::PlaceholderLast;i++) {
- SensorType type = (SensorType)i;
- const char *sensorName = getSensorType(type);
- if (strEqualCaseInsensitive(sensorName, name)) {
- return type;
- }
- }
- return SensorType::Invalid;
+ for (int i = 0;i<(int)SensorType::PlaceholderLast;i++) {
+ SensorType type = (SensorType)i;
+ const char *sensorName = getSensorType(type);
+ if (strEqualCaseInsensitive(sensorName, name)) {
+ return type;
+ }
+ }
+
+ return SensorType::Invalid;
}
diff --git a/firmware/controllers/sensors/sensor_checker.cpp b/firmware/controllers/sensors/sensor_checker.cpp
new file mode 100644
index 0000000000..b32ac0df9c
--- /dev/null
+++ b/firmware/controllers/sensors/sensor_checker.cpp
@@ -0,0 +1,221 @@
+#include "pch.h"
+
+// Decode what OBD code we should use for a particular [sensor, code] problem
+static obd_code_e getCode(SensorType type, UnexpectedCode code) {
+ switch (type) {
+ case SensorType::Tps1:
+ case SensorType::Tps1Primary:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_TPS1_Primary_Timeout;
+ case UnexpectedCode::Low: return OBD_TPS1_Primary_Low;
+ case UnexpectedCode::High: return OBD_TPS1_Primary_High;
+ case UnexpectedCode::Inconsistent: return OBD_TPS1_Correlation;
+ default: break;
+ } break;
+ case SensorType::Tps1Secondary:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_TPS1_Secondary_Timeout;
+ case UnexpectedCode::Low: return OBD_TPS1_Secondary_Low;
+ case UnexpectedCode::High: return OBD_TPS1_Secondary_High;
+ default: break;
+ } break;
+ case SensorType::Tps2:
+ case SensorType::Tps2Primary:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_TPS2_Primary_Timeout;
+ case UnexpectedCode::Low: return OBD_TPS2_Primary_Low;
+ case UnexpectedCode::High: return OBD_TPS2_Primary_High;
+ case UnexpectedCode::Inconsistent: return OBD_TPS2_Correlation;
+ default: break;
+ } break;
+ case SensorType::Tps2Secondary:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_TPS2_Secondary_Timeout;
+ case UnexpectedCode::Low: return OBD_TPS2_Secondary_Low;
+ case UnexpectedCode::High: return OBD_TPS2_Secondary_High;
+ default: break;
+ } break;
+
+ case SensorType::AcceleratorPedal:
+ case SensorType::AcceleratorPedalPrimary:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_PPS_Primary_Timeout;
+ case UnexpectedCode::Low: return OBD_PPS_Primary_Low;
+ case UnexpectedCode::High: return OBD_PPS_Primary_High;
+ case UnexpectedCode::Inconsistent: return OBD_PPS_Correlation;
+ default: break;
+ } break;
+ case SensorType::AcceleratorPedalSecondary:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_PPS_Secondary_Timeout;
+ case UnexpectedCode::Low: return OBD_PPS_Secondary_Low;
+ case UnexpectedCode::High: return OBD_PPS_Secondary_High;
+ default: break;
+ } break;
+
+ case SensorType::Map:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_Map_Timeout;
+ case UnexpectedCode::Low: return OBD_Map_Low;
+ case UnexpectedCode::High: return OBD_Map_High;
+ default: break;
+ } break;
+ case SensorType::Clt:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_Clt_Timeout;
+ case UnexpectedCode::Low: return OBD_Clt_Low;
+ case UnexpectedCode::High: return OBD_Clt_High;
+ default: break;
+ } break;
+ case SensorType::Iat:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_Iat_Timeout;
+ case UnexpectedCode::Low: return OBD_Iat_Low;
+ case UnexpectedCode::High: return OBD_Iat_High;
+ default: break;
+ } break;
+ case SensorType::FuelEthanolPercent:
+ switch (code) {
+ case UnexpectedCode::Timeout: return OBD_FlexSensor_Timeout;
+ case UnexpectedCode::Low: return OBD_FlexSensor_Low;
+ case UnexpectedCode::High: return OBD_FlexSensor_High;
+ default: break;
+ } break;
+ default:
+ break;
+ }
+
+ return OBD_None;
+}
+
+inline const char* describeUnexpected(UnexpectedCode code) {
+ switch (code) {
+ case UnexpectedCode::Timeout: return "has timed out";
+ case UnexpectedCode::High: return "input too high";
+ case UnexpectedCode::Low: return "input too low";
+ case UnexpectedCode::Inconsistent: return "is inconsistent";
+ case UnexpectedCode::Configuration: return "is misconfigured";
+ case UnexpectedCode::Unknown:
+ default:
+ return "unknown";
+ }
+}
+
+static void check(SensorType type) {
+ // Don't check sensors we don't have
+ if (!Sensor::hasSensor(type)) {
+ return;
+ }
+
+ auto result = Sensor::get(type);
+
+ // If the sensor is OK, nothing to check.
+ if (result) {
+ return;
+ }
+
+ obd_code_e code = getCode(type, result.Code);
+
+ if (code != OBD_None) {
+ warning(code, "Sensor fault: %s %s", Sensor::getSensorName(type), describeUnexpected(result.Code));
+ }
+}
+
+static obd_code_e getCodeForInjector(int idx, brain_pin_diag_e diag) {
+ if (idx < 0 || idx >= 12) {
+ return OBD_None;
+ }
+
+ // TODO: do something more intelligent with `diag`?
+ UNUSED(diag);
+
+ return (obd_code_e)((int)OBD_Injector_Circuit_1 + idx);
+}
+
+static obd_code_e getCodeForIgnition(int idx, brain_pin_diag_e diag) {
+ if (idx < 0 || idx >= 12) {
+ return OBD_None;
+ }
+
+ // TODO: do something more intelligent with `diag`?
+ UNUSED(diag);
+
+ return (obd_code_e)((int)OBD_Ignition_Circuit_1 + idx);
+}
+
+void SensorChecker::onSlowCallback() {
+ // Don't check when the ignition is off, or when it was just turned on (let things stabilize)
+ // TODO: also inhibit checking if we just did a flash burn, since that blocks the ECU for a few seconds.
+ if (!m_ignitionIsOn || !m_timeSinceIgnOff.hasElapsedSec(5)) {
+ return;
+ }
+
+ // Check sensors
+ check(SensorType::Tps1Primary);
+ check(SensorType::Tps1Secondary);
+ check(SensorType::Tps1);
+ check(SensorType::Tps2Primary);
+ check(SensorType::Tps2Secondary);
+ check(SensorType::Tps2);
+
+ check(SensorType::Tps2);
+ check(SensorType::Tps2Primary);
+ check(SensorType::Tps2Secondary);
+
+ check(SensorType::Map);
+
+ check(SensorType::Clt);
+ check(SensorType::Iat);
+
+ check(SensorType::FuelEthanolPercent);
+
+// only bother checking these if we have GPIO chips actually capable of reporting an error
+#if BOARD_EXT_GPIOCHIPS > 0 && EFI_PROD_CODE
+ // Check injectors
+ for (int i = 0; i < efi::size(enginePins.injectors); i++) {
+ InjectorOutputPin& pin = enginePins.injectors[i];
+
+ // Skip not-configured pins
+ if (!isBrainPinValid(pin.brainPin)) {
+ continue;
+ }
+
+ auto diag = pin.getDiag();
+ if (diag != PIN_OK) {
+ auto code = getCodeForInjector(i + 1, diag);
+
+ char description[32];
+ pinDiag2string(description, efi::size(description), diag);
+ warning(code, "Injector %d fault: %s", i, description);
+ }
+ }
+
+ // Check ignition
+ for (int i = 0; i < efi::size(enginePins.injectors); i++) {
+ IgnitionOutputPin& pin = enginePins.coils[i];
+
+ // Skip not-configured pins
+ if (!isBrainPinValid(pin.brainPin)) {
+ continue;
+ }
+
+ auto diag = pin.getDiag();
+ if (diag != PIN_OK) {
+ auto code = getCodeForIgnition(i + 1, diag);
+
+ char description[32];
+ pinDiag2string(description, efi::size(description), diag);
+ warning(code, "Ignition %d fault: %s", i, description);
+ }
+ }
+#endif // BOARD_EXT_GPIOCHIPS > 0
+}
+
+void SensorChecker::onIgnitionStateChanged(bool ignitionOn) {
+ m_ignitionIsOn = ignitionOn;
+
+ if (!ignitionOn) {
+ // timer keeps track of how long since the state was turned to on (ie, how long ago was it last off)
+ m_timeSinceIgnOff.reset();
+ }
+}
diff --git a/firmware/controllers/sensors/sensor_checker.h b/firmware/controllers/sensors/sensor_checker.h
new file mode 100644
index 0000000000..1d93502658
--- /dev/null
+++ b/firmware/controllers/sensors/sensor_checker.h
@@ -0,0 +1,12 @@
+#pragma once
+
+// TODO: this name is now probably wrong, since it checks injectors/ignition too
+struct SensorChecker : public EngineModule {
+public:
+ void onSlowCallback() override;
+ void onIgnitionStateChanged(bool ignitionOn) override;
+
+private:
+ bool m_ignitionIsOn = false;
+ Timer m_timeSinceIgnOff;
+};
diff --git a/firmware/controllers/sensors/sensor_info_printing.cpp b/firmware/controllers/sensors/sensor_info_printing.cpp
index dae93dc40c..d6488e8f4b 100644
--- a/firmware/controllers/sensors/sensor_info_printing.cpp
+++ b/firmware/controllers/sensors/sensor_info_printing.cpp
@@ -15,8 +15,8 @@ void ProxySensor::showInfo(const char* sensorName) const {
}
void FunctionalSensor::showInfo(const char* sensorName) const {
- const auto [valid, value] = get();
- efiPrintf("Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, m_rawValue, boolToString(valid), value);
+ const auto value = get();
+ efiPrintf("Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, m_rawValue, boolToString(value.Valid), value.Value);
// now print out the underlying function's info
if (auto func = m_function) {
@@ -28,8 +28,8 @@ void FunctionalSensor::showInfo(const char* sensorName) const {
#include "can_sensor.h"
void CanSensorBase::showInfo(const char* sensorName) const {
- const auto [valid, value] = get();
- efiPrintf("CAN Sensor \"%s\": valid: %s value: %.2f", sensorName, boolToString(valid), value);
+ const auto value = get();
+ efiPrintf("CAN Sensor \"%s\": valid: %s value: %.2f", sensorName, boolToString(value.Valid), value.Value);
}
#endif // EFI_CAN_SUPPORT
@@ -63,8 +63,8 @@ void Lps25Sensor::showInfo(const char* sensorName) const {
void LinearFunc::showInfo(float testRawValue) const {
efiPrintf(" Linear function slope: %.2f offset: %.2f min: %.1f max: %.1f", m_a, m_b, m_minOutput, m_maxOutput);
- const auto [valid, value] = convert(testRawValue);
- efiPrintf(" raw value %.2f converts to %.2f valid: %s", testRawValue, value, boolToString(valid));
+ const auto value = convert(testRawValue);
+ efiPrintf(" raw value %.2f converts to %.2f valid: %s", testRawValue, value.Value, boolToString(value.Valid));
}
void ResistanceFunc::showInfo(float testInputValue) const {
@@ -73,8 +73,8 @@ void ResistanceFunc::showInfo(float testInputValue) const {
}
void ThermistorFunc::showInfo(float testInputValue) const {
- const auto [valid, value] = convert(testInputValue);
- efiPrintf(" %.1f ohms -> valid: %s. %.1f deg C", testInputValue, boolToString(valid), value);
+ const auto value = convert(testInputValue);
+ efiPrintf(" %.1f ohms -> valid: %s. %.1f deg C", testInputValue, boolToString(value.Valid), value.Value);
}
void IdentityFunction::showInfo(float /*testInputValue*/) const {
diff --git a/firmware/controllers/sensors/sensors.mk b/firmware/controllers/sensors/sensors.mk
index efaa990c3a..05cd15bc95 100644
--- a/firmware/controllers/sensors/sensors.mk
+++ b/firmware/controllers/sensors/sensors.mk
@@ -8,6 +8,7 @@ CONTROLLERS_SENSORS_SRC_CPP = $(PROJECT_DIR)/controllers/sensors/thermistors.cp
$(PROJECT_DIR)/controllers/sensors/ego.cpp \
$(PROJECT_DIR)/controllers/sensors/sensor.cpp \
$(PROJECT_DIR)/controllers/sensors/sensor_info_printing.cpp \
+ $(PROJECT_DIR)/controllers/sensors/sensor_checker.cpp \
$(PROJECT_DIR)/controllers/sensors/functional_sensor.cpp \
$(PROJECT_DIR)/controllers/sensors/redundant_sensor.cpp \
$(PROJECT_DIR)/controllers/sensors/redundant_ford_tps.cpp \
diff --git a/firmware/controllers/sensors/software_knock.cpp b/firmware/controllers/sensors/software_knock.cpp
index 315278eb88..52f0309c8b 100644
--- a/firmware/controllers/sensors/software_knock.cpp
+++ b/firmware/controllers/sensors/software_knock.cpp
@@ -150,7 +150,7 @@ void initSoftwareKnock() {
#if KNOCK_HAS_CH2
efiSetPadMode("knock ch2", KNOCK_PIN_CH2, PAL_MODE_INPUT_ANALOG);
#endif
- kt.Start();
+ kt.start();
}
}
diff --git a/firmware/controllers/sensors/stored_value_sensor.h b/firmware/controllers/sensors/stored_value_sensor.h
index 868e52c52c..f3f2d65b7d 100644
--- a/firmware/controllers/sensors/stored_value_sensor.h
+++ b/firmware/controllers/sensors/stored_value_sensor.h
@@ -30,51 +30,55 @@
class StoredValueSensor : public Sensor {
public:
SensorResult get() const final override {
- bool valid = m_isValid;
- float value = m_value;
-
- if (!valid) {
- return unexpected;
- }
+ auto result = m_result;
// Timeouts are disabled, return last value
if (Sensor::s_inhibitSensorTimeouts) {
- return value;
+ return result;
+ }
+
+ // Result is already failed, return that so that we get the real error code instead of a timeout
+ if (!result) {
+ return result;
}
if (m_timeoutPeriod != 0) { // zero m_timeoutPeriod means value lasts forever
if (getTimeNowNt() - m_timeoutPeriod > m_lastUpdate) {
- return unexpected;
+ return UnexpectedCode::Timeout;
}
}
- return value;
+ return result;
}
StoredValueSensor(SensorType type, efitick_t timeoutNt)
: Sensor(type)
+ , m_result(unexpected)
, m_timeoutPeriod(timeoutNt)
{
}
// Invalidate the stored value.
void invalidate() {
- m_isValid = false;
+ m_result = unexpected;
+ }
+
+ // Invalidate the stored value with an error code
+ void invalidate(UnexpectedCode why) {
+ m_result = why;
}
// A new reading is available: set and validate a new value for the sensor.
void setValidValue(float value, efitick_t timestamp) {
// Set value before valid - so we don't briefly have the valid bit set on an invalid value
- m_value = value;
- m_isValid = true;
+ m_result = value;
m_lastUpdate = timestamp;
}
void showInfo(const char*) const override { }
private:
- bool m_isValid = false;
- float m_value = 0.0f;
+ SensorResult m_result;
const efitick_t m_timeoutPeriod;
efitick_t m_lastUpdate = 0;
diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp
index 692470521f..c58880d675 100644
--- a/firmware/controllers/settings.cpp
+++ b/firmware/controllers/settings.cpp
@@ -211,7 +211,7 @@ static void printTpsSenser(const char *msg, SensorType sensor, int16_t min, int1
raw, getPinNameByAdcChannel(msg, channel, pinNameBuffer));
- efiPrintf("current 10bit=%d value=%.2f", convertVoltageTo10bitADC(raw), tps.Value);
+ efiPrintf("current 10bit=%d value=%.2f", convertVoltageTo10bitADC(raw), tps.value_or(0));
}
void printTPSInfo(void) {
@@ -979,7 +979,6 @@ const command_f_s commandsF[] = {
{"script_curve_2_value", setScriptCurve2Value},
#if EFI_PROD_CODE
#if EFI_IDLE_CONTROL
- {"idle_offset", setIdleOffset},
{"idle_p", setIdlePFactor},
{"idle_i", setIdleIFactor},
{"idle_d", setIdleDFactor},
@@ -1191,6 +1190,7 @@ void initSettings(void) {
addConsoleActionSS("set_egt_cs_pin", (VoidCharPtrCharPtr) setEgtCSPin);
addConsoleActionI("set_egt_spi", setEgtSpi);
+ addConsoleActionI(CMD_ECU_UNLOCK, unlockEcu);
addConsoleActionSS("set_trigger_simulator_mode", setTriggerSimulatorMode);
addConsoleActionS("set_fuel_pump_pin", setFuelPumpPin);
diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp
index 23ce194668..7488af0a51 100644
--- a/firmware/controllers/system/efi_gpio.cpp
+++ b/firmware/controllers/system/efi_gpio.cpp
@@ -475,6 +475,14 @@ void OutputPin::setDefaultPinState(const pin_output_mode_e *outputMode) {
setValue(false); // initial state
}
+brain_pin_diag_e OutputPin::getDiag() const {
+#if BOARD_EXT_GPIOCHIPS > 0
+ return gpiochips_getDiag(brainPin);
+#else
+ return PIN_OK;
+#endif
+}
+
void initOutputPins() {
#if EFI_GPIO_HARDWARE
diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h
index 3db75fe24d..3ceb0962a6 100644
--- a/firmware/controllers/system/efi_gpio.h
+++ b/firmware/controllers/system/efi_gpio.h
@@ -60,6 +60,8 @@ public:
void toggle();
bool getLogicValue() const;
+ brain_pin_diag_e getDiag() const;
+
#if EFI_GPIO_HARDWARE
ioportid_t port = 0;
uint8_t pin = 0;
diff --git a/firmware/controllers/system/periodic_task.h b/firmware/controllers/system/periodic_task.h
index 56b7967fb1..e4701c3ff2 100644
--- a/firmware/controllers/system/periodic_task.h
+++ b/firmware/controllers/system/periodic_task.h
@@ -35,7 +35,7 @@ public:
/**
* This invokes PeriodicTask() immediately and starts the cycle of invocations and sleeps
*/
- virtual void Start() {
+ virtual void start() {
#if !EFI_UNIT_TEST
chVTObjectInit(&timer);
#endif // EFI_UNIT_TEST
diff --git a/firmware/controllers/system/thread_controller.h b/firmware/controllers/system/thread_controller.h
index 09272c0cf6..9703f0dc90 100644
--- a/firmware/controllers/system/thread_controller.h
+++ b/firmware/controllers/system/thread_controller.h
@@ -7,8 +7,6 @@
#pragma once
-#include "global.h"
-
/**
* @brief A base class for a controller that requires its own thread.
*
@@ -17,53 +15,35 @@
* allocate the stack at compile time, it has to be a template parameter instead of a normal parameter)
*/
template
-class ThreadController
+class ThreadController : public chibios_rt::BaseStaticThread
{
private:
- THD_WORKING_AREA(m_threadstack, TStackSize);
- const tprio_t m_prio;
- bool m_isStarted = false;
-
- /**
- * The OS can only call a function with a single void* param. We have
- * to convert back to an instance of ThreadController, and call the task to run.
- */
- static void StaticThreadTaskAdapter(void* thread)
- {
- ThreadController* t = static_cast(thread);
-
- // Run our thread task
- t->ThreadTask();
- }
+ const tprio_t m_prio;
protected:
- /**
- * Override this function to implement your controller's thread's behavior.
- */
- virtual void ThreadTask() = 0;
- thread_t* m_thread;
+ // Override this function to implement your controller's thread's behavior.
+ virtual void ThreadTask() = 0;
+
+ void main() override {
+ this->setName(m_name);
+
+ ThreadTask();
+ }
const char* const m_name;
public:
- ThreadController(const char* name, tprio_t priority)
+ ThreadController(const char* name, tprio_t priority)
: m_prio(priority)
, m_name(name)
- {
- }
+ {
+ }
- /**
- * @brief Start the thread.
- */
- void Start()
- {
- if (m_isStarted) {
- warning(CUSTOM_OBD_6003, "Tried to start thread %s but it was already running", m_name);
- return;
- }
-
- m_thread = chThdCreateStatic(m_threadstack, sizeof(m_threadstack), m_prio, StaticThreadTaskAdapter, this);
- m_thread->name = m_name;
- m_isStarted = true;
- }
+ /**
+ * @brief Start the thread.
+ */
+ void start()
+ {
+ chibios_rt::BaseStaticThread::start(m_prio);
+ }
};
diff --git a/firmware/controllers/tc_4l6x.cpp b/firmware/controllers/tc_4l6x.cpp
index cbcedcca73..a47f9b125a 100644
--- a/firmware/controllers/tc_4l6x.cpp
+++ b/firmware/controllers/tc_4l6x.cpp
@@ -101,6 +101,7 @@ void Gm4l6xTransmissionController::setPcState(gear_e gear) {
shiftingFrom = getCurrentGear();
isShifting = true;
}
+
switch (getCurrentGear()) {
case REVERSE:
pcts = &config->tcu_pcValsR;
@@ -136,7 +137,12 @@ void Gm4l6xTransmissionController::setPcState(gear_e gear) {
case GEAR_4:
pcts = &config->tcu_pcVals4;
break;
+ default:
+ // TODO: how did we get here?
+ pcPwm.setSimplePwmDutyCycle(0);
+ return;
}
+
float duty = 0.01f * interpolate2d(engine->engineState.sd.airMassInOneCylinder, config->tcu_pcAirmassBins, *pcts);
pcPwm.setSimplePwmDutyCycle(duty);
}
diff --git a/firmware/controllers/trigger/decoders/trigger_rover.cpp b/firmware/controllers/trigger/decoders/trigger_rover.cpp
index b9dc2a344e..b746a2463d 100644
--- a/firmware/controllers/trigger/decoders/trigger_rover.cpp
+++ b/firmware/controllers/trigger/decoders/trigger_rover.cpp
@@ -19,6 +19,8 @@ void initializeRoverK(TriggerWaveform *s) {
float tooth = 20;
s->setTriggerSynchronizationGap(2.0);
+ // wow that's odd
+ s->setSecondTriggerSynchronizationGap2(0.0001, 100000);
s->setThirdTriggerSynchronizationGap(2);
float base = 0;
diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp
index a235165a16..f1205f5449 100644
--- a/firmware/controllers/trigger/decoders/trigger_structure.cpp
+++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp
@@ -644,14 +644,14 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperatio
case TT_TOOTHED_WHEEL_32_2:
setToothedWheelConfiguration(this, 32, 2, triggerOperationMode);
- // todo: add this second/third into 'setToothedWheelConfiguration' as long as we have enough tooth?
- setSecondTriggerSynchronizationGap(1); // this gap is not required to synch on perfect signal but is needed to handle to reject cranking transition noise
+ // todo: why is this 32/2 asking for third gap while 60/2 is happy with just two gaps?
+ // method above sets second gap, here we add third
+ // this third gap is not required to sync on perfect signal but is needed to handle to reject cranking transition noise
setThirdTriggerSynchronizationGap(1);
break;
case TT_TOOTHED_WHEEL_60_2:
setToothedWheelConfiguration(this, 60, 2, triggerOperationMode);
- setSecondTriggerSynchronizationGap(1); // this gap is not required to synch on perfect signal but is needed to handle to reject cranking transition noise
break;
case TT_TOOTHED_WHEEL_36_2:
diff --git a/firmware/controllers/trigger/decoders/trigger_subaru.cpp b/firmware/controllers/trigger/decoders/trigger_subaru.cpp
index d3c1ff9c33..68abaa25d9 100644
--- a/firmware/controllers/trigger/decoders/trigger_subaru.cpp
+++ b/firmware/controllers/trigger/decoders/trigger_subaru.cpp
@@ -20,10 +20,6 @@ static void initialize_one_of_36_2_2_2(TriggerWaveform *s, int firstCount, int s
float wide = 30 * 2;
float narrow = 10 * 2;
- s->setTriggerSynchronizationGap(0.333f);
- s->setSecondTriggerSynchronizationGap(1.0f);
- s->setThirdTriggerSynchronizationGap(3.0f);
-
float base = 0;
for (int i = 0; i < firstCount; i++) {
@@ -56,10 +52,18 @@ static void initialize_one_of_36_2_2_2(TriggerWaveform *s, int firstCount, int s
*/
void initialize36_2_2_2(TriggerWaveform *s) {
initialize_one_of_36_2_2_2(s, 12, 15, true);
+
+ s->setTriggerSynchronizationGap(0.333f);
+ s->setSecondTriggerSynchronizationGap(1.0f);
+ s->setThirdTriggerSynchronizationGap(3.0f);
}
void initializeSubaruEZ30(TriggerWaveform *s) {
initialize_one_of_36_2_2_2(s, 18, 9, true);
+
+ s->setTriggerSynchronizationGap3(/*gapIndex*/0, 0.25, 0.5);
+ s->setTriggerSynchronizationGap3(/*gapIndex*/1, 0.7, 1.5);
+ s->setTriggerSynchronizationGap3(/*gapIndex*/2, 2, 4);
}
static void initializeSubaru7_6(TriggerWaveform *s, bool withCrankWheel) {
diff --git a/firmware/controllers/trigger/decoders/trigger_universal.cpp b/firmware/controllers/trigger/decoders/trigger_universal.cpp
index dc62b4d8a4..5aac78acaa 100644
--- a/firmware/controllers/trigger/decoders/trigger_universal.cpp
+++ b/firmware/controllers/trigger/decoders/trigger_universal.cpp
@@ -48,6 +48,10 @@ void initializeSkippedToothTriggerWaveformExt(TriggerWaveform *s, int totalTeeth
#endif // EFI_UNIT_TEST
s->setTriggerSynchronizationGap(skippedCount + 1);
+ if (totalTeethCount > 6 && skippedCount > 0) {
+ // this gap is not required to synch on perfect signal but is needed to handle to reject cranking transition noise and potentially high rev noise as well
+ s->setSecondTriggerSynchronizationGap(1);
+ }
s->shapeWithoutTdc = (totalTeethCount > 1) && (skippedCount == 0);
s->isSynchronizationNeeded = (totalTeethCount > 2) && (skippedCount != 0);
diff --git a/firmware/controllers/trigger/decoders/triggers-meta.yaml b/firmware/controllers/trigger/decoders/triggers-meta.yaml
deleted file mode 100644
index 8fdc1b2ea2..0000000000
--- a/firmware/controllers/trigger/decoders/triggers-meta.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-# this file is consumed by TriggerProcessor.java during the gen_config.sh code generation phase
-
-triggers:
- - name: TT_GM_24x
- isFirstCrankBased: true
-
- - name: TT_GM_24x_2
- isFirstCrankBased: true
-
- - name: TT_HONDA_K_12_1
- isFirstCrankBased: true
-
- - name: TT_RENIX_44_2_2
- isFirstCrankBased: true
-
- - name: TT_RENIX_66_2_2_2
- isFirstCrankBased: true
-
- - name: TT_MIATA_VVT
- isFirstCrankBased: true
-
- - name: TT_TRI_TACH
- isFirstCrankBased: true
-
- - name: TT_60_2_VW
- isFirstCrankBased: true
-
- - name: TT_SKODA_FAVORIT
- isFirstCrankBased: true
-
- - name: TT_KAWA_KX450F
- isFirstCrankBased: true
-
- - name: TT_GM_7X
- isFirstCrankBased: true
diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp
index 0ff0343166..2a758b8c64 100644
--- a/firmware/controllers/trigger/trigger_central.cpp
+++ b/firmware/controllers/trigger/trigger_central.cpp
@@ -757,11 +757,6 @@ static void triggerShapeInfo() {
extern PwmConfig triggerSignal;
#endif /* #if EFI_PROD_CODE */
-#if HAL_USE_ICU == TRUE
-extern int icuRisingCallbackCounter;
-extern int icuFallingCallbackCounter;
-#endif /* HAL_USE_ICU */
-
void triggerInfo(void) {
#if EFI_PROD_CODE || EFI_SIMULATOR
@@ -772,10 +767,6 @@ void triggerInfo(void) {
efiPrintf("trigger PAL mode %d", engine->hwTriggerInputEnabled);
#else
-#if HAL_USE_ICU == TRUE
- efiPrintf("trigger ICU hw: %d %d %d", icuRisingCallbackCounter, icuFallingCallbackCounter, engine->hwTriggerInputEnabled);
-#endif /* HAL_USE_ICU */
-
#endif /* HAL_TRIGGER_USE_PAL */
efiPrintf("Template %s (%d) trigger %s (%d) useRiseEdge=%s onlyFront=%s tdcOffset=%.2f",
diff --git a/firmware/hw_layer/adc/AdcConfiguration.h b/firmware/hw_layer/adc/AdcConfiguration.h
index 07fc48cf27..cae15a55cd 100644
--- a/firmware/hw_layer/adc/AdcConfiguration.h
+++ b/firmware/hw_layer/adc/AdcConfiguration.h
@@ -13,6 +13,14 @@
#define ADC_MAX_CHANNELS_COUNT 16
#endif /* ADC_MAX_CHANNELS_COUNT */
+#ifndef SLOW_ADC_CHANNEL_COUNT
+#ifdef ADC_MUX_PIN
+#define SLOW_ADC_CHANNEL_COUNT 32
+#else // not ADC_MUX_PIN
+#define SLOW_ADC_CHANNEL_COUNT 16
+#endif // def ADC_MUX_PIN
+#endif // SLOW_ADC_CHANNEL_COUNT
+
// this structure contains one multi-channel ADC state snapshot
typedef struct {
volatile adcsample_t adc_data[ADC_MAX_CHANNELS_COUNT];
diff --git a/firmware/hw_layer/adc/adc_inputs.cpp b/firmware/hw_layer/adc/adc_inputs.cpp
index 2f212d0c0b..5f9ed872f5 100644
--- a/firmware/hw_layer/adc/adc_inputs.cpp
+++ b/firmware/hw_layer/adc/adc_inputs.cpp
@@ -35,7 +35,7 @@
#define ADC_BUF_DEPTH_FAST 4
#endif
-static NO_CACHE adcsample_t slowAdcSamples[ADC_MAX_CHANNELS_COUNT];
+static NO_CACHE adcsample_t slowAdcSamples[SLOW_ADC_CHANNEL_COUNT];
static NO_CACHE adcsample_t fastAdcSampleBuf[ADC_BUF_DEPTH_FAST * ADC_MAX_CHANNELS_COUNT];
static adc_channel_mode_e adcHwChannelEnabled[HW_MAX_ADC_INDEX];
@@ -460,7 +460,7 @@ void initAdcInputs() {
portInitAdc();
// Start the slow ADC thread
- slowAdcController.Start();
+ slowAdcController.start();
#if EFI_USE_FAST_ADC
fastAdc.init();
diff --git a/firmware/hw_layer/backup_ram.h b/firmware/hw_layer/backup_ram.h
index 466adbf216..d692747b0d 100644
--- a/firmware/hw_layer/backup_ram.h
+++ b/firmware/hw_layer/backup_ram.h
@@ -10,6 +10,8 @@
#include "global.h"
#include "efi_gpio.h"
+#include "error_handling.h"
+
typedef enum {
/**
* IAC Stepper motor position, 16-bit (stored in BKP0R 0..15)
@@ -47,3 +49,26 @@ void backupRamSave(backup_ram_e idx, uint32_t value);
// make sure that all changes are saved before we shutdown the MCU
void backupRamFlush(void);
+// These use very specific values to avoid interpreting random garbage memory as a real value
+enum class ErrorCookie : uint32_t {
+ None = 0,
+ FirmwareError = 0xcafebabe,
+ HardFault = 0xdeadbeef,
+};
+
+#if EFI_PROD_CODE
+struct BackupSramData {
+ ErrorCookie Cookie;
+
+ critical_msg_t ErrorString;
+ port_extctx FaultCtx;
+ uint32_t FaultType;
+ uint32_t FaultAddress;
+ uint32_t Csfr;
+
+ uint32_t BootCount;
+ uint32_t BootCountCookie;
+};
+
+BackupSramData* getBackupSram();
+#endif // EFI_PROD_CODE
diff --git a/firmware/hw_layer/digital_input/digital_input.cpp b/firmware/hw_layer/digital_input/digital_input.cpp
deleted file mode 100644
index 018d631b83..0000000000
--- a/firmware/hw_layer/digital_input/digital_input.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * @file digital_input.cpp
- *
- * @date Nov 11, 2019
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#include "pch.h"
-
-#include "digital_input.h"
-
-void digital_input_s::setWidthCallback(VoidInt handler, void *arg) {
- widthListeners.registerCallback(handler, arg);
-}
-
-void digital_input_s::setPeriodCallback(VoidInt handler, void *arg) {
- periodListeners.registerCallback(handler, arg);
-}
diff --git a/firmware/hw_layer/digital_input/digital_input.h b/firmware/hw_layer/digital_input/digital_input.h
deleted file mode 100644
index d543c52427..0000000000
--- a/firmware/hw_layer/digital_input/digital_input.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * @file digital_input.h
- * Universal input capture API hiding platform/hardware implementation details
- *
- * @date Nov 11, 2019
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#pragma once
-
-#include "listener_array.h"
-
-struct digital_input_s {
-#if HAL_USE_ICU
- ICUDriver *driver;
-#endif /* HAL_USE_ICU */
-
- volatile bool started = false;
- brain_pin_e brainPin = Gpio::Unassigned;
- IntListenerArray<1> widthListeners;
- IntListenerArray<1> periodListeners;
-
- // Width/Period names are historically inherited from ICU implementation, todo: migrate to better names, high/low? rise/hall?
- void setWidthCallback(VoidInt handler, void *arg);
- void setPeriodCallback(VoidInt handler, void *arg);
-};
diff --git a/firmware/hw_layer/digital_input/digital_input_exti.cpp b/firmware/hw_layer/digital_input/digital_input_exti.cpp
index 93c0ed1049..ac45f97a6a 100644
--- a/firmware/hw_layer/digital_input/digital_input_exti.cpp
+++ b/firmware/hw_layer/digital_input/digital_input_exti.cpp
@@ -107,16 +107,6 @@ void efiExtiDisablePin(brain_pin_e brainPin)
channel.CallbackData = nullptr;
}
-digital_input_s* startDigitalCaptureExti(const char * /*msg*/, brain_pin_e /*brainPin*/) {
- return nullptr;
-}
-
-#if ! EFI_ICU_INPUTS
-digital_input_s* startDigitalCapture(const char *msg, brain_pin_e brainPin) {
- return startDigitalCaptureExti(msg, brainPin);
-}
-#endif // EFI_ICU_INPUTS
-
static inline void triggerInterrupt() {
// Manually fire the I2C1_EV interrupt, it will be queued after this interrupt returns
NVIC->STIR = I2C1_EV_IRQn;
diff --git a/firmware/hw_layer/digital_input/digital_input_exti.h b/firmware/hw_layer/digital_input/digital_input_exti.h
index 64860dcdae..b1100e7fab 100644
--- a/firmware/hw_layer/digital_input/digital_input_exti.h
+++ b/firmware/hw_layer/digital_input/digital_input_exti.h
@@ -7,8 +7,6 @@
#pragma once
-#include "digital_input.h"
-
#if HAL_USE_PAL
using ExtiCallback = void(*)(void*, efitick_t);
diff --git a/firmware/hw_layer/digital_input/digital_input_icu.cpp b/firmware/hw_layer/digital_input/digital_input_icu.cpp
deleted file mode 100644
index c608f38b16..0000000000
--- a/firmware/hw_layer/digital_input/digital_input_icu.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * @file digital_input_icu.cpp
- * @brief Helper methods related to Input Capture Unit (ICU)
- *
- * There are some ChibiOS limitation or STM32 limitations or limitations of my brain
- *
- * See http://www.chibios.com/forum/viewtopic.php?t=1461
- * "PWM input requires a whole timer on the STM32.
- * You could use channel 1 and channel 2 of the same timer but not simultaneously.
- * Giovanni"
- *
- * See http://www.chibios.com/forum/viewtopic.php?f=2&t=247&hilit=icu+channel&start=50
- * "It is not possible, the TIM timers support one ICU channel at time.
- * Giovanni"
- *
- * See https://stackoverflow.com/questions/43440599/stm32-multi-channel-input-capture-overcapturing-on-all-channels-interrupts-not
- * where they seem to be capturing something on multiple channels maybe not PWM mode of ICU is the key difference?
- *
- * rus084 is reminding that EXTI could be enough for our needs
- * See joystick.cpp
- * See trigger_input.cpp
- *
- * @date Jun 23, 2013
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#include "pch.h"
-
-#include "digital_input_icu.h"
-
-#if EFI_ICU_INPUTS && HAL_USE_ICU
-
-#include "mpu_util.h"
-#include "eficonsole.h"
-
-static void icuWidthCallback(ICUDriver *driver);
-static void icuPeriordCallBack(ICUDriver *driver);
-
-/*
- * 30ms seems like width maximum, at 16bit precision that means
- * CORE_CLOCK / 33.33333 = TICKS * 65536
- * 168000000 / 33.333333 / 65536 = 76.90
- */
-static ICUConfig wave_icucfg = {
- .mode = ICU_INPUT_ACTIVE_LOW,
- .frequency = CORE_CLOCK / 100,
- .width_cb = icuWidthCallback,
- .period_cb = icuPeriordCallBack,
- .overflow_cb = NULL,
- .channel = ICU_CHANNEL_1,
- .dier = 0,
- .arr = 0xFFFFFFFFU
-};
-
-static ArrayList registeredIcus;
-
-//Nullable
-static digital_input_s * finddigital_input_s(ICUDriver *driver) {
- for (int i = 0; i < registeredIcus.size; i++) {
- if (registeredIcus.elements[i].driver == driver) {
- return ®isteredIcus.elements[i];
- }
- }
- firmwareError(CUSTOM_ERR_ICU, "reader not found");
- return (digital_input_s *) NULL;
-}
-
-static void icuWidthCallback(ICUDriver *driver) {
- /*
- * see comment in icuPeriordCallBack
- int rowWidth = icuGetWidth(driver);
- */
- digital_input_s * hw = finddigital_input_s(driver);
- hw->widthListeners.invokeJustArgCallbacks();
-}
-
-static void icuPeriordCallBack(ICUDriver *driver) {
- /*
- * we do not use timer period at all - we just need the event. For all time characteristics,
- * we use system time
- * int period = icuGetPeriod(driver);
- */
-
- digital_input_s * hw = finddigital_input_s(driver);
- hw->periodListeners.invokeJustArgCallbacks();
-}
-
-static uint32_t getAlternateFunctions(ICUDriver *driver) {
- if (driver == NULL) {
- firmwareError(CUSTOM_ERR_ICU_AF, "getAlternateFunctions(NULL)");
- return 0xffffffff;
- }
-#if STM32_ICU_USE_TIM1
- if (driver == &ICUD1) {
- return GPIO_AF_TIM1;
- }
-#endif
-#if STM32_ICU_USE_TIM2
- if (driver == &ICUD2) {
- return GPIO_AF_TIM2;
- }
-#endif
-#if STM32_ICU_USE_TIM3
- if (driver == &ICUD3) {
- return GPIO_AF_TIM3;
- }
-#endif
-#if STM32_ICU_USE_TIM4
- if (driver == &ICUD4) {
- return GPIO_AF_TIM4;
- }
-#endif
-#if STM32_ICU_USE_TIM8
- if (driver == &ICUD8) {
- return GPIO_AF_TIM8;
- }
-#endif
-#if STM32_ICU_USE_TIM9
- if (driver == &ICUD9) {
- return GPIO_AF_TIM9;
- }
-#endif
- firmwareError(CUSTOM_ERR_ICU_DRIVER, "No such driver");
- return 0xffffffff;
-}
-
-icuchannel_t getInputCaptureChannel(brain_pin_e hwPin) {
- switch (hwPin) {
- case Gpio::A5: // TIM2 stm32f4discovery/Frankenso default
- case Gpio::A6: // TIM3
- case Gpio::A8: // TIM1
- case Gpio::A15: // TIM2
- case Gpio::C6: // TIM3 stm32f4discovery/Frankenso default
- case Gpio::E9: // TIM1
- return ICU_CHANNEL_1;
-
- case Gpio::A1: // TIM2
- case Gpio::A7: // TIM3
- case Gpio::A9: // TIM1
- case Gpio::B3: // TIM2
- case Gpio::B5: // TIM2
- case Gpio::C7: // TIM3
- case Gpio::E11: // TIM1
- return ICU_CHANNEL_2;
- default:
- firmwareError(CUSTOM_ERR_ICU_PIN, "Unexpected hw pin in getInputCaptureChannel %s", hwPortname(hwPin));
- return ICU_CHANNEL_1;
- }
-}
-
-/**
- * as of Feb 2016, TIM1, TIM2, TIM3 and TIM9 are used for input capture
- * (that's the kind of event you need for shaft position sensor)
- * ChibiOS limitation is that only channels #1 and #2 could be used for input capture
- *
- * @return NULL if pin could not be used for ICU
- */
-//Nullable
-ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin) {
- UNUSED(msg);
-
- if (!isBrainPinValid(hwPin)) {
- return NULL;
- }
-#if STM32_ICU_USE_TIM1
- if (hwPin == Gpio::A8 ||
- hwPin == Gpio::A9 ||
- hwPin == Gpio::E9 ||
- hwPin == Gpio::E11) {
- return &ICUD1;
- }
-#endif
-#if STM32_ICU_USE_TIM2
- if (hwPin == Gpio::A1 ||
- hwPin == Gpio::A5 ||
- hwPin == Gpio::A15 ||
- hwPin == Gpio::B3) {
- return &ICUD2;
- }
-#endif
-#if STM32_ICU_USE_TIM3
- if (hwPin == Gpio::A6 ||
- hwPin == Gpio::A7 ||
- hwPin == Gpio::B4 ||
- hwPin == Gpio::B5 ||
- hwPin == Gpio::C6 ||
- hwPin == Gpio::C7) {
- return &ICUD3;
- }
-#endif
-#if STM32_ICU_USE_TIM8
- if (hwPin == Gpio::C6 ||
- hwPin == Gpio::C7) {
- return &ICUD8;
- }
-#endif
-#if STM32_ICU_USE_TIM9
- if (hwPin == Gpio::A2 ||
- hwPin == Gpio::A3 ||
- hwPin == Gpio::E5 ||
- hwPin == Gpio::E6) {
- return &ICUD9;
- }
-#endif
- return nullptr;
-}
-
-static void turnOnCapturePin(const char *msg, ICUDriver* driver, brain_pin_e brainPin) {
- if (driver) {
- iomode_t mode = (iomode_t) PAL_MODE_ALTERNATE(getAlternateFunctions(driver));
- efiSetPadMode(msg, brainPin, mode);
- }
-}
-
-/**
- * turns pin off and returns digital_input_s back into registeredIcus pool
- */
-void stopDigitalCapture(const char *msg, brain_pin_e brainPin) {
- if (!isBrainPinValid(brainPin)) {
- return;
- }
- efiSetPadUnused(brainPin);
-
- ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
- if (driver == NULL) {
- return;
- }
-
- int regSize = registeredIcus.size;
- for (int i = 0; i < regSize; i++) {
- if (registeredIcus.elements[i].driver == driver) {
- // removing from driver from the list of used drivers
- memcpy(®isteredIcus.elements[i], ®isteredIcus.elements[regSize - 1],
- sizeof(digital_input_s));
- registeredIcus.size--;
- icuDisableNotificationsI(driver);
- icuStopCapture(driver);
- icuStop(driver);
- return;
- }
- }
-}
-
-static void startInputDriver(const char *msg, /*nullable*/digital_input_s *hw) {
- if (hw == NULL) {
- // we can get NULL driver if user somehow has invalid pin in his configuration
- warning(CUSTOM_ERR_INVALID_INPUT_ICU_PIN, "s_not input pin");
- return;
- }
-
- ICUDriver *driver = hw->driver;
-
- if (driver) {
- if (hw->started) {
- icuDisableNotificationsI(driver);
- icuStopCapture(driver);
- icuStop(driver);
- }
- wave_icucfg.channel = getInputCaptureChannel(hw->brainPin);
- efiIcuStart(msg, driver, &wave_icucfg);
- efiAssertVoid(CUSTOM_ICU_DRIVER, driver != NULL, "di: driver is NULL");
- efiAssertVoid(CUSTOM_ICU_DRIVER_STATE, driver->state == ICU_READY, "di: driver not ready");
- icuStartCapture(driver); // this would change state from READY to WAITING
- icuEnableNotifications(driver);
- }
- hw->started = true;
-}
-
-digital_input_s* startDigitalCapture(const char *msg, brain_pin_e brainPin) {
- ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
- if (!driver) {
- firmwareError(CUSTOM_ERR_INVALID_INPUT_ICU_PIN, "Invalid %s ICU input pin: %s", msg, hwPortname(brainPin));
- return nullptr;
- }
-
- digital_input_s *hw = registeredIcus.add();
- hw->widthListeners.clear();
- hw->periodListeners.clear();
- hw->started = false;
- hw->brainPin = brainPin;
- hw->driver = driver;
- turnOnCapturePin(msg, driver, brainPin);
-
- startInputDriver(msg, hw);
- return hw;
-}
-
-#endif /* EFI_ICU_INPUTS */
diff --git a/firmware/hw_layer/digital_input/digital_input_icu.h b/firmware/hw_layer/digital_input/digital_input_icu.h
deleted file mode 100644
index 29d184e97a..0000000000
--- a/firmware/hw_layer/digital_input/digital_input_icu.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * @file digital_input_icu.h
- *
- * @date Jun 23, 2013
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#pragma once
-
-#include "digital_input.h"
-
-#if HAL_USE_ICU
-
-digital_input_s* startDigitalCapture(const char *msg, brain_pin_e brainPin);
-
-void stopDigitalCapture(const char *msg, brain_pin_e brainPin);
-
-//Nullable
-ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin);
-//Nullable
-icuchannel_t getInputCaptureChannel(brain_pin_e hwPin);
-
-#endif /* HAL_USE_ICU */
-
diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input.cpp
index da5d38104d..2fc442e9b2 100644
--- a/firmware/hw_layer/digital_input/trigger/trigger_input.cpp
+++ b/firmware/hw_layer/digital_input/trigger/trigger_input.cpp
@@ -14,23 +14,7 @@
#if (EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
-#if (HAL_USE_ICU == TRUE) || (HAL_TRIGGER_USE_PAL == TRUE) || (HAL_TRIGGER_USE_ADC == TRUE)
-
-#if (HAL_USE_ICU == TRUE)
- void icuTriggerTurnOnInputPins();
- int icuTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft);
- void icuTriggerTurnOffInputPin(brain_pin_e brainPin);
-#else
- #define icuTriggerTurnOnInputPins() ((void)0)
- int icuTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
- UNUSED(msg);
- UNUSED(index);
- UNUSED(isTriggerShaft);
-
- return -2;
- }
- #define icuTriggerTurnOffInputPin(brainPin) ((void)0)
-#endif
+#if (HAL_TRIGGER_USE_PAL == TRUE) || (HAL_TRIGGER_USE_ADC == TRUE)
#if (HAL_TRIGGER_USE_PAL == TRUE)
void extiTriggerTurnOnInputPins();
@@ -66,7 +50,6 @@
enum triggerType {
TRIGGER_NONE,
- TRIGGER_ICU,
TRIGGER_EXTI,
TRIGGER_ADC,
};
@@ -88,18 +71,6 @@ static int turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft
return 0;
}
- /* try ICU first */
-#if EFI_ICU_INPUTS
- if (icuTriggerTurnOnInputPin(msg, index, isTriggerShaft) >= 0) {
- if (isTriggerShaft) {
- shaftTriggerType[index] = TRIGGER_ICU;
- } else {
- camTriggerType[index] = TRIGGER_ICU;
- }
- return 0;
- }
-#endif
-
/* ... then ADC */
#if HAL_TRIGGER_USE_ADC
if (adcTriggerTurnOnInputPin(msg, index, isTriggerShaft) >= 0) {
@@ -132,11 +103,6 @@ static void turnOffTriggerInputPin(int index, bool isTriggerShaft) {
activeConfiguration.triggerInputPins[index] : activeConfiguration.camInputs[index];
if (isTriggerShaft) {
-#if EFI_ICU_INPUTS
- if (shaftTriggerType[index] == TRIGGER_ICU) {
- icuTriggerTurnOffInputPin(brainPin);
- }
-#endif /* EFI_ICU_INPUTS */
if (shaftTriggerType[index] == TRIGGER_ADC) {
adcTriggerTurnOffInputPin(brainPin);
}
@@ -147,11 +113,6 @@ static void turnOffTriggerInputPin(int index, bool isTriggerShaft) {
shaftTriggerType[index] = TRIGGER_NONE;
} else {
-#if EFI_ICU_INPUTS
- if (camTriggerType[index] == TRIGGER_ICU) {
- icuTriggerTurnOffInputPin(brainPin);
- }
-#endif /* EFI_ICU_INPUTS */
if (camTriggerType[index] == TRIGGER_ADC) {
adcTriggerTurnOffInputPin(brainPin);
}
@@ -200,13 +161,12 @@ void startTriggerInputPins() {
void turnOnTriggerInputPins() {
/* init all trigger HW available */
- icuTriggerTurnOnInputPins();
extiTriggerTurnOnInputPins();
applyNewTriggerInputPins();
}
-#endif /* (HAL_USE_ICU == TRUE) || (HAL_TRIGGER_USE_PAL == TRUE) || (HAL_TRIGGER_USE_ADC == TRUE) */
+#endif /* (HAL_TRIGGER_USE_PAL == TRUE) || (HAL_TRIGGER_USE_ADC == TRUE) */
void stopTriggerDebugPins() {
diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp
index 0e2bf4b486..cbd23ce6d8 100644
--- a/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp
+++ b/firmware/hw_layer/digital_input/trigger/trigger_input_adc.cpp
@@ -23,8 +23,9 @@
#include "digital_input_exti.h"
-//!!!!!!!!!!
-#define TRIGGER_ADC_DEBUG_LED TRUE
+#ifndef TRIGGER_ADC_DEBUG_LED
+#define TRIGGER_ADC_DEBUG_LED FALSE
+#endif
//#define DEBUG_OUTPUT_IGN1 TRUE
//#define TRIGGER_ADC_DUMP_BUF TRUE
diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp
index 39429c0d8e..a1baa8d4b8 100644
--- a/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp
+++ b/firmware/hw_layer/digital_input/trigger/trigger_input_comp.cpp
@@ -14,7 +14,6 @@
#include "hal_comp.h"
#include "trigger_input.h"
-#include "digital_input_icu.h"
static volatile int centeredDacValue = 127;
static volatile int toothCnt = 0;
diff --git a/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp b/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp
deleted file mode 100644
index 35e40ad07e..0000000000
--- a/firmware/hw_layer/digital_input/trigger/trigger_input_icu.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * @file trigger_input_icu.cpp
- * @brief Position sensor hardware layer - ICU version
- *
- * todo: code reuse with digital_input_icu.cpp was never finished
- * todo: at the moment due to half-done code reuse we already depend on EFI_ICU_INPUTS but still have custom code
- * todo: VVT implementation is a nasty copy-paste :(
- *
- * see digital_input_icu.cpp
- *
- * @date Dec 30, 2012
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#include "pch.h"
-
-int icuRisingCallbackCounter = 0;
-int icuFallingCallbackCounter = 0;
-
-#if EFI_SHAFT_POSITION_INPUT && (HAL_USE_ICU == TRUE)
-
-#include "trigger_input.h"
-#include "digital_input_icu.h"
-#include "tooth_logger.h"
-
-static void vvtRisingCallback(void *arg) {
- efitick_t now = getTimeNowNt();
-
- int index = (int)arg;
-
-#if EFI_TOOTH_LOGGER
- if (!engineConfiguration->displayLogicLevelsInEngineSniffer) {
- // real physical fronts go into engine sniffer
- LogTriggerTooth(SHAFT_SECONDARY_RISING, now);
- }
-#endif /* EFI_TOOTH_LOGGER */
- hwHandleVvtCamSignal(engineConfiguration->invertCamVVTSignal ? TV_FALL : TV_RISE, now, index);
-}
-
-static void vvtFallingCallback(void * arg) {
- efitick_t now = getTimeNowNt();
-
- int index = (int)arg;
-#if EFI_TOOTH_LOGGER
- if (!engineConfiguration->displayLogicLevelsInEngineSniffer) {
- LogTriggerTooth(SHAFT_SECONDARY_FALLING, now);
- }
-#endif /* EFI_TOOTH_LOGGER */
- hwHandleVvtCamSignal(engineConfiguration->invertCamVVTSignal ? TV_RISE : TV_FALL, now, index);
-}
-
-/**
- * that's hardware timer input capture IRQ entry point
- */
-static void shaftRisingCallback(bool isPrimary) {
- efitick_t stamp = getTimeNowNt();
-
- icuRisingCallbackCounter++;
-
- // icucnt_t last_width = icuGetWidth(icup); so far we are fine with system time
-
- hwHandleShaftSignal(isPrimary ? 0 : 1, true, stamp);
-}
-
-static void shaftFallingCallback(bool isPrimary) {
- efitick_t stamp = getTimeNowNt();
-
- icuFallingCallbackCounter++;
-
- hwHandleShaftSignal(isPrimary ? 0 : 1, false, stamp);
-}
-
-/*==========================================================================*/
-/* Exported functions. */
-/*==========================================================================*/
-
-int icuTriggerTurnOnInputPin(const char *msg, int index, bool isTriggerShaft) {
- (void)msg;
- brain_pin_e brainPin = isTriggerShaft ? engineConfiguration->triggerInputPins[index] : engineConfiguration->camInputs[index];
- if (!isBrainPinValid(brainPin)) {
- return -1;
- }
-
- digital_input_s* input = startDigitalCapture(msg, brainPin);
- if (input == NULL) {
- /* error already reported */
- return -1;
- }
-
- if (isTriggerShaft) {
- void * arg = (void*) (index == 0);
- input->setWidthCallback((VoidInt)(void*)shaftRisingCallback, arg);
- input->setPeriodCallback((VoidInt)(void*)shaftFallingCallback, arg);
- } else {
- void * arg = (void *)index;
- input->setWidthCallback((VoidInt)(void*)vvtRisingCallback, arg);
- input->setPeriodCallback((VoidInt)(void*)vvtFallingCallback, arg);
- }
-
- return 0;
-}
-
-void icuTriggerTurnOffInputPin(brain_pin_e brainPin) {
- stopDigitalCapture("trigger", brainPin);
-}
-
-void icuTriggerTurnOnInputPins() {
-}
-#endif /* (EFI_SHAFT_POSITION_INPUT && (HAL_USE_ICU == TRUE)) */
diff --git a/firmware/hw_layer/drivers/can/can_hw.cpp b/firmware/hw_layer/drivers/can/can_hw.cpp
index 4e62a8178a..8a42763e6b 100644
--- a/firmware/hw_layer/drivers/can/can_hw.cpp
+++ b/firmware/hw_layer/drivers/can/can_hw.cpp
@@ -139,11 +139,11 @@ public:
{
}
- void Start(CANDriver* device) {
+ void start(CANDriver* device) {
m_device = device;
if (device) {
- ThreadController::Start();
+ ThreadController::start();
}
}
@@ -318,12 +318,12 @@ void initCan() {
// fire up threads, as necessary
if (engineConfiguration->canWriteEnabled) {
- canWrite.Start();
+ canWrite.start();
}
if (engineConfiguration->canReadEnabled) {
- canRead1.Start(device1);
- canRead2.Start(device2);
+ canRead1.start(device1);
+ canRead2.start(device2);
}
isCanEnabled = true;
diff --git a/firmware/hw_layer/drivers/drivers.mk b/firmware/hw_layer/drivers/drivers.mk
index b74c8529e9..78c7ceceee 100644
--- a/firmware/hw_layer/drivers/drivers.mk
+++ b/firmware/hw_layer/drivers/drivers.mk
@@ -25,6 +25,7 @@ HW_LAYER_DRIVERS_CPP = \
$(DRIVERS_DIR)/gpio/mc33972.cpp \
$(DRIVERS_DIR)/gpio/mc33810.cpp \
$(DRIVERS_DIR)/gpio/drv8860.cpp \
+ $(DRIVERS_DIR)/gpio/tle9104.cpp \
$(DRIVERS_DIR)/gpio/l9779.cpp \
$(DRIVERS_DIR)/gpio/protected_gpio.cpp \
$(DRIVERS_DIR)/lcd/HD44780.cpp \
diff --git a/firmware/hw_layer/drivers/gpio/l9779.cpp b/firmware/hw_layer/drivers/gpio/l9779.cpp
index 7ca1d18261..2aee2728c2 100644
--- a/firmware/hw_layer/drivers/gpio/l9779.cpp
+++ b/firmware/hw_layer/drivers/gpio/l9779.cpp
@@ -299,6 +299,10 @@ int L9779::spi_rw_array(const uint16_t *tx, uint16_t *rx, int n)
uint16_t rxdata;
SPIDriver *spi = cfg->spi_bus;
+ if (n <= 0) {
+ return -2;
+ }
+
/* Acquire ownership of the bus. */
spiAcquireBus(spi);
/* Setup transfer parameters. */
diff --git a/firmware/hw_layer/drivers/gpio/mc33810.cpp b/firmware/hw_layer/drivers/gpio/mc33810.cpp
index 98f88caf94..0b86a54610 100644
--- a/firmware/hw_layer/drivers/gpio/mc33810.cpp
+++ b/firmware/hw_layer/drivers/gpio/mc33810.cpp
@@ -3,6 +3,8 @@
*
* Automotive Engine Control IC
* MCZ33810
+ * eight channel output driver: four integrated low-side drivers and four low-side gate pre-drivers.
+ *
*
* @date Dec 29, 2018
* @author Andrey Belomutskiy, (c) 2012-2020
diff --git a/firmware/hw_layer/drivers/gpio/tle8888.cpp b/firmware/hw_layer/drivers/gpio/tle8888.cpp
index 501f41db38..b57a95a28e 100644
--- a/firmware/hw_layer/drivers/gpio/tle8888.cpp
+++ b/firmware/hw_layer/drivers/gpio/tle8888.cpp
@@ -85,8 +85,8 @@ typedef enum {
#define CMD_SR CMD_W(CMD_SR_CODE, 0x03)
#define CMD_OE_SET CMD_W(0x1c, 0x02)
#define CMD_OE_CLR CMD_W(0x1c, 0x01)
-#define CMD_UNLOCK CMD_W(0x1e, 0x01)
-#define CMD_LOCK CMD_W(0x1e, 0x02)
+#define CMD_CHIP_UNLOCK CMD_W(0x1e, 0x01)
+//#define CMD_CHIP_LOCK CMD_W(0x1e, 0x02)
/* Diagnostic registers */
#define REG_DIAG(n) (0x20 + ((n) & 0x01))
@@ -132,7 +132,7 @@ typedef enum {
* Default open window time is 0b0011 * 3.2 = 12.8 mS */
#define WWD_PERIOD_MS (100.8 + (12.8 / 2))
-/* DOTO: add irq support */
+/* TODO: add irq support */
#define DIAG_PERIOD_MS (7)
const uint8_t tle8888_fwd_responses[16][4] = {
@@ -399,6 +399,10 @@ int Tle8888::spi_rw_array(const uint16_t *tx, uint16_t *rx, int n)
uint16_t rxdata;
SPIDriver *spi = cfg->spi_bus;
+ if (n <= 0) {
+ return -2;
+ }
+
/**
* 15.1 SPI Protocol
*
@@ -553,7 +557,7 @@ int Tle8888::update_direct_output(size_t pin, int value)
if (pin < 4) {
/* OUT1..4 */
index = pin;
- } else if (pin > 24) {
+ } else if (pin >= 24) {
/* IGN1..4 */
index = (pin - 24) + 4;
} else {
@@ -645,7 +649,7 @@ int Tle8888::chip_init()
uint16_t tx[] = {
/* unlock */
- CMD_UNLOCK,
+ CMD_CHIP_UNLOCK,
/* set INCONFIG - aux input mapping */
CMD_INCONFIG(0, InConfig[0]),
CMD_INCONFIG(1, InConfig[1]),
@@ -956,14 +960,14 @@ int Tle8888::writePad(unsigned int pin, int value) {
chibios_rt::CriticalSectionLocker csl;
if (value) {
- o_state |= (1 << pin);
+ o_state |= BIT(pin);
} else {
- o_state &= ~(1 << pin);
+ o_state &= ~BIT(pin);
}
}
/* direct driven? */
- if (o_direct_mask & (1 << pin)) {
+ if (o_direct_mask & BIT(pin)) {
return update_direct_output(pin, value);
} else {
return wake_driver();
@@ -977,7 +981,7 @@ int Tle8888::readPad(size_t pin) {
if (pin < TLE8888_OUTPUTS_REGULAR) {
/* return output state */
- /* DOTO: check that pins is disabled by diagnostic? */
+ /* TODO: check that pins is disabled by diagnostic? */
return !!(o_data_cached & BIT(pin));
} else if (pin == TLE8888_OUTPUT_MR) {
/* Main relay can be enabled by KEY input, so report real state */
@@ -1097,6 +1101,17 @@ int Tle8888::chip_init_data() {
palClearPort(cfg->inj_en.port, PAL_PORT_BIT(cfg->inj_en.pad));
}
+ for (i = 0; i < TLE8888_DIRECT_MISC; i++) {
+ /* Set some invalid default OUT number...
+ * Keeping this register default (0) will map one of input signals
+ * to OUT5 and no control over SPI for this pin will be possible.
+ * If some other pin is also mapped to OUT5 both inputs should be
+ * high (logical AND) to enable OUT5.
+ * Set non-exist output in case no override is provided in config.
+ * See code below */
+ InConfig[i] = 25 - 1 - 4;
+ }
+
for (i = 0; i < TLE8888_DIRECT_OUTPUTS; i++) {
int out = -1;
uint32_t mask;
@@ -1113,12 +1128,16 @@ int Tle8888::chip_init_data() {
out = cfg->direct_maps[i - 8].output - 1;
}
- if ((out < 0) || (cfg->direct_gpio[i].port == NULL))
+ if ((out < 0) || (cfg->direct_gpio[i].port == NULL)) {
+ /* now this is safe, InConfig[] is inited with some non-exist output */
continue;
+ }
/* TODO: implement PP pin driving throught direct gpio */
- if ((cfg->stepper) && (out >= 20) && (out <= 23))
+ if ((cfg->stepper) && (out >= 20) && (out <= 23)) {
+ /* now this is safe, InConfig[] is inited with some non-exist output */
continue;
+ }
/* calculate mask */
mask = BIT(out);
diff --git a/firmware/hw_layer/drivers/gpio/tle9104.cpp b/firmware/hw_layer/drivers/gpio/tle9104.cpp
new file mode 100644
index 0000000000..8d8cb883aa
--- /dev/null
+++ b/firmware/hw_layer/drivers/gpio/tle9104.cpp
@@ -0,0 +1,233 @@
+#include "pch.h"
+#include "gpio/gpio_ext.h"
+#include "gpio/tle9104.h"
+
+#if BOARD_TLE9104_COUNT > 0
+
+#define TLE9104_REG_CTRL 0x00
+#define TLE9104_REG_CFG 0x01
+#define TLE9104_REG_OFF_DIAG_CFG 0x02
+#define TLE9104_REG_ON_DIAG_CFG 0x03
+#define TLE9104_REG_DIAG_OUT_1_2_ON 0x04
+#define TLE9104_REG_DIAG_OUT_3_4_ON 0x05
+#define TLE9104_REG_DIAG_OFF 0x06
+#define TLE9104_REG_GLOBAL_STATUS 0x07
+#define TLE9104_REG_ICVID 0x08
+
+struct Tle9104 : public GpioChip {
+ int init() override;
+
+ int writePad(size_t pin, int value) override;
+ brain_pin_diag_e getDiag(size_t pin) override;
+
+
+ uint16_t readWrite(uint8_t addr, uint8_t data);
+ uint16_t read(uint8_t addr);
+ void write(uint8_t addr, uint8_t data);
+
+ void updateDiagState();
+
+ const tle9104_config* cfg;
+
+
+ uint8_t diag_off;
+ uint8_t diag_on12;
+ uint8_t diag_on34;
+
+ OutputPin m_en;
+ OutputPin m_resn;
+};
+
+static bool parityBit(uint16_t val) {
+ // (1 + number of bits set) mod 2 = parity bit
+ int count = 1;
+
+ while (val != 0) {
+ if (val & 0x01) {
+ count++;
+ }
+
+ val = val >> 1;
+ }
+
+ return (count % 2) == 1;
+}
+
+uint16_t Tle9104::readWrite(uint8_t addr, uint8_t data) {
+ uint16_t tx = (addr << 8) + data;
+
+ // set the parity bit appropriately
+ tx |= parityBit(tx) ? (1 << 14) : 0;
+
+ SPIDriver* spi = cfg->spi_bus;
+
+ spiSelect(spi);
+ uint16_t rx = spiPolledExchange(spi, tx);
+ spiUnselect(spi);
+
+ bool parityOk = parityBit(rx);
+
+ // return data
+ return rx;
+}
+
+uint16_t Tle9104::read(uint8_t addr) {
+ // R/W bit is 0 for read
+ readWrite(addr, 0);
+
+ return readWrite(addr, 0);
+}
+
+void Tle9104::write(uint8_t addr, uint8_t data) {
+ // R/W bit is 1 for write
+ readWrite(0x80 | addr, data);
+}
+
+int Tle9104::init() {
+ m_resn.initPin("TLE9104 RESN", cfg->resn);
+ m_en.initPin("TLE9104 EN", cfg->en);
+
+ // disable outputs
+ m_en.setValue(false);
+
+ for (int i = 0; i < 4; i++) {
+ gpio_pin_markUsed(cfg->direct_io[i].port, cfg->direct_io[i].pad, "TLE9104 Direct IO");
+ palSetPadMode(cfg->direct_io[i].port, cfg->direct_io[i].pad, PAL_MODE_OUTPUT_PUSHPULL);
+
+ // Ensure all outputs are off
+ writePad(i, false);
+ }
+
+ // Reset the chip
+ m_resn.setValue(false);
+ chThdSleepMilliseconds(1);
+ m_resn.setValue(true);
+ chThdSleepMilliseconds(1);
+
+ spiStart(cfg->spi_bus, &cfg->spi_config);
+
+ // read ID register
+ uint16_t id = read(TLE9104_REG_ICVID);
+
+ // No chip detected if ID is wrong
+ if ((id & 0xFF) != 0xB1) {
+ return -1;
+ }
+
+ // disable comms watchdog, enable direct drive on all 4 channels
+ // TODO: should we enable comms watchdog?
+ write(TLE9104_REG_CFG, 0x0F);
+
+ // clear any suprious diag states from startup: first call resets, second reads true state
+ updateDiagState();
+ updateDiagState();
+
+ // set output enable, clear all other flags
+ write(TLE9104_REG_GLOBAL_STATUS, 0x80);
+
+ // Set hardware enable
+ m_en.setValue(true);
+
+ return 0;
+}
+
+int Tle9104::writePad(size_t pin, int value) {
+ // Inverted since TLE9104 is active low (falling edge to turn on output)
+ if (value) {
+ palClearPad(cfg->direct_io[pin].port, cfg->direct_io[pin].pad);
+ } else {
+ palSetPad(cfg->direct_io[pin].port, cfg->direct_io[pin].pad);
+ }
+
+ return 0;
+}
+
+void Tle9104::updateDiagState() {
+ spiStart(cfg->spi_bus, &cfg->spi_config);
+
+ diag_on12 = read(TLE9104_REG_DIAG_OUT_1_2_ON);
+ diag_on34 = read(TLE9104_REG_DIAG_OUT_3_4_ON);
+ diag_off = read(TLE9104_REG_DIAG_OFF);
+
+ // clear diag states
+ write(TLE9104_REG_DIAG_OUT_1_2_ON, 0);
+ write(TLE9104_REG_DIAG_OUT_3_4_ON, 0);
+ write(TLE9104_REG_DIAG_OFF, 0);
+}
+
+brain_pin_diag_e Tle9104::getDiag(size_t pin) {
+ int off_diag;
+ int on_diag;
+
+ switch (pin) {
+ case 0:
+ on_diag = diag_on12;
+ off_diag = diag_off;
+ break;
+ case 1:
+ on_diag = diag_on12 >> 3;
+ off_diag = diag_off >> 2;
+ break;
+ case 2:
+ on_diag = diag_on34;
+ off_diag = diag_off >> 4;
+ break;
+ case 3:
+ on_diag = diag_on34 >> 3;
+ off_diag = diag_off >> 6;
+ break;
+ default:
+ return PIN_INVALID;
+ }
+
+ // on diag has 3 bits
+ on_diag = on_diag & 0x7;
+ // of diag has 2 bits
+ off_diag = off_diag & 0x3;
+
+ int result = 0;
+
+ // Decode on-state faults
+ switch (on_diag) {
+ case 2:
+ result |= PIN_SHORT_TO_BAT;
+ break;
+ case 3:
+ // overtemp and overcurrent
+ result |= PIN_DRIVER_OVERTEMP;
+ // falls through
+ case 4:
+ result |= PIN_OVERLOAD;
+ break;
+ case 5:
+ result |= PIN_DRIVER_OVERTEMP;
+ break;
+ }
+
+ // Decode off-state faults
+ switch (off_diag) {
+ case 2:
+ result |= PIN_OPEN;
+ break;
+ case 3:
+ result |= PIN_SHORT_TO_GND;
+ break;
+ }
+
+ return (brain_pin_diag_e)result;
+}
+
+static Tle9104 chips[4];
+
+void tle9104_add(Gpio base, int index, const tle9104_config* cfg) {
+ Tle9104& chip = chips[index];
+
+ chip.cfg = cfg;
+ gpiochip_register(base, "TLE9104", chip, 4);
+}
+
+void updatetlediag() {
+ chips[0].updateDiagState();
+}
+
+#endif // BOARD_TLE9104_COUNT > 0
diff --git a/firmware/hw_layer/drivers/gpio/tle9104.h b/firmware/hw_layer/drivers/gpio/tle9104.h
new file mode 100644
index 0000000000..1f37a2311d
--- /dev/null
+++ b/firmware/hw_layer/drivers/gpio/tle9104.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#if BOARD_TLE9104_COUNT > 0
+
+struct tle9104_config {
+ SPIDriver *spi_bus;
+ SPIConfig spi_config;
+
+ struct {
+ ioportid_t port;
+ uint_fast8_t pad;
+ } direct_io[4];
+
+ Gpio resn;
+ Gpio en;
+};
+
+void tle9104_add(Gpio base, int index, const tle9104_config* cfg);
+
+// This example config worked on the bench!
+// tle9104_config tle9104_cfg = {
+// .spi_bus = NULL,
+// .spi_config = {
+// .circular = false,
+// .end_cb = NULL,
+// .ssport = NULL,
+// .sspad = 0,
+// .cr1 =
+// SPI_CR1_16BIT_MODE |
+// SPI_CR1_SSM |
+// SPI_CR1_SSI |
+// ((3 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | // div = 16
+// SPI_CR1_MSTR |
+// SPI_CR1_CPHA |
+// 0,
+// .cr2 = SPI_CR2_16BIT_MODE
+// },
+// .direct_io = {
+// { GPIOB, 12 },
+// { GPIOB, 13 },
+// { GPIOB, 14 },
+// { GPIOB, 15 }
+// },
+// .resn = Gpio::A3,
+// .en = Gpio::C9
+// };
+
+#endif // BOARD_TLE9104_COUNT > 0
diff --git a/firmware/hw_layer/drivers/serial/serial_hw.cpp b/firmware/hw_layer/drivers/serial/serial_hw.cpp
index b11723d386..1a2cc59238 100644
--- a/firmware/hw_layer/drivers/serial/serial_hw.cpp
+++ b/firmware/hw_layer/drivers/serial/serial_hw.cpp
@@ -85,7 +85,7 @@ void initAuxSerial(void) {
startAuxSerialPins();
if (isSerialRXEnabled)
- serialRead.Start();
+ serialRead.start();
}
#endif // EFI_AUX_SERIAL
diff --git a/firmware/hw_layer/hw_layer.mk b/firmware/hw_layer/hw_layer.mk
index 6582c6de4d..6ee1c6e057 100644
--- a/firmware/hw_layer/hw_layer.mk
+++ b/firmware/hw_layer/hw_layer.mk
@@ -10,11 +10,8 @@ HW_INC = hw_layer/$(CPU_HWLAYER) \
HW_LAYER_EMS_CPP = \
$(PROJECT_DIR)/hw_layer/pin_repository.cpp \
$(PROJECT_DIR)/hw_layer/microsecond_timer/microsecond_timer.cpp \
- $(PROJECT_DIR)/hw_layer/digital_input/digital_input.cpp \
- $(PROJECT_DIR)/hw_layer/digital_input/digital_input_icu.cpp \
$(PROJECT_DIR)/hw_layer/digital_input/digital_input_exti.cpp \
$(PROJECT_DIR)/hw_layer/digital_input/trigger/trigger_input.cpp \
- $(PROJECT_DIR)/hw_layer/digital_input/trigger/trigger_input_icu.cpp \
$(PROJECT_DIR)/hw_layer/digital_input/trigger/trigger_input_exti.cpp \
$(PROJECT_DIR)/hw_layer/digital_input/trigger/trigger_input_adc.cpp \
$(PROJECT_DIR)/hw_layer/hardware.cpp \
@@ -26,7 +23,6 @@ HW_LAYER_EMS_CPP = \
$(PROJECT_DIR)/hw_layer/sensors/hip9011.cpp \
$(PROJECT_DIR)/hw_layer/sensors/hip9011_logic.cpp \
$(PROJECT_DIR)/hw_layer/mc33816.cpp \
- $(PROJECT_DIR)/hw_layer/mc33816_data.cpp \
$(PROJECT_DIR)/hw_layer/stepper.cpp \
$(PROJECT_DIR)/hw_layer/stepper_dual_hbridge.cpp \
$(PROJECT_DIR)/hw_layer/servo.cpp \
@@ -36,6 +32,7 @@ HW_LAYER_EMS_CPP = \
$(PROJECT_DIR)/hw_layer/debounce.cpp \
$(PROJECT_DIR)/hw_layer/adc/mcp3208.cpp \
+ALLCSRC += $(PROJECT_DIR)/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.c
#
# '-include' is a magic kind of 'include' which would survive if file to be included is not found
diff --git a/firmware/hw_layer/io_pins.cpp b/firmware/hw_layer/io_pins.cpp
index 2311c957b6..42f4989d9c 100644
--- a/firmware/hw_layer/io_pins.cpp
+++ b/firmware/hw_layer/io_pins.cpp
@@ -112,19 +112,6 @@ iomode_t getInputMode(pin_input_mode_e mode) {
}
}
-#if HAL_USE_ICU
-static char icuError[30];
-
-void efiIcuStart(const char *msg, ICUDriver *icup, const ICUConfig *config) {
- if (icup->state != ICU_STOP && icup->state != ICU_READY) {
- chsnprintf(icuError, sizeof(icuError), "ICU already used %s", msg);
- firmwareError(CUSTOM_ERROR_ICU, icuError);
- return;
- }
- icuStart(icup, config);
-}
-#endif /* HAL_USE_ICU */
-
void writePad(const char *msg, brain_pin_e pin, int bit) {
palWritePad(getHwPort(msg, pin), getHwPin(msg, pin), bit);
}
diff --git a/firmware/hw_layer/io_pins.h b/firmware/hw_layer/io_pins.h
index 3372e0fd34..fc192360c7 100644
--- a/firmware/hw_layer/io_pins.h
+++ b/firmware/hw_layer/io_pins.h
@@ -36,9 +36,6 @@ EXTERNC void efiSetPadUnused(brain_pin_e brainPin);
EXTERNC bool efiReadPin(brain_pin_e pin);
EXTERNC iomode_t getInputMode(pin_input_mode_e mode);
-#if HAL_USE_ICU
-EXTERNC void efiIcuStart(const char *msg, ICUDriver *icup, const ICUConfig *config);
-#endif /* HAL_USE_ICU */
#endif /* EFI_GPIO_HARDWARE */
diff --git a/firmware/hw_layer/mass_storage/mass_storage_init.cpp b/firmware/hw_layer/mass_storage/mass_storage_init.cpp
index e4f2668a65..04e0d411b5 100644
--- a/firmware/hw_layer/mass_storage/mass_storage_init.cpp
+++ b/firmware/hw_layer/mass_storage/mass_storage_init.cpp
@@ -117,7 +117,7 @@ void initUsbMsd() {
msd.attachLun(1, (BaseBlockDevice*)&ND1, blkbuf1, &sdCardInquiry, nullptr);
// start the mass storage thread
- msd.Start();
+ msd.start();
}
#endif // HAL_USE_USB_MSD
diff --git a/firmware/hw_layer/mc33816.cpp b/firmware/hw_layer/mc33816.cpp
index 31a04d1ee6..c741e7c989 100644
--- a/firmware/hw_layer/mc33816.cpp
+++ b/firmware/hw_layer/mc33816.cpp
@@ -21,7 +21,7 @@
#include "mc33816.h"
#include "mc33816_memory_map.h"
#include "hardware.h"
-#include "mc33816_data.h"
+#include "mc33816/rusefi/sample_code/PT2001_LoadData.h"
#include "mpu_util.h"
static bool isInitializaed = false;
@@ -119,13 +119,15 @@ static unsigned short readId() {
// Read a single word in Data RAM
unsigned short mcReadDram(MC33816Mem addr) {
+ uint16_t addrInt = static_cast(addr);
+
unsigned short readValue;
spiSelect(driver);
// Select Channel command, Common Page
spi_writew(0x7FE1);
spi_writew(0x0004);
// read (MSB=1) at data ram x9 (SCV_I_Hold), and 1 word
- spi_writew((0x8000 | addr << 5) + 1);
+ spi_writew((0x8000 | addrInt << 5) + 1);
readValue = recv_16bit_spi();
spiUnselect(driver);
@@ -134,12 +136,14 @@ unsigned short mcReadDram(MC33816Mem addr) {
// Update a single word in Data RAM
void mcUpdateDram(MC33816Mem addr, unsigned short data) {
+ uint16_t addrInt = static_cast(addr);
+
spiSelect(driver);
// Select Channel command, Common Page
spi_writew(0x7FE1);
spi_writew(0x0004);
// write (MSB=0) at data ram x9 (SCV_I_Hold), and 1 word
- spi_writew((addr << 5) + 1);
+ spi_writew((addrInt << 5) + 1);
spi_writew(data);
spiUnselect(driver);
@@ -173,6 +177,8 @@ static void setTimings() {
mcUpdateDram(MC33816Mem::Tbypass, (MC_CK * engineConfiguration->mc33_t_bypass));
mcUpdateDram(MC33816Mem::Thold_off, (MC_CK * engineConfiguration->mc33_t_hold_off));
mcUpdateDram(MC33816Mem::Thold_tot, (MC_CK * engineConfiguration->mc33_t_hold_tot));
+ mcUpdateDram(MC33816Mem::Tboost_min, (MC_CK * engineConfiguration->mc33_t_min_boost));
+ mcUpdateDram(MC33816Mem::Tboost_max, (MC_CK * engineConfiguration->mc33_t_max_boost));
// HPFP solenoid settings
mcUpdateDram(MC33816Mem::HPFP_Ipeak,
@@ -295,23 +301,23 @@ static void download_RAM(int target) {
memory_area = 0x1;
start_address = 0;
codeWidthRegAddr = 0x107;
- RAM_ptr = MC33816_code_RAM1;
- size = sizeof(MC33816_code_RAM1) / 2;
+ RAM_ptr = PT2001_code_RAM1;
+ size = sizeof(PT2001_code_RAM1) / 2;
break;
case CODE_RAM2:
memory_area = 0x2;
start_address = 0;
codeWidthRegAddr = 0x127;
- RAM_ptr = MC33816_code_RAM2;
- size = sizeof(MC33816_code_RAM2) / 2;
+ RAM_ptr = PT2001_code_RAM2;
+ size = sizeof(PT2001_code_RAM2) / 2;
break;
case DATA_RAM: // ch1 only?
memory_area = 0x4;
start_address = 0;
- RAM_ptr = MC33816_data_RAM;
- size = sizeof(MC33816_data_RAM) / 2;
+ RAM_ptr = PT2001_data_RAM;
+ size = sizeof(PT2001_data_RAM) / 2;
break;
// optional, both data_rams with 0x3, writes same code to both
default:
@@ -355,32 +361,32 @@ static void download_register(int r_target) {
{
case REG_CH1: // channel 1 configurations
r_start_address = 0x100;
- reg_ptr = MC33816_ch1_config;
- r_size = sizeof(MC33816_ch1_config) / 2; // gets number of words to be sent
+ reg_ptr = PT2001_ch1_config;
+ r_size = sizeof(PT2001_ch1_config) / 2; // gets number of words to be sent
break;
case REG_CH2: // channel 2 configurations
r_start_address = 0x120;
- reg_ptr = MC33816_ch2_config;
- r_size = sizeof(MC33816_ch2_config) / 2; // gets number of words to be sent
+ reg_ptr = PT2001_ch2_config;
+ r_size = sizeof(PT2001_ch2_config) / 2; // gets number of words to be sent
break;
case REG_DIAG: // diagnostic configurations
r_start_address = 0x140;
- reg_ptr = MC33816_diag_config;
- r_size = sizeof(MC33816_diag_config) / 2; // gets number of words to be sent
+ reg_ptr = PT2001_diag_config;
+ r_size = sizeof(PT2001_diag_config) / 2; // gets number of words to be sent
break;
case REG_IO: // IO configurations
r_start_address = 0x180;
- reg_ptr = MC33816_io_config;
- r_size = sizeof(MC33816_io_config) / 2; // gets number of words to be sent
+ reg_ptr = PT2001_io_config;
+ r_size = sizeof(PT2001_io_config) / 2; // gets number of words to be sent
break;
case REG_MAIN: // main configurations
r_start_address = 0x1C0;
- reg_ptr = MC33816_main_config;
- r_size = sizeof(MC33816_main_config) / 2; // gets number of words to be sent
+ reg_ptr = PT2001_main_config;
+ r_size = sizeof(PT2001_main_config) / 2; // gets number of words to be sent
break;
default:
diff --git a/firmware/hw_layer/mc33816/rusefi/.gitignore b/firmware/hw_layer/mc33816/rusefi/.gitignore
index 67d8d40d4e..3d96836814 100644
--- a/firmware/hw_layer/mc33816/rusefi/.gitignore
+++ b/firmware/hw_layer/mc33816/rusefi/.gitignore
@@ -1,5 +1,10 @@
bin
-sample_code
+sample_code/*
+!sample_code/PT2001_dram.h
+!sample_code/PT2001_LoadData.c
+!sample_code/PT2001_LoadData.h
CSV Files
Registers/*.hex
-*.txt
\ No newline at end of file
+*.txt
+*.vsdx
+*.def.hex
diff --git a/firmware/hw_layer/mc33816/rusefi/Actuator/dcdc_current.xml b/firmware/hw_layer/mc33816/rusefi/Actuator/dcdc_current.xml
new file mode 100644
index 0000000000..ad6780b89c
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/Actuator/dcdc_current.xml
@@ -0,0 +1,16 @@
+
+ 10
+ 10
+ 10
+ CurFbk4
+ Form
+
+
+
+
+ -52
+ 13
+
+ DCDC_Voltage
+ None
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/Actuator/dcdc_voltage.xml b/firmware/hw_layer/mc33816/rusefi/Actuator/dcdc_voltage.xml
new file mode 100644
index 0000000000..795ce88b35
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/Actuator/dcdc_voltage.xml
@@ -0,0 +1,17 @@
+
+ 30
+ 1000
+ 80
+
+
+ Form
+
+
+
+
+ -1000
+ 13
+
+ DCDC_Current
+ VboostDiv
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/Actuator/inj1.xml b/firmware/hw_layer/mc33816/rusefi/Actuator/inj1.xml
new file mode 100644
index 0000000000..64b9fb2bcb
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/Actuator/inj1.xml
@@ -0,0 +1,23 @@
+
+ 1000
+ 500
+ 10
+ CurFbk1
+ Form
+
+
+
+
+
+
+ -66
+ -1
+ -1
+ 65
+ -1
+ -1
+ 13
+ 65
+
+ None
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/AutoLoad.xml b/firmware/hw_layer/mc33816/rusefi/AutoLoad.xml
new file mode 100644
index 0000000000..90bbb5781a
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/AutoLoad.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/Feedbacks/dcdc_voltage.xml b/firmware/hw_layer/mc33816/rusefi/Feedbacks/dcdc_voltage.xml
new file mode 100644
index 0000000000..8316e9909c
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/Feedbacks/dcdc_voltage.xml
@@ -0,0 +1,99 @@
+
+
+ FeedbackHs1Vds
+
+ Hs2Command
+
+ False
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+
+ FeedbackHs1Vsrc
+
+ Hs2Command
+ -1
+ 0
+
+ True
+ 500 ns
+
+
+ False
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+
+ FeedbackHs2Vds
+
+ Hs1Command
+
+ False
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+
+ FeedbackHs2Vsrc
+
+ Hs1Command
+ -1
+ 0
+
+ True
+ 500 ns
+
+
+ False
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+
+ FeedbackLs1Vds
+
+
+ False
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+
+ FeedbackHs2VdsVbat
+
+ Hs1Command
+
+ False
+ 500 ns
+
+
+ True
+ 500 ns
+
+
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do b/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do
index c9f06122c3..a22ebe8f76 100644
--- a/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do
+++ b/firmware/hw_layer/mc33816/rusefi/Logic_Wave/wave_list.do
@@ -1,198 +1,248 @@
-
- STARTx
-
Start1
- PT2000
-
- 8
- Input
- Decimal
-
-
- Start2
-
- PT2000
-
- 9
- Input
- Decimal
-
-
- Start3
-
- PT2000
-
- 10
- Input
- Decimal
-
-
- Start4
-
- PT2000
-
- 11
- Input
- Decimal
-
-
- Start5
-
- PT2000
-
- 12
- Input
- Decimal
-
-
- Start6
-
- PT2000
-
- 13
- Input
- Decimal
-
-
- Start7
-
- PT2000
-
- 14
- Input
- Decimal
-
-
- INJ1
-
-
- Hs1Command
-
- PT2000
+ PT2001
6
- Output
+ Input
Decimal
- Hs2Command
+ Flag2Out
- PT2000
-
- 7
- Output
- Decimal
-
-
- Ls1Command
-
- PT2000
-
- 13
- Output
- Decimal
-
-
- CurrentFeedback1
-
- PT2000
+ PT2001
0
- Internal
- Decimal
-
-
- FeedbackHs1Vds
-
- PT2000
-
- 10
- Internal
- Decimal
-
-
- FeedbackHs1Vsrc
-
- PT2000
-
- 11
- Internal
- Decimal
-
-
- FeedbackLs1Vds
-
- PT2000
-
- 24
- Internal
- Decimal
-
-
- DCDC
-
-
- BoostFeedback
-
- PT2000
-
- 35
- Internal
- Decimal
-
-
- Ls7Command
-
- PT2000
-
- 19
Output
Decimal
- Ls8Command
+ Flag1Out
- PT2000
+ PT2001
- 20
+ 1
Output
Decimal
Flag0Out
- PT2000
+ PT2001
+
+ 2
+ Output
+ Decimal
+
+
+ Dac1
+
+ PT2001
+
+ 43
+ Output
+ Decimal
+
+
+ Hs1Command
+
+ PT2001
4
Output
Decimal
-
- DEBUG
-
- Irq
+ Hs2Command
- PT2000
+ PT2001
5
Output
Decimal
- irqSource
+ Ls1Command
- PT2000
+ PT2001
+
+ 9
+ Output
+ Decimal
+
+
+ Cnt1
+
+ PT2001
Injection Channel 1
ChSequencers
MicroMachineSeq0
- UProgramCounter
+ Counters
+
+ 0
+ Output
+ Decimal
+
+
+ Cnt2
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 1
+ Output
+ Decimal
+
+
+ Cnt3
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 2
+ Output
+ Decimal
+
+
+ Cnt4
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 3
+ Output
+ Decimal
+
+
+ Eoc1
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 4
+ Output
+ Decimal
+
+
+ Eoc2
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 5
+ Output
+ Decimal
+
+
+ Eoc3
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 6
+ Output
+ Decimal
+
+
+ Eoc4
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
7
Output
Decimal
+
+ TerminalCount1
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 8
+ Output
+ Decimal
+
+
+ TerminalCount2
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 9
+ Output
+ Decimal
+
+
+ TerminalCount3
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 10
+ Output
+ Decimal
+
+
+ TerminalCount4
+
+ PT2001
+ Injection Channel 1
+ ChSequencers
+ MicroMachineSeq0
+ Counters
+
+ 11
+ Output
+ Decimal
+
+
+ Oaout1FlagOut
+
+ PT2001
+
+ 16
+ Output
+ Decimal
+
+
+ Flag0Out
+
+ PT2001
+
+ 2
+ Output
+ Decimal
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc
index 0f73936db1..ef067bcc37 100644
--- a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc
+++ b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/ch1.psc
@@ -23,11 +23,32 @@ inj2_start: dfsct hs1 hs2 ls2; * Set the 3 shortcuts: VBAT,
jmpr boost0; * Jump to launch phase
* ### Launch phase enable boost ###
+* Row1 - !start: injection ended
+* Row2 - Overcurrent, jump to error case (threshold is reached early)
+* Row3 - Overcurrent, jump to peak phase (threshold is reached on time)
+* Row4 - timer1: Minimum boost time reached - switch to row3 instead of row2 to allow peak phase
+* Row5 - timer2: Boost phase timeout - boost took too long, go to error phase
boost0: load Iboost dac_sssc _ofs; * Load the boost phase current threshold in the current DAC
- cwer peak0 ocur row2; * Jump to peak phase when current is over threshold
+ cwer boost0_err ocur row2; * On overcurrent, go to boost error case
+ cwer peak0 ocur row3; * Jump to peak phase when current is over threshold
+
+ ldcd rst _ofs keep keep Tboost_min c1; * Start boost counter to switch out of error behavior if threshold reached
+ cwer boost0_mintime tc1 row4; * On timer timeout, go allow overcurrent without error (ie, end of boost)
+
+ ldcd rst _ofs keep keep Tboost_max c2; * Start boost counter in case Iboost never reached
+ cwer boost0_err tc2 row5; * Jump to boost0_err in case boost phase takes too long
+
stf low b0; * set flag0 low to force the DC-DC converter in idle mode
stos off on on; * Turn VBAT off, BOOST on, LS on
- wait row12; * Wait for one of the previously defined conditions
+ wait row1245; * Wait for one of the previously defined conditions
+
+* ### Boost phase - minimum time reached ###
+boost0_mintime: wait row135; * Minimum time for boost phase has been reached, now wait for !start, overcurrent or timeout
+
+boost0_err: stos off off off; * Turn off all drivers
+ stf low b10; * Set ch1 error flag (OA_1) to signal MCU
+ stf high b0; * set flag0 high to release the DC-DC converter idle mode
+ wait row1; * Wait for start signal to go low for the next injection attempt
* ### Peak phase continue on Vbat ###
peak0: ldcd rst _ofs keep keep Tpeak_tot c1; * Load the length of the total peak phase in counter 1
@@ -95,11 +116,33 @@ inj4_start: dfsct hs3 hs4 ls4; * Set the 3 shortcuts: VBAT,
jmpr boost1; * Jump to launch phase
* ### Launch phase enable boost ###
+* Row1 - !start: injection ended
+* Row2 - Overcurrent, jump to error case (threshold is reached early)
+* Row3 - Overcurrent, jump to peak phase (threshold is reached on time)
+* Row4 - timer1: Minimum boost time reached - switch to row3 instead of row2 to allow peak phase
+* Row5 - timer2: Boost phase timeout - boost took too long, go to error phase
boost1: load Iboost dac_sssc _ofs; * Load the boost phase current threshold in the current DAC
- cwer peak1 ocur row2; * Jump to peak phase when current is over threshold
+ cwer boost1_err ocur row2; * On overcurrent, go to boost error case
+ cwer peak1 ocur row3; * Jump to peak phase when current is over threshold
+
+ ldcd rst _ofs keep keep Tboost_min c1; * Start boost counter to switch out of error behavior if threshold reached
+ cwer boost1_mintime tc1 row4; * On timer timeout, go allow overcurrent without error (ie, end of boost)
+
+ ldcd rst _ofs keep keep Tboost_max c2; * Start boost counter in case Iboost never reached
+ cwer boost1_err tc2 row5; * Jump to boost1_err in case boost phase takes too long
+
stf low b0; * set flag0 low to force the DC-DC converter in idle mode
stos off on on; * Turn VBAT off, BOOST on, LS on
- wait row12; * Wait for one of the previously defined conditions
+ wait row1245; * Wait for one of the previously defined conditions
+
+* ### Boost phase - minimum time reached ###
+boost1_mintime: wait row135; * Minimum time for boost phase has been reached, now wait for !start, overcurrent or timeout
+
+boost1_err: stos off off off; * Turn off all drivers
+ stf low b11; * Set ch1 error flag (OA_1) to signal MCU
+ stf high b0; * set flag0 high to release the DC-DC converter idle mode
+ wait row1; * Wait for start signal to go low for the next injection attempt
+
* ### Peak phase continue on Vbat ###
peak1: ldcd rst _ofs keep keep Tpeak_tot c1; * Load the length of the total peak phase in counter 1
diff --git a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def
index 8f7cfc8f76..3551deace4 100644
--- a/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def
+++ b/firmware/hw_layer/mc33816/rusefi/MicrocodeCh1/dram1.def
@@ -6,6 +6,5 @@
#define Tbypass 5;
#define Thold_off 6;
#define Thold_tot 7;
-#define SCV_I_hold 9;
-#define SCV_Thold_tot 10;
-#define SCV_Thold_off 11;
+#define Tboost_max 8;
+#define Tboost_min 9;
diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin
index 8f194545d6..888c61fb52 100644
--- a/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin
+++ b/firmware/hw_layer/mc33816/rusefi/Registers/ch1_config_reg.bin
@@ -2,12 +2,12 @@
0000000000000000
0000000000000000
0000000000000000
-0000001100000011
+0000101100010011
0000000000000000
0000000000000000
-0000000001011000
-1000111001100010
-0111101100100011
+0000000001101100
+0110101101011001
+1100100010100101
0000000000000000
0000000000101100
0000000000000000
diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin
index 9513d7f2f0..a24a2da48f 100644
--- a/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin
+++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.bin
@@ -1,15 +1,15 @@
-0000000011110000
-0000000011110000
-0000000010001100
-0010000000000000
-0000000111110100
-0000000010110100
+0000000011000000
+0000000010010010
+0000000001001001
0000000000111100
+0001000001101000
+0000000000111100
+0000000101101000
1110101001100000
-0000000000000000
-0000000000111101
-0110000000000000
-0000000000111100
+0000100101100000
+0000001001011000
+0000000000000000
+0000000000000000
0000000000000000
0000000000000000
0000000000000000
diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex
index 93583683df..29695b917a 100644
--- a/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex
+++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram1.hex
@@ -1,23 +1,23 @@
//
// Application:
-// Asic ID: MC33816
+// Asic ID: PT2001
// Version:
// DRAM
-// Date: Sunday, August 02, 2020
-// Author: DEV
+// Date: Thursday, July 14, 2022
+// Author: makenne
//
-0x00F0,
-0x00F0,
-0x008C,
-0x2000,
-0x01F4,
-0x00B4,
+0x00C0,
+0x0092,
+0x0049,
0x003C,
+0x1068,
+0x003C,
+0x0168,
0xEA60,
+0x0960,
+0x0258,
+0x0000,
0x0000,
-0x003D,
-0x6000,
-0x003C,
0x0000,
0x0000,
0x0000,
diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex b/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex
index ddc7cc3add..7f82827d41 100644
--- a/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex
+++ b/firmware/hw_layer/mc33816/rusefi/Registers/dram2.hex
@@ -1,10 +1,10 @@
//
// Application:
-// Asic ID: MC33816
+// Asic ID: PT2001
// Version:
// DRAM
-// Date: Sunday, August 02, 2020
-// Author: DEV
+// Date: Wednesday, July 13, 2022
+// Author: makenne
//
0x00C1,
0x00BF,
diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin
index a5c10c34eb..774da943bd 100644
--- a/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin
+++ b/firmware/hw_layer/mc33816/rusefi/Registers/io_config_reg.bin
@@ -42,3 +42,12 @@
0000000000000000
0000000000000000
0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
+0000000000000000
diff --git a/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin b/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin
index ad1acd825b..6ca460f13e 100644
--- a/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin
+++ b/firmware/hw_layer/mc33816/rusefi/Registers/main_config_reg.bin
@@ -1,7 +1,7 @@
0000000000000011
-0001111111111110
+0001001111111110
0000000000000000
-0001001000000000
+0001111000000000
0000000000000000
0000000000000000
0000000000000001
diff --git a/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml b/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml
index 69fd5e9267..8d25a79457 100644
--- a/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml
+++ b/firmware/hw_layer/mc33816/rusefi/Stimulus/stim.xml
@@ -1,16 +1,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/labels.xml b/firmware/hw_layer/mc33816/rusefi/labels.xml
index 0fac009540..8e2e2d49cd 100644
--- a/firmware/hw_layer/mc33816/rusefi/labels.xml
+++ b/firmware/hw_layer/mc33816/rusefi/labels.xml
@@ -1,23 +1,29 @@
-
-
- init0
- irq_sw
-
- irq_auto
- init1
-
-
-
-
-
- init0
-
-
-
- init1
-
-
-
-
+
+
+ init0
+ init0
+ init0
+ init0
+
+
+ init0
+ init0
+ init0
+
+
+
+
+ init0
+ init0
+ init0
+ init0
+
+
+ init1
+ init0
+ init0
+ init0
+
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/project.xml b/firmware/hw_layer/mc33816/rusefi/project.xml
index a36057b5b1..8b8084d3d4 100644
--- a/firmware/hw_layer/mc33816/rusefi/project.xml
+++ b/firmware/hw_layer/mc33816/rusefi/project.xml
@@ -1,6 +1,6 @@
- MC33816
+ PT2001
IDE Project
%APPLICATION%
%DEVICEID%
@@ -11,37 +11,45 @@
Registers\main_config_reg.hex
Registers\ch1_config_reg.hex
Registers\ch2_config_reg.hex
- Registers\ch3_config_reg.hex
Registers\diag_config_reg.hex
Registers\io_config_reg.hex
- MicrocodeCh1\ch1.psc
- MicrocodeCh2\ch2.psc
- MicrocodeCh3\ch3.psc
+ MicrocodeCh1\ch1.psc
+ MicrocodeCh2\ch2.psc
+ bin\ch1.bin
+ bin\ch2.bin
+ bin\ch1.hex
+ bin\ch2.hex
Registers\dram1.hex
Registers\dram2.hex
- Registers\dram3.hex
- Simulator\AutoLoad.xml
+ labels.xml
+ Actuator\inj1.xml
+ Actuator\dcdc_current.xml
+ Actuator\dcdc_voltage.xml
+ Feedbacks\dcdc_voltage.xml
+ Stimulus\stim.xml
+ Logic_Wave\wave_list.do
+ AutoLoad.xml
1 MHz
-
-
-
+
+
+
True
True
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -163,72 +171,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Hex
Hex
@@ -253,7 +195,6 @@
Hex
Hex
Hex
- Hex
Hex
@@ -300,26 +241,6 @@
Hex
Hex
Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
Hex
@@ -374,27 +295,6 @@
Hex
Hex
Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
- Hex
Hex
@@ -416,7 +316,6 @@
Hex
Hex
Hex
- Hex
Hex
@@ -438,7 +337,6 @@
Hex
Hex
Hex
- Hex
Hex
@@ -463,11 +361,11 @@
Hex
-
-
-
-
+
+
+
+
-
+
\ No newline at end of file
diff --git a/firmware/hw_layer/mc33816/rusefi/readme.md b/firmware/hw_layer/mc33816/rusefi/readme.md
index 5a9f8c4922..941ae0e040 100644
--- a/firmware/hw_layer/mc33816/rusefi/readme.md
+++ b/firmware/hw_layer/mc33816/rusefi/readme.md
@@ -1,12 +1,22 @@
Source code here is different from but is heavily inspired by MC33816 example as conveniently comes with MC33816 Dev Studio.
-* Hit 'Build' button in MC33816 Developer Studio to get assembly stuff in 'build' folder. At the moment we use PT2001 version
-of the chip so actually "PT2001 Developer studio"
+## Workflow:
-* Once you are done wit 'Build' second step is 'Generate PT2001 Load Data Code'. See sample_code/PT2001_LoadData.c
+### PT2001 Studio: Compiling/Generating C/header Files
-* Fun fact: it looks like the difference between "MC33816 Developer Studio" and "PT2001 Developer studio" is ``assembler\cipher\key4.key`` file
-
+1. Open "PT2001 Developer Studio", and open project `firmware/hw_layer/mc33816/rusefi/project.xml`.
+2. Press the "Build" button at the right/center of the window to assemble the microcode.
+3. Use `Tools` -> `Generate PT2001 Load Data Code` to generate C/header files used by rusEFI to program the PT2001 over SPI at boot (see `mc33816/rusefi/sample_code/`).
-Just in case we have a backup of both tools at https://github.com/rusefi/rusefi_external_utils/tree/master/NXP-GDI
\ No newline at end of file
+### PSC Simulator: Simulating microcode/config changes
+
+1. Follow "PT2001 Studio" steps to build the project first.
+2. Open "PSC Simulator", add the project if not added yet (`Project` -> `Add Existing`), and open it from the tree view.
+3. Press `Compile All` in the toolbar.
+4. In the top bar, push `Run`, and type in the desired simulation length. `4 ms` (with a space) is a good starting point for the existing stimulus.
+5. Press OK on the `Auto Load` dialog box that comes up (all boxes checked).
+6. Wait for the simulation to run. There's an indication in the bottom left corner of the main window about simulation progress.
+7. Inspect the simulation results!
+
+Just in case we have a backup of tools at https://github.com/rusefi/rusefi_external_utils/tree/master/NXP-GDI
diff --git a/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.c b/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.c
new file mode 100644
index 0000000000..c29aea1c30
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.c
@@ -0,0 +1,136 @@
+/*******************************************************************************
+* Example Code
+*
+* Copyright(C) 2022 NXP Semiconductors
+* NXP Semiconductors Confidential and Proprietary
+*
+* Software that is described herein is for illustrative purposes only
+* which provides customers with programming information regarding the
+* NXP products. This software is supplied "AS IS" without any warranties
+* of any kind, and NXP Semiconductors and its licensor disclaim any and
+* all warranties, express or implied, including all implied warranties of
+* merchantability, fitness for a particular purpose and non-infringement of
+* intellectual property rights. NXP Semiconductors assumes no responsibility
+* or liability for the use of the software, conveys no license or rights
+* under any patent, copyright, mask work right, or any other intellectual
+* property rights in or to any products. NXP Semiconductors reserves the
+* right to make changes in the software without notification. NXP
+* Semiconductors also makes no representation or warranty that such
+* application will be suitable for the specified use without further testing
+* or modification.
+*
+* IN NO EVENT WILL NXP SEMICONDUCTORS BE LIABLE, WHETHER IN CONTRACT,
+* TORT, OR OTHERWISE, FOR ANY INCIDENTAL, SPECIAL, INDIRECT, CONSEQUENTIAL
+* OR PUNITIVE DAMAGES, INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR ANY
+* LOSS OF USE, LOSS OF TIME, INCONVENIENCE, COMMERCIAL LOSS, OR LOST
+* PROFITS, SAVINGS, OR REVENUES, TO THE FULL EXTENT SUCH MAY BE DISCLAIMED
+* BY LAW. NXP SEMICONDUCTOR’S TOTAL LIABILITY FOR ALL COSTS, DAMAGES,
+* CLAIMS, OR LOSSES WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE IS LIMITED TO THE AGGREGATE AMOUNT PAID BY YOU TO NXP SEMICONDUCTORS
+* IN CONNECTION WITH THE SOFTWARE TO WHICH LOSSES OR DAMAGES ARE CLAIMED.
+*
+* Permission to use, copy, modify, and distribute this software and its
+* documentation is hereby granted, under NXP Semiconductors' and its
+* licensor's relevant copyrights in the software, without fee, provided
+* that it is used in conjunction with NXP Semiconductors devices. This
+* copyright, permission, and disclaimer notice must appear in all copies
+* of this code.
+*******************************************************************************/
+
+//==============================================================================
+// This file contains data arrays that are used to load the code RAM, data RAM
+// and registers on the PT2001.
+//==============================================================================
+
+// ECU: IDE Project
+// Project: rusefi
+
+#include "PT2001_LoadData.h"
+
+// Data to be loaded into the Code RAM 1 memory space
+unsigned short PT2001_code_RAM1[108] =
+{
+ 0x7612, 0x6C43, 0x917F, 0xA514, 0x8DD1, 0xC289, 0x7C38, 0xA73B, 0xF359, 0x56C3,
+ 0xEE73, 0x812F, 0xC3A9, 0xC08B, 0x4371, 0x45BB, 0x64D7, 0xB185, 0x1C57, 0x49AA,
+ 0x40E9, 0xBF4C, 0x2F07, 0xDBCD, 0x057C, 0x8C8A, 0xD1F7, 0x3B13, 0x492C, 0x6544,
+ 0x277D, 0x799E, 0xD6B1, 0x477E, 0x0091, 0x0103, 0x6DA0, 0xA3AE, 0xE91C, 0xAF72,
+ 0x3DAC, 0x2230, 0xB8C0, 0x8A6B, 0x1E34, 0xDEBF, 0x0592, 0x9E7A, 0x8E2D, 0x809B,
+ 0x4F9F, 0x85C9, 0x5119, 0x7C72, 0xF333, 0xC575, 0x8B35, 0xD254, 0xD8FA, 0x3D01,
+ 0x1B1D, 0xDA87, 0xFE4A, 0x74B1, 0x789D, 0x2B94, 0x360D, 0x00A8, 0x8F78, 0xC909,
+ 0x3F0C, 0x9409, 0xFDFB, 0x43E3, 0x56E1, 0x9FA5, 0xEC49, 0xDEC7, 0x3A2C, 0xD350,
+ 0x40AC, 0x3447, 0xC1EB, 0x2D74, 0x1526, 0x7C64, 0xE7AE, 0x17AF, 0xDA5A, 0x78DB,
+ 0x1F1B, 0x5A34, 0x6503, 0xD511, 0xF26C, 0x9461, 0x7962, 0x531A, 0xB074, 0xF3C1,
+ 0xB55C, 0xDAC7, 0x4746, 0x3AE8, 0xDFB2, 0x04D9, 0x05F1, 0x1C88
+};
+
+// Data to be loaded into the Code RAM 2 memory space
+unsigned short PT2001_code_RAM2[43] =
+{
+ 0x761B, 0x6F45, 0x838D, 0x80B4, 0x53F2, 0x0EBC, 0x8F2D, 0xA78E, 0xE8AB, 0xE3DB,
+ 0xF477, 0x800F, 0x2336, 0x2F77, 0x267B, 0xBC19, 0x007E, 0x4E55, 0x28AA, 0x52E4,
+ 0x40CF, 0x0AFD, 0x8B32, 0xFF03, 0x3D8E, 0x802E, 0x1340, 0x95D0, 0x1E86, 0x6591,
+ 0xDBEB, 0x786D, 0xB2DF, 0xF4BF, 0xBEB2, 0xF1F4, 0x9E53, 0xE743, 0xE842, 0x3DD7,
+ 0x3DA2, 0x4663, 0x03AF
+};
+
+// Data to be loaded into the Data RAM memory space
+unsigned short PT2001_data_RAM[128] =
+{
+ 0x00C0, 0x0092, 0x0049, 0x003C, 0x1068, 0x003C, 0x0168, 0xEA60, 0x0960, 0x0258,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x00C1, 0x00BF, 0x002F, 0x001D, 0x0000, 0x0046,
+ 0x0037, 0x003C, 0xEA60, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+// Data to be loaded into the Main register memory space
+unsigned short PT2001_main_config[29] =
+{
+ 0x0003, 0x13FE, 0x0000, 0x1E00, 0x0000, 0x0000, 0x0001, 0x0000, 0x001F, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+// Data to be loaded into the CH1 register memory space
+unsigned short PT2001_ch1_config[19] =
+{
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0B13, 0x0000, 0x0000, 0x006C, 0x6B59, 0xC8A5,
+ 0x0000, 0x002C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+// Data to be loaded into the CH2 register memory space
+unsigned short PT2001_ch2_config[19] =
+{
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0000, 0x0000, 0x002B, 0x218C, 0xDCB6,
+ 0x0000, 0x0014, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+// Data to be loaded into the IO register memory space
+unsigned short PT2001_io_config[53] =
+{
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0063, 0x018C, 0x0800, 0x0410, 0x0041, 0x0098,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0041, 0x0041, 0x0041, 0x0000, 0x0004, 0x1000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7F7F, 0x7F7F,
+ 0x007F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000
+};
+
+// Data to be loaded into the Diag register memory space
+unsigned short PT2001_diag_config[44] =
+{
+ 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000,
+ 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x001E, 0x0000,
+ 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000,
+ 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0001
+};
+
diff --git a/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.h b/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.h
new file mode 100644
index 0000000000..bca5c044e7
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_LoadData.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+* Example Code
+*
+* Copyright(C) 2022 NXP Semiconductors
+* NXP Semiconductors Confidential and Proprietary
+*
+* Software that is described herein is for illustrative purposes only
+* which provides customers with programming information regarding the
+* NXP products. This software is supplied "AS IS" without any warranties
+* of any kind, and NXP Semiconductors and its licensor disclaim any and
+* all warranties, express or implied, including all implied warranties of
+* merchantability, fitness for a particular purpose and non-infringement of
+* intellectual property rights. NXP Semiconductors assumes no responsibility
+* or liability for the use of the software, conveys no license or rights
+* under any patent, copyright, mask work right, or any other intellectual
+* property rights in or to any products. NXP Semiconductors reserves the
+* right to make changes in the software without notification. NXP
+* Semiconductors also makes no representation or warranty that such
+* application will be suitable for the specified use without further testing
+* or modification.
+*
+* IN NO EVENT WILL NXP SEMICONDUCTORS BE LIABLE, WHETHER IN CONTRACT,
+* TORT, OR OTHERWISE, FOR ANY INCIDENTAL, SPECIAL, INDIRECT, CONSEQUENTIAL
+* OR PUNITIVE DAMAGES, INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR ANY
+* LOSS OF USE, LOSS OF TIME, INCONVENIENCE, COMMERCIAL LOSS, OR LOST
+* PROFITS, SAVINGS, OR REVENUES, TO THE FULL EXTENT SUCH MAY BE DISCLAIMED
+* BY LAW. NXP SEMICONDUCTOR’S TOTAL LIABILITY FOR ALL COSTS, DAMAGES,
+* CLAIMS, OR LOSSES WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE IS LIMITED TO THE AGGREGATE AMOUNT PAID BY YOU TO NXP SEMICONDUCTORS
+* IN CONNECTION WITH THE SOFTWARE TO WHICH LOSSES OR DAMAGES ARE CLAIMED.
+*
+* Permission to use, copy, modify, and distribute this software and its
+* documentation is hereby granted, under NXP Semiconductors' and its
+* licensor's relevant copyrights in the software, without fee, provided
+* that it is used in conjunction with NXP Semiconductors devices. This
+* copyright, permission, and disclaimer notice must appear in all copies
+* of this code.
+*******************************************************************************/
+
+//==============================================================================
+// This file contains data array declarations for the code RAM, data RAM and
+// register arrays for the PT2001.
+//==============================================================================
+
+// ECU: IDE Project
+// Project: rusefi
+
+#ifndef PT2001_DATA_H_
+#define PT2001_DATA_H_
+
+extern unsigned short PT2001_code_RAM1[108]; // CODE RAM CH 1
+extern unsigned short PT2001_code_RAM2[43]; // CODE RAM CH 2
+extern unsigned short PT2001_data_RAM[128]; // DATA RAM
+extern unsigned short PT2001_main_config[29]; // main configurations
+extern unsigned short PT2001_ch1_config[19]; // CH 1 configurations
+extern unsigned short PT2001_ch2_config[19]; // CH 2 configurations
+extern unsigned short PT2001_io_config[53]; // IO configurations
+extern unsigned short PT2001_diag_config[44]; // diag configurations
+
+#endif /* PT2001_DATA_H_ */
diff --git a/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_dram.h b/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_dram.h
new file mode 100644
index 0000000000..a8eacde269
--- /dev/null
+++ b/firmware/hw_layer/mc33816/rusefi/sample_code/PT2001_dram.h
@@ -0,0 +1,72 @@
+/*******************************************************************************
+* Example Code
+*
+* Copyright(C) 2022 NXP Semiconductors
+* NXP Semiconductors Confidential and Proprietary
+*
+* Software that is described herein is for illustrative purposes only
+* which provides customers with programming information regarding the
+* NXP products. This software is supplied "AS IS" without any warranties
+* of any kind, and NXP Semiconductors and its licensor disclaim any and
+* all warranties, express or implied, including all implied warranties of
+* merchantability, fitness for a particular purpose and non-infringement of
+* intellectual property rights. NXP Semiconductors assumes no responsibility
+* or liability for the use of the software, conveys no license or rights
+* under any patent, copyright, mask work right, or any other intellectual
+* property rights in or to any products. NXP Semiconductors reserves the
+* right to make changes in the software without notification. NXP
+* Semiconductors also makes no representation or warranty that such
+* application will be suitable for the specified use without further testing
+* or modification.
+*
+* IN NO EVENT WILL NXP SEMICONDUCTORS BE LIABLE, WHETHER IN CONTRACT,
+* TORT, OR OTHERWISE, FOR ANY INCIDENTAL, SPECIAL, INDIRECT, CONSEQUENTIAL
+* OR PUNITIVE DAMAGES, INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR ANY
+* LOSS OF USE, LOSS OF TIME, INCONVENIENCE, COMMERCIAL LOSS, OR LOST
+* PROFITS, SAVINGS, OR REVENUES, TO THE FULL EXTENT SUCH MAY BE DISCLAIMED
+* BY LAW. NXP SEMICONDUCTOR’S TOTAL LIABILITY FOR ALL COSTS, DAMAGES,
+* CLAIMS, OR LOSSES WHATSOEVER ARISING OUT OF OR IN CONNECTION WITH THE
+* SOFTWARE IS LIMITED TO THE AGGREGATE AMOUNT PAID BY YOU TO NXP SEMICONDUCTORS
+* IN CONNECTION WITH THE SOFTWARE TO WHICH LOSSES OR DAMAGES ARE CLAIMED.
+*
+* Permission to use, copy, modify, and distribute this software and its
+* documentation is hereby granted, under NXP Semiconductors' and its
+* licensor's relevant copyrights in the software, without fee, provided
+* that it is used in conjunction with NXP Semiconductors devices. This
+* copyright, permission, and disclaimer notice must appear in all copies
+* of this code.
+*******************************************************************************/
+
+/*
+ * PT2001_dram.h
+ *
+ * DRAM Header File
+ *
+ */
+
+#ifndef PT2001_DRAM_H_
+#define PT2001_DRAM_H_
+
+// DRAM 1 Parameter Addresses
+#define PT2001_D1_Iboost 0x00
+#define PT2001_D1_Ipeak 0x01
+#define PT2001_D1_Ihold 0x02
+#define PT2001_D1_Tpeak_off 0x03
+#define PT2001_D1_Tpeak_tot 0x04
+#define PT2001_D1_Tbypass 0x05
+#define PT2001_D1_Thold_off 0x06
+#define PT2001_D1_Thold_tot 0x07
+#define PT2001_D1_Tboost_max 0x08
+#define PT2001_D1_Tboost_min 0x09
+
+// DRAM 2 Parameter Addresses
+#define PT2001_D2_Vboost_high 0x40
+#define PT2001_D2_Vboost_low 0x41
+#define PT2001_D2_Isense4_high 0x42
+#define PT2001_D2_Isense4_low 0x43
+#define PT2001_D2_PCV_Ipeak 0x45
+#define PT2001_D2_PCV_Ihold 0x46
+#define PT2001_D2_PCV_Thold_off 0x47
+#define PT2001_D2_PCV_Thold_tot 0x48
+
+#endif /* PT2001_DRAM_H_ */
diff --git a/firmware/hw_layer/mc33816_data.cpp b/firmware/hw_layer/mc33816_data.cpp
deleted file mode 100644
index d6c5b1fa31..0000000000
--- a/firmware/hw_layer/mc33816_data.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * mc33816_data.c
- *
- * For historic reasons rusEFI source code refers to all this as mc33816 while the microcode
- * is signed with MC33PT2001 key. to use real mc33816 you would have to replace binary data with true mc33816 version
- *
- * this is manual copy-paste of sample_code/PT2001_LoadData.c
- * see mc33816/rusefi/readme.md
- */
-
-#include "pch.h"
-
-#include "mc33816_data.h"
-
-#if EFI_MC33816
-
-// Data to be loaded into the Code RAM 1 memory space
-const unsigned short MC33816_code_RAM1[88] =
-{
- 0x7612, 0x6C2B, 0x917F, 0xA514, 0x8DD1, 0xC289, 0x7C38, 0xA73B, 0xF359, 0x56C3,
- 0xEE73, 0x812F, 0xDFA9, 0x2ED5, 0x2722, 0xBC58, 0x649B, 0xFB66, 0xFAD7, 0xBB51,
- 0xBD0C, 0xBEA9, 0x2F34, 0xDA2C, 0x41CF, 0x8DDD, 0xB4F4, 0xCA54, 0xAF19, 0x6707,
- 0xDA8A, 0x1D69, 0x6015, 0xA215, 0xB473, 0xF3AB, 0x6CC1, 0xE620, 0x8D0F, 0x5FC6,
- 0x3DA2, 0x4662, 0x0EF2, 0x63A6, 0xEFAD, 0x9915, 0xA134, 0xBB55, 0xD6E8, 0xBDC9,
- 0x433D, 0x3943, 0x4AEA, 0xCD3C, 0xE90A, 0xC413, 0xD3A3, 0xF690, 0xE423, 0x0106,
- 0x72BC, 0xD39A, 0x0329, 0x3AF3, 0x9F62, 0x9FA6, 0xD615, 0xEF1D, 0xAF32, 0x31BF,
- 0x5A43, 0x2FAD, 0xFD4E, 0xB35B, 0x56F3, 0xFAB7, 0x5ADE, 0x3A4C, 0xCA7D, 0x20AF,
- 0x24CE, 0x808E, 0x43CD, 0xDF83, 0xE8DF, 0x7CC1, 0xE738, 0x1B09
-};
-
-// Data to be loaded into the Code RAM 2 memory space
-const unsigned short MC33816_code_RAM2[43] =
-{
- 0x761B, 0x6F45, 0x838D, 0x80B4, 0x53F2, 0x0EBC, 0x8F2D, 0xA78E, 0xE8AB, 0xE3DB,
- 0xF477, 0x800F, 0x2336, 0x2F77, 0x267B, 0xBC19, 0x007E, 0x4E55, 0x28AA, 0x52E4,
- 0x40CF, 0x0AFD, 0x8B32, 0xFF03, 0x3D8E, 0x802E, 0x1340, 0x95D0, 0x1E86, 0x6591,
- 0xDBEB, 0x786D, 0xB2DF, 0xF4BF, 0xBEB2, 0xF1F4, 0x9E53, 0xE743, 0xE842, 0x3DD7,
- 0x3DA2, 0x4663, 0x03AF
-};
-
-// Data to be loaded into the Data RAM memory space
-const unsigned short MC33816_data_RAM[128] =
-{
- 0x00F0, 0x00F0, 0x008C, 0x2000, 0x01F4, 0x00B4, 0x003C, 0xEA60, 0x0000, 0x003D,
- 0x6000, 0x003C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x00C1, 0x00BF, 0x002F, 0x001D, 0x0000, 0x0046,
- 0x0037, 0x003C, 0xEA60, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-// 0x1CE
-// if set to '1' Driver_status register is reset on read.
-#define Rsetbr 1
-
-// Data to be loaded into the Main register memory space
-const unsigned short MC33816_main_config[29] =
-{
- 0x0003, 0x1FFE, 0x0000, 0x1200, 0x0000, 0x0000, 0x0001, 0x0000, 0x001F, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, Rsetbr, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-// Data to be loaded into the CH1 register memory space
-const unsigned short MC33816_ch1_config[19] =
-{
- 0x0008, 0x0000, 0x0000, 0x0000, 0x0303, 0x0000, 0x0000, 0x0058, 0x8E62, 0x7B23,
- 0x0000, 0x002C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-// Data to be loaded into the CH2 register memory space
-const unsigned short MC33816_ch2_config[19] =
-{
- 0x0008, 0x0000, 0x0000, 0x0000, 0x0C00, 0x0000, 0x0000, 0x002B, 0x218C, 0xDCB6,
- 0x0000, 0x0014, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-// Data to be loaded into the IO register memory space
-const unsigned short MC33816_io_config[44] =
-{
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0063, 0x018C, 0x0800, 0x0410, 0x0041, 0x0098,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0041, 0x0041, 0x0041, 0x0000, 0x0004, 0x1000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7F7F, 0x7F7F,
- 0x007F, 0x0000, 0x0000, 0x0000
-};
-
-// Data to be loaded into the Diag register memory space
-const unsigned short MC33816_diag_config[44] =
-{
- 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000,
- 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x001E, 0x0000,
- 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000,
- 0x001E, 0x0000, 0x0000, 0x001E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0001
-};
-
-#endif // EFI_MC33816
diff --git a/firmware/hw_layer/mc33816_data.h b/firmware/hw_layer/mc33816_data.h
deleted file mode 100644
index d838ad9f9a..0000000000
--- a/firmware/hw_layer/mc33816_data.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * mc33816_data.h
- *
- * @date May 3, 2019
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#pragma once
-
-extern const unsigned short MC33816_code_RAM1[88]; // CODE RAM CH 1
-extern const unsigned short MC33816_code_RAM2[43]; // CODE RAM CH 2
-extern const unsigned short MC33816_data_RAM[128]; // DATA RAM
-extern const unsigned short MC33816_main_config[29]; // main configurations
-extern const unsigned short MC33816_ch1_config[19]; // CH 1 configurations
-extern const unsigned short MC33816_ch2_config[19]; // CH 2 configurations
-extern const unsigned short MC33816_io_config[44]; // IO configurations
-extern const unsigned short MC33816_diag_config[44]; // diag configurations
-
diff --git a/firmware/hw_layer/mc33816_memory_map.h b/firmware/hw_layer/mc33816_memory_map.h
index b1ddd8378e..85463480c3 100644
--- a/firmware/hw_layer/mc33816_memory_map.h
+++ b/firmware/hw_layer/mc33816_memory_map.h
@@ -2,23 +2,27 @@
* see mc33816/rusefi/readme.md
*/
-typedef enum {
+#include "mc33816/rusefi/sample_code/PT2001_dram.h"
+
+enum class MC33816Mem {
// see dram1.def values
- Iboost = 0,
- Ipeak = 1,
- Ihold = 2,
- Tpeak_off = 3,
- Tpeak_tot = 4,
- Tbypass = 5,
- Thold_off = 6,
- Thold_tot = 7,
+ Iboost = PT2001_D1_Iboost,
+ Ipeak = PT2001_D1_Ipeak,
+ Ihold = PT2001_D1_Ihold,
+ Tpeak_off = PT2001_D1_Tpeak_off,
+ Tpeak_tot = PT2001_D1_Tpeak_tot,
+ Tbypass = PT2001_D1_Tbypass,
+ Thold_off = PT2001_D1_Thold_off,
+ Thold_tot = PT2001_D1_Thold_tot,
+ Tboost_min = PT2001_D1_Tboost_min,
+ Tboost_max = PT2001_D1_Tboost_max,
// see dram2.def values, base 64 for channel 2
- Vboost_high = 64,
- Vboost_low = 65,
- Isense4_high = 66,
- Isense4_low = 67,
- HPFP_Ipeak = 69,
- HPFP_Ihold = 70,
- HPFP_Thold_off = 71,
- HPFP_Thold_tot = 72,
-} MC33816Mem;
+ Vboost_high = PT2001_D2_Vboost_high,
+ Vboost_low = PT2001_D2_Vboost_low,
+ Isense4_high = PT2001_D2_Isense4_high,
+ Isense4_low = PT2001_D2_Isense4_low,
+ HPFP_Ipeak = PT2001_D2_PCV_Ipeak,
+ HPFP_Ihold = PT2001_D2_PCV_Ihold,
+ HPFP_Thold_off = PT2001_D2_PCV_Thold_off,
+ HPFP_Thold_tot = PT2001_D2_PCV_Thold_tot,
+};
diff --git a/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp b/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp
index aa95bdc315..caf879ce3c 100644
--- a/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp
+++ b/firmware/hw_layer/microsecond_timer/microsecond_timer.cpp
@@ -177,7 +177,7 @@ void initMicrosecondTimer() {
watchDogBuddyCallback(NULL);
#if EFI_EMULATE_POSITION_SENSORS
- watchdogControllerInstance.Start();
+ watchdogControllerInstance.start();
#endif /* EFI_EMULATE_POSITION_SENSORS */
}
diff --git a/firmware/hw_layer/openblt/openblt.mk b/firmware/hw_layer/openblt/openblt.mk
index 3011ec2458..01fe298414 100644
--- a/firmware/hw_layer/openblt/openblt.mk
+++ b/firmware/hw_layer/openblt/openblt.mk
@@ -85,7 +85,6 @@ PROJ_FILES += $(PROJECT_DIR)/hw_layer/openblt/led.h
# CPU-dependent sources
ifeq ($(PROJECT_CPU),ARCH_STM32F4)
- PROJ_FILES += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f4/openblt/lib/startup_stm32f429xx.s
# Collect bootloader port files
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM4_STM32F4/*.c)
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM4_STM32F4/*.h)
@@ -97,7 +96,6 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F4)
# Port specific options
PORTFLAGS += -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
else ifeq ($(PROJECT_CPU),ARCH_STM32F7)
- PROJ_FILES += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/openblt/lib/startup_stm32f767xx.s
# Collect bootloader port files
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32F7/*.c)
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32F7/*.h)
@@ -109,7 +107,6 @@ else ifeq ($(PROJECT_CPU),ARCH_STM32F7)
# Port specific options
PORTFLAGS = -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16
else ifeq ($(PROJECT_CPU),ARCH_STM32H7)
- # todo: do we need startup_stmXX.s here?
# Collect bootloader port files
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32H7/*.c)
PROJ_FILES += $(wildcard $(OPENBLT_TRGT_DIR)/Source/ARMCM7_STM32H7/*.h)
diff --git a/firmware/hw_layer/ports/cypress/backup_ram.cpp b/firmware/hw_layer/ports/cypress/backup_ram.cpp
index da55b5429e..9b66250127 100644
--- a/firmware/hw_layer/ports/cypress/backup_ram.cpp
+++ b/firmware/hw_layer/ports/cypress/backup_ram.cpp
@@ -78,3 +78,8 @@ void backupRamFlush(void) {
// but if there is, at least try to reinitialize...
wasLoaded = false;
}
+
+// TODO: implement me!
+BackupSramData* getBackupSram() {
+ return nullptr;
+}
diff --git a/firmware/hw_layer/ports/kinetis/backup_ram.cpp b/firmware/hw_layer/ports/kinetis/backup_ram.cpp
index adaeaf2419..cd4e17c430 100644
--- a/firmware/hw_layer/ports/kinetis/backup_ram.cpp
+++ b/firmware/hw_layer/ports/kinetis/backup_ram.cpp
@@ -14,3 +14,8 @@ uint32_t backupRamLoad(backup_ram_e idx) {
void backupRamSave(backup_ram_e idx, uint32_t value) {
}
+
+// TODO: implement me!
+BackupSramData* getBackupSram() {
+ return nullptr;
+}
diff --git a/firmware/hw_layer/ports/mpu_util.h b/firmware/hw_layer/ports/mpu_util.h
index 1247bbb98e..03ae588a2b 100644
--- a/firmware/hw_layer/ports/mpu_util.h
+++ b/firmware/hw_layer/ports/mpu_util.h
@@ -9,6 +9,9 @@
// Base MCU
void baseMCUInit(void);
void jump_to_bootloader();
+#if EFI_USE_OPENBLT
+void jump_to_openblt();
+#endif
bool allowFlashWhileRunning();
bool ramReadProbe(volatile const char *read_address);
diff --git a/firmware/hw_layer/ports/stm32/backup_ram.cpp b/firmware/hw_layer/ports/stm32/backup_ram.cpp
index ac333fd3e9..d6b0c4e33a 100644
--- a/firmware/hw_layer/ports/stm32/backup_ram.cpp
+++ b/firmware/hw_layer/ports/stm32/backup_ram.cpp
@@ -58,3 +58,12 @@ void backupRamSave(backup_ram_e idx, uint32_t value) {
void backupRamFlush(void) {
// nothing to do here, in STM32 all data is saved instantaneously
}
+
+// STM32 only has 4k bytes of backup SRAM
+static_assert(sizeof(BackupSramData) <= 4096);
+
+extern BackupSramData __backup_sram_addr__;
+
+BackupSramData* getBackupSram() {
+ return &__backup_sram_addr__;
+}
diff --git a/firmware/hw_layer/ports/stm32/mcuconf_common_f4_f7.h b/firmware/hw_layer/ports/stm32/mcuconf_common_f4_f7.h
index f471ab75f7..435922ca88 100644
--- a/firmware/hw_layer/ports/stm32/mcuconf_common_f4_f7.h
+++ b/firmware/hw_layer/ports/stm32/mcuconf_common_f4_f7.h
@@ -177,9 +177,9 @@
/*
* ICU driver system settings.
*/
-#define STM32_ICU_USE_TIM1 TRUE
-#define STM32_ICU_USE_TIM2 TRUE
-#define STM32_ICU_USE_TIM3 TRUE
+#define STM32_ICU_USE_TIM1 FALSE
+#define STM32_ICU_USE_TIM2 FALSE
+#define STM32_ICU_USE_TIM3 FALSE
#define STM32_ICU_USE_TIM4 FALSE
#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_USE_TIM8 FALSE
@@ -262,9 +262,18 @@
/*
* SPI driver system settings.
*/
+#ifndef STM32_SPI_USE_SPI1
#define STM32_SPI_USE_SPI1 TRUE
+#endif
+
+#ifndef STM32_SPI_USE_SPI2
#define STM32_SPI_USE_SPI2 TRUE
+#endif
+
+#ifndef STM32_SPI_USE_SPI3
#define STM32_SPI_USE_SPI3 TRUE
+#endif
+
#define STM32_SPI_USE_SPI4 FALSE
#define STM32_SPI_USE_SPI5 FALSE
#define STM32_SPI_USE_SPI6 FALSE
diff --git a/firmware/hw_layer/ports/stm32/stm32_adc_v2.cpp b/firmware/hw_layer/ports/stm32/stm32_adc_v2.cpp
index 38315ffeba..51286630e0 100644
--- a/firmware/hw_layer/ports/stm32/stm32_adc_v2.cpp
+++ b/firmware/hw_layer/ports/stm32/stm32_adc_v2.cpp
@@ -13,10 +13,18 @@
/* Depth of the conversion buffer, channels are sampled X times each.*/
#define SLOW_ADC_OVERSAMPLE 8
+#ifdef ADC_MUX_PIN
+static OutputPin muxControl;
+#endif // ADC_MUX_PIN
+
void portInitAdc() {
// Init slow ADC
adcStart(&ADCD1, NULL);
+#ifdef ADC_MUX_PIN
+ muxControl.initPin("ADC Mux", ADC_MUX_PIN);
+#endif //ADC_MUX_PIN
+
#if EFI_USE_FAST_ADC
// Init fast ADC (MAP sensor)
adcStart(&ADCD2, NULL);
@@ -108,14 +116,14 @@ float getMcuTemperature() {
#define ADC_SAMPLING_SLOW ADC_SAMPLE_56
#define ADC_SAMPLING_FAST ADC_SAMPLE_28
-// Slow ADC has 16 channels we can sample
-constexpr size_t slowChannelCount = 16;
+// Slow ADC has 16 channels we can sample, or 32 if ADC mux mode is enabled.
+constexpr size_t adcChannelCount = 16;
// Conversion group for slow channels
// This simply samples every channel in sequence
static constexpr ADCConversionGroup convGroupSlow = {
.circular = FALSE,
- .num_channels = slowChannelCount,
+ .num_channels = adcChannelCount,
.end_cb = nullptr,
.error_cb = nullptr,
/* HW dependent part.*/
@@ -148,9 +156,9 @@ static constexpr ADCConversionGroup convGroupSlow = {
.sqr3 = ADC_SQR3_SQ1_N(0) | ADC_SQR3_SQ2_N(1) | ADC_SQR3_SQ3_N(2) | ADC_SQR3_SQ4_N(3) | ADC_SQR3_SQ5_N(4) | ADC_SQR3_SQ6_N(5), // Conversion group sequence 1...6
};
-static NO_CACHE adcsample_t slowSampleBuffer[SLOW_ADC_OVERSAMPLE * slowChannelCount];
+static NO_CACHE adcsample_t slowSampleBuffer[SLOW_ADC_OVERSAMPLE * adcChannelCount];
-bool readSlowAnalogInputs(adcsample_t* convertedSamples) {
+bool readBatch(adcsample_t* convertedSamples, size_t start) {
msg_t result = adcConvert(&ADCD1, &convGroupSlow, slowSampleBuffer, SLOW_ADC_OVERSAMPLE);
// If something went wrong - try again later
@@ -159,21 +167,36 @@ bool readSlowAnalogInputs(adcsample_t* convertedSamples) {
}
// Average samples to get some noise filtering and oversampling
- for (size_t i = 0; i < slowChannelCount; i++) {
+ for (size_t i = 0; i < adcChannelCount; i++) {
uint32_t sum = 0;
size_t index = i;
for (size_t j = 0; j < SLOW_ADC_OVERSAMPLE; j++) {
sum += slowSampleBuffer[index];
- index += slowChannelCount;
+ index += adcChannelCount;
}
adcsample_t value = static_cast(sum / SLOW_ADC_OVERSAMPLE);
- convertedSamples[i] = value;
+ convertedSamples[start + i] = value;
}
return true;
}
+bool readSlowAnalogInputs(adcsample_t* convertedSamples) {
+ bool result = true;
+
+ result &= readBatch(convertedSamples, 0);
+
+#ifdef ADC_MUX_PIN
+ muxControl.setValue(1);
+ // read the second batch, starting where we left off
+ result &= readBatch(convertedSamples, adcChannelCount);
+ muxControl.setValue(0);
+#endif
+
+ return result;
+}
+
#if EFI_USE_FAST_ADC
#include "AdcConfiguration.h"
diff --git a/firmware/hw_layer/ports/stm32/stm32_adc_v4.cpp b/firmware/hw_layer/ports/stm32/stm32_adc_v4.cpp
index b9f2195570..980920f972 100644
--- a/firmware/hw_layer/ports/stm32/stm32_adc_v4.cpp
+++ b/firmware/hw_layer/ports/stm32/stm32_adc_v4.cpp
@@ -10,6 +10,10 @@
#include "mpu_util.h"
#include "map_averaging.h"
+#ifdef ADC_MUX_PIN
+#error "ADC mux not yet supported on STM32H7"
+#endif
+
#ifndef H7_ADC_SPEED
#define H7_ADC_SPEED (10000)
#endif
diff --git a/firmware/hw_layer/ports/stm32/stm32_common.cpp b/firmware/hw_layer/ports/stm32/stm32_common.cpp
index 087fe6cdd6..fe4b556a6d 100644
--- a/firmware/hw_layer/ports/stm32/stm32_common.cpp
+++ b/firmware/hw_layer/ports/stm32/stm32_common.cpp
@@ -326,7 +326,7 @@ stm32_hardware_pwm* getNextPwmDevice() {
}
#endif
-void jump_to_bootloader() {
+static void reset_and_jump(uint32_t breadcrumb) {
#ifdef STM32H7XX
// H7 needs a forcible reset of the USB peripheral(s) in order for the bootloader to work properly.
// If you don't do this, the bootloader will execute, but USB doesn't work (nobody knows why)
@@ -334,11 +334,19 @@ void jump_to_bootloader() {
RCC->AHB1ENR &= ~(RCC_AHB1ENR_USB1OTGHSEN | RCC_AHB1ENR_USB2OTGFSEN);
#endif
- // leave DFU breadcrumb which assembly startup code would check, see [rusefi][DFU] section in assembly code
- *((unsigned long *)0x2001FFF0) = 0xDEADBEEF; // End of RAM
+ *((unsigned long *)0x2001FFF0) = breadcrumb; // End of RAM
// and now reboot
NVIC_SystemReset();
}
+
+void jump_to_bootloader() {
+ // leave DFU breadcrumb which assembly startup code would check, see [rusefi][DFU] section in assembly code
+ reset_and_jump(0xDEADBEEF);
+}
+
+void jump_to_openblt() {
+ reset_and_jump(0xCAFEBABE);
+}
#endif /* EFI_PROD_CODE */
#if EFI_AUX_SERIAL
@@ -406,19 +414,11 @@ void baseMCUInit(void) {
BOR_Set(BOR_Level_1); // one step above default value
}
-
-extern "C" {
-void prvGetRegistersFromStack(uint32_t *pulFaultStackAddress);
-}
-
extern uint32_t __main_stack_base__;
-#define GET_CFSR() (*((volatile uint32_t *) (0xE000ED28)))
-
typedef struct port_intctx intctx_t;
EXTERNC int getRemainingStack(thread_t *otp) {
-
#if CH_DBG_ENABLE_STACK_CHECK
// this would dismiss coverity warning - see http://rusefi.com/forum/viewtopic.php?f=5&t=655
// coverity[uninit_use]
@@ -440,135 +440,6 @@ EXTERNC int getRemainingStack(thread_t *otp) {
#endif /* CH_DBG_ENABLE_STACK_CHECK */
}
-void _unhandled_exception(void) {
-/*lint -restore*/
-
- chDbgPanic3("_unhandled_exception", __FILE__, __LINE__);
- while (true) {
- }
-}
-
-void DebugMonitorVector(void) {
- chDbgPanic3("DebugMonitorVector", __FILE__, __LINE__);
- while (TRUE)
- ;
-}
-
-void UsageFaultVector(void) {
- chDbgPanic3("UsageFaultVector", __FILE__, __LINE__);
- while (TRUE)
- ;
-}
-
-void BusFaultVector(void) {
- chDbgPanic3("BusFaultVector", __FILE__, __LINE__);
- while (TRUE) {
- }
-}
-
-/**
- + * @brief Register values for postmortem debugging.
- + */
-volatile uint32_t postmortem_r0;
-volatile uint32_t postmortem_r1;
-volatile uint32_t postmortem_r2;
-volatile uint32_t postmortem_r3;
-volatile uint32_t postmortem_r12;
-volatile uint32_t postmortem_lr; /* Link register. */
-volatile uint32_t postmortem_pc; /* Program counter. */
-volatile uint32_t postmortem_psr;/* Program status register. */
-volatile uint32_t postmortem_CFSR;
-volatile uint32_t postmortem_HFSR;
-volatile uint32_t postmortem_DFSR;
-volatile uint32_t postmortem_AFSR;
-volatile uint32_t postmortem_BFAR;
-volatile uint32_t postmortem_MMAR;
-volatile uint32_t postmortem_SCB_SHCSR;
-
-/**
- * @brief Evaluates to TRUE if system runs under debugger control.
- * @note This bit resets only by power reset.
- */
-#define is_under_debugger() (((CoreDebug)->DHCSR) & \
- CoreDebug_DHCSR_C_DEBUGEN_Msk)
-
-/**
- *
- */
-void prvGetRegistersFromStack(uint32_t *pulFaultStackAddress) {
-
- postmortem_r0 = pulFaultStackAddress[0];
- postmortem_r1 = pulFaultStackAddress[1];
- postmortem_r2 = pulFaultStackAddress[2];
- postmortem_r3 = pulFaultStackAddress[3];
- postmortem_r12 = pulFaultStackAddress[4];
- postmortem_lr = pulFaultStackAddress[5];
- postmortem_pc = pulFaultStackAddress[6];
- postmortem_psr = pulFaultStackAddress[7];
-
- /* Configurable Fault Status Register. Consists of MMSR, BFSR and UFSR */
- postmortem_CFSR = GET_CFSR();
-
- /* Hard Fault Status Register */
- postmortem_HFSR = (*((volatile uint32_t *) (0xE000ED2C)));
-
- /* Debug Fault Status Register */
- postmortem_DFSR = (*((volatile uint32_t *) (0xE000ED30)));
-
- /* Auxiliary Fault Status Register */
- postmortem_AFSR = (*((volatile uint32_t *) (0xE000ED3C)));
-
- /* Read the Fault Address Registers. These may not contain valid values.
- Check BFARVALID/MMARVALID to see if they are valid values
- MemManage Fault Address Register */
- postmortem_MMAR = (*((volatile uint32_t *) (0xE000ED34)));
- /* Bus Fault Address Register */
- postmortem_BFAR = (*((volatile uint32_t *) (0xE000ED38)));
-
- postmortem_SCB_SHCSR = SCB->SHCSR;
-
- if (is_under_debugger()) {
- __asm("BKPT #0\n");
- // Break into the debugger
- }
-
- /* harmless infinite loop */
- while (1) {
- ;
- }
-}
-
-void HardFaultVector(void) {
-#if 0 && defined __GNUC__
- __asm volatile (
- " tst lr, #4 \n"
- " ite eq \n"
- " mrseq r0, msp \n"
- " mrsne r0, psp \n"
- " ldr r1, [r0, #24] \n"
- " ldr r2, handler2_address_const \n"
- " bx r2 \n"
- " handler2_address_const: .word prvGetRegistersFromStack \n"
- );
-
-#else
-#endif /* 0 && defined __GNUC__ */
-
- int cfsr = GET_CFSR();
- if (cfsr & 0x1) {
- chDbgPanic3("H IACCVIOL", __FILE__, __LINE__);
- } else if (cfsr & 0x100) {
- chDbgPanic3("H IBUSERR", __FILE__, __LINE__);
- } else if (cfsr & 0x20000) {
- chDbgPanic3("H INVSTATE", __FILE__, __LINE__);
- } else {
- chDbgPanic3("HardFaultVector", __FILE__, __LINE__);
- }
-
- while (TRUE) {
- }
-}
-
#if HAL_USE_SPI
bool isSpiInitialized[5] = { false, false, false, false, false };
diff --git a/firmware/hw_layer/ports/stm32/stm32f4/STM32F4.ld b/firmware/hw_layer/ports/stm32/stm32f4/STM32F4.ld
index 32d9e26b79..9b06b82eaa 100644
--- a/firmware/hw_layer/ports/stm32/stm32f4/STM32F4.ld
+++ b/firmware/hw_layer/ports/stm32/stm32f4/STM32F4.ld
@@ -50,6 +50,8 @@ MEMORY
ram7 : org = 0xD0000000, len = SDRAM_SIZE /* SDRAM */
}
+__backup_sram_addr__ = ORIGIN(ram5);
+
/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/
diff --git a/firmware/hw_layer/ports/stm32/stm32f4/cfg/halconf.h b/firmware/hw_layer/ports/stm32/stm32f4/cfg/halconf.h
index f85ec85c35..1e04ed6122 100644
--- a/firmware/hw_layer/ports/stm32/stm32f4/cfg/halconf.h
+++ b/firmware/hw_layer/ports/stm32/stm32f4/cfg/halconf.h
@@ -73,7 +73,7 @@
* @brief Enables the ICU subsystem.
*/
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU TRUE
+#define HAL_USE_ICU FALSE
#endif
/**
diff --git a/firmware/hw_layer/ports/stm32/stm32f4/cfg/mcuconf.h b/firmware/hw_layer/ports/stm32/stm32f4/cfg/mcuconf.h
index 73f9770267..8fbac82088 100644
--- a/firmware/hw_layer/ports/stm32/stm32f4/cfg/mcuconf.h
+++ b/firmware/hw_layer/ports/stm32/stm32f4/cfg/mcuconf.h
@@ -76,7 +76,7 @@
#define STM32_PLLI2SR_VALUE 5
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
-#define STM32_BKPRAM_ENABLE FALSE
+#define STM32_BKPRAM_ENABLE TRUE
/*
* GPT driver system settings.
diff --git a/firmware/hw_layer/ports/stm32/stm32f4/openblt/lib/startup_stm32f429xx.s b/firmware/hw_layer/ports/stm32/stm32f4/openblt/lib/startup_stm32f429xx.s
index dd0922ad35..cdf38a983a 100644
--- a/firmware/hw_layer/ports/stm32/stm32f4/openblt/lib/startup_stm32f429xx.s
+++ b/firmware/hw_layer/ports/stm32/stm32f4/openblt/lib/startup_stm32f429xx.s
@@ -59,6 +59,16 @@ defined in linker script */
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
+ // Clive Two.Zero is the God of ST community forum
+ // Device specific, if in doubt RTFM
+ LDR R0, =0x2001FFF0 // End of SRAM for your CPU
+ LDR R1, =0xDEADBEEF // magic value
+ LDR R2, [R0, #0]
+ STR R0, [R0, #0] // Invalidate
+ CMP R2, R1
+ BEQ UseDFU
+ // DFU bootloader not needed, continue with OpenBLT
+
ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
@@ -98,6 +108,12 @@ LoopFillZerobss:
bx lr
.size Reset_Handler, .-Reset_Handler
+UseDFU:
+ // AN2606 Application note
+ // STM32 microcontroller system memory boot mode
+.include "../../dfu_init.h"
+ BX R0 // this jumps to DFU bootloader
+
/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
diff --git a/firmware/hw_layer/ports/stm32/stm32f7/STM32F7.ld b/firmware/hw_layer/ports/stm32/stm32f7/STM32F7.ld
index 3ca03d32bd..18cc0c8610 100644
--- a/firmware/hw_layer/ports/stm32/stm32f7/STM32F7.ld
+++ b/firmware/hw_layer/ports/stm32/stm32f7/STM32F7.ld
@@ -51,6 +51,8 @@ MEMORY
ram7 (wx) : org = 0x00000000, len = 0
}
+__backup_sram_addr__ = ORIGIN(ram5);
+
/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/
diff --git a/firmware/hw_layer/ports/stm32/stm32f7/board.h b/firmware/hw_layer/ports/stm32/stm32f7/board.h
index e26f031de5..bc22c66f95 100644
--- a/firmware/hw_layer/ports/stm32/stm32f7/board.h
+++ b/firmware/hw_layer/ports/stm32/stm32f7/board.h
@@ -54,12 +54,6 @@
#define STM32_LSEDRV (3U << 3U)
-// Nucleo boards use MCO signal from St-Link and NOT oscillator - these need STM32_HSE_BYPASS
-// if you do not have Sl-Link and MCO on your board, you need EFI_USE_OSC
-
-#ifndef EFI_USE_OSC
-#define STM32_HSE_BYPASS
-#endif /* EFI_USE_OSC */
/*
* Board voltages.
diff --git a/firmware/hw_layer/ports/stm32/stm32f7/cfg/halconf.h b/firmware/hw_layer/ports/stm32/stm32f7/cfg/halconf.h
index ab0db02f51..b4f28c1683 100644
--- a/firmware/hw_layer/ports/stm32/stm32f7/cfg/halconf.h
+++ b/firmware/hw_layer/ports/stm32/stm32f7/cfg/halconf.h
@@ -71,7 +71,7 @@
* @brief Enables the ICU subsystem.
*/
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU TRUE
+#define HAL_USE_ICU FALSE
#endif
/**
diff --git a/firmware/hw_layer/ports/stm32/stm32f7/cfg/mcuconf.h b/firmware/hw_layer/ports/stm32/stm32f7/cfg/mcuconf.h
index 6afa048be7..6a4b5c1b15 100644
--- a/firmware/hw_layer/ports/stm32/stm32f7/cfg/mcuconf.h
+++ b/firmware/hw_layer/ports/stm32/stm32f7/cfg/mcuconf.h
@@ -65,7 +65,7 @@
#define STM32_NO_INIT FALSE
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
-#define STM32_BKPRAM_ENABLE FALSE
+#define STM32_BKPRAM_ENABLE TRUE
#define STM32_HSI_ENABLED TRUE
#define STM32_LSI_ENABLED TRUE
#define STM32_HSE_ENABLED TRUE
diff --git a/firmware/hw_layer/ports/stm32/stm32f7/openblt/lib/startup_stm32f767xx.s b/firmware/hw_layer/ports/stm32/stm32f7/openblt/lib/startup_stm32f767xx.s
index 344526dac5..bdfac69edc 100644
--- a/firmware/hw_layer/ports/stm32/stm32f7/openblt/lib/startup_stm32f767xx.s
+++ b/firmware/hw_layer/ports/stm32/stm32f7/openblt/lib/startup_stm32f767xx.s
@@ -75,6 +75,16 @@ defined in linker script */
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
+ // Clive Two.Zero is the God of ST community forum
+ // Device specific, if in doubt RTFM
+ LDR R0, =0x2001FFF0 // End of SRAM for your CPU
+ LDR R1, =0xDEADBEEF // magic value
+ LDR R2, [R0, #0]
+ STR R0, [R0, #0] // Invalidate
+ CMP R2, R1
+ BEQ UseDFU
+ // DFU bootloader not needed, continue with OpenBLT
+
ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
@@ -114,6 +124,12 @@ LoopFillZerobss:
bx lr
.size Reset_Handler, .-Reset_Handler
+UseDFU:
+ // AN2606 Application note
+ // STM32 microcontroller system memory boot mode
+.include "../../dfu_init.h"
+ BX R0 // this jumps to DFU bootloader
+
/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
diff --git a/firmware/hw_layer/ports/stm32/stm32h7/STM32H743xI.ld b/firmware/hw_layer/ports/stm32/stm32h7/STM32H743xI.ld
index adb2bbaf87..b58656a067 100755
--- a/firmware/hw_layer/ports/stm32/stm32h7/STM32H743xI.ld
+++ b/firmware/hw_layer/ports/stm32/stm32h7/STM32H743xI.ld
@@ -45,6 +45,8 @@ MEMORY
ram7 (wx) : org = 0x38800000, len = 4k /* BCKP SRAM */
}
+__backup_sram_addr__ = ORIGIN(ram7);
+
/* For each data/text section two region are defined, a virtual region
and a load region (_LMA suffix).*/
diff --git a/firmware/hw_layer/ports/stm32/stm32h7/board.h b/firmware/hw_layer/ports/stm32/stm32h7/board.h
index 7323473dc0..dc046fec29 100644
--- a/firmware/hw_layer/ports/stm32/stm32h7/board.h
+++ b/firmware/hw_layer/ports/stm32/stm32h7/board.h
@@ -66,13 +66,6 @@
#define STM32_HSECLK 8000000U
#endif
-// Nucleo boards use MCO signal from St-Link and NOT oscillator - these need STM32_HSE_BYPASS
-// if you do not have Sl-Link and MCO on your board, you need EFI_USE_OSC
-
-#ifndef EFI_USE_OSC
-#define STM32_HSE_BYPASS
-#endif /* EFI_USE_OSC */
-
/*
* Board voltages.
* Required for performance limits calculation.
diff --git a/firmware/hw_layer/ports/stm32/stm32h7/openblt/lib/startup_stm32h743xx.s b/firmware/hw_layer/ports/stm32/stm32h7/openblt/lib/startup_stm32h743xx.s
index d0bc86e6eb..6cb101d637 100644
--- a/firmware/hw_layer/ports/stm32/stm32h7/openblt/lib/startup_stm32h743xx.s
+++ b/firmware/hw_layer/ports/stm32/stm32h7/openblt/lib/startup_stm32h743xx.s
@@ -59,6 +59,16 @@ defined in linker script */
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
+ // Clive Two.Zero is the God of ST community forum
+ // Device specific, if in doubt RTFM
+ LDR R0, =0x2001FFF0 // End of SRAM for your CPU
+ LDR R1, =0xDEADBEEF // magic value
+ LDR R2, [R0, #0]
+ STR R0, [R0, #0] // Invalidate
+ CMP R2, R1
+ BEQ UseDFU
+ // DFU bootloader not needed, continue with OpenBLT
+
ldr sp, =_estack /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
@@ -98,6 +108,12 @@ LoopFillZerobss:
bx lr
.size Reset_Handler, .-Reset_Handler
+UseDFU:
+ // AN2606 Application note
+ // STM32 microcontroller system memory boot mode
+.include "../../dfu_init.h"
+ BX R0 // this jumps to DFU bootloader
+
/**
* @brief This is the code that gets called when the processor receives an
* unexpected interrupt. This simply enters an infinite loop, preserving
diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp
index b0c2941a0b..0ee8db0776 100644
--- a/firmware/hw_layer/smart_gpio.cpp
+++ b/firmware/hw_layer/smart_gpio.cpp
@@ -18,6 +18,7 @@
#include "drivers/gpio/tle8888.h"
#include "drivers/gpio/drv8860.h"
#include "drivers/gpio/l9779.h"
+#include "drivers/gpio/tle9104.h"
#if (BOARD_TLE6240_COUNT > 0)
// todo: migrate to TS or board config
@@ -163,7 +164,7 @@ struct tle8888_config tle8888_cfg = {
[1] = {.port = GPIOE, .pad = 13},
[2] = {.port = GPIOE, .pad = 12},
[3] = {.port = GPIOE, .pad = 11},
- /* IN5..8 -> IGN1..IGN4 (Ignotors) */
+ /* IN5..8 -> IGN1..IGN4 (Ignitors) */
/* Not used */
[4] = {.port = NULL, .pad = 0},
[5] = {.port = NULL, .pad = 0},
@@ -176,10 +177,10 @@ struct tle8888_config tle8888_cfg = {
[11] = {.port = GPIOE, .pad = 7},
},
.direct_maps = {
- [0] = {.output = 5},
- [1] = {.output = 6},
- [2] = {.output = 21},
- [3] = {.output = 22},
+ [0] = {.output = 5}, /* MRE: LS2 */
+ [1] = {.output = 6}, /* MRE: LS1 */
+ [2] = {.output = 21}, /* MRE: GP1 - not used when stepper = true */
+ [3] = {.output = 22}, /* MRE: GP2 - not used when stepper = true */
},
.ign_en = {.port = GPIOD, .pad = 10},
.inj_en = {.port = GPIOD, .pad = 11},
@@ -283,6 +284,10 @@ void initSmartGpio() {
/* none of official boards has this IC */
#endif /* (BOARD_MC33810_COUNT > 0) */
+#if (BOARD_TLE9104_COUNT > 0)
+ // No official boards have this IC
+#endif
+
/* external chip init */
gpiochips_init();
}
@@ -317,6 +322,9 @@ void stopSmartCsPins() {
#if (BOARD_MC33810_COUNT > 0)
/* none of official boards has this IC */
#endif /* (BOARD_MC33810_COUNT > 0) */
+#if (BOARD_TLE9104_COUNT > 0)
+ // No official boards have this IC
+#endif
}
void startSmartCsPins() {
@@ -343,6 +351,9 @@ void startSmartCsPins() {
#if (BOARD_MC33810_COUNT > 0)
/* none of official boards has this IC */
#endif /* (BOARD_MC33810_COUNT > 0) */
+#if (BOARD_TLE9104_COUNT > 0)
+ // No official boards have this IC
+#endif
}
#endif /* EFI_PROD_CODE */
diff --git a/firmware/hw_layer/stepper.cpp b/firmware/hw_layer/stepper.cpp
index d0c943df7f..6c8661eeaa 100644
--- a/firmware/hw_layer/stepper.cpp
+++ b/firmware/hw_layer/stepper.cpp
@@ -58,7 +58,7 @@ void StepperMotorBase::changeCurrentPosition(bool positive) {
}
void StepperMotorBase::postCurrentPosition(void) {
- if (engineConfiguration->debugMode == DBG_IDLE_CONTROL) {
+ if (engineConfiguration->debugMode == DBG_STEPPER_IDLE_CONTROL) {
#if EFI_TUNER_STUDIO
engine->outputChannels.debugIntField5 = m_currentPosition;
#endif /* EFI_TUNER_STUDIO */
@@ -209,7 +209,7 @@ bool StepDirectionStepper::step(bool positive) {
void StepperMotor::initialize(StepperHw *hardware, int totalSteps) {
StepperMotorBase::initialize(hardware, totalSteps);
- Start();
+ start();
}
void StepDirectionStepper::initialize(brain_pin_e stepPin, brain_pin_e directionPin, pin_output_mode_e directionPinMode, float reactionTime, brain_pin_e enablePin, pin_output_mode_e enablePinMode) {
diff --git a/firmware/init/sensor/init_can_sensors.cpp b/firmware/init/sensor/init_can_sensors.cpp
index e85eac7fdd..f3904c8056 100644
--- a/firmware/init/sensor/init_can_sensors.cpp
+++ b/firmware/init/sensor/init_can_sensors.cpp
@@ -1,5 +1,7 @@
/**
* @file init_can_sensors.cpp
+ * body control unit use-case: inject many sensors from external ECU via ODB-II request/response
+ * this is totally different from Lua "set" sensor method
*
* @date March 31, 2020
* @author Matthew Kennedy, (c) 2020
diff --git a/firmware/init/sensor/init_thermistors.cpp b/firmware/init/sensor/init_thermistors.cpp
index fefe4817d2..b140f5ec74 100644
--- a/firmware/init/sensor/init_thermistors.cpp
+++ b/firmware/init/sensor/init_thermistors.cpp
@@ -26,7 +26,7 @@ static FuncPair fclt, fiat, faux1, faux2;
static void validateThermistorConfig(const char *msg, thermistor_conf_s& cfg) {
if (cfg.tempC_1 >= cfg.tempC_2 ||
cfg.tempC_2 >= cfg.tempC_3) {
- firmwareError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction, "Invalid thermistor %s configuration: please check that temperatures are in the ascending order %f %f %f",
+ firmwareError(OBD_ThermistorConfig, "Invalid thermistor %s configuration: please check that temperatures are in the ascending order %f %f %f",
msg,
cfg.tempC_1,
cfg.tempC_2,
diff --git a/firmware/init/sensor/init_tps.cpp b/firmware/init/sensor/init_tps.cpp
index 93fe3f6d5d..935d37a30c 100644
--- a/firmware/init/sensor/init_tps.cpp
+++ b/firmware/init/sensor/init_tps.cpp
@@ -62,7 +62,7 @@ private:
// If the voltage for closed vs. open is very near, something is wrong with your calibration
if (split < 0.5f) {
- firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "\"%s\" problem: open %.2f/closed %.2f cal values are too close together. Check your calibration and wiring!", name(),
+ firmwareError(OBD_TPS_Configuration, "\"%s\" problem: open %.2f/closed %.2f cal values are too close together. Check your calibration and wiring!", name(),
cfg.open,
cfg.closed);
return false;
@@ -91,6 +91,12 @@ public:
}
void init(bool isFordTps, RedundantFordTps* fordTps, const TpsConfig& primary, const TpsConfig& secondary) {
+ bool hasFirst = m_pri.init(primary);
+ if (!hasFirst) {
+ // no input if we have no first channel
+ return;
+ }
+
{
// Check that the primary and secondary aren't too close together - if so, the user may have done
// an unsafe thing where they wired a single sensor to both inputs. Don't do that!
@@ -99,13 +105,11 @@ public:
bool tooCloseOpen = absF(primary.open - secondary.open) < 0.2f;
if (hasBothSensors && tooCloseClosed && tooCloseOpen) {
- firmwareError(OBD_Throttle_Position_Sensor_Circuit_Malfunction, "Configuration for redundant pair %s/%s are too similar - did you wire one sensor to both inputs...?", m_pri.name(), m_sec.name());
+ firmwareError(OBD_TPS_Configuration, "Configuration for redundant pair %s/%s are too similar - did you wire one sensor to both inputs...?", m_pri.name(), m_sec.name());
return;
}
}
- m_pri.init(primary);
-
bool hasSecond = m_sec.init(secondary);
if (isFordTps && fordTps) {
diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt
index 4427913143..5948ca3881 100644
--- a/firmware/integration/rusefi_config.txt
+++ b/firmware/integration/rusefi_config.txt
@@ -141,10 +141,8 @@ struct_no_prefix engine_configuration_s
#define TOOTH_PACKET_SIZE 2
#define TOOTH_DATA_LENGTH @@TOOTH_PACKET_SIZE@@*@@TOOTH_PACKET_COUNT@@
-#define COMPOSITE_PACKET_COUNT 500
+#define COMPOSITE_PACKET_COUNT 1000
#define COMPOSITE_PACKET_SIZE 5
-#define COMPOSITE_DATA_LENGTH @@COMPOSITE_PACKET_SIZE@@*@@COMPOSITE_PACKET_COUNT@@
-#define COMPOSITE_DATA_LENGTH_HALF 1250
#define MAP_ANGLE_SIZE 8
#define MAP_WINDOW_SIZE 8
@@ -216,6 +214,9 @@ struct_no_prefix engine_configuration_s
#define TRIGGER_HAS_SECOND_CHANNEL "hasSecondChannel"
#define TRIGGER_HARDCODED_OPERATION_MODE "knownOperationMode"
#define TRIGGER_COMMENT "#"
+#define TRIGGER_GAPS_COUNT "gapsCount"
+#define TRIGGER_GAP_FROM "gapFrom"
+#define TRIGGER_GAP_TO "gapTo"
!
! all the xxx_PACKING_xxx constants are about persisting tables in compact for, for example packing RPM with 50 increment in a byte
@@ -303,7 +304,7 @@ float baseFuel;+Base mass of the per-cylinder fuel injected during cranking. Thi
int16_t rpm;+This sets the RPM limit below which the ECU will use cranking fuel and ignition logic, typically this is around 350-450rpm. \nset cranking_rpm X;"RPM", 1, 0, 0, 3000, 0
end_struct
-#define debug_mode_e_enum "INVALID", "TPS acceleration enrichment", "GPPWM", "Idle Control", "Engine Load accl enrich", "Trigger Counters", "Soft Spark Cut", "VVT1 PID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "SD card", "sr5", "Knock", "INVALID", "Electronic Throttle", "Executor", "Bench Test / TS commands", "INVALID", "Analog inputs #1", "INSTANT_RPM", "INVALID", "Status", "CJ125", "INVALID", "MAP", "Metrics", "INVALID", "Ion Sense", "TLE8888", "Analog inputs #2", "Dwell Metric", "INVALID", "INVALID", "Boost Control", "INVALID", "INVALID", "ETB Autotune", "Composite Log", "INVALID", "INVALID", "INVALID", "Dyno_View", "Logic_Analyzer", "INVALID", "TCU", "Lua", "VVT2 PID", "VVT3 PID", "VVT4 PID", "mode 52", "mode 53"
+#define debug_mode_e_enum "INVALID", "TPS acceleration enrichment", "INVALID", "Stepper Idle Control", "Engine Load accl enrich", "Trigger Counters", "Soft Spark Cut", "VVT1 PID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "SD card", "sr5", "Knock", "INVALID", "Electronic Throttle", "Executor", "Bench Test / TS commands", "INVALID", "Analog inputs #1", "INSTANT_RPM", "INVALID", "Status", "CJ125", "INVALID", "MAP", "Metrics", "INVALID", "Ion Sense", "TLE8888", "Analog inputs #2", "Dwell Metric", "INVALID", "INVALID", "Boost Control", "INVALID", "INVALID", "ETB Autotune", "Composite Log", "INVALID", "INVALID", "INVALID", "Dyno_View", "Logic_Analyzer", "INVALID", "TCU", "Lua", "VVT2 PID", "VVT3 PID", "VVT4 PID", "mode 52", "mode 53"
custom debug_mode_e 1 bits, U08, @OFFSET@, [0:5], @@debug_mode_e_enum@@
#define VM_VVT_INACTIVE 0
@@ -528,7 +529,11 @@ custom injection_mode_e 1 bits, U08, @OFFSET@, [0:1], "Simultaneous", "Sequentia
injection_mode_e crankingInjectionMode;+This is the injection strategy during engine start. See Fuel/Injection settings for more detail. It is suggested to use "Simultaneous".
injection_mode_e injectionMode;+This is where the fuel injection type is defined: "Simultaneous" means all injectors will fire together at once. "Sequential" fires the injectors on a per cylinder basis, which requires individually wired injectors. "Batched" will fire the injectors in groups. If your injectors are individually wired you will also need to enable "Two wire batch emulation". \nset injection_mode X\nSee also twoWireBatchInjection
-angle_t unusedHere1341234
+
+uint16_t boostControlMinRpm; Minimum RPM to enable boost control. Use this to avoid solenoid noise at idle, and help spool in some cases.;"", 1, 0, 0, 25000, 0
+uint8_t boostControlMinTps; Minimum TPS to enable boost control. Use this to avoid solenoid noise at idle, and help spool in some cases.;"", 1, 0, 0, 100, 0
+uint8_t boostControlMinMap; Minimum MAP to enable boost control. Use this to avoid solenoid noise at idle, and help spool in some cases.;"", 1, 0, 0, 250, 0
+
angle_t crankingTimingAngle;+Ignition advance angle used during engine cranking, 5-10 degrees will work as a base setting for most engines.\nThere is tapering towards running timing advance\nset cranking_timing_angle X;"deg", 1, 0, -30, 30, 0
custom ignition_mode_e 1 bits, U08, @OFFSET@, [0:1], "Single Coil", "Individual Coils", "Wasted Spark", "Two Distributors"
@@ -594,7 +599,7 @@ int unused460
custom spi_device_e 1 bits, U08, @OFFSET@, [0:2], "Off", "SPI1", "SPI2", "SPI3", "SPI4"
spi_device_e hip9011SpiDevice;
uint8_t failedMapFallback;Single value to be used in event of a failed MAP sensor \nThis value is only used for speed density fueling calculations.;"kPa", 1, 0, 0, 100, 0
- uint8_t boostControlSafeDutyCycle;+Duty cycle to use in case of a sensor failure. This duty cycle should produce the minimum possible amount of boost.;"%", 1, 0, 0, 100, 0
+ uint8_t boostControlSafeDutyCycle;+Duty cycle to use in case of a sensor failure. This duty cycle should produce the minimum possible amount of boost. This duty is also used in case any of the minimum RPM/TPS/MAP conditions are not met.;"%", 1, 0, 0, 100, 0
adc_channel_e mafAdcChannel
float globalFuelCorrection;set global_fuel_correction X;"coef", 1, 0, 0, 1000, 2
@@ -709,7 +714,7 @@ custom adc_channel_mode_e 1 bits, U08, @OFFSET@, [0:1], "Off", "Slow", "Fast"
float idle_antiwindupFreq;+0.1 is a good default value;"x", 1, 0, -1000000, 1000000, 4
brain_input_pin_e[TRIGGER_INPUT_PIN_COUNT iterate] triggerInputPins;
- uint16_t unused688
+ uint16_t mc33_t_min_boost;Minimum allowed time for the boost phase. If the boost target current is reached before this time elapses, it is assumed that the injector has failed short circuit.;"us", 1, 0, 0, 10000, 0
pin_output_mode_e hip9011CsPinMode;
output_pin_e tachOutputPin;
pin_output_mode_e tachOutputPinMode;
@@ -954,13 +959,13 @@ bit verboseCan2,"Print all","Do not print";Print incoming and outgoing second bu
antiLagActivationMode_e antiLagActivationMode;
int launchSpeedThreshold;+Disabled above this speed;"Kph", 1, 0, 0, 300, 0
- int launchTimingRpmRange;+Range from Launch Rpm for Timing Retard to activate;"RPM", 1, 0, 0, 8000, 0
+ int launchTimingRpmRange;Range from Launch RPM for Timing Retard to activate;"RPM", 1, 0, 0, 8000, 0
int launchFuelAdded;+Extra Fuel Added;"%", 1, 0, 0, 100, 0
int launchBoostDuty;+Duty Cycle for the Boost Solenoid;"%", 1, 0, 0, 100, 0
- int hardCutRpmRange;RPM Range for Hard Cut;"rpm", 1, 0, 0, 3000, 0
- int launchAdvanceRpmRange;;"rpm", 1, 0, 0, 20000, 0
- int launchTpsTreshold;;"rpm", 1, 0, 0, 20000, 0
- float launchActivateDelay;;"rpm", 1, 0, 0, 20000, 0
+ int hardCutRpmRange;Range from Launch RPM to activate Hard Cut;"RPM", 1, 0, 0, 3000, 0
+ int unused962
+ int launchTpsThreshold;;"", 1, 0, 0, 20000, 0
+ float launchActivateDelay;;"", 1, 0, 0, 20000, 0
stft_s stft
@@ -1007,7 +1012,7 @@ end_struct
bit isVerboseIAC;+Print details into rusEFI console\nenable verbose_idle
bit boardUseTachPullUp,"12v","5v"
bit boardUseTempPullUp,"With Pull Ups","Piggyback Mode"
- bit unused234234234
+ bit yesUnderstandLocking,"yes","no"
bit silentTriggerError;+Sometimes we have a performance issue while printing error
bit useLinearCltSensor
bit canReadEnabled;enable can_read/disable can_read
@@ -1030,8 +1035,8 @@ bit launchSparkCutEnable;+This is the Cut Mode normally used
bit boardUseD3PullDown,"With Pull Down","With Pull Up"
bit boardUseD4PullDown,"With Pull Down","With Pull Up"
bit boardUseD5PullDown,"With Pull Down","With Pull Up"
-bit useFSIO5ForCriticalIssueEngineStop;Sometimes we just have to shut the engine down. Use carefully!
-bit useFSIO4ForSeriousEngineWarning;Sometimes we have to miss injection on purpose to attract driver's attention
+bit unused443
+bit unused444
bit launchActivateInverted
bit twoStroke,"Two Stroke","Four Stroke"
bit skippedWheelOnCam,"On camshaft","On crankshaft";+Where is your primary skipped wheel located?
@@ -1410,7 +1415,7 @@ tChargeMode_e tChargeMode;
uint16_t mc33_i_boost;;"mA", 1, 0, 1000, 25000, 0
uint16_t mc33_i_peak;;"mA", 1, 0, 1000, 20000, 0
uint16_t mc33_i_hold;;"mA", 1, 0, 1000, 20000, 0
- uint16_t mc33_t_max_boost;;"us", 1, 0, 0, 10000, 0
+ uint16_t mc33_t_max_boost;Maximum allowed boost phase time. If the injector current doesn't reach the threshold before this time elapses, it is assumed that the injector is missing or has failed open circuit.;"us", 1, 0, 0, 10000, 0
uint16_t mc33_t_peak_off;;"us", 1, 0, 0, 10000, 0
uint16_t mc33_t_peak_tot;;"us", 1, 0, 0, 10000, 0
uint16_t mc33_t_bypass;;"us", 1, 0, 0, 10000, 0
@@ -1509,7 +1514,9 @@ pwm_freq_t tcu_32_solenoid_freq
float etbMinimumPosition;;"%", 1, 0, 0.01, 100, 2
-uint8_t[246] mainUnusedEnd;;"units", 1, 0, 0, 1, 0
+uint16_t tuneHidingKey;;"", 1, 0, 0, 20000, 0
+
+uint8_t[244] mainUnusedEnd;;"units", 1, 0, 0, 1, 0
! end of engine_configuration_s
end_struct
@@ -1922,12 +1929,15 @@ end_struct
! todo: replace with ts_command_e_ usages
#define CMD_TS_X14 20
+#define CMD_TS_WBO_UPDATE 0x15
! 0x16
#define CMD_TS_BENCH_CATEGORY 22
+#define CMD_KEYPAD 0x17
#define CMD_TS_LUA_OUTPUT_CATEGORY 33
#define CMD_TS_X31 49
#define CMD_TS_SOLENOID_CATEGORY 41
+#define CMD_ECU_UNLOCK "unlock"
#define CMD_ENGINE_TYPE "engine_type"
#define CMD_INJECTION "injection"
#define CMD_IGNITION "ignition"
diff --git a/firmware/libfirmware b/firmware/libfirmware
new file mode 160000
index 0000000000..112b0ec766
--- /dev/null
+++ b/firmware/libfirmware
@@ -0,0 +1 @@
+Subproject commit 112b0ec76630fdcf33321262c028122feff0d1e4
diff --git a/firmware/main_hardfault.c b/firmware/main_hardfault.c
index 70b933a599..5afdb17646 100644
--- a/firmware/main_hardfault.c
+++ b/firmware/main_hardfault.c
@@ -17,102 +17,110 @@
#define bkpt() __asm volatile("BKPT #0\n")
void NMI_Handler(void) {
- //TODO
- while(1);
+ NVIC_SystemReset();
}
//See http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/BABBGBEC.html
typedef enum {
- Reset = 1,
- NMI = 2,
- HardFault = 3,
- MemManage = 4,
- BusFault = 5,
- UsageFault = 6,
+ Reset = 1,
+ NMI = 2,
+ HardFault = 3,
+ MemManage = 4,
+ BusFault = 5,
+ UsageFault = 6,
} FaultType;
-void HardFault_Handler(void) {
- //Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info
- //Get thread context. Contains main registers including PC and LR
- struct port_extctx ctx;
- memcpy(&ctx, (void*)__get_PSP(), sizeof(struct port_extctx));
- (void)ctx;
- //Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
- FaultType faultType = (FaultType)__get_IPSR();
- (void)faultType;
- //For HardFault/BusFault this is the address that was accessed causing the error
- uint32_t faultAddress = SCB->BFAR;
- (void)faultAddress;
- //Flags about hardfault / busfault
- //See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
- bool isFaultPrecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 1) ? true : false);
- bool isFaultImprecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 2) ? true : false);
- bool isFaultOnUnstacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 3) ? true : false);
- bool isFaultOnStacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 4) ? true : false);
- bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 7) ? true : false);
- (void)isFaultPrecise;
- (void)isFaultImprecise;
- (void)isFaultOnUnstacking;
- (void)isFaultOnStacking;
- (void)isFaultAddressValid;
- //Cause debugger to stop. Ignored if no debugger is attached
- bkpt();
- NVIC_SystemReset();
+void logHardFault(uint32_t type, uintptr_t faultAddress, struct port_extctx* ctx, uint32_t csfr);
+
+void HardFault_Handler_C(void* sp) {
+ //Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info
+ //Get thread context. Contains main registers including PC and LR
+ struct port_extctx ctx;
+ memcpy(&ctx, sp, sizeof(struct port_extctx));
+
+ //Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
+ FaultType faultType = (FaultType)__get_IPSR();
+ (void)faultType;
+ //For HardFault/BusFault this is the address that was accessed causing the error
+ uint32_t faultAddress = SCB->BFAR;
+
+ //Flags about hardfault / busfault
+ //See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
+ bool isFaultPrecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 1) ? true : false);
+ bool isFaultImprecise = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 2) ? true : false);
+ bool isFaultOnUnstacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 3) ? true : false);
+ bool isFaultOnStacking = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 4) ? true : false);
+ bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos) & (1 << 7) ? true : false);
+ (void)isFaultPrecise;
+ (void)isFaultImprecise;
+ (void)isFaultOnUnstacking;
+ (void)isFaultOnStacking;
+ (void)isFaultAddressValid;
+
+ logHardFault(faultType, faultAddress, &ctx, SCB->CFSR >> SCB_CFSR_BUSFAULTSR_Pos);
+
+ //Cause debugger to stop. Ignored if no debugger is attached
+ bkpt();
+ NVIC_SystemReset();
}
-void BusFault_Handler(void) __attribute__((alias("HardFault_Handler")));
+void UsageFault_Handler_C(void* sp) {
+ //Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info
+ //Get thread context. Contains main registers including PC and LR
+ struct port_extctx ctx;
+ memcpy(&ctx, sp, sizeof(struct port_extctx));
-void UsageFault_Handler(void) {
- //Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info
- //Get thread context. Contains main registers including PC and LR
- struct port_extctx ctx;
- memcpy(&ctx, (void*)__get_PSP(), sizeof(struct port_extctx));
- (void)ctx;
- //Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
- FaultType faultType = (FaultType)__get_IPSR();
- (void)faultType;
- //Flags about hardfault / busfault
- //See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
- bool isUndefinedInstructionFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 0) ? true : false);
- bool isEPSRUsageFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 1) ? true : false);
- bool isInvalidPCFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 2) ? true : false);
- bool isNoCoprocessorFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 3) ? true : false);
- bool isUnalignedAccessFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 8) ? true : false);
- bool isDivideByZeroFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 9) ? true : false);
- (void)isUndefinedInstructionFault;
- (void)isEPSRUsageFault;
- (void)isInvalidPCFault;
- (void)isNoCoprocessorFault;
- (void)isUnalignedAccessFault;
- (void)isDivideByZeroFault;
- bkpt();
- NVIC_SystemReset();
+ //Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
+ FaultType faultType = (FaultType)__get_IPSR();
+ (void)faultType;
+ //Flags about hardfault / busfault
+ //See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
+ bool isUndefinedInstructionFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 0) ? true : false);
+ bool isEPSRUsageFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 1) ? true : false);
+ bool isInvalidPCFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 2) ? true : false);
+ bool isNoCoprocessorFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 3) ? true : false);
+ bool isUnalignedAccessFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 8) ? true : false);
+ bool isDivideByZeroFault = ((SCB->CFSR >> SCB_CFSR_USGFAULTSR_Pos) & (1 << 9) ? true : false);
+ (void)isUndefinedInstructionFault;
+ (void)isEPSRUsageFault;
+ (void)isInvalidPCFault;
+ (void)isNoCoprocessorFault;
+ (void)isUnalignedAccessFault;
+ (void)isDivideByZeroFault;
+
+ logHardFault(faultType, 0, &ctx, SCB->CFSR);
+
+ bkpt();
+ NVIC_SystemReset();
}
-void MemManage_Handler(void) {
- //Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info
- //Get thread context. Contains main registers including PC and LR
- struct port_extctx ctx;
- memcpy(&ctx, (void*)__get_PSP(), sizeof(struct port_extctx));
- (void)ctx;
- //Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
- FaultType faultType = (FaultType)__get_IPSR();
- (void)faultType;
- //For HardFault/BusFault this is the address that was accessed causing the error
- uint32_t faultAddress = SCB->MMFAR;
- (void)faultAddress;
- //Flags about hardfault / busfault
- //See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
- bool isInstructionAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 0) ? true : false);
- bool isDataAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 1) ? true : false);
- bool isExceptionUnstackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 3) ? true : false);
- bool isExceptionStackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 4) ? true : false);
- bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 7) ? true : false);
- (void)isInstructionAccessViolation;
- (void)isDataAccessViolation;
- (void)isExceptionUnstackingFault;
- (void)isExceptionStackingFault;
- (void)isFaultAddressValid;
- bkpt();
- NVIC_SystemReset();
+void MemManage_Handler_C(void* sp) {
+ //Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info
+ //Get thread context. Contains main registers including PC and LR
+ struct port_extctx ctx;
+ memcpy(&ctx, sp, sizeof(struct port_extctx));
+
+ //Interrupt status register: Which interrupt have we encountered, e.g. HardFault?
+ FaultType faultType = (FaultType)__get_IPSR();
+ (void)faultType;
+ //For HardFault/BusFault this is the address that was accessed causing the error
+ uint32_t faultAddress = SCB->MMFAR;
+
+ //Flags about hardfault / busfault
+ //See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Cihdjcfc.html for reference
+ bool isInstructionAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 0) ? true : false);
+ bool isDataAccessViolation = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 1) ? true : false);
+ bool isExceptionUnstackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 3) ? true : false);
+ bool isExceptionStackingFault = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 4) ? true : false);
+ bool isFaultAddressValid = ((SCB->CFSR >> SCB_CFSR_MEMFAULTSR_Pos) & (1 << 7) ? true : false);
+ (void)isInstructionAccessViolation;
+ (void)isDataAccessViolation;
+ (void)isExceptionUnstackingFault;
+ (void)isExceptionStackingFault;
+ (void)isFaultAddressValid;
+
+ logHardFault(faultType, faultAddress, &ctx, SCB->CFSR);
+
+ bkpt();
+ NVIC_SystemReset();
}
diff --git a/firmware/main_hardfault_asm.S b/firmware/main_hardfault_asm.S
new file mode 100644
index 0000000000..bd7f6eb9e6
--- /dev/null
+++ b/firmware/main_hardfault_asm.S
@@ -0,0 +1,35 @@
+.syntax unified
+.cpu cortex-m3
+.thumb
+.align 2
+.thumb_func
+
+.type HardFault_Handler, %function
+.type UsageFault_Handler, %function
+.type MemManage_Handler, %function
+
+.global HardFault_Handler
+.global BusFault_Handler
+HardFault_Handler:
+BusFault_Handler:
+ tst LR, #4
+ ite EQ
+ mrseq R0, MSP
+ mrsne R0, PSP
+ b HardFault_Handler_C
+
+.global UsageFault_Handler
+UsageFault_Handler:
+ tst LR, #4
+ ite EQ
+ mrseq R0, MSP
+ mrsne R0, PSP
+ b UsageFault_Handler_C
+
+.global MemManage_Handler
+MemManage_Handler:
+ tst LR, #4
+ ite EQ
+ mrseq R0, MSP
+ mrsne R0, PSP
+ b MemManage_Handler_C
diff --git a/firmware/pch/pch.h b/firmware/pch/pch.h
index 1dd48a2b93..c39c1cc3b2 100644
--- a/firmware/pch/pch.h
+++ b/firmware/pch/pch.h
@@ -17,6 +17,13 @@
#define TRUE (!(FALSE))
#endif /* TRUE */
+#include
+#include
+#include
+#include
+#include
+#include
+
#include "efifeatures.h"
#include "rusefi_generated.h"
#include "loggingcentral.h"
diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp
index 4c7d09ddb1..ece3016bd7 100644
--- a/firmware/rusefi.cpp
+++ b/firmware/rusefi.cpp
@@ -156,7 +156,7 @@ void rebootNow() {
* Some configuration changes require full firmware reset.
* Once day we will write graceful shutdown, but that would be one day.
*/
-static void scheduleReboot() {
+void scheduleReboot() {
efiPrintf("Rebooting in 3 seconds...");
chibios_rt::CriticalSectionLocker csl;
chVTSetI(&resetTimer, TIME_MS2I(3000), (vtfunc_t) rebootNow, NULL);
@@ -170,10 +170,9 @@ void onAssertionFailure() {
}
void runRusEfiWithConfig();
-void runMainLoop();
+__NO_RETURN void runMainLoop();
void runRusEfi() {
- efiAssertVoid(CUSTOM_RM_STACK_1, getCurrentRemainingStack() > 512, "init s");
engine->setConfig();
#if EFI_TEXT_LOGGING
@@ -181,6 +180,10 @@ void runRusEfi() {
startLoggingProcessor();
#endif
+#if EFI_PROD_CODE
+ checkLastBootError();
+#endif
+
#ifdef STM32F7
void sys_dual_bank(void);
addConsoleAction("dual_bank", sys_dual_bank);
@@ -308,8 +311,6 @@ void runMainLoop() {
* control is around main_trigger_callback
*/
while (true) {
- efiAssertVoid(CUSTOM_RM_STACK, getCurrentRemainingStack() > 128, "stack#1");
-
#if EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE
// sensor state + all pending messages for our own rusEfi console
// todo: is this mostly dead code?
diff --git a/firmware/rusefi.h b/firmware/rusefi.h
index c4fb86bc48..9f12590f75 100644
--- a/firmware/rusefi.h
+++ b/firmware/rusefi.h
@@ -7,5 +7,5 @@
#pragma once
-void runRusEfi();
-void rebootNow();
+__NO_RETURN void runRusEfi();
+__NO_RETURN void rebootNow();
diff --git a/firmware/rusefi.mk b/firmware/rusefi.mk
index 28fa24070e..ecfa678bc5 100644
--- a/firmware/rusefi.mk
+++ b/firmware/rusefi.mk
@@ -1,14 +1,15 @@
ifeq ("$(wildcard $(RULESFILE))","")
-$(info Chibios: Invoking "git submodule update --init")
+$(info $(RULESFILE) not found. Chibios: Invoking "git submodule update --init")
$(shell git submodule update --init)
$(info Invoked "git submodule update --init")
# make is not happy about newly checked out module for some reason but next invocation would work
$(error Please run 'make' again. Please make sure you have 'git' command in PATH)
endif
-ifeq ("$(wildcard $(CHIBIOS_CONTRIB)/os/hal/hal.mk)","")
-$(info Contrib: Invoking "git submodule update --init")
+CHIBIOS_CONTRIB_FILE=$(CHIBIOS_CONTRIB)/os/hal/hal.mk
+ifeq ("$(wildcard $(CHIBIOS_CONTRIB_FILE))","")
+$(info $(CHIBIOS_CONTRIB_FILE) not found. Contrib: Invoking "git submodule update --init")
$(shell git submodule update --init)
$(info Invoked "git submodule update --init")
# make is not happy about newly checked out module for some reason but next invocation would work
diff --git a/firmware/svnversion.h b/firmware/svnversion.h
index 38b70b76b9..4633665b18 100644
--- a/firmware/svnversion.h
+++ b/firmware/svnversion.h
@@ -1,12 +1,12 @@
// This file was generated by Version2Header
-// Sun Jul 03 00:23:44 UTC 2022
+// Fri Aug 05 00:28:20 UTC 2022
#ifndef GIT_HASH
-#define GIT_HASH "0b10f7dca81603924d6cff9a143a7aba8c8d8cf5"
+#define GIT_HASH "6d59fc9d8d224fc19832ab01bf53d1c39662a65a"
#endif
#ifndef VCS_VERSION
-#define VCS_VERSION "41518"
+#define VCS_VERSION "44688"
#endif
diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input
index 10b6f0d01d..36afec60e2 100644
--- a/firmware/tunerstudio/rusefi.input
+++ b/firmware/tunerstudio/rusefi.input
@@ -89,7 +89,6 @@ enable2ndByteCanID = false
; this section will be generated automatically by ConfigDefinition.jar based on rusefi_config.txt
; CONFIG_DEFINITION_END
- idleRpmPid_offset = "Constant base value"
[Tuning]
spotDepth = 2 ; 0 = no indicators, 1 = Z only, 2 = XYZ indicators.
@@ -118,8 +117,6 @@ enable2ndByteCanID = false
dataReadTimeout = 10000 ; time in ms
dataReadyCondition = { toothLogReady }
continuousRead = true
- ; each packet is @@COMPOSITE_PACKET_SIZE@@ and we have @@COMPOSITE_PACKET_COUNT@@ of those
- dataLength = @@COMPOSITE_DATA_LENGTH_HALF@@
;tooth
; recordDef = headerLen, footerLen, recordLen
@@ -211,14 +208,14 @@ enable2ndByteCanID = false
; wall of debug mode :)
; https://rusefi.com/wiki/index.php?title=Manual:Debug_fields
-; Alternator TPS Acceleration GPPWM Idle Engine Load Acc Trigger Counters VVT1 PID Cranking Ignition Timing Fu Corr VSS SD Card Knock Wall Wetting ETB PID Executor InstantRpm CJ125 CAN MAP TLE8888 Analog inputs 2 Start ETB Autotune DYNO_VIEW LOGIC_ANALYZER Wideband TCU Lua VVT2 PID VVT3 PID VVT4 PID
+; Alternator TPS Acceleration Idle Engine Load Acc Trigger Counters VVT1 PID Cranking Ignition Timing Fu Corr VSS SD Card Knock Wall Wetting ETB PID Executor InstantRpm CJ125 CAN MAP TLE8888 Analog inputs 2 Start ETB Autotune DYNO_VIEW LOGIC_ANALYZER Wideband TCU Lua VVT2 PID VVT3 PID VVT4 PID
; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
-; DBG_ALTERNATOR_PID DBG_TPS_ACCEL DBG_GPPWM DBG_IDLE_CONTROL
- debugFieldF1List = bits, U08, [0:7], "Alt: Controller Output", "From TPS", "GPPWM 1", "Idle: Controller Output", "Idle output", " ", "", "VVT1: Controller Output"," ", "", "Ign IAT Corr", "", "", "Total SD", "last volts", "", "WW: Alpha", "ETB Controller Output", "", "", "df1", "df1", "InstantRpm", "", "24:df1", "CJ125: output", "", "MAP Average", "", "", "", "", "TPS1 Pri/Sec Diff", "", "", "", "","S unused" "", "Osc Amplitude", "", "", "", "" , "VSS", "", "WB: Pump DAC duty", "", "Lua Debug 1", "VVT2: Controller Output","VVT3: Controller Output","VVT4: Controller Output"
- debugFieldF2List = bits, U08, [0:7], "Alt: I Term", "To TPS", "GPPWM 2", "Idle: I Term", "Idle df2", " ", "", "VVT1: I Term", " ", "", "Ign CLT Corr", "", "", "Write Cnt","last filtered","", "WW: Beta", "ETB I Term", "", "", "df2", "df2", "InstantRPM Ratio","", "24:df2", "CJ125: i term", "", "MAP Duration", "", "", "", "", "TPS2 Pri/Sec Diff", "", "", "", "","S unused" "", "Duty Amplitude", "", "", "", "" , "Speed", "", "WB: ESR", "", "Lua Debug 2", "VVT2: I Term", "VVT3: I Term", "VVT4: I Term"
- debugFieldF3List = bits, U08, [0:7], "Alt: Previous Error", "Current TPS<>TPS", "GPPWM 3", "Idle: prev error", "Idle df3", "ICU sum", "", "VVT1: prev error", "", "", "", "", "", "Sync Cnt", "", "", "WW: film mass", "ETB err", "", "", "df3", "df3", "22df3", "", "24:df3", "CJ125: err", "", "MAP Fast", "", "", "", "", "TPS1/2 Diff", "", "", "", "","S unused" "", "Tu", "", "", "", "" , "DeltaSpeed", "", "WB: Nernst Voltage", "", "Lua Debug 3", "VVT2: prev error", "VVT3: prev error", "VVT4: prev error"
- debugFieldF4List = bits, U08, [0:7], "Alt: I Gain", "Extra Fuel", "GPPWM 4", "Idle: I Gain", "Idle df4", " ", "", "VVT1: I Gain", "", "", "Ign PID Adj", "", "", "File Cnt", "", "", "WW: m_cmd", "ETB I setting", "", "", "df4", "df4", "22df4", "", "24:df4", "CJ125: UA", "", "MAP Estimate", "", "", "", "", "Acc Pedal Pri/Sec Diff","", "", "", "","S unused" "", "Ku", "", "", "", "", "accel", "", "WB: Lambda", "", "Lua Debug 4", "VVT2: I Gain", "VVT3: I Gain", "VVT4: I Gain"
- debugFieldF5List = bits, U08, [0:7], "Alt: D Gain", "df5", "df5", "Idle: D Gain", "Idle df5", " ", "df5", "VVT1: D Gain", "", "", "", "", "", "", "", "", "WW: film mass next","ETB D setting", "df5", "df5", "df5", "df5", "22df5", "", "24:df5", "CJ125: UR", "", "MAP Instant", "", "", "", "", "TPS1 Pri/Sec Ratio", "", "", "", "","S unused" "", "Kp", "", "", "", "", "", "", "", "", "Lua Debug 5", "VVT2: D Gain", "VVT3: D Gain", "VVT4: D Gain"
+; DBG_ALTERNATOR_PID DBG_TPS_ACCEL DBG_IDLE_CONTROL
+ debugFieldF1List = bits, U08, [0:7], "Alt: Controller Output", "From TPS", "", "Idle: Controller Output", "Idle output", " ", "", "VVT1: Controller Output"," ", "", "Ign IAT Corr", "", "", "Total SD", "last volts", "", "WW: Alpha", "ETB Controller Output", "", "", "df1", "df1", "InstantRpm", "", "24:df1", "CJ125: output", "", "MAP Average", "", "", "", "", "TPS1 Pri/Sec Diff", "", "", "", "","S unused" "", "Osc Amplitude", "", "", "", "" , "VSS", "", "WB: Pump DAC duty", "", "Lua Debug 1", "VVT2: Controller Output","VVT3: Controller Output","VVT4: Controller Output"
+ debugFieldF2List = bits, U08, [0:7], "Alt: I Term", "To TPS", "", "Idle: I Term", "Idle df2", " ", "", "VVT1: I Term", " ", "", "Ign CLT Corr", "", "", "Write Cnt","last filtered","", "WW: Beta", "ETB I Term", "", "", "df2", "df2", "InstantRPM Ratio","", "24:df2", "CJ125: i term", "", "MAP Duration", "", "", "", "", "TPS2 Pri/Sec Diff", "", "", "", "","S unused" "", "Duty Amplitude", "", "", "", "" , "Speed", "", "WB: ESR", "", "Lua Debug 2", "VVT2: I Term", "VVT3: I Term", "VVT4: I Term"
+ debugFieldF3List = bits, U08, [0:7], "Alt: Previous Error", "Current TPS<>TPS", "", "Idle: prev error", "Idle df3", "ICU sum", "", "VVT1: prev error", "", "", "", "", "", "Sync Cnt", "", "", "WW: film mass", "ETB err", "", "", "df3", "df3", "22df3", "", "24:df3", "CJ125: err", "", "MAP Fast", "", "", "", "", "TPS1/2 Diff", "", "", "", "","S unused" "", "Tu", "", "", "", "" , "DeltaSpeed", "", "WB: Nernst Voltage", "", "Lua Debug 3", "VVT2: prev error", "VVT3: prev error", "VVT4: prev error"
+ debugFieldF4List = bits, U08, [0:7], "Alt: I Gain", "Extra Fuel", "", "Idle: I Gain", "Idle df4", " ", "", "VVT1: I Gain", "", "", "Ign PID Adj", "", "", "File Cnt", "", "", "WW: m_cmd", "ETB I setting", "", "", "df4", "df4", "22df4", "", "24:df4", "CJ125: UA", "", "MAP Estimate", "", "", "", "", "Acc Pedal Pri/Sec Diff","", "", "", "","S unused" "", "Ku", "", "", "", "", "accel", "", "WB: Lambda", "", "Lua Debug 4", "VVT2: I Gain", "VVT3: I Gain", "VVT4: I Gain"
+ debugFieldF5List = bits, U08, [0:7], "Alt: D Gain", "df5", "", "Idle: D Gain", "Idle df5", " ", "df5", "VVT1: D Gain", "", "", "", "", "", "", "", "", "WW: film mass next","ETB D setting", "df5", "df5", "df5", "df5", "22df5", "", "24:df5", "CJ125: UR", "", "MAP Instant", "", "", "", "", "TPS1 Pri/Sec Ratio", "", "", "", "","S unused" "", "Kp", "", "", "", "", "", "", "", "", "Lua Debug 5", "VVT2: D Gain", "VVT3: D Gain", "VVT4: D Gain"
debugFieldF6List = bits, U08, [0:7], "Alt: D Term", "", "", "Idle: D Term", "Idle df6", " ", "", "VVT1: D Term", "", "", "", "", "", "", "", "", "", "ETB df6", "", "", "df6", "df6", "22df6", "", "24:df6", "cj: f7", "", "", "", "", "", "", "", "", "", "", "","S unused" "", "Ki", "", "", "", "", "", "", "", "", "Lua Debug 6", "VVT2: D Term", "VVT3: D Term", "VVT4: D Term"
debugFieldF7List = bits, U08, [0:7], "Alt: Max-Value", "", "", "Idle: Max-Value", "Idle df7", "", "", "VVT1: Max-Value", "", "", "", "", "", "", "", "", "", "ETB df7", "", "", "df7", "df7", "22df7", "", "24:df7", "cj: f7", "", "", "", "", "", "", "", "", "", "", "","S unused" "", "Kd", "", "", "", "", "", "", "", "", "Lua Debug 7", "", "", ""
debugFieldI1List = bits, U08, [0:7], "Alt: P Gain", "", "", "Idle: P Gain", "Idle di1", " ", "", "VVT1: P Gain", " ", "Cycle Counter", "Multispark Count", "", "", "", "hip corr", "", "", "ETB P-Gain", "t counter", "", "di1", "di1", "Spark Event Gap","", "24:di1", "CJ125: state", "read count","MAP counter", "", "", "", "SPI Counter", "", "", "", "", "","Start Count", "", "", "", "", "", "", "deltatime", "", "", "Solenoid 1 State", "Lua memory used","VVT2: P Gain", "VVT3: P Gain", "VVT4: P Gain"
@@ -1036,21 +1033,21 @@ luaLastCycleDurationGauge = luaLastCycleDuration,"luaLastCycleDuration", "nt", 0
testBenchIterGauge = testBenchIter, "Test Bench Iterations", "count", -10, {benchTestCount + 10}, -5, 0, {benchTestCount}, {benchTestCount + 5}, 1, 1
gaugeCategory = PIDs
-alternatorStatus_iTermGauge = alternatorStatus_iTerm,"alternatorStatus_ iTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-alternatorStatus_dTermGauge = alternatorStatus_dTerm,"alternatorStatus_ dTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-alternatorStatus_outputGauge = alternatorStatus_output,"alternatorStatus_ output", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-alternatorStatus_errorGauge = alternatorStatus_error,"alternatorStatus_ error", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-alternatorStatus_resetCounterGauge = alternatorStatus_resetCounter,"alternatorStatus_ resetCounter", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 0,0
-idleStatus_iTermGauge = idleStatus_iTerm,"idleStatus_ iTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-idleStatus_dTermGauge = idleStatus_dTerm,"idleStatus_ dTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-idleStatus_outputGauge = idleStatus_output,"idleStatus_ output", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-idleStatus_errorGauge = idleStatus_error,"idleStatus_ error", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-idleStatus_resetCounterGauge = idleStatus_resetCounter,"idleStatus_ resetCounter", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 0,0
-etbStatus_iTermGauge = etbStatus_iTerm,"etbStatus_ iTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-etbStatus_dTermGauge = etbStatus_dTerm,"etbStatus_ dTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-etbStatus_outputGauge = etbStatus_output,"etbStatus_ output", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-etbStatus_errorGauge = etbStatus_error,"etbStatus_ error", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
-etbStatus_resetCounterGauge = etbStatus_resetCounter,"etbStatus_ resetCounter", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 0,0
+alternatorStatus_iTermGauge = alternatorStatus_iTerm,"Alternator PID iTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+alternatorStatus_dTermGauge = alternatorStatus_dTerm,"Alternator PID dTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+alternatorStatus_outputGauge = alternatorStatus_output,"Alternator PID output", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+alternatorStatus_errorGauge = alternatorStatus_error,"Alternator PID error", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+alternatorStatus_resetCounterGauge = alternatorStatus_resetCounter,"Alternator PID resetCounter", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 0,0
+idleStatus_iTermGauge = idleStatus_iTerm,"Idle PID iTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+idleStatus_dTermGauge = idleStatus_dTerm,"Idle PID dTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+idleStatus_outputGauge = idleStatus_output,"Idle PID output", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+idleStatus_errorGauge = idleStatus_error,"Idle PID error", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+idleStatus_resetCounterGauge = idleStatus_resetCounter,"Idle PID resetCounter", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 0,0
+etbStatus_iTermGauge = etbStatus_iTerm,"ETB 1 PID iTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+etbStatus_dTermGauge = etbStatus_dTerm,"ETB 1 PID dTerm", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+etbStatus_outputGauge = etbStatus_output,"ETB 1 PID output", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+etbStatus_errorGauge = etbStatus_error,"ETB 1 PID error", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
+etbStatus_resetCounterGauge = etbStatus_resetCounter,"ETB 1 PID resetCounter", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 0,0
canReadCounterGauge = canReadCounter,"canReadCounter", "", 0.0,0.0, 0.0,0.0, 0.0,0.0, 0,0
canWriteOkGauge = canWriteOk,"canWriteOk", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
canWriteNotOkGauge = canWriteNotOk,"canWriteNotOk", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
@@ -1067,8 +1064,9 @@ di_nextStartGauge = di_nextStart,"DI: next start", "v", 0.0,100.0, 0.0,100.0, 0.
m_requested_pumpGauge = m_requested_pump,"DI: Pump Angle", "deg", 0.0,0.0, 0.0,0.0, 0.0,0.0, 0,0
fuel_requested_percentGauge = fuel_requested_percent,"DI: fuel_requested_percent", "v", 0.0,100.0, 0.0,100.0, 0.0,100.0, 0,0
fuel_requested_percent_piGauge = fuel_requested_percent_pi,"DI: fuel_requested_percent_pi", "v", 0.0,100.0, 0.0,100.0, 0.0,100.0, 0,0
-m_I_sum_percentGauge = m_I_sum_percent,"DI: m_I_sum_percent", "v", 0.0,100.0, 0.0,100.0, 0.0,100.0, 0,0
-m_pressureTarget_kPaGauge = m_pressureTarget_kPa,"DI: m_pressureTarget_kPa", "v", 0.0,100.0, 0.0,100.0, 0.0,100.0, 0,0
+;todo see comment in HpfpQuantity class definition
+;m_I_sum_percentGauge = m_I_sum_percent,"DI: m_I_sum_percent", "v", 0.0,100.0, 0.0,100.0, 0.0,100.0, 0,0
+;m_pressureTarget_kPaGauge = m_pressureTarget_kPa,"DI: m_pressureTarget_kPa", "v", 0.0,100.0, 0.0,100.0, 0.0,100.0, 0,0
highFuelPressureGauge = highFuelPressure, @@GAUGE_NAME_FUEL_PRESSURE_HIGH@@, @@GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS@@, 0, 200, 0, 0, 200, 200, 1, 0
gaugeCategory = Sensors - Extra 2
@@ -1211,6 +1209,14 @@ gaugeCategory = Sensors - Raw
rawTps1SecondaryGauge = rawTps1Secondary, "Raw TPS 1 Secondary", "V", 0, 5, 0, 0, 5, 5, 3, 0
rawTps2PrimaryGauge = rawTps2Primary, "Raw TPS 2 Primary", "V", 0, 5, 0, 0, 5, 5, 3, 0
rawTps2SecondaryGauge = rawTps2Secondary, "Raw TPS 2 Secondary", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput1Gauge = rawAnalogInput1, "Raw Aux 1", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput2Gauge = rawAnalogInput2, "Raw Aux 2", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput3Gauge = rawAnalogInput3, "Raw Aux 3", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput4Gauge = rawAnalogInput4, "Raw Aux 4", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput5Gauge = rawAnalogInput5, "Raw Aux 5", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput6Gauge = rawAnalogInput6, "Raw Aux 6", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput7Gauge = rawAnalogInput7, "Raw Aux 7", "V", 0, 5, 0, 0, 5, 5, 3, 0
+ rawAnalogInput8Gauge = rawAnalogInput8, "Raw Aux 8", "V", 0, 5, 0, 0, 5, 5, 3, 0
rawPpsPrimaryGauge = rawPpsPrimary , "Raw Pedal Primary", "V", 0, 5, 0, 0, 5, 5, 3, 0
rawPpsSecondaryGauge = rawPpsSecondary,"Raw Pedal Secondary","V",0, 5, 0, 0, 5, 5, 3, 0
rawCltGauge = rawClt , "Raw CLT", "V", 0, 5, 0, 0, 5, 5, 3, 0
@@ -1255,6 +1261,12 @@ gaugeCategory = Knock
gaugeCategory = DynoView
accelGauge = VssAcceleration, "Vehicle acceleration", "m/s2", -10, 10, -6, -4, 4, 6, 2, 2
+gaugeCategory = Outputs
+ gppwmGauge = gppwmOutput1, "GPPWM Output 1", "%", 0, 100, 0, 0, 100, 100, 1, 1
+ gppwmGauge = gppwmOutput2, "GPPWM Output 2", "%", 0, 100, 0, 0, 100, 100, 1, 1
+ gppwmGauge = gppwmOutput3, "GPPWM Output 3", "%", 0, 100, 0, 0, 100, 100, 1, 1
+ gppwmGauge = gppwmOutput4, "GPPWM Output 4", "%", 0, 100, 0, 0, 100, 100, 1, 1
+
[WueAnalyze]
; wueCurveName, afrTempCompensationCurve, lambdaTargetTableName, lambdaChannel, coolantTempChannel, egoCorrectionChannel, wueChannel, activeCondition
@@ -1391,13 +1403,14 @@ menuDialog = main
# Digital outputs
subMenu = mainRelayDialog, "Main relay"
- subMenu = starterRelay, "Starter Disable relay"
subMenu = fuelPump, "Fuel pump"
- subMenu = fanSetting, "Fan"
+ subMenu = fanSetting, "Radiator Fan"
subMenu = acSettings, "Air Conditioning"
subMenu = tachSettings, "Tachometer"
subMenu = malfunction, "Check engine light"
subMenu = statusLeds, "Status LEDs"
+ subMenu = startStopDialog, "Start Button"
+ subMenu = starterRelay, "Starter Disable relay"
menu = "Fuel"
# basic
@@ -1545,7 +1558,7 @@ menuDialog = main
subMenu = vvtTable2Tbl, "VVT exhaust target", { vvtMode2 != @@vvt_mode_e_VVT_INACTIVE@@ }
subMenu = std_separator
- subMenu = auxInputsDialog, "Aux inputs"
+ subMenu = auxInputsDialog, "Lua Analog Inputs"
subMenu = luaOutputs, "Lua Script PWM Outputs"
subMenu = scriptSetting, "Lua Script Settings"
@@ -1771,6 +1784,8 @@ cmd_stop_engine = "@@TS_IO_TEST_COMMAND_char@@\x00\x79\x00\x00"
cmd_reset_controller = "@@TS_IO_TEST_COMMAND_char@@\x00\xbb\x00\x00"
; jump to DFU mode
cmd_dfu = "@@TS_IO_TEST_COMMAND_char@@\x00\xba\x00\x00"
+; jump to OpenBLT bootloader
+cmd_openblt = "@@TS_IO_TEST_COMMAND_char@@\x00\xbc\x00\x00"
; See 'executeTSCommand' in firmware source code
@@ -1967,7 +1982,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
; see also in firmware '[doesTriggerImplyOperationMode]' tag
field = "What kind of engine", twoStroke
- field = "Skipped wheel location", skippedWheelOnCam, { twoStroke == 0 && (@@TRIGGER_TYPE_WITHOUT_KNOWN_LOCATION@@) }
+ field = "Skipped wheel location", skippedWheelOnCam, { twoStroke == 0 && (trigger_type == @@trigger_type_e_TT_TOOTHED_WHEEL@@ || @@TRIGGER_TYPE_WITHOUT_KNOWN_LOCATION@@) }
field = "With VR sensors only rising edge has reliable position"
field = "use only rising edge", useOnlyRisingEdgeForTrigger
field = "!Reminder that 4-stroke cycle is 720 degrees"
@@ -2246,7 +2261,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "TPS minimum valid value", tpsErrorDetectionTooLow, {tps1_1AdcChannel != @@ADC_CHANNEL_NONE@@}
field = "TPS maximum valid value", tpsErrorDetectionTooHigh, {tps1_1AdcChannel != @@ADC_CHANNEL_NONE@@}
- dialog = tpsSensorLeft, "TPS"
+ dialog = tpsSensorLeft
panel = tpsLimits
panel = tpsNum1
panel = tpsNum2
@@ -2276,7 +2291,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
panel = pedalSensorLeft, West
panel = pedalGauges, East
- dialog = tpsSensor, "TPS", border
+ dialog = tpsSensor, "", border
panel = tpsSensorLeft, West
panel = tpsGauges, East
@@ -2313,15 +2328,16 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Boost voltage", mc33_hvolt
field = "Boost current target", mc33_i_boost
+ field = "Min boost time", mc33_t_min_boost
field = "Max boost time (timeout)", mc33_t_max_boost
- field = "Boost -> Peak Bypass Time", mc33_t_peak_off
- field = "Peak current target", mc33_i_peak
- field = "Peak time", mc33_t_peak_tot
+ field = "Peak phase current target", mc33_i_peak
+ field = "Peak phase duration", mc33_t_peak_tot
+ field = "Peak phase loop off time", mc33_t_peak_off
field = "Peak -> Hold Bypass Time", mc33_t_bypass
field = "Hold current target", mc33_i_hold
- field = "Hold off time", mc33_t_hold_off
+ field = "Hold phase loop off time", mc33_t_hold_off
field = "Maximum injection duration", mc33_t_hold_tot
@@ -2830,7 +2846,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "derivativeFilterLoss", idle_derivativeFilterLoss
field = "antiwindupFreq", idle_antiwindupFreq
field = "D-factor", idleRpmPid_dFactor
- field = "Offset", idleRpmPid_offset
field = "Min", idleRpmPid_minValue
field = "Max", idleRpmPid_maxValue
field = "iTerm Min", idlerpmpid_iTermMin
@@ -3159,7 +3174,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
dialog = energySystems, "Battery and Alternator Settings", yAxis
panel = batteryDialog@@if_ts_show_vbatt
panel = alternator
- panel = startStopDialog
dialog = speedSensorAnalog, "Speed sensor"
field = "Input pin", vehicleSpeedSensorInputPin
@@ -3434,7 +3448,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
dialog = scriptSettingDialog, "Script Settings", border
panel = scriptSetting, East
- dialog = auxInputsDialog, "Aux Analog Inputs"
+ dialog = auxInputsDialog, "Lua Analog Inputs"
field = "ADC #1", auxAnalogInputs1
field = "ADC #2", auxAnalogInputs2
field = "ADC #3", auxAnalogInputs3
@@ -3533,6 +3547,9 @@ dialog = tcuControls, "Transmission Settings"
field = "Output Mode", boostControlPinMode, { isBoostControlEnabled }
field = "Frequency", boostPwmFrequency, { isBoostControlEnabled }
field = "Safe duty cycle", boostControlSafeDutyCycle, { isBoostControlEnabled }
+ field = "No boost control below RPM", boostControlMinRpm, { isBoostControlEnabled }
+ field = "No boost control below TPS", boostControlMinTps, { isBoostControlEnabled }
+ field = "No boost control below MAP", boostControlMinMap, { isBoostControlEnabled }
dialog = boostOpenLoopDialog, "", border
panel = boostTableTbl, Center
@@ -3690,6 +3707,7 @@ dialog = tcuControls, "Transmission Settings"
commandButton = "Write Config", cmd_write_config
commandButton = "Reset ECU", cmd_reset_controller
commandButton = "Reset to DFU", cmd_dfu
+ commandButton = "Reset to OpenBLT", cmd_openblt
commandButton = "F7 nDBANK fix", cmd_nDBANK@@if_ts_show_f7_presets
commandButton = "No flash Burn mode", cmd_burn_without_flash
@@ -3810,7 +3828,7 @@ dialog = tcuControls, "Transmission Settings"
field = "Log recent errors list", enableLogErrorList
; Racing Features->Launch Control
- dialog = smLaunchControlWest, "Launch Control Settings EXPERIMENTAL"
+ dialog = smLaunchControlWest, "Launch Control Settings"
field = "Enable Launch Control", launchControlEnabled
field = "Activation Mode", launchActivationMode
@@ -3829,14 +3847,15 @@ dialog = tcuControls, "Transmission Settings"
field = "Launch RPM", launchRpm, {launchControlEnabled == 1}
;field = "Extra Fuel", launchFuelAdded, {launchControlEnabled == 1}
;field = "Boost Solenoid Duty", launchBoostDuty, {launchControlEnabled == 1}
+ field = "TPS Threshold", launchTpsThreshold, {launchControlEnabled == 1}
field = "Ignition Retard enable", enableLaunchRetard, {launchControlEnabled == 1}
- field = "Ignition Retard", launchTimingRetard, {launchControlEnabled == 1}
- field = "Ignition Retard RPM Range", launchTimingRpmRange, {launchControlEnabled == 1}
- field = "Smooth Retard Mode", launchSmoothRetard, {launchControlEnabled == 1}
+ field = "Ignition Retard", launchTimingRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
+ field = "Ignition Retard RPM Adder", launchTimingRpmRange, {launchControlEnabled == 1 && enableLaunchRetard == 1}
+ field = "Smooth Retard Mode", launchSmoothRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
field = "Hard Cut Mode"
field = "Ignition Cut", launchSparkCutEnable, {launchControlEnabled == 1}
field = "Fuel Cut", launchFuelCutEnable, {launchControlEnabled == 1}
- field = "Hard Cut RPM Range", hardCutRpmRange, {launchControlEnabled == 1}
+ field = "Hard Cut RPM Adder", hardCutRpmRange, {launchControlEnabled == 1}
dialog = smLaunchControl, "", border
@@ -3886,6 +3905,8 @@ dialog = tcuControls, "Transmission Settings"
field = "boardUseCamVrPullUp", boardUseCamVrPullUp
dialog = parkingLot, "Experimental/Broken"
+ field = "I understand ECU Locking", yesUnderstandLocking
+ field = "Tune read/write password", tuneHidingKey, { yesUnderstandLocking == 1 }
field = verboseQuad, verboseQuad
field = useEeprom, useEeprom
field = "disablePrimaryUart", disablePrimaryUart
diff --git a/firmware/util/efilib.cpp b/firmware/util/efilib.cpp
index 23f695193b..fd8f420bf8 100644
--- a/firmware/util/efilib.cpp
+++ b/firmware/util/efilib.cpp
@@ -19,10 +19,6 @@ const char * boolToString(bool value) {
return value ? "Yes" : "No";
}
-int minI(int i1, int i2) {
- return i1 < i2 ? i1 : i2;
-}
-
/*
float efiFloor(float value, float precision) {
int a = (int) (value / precision);
@@ -40,34 +36,6 @@ float efiRound(float value, float precision) {
return fixNegativeZero(a * precision);
}
-float absF(float value) {
- return value > 0 ? value : -value;
-}
-
-int absI(int32_t value) {
- return value >= 0 ? value : -value;
-}
-
-int maxI(int i1, int i2) {
- return i1 > i2 ? i1 : i2;
-}
-
-float maxF(float i1, float i2) {
- return i1 > i2 ? i1 : i2;
-}
-
-float minF(float i1, float i2) {
- return i1 < i2 ? i1 : i2;
-}
-
-int clampI(int min, int clamp, int max) {
- return maxI(min, minI(clamp, max));
-}
-
-float clampF(float min, float clamp, float max) {
- return maxF(min, minF(clamp, max));
-}
-
uint32_t efiStrlen(const char *param) {
const char *s;
for (s = param; *s; ++s)
@@ -197,12 +165,6 @@ char* itoa10(char *p, int num) {
return itoa_signed(p, num, 10);
}
-#define EPS 0.0001
-
-bool isSameF(float v1, float v2) {
- return absF(v1 - v2) < EPS;
-}
-
int efiPow10(int param) {
switch (param) {
case 0:
@@ -336,69 +298,3 @@ float limitRateOfChange(float newValue, float oldValue, float incrLimitPerSec, f
return (incrLimitPerSec <= 0.0f) ? newValue : oldValue + minF(newValue - oldValue, incrLimitPerSec * secsPassed);
return (decrLimitPerSec <= 0.0f) ? newValue : oldValue - minF(oldValue - newValue, decrLimitPerSec * secsPassed);
}
-
-constexpr float constant_e = 2.71828f;
-
-// 'constexpr' is a keyword that tells the compiler
-// "yes, this thing, it's a 'pure function' that only depends on its inputs and has no side effects"
-// like how const is a constant value, constexpr is a constant expression
-// so if somewhere you used it in a way that it could determine the exact arguments to the function at compile time, it will _run_ the function at compile time, and cook in the result as a constant
-constexpr float expf_taylor_impl(float x, uint8_t n)
-{
- if (x < -2)
- {
- return 0.818f;
- }
- else if (x > 0)
- {
- return 1;
- }
-
- x = x + 1;
-
- float x_power = x;
- int fac = 1;
- float sum = 1;
-
- for (int i = 1; i <= n; i++)
- {
- fac *= i;
- sum += x_power / fac;
-
- x_power *= x;
- }
-
- return sum / constant_e;
-}
-
-float expf_taylor(float x)
-{
- return expf_taylor_impl(x, 4);
-}
-
-float tanf_taylor(float x) {
- // This exists because the "normal" implementation, tanf, pulls in like 6kb of
- // code and loookup tables
-
- // This is only specified from [0, pi/2 - 0.01)
- // Inside that range it has an error of less than 0.1%, and it gets worse as theta -> pi/2
-
- // Precompute some exponents of x
- float x2 = x * x;
- float x3 = x2 * x;
- float x4 = x3 * x;
- float x5 = x4 * x;
- float x6 = x5 * x;
- // x7 not used
- float x8 = x6 * x2;
-
- // 3-term Taylor Series for sin(theta)
- float sin_val = x - (x3 / 6) + (x5 / 120);
-
- // 5-term Taylor Series for cos(theta)
- float cos_val = 1 - (x2 / 2) + (x4 / 24) - (x6 / 720) + (x8 / 40320);
-
- // tan = sin / cos
- return sin_val / cos_val;
-}
-
diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h
index 6b7bb22bbc..e26d6efe80 100644
--- a/firmware/util/efilib.h
+++ b/firmware/util/efilib.h
@@ -62,24 +62,15 @@ float atoff(const char *string);
int atoi(const char *string);
#define UNUSED(x) (void)(x)
-
-int absI(int32_t value);
-float absF(float value);
+
/**
* Rounds value to specified precision.
* @param precision some pow of 10 value - for example, 100 for two digit precision
*/
float efiRound(float value, float precision);
-int maxI(int i1, int i2);
-int minI(int i1, int i2);
-float maxF(float i1, float i2);
-float minF(float i1, float i2);
+
// sometimes known as 'itoa'
char* itoa10(char *p, int num);
-bool isSameF(float v1, float v2);
-
-int clampI(int min, int clamp, int max);
-float clampF(float min, float clamp, float max);
/**
* clamps value into the [0, 100] range
@@ -92,14 +83,6 @@ bool strEqual(const char *str1, const char *str2);
// Currently used by air-interp. tCharge mode (see EngineState::updateTChargeK()).
float limitRateOfChange(float newValue, float oldValue, float incrLimitPerSec, float decrLimitPerSec, float secsPassed);
-// @brief Compute e^x using a 4th order taylor expansion centered at x=-1. Provides
-// bogus results outside the range -2 < x < 0.
-float expf_taylor(float x);
-
-// @brief Compute tan(theta) using a ratio of the Taylor series for sin and cos
-// Valid for the range [0, pi/2 - 0.01]
-float tanf_taylor(float theta);
-
#ifdef __cplusplus
}
@@ -109,69 +92,10 @@ float tanf_taylor(float theta);
#define IS_NEGATIVE_ZERO(value) (__builtin_signbit(value) && value==0)
#define fixNegativeZero(value) (IS_NEGATIVE_ZERO(value) ? 0 : value)
-// C++ helpers go here
-namespace efi
-{
-template
-constexpr size_t size(const T(&)[N]) {
- return N;
-}
-
-// Zero the passed object
-template
-constexpr void clear(T* obj) {
- // The cast to void* is to prevent errors like:
- // clearing an object of non-trivial type 'struct persistent_config_s'; use assignment or value-initialization instead
- // This is technically wrong, but we know config objects only ever actually
- // contain integral types, though they may be wrapped in a scaled_channel
- memset(reinterpret_cast(obj), 0, sizeof(T));
-}
-
-template
-constexpr void clear(T& obj) {
- clear(&obj);
-}
-} // namespace efi
-
#define assertIsInBounds(length, array, msg) efiAssertVoid(OBD_PCM_Processor_Fault, std::is_unsigned_v && (length) < efi::size(array), msg)
#define assertIsInBoundsWithResult(length, array, msg, failedResult) efiAssert(OBD_PCM_Processor_Fault, std::is_unsigned_v && (length) < efi::size(array), msg, failedResult)
-/**
- * Copies an array from src to dest. The lengths of the arrays must match.
- */
-template
-constexpr void copyArray(DElement (&dest)[N], const SElement (&src)[N]) {
- for (size_t i = 0; i < N; i++) {
- dest[i] = src[i];
- }
-}
-
-// specialization that can use memcpy when src and dest types match
-template
-constexpr void copyArray(scaled_channel (&dest)[N], const DElement (&src)[N]) {
- memcpy(dest, src, sizeof(DElement) * N);
-}
-
-template
-constexpr void copyArray(DElement (&dest)[N], const DElement (&src)[N]) {
- memcpy(dest, src, sizeof(DElement) * N);
-}
-
-/**
- * Copies an array from src to the beginning of dst. If dst is larger
- * than src, then only the elements copied from src will be touched.
- * Any remaining elements at the end will be untouched.
- */
-template
-constexpr void copyArrayPartial(TElement (&dest)[NDest], const TElement (&src)[NSrc]) {
- static_assert(NDest >= NSrc, "Source array must be larger than destination.");
-
- for (size_t i = 0; i < NSrc; i++) {
- dest[i] = src[i];
- }
-}
-
template
bool isInRange(T min, T val, T max) {
return val >= min && val <= max;
@@ -195,16 +119,3 @@ static constexpr Gpio operator+(size_t a, Gpio b) {
}
#endif /* __cplusplus */
-
-#if defined(__cplusplus) && defined(__OPTIMIZE__)
-#include
-// "g++ -O2" version, adds more strict type check and yet no "strict-aliasing" warnings!
-#define cisnan(f) ({ \
- static_assert(sizeof(f) == sizeof(int32_t)); \
- union cisnanu_t { std::remove_reference_t __f; int32_t __i; } __cisnan_u = { f }; \
- __cisnan_u.__i == 0x7FC00000; \
-})
-#else
-// "g++ -O0" or other C++/C compilers
-#define cisnan(f) (*(((int*) (&f))) == 0x7FC00000)
-#endif /* __cplusplus && __OPTIMIZE__ */
diff --git a/firmware/util/expected.h b/firmware/util/expected.h
index b7ca0c940c..ac05d2fd9d 100644
--- a/firmware/util/expected.h
+++ b/firmware/util/expected.h
@@ -17,13 +17,35 @@
struct unexpected_t {};
+enum class UnexpectedCode : char {
+ Unknown = 0,
+
+ // Too much time has passed
+ Timeout,
+
+ // The decoded value was impossibly high/low
+ High,
+ Low,
+
+ // An inconsistency was detected using multiple sources of information
+ Inconsistent,
+
+ // A value is unavailable due to configuration
+ Configuration,
+};
template
struct expected {
- const bool Valid;
- const TValue Value;
+ bool Valid;
+
+ union {
+ TValue Value;
+ UnexpectedCode Code;
+ };
// Implicit constructor to construct in the invalid state
- constexpr expected(const unexpected_t&) : Valid(false), Value{} {}
+ constexpr expected(const unexpected_t&) : Valid(false), Code{UnexpectedCode::Unknown} {}
+
+ constexpr expected(UnexpectedCode code) : Valid(false), Code{code} {}
// Implicit constructor to convert from TValue (for valid values, so an expected behaves like a T)
constexpr expected(TValue validValue)
diff --git a/firmware/util/loggingcentral.cpp b/firmware/util/loggingcentral.cpp
index c8be4f937d..5a62952187 100644
--- a/firmware/util/loggingcentral.cpp
+++ b/firmware/util/loggingcentral.cpp
@@ -160,7 +160,7 @@ void startLoggingProcessor() {
}
// Start processing used buffers
- lbf.Start();
+ lbf.start();
}
#endif // EFI_PROD_CODE
diff --git a/firmware/util/math/crc.c b/firmware/util/math/crc.c
deleted file mode 100644
index c1734b6851..0000000000
--- a/firmware/util/math/crc.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * @file crc.c
- * @date Sep 20, 2013
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#include "crc.h"
-
-static const uint32_t crc32_tab[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
- 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
- 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
- 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb,
- 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
- 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e,
- 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
- 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75,
- 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
- 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808,
- 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
- 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
- 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
- 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162,
- 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
- 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49,
- 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
- 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc,
- 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
- 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3,
- 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
- 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
- 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
- 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d,
- 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
- 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0,
- 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
- 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767,
- 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
- 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a,
- 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
- 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
- 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
- 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14,
- 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
- 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b,
- 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
- 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee,
- 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
- 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5,
- 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
- 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
- 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
-
-/**
- * Online CRC calculator:
- * http://www.zorc.breitbandkatze.de/crc.html
- */
-uint32_t crc32(const void *buf, uint32_t size) {
- return crc32inc(buf, 0, size);
-}
-
-uint32_t crc32inc(const void *buf, uint32_t crc, uint32_t size) {
- const uint8_t *p;
-
- p = buf;
- crc = crc ^ 0xFFFFFFFF;
-
- while (size--) {
- crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
- }
-
- return crc ^ 0xFFFFFFFF;
-}
-
-/**
- * http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
- * https://stackoverflow.com/questions/38639423/understanding-results-of-crc8-sae-j1850-normal-vs-zero
- * j1850 SAE crc8
- */
-uint8_t crc8(const uint8_t *data, uint8_t len) {
- uint8_t crc = 0;
-
- if (data == 0)
- return 0;
- crc ^= 0xff;
- while (len--) {
- crc ^= *data++;
- for (unsigned k = 0; k < 8; k++)
- crc = crc & 0x80 ? (crc << 1) ^ 0x1d : crc << 1;
- }
- crc &= 0xff;
- crc ^= 0xff;
- return crc;
-}
-
diff --git a/firmware/util/math/crc.h b/firmware/util/math/crc.h
deleted file mode 100644
index d634c974b6..0000000000
--- a/firmware/util/math/crc.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * @file crc.h
- *
- * @date Sep 20, 2013
- * @author Andrey Belomutskiy, (c) 2012-2020
- */
-
-#pragma once
-
-#include "stdint.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-uint8_t crc8(const uint8_t * buf, uint8_t len);
-uint32_t crc32(const void *buf, uint32_t size);
-uint32_t crc32inc(const void *buf, uint32_t crc, uint32_t size);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
diff --git a/firmware/util/math/efi_pid.cpp b/firmware/util/math/efi_pid.cpp
index 8ad13e12cf..fe1f0f40b5 100644
--- a/firmware/util/math/efi_pid.cpp
+++ b/firmware/util/math/efi_pid.cpp
@@ -137,7 +137,8 @@ void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) const {
void Pid::postState(pid_status_s& pidStatus) const {
pidStatus.output = output;
- pidStatus.error = getPrevError();
+ pidStatus.error = previousError;
+ pidStatus.pTerm = parameters == nullptr ? 0 : parameters->pFactor * previousError;
pidStatus.iTerm = iTerm;
pidStatus.dTerm = dTerm;
}
diff --git a/firmware/util/math/efi_pid.h b/firmware/util/math/efi_pid.h
index 62d03717e1..16df09fd11 100644
--- a/firmware/util/math/efi_pid.h
+++ b/firmware/util/math/efi_pid.h
@@ -69,7 +69,7 @@ public:
float iTermMin = -1000000.0;
float iTermMax = 1000000.0;
protected:
- pid_s *parameters;
+ pid_s *parameters = nullptr;
virtual void updateITerm(float value);
};
diff --git a/firmware/util/math/interpolation.h b/firmware/util/math/interpolation.h
index 7141aadfa5..3672df938c 100644
--- a/firmware/util/math/interpolation.h
+++ b/firmware/util/math/interpolation.h
@@ -45,113 +45,6 @@ void ensureArrayIsAscendingOrDefault(const char* msg, const TValue (&values)[TSi
ensureArrayIsAscending(msg, values);
}
-namespace priv {
-struct BinResult
-{
- size_t Idx;
- float Frac;
-};
-
-/**
- * @brief Finds the location of a value in the bin array.
- *
- * @param value The value to find in the bins.
- * @return A result containing the index to the left of the value,
- * and how far from (idx) to (idx + 1) the value is located.
- */
-template
-BinResult getBin(float value, const TBin (&bins)[TSize]) {
- // Enforce numeric only (int, float, uintx_t, etc)
- static_assert(std::is_arithmetic_v, "Table bins must be an arithmetic type");
-
- // Enforce that there are enough bins to make sense (what does one bin even mean?)
- static_assert(TSize >= 2);
-
- // Handle NaN
- if (cisnan(value)) {
- return { 0, 0.0f };
- }
-
- // Handle off-scale low
- if (value <= bins[0]) {
- return { 0, 0.0f };
- }
-
- // Handle off-scale high
- if (value >= bins[TSize - 1]) {
- return { TSize - 2, 1.0f };
- }
-
- size_t idx = 0;
-
- // Find the last index less than the searched value
- // Linear search for now, maybe binary search in future
- // after collecting real perf data
- for (idx = 0; idx < TSize - 1; idx++) {
- if (bins[idx + 1] > value) {
- break;
- }
- }
-
- float low = bins[idx];
- float high = bins[idx + 1];
-
- // Compute how far along the bin we are
- // (0.0f = left side, 1.0f = right side)
- float fraction = (value - low) / (high - low);
-
- return { idx, fraction };
-}
-
-template
-BinResult getBin(float value, const scaled_channel (&bins)[TSize]) {
- return getBin(value * (float(TMult) / TDiv), *reinterpret_cast(&bins));
-}
-
-static float linterp(float low, float high, float frac)
-{
- return high * frac + low * (1 - frac);
-}
-} // namespace priv
-
-template
-float interpolate2d(const float value, const TBin (&bin)[TSize], const TValue (&values)[TSize]) {
- // Enforce numeric only (int, float, uintx_t, etc)
- static_assert(std::is_arithmetic_v || is_scaled_channel, "Table values must be an arithmetic type or scaled channel");
-
- auto b = priv::getBin(value, bin);
-
- // Convert to float as we read it out
- float low = static_cast(values[b.Idx]);
- float high = static_cast(values[b.Idx + 1]);
- float frac = b.Frac;
-
- return priv::linterp(low, high, frac);
-}
-
-template
-float interpolate3d(const VType (&table)[RNum][CNum],
- const RType (&rowBins)[RNum], float rowValue,
- const CType (&colBins)[CNum], float colValue)
-{
- auto row = priv::getBin(rowValue, rowBins);
- auto col = priv::getBin(colValue, colBins);
-
- // Orient the table such that (0, 0) is the bottom left corner,
- // then the following variable names will make sense
- float lowerLeft = table[row.Idx ][col.Idx ];
- float upperLeft = table[row.Idx + 1][col.Idx ];
- float lowerRight = table[row.Idx ][col.Idx + 1];
- float upperRight = table[row.Idx + 1][col.Idx + 1];
-
- // Interpolate each side by itself
- float left = priv::linterp(lowerLeft, upperLeft, row.Frac);
- float right = priv::linterp(lowerRight, upperRight, row.Frac);
-
- // Then interpolate between those
- return priv::linterp(left, right, col.Frac);
-}
-
/** @brief Binary search
* @returns the highest index within sorted array such that array[i] is greater than or equal to the parameter
* @note If the parameter is smaller than the first element of the array, -1 is returned.
diff --git a/firmware/util/scaled_channel.h b/firmware/util/scaled_channel.h
index f2b8256634..953284d0e8 100644
--- a/firmware/util/scaled_channel.h
+++ b/firmware/util/scaled_channel.h
@@ -11,85 +11,9 @@
#pragma once
-#include
-#include
-#include
-
+#include
#include "rusefi_generated.h"
-struct scaled_channel_base { };
-
-template
-static constexpr bool is_scaled_channel = std::is_base_of_v;
-
-// This class lets us transparently store something at a ratio inside an integer type
-// Just use it like a float - you can read and write to it, like this:
-// scaled_channel myVar;
-// myVar = 2.4f; // converts to an int, stores 24
-// float x = myVar; // converts back to float, returns 2.4f
-template
-class scaled_channel : scaled_channel_base {
- using TSelf = scaled_channel;
-
-public:
- struct IncompleteType;
-
- constexpr scaled_channel() : m_value(static_cast(0)) { }
-
- // Only allow conversion directly to T when mul/div are both 1, otherwise this constructor doesn't exist and the float conversion is used.
- constexpr scaled_channel(std::conditional_t val) {
- m_value = val;
- }
-
- // Scale the float in to our scaled channel
- constexpr scaled_channel(std::conditional_t val) {
- // If there are scale factors, it must NOT be a float. Why would you scale a float?
- static_assert(std::is_integral_v);
-
- m_value = std::roundf(val * float(mul) / div);
- }
-
- // Only allow conversion directly to T when mul/div are both 1, otherwise this operator doesn't exist and the float conversion is used.
- constexpr operator typename std::conditional_t() const {
- return m_value;
- }
-
- // Allow reading back out as a float (note: this may be lossy!)
- constexpr operator typename std::conditional_t() const {
- return m_value * (float(div) / mul);
- }
-
- // Postfix increment operator
- // only enable if:
- // - base type T is an integral type (integer)
- // - multiplier is equal to 1
- void operator++(int) {
- static_assert(mul == 1 && div == 1,
- "Increment operator only supported for non-scaled integer types");
- static_assert(std::is_integral_v, "Increment operator only supported for non-scaled integer types");
-
- m_value++;
- }
-
- constexpr const char* getFirstByteAddr() const {
- return &m_firstByte;
- }
-
-private:
- union {
- T m_value;
- char m_firstByte;
- };
-};
-
-// We need to guarantee that scaled values containing some type are the same size
-// as that underlying type. We rely on the class only having a single member for
-// this trick to work.
-static_assert(sizeof(scaled_channel) == 1);
-static_assert(sizeof(scaled_channel) == 2);
-static_assert(sizeof(scaled_channel) == 4);
-static_assert(sizeof(scaled_channel) == 4);
-
// Common scaling options - use these if you can!
using scaled_temperature = scaled_channel; // +-327 deg C at 0.01 deg resolution
using scaled_ms = scaled_channel; // +- 100ms at 0.003ms precision
@@ -101,7 +25,3 @@ using scaled_voltage = scaled_channel; // 0-65v at
using scaled_afr = scaled_channel; // 0-65afr at 0.001 resolution
using scaled_lambda = scaled_channel; // 0-6.5 lambda at 0.0001 resolution
using scaled_fuel_mass_mg = scaled_channel; // 0 - 655.35 milligrams, 0.01mg resolution
-
-// make sure the scaled channel detector works
-static_assert(!is_scaled_channel);
-static_assert(is_scaled_channel>);
diff --git a/firmware/util/util.mk b/firmware/util/util.mk
index 458c2d4b0d..a53141e9f3 100644
--- a/firmware/util/util.mk
+++ b/firmware/util/util.mk
@@ -1,7 +1,6 @@
UTIL_DIR=$(PROJECT_DIR)/util
UTILSRC = \
- $(UTIL_DIR)/math/crc.c \
$(UTIL_DIR)/tinymt32.c \
UTILSRC_CPP = \
diff --git a/java_console/autoupdate/build.gradle b/java_console/autoupdate/build.gradle
index 8b85bf87aa..772236c6bb 100644
--- a/java_console/autoupdate/build.gradle
+++ b/java_console/autoupdate/build.gradle
@@ -9,17 +9,16 @@ configurations {
}
dependencies {
- implementation libs.javaxJson
- api project(':inifile')
- implementation project(':logging-api')
- implementation project(':shared_io')
+ api libs.javaxJson
+ api project(':logging-api')
+ api project(':shared_io')
- implementation group: 'com.fazecast', name: 'jSerialComm', version: '2.6.2'
- implementation group: 'net.jcip', name: 'jcip-annotations', version: '1.0'
- implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
- implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
+ api group: 'net.jcip', name: 'jcip-annotations', version: '1.0'
+ api libs.json
+ // not 'api' since Android would use own implementation
+ implementation ts_plugin_libs.httpclient
// junit 4.13 does not mix well with httpclient :(
testImplementation group: 'junit', name: 'junit', version: '4.8.2'
- testImplementation group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
+ testImplementation libs.mockito
}
\ No newline at end of file
diff --git a/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/Autoupdate.java b/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/Autoupdate.java
index ecab859220..a9f7e7a77b 100644
--- a/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/Autoupdate.java
+++ b/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/Autoupdate.java
@@ -21,7 +21,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
public class Autoupdate {
- private static final String TITLE = "rusEFI Bundle Updater 20210212";
+ private static final String TITLE = "rusEFI Bundle Updater 20220717";
private static final String BUNDLE_NAME_FILE = "../bundle_name.txt";
private static final String AUTOUPDATE_MODE = "autoupdate";
private static final String RUSEFI_CONSOLE_JAR = "rusefi_console.jar";
@@ -33,18 +33,17 @@ public class Autoupdate {
if (args.length > 0 && args[0].equalsIgnoreCase("release")) {
System.out.println("Release update requested");
handleBundle(bundleFullName, UpdateMode.ALWAYS, ConnectionAndMeta.BASE_URL_RELEASE);
- return;
- }
-
- System.out.println("Latest update requested");
- UpdateMode mode = getMode();
- if (mode != UpdateMode.NEVER) {
- if (bundleFullName != null) {
- System.out.println("Handling " + bundleFullName);
- handleBundle(bundleFullName, mode, ConnectionAndMeta.BASE_URL_LATEST);
- }
} else {
- System.out.println("Update mode: NEVER");
+ UpdateMode mode = getMode();
+ if (mode != UpdateMode.NEVER) {
+ System.out.println("Snapshot requested");
+ if (bundleFullName != null) {
+ System.out.println("Handling " + bundleFullName);
+ handleBundle(bundleFullName, mode, ConnectionAndMeta.BASE_URL_LATEST);
+ }
+ } else {
+ System.out.println("Update mode: NEVER");
+ }
}
startConsole(args);
}
@@ -104,8 +103,17 @@ public class Autoupdate {
System.out.println("Downloaded " + file.length() + " bytes");
FileUtil.unzip(zipFileName, new File(".."));
- } catch (Exception e) {
- System.err.println(e);
+ } catch (ReportedIOException e) {
+ // we had already reported error with a UI dialog when we had parent frame
+ System.err.println("Error downloading bundle: " + e);
+ } catch (IOException e) {
+ // we are here if error happened while we did not have UI frame
+ // todo: open frame prior to network connection and keep frame opened while uncompressing?
+ System.err.println("Error downloading bundle: " + e);
+ if (!AutoupdateUtil.runHeadless) {
+ JOptionPane.showMessageDialog(null, "Error downloading " + e, "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
}
}
@@ -190,6 +198,9 @@ public class Autoupdate {
return doUpdate.get();
}
+ /**
+ * @return null in case of error
+ */
@Nullable
public static String readBundleFullName() {
try {
diff --git a/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/AutoupdateUtil.java b/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/AutoupdateUtil.java
index 1b242c4323..3f47d6cb74 100644
--- a/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/AutoupdateUtil.java
+++ b/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/AutoupdateUtil.java
@@ -28,29 +28,55 @@ public class AutoupdateUtil {
return result;
}
- public static void downloadAutoupdateFile(String localZipFileName, ConnectionAndMeta connectionAndMeta, String title) throws IOException {
- FrameHelper frameHelper = null;
- final AtomicReference jProgressBarAtomicReference = new AtomicReference<>();
- if (!runHeadless) {
- frameHelper = new FrameHelper();
+ static class ProgressView {
+ private final FrameHelper frameHelper;
+ private JProgressBar progressBar;
+
+ ProgressView(FrameHelper frameHelper, JProgressBar progressBar) {
+ this.frameHelper = frameHelper;
+ this.progressBar = progressBar;
+ }
+
+ public void dispose() {
+ if (frameHelper != null) {
+ frameHelper.getFrame().dispose();
+ }
+ }
+ }
+
+ private static ProgressView createProgressView(String title) {
+ if (runHeadless) {
+ return new ProgressView(null, null);
+ } else {
+ FrameHelper frameHelper = new FrameHelper();
JProgressBar jProgressBar = new JProgressBar();
frameHelper.getFrame().setTitle(title);
jProgressBar.setMaximum(ConnectionAndMeta.CENTUM);
- jProgressBarAtomicReference.set(jProgressBar);
frameHelper.showFrame(jProgressBar, true);
+ return new ProgressView(frameHelper, jProgressBar);
}
+ }
- ConnectionAndMeta.DownloadProgressListener listener = currentProgress -> {
- if (!runHeadless) {
- SwingUtilities.invokeLater(() -> jProgressBarAtomicReference.get().setValue(currentProgress));
- }
- };
+ public static void downloadAutoupdateFile(String localZipFileName, ConnectionAndMeta connectionAndMeta, String title) throws IOException {
+ ProgressView view = createProgressView(title);
- ConnectionAndMeta.downloadFile(localZipFileName, connectionAndMeta, listener);
+ try {
+ ConnectionAndMeta.DownloadProgressListener listener = currentProgress -> {
+ if (!runHeadless) {
+ SwingUtilities.invokeLater(() -> view.progressBar.setValue(currentProgress));
+ }
+ };
- if (!runHeadless) {
- frameHelper.getFrame().dispose();
+ ConnectionAndMeta.downloadFile(localZipFileName, connectionAndMeta, listener);
+ } catch (IOException e) {
+ if (view.progressBar!=null) {
+ JOptionPane.showMessageDialog(view.progressBar, "Error downloading: " + e, "Error", JOptionPane.ERROR_MESSAGE);
+ throw new ReportedIOException(e);
+ } else
+ throw e;
+ } finally {
+ view.dispose();
}
}
diff --git a/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/ReportedIOException.java b/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/ReportedIOException.java
new file mode 100644
index 0000000000..255654db19
--- /dev/null
+++ b/java_console/autoupdate/src/main/java/com/rusefi/autoupdate/ReportedIOException.java
@@ -0,0 +1,14 @@
+package com.rusefi.autoupdate;
+
+import java.io.IOException;
+
+/**
+ * IO Exception which was already reported with a UI dialog
+ */
+public class ReportedIOException extends IOException {
+ private IOException e;
+
+ public ReportedIOException(IOException e) {
+ this.e = e;
+ }
+}
diff --git a/java_console/build.xml b/java_console/build.xml
index 682ede3e10..8256b76945 100644
--- a/java_console/build.xml
+++ b/java_console/build.xml
@@ -90,11 +90,13 @@
+
+
diff --git a/java_console/io/build.gradle b/java_console/io/build.gradle
index 07110502d8..92e5cabee9 100644
--- a/java_console/io/build.gradle
+++ b/java_console/io/build.gradle
@@ -1,5 +1,6 @@
plugins {
- id 'java'
+ id 'java-library'
+ id 'java-test-fixtures'
}
apply from: '../../android/dependencies.gradle'
@@ -24,10 +25,10 @@ dependencies {
implementation group: 'com.fazecast', name: 'jSerialComm', version: '2.9.2'
implementation group: 'tel.schich', name: 'javacan-core', version: '3.2.0'
implementation group: 'net.jcip', name: 'jcip-annotations', version: '1.0'
- implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
- implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
+ implementation libs.json
+ implementation ts_plugin_libs.httpclient
// junit 4.13 does not mix well with httpclient :(
testImplementation group: 'junit', name: 'junit', version: '4.8.2'
- testImplementation group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
+ testFixturesImplementation libs.mockito
}
\ No newline at end of file
diff --git a/java_console/io/io.iml b/java_console/io/io.iml
index 61dae13d6f..d76e80ee0f 100644
--- a/java_console/io/io.iml
+++ b/java_console/io/io.iml
@@ -5,6 +5,7 @@
+
diff --git a/java_console/io/src/main/java/com/rusefi/enums/debug_mode_e.java b/java_console/io/src/main/java/com/rusefi/enums/debug_mode_e.java
index 4fd81088a3..853872688c 100644
--- a/java_console/io/src/main/java/com/rusefi/enums/debug_mode_e.java
+++ b/java_console/io/src/main/java/com/rusefi/enums/debug_mode_e.java
@@ -6,8 +6,8 @@ package com.rusefi.enums;
public enum debug_mode_e {
DBG_0,
DBG_TPS_ACCEL,
- DBG_GPPWM,
- DBG_IDLE_CONTROL,
+ DBG_2,
+ DBG_STEPPER_IDLE_CONTROL,
DBG_EL_ACCEL,
DBG_TRIGGER_COUNTERS,
DBG_SOFT_SPARK_CUT,
diff --git a/java_console/io/src/main/java/com/rusefi/file/FileUtils.java b/java_console/io/src/main/java/com/rusefi/file/FileUtils.java
index 491d8a2055..f5c965c2c7 100644
--- a/java_console/io/src/main/java/com/rusefi/file/FileUtils.java
+++ b/java_console/io/src/main/java/com/rusefi/file/FileUtils.java
@@ -7,6 +7,7 @@ import java.io.*;
import java.util.List;
/**
+ * Minor mess: we also have FileUtil in shared_ui
* Date: 3/8/13
* Andrey Belomutskiy, (c) 2013-2020
*/
diff --git a/java_console/io/src/main/java/com/rusefi/io/stream/PCanIoStream.java b/java_console/io/src/main/java/com/rusefi/io/stream/PCanIoStream.java
index 6dea6b2242..c486a2e666 100644
--- a/java_console/io/src/main/java/com/rusefi/io/stream/PCanIoStream.java
+++ b/java_console/io/src/main/java/com/rusefi/io/stream/PCanIoStream.java
@@ -97,7 +97,9 @@ public class PCanIoStream extends AbstractIoStream {
private void readOnePacket(DataListener listener) {
// todo: can we reuse instance?
- TPCANMsg rx = new TPCANMsg();
+ // todo: should be? TPCANMsg rx = new TPCANMsg();
+ // https://github.com/rusefi/rusefi/issues/4370 nasty work-around
+ TPCANMsg rx = new TPCANMsg((byte) 255);
TPCANStatus status = can.Read(CHANNEL, rx, null);
if (status == TPCANStatus.PCAN_ERROR_OK) {
if (log.debugEnabled())
diff --git a/java_console/io/src/main/java/peak/can/basic/TPCANMsg.java b/java_console/io/src/main/java/peak/can/basic/TPCANMsg.java
index e54be5ce6a..93fa964ea4 100644
--- a/java_console/io/src/main/java/peak/can/basic/TPCANMsg.java
+++ b/java_console/io/src/main/java/peak/can/basic/TPCANMsg.java
@@ -69,6 +69,12 @@ public class TPCANMsg implements Cloneable
_data = new byte[8];
}
+ // rusEFI custom https://github.com/rusefi/rusefi/issues/4370 workaround
+ public TPCANMsg(byte length)
+ {
+ _data = new byte[length];
+ }
+
/**
* Constructs a new message object.
* @param id the message id
diff --git a/java_console/io/src/test/java/com/rusefi/TestHelper.java b/java_console/io/src/test/java/com/rusefi/TestHelper.java
index 8758ceebb1..3fd84f137b 100644
--- a/java_console/io/src/test/java/com/rusefi/TestHelper.java
+++ b/java_console/io/src/test/java/com/rusefi/TestHelper.java
@@ -18,7 +18,6 @@ import com.rusefi.server.rusEFISSLContext;
import com.rusefi.shared.FileUtil;
import com.rusefi.tune.xml.Constant;
import org.jetbrains.annotations.NotNull;
-import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.net.Socket;
@@ -33,16 +32,13 @@ import static com.rusefi.config.generated.Fields.TS_FILE_VERSION_OFFSET;
import static com.rusefi.io.tcp.TcpConnector.LOCALHOST;
import static org.junit.Assert.assertTrue;
-public class TestHelper {
+public class TestHelper extends MockitoTestHelper {
private static final Logging log = getLogging(TestHelper.class);
public static final String TEST_SIGNATURE_1 = "rusEFI 2020.07.06.frankenso_na6.2468827536";
public static final String TEST_SIGNATURE_2 = "rusEFI 2020.07.11.proteus_f4.1986715563";
public static final ControllerInfo CONTROLLER_INFO = new ControllerInfo("name", "make", "code", Fields.TS_SIGNATURE);
public static final String TEST_TOKEN_1 = "00000000-1234-1234-1234-123456789012";
public static final String TEST_TOKEN_3 = "33333333-3333-1234-1234-123456789012";
- public static final Answer> NEGATIVE_ANSWER = invocation -> {
- throw new UnsupportedOperationException("Not mocked " + invocation);
- };
@NotNull
public static ScalarIniField createIniField(Field field) {
diff --git a/java_console/io/src/testFixtures/java/com/rusefi/MockitoTestHelper.java b/java_console/io/src/testFixtures/java/com/rusefi/MockitoTestHelper.java
new file mode 100644
index 0000000000..70b3d230b9
--- /dev/null
+++ b/java_console/io/src/testFixtures/java/com/rusefi/MockitoTestHelper.java
@@ -0,0 +1,9 @@
+package com.rusefi;
+
+import org.mockito.stubbing.Answer;
+
+public class MockitoTestHelper {
+ public static final Answer> NEGATIVE_ANSWER = invocation -> {
+ throw new UnsupportedOperationException("Not mocked " + invocation);
+ };
+}
diff --git a/java_console/models/build.gradle b/java_console/models/build.gradle
index 788d5889c7..438216c43b 100644
--- a/java_console/models/build.gradle
+++ b/java_console/models/build.gradle
@@ -6,5 +6,6 @@ apply from: '../../android/dependencies.gradle'
dependencies {
api project(':autoupdate')
- implementation libs.snakeyaml
+ api project(':inifile')
+ api libs.snakeyaml
}
\ No newline at end of file
diff --git a/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java b/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java
index 366501b69c..667b9a25c9 100644
--- a/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java
+++ b/java_console/models/src/main/java/com/rusefi/composite/CompositeEvent.java
@@ -1,7 +1,7 @@
package com.rusefi.composite;
public class CompositeEvent {
- private final int timestamp;
+ private final long timestamp;
private final boolean primaryTrigger;
private final boolean secondaryTrigger;
private final boolean trg;
@@ -9,7 +9,7 @@ public class CompositeEvent {
private final boolean coil;
private final boolean injector;
- public CompositeEvent(int timestamp, boolean primaryTrigger, boolean secondaryTrigger, boolean trg, boolean sync, boolean coil, boolean injector) {
+ public CompositeEvent(long timestamp, boolean primaryTrigger, boolean secondaryTrigger, boolean trg, boolean sync, boolean coil, boolean injector) {
this.timestamp = timestamp;
this.primaryTrigger = primaryTrigger;
this.secondaryTrigger = secondaryTrigger;
@@ -19,7 +19,7 @@ public class CompositeEvent {
this.injector = injector;
}
- public int getTimestamp() {
+ public long getTimestamp() {
return timestamp;
}
diff --git a/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java b/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java
index bb427d7d64..d060c9f435 100644
--- a/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java
+++ b/java_console/models/src/main/java/com/rusefi/composite/CompositeParser.java
@@ -11,20 +11,22 @@ import java.util.List;
public class CompositeParser {
private static final Logging log = Logging.getLogging(CompositeParser.class);
- // 1 second
- private static final int maxDeltaTime = 1000000;
+
+ private static long prevTime = 0;
+ private static long timeAdder = 0;
public static List parse(byte[] response) {
ByteBuffer byteBuffer = ByteBuffer.wrap(response);
byteBuffer.order(ByteOrder.BIG_ENDIAN);
int ptr = 1;
- int curTime = 0, prevTime = 0;
List events = new ArrayList<>();
while (ptr + Fields.COMPOSITE_PACKET_SIZE <= response.length) {
- int timestamp = byteBuffer.getInt(ptr);
+ // Convert the int to a long since java can't do unsigned ints,
+ // so we have to use a long (but still only want 32 bits read)
+ long timestamp = Integer.toUnsignedLong (byteBuffer.getInt(ptr));
byte flags = byteBuffer.get(ptr + 4);
// log.debug(timestamp + " " + flags);
@@ -37,20 +39,18 @@ public class CompositeParser {
ptr += Fields.COMPOSITE_PACKET_SIZE;
- // 'timestamp' is an integer type for now, and sadly, but it overflows...
- // this is an attempt of temporary workaround
- int dt = timestamp - prevTime;
- // we allow time to increment only in small amounts.
- // so if any time discontinuities occur, we jump 1 sec.
- if (dt < 0 || dt > maxDeltaTime)
- dt = maxDeltaTime;
- // we want to catch integer overflows here
- curTime = Math.addExact(curTime, dt);
+ // If the timestamp went down, that means we just witnessed an integer overflow
+ if (timestamp < prevTime) {
+ // Add the maximum value of a uint32_t, plus one
+ timeAdder += 0xFFFFFFFFL + 1;
+ }
+
prevTime = timestamp;
+ long curTime = timeAdder + timestamp;
+
events.add(new CompositeEvent(curTime, primaryTrigger, secondaryTrigger, trg, sync, coil, injector));
}
return events;
}
-
}
diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/AcControl.java b/java_console/models/src/main/java/com/rusefi/config/generated/AcControl.java
index a3bad6cce1..209734a664 100644
--- a/java_console/models/src/main/java/com/rusefi/config/generated/AcControl.java
+++ b/java_console/models/src/main/java/com/rusefi/config/generated/AcControl.java
@@ -1,6 +1,6 @@
package com.rusefi.config.generated;
-// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/ac_control.txt Sat Jul 02 08:20:03 UTC 2022
+// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/ac_control.txt Sat Jul 30 15:33:11 UTC 2022
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@@ -35,6 +35,7 @@ public class AcControl {
public static final String CMD_BURNCONFIG = "burnconfig";
public static final String CMD_DATE = "date";
public static final String CMD_DISABLE = "disable";
+ public static final String CMD_ECU_UNLOCK = "unlock";
public static final String CMD_ENABLE = "enable";
public static final String CMD_ENGINE_TYPE = "engine_type";
public static final String CMD_ENGINESNIFFERRPMTHRESHOLD = "engineSnifferRpmThreshold";
@@ -53,6 +54,7 @@ public class AcControl {
public static final String CMD_IGNITION_PIN = "set_ignition_pin";
public static final String CMD_INJECTION = "injection";
public static final String CMD_INJECTION_PIN = "set_injection_pin";
+ public static final int CMD_KEYPAD = 0x17;
public static final String CMD_LOGIC_PIN = "set_logic_input_pin";
public static final String CMD_MIL_BENCH = "milbench";
public static final String CMD_PINS = "pins";
@@ -73,13 +75,12 @@ public class AcControl {
public static final int CMD_TS_BENCH_CATEGORY = 22;
public static final int CMD_TS_LUA_OUTPUT_CATEGORY = 33;
public static final int CMD_TS_SOLENOID_CATEGORY = 41;
+ public static final int CMD_TS_WBO_UPDATE = 0x15;
public static final int CMD_TS_X14 = 20;
public static final int CMD_TS_X31 = 49;
public static final String CMD_VSS_PIN = "vss_pin";
public static final String CMD_WRITECONFIG = "writeconfig";
- public static final int COMPOSITE_DATA_LENGTH = 2500;
- public static final int COMPOSITE_DATA_LENGTH_HALF = 1250;
- public static final int COMPOSITE_PACKET_COUNT = 500;
+ public static final int COMPOSITE_PACKET_COUNT = 1000;
public static final int COMPOSITE_PACKET_SIZE = 5;
public static final String CONSOLE_DATA_PROTOCOL_TAG = " @";
public static final int CRANKING_ADVANCE_CURVE_SIZE = 4;
@@ -341,6 +342,9 @@ public class AcControl {
public static final int TPS_2_BYTE_PACKING_MULT = 100;
public static final int TPS_TPS_ACCEL_TABLE = 8;
public static final String TRIGGER_COMMENT = "#";
+ public static final String TRIGGER_GAP_FROM = "gapFrom";
+ public static final String TRIGGER_GAP_TO = "gapTo";
+ public static final String TRIGGER_GAPS_COUNT = "gapsCount";
public static final String TRIGGER_HARDCODED_OPERATION_MODE = "knownOperationMode";
public static final String TRIGGER_HAS_SECOND_CHANNEL = "hasSecondChannel";
public static final int TRIGGER_INPUT_PIN_COUNT = 2;
diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/BoostControl.java b/java_console/models/src/main/java/com/rusefi/config/generated/BoostControl.java
index ada35a88ec..48bc3e3cda 100644
--- a/java_console/models/src/main/java/com/rusefi/config/generated/BoostControl.java
+++ b/java_console/models/src/main/java/com/rusefi/config/generated/BoostControl.java
@@ -1,6 +1,6 @@
package com.rusefi.config.generated;
-// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/boost_control.txt Thu Jun 30 03:37:30 UTC 2022
+// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators/boost_control.txt Sat Jul 30 15:33:11 UTC 2022
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@@ -35,6 +35,7 @@ public class BoostControl {
public static final String CMD_BURNCONFIG = "burnconfig";
public static final String CMD_DATE = "date";
public static final String CMD_DISABLE = "disable";
+ public static final String CMD_ECU_UNLOCK = "unlock";
public static final String CMD_ENABLE = "enable";
public static final String CMD_ENGINE_TYPE = "engine_type";
public static final String CMD_ENGINESNIFFERRPMTHRESHOLD = "engineSnifferRpmThreshold";
@@ -53,6 +54,7 @@ public class BoostControl {
public static final String CMD_IGNITION_PIN = "set_ignition_pin";
public static final String CMD_INJECTION = "injection";
public static final String CMD_INJECTION_PIN = "set_injection_pin";
+ public static final int CMD_KEYPAD = 0x17;
public static final String CMD_LOGIC_PIN = "set_logic_input_pin";
public static final String CMD_MIL_BENCH = "milbench";
public static final String CMD_PINS = "pins";
@@ -73,13 +75,12 @@ public class BoostControl {
public static final int CMD_TS_BENCH_CATEGORY = 22;
public static final int CMD_TS_LUA_OUTPUT_CATEGORY = 33;
public static final int CMD_TS_SOLENOID_CATEGORY = 41;
+ public static final int CMD_TS_WBO_UPDATE = 0x15;
public static final int CMD_TS_X14 = 20;
public static final int CMD_TS_X31 = 49;
public static final String CMD_VSS_PIN = "vss_pin";
public static final String CMD_WRITECONFIG = "writeconfig";
- public static final int COMPOSITE_DATA_LENGTH = 2500;
- public static final int COMPOSITE_DATA_LENGTH_HALF = 1250;
- public static final int COMPOSITE_PACKET_COUNT = 500;
+ public static final int COMPOSITE_PACKET_COUNT = 1000;
public static final int COMPOSITE_PACKET_SIZE = 5;
public static final String CONSOLE_DATA_PROTOCOL_TAG = " @";
public static final int CRANKING_ADVANCE_CURVE_SIZE = 4;
@@ -341,6 +342,9 @@ public class BoostControl {
public static final int TPS_2_BYTE_PACKING_MULT = 100;
public static final int TPS_TPS_ACCEL_TABLE = 8;
public static final String TRIGGER_COMMENT = "#";
+ public static final String TRIGGER_GAP_FROM = "gapFrom";
+ public static final String TRIGGER_GAP_TO = "gapTo";
+ public static final String TRIGGER_GAPS_COUNT = "gapsCount";
public static final String TRIGGER_HARDCODED_OPERATION_MODE = "knownOperationMode";
public static final String TRIGGER_HAS_SECOND_CHANNEL = "hasSecondChannel";
public static final int TRIGGER_INPUT_PIN_COUNT = 2;
@@ -423,8 +427,8 @@ public class BoostControl {
public static final Field UNUSEDBIT_5_29 = Field.create("UNUSEDBIT_5_29", 0, FieldType.BIT, 29);
public static final Field UNUSEDBIT_5_30 = Field.create("UNUSEDBIT_5_30", 0, FieldType.BIT, 30);
public static final Field UNUSEDBIT_5_31 = Field.create("UNUSEDBIT_5_31", 0, FieldType.BIT, 31);
- public static final Field LOADTARGETADD = Field.create("LOADTARGETADD", 4, FieldType.FLOAT);
- public static final Field LOADTARGETMULT = Field.create("LOADTARGETMULT", 8, FieldType.FLOAT);
+ public static final Field LUATARGETADD = Field.create("LUATARGETADD", 4, FieldType.FLOAT);
+ public static final Field LUATARGETMULT = Field.create("LUATARGETMULT", 8, FieldType.FLOAT);
public static final Field OPENLOOPPART = Field.create("OPENLOOPPART", 12, FieldType.FLOAT);
public static final Field BOOSTCONTROLLERCLOSEDLOOPPART = Field.create("BOOSTCONTROLLERCLOSEDLOOPPART", 16, FieldType.INT8).setScale(0.5);
public static final Field ALIGNMENTFILL_AT_17 = Field.create("ALIGNMENTFILL_AT_17", 17, FieldType.INT8).setScale(1.0);
@@ -462,8 +466,8 @@ public class BoostControl {
UNUSEDBIT_5_29,
UNUSEDBIT_5_30,
UNUSEDBIT_5_31,
- LOADTARGETADD,
- LOADTARGETMULT,
+ LUATARGETADD,
+ LUATARGETMULT,
OPENLOOPPART,
BOOSTCONTROLLERCLOSEDLOOPPART,
ALIGNMENTFILL_AT_17,
diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/EngineState.java b/java_console/models/src/main/java/com/rusefi/config/generated/EngineState.java
index 31d28e3107..91e58d7129 100644
--- a/java_console/models/src/main/java/com/rusefi/config/generated/EngineState.java
+++ b/java_console/models/src/main/java/com/rusefi/config/generated/EngineState.java
@@ -1,6 +1,6 @@
package com.rusefi.config.generated;
-// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Thu Jun 30 17:52:53 UTC 2022
+// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/algo/engine_state.txt Sat Jul 30 15:33:11 UTC 2022
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@@ -35,6 +35,7 @@ public class EngineState {
public static final String CMD_BURNCONFIG = "burnconfig";
public static final String CMD_DATE = "date";
public static final String CMD_DISABLE = "disable";
+ public static final String CMD_ECU_UNLOCK = "unlock";
public static final String CMD_ENABLE = "enable";
public static final String CMD_ENGINE_TYPE = "engine_type";
public static final String CMD_ENGINESNIFFERRPMTHRESHOLD = "engineSnifferRpmThreshold";
@@ -53,6 +54,7 @@ public class EngineState {
public static final String CMD_IGNITION_PIN = "set_ignition_pin";
public static final String CMD_INJECTION = "injection";
public static final String CMD_INJECTION_PIN = "set_injection_pin";
+ public static final int CMD_KEYPAD = 0x17;
public static final String CMD_LOGIC_PIN = "set_logic_input_pin";
public static final String CMD_MIL_BENCH = "milbench";
public static final String CMD_PINS = "pins";
@@ -73,13 +75,12 @@ public class EngineState {
public static final int CMD_TS_BENCH_CATEGORY = 22;
public static final int CMD_TS_LUA_OUTPUT_CATEGORY = 33;
public static final int CMD_TS_SOLENOID_CATEGORY = 41;
+ public static final int CMD_TS_WBO_UPDATE = 0x15;
public static final int CMD_TS_X14 = 20;
public static final int CMD_TS_X31 = 49;
public static final String CMD_VSS_PIN = "vss_pin";
public static final String CMD_WRITECONFIG = "writeconfig";
- public static final int COMPOSITE_DATA_LENGTH = 2500;
- public static final int COMPOSITE_DATA_LENGTH_HALF = 1250;
- public static final int COMPOSITE_PACKET_COUNT = 500;
+ public static final int COMPOSITE_PACKET_COUNT = 1000;
public static final int COMPOSITE_PACKET_SIZE = 5;
public static final String CONSOLE_DATA_PROTOCOL_TAG = " @";
public static final int CRANKING_ADVANCE_CURVE_SIZE = 4;
@@ -341,6 +342,9 @@ public class EngineState {
public static final int TPS_2_BYTE_PACKING_MULT = 100;
public static final int TPS_TPS_ACCEL_TABLE = 8;
public static final String TRIGGER_COMMENT = "#";
+ public static final String TRIGGER_GAP_FROM = "gapFrom";
+ public static final String TRIGGER_GAP_TO = "gapTo";
+ public static final String TRIGGER_GAPS_COUNT = "gapsCount";
public static final String TRIGGER_HARDCODED_OPERATION_MODE = "knownOperationMode";
public static final String TRIGGER_HAS_SECOND_CHANNEL = "hasSecondChannel";
public static final int TRIGGER_INPUT_PIN_COUNT = 2;
@@ -395,36 +399,36 @@ public class EngineState {
public static final Field LUA_FUELMULT = Field.create("LUA_FUELMULT", 4, FieldType.FLOAT);
public static final Field LUA_CLUTCHUPSTATE = Field.create("LUA_CLUTCHUPSTATE", 8, FieldType.BIT, 0);
public static final Field LUA_BRAKEPEDALSTATE = Field.create("LUA_BRAKEPEDALSTATE", 8, FieldType.BIT, 1);
- public static final Field LUA_UNUSEDBIT_4_2 = Field.create("LUA_UNUSEDBIT_4_2", 8, FieldType.BIT, 2);
- public static final Field LUA_UNUSEDBIT_4_3 = Field.create("LUA_UNUSEDBIT_4_3", 8, FieldType.BIT, 3);
- public static final Field LUA_UNUSEDBIT_4_4 = Field.create("LUA_UNUSEDBIT_4_4", 8, FieldType.BIT, 4);
- public static final Field LUA_UNUSEDBIT_4_5 = Field.create("LUA_UNUSEDBIT_4_5", 8, FieldType.BIT, 5);
- public static final Field LUA_UNUSEDBIT_4_6 = Field.create("LUA_UNUSEDBIT_4_6", 8, FieldType.BIT, 6);
- public static final Field LUA_UNUSEDBIT_4_7 = Field.create("LUA_UNUSEDBIT_4_7", 8, FieldType.BIT, 7);
- public static final Field LUA_UNUSEDBIT_4_8 = Field.create("LUA_UNUSEDBIT_4_8", 8, FieldType.BIT, 8);
- public static final Field LUA_UNUSEDBIT_4_9 = Field.create("LUA_UNUSEDBIT_4_9", 8, FieldType.BIT, 9);
- public static final Field LUA_UNUSEDBIT_4_10 = Field.create("LUA_UNUSEDBIT_4_10", 8, FieldType.BIT, 10);
- public static final Field LUA_UNUSEDBIT_4_11 = Field.create("LUA_UNUSEDBIT_4_11", 8, FieldType.BIT, 11);
- public static final Field LUA_UNUSEDBIT_4_12 = Field.create("LUA_UNUSEDBIT_4_12", 8, FieldType.BIT, 12);
- public static final Field LUA_UNUSEDBIT_4_13 = Field.create("LUA_UNUSEDBIT_4_13", 8, FieldType.BIT, 13);
- public static final Field LUA_UNUSEDBIT_4_14 = Field.create("LUA_UNUSEDBIT_4_14", 8, FieldType.BIT, 14);
- public static final Field LUA_UNUSEDBIT_4_15 = Field.create("LUA_UNUSEDBIT_4_15", 8, FieldType.BIT, 15);
- public static final Field LUA_UNUSEDBIT_4_16 = Field.create("LUA_UNUSEDBIT_4_16", 8, FieldType.BIT, 16);
- public static final Field LUA_UNUSEDBIT_4_17 = Field.create("LUA_UNUSEDBIT_4_17", 8, FieldType.BIT, 17);
- public static final Field LUA_UNUSEDBIT_4_18 = Field.create("LUA_UNUSEDBIT_4_18", 8, FieldType.BIT, 18);
- public static final Field LUA_UNUSEDBIT_4_19 = Field.create("LUA_UNUSEDBIT_4_19", 8, FieldType.BIT, 19);
- public static final Field LUA_UNUSEDBIT_4_20 = Field.create("LUA_UNUSEDBIT_4_20", 8, FieldType.BIT, 20);
- public static final Field LUA_UNUSEDBIT_4_21 = Field.create("LUA_UNUSEDBIT_4_21", 8, FieldType.BIT, 21);
- public static final Field LUA_UNUSEDBIT_4_22 = Field.create("LUA_UNUSEDBIT_4_22", 8, FieldType.BIT, 22);
- public static final Field LUA_UNUSEDBIT_4_23 = Field.create("LUA_UNUSEDBIT_4_23", 8, FieldType.BIT, 23);
- public static final Field LUA_UNUSEDBIT_4_24 = Field.create("LUA_UNUSEDBIT_4_24", 8, FieldType.BIT, 24);
- public static final Field LUA_UNUSEDBIT_4_25 = Field.create("LUA_UNUSEDBIT_4_25", 8, FieldType.BIT, 25);
- public static final Field LUA_UNUSEDBIT_4_26 = Field.create("LUA_UNUSEDBIT_4_26", 8, FieldType.BIT, 26);
- public static final Field LUA_UNUSEDBIT_4_27 = Field.create("LUA_UNUSEDBIT_4_27", 8, FieldType.BIT, 27);
- public static final Field LUA_UNUSEDBIT_4_28 = Field.create("LUA_UNUSEDBIT_4_28", 8, FieldType.BIT, 28);
- public static final Field LUA_UNUSEDBIT_4_29 = Field.create("LUA_UNUSEDBIT_4_29", 8, FieldType.BIT, 29);
- public static final Field LUA_UNUSEDBIT_4_30 = Field.create("LUA_UNUSEDBIT_4_30", 8, FieldType.BIT, 30);
- public static final Field LUA_UNUSEDBIT_4_31 = Field.create("LUA_UNUSEDBIT_4_31", 8, FieldType.BIT, 31);
+ public static final Field LUA_ACREQUESTSTATE = Field.create("LUA_ACREQUESTSTATE", 8, FieldType.BIT, 2);
+ public static final Field LUA_UNUSEDBIT_5_3 = Field.create("LUA_UNUSEDBIT_5_3", 8, FieldType.BIT, 3);
+ public static final Field LUA_UNUSEDBIT_5_4 = Field.create("LUA_UNUSEDBIT_5_4", 8, FieldType.BIT, 4);
+ public static final Field LUA_UNUSEDBIT_5_5 = Field.create("LUA_UNUSEDBIT_5_5", 8, FieldType.BIT, 5);
+ public static final Field LUA_UNUSEDBIT_5_6 = Field.create("LUA_UNUSEDBIT_5_6", 8, FieldType.BIT, 6);
+ public static final Field LUA_UNUSEDBIT_5_7 = Field.create("LUA_UNUSEDBIT_5_7", 8, FieldType.BIT, 7);
+ public static final Field LUA_UNUSEDBIT_5_8 = Field.create("LUA_UNUSEDBIT_5_8", 8, FieldType.BIT, 8);
+ public static final Field LUA_UNUSEDBIT_5_9 = Field.create("LUA_UNUSEDBIT_5_9", 8, FieldType.BIT, 9);
+ public static final Field LUA_UNUSEDBIT_5_10 = Field.create("LUA_UNUSEDBIT_5_10", 8, FieldType.BIT, 10);
+ public static final Field LUA_UNUSEDBIT_5_11 = Field.create("LUA_UNUSEDBIT_5_11", 8, FieldType.BIT, 11);
+ public static final Field LUA_UNUSEDBIT_5_12 = Field.create("LUA_UNUSEDBIT_5_12", 8, FieldType.BIT, 12);
+ public static final Field LUA_UNUSEDBIT_5_13 = Field.create("LUA_UNUSEDBIT_5_13", 8, FieldType.BIT, 13);
+ public static final Field LUA_UNUSEDBIT_5_14 = Field.create("LUA_UNUSEDBIT_5_14", 8, FieldType.BIT, 14);
+ public static final Field LUA_UNUSEDBIT_5_15 = Field.create("LUA_UNUSEDBIT_5_15", 8, FieldType.BIT, 15);
+ public static final Field LUA_UNUSEDBIT_5_16 = Field.create("LUA_UNUSEDBIT_5_16", 8, FieldType.BIT, 16);
+ public static final Field LUA_UNUSEDBIT_5_17 = Field.create("LUA_UNUSEDBIT_5_17", 8, FieldType.BIT, 17);
+ public static final Field LUA_UNUSEDBIT_5_18 = Field.create("LUA_UNUSEDBIT_5_18", 8, FieldType.BIT, 18);
+ public static final Field LUA_UNUSEDBIT_5_19 = Field.create("LUA_UNUSEDBIT_5_19", 8, FieldType.BIT, 19);
+ public static final Field LUA_UNUSEDBIT_5_20 = Field.create("LUA_UNUSEDBIT_5_20", 8, FieldType.BIT, 20);
+ public static final Field LUA_UNUSEDBIT_5_21 = Field.create("LUA_UNUSEDBIT_5_21", 8, FieldType.BIT, 21);
+ public static final Field LUA_UNUSEDBIT_5_22 = Field.create("LUA_UNUSEDBIT_5_22", 8, FieldType.BIT, 22);
+ public static final Field LUA_UNUSEDBIT_5_23 = Field.create("LUA_UNUSEDBIT_5_23", 8, FieldType.BIT, 23);
+ public static final Field LUA_UNUSEDBIT_5_24 = Field.create("LUA_UNUSEDBIT_5_24", 8, FieldType.BIT, 24);
+ public static final Field LUA_UNUSEDBIT_5_25 = Field.create("LUA_UNUSEDBIT_5_25", 8, FieldType.BIT, 25);
+ public static final Field LUA_UNUSEDBIT_5_26 = Field.create("LUA_UNUSEDBIT_5_26", 8, FieldType.BIT, 26);
+ public static final Field LUA_UNUSEDBIT_5_27 = Field.create("LUA_UNUSEDBIT_5_27", 8, FieldType.BIT, 27);
+ public static final Field LUA_UNUSEDBIT_5_28 = Field.create("LUA_UNUSEDBIT_5_28", 8, FieldType.BIT, 28);
+ public static final Field LUA_UNUSEDBIT_5_29 = Field.create("LUA_UNUSEDBIT_5_29", 8, FieldType.BIT, 29);
+ public static final Field LUA_UNUSEDBIT_5_30 = Field.create("LUA_UNUSEDBIT_5_30", 8, FieldType.BIT, 30);
+ public static final Field LUA_UNUSEDBIT_5_31 = Field.create("LUA_UNUSEDBIT_5_31", 8, FieldType.BIT, 31);
public static final Field SD_ISTCHARGEAIRMODEL = Field.create("SD_ISTCHARGEAIRMODEL", 12, FieldType.BIT, 0);
public static final Field SD_UNUSEDBIT_1_1 = Field.create("SD_UNUSEDBIT_1_1", 12, FieldType.BIT, 1);
public static final Field SD_UNUSEDBIT_1_2 = Field.create("SD_UNUSEDBIT_1_2", 12, FieldType.BIT, 2);
@@ -526,36 +530,36 @@ public class EngineState {
LUA_FUELMULT,
LUA_CLUTCHUPSTATE,
LUA_BRAKEPEDALSTATE,
- LUA_UNUSEDBIT_4_2,
- LUA_UNUSEDBIT_4_3,
- LUA_UNUSEDBIT_4_4,
- LUA_UNUSEDBIT_4_5,
- LUA_UNUSEDBIT_4_6,
- LUA_UNUSEDBIT_4_7,
- LUA_UNUSEDBIT_4_8,
- LUA_UNUSEDBIT_4_9,
- LUA_UNUSEDBIT_4_10,
- LUA_UNUSEDBIT_4_11,
- LUA_UNUSEDBIT_4_12,
- LUA_UNUSEDBIT_4_13,
- LUA_UNUSEDBIT_4_14,
- LUA_UNUSEDBIT_4_15,
- LUA_UNUSEDBIT_4_16,
- LUA_UNUSEDBIT_4_17,
- LUA_UNUSEDBIT_4_18,
- LUA_UNUSEDBIT_4_19,
- LUA_UNUSEDBIT_4_20,
- LUA_UNUSEDBIT_4_21,
- LUA_UNUSEDBIT_4_22,
- LUA_UNUSEDBIT_4_23,
- LUA_UNUSEDBIT_4_24,
- LUA_UNUSEDBIT_4_25,
- LUA_UNUSEDBIT_4_26,
- LUA_UNUSEDBIT_4_27,
- LUA_UNUSEDBIT_4_28,
- LUA_UNUSEDBIT_4_29,
- LUA_UNUSEDBIT_4_30,
- LUA_UNUSEDBIT_4_31,
+ LUA_ACREQUESTSTATE,
+ LUA_UNUSEDBIT_5_3,
+ LUA_UNUSEDBIT_5_4,
+ LUA_UNUSEDBIT_5_5,
+ LUA_UNUSEDBIT_5_6,
+ LUA_UNUSEDBIT_5_7,
+ LUA_UNUSEDBIT_5_8,
+ LUA_UNUSEDBIT_5_9,
+ LUA_UNUSEDBIT_5_10,
+ LUA_UNUSEDBIT_5_11,
+ LUA_UNUSEDBIT_5_12,
+ LUA_UNUSEDBIT_5_13,
+ LUA_UNUSEDBIT_5_14,
+ LUA_UNUSEDBIT_5_15,
+ LUA_UNUSEDBIT_5_16,
+ LUA_UNUSEDBIT_5_17,
+ LUA_UNUSEDBIT_5_18,
+ LUA_UNUSEDBIT_5_19,
+ LUA_UNUSEDBIT_5_20,
+ LUA_UNUSEDBIT_5_21,
+ LUA_UNUSEDBIT_5_22,
+ LUA_UNUSEDBIT_5_23,
+ LUA_UNUSEDBIT_5_24,
+ LUA_UNUSEDBIT_5_25,
+ LUA_UNUSEDBIT_5_26,
+ LUA_UNUSEDBIT_5_27,
+ LUA_UNUSEDBIT_5_28,
+ LUA_UNUSEDBIT_5_29,
+ LUA_UNUSEDBIT_5_30,
+ LUA_UNUSEDBIT_5_31,
SD_ISTCHARGEAIRMODEL,
SD_UNUSEDBIT_1_1,
SD_UNUSEDBIT_1_2,
diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/TriggerState.java b/java_console/models/src/main/java/com/rusefi/config/generated/TriggerState.java
index 8734135ee3..de02b4bb94 100644
--- a/java_console/models/src/main/java/com/rusefi/config/generated/TriggerState.java
+++ b/java_console/models/src/main/java/com/rusefi/config/generated/TriggerState.java
@@ -1,6 +1,6 @@
package com.rusefi.config.generated;
-// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/trigger/trigger_state.txt Wed Jun 29 22:51:54 UTC 2022
+// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/trigger/trigger_state.txt Sat Jul 30 15:33:11 UTC 2022
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@@ -35,6 +35,7 @@ public class TriggerState {
public static final String CMD_BURNCONFIG = "burnconfig";
public static final String CMD_DATE = "date";
public static final String CMD_DISABLE = "disable";
+ public static final String CMD_ECU_UNLOCK = "unlock";
public static final String CMD_ENABLE = "enable";
public static final String CMD_ENGINE_TYPE = "engine_type";
public static final String CMD_ENGINESNIFFERRPMTHRESHOLD = "engineSnifferRpmThreshold";
@@ -53,6 +54,7 @@ public class TriggerState {
public static final String CMD_IGNITION_PIN = "set_ignition_pin";
public static final String CMD_INJECTION = "injection";
public static final String CMD_INJECTION_PIN = "set_injection_pin";
+ public static final int CMD_KEYPAD = 0x17;
public static final String CMD_LOGIC_PIN = "set_logic_input_pin";
public static final String CMD_MIL_BENCH = "milbench";
public static final String CMD_PINS = "pins";
@@ -73,13 +75,12 @@ public class TriggerState {
public static final int CMD_TS_BENCH_CATEGORY = 22;
public static final int CMD_TS_LUA_OUTPUT_CATEGORY = 33;
public static final int CMD_TS_SOLENOID_CATEGORY = 41;
+ public static final int CMD_TS_WBO_UPDATE = 0x15;
public static final int CMD_TS_X14 = 20;
public static final int CMD_TS_X31 = 49;
public static final String CMD_VSS_PIN = "vss_pin";
public static final String CMD_WRITECONFIG = "writeconfig";
- public static final int COMPOSITE_DATA_LENGTH = 2500;
- public static final int COMPOSITE_DATA_LENGTH_HALF = 1250;
- public static final int COMPOSITE_PACKET_COUNT = 500;
+ public static final int COMPOSITE_PACKET_COUNT = 1000;
public static final int COMPOSITE_PACKET_SIZE = 5;
public static final String CONSOLE_DATA_PROTOCOL_TAG = " @";
public static final int CRANKING_ADVANCE_CURVE_SIZE = 4;
@@ -341,6 +342,9 @@ public class TriggerState {
public static final int TPS_2_BYTE_PACKING_MULT = 100;
public static final int TPS_TPS_ACCEL_TABLE = 8;
public static final String TRIGGER_COMMENT = "#";
+ public static final String TRIGGER_GAP_FROM = "gapFrom";
+ public static final String TRIGGER_GAP_TO = "gapTo";
+ public static final String TRIGGER_GAPS_COUNT = "gapsCount";
public static final String TRIGGER_HARDCODED_OPERATION_MODE = "knownOperationMode";
public static final String TRIGGER_HAS_SECOND_CHANNEL = "hasSecondChannel";
public static final int TRIGGER_INPUT_PIN_COUNT = 2;
diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/TsOutputs.java b/java_console/models/src/main/java/com/rusefi/config/generated/TsOutputs.java
index ce86718df4..9c9c7ce5e2 100644
--- a/java_console/models/src/main/java/com/rusefi/config/generated/TsOutputs.java
+++ b/java_console/models/src/main/java/com/rusefi/config/generated/TsOutputs.java
@@ -1,6 +1,6 @@
package com.rusefi.config.generated;
-// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Wed Jun 29 22:51:52 UTC 2022
+// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) console/binary/output_channels.txt Sat Jul 30 15:33:10 UTC 2022
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@@ -35,6 +35,7 @@ public class TsOutputs {
public static final String CMD_BURNCONFIG = "burnconfig";
public static final String CMD_DATE = "date";
public static final String CMD_DISABLE = "disable";
+ public static final String CMD_ECU_UNLOCK = "unlock";
public static final String CMD_ENABLE = "enable";
public static final String CMD_ENGINE_TYPE = "engine_type";
public static final String CMD_ENGINESNIFFERRPMTHRESHOLD = "engineSnifferRpmThreshold";
@@ -53,6 +54,7 @@ public class TsOutputs {
public static final String CMD_IGNITION_PIN = "set_ignition_pin";
public static final String CMD_INJECTION = "injection";
public static final String CMD_INJECTION_PIN = "set_injection_pin";
+ public static final int CMD_KEYPAD = 0x17;
public static final String CMD_LOGIC_PIN = "set_logic_input_pin";
public static final String CMD_MIL_BENCH = "milbench";
public static final String CMD_PINS = "pins";
@@ -73,13 +75,12 @@ public class TsOutputs {
public static final int CMD_TS_BENCH_CATEGORY = 22;
public static final int CMD_TS_LUA_OUTPUT_CATEGORY = 33;
public static final int CMD_TS_SOLENOID_CATEGORY = 41;
+ public static final int CMD_TS_WBO_UPDATE = 0x15;
public static final int CMD_TS_X14 = 20;
public static final int CMD_TS_X31 = 49;
public static final String CMD_VSS_PIN = "vss_pin";
public static final String CMD_WRITECONFIG = "writeconfig";
- public static final int COMPOSITE_DATA_LENGTH = 2500;
- public static final int COMPOSITE_DATA_LENGTH_HALF = 1250;
- public static final int COMPOSITE_PACKET_COUNT = 500;
+ public static final int COMPOSITE_PACKET_COUNT = 1000;
public static final int COMPOSITE_PACKET_SIZE = 5;
public static final String CONSOLE_DATA_PROTOCOL_TAG = " @";
public static final int CRANKING_ADVANCE_CURVE_SIZE = 4;
@@ -341,6 +342,9 @@ public class TsOutputs {
public static final int TPS_2_BYTE_PACKING_MULT = 100;
public static final int TPS_TPS_ACCEL_TABLE = 8;
public static final String TRIGGER_COMMENT = "#";
+ public static final String TRIGGER_GAP_FROM = "gapFrom";
+ public static final String TRIGGER_GAP_TO = "gapTo";
+ public static final String TRIGGER_GAPS_COUNT = "gapsCount";
public static final String TRIGGER_HARDCODED_OPERATION_MODE = "knownOperationMode";
public static final String TRIGGER_HAS_SECOND_CHANNEL = "hasSecondChannel";
public static final int TRIGGER_INPUT_PIN_COUNT = 2;
@@ -690,107 +694,46 @@ public class TsOutputs {
public static final Field MULTISPARKCOUNTER = Field.create("MULTISPARKCOUNTER", 431, FieldType.INT8).setScale(1.0);
public static final Field INJECTORFLOWPRESSURERATIO = Field.create("INJECTORFLOWPRESSURERATIO", 432, FieldType.FLOAT);
public static final Field INJECTORFLOWPRESSUREDELTA = Field.create("INJECTORFLOWPRESSUREDELTA", 436, FieldType.FLOAT);
- public static final Field ALTERNATORSTATUS_ITERM = Field.create("ALTERNATORSTATUS_ITERM", 440, FieldType.INT16).setScale(0.01);
- public static final Field ALTERNATORSTATUS_DTERM = Field.create("ALTERNATORSTATUS_DTERM", 442, FieldType.INT16).setScale(0.01);
- public static final Field ALTERNATORSTATUS_OUTPUT = Field.create("ALTERNATORSTATUS_OUTPUT", 444, FieldType.INT16).setScale(0.01);
- public static final Field ALTERNATORSTATUS_ERROR = Field.create("ALTERNATORSTATUS_ERROR", 446, FieldType.INT16).setScale(0.01);
- public static final Field ALTERNATORSTATUS_RESETCOUNTER = Field.create("ALTERNATORSTATUS_RESETCOUNTER", 448, FieldType.INT).setScale(1.0);
- public static final Field IDLESTATUS_ITERM = Field.create("IDLESTATUS_ITERM", 452, FieldType.INT16).setScale(0.01);
- public static final Field IDLESTATUS_DTERM = Field.create("IDLESTATUS_DTERM", 454, FieldType.INT16).setScale(0.01);
- public static final Field IDLESTATUS_OUTPUT = Field.create("IDLESTATUS_OUTPUT", 456, FieldType.INT16).setScale(0.01);
- public static final Field IDLESTATUS_ERROR = Field.create("IDLESTATUS_ERROR", 458, FieldType.INT16).setScale(0.01);
- public static final Field IDLESTATUS_RESETCOUNTER = Field.create("IDLESTATUS_RESETCOUNTER", 460, FieldType.INT).setScale(1.0);
- public static final Field ETBSTATUS_ITERM = Field.create("ETBSTATUS_ITERM", 464, FieldType.INT16).setScale(0.01);
- public static final Field ETBSTATUS_DTERM = Field.create("ETBSTATUS_DTERM", 466, FieldType.INT16).setScale(0.01);
- public static final Field ETBSTATUS_OUTPUT = Field.create("ETBSTATUS_OUTPUT", 468, FieldType.INT16).setScale(0.01);
- public static final Field ETBSTATUS_ERROR = Field.create("ETBSTATUS_ERROR", 470, FieldType.INT16).setScale(0.01);
- public static final Field ETBSTATUS_RESETCOUNTER = Field.create("ETBSTATUS_RESETCOUNTER", 472, FieldType.INT).setScale(1.0);
- public static final Field BOOSTSTATUS_ITERM = Field.create("BOOSTSTATUS_ITERM", 476, FieldType.INT16).setScale(0.01);
- public static final Field BOOSTSTATUS_DTERM = Field.create("BOOSTSTATUS_DTERM", 478, FieldType.INT16).setScale(0.01);
- public static final Field BOOSTSTATUS_OUTPUT = Field.create("BOOSTSTATUS_OUTPUT", 480, FieldType.INT16).setScale(0.01);
- public static final Field BOOSTSTATUS_ERROR = Field.create("BOOSTSTATUS_ERROR", 482, FieldType.INT16).setScale(0.01);
- public static final Field BOOSTSTATUS_RESETCOUNTER = Field.create("BOOSTSTATUS_RESETCOUNTER", 484, FieldType.INT).setScale(1.0);
- public static final Field AUXSPEED1 = Field.create("AUXSPEED1", 488, FieldType.INT16).setScale(1.0);
- public static final Field AUXSPEED2 = Field.create("AUXSPEED2", 490, FieldType.INT16).setScale(1.0);
- public static final Field ISSVALUE = Field.create("ISSVALUE", 492, FieldType.INT16).setScale(1.0);
- public static final Field UNUSEDATTHEEND1 = Field.create("UNUSEDATTHEEND1", 494, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND2 = Field.create("UNUSEDATTHEEND2", 495, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND3 = Field.create("UNUSEDATTHEEND3", 496, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND4 = Field.create("UNUSEDATTHEEND4", 497, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND5 = Field.create("UNUSEDATTHEEND5", 498, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND6 = Field.create("UNUSEDATTHEEND6", 499, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND7 = Field.create("UNUSEDATTHEEND7", 500, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND8 = Field.create("UNUSEDATTHEEND8", 501, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND9 = Field.create("UNUSEDATTHEEND9", 502, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND10 = Field.create("UNUSEDATTHEEND10", 503, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND11 = Field.create("UNUSEDATTHEEND11", 504, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND12 = Field.create("UNUSEDATTHEEND12", 505, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND13 = Field.create("UNUSEDATTHEEND13", 506, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND14 = Field.create("UNUSEDATTHEEND14", 507, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND15 = Field.create("UNUSEDATTHEEND15", 508, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND16 = Field.create("UNUSEDATTHEEND16", 509, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND17 = Field.create("UNUSEDATTHEEND17", 510, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND18 = Field.create("UNUSEDATTHEEND18", 511, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND19 = Field.create("UNUSEDATTHEEND19", 512, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND20 = Field.create("UNUSEDATTHEEND20", 513, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND21 = Field.create("UNUSEDATTHEEND21", 514, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND22 = Field.create("UNUSEDATTHEEND22", 515, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND23 = Field.create("UNUSEDATTHEEND23", 516, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND24 = Field.create("UNUSEDATTHEEND24", 517, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND25 = Field.create("UNUSEDATTHEEND25", 518, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND26 = Field.create("UNUSEDATTHEEND26", 519, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND27 = Field.create("UNUSEDATTHEEND27", 520, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND28 = Field.create("UNUSEDATTHEEND28", 521, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND29 = Field.create("UNUSEDATTHEEND29", 522, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND30 = Field.create("UNUSEDATTHEEND30", 523, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND31 = Field.create("UNUSEDATTHEEND31", 524, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND32 = Field.create("UNUSEDATTHEEND32", 525, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND33 = Field.create("UNUSEDATTHEEND33", 526, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND34 = Field.create("UNUSEDATTHEEND34", 527, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND35 = Field.create("UNUSEDATTHEEND35", 528, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND36 = Field.create("UNUSEDATTHEEND36", 529, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND37 = Field.create("UNUSEDATTHEEND37", 530, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND38 = Field.create("UNUSEDATTHEEND38", 531, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND39 = Field.create("UNUSEDATTHEEND39", 532, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND40 = Field.create("UNUSEDATTHEEND40", 533, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND41 = Field.create("UNUSEDATTHEEND41", 534, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND42 = Field.create("UNUSEDATTHEEND42", 535, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND43 = Field.create("UNUSEDATTHEEND43", 536, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND44 = Field.create("UNUSEDATTHEEND44", 537, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND45 = Field.create("UNUSEDATTHEEND45", 538, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND46 = Field.create("UNUSEDATTHEEND46", 539, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND47 = Field.create("UNUSEDATTHEEND47", 540, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND48 = Field.create("UNUSEDATTHEEND48", 541, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND49 = Field.create("UNUSEDATTHEEND49", 542, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND50 = Field.create("UNUSEDATTHEEND50", 543, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND51 = Field.create("UNUSEDATTHEEND51", 544, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND52 = Field.create("UNUSEDATTHEEND52", 545, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND53 = Field.create("UNUSEDATTHEEND53", 546, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND54 = Field.create("UNUSEDATTHEEND54", 547, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND55 = Field.create("UNUSEDATTHEEND55", 548, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND56 = Field.create("UNUSEDATTHEEND56", 549, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND57 = Field.create("UNUSEDATTHEEND57", 550, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND58 = Field.create("UNUSEDATTHEEND58", 551, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND59 = Field.create("UNUSEDATTHEEND59", 552, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND60 = Field.create("UNUSEDATTHEEND60", 553, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND61 = Field.create("UNUSEDATTHEEND61", 554, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND62 = Field.create("UNUSEDATTHEEND62", 555, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND63 = Field.create("UNUSEDATTHEEND63", 556, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND64 = Field.create("UNUSEDATTHEEND64", 557, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND65 = Field.create("UNUSEDATTHEEND65", 558, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND66 = Field.create("UNUSEDATTHEEND66", 559, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND67 = Field.create("UNUSEDATTHEEND67", 560, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND68 = Field.create("UNUSEDATTHEEND68", 561, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND69 = Field.create("UNUSEDATTHEEND69", 562, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND70 = Field.create("UNUSEDATTHEEND70", 563, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND71 = Field.create("UNUSEDATTHEEND71", 564, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND72 = Field.create("UNUSEDATTHEEND72", 565, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND73 = Field.create("UNUSEDATTHEEND73", 566, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND74 = Field.create("UNUSEDATTHEEND74", 567, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND75 = Field.create("UNUSEDATTHEEND75", 568, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND76 = Field.create("UNUSEDATTHEEND76", 569, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND77 = Field.create("UNUSEDATTHEEND77", 570, FieldType.INT8).setScale(1.0);
- public static final Field UNUSEDATTHEEND78 = Field.create("UNUSEDATTHEEND78", 571, FieldType.INT8).setScale(1.0);
+ public static final Field ALTERNATORSTATUS_PTERM = Field.create("ALTERNATORSTATUS_PTERM", 440, FieldType.FLOAT);
+ public static final Field ALTERNATORSTATUS_ITERM = Field.create("ALTERNATORSTATUS_ITERM", 444, FieldType.INT16).setScale(0.01);
+ public static final Field ALTERNATORSTATUS_DTERM = Field.create("ALTERNATORSTATUS_DTERM", 446, FieldType.INT16).setScale(0.01);
+ public static final Field ALTERNATORSTATUS_OUTPUT = Field.create("ALTERNATORSTATUS_OUTPUT", 448, FieldType.INT16).setScale(0.01);
+ public static final Field ALTERNATORSTATUS_ERROR = Field.create("ALTERNATORSTATUS_ERROR", 450, FieldType.INT16).setScale(0.01);
+ public static final Field ALTERNATORSTATUS_RESETCOUNTER = Field.create("ALTERNATORSTATUS_RESETCOUNTER", 452, FieldType.INT).setScale(1.0);
+ public static final Field IDLESTATUS_PTERM = Field.create("IDLESTATUS_PTERM", 456, FieldType.FLOAT);
+ public static final Field IDLESTATUS_ITERM = Field.create("IDLESTATUS_ITERM", 460, FieldType.INT16).setScale(0.01);
+ public static final Field IDLESTATUS_DTERM = Field.create("IDLESTATUS_DTERM", 462, FieldType.INT16).setScale(0.01);
+ public static final Field IDLESTATUS_OUTPUT = Field.create("IDLESTATUS_OUTPUT", 464, FieldType.INT16).setScale(0.01);
+ public static final Field IDLESTATUS_ERROR = Field.create("IDLESTATUS_ERROR", 466, FieldType.INT16).setScale(0.01);
+ public static final Field IDLESTATUS_RESETCOUNTER = Field.create("IDLESTATUS_RESETCOUNTER", 468, FieldType.INT).setScale(1.0);
+ public static final Field ETBSTATUS_PTERM = Field.create("ETBSTATUS_PTERM", 472, FieldType.FLOAT);
+ public static final Field ETBSTATUS_ITERM = Field.create("ETBSTATUS_ITERM", 476, FieldType.INT16).setScale(0.01);
+ public static final Field ETBSTATUS_DTERM = Field.create("ETBSTATUS_DTERM", 478, FieldType.INT16).setScale(0.01);
+ public static final Field ETBSTATUS_OUTPUT = Field.create("ETBSTATUS_OUTPUT", 480, FieldType.INT16).setScale(0.01);
+ public static final Field ETBSTATUS_ERROR = Field.create("ETBSTATUS_ERROR", 482, FieldType.INT16).setScale(0.01);
+ public static final Field ETBSTATUS_RESETCOUNTER = Field.create("ETBSTATUS_RESETCOUNTER", 484, FieldType.INT).setScale(1.0);
+ public static final Field BOOSTSTATUS_PTERM = Field.create("BOOSTSTATUS_PTERM", 488, FieldType.FLOAT);
+ public static final Field BOOSTSTATUS_ITERM = Field.create("BOOSTSTATUS_ITERM", 492, FieldType.INT16).setScale(0.01);
+ public static final Field BOOSTSTATUS_DTERM = Field.create("BOOSTSTATUS_DTERM", 494, FieldType.INT16).setScale(0.01);
+ public static final Field BOOSTSTATUS_OUTPUT = Field.create("BOOSTSTATUS_OUTPUT", 496, FieldType.INT16).setScale(0.01);
+ public static final Field BOOSTSTATUS_ERROR = Field.create("BOOSTSTATUS_ERROR", 498, FieldType.INT16).setScale(0.01);
+ public static final Field BOOSTSTATUS_RESETCOUNTER = Field.create("BOOSTSTATUS_RESETCOUNTER", 500, FieldType.INT).setScale(1.0);
+ public static final Field AUXSPEED1 = Field.create("AUXSPEED1", 504, FieldType.INT16).setScale(1.0);
+ public static final Field AUXSPEED2 = Field.create("AUXSPEED2", 506, FieldType.INT16).setScale(1.0);
+ public static final Field ISSVALUE = Field.create("ISSVALUE", 508, FieldType.INT16).setScale(1.0);
+ public static final Field RAWANALOGINPUT1 = Field.create("RAWANALOGINPUT1", 510, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT2 = Field.create("RAWANALOGINPUT2", 512, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT3 = Field.create("RAWANALOGINPUT3", 514, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT4 = Field.create("RAWANALOGINPUT4", 516, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT5 = Field.create("RAWANALOGINPUT5", 518, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT6 = Field.create("RAWANALOGINPUT6", 520, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT7 = Field.create("RAWANALOGINPUT7", 522, FieldType.INT16).setScale(0.001);
+ public static final Field RAWANALOGINPUT8 = Field.create("RAWANALOGINPUT8", 524, FieldType.INT16).setScale(0.001);
+ public static final Field GPPWMOUTPUT1 = Field.create("GPPWMOUTPUT1", 526, FieldType.INT8).setScale(0.5);
+ public static final Field GPPWMOUTPUT2 = Field.create("GPPWMOUTPUT2", 527, FieldType.INT8).setScale(0.5);
+ public static final Field GPPWMOUTPUT3 = Field.create("GPPWMOUTPUT3", 528, FieldType.INT8).setScale(0.5);
+ public static final Field GPPWMOUTPUT4 = Field.create("GPPWMOUTPUT4", 529, FieldType.INT8).setScale(0.5);
+ public static final Field UNUSEDATTHEEND = Field.create("UNUSEDATTHEEND", 530, FieldType.INT8).setScale(1.0);
public static final Field[] VALUES = {
SD_PRESENT,
ISIGNITIONENABLEDINDICATOR,
@@ -1091,21 +1034,25 @@ public class TsOutputs {
MULTISPARKCOUNTER,
INJECTORFLOWPRESSURERATIO,
INJECTORFLOWPRESSUREDELTA,
+ ALTERNATORSTATUS_PTERM,
ALTERNATORSTATUS_ITERM,
ALTERNATORSTATUS_DTERM,
ALTERNATORSTATUS_OUTPUT,
ALTERNATORSTATUS_ERROR,
ALTERNATORSTATUS_RESETCOUNTER,
+ IDLESTATUS_PTERM,
IDLESTATUS_ITERM,
IDLESTATUS_DTERM,
IDLESTATUS_OUTPUT,
IDLESTATUS_ERROR,
IDLESTATUS_RESETCOUNTER,
+ ETBSTATUS_PTERM,
ETBSTATUS_ITERM,
ETBSTATUS_DTERM,
ETBSTATUS_OUTPUT,
ETBSTATUS_ERROR,
ETBSTATUS_RESETCOUNTER,
+ BOOSTSTATUS_PTERM,
BOOSTSTATUS_ITERM,
BOOSTSTATUS_DTERM,
BOOSTSTATUS_OUTPUT,
@@ -1114,83 +1061,18 @@ public class TsOutputs {
AUXSPEED1,
AUXSPEED2,
ISSVALUE,
- UNUSEDATTHEEND1,
- UNUSEDATTHEEND2,
- UNUSEDATTHEEND3,
- UNUSEDATTHEEND4,
- UNUSEDATTHEEND5,
- UNUSEDATTHEEND6,
- UNUSEDATTHEEND7,
- UNUSEDATTHEEND8,
- UNUSEDATTHEEND9,
- UNUSEDATTHEEND10,
- UNUSEDATTHEEND11,
- UNUSEDATTHEEND12,
- UNUSEDATTHEEND13,
- UNUSEDATTHEEND14,
- UNUSEDATTHEEND15,
- UNUSEDATTHEEND16,
- UNUSEDATTHEEND17,
- UNUSEDATTHEEND18,
- UNUSEDATTHEEND19,
- UNUSEDATTHEEND20,
- UNUSEDATTHEEND21,
- UNUSEDATTHEEND22,
- UNUSEDATTHEEND23,
- UNUSEDATTHEEND24,
- UNUSEDATTHEEND25,
- UNUSEDATTHEEND26,
- UNUSEDATTHEEND27,
- UNUSEDATTHEEND28,
- UNUSEDATTHEEND29,
- UNUSEDATTHEEND30,
- UNUSEDATTHEEND31,
- UNUSEDATTHEEND32,
- UNUSEDATTHEEND33,
- UNUSEDATTHEEND34,
- UNUSEDATTHEEND35,
- UNUSEDATTHEEND36,
- UNUSEDATTHEEND37,
- UNUSEDATTHEEND38,
- UNUSEDATTHEEND39,
- UNUSEDATTHEEND40,
- UNUSEDATTHEEND41,
- UNUSEDATTHEEND42,
- UNUSEDATTHEEND43,
- UNUSEDATTHEEND44,
- UNUSEDATTHEEND45,
- UNUSEDATTHEEND46,
- UNUSEDATTHEEND47,
- UNUSEDATTHEEND48,
- UNUSEDATTHEEND49,
- UNUSEDATTHEEND50,
- UNUSEDATTHEEND51,
- UNUSEDATTHEEND52,
- UNUSEDATTHEEND53,
- UNUSEDATTHEEND54,
- UNUSEDATTHEEND55,
- UNUSEDATTHEEND56,
- UNUSEDATTHEEND57,
- UNUSEDATTHEEND58,
- UNUSEDATTHEEND59,
- UNUSEDATTHEEND60,
- UNUSEDATTHEEND61,
- UNUSEDATTHEEND62,
- UNUSEDATTHEEND63,
- UNUSEDATTHEEND64,
- UNUSEDATTHEEND65,
- UNUSEDATTHEEND66,
- UNUSEDATTHEEND67,
- UNUSEDATTHEEND68,
- UNUSEDATTHEEND69,
- UNUSEDATTHEEND70,
- UNUSEDATTHEEND71,
- UNUSEDATTHEEND72,
- UNUSEDATTHEEND73,
- UNUSEDATTHEEND74,
- UNUSEDATTHEEND75,
- UNUSEDATTHEEND76,
- UNUSEDATTHEEND77,
- UNUSEDATTHEEND78,
+ RAWANALOGINPUT1,
+ RAWANALOGINPUT2,
+ RAWANALOGINPUT3,
+ RAWANALOGINPUT4,
+ RAWANALOGINPUT5,
+ RAWANALOGINPUT6,
+ RAWANALOGINPUT7,
+ RAWANALOGINPUT8,
+ GPPWMOUTPUT1,
+ GPPWMOUTPUT2,
+ GPPWMOUTPUT3,
+ GPPWMOUTPUT4,
+ UNUSEDATTHEEND,
};
}
diff --git a/java_console/models/src/main/java/com/rusefi/models/trigger/WheelMeta.java b/java_console/models/src/main/java/com/rusefi/models/trigger/WheelMeta.java
deleted file mode 100644
index 6aab6ddda3..0000000000
--- a/java_console/models/src/main/java/com/rusefi/models/trigger/WheelMeta.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.rusefi.models.trigger;
-
-public class WheelMeta {
- private final String name;
- private final boolean isFirstCrankBased;
-
- public WheelMeta(String name, boolean isFirstCrankBased) {
- this.name = name;
- this.isFirstCrankBased = isFirstCrankBased;
- }
-}
diff --git a/java_console/models/src/main/java/com/rusefi/models/trigger/WheelMetaReader.java b/java_console/models/src/main/java/com/rusefi/models/trigger/WheelMetaReader.java
deleted file mode 100644
index 9c4e9ef133..0000000000
--- a/java_console/models/src/main/java/com/rusefi/models/trigger/WheelMetaReader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.rusefi.models.trigger;
-
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.util.List;
-import java.util.Map;
-
-public class WheelMetaReader {
- public static final String CONTROLLERS_TRIGGER_DECODERS_TRIGGERS_META_YAML = "firmware/controllers/trigger/decoders/triggers-meta.yaml";
-
- public static List