diff --git a/.clang-format b/.clang-format index 8f266c4a..74af22b7 100644 --- a/.clang-format +++ b/.clang-format @@ -1,11 +1,13 @@ Language: Cpp AccessModifierOffset: -2 AlignAfterOpenBracket: AlwaysBreak +AlignArrayOfStructures: None # clang-bug +AlignConsecutiveMacros: Consecutive AlignConsecutiveAssignments: true +AlignConsecutiveBitFields: None # TODO: !573 AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: true AlignEscapedNewlines: Left -AlignOperands: true +AlignOperands: Align AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true @@ -20,12 +22,13 @@ AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: [] BinPackArguments: false BinPackParameters: false BraceWrapping: AfterCaseLabel: false AfterClass: false - AfterControlStatement: false + AfterControlStatement: Never AfterEnum: false AfterFunction: false AfterNamespace: false @@ -35,11 +38,14 @@ BraceWrapping: AfterExternBlock: false BeforeCatch: false BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: true BreakBeforeBraces: Attach BreakBeforeInheritanceComma: false BreakInheritanceList: BeforeColon @@ -58,12 +64,12 @@ Cpp11BracedListStyle: true DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH +ForEachMacros: [] +IfMacros: [] IncludeBlocks: Regroup IncludeCategories: - Regex: '^"(general\.h)"$' @@ -98,20 +104,27 @@ IncludeCategories: SortPriority: 20 IncludeIsMainRegex: "(_cfg)?$" IncludeIsMainSourceRegex: "" +IndentAccessModifiers: false IndentCaseLabels: true +IndentCaseBlocks: false IndentGotoLabels: true IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentRequires: false IndentWidth: 4 IndentWrappedFunctionNames: true +InsertTrailingCommas: None JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature MacroBlockBegin: "" MacroBlockEnd: "" MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCBinPackProtocolList: Auto ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true PenaltyBreakAssignment: 20 @@ -122,33 +135,44 @@ PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 100000 +PenaltyIndentedWhitespace: 0 PointerAlignment: Right +PPIndentWidth: -1 +ReferenceAlignment: Pointer ReflowComments: false -SortIncludes: true +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements +SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 -SpacesInAngles: false +SpacesInAngles: Never SpacesInConditionalStatement: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 SpacesInParentheses: false SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both Standard: Latest -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION +StatementAttributeLikeMacros: [] +StatementMacros: [] TabWidth: 4 UseCRLF: true UseTab: Never +WhitespaceSensitiveMacros: [] diff --git a/.gitignore b/.gitignore index bdc3a921..7a3951e5 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,7 @@ __pycache__ *.~$* **/foxbms-2_axivion_report.json + +*.exe + +/races.txt diff --git a/BSD-3-Clause.txt b/BSD-3-Clause.txt index 0c316f19..7de64831 100644 --- a/BSD-3-Clause.txt +++ b/BSD-3-Clause.txt @@ -1,6 +1,6 @@ BSD 3-Clause License (BSD 3-Clause "New" or "Revised" License) -Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/CITATION.cff b/CITATION.cff index 3993be8c..b3ba1510 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -37,11 +37,14 @@ authors: - family-names: "Bockrath" given-names: "Steffen" orcid: "https://orcid.org/0000-0003-4452-532X" + - family-names: "Seebeck" + given-names: "Rolf" + orcid: "https://orcid.org/0000-0002-5981-8128" cff-version: "1.1.0" doi: "10.5281/zenodo.4727562" keywords: - "BMS" message: "If the foxBMS project contributes to a project that leads to a scientific publication, please acknowledge this fact by citing." title: "foxBMS - The Most Advanced Open Source BMS Platform: foxBMS 2" -version: "1.2.1" -date-released: 2021-12-08 +version: "1.3.0" +date-released: 2022-05-30 diff --git a/conf/bms/schema/application.schema.json b/conf/bms/schema/application.schema.json new file mode 100644 index 00000000..0c98397f --- /dev/null +++ b/conf/bms/schema/application.schema.json @@ -0,0 +1,124 @@ +{ + "$id": "/properties/application", + "title": "Configuration of the application", + "required": [ + "algorithm", + "insulation-monitoring-device" + ], + "additionalProperties": false, + "properties": { + "algorithm": { + "$id": "/properties/application/algorithm", + "title": "Configuration of the algorithm module", + "required": [ + "state-estimation" + ], + "properties": { + "state-estimation": { + "$id": "/properties/application/algorithm/state-estimation", + "title": "State estimators (must correspond to the directory name)", + "required": [ + "soc", + "soe", + "soh" + ], + "properties": { + "soc": { + "$id": "/properties/application/algorithm/state-estimation/soc", + "title": "State-of-Charge algorithm (must correspond to the directory name)", + "type": "string", + "enum": [ + "counting", + "debug", + "none" + ] + }, + "soe": { + "$id": "/properties/application/algorithm/state-estimation/soe", + "title": "State-of-Energy algorithm (must correspond to the directory name)", + "type": "string", + "enum": [ + "counting", + "debug", + "none" + ] + }, + "soh": { + "$id": "/properties/application/algorithm/state-estimation/soh", + "title": "State-of-Health algorithm (must correspond to the directory name)", + "type": "string", + "enum": [ + "debug", + "none" + ] + } + } + } + } + }, + "insulation-monitoring-device": { + "$id": "/properties/application/insulation-monitoring-device", + "title": "Configuration of the used insulation measurement device", + "required": [ + "manufacturer", + "model" + ], + "additionalProperties": false, + "properties": { + "manufacturer": { + "$id": "/properties/application/insulation-monitoring-device/manufacturer", + "title": "Manufacturer of the insulation monitoring device (must correspond to the directory name)", + "type": "string", + "enum": [ + "none", + "bender" + ] + }, + "model": { + "$id": "/properties/application/insulation-monitoring-device/model", + "title": "Name of the insulation monitoring device (must correspond to the directory name)", + "type": "string" + } + }, + "if": { + "properties": { + "manufacturer": { + "enum": [ + "none" + ] + } + } + }, + "then": { + "properties": { + "model": { + "enum": [ + "" + ] + } + } + }, + "else": { + "if": { + "properties": { + "manufacturer": { + "enum": [ + "bender" + ] + } + } + }, + "then": { + "properties": { + "model": { + "enum": [ + "ir155", + "iso165c" + ] + } + } + } + } + } + } +} diff --git a/conf/bms/schema/bms.schema.json b/conf/bms/schema/bms.schema.json index 113068a3..7bfa1cb6 100644 --- a/conf/bms/schema/bms.schema.json +++ b/conf/bms/schema/bms.schema.json @@ -7,374 +7,13 @@ "additionalProperties": false, "properties": { "application": { - "$id": "/properties/application", - "title": "Configuration of the application", - "required": [ - "algorithm", - "insulation-monitoring-device" - ], - "additionalProperties": false, - "properties": { - "algorithm": { - "$id": "/properties/application/algorithm", - "title": "Configuration of the algorithm module", - "required": [ - "state-estimation" - ], - "properties": { - "state-estimation": { - "$id": "/properties/application/algorithm/state-estimation", - "title": "State estimators (must correspond to the directory name)", - "required": [ - "soc", - "soe", - "soh" - ], - "properties": { - "soc": { - "$id": "/properties/application/algorithm/state-estimation/soc", - "title": "State-of-Charge algorithm (must correspond to the directory name)", - "type": "string", - "enum": [ - "counting", - "debug", - "none" - ] - }, - "soe": { - "$id": "/properties/application/algorithm/state-estimation/soe", - "title": "State-of-Energy algorithm (must correspond to the directory name)", - "type": "string", - "enum": [ - "counting", - "debug", - "none" - ] - }, - "soh": { - "$id": "/properties/application/algorithm/state-estimation/soh", - "title": "State-of-Health algorithm (must correspond to the directory name)", - "type": "string", - "enum": [ - "debug", - "none" - ] - } - } - } - } - }, - "insulation-monitoring-device": { - "$id": "/properties/application/insulation-monitoring-device", - "title": "Configuration of the used insulation measurement device", - "required": [ - "manufacturer", - "model" - ], - "additionalProperties": false, - "properties": { - "manufacturer": { - "$id": "/properties/application/insulation-monitoring-device/manufacturer", - "title": "Manufacturer of the insulation monitoring device (must correspond to the directory name)", - "type": "string", - "enum": [ - "none", - "bender" - ] - }, - "model": { - "$id": "/properties/application/insulation-monitoring-device/model", - "title": "Name of the insulation monitoring device (must correspond to the directory name)", - "type": "string" - } - }, - "if": { - "properties": { - "manufacturer": { - "enum": [ - "none" - ] - } - } - }, - "then": { - "properties": { - "model": { - "enum": [ - "" - ] - } - } - }, - "else": { - "if": { - "properties": { - "manufacturer": { - "enum": [ - "bender" - ] - } - } - }, - "then": { - "properties": { - "model": { - "enum": [ - "ir155", - "iso165c" - ] - } - } - } - } - } - } + "$ref": "application.schema.json#" }, "slave-unit": { - "$id": "/properties/slave-unit", - "title": "Configuration of Slave Unit", - "required": [ - "analog-front-end", - "balancing-strategy", - "temperature-sensor" - ], - "additionalProperties": false, - "properties": { - "analog-front-end": { - "$id": "/properties/slave-unit/analog-front-end", - "title": "Configuration of the Analog Front-End", - "required": [ - "manufacturer", - "chip" - ], - "additionalProperties": false, - "properties": { - "manufacturer": { - "$id": "/properties/slave-unit/analog-front-end/manufacturer", - "title": "Manufacturer of the Analog Front-End (must correspond to the directory name)", - "type": "string", - "enum": [ - "ltc", - "maxim", - "nxp", - "debug" - ] - }, - "chip": { - "$id": "/properties/slave-unit/analog-front-end/chip", - "title": "Name of the Analog Front-End (must correspond to the directory name)", - "type": "string" - } - }, - "if": { - "properties": { - "manufacturer": { - "enum": [ - "ltc" - ] - } - } - }, - "then": { - "properties": { - "chip": { - "enum": [ - "6804-1", - "6806", - "6811-1", - "6812-1", - "6813-1" - ] - } - } - }, - "else": { - "if": { - "properties": { - "manufacturer": { - "enum": [ - "nxp" - ] - } - } - }, - "then": { - "properties": { - "chip": { - "enum": [ - "common" - ] - } - } - }, - "else": { - "if": { - "properties": { - "manufacturer": { - "enum": [ - "maxim" - ] - } - } - }, - "then": { - "properties": { - "chip": { - "enum": [ - "max17852" - ] - } - } - }, - "else": { - "if": { - "properties": { - "manufacturer": { - "enum": [ - "debug" - ] - } - } - }, - "then": { - "properties": { - "chip": { - "enum": [ - "default" - ] - } - } - } - } - } - } - }, - "balancing-strategy": { - "$id": "/properties/slave-unit/balancing-strategy", - "title": "Balancing strategy", - "type": "string", - "enum": [ - "voltage", - "history", - "none" - ] - }, - "temperature-sensor": { - "$id": "/properties/slave-unit/temperature-sensor", - "title": "Configuration of the temperature sensor", - "required": [ - "manufacturer", - "model", - "method" - ], - "additionalProperties": false, - "properties": { - "manufacturer": { - "$id": "/properties/slave-unit/temperature-sensor/manufacturer", - "title": "Manufacturer of the temperature sensor (must correspond to the directory name)", - "type": "string", - "enum": [ - "epcos", - "vishay", - "fake" - ] - }, - "model": { - "$id": "/properties/slave-unit/temperature-sensor/model", - "title": "Name of the temperature sensor (must correspond to the directory name)", - "type": "string" - }, - "method": { - "$id": "/properties/slave-unit/temperature-sensor/method", - "title": "Method on which the temperature calculation is based on (must correspond to the directory name)", - "type": "string", - "enum": [ - "polynomial", - "lookup-table" - ] - } - }, - "if": { - "properties": { - "manufacturer": { - "enum": [ - "epcos" - ] - } - } - }, - "then": { - "properties": { - "model": { - "enum": [ - "b57251v5103j060", - "b57861s0103f045" - ] - } - } - }, - "else": { - "if": { - "properties": { - "manufacturer": { - "enum": [ - "vishay" - ] - } - } - }, - "then": { - "properties": { - "model": { - "enum": [ - "ntcalug01a103g", - "ntcle317e4103sba" - ] - } - } - }, - "else": { - "if": { - "properties": { - "manufacturer": { - "enum": [ - "fake" - ] - } - } - }, - "then": { - "properties": { - "model": { - "enum": [ - "none" - ] - } - } - } - } - } - } - } + "$ref": "slave.schema.json#" }, "operating-system": { - "$id": "/properties/operating-system", - "title": "Configuration of the Operating System", - "required": [ - "name" - ], - "additionalProperties": false, - "properties": { - "name": { - "$id": "/properties/operating-system/name", - "title": "Name of the Operating System (must correspond to the directory name)", - "type": "string", - "enum": [ - "freertos", - "safertos" - ] - } - } + "$ref": "os.schema.json#" } } } diff --git a/conf/bms/schema/os.schema.json b/conf/bms/schema/os.schema.json new file mode 100644 index 00000000..f9bf2dd6 --- /dev/null +++ b/conf/bms/schema/os.schema.json @@ -0,0 +1,19 @@ +{ + "$id": "/properties/operating-system", + "title": "Configuration of the Operating System", + "required": [ + "name" + ], + "additionalProperties": false, + "properties": { + "name": { + "$id": "/properties/operating-system/name", + "title": "Name of the Operating System (must correspond to the directory name)", + "type": "string", + "enum": [ + "freertos", + "safertos" + ] + } + } +} diff --git a/conf/bms/schema/slave.schema.json b/conf/bms/schema/slave.schema.json new file mode 100644 index 00000000..313502d2 --- /dev/null +++ b/conf/bms/schema/slave.schema.json @@ -0,0 +1,227 @@ +{ + "$id": "/properties/slave-unit", + "title": "Configuration of Slave Unit", + "required": [ + "analog-front-end", + "balancing-strategy", + "temperature-sensor" + ], + "additionalProperties": false, + "properties": { + "analog-front-end": { + "$id": "/properties/slave-unit/analog-front-end", + "title": "Configuration of the Analog Front-End", + "required": [ + "manufacturer", + "chip" + ], + "additionalProperties": false, + "properties": { + "manufacturer": { + "$id": "/properties/slave-unit/analog-front-end/manufacturer", + "title": "Manufacturer of the Analog Front-End (must correspond to the directory name)", + "type": "string", + "enum": [ + "ltc", + "maxim", + "nxp", + "debug" + ] + }, + "chip": { + "$id": "/properties/slave-unit/analog-front-end/chip", + "title": "Name of the Analog Front-End (must correspond to the directory name)", + "type": "string" + } + }, + "if": { + "properties": { + "manufacturer": { + "enum": [ + "ltc" + ] + } + } + }, + "then": { + "properties": { + "chip": { + "enum": [ + "6804-1", + "6806", + "6811-1", + "6812-1", + "6813-1" + ] + } + } + }, + "else": { + "if": { + "properties": { + "manufacturer": { + "enum": [ + "nxp" + ] + } + } + }, + "then": { + "properties": { + "chip": { + "enum": [ + "common" + ] + } + } + }, + "else": { + "if": { + "properties": { + "manufacturer": { + "enum": [ + "maxim" + ] + } + } + }, + "then": { + "properties": { + "chip": { + "enum": [ + "max17852" + ] + } + } + }, + "else": { + "if": { + "properties": { + "manufacturer": { + "enum": [ + "debug" + ] + } + } + }, + "then": { + "properties": { + "chip": { + "enum": [ + "default" + ] + } + } + } + } + } + } + }, + "balancing-strategy": { + "$id": "/properties/slave-unit/balancing-strategy", + "title": "Balancing strategy", + "type": "string", + "enum": [ + "voltage", + "history", + "none" + ] + }, + "temperature-sensor": { + "$id": "/properties/slave-unit/temperature-sensor", + "title": "Configuration of the temperature sensor", + "required": [ + "manufacturer", + "model", + "method" + ], + "additionalProperties": false, + "properties": { + "manufacturer": { + "$id": "/properties/slave-unit/temperature-sensor/manufacturer", + "title": "Manufacturer of the temperature sensor (must correspond to the directory name)", + "type": "string", + "enum": [ + "epcos", + "vishay", + "fake" + ] + }, + "model": { + "$id": "/properties/slave-unit/temperature-sensor/model", + "title": "Name of the temperature sensor (must correspond to the directory name)", + "type": "string" + }, + "method": { + "$id": "/properties/slave-unit/temperature-sensor/method", + "title": "Method on which the temperature calculation is based on (must correspond to the directory name)", + "type": "string", + "enum": [ + "polynomial", + "lookup-table" + ] + } + }, + "if": { + "properties": { + "manufacturer": { + "enum": [ + "epcos" + ] + } + } + }, + "then": { + "properties": { + "model": { + "enum": [ + "b57251v5103j060", + "b57861s0103f045" + ] + } + } + }, + "else": { + "if": { + "properties": { + "manufacturer": { + "enum": [ + "vishay" + ] + } + } + }, + "then": { + "properties": { + "model": { + "enum": [ + "ntcalug01a103g", + "ntcle317e4103sba" + ] + } + } + }, + "else": { + "if": { + "properties": { + "manufacturer": { + "enum": [ + "fake" + ] + } + } + }, + "then": { + "properties": { + "model": { + "enum": [ + "none" + ] + } + } + } + } + } + } + } +} diff --git a/conf/cc/cc-options.yaml b/conf/cc/cc-options.yaml index 3116b19f..7ad83710 100644 --- a/conf/cc/cc-options.yaml +++ b/conf/cc/cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.5.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ @@ -93,6 +94,7 @@ LINKFLAGS: - --scan_libraries HEXGENFLAGS: + - --emit_warnings_as_errors - --memwidth=32 - --tektronix - -image diff --git a/conf/cc/linker_pulls.json b/conf/cc/linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/conf/cc/linker_pulls.json +++ b/conf/cc/linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/conf/env/paths_linux.txt b/conf/env/paths_linux.txt index 936f5551..25a51a0f 100644 --- a/conf/env/paths_linux.txt +++ b/conf/env/paths_linux.txt @@ -1,4 +1,4 @@ -/opt/ti/ccs1031/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/bin -/opt/ti/ccs1031/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/lib -/opt/ti/ccs1031/ccs/utils/bin -/opt/ti/ccs1031/ccs/utils/tiobj2bin +/opt/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin +/opt/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/lib +/opt/ti/ccs1100/ccs/utils/bin +/opt/ti/ccs1100/ccs/utils/tiobj2bin diff --git a/conf/env/paths_win32.txt b/conf/env/paths_win32.txt index d3e2b170..2fa3f930 100644 --- a/conf/env/paths_win32.txt +++ b/conf/env/paths_win32.txt @@ -1,11 +1,10 @@ -C:\ti\ccs1031\ccs\tools\compiler\ti-cgt-arm_20.2.4.LTS\bin -C:\ti\ccs1031\ccs\tools\compiler\ti-cgt-arm_20.2.4.LTS\lib -C:\ti\ccs1031\ccs\utils\bin -C:\ti\ccs1031\ccs\utils\cygwin -C:\ti\ccs1031\ccs\utils\tiobj2bin +C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-arm_20.2.5.LTS\bin +C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-arm_20.2.5.LTS\lib +C:\ti\ccs1100\ccs\utils\bin +C:\ti\ccs1100\ccs\utils\cygwin +C:\ti\ccs1100\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin -C:\Bauhaus\7.2.6\bin +C:\Bauhaus\7.4.0\bin diff --git a/conf/fmt/pyproject.toml b/conf/fmt/pyproject.toml index b554b7f8..57c6145a 100644 --- a/conf/fmt/pyproject.toml +++ b/conf/fmt/pyproject.toml @@ -19,10 +19,12 @@ exclude = ''' | tools/waf3-2.0.20-bfe1012d9751ef8c4f223dfd0424d33f | tools/waf3-2.0.21-16cd196b0fc7b4eebe195ce20396f3d1 | tools/waf3-2.0.22-1241519b19b496207abef1f72bbf61c2 + | tests/scripts/waf-core )/ | docs/conf.py | tools/vendor | tools/waf-tools/why.py + | tools/waf-verify-sig.py ) ''' diff --git a/conf/guidelines/rules.json b/conf/guidelines/rules.json index e402f0d1..abcfd10a 100644 --- a/conf/guidelines/rules.json +++ b/conf/guidelines/rules.json @@ -1,92 +1,94 @@ { "binary": [ + "7z", "coverage", + "exe", "svg", "pyc", "png", "gif", "ico", "vsdx", + "pyc", + "svg", + "tar", "tar.bz2", "tar.gz", - "tar", - "zip", - "7z" + "vsdx", + "zip" ], "global": [ + "**/**.log", + "**/*~", + "**/__pycache__/**", + "**/foxbms-2_axivion_report.json", ".git/**", - ".vscode/**", + ".lock-waf_*_build", ".mypy_cache/**", + ".vscode/**", "build/**", - "libbuild/**", - "**/foxbms-2_axivion_report.json", "build-tools-tests/**", "conf/hcg/include/*", "conf/hcg/source/*", + "docs/_ext/**", + "foxbms/**", + "libbuild/**", "src/app/driver/sbc/fs8x_driver/**", - "src/os/freertos/include/**", - "src/os/freertos/portable/**", - "src/os/freertos/croutine.c", - "src/os/freertos/event_groups.c", + "src/os/freertos/**/*.asm", + "src/os/freertos/**/*.c", + "src/os/freertos/**/*.h", + "src/os/freertos/.github/uncrustify.cfg", "src/os/freertos/GitHub-FreeRTOS-Kernel-Home.url", "src/os/freertos/History.txt", "src/os/freertos/LICENSE.md", - "src/os/freertos/list.c", - "src/os/freertos/queue.c", + "src/os/freertos/portable/memmang/ReadMe.url", + "src/os/freertos/portable/readme.txt", "src/os/freertos/Quick_Start_Guide.url", "src/os/freertos/README.md", - "src/os/freertos/stream_buffer.c", - "src/os/freertos/tasks.c", - "src/os/freertos/timers.c", - "src/os/freertos/uncrustify.cfg", - "docs/_ext/**", - "foxbms/**", - "tools/waf3-**", - "tools/.waf3-**", - "**/__pycache__/**", - "**/*~", - ".lock-waf_*_build", - "tools/vendor/**", - "tools/waf", - "tools/waf-verify-sig.py", - "tests/scripts/waf-tools/f_guidelines/tests/**", + "src/os/safertos/**/*.asm", + "src/os/safertos/**/*.c", + "src/os/safertos/**/*.h", "tests/scripts/waf-core/general/**", "tests/scripts/waf-core/init/**", "tests/scripts/waf-core/install/**", "tests/scripts/waf-core/install_group/**", "tests/scripts/waf-core/preproc/**", - "**/**.log" + "tests/scripts/waf-tools/f_guidelines/tests/**", + "tools/.waf3-**", + "tools/vendor/**", + "tools/waf", + "tools/waf3-**", + "tools/waf-verify-sig.py" ], "file_names": { "name": "GENERAL:001", "regex": "^[a-z0-9_\\-.]*$", "exclude": [ + "**/README.md", ".github/PULL_REQUEST_TEMPLATE.md", ".gitlab/**", - "CITATION.cff", "BSD-3-Clause.txt", "CC-BY-4.0.txt", "CHANGELOG.md", - "LICENSE.md", - "**/README.md", + "CITATION.cff", "conf/hcg/**/*.asm", - "conf/hcg/**/*.cmd", "conf/hcg/**/*.c", + "conf/hcg/**/*.cmd", "conf/hcg/**/*.h", + "LICENSE.md", "src/app/driver/afe/nxp/common/MC33775A.h", - "src/os/freertos/README.ti-halcogen.md", - "tests/axivion/cafeCC.config" + "src/os/freertos/README.ti-halcogen.md" ] }, "unique_filenames": { "name": "GENERAL:002", "exclude": [ - "**/.gitignore", + "**/.clang-format", "**/.dummy", - "**/README.md", - "**/wscript", + "**/.gitignore", "**/__init__.py", - "**/.clang-format" + "**/README.md", + "**/wscript" ] }, "encoding": { @@ -113,20 +115,20 @@ "posix_3.206": { "name": "GENERAL:004", "exclude": [ + "**/*.dbc", "**/*.patch", "**/*.sym", - "**/*.dbc", "tools/utils/git-hooks/pre-commit" ] }, "trailing_whitespace": { "name": "GENERAL:005", "exclude": [ + "**/*.dbc", "**/*.dil", "**/*.patch", - "tools/gui/data/pcan_view_v2.0.trc", "**/*.sym", - "**/*.dbc" + "tools/gui/data/pcan_view_v2.0.trc" ] }, "tabs": { @@ -146,9 +148,9 @@ "header": { "name": "C:002", "exclude": [ - "src/app/driver/sbc/fs8x_driver/**", "src/app/driver/afe/ltc/common/ltc_pec.*", - "src/app/driver/afe/nxp/common/MC33775A.h" + "src/app/driver/afe/nxp/common/MC33775A.h", + "src/app/driver/sbc/fs8x_driver/**" ], "text": [ "/**", @@ -199,9 +201,9 @@ "exclude": [ "docs/developer-manual/style-guide/examples/*.c", "docs/developer-manual/style-guide/examples/*.h", - "src/app/driver/sbc/fs8x_driver/sbc_fs8x*.*", "src/app/driver/afe/ltc/common/ltc_pec.*", "src/app/driver/afe/nxp/common/MC33775A.h", + "src/app/driver/sbc/fs8x_driver/sbc_fs8x*.*", "src/app/main/linker_script_elf.cmd", "src/os/**" ], @@ -211,6 +213,7 @@ "[ ]\\* (@author)[ ]{2}foxBMS Team$", "[ ]\\* (@date)[ ]{4}[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]\\(date of creation\\)$", "[ ]\\* (@updated)[ ][0-9]{4}-[0-9]{2}-[0-9]{2}[ ]\\(date of last update\\)$", + "[ ]\\* (@version)[ ]v@VERSION@", "[ ]\\* (@ingroup)[ ][A-Za-z_]+$", "[ ]\\* (@prefix)[ ]{2}[A-Z][0-9A-Z]{1,4}$", "([ ]\\*)", @@ -225,9 +228,9 @@ "**/*.h" ], "exclude": [ - "src/app/driver/sbc/fs8x_driver/**", "src/app/driver/afe/ltc/common/ltc_pec.*", "src/app/driver/afe/nxp/common/MC33775A.h", + "src/app/driver/sbc/fs8x_driver/**", "src/os/**" ], "prefix": "FOXBMS__", @@ -242,8 +245,8 @@ "sections": { "exclude": [ "src/app/driver/afe/ltc/common/ltc_pec.*", - "src/app/driver/sbc/fs8x_driver/**", "src/app/driver/afe/nxp/common/MC33775A.h", + "src/app/driver/sbc/fs8x_driver/**", "src/app/main/linker_script_elf.cmd" ], "name": "C:006", @@ -293,11 +296,11 @@ "docs/developer-manual/style-guide/examples/c-026.c", "docs/developer-manual/style-guide/examples/c-027.c", "docs/developer-manual/style-guide/examples/c-028*.c", - "tests/unit/**", - "tests/variants/**", "src/app/driver/config/can_cfg.c", + "src/app/engine/config/diag_cfg.c", "src/app/engine/config/sys_mon_cfg.c", - "src/app/engine/config/diag_cfg.c" + "tests/unit/**", + "tests/variants/**" ], "sections": [ "/*========== Includes =======================================================*/", @@ -361,6 +364,7 @@ "docs/software/modules/engine/database/database_how-to.c", "docs/software/modules/task/ftask/ftask_how-to.c", "src/**", + "tests/c-std/c-std-test.c", "tests/variants/lib-build/*" ], "sections": [ @@ -387,8 +391,8 @@ }, "Python": { "exclude": [ - "tools/waf-tools/why.py", - "tools/waf-tools/doxygen.py" + "tools/waf-tools/doxygen.py", + "tools/waf-tools/why.py" ], "files": [ "**/*.py", @@ -444,20 +448,20 @@ "name": "PYTHON:004", "provider": "black", "exclude": [ - "tools/waf-tools/why.py", "**/*waf3-**.*-*/**", "**/c4che/**", - ".vscode/**" + ".vscode/**", + "tools/waf-tools/why.py" ] }, "static_program_analysis": { "name": "PYTHON:005", "provider": "pylint", "exclude": [ - "tools/waf-tools/why.py", "**/*waf3-**.*-*/**", "**/c4che/**", - ".vscode/**" + ".vscode/**", + "tools/waf-tools/why.py" ] } }, @@ -500,8 +504,8 @@ "docs/general/team-ad-sc.rst", "docs/general/team-dev.rst", "docs/general/team-former.rst", - "docs/tools/waf-tools/f_*.rst", - "docs/tools/waf-tools/compiler-tool/f_*.rst" + "docs/tools/waf-tools/compiler-tool/f_*.rst", + "docs/tools/waf-tools/f_*.rst" ] }, "orphan": { @@ -514,9 +518,9 @@ "conf/env/conda_env_*.yaml" ], "files": [ + "**/*.dot", "**/*.yaml", - "**/*.yml", - "**/*.dot" + "**/*.yml" ], "header": { "name": "YAML:002", @@ -573,9 +577,7 @@ ], "header": { "name": "BATCH:002", - "exclude": [ - "tests/axivion/racepdfs/make_race_pdfs.bat" - ], + "exclude": [], "text": [ "@REM Copyright (c) 2010 - @YEAR@, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.", "@REM All rights reserved.", diff --git a/conf/hcg/hcg.dil b/conf/hcg/hcg.dil index 819eaeca..5d4bdebe 100644 --- a/conf/hcg/hcg.dil +++ b/conf/hcg/hcg.dil @@ -1,4 +1,4 @@ -# TMS570LC4357ZWT 11/17/21 18:06:52 +# TMS570LC4357ZWT 02/22/22 12:03:10 # ARCH=TMS570LC4357ZWT # @@ -451,7 +451,7 @@ DRIVER.SYSTEM.VAR.CORE_MPU_REGION_12_SUB_4_DISABLE.VALUE=0 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_2_SUB_7_DISABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_120_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_112_INT_ENABLE.VALUE=0 -DRIVER.SYSTEM.VAR.VIM_CHANNEL_104_INT_ENABLE.VALUE=0 +DRIVER.SYSTEM.VAR.VIM_CHANNEL_104_INT_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_30_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_22_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_14_INT_TYPE.VALUE=IRQ @@ -7583,7 +7583,7 @@ DRIVER.HET.VAR.HET2_BIT4_ANDSHARE.VALUE=0x00000000 DRIVER.HET.VAR.HET2_INT_X5.VALUE=0x00000000 DRIVER.HET.VAR.HET2_IGNORE_SUSPEND_ENABLE.VALUE=0x00020000 DRIVER.HET.VAR.HET1_BIT30_PULDIS.VALUE=0x00000000 -DRIVER.HET.VAR.HET1_BIT26_HRSHARE.VALUE=0x00002000 +DRIVER.HET.VAR.HET1_BIT26_HRSHARE.VALUE=0x00000000 DRIVER.HET.VAR.HET1_BIT22_PULDIS.VALUE=0x00000000 DRIVER.HET.VAR.HET1_BIT18_HRSHARE.VALUE=0x00000000 DRIVER.HET.VAR.HET1_BIT14_PULDIS.VALUE=0x00000000 @@ -8247,7 +8247,7 @@ DRIVER.HET.VAR.HET1_BIT13_PSL.VALUE=0x00000000 DRIVER.HET.VAR.HET1_LR_TIME.VALUE=800.000 DRIVER.HET.VAR.HET2_EDGE0_LVL.VALUE=0x00000000 DRIVER.HET.VAR.HET1_PWM3_ACTION.VALUE=3 -DRIVER.HET.VAR.HET1_BIT25_DIR.VALUE=0x00000000 +DRIVER.HET.VAR.HET1_BIT25_DIR.VALUE=0x02000000 DRIVER.HET.VAR.HET1_BIT21_PULL.VALUE=1 DRIVER.HET.VAR.HET1_BIT17_DIR.VALUE=0x00000000 DRIVER.HET.VAR.HET1_BIT13_PULL.VALUE=1 @@ -9000,7 +9000,7 @@ DRIVER.PINMUX.VAR.MUX92_CONFLICT.VALUE=0 DRIVER.PINMUX.VAR.MUX84_CONFLICT.VALUE=0 DRIVER.PINMUX.VAR.MUX76_CONFLICT.VALUE=0 DRIVER.PINMUX.VAR.MUX68_CONFLICT.VALUE=0 -DRIVER.PINMUX.VAR.PINMUX31.VALUE="PINMUX_BALL_B4_MIBSPI4NCS_5 | PINMUX_BALL_N2_N2HET1_13 | PINMUX_BALL_N1_MIBSPI1NCS_4 | PINMUX_BALL_A4_N2HET1_16" +DRIVER.PINMUX.VAR.PINMUX31.VALUE="PINMUX_BALL_B4_MIBSPI4NCS_5 | PINMUX_BALL_N2_N2HET1_13 | PINMUX_BALL_N1_ECAP1 | PINMUX_BALL_A4_N2HET1_16" DRIVER.PINMUX.VAR.PINMUX23.VALUE="PINMUX_BALL_V5_MIBSPI3NCS_1 | PINMUX_BALL_B2_I2C1_SDA | PINMUX_BALL_C3_I2C1_SCL | PINMUX_BALL_W9_MIBSPI3NCS_5" DRIVER.PINMUX.VAR.PINMUX15.VALUE="PINMUX_BALL_K5_ETMDATA_23 | PINMUX_BALL_L5_ETMDATA_24 | PINMUX_BALL_M5_ETMDATA_25 | PINMUX_BALL_N5_ETMDATA_26" DRIVER.PINMUX.VAR.PINMUX32.VALUE="PINMUX_BALL_A13_N2HET1_17 | PINMUX_BALL_J1_N2HET1_18 | PINMUX_BALL_B13_N2HET1_19 | PINMUX_BALL_P2_N2HET1_20" @@ -9184,7 +9184,7 @@ DRIVER.PINMUX.VAR.TEMP3_ENABLE_SELECT.VALUE=ON DRIVER.PINMUX.VAR.MUX120_CONFLICT.VALUE=0 DRIVER.PINMUX.VAR.MUX112_CONFLICT.VALUE=0 DRIVER.PINMUX.VAR.MUX104_CONFLICT.VALUE=0 -DRIVER.PINMUX.VAR.PIN_MUX_94_SELECT.VALUE=1 +DRIVER.PINMUX.VAR.PIN_MUX_94_SELECT.VALUE=5 DRIVER.PINMUX.VAR.PIN_MUX_86_SELECT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_78_SELECT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_3_SELECT.VALUE=0 @@ -9897,7 +9897,7 @@ DRIVER.PINMUX.VAR.MUX78_OPTION0.VALUE=1 DRIVER.PINMUX.VAR.TEMP1_ENABLE.VALUE=1 DRIVER.PINMUX.VAR.MUX111_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX103_OPTION5.VALUE=0 -DRIVER.PINMUX.VAR.MUX94_OPTION1.VALUE=1 +DRIVER.PINMUX.VAR.MUX94_OPTION1.VALUE=0 DRIVER.PINMUX.VAR.MUX86_OPTION1.VALUE=0 DRIVER.PINMUX.VAR.MUX78_OPTION1.VALUE=0 DRIVER.PINMUX.VAR.ECAP4_FILTER_SELECT.VALUE=OFF @@ -9920,7 +9920,7 @@ DRIVER.PINMUX.VAR.MUX78_OPTION4.VALUE=0 DRIVER.PINMUX.VAR.MUX9_OPTION0.VALUE=0 DRIVER.PINMUX.VAR.SIGNAL21_OPTION1.VALUE=0 DRIVER.PINMUX.VAR.SIGNAL13_OPTION1.VALUE=0 -DRIVER.PINMUX.VAR.MUX94_OPTION5.VALUE=0 +DRIVER.PINMUX.VAR.MUX94_OPTION5.VALUE=1 DRIVER.PINMUX.VAR.MUX86_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX78_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX9_OPTION1.VALUE=0 @@ -10450,7 +10450,7 @@ DRIVER.CRC.VAR.CRC1_CH1_CCI.VALUE=0x00000000 DRIVER.CRC.VAR.CRC2_CH1_MODE.VALUE=AUTO DRIVER.CRC.VAR.CRC1_CH1_PSSIH.VALUE=0 DRIVER.CRC.VAR.CRC2_CH2_DTE.VALUE=1 -DRIVER.CRC.VAR.CRC1_CH1_CFI.VALUE=0x00000002 +DRIVER.CRC.VAR.CRC1_CH1_CFI.VALUE=0x00000000 DRIVER.CRC.VAR.CRC1_CH1_PSSIL.VALUE=0 DRIVER.CRC.VAR.HTU_MP1_ENDADD_1.VALUE=0 DRIVER.CRC.VAR.HTU_ICPB_4_SEL_1.VALUE=ENABLE @@ -10513,8 +10513,8 @@ DRIVER.CRC.VAR.CRC2_CH1_WDTO.VALUE=0x00000000 DRIVER.CRC.VAR.CRC2_CH2_PSIH.VALUE=0 DRIVER.CRC.VAR.CRC1_CH2_SCP.VALUE=0x00000000 DRIVER.CRC.VAR.HTU_ENA_1.VALUE=0 -DRIVER.CRC.VAR.CRC1_CH1_TOE.VALUE=0x00000010 -DRIVER.CRC.VAR.CRC1_CH1_MODE.VALUE=AUTO +DRIVER.CRC.VAR.CRC1_CH1_TOE.VALUE=0x00000000 +DRIVER.CRC.VAR.CRC1_CH1_MODE.VALUE=FULL_CPU DRIVER.CRC.VAR.CRC2_CH2_PSIL.VALUE=0 DRIVER.CRC.VAR.CRC1_CH2_PSA.VALUE=1 DRIVER.CRC.VAR.CRC1_CH2_ORI.VALUE=0x00000000 @@ -11373,14 +11373,14 @@ DRIVER.ECAP.VAR.ECAP5_CEVT2.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP5_CEVT3.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP5_CEVT4.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP1_PWM_DUTY.VALUE=50 -DRIVER.ECAP.VAR.ECAP1_CAP2_POLARITY.VALUE=RISING_EDGE +DRIVER.ECAP.VAR.ECAP1_CAP2_POLARITY.VALUE=FALLING_EDGE DRIVER.ECAP.VAR.ECAP4_PWM_PERIOD.VALUE=1000.000 DRIVER.ECAP.VAR.ECAP1_PWM_DUTYTIME.VALUE=500 DRIVER.ECAP.VAR.ECAP5_CNTOVF.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP5_PRESCALE_REG.VALUE=0 DRIVER.ECAP.VAR.ECAP2_CAP4_POLARITY.VALUE=RISING_EDGE DRIVER.ECAP.VAR.ECAP1_PRESCALE.VALUE=1 -DRIVER.ECAP.VAR.ECAP1_ENA_LOAD.VALUE=0 +DRIVER.ECAP.VAR.ECAP1_ENA_LOAD.VALUE=1 DRIVER.ECAP.VAR.ECAP6_CAP2_POLARITY.VALUE=RISING_EDGE DRIVER.ECAP.VAR.ECAP1_CAPTURE_MODE.VALUE=CONTINUOUS DRIVER.ECAP.VAR.ECAP2_PRESCALE_REG.VALUE=0 @@ -11389,7 +11389,7 @@ DRIVER.ECAP.VAR.ECAP6_PWM_ACTUALPERIOD.VALUE=1000 DRIVER.ECAP.VAR.ECAP4_CAP1_POLARITY.VALUE=RISING_EDGE DRIVER.ECAP.VAR.ECAP1_CEVT1.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP1_CEVT2.VALUE=0x0000 -DRIVER.ECAP.VAR.ECAP1_CEVT3.VALUE=0x0000 +DRIVER.ECAP.VAR.ECAP1_CEVT3.VALUE=0x0008 DRIVER.ECAP.VAR.ECAP2_RESET_COUNTER.VALUE=0 DRIVER.ECAP.VAR.ECAP1_CEVT4.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP4_PRESCALE.VALUE=1 @@ -11432,7 +11432,7 @@ DRIVER.ECAP.VAR.ECAP2_CEVT2.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP2_PWM_PERIOD.VALUE=1000.000 DRIVER.ECAP.VAR.ECAP2_CEVT3.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP2_CEVT4.VALUE=0x0000 -DRIVER.ECAP.VAR.ECAP1_WRAP_COUNTER.VALUE=CAPTURE_EVENT1 +DRIVER.ECAP.VAR.ECAP1_WRAP_COUNTER.VALUE=CAPTURE_EVENT3 DRIVER.ECAP.VAR.ECAP6_CAP1_POLARITY.VALUE=RISING_EDGE DRIVER.ECAP.VAR.ECAP5_ENA_PWM.VALUE=0 DRIVER.ECAP.VAR.ECAP4_RESET_COUNTER.VALUE=0 @@ -11490,7 +11490,7 @@ DRIVER.ECAP.VAR.ECAP2_WRAP_COUNTER.VALUE=CAPTURE_EVENT1 DRIVER.ECAP.VAR.ECAP3_CAPTURE_MODE.VALUE=CONTINUOUS DRIVER.ECAP.VAR.ECAP1_RESET_COUNTER_CAP1.VALUE=RESET_DISABLE DRIVER.ECAP.VAR.ECAP1_RESET_COUNTER_CAP2.VALUE=RESET_DISABLE -DRIVER.ECAP.VAR.ECAP1_RESET_COUNTER_CAP3.VALUE=RESET_DISABLE +DRIVER.ECAP.VAR.ECAP1_RESET_COUNTER_CAP3.VALUE=RESET_ENABLE DRIVER.ECAP.VAR.ECAP1_RESET_COUNTER_CAP4.VALUE=RESET_DISABLE DRIVER.ECAP.VAR.ECAP5_CMP.VALUE=0x0000 DRIVER.ECAP.VAR.ECAP2_PRD.VALUE=0x0000 diff --git a/conf/spa/README.md b/conf/spa/README.md index 072aa60c..6849f107 100644 --- a/conf/spa/README.md +++ b/conf/spa/README.md @@ -1,23 +1,6 @@ # Static Program Analysis -Do not use the cppcheck configuration in this directory for the Cppcheck GUI. -Instead after running ``waf build_static_analysis`` goto -``build/static_analysis`` and use the cppcheck configuration there. +## Python -## Usage in CI - -The CI job uses the waf task which is intended to be a pass/fail criterion. -We are masking out quite a few rules (with the intention to reduce this -number). -The waf task prints only the failing rules that are NOT masked. - -## Usage on your machine - -For using cppcheck on your local machine, please take the cppcheck-GUI. -Together with the configuration file that is generated in -``build/static_analysis`` you should be able to comfortably have a complete -list of all rule violations. -The GUI allows you to filter rule violations. - -You can configure cppcheck to send you directly into the editor of your choice -when double-clicking on a violation. +The ``pylint`` configuration for the foxBMS 2 project is defined in +``.pylintrc`` in this directory. diff --git a/conf/spa/cppcheck-suppression.txt b/conf/spa/cppcheck-suppression.txt deleted file mode 100644 index 06a94bf9..00000000 --- a/conf/spa/cppcheck-suppression.txt +++ /dev/null @@ -1,148 +0,0 @@ -// cppcheck -unusedFunction -// DATA_Read_{n}_DataBlock{s} is used by variadic macro -unusedFunction:src/app/engine/database/database.c:279 -unusedFunction:src/app/engine/database/database.c:284 -unusedFunction:src/app/engine/database/database.c:289 -// DATA_Write_{n}_DataBlock{s} is used by variadic macro -unusedFunction:src/app/engine/database/database.c:279 -unusedFunction:src/app/engine/database/database.c:284 -unusedFunction:src/app/engine/database/database.c:289 -unsignedLessThanZero:*/app/engine/diag/diag.c -redundantAssignment -unreadVariable -variableScope -knownConditionTrueFalse:*/app/engine/diag/diag.c -missingInclude -unmatchedSuppression -comparisonError:*/app/driver/afe/ltc/6806/ltc_6806.c -comparisonError:*/app/driver/afe/ltc/6813-1/ltc_6813-1.c - -// MISRA -misra-c2012-2.7 -misra-c2012-3.1:*/app/driver/afe/ltc/common/ltc_pec.c -misra-c2012-3.1:*/app/engine/diag/diag.c -misra-c2012-5.1:*/app/application/config/sof_cfg.h -misra-c2012-5.1:*/app/driver/config/contactor_cfg.* -misra-c2012-5.1:*/app/driver/afe/maxim/common/mxm_17841b.h -misra-c2012-5.2:*/app/driver/sbc/nxpfs85xx.h -misra-c2012-5.5:*/app/driver/mcu/mcu.h -misra-c2012-8.11:*/app/application/algorithm/config/algorithm_cfg.h -misra-c2012-8.11:*/app/application/config/battery_cell_cfg.h -misra-c2012-8.11:*/app/driver/config/can_cfg.h -misra-c2012-8.11:*/app/driver/config/spi_cfg.h -misra-c2012-8.11:*/app/driver/dma/dma.h -misra-c2012-8.11:*/app/engine/config/sys_mon_cfg.h -misra-c2012-8.11:*/app/task/os/os.h -misra-c2012-8.11:*/opt/cells/config/lg_inr18650mj1.h -misra-c2012-10.4:*/app/application/bal/bal.c -misra-c2012-10.4:*/app/driver/config/contactor_cfg.c -misra-c2012-10.4:*/app/driver/foxmath/foxmath.c -misra-c2012-10.4:*/app/driver/ts/* -misra-c2012-10.4:*/app/main/include/fassert.h -misra-c2012-10.6:*/app/driver/afe/maxim/common/mxm_registry.c -misra-c2012-10.6:*/app/driver/afe/maxim/common/mxm_battery_management.c -misra-c2012-10.8:*/app/application/bal/history/bal_strategy_history.c -misra-c2012-10.8:*/app/driver/mcu/mcu.c -misra-c2012-11.4:*/app/driver/mcu/mcu.c -misra-c2012-11.4:*/app/engine/diag/diag.c -misra-c2012-11.4:*/app/driver/i2c/i2c.c -misra-c2012-11.4:*/app/driver/spi/spi.c -misra-c2012-11.5:*/app/engine/database/database.c -misra-c2012-12.2:*/app/driver/afe/maxim/common/mxm_1785x_tools.c -misra-c2012-12.3:*/app/driver/config/spi_cfg.c -misra-c2012-18.8:*/app/driver/sbc/nxpfs85xx.c -// false positive: -misra-c2012-12.3:*/app/driver/afe/maxim/common/mxm_17841b.c -misra-c2012-12.3:*/app/driver/afe/maxim/max17852/mxm_17852.c -misra-c2012-12.4:*/app/engine/diag/diag.c -misra-c2012-14.4:*/app/driver/afe/maxim/max17852/mxm_17852.c:347 -misra-c2012-15.5:*/app/application/bal/bal.c -misra-c2012-15.5:*/app/application/bal/voltage/bal_strategy_voltage.c -misra-c2012-15.5:*/app/application/bal/history/bal_strategy_history.c -misra-c2012-15.5:*/app/application/bms/bms.c -misra-c2012-15.5:*/app/application/config/sof_cfg.h -misra-c2012-15.5:*/app/driver/contactor/contactor.c -misra-c2012-15.5:*/app/driver/interlock/interlock.c -misra-c2012-15.5:*/app/driver/sbc/sbc.c -misra-c2012-15.5:*/app/engine/diag/diag.c -misra-c2012-15.5:*/app/engine/sys_mon/sys_mon.c -misra-c2012-15.5:*/app/engine/sys/sys.c -misra-c2012-15.7 -misra-c2012-17.7:*/app/engine/sys_mon/sys_mon.c -misra-c2012-17.7:*/app/engine/diag/diag.c -misra-c2012-17.8:*/app/application/algorithm/state_estimation/soc/counting/soc_counting.c -misra-c2012-17.8:*/app/driver/foxmath/foxmath.c -misra-c2012-18.8:*/app/engine/diag/diag.c -misra-c2012-18.8:*/app/engine/sys/sys.c -misra-c2012-18.8:*/app/driver/afe/maxim/common/mxm_1785x.c:1115 -misra-c2012-18.8:*/app/driver/afe/maxim/common/mxm_1785x.c:1157 -misra-c2012-18.8:*/app/driver/afe/maxim/max17852/mxm_17852.c:107 -misra-c2012-18.8:*/app/driver/can/can.c:434 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:91 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:110 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:126 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:142 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:156 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:170 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:184 -misra-c2012-18.8:*/app/task/ftask/freertos/ftask_freertos.c:198 -misra-c2012-18.8:*/app/task/os/freertos/os_freertos.c:82 -misra-c2012-19.2:*/app/driver/afe/nxp/common/MC33775A.h -misra-c2012-20.7:*/app/driver/afe/ltc/6806/ltc_6806.c -misra-c2012-20.7:*/app/driver/afe/ltc/6813-1/ltc_6813-1.c -misra-c2012-20.7:*/app/driver/afe/ltc/common/ltc.h -misra-c2012-20.10:*/app/driver/afe/ltc/6806/ltc_6806.c -misra-c2012-20.10:*/app/driver/afe/ltc/6813-1/ltc_6813-1.c -misra-c2012-20.10:*/app/driver/afe/ltc/common/ltc.h - -// threadsafety -threadsafety-threadsafety:*/app/application/algorithm/algorithm.c -threadsafety-threadsafety:*/app/application/algorithm/moving_average/moving_average.c -threadsafety-threadsafety:*/app/application/bal/voltage/bal_strategy_voltage.c:123 -threadsafety-threadsafety:*/app/application/bms/bms.c -threadsafety-threadsafety:*/app/application/redundancy/redundancy.c:1121 -threadsafety-threadsafety:*/app/application/redundancy/redundancy.c:1122 -threadsafety-threadsafety:*/app/application/redundancy/redundancy.c:1125 -threadsafety-threadsafety:*/app/application/redundancy/redundancy.c:1127 -threadsafety-threadsafety:*/app/driver/can/can.c -threadsafety-threadsafety:*/app/driver/led/led.c -threadsafety-threadsafety:*/app/engine/sys_mon/sys_mon.c -threadsafety-threadsafety:*/app/task/config/ftask_cfg.c -threadsafety-threadsafety:*/app/driver/afe/debug/default/debug_default.c:369 -threadsafety-threadsafety:*/app/driver/afe/maxim/api/mxm_afe.c -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:91 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:92 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:110 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:110 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:111 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:119 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:126 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:141 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:142 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:155 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:156 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:169 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:170 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:183 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:184 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:197 -threadsafety-threadsafety:*/app/task/ftask/freertos/ftask_freertos.c:198 -threadsafety-threadsafety:*/app/task/os/freertos/os_freertos.c:80 -threadsafety-threadsafety:*/app/task/os/freertos/os_freertos.c:82 - -// y2038 -y2038-unsafe-call:*/app/engine/sys_mon/sys_mon.* - -// cert -cert-API01-C:*/app/engine/config/database_cfg.h -cert-API01-C:*/app/engine/config/diag_cfg.h -cert-API01-C:*/app/engine/diag/diag.h -cert-API01-C:*/app/driver/afe/nxp/common/MC33775A.h -cert-INT31-c:*/app/driver/afe/maxim/common/mxm_1785x_tools.c - -// Disable whole files -*:*/app/main/fstartup.c -*:*/app/driver/sbc/fs8x_driver/* -*:*/app/driver/imd/bender/ir155/* -*:*/app/driver/imd/bender/iso165c/* diff --git a/conf/spa/cppcheck.cppcheck b/conf/spa/cppcheck.cppcheck deleted file mode 100644 index 1b229350..00000000 --- a/conf/spa/cppcheck.cppcheck +++ /dev/null @@ -1,22 +0,0 @@ - - - -@root@ - . - Unspecified - false - false - false - 10 - - - -@paths@ - - -@exclude@ - - -@addons@ - - diff --git a/conf/spa/cppcheckmisra.json b/conf/spa/cppcheckmisra.json deleted file mode 100644 index 98e24ba3..00000000 --- a/conf/spa/cppcheckmisra.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "script": "misra.py", - "args": [ - "@misra_args@" - ] -} diff --git a/conf/tpl/batch.bat b/conf/tpl/batch.bat index 2d7f802f..a0104e83 100644 --- a/conf/tpl/batch.bat +++ b/conf/tpl/batch.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/conf/tpl/c.c b/conf/tpl/c.c index bc82c493..6e091f15 100644 --- a/conf/tpl/c.c +++ b/conf/tpl/c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file c.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2020-08-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup SOME_GROUP * @prefix ABC * diff --git a/conf/tpl/c.h b/conf/tpl/c.h index 930d089f..64d7e9e5 100644 --- a/conf/tpl/c.h +++ b/conf/tpl/c.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file c.h * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2020-08-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup SOME_GROUP * @prefix ABC * diff --git a/conf/tpl/python_script.py b/conf/tpl/python_script.py index bf1f921e..5097d02f 100644 --- a/conf/tpl/python_script.py +++ b/conf/tpl/python_script.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Template for Python scripts""" -import logging import argparse +import logging def main(): diff --git a/conf/tpl/shell.sh b/conf/tpl/shell.sh index 903337f9..c4495db0 100644 --- a/conf/tpl/shell.sh +++ b/conf/tpl/shell.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/conf/tpl/test_c.c b/conf/tpl/test_c.c index 414fbd97..49e11c80 100644 --- a/conf/tpl/test_c.c +++ b/conf/tpl/test_c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_c.c * @author foxBMS Team * @date 2020-08-10 (date of creation) - * @updated 2020-08-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/conf/tpl/test_c.h b/conf/tpl/test_c.h index febb0e20..b0b10447 100644 --- a/conf/tpl/test_c.h +++ b/conf/tpl/test_c.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_c.h * @author foxBMS Team * @date 2020-08-10 (date of creation) - * @updated 2020-08-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/conf/tpl/yaml.yaml b/conf/tpl/yaml.yaml index 50e84927..9dd1c631 100644 --- a/conf/tpl/yaml.yaml +++ b/conf/tpl/yaml.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/conf/unit/ceedling.cmd b/conf/unit/ceedling.cmd index b2a5633a..9fa1eeef 100644 --- a/conf/unit/ceedling.cmd +++ b/conf/unit/ceedling.cmd @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/conf/unit/project.yml b/conf/unit/project.yml index 3526d532..f1f25ecc 100644 --- a/conf/unit/project.yml +++ b/conf/unit/project.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/conf/unit/vsc-settings.yml b/conf/unit/vsc-settings.yml index fdd47456..393fd2bd 100644 --- a/conf/unit/vsc-settings.yml +++ b/conf/unit/vsc-settings.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/conf.py b/docs/conf.py index 2499ca22..dc2518b7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,6 +41,7 @@ import os import sys import time + import sphinx_rtd_theme # pylint: skip-file @@ -57,7 +58,7 @@ project = "foxBMS 2" copyright = ( - "2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten " + "2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten " "Forschung e.V. All rights reserved. See license section for further " "information" ) diff --git a/docs/developer-manual/software/software-development-process.dot b/docs/developer-manual/software/software-development-process.dot index c409134b..0fda4fa6 100644 --- a/docs/developer-manual/software/software-development-process.dot +++ b/docs/developer-manual/software/software-development-process.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/software/software-tools.rst b/docs/developer-manual/software/software-tools.rst index 4105f341..bc8d777d 100644 --- a/docs/developer-manual/software/software-tools.rst +++ b/docs/developer-manual/software/software-tools.rst @@ -60,9 +60,6 @@ The following tools are shown in :numref:`mapping-of-third-party-tools`. | Axivion Suite | static program | T2 | | | | analysis tools | | | +-----------------+-------------------------+-------------+----------------------------------------+ - | Cppcheck | static program | T1 | just a helper for the static analysis; | - | | analysis tools | | Axivion is used as the main tool | - +-----------------+-------------------------+-------------+----------------------------------------+ | sphinx | documentation tools | T1 | just a rendering tool for | | | | | the documentation text files | +-----------------+-------------------------+-------------+----------------------------------------+ diff --git a/docs/developer-manual/software/software-verification.rst b/docs/developer-manual/software/software-verification.rst index d07af16d..9c617754 100644 --- a/docs/developer-manual/software/software-verification.rst +++ b/docs/developer-manual/software/software-verification.rst @@ -21,8 +21,7 @@ Software Analysis ----------------- The source code is subject to a static program analysis. These tests are -performed by Axivion Suite and Cppcheck (see :numref:`AXIVION_BAUHAUS_SUITE` -and :numref:`CPPCHECK`). +performed by Axivion Suite (see :numref:`AXIVION_BAUHAUS_SUITE`). The architecture is verified by the Axivion Suite (see :numref:`AXIVION_BAUHAUS_SUITE`) diff --git a/docs/developer-manual/style-guide/examples/c-004.c b/docs/developer-manual/style-guide/examples/c-004.c index de202f63..a6a99ea1 100644 --- a/docs/developer-manual/style-guide/examples/c-004.c +++ b/docs/developer-manual/style-guide/examples/c-004.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file c-004.c * @author foxBMS Team * @date 2021-04-06 (date of creation) - * @updated 2021-04-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup SOME_GROUP * @prefix ABC * diff --git a/docs/developer-manual/style-guide/examples/c-005.c b/docs/developer-manual/style-guide/examples/c-005.c index 697f1247..33efee03 100644 --- a/docs/developer-manual/style-guide/examples/c-005.c +++ b/docs/developer-manual/style-guide/examples/c-005.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-006-source.c b/docs/developer-manual/style-guide/examples/c-006-source.c index fe2caa5f..aa1f1c98 100644 --- a/docs/developer-manual/style-guide/examples/c-006-source.c +++ b/docs/developer-manual/style-guide/examples/c-006-source.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-006-source.h b/docs/developer-manual/style-guide/examples/c-006-source.h index 020e8074..0b6798ee 100644 --- a/docs/developer-manual/style-guide/examples/c-006-source.h +++ b/docs/developer-manual/style-guide/examples/c-006-source.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-006-test.c b/docs/developer-manual/style-guide/examples/c-006-test.c index 98b31083..a83e061c 100644 --- a/docs/developer-manual/style-guide/examples/c-006-test.c +++ b/docs/developer-manual/style-guide/examples/c-006-test.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-006-test.h b/docs/developer-manual/style-guide/examples/c-006-test.h index 79779c8b..8796635c 100644 --- a/docs/developer-manual/style-guide/examples/c-006-test.h +++ b/docs/developer-manual/style-guide/examples/c-006-test.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-007_abc.c b/docs/developer-manual/style-guide/examples/c-007_abc.c index 12b8a2e8..5eb0af6c 100644 --- a/docs/developer-manual/style-guide/examples/c-007_abc.c +++ b/docs/developer-manual/style-guide/examples/c-007_abc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-007_abc.h b/docs/developer-manual/style-guide/examples/c-007_abc.h index 33ada564..21dd9aec 100644 --- a/docs/developer-manual/style-guide/examples/c-007_abc.h +++ b/docs/developer-manual/style-guide/examples/c-007_abc.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-007_abc_cfg.c b/docs/developer-manual/style-guide/examples/c-007_abc_cfg.c index 99907d09..3c98bfc3 100644 --- a/docs/developer-manual/style-guide/examples/c-007_abc_cfg.c +++ b/docs/developer-manual/style-guide/examples/c-007_abc_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-007_abc_cfg.h b/docs/developer-manual/style-guide/examples/c-007_abc_cfg.h index 30aa4895..18ff4ef7 100644 --- a/docs/developer-manual/style-guide/examples/c-007_abc_cfg.h +++ b/docs/developer-manual/style-guide/examples/c-007_abc_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-008.c b/docs/developer-manual/style-guide/examples/c-008.c index aae9fa06..cc223c0a 100644 --- a/docs/developer-manual/style-guide/examples/c-008.c +++ b/docs/developer-manual/style-guide/examples/c-008.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-008.h b/docs/developer-manual/style-guide/examples/c-008.h index b54b8eaa..457b0f2a 100644 --- a/docs/developer-manual/style-guide/examples/c-008.h +++ b/docs/developer-manual/style-guide/examples/c-008.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-009.c b/docs/developer-manual/style-guide/examples/c-009.c index b9b7a90c..fe077ad9 100644 --- a/docs/developer-manual/style-guide/examples/c-009.c +++ b/docs/developer-manual/style-guide/examples/c-009.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-011.c b/docs/developer-manual/style-guide/examples/c-011.c index 7ee1c482..16086ad8 100644 --- a/docs/developer-manual/style-guide/examples/c-011.c +++ b/docs/developer-manual/style-guide/examples/c-011.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -53,7 +53,7 @@ static uint8_t ABC_AnotherFunction(void) { return 0; } -extern uint8_t ABC_ImportantFunction(void) { +extern uint8_t ABC_ImportantFunction(uint8_t *pPointer, uint8_t length) { /* code */ return 0; } diff --git a/docs/developer-manual/style-guide/examples/c-011.h b/docs/developer-manual/style-guide/examples/c-011.h index 34b0c842..3fe0efd2 100644 --- a/docs/developer-manual/style-guide/examples/c-011.h +++ b/docs/developer-manual/style-guide/examples/c-011.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -47,8 +47,10 @@ /** * @brief Does this and that * @details Detailed description of this function + * @param[out] pPointer important function writes to this pointer + * @param length length that should be written to the pointer * @return some uint8_t which describes xyz */ -extern uint8_t ABC_ImportantFunction(void); +extern uint8_t ABC_ImportantFunction(uint8_t *pPointer, uint8_t length); #endif /* FOXBMS__C_011_H_ */ diff --git a/docs/developer-manual/style-guide/examples/c-012.c b/docs/developer-manual/style-guide/examples/c-012.c index c7c6b2ea..a526641b 100644 --- a/docs/developer-manual/style-guide/examples/c-012.c +++ b/docs/developer-manual/style-guide/examples/c-012.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-013.c b/docs/developer-manual/style-guide/examples/c-013.c index 18cba630..db13116c 100644 --- a/docs/developer-manual/style-guide/examples/c-013.c +++ b/docs/developer-manual/style-guide/examples/c-013.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-013.h b/docs/developer-manual/style-guide/examples/c-013.h index 2eecf484..31fa00a5 100644 --- a/docs/developer-manual/style-guide/examples/c-013.h +++ b/docs/developer-manual/style-guide/examples/c-013.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-015.c b/docs/developer-manual/style-guide/examples/c-015.c index aa4a52c0..68cabad3 100644 --- a/docs/developer-manual/style-guide/examples/c-015.c +++ b/docs/developer-manual/style-guide/examples/c-015.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -41,12 +41,17 @@ #include "c-015.h" -extern uint32_t ABC_ArrayAverage(uint8_t *pArray, uint8_t arrayLength) { - uint32_t sum = 0u; +extern uint32_t ABC_ArrayAverage(uint8_t *pArray, uint8_t arrayLength, uint8_t additionalParameter) { + /* AXIVION Routine Generic-MissingParameterAssert: additionalParameter: This parameter is unused in this example */ FAS_ASSERT(pArray != NULL_PTR); FAS_ASSERT(arrayLength > 0u); + /* unused parameter just for the example */ + (void)additionalParameter; + + uint32_t sum = 0u; + for (uint16_t i = 0u; i < arrayLength; i++) { sum += pArray[i]; } diff --git a/docs/developer-manual/style-guide/examples/c-015.h b/docs/developer-manual/style-guide/examples/c-015.h index 931611b4..c614e52e 100644 --- a/docs/developer-manual/style-guide/examples/c-015.h +++ b/docs/developer-manual/style-guide/examples/c-015.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -44,6 +44,6 @@ #include "general.h" -extern uint32_t ABC_ArrayAverage(uint8_t *pArray, uint8_t arrayLength); +extern uint32_t ABC_ArrayAverage(uint8_t *pArray, uint8_t arrayLength, uint8_t additionalParameter); #endif /* FOXBMS__C_015_H_ */ diff --git a/docs/developer-manual/style-guide/examples/c-016.c b/docs/developer-manual/style-guide/examples/c-016.c index 1109b3c1..09a341b6 100644 --- a/docs/developer-manual/style-guide/examples/c-016.c +++ b/docs/developer-manual/style-guide/examples/c-016.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-017.c b/docs/developer-manual/style-guide/examples/c-017.c index 1fa2caa0..64037425 100644 --- a/docs/developer-manual/style-guide/examples/c-017.c +++ b/docs/developer-manual/style-guide/examples/c-017.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-018.c b/docs/developer-manual/style-guide/examples/c-018.c index d6442a6a..e7db6ea1 100644 --- a/docs/developer-manual/style-guide/examples/c-018.c +++ b/docs/developer-manual/style-guide/examples/c-018.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -41,7 +41,7 @@ #include "general.h" -typedef struct INIT_STRUCT { +typedef struct { uint32_t value; } INIT_STRUCT_s; diff --git a/docs/developer-manual/style-guide/examples/c-019.c b/docs/developer-manual/style-guide/examples/c-019.c index 559a6f06..4fd0d1a1 100644 --- a/docs/developer-manual/style-guide/examples/c-019.c +++ b/docs/developer-manual/style-guide/examples/c-019.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -42,13 +42,13 @@ #include "general.h" /* Initialization example for structs */ -typedef struct POINT { +typedef struct { float x; float y; float z; } POINT_s; -typedef struct PATH { +typedef struct { POINT_s point; uint32_t timestamp; uint32_t previousTimestamp; diff --git a/docs/developer-manual/style-guide/examples/c-020.c b/docs/developer-manual/style-guide/examples/c-020.c index dccbedc3..c63b6120 100644 --- a/docs/developer-manual/style-guide/examples/c-020.c +++ b/docs/developer-manual/style-guide/examples/c-020.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-021.c b/docs/developer-manual/style-guide/examples/c-021.c index d477f186..1a5297b0 100644 --- a/docs/developer-manual/style-guide/examples/c-021.c +++ b/docs/developer-manual/style-guide/examples/c-021.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-022.c b/docs/developer-manual/style-guide/examples/c-022.c index 44a1ce60..9d4c7372 100644 --- a/docs/developer-manual/style-guide/examples/c-022.c +++ b/docs/developer-manual/style-guide/examples/c-022.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -42,7 +42,7 @@ #include "general.h" /** Symbolic names for battery system state */ -typedef struct ABC_DATE { +typedef struct { uint16_t year; /*!< year */ uint8_t month; /*!< month (1: january ... 12: december) */ uint8_t day; /*!< day of the month */ diff --git a/docs/developer-manual/style-guide/examples/c-023.c b/docs/developer-manual/style-guide/examples/c-023.c index b9828d46..bfe57f06 100644 --- a/docs/developer-manual/style-guide/examples/c-023.c +++ b/docs/developer-manual/style-guide/examples/c-023.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -40,7 +40,7 @@ */ /** Symbolic names for weekdays */ -typedef enum ABC_DAYS { +typedef enum { ABC_MONDAY, /**< First day of the week */ ABC_TUESDAY, /**< Second day of the week */ /* ... */ /* more members */ diff --git a/docs/developer-manual/style-guide/examples/c-024.c b/docs/developer-manual/style-guide/examples/c-024.c index 1bc599aa..80fb2486 100644 --- a/docs/developer-manual/style-guide/examples/c-024.c +++ b/docs/developer-manual/style-guide/examples/c-024.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-025.c b/docs/developer-manual/style-guide/examples/c-025.c index 99cc1fe4..e74eca04 100644 --- a/docs/developer-manual/style-guide/examples/c-025.c +++ b/docs/developer-manual/style-guide/examples/c-025.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-026.c b/docs/developer-manual/style-guide/examples/c-026.c index 6a72e6a0..bbe44b7a 100644 --- a/docs/developer-manual/style-guide/examples/c-026.c +++ b/docs/developer-manual/style-guide/examples/c-026.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-027.c b/docs/developer-manual/style-guide/examples/c-027.c index 67dd79a3..3e06e45b 100644 --- a/docs/developer-manual/style-guide/examples/c-027.c +++ b/docs/developer-manual/style-guide/examples/c-027.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/c-028-battery-defines.c b/docs/developer-manual/style-guide/examples/c-028-battery-defines.c index cb1a2694..fa86e5f1 100644 --- a/docs/developer-manual/style-guide/examples/c-028-battery-defines.c +++ b/docs/developer-manual/style-guide/examples/c-028-battery-defines.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -46,9 +46,9 @@ static void C28_BatteriesLoop(void); static void C28_BatteriesLoop(void) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* string related code */ - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { /* module related code */ - for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { /* cell related code */ } } diff --git a/docs/developer-manual/style-guide/examples/c-028.c b/docs/developer-manual/style-guide/examples/c-028.c index f87baa80..d0d2bb88 100644 --- a/docs/developer-manual/style-guide/examples/c-028.c +++ b/docs/developer-manual/style-guide/examples/c-028.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/python-006.py b/docs/developer-manual/style-guide/examples/python-006.py index 2fd6da06..a48d2a8f 100644 --- a/docs/developer-manual/style-guide/examples/python-006.py +++ b/docs/developer-manual/style-guide/examples/python-006.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/python-007.py b/docs/developer-manual/style-guide/examples/python-007.py index d1fdf8b9..a3113123 100644 --- a/docs/developer-manual/style-guide/examples/python-007.py +++ b/docs/developer-manual/style-guide/examples/python-007.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/examples/wscript b/docs/developer-manual/style-guide/examples/wscript index 7f4ca5cf..012153c1 100644 --- a/docs/developer-manual/style-guide/examples/wscript +++ b/docs/developer-manual/style-guide/examples/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -47,8 +47,8 @@ This build script is not meant to be reused! """ -import os import collections +import os def build(bld): @@ -65,6 +65,7 @@ def build(bld): "some_other_required_header2", "required_additional_header", "required_additional_header2", + "mcu", ] dummy_txt = "/* dummy file */\n" for i in dummy_headers: diff --git a/docs/developer-manual/style-guide/guidelines_c.rst b/docs/developer-manual/style-guide/guidelines_c.rst index 71c198c5..330f97e6 100644 --- a/docs/developer-manual/style-guide/guidelines_c.rst +++ b/docs/developer-manual/style-guide/guidelines_c.rst @@ -393,6 +393,12 @@ Function doxygen documentation (``C:011``) is not of type ``void``. - Function arguments **MUST** be documented using the doxygen parameter ``@param``. + - If a function argument is a pointer, the data flow direction (indicating + if the pointer is used as input, output or both) **MUST** be indicated + with a suffixed ``[in]``, ``[out]`` or ``[in,out]`` after the ``@param`` + tag. + - This practice **MUST NOT** be applied to normal parameters that are + passed by value as they are implicitly assumed to be input. - All doxygen parameter arguments **MUST** be whitespace aligned. :numref:`function-prototype-and-doxygen` and @@ -519,6 +525,11 @@ Function parameter checking (``C:015``) - Input values of function parameters **SHOULD** be checked at the beginning of a function if possible. - Pointers passed as parameters **MUST** be checked against ``NULL_PTR``. + - The check **SHOULD** be implemented with an assertion. + - If no assertion can be made for the parameter (e.g. if the parameter + intentionally accepts all possible values), the parameter **MUST** be + marked like this at the start of the function context: + ``/* AXIVION Routine Generic-MissingParameterAssert: *ENTITYNAME*: *RATIONALE* */``. Parameter checking is shown in :numref:`function-input-check`. @@ -865,8 +876,8 @@ loop Statements (``C:028``) There are three defines that are typically looped over: the number of strings -(``BS_NR_OF_STRINGS``), the number of modules (``BS_NR_OF_MODULES``) and the -number of batteries per module (``BS_NR_OF_CELLS_PER_MODULE``). +(``BS_NR_OF_STRINGS``), the number of modules (``BS_NR_OF_MODULES_PER_STRING``) +and the number of batteries per module (``BS_NR_OF_CELL_BLOCKS_PER_MODULE``). These loops **MUST** follow the pattern as shown in :numref:`special-counter-variables` and @@ -876,21 +887,21 @@ These loops **MUST** follow the pattern as shown in :name: special-counter-variables :widths: grid - +-------------------------------+-------------------+ - | Define | Counter variable | - +===============================+===================+ - | ``BS_NR_OF_STRINGS`` | ``s`` | - +-------------------------------+-------------------+ - | ``BS_NR_OF_MODULES`` | ``m`` | - +-------------------------------+-------------------+ - | ``BS_NR_OF_CELLS_PER_MODULE`` | ``c`` | - +-------------------------------+-------------------+ + +-------------------------------------+-------------------+ + | Define | Counter variable | + +=====================================+===================+ + | ``BS_NR_OF_STRINGS`` | ``s`` | + +-------------------------------------+-------------------+ + | ``BS_NR_OF_MODULES_PER_STRING`` | ``m`` | + +-------------------------------------+-------------------+ + | ``BS_NR_OF_CELL_BLOCKS_PER_MODULE`` | ``c`` | + +-------------------------------------+-------------------+ .. literalinclude:: ./examples/c-028-battery-defines.c :language: C :lines: 41- :linenos: - :caption: Looping over BS_NR_OF_STRINGS, BS_NR_OF_MODULES, BS_NR_OF_CELLS_PER_MODULE + :caption: Looping over BS_NR_OF_STRINGS, BS_NR_OF_MODULES_PER_STRING, BS_NR_OF_CELL_BLOCKS_PER_MODULE :name: special-counter-variables-example .. _rule_c_comment_style: diff --git a/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete-simplified.dot b/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete-simplified.dot index 47d0c282..e3041678 100644 --- a/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete-simplified.dot +++ b/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete-simplified.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete.dot b/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete.dot index edbd2a3f..8180872a 100644 --- a/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete.dot +++ b/docs/developer-manual/style-guide/state-machine-example/state-diagram-complete.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/state-machine-example/state-diagram-recoverable-error.dot b/docs/developer-manual/style-guide/state-machine-example/state-diagram-recoverable-error.dot index 961f7b9e..2d861c9d 100644 --- a/docs/developer-manual/style-guide/state-machine-example/state-diagram-recoverable-error.dot +++ b/docs/developer-manual/style-guide/state-machine-example/state-diagram-recoverable-error.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/state-machine-example/state-diagram-top-view.dot b/docs/developer-manual/style-guide/state-machine-example/state-diagram-top-view.dot index 499805c8..1332ad4e 100644 --- a/docs/developer-manual/style-guide/state-machine-example/state-diagram-top-view.dot +++ b/docs/developer-manual/style-guide/state-machine-example/state-diagram-top-view.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/developer-manual/style-guide/state-machine-example/state-machine.c b/docs/developer-manual/style-guide/state-machine-example/state-machine.c index 68f99539..b2ae41f3 100644 --- a/docs/developer-manual/style-guide/state-machine-example/state-machine.c +++ b/docs/developer-manual/style-guide/state-machine-example/state-machine.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file state-machine.c * @author foxBMS Team * @date 2020-10-29 (date of creation) - * @updated 2020-11-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup STATE_MACHINE * @prefix EG * @@ -74,7 +75,7 @@ #define EG_FSM_LONG_TIME (10u) /** Symbolic names to check for multiple calls of #EG_Trigger */ -typedef enum EG_CHECK_MULTIPLE_CALLS { +typedef enum { EG_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */ EG_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */ } EG_CHECK_MULTIPLE_CALLS_e; @@ -297,7 +298,7 @@ static EG_FSM_STATES_e EG_ProcessInitializationState(EG_STATE_s *pEgState) { break; case EG_FSM_SUBSTATE_INITIALIZATION_0: - if (true == EG_SomeInitializationFunction0()) { + if (EG_SomeInitializationFunction0() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_INITIALIZATION_1, EG_FSM_SHORT_TIME); } else { /* Something went wrong, so transition to error state */ @@ -306,7 +307,7 @@ static EG_FSM_STATES_e EG_ProcessInitializationState(EG_STATE_s *pEgState) { break; case EG_FSM_SUBSTATE_INITIALIZATION_1: - if (true == EG_SomeInitializationFunction1()) { + if (EG_SomeInitializationFunction1() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_INITIALIZATION_EXIT, EG_FSM_SHORT_TIME); } else { /* Something went wrong, so transition to error state */ @@ -315,7 +316,7 @@ static EG_FSM_STATES_e EG_ProcessInitializationState(EG_STATE_s *pEgState) { break; case EG_FSM_SUBSTATE_INITIALIZATION_EXIT: - if (true == EG_SomeInitializationFunctionExit()) { + if (EG_SomeInitializationFunctionExit() == true) { /* Initialization was successful, so transition to running state */ nextState = EG_FSM_STATE_RUNNING; } else { @@ -340,7 +341,7 @@ static EG_FSM_STATES_e EG_ProcessRunningState(EG_STATE_s *pEgState) { break; case EG_FSM_SUBSTATE_RUNNING_0: - if (true == EG_SomeRunningFunction0()) { + if (EG_SomeRunningFunction0() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_RUNNING_1, EG_FSM_SHORT_TIME); } else { /* Something went wrong, so transition to error state */ @@ -349,7 +350,7 @@ static EG_FSM_STATES_e EG_ProcessRunningState(EG_STATE_s *pEgState) { break; case EG_FSM_SUBSTATE_RUNNING_1: - if (true == EG_SomeRunningFunction1()) { + if (EG_SomeRunningFunction1() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_RUNNING_2, EG_FSM_SHORT_TIME); } else { /* Something went wrong, so transition to error state */ @@ -358,7 +359,7 @@ static EG_FSM_STATES_e EG_ProcessRunningState(EG_STATE_s *pEgState) { break; case EG_FSM_SUBSTATE_RUNNING_2: - if (true == EG_SomeRunningFunction2()) { + if (EG_SomeRunningFunction2() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_RUNNING_0, EG_FSM_SHORT_TIME); } else { /* Something went wrong, so transition to error state */ diff --git a/docs/developer-manual/style-guide/state-machine-example/state-machine.h b/docs/developer-manual/style-guide/state-machine-example/state-machine.h index 5a7a55b8..e0e7efef 100644 --- a/docs/developer-manual/style-guide/state-machine-example/state-machine.h +++ b/docs/developer-manual/style-guide/state-machine-example/state-machine.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file state-machine.h * @author foxBMS Team * @date 2020-10-29 (date of creation) - * @updated 2020-11-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup STATE_MACHINE * @prefix EG * @@ -59,7 +60,7 @@ /*========== Macros and Definitions =========================================*/ /** States of the state machine */ -typedef enum EG_FSM_STATES { +typedef enum { EG_FSM_STATE_DUMMY, /*!< dummy state - always the first state */ EG_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */ EG_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */ @@ -69,7 +70,7 @@ typedef enum EG_FSM_STATES { } EG_FSM_STATES_e; /** Substates of the state machine */ -typedef enum EG_FSM_SUBSTATES { +typedef enum { EG_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */ EG_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */ EG_FSM_SUBSTATE_INITIALIZATION_0, /*!< fist initialization substate */ @@ -81,14 +82,14 @@ typedef enum EG_FSM_SUBSTATES { } EG_FSM_SUBSTATES_e; /** some struct with some information */ -typedef struct EG_INFORMATION { +typedef struct { uint8_t r0; /*!< some info 0 */ - uint8_t r1; /*!< some info 0 */ - uint8_t r2; /*!< some info 0 */ + uint8_t r1; /*!< some info 1 */ + uint8_t r2; /*!< some info 2 */ } EG_INFORMATION_s; /** This struct describes the state of the monitoring instance */ -typedef struct EG_STATE { +typedef struct { uint16_t timer; /*!< timer of the state */ uint8_t triggerEntry; /*!< trigger entry of the state */ EG_FSM_STATES_e nextState; /*!< next state of the FSM */ diff --git a/docs/developer-manual/style-guide/state-machine-example/wscript b/docs/developer-manual/style-guide/state-machine-example/wscript index 689de49d..8ec3b943 100644 --- a/docs/developer-manual/style-guide/state-machine-example/wscript +++ b/docs/developer-manual/style-guide/state-machine-example/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -53,16 +53,19 @@ import os def build(bld): """Build the state machine object""" source = ["state-machine.c"] + dummy_txt = "/* dummy file */\n" + dummy_headers = ["HL_sys_core", "HL_sys_common"] + for i in dummy_headers: + bld.path.find_or_declare(f"{i}.h").write(dummy_txt) includes = [ ".", os.path.join("..", "..", "..", "..", "src", "app", "main", "include"), ] cflags = bld.env.CFLAGS_FOXBMS - bld.path.find_or_declare("HL_sys_common.h").write( + bld.path.find_or_declare("mcu.h").write( "/* dummy file */\n" "extern void OS_EnterTaskCritical();\n" "extern void OS_ExitTaskCritical();\n" ) - bld.path.find_or_declare("HL_sys_core.h").write("/* dummy file */\n") bld.add_group() bld(features="c", source=source, includes=includes, cflags=cflags) diff --git a/docs/developer-manual/style-guide/state-machines_how-to.rst b/docs/developer-manual/style-guide/state-machines_how-to.rst index ee32ff68..96833dc3 100644 --- a/docs/developer-manual/style-guide/state-machines_how-to.rst +++ b/docs/developer-manual/style-guide/state-machines_how-to.rst @@ -104,7 +104,7 @@ account, the enum for the states used in this example looks like this: :caption: Enumeration of the states :name: enum-for-states - typedef enum EG_FSM_STATES { + typedef enum { EG_FSM_STATE_DUMMY, /*!< dummy state - always the first state */ EG_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */ EG_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */ @@ -124,7 +124,7 @@ account, the enum for the substates used in this example looks like this: :caption: Enumeration of the substates :name: substates - typedef enum EG_FSM_SUBSTATES { + typedef enum { EG_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */ EG_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */ EG_FSM_SUBSTATE_INITIALIZATION_0, /*!< fist initialization substate */ @@ -149,7 +149,7 @@ is just a struct holding three values. :caption: The state type :name: state-type - typedef struct EG_STATE { + typedef struct { uint16_t timer; /*!< timer of the state */ uint8_t triggerEntry; /*!< trigger entry of the state */ EG_FSM_STATES_e nextState; /*!< next state of the FSM */ @@ -668,7 +668,7 @@ transfer into the state |state_error|. If this substate was successful the switch (pEgState->currentSubstate) { /* ... */ case EG_FSM_SUBSTATE_INITIALIZATION_0: - if (true == EG_SomeInitializationFunction0()) { + if (EG_SomeInitializationFunction0() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_INITIALIZATION_1, EG_FSM_SHORT_TIME); } else { /* Something might go wrong, so transition to error state */ @@ -701,7 +701,7 @@ implementation: switch (pEgState->currentSubstate) { /* ... */ case EG_FSM_SUBSTATE_INITIALIZATION_EXIT: - if (true == EG_SomeInitializationFunctionExit()) { + if (EG_SomeInitializationFunctionExit() == true) { /* Initialization was successful, so transition to running state */ nextState = EG_FSM_STATE_RUNNING; } else { @@ -774,7 +774,7 @@ implementation is shown below: break; case EG_FSM_SUBSTATE_RUNNING_0: - if (true == EG_SomeRunningFunction0()) { + if (EG_SomeRunningFunction0() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_RUNNING_1, EG_FSM_SHORT_TIME); } else { /* Something might go wrong, so transition to error state */ @@ -783,7 +783,7 @@ implementation is shown below: break; case EG_FSM_SUBSTATE_RUNNING_1: - if (true == EG_SomeRunningFunction1()) { + if (EG_SomeRunningFunction1() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_RUNNING_2, EG_FSM_SHORT_TIME); } else { /* Something might go wrong, so transition to error state */ @@ -792,7 +792,7 @@ implementation is shown below: break; case EG_FSM_SUBSTATE_RUNNING_2: - if (true == EG_SomeRunningFunction2()) { + if (EG_SomeRunningFunction2() == true) { EG_SetSubstate(pEgState, EG_FSM_SUBSTATE_RUNNING_0, EG_FSM_SHORT_TIME); } else { /* Something might go wrong, so transition to error state */ diff --git a/docs/general/changelog.rst b/docs/general/changelog.rst index c9c6b503..ab923977 100644 --- a/docs/general/changelog.rst +++ b/docs/general/changelog.rst @@ -12,9 +12,10 @@ Changelog Axivion is the company that builds the Axivion Bauhaus suite PEC stands for pack error check slaveplausibility is the old name of a plausibility module - sym is the file extention of a symbol file + sym is the file extension of a symbol file JUnit is a test system (originally for Java) matcher as in `problem matcher` + Cppcheck is a static program analysis tools .. spelling:: Axivion @@ -23,6 +24,7 @@ Changelog sym JUnit matcher + Cppcheck All notable changes to this project will be documented in this file. @@ -39,6 +41,151 @@ Versioning follows then these rules: - increasing ``MINOR`` adds functionality in a backwards compatible manner - increasing ``PATCH`` fixes bugs in a backwards compatible manner +******************** +[1.3.0] - 2022-05-30 +******************** + +|foxbms| updated to TI ARM CGT 20.2.5.LTS. Installation instructions are found +at :numref:`css_install`. + +|foxbms| updated to LLVM 13.0.0. Installation instructions are found at +:numref:`llvm_install`. + +Added +===== + +- The new default compiler set in ``conf/env/paths_win32.txt`` and + ``conf/env/paths_linux.txt`` is now TI ARM CGT v20.2.5.LTS (shipped with CCS + ``11.0.0``). +- Add support for the environment variable ``FOXBMS_2_CCS_VERSION_STRICT`` to + check for the exact CCS version. +- Added hardware specifications for the LTC based slaves to the documentation. +- Added a superimposed state machine for all insulation monitoring device + drivers to control the subordinate, device specific driver implementations. +- Added driver implementation for Bender IR155 insulation monitoring device. +- Transmit the unique ID of the MCU on which |foxbms| is running on startup + via CAN. +- Added a mechanism to the ``algorithm`` module that allows to reinitialize an + algorithm. +- Added an API to the ``MCU`` module that allows to measure microseconds with + the ``RTI`` module. +- Added a can helper that transforms a boolean to an integer value (fitting to + the CAN messages). +- The Axivion configuration has been updated to ``7.2.3`` in the release + ``1.1.2``, however the version setting in the configuration file has not. + The versions of the Axivion Suite and the configuration files have been + aligned to ``7.2.3``. +- Added the version information to the header section of all ``C`` source and + header files. +- Added a function to compute CRCs with the MCU hardware. +- The ``FRAM`` module now writes a CRC of the data written to the FRAM. It + also reads the stored CRC and compares it with the CRC calculated on the + read data. This makes FRAM entries existing prior to this version invalid. +- A ``DIAG`` entry was added for FRAM errors. +- Added documentation for the ``FRAM`` and the ``CRC`` modules. +- Integrated interaction with the diagnostic module into the Maxim ``AFE`` + driver. +- Added information on debug adapters to the documentation. +- Documented the rule that pointer parameters to functions must indicate in + their Doxygen documentation whether they are used as input, output or both. +- Added a continuously running task with same priority as the 1ms task. + It is suspended by default if unused. +- Added documentation on the Maxim driver. + +Changed +======= + +- The linker step now uses ``--start-group`` and ``--end-group`` to re-read + libraries until all symbols are resolved instead of ``--reread_libs``. + This change simplifies the integration of the build into Axivion. +- FreeRTOS configuration is now validated in + ``os_freertos_config-validation.h``. +- Updated the documentation of the of the LTC-based interface |ltc6820| version + 1.0.3 (see :ref:`INTERFACE_LTC_6820___V1_0_3__`). +- Updated LLVM to version 13.0.0. +- Updated the pinout documentation for the |bms-master| version 1.1.1 + (see :ref:`MASTER_TMS570___V1_1_1__`). +- Update the static code analysis to Axivion 7.4.0. +- Increased the size of the variable that describes stack sizes for FreeRTOS, + allowing for the fully supported stack size of the port. +- The diagnosis entries for the ``LTC`` module have been renamed in order to + reflect that they are relevant for all ``AFE`` implementations. +- The schema file for the ``bms.json`` configuration file has been split into + several files for readability and |code| has been made aware of the schema. +- Added a style check that constant values should be on the right hand side of + a comparison. +- Updated FreeRTOS to version 10.4.5 (from 10.4.3). +- Cleaned up the CAN callback for receiving commands. +- Extended the script for updating the doxygen headers in source files so that + it fetches first and then compares to the tracking branch. +- Updated the documentation of the system monitoring module and implemented + the recording of violations to the persistent memory. +- Split the definition of CAN callback functions into separate definitions for + received and transmitted messages in order to better reflect the actual + implementation and prevent wrong usage. +- Number of strings now configured to one by default. +- Renamed the ``FRAM`` functions to adhere to *verb-noun* style. +- Extended the Axivion configuration so that parameters without an assertion + can be suppressed. +- The threshold above which balancing is started for a single cell has been + made configurable by the |foxbms| CAN messages that are already defined. +- MCU specific defines have been moved from ``general.h`` to ``mcu.h``. +- The static assert macro ``static_assert`` has been renamed to + ``f_static_assert`` to work around compiler limitations. +- The following defines have been renamed to be aligned with + :ref:`NAMING_CONVENTIONS`: + + - ``BS_NR_OF_MODULES`` to ``BS_NR_OF_MODULES_PER_STRING``, + - ``BS_NR_OF_CELLS_PER_MODULE`` to ``BS_NR_OF_CELL_BLOCKS_PER_MODULE`` and + - ``BS_NR_OF_BAT_CELLS`` to ``BS_NR_OF_CELL_BLOCKS_PER_STRING``. +- Loop correctly over ``BS_NR_OF_MODULES_PER_STRING``, + ``BS_NR_OF_CELL_BLOCKS_PER_MODULE`` and ``BS_NR_OF_CELL_BLOCKS_PER_STRING``. + +- Function names are now checked by Axivion to conform to the guidelines. +- Improved the MISRA-C conformance of of the database module + (:ref:`DATABASE_MODULE`). +- Fixed the pack current check in ``SOA_CheckCurrent``. +- Fixed LLVM install script to check for permissions before running the script. + +Deprecated +========== + +Removed +======= + +- Removed unused function ``OS_SystemTickHandler()``. +- The Cppcheck support and its configuration files as well as the respective + build and clean commands have been removed. + The static program analysis of the embedded software is done by Axivion + Bauhaus Suite (see :ref:`AXIVION_BAUHAUS_SUITE`). + +Fixed +===== + +- Fixed a bug where the ``update_doxygen_header.py`` script tried to + ``git add`` files that did not exist. +- The HALCoGen SPI interface chip select configuration is overwritten and all + hardware chip selects are disabled when using a software chip select. + This causes all SPI communication using hardware chip selects to fail for + this SPI interface. + Now the SPI chip select register are correctly configured before starting a + SPI transaction. +- Suppress a superfluous warning during unit test builds concerning the number + of bytes per word (as this information is used for task sizing). +- Fixed "unsafe" macros that had not parentheses and added this violation to + violations that fail the CI. +- Fixed undesired attempt of installation of git hooks even when the project + was not stored in a git repository. +- Fixed import order in Python files. +- Fixed a static assertion in the Maxim driver (that prevented in some + constellations compilation due to a logic error). +- Fixed a timing violation in the Maxim driver (a computationally costly + operation has been moved out of the 1ms-task). +- Some defines where invisible to the preprocessor due to missing includes. + This has been resolved and measures taken that this situation cannot return. +- The HALCoGen generated startup file ``HL_sys_startup.c`` does not need to be + compiled as |foxbms| implements the startup in ``fstartup.c``. + ******************** [1.2.1] - 2021-12-08 ******************** @@ -211,7 +358,7 @@ Added * fix some includes (library-inclusions and unnecessary inclusions) * adds the Axivion example for race condition analysis and a minimal configuration of entry points - * updates .axivion.preinc with missing symbols + * updates ``.axivion.preinc`` with missing symbols * makes cafeCC point to the right compiler library * excludes vendored code from analysis * disables all naming conventions (as they are currently not configured and @@ -364,7 +511,7 @@ Changed - Dropped the requirement for an internal library (``pyhameg``) in the HIL test. - Updated the unit test framework ``ceedling`` to version ``0.31.1``. -- Simplified the configuration of the cppcheck tool. +- Simplified the configuration of the Cppcheck tool. - Improved several function names in the ``ftask`` module. - All required Queues are now created in one function (``FTSK_CreateQueues``) before the scheduler starts. diff --git a/docs/general/license.rst b/docs/general/license.rst index 3e127d0d..9bb6373c 100644 --- a/docs/general/license.rst +++ b/docs/general/license.rst @@ -149,7 +149,7 @@ FreeRTOS +---------------------------+---------------------------------------+ | License URL | https://www.freertos.org/a00114.html | +---------------------------+---------------------------------------+ -| Latest license check | 2020-06-23 | +| Latest license check | 2022-01-17 | +---------------------------+---------------------------------------+ | Website | https://www.freertos.org/ | +---------------------------+---------------------------------------+ @@ -268,27 +268,13 @@ LLVM +-----------------------+----------------------------------------------+ | SPDX short identifier | LLVM-exception | +-----------------------+----------------------------------------------+ -| License URL | https://releases.llvm.org/11.0.0/LICENSE.TXT | +| License URL | https://releases.llvm.org/13.0.0/LICENSE.TXT | +-----------------------+----------------------------------------------+ -| Latest license check | 2020-06-23 | +| Latest license check | 2022-01-13 | +-----------------------+----------------------------------------------+ | Website | https://llvm.org/ | +-----------------------+----------------------------------------------+ - -Cppcheck --------- - -+-----------------------+-----------------------------------+ -| License | GPLv3 | -+-----------------------+-----------------------------------+ -| License File | /GPLv3.txt | -+-----------------------+-----------------------------------+ -| Latest license check | 2020-06-23 | -+-----------------------+-----------------------------------+ -| Website | http://cppcheck.sourceforge.net/ | -+-----------------------+-----------------------------------+ - RubyInstaller ------------- diff --git a/docs/general/releases.csv b/docs/general/releases.csv index b5317e57..c4fc8cb4 100644 --- a/docs/general/releases.csv +++ b/docs/general/releases.csv @@ -1,4 +1,5 @@ foxBMS 2; Release Date; Permanent link to documentation +v1.3.0; 2022-05-30; https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/docs/html/v1.3.0/ v1.2.1; 2021-12-08; https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/docs/html/v1.2.1/ v1.2.0; 2021-10-21; https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/docs/html/v1.2.0/ v1.1.2; 2021-09-03; https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/docs/html/v1.1.2/ diff --git a/docs/general/team-dev.rst b/docs/general/team-dev.rst index 00bbe594..8e9d9473 100644 --- a/docs/general/team-dev.rst +++ b/docs/general/team-dev.rst @@ -5,7 +5,9 @@ - Patrick Kanzler - Radu Schwarz - Reinhold Waller +- Rolf Seebeck - Sebastian Wacker - Stéphane Koffel - Stefan Waldhör +- Steffen Bockrath - Tobias Huf diff --git a/docs/getting-started/llvm-installation/llvm-installation.rst b/docs/getting-started/llvm-installation/llvm-installation.rst new file mode 100644 index 00000000..af899bf0 --- /dev/null +++ b/docs/getting-started/llvm-installation/llvm-installation.rst @@ -0,0 +1,31 @@ +:orphan: + +.. include:: ./../../macros.txt +.. include:: ./../../units.txt + +.. _MANUAL_LLVM_INSTALLATION: + +######################## +Manual LLVM Installation +######################## + +.. note:: + + The LLVM installer does not support installing different versions of + LLVM. + If there is already some LLVM version installed into + ``C:\Program Files\LLVM\*`` this installation must be copied to some + temporary folder, and then can be copied back into + ``C:\Program Files\LLVM\other-LLVM-version`` after the installation + has finished. + +#. Download LLVM (version |version_llvm|) from + `github.com/LLVM`_ + version 13.0.0 `_ + from the project's GitHub release page. +#. Copy the existing LLVM installation to some temporary directory. +#. Remove the LLVM installation directory. +#. Run the installer. + Choose |path_llvm| as installation directory + Do not add LLVM to ``PATH``. +#. Copy the previous LLVM installations back to the original place. diff --git a/docs/getting-started/software-installation.rst b/docs/getting-started/software-installation.rst index 9e507651..92e22251 100644 --- a/docs/getting-started/software-installation.rst +++ b/docs/getting-started/software-installation.rst @@ -35,7 +35,6 @@ all required software dependencies. These are the required steps: #. installing LLVM (required for code formatting) #. installing Ruby and the Ceedling package (required for unit testing) #. installing GCC (required for unit testing) - #. installing Cppcheck (required for static program analysis) #. installing VS Code (required for developing) #. setting up a development environment @@ -71,9 +70,9 @@ later steps of this manual. :caption: Downloading a release :name: download-foxbms-2 - C:\Users\vulpes\Documents>curl -Ss -L -o foxbms-2-v1.2.1.zip https://github.com/foxBMS/foxbms-2/archive/v1.2.1.zip - C:\Users\vulpes\Documents>tar -x -f foxbms-2-v1.2.1.zip - C:\Users\vulpes\Documents>ren foxbms-2-1.2.1 foxbms-2 + C:\Users\vulpes\Documents>curl -Ss -L -o foxbms-2-v1.3.0.zip https://github.com/foxBMS/foxbms-2/archive/v1.3.0.zip + C:\Users\vulpes\Documents>tar -x -f foxbms-2-v1.3.0.zip + C:\Users\vulpes\Documents>ren foxbms-2-1.3.0 foxbms-2 C:\Users\vulpes\Documents>cd foxbms-2 .. note:: @@ -178,9 +177,9 @@ Installing Miniconda and Configuration | Automated Configuration | Manual Configuration | +================================================================================+=========================================+ | For automated configuration of conda according to |foxbms| requirements just | The manual configuration | - | run: | of conda is | - | | described in | - | .. code-block:: console | :ref:`MANUAL_CONDA_CONFIGURATION`. | + | run: | of conda is described in | + | | :ref:`MANUAL_CONDA_CONFIGURATION`. | + | .. code-block:: console | | | :caption: Running the automated ``conda-init.bat`` configuration script | | | | | | C:\Users\vulpes\Documents\foxbms-2>tools\utils\conda-init.bat | | @@ -188,22 +187,25 @@ Installing Miniconda and Configuration | .. note:: | | | | | | If the script returns | | - | *Maybe you need to add "foxbms" to your channels list.* | | + | "Maybe you need to add "foxbms" to your channels list." | | | please follow the instructions at :ref:`condarc_configuration`. | | | | | +--------------------------------------------------------------------------------+-----------------------------------------+ +.. _llvm_install: + Installing LLVM =============== +--------------------------------------------------------------------------------+-----------------------------------------+ | Automated Installation | Manual Installation | +================================================================================+=========================================+ -| For automated installation of LLVM according to |foxbms| requirements | Download `LLVM`_ (version |version_llvm|| -| just run (the installer will prompt for privileged installation): | or greater) from `github.com/LLVM`_ and | -| | run the installer. Let it install it | -| .. code-block:: console | into |path_llvm|. Do not add LLVM to | -| :caption: Running the automated ``llvm-install.bat`` installer script | ``PATH``. | +| For a semi-automated installation of LLVM according to |foxbms| | The manual installation | +| requirements just run in an elevated command prompt (known as "Run as | of LLVM is described in | +| administrator"): | :ref:`MANUAL_LLVM_INSTALLATION`. | +| | | +| .. code-block:: console | | +| :caption: Running the automated ``llvm-install.bat`` installer script | | | for LLVM | | | | | | C:\Users\vulpes\Documents\foxbms-2>tools\utils\llvm-install.bat | | @@ -251,24 +253,6 @@ Installing GCC | | | +--------------------------------------------------------------------------------+-----------------------------------------+ -Installing Cppcheck -=================== - -.. note:: - - The Cppcheck installer does not support installing different versions of - Cppcheck. If there is already some Cppcheck version installed into - ``C:\Program Files\Cppcheck\*`` this installation must be copied to some - temporary folder, and then can be copied back into - ``C:\Program Files\Cppcheck\other-cppcheck-version`` after the installation - has finished. - -#. Download Cppcheck - `version 2.2 `_ - from the project's GitHub release page. -#. Install Cppcheck into ``C:\Program Files\Cppcheck\Cppcheck-2.2-x64`` by - running the installer. - Installing VS Code and Extensions ================================= diff --git a/docs/hardware/connectors.rst b/docs/hardware/connectors.rst index 6e585f01..aae15519 100644 --- a/docs/hardware/connectors.rst +++ b/docs/hardware/connectors.rst @@ -14,10 +14,10 @@ This section summarizes the types of connectors used in |foxbms|. Comment: This section should contain: Molex connectors, the extension connectors, additional pin header, JTAG connectors (both cTI and Mictor) -.. _CONVENTION_FOR_CONNECTOR_PIN_NUMBERING: +.. _CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING: -Convention for Connector Pin Numbering --------------------------------------- +Convention for Molex Micro-Fit 3.0 Connector Pin Numbering +---------------------------------------------------------- :numref:`molex-connector-numbering` presents the convention for the numbering of pins in Molex connectors. @@ -41,3 +41,49 @@ The numbering shown on the left in :numref:`molex-connector-numbering` is always valid when viewing in the direction indicated by the arrow with the indication ``viewing direction``. This must be taken into account when crimping the receptacles. + +.. _CONVENTION_FOR_SAMTEC_EDGE_RATE_CONNECTOR_PIN_NUMBERING: + +Convention for Samtec Edge Rate connectors +------------------------------------------ + +|tbc| + +.. _CONVENTION_FOR_MICTOR_CONNECTOR_PIN_NUMBERING: + +Convention for Mictor Pin Numbering +----------------------------------- + +|tbc| + +.. _CONVENTION_FOR_WUERTH_WR_MJ_CONNECTOR_PIN_NUMBERING: + +Convention for Wuerth WR-MJ connector +------------------------------------- + +|tbc| + +.. _DEBUG_ADAPTERS: + +Debug adapters +-------------- + +The |master| is connected to the debugger through a debug port. +On the standard design, a Mictor 38 pin connector is used with the pin +numbering described in :ref:`CONVENTION_FOR_MICTOR_CONNECTOR_PIN_NUMBERING`. + +The benefit of this connector is that it enables both a JTAG connection (for +debugging purposes) and a trace connection (for detailed trace analysis). +In order to interface this port to a normal debugger, an adapter as to be used. +As an example part number +`8.06.08 `_ +from Segger can be used. +This is just an example, other manufacturers such as Lauterbach have similar +adapters. + +On more compact, derived designs of the |master| a connector according to the +compact TI 20 pin connector is used. +On this connector, only JTAG connections are supported. +This connector can be interfaced for example with part number +`8.06.06 `_ +from Segger. diff --git a/docs/hardware/hardware.rst b/docs/hardware/hardware.rst index 6a0a951f..dc054203 100644 --- a/docs/hardware/hardware.rst +++ b/docs/hardware/hardware.rst @@ -6,14 +6,4 @@ Hardware ======== -An overview of the hardware is shown in the block diagram -:numref:`foxbms-2-master-hardware-block-diagram`. - -.. figure:: img/block-diagram.png - :alt: Block diagram of the |foxbms| hardware - :name: foxbms-2-master-hardware-block-diagram - :width: 100 % - - Block diagram of the |foxbms| hardware - |tbc| diff --git a/docs/hardware/interfaces.rst b/docs/hardware/interfaces.rst index 4059552b..a29c5c48 100644 --- a/docs/hardware/interfaces.rst +++ b/docs/hardware/interfaces.rst @@ -17,4 +17,7 @@ LTC-based Interfaces MAXIM-based Interfaces ---------------------- -|tbc| +.. toctree:: + :maxdepth: 1 + + ./interfaces/maxim-max17841b-vx.x.x/maxim-max17841b-v1.0.0 diff --git a/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3.rst b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3.rst index 022dbc39..148bd2c3 100644 --- a/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3.rst +++ b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3.rst @@ -1,10 +1,10 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _INTERFACE_LTC_6820_V1_0_3: +.. _INTERFACE_LTC_6820___V1_0_3__: -Interface LTC-6820 V1.0.3 -========================= +Interface LTC-6820 ``v1.0.3`` +============================= .. |local_interface_version| replace:: ``1.0.3`` @@ -20,7 +20,8 @@ Overview .. hint:: All connector pinouts described below follow the - :ref:`CONVENTION_FOR_CONNECTOR_PIN_NUMBERING`. + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING` and + :ref:`CONVENTION_FOR_SAMTEC_EDGE_RATE_CONNECTOR_PIN_NUMBERING`. The |bms-interface| is used to enable communication between the |bms-master| and the |bms-slaves|. @@ -30,15 +31,62 @@ The |bms-interface| is intended to be used together with a |bms-master|. .. _interface-ltc6820_v1.0.3_rendering: .. figure:: ./ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_rendering.png - :width: 100 % + :width: 80 % 3D rendering of the |bms-interface| +-------------- +Specifications +-------------- + +^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions +^^^^^^^^^^^^^^^^^^^^^ + +The size of the PCB is 70 |_| |mm| |_| x |_| 120 |_| |mm|. A 3D-model and a +drawing of the PCB can be found in section :ref:`DESIGN_RESOURCES`. + +^^^^^^^^^^^^^^^^^ +isoSPI Insulation +^^^^^^^^^^^^^^^^^ + +The interface board is designed for a maximum continuous insulation voltage of +1250 |_| V |_| DC between all four isoSPI channels and between each isoSPI +channel and the |bms-master|. + +The insulation is designed according to DIN |_| EN |_| 60664-1:2008-01 under +the following conditions: + +- Type of insulation: functional +- Electrical field: homogeneous +- Pollution degree: 2 +- PCB insulator class: 3b +- Transient voltage: 4300 |_| V |_| DC +- Continuous (working) voltage: 1250 |_| V |_| DC (selected due to design + space constraints on PCB) + +The PCB design complies with the following parameters: + +- Clearance: 1.3 |_| |mm| +- Creepage distance: 12.5 |_| |mm| + + ^^^^^^^^^^^^^ Block Diagram ^^^^^^^^^^^^^ -|tbc| +A block diagram of the |bms-interface| is shown in +:numref:`Fig. %s `. + +.. _interface-ltc6820_v1.0.3_block_diagram: +.. figure:: ./ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.png + :width: 100 % + + Block diagram of the |bms-interface| + +Each of the four isoSPI channels uses one |ltc6820| communication chip from +|adi| and an insulation transformer. +The |ltc6820| chips are directly connected to the MCU via |spi|. ^^^^^^^^^^^^^^^^^^^^^^^^^^ Schematic and Board Layout @@ -46,6 +94,8 @@ Schematic and Board Layout More information about the board schematic and layout files can be found in section :ref:`DESIGN_RESOURCES`. +For better debugging, there are test-points on the PCB for all relevant IO +signals. --------- Functions @@ -60,7 +110,7 @@ using the |ltc6820| transceiver chip from |adi|. The |ltc6820| transceivers are controlled by the SPI signals from the |bms-master|. The isoSPI signals are available on the connectors J101, J102, J103 and J104. -The pinout is described in +The pinout of these connectors is described in :numref:`Table %s `. .. csv-table:: isoSPI Daisy Chain Output Connectors @@ -69,18 +119,12 @@ The pinout is described in :delim: ; :file: ./ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_isospi_connectors.csv --------------- -Specifications --------------- - -^^^^^^^^^^^^^^^^^^^^^ -Mechanical Dimensions -^^^^^^^^^^^^^^^^^^^^^ - -The size of the PCB is 70x120mm. - -^^^^^^^^^^^^^^^^ -isoSPI Isolation -^^^^^^^^^^^^^^^^ +For the connection to the |bms-master|, a 40-pole mezzanine connector (J100) +is used. The pinout and pin usage is described in +:numref:`Table %s `. -|tbc| +.. csv-table:: Signal connector to |bms-master| + :name: interface-ltc6820_v1.0.3_master_connector + :header-rows: 1 + :delim: ; + :file: ./ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_master_connector.csv diff --git a/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.png b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.png new file mode 100644 index 00000000..865bae8e Binary files /dev/null and b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.png differ diff --git a/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.vsdx b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.vsdx new file mode 100644 index 00000000..4769f1ed Binary files /dev/null and b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_block_diagram.vsdx differ diff --git a/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_master_connector.csv b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_master_connector.csv new file mode 100644 index 00000000..ece424a5 --- /dev/null +++ b/docs/hardware/interfaces/ltc-ltc6820-vx.x.x/ltc-ltc6820-v1.0.3/ltc-ltc6820-v1.0.3_master_connector.csv @@ -0,0 +1,41 @@ +Pin; Signal; Description; Usage on |bms-interface| +1; ``MCU_SPI1.SOMI0``; \-; isoSPI channel 1/2 +2; ``MCU_SPI1.SOMI1``; \-; \- +3; ``MCU_SPI1.SIMO0``; \-; isoSPI channel 1/2 +4; ``MCU_SPI1.SIMO1``; \-; \- +5; ``MCU_SPI1.CLK``; \-; isoSPI channel 1/2 +6; ``MCU_SPI1.CS1``; \-; isoSPI channel 1 +7; ``MCU_SPI1.CS2``; \-; isoSPI channel 2 +8; ``MCU_SPI1.CS3``; \-; \- +9; ``MCU_SPI1.CS4``; \-; \- +10; ``MCU_SPI1.CS5``; \-; \- +11; ``MCU_SPI4.SOMI``; \-; isoSPI channel 3/4 +12; ``MCU_SPI4.SIMO``; \-; isoSPI channel 3/4 +13; ``MCU_SPI4.CLK``; \-; isoSPI channel 3/4 +14; ``MCU_SPI4.CS0``; \-; isoSPI channel 3 +15; ``MCU_SPI4.CS1``; \-; isoSPI channel 4 +16; ``MCU_SPI4.CS2``; \-; \- +17; ``MCU_SPI4.CS3``; \-; \- +18; ``MCU_SPI4.CS4``; \-; \- +19; ``MCU_SPI4.CS5``; \-; \- +20; ``IF_INT0``; Interrupt pin, connected to MCU GIOA_2; \- +21; ``IF_INT1``; Interrupt pin, connected to MCU GIOA_3; \- +22; ``IF_INT2``; Interrupt pin, connected to MCU GIOA_4; \- +23; ``IF_INT3``; Interrupt pin, connected to MCU GIOA_6; \- +24; ``IF_GPIO.0``; GPIO pin, connected to port expander 3 IO1_0; isoSPI channel 1 |ltc6820| enable +25; ``IF_GPIO.1``; GPIO pin, connected to port expander 3 IO1_1; isoSPI channel 1 |ltc6820| master +26; ``IF_GPIO.2``; GPIO pin, connected to port expander 3 IO1_2; isoSPI channel 2 |ltc6820| enable +27; ``IF_GPIO.3``; GPIO pin, connected to port expander 3 IO1_3; isoSPI channel 2 |ltc6820| master +28; ``IF_GPIO.4``; GPIO pin, connected to port expander 3 IO1_4; isoSPI channel 3 |ltc6820| enable +29; ``IF_GPIO.5``; GPIO pin, connected to port expander 3 IO1_5; isoSPI channel 3 |ltc6820| master +30; ``IF_GPIO.6``; GPIO pin, connected to port expander 3 IO1_6; isoSPI channel 4 |ltc6820| enable +31; ``IF_GPIO.7``; GPIO pin, connected to port expander 3 IO1_7; isoSPI channel 4 |ltc6820| master +32; ``GND``; Power supply ground; Power supply ground +33; ``GND``; Power supply ground; Power supply ground +34; ``PER_3.3V``; 3.3 |_| V from peripheral SBC; 3.3 |_| V power supply +35; ``PER_3.3V``; 3.3 |_| V from peripheral SBC; 3.3 |_| V power supply +36; ``PER_5.0V``; 5.0 |_| V from peripheral SBC; \- +37; ``PER_5.0V``; 5.0 |_| V from peripheral SBC; \- +38; ``VBB_12V``; 12 |_| V from buck-boost converter; \- +39; ``VSUP``; Master supply voltage (after protection circuits); \- +40; ``VSUP``; Master supply voltage (after protection circuits); \- diff --git a/docs/hardware/interfaces/maxim-max17841b-vx.x.x/.dummy b/docs/hardware/interfaces/maxim-max17841b-vx.x.x/.dummy deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/hardware/interfaces/maxim-max17841b-vx.x.x/maxim-max17841b-v1.0.0.rst b/docs/hardware/interfaces/maxim-max17841b-vx.x.x/maxim-max17841b-v1.0.0.rst new file mode 100644 index 00000000..d9629a95 --- /dev/null +++ b/docs/hardware/interfaces/maxim-max17841b-vx.x.x/maxim-max17841b-v1.0.0.rst @@ -0,0 +1,80 @@ +.. include:: ./../../../macros.txt +.. include:: ./../../../units.txt + +.. _INTERFACE_MAX17841B___V1_0_0__: + +Interface MAX17841B ``v1.0.0`` +============================== + +.. |local_interface_version| replace:: ``1.0.0`` + +.. note:: + + The design for this interface is not complete. + If you are interested in a design, please contact us. + +-------- +Overview +-------- + +.. important:: + + The following description only applies for the |max17841b|\ -based + |bms-interface| hardware version |local_interface_version|. + +.. hint:: + + All connector pinouts described below follow the + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING` and + :ref:`CONVENTION_FOR_SAMTEC_EDGE_RATE_CONNECTOR_PIN_NUMBERING`. + +The |bms-interface| is used to enable communication between the |bms-master| +and the |bms-slaves|. +The |bms-interface| is intended to be used together with a |bms-master|. + +-------------- +Specifications +-------------- + +^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions +^^^^^^^^^^^^^^^^^^^^^ + +The size of the PCB is 70 |_| |mm| |_| x |_| 120 |_| |mm|. + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Battery Management UART Insulation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The interface board is designed for a maximum continuous insulation voltage of +1250 |_| V |_| DC between all two Maxim Battery Management UART channels and +between each Maxim Battery Management UART channel and the |bms-master|. + +The insulation is designed according to DIN |_| EN |_| 60664-1:2008-01 under +the following conditions: + +- Type of insulation: functional +- Electrical field: homogeneous +- Pollution degree: 2 +- PCB insulator class: 3b +- Transient voltage: 4300 |_| V |_| DC +- Continuous (working) voltage: 1250 |_| V |_| DC (selected due to design + space constraints on PCB) + +The PCB design complies with the following parameters: + +- Clearance: 1.3 |_| |mm| +- Creepage distance: 12.5 |_| |mm| + + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Maxim Battery Management UART communication +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The |bms-interface| offers up to two isolated Maxim Battery Management UART +communication channels using the |max17841b| transceiver chip from |mxm|. +The |max17841b| transceivers are controlled by the SPI signals from the +|bms-master|. + +For the connection to the |bms-master|, a 40-pole mezzanine connector (J100) +is used. diff --git a/docs/hardware/master.rst b/docs/hardware/master.rst index 7b7ec78e..d418b039 100644 --- a/docs/hardware/master.rst +++ b/docs/hardware/master.rst @@ -6,9 +6,7 @@ Master Overview =============== - -TMS570LC4357-based Master -------------------------- +**TMS570LC4357-based Master** .. toctree:: :maxdepth: 1 diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1.rst b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1.rst index a4ec4b0d..26152aa3 100644 --- a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1.rst +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1.rst @@ -1,9 +1,47 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _MASTER_TMS570_V1_1_1: +.. _MASTER_TMS570___V1_1_1__: -Master TMS570 V1.1.1 -==================== +Master TMS570 ``v1.1.1`` +======================== -|tbc| +The following specifications must be met to ensure a safe and optimal work with +the |bms-master| hardware. + +^^^^^^^^^^^^^^^^^^ +Electrical Ratings +^^^^^^^^^^^^^^^^^^ + +================================================== ======= ======= ======= ==== +Description Minimum Typical Maximum Unit +================================================== ======= ======= ======= ==== +Supply Voltage Clamp 30 (VSUP_30) 9 12 55 V DC +Supply Voltage Clamp 30C (VSUP_30C) 9 12 55 V DC +Contactor Continuous Current -- -- 1.8 A +Contactor Feedback Supply Voltage -- VSUP_30 -- V +Interlock Circuit Sink Current -- 10 -- mA +Idle Supply Current at 12V DC for VSUP_30 -- 215 -- mA +Idle Supply Current at 24V DC for VSUP_30 -- 160 -- mA +================================================== ======= ======= ======= ==== + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions (BMS-Master PCB only) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +================================================== ======= ======= +Description Value Unit +================================================== ======= ======= +Width 120 mm +Length 200 mm +Height 13 mm +Weight 129 g +================================================== ======= ======= + + +.. toctree:: + :maxdepth: 1 + + ./ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_block_diagram.rst + ./ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_functional_description.rst + ./ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_pinout.rst diff --git a/docs/hardware/img/block-diagram.png b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/img/ti-tms570lc4357-v1.1.1._block-diagram.png similarity index 100% rename from docs/hardware/img/block-diagram.png rename to docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/img/ti-tms570lc4357-v1.1.1._block-diagram.png diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_can1.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_can1.csv new file mode 100644 index 00000000..155c5578 --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_can1.csv @@ -0,0 +1,5 @@ +Pin,Signal,Description +1,``GND``,\- +2,\-,\- +3,``CAN_LOW``,\- +4,``CAN_HIGH``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_can2.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_can2.csv new file mode 100644 index 00000000..155c5578 --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_can2.csv @@ -0,0 +1,5 @@ +Pin,Signal,Description +1,``GND``,\- +2,\-,\- +3,``CAN_LOW``,\- +4,``CAN_HIGH``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_debug.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_debug.csv new file mode 100644 index 00000000..232fcde6 --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_debug.csv @@ -0,0 +1,39 @@ +Pin,Signal,Description +1,\-,\- +2,\-,\- +3,\-,\- +4,\-,\- +5,``GND``,\- +6,``TRACECLK``,\- +7,``DBGRQ``,\- +8,``DBGACK``,\- +9,``RESET``,\- +10,``EXTRIG``,\- +11,``TDO``,\- +12,``MCU_3.3V``,\- +13,``RTCK``,\- +14,``MCU_3.3V``,\- +15,``TCK``,\- +16,``ETMDATA7``,\- +17,``TMS``,\- +18,``ETMDATA6``,\- +19,``TDI``,\- +20,``ETMDATA5``,\- +21,``TRST``,\- +22,``ETMDATA4``,\- +23,``ETMDATA15``,\- +24,``ETMDATA3``,\- +25,``ETMDATA14``,\- +26,``ETMDATA2``,\- +27,``ETMDATA13``,\- +28,``ETMDATA1``,\- +29,``ETMDATA12``,\- +30,``GND``,\- +31,``ETMDATA11``,\- +32,``GND``,\- +33,``ETMDATA10``,\- +34,``MCU_3.3V``,\- +35,``ETMDATA9``,\- +36,``TRACECTL``,\- +37,``ETMDATA8``,\- +38,``ETMDATA0``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_ethernet.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_ethernet.csv new file mode 100644 index 00000000..20f9ef0e --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_ethernet.csv @@ -0,0 +1,15 @@ +Pin,Signal,Description +1,``TX1_P``,\- +2,``TX1_N``,\- +3,``RX1_P``,\- +4,``TX2_P``,\- +5,``TX2_N``,\- +6,``RX1_N``,\- +7,``RX2_P``,\- +8,``RX2_N``,\- +9,``LED_YE_C``,\- +10,``LED_YE_A``,\- +11,``LED_GN_C``,\- +12,``LED_GN_A``,\- +S1,``SHIELD``,\- +S2,``SHIELD``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_extension.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_extension.csv new file mode 100644 index 00000000..9d77676d --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_extension.csv @@ -0,0 +1,121 @@ +Pin,Signal,Description +1,``MCU_SPI3.SOMI``,\- +2,``MCU_SPI3.SIMO``,\- +3,``MCU_SPI3.CLK``,\- +4,``MCU_SPI3.CS4``,\- +5,``MCU_SPI3.CS5``,\- +6,``MCU_SPI5.SOMI0``,\- +7,``MCU_SPI5.SOMI1``,\- +8,``MCU_SPI5.SOMI2``,\- +9,``MCU_SPI5.SOMI3``,\- +10,``MCU_SPI5.SIMO0``,\- +11,``MCU_SPI5.SIMO1``,\- +12,``MCU_SPI5.SIMO2``,\- +13,``MCU_SPI5.SIMO3``,\- +14,``MCU_SPI5.CLK``,\- +15,``MCU_SPI5.CS0``,\- +16,``MCU_SPI5.CS1``,\- +17,``MCU_SPI5.CS2``,\- +18,``MCU_SPI5.CS3``,\- +19,``EXT_CON.MCU_I2C1.SDA``,\- +20,``EXT_CON.MCU_I2C1.SCL``,\- +21,``EXT_CON.MCU_LIN1.RX``,\- +22,``EXT_CON.MCU_LIN1.TX``,\- +23,``EXT_CON.MCU_LIN2.RX``,\- +24,``EXT_CON.MCU_LIN2.TX``,\- +25,``EXT_CON.MCU_SCI3.RX``,\- +26,``EXT_CON.MCU_SCI3.TX``,\- +27,``EXT_CON.MCU_FRAY1.RX``,\- +28,``EXT_CON.MCU_FRAY1.TX``,\- +29,``EXT_CON.MCU_FRAY1.TXEN``,\- +30,``EXT_CON.MCU_FRAY2.RX``,\- +31,``EXT_CON.MCU_FRAY2.TX``,\- +32,``EXT_CON.MCU_FRAY2.TXEN``,\- +33,``EXT_CON.MCU_CAN3.RX``,\- +34,``EXT_CON.MCU_CAN3.TX``,\- +35,``EXT_CON.MCU_CAN4.RX``,\- +36,``EXT_CON.MCU_CAN4.TX``,\- +37,``EXT_CON.MCU_GIOA7``,\- +38,``EXT_CON.MCU_A11``,\- +39,``EXT_CON.MCU_A4``,\- +40,``EXT_CON.MCU_J1``,\- +41,``EXT_CON.MCU_P2``,\- +42,``EXT_CON.MCU_H4``,\- +43,``EXT_CON.MCU_B3``,\- +44,``EXT_CON.MCU_J4``,\- +45,``EXT_CON.MCU_P1``,\- +46,``EXT_CON.MCU_A14``,\- +47,``EXT_CON.MCU_K19``,\- +48,``EXT_CON.MCU_M16``,\- +49,``EXT_CON.MCU_N16``,\- +50,``DCC1``,\- +51,``EPWM1A``,\- +52,``EPWM1B``,\- +53,``ECAP4``,\- +54,``ECAP5``,\- +55,\-,\- +56,``AD1EVT``,\- +57,``AD2EVT``,\- +58,``AD1IN24``,\- +59,``AD1IN25``,\- +60,``AD1IN26``,\- +61,``AD1IN27``,\- +62,``AD2IN16``,\- +63,``AD2IN17``,\- +64,``AD2IN18``,\- +65,``AD2IN19``,\- +66,``GND``,\- +67,``GND``,\- +68,``WW_ENABLE``,\- +69,``WW_RESET``,\- +70,``EXT_CON.SMSW_LHM``,\- +71,``EXT_CON.SMSW1_IN1``,\- +72,``EXT_CON.SMSW1_IN2``,\- +73,``EXT_CON.SMSW1_IN3``,\- +74,``EXT_CON.SMSW1_IN4``,\- +75,``EXT_CON.SMSW2_IN1``,\- +76,``EXT_CON.SMSW2_IN2``,\- +77,``EXT_CON.SMSW2_IN3``,\- +78,``EXT_CON.SMSW2_IN4``,\- +79,``EXT_CON.SBC_MCU_FS0B``,\- +80,``SBC_MCU_RESET``,\- +81,``SBC_MCU_PGOOD``,\- +82,``EXT_CON.SBC_PER_FS0B``,\- +83,``SBC_PER_RESET``,\- +84,``SBC_PER_PGOOD``,\- +85,``EXT_CON.IL_ENABLE_EXT``,\- +86,``EXT_CON.IL_STATE``,\- +87,``GND``,\- +88,``GND``,\- +89,``PER_1.2V_1``,\- +90,``PER_1.2V_0``,\- +91,``PER_1.2V_1``,\- +92,``PER_1.2V_0``,\- +93,``GND``,\- +94,``PER_3.3V_LDO``,\- +95,``GND``,\- +96,``PER_3.3V_LDO``,\- +97,``GND``,\- +98,``PER_3.3V``,\- +99,``GND``,\- +100,``PER_3.3V``,\- +101,``GND``,\- +102,``PER_5.0V_LDO``,\- +103,``GND``,\- +104,``PER_5.0V_LDO``,\- +105,``MCU_3.3V``,\- +106,``PER_5.0V``,\- +107,``MCU_3.3V``,\- +108,``PER_5.0V``,\- +109,``MCU_5.0V_LDO``,\- +110,``PER_5.74V``,\- +111,``MCU_5.0V_LDO``,\- +112,``PER_5.74V``,\- +113,``GND``,\- +114,``GND``,\- +115,``GND``,\- +116,``GND``,\- +117,``VSUP``,\- +118,``VBB_12V``,\- +119,``VSUP``,\- +120,``VBB_12V``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_interface.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_interface.csv new file mode 100644 index 00000000..9a96609a --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_interface.csv @@ -0,0 +1,41 @@ +Pin,Signal,Description +1,``IF_CON.MCU_SPI1.SOMI0``,\- +2,``IF_CON.MCU_SPI1.SOMI1``,\- +3,``IF_CON.MCU_SPI1.SIMO0``,\- +4,``IF_CON.MCU_SPI1.SIMO1``,\- +5,``IF_CON.MCU_SPI1.CLK``,\- +6,``MCU_SPI1.CS1``,\- +7,``MCU_SPI1.CS2``,\- +8,``MCU_SPI1.CS3``,\- +9,``MCU_SPI1.CS4``,\- +10,``MCU_SPI1.CS5``,\- +11,``IF_CON.MCU_SPI4.SOMI``,\- +12,``IF_CON.MCU_SPI4.SIMO``,\- +13,``IF_CON.MCU_SPI4.CLK``,\- +14,``MCU_SPI4.CS0``,\- +15,``MCU_SPI4.CS1``,\- +16,``MCU_SPI4.CS2``,\- +17,``MCU_SPI4.CS3``,\- +18,``MCU_SPI4.CS4``,\- +19,``MCU_SPI4.CS5``,\- +20,``IF_INT0``,\- +21,``IF_INT1``,\- +22,``IF_INT2``,\- +23,``IF_INT3``,\- +24,``IF_CON.IF_GPIO.0``,\- +25,``IF_CON.IF_GPIO.1``,\- +26,``IF_CON.IF_GPIO.2``,\- +27,``IF_CON.IF_GPIO.3``,\- +28,``IF_CON.IF_GPIO.4``,\- +29,``IF_CON.IF_GPIO.5``,\- +30,``IF_CON.IF_GPIO.6``,\- +31,``IF_CON.IF_GPIO.7``,\- +32,``GND``,\- +33,``GND``,\- +34,``PER_3.3V``,\- +35,``PER_3.3V``,\- +36,``PER_5.0V``,\- +37,``PER_5.0V``,\- +38,``VBB_12V``,\- +39,``VSUP``,\- +40,``VSUP``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_interlock.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_interlock.csv new file mode 100644 index 00000000..bccb831b --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_interlock.csv @@ -0,0 +1,3 @@ +Pin,Signal,Description +1,``INTERLOCK_HIGH``,\- +2,``INTERLOCK_LOW``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_isomon.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_isomon.csv new file mode 100644 index 00000000..97b21d1d --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_isomon.csv @@ -0,0 +1,5 @@ +Pin,Signal,Description +1,``VSUP-``,\- +2,``VSUP+``,\- +3,``OK/NOK Signal``,\- +4,``PWM``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_rs485.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_rs485.csv new file mode 100644 index 00000000..159dbbc9 --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_rs485.csv @@ -0,0 +1,7 @@ +Pin,Signal,Description +1,``Y``,\- +2,``A``,\- +3,``GND``,\- +4,``Z``,\- +5,``B``,\- +6,``GND``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_sps.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_sps.csv new file mode 100644 index 00000000..494b2b0e --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_sps.csv @@ -0,0 +1,5 @@ +Pin,Signal,Description +1,``SPS_FEEDBACK_X``,\- +2,``FEEDBACK_SUPPLY``,\- +3,``SPS_OUT_X``,\- +4,``GND``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_supply_ext.csv b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_supply_ext.csv new file mode 100644 index 00000000..3b9b0c55 --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/pinout/ti-tms570lc4357-v1.1.1_supply_ext.csv @@ -0,0 +1,9 @@ +Pin,Signal,Description +1,``CLAMP15/IGNITION``,\- +2,``CLAMP30/SUPPLY+``,\- +3,``CLAMP30C/CONTACTOR_SUPPLY``,\- +4,``CLAMP31/SUPPLY-``,\- +5,``CLAMP31/SUPPLY-``,\- +6,``CLAMP30/SUPPLY+``,\- +7,``CLAMP30C/CONTACTOR_SUPPLY``,\- +8,``CLAMP31/SUPPLY-``,\- diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_block_diagram.rst b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_block_diagram.rst new file mode 100644 index 00000000..5bc1c10e --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_block_diagram.rst @@ -0,0 +1,17 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _MASTER_TMS570___V1_1_1___BLOCK_DIAGRAM: + +Master TMS570 ``v1.1.1`` Block diagram +====================================== + +A block diagram of the |bms-master| is shown in figure +:numref:`foxbms-2-master-hardware-block-diagram`. + +.. figure:: img/ti-tms570lc4357-v1.1.1._block-diagram.png + :alt: Block diagram of the |bms-master| hardware + :name: foxbms-2-master-hardware-block-diagram + :width: 100 % + + Block diagram of the |bms-master| hardware diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_functional_description.rst b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_functional_description.rst new file mode 100644 index 00000000..6872b27f --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_functional_description.rst @@ -0,0 +1,7 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _MASTER_TMS570___V1_1_1___FUNCTIONAL_DESCRIPTION: + +Master TMS570 ``v1.1.1`` Functional description +=============================================== diff --git a/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_pinout.rst b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_pinout.rst new file mode 100644 index 00000000..9c2e0e08 --- /dev/null +++ b/docs/hardware/master/ti-tms570lc4357-vx.x.x/ti-tms570lc4357-v1.1.1/ti-tms570lc4357-v1.1.1_pinout.rst @@ -0,0 +1,175 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _MASTER_TMS570___V1_1_1___PINOUT: + +Master TMS570 ``v1.1.1`` Pinout +=============================== + +.. |local_master_version| replace:: ``v1.1.1`` + +.. important:: + + The following description only applies for the |bms-master| hardware version + |local_master_version|. + +.. hint:: + + All connector pinouts described below follow the + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING`, + :ref:`CONVENTION_FOR_SAMTEC_EDGE_RATE_CONNECTOR_PIN_NUMBERING`, + :ref:`CONVENTION_FOR_MICTOR_CONNECTOR_PIN_NUMBERING` or + :ref:`CONVENTION_FOR_WUERTH_WR_MJ_CONNECTOR_PIN_NUMBERING`. + +This section describes the pinout of all connectors on the |bms-master| +|local_master_version|. + +Supply +###### + +The external supply for the |bms-master| is supplied using a 8 pole Molex +Micro-Fit 3.0 connector (J2009) with the pinout depicted in table +:numref:`Table %s `. + +.. csv-table:: Supply (J2009) + :name: ti-tms570lc4357-v1.1.1_supply_ext + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_supply_ext.csv + +CAN1 +#### + +The CAN1 interface is provided on a 4 pin Molex Micro-Fit 3.0 connector (J2021) +with the pinout depicted in table +:numref:`Table %s `. + +.. csv-table:: CAN1 (J2021) + :name: ti-tms570lc4357-v1.1.1_CAN1 + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_can1.csv + +CAN2 (isolated) +############### + +An isolated CAN interface is provided on a 4 pin Molex Micro-Fit 3.0 connector +(J2024) with the pinout depicted in +:numref:`Table %s `. + +.. csv-table:: Pinout and signal description for isolated CAN2 (J2024) + :name: ti-tms570lc4357-v1.1.1_CAN2 + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_can2.csv + +Insulation monitoring +##################### + +A Bender IR155-3204 insulation monitoring device can be connected to the +|bms-master| using 4 pole Molex Micro-Fit 3.0 connector (J2034) with the +following pinout described in +:numref:`Table %s `. + +.. csv-table:: Insulation monitoring interface (J2034) + :name: ti-tms570lc4357-v1.1.1_isomon + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_isomon.csv + +Interlock +######### + +The current-fed interlock loop is interfaced using a 2 pin Molex Micro-Fit 3.0 +connector J2034. +The pinout is depicted in :numref:`Table %s `. + +.. csv-table:: Interlock connector (J2033) + :name: ti-tms570lc4357-v1.1.1_interlock + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_interlock.csv + + +Smart Power Switches +#################### + +In total eight smart power switch outputs with feedback capability are +available one the |bms-master|. +They can be interfaced using the connectors J2000, J2002, J2003, J2004, J2006, +J2007, J2008 and J2010. +The pinout for each output smart power switch output ``X`` is depicted in +:numref:`Table %s `. + +.. csv-table:: Smart power switch output connectors + :name: ti-tms570lc4357-v1.1.1_sps + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_sps.csv + +Interface connector +################### + +For the connection to the |bms-interface|, a 40-pole Samtec Edge Rate mezzanine +connector (J9000) is used. +The pinout and pin usage is described in +:numref:`Table %s `. + +.. csv-table:: Signal connector to |bms-interface| (J9000) + :name: ti-tms570lc4357-v1.1.1_interface + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_interface.csv + +Extension connector +################### + +For the connection to the |bms-extension|, a 120-pole Samtec Edge Rate +mezzanine connector (J9002) is used. +The pinout and pin usage is described in +:numref:`Table %s `. + +.. csv-table:: Signal connector to |bms-extension| (J9002) + :name: ti-tms570lc4357-v1.1.1_extension + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_extension.csv + +Debug connector +############### + +For the connection of a debugger to the |bms-master|, a 38-pole Mictor +connector (J3008) is provided. +The pinout and pin usage is described in +:numref:`Table %s `. + +.. csv-table:: Debug connector (J3008) + :name: ti-tms570lc4357-v1.1.1_debug + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_debug.csv + +RS485 +##### + +The RS485 interface can be interfaced using the 6 pin Molex Micro-Fit 3.0 +connector (J2013). +The pinout is depicted in :numref:`Table %s `. + +.. csv-table:: RS485 interface (J2013) + :name: ti-tms570lc4357-v1.1.1_rs485 + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_rs485.csv + +Ethernet +######## + +The 12 pin Wuerth WR-MJ connector pinout with additional shield contacts is +described in :numref:`Table %s `. + +.. csv-table:: Ethernet connector (J2001) + :name: ti-tms570lc4357-v1.1.1_ethernet + :header-rows: 1 + :delim: , + :file: ./pinout/ti-tms570lc4357-v1.1.1_ethernet.csv diff --git a/docs/hardware/slaves/12-ltc-ltc6804-1-vx.x.x/12-ltc-ltc6804-1-v1.x.x.rst b/docs/hardware/slaves/12-ltc-ltc6804-1-vx.x.x/12-ltc-ltc6804-1-v1.x.x.rst index fcceeb16..03aa5ad5 100644 --- a/docs/hardware/slaves/12-ltc-ltc6804-1-vx.x.x/12-ltc-ltc6804-1-v1.x.x.rst +++ b/docs/hardware/slaves/12-ltc-ltc6804-1-vx.x.x/12-ltc-ltc6804-1-v1.x.x.rst @@ -1,10 +1,10 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _LTC6804_1_BASED_12_CELL_SLAVE____V1_X_X___: +.. _LTC6804_1_BASED_12_CELL_SLAVE___V1_X_X__: -LTC6804-1-based 12-Cell Slave (``v1.x.x``) -========================================== +LTC6804-1-based 12-Cell Slave ``v1.x.x`` +======================================== .. |local_slave_version| replace:: ``1.x.x`` @@ -22,7 +22,7 @@ Overview .. hint:: All connector pinouts described below follow the - :ref:`CONVENTION_FOR_CONNECTOR_PIN_NUMBERING`. + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING`. ^^^^^^^^^^^^^ Block Diagram diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3.rst b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3.rst index 90ebb476..f061800f 100644 --- a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3.rst +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3.rst @@ -1,10 +1,10 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _LTC6811_1_BASED_12_CELL_SLAVE____V2_0_3_TO_V2_1_1___: +.. _LTC6811_1_BASED_12_CELL_SLAVE___V2_0_3_TO_V2_1_1__: -LTC6811-1-based 12-Cell Slave (``v2.0.3 to v2.1.1``) -==================================================== +LTC6811-1-based 12-Cell Slave ``v2.0.3 to v2.1.1`` +================================================== .. |local_slave_version_start| replace:: ``2.0.3`` .. |local_slave_version| replace:: ``2.1.1`` @@ -22,7 +22,39 @@ Overview .. hint:: All connector pinouts described below follow the - :ref:`CONVENTION_FOR_CONNECTOR_PIN_NUMBERING`. + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING`. + +-------------- +Specifications +-------------- + +^^^^^^^^^^^^^^^^^^ +Electrical Ratings +^^^^^^^^^^^^^^^^^^ + +The current consumption from the module has been measured at 43.2 |_| V module +voltage, which is equivalent to a cell voltage of 3.6 |_| V per cell. +No sense lines have been connected from this measurement (as the impact of cell +voltage sensing is negligible on the current consumption). + +The DC supply current has been measured with a voltage of 12 |_| V and no +|VBAT| or cells connected. + +.. csv-table:: Electrical Ratings + :name: 6811-1_slave_12cell_v2.0.3_electrical_ratings + :header-rows: 1 + :delim: ; + :file: ./12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_electrical-ratings.csv + +^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions +^^^^^^^^^^^^^^^^^^^^^ + +.. csv-table:: Mechanical Dimensions + :name: 6811-1_slave_12cell_v2.0.3_mechanical_dimensions + :header-rows: 1 + :delim: ; + :file: ./12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_mechanical-dimensions.csv ^^^^^^^^^^^^^ Block Diagram @@ -44,12 +76,6 @@ Schematic and Board Layout More information about the board schematic and layout files can be found in section :ref:`DESIGN_RESOURCES`. -^^^^^^^^^^^^^^^^^^^^^ -Mechanical Dimensions -^^^^^^^^^^^^^^^^^^^^^ - -The size of the PCB is 160x100mm. - --------- Functions --------- diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_cell-voltage-sense-connector.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_cell-voltage-sense-connector.csv index f68187a7..7b054f3c 100644 --- a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_cell-voltage-sense-connector.csv +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_cell-voltage-sense-connector.csv @@ -7,10 +7,10 @@ Pin; Signal; Direction; Description 6; |CELL_8+|; Input; Cell 8 positive terminal 7; |CELL_10+|; Input; Cell 10 positive terminal 8; |VBAT+|; Input; Battery module positive terminal -9; |NC|; --; -- -10; |NC|; --; -- -11; |NC|; --; -- -12; |NC|; --; -- +9; |NC|; \-; \- +10; |NC|; \-; \- +11; |NC|; \-; \- +12; |NC|; \-; \- 13; |CELL_0-|; Input; Cell 0 negative terminal 14; |CELL_1+|; Input; Cell 1 positive terminal 15; |CELL_3+|; Input; Cell 3 positive terminal @@ -18,8 +18,8 @@ Pin; Signal; Direction; Description 17; |CELL_7+|; Input; Cell 7 positive terminal 18; |CELL_9+|; Input; Cell 9 positive terminal 19; |CELL_11+|; Input; Cell 11 positive terminal -20; |NC|; --; -- -21; |NC|; --; -- -22; |NC|; --; -- -23; |NC|; --; -- -24; |NC|; --; -- +20; |NC|; \-; \- +21; |NC|; \-; \- +22; |NC|; \-; \- +23; |NC|; \-; \- +24; |NC|; \-; \- diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_electrical-ratings.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_electrical-ratings.csv new file mode 100644 index 00000000..0db0664d --- /dev/null +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_electrical-ratings.csv @@ -0,0 +1,12 @@ +Description; Minimum; Typical; Maximum; Unit +Battery Module Voltage; 11; --; 60; |V| +Single Battery Cell Voltage; 0; --; 5; |V| +Temperature Sensor Inputs; --; 10k; --; |Ohm| +Analog Inputs (pin headers); 0; --; 5; |V| +Digital Inputs/Outputs (pin headers); 0; --; 5; |V| +Current consumption: Primary in sleep, Secondary in sleep; --; 9.1; --; |uA| +Current consumption: Primary active, Secondary in sleep; --; 11.64; --; |mA| +Current consumption: Primary active, Secondary active; --; 22.33; --; |mA| +DC supply current: Primary in sleep, Secondary in sleep; --; 4.3; --; |mA| +DC supply current: Primary active, Secondary in sleep; --; 73.6; --; |mA| +DC supply current: Primary active, Secondary active; --; 144.3; --; |mA| diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_mechanical-dimensions.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_mechanical-dimensions.csv new file mode 100644 index 00000000..e35cb90c --- /dev/null +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.0.3/12-ltc-ltc6811-1-v2.0.3_mechanical-dimensions.csv @@ -0,0 +1,5 @@ +Description; Value; Unit +Width; 100; |mm| +Length; 160; |mm| +Height; 15; |mm| +Weight; 83; |g| diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2.rst b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2.rst index 1cd753c5..9f9d05d9 100644 --- a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2.rst +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2.rst @@ -1,10 +1,10 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _LTC6811_1_BASED_12_CELL_SLAVE____V2_1_2_TO_V2_1_5___: +.. _LTC6811_1_BASED_12_CELL_SLAVE___V2_1_2_TO_V2_1_5__: -LTC6811-1-based 12-Cell Slave (``v2.1.2 to v2.1.5``) -==================================================== +LTC6811-1-based 12-Cell Slave ``v2.1.2 to v2.1.5`` +================================================== .. |local_slave_version_start| replace:: ``2.1.2`` .. |local_slave_version| replace:: ``2.1.5`` @@ -22,7 +22,39 @@ Overview .. hint:: All connector pinouts described below follow the - :ref:`CONVENTION_FOR_CONNECTOR_PIN_NUMBERING`. + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING`. + +-------------- +Specifications +-------------- + +^^^^^^^^^^^^^^^^^^ +Electrical Ratings +^^^^^^^^^^^^^^^^^^ + +The current consumption from the module has been measured at 43.2 |_| V module +voltage, which is equivalent to a cell voltage of 3.6 |_| V per cell. +No sense lines have been connected from this measurement (as the impact of cell +voltage sensing is negligible on the current consumption). + +The DC supply current has been measured with a voltage of 12 |_| V and no +|VBAT| or cells connected. + +.. csv-table:: Electrical Ratings + :name: 6811-1_slave_12cell_v2.1.2_electrical_ratings + :header-rows: 1 + :delim: ; + :file: ./12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_electrical-ratings.csv + +^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions +^^^^^^^^^^^^^^^^^^^^^ + +.. csv-table:: Mechanical Dimensions + :name: 6811-1_slave_12cell_v2.1.2_mechanical_dimensions + :header-rows: 1 + :delim: ; + :file: ./12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_mechanical-dimensions.csv ^^^^^^^^^^^^^ Block Diagram @@ -44,12 +76,6 @@ Schematic and Board Layout More information about the board schematic and layout files can be found in section :ref:`DESIGN_RESOURCES`. -^^^^^^^^^^^^^^^^^^^^^ -Mechanical Dimensions -^^^^^^^^^^^^^^^^^^^^^ - -The size of the PCB is 160x100mm. - --------- Functions --------- diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_cell-voltage-sense-connector.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_cell-voltage-sense-connector.csv index 8eaee24d..23bffb6f 100644 --- a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_cell-voltage-sense-connector.csv +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_cell-voltage-sense-connector.csv @@ -7,10 +7,10 @@ Pin; Signal; Direction; Description 6; |CELL_8+|; Input; Cell 8 positive terminal 7; |CELL_10+|; Input; Cell 10 positive terminal 8; |VBAT+|; Input; Battery module positive terminal -9; |NC|; --; -- -10; |NC|; --; -- -11; |NC|; --; -- -12; |NC|; --; -- +9; |NC|; \-; \- +10; |NC|; \-; \- +11; |NC|; \-; \- +12; |NC|; \-; \- 13; |CELL_0-|; Input; Cell 0 negative terminal 14; |CELL_1+|; Input; Cell 1 positive terminal 15; |CELL_3+|; Input; Cell 3 positive terminal @@ -18,8 +18,8 @@ Pin; Signal; Direction; Description 17; |CELL_7+|; Input; Cell 7 positive terminal 18; |CELL_9+|; Input; Cell 9 positive terminal 19; |CELL_11+|; Input; Cell 11 positive terminal -20; |NC|; --; -- -21; |NC|; --; -- -22; |NC|; --; -- -23; |NC|; --; -- -24; |NC|; --; -- +20; |NC|; \-; \- +21; |NC|; \-; \- +22; |NC|; \-; \- +23; |NC|; \-; \- +24; |NC|; \-; \- diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_electrical-ratings.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_electrical-ratings.csv new file mode 100644 index 00000000..c0da564d --- /dev/null +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_electrical-ratings.csv @@ -0,0 +1,13 @@ +Description; Minimum; Typical; Maximum; Unit +Battery Module Voltage; 11; --; 60; |V| +Single Battery Cell Voltage; 0; --; 5; |V| +Temperature Sensor Inputs; --; 10k; --; |Ohm| +Analog Inputs (pin headers); 0; --; 5; |V| +Digital Inputs/Outputs (pin headers); 0; --; 5; |V| +External DC Supply; 8; 12; 24; |V| +Current consumption: Primary in sleep, Secondary in sleep; --; 9.1; --; |uA| +Current consumption: Primary active, Secondary in sleep; --; 11.64; --; |mA| +Current consumption: Primary active, Secondary active; --; 22.33; --; |mA| +DC supply current: Primary in sleep, Secondary in sleep; --; 4.3; --; |mA| +DC supply current: Primary active, Secondary in sleep; --; 73.6; --; |mA| +DC supply current: Primary active, Secondary active; --; 144.3; --; |mA| diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_mechanical-dimensions.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_mechanical-dimensions.csv new file mode 100644 index 00000000..e35cb90c --- /dev/null +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.2/12-ltc-ltc6811-1-v2.1.2_mechanical-dimensions.csv @@ -0,0 +1,5 @@ +Description; Value; Unit +Width; 100; |mm| +Length; 160; |mm| +Height; 15; |mm| +Weight; 83; |g| diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6.rst b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6.rst index 835893b4..cfae58e4 100644 --- a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6.rst +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6.rst @@ -1,10 +1,10 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _LTC6811_1_BASED_12_CELL_SLAVE____V2_1_6___AND_ABOVE_: +.. _LTC6811_1_BASED_12_CELL_SLAVE___V2_1_6___AND_ABOVE: -LTC6811-1-based 12-Cell Slave (``v2.1.6`` and above) -==================================================== +LTC6811-1-based 12-Cell Slave ``v2.1.6`` and above +================================================== .. |local_slave_version_start| replace:: ``2.1.6`` .. |local_slave_version| replace:: ``above`` @@ -22,7 +22,39 @@ Overview .. hint:: All connector pinouts described below follow the - :ref:`CONVENTION_FOR_CONNECTOR_PIN_NUMBERING`. + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING`. + +-------------- +Specifications +-------------- + +^^^^^^^^^^^^^^^^^^ +Electrical Ratings +^^^^^^^^^^^^^^^^^^ + +The current consumption from the module has been measured at 43.2 |_| V module +voltage, which is equivalent to a cell voltage of 3.6 |_| V per cell. +No sense lines have been connected from this measurement (as the impact of cell +voltage sensing is negligible on the current consumption). + +The DC supply current has been measured with a voltage of 12 |_| V and no +|VBAT| or cells connected. + +.. csv-table:: Electrical Ratings + :name: 6811-1_slave_12cell_v2.1.6_electrical_ratings + :header-rows: 1 + :delim: ; + :file: ./12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_electrical-ratings.csv + +^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions +^^^^^^^^^^^^^^^^^^^^^ + +.. csv-table:: Mechanical Dimensions + :name: 6811-1_slave_12cell_v2.1.6_mechanical_dimensions + :header-rows: 1 + :delim: ; + :file: ./12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_mechanical-dimensions.csv ^^^^^^^^^^^^^ Block Diagram @@ -44,12 +76,6 @@ Schematic and Board Layout More information about the board schematic and layout files can be found in section :ref:`DESIGN_RESOURCES`. -^^^^^^^^^^^^^^^^^^^^^ -Mechanical Dimensions -^^^^^^^^^^^^^^^^^^^^^ - -The size of the PCB is 160x100mm. - --------- Functions --------- diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_cell-voltage-sense-connector.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_cell-voltage-sense-connector.csv index f68187a7..7b054f3c 100644 --- a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_cell-voltage-sense-connector.csv +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_cell-voltage-sense-connector.csv @@ -7,10 +7,10 @@ Pin; Signal; Direction; Description 6; |CELL_8+|; Input; Cell 8 positive terminal 7; |CELL_10+|; Input; Cell 10 positive terminal 8; |VBAT+|; Input; Battery module positive terminal -9; |NC|; --; -- -10; |NC|; --; -- -11; |NC|; --; -- -12; |NC|; --; -- +9; |NC|; \-; \- +10; |NC|; \-; \- +11; |NC|; \-; \- +12; |NC|; \-; \- 13; |CELL_0-|; Input; Cell 0 negative terminal 14; |CELL_1+|; Input; Cell 1 positive terminal 15; |CELL_3+|; Input; Cell 3 positive terminal @@ -18,8 +18,8 @@ Pin; Signal; Direction; Description 17; |CELL_7+|; Input; Cell 7 positive terminal 18; |CELL_9+|; Input; Cell 9 positive terminal 19; |CELL_11+|; Input; Cell 11 positive terminal -20; |NC|; --; -- -21; |NC|; --; -- -22; |NC|; --; -- -23; |NC|; --; -- -24; |NC|; --; -- +20; |NC|; \-; \- +21; |NC|; \-; \- +22; |NC|; \-; \- +23; |NC|; \-; \- +24; |NC|; \-; \- diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_electrical-ratings.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_electrical-ratings.csv new file mode 100644 index 00000000..c0da564d --- /dev/null +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_electrical-ratings.csv @@ -0,0 +1,13 @@ +Description; Minimum; Typical; Maximum; Unit +Battery Module Voltage; 11; --; 60; |V| +Single Battery Cell Voltage; 0; --; 5; |V| +Temperature Sensor Inputs; --; 10k; --; |Ohm| +Analog Inputs (pin headers); 0; --; 5; |V| +Digital Inputs/Outputs (pin headers); 0; --; 5; |V| +External DC Supply; 8; 12; 24; |V| +Current consumption: Primary in sleep, Secondary in sleep; --; 9.1; --; |uA| +Current consumption: Primary active, Secondary in sleep; --; 11.64; --; |mA| +Current consumption: Primary active, Secondary active; --; 22.33; --; |mA| +DC supply current: Primary in sleep, Secondary in sleep; --; 4.3; --; |mA| +DC supply current: Primary active, Secondary in sleep; --; 73.6; --; |mA| +DC supply current: Primary active, Secondary active; --; 144.3; --; |mA| diff --git a/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_mechanical-dimensions.csv b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_mechanical-dimensions.csv new file mode 100644 index 00000000..e35cb90c --- /dev/null +++ b/docs/hardware/slaves/12-ltc-ltc6811-1-vx.x.x/12-ltc-ltc6811-1-v2.1.6/12-ltc-ltc6811-1-v2.1.6_mechanical-dimensions.csv @@ -0,0 +1,5 @@ +Description; Value; Unit +Width; 100; |mm| +Length; 160; |mm| +Height; 15; |mm| +Weight; 83; |g| diff --git a/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3.rst b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3.rst index f06b1a06..53668571 100644 --- a/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3.rst +++ b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3.rst @@ -1,10 +1,10 @@ .. include:: ./../../../macros.txt .. include:: ./../../../units.txt -.. _LTC6813_1_BASED_18_CELL_SLAVE____V1_1_3___AND_ABOVE_: +.. _LTC6813_1_BASED_18_CELL_SLAVE___V1_1_3___AND_ABOVE: -LTC6813-1-based 18-Cell Slave (``v1.1.3`` and above) -==================================================== +LTC6813-1-based 18-Cell Slave ``v1.1.3`` and above +================================================== .. |local_slave_version_start| replace:: ``1.1.3`` .. |local_slave_version| replace:: ``above`` @@ -22,7 +22,39 @@ Overview .. hint:: All connector pinouts described below follow the - :ref:`CONVENTION_FOR_CONNECTOR_PIN_NUMBERING`. + :ref:`CONVENTION_FOR_MOLEX_3_0_CONNECTOR_PIN_NUMBERING`. + +-------------- +Specifications +-------------- + +^^^^^^^^^^^^^^^^^^ +Electrical Ratings +^^^^^^^^^^^^^^^^^^ + +The current consumption from the module has been measured at 64.8 |_| V module +voltage, which is equivalent to a cell voltage of 3.6 |_| V per cell. +No sense lines have been connected from this measurement (as the impact of cell +voltage sensing is negligible on the current consumption). + +The DC supply current has been measured with a voltage of 12 |_| V and no +|VBAT| or cells connected. + +.. csv-table:: Electrical Ratings + :name: 6813-1_slave_18cell_v1.1.3_electrical_ratings + :header-rows: 1 + :delim: ; + :file: ./18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_electrical-ratings.csv + +^^^^^^^^^^^^^^^^^^^^^ +Mechanical Dimensions +^^^^^^^^^^^^^^^^^^^^^ + +.. csv-table:: Mechanical Dimensions + :name: 6813-1_slave_18cell_v1.1.3_mechanical_dimensions + :header-rows: 1 + :delim: ; + :file: ./18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_mechanical-dimensions.csv ^^^^^^^^^^^^^ Block Diagram @@ -35,7 +67,7 @@ The block diagram of the |BMS-Slave| is shown in .. figure:: ./18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3.png :width: 100 % - |BMS-Slave| 12-Cell Block Diagram + |BMS-Slave| 18-Cell Block Diagram ^^^^^^^^^^^^^^^^^^^^^^^^^^ Schematic and Board Layout @@ -44,11 +76,7 @@ Schematic and Board Layout More information about the board schematic and layout files can be found in section :ref:`DESIGN_RESOURCES`. -^^^^^^^^^^^^^^^^^^^^^ -Mechanical Dimensions -^^^^^^^^^^^^^^^^^^^^^ -The size of the PCB is 160x100mm. --------- Functions @@ -110,10 +138,10 @@ parallel. The MOSFET switches (T1500 - T1517) that control the connection to the cells are controlled by the primary |ltc6813-1| monitoring IC. The |ltc6813-1| on the secondary unit does not support balancing. -The resistor value of 2x 130 |Ohm| results in a balancing current of about 55mA -at a cell voltage of 3.6V. +The resistor value of 2x 130 |_| |Ohm| results in a balancing current of about +55 |_| mA at a cell voltage of 3.6 |_| V. This current results in a power dissipation of about 0.2W per balancing -channel (at 3.6V). +channel (at 3.6 |_| V). ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Global Cell Balancing Feedback @@ -146,13 +174,14 @@ The pinout is identical for the primary and secondary unit and is described in :delim: ; :file: ./18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_temperature-sensor-connector.csv -Standard 10\ |kOhm| NTC resistors are recommended for use. +Standard 10 |_| |kOhm| NTC resistors are recommended for use. When using other values than these, the series resistors (R100-R107) on the board may have to be adjusted. Please note that the accuracy of the internal voltage reference VREF2 decreases -heavily with a load of over 3mA. -Using 8x 10\ |kOhm| NTC resistors with the corresponding 10\ |kOhm| series -resistors results in a current of 1.2mA (at 20°C) which is drawn from VREF2. +heavily with a load of over 3 |_| mA. +Using 8x 10 |_| |kOhm| NTC resistors with the corresponding 10 |_| |kOhm| +series resistors results in a current of 1.2mA (at 20 |_| °C) which is drawn +from VREF2. Each 8 temperature sensors are connected to an analog multiplexer. The analog multiplexer can be controlled via |I2C| by the |ltc6813-1| @@ -274,8 +303,8 @@ Software Timer The internal software timer of the |ltc6813-1| can be enabled/disabled by a dedicated external pin (SWTEN, pin 36 of the |ltc6813-1|). -In order to support all features, the foxBMS BMS-Slave board offers a possibility -to switch the software timer. +In order to support all features, the foxBMS BMS-Slave board offers a +possibility to switch the software timer. The software timer is enabled in the standard configuration, which means pin 36 is pulled to VREG via a zero-ohm resistor (R1407). The timer can be disabled by removing the resistor R1407 and placing a @@ -288,9 +317,9 @@ Daisy Chain Communication Current The daisy chain communication current can be set by the resistors R1400 and R1402. -The default value is 820 |Ohm| for R1402 and 1.2\ |kOhm| for R1400. +The default value is 820 |_| |Ohm| for R1402 and 1.2 |_| |kOhm| for R1400. This values result in a bias current of approximately 1mA and a differential -signal amplitude of 1.18V. +signal amplitude of 1.18 |_| V. Theses values are suitable for high noise environments with cable lengths of over 50m. More information can be found in the |ltc6813-1| data sheet. @@ -348,9 +377,9 @@ External Isolated |DC-| Supply ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It is possible to supply the |BMS-Slave| by an external DC power supply with a -voltage range of 8V to 24V. +voltage range of 8 |_| V to 24 |_| V. The DC input is protected against reverse voltage and over-current -(with a 1.25A fuse). +(with a 1.25 |_| A fuse). The external DC supply has to be connected on connector X1001 or X1002 (both connectors are in parallel for daisy chaining the supply). The pinout of the connectors X1001 and X1002 is shown in diff --git a/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_cell_voltage-sense-connector.csv b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_cell_voltage-sense-connector.csv index b37ace4a..20e13022 100644 --- a/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_cell_voltage-sense-connector.csv +++ b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_cell_voltage-sense-connector.csv @@ -10,7 +10,7 @@ Pin; Signal; Direction; Description 9; |CELL_14+|; Input; Cell 14 positive terminal 10; |CELL_16+|; Input; Cell 16 positive terminal 11; |VBAT+|; Input; Battery module positive terminal -12; |NC|; --; -- +12; |NC|; \-; \- 13; |CELL_0-|; Input; Cell 0 negative terminal 14; |CELL_1+|; Input; Cell 1 positive terminal 15; |CELL_3+|; Input; Cell 3 positive terminal @@ -21,5 +21,5 @@ Pin; Signal; Direction; Description 20; |CELL_13+|; Input; Cell 13 positive terminal 21; |CELL_15+|; Input; Cell 15 positive terminal 22; |CELL_17+|; Input; Cell 17 positive terminal -23; |NC|; --; -- -24; |NC|; --; -- +23; |NC|; \-; \- +24; |NC|; \-; \- diff --git a/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_electrical-ratings.csv b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_electrical-ratings.csv new file mode 100644 index 00000000..39d90c9f --- /dev/null +++ b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_electrical-ratings.csv @@ -0,0 +1,13 @@ +Description; Minimum; Typical; Maximum; Unit +Battery Module Voltage; 16; --; 90; |V| +Single Battery Cell Voltage; 0; --; 5; |V| +Temperature Sensor Inputs; --; 10k; --; |Ohm| +Analog Inputs (pin headers); 0; --; 5; |V| +Digital Inputs/Outputs (pin headers); 0; --; 5; |V| +External DC Supply; 8; 12; 24; |V| +Current consumption: Primary in sleep, Secondary in sleep; --; 13.35; --; |uA| +Current consumption: Primary active, Secondary in sleep; --; 11.66; --; |mA| +Current consumption: Primary active, Secondary active; --; 22.35; --; |mA| +DC supply current: Primary in sleep, Secondary in sleep; --; 3.3; --; |mA| +DC supply current: Primary active, Secondary in sleep; --; 112.0; --; |mA| +DC supply current: Primary active, Secondary active; --; 211.6; --; |mA| diff --git a/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_mechanical-dimensions.csv b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_mechanical-dimensions.csv new file mode 100644 index 00000000..46ac1e04 --- /dev/null +++ b/docs/hardware/slaves/18-ltc-ltc6813-1-vx.x.x/18-ltc-ltc6813-1-v1.1.3/18-ltc-ltc6813-1-v1.1.3_mechanical-dimensions.csv @@ -0,0 +1,5 @@ +Description; Value; Unit +Width; 100; |mm| +Length; 160; |mm| +Height; 15; |mm| +Weight; 88; |g| diff --git a/docs/index.rst b/docs/index.rst index 54d1c911..012baf98 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -141,6 +141,7 @@ All sections are listed here: ./software/build-process/build-process.rst ./software/build-environment/build-environment.rst ./software/how-to/how-to.rst + ./software/linker-script/linker-script.rst ./software/architecture/architecture.rst ./software/api/overview.rst @@ -184,7 +185,6 @@ All sections are listed here: ./tools/debugger/debug-application.rst ./tools/halcogen/halcogen.rst ./tools/static-analysis/axivion.rst - ./tools/static-analysis/cppcheck.rst .. _DEVELOPER_MANUAL: diff --git a/docs/macros.txt b/docs/macros.txt index 53bf3c2c..bba669fc 100644 --- a/docs/macros.txt +++ b/docs/macros.txt @@ -3,7 +3,7 @@ .. |timestamp| date:: %Y-%m-%d %H:%M:%S .. |foxbms| replace:: foxBMS 2 -.. |version_foxbms| replace:: ``1.2.1`` +.. |version_foxbms| replace:: ``1.3.0`` .. |github_foxbms| replace:: https://github.com/foxBMS/ .. |foxbms_repository| replace:: https://github.com/foxBMS/foxbms-2 .. _Fraunhofer IISB: https://www.iisb.fraunhofer.de @@ -37,9 +37,9 @@ .. |version_hcg| replace:: ``04.07.01`` .. _LLVM: https://releases.llvm.org -.. _github.com/llvm: https://github.com/llvm/llvm-project/releases/tag/llvmorg-11.0.1 -.. |version_llvm| replace:: ``11.0.1`` -.. |path_llvm| replace:: ``C:\Program Files\LLVM\11.0.1`` +.. _github.com/llvm: https://github.com/llvm/llvm-project/releases/tag/llvmorg-13.0.0 +.. |version_llvm| replace:: ``13.0.0`` +.. |path_llvm| replace:: ``C:\Program Files\LLVM\13.0.0`` .. |version_pcan_se| replace:: ``Version 6.4.1`` .. |version_sym_file| replace:: ``Version 5.0`` @@ -91,14 +91,8 @@ .. _Test Explorer Ceedling extension license: https://marketplace.visualstudio.com/items/numaru.vscode-ceedling-test-adapter/license -.. _Cppcheck project website: http://cppcheck.sourceforge.net/ - .. _MISRA C: https://www.misra.org.uk/ -.. _list of supported MISRA rules: http://cppcheck.sourceforge.net/misra.php - -.. _Cppcheck manual: http://cppcheck.sourceforge.net/manual.pdf - .. |nxp775| replace:: MC33775A .. |nxp664| replace:: MC33664 @@ -113,11 +107,13 @@ .. |msl| replace:: *MSL* .. |adi| replace:: Analog Devices +.. |mxm| replace:: Maxim Integrated .. |ltc6804-1| replace:: LTC6804-1 .. |ltc6811-1| replace:: LTC6811-1 .. |ltc6813-1| replace:: LTC6813-1 .. |ltc6820| replace:: LTC6820 +.. |max17841b| replace:: MAX17841B .. |master| replace:: foxBMS Master Unit .. |masters| replace:: foxBMS Master Units .. |slave| replace:: foxBMS Slave Unit @@ -131,9 +127,11 @@ .. |bms-18-slave| replace:: Slave 18-cell board .. |I2C| replace:: I\ :sup:`2`\ C +.. |SPI| replace:: SPI .. |tbc| replace:: This section of the documentation is not yet complete. +.. |VBAT| replace:: ``VBAT`` .. |VBAT-| replace:: ``VBAT-`` .. |FUSED_VBAT-| replace:: ``FUSED_VBAT-`` .. |VBAT+| replace:: ``VBAT+`` @@ -182,9 +180,6 @@ .. |CELL_16-| replace:: ``CELL_16-`` .. |CELL_17-| replace:: ``CELL_17-`` -.. |Ohm| replace:: :math:`{\Omega}` -.. |kOhm| replace:: :math:`{k\Omega}` - .. |DC+| replace:: ``DC+`` .. |DC-| replace:: ``DC-`` diff --git a/docs/misc/developer-manual-nomenclature.csv b/docs/misc/developer-manual-nomenclature.csv index 63c2095d..48e8d536 100644 --- a/docs/misc/developer-manual-nomenclature.csv +++ b/docs/misc/developer-manual-nomenclature.csv @@ -1,3 +1,6 @@ -Word; Definition -validation; Ensuring that the specification meets the applications's needs -verification; Ensuring that the software meets the requirements +Word; Definition +Error; Difference between **measured** and **expected** output +Fault; Abnormal condition that might cause the software/hardware to fail +Failure; Inability of the software/hardware to execute its required tasks +Validation; Ensuring that the specification meets the applications's needs +Verification; Ensuring that the software meets the requirements diff --git a/docs/software/architecture/img/axivion_architecture.svg b/docs/software/architecture/img/axivion_architecture.svg index 904389e1..ce37290b 100644 --- a/docs/software/architecture/img/axivion_architecture.svg +++ b/docs/software/architecture/img/axivion_architecture.svg @@ -3,2397 +3,2420 @@ viewBox="0 0 707.405 537.379" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2" baseProfile="tiny"> Architecture (Hier.) -Exported from Gravis 7.2.3 (2021-08-16) +Exported from Gravis 7.4.0 (2022-05-10) -HAL -Driver - - - + -CAN +Measurement - - - - + -Power Supply +SPI - - - - + -Contactor +IO - - - - + -FRAM +Analog Front-End - - - - + -Common +CAN - - - - + -Interlock +Contactor - - - - + -IO +DMA - - - - + -Analog Front-End +FRAM - - - - + -Temperature Sensors +ADC - - - - + -SPI +MCU - - - - + -ADC +Common - - - - + -DMA +Power Supply - - - - + -Measurement +Temperature Sensors - - - - + -MCU +Interlock - -OS -Application - - - + -SOX +Balancing - - - - + -BMS +Plausibility - - - - + -Plausibility +BMS - - - - + -Balancing +SOX - - + - + - + - + - + - + - + - + -Engine -Database - - - + -System Monitoring +System - - - - + -Diagnosis +System Monitoring - - - - + -System +Diagnosis - -Main - - - + -fassert +core components - - - - + -version information +fassert - - - - + -main +version information - - - - + -core components +main - -Task Configuration -OS Interface -Task Setup - - + - - - - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + diff --git a/docs/software/build-process/misc/libcc-options.yaml b/docs/software/build-process/misc/libcc-options.yaml index 951966c6..c0e5a825 100644 --- a/docs/software/build-process/misc/libcc-options.yaml +++ b/docs/software/build-process/misc/libcc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/software/build-process/misc/libproject-example.c b/docs/software/build-process/misc/libproject-example.c index 3e9cf568..74aab1ad 100644 --- a/docs/software/build-process/misc/libproject-example.c +++ b/docs/software/build-process/misc/libproject-example.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file libproject-example.c * @author foxBMS Team * @date 2020-10-06 (date of creation) - * @updated 2020-10-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup USER_LIB * @prefix SUPER * diff --git a/docs/software/build-process/misc/libproject-example.h b/docs/software/build-process/misc/libproject-example.h index 167d3170..2c44d5a6 100644 --- a/docs/software/build-process/misc/libproject-example.h +++ b/docs/software/build-process/misc/libproject-example.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file libproject-example.h * @author foxBMS Team * @date 2020-10-06 (date of creation) - * @updated 2020-10-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup USER_LIB * @prefix SUPER * diff --git a/docs/software/build-process/misc/wscript b/docs/software/build-process/misc/wscript index 8a00c73e..d7ed394d 100644 --- a/docs/software/build-process/misc/wscript +++ b/docs/software/build-process/misc/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -51,10 +51,10 @@ from waflib import ( Errors, Logs, Options, - Utils, Scripting, Task, TaskGen, + Utils, ) from waflib.Build import BuildContext, CleanContext, ListContext, StepContext diff --git a/docs/software/build/waf-available-commands.csv b/docs/software/build/waf-available-commands.csv index c26626aa..7b228c9b 100644 --- a/docs/software/build/waf-available-commands.csv +++ b/docs/software/build/waf-available-commands.csv @@ -2,10 +2,8 @@ Command/Option; Description ``build_all``; Shortcut to run all available build commands ``build_bin``; Builds the binaries ``build_docs``; Builds the documentation -``build_static_analysis``; Runs a static code analysis on all C sources that are not third party sources ``build_unit_test``; Builds and runs all unit tests for the embedded sources ``clean_all``; Shortcut to run all available clean commands ``clean_bin``; Cleans all binaries ``clean_docs``; Cleans the rendered documentation -``clean_static_analysis``; Cleans all output files written during ``build_static_analysis`` ``clean_unit_test``; Cleans all output files written during ``build_unit_test`` diff --git a/docs/software/configuration/linker_pulls/wscript b/docs/software/configuration/linker_pulls/wscript index 4cd4ca9a..eeb7d849 100644 --- a/docs/software/configuration/linker_pulls/wscript +++ b/docs/software/configuration/linker_pulls/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/software/configuration/without-halcogen/wscript b/docs/software/configuration/without-halcogen/wscript index 0aff22bb..8d6dd225 100644 --- a/docs/software/configuration/without-halcogen/wscript +++ b/docs/software/configuration/without-halcogen/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/software/linker-script/linker-script-definitions.csv b/docs/software/linker-script/linker-script-definitions.csv new file mode 100644 index 00000000..3258bfa5 --- /dev/null +++ b/docs/software/linker-script/linker-script-definitions.csv @@ -0,0 +1,5 @@ +Name; Meaning; Explanation +``bss``/``.bss``; block starting symbol; global and static data, that is **not** initialized at declaration +``data``/``.data``; \-; global and static data, that is initialized at declaration +``const``/``.const``; constant; constant variables +``text``/``.text``; \-; executable instructions of the program diff --git a/docs/software/linker-script/linker-script.rst b/docs/software/linker-script/linker-script.rst new file mode 100644 index 00000000..fdae6711 --- /dev/null +++ b/docs/software/linker-script/linker-script.rst @@ -0,0 +1,118 @@ +.. include:: ../../macros.txt +.. include:: ../../units.txt + +.. _LINKER_SCRIPT: + +Linker Script +============= + +Memory Map +---------- + +The relevant parts of the memory map of the TMS 570LC4375 for configuring the +linker script are:: + + ┌────────────────────────────────────────┬────────────┐ + │ ... │ 0xFFFFFFFF │ + │ │ 0xFB000000 │ + ├────────────────────────────────────────┤────────────┤ + │ Flash │ 0xF047FFFF │ + │ (Flash ECC, OTP and EEPROM accesses) │ 0xF0000000 │ + ├────────────────────────────────────────┤────────────┤ + │ ... │ 0x0807FFFF │ + │ │ 0x08400000 │ + ├────────────────────────────────────────┤────────────┤ + │ RAM (512KB) │ 0x0807FFFF │ + │ │ 0x08000000 │ + ├────────────────────────────────────────┤────────────┤ + │ Flash (4MB) │ 0x003FFFFF │ + │ │ 0x00000000 │ + └────────────────────────────────────────┴────────────┘ + +The Flash bank is divided into two equally sized banks with a length of +``0x200000`` (i.e., ``FLASH_BANK_LENGTH``), i.e., the total flash size is +``2 * 0x200000``. + +Detail information for the Flash ECC:: + + ┌────────────────────────────────────────┬────────────┐ + │ Flash Data Space ECC │ 0xF05FFFFF │ + │ │ 0xF047FFFF │ + └────────────────────────────────────────┴────────────┘ + +Linker Script +------------- + +The main linker script is found at ``src\app\main\linker_script_elf.cmd``. +A derived hex-linker script is found at ``src\app\main\linker_script_hex.cmd``. + +The ``MEMORY`` and ``SECTIONS`` directives can be used to configure the +allocation process. +The ``ECC`` directive can be used to configure the Error-correcting code of the +memory. + +The ``MEMORY`` directive tells the linker the location and the size of memory +blocks. You can then assign . +The task of the ``SECTIONS`` directive is to tell the linker how to map input +sections into output sections, and how to place the output sections in memory, +i.e., specific sections can be placed in particular memory regions. + +Memory Layout Configuration ++++++++++++++++++++++++++++ + +Flash:: + + ┌────────────────────────────────────────┬────────────┐ + │ VECTORS_TABLE │ 0x00000000 │ + │ (0x20) │ 0x0000001F │ + ├────────────────────────────────────────┤────────────┤ + │ KERNEL_FUNCTIONS │ 0x00000020 │ + │ (0x8000) │ 0x0000801F │ + ├────────────────────────────────────────┤────────────┤ + │ FLASH │ 0x00008020 │ + │ (0x3F7F20) │ 0x003FFF3F │ + ├────────────────────────────────────────┤────────────┤ + │ VERSION_INFORMATION │ 0x003FFF40 │ + │ (0xC0) │ 0x003FFFFF │ + └────────────────────────────────────────┴────────────┘ + +RAM:: + + ┌────────────────────────────────────────┬────────────┐ + │ STACKS │ 0x08000000 │ + │ (0x800) │ 0x080007FF │ + ├────────────────────────────────────────┤────────────┤ + │ KERNEL_DATA │ 0x08000800 │ + │ (0x800) │ 0x08000FFF │ + ├────────────────────────────────────────┤────────────┤ + │ RAM │ 0x08001000 │ + │ (0x7E000) │ 0x0807EFFF │ + ├────────────────────────────────────────┤────────────┤ + │ SHARED_RAM │ 0x0807F000 │ + │ (0x1000) │ 0x0807FFFF │ + └────────────────────────────────────────┴────────────┘ + +Flash ECC:: + + ┌────────────────────────────────────────┬────────────┐ + │ ECC_VECTORS_TABLE │ 0xF0400000 │ + │ (0x4) │ 0xF0400003 │ + ├────────────────────────────────────────┤────────────┤ + │ ECC_KERNEL_FUNCTIONS │ 0xF0400004 │ + │ (0x1000) │ 0xF0401003 │ + ├────────────────────────────────────────┤────────────┤ + │ ECC_FLASH │ 0xF0401004 │ + │ (0x7EFE4) │ 0xF047FFE7 │ + ├────────────────────────────────────────┤────────────┤ + │ ECC_VERSION_INFORMATION │ 0xF047FFE8 │ + │ (0x18) │ 0xF047FFFF │ + └────────────────────────────────────────┴────────────┘ + +Common Linker Script related Abbreviations +------------------------------------------ + +.. csv-table:: Common Linker Script related Abbreviations + :name: common-linker-script-related-abbreviations + :header-rows: 1 + :delim: ; + :file: ./linker-script-definitions.csv diff --git a/docs/software/modules/application/algorithm/state-estimation/soh/soh_debug.rst b/docs/software/modules/application/algorithm/state-estimation/soh/soh_debug.rst index 72b50398..48728fa4 100644 --- a/docs/software/modules/application/algorithm/state-estimation/soh/soh_debug.rst +++ b/docs/software/modules/application/algorithm/state-estimation/soh/soh_debug.rst @@ -18,12 +18,14 @@ Driver Configuration ^^^^^^^^^^^^^ -The module has no configuration files. +- ``src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.c`` (`API <./../../../../../../_static/doxygen/src/html/soh__debug__cfg_8c.html>`__, `source <./../../../../../../_static/doxygen/src/html/soh__debug__cfg_8c_source.html>`__) +- ``src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.h`` (`API <./../../../../../../_static/doxygen/src/html/soh__debug__cfg_8h.html>`__, `source <./../../../../../../_static/doxygen/src/html/soh__debug__cfg_8h_source.html>`__) Unit Test ^^^^^^^^^ - ``tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug.c`` (`API <./../../../../../../_static/doxygen/tests/html/test__soh__debug_8c.html>`__, `source <./../../../../../../_static/doxygen/tests/html/test__soh__debug_8c_source.html>`__) +- ``tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug_cfg.c`` (`API <./../../../../../../_static/doxygen/tests/html/test__soh__debug__cfg_8c.html>`__, `source <./../../../../../../_static/doxygen/tests/html/test__soh__debug__cfg_8c_source.html>`__) Detailed Description -------------------- diff --git a/docs/software/modules/application/algorithm/state-estimation/soh/soh_none.rst b/docs/software/modules/application/algorithm/state-estimation/soh/soh_none.rst index abb82e1f..964142e4 100644 --- a/docs/software/modules/application/algorithm/state-estimation/soh/soh_none.rst +++ b/docs/software/modules/application/algorithm/state-estimation/soh/soh_none.rst @@ -18,12 +18,14 @@ Driver Configuration ^^^^^^^^^^^^^ -The module has no configuration files. +- ``src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.c`` (`API <./../../../../../../_static/doxygen/src/html/soh__none__cfg_8c.html>`__, `source <./../../../../../../_static/doxygen/src/html/soh__none__cfg_8c_source.html>`__) +- ``src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.h`` (`API <./../../../../../../_static/doxygen/src/html/soh__none__cfg_8h.html>`__, `source <./../../../../../../_static/doxygen/src/html/soh__none__cfg_8h_source.html>`__) Unit Test ^^^^^^^^^ - ``tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none.c`` (`API <./../../../../../../_static/doxygen/tests/html/test__soh__none_8c.html>`__, `source <./../../../../../../_static/doxygen/tests/html/test__soh__none_8c_source.html>`__) +- ``tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none_cfg.c`` (`API <./../../../../../../_static/doxygen/tests/html/test__soh__none__cfg_8c.html>`__, `source <./../../../../../../_static/doxygen/tests/html/test__soh__none__cfg_8c_source.html>`__) Detailed Description -------------------- diff --git a/docs/software/modules/application/bal/bal.rst b/docs/software/modules/application/bal/bal.rst index 87160f0f..97cd346b 100644 --- a/docs/software/modules/application/bal/bal.rst +++ b/docs/software/modules/application/bal/bal.rst @@ -43,8 +43,8 @@ Voltage-based Balancing ^^^^^^^^^^^^^^^^^^^^^^^ In voltage-based balancing, the balancing module takes the minimum battery cell voltage of the complete battery pack -and activates balancing for all the cells whose voltage is above the minimum + ``BAL_THRESHOLD_mV``. Once all cells -have been balanced, the threshold is set to ``BAL_THRESHOLD_mV`` + ``BAL_HYSTERESIS_mV`` to avoid an oscillating +and activates balancing for all the cells whose voltage is above the minimum + ``BAL_GetBalancingThreshold_mV()``. Once all cells +have been balanced, the threshold is set to ``BAL_GetBalancingThreshold_mV()`` + ``BAL_HYSTERESIS_mV`` to avoid an oscillating behavior between balancing and not balancing. .. _BALANCING_MODULE_HISTORY_BASED_BALANCING: @@ -85,7 +85,7 @@ stays turned on until the charge difference reaches 0. In SOC history-based balancing, ``BS_BALANCING_RESISTANCE_ohm`` must be defined identically to the balancing resistances soldered on the Slave Board. When the imbalances are computed, they are set to a non-zero value to balance each specific cell only if its cell voltage is above the minimum cell voltage of the battery pack plus a threshold. The -threshold is set in this case to ``BAL_THRESHOLD_mV`` + ``BAL_HYSTERESIS_mV``. +threshold is set in this case to ``BAL_GetBalancingThreshold_mV()`` + ``BAL_HYSTERESIS_mV``. The correspondence between cell voltage and SOC must be defined by the user depending on the specific battery cells used. Currently, it is done in the function ``SOC_GetFromVoltage()`` in ``sox.c``. This function gets a voltage in V diff --git a/docs/software/modules/application/plausibility/plausibility.rst b/docs/software/modules/application/plausibility/plausibility.rst index 0f5e3d2f..998f422d 100644 --- a/docs/software/modules/application/plausibility/plausibility.rst +++ b/docs/software/modules/application/plausibility/plausibility.rst @@ -3,7 +3,7 @@ .. _PLAUSIBILITY_MODULE: -plausibility Module +Plausibility Module =================== Module Files diff --git a/docs/software/modules/driver/afe/maxim/max1785x.rst b/docs/software/modules/driver/afe/maxim/max1785x.rst index afa9f900..3cd78cf0 100644 --- a/docs/software/modules/driver/afe/maxim/max1785x.rst +++ b/docs/software/modules/driver/afe/maxim/max1785x.rst @@ -33,7 +33,189 @@ Driver structure The driver is separated into three main modules with additional helper modules. The three main modules are: - * MAX17841B bridge IC driver in ``mxm_17841b.c``, + * MAX17841B bridge IC driver that interacts with the interface + from :ref:`INTERFACE_MAX17841B___V1_0_0__` in ``mxm_17841b.c``, * Battery Management UART protocol abstraction in ``max_battery_management.c`` and * MAX1785x device driver in ``mxm_1785x.c``. + * Implementation of the operation state machine in ``mxm_17852.c``. + This implementation is selected by the driver variant in ``bms.json``. + + +Configuration +------------- + +The driver for the |mxm| monitoring ICs is configurable for some aspects. + +Adaption to new hardware +^^^^^^^^^^^^^^^^^^^^^^^^ + +In order to adapt the driver to new interface hardware, it is necessary to +adapt the following: + + * Ensure that the functions that interact with the shutdown pin of + the |max17841b| bridge IC are correct. + They are implemented in ``mxm_cfg.c``. + * Check the |spi| configuration of the system and that it aligns with + the capabilities of the bridge IC. + * The driver is intended to be implemented as generic as possible. + That means that the main modules should not be necessary to be changed. + In order to implement new behavior during the measurement cycle the + implementation of the ``MXM_StateMachineOperation`` has to be adapted. + This can be achieved by implementing a new variant in parallel to the + current ``max17852`` variant. + +.. _Startup_behavior: + +Startup behavior +^^^^^^^^^^^^^^^^ + +During enumeration of the daisy-chain, the monitoring driver can stop and hang +if the number of found devices does not match the expected number of devices +as reported by the system configuration. +In order to select whether the driver should hang or continue, the constant +``mxm_allowSkippingPostInitSelfCheck`` can be set. + +Main flow +--------- + +The following flow chart describes the main flow of this ``AFE`` driver. + +.. mermaid:: + + stateDiagram-v2 + uninitialized: Uninitialized + pre_init: Pre-Initialization Self Check + init: Initialization + post_init: Post-Initialization Self Check + idle: Idle + operation: Operation + + [*] --> uninitialized + uninitialized --> pre_init: Initialization + pre_init --> init: Success + init --> post_init: Success + post_init --> idle: Success + idle --> operation: Operation Requested + operation --> idle: Halt Requested + operation --> uninitialized: Error + pre_init --> uninitialized: Error + init --> uninitialized: Error + post_init --> uninitialized: Error + + state operation { + op_init: Initialization of AFE + op_mux_control: Multiplexer control + op_measurement: Measurement + op_diagnostic: Diagnostic measures + op_balancing: Balancing control + + [*] --> op_init + op_init --> op_mux_control + op_mux_control --> op_measurement + op_measurement --> op_diagnostic + op_diagnostic --> op_balancing + op_balancing --> op_mux_control + } + +* State `Unitialized`: This is the default state of the driver. + The driver transitions with the next execution into the + `Pre-Initialization Self Check` state. + +* State `Pre-Initialization Self Check`: In this state, the driver checks + assumptions on its functions. + If this step fails, the driver is not able to conclude its work. + +* State `Initialization`: In this state, the daisy-chain of the driver is + initialized and each ``AFE`` is assigned an address. + +* State `Post-Initialization Self Check`: During this state, the number of + found ``AFE`` is compared to the expected number of devices. + If these mismatch the driver can halt in this state depending on the + configuration described in :ref:`Startup_behavior`. + +* State `Idle`: The driver rests in this state as long as the system requests + the driver to start. + +* State `Operation`: This is the main state during which the ``AFE`` devices + are controlled. + + * State `Initialization of AFE`: In this chain of substates the ``AFE`` is + initialized and programmed with the expected configuration. + + * State `Multiplexer control`: In this chain of substates the temperature + multiplexer of the |slave| is controlled and switched to the next channel. + + * State `Measurement`: In this chain of substates the measurement the driver + requests a measurement and retrieves each measurement value. + + * State `Diagnostic measures`: In this chain of substates diagnostic + registers are read. + When a power on reset condition is recognized (indicating a loss of power + and potentially undefined state in one of the ``AFE`` devices), a reset of + the driver is triggered. + + * State `Balancing control`: In this chain of substates the balancing + switches are controlled. + The driver alternates between even and odd switches in order to not create + a connection between adjacent switches. + +* If any state except `Idle` or `Unitialized` is stuck and does not advance to + the next state during a predefined time frame, the driver resets itself to + the `Uninitialized` state. + Requests for operation are preserved during this reset as the system assumes + that the driver has been already asked to start. + +Diagnostic signals generated +---------------------------- + +This driver uses the following diagnostic messages of the ``diag``-module: + +* ``DIAG_ID_AFE_CONFIG``: This signal is issued when the self check of the + driver that is executed before the initialization fails. + If this happens, it is very likely due to an implementation error. +* ``DIAG_ID_AFE_COM_INTEGRITY``: This signal is issued when the CRC of a + received message is not correct. +* ``DIAG_ID_AFE_SPI``: This signal is issued when the SPI API returns an + unsuccessful transmission. + If this happens, it is very likely due to implementation issues with the + ``SPI`` interface. + Normally, the ``SPI`` transmission functions should succeed. + +Trivia +------ + +This section gathers additional information that is worth knowing about the +implementation. + +String mapping +^^^^^^^^^^^^^^ + +The driver assumes, that it has to service all strings in the system and that +all strings are connected into one daisy-chain. +(It expects a chain of strings of modules.) + +If only one string is defined, the driver maps the modules onto this string as +expected. +If more than one string is defined, the driver maps the modules by filling the +first string, then filling the second and so forth. +This behavior is not configurable. + +Automatic reset +^^^^^^^^^^^^^^^ + +When a communication issue occurs, the slave boards might get stuck in a state +that is unknown to the |master|. +In order to prevent this situation, the driver has an error counter. +This error counter is automatically reset after +`MXM_TIMEOUT_RESET_ERROR_COUNTER_ms` milliseconds without any new error. +If the error threshold of `MXM_MAXIMUM_ERROR_COUNT` is passed, the driver +starts an automatic reset of the whole daisy-chain. + +This is achieved by pulling down the shutdown line of the bridge IC, +effectively resetting it to default condition. +During this shutdown, the |slave| will go into deep sleep and thus loose their +non-persistent configuration (and also disable the on-board supply). +The driver resets itself to initial condition restores flags indicating whether +it may start and then restart the daisy-chain. +The user can register this by checking for the freshness of measurement values. diff --git a/docs/software/modules/driver/crc/crc.rst b/docs/software/modules/driver/crc/crc.rst new file mode 100644 index 00000000..08809d5b --- /dev/null +++ b/docs/software/modules/driver/crc/crc.rst @@ -0,0 +1,55 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _CRC: + +CRC +=== + +Module Files +------------ + +Driver +^^^^^^ + +- ``src/app/driver/crc/crc.c`` (`API <../../../../_static/doxygen/src/html/crc_8c.html>`__, `source <../../../../_static/doxygen/src/html/crc_8c_source.html>`__) +- ``src/app/driver/crc/crc.h`` (`API <../../../../_static/doxygen/src/html/crc_8h.html>`__, `source <../../../../_static/doxygen/src/html/crc_8h_source.html>`__) + +Unit Test +^^^^^^^^^ + +- ``tests/unit/app/driver/crc/test_crc.c`` (`API <../../../../_static/doxygen/tests/html/test__crc_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__crc_8c_source.html>`__) + +Description +----------- + +The CRC module uses the hardware of the MCU to compute the CRC of a data +flow. + +The CRC hardware is based on a 64 bit polynomial. The data is written +in 64 bit chunks to the registers ``PSA_SIGREGL1`` and ``PSA_SIGREGH1``. +The data flow does not need to be aligned on 64 bit: if is is not the case, +the last chunks of data will be padded with zeros to reach a size of 64 bit. + +The seed for the CRC computation is defined in ``crc.h`` with +``CRC_SEED_LOW`` and ``CRC_SEED_HIGH``, low referring to the LSB and high +to the MSB. + +The function ``CRC_CalculateCrc()`` takes three arguments: + + - a ``uint64_t *`` pointer where the calculated 64 bit CRC is written + - a ``uint8_t *`` pointer to the data + - the length in bytes of the data + +.. warning:: + This function is not re-entrant: as it uses hardware registers, it + must only be called once before its execution has finished, otherwise + the CRC computation will be wrong. + Currently it is only used with the FRAM, which only makes one access + at the same time, ensuring that the function is only called once. + If the function is to be used elsewhere, this point must be taken into + account. + +An internal re-entrance counter is used. If the function was only called +once, it returns ``STD_OK``, otherwise it returns ``STD_NOT_OK`` and the +CRC value is set to zero. diff --git a/docs/software/modules/driver/foxmath/foxmath.rst b/docs/software/modules/driver/foxmath/foxmath.rst index aee2e9a6..465893ae 100644 --- a/docs/software/modules/driver/foxmath/foxmath.rst +++ b/docs/software/modules/driver/foxmath/foxmath.rst @@ -28,4 +28,6 @@ Unit Test Description ----------- -|tbc| +This module contains a set of math functions specific to the implementation +of |foxbms|. +The doxygen documentation of this module provides details. diff --git a/docs/software/modules/driver/fram/fram.rst b/docs/software/modules/driver/fram/fram.rst index ac54d9d3..d5e6013d 100644 --- a/docs/software/modules/driver/fram/fram.rst +++ b/docs/software/modules/driver/fram/fram.rst @@ -29,4 +29,71 @@ Unit Test Description ----------- -|tbc| +The FRAM (ferroelectric random access memory) used is the model CY15B102QN. +It is a 2 Mbit logically organized as 256K × 8 bits. +It is non-volatile, does not need to be supplied to retain its data and can +be written a virtually unlimited number of times. +The FRAM is driven by an SPI interface. + +FRAM data variables and entries are defined in the ``fram_cfg.c`` file. +These must also be declared as extern in the ``fram_cfg.h`` file. +In ``fram_cfg.c``, the structure ``fram_base_header`` contains a list of all +variables and entries, along with their size. +In fram_cfg.h, an enum called ``FRAM_BLOCK_ID_e`` is declared. One element +in the enum must be defined as ID for each FRAM variable and entry. + +.. warning:: + The entries in the enum ``FRAM_BLOCK_ID_e`` must have the same order as + their definition in the structure ``fram_base_header``. There must be the + same number of entries in the structure ``fram_base_header`` as + in the enum ``FRAM_BLOCK_ID_e``. + +.. warning:: + The enum must always end with ``FRAM_BLOCK_MAX``. + +The function ``FRAM_Initialize()`` computes the address of each entry in +the FRAM. If the computed address is greater than the highest address +of the FRAM memory, an error is thrown. + +.. warning:: + The function ``FRAM_Initialize()`` must be called before using the FRAM. + +There are two main functions to interact with the FRAM: +``FRAM_WriteData()`` and ``FRAM_ReadData()``. They must simply be called with +one of the IDs defined in the enum called ``FRAM_BLOCK_ID_e``. +When ``FRAM_WriteData()`` is called, the content of the corresponding variable +defined in the ``fram_cfg.c`` file is written to the FRAM. +When ``FRAM_ReadData()`` is called, the content of the FRAM is read and written +to the corresponding variable defined in the ``fram_cfg.c`` file. +These functions use SPI and are blocking. The SPI used for the FRAM can be +configured in ``spi_cfg.c``. + +.. warning:: + The SPI used for the communication with the FRAM must be configured + with ``SPI_HARDWARE_CHIP_SELECT_DISABLE_ALL`` as the Chip Select pin is + driven via software. + +When writing a variable or entry, the FRAM module first computes a CRC of the +data written and stores it in the FRAM before the data. When reading, the +FRAM module reads the CRC and the data, computes the CRC of the read data +and compares it with the read CRC. This mechanism is transparent when using +the FRAM so it is not necessary to define a CRC field in the variables and +entries. + +When changing the FRAM layout, the alignment will not match anymore and this +will be detected with the CRC. The function ``FRAM_ReinitializeAllEntries()`` +is available. It will write all variables and entries with their current +state. The consequence is that the alignment will be restored. This function +is useful when making developments that involve changes in the FRAM data +layout. + +The read and write functions return one of the following four values: + + - ``FRAM_ACCESS_OK``: the write or read access was successful and + the CRC read matches with the CRC calculated on the read data. + - ``FRAM_ACCESS_SPI_BUSY``: the SPI is busy, the transaction could not + take place. + - ``FRAM_ACCESS_CRC_BUSY``: the CRC hardware is busy, the transaction + could not take place. + - ``FRAM_ACCESS_CRC_ERROR``: the data was read from the FRAM but the read + CRC does not match with the CRC computed on the read data. diff --git a/docs/software/modules/driver/imd/bender/bender_ir155.rst b/docs/software/modules/driver/imd/bender/bender_ir155.rst index 525b7ea8..9917f8d1 100644 --- a/docs/software/modules/driver/imd/bender/bender_ir155.rst +++ b/docs/software/modules/driver/imd/bender/bender_ir155.rst @@ -12,24 +12,60 @@ Module Files Driver ^^^^^^ -- ``src/app/driver/imd/bender/ir155/bender_ir155.c`` (`API <../../../../_static/doxygen/src/html/bender__ir155_8c.html>`__, `source <../../../../_static/doxygen/src/html/bender__ir155_8c_source.html>`__) -- ``src/app/driver/imd/bender/ir155/bender_ir155.h`` (`API <../../../../_static/doxygen/src/html/bender__ir155_8h.html>`__, `source <../../../../_static/doxygen/src/html/bender__ir155_8h_source.html>`__) +- ``src/app/driver/imd/bender/ir155/bender_ir155.c`` (`API <../../../../../_static/doxygen/src/html/bender__ir155_8c.html>`__, `source <../../../../../_static/doxygen/src/html/bender__ir155_8c_source.html>`__) +- ``src/app/driver/imd/bender/ir155/bender_ir155.h`` (`API <../../../../../_static/doxygen/src/html/bender__ir155_8h.html>`__, `source <../../../../../_static/doxygen/src/html/bender__ir155_8h_source.html>`__) +- ``src/app/driver/imd/bender/ir155/bender_ir155_helper.c`` (`API <../../../../../_static/doxygen/src/html/bender__ir155__helper_8c.html>`__, `source <../../../../../_static/doxygen/src/html/bender__ir155__helper_8c_source.html>`__) +- ``src/app/driver/imd/bender/ir155/bender_ir155_helper.h`` (`API <../../../../../_static/doxygen/src/html/bender__ir155__helper_8h.html>`__, `source <../../../../../_static/doxygen/src/html/bender__ir155__helper_8h_source.html>`__) Configuration ^^^^^^^^^^^^^ -*none* +- ``src/app/driver/imd/bender/ir155/config/bender_ir155_cfg.h`` (`API <../../../../../_static/doxygen/src/html/bender__ir155__cfg_8h.html>`__, `source <../../../../../_static/doxygen/src/html/bender__ir155__cfg_8h_source.html>`__) Unit Test ^^^^^^^^^ -- ``tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c`` (`API <../../../../_static/doxygen/tests/html/test__bender__ir155_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__bender__ir155_8c_source.html>`__) +- ``tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c`` (`API <../../../../../_static/doxygen/tests/html/test__bender__ir155_8c.html>`__, `source <../../../../../_static/doxygen/tests/html/test__bender__ir155_8c_source.html>`__) +- ``tests/unit/app/driver/imd/bender/ir155/test_bender_helper_ir155.c`` (`API <../../../../../_static/doxygen/tests/html/test__bender__ir155__helper_8c.html>`__, `source <../../../../../_static/doxygen/tests/html/test__bender__ir155__helper_8c_source.html>`__) -Description ------------ -The driver is currently a stub and not functional. -It behaves like the ``no-imd`` driver -(see :ref:`DUMMY_INSULATION_MEASUREMENT_DEVICE`) +Description of the IMD state machine +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Bender IR155 driver is interfaced and controlled by the superimposed +:ref:`IMD state machine`. +The required functionality, that needs to be provided by this driver is: + +* Initialize the Bender IR155 device +* Activate the insulation measurement +* Deactivate the insulation measurement +* Measurement of the insulation resistance + +Each functionality is implemented in a dedicated state machine that is +explained in detail in the following. + +Initialization procedure +"""""""""""""""""""""""" |tbc| + +The initialization process is implemented in function `IR155_InitializeModule`. + +Activation of insulation measurement +"""""""""""""""""""""""""""""""""""" + +The Bender IR155 device is activated via a MOSFET setting supply enable pin +(`IMD_SUP_EN`) to high. + +Disable insulation measurement +"""""""""""""""""""""""""""""" + +The Bender IR155 device is deactivated via a MOSFET setting supply enable pin +(`IMD_SUP_EN`) to low. + +Insulation measurement +"""""""""""""""""""""" + +|tbc| + +The measurement process is implemented in function `IR155_MeasureInsulation`. diff --git a/docs/software/modules/driver/imd/bender/bender_iso165c.rst b/docs/software/modules/driver/imd/bender/bender_iso165c.rst index 0c36ab3c..86734329 100644 --- a/docs/software/modules/driver/imd/bender/bender_iso165c.rst +++ b/docs/software/modules/driver/imd/bender/bender_iso165c.rst @@ -12,20 +12,83 @@ Module Files Driver ^^^^^^ -- ``src/app/driver/imd/bender/iso165c/bender_iso165c.c`` (`API <../../../../_static/doxygen/src/html/bender__iso165c_8c.html>`__, `source <../../../../_static/doxygen/src/html/bender__iso165c_8c_source.html>`__) -- ``src/app/driver/imd/bender/iso165c/bender_iso165c.h`` (`API <../../../../_static/doxygen/src/html/bender__iso165c_8h.html>`__, `source <../../../../_static/doxygen/src/html/bender__iso165c_8h_source.html>`__) +- ``src/app/driver/imd/bender/iso165c/bender_iso165c.c`` (`API <../../../../../_static/doxygen/src/html/bender__iso165c_8c.html>`__, `source <../../../../../_static/doxygen/src/html/bender__iso165c_8c_source.html>`__) +- ``src/app/driver/imd/bender/iso165c/bender_iso165c.h`` (`API <../../../../../_static/doxygen/src/html/bender__iso165c_8h.html>`__, `source <../../../../../_static/doxygen/src/html/bender__iso165c_8h_source.html>`__) Configuration ^^^^^^^^^^^^^ -*none* +- ``src/app/driver/imd/bender/iso165c/bender_iso165c.c`` (`API <../../../../../_static/doxygen/src/html/bender__iso165c__cfg_8c.html>`__, `source <../../../../../_static/doxygen/src/html/bender__iso165c_8c_source.html>`__) +- ``src/app/driver/imd/bender/iso165c/bender_iso165c.h`` (`API <../../../../../_static/doxygen/src/html/bender__iso165c__cfg_8h.html>`__, `source <../../../../../_static/doxygen/src/html/bender__iso165c_8h_source.html>`__) Unit Test ^^^^^^^^^ -- ``tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c`` (`API <../../../../_static/doxygen/tests/html/test__bender__iso165c_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__bender__iso165c_8c_source.html>`__) +- ``tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c`` (`API <../../../../../_static/doxygen/tests/html/test__bender__iso165c_8c.html>`__, `source <../../../../../_static/doxygen/tests/html/test__bender__iso165c_8c_source.html>`__) Description ----------- -|tbc| +Description of the IMD state machine +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Bender iso165C driver is interfaced and controlled by the superimposed +:ref:`IMD state machine`. +The required functionality, that needs to be provided by this driver is: + +* Initialize the Bender iso165C device +* Activate the insulation measurement +* Deactivate the insulation measurement +* Measurement of the insulation resistance + +Each functionality is implemented in a dedicated state machine that is +explained in detail in the following. + +Initialization procedure +"""""""""""""""""""""""" + +The state flow diagram of the initialization procedure of the Bender iso165C +state machine is depicted below. + +.. graphviz:: state-diagrams/iso165c_state_diagram_initialization.dot + :caption: iso165C initialization state flow diagram + :name: iso165c-init-state-diagram + +The initialization process is implemented in function `I165C_Initialize`. + +Activation of insulation measurement +"""""""""""""""""""""""""""""""""""" + +The state flow diagram of the enabling procedure of the Bender iso165C +state machine is depicted below. + +.. graphviz:: state-diagrams/iso165c_state_diagram_enable.dot + :caption: iso165C enable state flow diagram + :name: iso165c-enable-state-diagram + +The enabling process is implemented in function `I165C_Enable`. + +Disable insulation measurement +"""""""""""""""""""""""""""""" + +The state flow diagram of the disabling procedure of the Bender iso165C +state machine is depicted below. + +.. graphviz:: state-diagrams/iso165c_state_diagram_disable.dot + :caption: iso165C disable state flow diagram + :name: iso165c-disable-state-diagram + +The disabling process is implemented in function `I165C_Disable`. + +Insulation measurement +"""""""""""""""""""""" + + +The state flow diagram of the periodic insulation measurement procedure of the +Bender iso165C state machine is depicted below. + +.. graphviz:: state-diagrams/iso165c_state_diagram_running.dot + :caption: iso165C running state flow diagram + :name: iso165c-running-state-diagram + +The measurement process is implemented in function `I165C_Running`. diff --git a/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_disable.dot b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_disable.dot new file mode 100644 index 00000000..08b64231 --- /dev/null +++ b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_disable.dot @@ -0,0 +1,60 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +digraph iso165c_disable_fsm { + rankdir=TB; + size="50!,200"; + compound=true; + node [shape = doublecircle] nd_never_run + node [shape = circle] nd_stop_measurement_ack + nd_request_hv_relay_state + nd_check_neg_hv_relay_state + nd_check_pos_hv_relay_state + + nd_never_run [label=<Disable Start>]; + nd_stop_measurement_ack [label=<Wait for acknowledge>]; + nd_request_hv_relay_state [label=<Request opening of relays>]; + nd_check_neg_hv_relay_state [label=<Check negative HV relay state>]; + nd_check_pos_hv_relay_state [label=<Check positive HV relay state>]; + + + nd_never_run -> nd_stop_measurement_ack [label=<Disable measurement>]; + nd_stop_measurement_ack -> nd_stop_measurement_ack + nd_stop_measurement_ack -> nd_request_hv_relay_state + nd_request_hv_relay_state -> nd_check_neg_hv_relay_state + nd_check_neg_hv_relay_state -> nd_check_pos_hv_relay_state +} diff --git a/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_enable.dot b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_enable.dot new file mode 100644 index 00000000..47079f3a --- /dev/null +++ b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_enable.dot @@ -0,0 +1,62 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +digraph iso165c_enable_fsm { + rankdir=TB; + size="50!,200"; + compound=true; + node [shape = doublecircle] nd_never_run + node [shape = circle] nd_request_hv_relay_state + nd_check_neg_hv_relay_state + nd_check_pos_hv_relay_state + nd_start_measurement + nd_start_measurement_ack + + nd_never_run [label=<Enable Start>]; + nd_request_hv_relay_state [label=<Request relay state>]; + nd_check_neg_hv_relay_state [label=<Check negative HV relay state>]; + nd_check_pos_hv_relay_state [label=<Check positive HV relay state>]; + nd_start_measurement [label=<Start insulation measurement>]; + nd_start_measurement_ack [label=<Wait for acknowledge>]; + + nd_never_run -> nd_request_hv_relay_state [label=<Close HV relays>]; + nd_request_hv_relay_state -> nd_check_neg_hv_relay_state + nd_check_neg_hv_relay_state -> nd_check_pos_hv_relay_state + nd_check_pos_hv_relay_state -> nd_start_measurement + nd_start_measurement -> nd_start_measurement_ack + nd_start_measurement_ack -> nd_start_measurement_ack +} diff --git a/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_initialization.dot b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_initialization.dot new file mode 100644 index 00000000..453d98a6 --- /dev/null +++ b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_initialization.dot @@ -0,0 +1,109 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +digraph iso165c_init_fsm { + rankdir=TB; + size="50!,200"; + compound=true; + node [shape = doublecircle] nd_never_run + node [shape = circle] nd_unlock_wait_ack + nd_check_meas_state + nd_check_meas_state_ack + nd_open_hv_relay + nd_request_hv_relay_state + nd_check_neg_hv_relay_state + nd_check_pos_hv_relay_state + nd_request_self_test + nd_request_self_test_ack + nd_wait_self_test + nd_set_averaging_factor + nd_set_averaging_factor_ack + nd_set_error_threshold + nd_set_error_threshold_ack + nd_set_warning_threshold + nd_set_warning_threshold_ack + nd_disable_measurement + nd_disable_measurement_ack + + nd_never_run [label=<Initialization Start>]; + nd_unlock_wait_ack [label=<Wait for acknowledge>]; + nd_check_meas_state [label=<Check insulation measurement state>]; + nd_check_meas_state_ack [label=<Wait for acknowledge>]; + nd_open_hv_relay [label=<Open HV Relays>]; + nd_request_hv_relay_state [label=<Request relay state>]; + nd_check_neg_hv_relay_state [label=<Check negative HV relay state>]; + nd_check_pos_hv_relay_state [label=<Check positive HV relay state>]; + nd_request_self_test [label=<Start self-test>]; + nd_request_self_test_ack [label=<Wait for acknowledge>]; + nd_wait_self_test [label=<Wait until self-test finished>]; + nd_set_averaging_factor [label=<Set measurement averaging factor>]; + nd_set_averaging_factor_ack [label=<Wait for acknowledge>]; + nd_set_error_threshold [label=<Set insulation resistance error threshold>]; + nd_set_error_threshold_ack [label=<Wait for acknowledge>]; + nd_set_warning_threshold [label=<Set insulation resistance warning threshold>]; + nd_set_warning_threshold_ack [label=<Wait for acknowledge>]; + nd_disable_measurement [label=<Disable insulation measurement>]; + nd_disable_measurement_ack [label=<Wait for acknowledge>]; + + nd_never_run -> nd_unlock_wait_ack [label=<Unlock device>]; + nd_unlock_wait_ack -> nd_check_meas_state + nd_check_meas_state -> nd_check_meas_state_ack [label=<Enable measurement if disabled>]; + nd_check_meas_state_ack -> nd_check_meas_state_ack + nd_check_meas_state_ack -> nd_open_hv_relay [label=<Measurement enabled>]; + nd_check_meas_state -> nd_open_hv_relay + nd_open_hv_relay -> nd_request_hv_relay_state + nd_request_hv_relay_state -> nd_check_neg_hv_relay_state + nd_check_neg_hv_relay_state -> nd_check_pos_hv_relay_state + nd_check_pos_hv_relay_state -> nd_request_self_test + nd_request_self_test -> nd_request_self_test_ack + nd_request_self_test -> nd_disable_measurement [label=<Skip configuration if device has already been configured>]; + nd_request_self_test_ack -> nd_request_self_test_ack + nd_request_self_test_ack -> nd_wait_self_test + nd_wait_self_test -> nd_wait_self_test [label=<Wait until finished>]; + nd_wait_self_test -> nd_set_averaging_factor + nd_set_averaging_factor -> nd_set_averaging_factor_ack + nd_set_averaging_factor_ack -> nd_set_averaging_factor_ack + nd_set_averaging_factor_ack -> nd_set_error_threshold + nd_set_error_threshold -> nd_set_error_threshold_ack + nd_set_error_threshold_ack -> nd_set_error_threshold_ack + nd_set_error_threshold_ack -> nd_set_warning_threshold + nd_set_warning_threshold -> nd_set_warning_threshold_ack + nd_set_warning_threshold_ack -> nd_set_warning_threshold_ack + nd_set_warning_threshold_ack -> nd_disable_measurement + nd_disable_measurement -> nd_disable_measurement_ack + nd_disable_measurement_ack -> nd_disable_measurement_ack +} diff --git a/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_running.dot b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_running.dot new file mode 100644 index 00000000..d6706c46 --- /dev/null +++ b/docs/software/modules/driver/imd/bender/state-diagrams/iso165c_state_diagram_running.dot @@ -0,0 +1,57 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +digraph iso165c_running_fsm { + rankdir=TB; + size="50!,200"; + compound=true; + node [shape = doublecircle] nd_never_run + node [shape = circle] nd_read_measurement_values + nd_read_measurement_values_ack + nd_get_measurement + + nd_never_run [label=<Start insulation measurement>]; + nd_read_measurement_values [label=<Request resistance measurement values>]; + nd_read_measurement_values_ack [label=<Evaluate measurement result>]; + nd_get_measurement [label=<Evaluate status and device flags>]; + + nd_never_run -> nd_read_measurement_values + nd_read_measurement_values -> nd_read_measurement_values_ack + nd_read_measurement_values_ack -> nd_read_measurement_values_ack + nd_read_measurement_values_ack -> nd_get_measurement + nd_get_measurement -> nd_read_measurement_values [label=<Restart measurement cycle>]; +} diff --git a/docs/software/modules/driver/imd/imd-state-diagram.dot b/docs/software/modules/driver/imd/imd-state-diagram.dot new file mode 100644 index 00000000..665d2008 --- /dev/null +++ b/docs/software/modules/driver/imd/imd-state-diagram.dot @@ -0,0 +1,69 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +digraph imd_fsm { + rankdir=TB; + size="8,16" + compound=true; + node [shape = doublecircle] nd_initialization + nd_imd_enable; + nd_shutdown; + nd_running; + node [shape = circle] nd_never_run + nd_uninitialized + nd_error + + nd_never_run [label=<Startup>]; + nd_uninitialized [label=<Uninitialized>]; + nd_initialization [label=<Initialization >]; + nd_imd_enable [label=<IMD enable>]; + nd_running [label=<Running>]; + nd_shutdown [label=<Shutdown>]; + nd_error [label=<Error>]; + + nd_never_run -> nd_uninitialized + nd_uninitialized -> nd_initialization [label=<Request>]; + nd_initialization -> nd_imd_enable + nd_initialization -> nd_error + nd_imd_enable -> nd_running [label=<Request>]; + nd_imd_enable -> nd_error + nd_running -> nd_running + nd_running -> nd_shutdown [label=<Request>]; + nd_running -> nd_error + nd_shutdown -> nd_imd_enable + nd_shutdown -> nd_error +} diff --git a/docs/software/modules/driver/imd/imd.rst b/docs/software/modules/driver/imd/imd.rst index 1ba7c61c..172efb77 100644 --- a/docs/software/modules/driver/imd/imd.rst +++ b/docs/software/modules/driver/imd/imd.rst @@ -15,3 +15,152 @@ Several different Insulation Measurement Devices (IMD) are supported. ./bender/bender_ir155.rst ./bender/bender_iso165c.rst ./none/no-imd.rst + + +A superimposed state machine is implemented that interacts with the actual IMD +implementation. There a different reasons for the state machine to transition +between the states. Generally three cases can happen: + +- an external request to the state machine is received to either initialize + the IMD or to start/stop the insulation resistance measurement +- the IMD implementation request a transition e.g., when the initialization is + finished +- inherent determined transitions e.g., ``IMD_FSM_STATE_HAS_NEVER_RUN`` + transitions to state ``IMD_FSM_STATE_UNINITIALIZED`` + +The state machine consists of the following states: + +- ``IMD_FSM_STATE_HAS_NEVER_RUN`` +- ``IMD_FSM_STATE_UNINITIALIZED`` +- ``IMD_FSM_STATE_INITIALIZATION`` +- ``IMD_FSM_STATE_IMD_ENABLE`` +- ``IMD_FSM_STATE_SHUTDOWN`` +- ``IMD_FSM_STATE_RUNNING`` +- ``IMD_FSM_STATE_ERROR`` + +The transitions between the main states of the IMD state machine is depicted +below. + +.. graphviz:: imd-state-diagram.dot + :caption: IMD state flow diagram + :name: imd-state-diagram + +These transitions will either be performed automatically or on request. The +following requests can be made to the state machine: + +- ``IMD_STATE_INITIALIZE_REQUEST`` +- ``IMD_STATE_SWITCH_ON_REQUEST`` +- ``IMD_STATE_SHUTDOWN_REQUEST`` + +Brief state machine description +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The state machine trigger function ``IMD_Trigger()`` is called periodically +from the 100|_||ms| task. +It starts in state ``IMD_FSM_STATE_HAS_NEVER_RUN`` after startup and +transitions with the next call automatically to state +``IMD_FSM_STATE_UNINITIALIZED``. +The state machine waits in this state until the +``IMD_STATE_INITIALIZE_REQUEST`` has been submitted to the state machine +during the startup phase from the `sys` module. +The state machine transitions to state ``IMD_FSM_STATE_IMD_ENABLE`` after a +successful initialization of the required peripherals and the software modules +of the selected IMD driver implementation in state +``IMD_FSM_STATE_INITIALIZATION``. +Now, the state machine waits again to receive the +``IMD_STATE_SWITCH_ON_REQUEST`` from the application state machine activate the +IMD device and begin with the insulation resistance measurement and the +evaluation of the measurement results from IMD. +The state machine continuously monitors the insulation resistance of the +battery system in this state until the ``IMD_STATE_SHUTDOWN_REQUEST`` is +submitted to the state machine. +This can be necessary to prevent a mutual interference if multiple insulation +monitoring devices would be monitoring the battery system, e.g., when a vehicle +is connected to a charging station. + + +Description of the IMD state machine +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In the following, the implementations of all cases are explained in detail. + +``IMD_FSM_STATE_HAS_NEVER_RUN`` +""""""""""""""""""""""""""""""" + +This is the default state after the startup of the BMS. The state machine will +immediately transition to state ``IMD_FSM_STATE_UNINITIALIZED`` with the next +call. + +``IMD_FSM_STATE_UNINITIALIZED`` +""""""""""""""""""""""""""""""" + +The state machine will wait until an ``IMD_STATE_INITIALIZE_REQUEST`` is +received. +This request is submitted from the ``sys`` state machine during the startup +phase of the BMS. + +``IMD_FSM_STATE_INITIALIZATION`` +"""""""""""""""""""""""""""""""" + +The ``IMD_FSM_STATE_INITIALIZATION`` state is responsible to only initialize +the required peripherals and the software module of the selected IMD to prepare +the module for the measurement. +The actual measurement of the IMD shall not be started. +The state machine will switch to ``IMD_FSM_STATE_ERROR`` in case an error is +detected during the initialization. The interface is utilized using function +``IMD_ProcessInitializationState``. + +``IMD_FSM_STATE_IMD_ENABLE`` +"""""""""""""""""""""""""""" + +This state is responsible to activate the IMD device and start the insulation +measurement after a successful initialization. +Before this is done, the state request ``IMD_STATE_SWITCH_ON_REQUEST`` need to +be submitted to the state machine. +In the default software, this will be done by the ``bms`` state machine during +its initialization phase. +The ``imd`` state machine will switch to ``IMD_FSM_STATE_ERROR`` in case an +error is detected during the activation. +The state machine will switch to ``IMD_FSM_STATE_RUNNING`` once the IMD is +enabled. +The function ``IMD_ProcessEnableState`` provides the required interface for the +IMD implementation. + +``IMD_FSM_STATE_SHUTDOWN`` +"""""""""""""""""""""""""" + +The insulation measurement and the IMD are switched off in this case using the +interface function ``IMD_ProcessShutdownState``. +If this this successful, state ``IMD_FSM_STATE_IMD_ENABLE`` is executed next, +otherwise a transition into state ``IMD_FSM_STATE_ERROR`` will be done. + +``IMD_FSM_STATE_RUNNING`` +""""""""""""""""""""""""" + +This the main state of the superimposed IMD state machine. +This state acquires the measurement results from the selected IMD implementation +using the function ``IMD_ProcessRunningState()`` and evaluates the measurement +results in function ``IMD_EvaluateInsulationMeasurement``. +This way the evaluation is encapsulated from the insulation measurement +performed by the IMD. +Additionally, the state machine will react on a ``IMD_STATE_SHUTDOWN_REQUEST`` +request and subsequently switch to state ``IMD_FSM_STATE_SHUTDOWN``. + +``IMD_FSM_STATE_ERROR`` +""""""""""""""""""""""" + +|tbc| + +Interfaces for IMD driver implementation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following functions are used to interface the actual IMD implementation: + + +.. literalinclude:: ./../../../../../src/app/driver/imd/imd.h + :language: C + :linenos: + :start-after: /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE imd-documentation */ + :end-before: /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE imd-documentation */ + :caption: Interface description for IMD implementations + :name: imd-interface-description diff --git a/docs/software/modules/driver/interlock/interlock-schematic.dot b/docs/software/modules/driver/interlock/interlock-schematic.dot index b7c56cda..57ced68a 100644 --- a/docs/software/modules/driver/interlock/interlock-schematic.dot +++ b/docs/software/modules/driver/interlock/interlock-schematic.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/software/modules/driver/mcu/mcu.rst b/docs/software/modules/driver/mcu/mcu.rst index 264ecfa0..b0aafa66 100644 --- a/docs/software/modules/driver/mcu/mcu.rst +++ b/docs/software/modules/driver/mcu/mcu.rst @@ -28,4 +28,40 @@ Unit Test Description ----------- -|tbc| +The ``MCU`` module supplies an API that helps using certain functions of the MCU. +As an example, it can be used to access the current value of the free running +counter of the real time interrupt module. + +This can be used as a quick and reliable method for measuring code execution +time. +The following example :ref:`mcu-measure-time-rti` can help finding states in a +line of code that takes longer than expected for execution. + +.. code-block:: c + :linenos: + :caption: Measuring execution time with the ``RTI`` + :name: mcu-measure-time-rti + + const uint32_t entry = MCU_GetFreeRunningCount(); + /* code under test here */ + const uint32_t exit = MCU_GetFreeRunningCount(); + const uint32_t time_us = MCU_ConvertFrcDifferenceToTimespan_us(exit - entry); + if (time_us > 250u) { + /* do something that the compiler won't optimize away */ + volatile uint8_t test = 0u; + /* set breakpoint for example here */ + test++; + } + +The ``MCU`` module also supplies the function ``MCU_Delay_us()``. +It waits blocking for the time in microseconds given as parameter. +As this function uses the free running counter, it can be interrupted by the +operating system. +After its execution resumes, it will exit if the time given as parameter has +elapsed. +A timeout has also been implemented to avoid blocking the system with the +function. +If the time given as parameter is higher than the time resulting from the +timeout, the function will exit after the timeout and will not wait for the +time given as parameter. +This means that the timeout value should be checked. diff --git a/docs/software/modules/engine/database/database_how-to.c b/docs/software/modules/engine/database/database_how-to.c index 383f5f44..cd5bd41c 100644 --- a/docs/software/modules/engine/database/database_how-to.c +++ b/docs/software/modules/engine/database/database_how-to.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file database_how-to.c * @author foxBMS Team * @date 2021-04-12 (date of creation) - * @updated 2021-04-12 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup SOME_GROUP * @prefix DATA * @@ -62,14 +63,14 @@ /** configuration struct of database channel (data block) as * defined in database_cfg.h */ -typedef struct DATA_BASE { +typedef struct { void *pDatabaseEntry; /*!< pointer to the database entry */ - uint16_t datalength; /*!< length of the entry */ + uint16_t dataLength; /*!< length of the entry */ } DATA_BASE_s; /* example-data-block-id-start */ /** data block identification numbers */ -typedef enum DATA_BLOCK_ID { +typedef enum { DATA_BLOCK_ID_EXAMPLE, /**< some example database entry */ /* ... * ... @@ -84,7 +85,7 @@ typedef enum DATA_BLOCK_ID { /* example-data-block-id-end */ /** typedef for data block header as defined in database_cfg.h */ -typedef struct DATA_BLOCKHEADER { +typedef struct { DATA_BLOCK_ID_e uniqueId; /*!< uniqueId of database entry */ uint32_t timestamp; /*!< timestamp of last database update */ uint32_t previousTimestamp; /*!< timestamp of previous database update */ @@ -94,7 +95,7 @@ typedef struct DATA_BLOCKHEADER { /** * data block struct of example */ -typedef struct DATA_BLOCK_EXAMPLE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -106,7 +107,7 @@ typedef struct DATA_BLOCK_EXAMPLE { /** * data block struct of example_0 */ -typedef struct DATA_BLOCK_EXAMPLE_0 { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -117,7 +118,7 @@ typedef struct DATA_BLOCK_EXAMPLE_0 { /** * data block struct of example_1 */ -typedef struct DATA_BLOCK_EXAMPLE_1 { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -128,7 +129,7 @@ typedef struct DATA_BLOCK_EXAMPLE_1 { /** * data block struct of example_2 */ -typedef struct DATA_BLOCK_EXAMPLE_2 { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -139,7 +140,7 @@ typedef struct DATA_BLOCK_EXAMPLE_2 { /** * data block struct of example_3 */ -typedef struct DATA_BLOCK_EXAMPLE_3 { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ diff --git a/docs/software/modules/engine/database/wscript b/docs/software/modules/engine/database/wscript index d56c52d8..b9da96c0 100644 --- a/docs/software/modules/engine/database/wscript +++ b/docs/software/modules/engine/database/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -53,12 +53,16 @@ import os def build(bld): """Build the database object""" source = ["database_how-to.c"] + dummy_txt = "/* dummy file */\n" + dummy_headers = ["HL_sys_core", "HL_sys_common"] + for i in dummy_headers: + bld.path.find_or_declare(f"{i}.h").write(dummy_txt) includes = [ ".", os.path.join("..", "..", "..", "..", "..", "src", "app", "main", "include"), ] cflags = bld.env.CFLAGS_FOXBMS - bld.path.find_or_declare("HL_sys_common.h").write( + bld.path.find_or_declare("mcu.h").write( "/* dummy file */\n" "extern void OS_EnterTaskCritical();\n" "extern void OS_ExitTaskCritical();\n" diff --git a/docs/software/modules/engine/diag/diag.rst b/docs/software/modules/engine/diag/diag.rst index cc5e66ce..fc30e7b3 100644 --- a/docs/software/modules/engine/diag/diag.rst +++ b/docs/software/modules/engine/diag/diag.rst @@ -27,7 +27,6 @@ Configuration - ``src/app/engine/diag/cbs/diag_cbs_deep-discharge.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__deep-discharge_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__deep-discharge_8c_source.html>`__) - ``src/app/engine/diag/cbs/diag_cbs_dummy.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__dummy_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__dummy_8c_source.html>`__) - ``src/app/engine/diag/cbs/diag_cbs_interlock.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__interlock_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__interlock_8c_source.html>`__) -- ``src/app/engine/diag/cbs/diag_cbs_ltc.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__ltc_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__ltc_8c_source.html>`__) - ``src/app/engine/diag/cbs/diag_cbs_afe.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__afe_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__afe_8c_source.html>`__) - ``src/app/engine/diag/cbs/diag_cbs_plausibility.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__plausibility_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__plausibility_8c_source.html>`__) - ``src/app/engine/diag/cbs/diag_cbs_power-measurement.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__power-measurement_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__power-measurement_8c_source.html>`__) @@ -41,23 +40,42 @@ Unit Test - ``tests/unit/app/engine/config/test_diag_cfg.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cfg_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cfg_8c_source.html>`__) - ``tests/unit/app/engine/diag/test_diag.c`` (`API <../../../../_static/doxygen/tests/html/test__diag_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_can.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__can_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__can_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_contactor.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__contactor_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__contactor_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_current.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__current_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__current_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_current-sensor.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__current-sensor_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__current-sensor_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_deep-discharge.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__deep-discharge_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__deep-discharge_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_dummy.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__dummy_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__dummy_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_interlock.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__interlock_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__interlock_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_ltc.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__ltc_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__ltc_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_afe.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__afe_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__afe_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_plausibility.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__plausibility_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__plausibility_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_power-measurement.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__power-measurement_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__power-measurement_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_sbc.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__sbc_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__sbc_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_sys-mon.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__sys-mon_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__sys-mon_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_temperature.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__temperature_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__temperature_8c_source.html>`__) -- ``tests/unit/app/engine/diag/cbs/diag_cbs_voltage.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__voltage_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__voltage_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_can.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__can_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__can_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_contactor.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__contactor_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__contactor_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_current.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__current_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__current_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_current-sensor.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__current-sensor_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__current-sensor_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_deep-discharge.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__deep-discharge_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__deep-discharge_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_dummy.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__dummy_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__dummy_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_interlock.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__interlock_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__interlock_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__afe_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__afe_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_plausibility.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__plausibility_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__plausibility_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_power-measurement.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__power-measurement_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__power-measurement_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_sbc.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__sbc_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__sbc_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_sys-mon.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__sys-mon_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__sys-mon_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_temperature.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__temperature_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__temperature_8c_source.html>`__) +- ``tests/unit/app/engine/diag/cbs/test_diag_cbs_voltage.c`` (`API <../../../../_static/doxygen/tests/html/test__diag__cbs__voltage_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__diag__cbs__voltage_8c_source.html>`__) Detailed Description -------------------- -|tbc| +A detailed description on how to use the diagnosis module can be found in +:ref:`HOW_TO_USE_THE_DIAGNOSIS_MODULE`. + +The diagnosis module is implemented as a central table ``DIAG_ID_cfg`` that +maps ``DIAG_ID``\ s to callbacks. +Whenever the diagnosis handler is called in the application code the +diagnosis module selects based on this table the appropriate callback. +It is in the responsibility of the callback to handle the reported issue. + +In most implementations the callback sets according to the reported issue an +entry in the database for convenient use of error conditions. +An example is the CAN module that reports set error conditions from the +relevant tables in the database. +These entries are set from the callbacks of the diagnosis module. + +In addition to the callbacks, several parameters of the occurring issue can be +set. +As an example the table configures whether an diagnosis entry has a fatal +severity. +The diagnosis module makes convenience functions available that allow for +scanning for fatal errors in order to react on any of these issues. diff --git a/docs/software/modules/engine/sys/sys_state-machine-detailed.dot b/docs/software/modules/engine/sys/sys_state-machine-detailed.dot index 273f78e5..69024652 100644 --- a/docs/software/modules/engine/sys/sys_state-machine-detailed.dot +++ b/docs/software/modules/engine/sys/sys_state-machine-detailed.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/software/modules/engine/sys/sys_state-machine-top-view.dot b/docs/software/modules/engine/sys/sys_state-machine-top-view.dot index 6f9f3aad..cb398f8d 100644 --- a/docs/software/modules/engine/sys/sys_state-machine-top-view.dot +++ b/docs/software/modules/engine/sys/sys_state-machine-top-view.dot @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/docs/software/modules/engine/sys_mon/sys_mon.rst b/docs/software/modules/engine/sys_mon/sys_mon.rst index fe9eb687..60e2fa73 100644 --- a/docs/software/modules/engine/sys_mon/sys_mon.rst +++ b/docs/software/modules/engine/sys_mon/sys_mon.rst @@ -18,8 +18,8 @@ Driver Configuration ^^^^^^^^^^^^^ -- ``src/app/engine/config/sys_mon_cfg.c`` (`API <../../../../_static/doxygen/src/html/sys__mon_8c.html>`__, `source <../../../../_static/doxygen/src/html/sys__mon_8c_source.html>`__) -- ``src/app/engine/config/sys_mon_cfg.h`` (`API <../../../../_static/doxygen/src/html/sys__mon_8h.html>`__, `source <../../../../_static/doxygen/src/html/sys__mon_8h_source.html>`__) +- ``src/app/engine/config/sys_mon_cfg.c`` (`API <../../../../_static/doxygen/src/html/sys__mon__cfg_8c.html>`__, `source <../../../../_static/doxygen/src/html/sys__mon__cfg_8c_source.html>`__) +- ``src/app/engine/config/sys_mon_cfg.h`` (`API <../../../../_static/doxygen/src/html/sys__mon__cfg_8h.html>`__, `source <../../../../_static/doxygen/src/html/sys__mon__cfg_8h_source.html>`__) Unit Test ^^^^^^^^^ @@ -30,4 +30,88 @@ Unit Test Detailed Description -------------------- -|tbc| +The system monitoring module allows to detect timing variations in the +execution of the system tasks on millisecond level. +This is done by capturing a timestamp on entry and exit of the task functions. +A continuously running monitoring task compares the actual runtime of the tasks +against a configured maximum allowed runtime. +In the case that the predefined thresholds are surpassed, a diagnosis entry is +created and, if configured, the violation is recorded in persistent memory. +The current state of the system monitoring is communicated through a CAN +message. + +Configuration +^^^^^^^^^^^^^ + +The monitoring actions for each task can be configured in the array described +in :ref:`current-system-monitoring-configuration`. + +.. literalinclude:: ./../../../../../src/app/engine/config/sys_mon_cfg.c + :language: C + :linenos: + :start-after: /* DOCUMENTATION marker - sys_mon config entry */ + :end-before: /* DOCUMENTATION marker - sys_mon config exit */ + :caption: Current system monitoring configuration + :name: current-system-monitoring-configuration + +In this configuration, every task must have an entry. +For each task, the system monitoring can be enabled or disabled. +This is for example useful, when the algorithm task may violate the timings +from time to time. +Care should be taken, when a higher priority task is not monitored. +A timing violation on a higher priority task likely means that it takes up +all remaining resources leading to a block of the remaining lower priority +tasks. + +Apart from settings such as the expected cycle time and timing variation, it is +possible to configure whether a flag in persistent memory shall be set for each +task. +If this is disabled, the flag still exists, but will always return false +(meaning no violation). + +Diagnosis entries +^^^^^^^^^^^^^^^^^ + +When monitoring is enabled for a task and when the task violates its timings, +a diagnosis entry of type ``DIAG_ID_SYSTEMMONITORING`` is created in the +:ref:`DIAGNOSIS_MODULE`. +The diagnosis handler for this ID sets the appropriate error flags in the +``DATA_BLOCK_ERRORSTATE_s`` database table. + +These flags will not be cleared automatically. +The only actions that clear these flags are a power on reset cycle or sending +the appropriate flag in the ``foxBMS_Command`` CAN message. + +Error recording +^^^^^^^^^^^^^^^ + +If enabled, the system monitoring sets flags in persistent memory. +This is handled through the :ref:`FRAM` module. +Flags are written to the ``FRAM_SYS_MON_RECORD_s`` entry and committed to +persistent memory through a handler that is called from the 10 millisecond +task. + +These flags will not be cleared automatically. +The only action that clears these flags is sending the appropriate flag in the +``foxBMS_Command`` CAN message. + +CAN interface +^^^^^^^^^^^^^ + +The system monitoring module communicates through the :ref:`CAN` interface. +Detected violations of timing expectations are communicated through two +messages. +A general flag indicating if any violation has occurred is sent as the +variable ``foxBMS_SysMonError`` in message ``foxBMS_State``. +This flag is a sum value of all recorded and current entries in the database +and the persistent memory. + +A detail information on the current state is transmitted in the +``foxBMS_DetailState`` message. +This message sets flags for recorded and current violations of each task. + +In order to reset all current and recorded flags, the ``foxBMS_resetFlags`` +must be set in the ``foxBMS_Command`` message. +This calls the function ``SYSM_ClearAllTimingViolations()`` which resets +both the current and recorded flags and commits the update directly to the +persistent memory. diff --git a/docs/software/modules/main/fassert_how-to.rst b/docs/software/modules/main/fassert_how-to.rst index e55372ca..d0241b7e 100644 --- a/docs/software/modules/main/fassert_how-to.rst +++ b/docs/software/modules/main/fassert_how-to.rst @@ -47,7 +47,7 @@ the size of a variable is not zero. :name: static-assert /* db_variable is defined in your code and should contain something */ - static_assert((db_variable != 0), "database may not be zero"); + f_static_assert((db_variable != 0), "database may not be zero"); /* This assertion will not compile if db_variable has size zero. */ diff --git a/docs/software/modules/modules.rst b/docs/software/modules/modules.rst index afe1b3e6..870a78e3 100644 --- a/docs/software/modules/modules.rst +++ b/docs/software/modules/modules.rst @@ -40,6 +40,7 @@ Software Modules ./driver/adc/adc.rst ./driver/can/can.rst + ./driver/crc/crc.rst ./driver/contactor/contactor.rst ./driver/dma/dma.rst ./driver/foxmath/foxmath.rst diff --git a/docs/software/modules/task/ftask/ftask-user-code-functions.csv b/docs/software/modules/task/ftask/ftask-user-code-functions.csv index 5020e087..eb100024 100644 --- a/docs/software/modules/task/ftask/ftask-user-code-functions.csv +++ b/docs/software/modules/task/ftask/ftask-user-code-functions.csv @@ -1,5 +1,5 @@ -Function; Description -``FTSK_RunUserCodeCyclic1ms``; Code that should be run every 1ms -``FTSK_RunUserCodeCyclic10ms``; Code that should be run every 10ms -``FTSK_RunUserCodeCyclic100ms``; Code that should be run every 100ms -``FTSK_RunUserCodeCyclicAlgorithm100ms``; Code that should be run every 100ms, but with a lower priority than ``FTSK_RunUserCodeCyclic100ms`` +Function; Description +``FTSK_RunUserCodeCyclic1ms``; Code that should be run every 1ms +``FTSK_RunUserCodeCyclic10ms``; Code that should be run every 10ms +``FTSK_RunUserCodeCyclic100ms``; Code that should be run every 100ms +``FTSK_RunUserCodeCyclicAlgorithm100ms``; Code that should be run every 100ms, but with a lower priority than ``FTSK_RunUserCodeCyclic100ms`` diff --git a/docs/software/modules/task/ftask/ftask.rst b/docs/software/modules/task/ftask/ftask.rst index fe9b96e1..18ab4b64 100644 --- a/docs/software/modules/task/ftask/ftask.rst +++ b/docs/software/modules/task/ftask/ftask.rst @@ -119,7 +119,7 @@ User Code Function will be run or has run. This enables to determine if a task r os_boot = OS_ENGINE_RUNNING; OS_DelayTaskUntil(&os_schedulerStartTime, ftsk_taskDefinitionEngine.Phase); - while (1) { + while (true) { /* notify system monitoring that task will be called */ SYSM_Notify(SYSM_TASK_ID_ENGINE, SYSM_NOTIFY_ENTER, OS_GetTickCount()); /* user code implementation */ diff --git a/docs/software/modules/task/ftask/ftask_how-to.c b/docs/software/modules/task/ftask/ftask_how-to.c index 2492812b..8d461b99 100644 --- a/docs/software/modules/task/ftask/ftask_how-to.c +++ b/docs/software/modules/task/ftask/ftask_how-to.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ftask_how-to.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2020-08-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup SOME_GROUP * @prefix FTSK * @@ -64,7 +65,7 @@ #define DATA_WRITE_DATA(...) /** mock-up of data block identification numbers */ -typedef enum DATA_BLOCK_ID { +typedef enum { DATA_BLOCK_ID_EXAMPLE, /**< some example database entry */ /* ... * ... @@ -74,7 +75,7 @@ typedef enum DATA_BLOCK_ID { } DATA_BLOCK_ID_e; /** mock-up-typedef for data block header as defined in database_cfg.h */ -typedef struct DATA_BLOCKHEADER { +typedef struct { DATA_BLOCK_ID_e uniqueId; /*!< uniqueId of database entry */ uint32_t timestamp; /*!< timestamp of last database update */ uint32_t previousTimestamp; /*!< timestamp of previous database update */ @@ -83,7 +84,7 @@ typedef struct DATA_BLOCKHEADER { /** * mock-up data block struct of example */ -typedef struct DATA_BLOCK_EXAMPLE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ diff --git a/docs/software/modules/task/ftask/wscript b/docs/software/modules/task/ftask/wscript index 6615cf7f..6748ee14 100644 --- a/docs/software/modules/task/ftask/wscript +++ b/docs/software/modules/task/ftask/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -58,6 +58,7 @@ def build(bld): os.path.join("..", "..", "..", "..", "..", "src", "app", "main", "include"), ] cflags = bld.env.CFLAGS_FOXBMS + bld.path.find_or_declare("mcu.h").write("/* dummy file */\n") bld.path.find_or_declare("HL_sys_common.h").write( "/* dummy file */\n" "extern void OS_EnterTaskCritical();\n" diff --git a/docs/software/unit-tests/unit-tests_how-to.rst b/docs/software/unit-tests/unit-tests_how-to.rst index 85e73eb9..b43aa68a 100644 --- a/docs/software/unit-tests/unit-tests_how-to.rst +++ b/docs/software/unit-tests/unit-tests_how-to.rst @@ -13,7 +13,25 @@ Verify that the unit testing framework is work is working as expected: waf build_unit_test waf build_unit_test --coverage -Typical usage and more information on the unit tests can be found in :ref:`Unit tests `. +Typical usage and more information on the unit tests can be found in +:ref:`Unit tests `. + +How to exclude files from unit tests +==================================== + +Normally, all files should be covered by a (at least empty) unit test. +If a certain file is not meant to be covered by unit tests, it has to be +excluded in several locations in order to suppress checking mechanisms in the +toolchain. + +The configuration of ceedling is stored in a file called ``project.yml``. +In this file the files that will not receive any coverage must be added to +``:uncovered_ignore_list:``. +Otherwise, ceedling will report uncovered files. + +Additionally, the main wscript contains a mechanism that checks that every +file has a corresponding test file in the proper location. +Untested files have to be added to ``excl`` in ``check_testfiles(ctx)``. Using ceedling directly ======================= diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 53fbe9ba..13d13b71 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -18,6 +18,7 @@ bugfix bz cafeCC ceedling +cfg changelog chemistries cmd @@ -28,7 +29,7 @@ conda config contactor contactors -cppcheck +creepage criticality CRC dask @@ -47,6 +48,8 @@ endianness enum enums expander +extern +ferroelectric fiducial filename filenames @@ -56,6 +59,7 @@ foxbms foxBMS foxmath functionalities +fram freertos freeRTOS galvanically @@ -94,9 +98,11 @@ LTC ltc LTS mA +Mbit MCU microcontroller microcontrollers +Mictor milliampere milliamperes Miniconda @@ -144,6 +150,7 @@ rst rtr runnable runtime +Samtec scikit scipy Segger @@ -199,12 +206,14 @@ vendored versioned versioning viewable +VSUP waf Wh whitespace workflow workflows workspace +Wuerth wscript xEFxBBxBF xml diff --git a/docs/tools/static-analysis/axivion.rst b/docs/tools/static-analysis/axivion.rst index f396f0ff..30768264 100644 --- a/docs/tools/static-analysis/axivion.rst +++ b/docs/tools/static-analysis/axivion.rst @@ -52,7 +52,7 @@ environment variables): .. code-block:: console - C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_analysis.bat + C:\Users\vulpes\Documents\foxbms-2>tests\axivion\scripts\start_local_analysis.bat Local Builds And Results ------------------------ @@ -63,14 +63,14 @@ Local Builds And Results .. code-block:: console - C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_dashserver.bat + C:\Users\vulpes\Documents\foxbms-2>tests\axivion\scripts\start_local_dashserver.bat - Run the following command to update the analysis result (the local dashboard will not be available during the execution of the local analysis): .. code-block:: console - C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_analysis.bat + C:\Users\vulpes\Documents\foxbms-2>tests\axivion\scripts\start_local_analysis.bat VS Code Setup ------------- @@ -82,7 +82,7 @@ Running the Tests ^^^^^^^^^^^^^^^^^ Press :kbd:`Ctrl + Shift + B` and run the task *axivion analysis*. This task -runs the Axivion analysis script ``tests/axivion/start_analysis.bat``. +runs the Axivion analysis script ``tests/axivion/scripts/start_analysis.bat``. Issues ^^^^^^ diff --git a/docs/tools/static-analysis/cppcheck.rst b/docs/tools/static-analysis/cppcheck.rst deleted file mode 100644 index 6c5f7d47..00000000 --- a/docs/tools/static-analysis/cppcheck.rst +++ /dev/null @@ -1,104 +0,0 @@ -.. include:: ./../../macros.txt -.. include:: ./../../units.txt - -.. _CPPCHECK: - -Cppcheck -======== - -.. - Comments: - ons is from "add-ons" and not properly recognized by the spellchecker - -.. spelling:: - ons - -Static Analysis tries to uncover potential errors in software by analyzing the -source code. In this project one of the tools that are used is Cppcheck. - -Setup ------ -Cppcheck is free open-source software and obtainable from the -`Cppcheck project website`_. Install the program into the standard paths, but -make sure to also install the optional add-ons, which are not selected by -default. These add-ons add features such as a MISRA analysis. - -MISRA -+++++ -`MISRA C`_ is an embedded code-style that puts rules in place that aim to avoid -typical mistakes in C-programs. - -In order for Cppcheck to be able to conduct a MISRA analysis, the add-on has to -be installed as described. -The project maintainers host a `list of supported MISRA rules`_. -As the MISRA rules are proprietary you will have to obtain the rule texts if -you want to see the full rule texts. -Please refer to the `Cppcheck manual`_ for more details (search for -``misra.py``). -The rule texts can be obtained from the PDF variant of the MISRA rules that -can be acquired on the `MISRA website `_. - -For the GUI, you will have to configure the location of the rule text file -manually in the programs settings. -For the integration in our waf-toolchain, the configure-step expects the file -in ``$USERHOME\Documents\MISRA-C\rules-2012.txt``. - -Usage ------ -For using Cppcheck two options are available. The first one is the Cppcheck -GUI, which allows to inspect each defect per file. The second one is the -waf-task, which allows to check all files in one pass. - -GUI -+++ -The GUI can use a configuration that is generated by the waf-task. For this -to work you have to execute the waf-task at least once. - -The generated configuration will be available under -``build/static_analysis/cppcheck.cppcheck``. You can configure Cppcheck to open -the editor of your choice when double-clicking on a violation. - -WAF -+++ -The waf-task can be called with the parameter ``build_static_analysis``. -It is intended for CI-jobs and will fail if a violation without suppression is -detected. A list of suppressed errors can be configured in -``conf/spa/cppcheck-suppression.txt``. - -Suppression ------------ -As mentioned in the section `WAF`_ some checks are suppressed and do not lead -to a failing build task. For most of them this is due to the fact that we are -coming from a codebase that is not adhering to all rules. By suppressing -single rules (ideally only for the offending files) we can revise our codebase -step-by-step and transition to zero violations. - -The following part mentions all suppressions that may not be disabled even -transitioning to a cleaner codebase. - -``unusedFunction`` -++++++++++++++++++ -This check has to be suppressed as Cppcheck is not able to recognize every -function that is actually in use. Apart from that Cppcheck is correct on some -unused functions. We aim to check such occurrences with unit- and integration- -tests with coverage-analysis. - -``missingInclude`` -++++++++++++++++++ -Cppcheck can be supplied with the headers of a C-file. It can, however, also -work without the headers and is designed to yield good results nevertheless. -In fact, supplying to many headers, will heavily impact performance of the -analysis and will most of the time not improve the results. - -For this reason we are omitting most of the header files in this analysis. -Cppcheck will inform about the missing header-file and this information -is suppressed. - -``unmatchedSuppression`` -++++++++++++++++++++++++ -The used suppressions should be as narrow as possible. Sometimes it is, -however, impractical to mention explicitly every file that violates a certain -rule. -In this case the suppression is applied on every file. In the case that a -particular file has no violations of this type, a warning is generated, which -can be suppressed. diff --git a/docs/tools/waf-tools/f_cppcheck.rst b/docs/tools/waf-tools/f_cppcheck.rst deleted file mode 100644 index 5a530886..00000000 --- a/docs/tools/waf-tools/f_cppcheck.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. include:: ./../../macros.txt -.. include:: ./../../units.txt - -.. _WAF_TOOL_CPPCHECK: - -Cppcheck -======== - -The tool is located in ``tools/waf-tools``. - -Tool Documentation ------------------- - -.. automodule:: f_cppcheck - :members: - :show-inheritance: diff --git a/docs/tools/waf-tools/waf-tools.rst b/docs/tools/waf-tools/waf-tools.rst index e676c6b0..54c498a4 100644 --- a/docs/tools/waf-tools/waf-tools.rst +++ b/docs/tools/waf-tools/waf-tools.rst @@ -25,7 +25,6 @@ Waf Tools Implementation Documentation ./f_bootstrap_library_project.rst ./f_check_db_vars.rst ./f_clang_format.rst - ./f_cppcheck.rst ./f_git_hooks.rst ./f_guidelines.rst ./f_hcg.rst diff --git a/docs/units.txt b/docs/units.txt index b6e6c774..85094cdd 100644 --- a/docs/units.txt +++ b/docs/units.txt @@ -2,9 +2,18 @@ .. |_| unicode:: 0xA0 :trim: +.. |uA| replace:: :math:`{\mu}A` +.. |mA| replace:: mA +.. |mAh| replace:: mAh +.. |Ah| replace:: Ah +.. |mu| replace:: :math:`{\mu}` +.. |mm| replace:: mm +.. |ms| replace:: ms +.. |Ohm| replace:: :math:`{\Omega}` +.. |kOhm| replace:: :math:`{k\Omega}` +.. |g| replace:: g .. |W| replace:: W +.. |V| replace:: V .. |kW| replace:: kW .. |Wh| replace:: Wh .. |kWh| replace:: kWh -.. |mAh| replace:: mAh -.. |Ah| replace:: Ah diff --git a/ide.bat b/ide.bat index dfb32773..fd36cdef 100644 --- a/ide.bat +++ b/ide.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/application/algorithm/algorithm.c b/src/app/application/algorithm/algorithm.c index 85fc1177..0f67e37e 100644 --- a/src/app/application/algorithm/algorithm.c +++ b/src/app/application/algorithm/algorithm.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file algorithm.c * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2020-06-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ALGORITHMS * @prefix ALGO * @@ -83,9 +84,9 @@ static void ALGO_Initialization(void) { FAS_ASSERT((algo_algorithms[i].cycleTime_ms % ALGO_TICK_MS) == 0u); /* check only uninitialized algorithms */ - if (ALGO_UNINITIALIZED == algo_algorithms[i].state) { + if (algo_algorithms[i].state == ALGO_UNINITIALIZED) { /* directly make ready when init function is a null pointer otherwise run init */ - if (NULL_PTR == algo_algorithms[i].fpInitialization) { + if (algo_algorithms[i].fpInitialization == NULL_PTR) { algo_algorithms[i].state = ALGO_READY; } else { const STD_RETURN_TYPE_e result = algo_algorithms[i].fpInitialization(); @@ -112,7 +113,7 @@ extern void ALGO_MainFunction(void) { OS_EnterTaskCritical(); const bool initializationRequested = algo_initializationRequested; OS_ExitTaskCritical(); - if (true == initializationRequested) { + if (initializationRequested == true) { ALGO_Initialization(); OS_EnterTaskCritical(); algo_initializationRequested = false; @@ -127,13 +128,20 @@ extern void ALGO_MainFunction(void) { ((algo_algorithms[i].cycleTime_ms != 0u) && ((counter_ticks % algo_algorithms[i].cycleTime_ms) == 0u)); if ((runAlgorithmAsap != false) || (runAlgorithmCycleElapsed != false)) { /* Cycle time elapsed -> call function */ - if (ALGO_READY == algo_algorithms[i].state) { + if (algo_algorithms[i].state == ALGO_READY) { /* Set state to running -> reset to READY before leaving algo function */ algo_algorithms[i].state = ALGO_RUNNING; algo_algorithms[i].startTime = OS_GetTickCount(); algo_algorithms[i].fpAlgorithm(); ALGO_MarkAsDone(i); } + /* check if we need to reinit */ + if (algo_algorithms[i].state == ALGO_REINIT_REQUESTED) { + /* set to uninitialized so that the algorithm can be reinitialized */ + algo_algorithms[i].state = ALGO_UNINITIALIZED; + + ALGO_UnlockInitialization(); + } } } @@ -144,7 +152,7 @@ extern void ALGO_MonitorExecutionTime(void) { const uint32_t timestamp = OS_GetTickCount(); for (uint16_t i = 0u; i < algo_length; i++) { - if ((algo_algorithms[i].startTime != 0u) && (ALGO_RUNNING == algo_algorithms[i].state) && + if ((algo_algorithms[i].startTime != 0u) && (algo_algorithms[i].state == ALGO_RUNNING) && ((algo_algorithms[i].startTime + algo_algorithms[i].maxCalculationDuration_ms) < timestamp)) { /* Block task from further execution because of runtime violation, but task will finish its execution */ algo_algorithms[i].state = ALGO_BLOCKED; diff --git a/src/app/application/algorithm/algorithm.h b/src/app/application/algorithm/algorithm.h index 01265d76..548badd0 100644 --- a/src/app/application/algorithm/algorithm.h +++ b/src/app/application/algorithm/algorithm.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file algorithm.h * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2020-06-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ALGORITHMS * @prefix ALGO * diff --git a/src/app/application/algorithm/config/algorithm_cfg.c b/src/app/application/algorithm/config/algorithm_cfg.c index 952f9bfb..56b5b2de 100644 --- a/src/app/application/algorithm/config/algorithm_cfg.c +++ b/src/app/application/algorithm/config/algorithm_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file algorithm_cfg.c * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2020-06-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ALGORITHMS_CONFIGURATION * @prefix ALGO * @@ -77,9 +78,20 @@ const uint16_t algo_length = sizeof(algo_algorithms) / sizeof(algo_algorithms[0] extern void ALGO_MarkAsDone(uint32_t algorithmIndex) { FAS_ASSERT(algorithmIndex < algo_length); - if (algo_algorithms[algorithmIndex].state != ALGO_BLOCKED) { + if (algo_algorithms[algorithmIndex].state == ALGO_REINIT_REQUESTED) { + /* do not alter state if a reinit request is pending */ + } else if (algo_algorithms[algorithmIndex].state != ALGO_BLOCKED) { algo_algorithms[algorithmIndex].state = ALGO_READY; + } else { + /* algo is in "blocked" state, nothing to do here */ } } +extern void ALGO_MarkAsReinit(uint32_t algorithmIndex) { + FAS_ASSERT(algorithmIndex < algo_length); + OS_EnterTaskCritical(); + algo_algorithms[algorithmIndex].state = ALGO_REINIT_REQUESTED; + OS_ExitTaskCritical(); +} + /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/application/algorithm/config/algorithm_cfg.h b/src/app/application/algorithm/config/algorithm_cfg.h index 770f0727..41d4189b 100644 --- a/src/app/application/algorithm/config/algorithm_cfg.h +++ b/src/app/application/algorithm/config/algorithm_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file algorithm_cfg.h * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2020-06-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ALGORITHMS_CONFIGURATION * @prefix ALGO * @@ -77,17 +78,18 @@ typedef STD_RETURN_TYPE_e ALGO_INITIALIZATION_FUNCTION_f(void); typedef void ALGO_COMPUTATION_FUNCTION_f(void); /** states that an algorithm can take */ -typedef enum ALGO_STATE { - ALGO_UNINITIALIZED, /*!< This is the default value indicating that initialization has not run yet */ - ALGO_READY, /*!< This indicates that the algorithm is ready to be run on next time slot */ - ALGO_RUNNING, /*!< This indicates that the algorithm is currently running. - Note that it may not spend more than #ALGO_TASKS::maxCalculationDuration_ms in this state. */ - ALGO_BLOCKED, /*!< This indicates that the algorithm has violated its maximum calculation duration. */ - ALGO_FAILED_INIT, /*!< This indicates a failed initialization. */ +typedef enum { + ALGO_UNINITIALIZED, /*!< This is the default value indicating that initialization has not run yet */ + ALGO_READY, /*!< This indicates that the algorithm is ready to be run on next time slot */ + ALGO_RUNNING, /*!< This indicates that the algorithm is currently running. + Note that it may not spend more than #ALGO_TASKS_s::maxCalculationDuration_ms in this state. */ + ALGO_BLOCKED, /*!< This indicates that the algorithm has violated its maximum calculation duration. */ + ALGO_FAILED_INIT, /*!< This indicates a failed initialization. */ + ALGO_REINIT_REQUESTED, /*!< This indicates that a reinitialization of the algorithm has been requested. */ } ALGO_STATE_e; /** Struct representing the key parameters of an algorithm */ -typedef struct ALGO_TASKS { +typedef struct { ALGO_STATE_e state; /*!< current execution state */ uint32_t cycleTime_ms; /*!< cycle time of algorithm */ uint32_t maxCalculationDuration_ms; /*!< maximum allowed calculation duration for task */ @@ -111,6 +113,12 @@ extern const uint16_t algo_length; */ extern void ALGO_MarkAsDone(uint32_t algorithmIndex); +/** + * @brief mark a algorithm as requiring a reinitialization. + * @param[in] algorithmIndex index entry of the algorithm + */ +extern void ALGO_MarkAsReinit(uint32_t algorithmIndex); + /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #endif /* FOXBMS__ALGORITHM_CFG_H_ */ diff --git a/src/app/application/algorithm/moving_average/moving_average.c b/src/app/application/algorithm/moving_average/moving_average.c index d740899d..52acacfe 100644 --- a/src/app/application/algorithm/moving_average/moving_average.c +++ b/src/app/application/algorithm/moving_average/moving_average.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file moving_average.c * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ALGORITHMS * @prefix ALGO * @@ -54,6 +55,8 @@ /*========== Includes =======================================================*/ #include "moving_average.h" +#include "algorithm_cfg.h" + #include "database.h" /*========== Macros and Definitions =========================================*/ @@ -189,8 +192,8 @@ extern void ALGO_MovAverage(void) { curCounter = curPow_tab.newCurrent; /* Check if valid values */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (curPow_tab.invalidCurrentMeasurement[stringNumber] != 0u) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (curPow_tab.invalidCurrentMeasurement[s] != 0u) { validValues = false; } } @@ -200,8 +203,8 @@ extern void ALGO_MovAverage(void) { newValues = 1u; int32_t packCurrent = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - packCurrent += curPow_tab.current_mA[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + packCurrent += curPow_tab.current_mA[s]; } /* Add value to array and calculate new moving average values */ @@ -310,8 +313,8 @@ extern void ALGO_MovAverage(void) { powCounter = curPow_tab.newPower; /* Check if valid values */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (curPow_tab.invalidPowerMeasurement[stringNumber] != 0u) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (curPow_tab.invalidPowerMeasurement[s] != 0u) { validValues = false; } } @@ -319,8 +322,8 @@ extern void ALGO_MovAverage(void) { newValues = 1u; int32_t packPower = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - packPower += curPow_tab.power_W[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + packPower += curPow_tab.power_W[s]; } /* Add value to array and calculate new moving mean values */ diff --git a/src/app/application/algorithm/moving_average/moving_average.h b/src/app/application/algorithm/moving_average/moving_average.h index 4f4f931a..068a043f 100644 --- a/src/app/application/algorithm/moving_average/moving_average.h +++ b/src/app/application/algorithm/moving_average/moving_average.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file moving_average.h * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2020-07-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ALGORITHMS * @prefix ALGO * diff --git a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.c b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.c index 77307a77..759cf444 100644 --- a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.c +++ b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_counting.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * @@ -61,7 +62,7 @@ /*========== Macros and Definitions =========================================*/ /** This structure contains all the variables relevant for the SOX */ -typedef struct SOC_STATE { +typedef struct { bool socInitialized; /*!< true if the initialization has passed, false otherwise */ bool sensorCcUsed[BS_NR_OF_STRINGS]; /*!< bool if coulomb counting functionality from current sensor is used */ float ccScalingAverage[BS_NR_OF_STRINGS]; /*!< current sensor offset scaling for average SOC */ @@ -152,15 +153,15 @@ static void SOC_RecalibrateViaLookupTable(DATA_BLOCK_SOX_s *pTableSoc) { DATA_BLOCK_MIN_MAX_s tableMinMaxCellVoltages = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX}; DATA_READ_DATA(&tableMinMaxCellVoltages); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { SOC_SetValue( pTableSoc, - SOC_GetFromVoltage(tableMinMaxCellVoltages.minimumCellVoltage_mV[stringNumber]), - SOC_GetFromVoltage(tableMinMaxCellVoltages.maximumCellVoltage_mV[stringNumber]), - SOC_GetFromVoltage(tableMinMaxCellVoltages.averageCellVoltage_mV[stringNumber]), - stringNumber); + SOC_GetFromVoltage(tableMinMaxCellVoltages.minimumCellVoltage_mV[s]), + SOC_GetFromVoltage(tableMinMaxCellVoltages.maximumCellVoltage_mV[s]), + SOC_GetFromVoltage(tableMinMaxCellVoltages.averageCellVoltage_mV[s]), + s); } - FRAM_Write(FRAM_BLOCK_ID_SOC); + FRAM_WriteData(FRAM_BLOCK_ID_SOC); } static void SOC_SetValue( @@ -196,7 +197,7 @@ static void SOC_SetValue( /* Update non-volatile memory values */ SOC_UpdateNvmValues(pTableSoc, stringNumber); - FRAM_Write(FRAM_BLOCK_ID_SOC); + FRAM_WriteData(FRAM_BLOCK_ID_SOC); } static void SOC_CheckDatabaseSocPercentageLimits(DATA_BLOCK_SOX_s *pTableSoc, uint8_t stringNumber) { @@ -238,7 +239,7 @@ void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool ccPresent, uint8_t stringNumber FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); DATA_READ_DATA(&soc_tableCurrentSensor); - FRAM_Read(FRAM_BLOCK_ID_SOC); + FRAM_ReadData(FRAM_BLOCK_ID_SOC); if (ccPresent == true) { soc_state.sensorCcUsed[stringNumber] = true; @@ -280,12 +281,12 @@ void SOC_Calculation(DATA_BLOCK_SOX_s *pSocValues) { /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE cc-documentation-stop-include */ FAS_ASSERT(pSocValues != NULL_PTR); bool continueFunction = true; - if (false == soc_state.socInitialized) { + if (soc_state.socInitialized == false) { /* Exit if SOC not initialized yet */ continueFunction = false; } - if (true == continueFunction) { + if (continueFunction == true) { /* Read current sensor entry for coulomb/current counting or CC recalibration */ DATA_READ_DATA(&soc_tableCurrentSensor); @@ -293,76 +294,65 @@ void SOC_Calculation(DATA_BLOCK_SOX_s *pSocValues) { /* Recalibrate SOC via LUT */ SOC_RecalibrateViaLookupTable(pSocValues); } else { - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (soc_state.sensorCcUsed[stringNumber] == false) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (soc_state.sensorCcUsed[s] == false) { /* check if current measurement has been updated */ - if (soc_state.previousTimestamp[stringNumber] != - soc_tableCurrentSensor.timestampCurrent[stringNumber]) { + if (soc_state.previousTimestamp[s] != soc_tableCurrentSensor.timestampCurrent[s]) { float timestep_s = - ((float)(soc_tableCurrentSensor.timestampCurrent[stringNumber] - soc_state.previousTimestamp[stringNumber])) / + ((float)(soc_tableCurrentSensor.timestampCurrent[s] - soc_state.previousTimestamp[s])) / 1000.0f; if (timestep_s > 0.0f) { /* Current in charge direction negative means SOC increasing --> BAT naming, not ROB */ float deltaSOC_perc = - (((float)soc_tableCurrentSensor.current_mA[stringNumber] * timestep_s) / - SOC_STRING_CAPACITY_mAs) * + (((float)soc_tableCurrentSensor.current_mA[s] * timestep_s) / SOC_STRING_CAPACITY_mAs) * 100.0f / 1000.0f; /* ((mA) * 1s) / 1As) * 100% */ #if POSITIVE_DISCHARGE_CURRENT == false deltaSOC_perc *= (-1.0f); #endif /* POSITIVE_DISCHARGE_CURRENT == false */ - pSocValues->averageSoc_perc[stringNumber] = pSocValues->averageSoc_perc[stringNumber] - - deltaSOC_perc; - pSocValues->minimumSoc_perc[stringNumber] = pSocValues->minimumSoc_perc[stringNumber] - - deltaSOC_perc; - pSocValues->maximumSoc_perc[stringNumber] = pSocValues->maximumSoc_perc[stringNumber] - - deltaSOC_perc; + pSocValues->averageSoc_perc[s] = pSocValues->averageSoc_perc[s] - deltaSOC_perc; + pSocValues->minimumSoc_perc[s] = pSocValues->minimumSoc_perc[s] - deltaSOC_perc; + pSocValues->maximumSoc_perc[s] = pSocValues->maximumSoc_perc[s] - deltaSOC_perc; /* Limit SOC calculation to 0% respectively 100% */ - SOC_CheckDatabaseSocPercentageLimits(pSocValues, stringNumber); + SOC_CheckDatabaseSocPercentageLimits(pSocValues, s); /* Update values in non-volatile memory */ - SOC_UpdateNvmValues(pSocValues, stringNumber); + SOC_UpdateNvmValues(pSocValues, s); } - soc_state.previousTimestamp[stringNumber] = - soc_tableCurrentSensor.timestampCurrent[stringNumber]; + soc_state.previousTimestamp[s] = soc_tableCurrentSensor.timestampCurrent[s]; } /* end check if current measurement has been updated */ /* update the variable for the next check */ } else { /* check if cc measurement has been updated */ - if (soc_state.previousTimestamp[stringNumber] != - soc_tableCurrentSensor.timestampCurrentCounting[stringNumber]) { + if (soc_state.previousTimestamp[s] != soc_tableCurrentSensor.timestampCurrentCounting[s]) { float deltaSoc_perc = - (((float)soc_tableCurrentSensor.currentCounter_As[stringNumber] / SOC_STRING_CAPACITY_As) * + (((float)soc_tableCurrentSensor.currentCounter_As[s] / SOC_STRING_CAPACITY_As) * 100.0f)); #if POSITIVE_DISCHARGE_CURRENT == false deltaSoc_perc *= (-1.0f); #endif /* POSITIVE_DISCHARGE_CURRENT == false */ - pSocValues->averageSoc_perc[stringNumber] = soc_state.ccScalingAverage[stringNumber] - - deltaSoc_perc; - pSocValues->minimumSoc_perc[stringNumber] = soc_state.ccScalingMinimum[stringNumber] - - deltaSoc_perc; - pSocValues->maximumSoc_perc[stringNumber] = soc_state.ccScalingMaximum[stringNumber] - - deltaSoc_perc; + pSocValues->averageSoc_perc[s] = soc_state.ccScalingAverage[s] - deltaSoc_perc; + pSocValues->minimumSoc_perc[s] = soc_state.ccScalingMinimum[s] - deltaSoc_perc; + pSocValues->maximumSoc_perc[s] = soc_state.ccScalingMaximum[s] - deltaSoc_perc; /* Limit SOC values to [0.0, 100.0] */ - SOC_CheckDatabaseSocPercentageLimits(pSocValues, stringNumber); + SOC_CheckDatabaseSocPercentageLimits(pSocValues, s); /* Update values in non-volatile memory */ - SOC_UpdateNvmValues(pSocValues, stringNumber); + SOC_UpdateNvmValues(pSocValues, s); - soc_state.previousTimestamp[stringNumber] = - soc_tableCurrentSensor.timestampCurrentCounting[stringNumber]; + soc_state.previousTimestamp[s] = soc_tableCurrentSensor.timestampCurrentCounting[s]; } /* end check if cc measurement has been updated */ } } /* Update database and FRAM value */ - FRAM_Write(FRAM_BLOCK_ID_SOC); + FRAM_WriteData(FRAM_BLOCK_ID_SOC); } } } @@ -383,7 +373,7 @@ float SOC_GetFromVoltage(int16_t voltage_mV) { } /* Interpolate between LUT values, but do not extrapolate LUT! */ - if (!(((0u == between_high) && (0u == between_low)) || /* cell voltage > maximum LUT voltage */ + if (!(((between_high == 0u) && (between_low == 0u)) || /* cell voltage > maximum LUT voltage */ (between_low >= bc_stateOfChargeLookupTableLength))) { /* cell voltage < minimum LUT voltage */ soc_perc = MATH_LinearInterpolation( (float)bc_stateOfChargeLookupTable[between_low].voltage_mV, diff --git a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.h b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.h index 2de8b88e..eabff223 100644 --- a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.h +++ b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_counting.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.c b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.c index 6e00691d..9bd3f359 100644 --- a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.c +++ b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_counting_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.h b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.h index beb0a24f..08921163 100644 --- a/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.h +++ b/src/app/application/algorithm/state_estimation/soc/counting/soc_counting_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_counting_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2021-05-20 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.c b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.c index ebbfb31a..c336e931 100644 --- a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.c +++ b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_debug.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * @@ -65,7 +66,7 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool cc_present, uint8_t stringNumber) { +extern void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool ccPresent, uint8_t stringNumber) { FAS_ASSERT(pSocValues != NULL_PTR); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); } diff --git a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.h b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.h index 5502257d..5fdf7a69 100644 --- a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.h +++ b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_debug.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.c b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.c index acf6752a..6805c728 100644 --- a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.c +++ b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_debug_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.h b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.h index 5b7ad948..5ae8c78b 100644 --- a/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.h +++ b/src/app/application/algorithm/state_estimation/soc/debug/soc_debug_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_debug_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/none/soc_none.c b/src/app/application/algorithm/state_estimation/soc/none/soc_none.c index f024b3fe..911de357 100644 --- a/src/app/application/algorithm/state_estimation/soc/none/soc_none.c +++ b/src/app/application/algorithm/state_estimation/soc/none/soc_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_none.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * @@ -65,7 +66,7 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool cc_present, uint8_t stringNumber) { +extern void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool ccPresent, uint8_t stringNumber) { FAS_ASSERT(pSocValues != NULL_PTR); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); } diff --git a/src/app/application/algorithm/state_estimation/soc/none/soc_none.h b/src/app/application/algorithm/state_estimation/soc/none/soc_none.h index d3ca5594..4aa43ab9 100644 --- a/src/app/application/algorithm/state_estimation/soc/none/soc_none.h +++ b/src/app/application/algorithm/state_estimation/soc/none/soc_none.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_none.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.c b/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.c index 104eefe1..81e95ba7 100644 --- a/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.c +++ b/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_none_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.h b/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.h index 063ccaca..160f14b2 100644 --- a/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.h +++ b/src/app/application/algorithm/state_estimation/soc/none/soc_none_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soc_none_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOC * diff --git a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.c b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.c index 1c94c556..37b3cc85 100644 --- a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.c +++ b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_counting.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * @@ -67,7 +68,7 @@ /** * This structure contains all the variables relevant for the SOX. */ -typedef struct SOE_STATE { +typedef struct { bool soeInitialized; /*!< true if the initialization has passed, false otherwise */ bool sensorEcUsed[BS_NR_OF_STRINGS]; /*!< true if energy counting functionality of current sensor is used */ float ecScalingAverage[BS_NR_OF_STRINGS]; /*!< current sensor offset scaling for average SOE */ @@ -194,15 +195,15 @@ static void SOE_RecalibrateViaLookupTable(DATA_BLOCK_SOX_s *pSoeValues) { DATA_READ_DATA(&tableMinimumMaximumAverage); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { SOE_SetValue( pSoeValues, - SOE_GetFromVoltage(tableMinimumMaximumAverage.minimumCellVoltage_mV[stringNumber]), - SOE_GetFromVoltage(tableMinimumMaximumAverage.maximumCellVoltage_mV[stringNumber]), - SOE_GetFromVoltage(tableMinimumMaximumAverage.averageCellVoltage_mV[stringNumber]), - stringNumber); + SOE_GetFromVoltage(tableMinimumMaximumAverage.minimumCellVoltage_mV[s]), + SOE_GetFromVoltage(tableMinimumMaximumAverage.maximumCellVoltage_mV[s]), + SOE_GetFromVoltage(tableMinimumMaximumAverage.averageCellVoltage_mV[s]), + s); } - FRAM_Write(FRAM_BLOCK_ID_SOE); + FRAM_WriteData(FRAM_BLOCK_ID_SOE); } static float SOE_GetFromVoltage(int16_t voltage_mV) { @@ -220,7 +221,7 @@ static float SOE_GetFromVoltage(int16_t voltage_mV) { } /* Interpolate between LUT values, but do not extrapolate LUT! */ - if (!(((0u == between_high) && (0u == between_low)) || /* cell voltage > maximum LUT voltage */ + if (!(((between_high == 0u) && (between_low == 0u)) || /* cell voltage > maximum LUT voltage */ (between_low >= bc_stateOfEnergyLookupTableLength))) { /* cell voltage < minimum LUT voltage */ soe_perc = MATH_LinearInterpolation( (float)bc_stateOfEnergyLookupTable[between_low].voltage_mV, @@ -311,7 +312,7 @@ static void SOE_CheckDatabaseSoePercentageLimits(DATA_BLOCK_SOX_s *pTableSoe, ui extern void SOE_Init(DATA_BLOCK_SOX_s *pSoeValues, bool ec_present, uint8_t stringNumber) { FAS_ASSERT(pSoeValues != NULL_PTR); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); - FRAM_Read(FRAM_BLOCK_ID_SOE); + FRAM_ReadData(FRAM_BLOCK_ID_SOE); pSoeValues->averageSoe_perc[stringNumber] = fram_soe.averageSoe_perc[stringNumber]; pSoeValues->minimumSoe_perc[stringNumber] = fram_soe.minimumSoe_perc[stringNumber]; @@ -328,7 +329,7 @@ extern void SOE_Init(DATA_BLOCK_SOX_s *pSoeValues, bool ec_present, uint8_t stri pSoeValues->averageSoe_Wh[stringNumber] = SOE_GetStringEnergyFromSoePercentage(pSoeValues->averageSoe_perc[stringNumber]); - if (true == ec_present) { + if (ec_present == true) { DATA_READ_DATA(&soe_tableCurrentSensor); soe_state.sensorEcUsed[stringNumber] = true; @@ -355,12 +356,12 @@ extern void SOE_Init(DATA_BLOCK_SOX_s *pSoeValues, bool ec_present, uint8_t stri void SOE_Calculation(DATA_BLOCK_SOX_s *pSoeValues) { FAS_ASSERT(pSoeValues != NULL_PTR); bool continueFunction = true; - if (false == soe_state.soeInitialized) { + if (soe_state.soeInitialized == false) { /* Exit if SOE not initialized yet */ continueFunction = false; } - if (true == continueFunction) { + if (continueFunction == true) { /* Use energy counting/integrate */ DATA_READ_DATA(&soe_tableCurrentSensor); @@ -368,51 +369,49 @@ void SOE_Calculation(DATA_BLOCK_SOX_s *pSoeValues) { /* Recalibrate SOE via LUT */ SOE_RecalibrateViaLookupTable(pSoeValues); } else { - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (false == soe_state.sensorEcUsed[stringNumber]) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (soe_state.sensorEcUsed[s] == false) { /* no energy counting activated -> manually integrate energy */ - uint32_t timestamp = soe_tableCurrentSensor.timestampCurrent[stringNumber]; - uint32_t previous_timestamp = soe_tableCurrentSensor.previousTimestampCurrent[stringNumber]; + uint32_t timestamp = soe_tableCurrentSensor.timestampCurrent[s]; + uint32_t previous_timestamp = soe_tableCurrentSensor.previousTimestampCurrent[s]; /* check if current measurement has been updated */ - if (soe_state.previousTimestamp[stringNumber] != timestamp) { + if (soe_state.previousTimestamp[s] != timestamp) { float timestep_s = (((float)timestamp - (float)previous_timestamp)) / 1000.0f; if (timestep_s > 0.0f) { /* Current in charge direction negative means SOE increasing --> BAT naming, not ROB */ - float deltaSOE_Wh = ((((float)soe_tableCurrentSensor.current_mA[stringNumber] / - 1000.0f) * /* convert to A */ - ((float)soe_tableCurrentSensor.highVoltage_mV[stringNumber][0] / - 1000.0f)) / /* convert to V */ - timestep_s) / /* unit: s */ - 3600.0f; /* convert Ws -> Wh */ + float deltaSOE_Wh = + ((((float)soe_tableCurrentSensor.current_mA[s] / 1000.0f) * /* convert to A */ + ((float)soe_tableCurrentSensor.highVoltage_mV[s][0] / 1000.0f)) / /* convert to V */ + timestep_s) / /* unit: s */ + 3600.0f; /* convert Ws -> Wh */ #if POSITIVE_DISCHARGE_CURRENT == false /* negate calculated delta SOE_Wh */ deltaSOE_Wh *= (-1.0f); #endif /* POSITIVE_DISCHARGE_CURRENT == false */ - pSoeValues->averageSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh; - pSoeValues->minimumSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh; - pSoeValues->maximumSoe_Wh[stringNumber] -= (uint32_t)deltaSOE_Wh; + pSoeValues->averageSoe_Wh[s] -= (uint32_t)deltaSOE_Wh; + pSoeValues->minimumSoe_Wh[s] -= (uint32_t)deltaSOE_Wh; + pSoeValues->maximumSoe_Wh[s] -= (uint32_t)deltaSOE_Wh; - pSoeValues->averageSoe_perc[stringNumber] = - SOE_GetStringSoePercentageFromEnergy(pSoeValues->averageSoe_Wh[stringNumber]); - pSoeValues->minimumSoe_perc[stringNumber] = - SOE_GetStringSoePercentageFromEnergy(pSoeValues->minimumSoe_Wh[stringNumber]); - pSoeValues->maximumSoe_perc[stringNumber] = - SOE_GetStringSoePercentageFromEnergy(pSoeValues->maximumSoe_Wh[stringNumber]); + pSoeValues->averageSoe_perc[s] = + SOE_GetStringSoePercentageFromEnergy(pSoeValues->averageSoe_Wh[s]); + pSoeValues->minimumSoe_perc[s] = + SOE_GetStringSoePercentageFromEnergy(pSoeValues->minimumSoe_Wh[s]); + pSoeValues->maximumSoe_perc[s] = + SOE_GetStringSoePercentageFromEnergy(pSoeValues->maximumSoe_Wh[s]); /* update timestamp SOE state variable for next iteration */ - soe_state.previousTimestamp[stringNumber] = timestamp; + soe_state.previousTimestamp[s] = timestamp; } } /* end check if current measurement has been updated */ } else { /* check if ec measurement has been updated */ - if (soe_state.previousTimestamp[stringNumber] != - soe_tableCurrentSensor.timestampEnergyCounting[stringNumber]) { + if (soe_state.previousTimestamp[s] != soe_tableCurrentSensor.timestampEnergyCounting[s]) { /* Calculate SOE value with current sensor EC value */ float deltaSoe_perc = - (((float)soe_tableCurrentSensor.energyCounter_Wh[stringNumber] / SOE_STRING_ENERGY_Wh) * + (((float)soe_tableCurrentSensor.energyCounter_Wh[s] / SOE_STRING_ENERGY_Wh) * UNIT_CONVERSION_FACTOR_100_FLOAT); #if POSITIVE_DISCHARGE_CURRENT == false @@ -420,37 +419,33 @@ void SOE_Calculation(DATA_BLOCK_SOX_s *pSoeValues) { deltaSoe_perc *= (-1.0f); #endif /* Apply EC scaling offset to get actual string energy */ - pSoeValues->averageSoe_perc[stringNumber] = soe_state.ecScalingAverage[stringNumber] - - deltaSoe_perc; - pSoeValues->minimumSoe_perc[stringNumber] = soe_state.ecScalingMinimum[stringNumber] - - deltaSoe_perc; - pSoeValues->maximumSoe_perc[stringNumber] = soe_state.ecScalingMaximum[stringNumber] - - deltaSoe_perc; + pSoeValues->averageSoe_perc[s] = soe_state.ecScalingAverage[s] - deltaSoe_perc; + pSoeValues->minimumSoe_perc[s] = soe_state.ecScalingMinimum[s] - deltaSoe_perc; + pSoeValues->maximumSoe_perc[s] = soe_state.ecScalingMaximum[s] - deltaSoe_perc; /* Limit SOE values to [0.0, 100.0] */ - SOE_CheckDatabaseSoePercentageLimits(pSoeValues, stringNumber); + SOE_CheckDatabaseSoePercentageLimits(pSoeValues, s); /* Calculate new Wh values */ - pSoeValues->maximumSoe_Wh[stringNumber] = - SOE_GetStringEnergyFromSoePercentage(pSoeValues->maximumSoe_perc[stringNumber]); - pSoeValues->averageSoe_Wh[stringNumber] = - SOE_GetStringEnergyFromSoePercentage(pSoeValues->averageSoe_perc[stringNumber]); - pSoeValues->minimumSoe_Wh[stringNumber] = - SOE_GetStringEnergyFromSoePercentage(pSoeValues->minimumSoe_perc[stringNumber]); + pSoeValues->maximumSoe_Wh[s] = + SOE_GetStringEnergyFromSoePercentage(pSoeValues->maximumSoe_perc[s]); + pSoeValues->averageSoe_Wh[s] = + SOE_GetStringEnergyFromSoePercentage(pSoeValues->averageSoe_perc[s]); + pSoeValues->minimumSoe_Wh[s] = + SOE_GetStringEnergyFromSoePercentage(pSoeValues->minimumSoe_perc[s]); /* Update timestamp for next iteration */ - soe_state.previousTimestamp[stringNumber] = - soe_tableCurrentSensor.timestampEnergyCounting[stringNumber]; + soe_state.previousTimestamp[s] = soe_tableCurrentSensor.timestampEnergyCounting[s]; } } - fram_soe.averageSoe_perc[stringNumber] = pSoeValues->averageSoe_perc[stringNumber]; - fram_soe.minimumSoe_perc[stringNumber] = pSoeValues->minimumSoe_perc[stringNumber]; - fram_soe.maximumSoe_perc[stringNumber] = pSoeValues->maximumSoe_perc[stringNumber]; + fram_soe.averageSoe_perc[s] = pSoeValues->averageSoe_perc[s]; + fram_soe.minimumSoe_perc[s] = pSoeValues->minimumSoe_perc[s]; + fram_soe.maximumSoe_perc[s] = pSoeValues->maximumSoe_perc[s]; } /* Update database and FRAM value */ - FRAM_Write(FRAM_BLOCK_ID_SOE); + FRAM_WriteData(FRAM_BLOCK_ID_SOE); } } } diff --git a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.h b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.h index aa008336..e21f4c94 100644 --- a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.h +++ b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_counting.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.c b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.c index 73a1060a..2e509d5c 100644 --- a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.c +++ b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_counting_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.h b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.h index 6ac8f1d7..ddf133a4 100644 --- a/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.h +++ b/src/app/application/algorithm/state_estimation/soe/counting/soe_counting_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_counting_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2021-05-20 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * @@ -68,7 +69,8 @@ #define SOE_CELL_ENERGY_Wh ((float)BC_ENERGY_Wh) /** Slice energy in Wh */ -#define SOE_STRING_ENERGY_Wh (BC_ENERGY_Wh * (float)(BS_NR_OF_BAT_CELLS * BS_NR_OF_PARALLEL_CELLS_PER_MODULE)) +#define SOE_STRING_ENERGY_Wh \ + (BC_ENERGY_Wh * (float)(BS_NR_OF_CELL_BLOCKS_PER_STRING * BS_NR_OF_PARALLEL_CELLS_PER_MODULE)) /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.c b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.c index d06164fa..31958080 100644 --- a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.c +++ b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_debug.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.h b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.h index 0006e8fe..607e7aed 100644 --- a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.h +++ b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_debug.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.c b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.c index 366a9034..75f69031 100644 --- a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.c +++ b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_debug_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.h b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.h index 3cdf38d8..21555441 100644 --- a/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.h +++ b/src/app/application/algorithm/state_estimation/soe/debug/soe_debug_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_debug_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/none/soe_none.c b/src/app/application/algorithm/state_estimation/soe/none/soe_none.c index 9c562f69..2292311a 100644 --- a/src/app/application/algorithm/state_estimation/soe/none/soe_none.c +++ b/src/app/application/algorithm/state_estimation/soe/none/soe_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_none.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/none/soe_none.h b/src/app/application/algorithm/state_estimation/soe/none/soe_none.h index de4c5c93..fe41c2d8 100644 --- a/src/app/application/algorithm/state_estimation/soe/none/soe_none.h +++ b/src/app/application/algorithm/state_estimation/soe/none/soe_none.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_none.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.c b/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.c index 6a906cde..7bdb5c2b 100644 --- a/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.c +++ b/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_none_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.h b/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.h index 0229e430..0f981bf6 100644 --- a/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.h +++ b/src/app/application/algorithm/state_estimation/soe/none/soe_none_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soe_none_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOE * diff --git a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.c b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.c index d3b5bf9f..4bec59d2 100644 --- a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.c +++ b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,9 +43,10 @@ * @file sof.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION_CONFIGURATION - * @prefix SOX + * @prefix SOF * * @brief SOX module responsible for current derating calculation * @@ -195,6 +196,8 @@ static void SOF_CalculateVoltageBasedCurrentLimit( FAS_ASSERT(pAllowedVoltageBasedCurrent != NULL_PTR); FAS_ASSERT(pConfigLimitValues != NULL_PTR); FAS_ASSERT(pCalculatedSofCurves != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: minimumCellVoltage_mV: parameter accept whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: maximumCellVoltage_mV: parameter accept whole range */ /* minimum cell voltage calculation */ if (minimumCellVoltage_mV <= pConfigLimitValues->limitLowerCellVoltage_mV) { @@ -238,6 +241,8 @@ static void SOF_CalculateTemperatureBasedCurrentLimit( FAS_ASSERT(pAllowedTemperatureBasedCurrent != NULL_PTR); FAS_ASSERT(pConfigLimitValues != NULL_PTR); FAS_ASSERT(pCalculatedSofCurves != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: minimumCellTemperature_ddegC: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: maximumCellTemperature_ddegC: parameter accepts whole range */ SOF_CURRENT_LIMITS_s temporaryCurrentLimits = {0.0f, 0.0f, 0.0f, 0.0f}; /* Temperature low Discharge */ @@ -326,6 +331,8 @@ static void SOF_CalculateTemperatureBasedCurrentLimit( static SOF_CURRENT_LIMITS_s SOF_MinimumOfTwoSofValues( SOF_CURRENT_LIMITS_s voltageBasedLimits, SOF_CURRENT_LIMITS_s temperatureBasedLimits) { + /* AXIVION Routine Generic-MissingParameterAssert: voltageBasedLimits: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: temperatureBasedLimits: parameter accepts whole range */ SOF_CURRENT_LIMITS_s retval = {0}; retval.continuousChargeCurrent_mA = MATH_MinimumOfTwoFloats( voltageBasedLimits.continuousChargeCurrent_mA, temperatureBasedLimits.continuousChargeCurrent_mA); @@ -370,122 +377,117 @@ extern void SOF_Calculation(void) { float minDischarge_mA = FLT_MAX; float minCharge_mA = FLT_MAX; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { SOF_CURRENT_LIMITS_s voltageBasedSof = {0}; SOF_CURRENT_LIMITS_s temperatureBasedSof = {0}; /* Calculate allowed current if string is connected */ - if (true == BMS_IsStringClosed(stringNumber)) { + if (BMS_IsStringClosed(s) == true) { SOF_CalculateVoltageBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[s], + (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[s], &voltageBasedSof, &sof_recommendedCurrent, &sof_curveRecommendedOperatingCurrent); SOF_CalculateTemperatureBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[s], + (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[s], &temperatureBasedSof, &sof_recommendedCurrent, &sof_curveRecommendedOperatingCurrent); allowedCurrent = SOF_MinimumOfTwoSofValues(voltageBasedSof, temperatureBasedSof); - sof_tableSofValues.recommendedContinuousChargeCurrent_mA[stringNumber] = - allowedCurrent.continuousChargeCurrent_mA; - sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[stringNumber] = + sof_tableSofValues.recommendedContinuousChargeCurrent_mA[s] = allowedCurrent.continuousChargeCurrent_mA; + sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[s] = allowedCurrent.continuousDischargeCurrent_mA; - sof_tableSofValues.recommendedPeakChargeCurrent_mA[stringNumber] = allowedCurrent.peakChargeCurrent_mA; - sof_tableSofValues.recommendedPeakDischargeCurrent_mA[stringNumber] = - allowedCurrent.peakDischargeCurrent_mA; + sof_tableSofValues.recommendedPeakChargeCurrent_mA[s] = allowedCurrent.peakChargeCurrent_mA; + sof_tableSofValues.recommendedPeakDischargeCurrent_mA[s] = allowedCurrent.peakDischargeCurrent_mA; nrClosedStrings++; - if (minCharge_mA > sof_tableSofValues.recommendedContinuousChargeCurrent_mA[stringNumber]) { - minCharge_mA = sof_tableSofValues.recommendedContinuousChargeCurrent_mA[stringNumber]; + if (minCharge_mA > sof_tableSofValues.recommendedContinuousChargeCurrent_mA[s]) { + minCharge_mA = sof_tableSofValues.recommendedContinuousChargeCurrent_mA[s]; } - if (minDischarge_mA > sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[stringNumber]) { - minDischarge_mA = sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[stringNumber]; + if (minDischarge_mA > sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[s]) { + minDischarge_mA = sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[s]; } } else { - sof_tableSofValues.recommendedContinuousChargeCurrent_mA[stringNumber] = 0.0f; - sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[stringNumber] = 0.0f; - sof_tableSofValues.recommendedPeakChargeCurrent_mA[stringNumber] = 0.0f; - sof_tableSofValues.recommendedPeakDischargeCurrent_mA[stringNumber] = 0.0f; + sof_tableSofValues.recommendedContinuousChargeCurrent_mA[s] = 0.0f; + sof_tableSofValues.recommendedContinuousDischargeCurrent_mA[s] = 0.0f; + sof_tableSofValues.recommendedPeakChargeCurrent_mA[s] = 0.0f; + sof_tableSofValues.recommendedPeakDischargeCurrent_mA[s] = 0.0f; } #if BMS_CHECK_SOF_CURRENT_LIMITS == true /* Calculate maximum allowed current MOL level */ SOF_CalculateVoltageBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[s], + (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[s], &voltageBasedSof, &sof_maximumOperatingLimit, &sof_curveMol); SOF_CalculateTemperatureBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[s], + (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[s], &temperatureBasedSof, &sof_maximumOperatingLimit, &sof_curveMol); allowedCurrent = SOF_MinimumOfTwoSofValues(voltageBasedSof, temperatureBasedSof); - sof_tableSofValues.continuousMolChargeCurrent_mA[stringNumber] = allowedCurrent.continuousChargeCurrent_mA; - sof_tableSofValues.continuousMolDischargeCurrent_mA[stringNumber] = - allowedCurrent.continuousDischargeCurrent_mA; - sof_tableSofValues.peakMolChargeCurrent_mA[stringNumber] = allowedCurrent.peakChargeCurrent_mA; - sof_tableSofValues.peakMolDischargeCurrent_mA[stringNumber] = allowedCurrent.peakDischargeCurrent_mA; + sof_tableSofValues.continuousMolChargeCurrent_mA[s] = allowedCurrent.continuousChargeCurrent_mA; + sof_tableSofValues.continuousMolDischargeCurrent_mA[s] = allowedCurrent.continuousDischargeCurrent_mA; + sof_tableSofValues.peakMolChargeCurrent_mA[s] = allowedCurrent.peakChargeCurrent_mA; + sof_tableSofValues.peakMolDischargeCurrent_mA[s] = allowedCurrent.peakDischargeCurrent_mA; /* Calculate maximum allowed current RSL level */ SOF_CalculateVoltageBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[s], + (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[s], &voltageBasedSof, &sof_recommendedSafetyLimit, &sof_curveRsl); SOF_CalculateTemperatureBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[s], + (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[s], &temperatureBasedSof, &sof_recommendedSafetyLimit, &sof_curveRsl); allowedCurrent = SOF_MinimumOfTwoSofValues(voltageBasedSof, temperatureBasedSof); - sof_tableSofValues.continuousRslChargeCurrent_mA[stringNumber] = allowedCurrent.continuousChargeCurrent_mA; - sof_tableSofValues.continuousRslDischargeCurrent_mA[stringNumber] = - allowedCurrent.continuousDischargeCurrent_mA; - sof_tableSofValues.peakRslChargeCurrent_mA[stringNumber] = allowedCurrent.peakChargeCurrent_mA; - sof_tableSofValues.peakRslDischargeCurrent_mA[stringNumber] = allowedCurrent.peakDischargeCurrent_mA; + sof_tableSofValues.continuousRslChargeCurrent_mA[s] = allowedCurrent.continuousChargeCurrent_mA; + sof_tableSofValues.continuousRslDischargeCurrent_mA[s] = allowedCurrent.continuousDischargeCurrent_mA; + sof_tableSofValues.peakRslChargeCurrent_mA[s] = allowedCurrent.peakChargeCurrent_mA; + sof_tableSofValues.peakRslDischargeCurrent_mA[s] = allowedCurrent.peakDischargeCurrent_mA; /* Calculate maximum allowed current MSL level */ SOF_CalculateVoltageBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumCellVoltage_mV[s], + (float)sof_tableMinimumMaximumValues.maximumCellVoltage_mV[s], &voltageBasedSof, &sof_configMaximumSafetyLimit, &sof_curveMsl); SOF_CalculateTemperatureBasedCurrentLimit( - (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[stringNumber], - (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[stringNumber], + (float)sof_tableMinimumMaximumValues.minimumTemperature_ddegC[s], + (float)sof_tableMinimumMaximumValues.maximumTemperature_ddegC[s], &temperatureBasedSof, &sof_configMaximumSafetyLimit, &sof_curveMsl); allowedCurrent = SOF_MinimumOfTwoSofValues(voltageBasedSof, temperatureBasedSof); - sof_tableSofValues.continuousMslChargeCurrent_mA[stringNumber] = allowedCurrent.continuousChargeCurrent_mA; - sof_tableSofValues.continuousMslDischargeCurrent_mA[stringNumber] = - allowedCurrent.continuousDischargeCurrent_mA; - sof_tableSofValues.peakMslChargeCurrent_mA[stringNumber] = allowedCurrent.peakChargeCurrent_mA; - sof_tableSofValues.peakMslDischargeCurrent_mA[stringNumber] = allowedCurrent.peakDischargeCurrent_mA; + sof_tableSofValues.continuousMslChargeCurrent_mA[s] = allowedCurrent.continuousChargeCurrent_mA; + sof_tableSofValues.continuousMslDischargeCurrent_mA[s] = allowedCurrent.continuousDischargeCurrent_mA; + sof_tableSofValues.peakMslChargeCurrent_mA[s] = allowedCurrent.peakChargeCurrent_mA; + sof_tableSofValues.peakMslDischargeCurrent_mA[s] = allowedCurrent.peakDischargeCurrent_mA; #else /* BMS_CHECK_SOF_CURRENT_LIMITS == false */ - sof_tableSofValues.continuousMolChargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_CHARGE_MOL_mA; - sof_tableSofValues.continuousMolDischargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_DISCHARGE_MOL_mA; - sof_tableSofValues.peakMolChargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_CHARGE_MOL_mA; - sof_tableSofValues.peakMolDischargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_DISCHARGE_MOL_mA; - - sof_tableSofValues.continuousRslChargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_CHARGE_RSL_mA; - sof_tableSofValues.continuousRslDischargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_DISCHARGE_RSL_mA; - sof_tableSofValues.peakRslChargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_CHARGE_RSL_mA; - sof_tableSofValues.peakRslDischargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_DISCHARGE_RSL_mA; - - sof_tableSofValues.continuousMslChargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_CHARGE_MSL_mA; - sof_tableSofValues.continuousMslDischargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_DISCHARGE_MSL_mA; - sof_tableSofValues.peakMslChargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_CHARGE_MSL_mA; - sof_tableSofValues.peakMslDischargeCurrent_mA[stringNumber] = BC_CURRENT_MAX_DISCHARGE_MSL_mA; + sof_tableSofValues.continuousMolChargeCurrent_mA[s] = BC_CURRENT_MAX_CHARGE_MOL_mA; + sof_tableSofValues.continuousMolDischargeCurrent_mA[s] = BC_CURRENT_MAX_DISCHARGE_MOL_mA; + sof_tableSofValues.peakMolChargeCurrent_mA[s] = BC_CURRENT_MAX_CHARGE_MOL_mA; + sof_tableSofValues.peakMolDischargeCurrent_mA[s] = BC_CURRENT_MAX_DISCHARGE_MOL_mA; + + sof_tableSofValues.continuousRslChargeCurrent_mA[s] = BC_CURRENT_MAX_CHARGE_RSL_mA; + sof_tableSofValues.continuousRslDischargeCurrent_mA[s] = BC_CURRENT_MAX_DISCHARGE_RSL_mA; + sof_tableSofValues.peakRslChargeCurrent_mA[s] = BC_CURRENT_MAX_CHARGE_RSL_mA; + sof_tableSofValues.peakRslDischargeCurrent_mA[s] = BC_CURRENT_MAX_DISCHARGE_RSL_mA; + + sof_tableSofValues.continuousMslChargeCurrent_mA[s] = BC_CURRENT_MAX_CHARGE_MSL_mA; + sof_tableSofValues.continuousMslDischargeCurrent_mA[s] = BC_CURRENT_MAX_DISCHARGE_MSL_mA; + sof_tableSofValues.peakMslChargeCurrent_mA[s] = BC_CURRENT_MAX_CHARGE_MSL_mA; + sof_tableSofValues.peakMslDischargeCurrent_mA[s] = BC_CURRENT_MAX_DISCHARGE_MSL_mA; #endif /* BMS_CHECK_SOF_CURRENT_LIMITS == true */ } diff --git a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.h b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.h index 77ff7858..c9b805da 100644 --- a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.h +++ b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,9 +43,10 @@ * @file sof.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION - * @prefix SOX + * @prefix SOF * * @brief Header for SOX module, responsible for current derating calculation * @@ -62,7 +63,7 @@ * struct definition for 4 different values: in two current directions (charge, * discharge) for two use cases (peak and continuous) */ -typedef struct SOF_CURRENT_LIMITS { +typedef struct { float continuousChargeCurrent_mA; /*!< maximum current for continues charging */ float peakChargeCurrent_mA; /*!< maximum current for peak charging */ float continuousDischargeCurrent_mA; /*!< maximum current for continues discharging */ @@ -73,7 +74,7 @@ typedef struct SOF_CURRENT_LIMITS { * struct definition for calculating the linear SOF curve. The SOF curve is * voltage, temperature and charge/discharge dependent. */ -typedef struct SOF_CURVE { +typedef struct { float slopeLowTemperatureDischarge; /*!< low temperature dependent derating slope for discharge current */ float offsetLowTemperatureDischarge; /*!< discharge current offset for low temperature dependent derating */ float slopeHighTemperatureDischarge; /*!< high temperature dependent derating slope for discharge current */ diff --git a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.c b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.c index 3eb7843c..74bf704a 100644 --- a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.c +++ b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sof_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOF * diff --git a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.h b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.h index 1d05e027..a5c8e21b 100644 --- a/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.h +++ b/src/app/application/algorithm/state_estimation/sof/trapezoid/sof_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sof_cfg.h * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION_CONFIGURATION * @prefix SOF * @@ -318,7 +319,7 @@ /** * structure for configuration of SoF Calculation */ -typedef struct SOF_CONFIG { +typedef struct { /** Current derating limits @{ */ float maximumDischargeCurrent_mA; float maximumChargeCurrent_mA; diff --git a/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.c b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.c index 4cfc4133..6ec4254e 100644 --- a/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.c +++ b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soh_debug.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOH * @@ -65,5 +66,22 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ +extern void SOH_Init(DATA_BLOCK_SOX_s *pSohValues, uint8_t stringNumber) { + FAS_ASSERT(pSohValues != NULL_PTR); + FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); + if (stringNumber < BS_NR_OF_STRINGS) { + pSohValues->averageSoh_perc[stringNumber] = 0u; + pSohValues->minimumSoh_perc[stringNumber] = 0u; + pSohValues->maximumSoh_perc[stringNumber] = 0u; + } +} + +extern void SOH_Calculation(DATA_BLOCK_SOX_s *pSohValues) { + FAS_ASSERT(pSohValues != NULL_PTR); + + pSohValues->averageSoh_perc[0u] = 50.0f; + pSohValues->minimumSoh_perc[0u] = 49.9f; + pSohValues->maximumSoh_perc[0u] = 50.1f; +} /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.h b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.h index ba8ce1a5..0fb750ce 100644 --- a/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.h +++ b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soh_debug.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOH * diff --git a/src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.c b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.c new file mode 100644 index 00000000..6b26f193 --- /dev/null +++ b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.c @@ -0,0 +1,70 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file soh_debug_cfg.c + * @author foxBMS Team + * @date 2021-12-14 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup APPLICATION + * @prefix SOH + * + * @brief SOH calculation configuration file + * + */ + +/*========== Includes =======================================================*/ +#include "soh_debug_cfg.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.h b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.h new file mode 100644 index 00000000..bfeaab52 --- /dev/null +++ b/src/app/application/algorithm/state_estimation/soh/debug/soh_debug_cfg.h @@ -0,0 +1,69 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file soh_debug_cfg.h + * @author foxBMS Team + * @date 2021-12-14 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup APPLICATION + * @prefix SOH + * + * @brief Header for SOH configuration + * + */ + +#ifndef FOXBMS__SOH_DEBUG_CFG_H_ +#define FOXBMS__SOH_DEBUG_CFG_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__SOH_DEBUG_CFG_H_ */ diff --git a/src/app/application/algorithm/state_estimation/soh/none/soh_none.c b/src/app/application/algorithm/state_estimation/soh/none/soh_none.c index edd14f44..a484d15b 100644 --- a/src/app/application/algorithm/state_estimation/soh/none/soh_none.c +++ b/src/app/application/algorithm/state_estimation/soh/none/soh_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soh_none.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOH * @@ -65,5 +66,13 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ +extern void SOH_Init(DATA_BLOCK_SOX_s *pSohValues, uint8_t stringNumber) { + FAS_ASSERT(pSohValues != NULL_PTR); + FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); +} + +extern void SOH_Calculation(DATA_BLOCK_SOX_s *pSohValues) { + FAS_ASSERT(pSohValues != NULL_PTR); +} /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/application/algorithm/state_estimation/soh/none/soh_none.h b/src/app/application/algorithm/state_estimation/soh/none/soh_none.h index b166922c..a26c091a 100644 --- a/src/app/application/algorithm/state_estimation/soh/none/soh_none.h +++ b/src/app/application/algorithm/state_estimation/soh/none/soh_none.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soh_none.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOH * diff --git a/src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.c b/src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.c new file mode 100644 index 00000000..3acb2e2a --- /dev/null +++ b/src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.c @@ -0,0 +1,70 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file soh_none_cfg.c + * @author foxBMS Team + * @date 2021-12-14 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup APPLICATION + * @prefix SOH + * + * @brief SOH calculation configuration file + * + */ + +/*========== Includes =======================================================*/ +#include "soh_none_cfg.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.h b/src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.h new file mode 100644 index 00000000..d976b913 --- /dev/null +++ b/src/app/application/algorithm/state_estimation/soh/none/soh_none_cfg.h @@ -0,0 +1,69 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file soh_none_cfg.h + * @author foxBMS Team + * @date 2021-12-14 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup APPLICATION + * @prefix SOH + * + * @brief Header for SOH configuration + * + */ + +#ifndef FOXBMS__SOH_NONE_CFG_H_ +#define FOXBMS__SOH_NONE_CFG_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__SOH_NONE_CFG_H_ */ diff --git a/src/app/application/algorithm/state_estimation/state_estimation.c b/src/app/application/algorithm/state_estimation/state_estimation.c index e00848c4..10b763bb 100644 --- a/src/app/application/algorithm/state_estimation/state_estimation.c +++ b/src/app/application/algorithm/state_estimation/state_estimation.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file state_estimation.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SE * @@ -69,21 +70,28 @@ static DATA_BLOCK_SOX_s se_tableSocAndSoeEstimation = {.header.uniqueId = DATA_B /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void SE_SocInit(bool cc_present, uint8_t stringNumber) { +extern void SE_InitializeSoc(bool ccPresent, uint8_t stringNumber) { FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); - SOC_Init(&se_tableSocAndSoeEstimation, cc_present, stringNumber); + SOC_Init(&se_tableSocAndSoeEstimation, ccPresent, stringNumber); DATA_WRITE_DATA(&se_tableSocAndSoeEstimation); } -extern void SE_SoeInit(bool ec_present, uint8_t stringNumber) { +extern void SE_InitializeSoe(bool ec_present, uint8_t stringNumber) { FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); SOE_Init(&se_tableSocAndSoeEstimation, ec_present, stringNumber); DATA_WRITE_DATA(&se_tableSocAndSoeEstimation); } -extern void SE_StateEstimations(void) { +extern void SE_InitializeSoh(uint8_t stringNumber) { + FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); + SOH_Init(&se_tableSocAndSoeEstimation, stringNumber); + DATA_WRITE_DATA(&se_tableSocAndSoeEstimation); +} + +extern void SE_RunStateEstimations(void) { SOC_Calculation(&se_tableSocAndSoeEstimation); SOE_Calculation(&se_tableSocAndSoeEstimation); + SOH_Calculation(&se_tableSocAndSoeEstimation); DATA_WRITE_DATA(&se_tableSocAndSoeEstimation); } diff --git a/src/app/application/algorithm/state_estimation/state_estimation.h b/src/app/application/algorithm/state_estimation/state_estimation.h index feb86070..ee7a844e 100644 --- a/src/app/application/algorithm/state_estimation/state_estimation.h +++ b/src/app/application/algorithm/state_estimation/state_estimation.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file state_estimation.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SE * @@ -69,22 +70,28 @@ /*========== Extern Function Prototypes =====================================*/ /** * @brief Wrapper for algorithm specific SOC initialization - * @param[in] cc_present true if current sensor present, false otherwise + * @param[in] ccPresent true if current sensor present, false otherwise * @param[in] stringNumber string addressed */ -extern void SE_SocInit(bool cc_present, uint8_t stringNumber); +extern void SE_InitializeSoc(bool ccPresent, uint8_t stringNumber); /** * @brief Wrapper for algorithm specific SOE initialization * @param[in] ec_present true if current sensor present, false otherwise * @param[in] stringNumber string addressed */ -extern void SE_SoeInit(bool ec_present, uint8_t stringNumber); +extern void SE_InitializeSoe(bool ec_present, uint8_t stringNumber); + +/** + * @brief Wrapper for algorithm specific SOH initialization + * @param[in] stringNumber string addressed + */ +extern void SE_InitializeSoh(uint8_t stringNumber); /** * @brief Main function to perform state estimations */ -extern void SE_StateEstimations(void); +extern void SE_RunStateEstimations(void); /** \defgroup state-estimation-api State Estimation API * @details This API is implemented by the state estimation functions and @@ -95,10 +102,10 @@ extern void SE_StateEstimations(void); * @brief initializes startup SOC-related values like lookup from nonvolatile * ram at startup * @param[out] pSocValues pointer to SOC database entry - * @param[in] cc_present true if current sensor present, false otherwise + * @param[in] ccPresent true if current sensor present, false otherwise * @param[in] stringNumber string addressed */ -extern void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool cc_present, uint8_t stringNumber); +extern void SOC_Init(DATA_BLOCK_SOX_s *pSocValues, bool ccPresent, uint8_t stringNumber); /** * @brief periodically called algorithm to calculate state-of-charge (SOC) @@ -129,13 +136,16 @@ extern void SOE_Calculation(DATA_BLOCK_SOX_s *pSoeValues); /** * @brief initializes startup state-of-health related values + * @param[out] pSohValues pointer to SOH database entry + * @param[in] stringNumber string addressed */ -extern void SOH_Init(void); +extern void SOH_Init(DATA_BLOCK_SOX_s *pSohValues, uint8_t stringNumber); /** * @brief calculates state-of-health (SOH) + * @param[out] pSohValues pointer to SOH database entry */ -extern void SOH_Calculation(void); +extern void SOH_Calculation(DATA_BLOCK_SOX_s *pSohValues); /** INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE se-state-estimation-api-stop-include * @} diff --git a/src/app/application/algorithm/wscript b/src/app/application/algorithm/wscript index 00e54295..a3c523dd 100644 --- a/src/app/application/algorithm/wscript +++ b/src/app/application/algorithm/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -57,6 +57,7 @@ def build(bld): os.path.join("state_estimation", "soe", soe, f"soe_{soe}_cfg.c"), os.path.join("state_estimation", "soe", soe, f"soe_{soe}.c"), os.path.join("state_estimation", "soh", soh, f"soh_{soh}.c"), + os.path.join("state_estimation", "soh", soh, f"soh_{soh}_cfg.c"), os.path.join(".", "state_estimation", "state_estimation.c"), os.path.join(".", "state_estimation", "sof", "trapezoid", "sof.c"), os.path.join(".", "state_estimation", "sof", "trapezoid", "sof_cfg.c"), @@ -77,6 +78,7 @@ def build(bld): os.path.join("..", "..", "driver", "foxmath"), os.path.join("..", "..", "driver", "fram"), os.path.join("..", "..", "driver", "sps"), + os.path.join("..", "..", "driver", "mcu"), os.path.join("..", "..", "engine", "config"), os.path.join("..", "..", "engine", "database"), os.path.join("..", "..", "engine", "diag"), diff --git a/src/app/application/bal/bal.c b/src/app/application/bal/bal.c index b94091e5..de72bc92 100644 --- a/src/app/application/bal/bal.c +++ b/src/app/application/bal/bal.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-07-31 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BAL * @@ -67,6 +68,7 @@ /*========== Extern Function Implementations ================================*/ #pragma WEAK(BAL_SaveLastStates) extern void BAL_SaveLastStates(BAL_STATE_s *pBalancingState) { + FAS_ASSERT(pBalancingState != NULL_PTR); if (pBalancingState->lastState != pBalancingState->state) { pBalancingState->lastState = pBalancingState->state; pBalancingState->lastSubstate = pBalancingState->substate; @@ -80,6 +82,7 @@ extern void BAL_SaveLastStates(BAL_STATE_s *pBalancingState) { #pragma WEAK(BAL_CheckReEntrance) extern uint8_t BAL_CheckReEntrance(BAL_STATE_s *currentState) { + FAS_ASSERT(currentState != NULL_PTR); uint8_t retval = 0; OS_EnterTaskCritical(); @@ -95,6 +98,7 @@ extern uint8_t BAL_CheckReEntrance(BAL_STATE_s *currentState) { #pragma WEAK(BAL_TransferStateRequest) extern BAL_STATE_REQUEST_e BAL_TransferStateRequest(BAL_STATE_s *currentState) { + FAS_ASSERT(currentState != NULL_PTR); BAL_STATE_REQUEST_e retval = BAL_STATE_NO_REQUEST; OS_EnterTaskCritical(); @@ -107,6 +111,7 @@ extern BAL_STATE_REQUEST_e BAL_TransferStateRequest(BAL_STATE_s *currentState) { #pragma WEAK(BAL_CheckStateRequest) extern BAL_RETURN_TYPE_e BAL_CheckStateRequest(BAL_STATE_s *pCurrentState, BAL_STATE_REQUEST_e stateRequest) { + FAS_ASSERT(pCurrentState != NULL_PTR); if (stateRequest == BAL_STATE_ERROR_REQUEST) { return BAL_OK; } @@ -141,6 +146,7 @@ extern BAL_RETURN_TYPE_e BAL_CheckStateRequest(BAL_STATE_s *pCurrentState, BAL_S #pragma WEAK(BAL_Init) extern STD_RETURN_TYPE_e BAL_Init(DATA_BLOCK_BALANCING_CONTROL_s *pControl) { + FAS_ASSERT(pControl != NULL_PTR); DATA_READ_DATA(pControl); pControl->enableBalancing = 0; DATA_WRITE_DATA(pControl); @@ -149,6 +155,7 @@ extern STD_RETURN_TYPE_e BAL_Init(DATA_BLOCK_BALANCING_CONTROL_s *pControl) { #pragma WEAK(BAL_ProcessStateUninitalized) extern void BAL_ProcessStateUninitalized(BAL_STATE_s *pCurrentState, BAL_STATE_REQUEST_e stateRequest) { + FAS_ASSERT(pCurrentState != NULL_PTR); if (stateRequest == BAL_STATE_INIT_REQUEST) { pCurrentState->timer = BAL_STATEMACH_SHORTTIME_100ms; pCurrentState->state = BAL_STATEMACH_INITIALIZATION; @@ -162,6 +169,7 @@ extern void BAL_ProcessStateUninitalized(BAL_STATE_s *pCurrentState, BAL_STATE_R #pragma WEAK(BAL_ProcessStateInitialization) extern void BAL_ProcessStateInitialization(BAL_STATE_s *currentState) { + FAS_ASSERT(currentState != NULL_PTR); currentState->timer = BAL_STATEMACH_SHORTTIME_100ms; currentState->state = BAL_STATEMACH_INITIALIZED; currentState->substate = BAL_ENTRY; @@ -169,6 +177,7 @@ extern void BAL_ProcessStateInitialization(BAL_STATE_s *currentState) { #pragma WEAK(BAL_ProcessStateInitialized) extern void BAL_ProcessStateInitialized(BAL_STATE_s *currentState) { + FAS_ASSERT(currentState != NULL_PTR); currentState->initializationFinished = STD_OK; currentState->timer = BAL_STATEMACH_SHORTTIME_100ms; currentState->state = BAL_STATEMACH_CHECK_BALANCING; diff --git a/src/app/application/bal/bal.h b/src/app/application/bal/bal.h index 38e06f28..b7027073 100644 --- a/src/app/application/bal/bal.h +++ b/src/app/application/bal/bal.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BAL * @@ -65,7 +66,7 @@ /** * States of the BAL state machine */ -typedef enum BAL_STATEMACH { +typedef enum { /* Init-Sequence */ BAL_STATEMACH_UNINITIALIZED, /*!< */ BAL_STATEMACH_INITIALIZATION, /*!< */ @@ -84,7 +85,7 @@ typedef enum BAL_STATEMACH { /** * Substates of the BAL state machine */ -typedef enum BAL_STATEMACH_SUB { +typedef enum { BAL_ENTRY, /*!< Substate entry state */ BAL_CHECK_IMBALANCES, /*!< Check if balancing has been initialized */ BAL_COMPUTE_IMBALANCES, /*!< Compute imbalances */ @@ -96,7 +97,7 @@ typedef enum BAL_STATEMACH_SUB { /** * State requests for the BAL statemachine */ -typedef enum BAL_STATE_REQUEST { +typedef enum { BAL_STATE_INIT_REQUEST, /*!< */ BAL_STATE_ERROR_REQUEST, /*!< */ BAL_STATE_NO_BALANCING_REQUEST, /*!< */ @@ -109,7 +110,7 @@ typedef enum BAL_STATE_REQUEST { /** * Possible return values when state requests are made to the BAL statemachine */ -typedef enum BAL_RETURN_TYPE { +typedef enum { BAL_OK, /*!< BAL --> ok */ BAL_BUSY_OK, /*!< BAL busy */ BAL_REQUEST_PENDING, /*!< requested to be executed */ @@ -125,7 +126,7 @@ typedef enum BAL_RETURN_TYPE { * This structure contains all the variables relevant for the BAL state machine. * The user can get the current state of the BAL state machine with this variable */ -typedef struct BAL_STATE { +typedef struct { uint16_t timer; /*!< time in ms before the state machine processes the next state, e.g. in counts of 1ms */ BAL_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */ BAL_STATEMACH_e state; /*!< state of Driver State Machine */ diff --git a/src/app/application/bal/history/bal_strategy_history.c b/src/app/application/bal/history/bal_strategy_history.c index b05be667..fee1de9e 100644 --- a/src/app/application/bal/history/bal_strategy_history.c +++ b/src/app/application/bal/history/bal_strategy_history.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_strategy_history.c * @author foxBMS Team * @date 2020-05-29 (date of creation) - * @updated 2020-07-31 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BAL * @@ -81,7 +82,7 @@ static BAL_STATE_s bal_state = { .errorRequestCounter = 0, .initializationFinished = STD_NOT_OK, .active = false, - .balancingThreshold = BAL_THRESHOLD_mV + BAL_HYSTERESIS_mV, + .balancingThreshold = BAL_DEFAULT_THRESHOLD_mV + BAL_HYSTERESIS_mV, .balancingAllowed = true, .balancingGlobalAllowed = false, }; @@ -126,7 +127,7 @@ static void BAL_ActivateBalancing(void) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { uint16_t nrBalancedCells = 0u; - for (uint8_t c = 0u; c < BS_NR_OF_BAT_CELLS; c++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_STRING; c++) { if (bal_state.balancingAllowed == false) { bal_balancing.balancingState[s][c] = 0; } else { @@ -157,7 +158,7 @@ static void BAL_ActivateBalancing(void) { static void BAL_Deactivate(void) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { - for (uint16_t c = 0u; c < BS_NR_OF_BAT_CELLS; c++) { + for (uint16_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_STRING; c++) { bal_balancing.balancingState[s][c] = 0; bal_balancing.deltaCharge_mAs[s][c] = 0; } @@ -252,7 +253,7 @@ static bool BAL_CheckImbalances(void) { bool retVal = false; for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { - for (uint16_t c = 0u; c < BS_NR_OF_BAT_CELLS; c++) { + for (uint16_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_STRING; c++) { if (bal_balancing.deltaCharge_mAs[s][c] > 0) { retVal = true; } @@ -275,7 +276,7 @@ static void BAL_ComputeImbalances(void) { voltageMin = bal_cellvoltage.cellVoltage_mV[s][0]; minVoltageIndex = 0; - for (uint16_t c = 0u; c < BS_NR_OF_BAT_CELLS; c++) { + for (uint16_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_STRING; c++) { if (bal_cellvoltage.cellVoltage_mV[s][c] <= voltageMin) { voltageMin = bal_cellvoltage.cellVoltage_mV[s][c]; minVoltageIndex = c; @@ -286,7 +287,10 @@ static void BAL_ComputeImbalances(void) { maxDOD = BC_CAPACITY_mAh * (uint32_t)((1.0f - SOC) * 3600.0f); bal_balancing.deltaCharge_mAs[s][minVoltageIndex] = 0; - for (uint16_t c = 0u; c < BS_NR_OF_BAT_CELLS; c++) { + /* update balancing threshold */ + bal_state.balancingThreshold = BAL_GetBalancingThreshold_mV() + BAL_HYSTERESIS_mV; + + for (uint16_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_STRING; c++) { if (c != minVoltageIndex) { if (bal_cellvoltage.cellVoltage_mV[s][c] >= (voltageMin + bal_state.balancingThreshold)) { SOC = SOC_GetFromVoltage(((float)(bal_cellvoltage.cellVoltage_mV[s][c])) / 1000.0f); diff --git a/src/app/application/bal/history/bal_strategy_history.h b/src/app/application/bal/history/bal_strategy_history.h index 0f30a08e..947ae810 100644 --- a/src/app/application/bal/history/bal_strategy_history.h +++ b/src/app/application/bal/history/bal_strategy_history.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_strategy_history.h * @author foxBMS Team * @date 2020-05-29 (date of creation) - * @updated 2020-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BALS * diff --git a/src/app/application/bal/none/bal_strategy_none.c b/src/app/application/bal/none/bal_strategy_none.c index 9e4b50cf..64fed584 100644 --- a/src/app/application/bal/none/bal_strategy_none.c +++ b/src/app/application/bal/none/bal_strategy_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_strategy_none.c * @author foxBMS Team * @date 2020-07-02 (date of creation) - * @updated 2020-07-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BAL * @@ -70,14 +71,12 @@ extern STD_RETURN_TYPE_e BAL_GetInitializationState(void) { return STD_OK; } -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 #pragma WEAK(BAL_SetStateRequest) extern BAL_RETURN_TYPE_e BAL_SetStateRequest(BAL_STATE_REQUEST_e stateRequest) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)stateRequest; return BAL_OK; } -#pragma diag_pop extern void BAL_Trigger(void) { } diff --git a/src/app/application/bal/none/bal_strategy_none.h b/src/app/application/bal/none/bal_strategy_none.h index 58a2fac8..e040660d 100644 --- a/src/app/application/bal/none/bal_strategy_none.h +++ b/src/app/application/bal/none/bal_strategy_none.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_strategy_none.h * @author foxBMS Team * @date 2020-08-03 (date of creation) - * @updated 2020-08-03 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BALS * diff --git a/src/app/application/bal/voltage/bal_strategy_voltage.c b/src/app/application/bal/voltage/bal_strategy_voltage.c index 4c0737b6..e71fc473 100644 --- a/src/app/application/bal/voltage/bal_strategy_voltage.c +++ b/src/app/application/bal/voltage/bal_strategy_voltage.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_strategy_voltage.c * @author foxBMS Team * @date 2020-05-29 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BAL * @@ -80,7 +81,7 @@ static BAL_STATE_s bal_state = { .errorRequestCounter = 0, .initializationFinished = STD_NOT_OK, .active = false, - .balancingThreshold = BAL_THRESHOLD_mV + BAL_HYSTERESIS_mV, + .balancingThreshold = BAL_DEFAULT_THRESHOLD_mV + BAL_HYSTERESIS_mV, .balancingAllowed = true, .balancingGlobalAllowed = false, }; @@ -127,13 +128,14 @@ static bool BAL_ActivateBalancing(void) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { int16_t min = minMax.minimumCellVoltage_mV[s]; uint16_t nrBalancedCells = 0u; - for (uint8_t c = 0u; c < BS_NR_OF_BAT_CELLS; c++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_STRING; c++) { if (cellvoltage.cellVoltage_mV[s][c] > (min + bal_state.balancingThreshold)) { bal_balancing.balancingState[s][c] = 1; finished = false; - bal_state.balancingThreshold = BAL_THRESHOLD_mV; - bal_state.active = true; - bal_balancing.enableBalancing = 1; + /* set without hysteresis so that we now balance all cells that are below the initial threshold */ + bal_state.balancingThreshold = BAL_GetBalancingThreshold_mV(); + bal_state.active = true; + bal_balancing.enableBalancing = 1; nrBalancedCells++; } else { bal_balancing.balancingState[s][c] = 0; @@ -148,7 +150,7 @@ static bool BAL_ActivateBalancing(void) { static void BAL_Deactivate(void) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { - for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { bal_balancing.balancingState[s][i] = 0; bal_balancing.deltaCharge_mAs[s][i] = 0; } @@ -217,11 +219,11 @@ static void BAL_ProcessStateBalancing(BAL_STATE_REQUEST_e state_request) { bal_state.substate = BAL_CHECK_CURRENT; DATA_BLOCK_MIN_MAX_s checkMinMax = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX}; DATA_READ_DATA(&checkMinMax); - /* stop balacing if minimum voltage is below minimum threshold or + /* stop balancing if minimum voltage is below minimum threshold or * maximum cell temperature breached upper temperature limit */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if ((checkMinMax.minimumCellVoltage_mV[stringNumber] <= BAL_LOWER_VOLTAGE_LIMIT_mV) || - (checkMinMax.maximumTemperature_ddegC[stringNumber] >= BAL_UPPER_TEMPERATURE_LIMIT_ddegC)) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if ((checkMinMax.minimumCellVoltage_mV[s] <= BAL_LOWER_VOLTAGE_LIMIT_mV) || + (checkMinMax.maximumTemperature_ddegC[s] >= BAL_UPPER_TEMPERATURE_LIMIT_ddegC)) { if (bal_state.active == true) { BAL_Deactivate(); } @@ -252,8 +254,9 @@ static void BAL_ProcessStateBalancing(BAL_STATE_REQUEST_e state_request) { bal_state.state = BAL_STATEMACH_CHECK_BALANCING; bal_state.substate = BAL_ENTRY; } else { - if (true == BAL_ActivateBalancing()) { - bal_state.balancingThreshold = BAL_THRESHOLD_mV + BAL_HYSTERESIS_mV; + if (BAL_ActivateBalancing() == true) { + /* set threshold with hysteresis in order to prevent too early reenabling of balancing */ + bal_state.balancingThreshold = BAL_GetBalancingThreshold_mV() + BAL_HYSTERESIS_mV; bal_state.state = BAL_STATEMACH_CHECK_BALANCING; bal_state.substate = BAL_ENTRY; } else { diff --git a/src/app/application/bal/voltage/bal_strategy_voltage.h b/src/app/application/bal/voltage/bal_strategy_voltage.h index 5dcc9d88..20062d92 100644 --- a/src/app/application/bal/voltage/bal_strategy_voltage.h +++ b/src/app/application/bal/voltage/bal_strategy_voltage.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_strategy_voltage.h * @author foxBMS Team * @date 2020-05-29 (date of creation) - * @updated 2020-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix BALS * diff --git a/src/app/application/bms/bms.c b/src/app/application/bms/bms.c index ed98a282..6f3e77ff 100644 --- a/src/app/application/bms/bms.c +++ b/src/app/application/bms/bms.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bms.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-10-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix BMS * @@ -61,6 +62,7 @@ #include "database.h" #include "diag.h" #include "foxmath.h" +#include "imd.h" #include "led.h" #include "meas.h" #include "os.h" @@ -325,13 +327,11 @@ static uint8_t BMS_CheckCanRequests(void) { retVal = BMS_REQ_ID_STANDBY; } else if (request.stateRequestViaCan == BMS_REQ_ID_NORMAL) { retVal = BMS_REQ_ID_NORMAL; - } - -#if BS_SEPARATE_POWER_PATHS == 1 - else if (request.stateRequestViaCan == BMS_REQ_ID_CHARGE) { /* NOLINT(readability/braces) */ + } else if (request.stateRequestViaCan == BMS_REQ_ID_CHARGE) { retVal = BMS_REQ_ID_CHARGE; + } else { + /* invalid or no request, default to BMS_REQ_ID_NOREQ (already set) */ } -#endif /* BS_SEPARATE_POWER_PATHS == 1 */ return retVal; } @@ -341,11 +341,11 @@ static void BMS_CheckOpenSenseWire(void) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Iterate over all modules */ - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { /* Iterate over all voltage sense wires: cells per module + 1 */ - for (uint8_t wire = 0u; wire < (BS_NR_OF_CELLS_PER_MODULE + 1); wire++) { + for (uint8_t wire = 0u; wire < (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1); wire++) { /* open wire detected */ - if (bms_tableOpenWire.openwire[s][(wire + (m * (BS_NR_OF_CELLS_PER_MODULE + 1))) == 1] > 0u) { + if (bms_tableOpenWire.openwire[s][(wire + (m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1))) == 1] > 0u) { openWireDetected++; /* Add additional error handling here */ @@ -354,9 +354,9 @@ static void BMS_CheckOpenSenseWire(void) { } /* Set error if open wire detected */ if (openWireDetected == 0u) { - DIAG_Handler(DIAG_ID_OPEN_WIRE, DIAG_EVENT_OK, DIAG_STRING, s); + DIAG_Handler(DIAG_ID_AFE_OPEN_WIRE, DIAG_EVENT_OK, DIAG_STRING, s); } else { - DIAG_Handler(DIAG_ID_OPEN_WIRE, DIAG_EVENT_NOT_OK, DIAG_STRING, s); + DIAG_Handler(DIAG_ID_AFE_OPEN_WIRE, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } @@ -369,8 +369,8 @@ static STD_RETURN_TYPE_e BMS_CheckPrecharge(uint8_t stringNumber, const DATA_BLO FAS_ASSERT(pPackValues != NULL_PTR); /* Only check precharging if current value and voltages are valid */ - if ((0u == pPackValues->invalidStringCurrent[stringNumber]) && - (0u == pPackValues->invalidStringVoltage[stringNumber]) && (0u == pPackValues->invalidHvBusVoltage)) { + if ((pPackValues->invalidStringCurrent[stringNumber] == 0u) && + (pPackValues->invalidStringVoltage[stringNumber] == 0u) && (pPackValues->invalidHvBusVoltage == 0u)) { /* Only current not current direction is checked */ const int32_t current_mA = MATH_AbsInt32_t(pPackValues->stringCurrent_mA[stringNumber]); const int64_t cont_prechargeVoltDiff_mV = MATH_AbsInt64_t( @@ -415,7 +415,7 @@ static STD_RETURN_TYPE_e BMS_IsBatterySystemStateOkay(void) { const bool isErrorActive = BMS_IsAnyFatalErrorFlagSet(); /** Check if a fatal error has been detected previously. If yes, check delay */ - if (true == bms_state.transitionToErrorState) { + if (bms_state.transitionToErrorState == true) { /* Decrease active delay since last call */ const uint32_t timeSinceLastCall_ms = timestamp - previousTimestamp; if (timeSinceLastCall_ms <= bms_state.remainingDelay_ms) { @@ -431,7 +431,7 @@ static STD_RETURN_TYPE_e BMS_IsBatterySystemStateOkay(void) { } } else { /* Delay is not active, check if it should be activated */ - if (true == isErrorActive) { + if (isErrorActive == true) { bms_state.transitionToErrorState = true; bms_state.remainingDelay_ms = bms_state.minimumActiveDelay_ms; } @@ -442,7 +442,7 @@ static STD_RETURN_TYPE_e BMS_IsBatterySystemStateOkay(void) { /* Check if bms statemachine should switch to error state. This is the case * if the delay is activated and the remaining delay is down to 0 */ - if ((true == bms_state.transitionToErrorState) && (0u == bms_state.remainingDelay_ms)) { + if ((bms_state.transitionToErrorState == true) && (bms_state.remainingDelay_ms == 0u)) { retVal = STD_NOT_OK; } @@ -456,7 +456,7 @@ static uint8_t BMS_GetHighestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLO for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { if ((pPackValues->stringVoltage_mV[s] >= max_stringVoltage_mV) && - (0u == pPackValues->invalidStringVoltage[s])) { + (pPackValues->invalidStringVoltage[s] == 0u)) { if (bms_state.deactivatedStrings[s] == 0u) { if (precharge == BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT) { max_stringVoltage_mV = pPackValues->stringVoltage_mV[s]; @@ -481,10 +481,10 @@ static uint8_t BMS_GetClosestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLO bool searchString = false; /* Get voltage of first closed string */ - if (0u == pPackValues->invalidStringVoltage[bms_state.firstClosedString]) { + if (pPackValues->invalidStringVoltage[bms_state.firstClosedString] == 0u) { closedStringVoltage_mV = pPackValues->stringVoltage_mV[bms_state.firstClosedString]; searchString = true; - } else if (0u == pPackValues->invalidHvBusVoltage) { + } else if (pPackValues->invalidHvBusVoltage == 0u) { /* Use high voltage bus voltage if measured string voltage is invalid */ closedStringVoltage_mV = pPackValues->highVoltageBusVoltage_mV; searchString = true; @@ -493,11 +493,11 @@ static uint8_t BMS_GetClosestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLO searchString = false; } - if (true == searchString) { + if (searchString == true) { for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { const bool isStringClosed = BMS_IsStringClosed(s); const uint8_t isStringVoltageValid = pPackValues->invalidStringVoltage[s]; - if ((false == isStringClosed) && (0u == isStringVoltageValid)) { + if ((isStringClosed == false) && (isStringVoltageValid == 0u)) { /* Only check open strings with valid voltages */ int32_t minimumVoltageDifference_mV = INT32_MAX; int32_t voltageDifference_mV = labs(closedStringVoltage_mV - pPackValues->stringVoltage_mV[s]); @@ -527,7 +527,7 @@ static uint8_t BMS_GetLowestString(BMS_CONSIDER_PRECHARGE_e precharge, DATA_BLOC for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { if ((pPackValues->stringVoltage_mV[s] <= min_stringVoltage_mV) && - (0u == pPackValues->invalidStringVoltage[s])) { + (pPackValues->invalidStringVoltage[s] == 0u)) { if (bms_state.deactivatedStrings[s] == 0u) { if (precharge == BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT) { min_stringVoltage_mV = pPackValues->stringVoltage_mV[s]; @@ -548,12 +548,12 @@ static int32_t BMS_GetStringVoltageDifference(uint8_t string, const DATA_BLOCK_P FAS_ASSERT(string < BS_NR_OF_STRINGS); FAS_ASSERT(pPackValues != NULL_PTR); int32_t voltageDifference_mV = INT32_MAX; - if ((0u == pPackValues->invalidStringVoltage[string]) && - (0u == pPackValues->invalidStringVoltage[bms_state.firstClosedString])) { + if ((pPackValues->invalidStringVoltage[string] == 0u) && + (pPackValues->invalidStringVoltage[bms_state.firstClosedString] == 0u)) { /* Calculate difference between string voltages */ voltageDifference_mV = MATH_AbsInt32_t( pPackValues->stringVoltage_mV[string] - pPackValues->stringVoltage_mV[bms_state.firstClosedString]); - } else if ((0u == pPackValues->invalidStringVoltage[string]) && (0u == pPackValues->invalidHvBusVoltage)) { + } else if ((pPackValues->invalidStringVoltage[string] == 0u) && (pPackValues->invalidHvBusVoltage == 0u)) { /* Calculate difference between string and high voltage bus voltage */ voltageDifference_mV = MATH_AbsInt32_t(pPackValues->stringVoltage_mV[string] - pPackValues->highVoltageBusVoltage_mV); @@ -567,7 +567,7 @@ static int32_t BMS_GetStringVoltageDifference(uint8_t string, const DATA_BLOCK_P static int32_t BMS_GetAverageStringCurrent(DATA_BLOCK_PACK_VALUES_s *pPackValues) { FAS_ASSERT(pPackValues != NULL_PTR); int32_t average_current = pPackValues->packCurrent_mA / (int32_t)BS_NR_OF_STRINGS; - if (1u == pPackValues->invalidPackCurrent) { + if (pPackValues->invalidPackCurrent == 1u) { average_current = INT32_MAX; } return average_current; @@ -577,7 +577,7 @@ static void BMS_UpdateBatsysState(DATA_BLOCK_PACK_VALUES_s *pPackValues) { FAS_ASSERT(pPackValues != NULL_PTR); /* Only update system state if current value is valid */ - if (0u == pPackValues->invalidPackCurrent) { + if (pPackValues->invalidPackCurrent == 0u) { if (POSITIVE_DISCHARGE_CURRENT == true) { /* Positive current values equal a discharge of the battery system */ if (pPackValues->packCurrent_mA >= BS_REST_CURRENT_mA) { /* TODO: string use pack current */ @@ -722,10 +722,15 @@ void BMS_Trigger(void) { /****************************INITIALIZED******************************/ case BMS_STATEMACH_INITIALIZED: BMS_SAVELASTSTATES(); - bms_state.initFinished = STD_OK; - bms_state.timer = BMS_STATEMACH_SHORTTIME; - bms_state.state = BMS_STATEMACH_IDLE; - bms_state.substate = BMS_ENTRY; + if (IMD_RequestInsulationMeasurement() == IMD_ILLEGAL_REQUEST) { + /* Initialization of IMD device not finished yet -> wait until this is finished before moving on */ + bms_state.timer = BMS_STATEMACH_LONGTIME; + } else { + bms_state.initFinished = STD_OK; + bms_state.timer = BMS_STATEMACH_SHORTTIME; + bms_state.state = BMS_STATEMACH_IDLE; + bms_state.substate = BMS_ENTRY; + } break; /****************************IDLE*************************************/ @@ -776,10 +781,10 @@ void BMS_Trigger(void) { bms_state.substate = BMS_OPEN_ALL_PRECHARGES; break; } else if (bms_state.substate == BMS_OPEN_ALL_PRECHARGES) { - for (stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (bs_stringsWithPrecharge[stringNumber] == BS_STRING_WITH_PRECHARGE) { - CONT_OpenPrecharge(stringNumber); - bms_state.closedPrechargeContactors[stringNumber] = 0u; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (bs_stringsWithPrecharge[s] == BS_STRING_WITH_PRECHARGE) { + CONT_OpenPrecharge(s); + bms_state.closedPrechargeContactors[s] = 0u; } } /* Now go to string opening */ @@ -831,6 +836,8 @@ void BMS_Trigger(void) { bms_state.state = BMS_STATEMACH_ERROR; bms_state.substate = BMS_ENTRY; } + } else { + FAS_ASSERT(FAS_TRAP); } break; @@ -839,9 +846,9 @@ void BMS_Trigger(void) { BMS_SAVELASTSTATES(); if (bms_state.substate == BMS_ENTRY) { BAL_SetStateRequest(BAL_STATE_ALLOWBALANCING_REQUEST); -#if LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE - nextOpenWireCheck = timestamp + LTC_STANDBY_OPEN_WIRE_PERIOD_ms; -#endif /* LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE */ +#if BS_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE + nextOpenWireCheck = timestamp + BS_STANDBY_OPEN_WIRE_PERIOD_ms; +#endif /* BS_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE */ bms_state.timer = BMS_STATEMACH_MEDIUMTIME; bms_state.substate = BMS_CHECK_ERROR_FLAGS_INTERLOCK; DATA_READ_DATA(&systemstate); @@ -893,16 +900,18 @@ void BMS_Trigger(void) { bms_state.substate = BMS_ENTRY; break; } else { -#if LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE +#if BS_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE if (nextOpenWireCheck <= timestamp) { MEAS_RequestOpenWireCheck(); - nextOpenWireCheck = timestamp + LTC_STANDBY_OPEN_WIRE_PERIOD_ms; + nextOpenWireCheck = timestamp + BS_STANDBY_OPEN_WIRE_PERIOD_ms; } -#endif /* LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE */ +#endif /* BS_STANDBY_PERIODIC_OPEN_WIRE_CHECK == TRUE */ bms_state.timer = BMS_STATEMACH_SHORTTIME; bms_state.substate = BMS_CHECK_ERROR_FLAGS; break; } + } else { + FAS_ASSERT(FAS_TRAP); } break; @@ -1075,6 +1084,8 @@ void BMS_Trigger(void) { bms_state.substate = BMS_ENTRY; } break; + } else { + FAS_ASSERT(FAS_TRAP); } break; @@ -1083,9 +1094,9 @@ void BMS_Trigger(void) { BMS_SAVELASTSTATES(); if (bms_state.substate == BMS_ENTRY) { -#if LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE - nextOpenWireCheck = timestamp + LTC_NORMAL_OPEN_WIRE_PERIOD_ms; -#endif /* LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE */ +#if BS_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE + nextOpenWireCheck = timestamp + BS_NORMAL_OPEN_WIRE_PERIOD_ms; +#endif /* BS_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE */ DATA_READ_DATA(&systemstate); if (bms_state.nextstate == BMS_STATEMACH_CHARGE) { systemstate.bmsCanState = BMS_CANSTATE_CHARGE; @@ -1116,12 +1127,12 @@ void BMS_Trigger(void) { bms_state.substate = BMS_ENTRY; break; } else { -#if LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE +#if BS_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE if (nextOpenWireCheck <= timestamp) { MEAS_RequestOpenWireCheck(); - nextOpenWireCheck = timestamp + LTC_NORMAL_OPEN_WIRE_PERIOD_ms; + nextOpenWireCheck = timestamp + BS_NORMAL_OPEN_WIRE_PERIOD_ms; } -#endif /* LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE */ +#endif /* BS_NORMAL_PERIODIC_OPEN_WIRE_CHECK == TRUE */ bms_state.timer = BMS_STATEMACH_SHORTTIME; bms_state.substate = BMS_NORMAL_CLOSE_NEXT_STRING; break; @@ -1184,6 +1195,8 @@ void BMS_Trigger(void) { bms_state.timer = BMS_STATEMACH_SHORTTIME; break; } + } else { + FAS_ASSERT(FAS_TRAP); } break; @@ -1207,7 +1220,7 @@ void BMS_Trigger(void) { bms_state.substate = BMS_CHECK_ERROR_FLAGS; break; } else if (bms_state.substate == BMS_CHECK_ERROR_FLAGS) { - if (true == DIAG_IsAnyFatalErrorSet()) { + if (DIAG_IsAnyFatalErrorSet() == true) { /* we stay already in requested state */ if (nextOpenWireCheck <= timestamp) { /* Perform open-wire check periodically */ @@ -1263,6 +1276,7 @@ extern BMS_CURRENT_FLOW_STATE_e BMS_GetBatterySystemState(void) { } extern BMS_CURRENT_FLOW_STATE_e BMS_GetCurrentFlowDirection(int32_t current_mA) { + /* AXIVION Routine Generic-MissingParameterAssert: current_mA: parameter accepts whole range */ BMS_CURRENT_FLOW_STATE_e retVal = BMS_DISCHARGING; if (POSITIVE_DISCHARGE_CURRENT == true) { diff --git a/src/app/application/bms/bms.h b/src/app/application/bms/bms.h index 8ed98517..7c60274e 100644 --- a/src/app/application/bms/bms.h +++ b/src/app/application/bms/bms.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bms.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix BMS * @@ -62,7 +63,7 @@ /*========== Macros and Definitions =========================================*/ /** Symbolic names for battery system state */ -typedef enum BMS_CURRENT_FLOW_STATE { +typedef enum { BMS_CHARGING, /*!< battery is charged */ BMS_DISCHARGING, /*!< battery is discharged */ BMS_RELAXATION, /*!< battery relaxation ongoing */ @@ -70,20 +71,20 @@ typedef enum BMS_CURRENT_FLOW_STATE { } BMS_CURRENT_FLOW_STATE_e; /** Symbolic names for busyness of the syscontrol */ -typedef enum BMS_CHECK { +typedef enum { BMS_CHECK_OK, /*!< syscontrol ok */ BMS_CHECK_BUSY, /*!< syscontrol busy */ BMS_CHECK_NOT_OK, /*!< syscontrol not ok */ } BMS_CHECK_e; /** Symbolic names to take precharge into account or not */ -typedef enum BMS_CONSIDER_PRECHARGE { +typedef enum { BMS_DO_NOT_TAKE_PRECHARGE_INTO_ACCCOUNT, /*!< do not take precharge into account */ BMS_TAKE_PRECHARGE_INTO_ACCCOUNT, /*!< do take precharge into account */ } BMS_CONSIDER_PRECHARGE_e; /** States of the SYS state machine */ -typedef enum BMS_STATEMACH { +typedef enum { /* Init-Sequence */ BMS_STATEMACH_UNINITIALIZED, BMS_STATEMACH_INITIALIZATION, @@ -101,7 +102,7 @@ typedef enum BMS_STATEMACH { } BMS_STATEMACH_e; /** CAN states of the BMS state machine */ -typedef enum BMS_CANSTATE { +typedef enum { /* Init-Sequence */ BMS_CANSTATE_UNINITIALIZED, BMS_CANSTATE_INITIALIZATION, @@ -116,7 +117,7 @@ typedef enum BMS_CANSTATE { } BMS_CANSTATE_e; /** Substates of the SYS state machine */ -typedef enum BMS_STATEMACH_SUB { +typedef enum { BMS_ENTRY, /*!< Substate entry state */ BMS_CHECK_ERROR_FLAGS_INTERLOCK, /*!< Substate check measurements after interlock closed */ BMS_INTERLOCK_CHECKED, /*!< Substate interlocked checked */ @@ -150,26 +151,24 @@ typedef enum BMS_STATEMACH_SUB { } BMS_STATEMACH_SUB_e; /** State requests for the BMS statemachine */ -typedef enum BMS_STATE_REQUEST { +typedef enum { BMS_STATE_INIT_REQUEST, /*!< request for initialization */ BMS_STATE_ERROR_REQUEST, /*!< request for ERROR state */ BMS_STATE_NO_REQUEST, /*!< dummy request for no request */ } BMS_STATE_REQUEST_e; /** - * Possible return values when state requests are made to the SYS statemachine + * Possible return values when state requests are made to the BMS statemachine */ -typedef enum BMS_RETURN_TYPE { - BMS_OK, /*!< CONT --> ok */ - BMS_BUSY_OK, /*!< CONT under load --> ok */ - BMS_REQUEST_PENDING, /*!< requested to be executed */ - BMS_ILLEGAL_REQUEST, /*!< Request can not be executed */ - BMS_ALREADY_INITIALIZED, /*!< Initialization of LTC already finished */ - BMS_ILLEGAL_TASK_TYPE, /*!< Illegal */ +typedef enum { + BMS_OK, /*!< request was successful */ + BMS_REQUEST_PENDING, /*!< error: another request is currently processed */ + BMS_ILLEGAL_REQUEST, /*!< error: request can not be executed */ + BMS_ALREADY_INITIALIZED, /*!< error: BMS statemachine already initialized */ } BMS_RETURN_TYPE_e; /** Power path type (discharge or charge) */ -typedef enum BMS_POWER_PATH_TYPE { +typedef enum { BMS_POWER_PATH_OPEN, /* contactors open */ BMS_POWER_PATH_0, /* power path */ BMS_POWER_PATH_1, /* second power path */ @@ -180,7 +179,7 @@ typedef enum BMS_POWER_PATH_TYPE { * machine. The user can get the current state of the CONT state machine with * this variable */ -typedef struct BMS_STATE { +typedef struct { uint16_t timer; /*!< time in ms before the state machine processes the next state, e.g. in counts of 1ms */ BMS_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */ BMS_STATEMACH_e state; /*!< current state of State Machine */ diff --git a/src/app/application/config/bal_cfg.c b/src/app/application/config/bal_cfg.c new file mode 100644 index 00000000..6a858212 --- /dev/null +++ b/src/app/application/config/bal_cfg.c @@ -0,0 +1,90 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file bal_cfg.c + * @author foxBMS Team + * @date 2022-02-26 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS_CONFIGURATION + * @prefix BAL + * + * @brief implementation for the configuration for the driver for balancing + * + */ + +/*========== Includes =======================================================*/ +#include "bal_cfg.h" + +#include "os.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ +/** balancing voltage threshold in mV */ +static int32_t bal_threshold_mV = BAL_DEFAULT_THRESHOLD_mV; + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ +extern void BAL_SetBalancingThreshold(int32_t threshold_mV) { + int32_t boundedThreshold_mV = threshold_mV; + if (boundedThreshold_mV > BAL_MAXIMUM_THRESHOLD_mV) { + boundedThreshold_mV = BAL_MAXIMUM_THRESHOLD_mV; + } + if (boundedThreshold_mV < BAL_MINIMUM_THRESHOLD_mV) { + boundedThreshold_mV = BAL_MINIMUM_THRESHOLD_mV; + } + OS_EnterTaskCritical(); + bal_threshold_mV = boundedThreshold_mV; + OS_ExitTaskCritical(); +} + +extern int32_t BAL_GetBalancingThreshold_mV(void) { + return bal_threshold_mV; +} + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/application/config/bal_cfg.h b/src/app/application/config/bal_cfg.h index ef254afb..0f6c9e4d 100644 --- a/src/app/application/config/bal_cfg.h +++ b/src/app/application/config/bal_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bal_cfg.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix BAL * @@ -69,8 +70,14 @@ /** BAL statemachine balancing time in 100*ms */ #define BAL_STATEMACH_BALANCINGTIME_100ms (10U) -/** BAL voltage threshold for balancing in mV*/ -#define BAL_THRESHOLD_mV (200) +/** default value for the BAL voltage threshold */ +#define BAL_DEFAULT_THRESHOLD_mV (200) + +/** maximum value that BAL voltage threshold may take */ +#define BAL_MAXIMUM_THRESHOLD_mV (5000) + +/** minimum value that BAL voltage threshold may take */ +#define BAL_MINIMUM_THRESHOLD_mV (0) /** BAL hysteresis for voltage threshold when balancing was finished in mV */ #define BAL_HYSTERESIS_mV (200) @@ -84,6 +91,17 @@ /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ +/** + * @brief set balancing threshold + * @param[in] threshold_mV threshold in mV + */ +extern void BAL_SetBalancingThreshold(int32_t threshold_mV); + +/** + * @brief get balancing threshold + * @returns balancing threshold in mV + */ +extern int32_t BAL_GetBalancingThreshold_mV(void); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/application/config/battery_cell_cfg.c b/src/app/application/config/battery_cell_cfg.c index 7ef2a979..29986f6c 100644 --- a/src/app/application/config/battery_cell_cfg.c +++ b/src/app/application/config/battery_cell_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file battery_cell_cfg.c * @author foxBMS Team * @date 2020-10-08 (date of creation) - * @updated 2020-10-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_CELL_CONFIGURATION * @prefix BC * diff --git a/src/app/application/config/battery_cell_cfg.h b/src/app/application/config/battery_cell_cfg.h index 08d82629..49757ae2 100644 --- a/src/app/application/config/battery_cell_cfg.h +++ b/src/app/application/config/battery_cell_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file battery_cell_cfg.h * @author foxBMS Team * @date 2017-03-14 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_CELL_CONFIGURATION * @prefix BC * @@ -226,7 +227,7 @@ #endif /** structure for lookup table */ -typedef struct BC_LUT { +typedef struct { const int16_t voltage_mV; /*!< cell voltage in mV */ const float value; /*!< corresponding value, can be SOC/SOE in % or capacity/energy */ } BC_LUT_s; diff --git a/src/app/application/config/battery_system_cfg.c b/src/app/application/config/battery_system_cfg.c index 51ed30ed..3627b271 100644 --- a/src/app/application/config/battery_system_cfg.c +++ b/src/app/application/config/battery_system_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file battery_system_cfg.c * @author foxBMS Team * @date 2019-12-10 (date of creation) - * @updated 2019-12-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_SYSTEM_CONFIGURATION * @prefix BS * @@ -63,8 +64,6 @@ /*========== Extern Constant and Variable Definitions =======================*/ BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS] = { BS_STRING_WITH_PRECHARGE, - BS_STRING_WITHOUT_PRECHARGE, - BS_STRING_WITH_PRECHARGE, }; /*========== Static Function Prototypes =====================================*/ diff --git a/src/app/application/config/battery_system_cfg.h b/src/app/application/config/battery_system_cfg.h index 386349d4..d9113ce0 100644 --- a/src/app/application/config/battery_system_cfg.h +++ b/src/app/application/config/battery_system_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file battery_system_cfg.h * @author foxBMS Team * @date 2019-12-10 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_SYSTEM_CONFIGURATION * @prefix BS * @@ -65,7 +66,7 @@ /*========== Macros and Definitions =========================================*/ /** Symbolic identifiers for strings with precharge */ -typedef enum BS_STRING_PRECHARGE_PRESENT { +typedef enum { BS_STRING_WITH_PRECHARGE, BS_STRING_WITHOUT_PRECHARGE, } BS_STRING_PRECHARGE_PRESENT_e; @@ -75,18 +76,28 @@ typedef enum BS_STRING_PRECHARGE_PRESENT { * Currently unused. * Added for future compatibility. */ -typedef enum BS_STRING_ID { +typedef enum { BS_STRING0 = 0u, BS_STRING1 = 1u, BS_STRING2 = 2u, BS_STRING_MAX = 3u, } BS_STRING_ID_e; -/** Define if discharge current are positive negative, default is positive */ +/** Define if discharge current is seen as positive or negative */ #define POSITIVE_DISCHARGE_CURRENT (true) -/** Number of strings in system */ -#define BS_NR_OF_STRINGS (3u) +/** */ +/** + * @ingroup CONFIG_BATTERYSYSTEM + * @brief Number of parallel strings in the battery pack + * @details For details see + * Naming Conventions. + * Implementation detail: The number of parallel strings cannot exceed + * #REPEAT_MAXIMUM_REPETITIONS unless the implementation of the + * repetition macro is adapted. + * @ptype uint + */ +#define BS_NR_OF_STRINGS (1u) /* safety check: due to implementation BS_NR_OF_STRINGS may not be larger than REPEAT_MAXIMUM_REPETITIONS */ #if (BS_NR_OF_STRINGS > REPEAT_MAXIMUM_REPETITIONS) @@ -95,36 +106,43 @@ typedef enum BS_STRING_ID { /** * @ingroup CONFIG_BATTERYSYSTEM - * @brief number of modules in battery pack + * @brief number of modules in a string + * @details For details see + * Naming Conventions. * @ptype uint */ -#define BS_NR_OF_MODULES (1u) +#define BS_NR_OF_MODULES_PER_STRING (1u) /** * @ingroup CONFIG_BATTERYSYSTEM - * @brief number of battery cells per battery module (parallel cells are - * counted as one) + * @brief number of cells per module + * @details number of cells per module, where parallel cells are + * counted as one cell block. + * For details see + * Naming Conventions. * @ptype uint */ -#define BS_NR_OF_CELLS_PER_MODULE (18u) +#define BS_NR_OF_CELL_BLOCKS_PER_MODULE (18u) /** * @ingroup CONFIG_BATTERYSYSTEM * @brief number of battery cells in a parallel cell connection per battery * module + * @details For details see + * Naming Conventions. * @ptype uint */ #define BS_NR_OF_PARALLEL_CELLS_PER_MODULE (1u) -#if BS_NR_OF_CELLS_PER_MODULE <= 12u +#if BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 12u #define BS_MAX_SUPPORTED_CELLS (12u) -#elif BS_NR_OF_CELLS_PER_MODULE <= 15u +#elif BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 15u #define BS_MAX_SUPPORTED_CELLS (15u) -#elif BS_NR_OF_CELLS_PER_MODULE <= 16u +#elif BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 16u #define BS_MAX_SUPPORTED_CELLS (16u) -#elif BS_NR_OF_CELLS_PER_MODULE <= 18u +#elif BS_NR_OF_CELL_BLOCKS_PER_MODULE <= 18u #define BS_MAX_SUPPORTED_CELLS (18u) -#elif BS_NR_OF_CELLS_PER_MODULE == 36u +#elif BS_NR_OF_CELL_BLOCKS_PER_MODULE == 36u #define BS_MAX_SUPPORTED_CELLS (36u) #else #error "Unsupported number of cells per module, higher than 18 and not 36" @@ -157,10 +175,10 @@ typedef enum BS_STRING_ID { */ #define BS_NR_OF_TEMP_SENSORS_PER_MODULE (8u) -/** number of (not parallel) battery cells in the system */ -#define BS_NR_OF_BAT_CELLS (BS_NR_OF_MODULES * BS_NR_OF_CELLS_PER_MODULE) +/** number of battery cells in the system */ +#define BS_NR_OF_CELL_BLOCKS_PER_STRING (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_CELL_BLOCKS_PER_MODULE) /** number of temperature sensors in a string */ -#define BS_NR_OF_TEMP_SENSORS_PER_STRING (BS_NR_OF_MODULES * BS_NR_OF_TEMP_SENSORS_PER_MODULE) +#define BS_NR_OF_TEMP_SENSORS_PER_STRING (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_TEMP_SENSORS_PER_MODULE) /** number of temperature sensors in the battery system */ #define BS_NR_OF_TEMP_SENSORS (BS_NR_OF_TEMP_SENSORS_PER_STRING * BS_NR_OF_STRINGS) @@ -280,21 +298,6 @@ typedef enum BS_STRING_ID { /** Number of contactors. One per string + main and precharge */ #define BS_NR_OF_CONTACTORS ((2U * BS_NR_OF_STRINGS) + BS_NR_OF_CONTACTORS_OUTSIDE_STRINGS) -/** - * @ingroup CONFIG_BATTERYSYSTEM - * @brief separation of charge and discharge power line - * @ptype select(2) - */ -#define BS_SEPARATE_POWER_PATHS (1) - -#if (BS_NR_OF_CONTACTORS > 3) && (BS_SEPARATE_POWER_PATHS == 0) -#error "Configuration mismatch: Can't use only one power path with more than 3 contactors" -#endif /* */ - -#if (BS_NR_OF_CONTACTORS < 4) && (BS_SEPARATE_POWER_PATHS == 1) -#error "Configuration mismatch: Can't use separate power path with less than 4 contactors" -#endif /* */ - /** * @brief current threshold for determing rest state of battery. If absolute * current is below this limit value the battery is resting. @@ -352,6 +355,38 @@ typedef enum BS_STRING_ID { */ #define BS_CHECK_FUSE_PLACED_IN_CHARGE_PATH (false) +/** + * \defgroup open wire check configuration + * @details If open-wire check is performed, depending on the AFE + * implementation, cell voltages and temperatures are not updated + * and thus old values can be transmitted on the CAN bus. Check + * time is dependent on module configuration and external + * capacitance. Activate open-wire check with care! See the AFE + * implementation for details. + * @{ + */ +/** enable open-wire checks during standby */ +#define BS_STANDBY_PERIODIC_OPEN_WIRE_CHECK (false) + +/** Periodic open-wire check time in STANDBY state in ms */ +#define BS_STANDBY_OPEN_WIRE_PERIOD_ms (600000) + +/** open-wire check in normal mode (set to true or false) */ +#define BS_NORMAL_PERIODIC_OPEN_WIRE_CHECK (false) + +/** Periodic open-wire check time in NORMAL state in ms */ +#define BS_NORMAL_OPEN_WIRE_PERIOD_ms (600000) + +/** open-wire check in charge mode (set to true or false) */ +#define BS_CHARGE_PERIODIC_OPEN_WIRE_CHECK (false) + +/** Periodic open-wire check time in CHARGE state in ms */ +#define BS_CHARGE_OPEN_WIRE_PERIOD_ms (600000) + +/** Periodic open-wire check time in ERROR state in ms */ +#define BS_ERROR_OPEN_WIRE_PERIOD_ms (30000) +/**@}*/ + /*========== Extern Constant and Variable Declarations ======================*/ /** Precharge presence of not for each string */ extern BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS]; diff --git a/src/app/application/config/bms_cfg.h b/src/app/application/config/bms_cfg.h index 11c9f60e..0903f9d2 100644 --- a/src/app/application/config/bms_cfg.h +++ b/src/app/application/config/bms_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bms_cfg.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix BMS * diff --git a/src/app/application/config/plausibility_cfg.h b/src/app/application/config/plausibility_cfg.h index 9a3a912e..0c89a459 100644 --- a/src/app/application/config/plausibility_cfg.h +++ b/src/app/application/config/plausibility_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file plausibility_cfg.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION_CONFIGURATION * @prefix PL * diff --git a/src/app/application/config/soa_cfg.c b/src/app/application/config/soa_cfg.c index b08b21fa..65e12a45 100644 --- a/src/app/application/config/soa_cfg.c +++ b/src/app/application/config/soa_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soa_cfg.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION_CONFIGURATION * @prefix SOA * @@ -71,7 +72,7 @@ bool SOA_IsPackCurrentLimitViolated(uint32_t current_mA, BMS_CURRENT_FLOW_STATE_e currentDirection) { bool currentLimitViolated = false; /* Only check if battery is not at rest. No overcurrent possible if battery is resting */ - if ((BMS_CHARGING == currentDirection) || (BMS_DISCHARGING == currentDirection)) { + if ((currentDirection == BMS_CHARGING) || (currentDirection == BMS_DISCHARGING)) { if (current_mA > BS_MAXIMUM_PACK_CURRENT_mA) { currentLimitViolated = true; } @@ -82,7 +83,7 @@ bool SOA_IsPackCurrentLimitViolated(uint32_t current_mA, BMS_CURRENT_FLOW_STATE_ bool SOA_IsStringCurrentLimitViolated(uint32_t current_mA, BMS_CURRENT_FLOW_STATE_e currentDirection) { bool currentLimitViolated = false; /* Only check if battery is not at rest. No overcurrent possible if battery is resting */ - if ((BMS_CHARGING == currentDirection) || (BMS_DISCHARGING == currentDirection)) { + if ((currentDirection == BMS_CHARGING) || (currentDirection == BMS_DISCHARGING)) { if (current_mA > BS_MAXIMUM_STRING_CURRENT_mA) { currentLimitViolated = true; } @@ -93,11 +94,11 @@ bool SOA_IsStringCurrentLimitViolated(uint32_t current_mA, BMS_CURRENT_FLOW_STAT bool SOA_IsCellCurrentLimitViolated(uint32_t current_mA, BMS_CURRENT_FLOW_STATE_e currentDirection) { bool currentLimitViolated = false; /* Only check if battery is not at rest. No overcurrent possible if battery is resting */ - if (BMS_CHARGING == currentDirection) { + if (currentDirection == BMS_CHARGING) { if (current_mA > (BS_NR_OF_PARALLEL_CELLS_PER_MODULE * BC_CURRENT_MAX_CHARGE_MSL_mA)) { currentLimitViolated = true; } - } else if (BMS_DISCHARGING == currentDirection) { + } else if (currentDirection == BMS_DISCHARGING) { if (current_mA > (BS_NR_OF_PARALLEL_CELLS_PER_MODULE * BC_CURRENT_MAX_DISCHARGE_MSL_mA)) { currentLimitViolated = true; } @@ -112,11 +113,11 @@ bool SOA_IsCurrentOnOpenString(BMS_CURRENT_FLOW_STATE_e currentDirection, uint8_ FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); bool currentOnOpenString = false; /* Current is flowing as soon as a current direction detected */ - if ((BMS_CHARGING == currentDirection) || (BMS_DISCHARGING == currentDirection)) { + if ((currentDirection == BMS_CHARGING) || (currentDirection == BMS_DISCHARGING)) { const bool stringClosed = BMS_IsStringClosed(stringNumber); const bool stringPrecharging = BMS_IsStringPrecharging(stringNumber); /* String appears to be open */ - if ((false == stringClosed) && (false == stringPrecharging)) { + if ((stringClosed == false) && (stringPrecharging == false)) { currentOnOpenString = true; } } diff --git a/src/app/application/config/soa_cfg.h b/src/app/application/config/soa_cfg.h index 8519e75f..ddd6da33 100644 --- a/src/app/application/config/soa_cfg.h +++ b/src/app/application/config/soa_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soa_cfg.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION_CONFIGURATION * @prefix SOA * diff --git a/src/app/application/plausibility/plausibility.c b/src/app/application/plausibility/plausibility.c index 525b0d5d..afb6387d 100644 --- a/src/app/application/plausibility/plausibility.c +++ b/src/app/application/plausibility/plausibility.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file plausibility.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix PL * @@ -86,10 +87,11 @@ extern STD_RETURN_TYPE_e PL_CheckCellvoltage( int16_t baseCellVoltage, int16_t redundancy0CellVoltage, int16_t *pCellVoltage) { - STD_RETURN_TYPE_e retval = STD_OK; - + /* AXIVION Routine Generic-MissingParameterAssert: baseCellVoltage: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: redundancy0CellVoltage: parameter accepts whole range */ /* Pointer validity check */ FAS_ASSERT(pCellVoltage != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; if (abs(baseCellVoltage - redundancy0CellVoltage) > PL_CELL_VOLTAGE_TOLERANCE_mV) { retval = STD_NOT_OK; @@ -103,6 +105,8 @@ extern STD_RETURN_TYPE_e PL_CheckCelltemperature( int16_t baseCelltemperature, int16_t redundancy0Celltemperature, int16_t *pCelltemperature) { + /* AXIVION Routine Generic-MissingParameterAssert: baseCelltemperature: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: redundancy0Celltemperature: parameter accepts whole range */ /* Pointer validity check */ FAS_ASSERT(pCelltemperature != NULL_PTR); @@ -128,11 +132,11 @@ extern STD_RETURN_TYPE_e PL_CheckVoltageSpread( /* Iterate over all cells */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { STD_RETURN_TYPE_e plausibilityIssueDetected = STD_OK; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { /* Only do check for valid voltages */ if ((pCellvoltages->invalidCellVoltage[s][m] & (0x01u << c)) == 0) { - if (abs(pCellvoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] - + if (abs(pCellvoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] - pMinMaxAverageValues->averageCellVoltage_mV[s]) > PL_CELL_VOLTAGE_SPREAD_TOLERANCE_mV) { /* Voltage difference too large */ plausibilityIssueDetected = STD_NOT_OK; @@ -160,7 +164,7 @@ extern STD_RETURN_TYPE_e PL_CheckTemperatureSpread( /* Iterate over all cells */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { STD_RETURN_TYPE_e plausibilityIssueDetected = STD_OK; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) { /* Only do check for valid temperatures */ if ((pCellTemperatures->invalidCellTemperature[s][m] & (0x01u << c)) == 0) { diff --git a/src/app/application/plausibility/plausibility.h b/src/app/application/plausibility/plausibility.h index f57aec70..33355542 100644 --- a/src/app/application/plausibility/plausibility.h +++ b/src/app/application/plausibility/plausibility.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file plausibility.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix PL * diff --git a/src/app/application/redundancy/redundancy.c b/src/app/application/redundancy/redundancy.c index 54825757..c40ab2ad 100644 --- a/src/app/application/redundancy/redundancy.c +++ b/src/app/application/redundancy/redundancy.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file redundancy.c * @author foxBMS Team * @date 2020-07-31 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix MRC * @@ -530,40 +531,38 @@ static void MRC_ValidateCurrentMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCu mrc_tablePackValues.invalidPackCurrent = 0u; /* Iterate over all strings to calculate pack current */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Check timestamp of measurement */ STD_RETURN_TYPE_e noTimeout = MRC_MeasurementUpdatedRecently( - pTableCurrentSensor->timestampCurrent[stringNumber], - pTableCurrentSensor->previousTimestampCurrent[stringNumber], + pTableCurrentSensor->timestampCurrent[s], + pTableCurrentSensor->previousTimestampCurrent[s], MRC_CURRENT_MEASUREMENT_PERIOD_TIMEOUT_ms); - (void)DIAG_CheckEvent(noTimeout, DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT, DIAG_STRING, stringNumber); + (void)DIAG_CheckEvent(noTimeout, DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT, DIAG_STRING, s); - if (STD_OK == noTimeout) { + if (noTimeout == STD_OK) { /* Check if current entry has been updated since last call */ - if (mrc_state.lastStringCurrentTimestamp[stringNumber] != - pTableCurrentSensor->timestampCurrent[stringNumber]) { - mrc_state.lastStringCurrentTimestamp[stringNumber] = - pTableCurrentSensor->timestampCurrent[stringNumber]; - mrc_tablePackValues.stringCurrent_mA[stringNumber] = pTableCurrentSensor->current_mA[stringNumber]; - if (pTableCurrentSensor->invalidCurrentMeasurement[stringNumber] == 0u) { + if (mrc_state.lastStringCurrentTimestamp[s] != pTableCurrentSensor->timestampCurrent[s]) { + mrc_state.lastStringCurrentTimestamp[s] = pTableCurrentSensor->timestampCurrent[s]; + mrc_tablePackValues.stringCurrent_mA[s] = pTableCurrentSensor->current_mA[s]; + if (pTableCurrentSensor->invalidCurrentMeasurement[s] == 0u) { /* String current measurement valid -> set valid flag */ - mrc_tablePackValues.invalidStringCurrent[stringNumber] = 0u; - (void)DIAG_Handler(DIAG_ID_CURRENT_MEASUREMENT_ERROR, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + mrc_tablePackValues.invalidStringCurrent[s] = 0u; + (void)DIAG_Handler(DIAG_ID_CURRENT_MEASUREMENT_ERROR, DIAG_EVENT_OK, DIAG_STRING, s); } else { /* String current measurement invalid -> set invalid flag */ - (void)DIAG_Handler(DIAG_ID_CURRENT_MEASUREMENT_ERROR, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); - mrc_tablePackValues.invalidStringCurrent[stringNumber] = 1u; + (void)DIAG_Handler(DIAG_ID_CURRENT_MEASUREMENT_ERROR, DIAG_EVENT_NOT_OK, DIAG_STRING, s); + mrc_tablePackValues.invalidStringCurrent[s] = 1u; } } else { /* Nothing to do. Measurement has not been updated but still within timeout */ } } else { /* Measurement timeout reached -> set string current invalid */ - mrc_tablePackValues.invalidStringCurrent[stringNumber] = 1u; + mrc_tablePackValues.invalidStringCurrent[s] = 1u; } - if (0u == mrc_tablePackValues.invalidStringCurrent[stringNumber]) { - packCurrent_mA += mrc_tablePackValues.stringCurrent_mA[stringNumber]; + if (mrc_tablePackValues.invalidStringCurrent[s] == 0u) { + packCurrent_mA += mrc_tablePackValues.stringCurrent_mA[s]; } else { /* One string current is invalid -> pack current cannot be correct. * Set pack current invalid */ @@ -580,62 +579,58 @@ static void MRC_ValidateStringVoltageMeasurement( FAS_ASSERT(pTableCurrentSensor != NULL_PTR); FAS_ASSERT(pTableCellVoltage != NULL_PTR); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Check timeout of current sensor measurement */ STD_RETURN_TYPE_e updatedMeasurement = MRC_MeasurementUpdatedRecently( - pTableCurrentSensor->timestampHighVoltage[stringNumber][0u], - pTableCurrentSensor->previousTimestampHighVoltage[stringNumber][0u], + pTableCurrentSensor->timestampHighVoltage[s][0u], + pTableCurrentSensor->previousTimestampHighVoltage[s][0u], MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms); - DIAG_CheckEvent(updatedMeasurement, DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT, DIAG_STRING, stringNumber); + DIAG_CheckEvent(updatedMeasurement, DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT, DIAG_STRING, s); /* Perform plausibility check if AFE and new current sensor measurement is valid */ - if ((STD_OK == updatedMeasurement) && - (pTableCurrentSensor->invalidHighVoltageMeasurement[stringNumber][0u] == 0u) && - (pTableCellVoltage->nrValidCellVoltages[stringNumber] == BS_NR_OF_BAT_CELLS)) { - STD_RETURN_TYPE_e voltagePlausible = PL_CheckStringVoltage( - pTableCellVoltage->packVoltage_mV[stringNumber], pTableCurrentSensor->highVoltage_mV[stringNumber][0u]); - (void)DIAG_CheckEvent(voltagePlausible, DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, DIAG_STRING, stringNumber); + if ((updatedMeasurement == STD_OK) && (pTableCurrentSensor->invalidHighVoltageMeasurement[s][0u] == 0u) && + (pTableCellVoltage->nrValidCellVoltages[s] == BS_NR_OF_CELL_BLOCKS_PER_STRING)) { + STD_RETURN_TYPE_e voltagePlausible = + PL_CheckStringVoltage(pTableCellVoltage->packVoltage_mV[s], pTableCurrentSensor->highVoltage_mV[s][0u]); + (void)DIAG_CheckEvent(voltagePlausible, DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, DIAG_STRING, s); /* Use current sensor measurement */ /* TODO: use really current sensor? Average of both? AFE measurement? */ - mrc_tablePackValues.stringVoltage_mV[stringNumber] = pTableCurrentSensor->highVoltage_mV[stringNumber][0u]; + mrc_tablePackValues.stringVoltage_mV[s] = pTableCurrentSensor->highVoltage_mV[s][0u]; - if (STD_OK == voltagePlausible) { - mrc_tablePackValues.invalidStringVoltage[stringNumber] = 0u; + if (voltagePlausible == STD_OK) { + mrc_tablePackValues.invalidStringVoltage[s] = 0u; } else { - mrc_tablePackValues.invalidStringVoltage[stringNumber] = 1u; + mrc_tablePackValues.invalidStringVoltage[s] = 1u; } } else { /* Plausibility check cannot be performed if we do not have valid * values from AFE and current sensor measurement */ - (void)DIAG_CheckEvent(STD_NOT_OK, DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, DIAG_STRING, stringNumber); + (void)DIAG_CheckEvent(STD_NOT_OK, DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, DIAG_STRING, s); - if ((STD_OK == updatedMeasurement) && - (pTableCurrentSensor->invalidHighVoltageMeasurement[stringNumber][0u] == 0u)) { + if ((updatedMeasurement == STD_OK) && (pTableCurrentSensor->invalidHighVoltageMeasurement[s][0u] == 0u)) { /* Current sensor measurement valid -> use this measurement */ - mrc_tablePackValues.stringVoltage_mV[stringNumber] = - pTableCurrentSensor->highVoltage_mV[stringNumber][0u]; - mrc_tablePackValues.invalidStringVoltage[stringNumber] = 0u; - } else if (pTableCellVoltage->nrValidCellVoltages[stringNumber] == BS_NR_OF_BAT_CELLS) { + mrc_tablePackValues.stringVoltage_mV[s] = pTableCurrentSensor->highVoltage_mV[s][0u]; + mrc_tablePackValues.invalidStringVoltage[s] = 0u; + } else if (pTableCellVoltage->nrValidCellVoltages[s] == BS_NR_OF_CELL_BLOCKS_PER_STRING) { /* AFE measurement valid -> use this measurement */ - mrc_tablePackValues.stringVoltage_mV[stringNumber] = pTableCellVoltage->packVoltage_mV[stringNumber]; - mrc_tablePackValues.invalidStringVoltage[stringNumber] = 0u; + mrc_tablePackValues.stringVoltage_mV[s] = pTableCellVoltage->packVoltage_mV[s]; + mrc_tablePackValues.invalidStringVoltage[s] = 0u; } else { /* AFE and current sensor measurement invalid -> try to construct * a valid from the number of valid cell voltages and substitute * invalid cell voltages with the average cell voltage. */ uint16_t numberInvalidCellVoltages = - (BS_NR_OF_BAT_CELLS - pTableCellVoltage->nrValidCellVoltages[stringNumber]); + (BS_NR_OF_CELL_BLOCKS_PER_STRING - pTableCellVoltage->nrValidCellVoltages[s]); - mrc_tablePackValues.stringVoltage_mV[stringNumber] = - pTableCellVoltage->packVoltage_mV[stringNumber] + - (mrc_tableMinimumMaximumValues.averageCellVoltage_mV[stringNumber] * - (int16_t)numberInvalidCellVoltages); + mrc_tablePackValues.stringVoltage_mV[s] = + pTableCellVoltage->packVoltage_mV[s] + + (mrc_tableMinimumMaximumValues.averageCellVoltage_mV[s] * (int16_t)numberInvalidCellVoltages); /* Only use this as valid value if not more than five cell voltages are invalid */ if (numberInvalidCellVoltages > MRC_ALLOWED_NUMBER_OF_INVALID_CELL_VOLTAGES) { - mrc_tablePackValues.invalidStringVoltage[stringNumber] = 1u; + mrc_tablePackValues.invalidStringVoltage[s] = 1u; } else { - mrc_tablePackValues.invalidStringVoltage[stringNumber] = 0u; + mrc_tablePackValues.invalidStringVoltage[s] = 0u; } } } @@ -651,7 +646,7 @@ static void MRC_ValidateBatteryVoltageMeasurement(void) { /* Iterate over all strings to see which strings are connected */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { bool isStringConnected = BMS_IsStringClosed(s); - if ((0u == mrc_tablePackValues.invalidStringVoltage[s]) && (true == isStringConnected)) { + if ((mrc_tablePackValues.invalidStringVoltage[s] == 0u) && (isStringConnected == true)) { /* AXIVION Disable Style MisraC2012Directive-4.1: Values start with 0, iteration is less than UINT8_MAX; overflow impossible */ sumOfStringValues_mV += mrc_tablePackValues.stringVoltage_mV[s]; numberOfValidStringVoltages++; @@ -661,7 +656,7 @@ static void MRC_ValidateBatteryVoltageMeasurement(void) { } else { /* Take average of all strings if no strings are connected */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { - if (0u == mrc_tablePackValues.invalidStringVoltage[s]) { + if (mrc_tablePackValues.invalidStringVoltage[s] == 0u) { /* AXIVION Disable Style MisraC2012Directive-4.1: Values start with 0, iteration is less than UINT8_MAX; overflow impossible */ sumOfStringValues_mV += mrc_tablePackValues.stringVoltage_mV[s]; numberOfValidStringVoltages++; @@ -685,22 +680,22 @@ static void MRC_ValidateHighVoltageBusMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *p int32_t sum_mV = 0; uint8_t validVoltages = 0u; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Check timeout of current sensor measurement */ STD_RETURN_TYPE_e updatedMeasurement = MRC_MeasurementUpdatedRecently( - pTableCurrentSensor->timestampHighVoltage[stringNumber][2u], - pTableCurrentSensor->previousTimestampHighVoltage[stringNumber][2u], + pTableCurrentSensor->timestampHighVoltage[s][2u], + pTableCurrentSensor->previousTimestampHighVoltage[s][2u], MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms); - DIAG_CheckEvent(updatedMeasurement, DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT, DIAG_STRING, stringNumber); + DIAG_CheckEvent(updatedMeasurement, DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT, DIAG_STRING, s); - const bool stringClosed = BMS_IsStringClosed(stringNumber); - const bool stringPrecharging = BMS_IsStringPrecharging(stringNumber); - if (((true == stringPrecharging) || (true == stringClosed)) && (STD_OK == updatedMeasurement)) { + const bool stringClosed = BMS_IsStringClosed(s); + const bool stringPrecharging = BMS_IsStringPrecharging(s); + if (((stringPrecharging == true) || (stringClosed == true)) && (updatedMeasurement == STD_OK)) { /* Only voltages of connected strings can be used */ - if (0u == pTableCurrentSensor->invalidHighVoltageMeasurement[stringNumber][2]) { + if (pTableCurrentSensor->invalidHighVoltageMeasurement[s][2] == 0u) { /* Measured high voltage is valid */ validVoltages++; - sum_mV += pTableCurrentSensor->highVoltage_mV[stringNumber][2]; + sum_mV += pTableCurrentSensor->highVoltage_mV[s][2]; } } } @@ -722,22 +717,22 @@ static void MRC_ValidatePowerMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurr /* Validate pack power. Will be invalidated if not all power measurement values are valid */ mrc_tablePackValues.invalidPackPower = 0u; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Check timeout of current sensor measurement */ STD_RETURN_TYPE_e noTimeout = MRC_MeasurementUpdatedRecently( - pTableCurrentSensor->timestampPower[stringNumber], - pTableCurrentSensor->previousTimestampPower[stringNumber], + pTableCurrentSensor->timestampPower[s], + pTableCurrentSensor->previousTimestampPower[s], MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms); - DIAG_CheckEvent(noTimeout, DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT, DIAG_STRING, stringNumber); + DIAG_CheckEvent(noTimeout, DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT, DIAG_STRING, s); - if (STD_OK == noTimeout) { + if (noTimeout == STD_OK) { /* Check if current sensor measurement has been updated */ - if (pTableCurrentSensor->timestampPower[stringNumber] != mrc_state.lastStringPowerTimestamp[stringNumber]) { - mrc_state.lastStringPowerTimestamp[stringNumber] = pTableCurrentSensor->timestampPower[stringNumber]; + if (pTableCurrentSensor->timestampPower[s] != mrc_state.lastStringPowerTimestamp[s]) { + mrc_state.lastStringPowerTimestamp[s] = pTableCurrentSensor->timestampPower[s]; /* Check if measurement is valid */ - if (pTableCurrentSensor->invalidPowerMeasurement[stringNumber] == 0u) { - mrc_tablePackValues.stringPower_W[stringNumber] = pTableCurrentSensor->power_W[stringNumber]; - mrc_tablePackValues.invalidStringPower[stringNumber] = 0u; + if (pTableCurrentSensor->invalidPowerMeasurement[s] == 0u) { + mrc_tablePackValues.stringPower_W[s] = pTableCurrentSensor->power_W[s]; + mrc_tablePackValues.invalidStringPower[s] = 0u; } else { /* Measurement has been updated but value is invalid -> calculate from current and string voltage */ calculatePower = true; @@ -748,28 +743,27 @@ static void MRC_ValidatePowerMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurr } } else { /* Timeout reached. Set invalid flag */ - calculatePower = true; - mrc_tablePackValues.invalidStringPower[stringNumber] = 1u; + calculatePower = true; + mrc_tablePackValues.invalidStringPower[s] = 1u; } - if ((true == calculatePower) && (0u == mrc_tablePackValues.invalidStringCurrent[stringNumber]) && - (0u == mrc_tablePackValues.invalidStringVoltage[stringNumber])) { + if ((calculatePower == true) && (mrc_tablePackValues.invalidStringCurrent[s] == 0u) && + (mrc_tablePackValues.invalidStringVoltage[s] == 0u)) { /* Power measurement is invalid, but current and string voltage measurement are valid */ int64_t stringPower_W = - ((mrc_tablePackValues.stringCurrent_mA[stringNumber] * - mrc_tablePackValues.stringVoltage_mV[stringNumber]) / + ((mrc_tablePackValues.stringCurrent_mA[s] * mrc_tablePackValues.stringVoltage_mV[s]) / (UNIT_CONVERSION_FACTOR_1000_INTEGER * /* convert: mV -> V */ UNIT_CONVERSION_FACTOR_1000_INTEGER)); /* convert: mA -> A */ - mrc_tablePackValues.stringPower_W[stringNumber] = (int32_t)stringPower_W; - mrc_tablePackValues.invalidStringPower[stringNumber] = 0u; + mrc_tablePackValues.stringPower_W[s] = (int32_t)stringPower_W; + mrc_tablePackValues.invalidStringPower[s] = 0u; } - if (0u == mrc_tablePackValues.invalidStringPower[stringNumber]) { - packPower_W += mrc_tablePackValues.stringPower_W[stringNumber]; - DIAG_Handler(DIAG_ID_POWER_MEASUREMENT_ERROR, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + if (mrc_tablePackValues.invalidStringPower[s] == 0u) { + packPower_W += mrc_tablePackValues.stringPower_W[s]; + DIAG_Handler(DIAG_ID_POWER_MEASUREMENT_ERROR, DIAG_EVENT_OK, DIAG_STRING, s); } else { /* One string power is invalid -> pack power cannot be correct. * Set pack power invalid */ mrc_tablePackValues.invalidPackPower = 1u; - DIAG_Handler(DIAG_ID_POWER_MEASUREMENT_ERROR, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_POWER_MEASUREMENT_ERROR, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } mrc_tablePackValues.packPower_W = packPower_W; @@ -794,20 +788,20 @@ static STD_RETURN_TYPE_e MRC_CalculateCellVoltageMinMaxAverage( uint16_t moduleNumberMaximum = 0u; uint16_t cellNumberMaximum = 0u; /* Iterate over all cells in each string */ - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { if ((pValidatedVoltages->invalidCellVoltage[s][m] & (0x01u << c)) == 0u) { /* Cell voltage is valid -> use this voltage for subsequent calculations */ nrValidCellvoltages++; - sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; - if (pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] < min) { - min = pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + if (pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] < min) { + min = pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; moduleNumberMinimum = m; cellNumberMinimum = c; } - if (pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] > max) { - max = pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + if (pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] > max) { + max = pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; moduleNumberMaximum = m; cellNumberMaximum = c; } @@ -852,7 +846,7 @@ static STD_RETURN_TYPE_e MRC_CalculateCellTemperatureMinMaxAverage( int16_t max = INT16_MIN; float sum_ddegC = 0.0f; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) { if ((pValidatedTemperatures->invalidCellTemperature[s][m] & (0x01u << c)) == 0u) { /* Cell temperature is valid -> use this voltage for subsequent calculations */ @@ -912,20 +906,21 @@ static STD_RETURN_TYPE_e MRC_ValidateCellVoltage( /* Iterate over all cell measurements */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { int32_t sum = 0; - for (uint8_t m = 0; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 0; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t m = 0; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 0; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { if (((pCellvoltageBase->invalidCellVoltage[s][m] & (1u << c)) == 0u) && ((pCellvoltageRedundancy0->invalidCellVoltage[s][m] & (1u << c)) == 0u)) { /* Check if cell voltage of base AND redundant measurement is valid -> do plausibility check */ - if (STD_OK == PL_CheckCellvoltage( - pCellvoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c], - pCellvoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c], - &pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c])) { + if (STD_OK == + PL_CheckCellvoltage( + pCellvoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c], + pCellvoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c], + &pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c])) { /* Clear valid flag */ pValidatedVoltages->invalidCellVoltage[s][m] = pValidatedVoltages->invalidCellVoltage[s][m] & (~(1u << c)); numberValidMeasurements++; - sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; } else { /* Set invalid flag */ noPlausibilityIssueDetected = STD_NOT_OK; @@ -935,28 +930,28 @@ static STD_RETURN_TYPE_e MRC_ValidateCellVoltage( } } else if ((pCellvoltageBase->invalidCellVoltage[s][m] & (1u << c)) == 0u) { /* Only base measurement value is valid -> use this voltage without further plausibility checks */ - pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] = - pCellvoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] = + pCellvoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; /* Reset valid flag */ pValidatedVoltages->invalidCellVoltage[s][m] = pValidatedVoltages->invalidCellVoltage[s][m] & (~(1u << c)); numberValidMeasurements++; - sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; } else if ((pCellvoltageRedundancy0->invalidCellVoltage[s][m] & (1u << c)) == 0u) { /* Only redundant measurement value is valid -> use this voltage without further plausibility checks */ - pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] = - pCellvoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] = + pCellvoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; /* Reset valid flag */ pValidatedVoltages->invalidCellVoltage[s][m] = pValidatedVoltages->invalidCellVoltage[s][m] & (~(1u << c)); numberValidMeasurements++; - sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + sum += pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; } else { /* Both, base and redundant measurement value are invalid */ /* Save average cell voltage value of base and redundant */ - pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] = - (pCellvoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c] + - pCellvoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELLS_PER_MODULE) + c]) / + pValidatedVoltages->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] = + (pCellvoltageBase->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c] + + pCellvoltageRedundancy0->cellVoltage_mV[s][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]) / 2u; /* Set invalid flag */ pValidatedVoltages->invalidCellVoltage[s][m] |= (1u << c); @@ -1007,7 +1002,7 @@ static STD_RETURN_TYPE_e MRC_ValidateCellTemperature( /* Iterate over all cell measurements */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) { if (((pCelltemperatureBase->invalidCellTemperature[s][m] & (1u << c)) == 0u) && ((pCelltemperatureRedundancy0->invalidCellTemperature[s][m] & (1u << c)) == 0u)) { @@ -1092,7 +1087,7 @@ static STD_RETURN_TYPE_e MRC_UpdateCellTemperatureValidation( extern STD_RETURN_TYPE_e MRC_Initialize(void) { STD_RETURN_TYPE_e retval = STD_NOT_OK; for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { /* Invalidate cell voltage values */ mrc_tableCellVoltages.invalidCellVoltage[s][m] = 0xFFFFFFFFFFFFFFFFULL; mrc_tableCellVoltages.validModuleVoltage[s][m] = false; diff --git a/src/app/application/redundancy/redundancy.h b/src/app/application/redundancy/redundancy.h index 9a55c3a7..f1b3e7bc 100644 --- a/src/app/application/redundancy/redundancy.h +++ b/src/app/application/redundancy/redundancy.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file redundancy.h * @author foxBMS Team * @date 2020-07-31 (date of creation) - * @updated 2021-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix MRC * @@ -113,7 +114,7 @@ /** * This structure contains all the variables relevant for the redundancy state machine. */ -typedef struct MRC_STATE { +typedef struct { uint32_t lastBaseCellvoltageTimestamp; uint32_t lastRedundancy0CellvoltageTimestamp; uint32_t lastBaseCelltemperatureTimestamp; diff --git a/src/app/application/soa/soa.c b/src/app/application/soa/soa.c index 27fee6cb..4d8c43bc 100644 --- a/src/app/application/soa/soa.c +++ b/src/app/application/soa/soa.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soa.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOA * @@ -75,65 +76,66 @@ /*========== Extern Function Implementations ================================*/ extern void SOA_CheckVoltages(DATA_BLOCK_MIN_MAX_s *pMinimumMaximumCellVoltages) { + FAS_ASSERT(pMinimumMaximumCellVoltages != NULL_PTR); DIAG_RETURNTYPE_e retvalUndervoltMSL = DIAG_HANDLER_RETURN_ERR_OCCURRED; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - int16_t voltageMax_mV = pMinimumMaximumCellVoltages->maximumCellVoltage_mV[stringNumber]; - int16_t voltageMin_mV = pMinimumMaximumCellVoltages->minimumCellVoltage_mV[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + int16_t voltageMax_mV = pMinimumMaximumCellVoltages->maximumCellVoltage_mV[s]; + int16_t voltageMin_mV = pMinimumMaximumCellVoltages->minimumCellVoltage_mV[s]; if (voltageMax_mV >= BC_VOLTAGE_MAX_MOL_mV) { /* Over voltage maximum operating limit violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (voltageMax_mV >= BC_VOLTAGE_MAX_RSL_mV) { /* Over voltage recommended safety limit violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (voltageMax_mV >= BC_VOLTAGE_MAX_MSL_mV) { /* Over voltage maximum safety limit violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } if (voltageMax_mV < BC_VOLTAGE_MAX_MSL_mV) { /* over voltage maximum safety limit NOT violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); if (voltageMax_mV < BC_VOLTAGE_MAX_RSL_mV) { /* over voltage recommended safety limit NOT violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_EVENT_OK, DIAG_STRING, s); if (voltageMax_mV < BC_VOLTAGE_MAX_MOL_mV) { /* over voltage maximum operating limit NOT violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MOL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MOL, DIAG_EVENT_OK, DIAG_STRING, s); } } } if (voltageMin_mV <= BC_VOLTAGE_MIN_MOL_mV) { /* Under voltage maximum operating limit violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (voltageMin_mV <= BC_VOLTAGE_MIN_RSL_mV) { /* Under voltage recommended safety limit violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (voltageMin_mV <= BC_VOLTAGE_MIN_MSL_mV) { /* Under voltage maximum safety limit violated */ - retvalUndervoltMSL = DIAG_Handler( - DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + retvalUndervoltMSL = + DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); /* If under voltage flag is set and deep-discharge voltage is violated */ if ((retvalUndervoltMSL == DIAG_HANDLER_RETURN_ERR_OCCURRED) && (voltageMin_mV <= BC_VOLTAGE_DEEP_DISCHARGE_mV)) { - DIAG_Handler(DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } } if (voltageMin_mV > BC_VOLTAGE_MIN_MSL_mV) { /* under voltage maximum safety limit NOT violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); if (voltageMin_mV > BC_VOLTAGE_MIN_RSL_mV) { /* under voltage recommended safety limit NOT violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_RSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_RSL, DIAG_EVENT_OK, DIAG_STRING, s); if (voltageMin_mV > BC_VOLTAGE_MIN_MOL_mV) { /* under voltage maximum operating limit NOT violated */ - DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MOL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MOL, DIAG_EVENT_OK, DIAG_STRING, s); } } } @@ -143,39 +145,38 @@ extern void SOA_CheckVoltages(DATA_BLOCK_MIN_MAX_s *pMinimumMaximumCellVoltages) extern void SOA_CheckTemperatures( DATA_BLOCK_MIN_MAX_s *pMinimumMaximumCellTemperatures, DATA_BLOCK_PACK_VALUES_s *pCurrent) { + FAS_ASSERT(pMinimumMaximumCellTemperatures != NULL_PTR); + FAS_ASSERT(pCurrent != NULL_PTR); /* Iterate over each string and check temperatures */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - int32_t i_current = pCurrent->stringCurrent_mA[stringNumber]; - int16_t temperatureMin_ddegC = pMinimumMaximumCellTemperatures->minimumTemperature_ddegC[stringNumber]; - int16_t temperatureMax_ddegC = pMinimumMaximumCellTemperatures->maximumTemperature_ddegC[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + int32_t i_current = pCurrent->stringCurrent_mA[s]; + int16_t temperatureMin_ddegC = pMinimumMaximumCellTemperatures->minimumTemperature_ddegC[s]; + int16_t temperatureMax_ddegC = pMinimumMaximumCellTemperatures->maximumTemperature_ddegC[s]; /* Over temperature check */ if (BMS_GetCurrentFlowDirection(i_current) == BMS_DISCHARGING) { /* Discharge */ if (temperatureMax_ddegC >= BC_TEMPERATURE_MAX_DISCHARGE_MOL_ddegC) { /* Over temperature maximum operating limit violated*/ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMax_ddegC >= BC_TEMPERATURE_MAX_DISCHARGE_RSL_ddegC) { /* Over temperature recommended safety limit violated*/ - DIAG_Handler( - DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMax_ddegC >= BC_TEMPERATURE_MAX_DISCHARGE_MSL_ddegC) { /* Over temperature maximum safety limit violated */ - DIAG_Handler( - DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } if (temperatureMax_ddegC < BC_TEMPERATURE_MAX_DISCHARGE_MSL_ddegC) { /* over temperature maximum safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMax_ddegC < BC_TEMPERATURE_MAX_DISCHARGE_RSL_ddegC) { /* over temperature recommended safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMax_ddegC < BC_TEMPERATURE_MAX_DISCHARGE_MOL_ddegC) { /* over temperature maximum operating limit NOT violated */ - DIAG_Handler( - DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, s); } } } @@ -184,26 +185,25 @@ extern void SOA_CheckTemperatures( /* Charge */ if (temperatureMax_ddegC >= BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC) { /* Over temperature maximum operating limit violated */ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMax_ddegC >= BC_TEMPERATURE_MAX_CHARGE_RSL_ddegC) { /* Over temperature recommended safety limit violated */ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); /* Over temperature maximum safety limit violated */ if (temperatureMax_ddegC >= BC_TEMPERATURE_MAX_CHARGE_MSL_ddegC) { - DIAG_Handler( - DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } if (temperatureMax_ddegC < BC_TEMPERATURE_MAX_CHARGE_MSL_ddegC) { /* over temperature maximum safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMax_ddegC < BC_TEMPERATURE_MAX_CHARGE_RSL_ddegC) { /* over temperature recommended safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMax_ddegC < BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC) { /* over temperature maximum operating limit NOT violated*/ - DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, s); } } } @@ -214,28 +214,25 @@ extern void SOA_CheckTemperatures( /* Discharge */ if (temperatureMin_ddegC <= BC_TEMPERATURE_MIN_DISCHARGE_MOL_ddegC) { /* Under temperature maximum operating limit violated */ - DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMin_ddegC <= BC_TEMPERATURE_MIN_DISCHARGE_RSL_ddegC) { /* Under temperature recommended safety limit violated*/ - DIAG_Handler( - DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMin_ddegC <= BC_TEMPERATURE_MIN_DISCHARGE_MSL_ddegC) { /* Under temperature maximum safety limit violated */ - DIAG_Handler( - DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } if (temperatureMin_ddegC > BC_TEMPERATURE_MIN_DISCHARGE_MSL_ddegC) { /* under temperature maximum safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMin_ddegC > BC_TEMPERATURE_MIN_DISCHARGE_RSL_ddegC) { /* under temperature recommended safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMin_ddegC > BC_TEMPERATURE_MIN_DISCHARGE_MOL_ddegC) { /* under temperature maximum operating limit NOT violated*/ - DIAG_Handler( - DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, s); } } } @@ -243,28 +240,25 @@ extern void SOA_CheckTemperatures( /* Charge */ if (temperatureMin_ddegC <= BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) { /* Under temperature maximum operating limit violated */ - DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMin_ddegC <= BC_TEMPERATURE_MIN_CHARGE_RSL_ddegC) { /* Under temperature recommended safety limit violated */ - DIAG_Handler( - DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); if (temperatureMin_ddegC <= BC_TEMPERATURE_MIN_CHARGE_MSL_ddegC) { /* Under temperature maximum safety limit violated */ - DIAG_Handler( - DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } } if (temperatureMin_ddegC > BC_TEMPERATURE_MIN_CHARGE_MSL_ddegC) { /* under temperature maximum safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMin_ddegC > BC_TEMPERATURE_MIN_CHARGE_RSL_ddegC) { /* under temperature recommended safety limit NOT violated */ - DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, DIAG_EVENT_OK, DIAG_STRING, s); if (temperatureMin_ddegC > BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) { /* under temperature maximum operating limit NOT violated*/ - DIAG_Handler( - DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, DIAG_EVENT_OK, DIAG_STRING, s); } } } @@ -278,35 +272,35 @@ extern void SOA_CheckCurrent(DATA_BLOCK_PACK_VALUES_s *pTablePackValues) { /* Iterate over each string and check current */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Only perform check if current value is valid */ - if (0u == pTablePackValues->invalidStringCurrent[s]) { + if (pTablePackValues->invalidStringCurrent[s] == 0u) { BMS_CURRENT_FLOW_STATE_e currentDirection = BMS_GetCurrentFlowDirection(pTablePackValues->stringCurrent_mA[s]); uint32_t absStringCurrent_mA = (uint32_t)abs(pTablePackValues->stringCurrent_mA[s]); /* Check various current limits depending on current direction */ bool stringOvercurrent = SOA_IsStringCurrentLimitViolated(absStringCurrent_mA, currentDirection); bool cellOvercurrent = SOA_IsCellCurrentLimitViolated(absStringCurrent_mA, currentDirection); - if (BMS_CHARGING == currentDirection) { + if (currentDirection == BMS_CHARGING) { /* Check string current limit */ - if (true == stringOvercurrent) { + if (stringOvercurrent == true) { DIAG_Handler(DIAG_ID_STRING_OVERCURRENT_CHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { DIAG_Handler(DIAG_ID_STRING_OVERCURRENT_CHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); } /* Check battery cell limit */ - if (true == cellOvercurrent) { + if (cellOvercurrent == true) { DIAG_Handler(DIAG_ID_OVERCURRENT_CHARGE_CELL_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { DIAG_Handler(DIAG_ID_OVERCURRENT_CHARGE_CELL_MSL, DIAG_EVENT_OK, DIAG_STRING, s); } - } else if (BMS_DISCHARGING == currentDirection) { + } else if (currentDirection == BMS_DISCHARGING) { /* Check string current limit */ - if (true == stringOvercurrent) { + if (stringOvercurrent == true) { DIAG_Handler(DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { DIAG_Handler(DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MSL, DIAG_EVENT_OK, DIAG_STRING, s); } /* Check battery cell limit */ - if (true == cellOvercurrent) { + if (cellOvercurrent == true) { DIAG_Handler(DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MSL, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { DIAG_Handler(DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MSL, DIAG_EVENT_OK, DIAG_STRING, s); @@ -320,7 +314,7 @@ extern void SOA_CheckCurrent(DATA_BLOCK_PACK_VALUES_s *pTablePackValues) { } /* Check if current is floating while contactors are open */ - if (false == SOA_IsCurrentOnOpenString(currentDirection, s)) { + if (SOA_IsCurrentOnOpenString(currentDirection, s) == false) { DIAG_Handler(DIAG_ID_CURRENT_ON_OPEN_STRING, DIAG_EVENT_OK, DIAG_STRING, s); } else { DIAG_Handler(DIAG_ID_CURRENT_ON_OPEN_STRING, DIAG_EVENT_NOT_OK, DIAG_STRING, s); @@ -329,19 +323,19 @@ extern void SOA_CheckCurrent(DATA_BLOCK_PACK_VALUES_s *pTablePackValues) { } /* Check pack current */ - if (0u == pTablePackValues->invalidPackCurrent) { + if (pTablePackValues->invalidPackCurrent == 0u) { BMS_CURRENT_FLOW_STATE_e currentDirection = BMS_GetCurrentFlowDirection(pTablePackValues->packCurrent_mA); uint32_t absPackCurrent_mA = (uint32_t)abs(pTablePackValues->packCurrent_mA); - bool packOvercurrent = SOA_IsCellCurrentLimitViolated(absPackCurrent_mA, currentDirection); + bool packOvercurrent = SOA_IsPackCurrentLimitViolated(absPackCurrent_mA, currentDirection); - if (BMS_CHARGING == currentDirection) { - if (true == packOvercurrent) { + if (currentDirection == BMS_CHARGING) { + if (packOvercurrent == true) { DIAG_Handler(DIAG_ID_PACK_OVERCURRENT_CHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); } else { DIAG_Handler(DIAG_ID_PACK_OVERCURRENT_CHARGE_MSL, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); } - } else if (BMS_DISCHARGING == currentDirection) { - if (true == packOvercurrent) { + } else if (currentDirection == BMS_DISCHARGING) { + if (packOvercurrent == true) { DIAG_Handler(DIAG_ID_PACK_OVERCURRENT_DISCHARGE_MSL, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); } else { DIAG_Handler(DIAG_ID_PACK_OVERCURRENT_DISCHARGE_MSL, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); diff --git a/src/app/application/soa/soa.h b/src/app/application/soa/soa.h index 6ee7c0a0..f859c585 100644 --- a/src/app/application/soa/soa.h +++ b/src/app/application/soa/soa.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file soa.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup APPLICATION * @prefix SOA * diff --git a/src/app/application/wscript b/src/app/application/wscript index 03d18755..c0a91eac 100644 --- a/src/app/application/wscript +++ b/src/app/application/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -51,6 +51,7 @@ def build(bld): source = [ os.path.join("bal", "bal.c"), os.path.join("bms", "bms.c"), + os.path.join("config", "bal_cfg.c"), os.path.join("config", "battery_cell_cfg.c"), os.path.join("config", "battery_system_cfg.c"), os.path.join("config", "soa_cfg.c"), @@ -80,12 +81,14 @@ def build(bld): os.path.join("..", "driver", "dma"), os.path.join("..", "driver", "foxmath"), os.path.join("..", "driver", "fram"), + os.path.join("..", "driver", "imd"), os.path.join("..", "driver", "led"), os.path.join("..", "driver", "meas"), os.path.join("..", "driver", "sbc"), os.path.join("..", "driver", "sbc", "fs8x_driver"), os.path.join("..", "driver", "spi"), os.path.join("..", "driver", "sps"), + os.path.join("..", "driver", "mcu"), os.path.join("..", "engine", "config"), os.path.join("..", "engine", "database"), os.path.join("..", "engine", "diag"), diff --git a/src/app/driver/adc/adc.c b/src/app/driver/adc/adc.c index e9368ac6..c14e831a 100644 --- a/src/app/driver/adc/adc.c +++ b/src/app/driver/adc/adc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file adc.c * @author foxBMS Team * @date 2019-01-07 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix ADC * @@ -85,6 +86,8 @@ static float ADC_ConvertVoltage(float adcValue_mV); /*========== Static Function Implementations ================================*/ static float ADC_ConvertVoltage(float adcValue_mV) { + /* AXIVION Routine Generic-MissingParameterAssert: adcValue_mV: parameter accepts whole range */ + /** For details to equation see Equation 28 in Technical Reference Manual SPNU563A - March 2018 page 852 */ float result_mV = ((ADC_CONV_FACTOR_12BIT * (adcValue_mV - ADC_VREFLOW_mV)) / (ADC_VREFHIGH_mV - ADC_VREFLOW_mV)) - 0.5f; diff --git a/src/app/driver/adc/adc.h b/src/app/driver/adc/adc.h index 4e22b4d3..66fe337a 100644 --- a/src/app/driver/adc/adc.h +++ b/src/app/driver/adc/adc.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file adc.h * @author foxBMS Team * @date 2019-01-07 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix ADC * diff --git a/src/app/driver/afe/api/afe.h b/src/app/driver/afe/api/afe.h index 2fa0402e..3eed40a9 100644 --- a/src/app/driver/afe/api/afe.h +++ b/src/app/driver/afe/api/afe.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file afe.h * @author foxBMS Team * @date 2020-05-08 (date of creation) - * @updated 2020-06-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix AFE * @@ -61,7 +62,7 @@ /*========== Macros and Definitions =========================================*/ /** period for open wire measurement */ -#define AFE_ERROR_OPEN_WIRE_PERIOD_ms (30000) +#define AFE_ERROR_OPEN_WIRE_PERIOD_ms (30000u) /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/driver/afe/api/afe_dma.h b/src/app/driver/afe/api/afe_dma.h index aa4493ff..3ecc6401 100644 --- a/src/app/driver/afe/api/afe_dma.h +++ b/src/app/driver/afe/api/afe_dma.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file afe_dma.h * @author foxBMS Team * @date 2020-06-18 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * diff --git a/src/app/driver/afe/api/afe_plausibility.c b/src/app/driver/afe/api/afe_plausibility.c index f115259f..95a1aff2 100644 --- a/src/app/driver/afe/api/afe_plausibility.c +++ b/src/app/driver/afe/api/afe_plausibility.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file afe_plausibility.c * @author foxBMS Team * @date 2019-01-24 (date of creation) - * @updated 2021-01-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup MODULES * @prefix AFE * diff --git a/src/app/driver/afe/api/afe_plausibility.h b/src/app/driver/afe/api/afe_plausibility.h index 97a08c83..8ea020fc 100644 --- a/src/app/driver/afe/api/afe_plausibility.h +++ b/src/app/driver/afe/api/afe_plausibility.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file afe_plausibility.h * @author foxBMS Team * @date 2019-01-24 (date of creation) - * @updated 2021-01-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup MODULES * @prefix AFE * @@ -64,7 +65,7 @@ * @details This struct has to be implemented in a variable by each AFE and * passed to #AFE_PlausibilityCheckVoltageMeasurementRange(). */ -typedef struct AFE_PLAUSIBILITY_VALUES { +typedef struct { /** largest cell voltage value that is considered plausible in mV * * This value should be the maximum operating limit of the AFE. diff --git a/src/app/driver/afe/debug/default/api/debug_default_afe.c b/src/app/driver/afe/debug/default/api/debug_default_afe.c index 8c45fb8f..4424390f 100644 --- a/src/app/driver/afe/debug/default/api/debug_default_afe.c +++ b/src/app/driver/afe/debug/default/api/debug_default_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default_afe.c * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2020-09-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix FAKE * @@ -84,60 +85,46 @@ extern bool AFE_IsFirstMeasurementCycleFinished(void) { return FAKE_IsFirstMeasurementCycleFinished(&fake_state); } -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestIoWrite(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestIoRead(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestTemperatureRead(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestBalancingFeedbackRead(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestEepromRead(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestEepromWrite(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 extern STD_RETURN_TYPE_e AFE_RequestOpenWireCheck(uint8_t string) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)string; return STD_OK; } -#pragma diag_pop /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/afe/debug/default/api/debug_default_afe.h b/src/app/driver/afe/debug/default/api/debug_default_afe.h index 57f70160..9058878a 100644 --- a/src/app/driver/afe/debug/default/api/debug_default_afe.h +++ b/src/app/driver/afe/debug/default/api/debug_default_afe.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default_afe.h * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2020-09-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FAKE * diff --git a/src/app/driver/afe/debug/default/api/debug_default_afe_dma.c b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.c index 88e7b233..ffb000d4 100644 --- a/src/app/driver/afe/debug/default/api/debug_default_afe_dma.c +++ b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default_afe_dma.c * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FAKE * @@ -66,12 +67,10 @@ /*========== Extern Function Implementations ================================*/ -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 /* Function called on DMA complete interrupts (TX and RX). */ void AFE_DmaCallback(uint8_t spiIndex) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)spiIndex; } -#pragma diag_pop /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/afe/debug/default/api/debug_default_afe_dma.h b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.h index 6aa7ca93..c84ac46c 100644 --- a/src/app/driver/afe/debug/default/api/debug_default_afe_dma.h +++ b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default_afe_dma.h * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2020-09-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FAKE * diff --git a/src/app/driver/afe/debug/default/config/debug_default_cfg.c b/src/app/driver/afe/debug/default/config/debug_default_cfg.c index 01b81859..6e714e78 100644 --- a/src/app/driver/afe/debug/default/config/debug_default_cfg.c +++ b/src/app/driver/afe/debug/default/config/debug_default_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default_cfg.c * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2020-09-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix FAKE * diff --git a/src/app/driver/afe/debug/default/config/debug_default_cfg.h b/src/app/driver/afe/debug/default/config/debug_default_cfg.h index 496b7c70..1b490bac 100644 --- a/src/app/driver/afe/debug/default/config/debug_default_cfg.h +++ b/src/app/driver/afe/debug/default/config/debug_default_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default_cfg.h * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix FAKE * diff --git a/src/app/driver/afe/debug/default/debug_default.c b/src/app/driver/afe/debug/default/debug_default.c index a693a0ab..5751ba15 100644 --- a/src/app/driver/afe/debug/default/debug_default.c +++ b/src/app/driver/afe/debug/default/debug_default.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default.c * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix FAKE * @@ -89,7 +90,7 @@ #define FAKE_FSM_LONG_TIME (10u) /** Symbolic names to check for multiple calls of #FAKE_TriggerAfe */ -typedef enum FAKE_CHECK_MULTIPLE_CALLS { +typedef enum { FAKE_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */ FAKE_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */ } FAKE_CHECK_MULTIPLE_CALLS_e; @@ -279,29 +280,29 @@ static void FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState) { uint16_t i = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - pFakeState->data.cellVoltage->packVoltage_mV[stringNumber] = FAKE_CELL_VOLTAGE_mV * BS_NR_OF_BAT_CELLS; - for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - pFakeState->data.cellVoltage->cellVoltage_mV[stringNumber][i] = FAKE_CELL_VOLTAGE_mV; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + pFakeState->data.cellVoltage->packVoltage_mV[s] = FAKE_CELL_VOLTAGE_mV * BS_NR_OF_CELL_BLOCKS_PER_STRING; + for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + pFakeState->data.cellVoltage->cellVoltage_mV[s][i] = FAKE_CELL_VOLTAGE_mV; } pFakeState->data.cellVoltage->state = 0; pFakeState->data.cellTemperature->state = 0; for (i = 0; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) { - pFakeState->data.cellTemperature->cellTemperature_ddegC[stringNumber][i] = FAKE_CELL_TEMPERATURE_ddegC; + pFakeState->data.cellTemperature->cellTemperature_ddegC[s][i] = FAKE_CELL_TEMPERATURE_ddegC; } pFakeState->data.balancingFeedback->state = 0; - for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - pFakeState->data.balancingControl->balancingState[stringNumber][i] = 0; + for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + pFakeState->data.balancingControl->balancingState[s][i] = 0; } - pFakeState->data.balancingControl->nrBalancedCells[stringNumber] = 0u; - for (i = 0; i < BS_NR_OF_MODULES; i++) { - pFakeState->data.balancingFeedback->value[stringNumber][i] = 0; + pFakeState->data.balancingControl->nrBalancedCells[s] = 0u; + for (i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { + pFakeState->data.balancingFeedback->value[s][i] = 0; } pFakeState->data.slaveControl->state = 0; - for (i = 0; i < BS_NR_OF_MODULES; i++) { + for (i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { pFakeState->data.slaveControl->ioValueIn[i] = 0; pFakeState->data.slaveControl->ioValueOut[i] = 0; pFakeState->data.slaveControl->externalTemperatureSensor[i] = 0; @@ -314,12 +315,12 @@ static void FAKE_SetFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState) { pFakeState->data.slaveControl->eepromWriteAddressToUse = 0xFFFFFFFF; pFakeState->data.allGpioVoltages->state = 0; - for (i = 0; i < (BS_NR_OF_MODULES * BS_NR_OF_GPIOS_PER_MODULE); i++) { - pFakeState->data.allGpioVoltages->gpioVoltages_mV[stringNumber][i] = 0; + for (i = 0; i < (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_GPIOS_PER_MODULE); i++) { + pFakeState->data.allGpioVoltages->gpioVoltages_mV[s][i] = 0; } - for (i = 0; i < (BS_NR_OF_MODULES * (BS_NR_OF_CELLS_PER_MODULE + 1)); i++) { - pFakeState->data.openWire->openwire[stringNumber][i] = 0; + for (i = 0; i < (BS_NR_OF_MODULES_PER_STRING * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1)); i++) { + pFakeState->data.openWire->openwire[s][i] = 0; } pFakeState->data.openWire->state = 0; } @@ -338,9 +339,9 @@ static STD_RETURN_TYPE_e FAKE_SaveFakeVoltageMeasurementData(FAKE_STATE_s *pFake FAS_ASSERT(pFakeState != NULL_PTR); STD_RETURN_TYPE_e successfullSave = STD_OK; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) { - pFakeState->data.cellVoltage->cellVoltage_mV[stringNumber][i] = FAKE_CELL_VOLTAGE_mV; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + pFakeState->data.cellVoltage->cellVoltage_mV[s][i] = FAKE_CELL_VOLTAGE_mV; } } @@ -353,9 +354,9 @@ static STD_RETURN_TYPE_e FAKE_SaveFakeTemperatureMeasurementData(FAKE_STATE_s *p FAS_ASSERT(pFakeState != NULL_PTR); STD_RETURN_TYPE_e successfullSave = STD_OK; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { for (uint16_t i = 0u; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) { - pFakeState->data.cellTemperature->cellTemperature_ddegC[stringNumber][i] = FAKE_CELL_TEMPERATURE_ddegC; + pFakeState->data.cellTemperature->cellTemperature_ddegC[s][i] = FAKE_CELL_TEMPERATURE_ddegC; } } @@ -375,7 +376,7 @@ static FAKE_FSM_STATES_e FAKE_ProcessInitializationState(FAKE_STATE_s *pFakeStat break; case FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT: - if (true == FAKE_IsFirstMeasurementCycleFinished(pFakeState)) { + if (FAKE_IsFirstMeasurementCycleFinished(pFakeState) == true) { FAKE_SetSubstate( pFakeState, FAKE_FSM_SUBSTATE_INITIALIZATION_FIRST_MEASUREMENT_FINISHED, FAKE_FSM_SHORT_TIME); } else { diff --git a/src/app/driver/afe/debug/default/debug_default.h b/src/app/driver/afe/debug/default/debug_default.h index 431095a1..9fee96c7 100644 --- a/src/app/driver/afe/debug/default/debug_default.h +++ b/src/app/driver/afe/debug/default/debug_default.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file debug_default.h * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2020-11-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FAKE * @@ -62,7 +63,7 @@ /*========== Macros and Definitions =========================================*/ /** States of the state machine */ -typedef enum FAKE_FSM_STATES { +typedef enum { FAKE_FSM_STATE_DUMMY, /*!< dummy state - always the first state */ FAKE_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */ FAKE_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */ @@ -72,7 +73,7 @@ typedef enum FAKE_FSM_STATES { } FAKE_FSM_STATES_e; /** Substates of the state machine */ -typedef enum FAKE_FSM_SUBSTATES { +typedef enum { FAKE_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */ FAKE_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */ FAKE_FSM_SUBSTATE_INITIALIZATION_FINISH_FIRST_MEASUREMENT, /*!< finish the first fake measurement */ @@ -83,7 +84,7 @@ typedef enum FAKE_FSM_SUBSTATES { } FAKE_FSM_SUBSTATES_e; /** This struct contains pointer to used data buffers */ -typedef struct FAKE_DATABASE_ENTRIES { +typedef struct { DATA_BLOCK_CELL_VOLTAGE_s *cellVoltage; /*!< cell voltage */ DATA_BLOCK_CELL_TEMPERATURE_s *cellTemperature; /*!< cell temperature */ DATA_BLOCK_BALANCING_FEEDBACK_s *balancingFeedback; /*!< balancing feedback */ @@ -94,7 +95,7 @@ typedef struct FAKE_DATABASE_ENTRIES { } FAKE_DATABASE_ENTRIES_s; /** This struct describes the state of the monitoring instance */ -typedef struct FAKE_STATE { +typedef struct { uint16_t timer; /*!< timer of the state */ uint8_t triggerEntry; /*!< trigger entry of the state */ FAKE_FSM_STATES_e nextState; /*!< next state of the FSM */ diff --git a/src/app/driver/afe/debug/default/wscript b/src/app/driver/afe/debug/default/wscript index 9bd7fab3..40f0b286 100644 --- a/src/app/driver/afe/debug/default/wscript +++ b/src/app/driver/afe/debug/default/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -63,6 +63,7 @@ def build(bld): os.path.join("..", "..", "..", "spi"), os.path.join("..", "..", "..", "ts"), os.path.join("..", "..", "..", "ts", "api"), + os.path.join("..", "..", "..", "mcu"), os.path.join("..", "..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "..", "main", "include"), os.path.join("..", "..", "..", "..", "engine", "config"), diff --git a/src/app/driver/afe/debug/wscript b/src/app/driver/afe/debug/wscript index 48d09c4a..790f660d 100644 --- a/src/app/driver/afe/debug/wscript +++ b/src/app/driver/afe/debug/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/afe/ltc/6804-1/wscript b/src/app/driver/afe/ltc/6804-1/wscript index 828a12e7..d967f7e5 100644 --- a/src/app/driver/afe/ltc/6804-1/wscript +++ b/src/app/driver/afe/ltc/6804-1/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.c b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.c index 9b11d943..f95a1a51 100644 --- a/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.c +++ b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_6806_cfg.c * @author foxBMS Team * @date 2015-02-18 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix LTC * diff --git a/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h index d1d861d5..b7ba8212 100644 --- a/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h +++ b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_6806_cfg.h * @author foxBMS Team * @date 2015-02-18 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix LTC * @@ -244,34 +245,6 @@ /** If set to 1, check if multiplexers acknowledged transmission */ #define LTC_READCOM (0) -/** - * ------------------- OPEN WIRE CHECK ------------------------ - * If open-wire check is performed cell voltages and temperatures are not - * updated and thus old values can be transmitted on the CAN bus. Check time - * is dependent on module configuration and external capacitance. Activate - * open-wire check with care! See table below for various measured open-wire - * check durations! (set to true or false) - */ -#define LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK (false) - -/** Periodic open-wire check time in STANDBY state in ms */ -#define LTC_STANDBY_OPEN_WIRE_PERIOD_ms (600000) - -/** open-wire check in normal mode (set to true or false) */ -#define LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK (false) - -/** Periodic open-wire check time in NORMAL state in ms */ -#define LTC_NORMAL_OPEN_WIRE_PERIOD_ms (600000) - -/** open-wire check in charge mode (set to true or false) */ -#define LTC_CHARGE_PERIODIC_OPEN_WIRE_CHECK (false) - -/** Periodic open-wire check time in CHARGE state in ms */ -#define LTC_CHARGE_OPEN_WIRE_PERIOD_ms (600000) - -/** Periodic open-wire check time in ERROR state in ms */ -#define LTC_ERROR_OPEN_WIRE_PERIOD_ms (30000) - /** * Number of required ADOW commands because of external C-Pin capacitance and * the respective duration to perform an open wire check for 14 modules with @@ -328,7 +301,7 @@ extern const uint8_t ltc_voltage_input_used[BS_MAX_SUPPORTED_CELLS]; * @param adcVoltage_mV voltage read from the multiplexer in mV * @return temperature value in deci °C */ -extern int16_t LTC_Convert_MuxVoltages_to_Temperatures(uint16_t adcVoltage_mV); +extern int16_t LTC_ConvertMuxVoltagesToTemperatures(uint16_t adcVoltage_mV); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/afe/ltc/6806/ltc_6806.c b/src/app/driver/afe/ltc/6806/ltc_6806.c index e0204b3a..d60427f0 100644 --- a/src/app/driver/afe/ltc/6806/ltc_6806.c +++ b/src/app/driver/afe/ltc/6806/ltc_6806.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_6806.c * @author foxBMS Team * @date 2019-09-01 (date of creation) - * @updated 2021-12-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix LTC * @@ -60,13 +61,13 @@ #include "HL_spi.h" #include "HL_system.h" +#include "afe_plausibility.h" #include "database.h" #include "diag.h" #include "io.h" #include "ltc_pec.h" -#include "pex.h" #include "os.h" -#include "afe_plausibility.h" +#include "pex.h" /*========== Macros and Definitions =========================================*/ @@ -104,10 +105,12 @@ * PEC buffer for RX and TX * @{ */ +/* AXIVION Disable Style MisraC2012-1.2: The Pec buffer must be put in the shared RAM section for performance reasons */ #pragma SET_DATA_SECTION(".sharedRAM") uint16_t ltc_RxPecBuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; uint16_t ltc_TxPecBuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; #pragma SET_DATA_SECTION() +/* AXIVION Enable Style MisraC2012-1.2: only Pec buffer needed to be in the shared RAM setcion */ /**@}*/ /** index of used cells */ @@ -230,7 +233,7 @@ static uint16_t ltc_BC_cmdADOW_PDOWN_100ms_fuelcell[4] = /*========== Static Function Prototypes =====================================*/ static void LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state); -static void LTC_Initialize_Database(LTC_STATE_s *ltc_state); +static void LTC_InitializeDatabase(LTC_STATE_s *ltc_state); static void LTC_SaveLastStates(LTC_STATE_s *ltc_state); static void LTC_StateTransition(LTC_STATE_s *ltc_state, LTC_STATEMACH_e state, uint8_t substate, uint16_t timer_ms); static void LTC_CondBasedStateTransition( @@ -266,18 +269,18 @@ static void LTC_SaveRXtoVoltagebuffer_Fuelcell( uint8_t registerSet, uint8_t stringNumber); -static STD_RETURN_TYPE_e LTC_RX_PECCheck( +static STD_RETURN_TYPE_e LTC_CheckPec( LTC_STATE_s *ltc_state, uint16_t *DataBufferSPI_RX_with_PEC, uint8_t stringNumber); -static STD_RETURN_TYPE_e LTC_RX( +static STD_RETURN_TYPE_e LTC_ReadRegister( uint16_t *Command, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength); -static uint32_t LTC_GetSPIClock(SPI_INTERFACE_CONFIG_s *pSpiInterface); +static uint32_t LTC_GetSpiClock(SPI_INTERFACE_CONFIG_s *pSpiInterface); static void LTC_SetTransferTimes(LTC_STATE_s *ltc_state); static LTC_RETURN_TYPE_e LTC_CheckStateRequest(LTC_STATE_s *ltc_state, LTC_REQUEST_s statereq); @@ -293,30 +296,30 @@ static LTC_RETURN_TYPE_e LTC_CheckStateRequest(LTC_STATE_s *ltc_state, LTC_REQUE * @param ltc_state: state of the ltc state machine * */ -static void LTC_Initialize_Database(LTC_STATE_s *ltc_state) { +static void LTC_InitializeDatabase(LTC_STATE_s *ltc_state) { uint16_t i = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { ltc_state->ltcData.cellVoltage->state = 0; - for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - ltc_state->ltcData.cellVoltage->cellVoltage_mV[stringNumber][i] = 0; - ltc_state->ltcData.openWireDetection->openWirePup[stringNumber][i] = 0; - ltc_state->ltcData.openWireDetection->openWirePdown[stringNumber][i] = 0; - ltc_state->ltcData.openWireDetection->openWireDelta[stringNumber][i] = 0; + for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + ltc_state->ltcData.cellVoltage->cellVoltage_mV[s][i] = 0; + ltc_state->ltcData.openWireDetection->openWirePup[s][i] = 0; + ltc_state->ltcData.openWireDetection->openWirePdown[s][i] = 0; + ltc_state->ltcData.openWireDetection->openWireDelta[s][i] = 0; } ltc_state->ltcData.cellTemperature->state = 0; for (i = 0; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) { - ltc_state->ltcData.cellTemperature->cellTemperature_ddegC[stringNumber][i] = 0; + ltc_state->ltcData.cellTemperature->cellTemperature_ddegC[s][i] = 0; } ltc_state->ltcData.allGpioVoltages->state = 0; - for (i = 0; i < (BS_NR_OF_MODULES * BS_NR_OF_GPIOS_PER_MODULE); i++) { - ltc_state->ltcData.allGpioVoltages->gpioVoltages_mV[stringNumber][i] = 0; + for (i = 0; i < (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_GPIOS_PER_MODULE); i++) { + ltc_state->ltcData.allGpioVoltages->gpioVoltages_mV[s][i] = 0; } - for (i = 0; i < (BS_NR_OF_MODULES * (BS_NR_OF_CELLS_PER_MODULE + 1)); i++) { - ltc_state->ltcData.openWire->openwire[stringNumber][i] = 0; + for (i = 0; i < (BS_NR_OF_MODULES_PER_STRING * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1)); i++) { + ltc_state->ltcData.openWire->openwire[s][i] = 0; } ltc_state->ltcData.openWire->state = 0; } @@ -399,30 +402,30 @@ extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber) { STD_RETURN_TYPE_e cellVoltageMeasurementValid = STD_OK; int32_t stringVoltage_mV = 0; uint16_t numberValidMeasurements = 0; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { /* ------- 1. Check open-wires ----------------- * Is cell N input not open wire && * Is cell N+1 input not open wire && * Is cell voltage valid because of previous PEC error * If so, everything okay, else set cell voltage measurement to invalid. */ - if ((ltc_state->ltcData.openWire->openwire[stringNumber][(m * (BS_NR_OF_CELLS_PER_MODULE + 1u)) + c] == - 0u) && - (ltc_state->ltcData.openWire->openwire[stringNumber][(m * (BS_NR_OF_CELLS_PER_MODULE + 1u)) + c + 1u] == - 0u) && + if ((ltc_state->ltcData.openWire + ->openwire[stringNumber][(m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1u)) + c] == 0u) && + (ltc_state->ltcData.openWire + ->openwire[stringNumber][(m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1u)) + c + 1u] == 0u) && ((ltc_state->ltcData.cellVoltage->invalidCellVoltage[stringNumber][m] & (0x01u << c)) == 0u)) { /* Cell voltage is valid -> perform minimum/maximum plausibility check */ /* ------- 2. Perform minimum/maximum measurement range check ---------- */ if (STD_OK == AFE_PlausibilityCheckVoltageMeasurementRange( ltc_state->ltcData.cellVoltage - ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELLS_PER_MODULE) + c], + ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c], ltc_plausibleCellVoltages6806)) { /* Cell voltage is valid -> calculate string voltage */ /* -------- 3. Calculate string values ------------- */ stringVoltage_mV += ltc_state->ltcData.cellVoltage - ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; numberValidMeasurements++; } else { /* Invalidate cell voltage measurement */ @@ -449,7 +452,7 @@ extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber) { extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { STD_RETURN_TYPE_e cellTemperatureMeasurementValid = STD_OK; uint16_t numberValidMeasurements = 0; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) { /* ------- 1. Check valid flag ----------------- * Is cell temperature valid because of previous PEC error @@ -494,7 +497,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { * @param ltc_state: state of the ltc state machine * */ -extern void LTC_SaveAllGPIOMeasurement(LTC_STATE_s *ltc_state) { +extern void LTC_SaveAllGpioMeasurement(LTC_STATE_s *ltc_state) { ltc_state->ltcData.allGpioVoltages->state++; DATA_WRITE_DATA(ltc_state->ltcData.allGpioVoltages); } @@ -649,7 +652,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { statereq = LTC_TransferStateRequest(ltc_state, &tmpbusID, &tmpadcMode, &tmpadcMeasCh); if (statereq.request == LTC_STATE_INIT_REQUEST) { LTC_SaveLastStates(ltc_state); - LTC_Initialize_Database(ltc_state); + LTC_InitializeDatabase(ltc_state); LTC_ResetErrorTable(ltc_state); LTC_StateTransition( ltc_state, LTC_STATEMACH_INITIALIZATION, LTC_INIT_STRING, LTC_STATEMACH_SHORTTIME); @@ -679,7 +682,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_INITIALIZATION, LTC_RE_ENTRY_INITIALIZATION, LTC_STATEMACH_DAISY_CHAIN_FIRST_INITIALIZATION_TIME, @@ -694,7 +697,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_INITIALIZATION, LTC_START_INIT_INITIALIZATION, LTC_STATEMACH_DAISY_CHAIN_SECOND_INITIALIZATION_TIME, @@ -712,7 +715,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->ltcData.rxBuffer, ltc_state->ltcData.frameLength); /* Initialize main LTC loop */ ltc_state->lastsubstate = ltc_state->substate; - DIAG_CheckEvent(retVal, DIAG_ID_LTC_SPI, DIAG_STRING, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_SPI, DIAG_STRING, ltc_state->currentString); LTC_StateTransition( ltc_state, LTC_STATEMACH_INITIALIZATION, @@ -723,7 +726,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { /* Read values written in config register, currently unused */ LTC_SaveLastStates(ltc_state); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCFG, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -772,7 +775,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, (ltc_state->commandTransferTime + LTC_FUELCELL_NORMAL_ALL_CELLS_MS), @@ -795,7 +798,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, (ltc_state->commandTransferTime + LTC_FUELCELL_NORMAL_ALL_CELLS_MS), @@ -811,7 +814,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVA_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -820,7 +823,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_B_RDCVB_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -830,13 +833,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_B_RDCVB_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 0u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVB_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -845,7 +848,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_C_RDCVC_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -855,13 +858,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_C_RDCVC_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 1u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVC_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -870,7 +873,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_D_RDCVD_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -880,13 +883,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_D_RDCVD_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 2u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVD_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -895,7 +898,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_E_RDCVE_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -905,13 +908,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_E_RDCVE_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 3u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVE_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -920,7 +923,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_F_RDCVF_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -930,13 +933,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_F_RDCVF_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 4u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVF_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -945,7 +948,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_G_RDCVG_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -955,13 +958,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_G_RDCVG_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 5u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVG_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -970,7 +973,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_H_RDCVH_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -980,13 +983,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_H_RDCVH_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 6u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVH_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -995,7 +998,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_I_RDCVI_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -1005,13 +1008,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_I_RDCVI_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 7u, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVI_Fuelcell, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1020,7 +1023,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_CondBasedStateTransition( ltc_state, retVal, - DIAG_ID_LTC_SPI, + DIAG_ID_AFE_SPI, LTC_STATEMACH_READVOLTAGE, LTC_EXIT_READVOLTAGE, (ltc_state->commandDataTransferTime + LTC_TRANSMISSION_TIMEOUT), @@ -1030,8 +1033,8 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EXIT_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); - DIAG_CheckEvent(retVal, DIAG_ID_LTC_PEC, DIAG_STRING, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + DIAG_CheckEvent(retVal, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 8u, ltc_state->currentString); @@ -1095,7 +1098,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { retVal = LTC_StartOpenWireMeasurement(ltc_state->spiSeqPtr, ltc_state->adcMode, 1); if (retVal == STD_OK) { - DIAG_Handler(DIAG_ID_LTC_SPI, DIAG_EVENT_OK, DIAG_STRING, ltc_state->requestedString); + DIAG_Handler(DIAG_ID_AFE_SPI, DIAG_EVENT_OK, DIAG_STRING, ltc_state->requestedString); LTC_StateTransition( ltc_state, @@ -1119,7 +1122,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->reusageMeasurementMode = LTC_REUSE_READVOLT_FOR_ADOW_PUP; } } else { - DIAG_Handler(DIAG_ID_LTC_SPI, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->requestedString); + DIAG_Handler(DIAG_ID_AFE_SPI, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->requestedString); LTC_StateTransition( ltc_state, LTC_STATEMACH_STARTMEAS_CONTINUE, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); } @@ -1128,7 +1131,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->reusageMeasurementMode = LTC_NOT_REUSED; /* Copy data from voltage struct into open-wire struct */ - for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { ltc_state->ltcData.openWireDetection->openWirePup[ltc_state->requestedString][i] = ltc_state->ltcData.cellVoltage->cellVoltage_mV[ltc_state->requestedString][i]; } @@ -1148,7 +1151,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { retVal = LTC_StartOpenWireMeasurement(ltc_state->spiSeqPtr, ltc_state->adcMode, 0); if (retVal == STD_OK) { - DIAG_Handler(DIAG_ID_LTC_SPI, DIAG_EVENT_OK, DIAG_STRING, ltc_state->requestedString); + DIAG_Handler(DIAG_ID_AFE_SPI, DIAG_EVENT_OK, DIAG_STRING, ltc_state->requestedString); LTC_StateTransition( ltc_state, @@ -1172,7 +1175,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->reusageMeasurementMode = LTC_REUSE_READVOLT_FOR_ADOW_PDOWN; } } else { - DIAG_Handler(DIAG_ID_LTC_SPI, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->requestedString); + DIAG_Handler(DIAG_ID_AFE_SPI, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->requestedString); LTC_StateTransition( ltc_state, LTC_STATEMACH_STARTMEAS_CONTINUE, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); } @@ -1181,7 +1184,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->reusageMeasurementMode = LTC_NOT_REUSED; /* Copy data from voltage struct into open-wire struct */ - for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { ltc_state->ltcData.openWireDetection->openWirePdown[ltc_state->requestedString][i] = ltc_state->ltcData.cellVoltage->cellVoltage_mV[ltc_state->requestedString][i]; } @@ -1193,57 +1196,64 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { /* Perform actual open-wire check */ /* Take difference between pull-up and pull-down measurement */ - for (uint16_t i = 1u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 1u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { ltc_state->ltcData.openWireDetection->openWireDelta[ltc_state->requestedString][i] = (int32_t)( ltc_state->ltcData.openWireDetection->openWirePup[ltc_state->requestedString][i] - ltc_state->ltcData.openWireDetection->openWirePdown[ltc_state->requestedString][i]); } /* PDOWN or PUP positive or negative full scale value: C(N) or C(N-1) open*/ - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { /* PUP */ - for (uint8_t p = 0u; p < BS_NR_OF_CELLS_PER_MODULE; p++) { + for (uint8_t p = 0u; p < BS_NR_OF_CELL_BLOCKS_PER_MODULE; p++) { if ((ltc_state->ltcData.openWireDetection - ->openWirePup[ltc_state->requestedString][p + (m * BS_NR_OF_CELLS_PER_MODULE)] == + ->openWirePup[ltc_state->requestedString] + [p + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] == LTC_FUELCELL_POSITIVE_FULLSCALE_RANGE_mV) || (ltc_state->ltcData.openWireDetection - ->openWirePup[ltc_state->requestedString][p + (m * BS_NR_OF_CELLS_PER_MODULE)] == + ->openWirePup[ltc_state->requestedString] + [p + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] == LTC_FUELCELL_NEGATIVE_FULLSCALE_RANGE_mV)) { - ltc_state->ltcData.openWire - ->openwire[ltc_state->requestedString][p + (m * (BS_NR_OF_CELLS_PER_MODULE))] = 1; ltc_state->ltcData.openWire->openwire[ltc_state->requestedString] - [(p + 1u) + (m * (BS_NR_OF_CELLS_PER_MODULE))] = 1; + [p + (m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE))] = 1; + ltc_state->ltcData.openWire + ->openwire[ltc_state->requestedString] + [(p + 1u) + (m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE))] = 1; } if ((ltc_state->ltcData.openWireDetection - ->openWirePdown[ltc_state->requestedString][p + (m * BS_NR_OF_CELLS_PER_MODULE)] == + ->openWirePdown[ltc_state->requestedString] + [p + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] == LTC_FUELCELL_POSITIVE_FULLSCALE_RANGE_mV) || (ltc_state->ltcData.openWireDetection - ->openWirePdown[ltc_state->requestedString][p + (m * BS_NR_OF_CELLS_PER_MODULE)] == + ->openWirePdown[ltc_state->requestedString] + [p + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] == LTC_FUELCELL_NEGATIVE_FULLSCALE_RANGE_mV)) { - ltc_state->ltcData.openWire - ->openwire[ltc_state->requestedString][p + (m * (BS_NR_OF_CELLS_PER_MODULE))] = 1; ltc_state->ltcData.openWire->openwire[ltc_state->requestedString] - [(p + 1u) + (m * (BS_NR_OF_CELLS_PER_MODULE))] = 1; + [p + (m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE))] = 1; + ltc_state->ltcData.openWire + ->openwire[ltc_state->requestedString] + [(p + 1u) + (m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE))] = 1; } } } /* data sheet page 28: "for all values of n from 1 to 36: If CELL Delta(n+1) < -200mV then C(n) is open" */ - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - /* ltc_state->ltcData.openWireDelta parsed from 1 to (BS_NR_OF_CELLS_PER_MODULE-1) */ - for (uint8_t c = 1u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + /* ltc_state->ltcData.openWireDelta parsed from 1 to (BS_NR_OF_CELL_BLOCKS_PER_MODULE-1) */ + for (uint8_t c = 1u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { /* If delta cell(n+1) < -200mV: open-wire at C(n) */ if (ltc_state->ltcData.openWireDetection - ->openWireDelta[ltc_state->requestedString][c + (m * BS_NR_OF_CELLS_PER_MODULE)] < - LTC_ADOW_THRESHOLD) { - ltc_state->ltcData.openWire - ->openwire[ltc_state->requestedString][c + (m * BS_NR_OF_CELLS_PER_MODULE)] = 1; + ->openWireDelta[ltc_state->requestedString] + [c + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] < LTC_ADOW_THRESHOLD) { + ltc_state->ltcData.openWire->openwire[ltc_state->requestedString] + [c + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] = 1; } } } ltc_state->ltcData.openWire->nrOpenWires[ltc_state->requestedString] = 0; - for (uint16_t c = 0u; c < (BS_NR_OF_MODULES * (BS_NR_OF_CELLS_PER_MODULE + 1)); c++) { + for (uint16_t c = 0u; c < (BS_NR_OF_MODULES_PER_STRING * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1)); + c++) { if (ltc_state->ltcData.openWire->openwire[ltc_state->requestedString][c] == 1) { ltc_state->ltcData.openWire->nrOpenWires[ltc_state->requestedString]++; } @@ -1345,7 +1355,7 @@ static void LTC_SaveRXtoVoltagebuffer_Fuelcell( if (ltc_state->ltcData.errorTable->PEC_valid[stringNumber][m] == true) { ltc_state->ltcData.cellVoltage->cellVoltage_mV[stringNumber] [(ltc_state->ltcData.usedCellIndex[stringNumber]) + - (m * BS_NR_OF_CELLS_PER_MODULE)] = voltage; + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] = voltage; bitmask = ~bitmask; /* negate bitmask to only validate flags of this voltage register */ ltc_state->ltcData.cellVoltage->invalidCellVoltage[stringNumber][(m / LTC_NUMBER_OF_LTC_PER_MODULE)] &= bitmask; @@ -1358,7 +1368,7 @@ static void LTC_SaveRXtoVoltagebuffer_Fuelcell( (ltc_state->ltcData.usedCellIndex[stringNumber])++; incrementations++; - if ((ltc_state->ltcData.usedCellIndex[stringNumber]) > BS_NR_OF_CELLS_PER_MODULE) { + if ((ltc_state->ltcData.usedCellIndex[stringNumber]) > BS_NR_OF_CELL_BLOCKS_PER_MODULE) { break; } } @@ -1440,13 +1450,13 @@ static STD_RETURN_TYPE_e LTC_Init( static void LTC_ResetErrorTable(LTC_STATE_s *ltc_state) { uint16_t i = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { for (i = 0; i < LTC_N_LTC; i++) { - ltc_state->ltcData.errorTable->PEC_valid[stringNumber][i] = false; - ltc_state->ltcData.errorTable->mux0[stringNumber][i] = 0; - ltc_state->ltcData.errorTable->mux1[stringNumber][i] = 0; - ltc_state->ltcData.errorTable->mux2[stringNumber][i] = 0; - ltc_state->ltcData.errorTable->mux3[stringNumber][i] = 0; + ltc_state->ltcData.errorTable->PEC_valid[s][i] = false; + ltc_state->ltcData.errorTable->mux0[s][i] = 0; + ltc_state->ltcData.errorTable->mux1[s][i] = 0; + ltc_state->ltcData.errorTable->mux2[s][i] = 0; + ltc_state->ltcData.errorTable->mux3[s][i] = 0; } } } @@ -1518,7 +1528,7 @@ static STD_RETURN_TYPE_e LTC_StartOpenWireMeasurement( * @return retVal STD_OK if PEC check is OK, STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_RX_PECCheck( +static STD_RETURN_TYPE_e LTC_CheckPec( LTC_STATE_s *ltc_state, uint16_t *DataBufferSPI_RX_with_PEC, uint8_t stringNumber) { @@ -1581,7 +1591,7 @@ static STD_RETURN_TYPE_e LTC_RX_PECCheck( * @return statusSPI #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_RX( +static STD_RETURN_TYPE_e LTC_ReadRegister( uint16_t *Command, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -1617,7 +1627,7 @@ static STD_RETURN_TYPE_e LTC_RX( * * @return frequency of the SPI clock */ -static uint32_t LTC_GetSPIClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { +static uint32_t LTC_GetSpiClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { uint32_t SPI_Clock = 0; uint32_t prescaler = 0; @@ -1662,7 +1672,7 @@ static void LTC_SetTransferTimes(LTC_STATE_s *ltc_state) { uint32_t transferTime_us = 0; uint32_t SPI_Clock = 0; - SPI_Clock = LTC_GetSPIClock(ltc_state->ltcData.pSpiInterface); + SPI_Clock = LTC_GetSpiClock(ltc_state->ltcData.pSpiInterface); /* Transmission of a command and data */ /* Multiplication by 1000*1000 to get us */ @@ -1735,7 +1745,7 @@ static void LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state) { OS_ExitTaskCritical(); } -extern void LTC_monitoringPinInit(void) { +extern void LTC_InitializeMonitoringPin(void) { /* Set 3rd PE pins to enable daisy chains */ PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN10); PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN11); diff --git a/src/app/driver/afe/ltc/6806/wscript b/src/app/driver/afe/ltc/6806/wscript index 3c5bc062..127c8d25 100644 --- a/src/app/driver/afe/ltc/6806/wscript +++ b/src/app/driver/afe/ltc/6806/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -68,6 +68,7 @@ def build(bld): os.path.join("..", "..", "..", "spi"), os.path.join("..", "..", "..", "ts"), os.path.join("..", "..", "..", "ts", "api"), + os.path.join("..", "..", "..", "mcu"), os.path.join("..", "..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "..", "engine", "config"), os.path.join("..", "..", "..", "..", "engine", "database"), diff --git a/src/app/driver/afe/ltc/6811-1/wscript b/src/app/driver/afe/ltc/6811-1/wscript index b3c827f1..72f4975a 100644 --- a/src/app/driver/afe/ltc/6811-1/wscript +++ b/src/app/driver/afe/ltc/6811-1/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/afe/ltc/6812-1/wscript b/src/app/driver/afe/ltc/6812-1/wscript index dae5432f..837ee232 100644 --- a/src/app/driver/afe/ltc/6812-1/wscript +++ b/src/app/driver/afe/ltc/6812-1/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.c b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.c index 5c0e674e..9b9e251d 100644 --- a/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.c +++ b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_6813-1_cfg.c * @author foxBMS Team * @date 2015-02-18 (date of creation) - * @updated 2015-02-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix LTC * @@ -222,7 +223,7 @@ const uint8_t ltc_voltage_input_used[BS_MAX_SUPPORTED_CELLS] = { /*========== Extern Function Implementations ================================*/ -int16_t LTC_Convert_MuxVoltages_to_Temperatures(uint16_t adcVoltage_mV) { +int16_t LTC_ConvertMuxVoltagesToTemperatures(uint16_t adcVoltage_mV) { return TSI_GetTemperature(adcVoltage_mV); /* Convert degree celsius to deci degree celsius */ } diff --git a/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h index f3b228e0..62e1769d 100644 --- a/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h +++ b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_6813-1_cfg.h * @author foxBMS Team * @date 2015-02-18 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix LTC * @@ -149,9 +150,9 @@ * SPI1 is used for communication with LTC * @{ */ -#define LTC_SPI_HANDLE &spi_devices[0] -#define LTC_SPI_INSTANCE *LTC_SPI_HANDLE.Instance -#define LTC_SPI_PRESCALER *LTC_SPI_HANDLE.Init.BaudRatePrescaler +#define LTC_SPI_HANDLE (&spi_devices[0]) +#define LTC_SPI_INSTANCE (*LTC_SPI_HANDLE.Instance) +#define LTC_SPI_PRESCALER (*LTC_SPI_HANDLE.Init.BaudRatePrescaler) /**@}*/ /** start definition of LTC timings; Twake (see LTC data sheet) */ @@ -278,34 +279,6 @@ /** If set to 1, check if multiplexers acknowledged transmission */ #define LTC_READCOM (0) -/** - * ------------------- OPEN WIRE CHECK ------------------------ - * If open-wire check is performed cell voltages and temperatures are not - * updated and thus old values can be transmitted on the CAN bus. Check time - * is dependent on module configuration and external capacitance. Activate - * open-wire check with care! See table below for various measured open-wire - * check durations! (set to TRUE or FALSE) - */ -#define LTC_STANDBY_PERIODIC_OPEN_WIRE_CHECK (false) - -/** Periodic open-wire check time in STANDBY state in ms */ -#define LTC_STANDBY_OPEN_WIRE_PERIOD_ms (600000) - -/** open-wire check in normal mode (set to true or false) */ -#define LTC_NORMAL_PERIODIC_OPEN_WIRE_CHECK (false) - -/** Periodic open-wire check time in NORMAL state in ms */ -#define LTC_NORMAL_OPEN_WIRE_PERIOD_ms (600000) - -/** open-wire check in charge mode (set to true or false) */ -#define LTC_CHARGE_PERIODIC_OPEN_WIRE_CHECK (false) - -/** Periodic open-wire check time in CHARGE state in ms */ -#define LTC_CHARGE_OPEN_WIRE_PERIOD_ms (600000) - -/** Periodic open-wire check time in ERROR state in ms */ -#define LTC_ERROR_OPEN_WIRE_PERIOD_ms (30000) - /** * Number of required ADOW commands because of external C-Pin capacitance and * the respective duration to perform an open wire check for 14 modules with @@ -367,7 +340,7 @@ extern const uint8_t ltc_voltage_input_used[BS_MAX_SUPPORTED_CELLS]; * @param adcVoltage_mV voltage read from the multiplexer in mV * @return temperature value in deci °C */ -extern int16_t LTC_Convert_MuxVoltages_to_Temperatures(uint16_t adcVoltage_mV); +extern int16_t LTC_ConvertMuxVoltagesToTemperatures(uint16_t adcVoltage_mV); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/afe/ltc/6813-1/ltc_6813-1.c b/src/app/driver/afe/ltc/6813-1/ltc_6813-1.c index e8bda9fb..b0a59c82 100644 --- a/src/app/driver/afe/ltc/6813-1/ltc_6813-1.c +++ b/src/app/driver/afe/ltc/6813-1/ltc_6813-1.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_6813-1.c * @author foxBMS Team * @date 2019-09-01 (date of creation) - * @updated 2021-12-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix LTC * @@ -60,13 +61,13 @@ #include "HL_spi.h" #include "HL_system.h" +#include "afe_plausibility.h" #include "database.h" #include "diag.h" #include "io.h" #include "ltc_pec.h" -#include "pex.h" #include "os.h" -#include "afe_plausibility.h" +#include "pex.h" /*========== Macros and Definitions =========================================*/ @@ -100,10 +101,12 @@ * PEC buffer for RX and TX * @{ */ +/* AXIVION Disable Style MisraC2012-1.2: The Pec buffer must be put in the shared RAM section for performance reasons */ #pragma SET_DATA_SECTION(".sharedRAM") uint16_t ltc_RxPecBuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; uint16_t ltc_TxPecBuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; #pragma SET_DATA_SECTION() +/* AXIVION Enable Style MisraC2012-1.2: only Pec buffer needed to be in the shared RAM setcion */ /**@}*/ /** index of used cells */ @@ -160,9 +163,9 @@ LTC_STATE_s ltc_stateBase = { .balance_control_done = STD_NOT_OK, .transmit_ongoing = false, .dummyByte_ongoing = STD_NOT_OK, - .spiDiagErrorEntry = DIAG_ID_LTC_SPI, - .pecDiagErrorEntry = DIAG_ID_LTC_PEC, - .muxDiagErrorEntry = DIAG_ID_LTC_MUX, + .spiDiagErrorEntry = DIAG_ID_AFE_SPI, + .pecDiagErrorEntry = DIAG_ID_AFE_COM_INTEGRITY, + .muxDiagErrorEntry = DIAG_ID_AFE_MUX, .voltMeasDiagErrorEntry = DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, .tempMeasDiagErrorEntry = DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, .ltcData.pSpiInterface = spi_ltcInterface, @@ -281,9 +284,9 @@ static uint16_t ltc_BC_cmdADOW_PDOWN_filtered_DCP0[4] = { /*========== Static Function Prototypes =====================================*/ static void LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state); -static void LTC_Initialize_Database(LTC_STATE_s *ltc_state); +static void LTC_InitializeDatabase(LTC_STATE_s *ltc_state); static void LTC_SaveBalancingFeedback(LTC_STATE_s *ltc_state, uint16_t *DataBufferSPI_RX, uint8_t stringNumber); -static void LTC_Get_BalancingControlValues(LTC_STATE_s *ltc_state); +static void LTC_GetBalancingControlValues(LTC_STATE_s *ltc_state); static void LTC_SaveLastStates(LTC_STATE_s *ltc_state); static void LTC_StateTransition(LTC_STATE_s *ltc_state, LTC_STATEMACH_e state, uint8_t substate, uint16_t timer_ms); static void LTC_CondBasedStateTransition( @@ -317,7 +320,7 @@ static STD_RETURN_TYPE_e LTC_StartVoltageMeasurement( SPI_INTERFACE_CONFIG_s *pSpiInterface, LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh); -static STD_RETURN_TYPE_e LTC_StartGPIOMeasurement( +static STD_RETURN_TYPE_e LTC_StartGpioMeasurement( SPI_INTERFACE_CONFIG_s *pSpiInterface, LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh); @@ -326,52 +329,52 @@ static STD_RETURN_TYPE_e LTC_StartOpenWireMeasurement( LTC_ADCMODE_e adcMode, uint8_t PUP); -static uint16_t LTC_Get_MeasurementTCycle(LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh); -static void LTC_SaveRXtoVoltagebuffer( +static uint16_t LTC_GetMeasurementTimeCycle(LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh); +static void LTC_SaveRxToVoltageBuffer( LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t registerSet, uint8_t stringNumber); -static void LTC_SaveRXtoGPIOBuffer( +static void LTC_SaveRxToGpioBuffer( LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t registerSet, uint8_t stringNumber); -static STD_RETURN_TYPE_e LTC_RX_PECCheck( +static STD_RETURN_TYPE_e LTC_CheckPec( LTC_STATE_s *ltc_state, uint16_t *DataBufferSPI_RX_with_PEC, uint8_t stringNumber); -static STD_RETURN_TYPE_e LTC_RX( +static STD_RETURN_TYPE_e LTC_ReadRegister( uint16_t *Command, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength); -static STD_RETURN_TYPE_e LTC_TX( +static STD_RETURN_TYPE_e LTC_WriteRegister( uint16_t *Command, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength); -static void LTC_SetMUXChCommand(uint16_t *pTxBuff, uint8_t mux, uint8_t channel); -static STD_RETURN_TYPE_e LTC_SendEEPROMReadCommand( +static void LTC_SetMuxChCommand(uint16_t *pTxBuff, uint8_t mux, uint8_t channel); +static STD_RETURN_TYPE_e LTC_SendEepromReadCommand( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength, uint8_t step); -static void LTC_SetEEPROMReadCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step); -static void LTC_EEPROMSaveReadValue(LTC_STATE_s *ltc_state, uint16_t *pRxBuff); -static STD_RETURN_TYPE_e LTC_SendEEPROMWriteCommand( +static void LTC_SetEepromReadCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step); +static void LTC_EepromSaveReadValue(LTC_STATE_s *ltc_state, uint16_t *pRxBuff); +static STD_RETURN_TYPE_e LTC_SendEepromWriteCommand( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength, uint8_t step); -static void LTC_SetEEPROMWriteCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step); +static void LTC_SetEepromWriteCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step); static STD_RETURN_TYPE_e LTC_SetMuxChannel( SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -387,37 +390,37 @@ static STD_RETURN_TYPE_e LTC_SetPortExpander( uint32_t frameLength); static void LTC_PortExpanderSaveValues(LTC_STATE_s *ltc_state, uint16_t *pRxBuff); static void LTC_TempSensSaveTemp(LTC_STATE_s *ltc_state, uint16_t *pRxBuff); -static STD_RETURN_TYPE_e LTC_SetPortExpanderDirection_TI( +static STD_RETURN_TYPE_e LTC_SetPortExpanderDirectionTi( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength, LTC_PORT_EXPANDER_TI_DIRECTION_e direction); -static STD_RETURN_TYPE_e LTC_SetPortExpander_Output_TI( +static STD_RETURN_TYPE_e LTC_SetPortExpanderOutputTi( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength); -static STD_RETURN_TYPE_e LTC_GetPortExpander_Input_TI( +static STD_RETURN_TYPE_e LTC_GetPortExpanderInputTi( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength, uint8_t step); -static void LTC_PortExpanderSaveValues_TI(LTC_STATE_s *ltc_state, uint16_t *pTxBuff); +static void LTC_PortExpanderSaveValuesTi(LTC_STATE_s *ltc_state, uint16_t *pTxBuff); -static STD_RETURN_TYPE_e LTC_I2CClock(SPI_INTERFACE_CONFIG_s *pSpiInterface); -static STD_RETURN_TYPE_e LTC_Send_I2C_Command( +static STD_RETURN_TYPE_e LTC_I2cClock(SPI_INTERFACE_CONFIG_s *pSpiInterface); +static STD_RETURN_TYPE_e LTC_SendI2cCommand( SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength, uint16_t *cmd_data); -static STD_RETURN_TYPE_e LTC_I2CCheckACK(LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t mux, uint8_t stringNumber); +static STD_RETURN_TYPE_e LTC_I2cCheckAck(LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t mux, uint8_t stringNumber); static void LTC_SaveMuxMeasurement( LTC_STATE_s *ltc_state, @@ -425,7 +428,7 @@ static void LTC_SaveMuxMeasurement( LTC_MUX_CH_CFG_s *muxseqptr, uint8_t stringNumber); -static uint32_t LTC_GetSPIClock(SPI_INTERFACE_CONFIG_s *pSpiInterface); +static uint32_t LTC_GetSpiClock(SPI_INTERFACE_CONFIG_s *pSpiInterface); static void LTC_SetTransferTimes(LTC_STATE_s *ltc_state); static LTC_RETURN_TYPE_e LTC_CheckStateRequest(LTC_STATE_s *ltc_state, LTC_REQUEST_s statereq); @@ -441,32 +444,32 @@ static LTC_RETURN_TYPE_e LTC_CheckStateRequest(LTC_STATE_s *ltc_state, LTC_REQUE * @param ltc_state: state of the ltc state machine * */ -static void LTC_Initialize_Database(LTC_STATE_s *ltc_state) { - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { +static void LTC_InitializeDatabase(LTC_STATE_s *ltc_state) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { ltc_state->ltcData.cellVoltage->state = 0; - for (uint16_t i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - ltc_state->ltcData.cellVoltage->cellVoltage_mV[stringNumber][i] = 0; - ltc_state->ltcData.openWireDetection->openWirePup[stringNumber][i] = 0; - ltc_state->ltcData.openWireDetection->openWirePdown[stringNumber][i] = 0; - ltc_state->ltcData.openWireDetection->openWireDelta[stringNumber][i] = 0; + for (uint16_t i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + ltc_state->ltcData.cellVoltage->cellVoltage_mV[s][i] = 0; + ltc_state->ltcData.openWireDetection->openWirePup[s][i] = 0; + ltc_state->ltcData.openWireDetection->openWirePdown[s][i] = 0; + ltc_state->ltcData.openWireDetection->openWireDelta[s][i] = 0; } ltc_state->ltcData.cellTemperature->state = 0; for (uint16_t i = 0; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) { - ltc_state->ltcData.cellTemperature->cellTemperature_ddegC[stringNumber][i] = 0; + ltc_state->ltcData.cellTemperature->cellTemperature_ddegC[s][i] = 0; } ltc_state->ltcData.balancingFeedback->state = 0; - for (uint16_t i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - ltc_state->ltcData.balancingControl->balancingState[stringNumber][i] = 0; + for (uint16_t i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + ltc_state->ltcData.balancingControl->balancingState[s][i] = 0; } - ltc_state->ltcData.balancingControl->nrBalancedCells[stringNumber] = 0u; - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { - ltc_state->ltcData.balancingFeedback->value[stringNumber][i] = 0; + ltc_state->ltcData.balancingControl->nrBalancedCells[s] = 0u; + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { + ltc_state->ltcData.balancingFeedback->value[s][i] = 0; } ltc_state->ltcData.slaveControl->state = 0; - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { ltc_state->ltcData.slaveControl->ioValueIn[i] = 0; ltc_state->ltcData.slaveControl->ioValueOut[i] = 0; ltc_state->ltcData.slaveControl->externalTemperatureSensor[i] = 0; @@ -479,12 +482,12 @@ static void LTC_Initialize_Database(LTC_STATE_s *ltc_state) { ltc_state->ltcData.slaveControl->eepromWriteAddressToUse = 0xFFFFFFFF; ltc_state->ltcData.allGpioVoltages->state = 0; - for (uint16_t i = 0; i < (BS_NR_OF_MODULES * BS_NR_OF_GPIOS_PER_MODULE); i++) { - ltc_state->ltcData.allGpioVoltages->gpioVoltages_mV[stringNumber][i] = 0; + for (uint16_t i = 0; i < (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_GPIOS_PER_MODULE); i++) { + ltc_state->ltcData.allGpioVoltages->gpioVoltages_mV[s][i] = 0; } - for (uint16_t i = 0; i < (BS_NR_OF_MODULES * (BS_NR_OF_CELLS_PER_MODULE + 1)); i++) { - ltc_state->ltcData.openWire->openwire[stringNumber][i] = 0; + for (uint16_t i = 0; i < (BS_NR_OF_MODULES_PER_STRING * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1)); i++) { + ltc_state->ltcData.openWire->openwire[s][i] = 0; } ltc_state->ltcData.openWire->state = 0; } @@ -572,30 +575,30 @@ extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber) { STD_RETURN_TYPE_e cellVoltageMeasurementValid = STD_OK; int32_t stringVoltage_mV = 0; uint16_t numberValidMeasurements = 0; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { /* ------- 1. Check open-wires ----------------- * Is cell N input not open wire && * Is cell N+1 input not open wire && * Is cell voltage valid because of previous PEC error * If so, everything okay, else set cell voltage measurement to invalid. */ - if ((ltc_state->ltcData.openWire->openwire[stringNumber][(m * (BS_NR_OF_CELLS_PER_MODULE + 1u)) + c] == - 0u) && - (ltc_state->ltcData.openWire->openwire[stringNumber][(m * (BS_NR_OF_CELLS_PER_MODULE + 1u)) + c + 1u] == - 0u) && + if ((ltc_state->ltcData.openWire + ->openwire[stringNumber][(m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1u)) + c] == 0u) && + (ltc_state->ltcData.openWire + ->openwire[stringNumber][(m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1u)) + c + 1u] == 0u) && ((ltc_state->ltcData.cellVoltage->invalidCellVoltage[stringNumber][m] & (0x01u << c)) == 0u)) { /* Cell voltage is valid -> perform minimum/maximum plausibility check */ /* ------- 2. Perform minimum/maximum measurement range check ---------- */ if (STD_OK == AFE_PlausibilityCheckVoltageMeasurementRange( ltc_state->ltcData.cellVoltage - ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELLS_PER_MODULE) + c], + ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c], ltc_plausibleCellVoltages681x)) { /* Cell voltage is valid -> calculate string voltage */ /* -------- 3. Calculate string values ------------- */ stringVoltage_mV += ltc_state->ltcData.cellVoltage - ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELLS_PER_MODULE) + c]; + ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c]; numberValidMeasurements++; } else { /* Invalidate cell voltage measurement */ @@ -624,7 +627,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { STD_RETURN_TYPE_e cellTemperatureMeasurementValid = STD_OK; uint16_t numberValidMeasurements = 0; - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { for (uint8_t c = 0u; c < BS_NR_OF_TEMP_SENSORS_PER_MODULE; c++) { /* ------- 1. Check valid flag ----------------- * Is cell temperature valid because of previous PEC error @@ -658,7 +661,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { DATA_WRITE_DATA(ltc_state->ltcData.cellTemperature); } -extern void LTC_SaveAllGPIOMeasurement(LTC_STATE_s *ltc_state) { +extern void LTC_SaveAllGpioMeasurement(LTC_STATE_s *ltc_state) { ltc_state->ltcData.allGpioVoltages->state++; DATA_WRITE_DATA(ltc_state->ltcData.allGpioVoltages); } @@ -694,7 +697,7 @@ static void LTC_SaveBalancingFeedback(LTC_STATE_s *ltc_state, uint16_t *DataBuff * @param ltc_state: state of the ltc state machine * */ -static void LTC_Get_BalancingControlValues(LTC_STATE_s *ltc_state) { +static void LTC_GetBalancingControlValues(LTC_STATE_s *ltc_state) { DATA_READ_DATA(ltc_state->ltcData.balancingControl); } @@ -829,7 +832,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { statereq = LTC_TransferStateRequest(ltc_state, &tmpbusID, &tmpadcMode, &tmpadcMeasCh); if (statereq.request == LTC_STATE_INIT_REQUEST) { LTC_SaveLastStates(ltc_state); - LTC_Initialize_Database(ltc_state); + LTC_InitializeDatabase(ltc_state); LTC_ResetErrorTable(ltc_state); LTC_StateTransition( ltc_state, LTC_STATEMACH_INITIALIZATION, LTC_INIT_STRING, LTC_STATEMACH_SHORTTIME); @@ -912,7 +915,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { /* Read values written in config register, currently unused */ LTC_SaveLastStates(ltc_state); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCFG, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -965,7 +968,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, (ltc_state->commandTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, LTC_STATEMACH_SHORTTIME); @@ -989,7 +992,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, (ltc_state->commandTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, LTC_STATEMACH_SHORTTIME); @@ -1002,7 +1005,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVA, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1021,12 +1024,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_B_RDCVB_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 0, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 0, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVB, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1045,12 +1048,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_C_RDCVC_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVC, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1069,12 +1072,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_D_RDCVD_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 2, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 2, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVD, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1106,12 +1109,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_E_RDCVE_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVE, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1143,12 +1146,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_VOLTAGE_REGISTER_F_RDCVF_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 4, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 4, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCVF, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1167,14 +1170,14 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EXIT_READVOLTAGE) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); if (BS_MAX_SUPPORTED_CELLS == 12) { - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); } else if (BS_MAX_SUPPORTED_CELLS == 15) { - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 4, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 4, ltc_state->currentString); } else if (BS_MAX_SUPPORTED_CELLS == 18) { - LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 5, ltc_state->currentString); + LTC_SaveRxToVoltageBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 5, ltc_state->currentString); } /* Switch to different state if read voltage state is reused @@ -1264,7 +1267,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); if (LTC_GOTO_MUX_CHECK == true) { LTC_CondBasedStateTransition( ltc_state, @@ -1301,7 +1304,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1328,11 +1331,11 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); /* if CRC OK: check multiplexer answer on i2C bus */ - retVal = LTC_I2CCheckACK( + retVal = LTC_I2cCheckAck( ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->muxmeas_seqptr[ltc_state->currentString]->muxID, @@ -1368,10 +1371,10 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { /* user multiplexer type -> connected to GPIO2! */ if ((ltc_state->muxmeas_seqptr[ltc_state->currentString]->muxID == 1) || (ltc_state->muxmeas_seqptr[ltc_state->currentString]->muxID == 2)) { - retVal = LTC_StartGPIOMeasurement( + retVal = LTC_StartGpioMeasurement( ltc_state->spiSeqPtr, ltc_state->adcMode, LTC_ADCMEAS_SINGLECHANNEL_GPIO2); } else { - retVal = LTC_StartGPIOMeasurement( + retVal = LTC_StartGpioMeasurement( ltc_state->spiSeqPtr, ltc_state->adcMode, LTC_ADCMEAS_SINGLECHANNEL_GPIO1); } } @@ -1382,7 +1385,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_MUXMEASUREMENT, LTC_STATEMACH_READMUXMEASUREMENT, (ltc_state->commandTransferTime + - LTC_Get_MeasurementTCycle( + LTC_GetMeasurementTimeCycle( ltc_state->adcMode, LTC_ADCMEAS_SINGLECHANNEL_GPIO2)), /* wait, ADAX-Command */ LTC_STATEMACH_MUXMEASUREMENT, LTC_STATEMACH_READMUXMEASUREMENT, @@ -1393,7 +1396,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDAUXA, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1420,7 +1423,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveMuxMeasurement( ltc_state, @@ -1547,7 +1550,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - if (BS_NR_OF_CELLS_PER_MODULE > 12) { + if (BS_NR_OF_CELL_BLOCKS_PER_MODULE > 12) { AFE_SetTransmitOngoing(ltc_state); retVal = LTC_BalanceControl( ltc_state, @@ -1614,7 +1617,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->adcMeasCh = LTC_ADCMEAS_ALLCHANNEL_GPIOS; ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_StartGPIOMeasurement(ltc_state->spiSeqPtr, ltc_state->adcMode, ltc_state->adcMeasCh); + retVal = LTC_StartGpioMeasurement(ltc_state->spiSeqPtr, ltc_state->adcMode, ltc_state->adcMeasCh); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -1622,7 +1625,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_READALLGPIO, LTC_READ_AUXILIARY_REGISTER_A_RDAUXA, (ltc_state->commandTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), LTC_STATEMACH_ALLGPIOMEASUREMENT, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); /* TODO: @koffel here same state is kept if error occurs */ @@ -1634,7 +1637,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_READ_AUXILIARY_REGISTER_A_RDAUXA) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDAUXA, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1653,12 +1656,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_AUXILIARY_REGISTER_B_RDAUXB) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 0, ltc_state->currentString); + LTC_SaveRxToGpioBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 0, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDAUXB, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1691,12 +1694,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_AUXILIARY_REGISTER_C_RDAUXC) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); + LTC_SaveRxToGpioBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDAUXC, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1715,12 +1718,12 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_AUXILIARY_REGISTER_D_RDAUXD) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); - LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 2, ltc_state->currentString); + LTC_SaveRxToGpioBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 2, ltc_state->currentString); AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDAUXD, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1739,16 +1742,16 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EXIT_READAUXILIARY_ALLGPIOS) { - retVal = LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); + retVal = LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString); DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); if (BS_MAX_SUPPORTED_CELLS == 12) { - LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); + LTC_SaveRxToGpioBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); } else if (BS_MAX_SUPPORTED_CELLS > 12) { - LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); + LTC_SaveRxToGpioBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); } - LTC_SaveAllGPIOMeasurement(ltc_state); + LTC_SaveAllGpioMeasurement(ltc_state); LTC_StateTransition( ltc_state, LTC_STATEMACH_MEASCYCLE_FINISHED, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -1768,7 +1771,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->adcMeasCh = LTC_ADCMEAS_SINGLECHANNEL_GPIO3; ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_StartGPIOMeasurement(ltc_state->spiSeqPtr, ltc_state->adcMode, ltc_state->adcMeasCh); + retVal = LTC_StartGpioMeasurement(ltc_state->spiSeqPtr, ltc_state->adcMode, ltc_state->adcMeasCh); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -1776,7 +1779,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_BALANCEFEEDBACK, LTC_READ_FEEDBACK_BALANCECONTROL, (ltc_state->commandDataTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, ltc_state->adcMeasCh)), LTC_STATEMACH_BALANCEFEEDBACK, LTC_READ_FEEDBACK_BALANCECONTROL, LTC_STATEMACH_SHORTTIME); @@ -1785,7 +1788,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_READ_FEEDBACK_BALANCECONTROL) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDAUXA, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1813,7 +1816,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - if (LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { + if (LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1833,7 +1836,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_Send_I2C_Command( + retVal = LTC_SendI2cCommand( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, ltc_state->ltcData.rxBuffer, @@ -1869,7 +1872,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -1894,7 +1897,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_Send_I2C_Command( + retVal = LTC_SendI2cCommand( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, ltc_state->ltcData.rxBuffer, @@ -1930,7 +1933,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -1954,7 +1957,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1983,7 +1986,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - if (LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { + if (LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -2039,7 +2042,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2061,7 +2064,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_Send_I2C_Command( + retVal = LTC_SendI2cCommand( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, ltc_state->ltcData.rxBuffer, @@ -2097,7 +2100,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2122,7 +2125,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2151,7 +2154,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - if (LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { + if (LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -2173,7 +2176,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SetPortExpanderDirection_TI( + retVal = LTC_SetPortExpanderDirectionTi( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2205,7 +2208,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2221,7 +2224,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_USER_IO_SET_OUTPUT_REGISTER_TI) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SetPortExpander_Output_TI( + retVal = LTC_SetPortExpanderOutputTi( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2251,7 +2254,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2273,7 +2276,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SetPortExpanderDirection_TI( + retVal = LTC_SetPortExpanderDirectionTi( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2305,7 +2308,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2321,7 +2324,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_USER_IO_READ_INPUT_REGISTER_TI_FIRST) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_GetPortExpander_Input_TI( + retVal = LTC_GetPortExpanderInputTi( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2352,7 +2355,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2367,7 +2370,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_USER_IO_READ_INPUT_REGISTER_TI_SECOND) { ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_GetPortExpander_Input_TI( + retVal = LTC_GetPortExpanderInputTi( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2398,7 +2401,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_NOT_OK; - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2422,7 +2425,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2451,13 +2454,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - if (LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { + if (LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); - LTC_PortExpanderSaveValues_TI(ltc_state, ltc_state->ltcData.txBuffer); + LTC_PortExpanderSaveValuesTi(ltc_state, ltc_state->ltcData.txBuffer); } LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2473,7 +2476,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SendEEPROMReadCommand( + retVal = LTC_SendEepromReadCommand( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2510,7 +2513,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2535,7 +2538,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SendEEPROMReadCommand( + retVal = LTC_SendEepromReadCommand( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2566,7 +2569,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2590,7 +2593,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_RX( + retVal = LTC_ReadRegister( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2619,13 +2622,13 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - if (LTC_RX_PECCheck(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { + if (LTC_CheckPec(ltc_state, ltc_state->ltcData.rxBuffer, ltc_state->currentString) != STD_OK) { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { DIAG_Handler( ltc_state->pecDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); - LTC_EEPROMSaveReadValue(ltc_state, ltc_state->ltcData.rxBuffer); + LTC_EepromSaveReadValue(ltc_state, ltc_state->ltcData.rxBuffer); } LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); break; @@ -2640,7 +2643,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SendEEPROMWriteCommand( + retVal = LTC_SendEepromWriteCommand( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2677,7 +2680,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2702,7 +2705,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_SendEEPROMWriteCommand( + retVal = LTC_SendEepromWriteCommand( ltc_state, ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2733,7 +2736,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } AFE_SetTransmitOngoing(ltc_state); - retVal = LTC_I2CClock(ltc_state->spiSeqPtr); + retVal = LTC_I2cClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, retVal, @@ -2780,7 +2783,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_OPENWIRE_CHECK, LTC_REQUEST_PULLUP_CURRENT_OPENWIRE_CHECK, (ltc_state->commandDataTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); ltc_state->resendCommandCounter--; /* Check how many retries are left */ @@ -2791,7 +2794,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, (ltc_state->commandDataTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); /* Reuse read voltage register */ ltc_state->reusageMeasurementMode = LTC_REUSE_READVOLT_FOR_ADOW_PUP; } @@ -2806,7 +2809,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->reusageMeasurementMode = LTC_NOT_REUSED; /* Copy data from voltage struct into open-wire struct */ - for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { ltc_state->ltcData.openWireDetection->openWirePup[ltc_state->requestedString][i] = ltc_state->ltcData.cellVoltage->cellVoltage_mV[ltc_state->requestedString][i]; } @@ -2833,7 +2836,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_OPENWIRE_CHECK, LTC_REQUEST_PULLDOWN_CURRENT_OPENWIRE_CHECK, (ltc_state->commandDataTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); ltc_state->resendCommandCounter--; /* Check how many retries are left */ @@ -2844,7 +2847,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_READVOLTAGE, LTC_READ_VOLTAGE_REGISTER_A_RDCVA_READVOLTAGE, (ltc_state->commandDataTransferTime + - LTC_Get_MeasurementTCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); + LTC_GetMeasurementTimeCycle(ltc_state->adcMode, LTC_ADCMEAS_ALLCHANNEL_CELLS))); /* Reuse read voltage register */ ltc_state->reusageMeasurementMode = LTC_REUSE_READVOLT_FOR_ADOW_PDOWN; } @@ -2859,7 +2862,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->reusageMeasurementMode = LTC_NOT_REUSED; /* Copy data from voltage struct into open-wire struct */ - for (uint16_t i = 0u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 0u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { ltc_state->ltcData.openWireDetection->openWirePdown[ltc_state->requestedString][i] = ltc_state->ltcData.cellVoltage->cellVoltage_mV[ltc_state->requestedString][i]; } @@ -2868,37 +2871,39 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_PERFORM_OPENWIRE_CHECK) { /* Perform actual open-wire check */ - for (uint8_t m = 0; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0; m < BS_NR_OF_MODULES_PER_STRING; m++) { /* Open-wire at C0: cell_pup(0) == 0 */ if (ltc_state->ltcData.openWireDetection - ->openWirePup[ltc_state->requestedString][0 + (m * BS_NR_OF_CELLS_PER_MODULE)] == 0u) { - ltc_state->ltcData.openWire - ->openwire[ltc_state->requestedString][0 + (m * (BS_NR_OF_CELLS_PER_MODULE))] = 1u; + ->openWirePup[ltc_state->requestedString][0 + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] == + 0u) { + ltc_state->ltcData.openWire->openwire[ltc_state->requestedString] + [0 + (m * (BS_NR_OF_CELL_BLOCKS_PER_MODULE))] = 1u; } - /* Open-wire at Cmax: cell_pdown(BS_NR_OF_CELLS_PER_MODULE-1) == 0 */ + /* Open-wire at Cmax: cell_pdown(BS_NR_OF_CELL_BLOCKS_PER_MODULE-1) == 0 */ if (ltc_state->ltcData.openWireDetection->openWirePdown[ltc_state->requestedString][( - (BS_NR_OF_CELLS_PER_MODULE - 1) + (m * BS_NR_OF_CELLS_PER_MODULE))] == 0u) { + (BS_NR_OF_CELL_BLOCKS_PER_MODULE - 1) + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE))] == 0u) { ltc_state->ltcData.openWire ->openwire[ltc_state->requestedString] - [BS_NR_OF_CELLS_PER_MODULE + (m * BS_NR_OF_CELLS_PER_MODULE)] = 1u; + [BS_NR_OF_CELL_BLOCKS_PER_MODULE + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] = + 1u; } } /* Take difference between pull-up and pull-down measurement */ - for (uint16_t i = 1u; i < BS_NR_OF_BAT_CELLS; i++) { + for (uint16_t i = 1u; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { ltc_state->ltcData.openWireDetection->openWireDelta[ltc_state->requestedString][i] = ltc_state->ltcData.openWireDetection->openWirePup[ltc_state->requestedString][i] - ltc_state->ltcData.openWireDetection->openWirePdown[ltc_state->requestedString][i]; } /* Open-wire at C(N): delta cell(n+1) < -400mV */ - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 1u; c < (BS_NR_OF_CELLS_PER_MODULE - 1); c++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 1u; c < (BS_NR_OF_CELL_BLOCKS_PER_MODULE - 1); c++) { if (ltc_state->ltcData.openWireDetection - ->openWireDelta[ltc_state->requestedString][c + (m * BS_NR_OF_CELLS_PER_MODULE)] < - LTC_ADOW_THRESHOLD) { - ltc_state->ltcData.openWire - ->openwire[ltc_state->requestedString][c + (m * BS_NR_OF_CELLS_PER_MODULE)] = 1; + ->openWireDelta[ltc_state->requestedString] + [c + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] < LTC_ADOW_THRESHOLD) { + ltc_state->ltcData.openWire->openwire[ltc_state->requestedString] + [c + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] = 1; } } } @@ -2971,7 +2976,7 @@ static void LTC_SaveMuxMeasurement( val_ui = buffer_LSB | (buffer_MSB << 8); /* val_ui = *((uint16_t *)(&pRxBuff[4+i*8])); */ /* GPIO voltage in 100uV -> * 0.1 ---- conversion to mV */ - temperature_ddegC = LTC_Convert_MuxVoltages_to_Temperatures(val_ui / 10u); /* unit: deci °C */ + temperature_ddegC = LTC_ConvertMuxVoltagesToTemperatures(val_ui / 10u); /* unit: deci °C */ sensor_idx = ltc_muxsensortemperatur_cfg[muxseqptr->muxCh]; /* wrong configuration! */ if (sensor_idx >= BS_NR_OF_TEMP_SENSORS_PER_MODULE) { @@ -3013,7 +3018,7 @@ static void LTC_SaveMuxMeasurement( * @param stringNumber string addressed * */ -static void LTC_SaveRXtoVoltagebuffer( +static void LTC_SaveRxToVoltageBuffer( LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t registerSet, @@ -3079,7 +3084,7 @@ static void LTC_SaveRXtoVoltagebuffer( ltc_state->ltcData.cellVoltage ->cellVoltage_mV[stringNumber] [(ltc_state->ltcData.usedCellIndex[stringNumber]) + - (m * BS_NR_OF_CELLS_PER_MODULE)] = voltage; + (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE)] = voltage; bitmask = ~bitmask; /* negate bitmask to only validate flags of this voltage register */ ltc_state->ltcData.cellVoltage ->invalidCellVoltage[stringNumber][(m / LTC_NUMBER_OF_LTC_PER_MODULE)] &= bitmask; @@ -3092,7 +3097,7 @@ static void LTC_SaveRXtoVoltagebuffer( (ltc_state->ltcData.usedCellIndex[stringNumber])++; incrementations++; - if ((ltc_state->ltcData.usedCellIndex[stringNumber]) > BS_NR_OF_CELLS_PER_MODULE) { + if ((ltc_state->ltcData.usedCellIndex[stringNumber]) > BS_NR_OF_CELL_BLOCKS_PER_MODULE) { break; } } @@ -3123,7 +3128,7 @@ static void LTC_SaveRXtoVoltagebuffer( * @param stringNumber string addressed * */ -static void LTC_SaveRXtoGPIOBuffer( +static void LTC_SaveRxToGpioBuffer( LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t registerSet, @@ -3266,10 +3271,10 @@ static void LTC_SaveRXtoGPIOBuffer( * * @return muxError STD_OK is there was no error, STD_NOT_OK if there was errors */ -static STD_RETURN_TYPE_e LTC_I2CCheckACK(LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t mux, uint8_t stringNumber) { +static STD_RETURN_TYPE_e LTC_I2cCheckAck(LTC_STATE_s *ltc_state, uint16_t *pRxBuff, uint8_t mux, uint8_t stringNumber) { STD_RETURN_TYPE_e muxError = STD_OK; - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { if ((pRxBuff[4u + 1u + (LTC_NUMBER_OF_LTC_PER_MODULE * i * 8u)] & 0x0Fu) != 0x07u) { /* ACK = 0xX7 */ if (LTC_DISCARD_MUX_CHECK == false) { if (mux == 0u) { @@ -3395,83 +3400,86 @@ static STD_RETURN_TYPE_e LTC_BalanceControl( uint8_t PEC_Check[6]; uint16_t PEC_result = 0; - LTC_Get_BalancingControlValues(ltc_state); + LTC_GetBalancingControlValues(ltc_state); if (registerSet == 0u) { /* cells 1 to 12, WRCFG */ pTxBuff[0] = ltc_cmdWRCFG[0]; pTxBuff[1] = ltc_cmdWRCFG[1]; pTxBuff[2] = ltc_cmdWRCFG[2]; pTxBuff[3] = ltc_cmdWRCFG[3]; - for (uint16_t j = 0; j < BS_NR_OF_MODULES; j++) { - const uint16_t i = BS_NR_OF_MODULES - j - 1u; + for (uint16_t j = 0; j < BS_NR_OF_MODULES_PER_STRING; j++) { + /* The daisy-chain works like a shift register, so the order has to be reversed: + when addressing e.g. the first module in the daisy-chain, the data will be sent last on the SPI bus and + when addressing e.g. the last module in the daisy-chain, the data will be sent first on the SPI bus */ + const uint16_t reverseModuleNumber = BS_NR_OF_MODULES_PER_STRING - j - 1u; /* FC = disable all pull-downs, REFON = 1 (reference always on), DTEN off, ADCOPT = 0 */ - pTxBuff[4u + (i * 8u)] = 0xFC; - pTxBuff[5u + (i * 8u)] = 0x00; - pTxBuff[6u + (i * 8u)] = 0x00; - pTxBuff[7u + (i * 8u)] = 0x00; - pTxBuff[8u + (i * 8u)] = 0x00; - pTxBuff[9u + (i * 8u)] = 0x00; + pTxBuff[4u + (reverseModuleNumber * 8u)] = 0xFC; + pTxBuff[5u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[6u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[7u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[8u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[9u + (reverseModuleNumber * 8u)] = 0x00; if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 0u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x01u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 0u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x01u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 1u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x02u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 1u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x02u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 2u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x04u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 2u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x04u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 3u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x08u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 3u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x08u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 4u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x10u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 4u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x10u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 5u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x20u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 5u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x20u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 6u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x40u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 6u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x40u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 7u] == 1u) { - pTxBuff[8u + (i * 8u)] |= 0x80u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 7u] == 1u) { + pTxBuff[8u + (reverseModuleNumber * 8u)] |= 0x80u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 8u] == 1u) { - pTxBuff[9u + (i * 8u)] |= 0x01u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 8u] == 1u) { + pTxBuff[9u + (reverseModuleNumber * 8u)] |= 0x01u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 9u] == 1u) { - pTxBuff[9u + (i * 8u)] |= 0x02u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 9u] == 1u) { + pTxBuff[9u + (reverseModuleNumber * 8u)] |= 0x02u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 10u] == 1u) { - pTxBuff[9u + (i * 8u)] |= 0x04u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 10u] == 1u) { + pTxBuff[9u + (reverseModuleNumber * 8u)] |= 0x04u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 11u] == 1u) { - pTxBuff[9u + (i * 8u)] |= 0x08u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 11u] == 1u) { + pTxBuff[9u + (reverseModuleNumber * 8u)] |= 0x08u; } - PEC_Check[0] = pTxBuff[4u + (i * 8u)]; - PEC_Check[1] = pTxBuff[5u + (i * 8u)]; - PEC_Check[2] = pTxBuff[6u + (i * 8u)]; - PEC_Check[3] = pTxBuff[7u + (i * 8u)]; - PEC_Check[4] = pTxBuff[8u + (i * 8u)]; - PEC_Check[5] = pTxBuff[9u + (i * 8u)]; + PEC_Check[0] = pTxBuff[4u + (reverseModuleNumber * 8u)]; + PEC_Check[1] = pTxBuff[5u + (reverseModuleNumber * 8u)]; + PEC_Check[2] = pTxBuff[6u + (reverseModuleNumber * 8u)]; + PEC_Check[3] = pTxBuff[7u + (reverseModuleNumber * 8u)]; + PEC_Check[4] = pTxBuff[8u + (reverseModuleNumber * 8u)]; + PEC_Check[5] = pTxBuff[9u + (reverseModuleNumber * 8u)]; - PEC_result = LTC_pec15_calc(6, PEC_Check); - pTxBuff[10u + (i * 8u)] = (PEC_result >> 8u) & 0xFFu; - pTxBuff[11u + (i * 8u)] = PEC_result & 0xFFu; + PEC_result = LTC_pec15_calc(6, PEC_Check); + pTxBuff[10u + (reverseModuleNumber * 8u)] = (PEC_result >> 8u) & 0xFFu; + pTxBuff[11u + (reverseModuleNumber * 8u)] = PEC_result & 0xFFu; } retVal = LTC_TransmitReceiveData(pSpiInterface, pTxBuff, pRxBuff, frameLength); } else if (registerSet == 1u) { /* cells 13 to 15/18 WRCFG2 */ @@ -3479,54 +3487,57 @@ static STD_RETURN_TYPE_e LTC_BalanceControl( pTxBuff[1] = ltc_cmdWRCFG2[1]; pTxBuff[2] = ltc_cmdWRCFG2[2]; pTxBuff[3] = ltc_cmdWRCFG2[3]; - for (uint16_t j = 0; j < BS_NR_OF_MODULES; j++) { - const uint16_t i = BS_NR_OF_MODULES - j - 1; + for (uint16_t j = 0; j < BS_NR_OF_MODULES_PER_STRING; j++) { + /* The daisy-chain works like a shift register, so the order has to be reversed: + when addressing e.g. the first module in the daisy-chain, the data will be sent last on the SPI bus and + when addressing e.g. the last module in the daisy-chain, the data will be sent first on the SPI bus */ + const uint16_t reverseModuleNumber = BS_NR_OF_MODULES_PER_STRING - j - 1u; /* 0x0F = disable pull-downs on GPIO6-9 */ - pTxBuff[4u + (i * 8u)] = 0x0F; - pTxBuff[5u + (i * 8u)] = 0x00; - pTxBuff[6u + (i * 8u)] = 0x00; - pTxBuff[7u + (i * 8u)] = 0x00; - pTxBuff[8u + (i * 8u)] = 0x00; - pTxBuff[9u + (i * 8u)] = 0x00; + pTxBuff[4u + (reverseModuleNumber * 8u)] = 0x0F; + pTxBuff[5u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[6u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[7u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[8u + (reverseModuleNumber * 8u)] = 0x00; + pTxBuff[9u + (reverseModuleNumber * 8u)] = 0x00; if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 12u] == 1u) { - pTxBuff[4u + (i * 8u)] |= 0x10u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 12u] == 1u) { + pTxBuff[4u + (reverseModuleNumber * 8u)] |= 0x10u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 13u] == 1u) { - pTxBuff[4u + (i * 8u)] |= 0x20u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 13u] == 1u) { + pTxBuff[4u + (reverseModuleNumber * 8u)] |= 0x20u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 14u] == 1u) { - pTxBuff[4u + (i * 8u)] |= 0x40u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 14u] == 1u) { + pTxBuff[4u + (reverseModuleNumber * 8u)] |= 0x40u; } - if (BS_NR_OF_CELLS_PER_MODULE > 15u) { + if (BS_NR_OF_CELL_BLOCKS_PER_MODULE > 15u) { if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 15u] == 1u) { - pTxBuff[4u + (i * 8u)] |= 0x80u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 15u] == 1u) { + pTxBuff[4u + (reverseModuleNumber * 8u)] |= 0x80u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 16u] == 1u) { - pTxBuff[5u + (i * 8u)] |= 0x01u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 16u] == 1u) { + pTxBuff[5u + (reverseModuleNumber * 8u)] |= 0x01u; } if (ltc_state->ltcData.balancingControl - ->balancingState[stringNumber][(j * (BS_NR_OF_CELLS_PER_MODULE)) + 17u] == 1u) { - pTxBuff[5u + (i * 8u)] |= 0x02u; + ->balancingState[stringNumber][(j * (BS_NR_OF_CELL_BLOCKS_PER_MODULE)) + 17u] == 1u) { + pTxBuff[5u + (reverseModuleNumber * 8u)] |= 0x02u; } } - PEC_Check[0] = pTxBuff[4u + (i * 8u)]; - PEC_Check[1] = pTxBuff[5u + (i * 8u)]; - PEC_Check[2] = pTxBuff[6u + (i * 8u)]; - PEC_Check[3] = pTxBuff[7u + (i * 8u)]; - PEC_Check[4] = pTxBuff[8u + (i * 8u)]; - PEC_Check[5] = pTxBuff[9u + (i * 8u)]; + PEC_Check[0] = pTxBuff[4u + (reverseModuleNumber * 8u)]; + PEC_Check[1] = pTxBuff[5u + (reverseModuleNumber * 8u)]; + PEC_Check[2] = pTxBuff[6u + (reverseModuleNumber * 8u)]; + PEC_Check[3] = pTxBuff[7u + (reverseModuleNumber * 8u)]; + PEC_Check[4] = pTxBuff[8u + (reverseModuleNumber * 8u)]; + PEC_Check[5] = pTxBuff[9u + (reverseModuleNumber * 8u)]; - PEC_result = LTC_pec15_calc(6, PEC_Check); - pTxBuff[10u + (i * 8u)] = (PEC_result >> 8u) & 0xFFu; - pTxBuff[11u + (i * 8u)] = PEC_result & 0xFFu; + PEC_result = LTC_pec15_calc(6, PEC_Check); + pTxBuff[10u + (reverseModuleNumber * 8u)] = (PEC_result >> 8u) & 0xFFu; + pTxBuff[11u + (reverseModuleNumber * 8u)] = PEC_result & 0xFFu; } retVal = LTC_TransmitReceiveData(pSpiInterface, pTxBuff, pRxBuff, frameLength); } else { @@ -3544,13 +3555,13 @@ static STD_RETURN_TYPE_e LTC_BalanceControl( * */ static void LTC_ResetErrorTable(LTC_STATE_s *ltc_state) { - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { for (uint16_t i = 0; i < LTC_N_LTC; i++) { - ltc_state->ltcData.errorTable->PEC_valid[stringNumber][i] = false; - ltc_state->ltcData.errorTable->mux0[stringNumber][i] = 0; - ltc_state->ltcData.errorTable->mux1[stringNumber][i] = 0; - ltc_state->ltcData.errorTable->mux2[stringNumber][i] = 0; - ltc_state->ltcData.errorTable->mux3[stringNumber][i] = 0; + ltc_state->ltcData.errorTable->PEC_valid[s][i] = false; + ltc_state->ltcData.errorTable->mux0[s][i] = 0; + ltc_state->ltcData.errorTable->mux1[s][i] = 0; + ltc_state->ltcData.errorTable->mux2[s][i] = 0; + ltc_state->ltcData.errorTable->mux3[s][i] = 0; } } } @@ -3569,7 +3580,7 @@ static void LTC_ResetErrorTable(LTC_STATE_s *ltc_state) { * * @return retVal measurement time in ms */ -static uint16_t LTC_Get_MeasurementTCycle(LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh) { +static uint16_t LTC_GetMeasurementTimeCycle(LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh) { uint16_t retVal = LTC_ADCMEAS_UNDEFINED; /* default */ if (adcMeasCh == LTC_ADCMEAS_ALLCHANNEL_CELLS) { @@ -3672,7 +3683,7 @@ static STD_RETURN_TYPE_e LTC_StartVoltageMeasurement( * @return retVal #STD_OK if dummy byte was sent correctly by SPI, #STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_StartGPIOMeasurement( +static STD_RETURN_TYPE_e LTC_StartGpioMeasurement( SPI_INTERFACE_CONFIG_s *pSpiInterface, LTC_ADCMODE_e adcMode, LTC_ADCMEAS_CHAN_e adcMeasCh) { @@ -3781,7 +3792,7 @@ static STD_RETURN_TYPE_e LTC_StartOpenWireMeasurement( * @return retVal STD_OK if PEC check is OK, STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_RX_PECCheck( +static STD_RETURN_TYPE_e LTC_CheckPec( LTC_STATE_s *ltc_state, uint16_t *DataBufferSPI_RX_with_PEC, uint8_t stringNumber) { @@ -3843,7 +3854,7 @@ static STD_RETURN_TYPE_e LTC_RX_PECCheck( * @return statusSPI #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_RX( +static STD_RETURN_TYPE_e LTC_ReadRegister( uint16_t *Command, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -3892,7 +3903,7 @@ static STD_RETURN_TYPE_e LTC_RX( * @return STD_OK if SPI transmission is OK, STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_TX( +static STD_RETURN_TYPE_e LTC_WriteRegister( uint16_t *Command, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -3931,14 +3942,14 @@ static STD_RETURN_TYPE_e LTC_TX( * @brief configures the data that will be sent to the LTC daisy-chain to configure multiplexer channels. * * This function does not sent the data to the multiplexer daisy-chain. This is done - * by the function LTC_SetMuxChannel(), which calls LTC_SetMUXChCommand().. + * by the function LTC_SetMuxChannel(), which calls LTC_SetMuxChCommand().. * * @param pTxBuff transmit buffer * @param mux multiplexer ID to be configured (0,1,2 or 3) * @param channel multiplexer channel to be configured (0 to 7) * */ -static void LTC_SetMUXChCommand(uint16_t *pTxBuff, uint8_t mux, uint8_t channel) { +static void LTC_SetMuxChCommand(uint16_t *pTxBuff, uint8_t mux, uint8_t channel) { for (uint16_t i = 0; i < LTC_N_LTC; i++) { #if SLAVE_BOARD_VERSION == 2u @@ -3982,7 +3993,7 @@ static void LTC_SetMUXChCommand(uint16_t *pTxBuff, uint8_t mux, uint8_t channel) * * @return #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise */ -static STD_RETURN_TYPE_e LTC_SendEEPROMReadCommand( +static STD_RETURN_TYPE_e LTC_SendEepromReadCommand( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -3992,8 +4003,8 @@ static STD_RETURN_TYPE_e LTC_SendEEPROMReadCommand( STD_RETURN_TYPE_e statusSPI = STD_NOT_OK; /* send WRCOMM to send I2C message to choose channel */ - LTC_SetEEPROMReadCommand(ltc_state, pTxBuff, step); - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + LTC_SetEepromReadCommand(ltc_state, pTxBuff, step); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4006,7 +4017,7 @@ static STD_RETURN_TYPE_e LTC_SendEEPROMReadCommand( * @param step first or second stage of read process (0 or 1) * */ -static void LTC_SetEEPROMReadCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step) { +static void LTC_SetEepromReadCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step) { DATA_READ_DATA(ltc_state->ltcData.slaveControl); uint32_t address = ltc_state->ltcData.slaveControl->eepromReadAddressToUse; @@ -4045,7 +4056,7 @@ static void LTC_SetEEPROMReadCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, * @param pRxBuff receive buffer * */ -static void LTC_EEPROMSaveReadValue(LTC_STATE_s *ltc_state, uint16_t *pRxBuff) { +static void LTC_EepromSaveReadValue(LTC_STATE_s *ltc_state, uint16_t *pRxBuff) { DATA_READ_DATA(ltc_state->ltcData.slaveControl); for (uint16_t i = 0; i < LTC_N_LTC; i++) { @@ -4072,7 +4083,7 @@ static void LTC_EEPROMSaveReadValue(LTC_STATE_s *ltc_state, uint16_t *pRxBuff) { * * @return #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise */ -static STD_RETURN_TYPE_e LTC_SendEEPROMWriteCommand( +static STD_RETURN_TYPE_e LTC_SendEepromWriteCommand( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -4082,8 +4093,8 @@ static STD_RETURN_TYPE_e LTC_SendEEPROMWriteCommand( STD_RETURN_TYPE_e statusSPI = STD_NOT_OK; /* send WRCOMM to send I2C message to write EEPROM */ - LTC_SetEEPROMWriteCommand(ltc_state, pTxBuff, step); - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + LTC_SetEepromWriteCommand(ltc_state, pTxBuff, step); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4096,7 +4107,7 @@ static STD_RETURN_TYPE_e LTC_SendEEPROMWriteCommand( * @param step first or second stage of read process (0 or 1) * */ -static void LTC_SetEEPROMWriteCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step) { +static void LTC_SetEepromWriteCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, uint8_t step) { DATA_READ_DATA(ltc_state->ltcData.slaveControl); uint32_t address = ltc_state->ltcData.slaveControl->eepromWriteAddressToUse; @@ -4139,7 +4150,7 @@ static void LTC_SetEEPROMWriteCommand(LTC_STATE_s *ltc_state, uint16_t *pTxBuff, /** * @brief sends data to the LTC daisy-chain to configure multiplexer channels. * - * This function calls the function LTC_SetMUXChCommand() to set the data. + * This function calls the function LTC_SetMuxChCommand() to set the data. * * @param pSpiInterface pointer to SPI configuration * @param pTxBuff transmit buffer @@ -4160,8 +4171,8 @@ static STD_RETURN_TYPE_e LTC_SetMuxChannel( STD_RETURN_TYPE_e statusSPI = STD_NOT_OK; /* send WRCOMM to send I2C message to choose channel */ - LTC_SetMUXChCommand(pTxBuff, mux, channel); - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + LTC_SetMuxChCommand(pTxBuff, mux, channel); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4179,7 +4190,7 @@ static STD_RETURN_TYPE_e LTC_SetMuxChannel( * * @return #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise */ -static STD_RETURN_TYPE_e LTC_Send_I2C_Command( +static STD_RETURN_TYPE_e LTC_SendI2cCommand( SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, @@ -4187,7 +4198,7 @@ static STD_RETURN_TYPE_e LTC_Send_I2C_Command( uint16_t *cmd_data) { STD_RETURN_TYPE_e statusSPI = STD_NOT_OK; - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { pTxBuff[4u + (i * 6u)] = cmd_data[0]; pTxBuff[5u + (i * 6u)] = cmd_data[1]; @@ -4199,7 +4210,7 @@ static STD_RETURN_TYPE_e LTC_Send_I2C_Command( } /* send WRCOMM to send I2C message */ - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4251,8 +4262,8 @@ static STD_RETURN_TYPE_e LTC_SetPortExpander( DATA_READ_DATA(ltc_state->ltcData.slaveControl); - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { - const uint8_t output_data = ltc_state->ltcData.slaveControl->ioValueOut[BS_NR_OF_MODULES - 1 - i]; + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { + const uint8_t output_data = ltc_state->ltcData.slaveControl->ioValueOut[BS_NR_OF_MODULES_PER_STRING - 1 - i]; pTxBuff[4u + (i * 8u)] = LTC_ICOM_START | 0x04u; /* 6: ICOM0 start condition, 4: upper nibble of PCA8574 address */ @@ -4271,7 +4282,7 @@ static STD_RETURN_TYPE_e LTC_SetPortExpander( } /* send WRCOMM to send I2C message */ - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4311,7 +4322,7 @@ static void LTC_PortExpanderSaveValues(LTC_STATE_s *ltc_state, uint16_t *pRxBuff * * @return #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise */ -static STD_RETURN_TYPE_e LTC_SetPortExpanderDirection_TI( +static STD_RETURN_TYPE_e LTC_SetPortExpanderDirectionTi( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -4322,7 +4333,7 @@ static STD_RETURN_TYPE_e LTC_SetPortExpanderDirection_TI( DATA_READ_DATA(ltc_state->ltcData.slaveControl); - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { pTxBuff[4u + (i * 8u)] = LTC_ICOM_START | 0x4u; /*upper nibble of TCA6408A address */ pTxBuff[5u + (i * 8u)] = (uint8_t)((LTC_PORTEXPANDER_ADR_TI << 1u) << 4u) | LTC_FCOM_MASTER_NACK; /* 0: lower nibble of TCA6408A address + R/W bit */ @@ -4339,7 +4350,7 @@ static STD_RETURN_TYPE_e LTC_SetPortExpanderDirection_TI( } /* send WRCOMM to send I2C message */ - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4357,7 +4368,7 @@ static STD_RETURN_TYPE_e LTC_SetPortExpanderDirection_TI( * * @return #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise */ -static STD_RETURN_TYPE_e LTC_SetPortExpander_Output_TI( +static STD_RETURN_TYPE_e LTC_SetPortExpanderOutputTi( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -4367,8 +4378,8 @@ static STD_RETURN_TYPE_e LTC_SetPortExpander_Output_TI( DATA_READ_DATA(ltc_state->ltcData.slaveControl); - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { - const uint8_t output_data = ltc_state->ltcData.slaveControl->ioValueOut[BS_NR_OF_MODULES - 1 - i]; + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { + const uint8_t output_data = ltc_state->ltcData.slaveControl->ioValueOut[BS_NR_OF_MODULES_PER_STRING - 1 - i]; pTxBuff[4u + (i * 8u)] = LTC_ICOM_START | 0x4u; /* upper nibble of TCA6408A address */ pTxBuff[5u + (i * 8u)] = (uint8_t)((LTC_PORTEXPANDER_ADR_TI << 1u) << 4u) | @@ -4385,7 +4396,7 @@ static STD_RETURN_TYPE_e LTC_SetPortExpander_Output_TI( } /* send WRCOMM to send I2C message */ - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4404,7 +4415,7 @@ static STD_RETURN_TYPE_e LTC_SetPortExpander_Output_TI( * * @return #STD_OK if SPI transmission is OK, #STD_NOT_OK otherwise */ -static STD_RETURN_TYPE_e LTC_GetPortExpander_Input_TI( +static STD_RETURN_TYPE_e LTC_GetPortExpanderInputTi( LTC_STATE_s *ltc_state, SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, @@ -4414,7 +4425,7 @@ static STD_RETURN_TYPE_e LTC_GetPortExpander_Input_TI( STD_RETURN_TYPE_e statusSPI = STD_NOT_OK; if (step == 0u) { - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { pTxBuff[4u + (i * 8u)] = LTC_ICOM_START | 0x4u; /* upper nibble of TCA6408A address */ pTxBuff[5u + (i * 8u)] = (uint8_t)((LTC_PORTEXPANDER_ADR_TI << 1u) << 4u) | LTC_FCOM_MASTER_NACK; /* lower nibble of TCA6408A address + R/W bit */ @@ -4431,7 +4442,7 @@ static STD_RETURN_TYPE_e LTC_GetPortExpander_Input_TI( } else { DATA_READ_DATA(ltc_state->ltcData.slaveControl); - for (uint16_t i = 0; i < BS_NR_OF_MODULES; i++) { + for (uint16_t i = 0; i < BS_NR_OF_MODULES_PER_STRING; i++) { pTxBuff[4u + (i * 8u)] = LTC_ICOM_START | 0x4u; /* upper nibble of TCA6408A address */ pTxBuff[5u + (i * 8u)] = (uint8_t)(((LTC_PORTEXPANDER_ADR_TI << 1u) | 1u) << 4u) | LTC_FCOM_MASTER_NACK; /* lower nibble of TCA6408A address + R/W bit */ @@ -4445,7 +4456,7 @@ static STD_RETURN_TYPE_e LTC_GetPortExpander_Input_TI( } /* send WRCOMM to send I2C message */ - statusSPI = LTC_TX(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); + statusSPI = LTC_WriteRegister(ltc_cmdWRCOMM, pSpiInterface, pTxBuff, pRxBuff, frameLength); return statusSPI; } @@ -4456,7 +4467,7 @@ static STD_RETURN_TYPE_e LTC_GetPortExpander_Input_TI( * @param ltc_state state of the ltc state machine * @param pTxBuff transmit buffer */ -static void LTC_PortExpanderSaveValues_TI(LTC_STATE_s *ltc_state, uint16_t *pTxBuff) { +static void LTC_PortExpanderSaveValuesTi(LTC_STATE_s *ltc_state, uint16_t *pTxBuff) { DATA_READ_DATA(ltc_state->ltcData.slaveControl); /* extract data */ @@ -4479,7 +4490,7 @@ static void LTC_PortExpanderSaveValues_TI(LTC_STATE_s *ltc_state, uint16_t *pTxB * @return statusSPI #STD_OK if clock pulses were sent correctly by SPI, #STD_NOT_OK otherwise * */ -static STD_RETURN_TYPE_e LTC_I2CClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { +static STD_RETURN_TYPE_e LTC_I2cClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { STD_RETURN_TYPE_e statusSPI = STD_NOT_OK; uint16_t ltc_TXBufferClock[4u + 9u]; @@ -4506,7 +4517,7 @@ static STD_RETURN_TYPE_e LTC_I2CClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { * * @return frequency of the SPI clock */ -static uint32_t LTC_GetSPIClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { +static uint32_t LTC_GetSpiClock(SPI_INTERFACE_CONFIG_s *pSpiInterface) { uint32_t SPI_Clock = 0; uint32_t prescaler = 0; @@ -4551,7 +4562,7 @@ static void LTC_SetTransferTimes(LTC_STATE_s *ltc_state) { uint32_t transferTime_us = 0; uint32_t SPI_Clock = 0; - SPI_Clock = LTC_GetSPIClock(ltc_state->ltcData.pSpiInterface); + SPI_Clock = LTC_GetSpiClock(ltc_state->ltcData.pSpiInterface); /* Transmission of a command and data */ /* Multiplication by 1000*1000 to get us */ @@ -4625,7 +4636,7 @@ static void LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state) { OS_ExitTaskCritical(); } -extern void LTC_monitoringPinInit(void) { +extern void LTC_InitializeMonitoringPin(void) { /* Set 3rd PE pins to enable daisy chains */ PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN10); PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN11); diff --git a/src/app/driver/afe/ltc/6813-1/wscript b/src/app/driver/afe/ltc/6813-1/wscript index 65368f42..b9d4d32a 100644 --- a/src/app/driver/afe/ltc/6813-1/wscript +++ b/src/app/driver/afe/ltc/6813-1/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -67,6 +67,7 @@ def build(bld): os.path.join("..", "..", "..", "pex"), os.path.join("..", "..", "..", "spi"), os.path.join("..", "..", "..", "ts"), + os.path.join("..", "..", "..", "mcu"), os.path.join("..", "..", "..", "ts", "api"), os.path.join("..", "..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "..", "engine", "config"), diff --git a/src/app/driver/afe/ltc/api/ltc_afe.c b/src/app/driver/afe/ltc/api/ltc_afe.c index 6cc40be7..258ecfb5 100644 --- a/src/app/driver/afe/ltc/api/ltc_afe.c +++ b/src/app/driver/afe/ltc/api/ltc_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_afe.c * @author foxBMS Team * @date 2020-05-08 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix AFE * @@ -75,7 +76,7 @@ extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { } extern STD_RETURN_TYPE_e AFE_Initialize(void) { - LTC_monitoringPinInit(); + LTC_InitializeMonitoringPin(); return STD_OK; } diff --git a/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c index b87daa2f..9b1cc421 100644 --- a/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c +++ b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_afe_dma_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix DMA * diff --git a/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h index 15d8447b..e11e90af 100644 --- a/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h +++ b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_afe_dma_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix DMA * diff --git a/src/app/driver/afe/ltc/common/config/ltc_cfg.h b/src/app/driver/afe/ltc/common/config/ltc_cfg.h index 8fa09091..ac4c7bca 100644 --- a/src/app/driver/afe/ltc/common/config/ltc_cfg.h +++ b/src/app/driver/afe/ltc/common/config/ltc_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_cfg.h * @author foxBMS Team * @date 2015-02-18 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix LTC * @@ -63,7 +64,7 @@ * Number of used LTC-ICs */ -#define LTC_N_LTC (BS_NR_OF_MODULES) +#define LTC_N_LTC (BS_NR_OF_MODULES_PER_STRING) /** * Number of Bytes to be transmitted in daisy-chain diff --git a/src/app/driver/afe/ltc/common/ltc.h b/src/app/driver/afe/ltc/common/ltc.h index 0f0b9e60..dc37a4de 100644 --- a/src/app/driver/afe/ltc/common/ltc.h +++ b/src/app/driver/afe/ltc/common/ltc.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc.h * @author foxBMS Team * @date 2015-09-01 (date of creation) - * @updated 2015-09-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix LTC * @@ -144,7 +145,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber); * @param ltc_state: state of the ltc state machine * */ -extern void LTC_SaveAllGPIOMeasurement(LTC_STATE_s *ltc_state); +extern void LTC_SaveAllGpioMeasurement(LTC_STATE_s *ltc_state); /** * @brief gets the current state request. @@ -172,7 +173,7 @@ extern LTC_STATEMACH_e LTC_GetState(LTC_STATE_s *ltc_state); * @brief Sets the transceiver pins to enable LTC6820 IC. * */ -extern void LTC_monitoringPinInit(void); +extern void LTC_InitializeMonitoringPin(void); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST diff --git a/src/app/driver/afe/ltc/common/ltc_afe_dma.c b/src/app/driver/afe/ltc/common/ltc_afe_dma.c index 04cfb569..92ab7446 100644 --- a/src/app/driver/afe/ltc/common/ltc_afe_dma.c +++ b/src/app/driver/afe/ltc/common/ltc_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_afe_dma.c * @author foxBMS Team * @date 2020-05-27 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * diff --git a/src/app/driver/afe/ltc/common/ltc_afe_dma.h b/src/app/driver/afe/ltc/common/ltc_afe_dma.h index 14f9999b..be4f9de9 100644 --- a/src/app/driver/afe/ltc/common/ltc_afe_dma.h +++ b/src/app/driver/afe/ltc/common/ltc_afe_dma.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_afe_dma.h * @author foxBMS Team * @date 2020-05-27 (date of creation) - * @updated 2020-06-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * @@ -58,8 +59,8 @@ /* clang-format off */ #include "afe_dma.h" /* clang-format on */ -#include "dma_cfg.h" #include "ltc_defs.h" +#include "dma_cfg.h" /*========== Macros and Definitions =========================================*/ diff --git a/src/app/driver/afe/ltc/common/ltc_defs.h b/src/app/driver/afe/ltc/common/ltc_defs.h index 719296cd..38f8863d 100644 --- a/src/app/driver/afe/ltc/common/ltc_defs.h +++ b/src/app/driver/afe/ltc/common/ltc_defs.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ltc_defs.h * @author foxBMS Team * @date 2015-09-01 (date of creation) - * @updated 2021-12-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix LTC * @@ -76,9 +77,9 @@ typedef struct { /** struct for storing information on the openwire detection */ typedef struct { - int16_t openWirePup[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]; - int16_t openWirePdown[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]; - int32_t openWireDelta[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]; + int16_t openWirePup[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]; + int16_t openWirePdown[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]; + int32_t openWireDelta[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]; } LTC_OPENWIRE_DETECTION_s; /*========== Extern Constant and Variable Declarations ======================*/ @@ -226,7 +227,7 @@ typedef enum { LTC_STATEMACH_MUXMEASUREMENT_CONFIG, /*!< Configuration of the multiplexers */ LTC_STATEMACH_READMUXMEASUREMENT, /*!< */ LTC_STATEMACH_STOREMUXMEASUREMENT, /*!< */ -} LTC_STATEMACH_BALANCECONTROL_SUB; +} LTC_STATEMACH_BALANCECONTROL_SUB_e; /** Substates for open-wire check */ typedef enum { @@ -235,7 +236,7 @@ typedef enum { LTC_REQUEST_PULLDOWN_CURRENT_OPENWIRE_CHECK, /*!< */ LTC_READ_VOLTAGES_PULLDOWN_OPENWIRE_CHECK, /*!< */ LTC_PERFORM_OPENWIRE_CHECK, -} LTC_STATEMACH_OPENWIRECHECK_SUB; +} LTC_STATEMACH_OPENWIRECHECK_SUB_e; /** Substates for diagnosis state */ typedef enum { diff --git a/src/app/driver/afe/ltc/wscript b/src/app/driver/afe/ltc/wscript index 25d2f3e4..74b4491d 100644 --- a/src/app/driver/afe/ltc/wscript +++ b/src/app/driver/afe/ltc/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/afe/maxim/api/mxm_afe.c b/src/app/driver/afe/maxim/api/mxm_afe.c index c7fc1a4e..fb650d09 100644 --- a/src/app/driver/afe/maxim/api/mxm_afe.c +++ b/src/app/driver/afe/maxim/api/mxm_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_afe.c * @author foxBMS Team * @date 2020-06-16 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix AFE * @@ -106,12 +107,18 @@ static MXM_BALANCING_STATE_s mxm_balancingState = { /** state variable for the Maxim monitoring driver */ static MXM_MONITORING_INSTANCE_s mxm_state = { - .pBalancingState = &mxm_balancingState, - .pInstance41B = &mxm_41bState, - .pInstance5X = &mxm_5xState, - .pCellVoltages_table = &mxm_tableCellVoltages, - .pCellTemperatures_table = &mxm_tableCellTemperatures, - .pOpenwire_table = &mxm_tableOpenWire, + .pBalancingState = &mxm_balancingState, + .pInstance41B = &mxm_41bState, + .pInstance5X = &mxm_5xState, + .pCellVoltages_table = &mxm_tableCellVoltages, + .pCellTemperatures_table = &mxm_tableCellTemperatures, + .pOpenwire_table = &mxm_tableOpenWire, + .selfCheck.crc = STD_NOT_OK, + .selfCheck.conv = STD_NOT_OK, + .selfCheck.firstSetBit = STD_NOT_OK, + .selfCheck.extractValueFromRegister = STD_NOT_OK, + .selfCheck.parseVoltageReadall = STD_NOT_OK, + .selfCheck.addressSpaceChecker = STD_NOT_OK, }; /*========== Extern Constant and Variable Definitions =======================*/ @@ -141,28 +148,22 @@ static void MXM_SetStateStructDefaultValues(void); /*========== Static Function Implementations ================================*/ static void MXM_Tick(void) { - /** counter variable for the number of all instances of this driver */ - static int8_t mxm_numberOfInstances = 0; - - /* TODO once all states are covered in the instance structs, this reentry check can be removed */ - FAS_ASSERT(mxm_numberOfInstances == 0); - mxm_numberOfInstances++; MXM_CheckIfErrorCounterCanBeReset(&mxm_state); MXM_StateMachine(&mxm_state); MXM_5XStateMachine(mxm_state.pInstance41B, mxm_state.pInstance5X); - MXM_StateMachine(&mxm_state); - MXM_5XStateMachine(mxm_state.pInstance41B, mxm_state.pInstance5X); - MXM_StateMachine(&mxm_state); - MXM_5XStateMachine(mxm_state.pInstance41B, mxm_state.pInstance5X); MXM_41BStateMachine(mxm_state.pInstance41B); + /* execute battery management state machine once (low cost and prepares for next cycle) */ MXM_5XStateMachine(mxm_state.pInstance41B, mxm_state.pInstance5X); - MXM_StateMachine(&mxm_state); - MXM_5XStateMachine(mxm_state.pInstance41B, mxm_state.pInstance5X); - MXM_StateMachine(&mxm_state); - MXM_5XStateMachine(mxm_state.pInstance41B, mxm_state.pInstance5X); - MXM_StateMachine(&mxm_state); - FAS_ASSERT(mxm_numberOfInstances == 1); /* there should be exactly one instance running at the moment */ - mxm_numberOfInstances--; + + /* check if init is stuck */ + if ((mxm_state.state != MXM_STATEMACHINE_STATES_UNINITIALIZED) && + (mxm_state.state != MXM_STATEMACHINE_STATES_IDLE) && (mxm_state.state != MXM_STATEMACHINE_STATES_OPERATION) && + (mxm_state.resetNecessary == false)) { + /* check if we spend too long in initialization and try to resolve with a reset */ + if (OS_CheckTimeHasPassed(mxm_state.timestampInit, MXM_MAXIMUM_INIT_TIME_ms) == true) { + MXM_ErrorHandlerReset(&mxm_state, true); + } + } } static void MXM_SetStateStructDefaultValues(void) { @@ -181,6 +182,7 @@ extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { const bool allowStartup = mxm_state.allowStartup; const bool operationRequested = mxm_state.operationRequested; const bool firstMeasurementDone = mxm_state.firstMeasurementDone; + OS_ExitTaskCritical(); (void)AFE_Initialize(); @@ -189,15 +191,18 @@ extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { /* if a first measurement has been done, operation has been requested before */ mxm_state.operationRequested = (operationRequested || firstMeasurementDone); - OS_ExitTaskCritical(); + } else { + MXM_Tick(); } - MXM_Tick(); + return STD_OK; } extern STD_RETURN_TYPE_e AFE_Initialize(void) { MXM_SetStateStructDefaultValues(); MXM_InitializeMonitoringPins(); + /* call pre init self check so that we can do these costly tests before the main cycle begins (results are stored) */ + (void)MXM_PreInitSelfCheck(&mxm_state); return STD_OK; } diff --git a/src/app/driver/afe/maxim/common/config/mxm_cfg.c b/src/app/driver/afe/maxim/common/config/mxm_cfg.c index 6d103449..99215c28 100644 --- a/src/app/driver/afe/maxim/common/config/mxm_cfg.c +++ b/src/app/driver/afe/maxim/common/config/mxm_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_cfg.c * @author foxBMS Team * @date 2019-01-09 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix MXM * @@ -54,6 +55,7 @@ /*========== Includes =======================================================*/ #include "mxm_cfg.h" +#include "diag.h" #include "io.h" #include "spi.h" @@ -86,14 +88,20 @@ extern STD_RETURN_TYPE_e MXM_GetSPIStateReady(void) { extern STD_RETURN_TYPE_e MXM_SendData(uint16_t *txBuffer, uint16_t length) { FAS_ASSERT(txBuffer != NULL_PTR); FAS_ASSERT(length != 0u); - return SPI_TransmitData(&spi_MxmInterface, txBuffer, length); + const STD_RETURN_TYPE_e spiReturnValue = SPI_TransmitData(&spi_MxmInterface, txBuffer, length); + /* this driver currently only handles one physical string, therefore reporting to string 0 */ + (void)DIAG_CheckEvent(spiReturnValue, DIAG_ID_AFE_SPI, DIAG_STRING, 0u); + return spiReturnValue; } extern STD_RETURN_TYPE_e MXM_ReceiveData(uint16_t *txBuffer, uint16_t *rxBuffer, uint16_t length) { FAS_ASSERT(txBuffer != NULL_PTR); FAS_ASSERT(rxBuffer != NULL_PTR); FAS_ASSERT(length != 0u); - return SPI_TransmitReceiveData(&spi_MxmInterface, txBuffer, rxBuffer, length); + const STD_RETURN_TYPE_e spiReturnValue = SPI_TransmitReceiveData(&spi_MxmInterface, txBuffer, rxBuffer, length); + /* this driver currently only handles one physical string, therefore reporting to string 0 */ + (void)DIAG_CheckEvent(spiReturnValue, DIAG_ID_AFE_SPI, DIAG_STRING, 0u); + return spiReturnValue; } extern void MXM_ShutDownBridgeIc(void) { diff --git a/src/app/driver/afe/maxim/common/config/mxm_cfg.h b/src/app/driver/afe/maxim/common/config/mxm_cfg.h index 34b3898a..614e93f5 100644 --- a/src/app/driver/afe/maxim/common/config/mxm_cfg.h +++ b/src/app/driver/afe/maxim/common/config/mxm_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_cfg.h * @author foxBMS Team * @date 2019-01-09 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix MXM * @@ -103,6 +104,9 @@ #define MXM_41B_CONFIG_3_DEFAULT_VALUE (0x0Fu) /**@}*/ +/** maximum time that the driver may spend in initialization in ms */ +#define MXM_MAXIMUM_INIT_TIME_ms (4000u) + /*========== Extern Constant and Variable Declarations ======================*/ /** if this flag is set, the post init self check will pass on even if the satellite numbers are not correct */ extern const bool mxm_allowSkippingPostInitSelfCheck; diff --git a/src/app/driver/afe/maxim/common/mxm_17841b.c b/src/app/driver/afe/maxim/common/mxm_17841b.c index c6adce7a..29ca9ae4 100644 --- a/src/app/driver/afe/maxim/common/mxm_17841b.c +++ b/src/app/driver/afe/maxim/common/mxm_17841b.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_17841b.c * @author foxBMS Team * @date 2018-12-14 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -158,9 +159,12 @@ static STD_RETURN_TYPE_e MXM_41BRegisterRead( * from the local register copies. It puts together a * buffer from these register values and calls MXM_41BRegisterWrite() * with this data. + * Calling this function will clear the interrupt registers and reset them + * to their default values (which is #MXM_41B_RX_INT_FLAG_DEFAULT_VALUE and + * #MXM_41B_TX_INT_FLAG_DEFAULT_VALUE). * * @param[in,out] pInstance state pointer - * @return returnvalue of MXM_41BRegisterWrite() + * @return returnvalue of #MXM_41BRegisterWrite() */ static STD_RETURN_TYPE_e MXM_41BConfigRegisterWrite(MXM_41B_INSTANCE_s *pInstance); @@ -191,7 +195,7 @@ static STD_RETURN_TYPE_e MXM_41BBufferWrite( uint8_t extendMessage); /** - * @brief Transition into idle, mark as successfull + * @brief Transition into idle, mark as successful * @param[out] pInstance pointer to the state-struct */ static void MXM_41BTransitionToIdleSuccess(MXM_41B_INSTANCE_s *pInstance); @@ -287,6 +291,9 @@ static STD_RETURN_TYPE_e MXM_41BRegisterWrite( /* sanity check: state-pointer may not be null */ FAS_ASSERT(pInstance != NULL_PTR); FAS_ASSERT(lengthPayload < (MXM_SPI_TX_BUFFER_LENGTH - 1u)); + /* AXIVION Routine Generic-MissingParameterAssert: command: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: kpkPayload: pointer may be NULL */ + STD_RETURN_TYPE_e retval = STD_NOT_OK; /* check if command is a write command (write addresses in MAX17841B are even) */ if ((command % 2u) == 0u) { @@ -323,6 +330,7 @@ static STD_RETURN_TYPE_e MXM_41BRegisterRead( /* RX Buffer may not be NULL pointer for this function */ FAS_ASSERT(pRxBuffer != NULL_PTR); FAS_ASSERT(length <= MXM_SPI_RX_BUFFER_LENGTH); + /* AXIVION Routine Generic-MissingParameterAssert: command: parameter accepts whole range */ STD_RETURN_TYPE_e retval = STD_NOT_OK; /* check if command is a read command (read addresses in MAX17841B are odd) */ @@ -343,17 +351,17 @@ static STD_RETURN_TYPE_e MXM_41BConfigRegisterWrite(MXM_41B_INSTANCE_s *pInstanc /* sanity check: state-pointer may not be null */ FAS_ASSERT(pInstance != NULL_PTR); uint8_t mxm_spi_temp_buffer[MXM_41B_CONFIG_REGISTER_LENGTH] = {0}; - /* TODO refactor so that int flags are not cleared by this function (because otherwise we would have to read them before every write) */ + /* AXIVION Disable Style Generic-NoMagicNumbers: Magic numbers for index value of array is clear in usage */ mxm_spi_temp_buffer[0u] = pInstance->regRXIntEnable; mxm_spi_temp_buffer[1u] = pInstance->regTXIntEnable; - mxm_spi_temp_buffer[2u] = MXM_41B_RX_INT_FLAG_DEFAULT_VALUE; /* TODO add reg_*x_int_flag */ + mxm_spi_temp_buffer[2u] = MXM_41B_RX_INT_FLAG_DEFAULT_VALUE; mxm_spi_temp_buffer[3u] = MXM_41B_TX_INT_FLAG_DEFAULT_VALUE; mxm_spi_temp_buffer[4u] = pInstance->regConfig1; mxm_spi_temp_buffer[5u] = pInstance->regConfig2; mxm_spi_temp_buffer[6u] = pInstance->regConfig3; /* AXIVION Enable Style Generic-NoMagicNumbers: */ - static_assert((6u < MXM_41B_CONFIG_REGISTER_LENGTH), "Revise this function and config register length!"); + f_static_assert((6u < MXM_41B_CONFIG_REGISTER_LENGTH), "Revise this function and config register length!"); return MXM_41BRegisterWrite( pInstance, MXM_REG_RX_INTERRUPT_ENABLE_W, mxm_spi_temp_buffer, MXM_41B_CONFIG_REGISTER_LENGTH); @@ -370,6 +378,7 @@ static STD_RETURN_TYPE_e MXM_41BBufferWrite( FAS_ASSERT(kpkMessage != NULL_PTR); FAS_ASSERT(messageLength >= 1u); FAS_ASSERT(messageLength <= 6u); + /* AXIVION Routine Generic-MissingParameterAssert: extendMessage: parameter accepts whole range */ /* write address and length to buffer */ pInstance->spiTXBuffer[0] = (uint16_t)MXM_BUF_WR_LD_Q_0; @@ -726,7 +735,8 @@ static void MXM_41BStateHandlerCheckFmea(MXM_41B_INSTANCE_s *pInstance) { } else if (pInstance->substate == MXM_41B_FMEA_VERIFY) { STD_RETURN_TYPE_e retval = STD_NOT_OK; if (MXM_GetSPIStateReady() == STD_OK) { - if (pInstance->spiRXBuffer[1] == 0u) { + pInstance->regFmea = pInstance->spiRXBuffer[1u]; + if (pInstance->regFmea == 0u) { retval = STD_OK; } } @@ -783,6 +793,12 @@ extern STD_RETURN_TYPE_e MXM_41BSetStateRequest( MXM_41B_STATE_REQUEST_STATUS_e *processed) { /* sanity check: state-pointer may not be null */ FAS_ASSERT(pInstance != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: state: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: pPayload: pointer may be NULL */ + /* AXIVION Routine Generic-MissingParameterAssert: payloadLength: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: extendMessageBytes: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: pRxBuffer: pointer may be NULL */ + /* AXIVION Routine Generic-MissingParameterAssert: rxBufferLength: parameter accepts whole range */ STD_RETURN_TYPE_e retval = STD_OK; /* start by checking for input inconsistency */ @@ -834,6 +850,8 @@ extern STD_RETURN_TYPE_e MXM_41BWriteRegisterFunction( MXM_41B_REG_BIT_VALUE value) { /* sanity check: state-pointer may not be null */ FAS_ASSERT(pInstance != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: registerFunction: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: value: parameter accepts whole range */ STD_RETURN_TYPE_e retval = STD_OK; /* TODO sanitize value */ @@ -968,6 +986,7 @@ extern void MXM_41BInitializeStateStruct(MXM_41B_INSTANCE_s *pInstance) { pInstance->extendMessageBytes = 0u; pInstance->waitCounter = 0u; pInstance->regRxSpace = 0u; + pInstance->regFmea = 0u; pInstance->hwModel = 0u; pInstance->hwMaskRevision = 0u; pInstance->shutdownTimeStamp = 0u; diff --git a/src/app/driver/afe/maxim/common/mxm_17841b.h b/src/app/driver/afe/maxim/common/mxm_17841b.h index fa5768ee..338d3949 100644 --- a/src/app/driver/afe/maxim/common/mxm_17841b.h +++ b/src/app/driver/afe/maxim/common/mxm_17841b.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_17841b.h * @author foxBMS Team * @date 2018-12-14 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -172,6 +173,7 @@ typedef struct { uint8_t regConfig2; /*!< local storage for the Config 2 register */ uint8_t regConfig3; /*!< local storage for the Config 3 register */ uint8_t regRxSpace; /*!< RX space register (shows the left space in RX buffer) */ + uint8_t regFmea; /*!< FMEA register */ uint16_t hwModel; /*!< model number of the connected IC */ uint8_t hwMaskRevision; /*!< mask revision of the connected IC */ uint32_t shutdownTimeStamp; /*!< timestamp of the last shutdown (or startup) action */ diff --git a/src/app/driver/afe/maxim/common/mxm_1785x.c b/src/app/driver/afe/maxim/common/mxm_1785x.c index 1001acc4..ef2dc904 100644 --- a/src/app/driver/afe/maxim/common/mxm_1785x.c +++ b/src/app/driver/afe/maxim/common/mxm_1785x.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_1785x.c * @author foxBMS Team * @date 2019-01-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -59,6 +60,7 @@ #include "afe_plausibility.h" #include "database.h" +#include "diag.h" #include "mxm_1785x_tools.h" #include "mxm_battery_management.h" #include "mxm_registry.h" @@ -184,29 +186,6 @@ static STD_RETURN_TYPE_e MXM_ParseVoltageReadall( */ static STD_RETURN_TYPE_e must_check_return MXM_ParseVoltageReadallTest(MXM_MONITORING_INSTANCE_s *pInstance); -/** - * @brief Execute all preinit selfchecks. - * @details Executes the following self-checks: - * - #MXM_CRC8SelfTest() - * - #MXM_ConvertTest() - * - #MXM_FirstSetBitTest() - * - #MXM_ExtractValueFromRegisterTest() - * - #MXM_ParseVoltageReadallTest() - * - #MXM_5XUserAccessibleAddressSpaceCheckerSelfCheck() - * - * These self-checks do not need an initialized daisy-chain - * and can therefore be executed at startup of the - * state-machine. - * - * After execution of each test, the return value is stored in - * the supplied state-struct. The function returns whether the - * self-check has successfully passed. - * @param[in,out] pState pointer to the state-struct, will write status into - * @return #STD_OK on success, #STD_NOT_OK on failure, - * return value has to be used - */ -static STD_RETURN_TYPE_e must_check_return MXM_PreInitSelfCheck(MXM_MONITORING_INSTANCE_s *pState); - /*========== Static Function Implementations ================================*/ static void MXM_GetDataFrom5XStateMachine(MXM_MONITORING_INSTANCE_s *pInstance) { @@ -227,6 +206,11 @@ static void MXM_ParseVoltageLineReadall( uint32_t fullScaleReference_mV) { FAS_ASSERT(kpkVoltRxBuffer != NULL_PTR); FAS_ASSERT(pVoltagesTarget != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: voltRxBufferLength: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: measurementOffset: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: conversionType: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: measurementType: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: fullScaleReference_mV: parameter accepts whole range */ /* assert that assumptions behind computation of numberOfConnectedDevices are correct */ @@ -291,6 +275,8 @@ static STD_RETURN_TYPE_e MXM_ParseVoltageReadall( STD_RETURN_TYPE_e retval = STD_OK; FAS_ASSERT(kpkVoltageRxBuffer != NULL_PTR); FAS_ASSERT(datastorage != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: voltageRxBufferLength: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: conversionType: parameter accepts whole range */ if (kpkVoltageRxBuffer[0] != BATTERY_MANAGEMENT_READALL) { /* rxBuffer does not contain a READALL command */ @@ -898,27 +884,6 @@ static STD_RETURN_TYPE_e must_check_return MXM_ParseVoltageReadallTest(MXM_MONIT return retval; } -static STD_RETURN_TYPE_e must_check_return MXM_PreInitSelfCheck(MXM_MONITORING_INSTANCE_s *pState) { - FAS_ASSERT(pState != NULL_PTR); - STD_RETURN_TYPE_e retval = STD_OK; - pState->selfCheck.crc = MXM_CRC8SelfTest(); - pState->selfCheck.conv = MXM_ConvertTest(); - pState->selfCheck.firstSetBit = MXM_FirstSetBitTest(); - pState->selfCheck.extractValueFromRegister = MXM_ExtractValueFromRegisterTest(); - pState->selfCheck.parseVoltageReadall = MXM_ParseVoltageReadallTest(pState); - pState->selfCheck.addressSpaceChecker = MXM_5XUserAccessibleAddressSpaceCheckerSelfCheck(); - - if ((pState->selfCheck.crc == STD_OK) && (pState->selfCheck.addressSpaceChecker == STD_OK) && - (pState->selfCheck.conv == STD_OK) && (pState->selfCheck.firstSetBit == STD_OK) && - (pState->selfCheck.extractValueFromRegister == STD_OK) && (pState->selfCheck.parseVoltageReadall == STD_OK)) { - /* check has passed, return value already set */ - } else { - retval = STD_NOT_OK; - } - - return retval; -} - /*========== Extern Function Implementations ================================*/ extern void MXM_CheckIfErrorCounterCanBeReset(MXM_MONITORING_INSTANCE_s *pInstance) { FAS_ASSERT(pInstance != NULL_PTR); @@ -1008,7 +973,7 @@ extern STD_RETURN_TYPE_e MXM_ProcessOpenWire(const MXM_MONITORING_INSTANCE_s *co FAS_ASSERT(kpkInstance->pOpenwire_table != NULL_PTR); const uint8_t numberOfSatellites = MXM_5XGetNumberOfSatellites(kpkInstance->pInstance5X); - static_assert( + f_static_assert( (((uint16_t)BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2u * MXM_MAXIMUM_NR_OF_MODULES)) <= (uint8_t)UINT8_MAX), "please check assumptions: code cannot handle number of modules"); const uint8_t messageLength = BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2u * numberOfSatellites); @@ -1051,6 +1016,8 @@ extern STD_RETURN_TYPE_e MXM_ProcessOpenWire(const MXM_MONITORING_INSTANCE_s *co extern STD_RETURN_TYPE_e MXM_ConstructBalancingBuffer(MXM_BALANCING_STATE_s *pBalancingInstance) { FAS_ASSERT(pBalancingInstance != NULL_PTR); FAS_ASSERT(pBalancingInstance->pBalancingControl_table != NULL_PTR); + /* check for impossible configuration */ + FAS_ASSERT((BS_NR_OF_CELL_BLOCKS_PER_MODULE <= MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE)); STD_RETURN_TYPE_e retval = STD_OK; /* Re-Initialize the cells to balance at each iteration */ @@ -1063,15 +1030,14 @@ extern STD_RETURN_TYPE_e MXM_ConstructBalancingBuffer(MXM_BALANCING_STATE_s *pBa e.g. : Cell 2 in the module corresponds to index 1 in the database the cell index is even, but the database index is odd. */ - static_assert((MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE <= BS_NR_OF_CELLS_PER_MODULE), "impossible configuration"); /* Iterate over all the cells of the module 'moduleBalancingIndex' in a daisy-chain */ if (pBalancingInstance->moduleBalancingIndex < MXM_MAXIMUM_NR_OF_MODULES) { - for (uint8_t c = 0; c < BS_NR_OF_CELLS_PER_MODULE; c++) { + for (uint8_t c = 0; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { /* Determine the position of the cell 'c' of module 'moduleBalancingIndex' in the DB */ uint8_t stringNumber = 0u; uint16_t moduleNumber = 0u; MXM_ConvertModuleToString(pBalancingInstance->moduleBalancingIndex, &stringNumber, &moduleNumber); - const uint16_t dBIndex = (moduleNumber * BS_NR_OF_CELLS_PER_MODULE) + c; + const uint16_t dBIndex = (moduleNumber * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c; if (pBalancingInstance->pBalancingControl_table->balancingState[stringNumber][dBIndex] == 1u) { /* Cell 'c' of module '::moduleBalancingIndex' needs to be balanced. Need to determine the balancing order --> even or odd cells? @@ -1110,17 +1076,17 @@ extern STD_RETURN_TYPE_e MXM_ParseVoltagesIntoDB(const MXM_MONITORING_INSTANCE_s FAS_ASSERT(kpkInstance != NULL_PTR); FAS_ASSERT(kpkInstance->pCellVoltages_table != NULL_PTR); FAS_ASSERT(kpkInstance->pCellTemperatures_table != NULL_PTR); - FAS_ASSERT((BS_NR_OF_MODULES * BS_NR_OF_STRINGS) <= MXM_MAXIMUM_NR_OF_MODULES); + FAS_ASSERT((BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_STRINGS) <= MXM_MAXIMUM_NR_OF_MODULES); uint16_t numberValidVoltageMeasurements[BS_NR_OF_STRINGS] = {0}; /* voltages */ - for (uint8_t i_mod = 0; i_mod < (BS_NR_OF_MODULES * BS_NR_OF_STRINGS); i_mod++) { + for (uint8_t i_mod = 0; i_mod < (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_STRINGS); i_mod++) { const bool moduleIsConnected = MXM_CheckIfADeviceIsConnected(kpkInstance, i_mod); uint8_t stringNumber = 0u; uint16_t moduleNumber = 0u; MXM_ConvertModuleToString(i_mod, &stringNumber, &moduleNumber); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); - FAS_ASSERT(moduleNumber < BS_NR_OF_MODULES); + FAS_ASSERT(moduleNumber < BS_NR_OF_MODULES_PER_STRING); kpkInstance->pCellVoltages_table->moduleVoltage_mV[stringNumber][moduleNumber] = kpkInstance->localVoltages.blockVoltages[i_mod]; /* every iteration that we hit a string first (module 0), we reset the packvoltage counter */ @@ -1129,9 +1095,10 @@ extern STD_RETURN_TYPE_e MXM_ParseVoltagesIntoDB(const MXM_MONITORING_INSTANCE_s } kpkInstance->pCellVoltages_table->packVoltage_mV[stringNumber] += (int32_t)kpkInstance->localVoltages.blockVoltages[i_mod]; - FAS_ASSERT(BS_NR_OF_CELLS_PER_MODULE <= MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE); /*!< invalid configuration! */ - for (uint8_t i_bat = 0; i_bat < BS_NR_OF_CELLS_PER_MODULE; i_bat++) { - uint16_t cell_counter_db = (moduleNumber * BS_NR_OF_CELLS_PER_MODULE) + i_bat; + FAS_ASSERT( + BS_NR_OF_CELL_BLOCKS_PER_MODULE <= MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE); /*!< invalid configuration! */ + for (uint8_t i_bat = 0; i_bat < BS_NR_OF_CELL_BLOCKS_PER_MODULE; i_bat++) { + uint16_t cell_counter_db = (moduleNumber * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + i_bat; uint16_t cell_counter_max = ((uint16_t)i_mod * MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE) + i_bat; const uint16_t cellVoltageLocal_mV = kpkInstance->localVoltages.cellVoltages_mV[cell_counter_max]; if ((int32_t)cellVoltageLocal_mV > INT16_MAX) { @@ -1155,13 +1122,13 @@ extern STD_RETURN_TYPE_e MXM_ParseVoltagesIntoDB(const MXM_MONITORING_INSTANCE_s /* temperatures */ uint16_t numberValidTemperatureMeasurements[BS_NR_OF_STRINGS] = {0}; - for (uint8_t i_mod = 0; i_mod < (BS_NR_OF_MODULES * BS_NR_OF_STRINGS); i_mod++) { + for (uint8_t i_mod = 0; i_mod < (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_STRINGS); i_mod++) { const bool moduleIsConnected = MXM_CheckIfADeviceIsConnected(kpkInstance, i_mod); uint8_t stringNumber = 0u; uint16_t moduleNumber = 0u; MXM_ConvertModuleToString(i_mod, &stringNumber, &moduleNumber); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); - FAS_ASSERT(moduleNumber < BS_NR_OF_MODULES); + FAS_ASSERT(moduleNumber < BS_NR_OF_MODULES_PER_STRING); /* store aux measurement from AUX2 (MUX0) */ if (kpkInstance->muxCounter < BS_NR_OF_TEMP_SENSORS_PER_MODULE) { @@ -1209,37 +1176,33 @@ extern void MXM_InitializeStateStruct( pBalancingInstance->previousTimeStamp = 0u; pBalancingInstance->currentTimeStamp = 0u; - pMonitoringInstance->resetNecessary = false; - pMonitoringInstance->errorCounter = 0u; - pMonitoringInstance->timestampLastError = 0u; - pMonitoringInstance->state = MXM_STATEMACHINE_STATES_UNINITIALIZED; - pMonitoringInstance->operationSubstate = MXM_INIT_ENTRY; - pMonitoringInstance->allowStartup = false; - pMonitoringInstance->operationRequested = false; - pMonitoringInstance->firstMeasurementDone = false; - pMonitoringInstance->stopRequested = false; - pMonitoringInstance->openwireRequested = false; - pMonitoringInstance->undervoltageAlert = false; - pMonitoringInstance->muxCounter = 0u; - pMonitoringInstance->diagnosticCounter = MXM_THRESHOLD_DIAGNOSTIC_AFTER_CYCLES; - pMonitoringInstance->dcByte = MXM_DC_EMPTY; - pMonitoringInstance->mxmVoltageCellCounter = 0u; - pMonitoringInstance->highest5xDevice = 0u; - pMonitoringInstance->requestStatus5x = MXM_5X_STATE_UNSENT; - pMonitoringInstance->batteryCmdBuffer.regAddress = MXM_REG_VERSION; - pMonitoringInstance->batteryCmdBuffer.lsb = 0u; - pMonitoringInstance->batteryCmdBuffer.msb = 0u; - pMonitoringInstance->batteryCmdBuffer.blocksize = 0u; - pMonitoringInstance->batteryCmdBuffer.deviceAddress = 0u; - pMonitoringInstance->batteryCmdBuffer.model = MXM_GetModelIdOfDaisyChain(); - pMonitoringInstance->resultSelfCheck = STD_NOT_OK; - pMonitoringInstance->selfCheck.crc = STD_NOT_OK; - pMonitoringInstance->selfCheck.conv = STD_NOT_OK; - pMonitoringInstance->selfCheck.firstSetBit = STD_NOT_OK; - pMonitoringInstance->selfCheck.extractValueFromRegister = STD_NOT_OK; - pMonitoringInstance->selfCheck.parseVoltageReadall = STD_NOT_OK; - pMonitoringInstance->selfCheck.addressSpaceChecker = STD_NOT_OK; - pMonitoringInstance->selfCheck.fmeaStatusASCI = STD_NOT_OK; + pMonitoringInstance->resetNecessary = false; + pMonitoringInstance->errorCounter = 0u; + pMonitoringInstance->timestampLastError = 0u; + pMonitoringInstance->timestampInit = 0u; + pMonitoringInstance->state = MXM_STATEMACHINE_STATES_UNINITIALIZED; + pMonitoringInstance->operationSubstate = MXM_INIT_ENTRY; + pMonitoringInstance->allowStartup = false; + pMonitoringInstance->operationRequested = false; + pMonitoringInstance->firstMeasurementDone = false; + pMonitoringInstance->stopRequested = false; + pMonitoringInstance->openwireRequested = false; + pMonitoringInstance->undervoltageAlert = false; + pMonitoringInstance->muxCounter = 0u; + pMonitoringInstance->diagnosticCounter = MXM_THRESHOLD_DIAGNOSTIC_AFTER_CYCLES; + pMonitoringInstance->dcByte = MXM_DC_EMPTY; + pMonitoringInstance->mxmVoltageCellCounter = 0u; + pMonitoringInstance->highest5xDevice = 0u; + pMonitoringInstance->requestStatus5x = MXM_5X_STATE_UNSENT; + pMonitoringInstance->batteryCmdBuffer.regAddress = MXM_REG_VERSION; + pMonitoringInstance->batteryCmdBuffer.lsb = 0u; + pMonitoringInstance->batteryCmdBuffer.msb = 0u; + pMonitoringInstance->batteryCmdBuffer.blocksize = 0u; + pMonitoringInstance->batteryCmdBuffer.deviceAddress = 0u; + pMonitoringInstance->batteryCmdBuffer.model = MXM_GetModelIdOfDaisyChain(); + pMonitoringInstance->resultSelfCheck = STD_NOT_OK; + /* for the "static" pre-init self-checks: do not reset if the result has passed; it will not change; FMEA can change */ + pMonitoringInstance->selfCheck.fmeaStatusASCI = STD_NOT_OK; for (uint32_t i = 0u; i < (MXM_MAXIMUM_NR_OF_MODULES * MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE); i++) { pMonitoringInstance->localVoltages.cellVoltages_mV[i] = 0u; @@ -1257,7 +1220,7 @@ extern void MXM_InitializeStateStruct( pMonitoringInstance->registry[i].connected = false; pMonitoringInstance->registry[i].deviceAddress = 0u; pMonitoringInstance->registry[i].model = MXM_MODEL_ID_NONE; - pMonitoringInstance->registry[i].siliconVersion = MXM_siliconVersion_invalid; + pMonitoringInstance->registry[i].siliconVersion = MXM_SILICON_VERSION_INVALID; pMonitoringInstance->registry[i].deviceID = 0u; pMonitoringInstance->registry[i].registerStatus1 = 0u; pMonitoringInstance->registry[i].registerStatus2 = 0u; @@ -1271,6 +1234,43 @@ extern void MXM_InitializeStateStruct( } } +extern STD_RETURN_TYPE_e MXM_PreInitSelfCheck(MXM_MONITORING_INSTANCE_s *pState) { + FAS_ASSERT(pState != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; + MXM_SELFCHECK_s *selfCheck = &pState->selfCheck; + FAS_ASSERT(selfCheck != NULL_PTR); + if (selfCheck->crc == STD_NOT_OK) { + selfCheck->crc = MXM_CRC8SelfTest(); + } + if (selfCheck->conv == STD_NOT_OK) { + selfCheck->conv = MXM_ConvertTest(); + } + if (selfCheck->firstSetBit == STD_NOT_OK) { + selfCheck->firstSetBit = MXM_FirstSetBitTest(); + } + if (selfCheck->extractValueFromRegister == STD_NOT_OK) { + selfCheck->extractValueFromRegister = MXM_ExtractValueFromRegisterTest(); + } + if (selfCheck->parseVoltageReadall == STD_NOT_OK) { + selfCheck->parseVoltageReadall = MXM_ParseVoltageReadallTest(pState); + } + if (selfCheck->addressSpaceChecker == STD_NOT_OK) { + selfCheck->addressSpaceChecker = MXM_5XUserAccessibleAddressSpaceCheckerSelfCheck(); + } + + if ((selfCheck->crc == STD_OK) && (selfCheck->addressSpaceChecker == STD_OK) && (selfCheck->conv == STD_OK) && + (selfCheck->firstSetBit == STD_OK) && (selfCheck->extractValueFromRegister == STD_OK) && + (selfCheck->parseVoltageReadall == STD_OK)) { + /* check has passed, return value already set */ + } else { + retval = STD_NOT_OK; + } + /* report to diag module, Maxim driver reports always to string 0 (current implementation just has one interface) */ + (void)DIAG_CheckEvent(retval, DIAG_ID_AFE_CONFIG, DIAG_SYSTEM, 0u); + + return retval; +} + extern MXM_MONITORING_STATE_e must_check_return MXM_MonGetVoltages(MXM_MONITORING_INSTANCE_s *pState, MXM_REG_NAME_e regAddress) { FAS_ASSERT(pState != NULL_PTR); @@ -1316,13 +1316,13 @@ extern void MXM_StateMachine(MXM_MONITORING_INSTANCE_s *pInstance) { if (pInstance->state == MXM_STATEMACHINE_STATES_UNINITIALIZED) { pInstance->requestStatus5x = MXM_5X_STATE_UNSENT; + pInstance->timestampInit = OS_GetTickCount(); MXM_MonRegistryInit(pInstance); pInstance->state = MXM_STATEMACHINE_STATES_SELFCHECK_PRE_INIT; } switch (pInstance->state) { case MXM_STATEMACHINE_STATES_SELFCHECK_PRE_INIT: - /* TODO proper selfchecks, that are only executed during IBIT, CBIT and PBIT */ pInstance->resultSelfCheck = MXM_PreInitSelfCheck(pInstance); if (pInstance->resultSelfCheck == STD_OK) { pInstance->requestStatus5x = MXM_5X_STATE_UNSENT; @@ -1381,6 +1381,8 @@ extern void MXM_StateMachine(MXM_MONITORING_INSTANCE_s *pInstance) { pInstance->selfCheck.fmeaStatusASCI = STD_OK; const STD_RETURN_TYPE_e resultNumberOfSatellitesGood = MXM_5XGetNumberOfSatellitesGood(pInstance->pInstance5X); + /* report to diag module, Maxim driver reports always to string 0 (current implementation just has one interface) */ + (void)DIAG_CheckEvent(resultNumberOfSatellitesGood, DIAG_ID_AFE_CONFIG, DIAG_STRING, 0u); if ((pInstance->resultSelfCheck == STD_OK) && (pInstance->selfCheck.fmeaStatusASCI == STD_OK) && (resultNumberOfSatellitesGood == STD_OK)) { pInstance->resultSelfCheck = STD_OK; diff --git a/src/app/driver/afe/maxim/common/mxm_1785x.h b/src/app/driver/afe/maxim/common/mxm_1785x.h index d29a6e4c..8fbef739 100644 --- a/src/app/driver/afe/maxim/common/mxm_1785x.h +++ b/src/app/driver/afe/maxim/common/mxm_1785x.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_1785x.h * @author foxBMS Team * @date 2019-01-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -191,7 +192,7 @@ extern bool must_check_return MXM_HandleStateReadall( * database. * @param[in,out] kpkInstance pointer to instance of the Maxim monitoring * state-machine - * @return returns the return value of the database write function #DATA_Write_1_DataBlock() + * @return returns the return value of the database write function #DATA_Write1DataBlock() */ extern STD_RETURN_TYPE_e MXM_ProcessOpenWire(const MXM_MONITORING_INSTANCE_s *const kpkInstance); @@ -266,6 +267,29 @@ extern STD_RETURN_TYPE_e MXM_ParseVoltagesIntoDB(const MXM_MONITORING_INSTANCE_s */ extern MXM_MODEL_ID_e MXM_GetModelIdOfDaisyChain(void); +/** + * @brief Execute all preinit selfchecks. + * @details Executes the following self-checks: + * - #MXM_CRC8SelfTest() + * - #MXM_ConvertTest() + * - #MXM_FirstSetBitTest() + * - #MXM_ExtractValueFromRegisterTest() + * - #MXM_ParseVoltageReadallTest() + * - #MXM_5XUserAccessibleAddressSpaceCheckerSelfCheck() + * + * These self-checks do not need an initialized daisy-chain + * and can therefore be executed at startup of the + * state-machine. + * + * After execution of each test, the return value is stored in + * the supplied state-struct. The function returns whether the + * self-check has successfully passed. + * @param[in,out] pState pointer to the state-struct, will write status into + * @return #STD_OK on success, #STD_NOT_OK on failure, + * return value has to be used + */ +extern STD_RETURN_TYPE_e MXM_PreInitSelfCheck(MXM_MONITORING_INSTANCE_s *pState); + /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST extern STD_RETURN_TYPE_e TEST_MXM_ParseVoltageReadallTest(MXM_MONITORING_INSTANCE_s *pInstance); diff --git a/src/app/driver/afe/maxim/common/mxm_1785x_tools.c b/src/app/driver/afe/maxim/common/mxm_1785x_tools.c index ea1e8513..d561ffdb 100644 --- a/src/app/driver/afe/maxim/common/mxm_1785x_tools.c +++ b/src/app/driver/afe/maxim/common/mxm_1785x_tools.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_1785x_tools.c * @author foxBMS Team * @date 2020-07-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -79,6 +80,7 @@ static uint8_t MXM_FirstSetBit(uint16_t bitmask); /*========== Static Function Implementations ================================*/ static uint8_t MXM_FirstSetBit(uint16_t bitmask) { + /* AXIVION Routine Generic-MissingParameterAssert: bitmask: parameter accepts whole range */ uint8_t retval = 0; while (((bitmask >> retval) & 1u) == 0u) { retval++; @@ -115,6 +117,10 @@ extern void MXM_Convert( MXM_CONVERSION_TYPE_e convType, uint32_t fullScaleReference_mV) { FAS_ASSERT(pTarget != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: lsb: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: msb: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: convType: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: fullScaleReference_mV: parameter accepts whole range */ uint16_t temporaryVoltage = 0; MXM_ExtractValueFromRegister(lsb, msb, MXM_REG_ADC_14BIT_VALUE, &temporaryVoltage); @@ -175,6 +181,9 @@ extern STD_RETURN_TYPE_e must_check_return MXM_ConvertTest(void) { extern void MXM_ExtractValueFromRegister(uint8_t lsb, uint8_t msb, MXM_REG_BM bitmask, uint16_t *pValue) { /* input sanitation */ FAS_ASSERT(pValue != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: lsb: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: msb: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: bitmask: parameter accepts whole range */ /* find lowest bit that is 1 in bitmask */ uint8_t start = MXM_FirstSetBit(bitmask); @@ -228,6 +237,8 @@ extern STD_RETURN_TYPE_e must_check_return MXM_ExtractValueFromRegisterTest(void extern void MXM_Unipolar14BitInto16Bit(uint16_t inputValue, uint8_t *lsb, uint8_t *msb) { FAS_ASSERT(lsb != NULL_PTR); FAS_ASSERT(msb != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: inputValue: parameter accepts whole range */ + uint16_t workingCopy = inputValue; /* left shift into 16bit position */ workingCopy = workingCopy << 2u; @@ -239,6 +250,9 @@ extern void MXM_Unipolar14BitInto16Bit(uint16_t inputValue, uint8_t *lsb, uint8_ } extern uint16_t MXM_VoltageIntoUnipolar14Bit(uint16_t voltage_mV, uint16_t fullscaleReference_mV) { + /* AXIVION Routine Generic-MissingParameterAssert: voltage_mV: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: fullscaleReference_mV: parameter accepts whole range */ + uint32_t temporaryVoltage = voltage_mV; /* multiply by the 14bit fullscale */ temporaryVoltage = temporaryVoltage * 0x3FFFu; @@ -255,18 +269,18 @@ extern void MXM_ConvertModuleToString( /* the module number cannot be higher than the highest module in the daisy-chain */ FAS_ASSERT(moduleNumber < MXM_MAXIMUM_NR_OF_MODULES); /* the module number cannot be higher than number of maximum modules in the string */ - FAS_ASSERT(moduleNumber < (BS_NR_OF_STRINGS * BS_NR_OF_MODULES)); + FAS_ASSERT(moduleNumber < (BS_NR_OF_STRINGS * BS_NR_OF_MODULES_PER_STRING)); /* calculate string number */ - *pStringNumber = (uint8_t)(moduleNumber / BS_NR_OF_MODULES); + *pStringNumber = (uint8_t)(moduleNumber / BS_NR_OF_MODULES_PER_STRING); FAS_ASSERT(*pStringNumber <= BS_NR_OF_STRINGS); - /* calculate module number and handle edge-case BS_NR_OF_MODULES == 1 */ - if (1u == BS_NR_OF_MODULES) { + /* calculate module number and handle edge-case BS_NR_OF_MODULES_PER_STRING == 1 */ + if (1u == BS_NR_OF_MODULES_PER_STRING) { *pModuleNumberInString = 0u; } else { - *pModuleNumberInString = moduleNumber % BS_NR_OF_MODULES; + *pModuleNumberInString = moduleNumber % BS_NR_OF_MODULES_PER_STRING; } - FAS_ASSERT(*pModuleNumberInString <= BS_NR_OF_MODULES); + FAS_ASSERT(*pModuleNumberInString <= BS_NR_OF_MODULES_PER_STRING); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/afe/maxim/common/mxm_1785x_tools.h b/src/app/driver/afe/maxim/common/mxm_1785x_tools.h index a8eee15a..21393698 100644 --- a/src/app/driver/afe/maxim/common/mxm_1785x_tools.h +++ b/src/app/driver/afe/maxim/common/mxm_1785x_tools.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_1785x_tools.h * @author foxBMS Team * @date 2020-07-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -86,6 +87,7 @@ typedef enum { typedef enum { MXM_INIT_ENTRY, MXM_INIT_DEVCFG1, + MXM_INIT_DEVCFG2, MXM_INIT_SET_STATUS2, MXM_INIT_STATUS1, MXM_INIT_GET_VERSION, @@ -150,9 +152,11 @@ typedef enum { MXM_OP_PINOPEN_PROCESS_OPENWIRE, MXM_OP_PINOPEN_RESTORE_CURRENT_SOURCE_CONF, MXM_OP_BAL_ENTRY, + MXM_OP_BAL_CONTROL_STOP_BALANCING, MXM_OP_BAL_CONTROL_RESET_ALL, MXM_OP_BAL_CONTROL_SET_ALL, MXM_OP_BAL_START, + MXM_OP_BAL_READ_BALSTAT, MXM_OP_BAL_EXIT, MXM_OP_CYCLE_END_ENTRY, MXM_OP_INCREMENT_MUX_COUNTER, @@ -187,16 +191,17 @@ typedef struct { /** struct describing an entry into the monitoring registry */ typedef struct { - bool connected; /*!< state variable, indicates whether monitoring IC is connected */ - uint8_t deviceAddress; /*!< address that has been assigned during enumeration */ - MXM_MODEL_ID_e model; /*!< model (e.g. 17853) */ - MXM_siliconVersion_e siliconVersion; /*!< silicon version of chip */ - uint32_t deviceID; /*!< 24-bit unique device ID */ - uint16_t registerStatus1; /*!< content of the STATUS1 register */ - uint16_t registerStatus2; /*!< content of the STATUS2 register */ - uint16_t registerStatus3; /*!< content of the STATUS3 register */ - uint16_t registerFmea1; /*!< content of the FMEA1 register */ - uint16_t registerFmea2; /*!< content of the FMEA2 register */ + bool connected; /*!< state variable, indicates whether monitoring IC is connected */ + uint8_t deviceAddress; /*!< address that has been assigned during enumeration */ + MXM_MODEL_ID_e model; /*!< model (e.g. 17853) */ + MXM_SILICON_VERSION_e siliconVersion; /*!< silicon version of chip */ + uint32_t deviceID; /*!< 24-bit unique device ID */ + uint16_t registerStatus1; /*!< content of the STATUS1 register */ + uint16_t registerStatus2; /*!< content of the STATUS2 register */ + uint16_t registerStatus3; /*!< content of the STATUS3 register */ + uint16_t registerFmea1; /*!< content of the FMEA1 register */ + uint16_t registerFmea2; /*!< content of the FMEA2 register */ + uint16_t registerBalstat; /*!< content of the BALSTAT register */ } MXM_REGISTRY_ENTRY_s; /** @@ -227,6 +232,7 @@ typedef struct { bool resetNecessary; /*!< a reset of the whole driver is requested (due to an error) */ uint8_t errorCounter; /*!< counts the number of errors and issues a reset when the counter trips */ uint32_t timestampLastError; /*!< timestamp of last error counter increment; will be reset if old enough */ + uint32_t timestampInit; /*!< timestamp of the moment that init has been initialized */ MXM_STATEMACHINE_STATES_e state; /*!< state of the maxim state-machine */ MXM_STATEMACHINE_OPERATION_STATES_e operationSubstate; /*!< substate during operation of monitoring */ bool allowStartup; /*!< indicates whether start of state-machine has been requested */ @@ -260,7 +266,7 @@ typedef struct { * in module 0 (modules are numbered from 0 to 31) will be in entry 4. * The voltage of cell 14 of module 1 will be in entry 27. This is independent * of the size of the setup which is defined in the defines - * #BS_NR_OF_CELLS_PER_MODULE and #BS_NR_OF_MODULES. + * #BS_NR_OF_CELL_BLOCKS_PER_MODULE and #BS_NR_OF_MODULES_PER_STRING. * Therefore, the size of the arrays inside this struct is defined as * #MXM_MAXIMUM_NR_OF_MODULES times #MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE. */ @@ -369,7 +375,7 @@ extern uint16_t MXM_VoltageIntoUnipolar14Bit(uint16_t voltage_mV, uint16_t fulls * modules are in the same daisy-chain but belong to different * strings). * - * This function assumes that a string contains #BS_NR_OF_MODULES modules + * This function assumes that a string contains #BS_NR_OF_MODULES_PER_STRING modules * in #BS_NR_OF_STRINGS strings and that they are connected in * a daisy-chain. * @param[in] moduleNumber number of the module in the daisy-chain (starts with 0) diff --git a/src/app/driver/afe/maxim/common/mxm_41b_register_map.h b/src/app/driver/afe/maxim/common/mxm_41b_register_map.h index f4254d43..021ca743 100644 --- a/src/app/driver/afe/maxim/common/mxm_41b_register_map.h +++ b/src/app/driver/afe/maxim/common/mxm_41b_register_map.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_41b_register_map.h * @author foxBMS Team * @date 2020-06-25 (date of creation) - * @updated 2021-06-16 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * diff --git a/src/app/driver/afe/maxim/common/mxm_afe_dma.c b/src/app/driver/afe/maxim/common/mxm_afe_dma.c index 374ec2f2..8ec89ea3 100644 --- a/src/app/driver/afe/maxim/common/mxm_afe_dma.c +++ b/src/app/driver/afe/maxim/common/mxm_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_afe_dma.c * @author foxBMS Team * @date 2020-06-16 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * @@ -69,6 +70,8 @@ /* Function called on DMA complete interrupts (TX and RX). */ void AFE_DmaCallback(uint8_t spiIndex) { /* This function is not implemented. */ + /* AXIVION Routine Generic-MissingParameterAssert: spiIndex: parameter is unused */ + (void)spiIndex; FAS_ASSERT(FAS_TRAP); } diff --git a/src/app/driver/afe/maxim/common/mxm_afe_dma.h b/src/app/driver/afe/maxim/common/mxm_afe_dma.h index 61ae6b20..b3302285 100644 --- a/src/app/driver/afe/maxim/common/mxm_afe_dma.h +++ b/src/app/driver/afe/maxim/common/mxm_afe_dma.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_afe_dma.h * @author foxBMS Team * @date 2020-06-16 (date of creation) - * @updated 2020-06-16 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * diff --git a/src/app/driver/afe/maxim/common/mxm_basic_defines.h b/src/app/driver/afe/maxim/common/mxm_basic_defines.h index 11e0d3f3..de5a8d5e 100644 --- a/src/app/driver/afe/maxim/common/mxm_basic_defines.h +++ b/src/app/driver/afe/maxim/common/mxm_basic_defines.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_basic_defines.h * @author foxBMS Team * @date 2020-02-11 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -118,24 +119,24 @@ typedef enum { /** valid values for the silicon version of connected monitoring ICs */ typedef enum { - MXM_siliconVersion_0 = 0x0u, /*!< initialization value */ - MXM_siliconVersion_1 = 0x1u, /*!< silicon version 1 (known from data-sheet) */ - MXM_siliconVersion_2 = 0x2u, /*!< silicon version 2 */ - MXM_siliconVersion_3 = 0x3u, /*!< silicon version 3 */ - MXM_siliconVersion_4 = 0x4u, /*!< silicon version 4 (located on old EV kit 2018) */ - MXM_siliconVersion_5 = 0x5u, /*!< silicon version 5 (located on new EV kit 04.2019) */ - MXM_siliconVersion_6 = 0x6u, /*!< silicon version 6 */ - MXM_siliconVersion_7 = 0x7u, /*!< silicon version 7 (most recent as of 2021-11-21) */ - MXM_siliconVersion_8 = 0x8u, /*!< unknown silicon version */ - MXM_siliconVersion_9 = 0x9u, /*!< unknown silicon version */ - MXM_siliconVersion_10 = 0xAu, /*!< unknown silicon version */ - MXM_siliconVersion_11 = 0xBu, /*!< unknown silicon version */ - MXM_siliconVersion_12 = 0xCu, /*!< unknown silicon version */ - MXM_siliconVersion_13 = 0xDu, /*!< unknown silicon version */ - MXM_siliconVersion_14 = 0xEu, /*!< unknown silicon version */ - MXM_siliconVersion_15 = 0xFu, /*!< unknown silicon version */ - MXM_siliconVersion_invalid = 0x10u, /*!< due to the register size, no version number can take this value */ -} MXM_siliconVersion_e; + MXM_SILICON_VERSION_0 = 0x0u, /*!< initialization value */ + MXM_SILICON_VERSION_1 = 0x1u, /*!< silicon version 1 (known from data-sheet) */ + MXM_SILICON_VERSION_2 = 0x2u, /*!< silicon version 2 */ + MXM_SILICON_VERSION_3 = 0x3u, /*!< silicon version 3 */ + MXM_SILICON_VERSION_4 = 0x4u, /*!< silicon version 4 (located on old EV kit 2018) */ + MXM_SILICON_VERSION_5 = 0x5u, /*!< silicon version 5 (located on new EV kit 04.2019) */ + MXM_SILICON_VERSION_6 = 0x6u, /*!< silicon version 6 */ + MXM_SILICON_VERSION_7 = 0x7u, /*!< silicon version 7 (most recent as of 2021-11-21) */ + MXM_SILICON_VERSION_8 = 0x8u, /*!< unknown silicon version */ + MXM_SILICON_VERSION_9 = 0x9u, /*!< unknown silicon version */ + MXM_SILICON_VERSION_10 = 0xAu, /*!< unknown silicon version */ + MXM_SILICON_VERSION_11 = 0xBu, /*!< unknown silicon version */ + MXM_SILICON_VERSION_12 = 0xCu, /*!< unknown silicon version */ + MXM_SILICON_VERSION_13 = 0xDu, /*!< unknown silicon version */ + MXM_SILICON_VERSION_14 = 0xEu, /*!< unknown silicon version */ + MXM_SILICON_VERSION_15 = 0xFu, /*!< unknown silicon version */ + MXM_SILICON_VERSION_INVALID = 0x10u, /*!< due to the register size, no version number can take this value */ +} MXM_SILICON_VERSION_e; /** Conversion Type */ typedef enum { diff --git a/src/app/driver/afe/maxim/common/mxm_battery_management.c b/src/app/driver/afe/maxim/common/mxm_battery_management.c index da03b75d..b6def0fb 100644 --- a/src/app/driver/afe/maxim/common/mxm_battery_management.c +++ b/src/app/driver/afe/maxim/common/mxm_battery_management.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_battery_management.c * @author foxBMS Team * @date 2019-01-14 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -56,6 +57,7 @@ /*========== Includes =======================================================*/ #include "mxm_battery_management.h" +#include "diag.h" #include "os.h" /*========== Macros and Definitions =========================================*/ @@ -227,18 +229,12 @@ static void MXM_5XStateHandler41BFmeaCheck(MXM_5X_INSTANCE_s *pInstance5x, MXM_4 static void MXM_5XStateHandlerInit(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTANCE_s *pInstance41b); /** - * @brief Handle the state #MXM_STATEMACH_5X_WRITEALL + * @brief Handle the states #MXM_STATEMACH_5X_WRITEALL and #MXM_STATEMACH_5X_WRITE_DEVICE * @param[in,out] pInstance5x pointer to the state-struct of the battery management state machine * @param[in,out] pInstance41b pointer to the state-struct of the bridge IC + * @param[in] writeDevice true: write device, false: write all */ -static void MXM_5XStateHandlerWriteAll(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTANCE_s *pInstance41b); - -/** - * @brief Handle the state #MXM_STATEMACH_5X_WRITE_DEVICE - * @param[in,out] pInstance5x pointer to the state-struct of the battery management state machine - * @param[in,out] pInstance41b pointer to the state-struct of the bridge IC - */ -static void MXM_5XStateHandlerWriteDevice(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTANCE_s *pInstance41b); +static void MXM_5XStateHandlerWrite(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTANCE_s *pInstance41b, bool writeDevice); /** * @brief Handle the state #MXM_STATEMACH_5X_READALL @@ -258,6 +254,7 @@ static void MXM_5XClearCommandBuffer(MXM_5X_INSTANCE_s *pInstance) { static STD_RETURN_TYPE_e MXM_5XIsUserAccessibleRegister(uint8_t regAddress, MXM_MODEL_ID_e model) { FAS_ASSERT(model <= MXM_MODEL_ID_invalid); + /* AXIVION Routine Generic-MissingParameterAssert: regAddress: parameter accepts whole range */ STD_RETURN_TYPE_e retval = STD_NOT_OK; @@ -282,6 +279,8 @@ static STD_RETURN_TYPE_e MXM_5XIsUserAccessibleRegister(uint8_t regAddress, MXM_ } static STD_RETURN_TYPE_e MXM_52IsUserAccessibleRegister(uint8_t regAddress) { + /* AXIVION Routine Generic-MissingParameterAssert: regAddress: parameter accepts whole range */ + STD_RETURN_TYPE_e retval = STD_NOT_OK; /* check if regAddress is outside user-accessible area */ /* AXIVION Disable Style Generic-NoMagicNumbers: memory limits of ICs are specific and unchangeable, therefore hardcoded */ @@ -795,11 +794,11 @@ static void MXM_5XStateHandlerInit(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTA } } /* update number of satellites */ - pInstance5x->numberOfSatellites = (uint8_t)( - (pInstance5x->rxBuffer[HELLOALL_RX_LENGTH - 1u] - HELLOALL_START_SEED) & MXM_5X_BIT_MASK_ONE_BYTE); + pInstance5x->numberOfSatellites = + (uint8_t)((pInstance5x->rxBuffer[HELLOALL_RX_LENGTH - 1u] - HELLOALL_START_SEED) & MXM_5X_BIT_MASK_ONE_BYTE); /* Plausibility check, compare with preset number of satellites */ - if (pInstance5x->numberOfSatellites == (BS_NR_OF_MODULES * BS_NR_OF_STRINGS)) { + if (pInstance5x->numberOfSatellites == (BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_STRINGS)) { pInstance5x->numberOfSatellitesIsGood = STD_OK; } @@ -814,53 +813,29 @@ static void MXM_5XStateHandlerInit(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTA } } -static void MXM_5XStateHandlerWriteAll(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTANCE_s *pInstance41b) { +static void MXM_5XStateHandlerWrite( + MXM_5X_INSTANCE_s *pInstance5x, + MXM_41B_INSTANCE_s *pInstance41b, + bool writeDevice) { FAS_ASSERT(pInstance5x != NULL_PTR); FAS_ASSERT(pInstance41b != NULL_PTR); if (pInstance5x->substate == MXM_5X_ENTRY_SUBSTATE) { /* entry of state --> set to first substate */ - MXM_5XTransitionToSubstate(pInstance5x, MXM_5X_WRITEALL_UART_TRANSACTION); + MXM_5XTransitionToSubstate(pInstance5x, MXM_5X_WRITE_UART_TRANSACTION); } - if (pInstance5x->substate == MXM_5X_WRITEALL_UART_TRANSACTION) { + if (pInstance5x->substate == MXM_5X_WRITE_UART_TRANSACTION) { if (pInstance5x->status41b == MXM_41B_STATE_UNSENT) { - const STD_RETURN_TYPE_e resultAddressCorrect = MXM_5XConstructCommandBufferWriteall(pInstance5x); - FAS_ASSERT(resultAddressCorrect == STD_OK); - const STD_RETURN_TYPE_e stateRequestReturn = MXM_41BSetStateRequest( - pInstance41b, - MXM_STATEMACH_41B_UART_TRANSACTION, - pInstance5x->commandBuffer, - pInstance5x->commandBufferCurrentLength, - 0, - pInstance5x->rxBuffer, - pInstance5x->commandBufferCurrentLength, - &pInstance5x->status41b); - /* TODO check CRC */ - FAS_ASSERT(stateRequestReturn == STD_OK); - } else if (pInstance5x->status41b == MXM_41B_STATE_UNPROCESSED) { - /* wait for processing */ - } else if (pInstance5x->status41b == MXM_41B_STATE_ERROR) { - MXM_5XHandle41BErrorState(pInstance5x); - } else if (pInstance5x->status41b == MXM_41B_STATE_PROCESSED) { - MXM_5XSignalSuccess(pInstance5x); - } else { - FAS_ASSERT(FAS_TRAP); - } - } -} - -static void MXM_5XStateHandlerWriteDevice(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_INSTANCE_s *pInstance41b) { - FAS_ASSERT(pInstance5x != NULL_PTR); - FAS_ASSERT(pInstance41b != NULL_PTR); - if (pInstance5x->substate == MXM_5X_ENTRY_SUBSTATE) { - /* entry of state --> set to first substate */ - MXM_5XTransitionToSubstate(pInstance5x, MXM_5X_WRITE_DEVICE_UART_TRANSACTION); - } + if (writeDevice == true) { + /* write device: call function for write device buffer */ + const STD_RETURN_TYPE_e resultAddressCorrect = MXM_5XConstructCommandBufferWriteDevice(pInstance5x); + FAS_ASSERT(resultAddressCorrect == STD_OK); + } else { + /* write all: call function for write all buffer */ + const STD_RETURN_TYPE_e resultAddressCorrect = MXM_5XConstructCommandBufferWriteall(pInstance5x); + FAS_ASSERT(resultAddressCorrect == STD_OK); + } - if (pInstance5x->substate == MXM_5X_WRITE_DEVICE_UART_TRANSACTION) { - if (pInstance5x->status41b == MXM_41B_STATE_UNSENT) { - const STD_RETURN_TYPE_e resultAddressCorrect = MXM_5XConstructCommandBufferWriteDevice(pInstance5x); - FAS_ASSERT(resultAddressCorrect == STD_OK); const STD_RETURN_TYPE_e stateRequestReturn = MXM_41BSetStateRequest( pInstance41b, MXM_STATEMACH_41B_UART_TRANSACTION, @@ -922,8 +897,12 @@ static void MXM_5XStateHandlerReadAll(MXM_5X_INSTANCE_s *pInstance5x, MXM_41B_IN pInstance5x->rxBuffer, ((int32_t)pInstance5x->commandBufferCurrentLength + (2 * (int32_t)pInstance5x->numberOfSatellites))) == 0x00u) { + /* currently only one physical string is supported, therefore reporting always to string 0 */ + (void)DIAG_CheckEvent(STD_OK, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, 0u); MXM_5XTransitionToSubstate(pInstance5x, MXM_5X_READALL_GET_DC); } else { + /* currently only one physical string is supported, therefore reporting always to string 0 */ + (void)DIAG_CheckEvent(STD_NOT_OK, DIAG_ID_AFE_COM_INTEGRITY, DIAG_STRING, 0u); MXM_5XSignalError(pInstance5x); } } else if (pInstance5x->substate == MXM_5X_READALL_GET_DC) { @@ -976,6 +955,8 @@ extern STD_RETURN_TYPE_e MXM_5XGetRXBuffer( uint16_t rxBufferLength) { FAS_ASSERT(kpkInstance != NULL_PTR); FAS_ASSERT(rxBufferLength <= MXM_5X_RX_BUFFER_LEN); + /* AXIVION Routine Generic-MissingParameterAssert: rxBuffer: pointer may be NULL */ + STD_RETURN_TYPE_e retval = STD_OK; if ((rxBuffer != NULL_PTR) && (rxBufferLength != 0u)) { @@ -1014,6 +995,10 @@ extern STD_RETURN_TYPE_e MXM_5XSetStateRequest( MXM_5X_COMMAND_PAYLOAD_s commandPayload, MXM_5X_STATE_REQUEST_STATUS_e *processed) { FAS_ASSERT(pInstance5x != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: state: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: commandPayload: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: processed: pointer may be NULL */ + STD_RETURN_TYPE_e retval = STD_OK; if (state >= MXM_STATEMACH_5X_MAXSTATE) { retval = STD_NOT_OK; @@ -1069,10 +1054,10 @@ void MXM_5XStateMachine(MXM_41B_INSTANCE_s *pInstance41b, MXM_5X_INSTANCE_s *pIn MXM_5XStateHandlerInit(pInstance5x, pInstance41b); break; case MXM_STATEMACH_5X_WRITEALL: - MXM_5XStateHandlerWriteAll(pInstance5x, pInstance41b); + MXM_5XStateHandlerWrite(pInstance5x, pInstance41b, false); break; case MXM_STATEMACH_5X_WRITE_DEVICE: - MXM_5XStateHandlerWriteDevice(pInstance5x, pInstance41b); + MXM_5XStateHandlerWrite(pInstance5x, pInstance41b, true); break; case MXM_STATEMACH_5X_READALL: MXM_5XStateHandlerReadAll(pInstance5x, pInstance41b); diff --git a/src/app/driver/afe/maxim/common/mxm_battery_management.h b/src/app/driver/afe/maxim/common/mxm_battery_management.h index e779521e..94ecafcb 100644 --- a/src/app/driver/afe/maxim/common/mxm_battery_management.h +++ b/src/app/driver/afe/maxim/common/mxm_battery_management.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_battery_management.h * @author foxBMS Team * @date 2019-01-14 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -196,15 +197,10 @@ typedef enum { * #MXM_5X_41B_FMEA_REQUEST */ MXM_5X_41B_FMEA_CHECK, /** substate for the initiation of a uart transaction for the WRITEALL - * command */ - MXM_5X_WRITEALL_UART_TRANSACTION, - /** substate for the verifying the buffer of a WRITEALL transaction */ - MXM_5X_WRITEALL_UART_VERIFY_BUFFER, - /** substate for the initiation of a uart transaction for the WRITEALL - * command */ - MXM_5X_WRITE_DEVICE_UART_TRANSACTION, - /** substate for checking the received CRC in a WRITEDEVICE transaction */ - MXM_5X_WRITE_DEVICE_CHECK_CRC, + * and WRITEDEVICE command */ + MXM_5X_WRITE_UART_TRANSACTION, + /** substate for checking the received CRC in a WRITEALL/WRITEDEVICE transaction */ + MXM_5X_WRITE_CHECK_CRC, /** substate for the initiation of a uart transaction for the READALL * command */ MXM_5X_READALL_UART_TRANSACTION, @@ -259,7 +255,7 @@ typedef struct { * found during the enumeration of all connected monitoring ICs. * Therefore this variable is initialized with 0. This value will be * compared with the expected number of monitoring ICs which is set in - * #BS_NR_OF_MODULES. + * #BS_NR_OF_MODULES_PER_STRING. */ uint8_t numberOfSatellites; /** @@ -267,7 +263,7 @@ typedef struct { * @details This status variable indicates whether the number of found * monitoring ICs in #MXM_5X_INSTANCE_s::numberOfSatellites * matches with the configured number of monitoring ICs in - * #BS_NR_OF_MODULES. This variable is updated during execution of + * #BS_NR_OF_MODULES_PER_STRING. This variable is updated during execution of * the substate * #MXM_5X_INIT_WAKE_UP_SATELLITE_DEVICES_HELLOALL_VERIFY_MSG_AND_COUNT * in the state #MXM_STATEMACH_5X_INIT in #MXM_5XStateMachine(). diff --git a/src/app/driver/afe/maxim/common/mxm_bitextract.c b/src/app/driver/afe/maxim/common/mxm_bitextract.c index 1ab4b682..68e2793b 100644 --- a/src/app/driver/afe/maxim/common/mxm_bitextract.c +++ b/src/app/driver/afe/maxim/common/mxm_bitextract.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_bitextract.c * @author foxBMS Team * @date 2019-01-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -92,13 +93,21 @@ static MXM_41B_REG_BIT_VALUE bitValue( uint8_t numberOfBits, MXM_41B_REG_BITS position, MXM_41B_REG_BITS shift) { - MXM_41B_REG_BIT_VALUE sBit; - sBit = (((1u << numberOfBits) - 1u) & (((uint8_t)value) >> (position - 1u))); + /* AXIVION Routine Generic-MissingParameterAssert: value: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: numberOfBits: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: position: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: shift: parameter accepts whole range */ + + MXM_41B_REG_BIT_VALUE sBit = (((1u << numberOfBits) - 1u) & (((uint8_t)value) >> (position - 1u))); return (MXM_41B_REG_BIT_VALUE)((((uint8_t)sBit) << shift) & (uint8_t)UINT8_MAX); } /*========== Extern Function Implementations ================================*/ extern MXM_41B_REG_BIT_VALUE mxm_41bReadValue(uint8_t reg, uint8_t numberOfBits, MXM_41B_REG_BITS position) { + /* AXIVION Routine Generic-MissingParameterAssert: reg: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: numberOfBits: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: position: parameter accepts whole range */ + return bitValue(reg, numberOfBits, (position + 1u), 0); } @@ -107,6 +116,11 @@ extern MXM_41B_REG_BIT_VALUE mxm_41bWriteValue( uint8_t numberOfBits, MXM_41B_REG_BITS shift, uint8_t reg) { + /* AXIVION Routine Generic-MissingParameterAssert: value: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: numberOfBits: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: shift: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: reg: parameter accepts whole range */ + uint8_t outputRegister = reg; outputRegister = outputRegister & ~(MXM_REG_MASK(shift, numberOfBits)); outputRegister = bitValue(value, numberOfBits, 1, shift) | outputRegister; diff --git a/src/app/driver/afe/maxim/common/mxm_bitextract.h b/src/app/driver/afe/maxim/common/mxm_bitextract.h index f0b62571..b56c9201 100644 --- a/src/app/driver/afe/maxim/common/mxm_bitextract.h +++ b/src/app/driver/afe/maxim/common/mxm_bitextract.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_bitextract.h * @author foxBMS Team * @date 2019-01-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * diff --git a/src/app/driver/afe/maxim/common/mxm_crc8.c b/src/app/driver/afe/maxim/common/mxm_crc8.c index d79e990f..8470d17d 100644 --- a/src/app/driver/afe/maxim/common/mxm_crc8.c +++ b/src/app/driver/afe/maxim/common/mxm_crc8.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_crc8.c * @author foxBMS Team * @date 2019-02-05 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -78,6 +79,8 @@ static uint8_t MXM_CRC8WithInitValue(uint16_t *pData, int32_t lenData, uint8_t c /*========== Static Function Implementations ================================*/ static uint8_t MXM_CRC8WithInitValue(uint16_t *pData, int32_t lenData, uint8_t crcInit) { FAS_ASSERT(pData != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: lenData: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: crcInit: parameter accepts whole range */ /** * @brief Precomputed CRC8-table for polynomial 0xA6 @@ -129,22 +132,28 @@ static uint8_t MXM_CRC8WithInitValue(uint16_t *pData, int32_t lenData, uint8_t c extern uint8_t MXM_CRC8(uint16_t *pData, int32_t lenData) { FAS_ASSERT(pData != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: lenData: parameter accepts whole range */ + return MXM_CRC8WithInitValue(pData, lenData, 0); } extern STD_RETURN_TYPE_e must_check_return MXM_CRC8SelfTest(void) { /* AXIVION Disable Style Generic-NoMagicNumbers: This test function uses magic numbers to test predefined values. */ - uint16_t testSequence1[4] = {0x02u, 0x12u, 0xB1u, 0xB2u}; - FAS_ASSERT(MXM_CRC8(testSequence1, 4) == 0xC4u); + uint16_t testSequence1[4] = {0x02u, 0x12u, 0xB1u, 0xB2u}; + const uint8_t sequence1Result = MXM_CRC8(testSequence1, 4); + FAS_ASSERT(sequence1Result == 0xC4u); - uint16_t testSequence2[3] = {0x03u, 0x12u, 0x00u}; - FAS_ASSERT(MXM_CRC8(testSequence2, 3) == 0xCBu); + uint16_t testSequence2[3] = {0x03u, 0x12u, 0x00u}; + const uint8_t sequence2Result = MXM_CRC8(testSequence2, 3); + FAS_ASSERT(sequence2Result == 0xCBu); - uint16_t testSequence3[10] = {0x02u, 0x5Bu, 0x12u, 0x42u, 0xFFu, 0xD3u, 0x13u, 0x77u, 0xA1u, 0x31u}; - FAS_ASSERT(MXM_CRC8(testSequence3, 10) == 0x7Eu); + uint16_t testSequence3[10] = {0x02u, 0x5Bu, 0x12u, 0x42u, 0xFFu, 0xD3u, 0x13u, 0x77u, 0xA1u, 0x31u}; + const uint8_t sequence3Result = MXM_CRC8(testSequence3, 10); + FAS_ASSERT(sequence3Result == 0x7Eu); - uint16_t testSequence4[3] = {0x03u, 0x66u, 0x00u}; - FAS_ASSERT(MXM_CRC8(testSequence4, 3) == 0x43u); + uint16_t testSequence4[3] = {0x03u, 0x66u, 0x00u}; + const uint8_t sequence4Result = MXM_CRC8(testSequence4, 3); + FAS_ASSERT(sequence4Result == 0x43u); /* AXIVION Enable Style Generic-NoMagicNumbers: */ diff --git a/src/app/driver/afe/maxim/common/mxm_crc8.h b/src/app/driver/afe/maxim/common/mxm_crc8.h index 990fdfbe..4a18df15 100644 --- a/src/app/driver/afe/maxim/common/mxm_crc8.h +++ b/src/app/driver/afe/maxim/common/mxm_crc8.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_crc8.h * @author foxBMS Team * @date 2019-02-05 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * diff --git a/src/app/driver/afe/maxim/common/mxm_register_map.h b/src/app/driver/afe/maxim/common/mxm_register_map.h index de94a9ef..89ff9244 100644 --- a/src/app/driver/afe/maxim/common/mxm_register_map.h +++ b/src/app/driver/afe/maxim/common/mxm_register_map.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_register_map.h * @author foxBMS Team * @date 2019-03-05 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -72,8 +73,8 @@ typedef enum { * accessible register which returns information on the device */ MXM_REG_ADDRESS = 0x01u, /*!< ADDRESS is a read and write * accessible register which sets the first, last, and device address - * used by a device in a UART chain (UARTSEL=1). This register has no NOLINT - * effect on a device operating in SPI mode (UARTSEL=0). NOLINT */ + * used by a device in a UART chain (UARTSEL=1). This register has no + * effect on a device operating in SPI mode (UARTSEL=0). */ MXM_REG_STATUS1 = 0x02u, /*!< STATUS1 is a read and write * accessible register which relates the current status of the device. * STATUS1 also contains summary information on STATUS2, STATUS3, and @@ -108,10 +109,10 @@ typedef enum { * input protection fault alerts. */ MXM_REG_ALRTAUXOV = 0x0Cu, /*!< ALRTAUXOV is a read * accessible register which relates current information on auxiliary - * over voltage (cold) fault alerts. NOLINT */ + * over voltage (cold) fault alerts. */ MXM_REG_ALRTAUXUV = 0x0Du, /*!< ALRTAUXUV is a read accessible * register which relates current information on auxiliary under voltage - * fault (hot) alerts. NOLINT */ + * fault (hot) alerts. */ MXM_REG_ALRTCOMPOV = 0x0Eu, /*!< ALRTCOMPOV is a read accessible * register which relates current information on cell over voltage fault * alerts based on the redundant comparator. */ @@ -120,10 +121,10 @@ typedef enum { * alerts based on the redundant comparator. */ MXM_REG_ALRTCOMPAUXOV = 0x10u, /*!< ALRTCOMPAUXOV is a read * accessible register which relates current information on auxiliary over - * voltage fault (cold) alerts based on the redundant comparator. NOLINT */ + * voltage fault (cold) alerts based on the redundant comparator. */ MXM_REG_ALRTCOMPAUXUV = 0x11u, /*!< ALRTCOMPAUXUV is a read * accessible register which relates current information on auxiliary under - * voltage fault (hot) alerts based on the redundant comparator. NOLINT */ + * voltage fault (hot) alerts based on the redundant comparator. */ MXM_REG_ALRTBALSW = 0x12u, /*!< ALRTBALSW is a read accessible * register which relates current summary information on balancing switch * fault alerts. */ @@ -150,8 +151,8 @@ typedef enum { MXM_REG_ALRTIRQEN = 0x19u, /*!< ALRTIRQEN is a read and write * accessible register which selects which STATS1 alerts trigger interrupts * via the ALERT interface port(s), and are included in the DCByte and - * Alert Packet (UART) or ALERT bit (SPI) notifications. Note the information NOLINT - * in the STATUS1 register itself (or any component terms rolled up into NOLINT + * Alert Packet (UART) or ALERT bit (SPI) notifications. Note the information + * in the STATUS1 register itself (or any component terms rolled up into * STATUS1) is not masked/disabled by these settings, allowing the * underlying data to always be available via STATUS1 readback. */ MXM_REG_ALRTOVEN = 0x1Au, /*!< ALRTOVEN is a read and write @@ -161,17 +162,17 @@ typedef enum { * accessible register which enables under voltage fault checks on selected * input channels during scans using either the ADC or Comparator. */ MXM_REG_ALRTAUXOVEN = 0x1Cu, /*!< ALRTAUXOVEN is a read and write - * accessible register which enables auxiliary over voltage (cold) fault NOLINT + * accessible register which enables auxiliary over voltage (cold) fault * checks on selected Auxiliary channels during scans using either the * ADC or Comparator. */ MXM_REG_ALRTAUXUVEN = 0x1Du, /*!< ALRTAUXUVEN is a read and write - * accessible register which enables auxiliary under voltage (hot) fault NOLINT + * accessible register which enables auxiliary under voltage (hot) fault * checks on selected Auxiliary channels using either the * ADC or Comparator. */ MXM_REG_ALRTCALTST = 0x1Eu, /*!< ALRTCALTST is a read and write * accessible register which allows the user to force Calibration alerts * to test readback and interrupt logic. The forced alert(s) will remain - * forced until this register is written back to zeros (assuming the NOLINT + * forced until this register is written back to zeros (assuming the * existing calibration data is within range) */ MXM_REG_OVTHCLR = 0x1Fu, /*!< OVTHCLR is a read and write * accessible register which selects the cell over voltage alert @@ -225,16 +226,16 @@ typedef enum { * read and write accessible register which selects the CSA under voltage * alert set threshold used with ADC measurements. */ MXM_REG_AUXROVTHCLR = 0x30u, /*!< AUXROVTHCLR is a read and write - * accessible register which selects the over voltage (cold) alert NOLINT + * accessible register which selects the over voltage (cold) alert * clear threshold used with Ratiometric Auxiliary ADC measurements. */ MXM_REG_AUXROVTHSET = 0x31u, /*!< AUXROVTHSET is a read and write - * accessible register which selects the over voltage (cold) alert set NOLINT + * accessible register which selects the over voltage (cold) alert set * threshold used with Ratiometric Auxiliary ADC measurements. */ MXM_REG_AUXRUVTHCLR = 0x32u, /*!< AUXRUVTHCLR is a read and write - * accessible register which selects the under voltage (hot) alert clear NOLINT + * accessible register which selects the under voltage (hot) alert clear * threshold used with Ratiometric Auxiliary ADC measurements. */ MXM_REG_AUXRUVTHSET = 0x33u, /*!< AUXRUVTHSET is a read and write - * accessible register which selects the under voltage (hot) alert set NOLINT + * accessible register which selects the under voltage (hot) alert set * threshold used with Ratiometric Auxiliary ADC measurements. */ MXM_REG_AUXOVTHCLR = 0x34u, /*!< AUXOVTHCLR is a read and write * accessible register which selects the over voltage alert clear @@ -255,10 +256,10 @@ typedef enum { * accessible register which selects the cell under voltage alert threshold * for the redundant comparator. */ MXM_REG_COMPAUXROVTH = 0x3Au, /*!< COMPAUXROVTH is a read and write - * accessible register which selects the over voltage (cold) alert threshold NOLINT + * accessible register which selects the over voltage (cold) alert threshold * applied during Ratiometric Auxiliary comparator measurements. */ MXM_REG_COMPAUXRUVTH = 0x3Bu, /*!< COMPAUXRUVTH is a read and write - * accessible register which selects the under voltage (hot) alert threshold NOLINT + * accessible register which selects the under voltage (hot) alert threshold * applied during Ratiometric Auxiliary comparator measurements. */ MXM_REG_COMPAUXAOVTH = 0x3Cu, /*!< COMPAUXAOVTH is a read and write * accessible register which selects the over voltage alert threshold @@ -392,7 +393,7 @@ typedef enum { * IIR initialization. */ MXM_REG_SCANCTRL = 0x66u, /*!< SCANCTRL is a read and write * accessible register which governs the internal measurement - * acquisitions (scan) requested of the device. The register also manages NOLINT + * acquisitions (scan) requested of the device. The register also manages * the handling of data generated as a result of any scan request. * * ADC Scans are used for precision measurements of cell and auxiliary @@ -424,7 +425,7 @@ typedef enum { * Diagnostics. */ MXM_REG_DIAGCFG = 0x6Bu, /*!< DIAGCFG is a read and write * accessible register which governs diagnostic source and mode options - * applied to the internal measurement acquisitions (scans). NOLINT */ + * applied to the internal measurement acquisitions (scans). */ MXM_REG_CTSTCFG = 0x6Cu, /*!< CTSTCFG is a read and write * accessible register which controls the application of diagnostic * current sources to selected cell input channels. */ @@ -439,7 +440,7 @@ typedef enum { * Switches in Manual and Auto Cell Balancing modes. * * Write access to this register is blocked during Automated Cell - * Balancing operations (CBMODE=001, 1xx). NOLINT */ + * Balancing operations (CBMODE=001, 1xx). */ MXM_REG_BALEXP1 = 0x70u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). @@ -448,98 +449,98 @@ typedef enum { * Discharge modes and the Watchdog time out for Manual Cell Balancing mode. * * Write access to this register is blocked during all Cell Balancing - * operations (CBMODE!=000). NOLINT */ + * operations (CBMODE!=000). */ MXM_REG_BALEXP2 = 0x71u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP3 = 0x72u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP4 = 0x73u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP5 = 0x74u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP6 = 0x75u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP7 = 0x76u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP8 = 0x77u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP9 = 0x78u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP10 = 0x79u, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP11 = 0x7Au, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP12 = 0x7Bu, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP13 = 0x7Cu, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALEXP14 = 0x7Du, /*!< BALEXPn is a read and write * accessible register which holds the Cell Balancing Expiration Time * for CELLn (using the switch across SWn and SWn-1). Used in Individual * Auto Cell Balancing modes only. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). NOLINT */ + * Balancing operations (CBMODE=1xx). */ MXM_REG_BALAUTOUVTHR = 0x7Eu, /*!< BALAUTOUVTHR is a read and write * accessible register which selects the cell under voltage exit threshold * for the ADC when used in Automated Cell Balancing operations. @@ -548,9 +549,9 @@ typedef enum { * of this threshold. * * Write access to this register is blocked during Automatic Cell - * Balancing operations (CBMODE=1xx). Also, during active measurement scans, NOLINT - * all writes with CBUVMINCELL=1 will be blocked and will result in ALRTRJCT NOLINT - * being issued (since the MINCELL data may be altered as a result of the NOLINT + * Balancing operations (CBMODE=1xx). Also, during active measurement scans, + * all writes with CBUVMINCELL=1 will be blocked and will result in ALRTRJCT + * being issued (since the MINCELL data may be altered as a result of the * scan in progress). * * A read from this register will display the current value of the threshold @@ -560,12 +561,12 @@ typedef enum { * Automated Cell Balancing operations. * * Write access to this register is blocked during Automated Cell Balancing - * operations (CBMODE=001, 1xx). NOLINT */ + * operations (CBMODE=001, 1xx). */ MXM_REG_BALCTRL = 0x80u, /*!< BALCTRL is a read and write * accessible register which initiates and controls all internal Cell * Balancing modes and operations. * - * Any write to this register to a mode other than CBMODE=000 (Disable) NOLINT + * Any write to this register to a mode other than CBMODE=000 (Disable) * will restart the CBTIMER at zero and launch the requested mode of * operation. */ MXM_REG_BALSTAT = 0x81u, /*!< BALSTAT is a read accessible @@ -636,7 +637,7 @@ typedef enum { * observed during an I2C transaction. These bits are updated as they * occur and are only cleared by writing to zero. Several faults may * occur during a corrupted transaction, so it is best to wait until - * I2CSTATUS reads 10 (Transaction Error) to ensure all errors have NOLINT + * I2CSTATUS reads 10 (Transaction Error) to ensure all errors have * been reported. * * While not advisable, if further I2C transactions are requested before diff --git a/src/app/driver/afe/maxim/common/mxm_registry.c b/src/app/driver/afe/maxim/common/mxm_registry.c index 2b0d2cad..f521a33c 100644 --- a/src/app/driver/afe/maxim/common/mxm_registry.c +++ b/src/app/driver/afe/maxim/common/mxm_registry.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_registry.c * @author foxBMS Team * @date 2020-07-16 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -83,7 +84,7 @@ extern void MXM_MonRegistryInit(MXM_MONITORING_INSTANCE_s *pState) { entry->deviceAddress = 0u; entry->deviceID = 0u; entry->model = MXM_MODEL_ID_NONE; - entry->siliconVersion = MXM_siliconVersion_0; + entry->siliconVersion = MXM_SILICON_VERSION_0; entry->registerStatus1 = MXM_MON_REGISTRY_STATUS_FMEA_DEFAULT; entry->registerStatus2 = MXM_MON_REGISTRY_STATUS_FMEA_DEFAULT; entry->registerStatus3 = MXM_MON_REGISTRY_STATUS_FMEA_DEFAULT; @@ -94,6 +95,8 @@ extern void MXM_MonRegistryInit(MXM_MONITORING_INSTANCE_s *pState) { extern STD_RETURN_TYPE_e MXM_MonRegistryConnectDevices(MXM_MONITORING_INSTANCE_s *pState, uint8_t numberOfDevices) { FAS_ASSERT(pState != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: numberOfDevices: parameter accepts whole range */ + STD_RETURN_TYPE_e retval = STD_OK; if (numberOfDevices > MXM_MAXIMUM_NR_OF_MODULES) { retval = STD_NOT_OK; @@ -177,11 +180,11 @@ extern void MXM_MonRegistryParseVersionIntoDevices(MXM_MONITORING_INSTANCE_s *pS uint16_t version = 0; MXM_ExtractValueFromRegister( pState->rxBuffer[bufferPosition], pState->rxBuffer[bufferPosition + 1u], MXM_REG_VERSION_VER, &version); - if (version >= (uint16_t)MXM_siliconVersion_invalid) { - currentDevice->siliconVersion = MXM_siliconVersion_invalid; + if (version >= (uint16_t)MXM_SILICON_VERSION_INVALID) { + currentDevice->siliconVersion = MXM_SILICON_VERSION_INVALID; } else { /* AXIVION Next Line Style MisraC2012-10.5: All invalid values have been cleared. */ - currentDevice->siliconVersion = (MXM_siliconVersion_e)version; + currentDevice->siliconVersion = (MXM_SILICON_VERSION_e)version; } } } @@ -223,6 +226,9 @@ extern void MXM_MonRegistryParseStatusFmeaIntoDevices(MXM_MONITORING_INSTANCE_s case (uint8_t)MXM_REG_FMEA2: currentDevice->registerFmea2 = registerValue; break; + case (uint8_t)MXM_REG_BALSTAT: + currentDevice->registerBalstat = registerValue; + break; default: /* unknown register, just discard */ break; diff --git a/src/app/driver/afe/maxim/common/mxm_registry.h b/src/app/driver/afe/maxim/common/mxm_registry.h index 2711dbcf..2df6bffd 100644 --- a/src/app/driver/afe/maxim/common/mxm_registry.h +++ b/src/app/driver/afe/maxim/common/mxm_registry.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_registry.h * @author foxBMS Team * @date 2020-07-16 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * diff --git a/src/app/driver/afe/maxim/max17852/mxm_17852.c b/src/app/driver/afe/maxim/max17852/mxm_17852.c index aea52dfd..ea3ce144 100644 --- a/src/app/driver/afe/maxim/max17852/mxm_17852.c +++ b/src/app/driver/afe/maxim/max17852/mxm_17852.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mxm_17852.c * @author foxBMS Team * @date 2021-11-24 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MXM * @@ -144,10 +145,9 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { } break; case MXM_OP_DIAGNOSTIC_STATUS1: - if (true == MXM_HandleStateReadall(pState, MXM_REG_STATUS1, MXM_OP_DIAGNOSTIC_STATUS2)) { - const uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_STATUS1, MXM_OP_DIAGNOSTIC_STATUS2) == true) { + const uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseStatusFmeaIntoDevices(pState, temp_len); const bool someDeviceHasBeenReset = MXM_CheckIfADeviceHasBeenReset(pState); if (someDeviceHasBeenReset == true) { @@ -157,34 +157,30 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { } break; case MXM_OP_DIAGNOSTIC_STATUS2: - if (true == MXM_HandleStateReadall(pState, MXM_REG_STATUS2, MXM_OP_DIAGNOSTIC_STATUS3)) { - const uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_STATUS2, MXM_OP_DIAGNOSTIC_STATUS3) == true) { + const uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseStatusFmeaIntoDevices(pState, temp_len); } break; case MXM_OP_DIAGNOSTIC_STATUS3: - if (true == MXM_HandleStateReadall(pState, MXM_REG_STATUS3, MXM_OP_DIAGNOSTIC_FMEA1)) { - const uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_STATUS3, MXM_OP_DIAGNOSTIC_FMEA1) == true) { + const uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseStatusFmeaIntoDevices(pState, temp_len); } break; case MXM_OP_DIAGNOSTIC_FMEA1: - if (true == MXM_HandleStateReadall(pState, MXM_REG_FMEA1, MXM_OP_DIAGNOSTIC_FMEA2)) { - const uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_FMEA1, MXM_OP_DIAGNOSTIC_FMEA2) == true) { + const uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseStatusFmeaIntoDevices(pState, temp_len); } break; case MXM_OP_DIAGNOSTIC_FMEA2: - if (true == MXM_HandleStateReadall(pState, MXM_REG_FMEA2, MXM_OP_DIAGNOSTIC_CLEAR_STATUS2)) { - const uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_FMEA2, MXM_OP_DIAGNOSTIC_CLEAR_STATUS2) == true) { + const uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseStatusFmeaIntoDevices(pState, temp_len); } break; @@ -245,7 +241,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { MXM_HandleStateWriteall(pState, MXM_OP_GET_SCAN_STROBE); break; case MXM_OP_GET_SCAN_STROBE: - if (true == MXM_HandleStateReadall(pState, MXM_REG_SCANCTRL, MXM_OP_GET_VOLTAGES)) { + if (MXM_HandleStateReadall(pState, MXM_REG_SCANCTRL, MXM_OP_GET_VOLTAGES) == true) { /* no additional handling needed */ } break; @@ -257,7 +253,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { if (pState->mxmVoltageCellCounter < (uint8_t)UINT8_MAX) { pState->mxmVoltageCellCounter++; } - static_assert( + f_static_assert( MXM_VOLTAGE_READ_ARRAY_LENGTH <= (uint8_t)UINT8_MAX, "invalid define MXM_VOLTAGE_READ_ARRAY_LENGTH"); /* modified: read one additional aux entry */ @@ -270,7 +266,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { } break; case MXM_OP_GET_ALRTSUM: - if (true == MXM_HandleStateReadall(pState, MXM_REG_ALRTSUM, MXM_OP_PARSE_VOLTAGES_INTO_DB)) { + if (MXM_HandleStateReadall(pState, MXM_REG_ALRTSUM, MXM_OP_PARSE_VOLTAGES_INTO_DB) == true) { /* no additional handling needed */ } break; @@ -315,12 +311,12 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { MXM_HandleStateWriteall(pState, MXM_OP_PINOPEN_GET_SCAN_STROBE); break; case MXM_OP_PINOPEN_GET_SCAN_STROBE: - if (true == MXM_HandleStateReadall(pState, MXM_REG_SCANCTRL, MXM_OP_PINOPEN_GET_ALRT)) { + if (MXM_HandleStateReadall(pState, MXM_REG_SCANCTRL, MXM_OP_PINOPEN_GET_ALRT) == true) { /* no additional handling needed */ } break; case MXM_OP_PINOPEN_GET_ALRT: - if (true == MXM_HandleStateReadall(pState, MXM_REG_ALRTCOMPUV, MXM_OP_PINOPEN_PROCESS_OPENWIRE)) { + if (MXM_HandleStateReadall(pState, MXM_REG_ALRTCOMPUV, MXM_OP_PINOPEN_PROCESS_OPENWIRE) == true) { /* no additional handling needed */ } break; @@ -347,7 +343,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { if (OS_CheckTimeHasPassedWithTimestamp( pState->pBalancingState->previousTimeStamp, pState->pBalancingState->currentTimeStamp, - MXM_DELAY_BALANCING)) { + MXM_DELAY_BALANCING) == false) { /* nothing to do, exit balancing state chain */ pState->operationSubstate = MXM_OP_BAL_EXIT; } else { @@ -355,7 +351,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { pState->pBalancingState->previousTimeStamp = pState->pBalancingState->currentTimeStamp; /* First reset the balancing switches, and THEN set the balancing switches according to the database */ - pState->operationSubstate = MXM_OP_BAL_CONTROL_RESET_ALL; + pState->operationSubstate = MXM_OP_BAL_CONTROL_STOP_BALANCING; /* Change the parity of cells to balance */ if (pState->pBalancingState->evenCellsBalancingProcessed == true) { @@ -369,6 +365,15 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { } } break; + case MXM_OP_BAL_CONTROL_STOP_BALANCING: + /* Send a WRITEALL command to stop all balancing action */ + if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { + pState->batteryCmdBuffer.regAddress = MXM_REG_BALCTRL; + pState->batteryCmdBuffer.lsb = 0x00U; + pState->batteryCmdBuffer.msb = 0x00U; + } + MXM_HandleStateWriteall(pState, MXM_OP_BAL_CONTROL_RESET_ALL); + break; case MXM_OP_BAL_CONTROL_RESET_ALL: /* Send a WRITEALL command to open all balancing switches */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { @@ -387,7 +392,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { pState->pBalancingState->oddCellsBalancingProcessed = false; STD_RETURN_TYPE_e database_retval = DATA_READ_DATA(pState->pBalancingState->pBalancingControl_table); - if (STD_OK == database_retval) { + if (database_retval == STD_OK) { /* Construct the balancing buffer */ const STD_RETURN_TYPE_e retval = MXM_ConstructBalancingBuffer(pState->pBalancingState); @@ -400,6 +405,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { (uint8_t)(pState->pBalancingState->cellsToBalance & MXM_BM_LSB); pState->batteryCmdBuffer.msb = (uint8_t)(pState->pBalancingState->cellsToBalance >> MXM_CELLS_IN_LSB); + pState->batteryCmdBuffer.msb &= ((uint8_t)1u << 7u); /* set CBRESTART bit */ const STD_RETURN_TYPE_e setStateRequestReturn = MXM_5XSetStateRequest( pState->pInstance5X, @@ -443,7 +449,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { /* nothing to do here */ } pState->requestStatus5x = MXM_5X_STATE_UNSENT; - pState->operationSubstate = MXM_OP_BAL_EXIT; + pState->operationSubstate = MXM_OP_BAL_START; } } else if (pState->requestStatus5x == MXM_5X_STATE_ERROR) { /* default-behavior: retry */ @@ -462,7 +468,14 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { pState->batteryCmdBuffer.lsb = 0x0EU; pState->batteryCmdBuffer.msb = 0x18U; } - MXM_HandleStateWriteall(pState, MXM_OP_BAL_EXIT); + MXM_HandleStateWriteall(pState, MXM_OP_BAL_READ_BALSTAT); + break; + case MXM_OP_BAL_READ_BALSTAT: + if (MXM_HandleStateReadall(pState, MXM_REG_BALSTAT, MXM_OP_BAL_EXIT) == true) { + const uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); + MXM_MonRegistryParseStatusFmeaIntoDevices(pState, temp_len); + } break; case MXM_OP_BAL_EXIT: pState->operationSubstate = MXM_OP_CYCLE_END_ENTRY; @@ -493,6 +506,15 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { pState->batteryCmdBuffer.lsb = 0x00u; /* alert interface disabled */ pState->batteryCmdBuffer.msb = 0x01u; /* single uart with external loopback*/ } + MXM_HandleStateWriteall(pState, MXM_INIT_DEVCFG2); + break; + case MXM_INIT_DEVCFG2: + /* default value for DEVCFG2 */ + if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { + pState->batteryCmdBuffer.regAddress = MXM_REG_DEVCFG2; + pState->batteryCmdBuffer.lsb = 0x00u; /* activate CB watchdog */ + pState->batteryCmdBuffer.msb = 0x40u; /* default*/ + } MXM_HandleStateWriteall(pState, MXM_INIT_SET_STATUS2); break; case MXM_INIT_SET_STATUS2: @@ -515,28 +537,25 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { break; case MXM_INIT_GET_VERSION: /* add version information to registry */ - if (true == MXM_HandleStateReadall(pState, MXM_REG_VERSION, MXM_INIT_GET_ID1)) { - uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_VERSION, MXM_INIT_GET_ID1) == true) { + uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseVersionIntoDevices(pState, temp_len); } break; case MXM_INIT_GET_ID1: /* add ID1 to registry */ - if (true == MXM_HandleStateReadall(pState, MXM_REG_ID1, MXM_INIT_GET_ID2)) { - uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_ID1, MXM_INIT_GET_ID2) == true) { + uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseIdIntoDevices(pState, temp_len, MXM_REG_ID1); } break; case MXM_INIT_GET_ID2: /* add ID2 to registry */ - if (true == MXM_HandleStateReadall(pState, MXM_REG_ID2, MXM_INIT_MEASUREEN1)) { - uint8_t temp_len = (uint8_t)( - (BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & - (uint8_t)UINT8_MAX); + if (MXM_HandleStateReadall(pState, MXM_REG_ID2, MXM_INIT_MEASUREEN1) == true) { + uint8_t temp_len = + (uint8_t)((BATTERY_MANAGEMENT_TX_LENGTH_READALL + (2uL * MXM_5XGetNumberOfSatellites(pState->pInstance5X))) & (uint8_t)UINT8_MAX); MXM_MonRegistryParseIdIntoDevices(pState, temp_len, MXM_REG_ID2); } break; @@ -616,127 +635,127 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP1); break; case MXM_INIT_BALEXP1: - /* set BALEXP1 to have 1 minute timeout in manual balancing */ + /* set BALEXP1 to have 5 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP1; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x05u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP2); break; case MXM_INIT_BALEXP2: - /* set BALEXP2 to have 1 minute timeout in manual balancing */ + /* set BALEXP2 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP2; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP3); break; case MXM_INIT_BALEXP3: - /* set BALEXP3 to have 1 minute timeout in manual balancing */ + /* set BALEXP3 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP3; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP4); break; case MXM_INIT_BALEXP4: - /* set BALEXP4 to have 1 minute timeout in manual balancing */ + /* set BALEXP4 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP4; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP5); break; case MXM_INIT_BALEXP5: - /* set BALEXP5 to have 1 minute timeout in manual balancing */ + /* set BALEXP5 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP5; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP6); break; case MXM_INIT_BALEXP6: - /* set BALEXP6 to have 1 minute timeout in manual balancing */ + /* set BALEXP6 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP6; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP7); break; case MXM_INIT_BALEXP7: - /* set BALEXP7 to have 1 minute timeout in manual balancing */ + /* set BALEXP7 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP7; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP8); break; case MXM_INIT_BALEXP8: - /* set BALEXP8 to have 1 minute timeout in manual balancing */ + /* set BALEXP8 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP8; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP9); break; case MXM_INIT_BALEXP9: - /* set BALEXP9 to have 1 minute timeout in manual balancing */ + /* set BALEXP9 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP9; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP10); break; case MXM_INIT_BALEXP10: - /* set BALEXP10 to have 1 minute timeout in manual balancing */ + /* set BALEXP10 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP10; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP11); break; case MXM_INIT_BALEXP11: - /* set BALEXP11 to have 1 minute timeout in manual balancing */ + /* set BALEXP11 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP11; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP12); break; case MXM_INIT_BALEXP12: - /* set BALEXP12 to have 1 minute timeout in manual balancing */ + /* set BALEXP12 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP12; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP13); break; case MXM_INIT_BALEXP13: - /* set BALEXP13 to have 1 minute timeout in manual balancing */ + /* set BALEXP13 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP13; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALEXP14); break; case MXM_INIT_BALEXP14: - /* set BALEXP14 to have 1 minute timeout in manual balancing */ + /* set BALEXP14 to have 0 minute timeout in manual balancing */ if (pState->requestStatus5x == MXM_5X_STATE_UNSENT) { pState->batteryCmdBuffer.regAddress = MXM_REG_BALEXP14; - pState->batteryCmdBuffer.lsb = 0x01u; + pState->batteryCmdBuffer.lsb = 0x00u; pState->batteryCmdBuffer.msb = 0x00u; } MXM_HandleStateWriteall(pState, MXM_INIT_BALSWDLY); @@ -783,7 +802,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { MXM_HandleStateWriteall(pState, MXM_INIT_I2C_GET_STAT1); break; case MXM_INIT_I2C_GET_STAT1: - if (true == MXM_HandleStateReadall(pState, MXM_REG_I2CSTAT, MXM_INIT_I2C_CFG)) { + if (MXM_HandleStateReadall(pState, MXM_REG_I2CSTAT, MXM_INIT_I2C_CFG) == true) { /* no additional handling needed */ } break; @@ -831,7 +850,7 @@ extern void MXM_StateMachineOperation(MXM_MONITORING_INSTANCE_s *pState) { MXM_HandleStateWriteall(pState, MXM_INIT_GET_I2C_STAT2); break; case MXM_INIT_GET_I2C_STAT2: - if (true == MXM_HandleStateReadall(pState, MXM_REG_I2CSTAT, MXM_OP_ENTRY_STATE)) { + if (MXM_HandleStateReadall(pState, MXM_REG_I2CSTAT, MXM_OP_ENTRY_STATE) == true) { /* no additional handling needed */ } break; diff --git a/src/app/driver/afe/maxim/max17852/wscript b/src/app/driver/afe/maxim/max17852/wscript index 3ac93d9a..9894274f 100644 --- a/src/app/driver/afe/maxim/max17852/wscript +++ b/src/app/driver/afe/maxim/max17852/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -71,6 +71,7 @@ def build(bld): os.path.join("..", "..", "..", "spi"), os.path.join("..", "..", "..", "ts"), os.path.join("..", "..", "..", "ts", "api"), + os.path.join("..", "..", "..", "mcu"), os.path.join("..", "..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "..", "main", "include"), os.path.join("..", "..", "..", "..", "engine", "config"), diff --git a/src/app/driver/afe/maxim/wscript b/src/app/driver/afe/maxim/wscript index 66367bdd..bb566d74 100644 --- a/src/app/driver/afe/maxim/wscript +++ b/src/app/driver/afe/maxim/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/afe/nxp/common/api/nxp_afe.c b/src/app/driver/afe/nxp/common/api/nxp_afe.c index 9fa6a727..90f891ee 100644 --- a/src/app/driver/afe/nxp/common/api/nxp_afe.c +++ b/src/app/driver/afe/nxp/common/api/nxp_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxp_afe.c * @author foxBMS Team * @date 2020-05-25 (date of creation) - * @updated 2020-06-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix AFE * @@ -55,8 +56,8 @@ /* clang-format off */ #include "afe.h" /* clang-format on */ -#include "dma.h" #include "afe_dma.h" +#include "dma.h" #include "n775.h" /*========== Macros and Definitions =========================================*/ diff --git a/src/app/driver/afe/nxp/common/config/n775_cfg.c b/src/app/driver/afe/nxp/common/config/n775_cfg.c index bdf5efb7..a7c30699 100644 --- a/src/app/driver/afe/nxp/common/config/n775_cfg.c +++ b/src/app/driver/afe/nxp/common/config/n775_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file n775_cfg.c * @author foxBMS Team * @date 2020-05-08 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix N775 * diff --git a/src/app/driver/afe/nxp/common/config/n775_cfg.h b/src/app/driver/afe/nxp/common/config/n775_cfg.h index dbcb0126..94b3b29d 100644 --- a/src/app/driver/afe/nxp/common/config/n775_cfg.h +++ b/src/app/driver/afe/nxp/common/config/n775_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file n775_cfg.h * @author foxBMS Team * @date 2020-05-08 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix N775 * @@ -66,7 +67,7 @@ /** * Number of used N775-ICs */ -#define N775_N_N775 (BS_NR_OF_MODULES) +#define N775_N_N775 (BS_NR_OF_MODULES_PER_STRING) /** * Number of N775-ICs per battery module diff --git a/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c index 5e72838d..be5e36ea 100644 --- a/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c +++ b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxp_afe_dma_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix DMA * diff --git a/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h index a25c01dc..8f6893a4 100644 --- a/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h +++ b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxp_afe_dma_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix DMA * diff --git a/src/app/driver/afe/nxp/common/n775.c b/src/app/driver/afe/nxp/common/n775.c index 94733b3d..fbd58fba 100644 --- a/src/app/driver/afe/nxp/common/n775.c +++ b/src/app/driver/afe/nxp/common/n775.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file n775.c * @author foxBMS Team * @date 2020-05-08 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix N775 * @@ -77,10 +78,17 @@ /*========== Static Constant and Variable Definitions =======================*/ /*========== Extern Constant and Variable Definitions =======================*/ +/** + * PEC buffer for RX and TX + * @{ + */ +/* AXIVION Disable Style MisraC2012-1.2: The Pec buffer must be put in the shared RAM section for performance reasons */ #pragma SET_DATA_SECTION(".sharedRAM") uint16_t n775_RXbuffer[N775_MAX_N_BYTES_FOR_DATA_RECEPTION] = {0}; uint16_t n775_TXbuffer[N775_TX_MESSAGE_LENGTH] = {0}; #pragma SET_DATA_SECTION() +/* AXIVION Enable Style MisraC2012-1.2: only Pec buffer needed to be in the shared RAM setcion */ +/**@}*/ N775_MESSAGE_s n775_sentData = {0}; N775_MESSAGE_s n775_receivedData = {0}; @@ -212,31 +220,31 @@ uint16_t n775_CalcCrc(const N775_MESSAGE_s *msg) { static void N775_Initialize_Database(void) { uint16_t i = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - n775_cellVoltage.state = 0; - n775_minMax.minimumCellVoltage_mV[stringNumber] = 0; - n775_minMax.maximumCellVoltage_mV[stringNumber] = 0; - n775_minMax.nrModuleMinimumCellVoltage[stringNumber] = 0; - n775_minMax.nrModuleMaximumCellVoltage[stringNumber] = 0; - n775_minMax.nrCellMinimumCellVoltage[stringNumber] = 0; - n775_minMax.nrCellMaximumCellVoltage[stringNumber] = 0; - for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - n775_cellVoltage.cellVoltage_mV[stringNumber][i] = 0; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + n775_cellVoltage.state = 0; + n775_minMax.minimumCellVoltage_mV[s] = 0; + n775_minMax.maximumCellVoltage_mV[s] = 0; + n775_minMax.nrModuleMinimumCellVoltage[s] = 0; + n775_minMax.nrModuleMaximumCellVoltage[s] = 0; + n775_minMax.nrCellMinimumCellVoltage[s] = 0; + n775_minMax.nrCellMaximumCellVoltage[s] = 0; + for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + n775_cellVoltage.cellVoltage_mV[s][i] = 0; } - n775_cellTemperature.state = 0; - n775_minMax.minimumTemperature_ddegC[stringNumber] = 0; - n775_minMax.maximumTemperature_ddegC[stringNumber] = 0; - n775_minMax.nrModuleMinimumTemperature[stringNumber] = 0; - n775_minMax.nrModuleMaximumTemperature[stringNumber] = 0; - n775_minMax.nrSensorMinimumTemperature[stringNumber] = 0; - n775_minMax.nrSensorMaximumTemperature[stringNumber] = 0; + n775_cellTemperature.state = 0; + n775_minMax.minimumTemperature_ddegC[s] = 0; + n775_minMax.maximumTemperature_ddegC[s] = 0; + n775_minMax.nrModuleMinimumTemperature[s] = 0; + n775_minMax.nrModuleMaximumTemperature[s] = 0; + n775_minMax.nrSensorMinimumTemperature[s] = 0; + n775_minMax.nrSensorMaximumTemperature[s] = 0; for (i = 0; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) { - n775_cellTemperature.cellTemperature_ddegC[stringNumber][i] = 0; + n775_cellTemperature.cellTemperature_ddegC[s][i] = 0; } - for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - n775_balancingControl.balancingState[stringNumber][i] = 0; + for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + n775_balancingControl.balancingState[s][i] = 0; } } diff --git a/src/app/driver/afe/nxp/common/n775.h b/src/app/driver/afe/nxp/common/n775.h index 384ab9c3..32a36dac 100644 --- a/src/app/driver/afe/nxp/common/n775.h +++ b/src/app/driver/afe/nxp/common/n775.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file n775.h * @author foxBMS Team * @date 2020-05-08 (date of creation) - * @updated 2020-05-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix N775 * diff --git a/src/app/driver/afe/nxp/common/n775_defs.h b/src/app/driver/afe/nxp/common/n775_defs.h index 8748a6e9..430469ed 100644 --- a/src/app/driver/afe/nxp/common/n775_defs.h +++ b/src/app/driver/afe/nxp/common/n775_defs.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file n775_defs.h * @author foxBMS Team * @date 2015-09-01 (date of creation) - * @updated 2015-09-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix N775 * @@ -162,7 +163,7 @@ typedef struct { DATA_BLOCK_BALANCING_CONTROL_s *balancing_control; DATA_BLOCK_SLAVE_CONTROL_s *user_io_control; DATA_BLOCK_OPEN_WIRE_s *openWire_check; /* Wie genau open wire check behandeln? Was genau abspeichern? */ - int *openWire_buffer; /* BS_NR_OF_BAT_CELLS */ + int *openWire_buffer; /* BS_NR_OF_CELL_BLOCKS_PER_STRING */ uint8_t *spi_TX_withPEC; /* 12 byte */ uint8_t *spi_RX_withPEC; /* 12 byte */ uint16_t *GPIOVoltages; /* N7752_NUMBER_OF_GPIOS * NR_OF_N775s */ @@ -224,7 +225,7 @@ typedef enum { * This structure contains all the variables relevant for the N775 state machine. * The user can get the current state of the N775 state machine with this variable */ -typedef struct N775_STATE { +typedef struct { uint16_t timer; /*!< time in ms before the state machine processes the next state, e.g. in counts of 1ms */ N775_STATE_REQUEST_e stateReq; /*!< current state request made to the state machine */ N775_STATEMACH_e state; /*!< state of Driver State Machine */ @@ -243,7 +244,7 @@ typedef struct N775_STATE { } N775_STATE_s; /** This structure reflects the messages used by the NXP MC33775A */ -typedef struct N775_MESSAGE { +typedef struct { uint16_t head; uint16_t dataHead; uint16_t data[4]; diff --git a/src/app/driver/afe/nxp/common/nxp_afe_dma.c b/src/app/driver/afe/nxp/common/nxp_afe_dma.c index 5b17ee66..0986653e 100644 --- a/src/app/driver/afe/nxp/common/nxp_afe_dma.c +++ b/src/app/driver/afe/nxp/common/nxp_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxp_afe_dma.c * @author foxBMS Team * @date 2020-05-27 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * diff --git a/src/app/driver/afe/nxp/common/nxp_afe_dma.h b/src/app/driver/afe/nxp/common/nxp_afe_dma.h index 40c64048..77952cff 100644 --- a/src/app/driver/afe/nxp/common/nxp_afe_dma.h +++ b/src/app/driver/afe/nxp/common/nxp_afe_dma.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxp_afe_dma.h * @author foxBMS Team * @date 2020-05-27 (date of creation) - * @updated 2020-05-27 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix AFE * diff --git a/src/app/driver/afe/nxp/wscript b/src/app/driver/afe/nxp/wscript index 095098c3..df576dec 100644 --- a/src/app/driver/afe/nxp/wscript +++ b/src/app/driver/afe/nxp/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -62,6 +62,7 @@ def build(bld): os.path.join("..", "..", "io"), os.path.join("..", "..", "spi"), os.path.join("..", "..", "ts"), + os.path.join("..", "..", "mcu"), os.path.join("..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "engine", "config"), os.path.join("..", "..", "..", "engine", "database"), diff --git a/src/app/driver/afe/wscript b/src/app/driver/afe/wscript index 8afb85a5..a37da4b8 100644 --- a/src/app/driver/afe/wscript +++ b/src/app/driver/afe/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/can/can.c b/src/app/driver/can/can.c index f7fbcfeb..ed8dd510 100644 --- a/src/app/driver/can/can.c +++ b/src/app/driver/can/can.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can.c * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CAN * @@ -205,7 +206,8 @@ extern void CAN_Initialize(void) { extern STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pData) { FAS_ASSERT(pNode != NULL_PTR); FAS_ASSERT(pData != NULL_PTR); - FAS_ASSERT((CAN1_NODE == pNode) || (CAN2_NODE == pNode)); + FAS_ASSERT((pNode == CAN1_NODE) || (pNode == CAN2_NODE)); + /* AXIVION Routine Generic-MissingParameterAssert: id: parameter accepts whole range */ STD_RETURN_TYPE_e result = STD_NOT_OK; @@ -231,7 +233,7 @@ extern STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pDat extern void CAN_MainFunction(void) { CAN_CheckCanTiming(); - if (true == can_state.periodicEnable) { + if (can_state.periodicEnable == true) { CAN_PeriodicTransmit(); } } @@ -293,45 +295,44 @@ static void CAN_CheckCanTiming(void) { /* check time stamps of current measurements */ DATA_READ_DATA(¤tTab); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* Current has been measured at least once */ - if (currentTab.timestampCurrent[stringNumber] != 0u) { + if (currentTab.timestampCurrent[s] != 0u) { /* Check time since last received string current data */ - if ((current_time - currentTab.timestampCurrent[stringNumber]) > - BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS) { - DIAG_Handler(DIAG_ID_CURRENT_SENSOR_RESPONDING, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + if ((current_time - currentTab.timestampCurrent[s]) > BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS) { + DIAG_Handler(DIAG_ID_CURRENT_SENSOR_RESPONDING, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { - DIAG_Handler(DIAG_ID_CURRENT_SENSOR_RESPONDING, DIAG_EVENT_OK, DIAG_STRING, stringNumber); - if (can_state.currentSensorPresent[stringNumber] == false) { - CAN_SetCurrentSensorPresent(true, stringNumber); + DIAG_Handler(DIAG_ID_CURRENT_SENSOR_RESPONDING, DIAG_EVENT_OK, DIAG_STRING, s); + if (can_state.currentSensorPresent[s] == false) { + CAN_SetCurrentSensorPresent(true, s); } } } /* check time stamps of CC measurements */ /* if timestamp_cc != 0, this means current sensor cc message has been received at least once */ - if (currentTab.timestampCurrentCounting[stringNumber] != 0) { - if ((current_time - currentTab.timestampCurrentCounting[stringNumber]) > + if (currentTab.timestampCurrentCounting[s] != 0) { + if ((current_time - currentTab.timestampCurrentCounting[s]) > BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS) { - DIAG_Handler(DIAG_ID_CAN_CC_RESPONDING, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CAN_CC_RESPONDING, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { - DIAG_Handler(DIAG_ID_CAN_CC_RESPONDING, DIAG_EVENT_OK, DIAG_STRING, stringNumber); - if (can_state.currentSensorCCPresent[stringNumber] == false) { - CAN_SetCurrentSensorCcPresent(true, stringNumber); + DIAG_Handler(DIAG_ID_CAN_CC_RESPONDING, DIAG_EVENT_OK, DIAG_STRING, s); + if (can_state.currentSensorCCPresent[s] == false) { + CAN_SetCurrentSensorCcPresent(true, s); } } } /* check time stamps of EC measurements */ /* if timestamp_ec != 0, this means current sensor ec message has been received at least once */ - if (currentTab.timestampEnergyCounting[stringNumber] != 0) { - if ((current_time - currentTab.timestampEnergyCounting[stringNumber]) > + if (currentTab.timestampEnergyCounting[s] != 0) { + if ((current_time - currentTab.timestampEnergyCounting[s]) > BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS) { - DIAG_Handler(DIAG_ID_CAN_EC_RESPONDING, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + DIAG_Handler(DIAG_ID_CAN_EC_RESPONDING, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } else { - DIAG_Handler(DIAG_ID_CAN_EC_RESPONDING, DIAG_EVENT_OK, DIAG_STRING, stringNumber); - if (can_state.currentSensorECPresent[stringNumber] == false) { - CAN_SetCurrentSensorEcPresent(true, stringNumber); + DIAG_Handler(DIAG_ID_CAN_EC_RESPONDING, DIAG_EVENT_OK, DIAG_STRING, s); + if (can_state.currentSensorECPresent[s] == false) { + CAN_SetCurrentSensorEcPresent(true, s); } } } @@ -352,7 +353,6 @@ extern void CAN_ReadRxBuffer(void) { can_rxMessages[i].dlc, can_rxMessages[i].endianness, can_rxBuffer.data, - NULL_PTR, &can_kShim); } } @@ -426,10 +426,15 @@ extern bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber) { } static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox) { + /* AXIVION Routine Generic-MissingParameterAssert: pNode: unused parameter */ + /* AXIVION Routine Generic-MissingParameterAssert: messageBox: unused parameter */ + (void)pNode; + (void)messageBox; } static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) { FAS_ASSERT(pNode != NULL_PTR); + CAN_BUFFERELEMENT_s can_rxBuffer = {0u}; uint8_t messageData[CAN_DLC] = {0u}; /** @@ -441,7 +446,7 @@ static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) { uint32_t retval = canGetData(pNode, messageBox, (uint8 *)&messageData[0]); /* copy to RAM */ /* Check that CAN RX queue is started before using it and data is valid */ - if ((ftsk_allQueuesCreated == true) && (CAN_HAL_RETVAL_NO_DATA_LOST == retval)) { + if ((ftsk_allQueuesCreated == true) && (retval == CAN_HAL_RETVAL_NO_DATA_LOST)) { /* id shifted by 18 to use standard frame from IF2ARB register*/ /* standard frame: bits [28:18] */ /* extended frame: bits [28:0] */ @@ -471,6 +476,9 @@ static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) { /** called in case of CAN interrupt, defined as weak in HAL */ /* AXIVION Next Line Style Linker-Multiple_Definition: TI HAL only provides a weak implementation */ void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox) { + /* AXIVION Routine Generic-MissingParameterAssert: node: unchecked in interrupt */ + /* AXIVION Routine Generic-MissingParameterAssert: messageBox: unchecked in interrupt */ + if (messageBox <= CAN_NR_OF_TX_MESSAGE_BOX) { CAN_TxInterrupt(node, messageBox); } else { @@ -492,10 +500,10 @@ extern STD_RETURN_TYPE_e CAN_TransmitBootMessage(void) { uint8_t versionControlByte = 0u; /* Set version control flags */ - if (true == foxbmsVersionInfo.underVersionControl) { + if (foxbmsVersionInfo.underVersionControl == true) { versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL); } - if (true == foxbmsVersionInfo.isDirty) { + if (foxbmsVersionInfo.isDirty == true) { versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG); } /* Set overflow flag (if release distance is larger than 31) */ @@ -513,7 +521,7 @@ extern STD_RETURN_TYPE_e CAN_TransmitBootMessage(void) { data[CAN_BYTE_3_POSITION] = versionControlByte; /* Read out device register with unique ID */ - uint32_t deviceRegister = systemREG1->DEVID; + const uint32_t deviceRegister = systemREG1->DEVID; /* Set unique ID */ data[CAN_BYTE_4_POSITION] = (uint8_t)((deviceRegister >> 24u) & 0xFFu); @@ -526,6 +534,30 @@ extern STD_RETURN_TYPE_e CAN_TransmitBootMessage(void) { return retval; } +extern STD_RETURN_TYPE_e CAN_TransmitDieId(void) { + uint8_t data[] = {REPEAT_U(0u, STRIP(CAN_MAX_DLC))}; + + /* Read out device register with die ID low and high */ + const uint32_t dieIdLow = systemREG1->DIEIDL; + const uint32_t dieIdHigh = systemREG1->DIEIDH; + + /* set die ID */ + /* AXIVION Disable Style Generic-NoMagicNumbers: The magic numbers are used to divide down the registers into the CAN message */ + data[CAN_BYTE_0_POSITION] = (uint8_t)((dieIdHigh >> 24u) & 0xFFu); + data[CAN_BYTE_1_POSITION] = (uint8_t)((dieIdHigh >> 16u) & 0xFFu); + data[CAN_BYTE_2_POSITION] = (uint8_t)((dieIdHigh >> 8u) & 0xFFu); + data[CAN_BYTE_3_POSITION] = (uint8_t)(dieIdHigh & 0xFFu); + data[CAN_BYTE_4_POSITION] = (uint8_t)((dieIdLow >> 24u) & 0xFFu); + data[CAN_BYTE_5_POSITION] = (uint8_t)((dieIdLow >> 16u) & 0xFFu); + data[CAN_BYTE_6_POSITION] = (uint8_t)((dieIdLow >> 8u) & 0xFFu); + data[CAN_BYTE_7_POSITION] = (uint8_t)(dieIdLow & 0xFFu); + /* AXIVION Enable Style Generic-NoMagicNumbers: */ + + STD_RETURN_TYPE_e retval = CAN_DataSend(CAN1_NODE, CAN_ID_DIE_ID, &data[0]); + + return retval; +} + /*========== Getter for static Variables (Unit Test) ========================*/ #ifdef UNITY_UNIT_TEST extern CAN_STATE_s *TEST_CAN_GetCANState(void) { diff --git a/src/app/driver/can/can.h b/src/app/driver/can/can.h index 8737bb3b..6f78786a 100644 --- a/src/app/driver/can/can.h +++ b/src/app/driver/can/can.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can.h * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CAN * @@ -75,7 +76,7 @@ #define CAN_TICK_MS (10U) /** This structure contains variables relevant for the CAN signal module. */ -typedef struct CAN_STATE { +typedef struct { bool periodicEnable; /*!< defines if periodic transmit and receive should run */ bool currentSensorPresent[BS_NR_OF_STRINGS]; /*!< defines if a current sensor is detected */ bool currentSensorCCPresent[BS_NR_OF_STRINGS]; /*!< defines if a CC info is being sent */ @@ -149,10 +150,16 @@ extern bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber); /** * @brief Transmit startup boot message - * @return #STD_OK if transmission successful, otherweise #STD_NOT_OK + * @return #STD_OK if transmission successful, otherwise #STD_NOT_OK */ extern STD_RETURN_TYPE_e CAN_TransmitBootMessage(void); +/** + * @brief Transmit chip id + * @return #STD_OK if transmission successful, otherwise #STD_NOT_OK + */ +extern STD_RETURN_TYPE_e CAN_TransmitDieId(void); + /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST extern CAN_STATE_s *TEST_CAN_GetCANState(void); diff --git a/src/app/driver/can/cbs/can_cbs.h b/src/app/driver/can/cbs/can_cbs.h index 01a9fdb4..bca8f185 100644 --- a/src/app/driver/can/cbs/can_cbs.h +++ b/src/app/driver/can/cbs/can_cbs.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs.h * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -81,6 +82,22 @@ extern uint32_t CAN_TxState( uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim); +/** + * @brief can tx callback function for detail state + * @param[in] id CAN ID + * @param[in] dlc CAN Data Length Code + * @param[in] endianness big or little endian + * @param[in] pCanData payload of can frame + * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanShim shim to the database entries + */ +extern uint32_t CAN_TxDetailState( + uint32_t id, + uint8_t dlc, + CAN_ENDIANNESS_e endianness, + uint8_t *pCanData, + uint8_t *pMuxId, + const CAN_SHIM_s *const kpkCanShim); /** * @brief can tx callback function for cell voltages * @param[in] id CAN ID @@ -265,112 +282,98 @@ extern uint32_t CAN_TxStringValues2( * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxImdInfo( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** * @brief can rx callback function for IMD response messages * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxImdResponse( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** * @brief can rx callback function for state requests * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxRequest( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** * @brief can rx callback function for SW reset * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxSwReset( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** * @brief can rx callback function for current sensor measurements * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxCurrentSensor( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** * @brief can rx callback function for debug messages * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxDebug( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** * @brief can rx callback function for SW version * @param[in] id CAN ID * @param[in] dlc CAN Data Length Code * @param[in] endianness big or little endian - * @param[in] pCanData payload of can frame - * @param[in] pMuxId multiplexer for multiplexed CAN messages + * @param[in] kpkCanData payload of can frame * @param[in] kpkCanShim shim to the database entries */ extern uint32_t CAN_RxSwVersion( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim); /** @} */ diff --git a/src/app/driver/can/cbs/can_cbs_rx_command.c b/src/app/driver/can/cbs/can_cbs_rx_command.c index 7e74e33a..ff852bf8 100644 --- a/src/app/driver/can/cbs/can_cbs_rx_command.c +++ b/src/app/driver/can/cbs/can_cbs_rx_command.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_rx_command.c * @author foxBMS Team * @date 2021-07-28 (date of creation) - * @updated 2021-07-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -58,42 +59,71 @@ #include "can_cbs.h" #include "can_helper.h" #include "diag.h" +#include "os.h" +#include "sys_mon.h" /*========== Macros and Definitions =========================================*/ +/** + * @brief CAN state request update time + * @details When a new CAN state request is received, it leads to an update + * of #DATA_BLOCK_STATEREQUEST_s::stateRequestViaCan if one of the + * following conditions is met: + * + * - The new request is different than the old request. + * - The old request is older than the timespan set in this define. + */ +#define CAN_CAN_REQUEST_UPDATE_TIME_ms (3000u) /*========== Static Constant and Variable Definitions =======================*/ /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** + * @brief clears the persistent flags + * @details This function clears all persistent flags (if signalData demands it) + * which are: + * - deep-discharge flag + * - sys mon violation flags + * @param[in] signalData if it is 1u, flags are cleared + */ +static void CAN_ClearAllPersistentFlags(uint64_t signalData); -/*========== Static Function Implementations ================================*/ - -/*========== Extern Function Implementations ================================*/ -extern uint32_t CAN_RxRequest( - uint32_t id, - uint8_t dlc, - CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, - const CAN_SHIM_s *const kpkCanShim) { - /* pMuxId is not used here, therefore has to be NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); +/** + * @brief handles the mode request + * @param[in] signalData extracted signal data + * @param[in,out] kpkCanShim can shim with database entries + */ +static void CAN_HandleModeRequest(uint64_t signalData, const CAN_SHIM_s *const kpkCanShim); - FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ - FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ - FAS_ASSERT(pCanData != NULL_PTR); - FAS_ASSERT(kpkCanShim != NULL_PTR); - uint64_t message = 0; - uint64_t signalData = 0; +/** + * @brief handles the balancing request + * @param[in] signalData extracted signal data + */ +static void CAN_HandleBalancingRequest(uint64_t signalData); - DATA_READ_DATA(kpkCanShim->pTableStateRequest); +/** + * @brief sets the balancing threshold + * @param[in] signalData extracted signal data + */ +static void CAN_SetBalancingThreshold(uint64_t signalData); - CAN_RxGetMessageDataFromCanData(&message, pCanData, endianness); +/*========== Static Function Implementations ================================*/ +static void CAN_ClearAllPersistentFlags(uint64_t signalData) { + /* AXIVION Routine Generic-MissingParameterAssert: signalData: parameter accepts whole range */ + if (signalData == 1u) { + /* clear deep discharge */ + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + (void)DIAG_Handler(DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_EVENT_OK, DIAG_STRING, s); + } + /* clear sys mon */ + SYSM_ClearAllTimingViolations(); + } +} - /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ - CAN_RxGetSignalDataFromMessageData(message, 1u, 2u, &signalData, endianness); - /* AXIVION Enable Style Generic-NoMagicNumbers: */ +static void CAN_HandleModeRequest(uint64_t signalData, const CAN_SHIM_s *const kpkCanShim) { + FAS_ASSERT(kpkCanShim != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: signalData: parameter accepts whole range */ /** 0x00: Disconnect strings from HV bus * 0x01: Connect strings to HV bus to start discharge @@ -112,35 +142,82 @@ extern uint32_t CAN_RxRequest( stateRequest = BMS_REQ_ID_CHARGE; break; default: - stateRequest = BMS_REQ_ID_NOREQ; + /* default value already set in initialization */ break; } kpkCanShim->pTableStateRequest->previousStateRequestViaCan = kpkCanShim->pTableStateRequest->stateRequestViaCan; kpkCanShim->pTableStateRequest->stateRequestViaCan = stateRequest; if ((kpkCanShim->pTableStateRequest->stateRequestViaCan != kpkCanShim->pTableStateRequest->previousStateRequestViaCan) || - ((OS_GetTickCount() - kpkCanShim->pTableStateRequest->header.timestamp) > 3000U)) { /* TODO: check pointer */ + (OS_CheckTimeHasPassed(kpkCanShim->pTableStateRequest->header.timestamp, CAN_CAN_REQUEST_UPDATE_TIME_ms))) { kpkCanShim->pTableStateRequest->stateRequestViaCanPending = stateRequest; } - kpkCanShim->pTableStateRequest->state++; - - /* Get balancing request */ - /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ - CAN_RxGetSignalDataFromMessageData(message, 8u, 1u, &signalData, endianness); - /* AXIVION Enable Style Generic-NoMagicNumbers: */ + if (kpkCanShim->pTableStateRequest->stateCounter == (uint8_t)UINT8_MAX) { + /* overflow of state counter */ + kpkCanShim->pTableStateRequest->stateCounter = 0u; + } else { + kpkCanShim->pTableStateRequest->stateCounter++; + } +} - if (STD_OK == BAL_GetInitializationState()) { - if ((uint8_t)signalData == 0u) { +static void CAN_HandleBalancingRequest(uint64_t signalData) { + /* AXIVION Routine Generic-MissingParameterAssert: signalData: parameter accepts whole range */ + /* AXIVION Next Line Style MisraC2012-2.2 MisraC2012-14.3: Depending on implementation STD_NOT_OK might be returned. */ + if (BAL_GetInitializationState() == STD_OK) { + if (signalData == 0u) { BAL_SetStateRequest(BAL_STATE_GLOBAL_DISABLE_REQUEST); } else { BAL_SetStateRequest(BAL_STATE_GLOBAL_ENABLE_REQUEST); } } +} + +static void CAN_SetBalancingThreshold(uint64_t signalData) { + /* cap signal data to UINT16_MAX */ + int32_t cappedSignalData = (int32_t)signalData; + if (signalData > (uint64_t)UINT16_MAX) { + cappedSignalData = (uint64_t)UINT16_MAX; + } + BAL_SetBalancingThreshold(cappedSignalData); +} + +/*========== Extern Function Implementations ================================*/ +extern uint32_t CAN_RxRequest( + uint32_t id, + uint8_t dlc, + CAN_ENDIANNESS_e endianness, + const uint8_t *const kpkCanData, + const CAN_SHIM_s *const kpkCanShim) { + FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ + FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ + FAS_ASSERT(kpkCanData != NULL_PTR); + FAS_ASSERT(kpkCanShim != NULL_PTR); + + DATA_READ_DATA(kpkCanShim->pTableStateRequest); + + uint64_t message = 0; + CAN_RxGetMessageDataFromCanData(&message, kpkCanData, endianness); + + uint64_t signalData = 0; + /* Get mode request */ + /* AXIVION Next Line Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ + CAN_RxGetSignalDataFromMessageData(message, 1u, 2u, &signalData, endianness); + CAN_HandleModeRequest(signalData, kpkCanShim); + + /* check for reset flag */ + /* AXIVION Next Line Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ + CAN_RxGetSignalDataFromMessageData(message, 2u, 1u, &signalData, endianness); + CAN_ClearAllPersistentFlags(signalData); + + /* Get balancing request */ + /* AXIVION Next Line Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ + CAN_RxGetSignalDataFromMessageData(message, 8u, 1u, &signalData, endianness); + CAN_HandleBalancingRequest(signalData); /* Get balancing threshold */ - /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ + /* AXIVION Next Line Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ CAN_RxGetSignalDataFromMessageData(message, 23u, 8u, &signalData, endianness); - /* AXIVION Enable Style Generic-NoMagicNumbers: */ + CAN_SetBalancingThreshold(signalData); /* TODO: Implement missing signals */ diff --git a/src/app/driver/can/cbs/can_cbs_rx_current_sensor.c b/src/app/driver/can/cbs/can_cbs_rx_current_sensor.c index 2af10ad4..c43697da 100644 --- a/src/app/driver/can/cbs/can_cbs_rx_current_sensor.c +++ b/src/app/driver/can/cbs/can_cbs_rx_current_sensor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_rx_current_sensor.c * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -68,14 +69,6 @@ /*========== Static Constant and Variable Definitions =======================*/ -/** - * CAN signals used in this message - * Parameters: - * bit start, bit length, factor, offset, minimum value, maximum value - */ -static const CAN_SIGNAL_TYPE_s currentSensorStatus = {7u, 8u, 1.0f, 0.0f, 0.0f, 255.0f}; -static const CAN_SIGNAL_TYPE_s currentSensorData = {23u, 32u, 1.0f, 0.0f, -2147483648.0f, 2147483648.0f}; - /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ @@ -87,16 +80,21 @@ extern uint32_t CAN_RxCurrentSensor( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) { - /* pMuxId is unused in this callback, therefore has to be a NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); - FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ - FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanData != NULL_PTR); FAS_ASSERT(kpkCanShim != NULL_PTR); + + /** + * CAN signals used in this message + * Parameters: + * bit start, bit length, factor, offset, minimum value, maximum value + */ + const CAN_SIGNAL_TYPE_s currentSensorStatus = {7u, 8u, 1.0f, 0.0f, 0.0f, 255.0f}; + const CAN_SIGNAL_TYPE_s currentSensorData = {23u, 32u, 1.0f, 0.0f, -2147483648.0f, 2147483648.0f}; + uint64_t message = 0u; uint64_t canSignal = 0u; @@ -112,7 +110,7 @@ extern uint32_t CAN_RxCurrentSensor( stringNumber = 2u; } - CAN_RxGetMessageDataFromCanData(&message, pCanData, endianness); + CAN_RxGetMessageDataFromCanData(&message, kpkCanData, endianness); /* Get status*/ CAN_RxGetSignalDataFromMessageData( diff --git a/src/app/driver/can/cbs/can_cbs_rx_imd.c b/src/app/driver/can/cbs/can_cbs_rx_imd.c index d827f978..78ce7f84 100644 --- a/src/app/driver/can/cbs/can_cbs_rx_imd.c +++ b/src/app/driver/can/cbs/can_cbs_rx_imd.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_rx_imd.c * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -71,25 +72,22 @@ extern uint32_t CAN_RxImdInfo( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) { /* This handler is only implemented for little endian */ FAS_ASSERT(endianness == CAN_LITTLE_ENDIAN); - /* pMuxId is not used here, therefore has to be NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ const uint8_t boundedDlc = MATH_MinimumOfTwoUint8_t(dlc, CAN_MAX_DLC); - FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanData != NULL_PTR); FAS_ASSERT(kpkCanShim != NULL_PTR); CAN_BUFFERELEMENT_s canMessage = {0}; uint32_t retVal = 1u; canMessage.id = id; for (uint8_t i = 0; i < boundedDlc; i++) { - canMessage.data[i] = pCanData[i]; + canMessage.data[i] = kpkCanData[i]; } if (OS_SendToBackOfQueue(*(kpkCanShim->pQueueImd), (void *)&canMessage, 0u) == OS_SUCCESS) { retVal = 0u; @@ -101,25 +99,23 @@ extern uint32_t CAN_RxImdResponse( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) { /* This handler is only implemented for little endian */ FAS_ASSERT(endianness == CAN_LITTLE_ENDIAN); - /* pMuxId is not used here, therefore has to be NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); - FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ - const uint8_t boundedDlc = MATH_MinimumOfTwoUint8_t(dlc, CAN_MAX_DLC); - FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanData != NULL_PTR); FAS_ASSERT(kpkCanShim != NULL_PTR); + + const uint8_t boundedDlc = MATH_MinimumOfTwoUint8_t(dlc, CAN_MAX_DLC); + CAN_BUFFERELEMENT_s canMessage = {0}; uint32_t retVal = 1u; canMessage.id = id; for (uint8_t i = 0; i < boundedDlc; i++) { - canMessage.data[i] = pCanData[i]; + canMessage.data[i] = kpkCanData[i]; } if (OS_SendToBackOfQueue(*(kpkCanShim->pQueueImd), (void *)&canMessage, 0u) == OS_SUCCESS) { retVal = 0u; diff --git a/src/app/driver/can/cbs/can_cbs_rx_misc.c b/src/app/driver/can/cbs/can_cbs_rx_misc.c index c9521484..bf11d1a8 100644 --- a/src/app/driver/can/cbs/can_cbs_rx_misc.c +++ b/src/app/driver/can/cbs/can_cbs_rx_misc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_rx_misc.c * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -71,17 +72,14 @@ extern uint32_t CAN_RxSwReset( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) { - /* pMuxId is not used here, therefore has to be NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); /* This handler is only implemented for little endian */ FAS_ASSERT(endianness == CAN_LITTLE_ENDIAN); FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ - FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanData != NULL_PTR); FAS_ASSERT(kpkCanShim != NULL_PTR); return 0; } @@ -90,21 +88,17 @@ extern uint32_t CAN_RxDebug( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) { - /* pMuxId is not used here, therefore has to be NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); - FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ - FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanData != NULL_PTR); FAS_ASSERT(kpkCanShim != NULL_PTR); uint64_t message = 0; uint64_t signalData = 0; - CAN_RxGetMessageDataFromCanData(&message, pCanData, endianness); + CAN_RxGetMessageDataFromCanData(&message, kpkCanData, endianness); uint64_t bitStart = 0; uint8_t bitLength = 8; @@ -127,17 +121,14 @@ extern uint32_t CAN_RxSwVersion( uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, - uint8_t *pCanData, - uint8_t *pMuxId, + const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) { - /* pMuxId is not used here, therefore has to be NULL_PTR */ - FAS_ASSERT(pMuxId == NULL_PTR); /* This handler is only implemented for little endian */ FAS_ASSERT(endianness == CAN_LITTLE_ENDIAN); FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ - FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanData != NULL_PTR); FAS_ASSERT(kpkCanShim != NULL_PTR); return 0; } diff --git a/src/app/driver/can/cbs/can_cbs_tx_limits.c b/src/app/driver/can/cbs/can_cbs_tx_limits.c index 4cdf2daa..e8fa1a08 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_limits.c +++ b/src/app/driver/can/cbs/can_cbs_tx_limits.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_limits.c * @author foxBMS Team * @date 2021-07-21 (date of creation) - * @updated 2021-07-21 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -109,7 +110,7 @@ extern uint32_t CAN_TxLimitValues( /* TODO: maximum discharge power */ /* minimum pack voltage */ - signalData = (float)(BS_NR_OF_BAT_CELLS * BC_VOLTAGE_MIN_MSL_mV); + signalData = (float)(BS_NR_OF_CELL_BLOCKS_PER_STRING * BC_VOLTAGE_MIN_MSL_mV); offset = 0.0f; factor = 0.00025f; /* convert mV to 4V */ signalData = (signalData + offset) * factor; @@ -118,7 +119,7 @@ extern uint32_t CAN_TxLimitValues( CAN_TxSetMessageDataWithSignalData(&message, 63u, 8u, data, endianness); /* maximum pack voltage */ - signalData = (float)(BS_NR_OF_BAT_CELLS * BC_VOLTAGE_MAX_MSL_mV); + signalData = (float)(BS_NR_OF_CELL_BLOCKS_PER_STRING * BC_VOLTAGE_MAX_MSL_mV); offset = 0.0f; factor = 0.00025f; /* convert mV to 4V */ signalData = (signalData + offset) * factor; diff --git a/src/app/driver/can/cbs/can_cbs_tx_minmax.c b/src/app/driver/can/cbs/can_cbs_tx_minmax.c index 19bab85c..0e36988b 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_minmax.c +++ b/src/app/driver/can/cbs/can_cbs_tx_minmax.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_minmax.c * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-07-21 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -92,35 +93,35 @@ extern uint32_t CAN_TxMinimumMaximumValues( if (0u == BMS_GetNumberOfConnectedStrings()) { /* Calculate min/max values of complete pack if all slice switches are open */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (kpkCanShim->pTableMinMax->maximumCellVoltage_mV[stringNumber] >= packMaximumVoltage_mV) { - packMaximumVoltage_mV = kpkCanShim->pTableMinMax->maximumCellVoltage_mV[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (kpkCanShim->pTableMinMax->maximumCellVoltage_mV[s] >= packMaximumVoltage_mV) { + packMaximumVoltage_mV = kpkCanShim->pTableMinMax->maximumCellVoltage_mV[s]; } - if (kpkCanShim->pTableMinMax->minimumCellVoltage_mV[stringNumber] <= packMinimumVoltage_mV) { - packMinimumVoltage_mV = kpkCanShim->pTableMinMax->minimumCellVoltage_mV[stringNumber]; + if (kpkCanShim->pTableMinMax->minimumCellVoltage_mV[s] <= packMinimumVoltage_mV) { + packMinimumVoltage_mV = kpkCanShim->pTableMinMax->minimumCellVoltage_mV[s]; } - if (kpkCanShim->pTableMinMax->maximumTemperature_ddegC[stringNumber] >= packMaximumTemperature_ddegC) { - packMaximumTemperature_ddegC = kpkCanShim->pTableMinMax->maximumTemperature_ddegC[stringNumber]; + if (kpkCanShim->pTableMinMax->maximumTemperature_ddegC[s] >= packMaximumTemperature_ddegC) { + packMaximumTemperature_ddegC = kpkCanShim->pTableMinMax->maximumTemperature_ddegC[s]; } - if (kpkCanShim->pTableMinMax->minimumTemperature_ddegC[stringNumber] <= packMinimumTemperature_ddegC) { - packMinimumTemperature_ddegC = kpkCanShim->pTableMinMax->minimumTemperature_ddegC[stringNumber]; + if (kpkCanShim->pTableMinMax->minimumTemperature_ddegC[s] <= packMinimumTemperature_ddegC) { + packMinimumTemperature_ddegC = kpkCanShim->pTableMinMax->minimumTemperature_ddegC[s]; } } } else { /* Calculate min/max values of connected slices */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (true == BMS_IsStringClosed(stringNumber)) { - if (kpkCanShim->pTableMinMax->maximumCellVoltage_mV[stringNumber] >= packMaximumVoltage_mV) { - packMaximumVoltage_mV = kpkCanShim->pTableMinMax->maximumCellVoltage_mV[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (BMS_IsStringClosed(s) == true) { + if (kpkCanShim->pTableMinMax->maximumCellVoltage_mV[s] >= packMaximumVoltage_mV) { + packMaximumVoltage_mV = kpkCanShim->pTableMinMax->maximumCellVoltage_mV[s]; } - if (kpkCanShim->pTableMinMax->minimumCellVoltage_mV[stringNumber] <= packMinimumVoltage_mV) { - packMinimumVoltage_mV = kpkCanShim->pTableMinMax->minimumCellVoltage_mV[stringNumber]; + if (kpkCanShim->pTableMinMax->minimumCellVoltage_mV[s] <= packMinimumVoltage_mV) { + packMinimumVoltage_mV = kpkCanShim->pTableMinMax->minimumCellVoltage_mV[s]; } - if (kpkCanShim->pTableMinMax->maximumTemperature_ddegC[stringNumber] >= packMaximumTemperature_ddegC) { - packMaximumTemperature_ddegC = kpkCanShim->pTableMinMax->maximumTemperature_ddegC[stringNumber]; + if (kpkCanShim->pTableMinMax->maximumTemperature_ddegC[s] >= packMaximumTemperature_ddegC) { + packMaximumTemperature_ddegC = kpkCanShim->pTableMinMax->maximumTemperature_ddegC[s]; } - if (kpkCanShim->pTableMinMax->minimumTemperature_ddegC[stringNumber] <= packMinimumTemperature_ddegC) { - packMinimumTemperature_ddegC = kpkCanShim->pTableMinMax->minimumTemperature_ddegC[stringNumber]; + if (kpkCanShim->pTableMinMax->minimumTemperature_ddegC[s] <= packMinimumTemperature_ddegC) { + packMinimumTemperature_ddegC = kpkCanShim->pTableMinMax->minimumTemperature_ddegC[s]; } } } diff --git a/src/app/driver/can/cbs/can_cbs_tx_state.c b/src/app/driver/can/cbs/can_cbs_tx_state.c index e44e4f26..6982fea7 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_state.c +++ b/src/app/driver/can/cbs/can_cbs_tx_state.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_state.c * @author foxBMS Team * @date 2021-07-21 (date of creation) - * @updated 2021-07-21 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -56,6 +57,7 @@ #include "can_cbs.h" #include "can_helper.h" #include "diag.h" +#include "sys_mon.h" /*========== Macros and Definitions =========================================*/ @@ -64,8 +66,22 @@ /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** get a boolean for if any timing error (current or recorded) occurred */ +static bool CAN_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim); /*========== Static Function Implementations ================================*/ +static bool CAN_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim) { + FAS_ASSERT(kpkCanShim != NULL_PTR); + SYSM_TIMING_VIOLATION_RESPONSE_s recordedTimingViolations = {0}; + SYSM_GetRecordedTimingViolations(&recordedTimingViolations); + + const bool anyTimingViolation = + (recordedTimingViolations.recordedViolationAny || kpkCanShim->pTableErrorState->timingViolationEngine || + kpkCanShim->pTableErrorState->timingViolation1ms || kpkCanShim->pTableErrorState->timingViolation10ms || + kpkCanShim->pTableErrorState->timingViolation100ms || kpkCanShim->pTableErrorState->timingViolation100msAlgo); + + return anyTimingViolation; +} /*========== Extern Function Implementations ================================*/ extern uint32_t CAN_TxState( @@ -98,27 +114,27 @@ extern uint32_t CAN_TxState( CAN_TxSetMessageDataWithSignalData(&message, 7u, 4u, data, endianness); /* General error - implement now */ - if (true == DIAG_IsAnyFatalErrorSet()) { - data = 1u; - } else { - data = 0u; - } + data = CAN_ConvertBooleanToInteger(DIAG_IsAnyFatalErrorSet()); CAN_TxSetMessageDataWithSignalData(&message, 11u, 1u, data, endianness); /* General warning: TODO */ /* Emergency shutoff */ - if (true == BMS_IsTransitionToErrorStateActive()) { - data = 1u; - } else { - data = 0u; - } + data = CAN_ConvertBooleanToInteger(BMS_IsTransitionToErrorStateActive()); CAN_TxSetMessageDataWithSignalData(&message, 10u, 1u, data, endianness); /* Number of deactivated strings: TODO */ + /* sys mon error */ + data = CAN_ConvertBooleanToInteger(CAN_AnySysMonTimingIssueDetected(kpkCanShim)); + CAN_TxSetMessageDataWithSignalData(&message, 12u, 1u, data, endianness); + + /* Insulation monitoring active */ + data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableInsulation->isImdRunning); + CAN_TxSetMessageDataWithSignalData(&message, 13u, 1u, data, endianness); + /* Error: insulation */ - data = kpkCanShim->pTableErrorState->insulationError; + data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableErrorState->criticalLowInsulationResistance); CAN_TxSetMessageDataWithSignalData(&message, 23u, 1u, data, endianness); /* Insulation resistance */ @@ -129,10 +145,6 @@ extern uint32_t CAN_TxState( /* Charging complete: TODO */ - /* Insulation monitoring active */ - data = kpkCanShim->pTableInsulation->insulationMeasurements; - CAN_TxSetMessageDataWithSignalData(&message, 13u, 1u, data, endianness); - /* Heater state: TODO */ /* Cooling state: TODO */ @@ -170,6 +182,67 @@ extern uint32_t CAN_TxState( return 0; } + +extern uint32_t CAN_TxDetailState( + uint32_t id, + uint8_t dlc, + CAN_ENDIANNESS_e endianness, + uint8_t *pCanData, + uint8_t *pMuxId, + const CAN_SHIM_s *const kpkCanShim) { + /* pMuxId is not used here, therefore has to be NULL_PTR */ + FAS_ASSERT(pMuxId == NULL_PTR); + + FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */ + FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */ + FAS_ASSERT(pCanData != NULL_PTR); + FAS_ASSERT(kpkCanShim != NULL_PTR); + uint64_t message = 0; + + DATA_READ_DATA(kpkCanShim->pTableErrorState); + SYSM_TIMING_VIOLATION_RESPONSE_s recordedTimingViolations = {0}; + SYSM_GetRecordedTimingViolations(&recordedTimingViolations); + + /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */ + /* current violation engine */ + uint64_t data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableErrorState->timingViolationEngine); + CAN_TxSetMessageDataWithSignalData(&message, 0u, 1u, data, endianness); + /* current violation 1ms */ + data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableErrorState->timingViolation1ms); + CAN_TxSetMessageDataWithSignalData(&message, 1u, 1u, data, endianness); + /* current violation 10ms */ + data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableErrorState->timingViolation10ms); + CAN_TxSetMessageDataWithSignalData(&message, 2u, 1u, data, endianness); + /* current violation 100ms */ + data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableErrorState->timingViolation100ms); + CAN_TxSetMessageDataWithSignalData(&message, 3u, 1u, data, endianness); + /* current violation 100ms algorithm */ + data = CAN_ConvertBooleanToInteger(kpkCanShim->pTableErrorState->timingViolation100msAlgo); + CAN_TxSetMessageDataWithSignalData(&message, 4u, 1u, data, endianness); + + /* recorded violation engine */ + data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolationEngine); + CAN_TxSetMessageDataWithSignalData(&message, 8u, 1u, data, endianness); + /* recorded violation 1ms */ + data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation1ms); + CAN_TxSetMessageDataWithSignalData(&message, 9u, 1u, data, endianness); + /* recorded violation 10ms */ + data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation10ms); + CAN_TxSetMessageDataWithSignalData(&message, 10u, 1u, data, endianness); + /* recorded violation 100ms */ + data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation100ms); + CAN_TxSetMessageDataWithSignalData(&message, 11u, 1u, data, endianness); + /* recorded violation 100ms algorithm */ + data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation100msAlgo); + CAN_TxSetMessageDataWithSignalData(&message, 12u, 1u, data, endianness); + /* AXIVION Enable Style Generic-NoMagicNumbers: */ + + /* now copy data in the buffer that will be use to send data */ + CAN_TxSetCanDataWithMessageData(message, pCanData, endianness); + + return 0; +} + extern uint32_t CAN_TxStringState( uint32_t id, uint8_t dlc, @@ -202,18 +275,14 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 3u, 4u, data, endianness); /* String connected */ - if (true == BMS_IsStringClosed(stringNumber)) { - data = 1u; - } else { - data = 0u; - } + data = CAN_ConvertBooleanToInteger(BMS_IsStringClosed(stringNumber)); CAN_TxSetMessageDataWithSignalData(&message, 4u, 1u, data, endianness); /* Balancing active: TODO */ /* String fuse blown */ - if ((1u == kpkCanShim->pTableErrorState->fuseStateCharge[stringNumber]) || - (1u == kpkCanShim->pTableErrorState->fuseStateNormal[stringNumber])) { + if ((kpkCanShim->pTableErrorState->fuseStateCharge[stringNumber] == 1u) || + (kpkCanShim->pTableErrorState->fuseStateNormal[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -241,8 +310,8 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 11u, 1u, data, endianness); /* Error: Overcurrent charge */ - if ((1u == kpkCanShim->pTableMsl->cellChargeOvercurrent[stringNumber]) || - (1u == kpkCanShim->pTableMsl->stringChargeOvercurrent[stringNumber])) { + if ((kpkCanShim->pTableMsl->cellChargeOvercurrent[stringNumber] == 1u) || + (kpkCanShim->pTableMsl->stringChargeOvercurrent[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -250,8 +319,8 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 12u, 1u, data, endianness); /* Error: Overcurrent discharge */ - if ((1u == kpkCanShim->pTableMsl->cellDischargeOvercurrent[stringNumber]) || - (1u == kpkCanShim->pTableMsl->stringDischargeOvercurrent[stringNumber])) { + if ((kpkCanShim->pTableMsl->cellDischargeOvercurrent[stringNumber] == 1u) || + (kpkCanShim->pTableMsl->stringDischargeOvercurrent[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -283,8 +352,8 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 19u, 1u, data, endianness); /* Info: Overcurrent charge - MOL */ - if ((1u == kpkCanShim->pTableMol->cellChargeOvercurrent[stringNumber]) || - (1u == kpkCanShim->pTableMol->stringChargeOvercurrent[stringNumber])) { + if ((kpkCanShim->pTableMol->cellChargeOvercurrent[stringNumber] == 1u) || + (kpkCanShim->pTableMol->stringChargeOvercurrent[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -292,8 +361,8 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 20u, 1u, data, endianness); /* Info: Overcurrent discharge - MOL */ - if ((1u == kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber]) || - (1u == kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber])) { + if ((kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber] == 1u) || + (kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -325,8 +394,8 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 27u, 1u, data, endianness); /* Warning: Overcurrent charge - RSL */ - if ((1u == kpkCanShim->pTableRsl->cellChargeOvercurrent[stringNumber]) || - (1u == kpkCanShim->pTableRsl->stringChargeOvercurrent[stringNumber])) { + if ((kpkCanShim->pTableRsl->cellChargeOvercurrent[stringNumber] == 1u) || + (kpkCanShim->pTableRsl->stringChargeOvercurrent[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -334,8 +403,8 @@ extern uint32_t CAN_TxStringState( CAN_TxSetMessageDataWithSignalData(&message, 28u, 1u, data, endianness); /* Warning: Overcurrent discharge - RSL */ - if ((1u == kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber]) || - (1u == kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber])) { + if ((kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber] == 1u) || + (kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber] == 1u)) { data = 1u; } else { data = 0u; @@ -376,8 +445,8 @@ extern uint32_t CAN_TxStringState( /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */ /* Error: current measurement */ - if ((1u == kpkCanShim->pTableErrorState->currentMeasurementError[stringNumber]) || - (1u == kpkCanShim->pTableErrorState->currentMeasurementTimeout[stringNumber])) { + if ((kpkCanShim->pTableErrorState->currentMeasurementError[stringNumber] == 1u) || + (kpkCanShim->pTableErrorState->currentMeasurementTimeout[stringNumber] == 1u)) { data = 1u; } else { data = 0u; diff --git a/src/app/driver/can/cbs/can_cbs_tx_state_estimation.c b/src/app/driver/can/cbs/can_cbs_tx_state_estimation.c index fbe0e695..a8b250c4 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_state_estimation.c +++ b/src/app/driver/can/cbs/can_cbs_tx_state_estimation.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_state_estimation.c * @author foxBMS Team * @date 2021-07-21 (date of creation) - * @updated 2021-07-21 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -95,31 +96,31 @@ extern uint32_t CAN_TxStateEstimation( /* Check current direction */ if (BMS_GetBatterySystemState() == BMS_CHARGING) { /* If battery system is charging use maximum values */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (true == BMS_IsStringClosed(stringNumber)) { - if (maximumStringSoc_perc < kpkCanShim->pTableSox->maximumSoc_perc[stringNumber]) { - maximumStringSoc_perc = kpkCanShim->pTableSox->maximumSoc_perc[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (BMS_IsStringClosed(s) == true) { + if (maximumStringSoc_perc < kpkCanShim->pTableSox->maximumSoc_perc[s]) { + maximumStringSoc_perc = kpkCanShim->pTableSox->maximumSoc_perc[s]; } - if (maximumStringSoe_perc < kpkCanShim->pTableSox->maximumSoe_perc[stringNumber]) { - maximumStringSoe_perc = kpkCanShim->pTableSox->maximumSoe_perc[stringNumber]; + if (maximumStringSoe_perc < kpkCanShim->pTableSox->maximumSoe_perc[s]) { + maximumStringSoe_perc = kpkCanShim->pTableSox->maximumSoe_perc[s]; } - if (minimumStringEnergy_Wh > kpkCanShim->pTableSox->minimumSoe_Wh[stringNumber]) { - minimumStringEnergy_Wh = kpkCanShim->pTableSox->minimumSoe_Wh[stringNumber]; + if (minimumStringEnergy_Wh > kpkCanShim->pTableSox->minimumSoe_Wh[s]) { + minimumStringEnergy_Wh = kpkCanShim->pTableSox->minimumSoe_Wh[s]; } } } } else { /* If battery system is discharging or at rest use minimum values */ - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (true == BMS_IsStringClosed(stringNumber)) { - if (minimumStringSoc_perc > kpkCanShim->pTableSox->minimumSoc_perc[stringNumber]) { - minimumStringSoc_perc = kpkCanShim->pTableSox->minimumSoc_perc[stringNumber]; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (BMS_IsStringClosed(s) == true) { + if (minimumStringSoc_perc > kpkCanShim->pTableSox->minimumSoc_perc[s]) { + minimumStringSoc_perc = kpkCanShim->pTableSox->minimumSoc_perc[s]; } - if (minimumStringSoe_perc > kpkCanShim->pTableSox->minimumSoe_perc[stringNumber]) { - minimumStringSoe_perc = kpkCanShim->pTableSox->minimumSoe_perc[stringNumber]; + if (minimumStringSoe_perc > kpkCanShim->pTableSox->minimumSoe_perc[s]) { + minimumStringSoe_perc = kpkCanShim->pTableSox->minimumSoe_perc[s]; } - if (minimumStringEnergy_Wh > kpkCanShim->pTableSox->minimumSoe_Wh[stringNumber]) { - minimumStringEnergy_Wh = kpkCanShim->pTableSox->minimumSoe_Wh[stringNumber]; + if (minimumStringEnergy_Wh > kpkCanShim->pTableSox->minimumSoe_Wh[s]) { + minimumStringEnergy_Wh = kpkCanShim->pTableSox->minimumSoe_Wh[s]; } } } diff --git a/src/app/driver/can/cbs/can_cbs_tx_system_values.c b/src/app/driver/can/cbs/can_cbs_tx_system_values.c index 38d3de3e..8a5e7df4 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_system_values.c +++ b/src/app/driver/can/cbs/can_cbs_tx_system_values.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_system_values.c * @author foxBMS Team * @date 2021-07-21 (date of creation) - * @updated 2021-07-21 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -89,7 +90,7 @@ extern uint32_t CAN_TxPackValues( /* Battery voltage */ float signalData = kpkCanShim->pTablePackValues->batteryVoltage_mV; float offset = 0.0f; - float factor = 0.01f; /* convert mV -> 100mV */ + float factor = 0.01f; /* convert mV to 100mV */ signalData = (signalData + offset) * factor; uint64_t data = (uint64_t)signalData; /* set data in CAN frame */ @@ -98,7 +99,7 @@ extern uint32_t CAN_TxPackValues( /* System voltage */ signalData = kpkCanShim->pTablePackValues->highVoltageBusVoltage_mV; offset = 0.0f; - factor = 0.01f; /* convert mV -> 100mV */ + factor = 0.01f; /* convert mV to 100mV */ signalData = (signalData + offset) * factor; data = (uint64_t)signalData; /* set data in CAN frame */ @@ -107,7 +108,7 @@ extern uint32_t CAN_TxPackValues( /* System current */ signalData = kpkCanShim->pTablePackValues->packCurrent_mA; offset = 0.0f; - factor = 0.1f; /* convert mA -> 10mA */ + factor = 0.1f; /* convert mA to 10mA */ signalData = (signalData + offset) * factor; data = (int64_t)signalData; /* set data in CAN frame */ @@ -116,7 +117,7 @@ extern uint32_t CAN_TxPackValues( /* System power */ signalData = kpkCanShim->pTablePackValues->packPower_W; offset = 0.0f; - factor = 0.1f; /* convert W -> 10W */ + factor = 0.1f; /* convert W to 10W */ signalData = (signalData + offset) * factor; data = (int64_t)signalData; /* set data in CAN frame */ diff --git a/src/app/driver/can/cbs/can_cbs_tx_temperature.c b/src/app/driver/can/cbs/can_cbs_tx_temperature.c index ebed51d0..09519344 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_temperature.c +++ b/src/app/driver/can/cbs/can_cbs_tx_temperature.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_temperature.c * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * diff --git a/src/app/driver/can/cbs/can_cbs_tx_voltage.c b/src/app/driver/can/cbs/can_cbs_tx_voltage.c index 4e516f32..f973af0c 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_voltage.c +++ b/src/app/driver/can/cbs/can_cbs_tx_voltage.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cbs_tx_voltage.c * @author foxBMS Team * @date 2021-04-20 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix CAN * @@ -111,7 +112,7 @@ static void CAN_TxVoltageSetData( CAN_ENDIANNESS_e endianness, const CAN_SHIM_s *const kpkCanShim) { /* cell index must not be greater than the number of cells */ - if (muxId < (BS_NR_OF_BAT_CELLS * BS_NR_OF_STRINGS)) { + if (muxId < (BS_NR_OF_CELL_BLOCKS_PER_STRING * BS_NR_OF_STRINGS)) { /* Get string, module and cell number */ const uint8_t stringNumber = DATA_GetStringNumberFromVoltageIndex(muxId); const uint8_t moduleNumber = DATA_GetModuleNumberFromVoltageIndex(muxId); @@ -136,7 +137,7 @@ static void CAN_TxVoltageSetData( /*Voltage data */ float signalData_mV = (float)(kpkCanShim->pTableCellVoltage - ->cellVoltage_mV[stringNumber][(moduleNumber * BS_NR_OF_CELLS_PER_MODULE) + cellNumber]); + ->cellVoltage_mV[stringNumber][(moduleNumber * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + cellNumber]); /* Apply offset and factor */ CAN_TxPrepareSignalData(&signalData_mV, cellVoltageSignal); /* Set voltage data in CAN frame */ @@ -161,7 +162,7 @@ extern uint32_t CAN_TxVoltage( uint64_t message = 0; /* Reset mux if maximum was reached */ - if (*pMuxId >= (BS_NR_OF_STRINGS * BS_NR_OF_BAT_CELLS)) { + if (*pMuxId >= (BS_NR_OF_STRINGS * BS_NR_OF_CELL_BLOCKS_PER_STRING)) { *pMuxId = 0u; } /* First signal to transmit cell voltages: get database values */ diff --git a/src/app/driver/can/cbs/can_helper.c b/src/app/driver/can/cbs/can_helper.c index 1adfb1ba..b96beb20 100644 --- a/src/app/driver/can/cbs/can_helper.c +++ b/src/app/driver/can/cbs/can_helper.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_helper.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CAN * @@ -332,4 +333,12 @@ extern void CAN_RxGetMessageDataFromCanData( } } +extern uint8_t CAN_ConvertBooleanToInteger(bool input) { + uint8_t returnValue = 0u; + if (input == true) { + returnValue = 1u; + } + return returnValue; +} + /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/can/cbs/can_helper.h b/src/app/driver/can/cbs/can_helper.h index 7c441e36..1d47686a 100644 --- a/src/app/driver/can/cbs/can_helper.h +++ b/src/app/driver/can/cbs/can_helper.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_helper.h * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CAN * @@ -76,7 +77,7 @@ /**@}*/ /** type definition for fields of a CAN signal */ -typedef struct CAN_SIGNAL_TYPE { +typedef struct { uint8_t bitStart; /*!< start bit of signal in CAN message */ uint8_t bitLength; /*!< length bit of signal in CAN message */ float factor; /*!< scaling factor applied to data */ @@ -169,6 +170,13 @@ extern void CAN_RxGetMessageDataFromCanData( const uint8_t *const kpkCanData, CAN_ENDIANNESS_e endianness); +/** + * @brief Transform a bool to a bit (set if true) + * @param[in] input input boolean (true will become 1u) + * @returns unsigned integer indicating the state of the input + */ +extern uint8_t CAN_ConvertBooleanToInteger(bool input); + /*========== Externalized Static Function Implementations (Unit Test) =======*/ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/checksum/checksum.c b/src/app/driver/checksum/checksum.c index 911bdf05..788086dc 100644 --- a/src/app/driver/checksum/checksum.c +++ b/src/app/driver/checksum/checksum.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file checksum.c * @author foxBMS Team * @date 2019-12-03 (date of creation) - * @updated 2019-12-03 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TODO * @prefix CHK * diff --git a/src/app/driver/checksum/checksum.h b/src/app/driver/checksum/checksum.h index 9a94e977..0797778c 100644 --- a/src/app/driver/checksum/checksum.h +++ b/src/app/driver/checksum/checksum.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file checksum.h * @author foxBMS Team * @date 2019-12-03 (date of creation) - * @updated 2019-12-03 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TODO * @prefix CHK * diff --git a/src/app/driver/config/can_cfg.c b/src/app/driver/config/can_cfg.c index fadbd7aa..99b7d2e8 100644 --- a/src/app/driver/config/can_cfg.c +++ b/src/app/driver/config/can_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cfg.c * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-10-12 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix CAN * @@ -94,6 +95,14 @@ const CAN_MSG_TX_TYPE_s can_txMessages[] = { CAN_BIG_ENDIAN, &CAN_TxState, NULL_PTR}, /*!< State */ + {CAN1_NODE, + CAN_ID_TX_DETAIL_STATE, + CAN_DLC, + CAN_TX_DETAIL_STATE_PERIOD_MS, + CAN_TX_DETAIL_STATE_PHASE_MS, + CAN_BIG_ENDIAN, + &CAN_TxDetailState, + NULL_PTR}, /*!< Detail State */ {CAN1_NODE, CAN_ID_TX_VOLTAGES, CAN_DLC, diff --git a/src/app/driver/config/can_cfg.h b/src/app/driver/config/can_cfg.h index 4c7fb9d0..ac8d1b7c 100644 --- a/src/app/driver/config/can_cfg.h +++ b/src/app/driver/config/can_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file can_cfg.h * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CAN * @@ -91,108 +92,115 @@ /** TX messages - pack related */ +/** CAN message ID for boot message */ +#define CAN_ID_BOOT_MESSAGE (0x199u) +/** CAN message ID for die id message */ +#define CAN_ID_DIE_ID (0x227u) /** CAN message ID to send state */ -#define CAN_ID_TX_STATE (0x220U) +#define CAN_ID_TX_STATE (0x220u) /** Periodicity of CAN state messages in ms */ -#define CAN_TX_STATE_PERIOD_MS (100U) +#define CAN_TX_STATE_PERIOD_MS (100u) /** Phase of CAN state messages in ms */ -#define CAN_TX_STATE_PHASE_MS (0U) +#define CAN_TX_STATE_PHASE_MS (0u) +/** CAN message ID to send detail state */ +#define CAN_ID_TX_DETAIL_STATE (0x226u) +/** Periodicity of CAN detail state messages in ms */ +#define CAN_TX_DETAIL_STATE_PERIOD_MS (1000u) +/** Phase of CAN detail state messages in ms */ +#define CAN_TX_DETAIL_STATE_PHASE_MS (100u) /** CAN message ID to send voltages */ -#define CAN_ID_TX_VOLTAGES (0x240U) +#define CAN_ID_TX_VOLTAGES (0x240u) /** Periodicity of CAN voltage messages in ms */ -#define CAN_TX_VOLTAGES_PERIOD_MS (100U) +#define CAN_TX_VOLTAGES_PERIOD_MS (100u) /** Phase of CAN voltage messages in ms */ -#define CAN_TX_VOLTAGES_PHASE_MS (10U) +#define CAN_TX_VOLTAGES_PHASE_MS (10u) /** CAN message ID to send temperatures */ -#define CAN_ID_TX_TEMPERATURES (0x250U) +#define CAN_ID_TX_TEMPERATURES (0x250u) /** Periodicity of CAN temperature messages in ms */ -#define CAN_TX_TEMPERATURES_PERIOD_MS (200U) +#define CAN_TX_TEMPERATURES_PERIOD_MS (200u) /** Phase of CAN temperature messages in ms */ -#define CAN_TX_TEMPERATURES_PHASE_MS (20U) +#define CAN_TX_TEMPERATURES_PHASE_MS (20u) /** CAN message ID to send limit values */ -#define CAN_ID_TX_LIMIT_VALUES (0x224U) +#define CAN_ID_TX_LIMIT_VALUES (0x224u) /** Periodicity of CAN limit messages in ms */ -#define CAN_TX_LIMIT_VALUES_PERIOD_MS (100U) +#define CAN_TX_LIMIT_VALUES_PERIOD_MS (100u) /** Phase of CAN limit messages in ms */ -#define CAN_TX_LIMIT_VALUES_PHASE_MS (30U) +#define CAN_TX_LIMIT_VALUES_PHASE_MS (30u) /** CAN message ID to send minimum and maximum values */ -#define CAN_ID_TX_MINIMUM_MAXIMUM_VALUES (0x223U) +#define CAN_ID_TX_MINIMUM_MAXIMUM_VALUES (0x223u) /** Periodicity of CAN minimum and maximum value messages in ms */ -#define CAN_TX_MINIMUM_MAXIMUM_VALUES_PERIOD_MS (100U) +#define CAN_TX_MINIMUM_MAXIMUM_VALUES_PERIOD_MS (100u) /** Phase of CAN minimum and maximum value messages in ms */ -#define CAN_TX_MINIMUM_MAXIMUM_VALUES_PHASE_MS (40U) +#define CAN_TX_MINIMUM_MAXIMUM_VALUES_PHASE_MS (40u) /** CAN message ID to send pack state estimation values */ -#define CAN_ID_TX_PACK_STATE_ESTIMATION (0x225U) +#define CAN_ID_TX_PACK_STATE_ESTIMATION (0x225u) /** Periodicity of CAN pack state estimation messages in ms */ -#define CAN_TX_PACK_STATE_ESTIMATION_PERIOD_MS (1000U) +#define CAN_TX_PACK_STATE_ESTIMATION_PERIOD_MS (1000u) /** Phase of CAN pack state estimation messages in ms */ -#define CAN_TX_PACK_STATE_ESTIMATION_PHASE_MS (50U) +#define CAN_TX_PACK_STATE_ESTIMATION_PHASE_MS (50u) /** CAN message ID to send pack values */ -#define CAN_ID_TX_PACK_VALUES (0x222U) +#define CAN_ID_TX_PACK_VALUES (0x222u) /** Periodicity of CAN pack values messages in ms */ -#define CAN_TX_PACK_VALUES_PERIOD_MS (100U) +#define CAN_TX_PACK_VALUES_PERIOD_MS (100u) /** Phase of CAN pack values messages in ms */ -#define CAN_TX_PACK_VALUES_PHASE_MS (60U) +#define CAN_TX_PACK_VALUES_PHASE_MS (60u) /** TX messages - string related */ /** CAN message ID to send string state */ -#define CAN_ID_TX_STRING_STATE (0x221U) +#define CAN_ID_TX_STRING_STATE (0x221u) /** Periodicity of CAN string state messages in ms */ -#define CAN_TX_STRING_STATE_PERIOD_MS (100U) +#define CAN_TX_STRING_STATE_PERIOD_MS (100u) /** Phase of CAN string state messages in ms */ -#define CAN_TX_STRING_STATE_PHASE_MS (70U) +#define CAN_TX_STRING_STATE_PHASE_MS (70u) /** CAN message ID to send string values */ -#define CAN_ID_TX_STRING_VALUES (0x280U) +#define CAN_ID_TX_STRING_VALUES (0x280u) /** Periodicity of CAN string state messages in ms */ -#define CAN_TX_STRING_VALUES_PERIOD_MS (100U) +#define CAN_TX_STRING_VALUES_PERIOD_MS (100u) /** Phase of CAN string state messages in ms */ -#define CAN_TX_STRING_VALUES_PHASE_MS (80U) +#define CAN_TX_STRING_VALUES_PHASE_MS (80u) /** CAN message ID to send string minimum and maximum values */ -#define CAN_ID_TX_STRING_MINIMUM_MAXIMUM (0x281U) +#define CAN_ID_TX_STRING_MINIMUM_MAXIMUM (0x281u) /** Periodicity of CAN string state messages in ms */ -#define CAN_TX_STRING_MINIMUM_MAXIMUM_PERIOD_MS (100U) +#define CAN_TX_STRING_MINIMUM_MAXIMUM_PERIOD_MS (100u) /** Phase of CAN string state messages in ms */ -#define CAN_TX_STRING_MINIMUM_MAXIMUM_PHASE_MS (90U) +#define CAN_TX_STRING_MINIMUM_MAXIMUM_PHASE_MS (90u) /** CAN message ID to send string minimum and maximum values */ -#define CAN_ID_TX_STRING_STATE_ESTIMATION (0x282U) +#define CAN_ID_TX_STRING_STATE_ESTIMATION (0x282u) /** Periodicity of CAN string state messages in ms */ -#define CAN_TX_STRING_STATE_ESTIMATION_PERIOD_MS (1000U) +#define CAN_TX_STRING_STATE_ESTIMATION_PERIOD_MS (1000u) /** Phase of CAN string state messages in ms */ -#define CAN_TX_STRING_STATE_ESTIMATION_PHASE_MS (0U) +#define CAN_TX_STRING_STATE_ESTIMATION_PHASE_MS (0u) /** CAN message ID to send string values 2 */ -#define CAN_ID_TX_STRING_VALUES_2 (0x283U) +#define CAN_ID_TX_STRING_VALUES_2 (0x283u) /** Periodicity of CAN string state messages in ms */ -#define CAN_TX_STRING_VALUES_2_PERIOD_MS (100U) +#define CAN_TX_STRING_VALUES_2_PERIOD_MS (100u) /** Phase of CAN string state messages in ms */ -#define CAN_TX_STRING_VALUES_2_PHASE_MS (10U) +#define CAN_TX_STRING_VALUES_2_PHASE_MS (10u) /** RX messages */ -/** CAN message ID for boot message */ -#define CAN_ID_BOOT_MESSAGE (0x199u) - /** CAN message ID to perform a software reset */ -#define CAN_ID_SOFTWARE_RESET (0x95U) +#define CAN_ID_SOFTWARE_RESET (0x95u) /** CAN message ID to perform a state request */ -#define CAN_ID_COMMAND (0x230U) +#define CAN_ID_COMMAND (0x230u) /** CAN message ID for debug message */ -#define CAN_ID_DEBUG (0x200U) +#define CAN_ID_DEBUG (0x200u) /** CAN message ID to get software version */ -#define CAN_ID_SW_VERSION (0x777U) +#define CAN_ID_SW_VERSION (0x777u) /** * -------------------------CAUTION------------------------- @@ -201,11 +209,11 @@ * -------------------------CAUTION------------------------- */ /** CAN message ID for info message from iso165c */ -#define CAN_ID_IMD_INFO (0x37U) +#define CAN_ID_IMD_INFO (0x37u) /** CAN message ID for request message to iso165c */ -#define CAN_ID_IMD_REQUEST (0x22U) +#define CAN_ID_IMD_REQUEST (0x22u) /** CAN message ID for response message from iso165c */ -#define CAN_ID_IMD_RESPONSE (0x23U) +#define CAN_ID_IMD_RESPONSE (0x23u) /** IDs for the messages from the current sensors */ /** String 0 @{*/ @@ -287,20 +295,20 @@ * DataLE = DataBE * \endverbatim */ -typedef enum CAN_ENDIANNESS { +typedef enum { CAN_LITTLE_ENDIAN, CAN_BIG_ENDIAN, } CAN_ENDIANNESS_e; /** Buffer element used to store the ID and data of a CAN RX message */ -typedef struct CAN_BUFFERELEMENT { +typedef struct { canBASE_t *canNode; /*!< CAN node on which the message has been received */ uint32_t id; /*!< ID of the CAN message */ uint8_t data[CAN_MAX_DLC]; /*!< payload of the CAN message */ } CAN_BUFFERELEMENT_s; /** composite type for storing and passing on the local database table handles */ -typedef struct CAN_SHIM { +typedef struct { OS_QUEUE *pQueueImd; /*!< handle of the message queue */ DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage; /*!< database table with cell voltages */ DATA_BLOCK_CELL_TEMPERATURE_s *pTableCellTemperature; /*!< database table with cell temperatures */ @@ -318,8 +326,8 @@ typedef struct CAN_SHIM { DATA_BLOCK_MOL_FLAG_s *pTableMol; /*!< database table with MOL flags */ } CAN_SHIM_s; -/** type definition for callback functions used in CAN messages */ -typedef uint32_t (*can_callback_funcPtr)( +/** type definition for tx callback functions used in CAN messages */ +typedef uint32_t (*CAN_TxCallbackFunction_f)( uint32_t ID, uint8_t DLC, CAN_ENDIANNESS_e endianness, @@ -327,26 +335,34 @@ typedef uint32_t (*can_callback_funcPtr)( uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim); +/** type definition for rx callback functions used in CAN messages */ +typedef uint32_t (*CAN_RxCallbackFunction_f)( + uint32_t ID, + uint8_t DLC, + CAN_ENDIANNESS_e endianness, + const uint8_t *const kpkCanData, + const CAN_SHIM_s *const kpkCanShim); + /** type definition for structure of a TX CAN message */ -typedef struct CAN_MSG_TX_TYPE { - canBASE_t *canNode; /*!< CAN node on which the message is transmitted */ - uint32_t id; /*!< CAN message id */ - uint8_t dlc; /*!< CAN message data length code */ - uint32_t repetitionTime; /*!< CAN message cycle time */ - uint32_t repetitionPhase; /*!< CAN message startup (first send) offset */ - CAN_ENDIANNESS_e endianness; /*!< Byte order (big or little endian) */ - can_callback_funcPtr callbackFunction; /*!< CAN message callback after message is sent */ +typedef struct { + canBASE_t *canNode; /*!< CAN node on which the message is transmitted */ + uint32_t id; /*!< CAN message id */ + uint8_t dlc; /*!< CAN message data length code */ + uint32_t repetitionTime; /*!< CAN message cycle time */ + uint32_t repetitionPhase; /*!< CAN message startup (first send) offset */ + CAN_ENDIANNESS_e endianness; /*!< Byte order (big or little endian) */ + CAN_TxCallbackFunction_f callbackFunction; /*!< CAN message callback after message is sent */ uint8_t *pMuxId; /*!< for multiplexed signals: callback can use this as pointer to a mux variable, NULL_PTR if unused*/ } CAN_MSG_TX_TYPE_s; /** type definition for structure of an RX CAN message */ -typedef struct CAN_MSG_RX_TYPE { - canBASE_t *canNode; /*!< CAN node on which the message is received */ - uint32_t id; /*!< message ID */ - uint8_t dlc; /*!< data length */ - CAN_ENDIANNESS_e endianness; /*!< Byte order (big or little endian) */ - can_callback_funcPtr callbackFunction; /*!< CAN message callback after message is received */ +typedef struct { + canBASE_t *canNode; /*!< CAN node on which the message is received */ + uint32_t id; /*!< message ID */ + uint8_t dlc; /*!< data length */ + CAN_ENDIANNESS_e endianness; /*!< Byte order (big or little endian) */ + CAN_RxCallbackFunction_f callbackFunction; /*!< CAN message callback after message is received */ } CAN_MSG_RX_TYPE_s; /** variable for storing and passing on the local database table handles */ diff --git a/src/app/driver/config/contactor_cfg.c b/src/app/driver/config/contactor_cfg.c index 63457c9f..35973241 100644 --- a/src/app/driver/config/contactor_cfg.c +++ b/src/app/driver/config/contactor_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file contactor_cfg.c * @author foxBMS Team * @date 2020-02-11 (date of creation) - * @updated 2020-02-11 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONF * @prefix CONT * @@ -62,11 +63,7 @@ CONT_CONTACTOR_STATE_s cont_contactorStates[BS_NR_OF_CONTACTORS] = { {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 0u, CONT_STRING0_PLUS}, {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 1u, CONT_STRING0_MINUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 2u, CONT_STRING1_PLUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 3u, CONT_STRING1_MINUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 4u, CONT_STRING2_PLUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 5u, CONT_STRING2_MINUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 6u, CONT_PRECHARGE}, + {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 2u, CONT_PRECHARGE}, }; /*========== Static Function Prototypes =====================================*/ diff --git a/src/app/driver/config/contactor_cfg.h b/src/app/driver/config/contactor_cfg.h index fd6153f3..8522d49a 100644 --- a/src/app/driver/config/contactor_cfg.h +++ b/src/app/driver/config/contactor_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file contactor_cfg.h * @author foxBMS Team * @date 2020-02-11 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix CONT * @@ -67,14 +68,14 @@ /*========== Extern Constant and Variable Declarations ======================*/ /** Symbolic names for the possible states of the contactors */ -typedef enum CONT_ELECTRICAL_STATE_TYPE { +typedef enum { CONT_SWITCH_OFF, /*!< Contactor off --> Contactor is open */ CONT_SWITCH_ON, /*!< Contactor on --> Contactor is closed */ CONT_SWITCH_UNDEF, /*!< Contactor undefined --> Contactor state not known */ } CONT_ELECTRICAL_STATE_TYPE_e; /** Symbolic names for the contactors */ -typedef enum CONT_NAMES { +typedef enum { CONT_STRING0_PLUS, /*!< Contactor in string0 plus path */ CONT_STRING0_MINUS, /*!< Contactor in string0 minus path */ CONT_STRING1_PLUS, /*!< Contactor in string1 plus path */ @@ -85,7 +86,7 @@ typedef enum CONT_NAMES { } CONT_NAMES_e; /** Symbolic names defining the electric behavior of the contactor */ -typedef enum CONT_FEEDBACK_TYPE { +typedef enum { CONT_FEEDBACK_NORMALLY_OPEN, /*!< Feedback line of a contactor is normally open */ CONT_FEEDBACK_NORMALLY_CLOSED, /*!< Feedback line of a contactor is normally closed */ CONT_FEEDBACK_THROUGH_CURRENT, /*!< Get feedback information through the current flowing into the contactor */ @@ -93,7 +94,7 @@ typedef enum CONT_FEEDBACK_TYPE { } CONT_FEEDBACK_TYPE_e; /** Status struct for a registry of all contactors */ -typedef struct CONT_CONTACTOR_STATE { +typedef struct { CONT_ELECTRICAL_STATE_TYPE_e currentSet; /*!< current setpoint for the contactor */ CONT_ELECTRICAL_STATE_TYPE_e feedback; /*!< feedback from the contactor */ const CONT_FEEDBACK_TYPE_e feedbackPinType; /*!< type of feedback that the contactor uses */ diff --git a/src/app/driver/config/dma_cfg.c b/src/app/driver/config/dma_cfg.c index f757b758..f068109f 100644 --- a/src/app/driver/config/dma_cfg.c +++ b/src/app/driver/config/dma_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file dma_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix DMA * diff --git a/src/app/driver/config/dma_cfg.h b/src/app/driver/config/dma_cfg.h index 1aef49d4..f3bc6f29 100644 --- a/src/app/driver/config/dma_cfg.h +++ b/src/app/driver/config/dma_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file dma_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2021-09-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix DMA * @@ -122,13 +123,13 @@ /**@}*/ /** describes the RX and TX DMA channels used for an SPI interface */ -typedef struct DMA_CHANNEL_CONFIG { +typedef struct { dmaChannel_t txChannel; dmaChannel_t rxChannel; } DMA_CHANNEL_CONFIG_s; /** describes the DMA requests corresponding to the DMA channel used for an SPI interface */ -typedef struct DMA_REQUEST_CONFIG { +typedef struct { dmaRequest_t txRequest; dmaRequest_t rxRequest; } DMA_REQUEST_CONFIG_s; diff --git a/src/app/driver/config/fram_cfg.c b/src/app/driver/config/fram_cfg.c index 51dbd6f1..698536c9 100644 --- a/src/app/driver/config/fram_cfg.c +++ b/src/app/driver/config/fram_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fram_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix FRAM * @@ -74,6 +75,8 @@ FRAM_SBC_INIT_s fram_sbcInit = { .finState = STD_NOT_OK, }; FRAM_DEEP_DISCHARGE_FLAG_s fram_deepDischargeFlags = {0}; +FRAM_SYS_MON_RECORD_s fram_sys_mon_record = {0}; +FRAM_INSULATION_FLAG_s fram_insulationFlags = {.groundErrorDetected = false}; /**@}*/ /** @@ -86,6 +89,8 @@ FRAM_BASE_HEADER_s fram_base_header[] = { {(void *)(&fram_sbcInit), sizeof(fram_sbcInit), 0}, {(void *)(&fram_deepDischargeFlags), sizeof(fram_deepDischargeFlags), 0}, {(void *)(&fram_soe), sizeof(fram_soe), 0}, + {(void *)(&fram_sys_mon_record), sizeof(fram_sys_mon_record), 0}, + {(void *)(&fram_insulationFlags), sizeof(fram_insulationFlags), 0}, }; /*========== Static Function Prototypes =====================================*/ diff --git a/src/app/driver/config/fram_cfg.h b/src/app/driver/config/fram_cfg.h index 19b1cb55..35a909a8 100644 --- a/src/app/driver/config/fram_cfg.h +++ b/src/app/driver/config/fram_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fram_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FRAM * @@ -61,6 +62,10 @@ #include "battery_system_cfg.h" /*========== Macros and Definitions =========================================*/ + +/* Header in each entry is made of 4 bytes SPI header + 8 bytes CRC */ +#define FRAM_CRC_HEADER_SIZE (sizeof(uint64_t)) + /** * @brief IDs for projects that use a memory layout * @details This enum can be use to differentiate between projects. While an older @@ -76,20 +81,30 @@ typedef uint16_t FRAM_PROJECT_ID; /** this is the standard main development branch */ #define FRAM_PROJECT_ID_FOXBMS_BASELINE ((FRAM_PROJECT_ID)0u) +/** fram block identification numbers */ +typedef enum { + FRAM_ACCESS_OK, /* Transaction with FRAM was successful */ + FRAM_ACCESS_SPI_BUSY, /* SPI busy, transaction with FRAM could not take place */ + FRAM_ACCESS_CRC_BUSY, /* CRC hardware busy, transaction with FRAM could not take place */ + FRAM_ACCESS_CRC_ERROR, /* Read CRC does not match with CRC computed on read data */ +} FRAM_RETURN_TYPE_e; + /** configuration struct of database channel (data block) */ typedef struct { void *blockptr; - uint16_t datalength; + uint32_t datalength; uint32_t address; } FRAM_BASE_HEADER_s; /** fram block identification numbers */ -typedef enum FRAM_BLOCK_ID { +typedef enum { FRAM_BLOCK_ID_VERSION, FRAM_BLOCK_ID_SOC, FRAM_BLOCK_ID_SBC_INIT_STATE, FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG, FRAM_BLOCK_ID_SOE, + FRAM_BLOCK_ID_SYS_MON_RECORD, + FRAM_BLOCK_ID_INSULATION_FLAG, FRAM_BLOCK_MAX, /**< DO NOT CHANGE, MUST BE THE LAST ENTRY */ } FRAM_BLOCK_ID_e; @@ -99,14 +114,14 @@ typedef enum FRAM_BLOCK_ID { * been written. This allows the BMS to recognize an incompatible * memory layout. */ -typedef struct FRAM_VERSION { +typedef struct { FRAM_PROJECT_ID project; /*!< an identifier for the project, it is not intended to migrate between different projects */ uint16_t version; /*!< version counter, i.e. for updating to a new version in the same project */ } FRAM_VERSION_s; /** struct for the FRAM entry of the SBC driver */ -typedef struct FRAM_SBC_INIT { +typedef struct { uint8_t phase; STD_RETURN_TYPE_e finState; } FRAM_SBC_INIT_s; @@ -116,7 +131,7 @@ typedef struct FRAM_SBC_INIT { * values are used, min, max and average. SOC defined as a float number between * 0.0f and 100.0f (0% and 100%) */ -typedef struct FRAM_SOC { +typedef struct { float minimumSoc_perc[BS_NR_OF_STRINGS]; /*!< minimum SOC */ float maximumSoc_perc[BS_NR_OF_STRINGS]; /*!< maximum SOC */ float averageSoc_perc[BS_NR_OF_STRINGS]; /*!< average SOC */ @@ -127,18 +142,50 @@ typedef struct FRAM_SOC { * values are used, min, max and average. SOE defined as a float number between * 0.0f and 100.0f (0% and 100%) */ -typedef struct FRAM_SOE { +typedef struct { float minimumSoe_perc[BS_NR_OF_STRINGS]; /*!< minimum SOE */ float maximumSoe_perc[BS_NR_OF_STRINGS]; /*!< maximum SOE */ float averageSoe_perc[BS_NR_OF_STRINGS]; /*!< average SOE */ } FRAM_SOE_s; -/** - * flag to indicate if a deep-discharge in a string has been detected - */ -typedef struct FRAM_DEEP_DISCHARGE_FLAG { + +/** flag to indicate if a deep-discharge in a string has been detected */ +typedef struct { bool deepDischargeFlag[BS_NR_OF_STRINGS]; /*!< false (0): no error, true (1): deep-discharge detected */ } FRAM_DEEP_DISCHARGE_FLAG_s; +/** flag to indicate if insulation ground error has been detected */ +typedef struct { + bool groundErrorDetected; /*!< false (0): no error, true (1): gorund error detected */ +} FRAM_INSULATION_FLAG_s; + +/** + * @brief struct that stores for each task the last violation of timing + */ +typedef struct { + /** convenience flag that is set as long as any timing issues are recorded */ + bool anyTimingIssueOccurred; + /** duration that has been recorded when the last violation of timings occurred */ + uint32_t taskEngineViolatingDuration; + /** timestamp that has been recorded when the violating execution of the task has been entered */ + uint32_t taskEngineEnterTimestamp; + /** duration that has been recorded when the last violation of timings occurred */ + uint32_t task1msViolatingDuration; + /** timestamp that has been recorded when the violating execution of the task has been entered */ + uint32_t task1msEnterTimestamp; + /** duration that has been recorded when the last violation of timings occurred */ + uint32_t task10msViolatingDuration; + /** timestamp that has been recorded when the violating execution of the task has been entered */ + uint32_t task10msEnterTimestamp; + /** duration that has been recorded when the last violation of timings occurred */ + uint32_t task100msViolatingDuration; + /** timestamp that has been recorded when the violating execution of the task has been entered */ + uint32_t task100msEnterTimestamp; + /** duration that has been recorded when the last violation of timings occurred */ + uint32_t task100msAlgorithmViolatingDuration; + /** timestamp that has been recorded when the violating execution of the task has been entered */ + uint32_t task100msAlgorithmEnterTimestamp; +} FRAM_SYS_MON_RECORD_s; + /*========== Extern Constant and Variable Declarations ======================*/ extern FRAM_BASE_HEADER_s fram_base_header[FRAM_BLOCK_MAX]; @@ -152,6 +199,8 @@ extern FRAM_SOC_s fram_soc; extern FRAM_SOE_s fram_soe; extern FRAM_SBC_INIT_s fram_sbcInit; extern FRAM_DEEP_DISCHARGE_FLAG_s fram_deepDischargeFlags; +extern FRAM_SYS_MON_RECORD_s fram_sys_mon_record; +extern FRAM_INSULATION_FLAG_s fram_insulationFlags; /**@}*/ /*========== Extern Function Prototypes =====================================*/ diff --git a/src/app/driver/config/interlock_cfg.c b/src/app/driver/config/interlock_cfg.c index 6620786a..56a47e59 100644 --- a/src/app/driver/config/interlock_cfg.c +++ b/src/app/driver/config/interlock_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file interlock_cfg.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-10-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix CONT * diff --git a/src/app/driver/config/interlock_cfg.h b/src/app/driver/config/interlock_cfg.h index b7efe9ca..fa95286d 100644 --- a/src/app/driver/config/interlock_cfg.h +++ b/src/app/driver/config/interlock_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file interlock_cfg.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix ILCK * @@ -105,7 +106,7 @@ #define ILCK_STATEMACH_SHORTTIME (1u) /** Symbolic names for contactors' possible states */ -typedef enum ILCK_ELECTRICAL_STATE_TYPE { +typedef enum { ILCK_SWITCH_OFF, /*!< Contactor off --> Contactor is open */ ILCK_SWITCH_ON, /*!< Contactor on --> Contactor is closed */ ILCK_SWITCH_UNDEF, /*!< Contactor undefined --> Contactor state not known */ diff --git a/src/app/driver/config/nxpfs85xx_cfg.c b/src/app/driver/config/nxpfs85xx_cfg.c index f793d9db..296de0ec 100644 --- a/src/app/driver/config/nxpfs85xx_cfg.c +++ b/src/app/driver/config/nxpfs85xx_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxpfs85xx_cfg.c * @author foxBMS Team * @date 2020-03-18 (date of creation) - * @updated 2020-03-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix SBC * diff --git a/src/app/driver/config/nxpfs85xx_cfg.h b/src/app/driver/config/nxpfs85xx_cfg.h index a3a67140..0fa8ec44 100644 --- a/src/app/driver/config/nxpfs85xx_cfg.h +++ b/src/app/driver/config/nxpfs85xx_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxpfs85xx_cfg.h * @author foxBMS Team * @date 2020-03-18 (date of creation) - * @updated 2020-03-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix SBC * diff --git a/src/app/driver/config/pex_cfg.c b/src/app/driver/config/pex_cfg.c index 56ee1c18..e77b3dca 100644 --- a/src/app/driver/config/pex_cfg.c +++ b/src/app/driver/config/pex_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pex_cfg.c * @author foxBMS Team * @date 2021-08-02 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix PEX * diff --git a/src/app/driver/config/pex_cfg.h b/src/app/driver/config/pex_cfg.h index dd45e321..a460f524 100644 --- a/src/app/driver/config/pex_cfg.h +++ b/src/app/driver/config/pex_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pex_cfg.h * @author foxBMS Team * @date 2021-08-02 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix PEX * @@ -69,7 +70,7 @@ /** Defines to match expander numbering from hardware description */ /**@{*/ -/* AXIVION Disable Style MisraC2012-2.5: Values are defined even if unused for driver useage. */ +/* AXIVION Disable Style MisraC2012-2.5: Values are defined even if unused for driver usage. */ #define PEX_PORT_EXPANDER1 (0u) #define PEX_PORT_EXPANDER2 (1u) #define PEX_PORT_EXPANDER3 (2u) diff --git a/src/app/driver/config/spi_cfg.c b/src/app/driver/config/spi_cfg.c index 2d64bed6..ab7f601e 100644 --- a/src/app/driver/config/spi_cfg.c +++ b/src/app/driver/config/spi_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file spi_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix SPI * @@ -91,16 +92,6 @@ static spiDAT1_t spi_kLtcDataConfig[BS_NR_OF_STRINGS] = { .WDEL = FALSE, /* Activation of delay between words */ .DFSEL = SPI_FMT_0, /* Data word format selection */ .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE}, - { /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = FALSE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE}, - { /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = FALSE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE}, }; /** SPI data configuration struct for MXM communication */ @@ -116,14 +107,6 @@ static spiDAT1_t spi_kNxp775DataConfigTx[BS_NR_OF_STRINGS] = { .WDEL = TRUE, /* Activation of delay between words */ .DFSEL = SPI_FMT_0, /* Data word format selection */ .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE}, - {.CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = TRUE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE}, - {.CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = TRUE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_0_ACTIVE}, }; /** SPI data configuration struct for NXP MC33775A communication, Rx part */ @@ -132,14 +115,6 @@ static spiDAT1_t spi_kNxp775DataConfigRx[BS_NR_OF_STRINGS] = { .WDEL = TRUE, /* Activation of delay between words */ .DFSEL = SPI_FMT_0, /* Data word format selection */ .CSNR = SPI_HARDWARE_CHIP_SELECT_0_ACTIVE}, - {.CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = TRUE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_0_ACTIVE}, - {.CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = TRUE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_0_ACTIVE}, }; /** SPI data configuration struct for FRAM communication */ @@ -205,20 +180,6 @@ SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS] = { .csPin = 2u, .csType = SPI_CHIP_SELECT_HARDWARE, }, - { - .pConfig = &spi_kLtcDataConfig[1u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, - { - .pConfig = &spi_kLtcDataConfig[2u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, }; /** SPI interface configuration for MXM communication */ @@ -239,20 +200,6 @@ SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceTx[BS_NR_OF_STRINGS] = { .csPin = 2u, .csType = SPI_CHIP_SELECT_HARDWARE, }, - { - .pConfig = &spi_kNxp775DataConfigTx[1u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, - { - .pConfig = &spi_kNxp775DataConfigTx[2u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, }; /** SPI interface configuration for N775 communication, Rx part */ @@ -264,20 +211,6 @@ SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceRx[BS_NR_OF_STRINGS] = { .csPin = 0u, .csType = SPI_CHIP_SELECT_HARDWARE, }, - { - .pConfig = &spi_kNxp775DataConfigRx[1u], - .pNode = spiREG4, - .pGioPort = &(spiREG4->PC3), - .csPin = 0u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, - { - .pConfig = &spi_kNxp775DataConfigRx[2u], - .pNode = spiREG4, - .pGioPort = &(spiREG4->PC3), - .csPin = 0u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, }; /** SPI interface configuration for FRAM communication */ diff --git a/src/app/driver/config/spi_cfg.h b/src/app/driver/config/spi_cfg.h index 149bf105..27f76e03 100644 --- a/src/app/driver/config/spi_cfg.h +++ b/src/app/driver/config/spi_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file spi_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix SPI * @@ -121,14 +122,14 @@ /**@}*/ /** enum for spi interface state */ -typedef enum SPI_BUSY_STATE { +typedef enum { SPI_IDLE, SPI_BUSY, } SPI_BUSY_STATE_e; /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE spi-documentation-cs-type-start-include */ /** type of chip select for spi */ -typedef enum SPI_CHIP_SELECT_TYPE { +typedef enum { SPI_CHIP_SELECT_HARDWARE, SPI_CHIP_SELECT_SOFTWARE, } SPI_CHIP_SELECT_TYPE_e; @@ -136,7 +137,7 @@ typedef enum SPI_CHIP_SELECT_TYPE { /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE spi-documentation-configuration-start-include */ /** configuration of the SPI interface */ -typedef struct SPI_INTERFACE_CONFIG { +typedef struct { spiDAT1_t *pConfig; spiBASE_t *pNode; volatile uint32_t *pGioPort; diff --git a/src/app/driver/config/sps_cfg.c b/src/app/driver/config/sps_cfg.c index 6c8a6fe1..9fb3ef9b 100644 --- a/src/app/driver/config/sps_cfg.c +++ b/src/app/driver/config/sps_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sps_cfg.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-10-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONF * @prefix SPS * diff --git a/src/app/driver/config/sps_cfg.h b/src/app/driver/config/sps_cfg.h index da3ece36..b2f9134f 100644 --- a/src/app/driver/config/sps_cfg.h +++ b/src/app/driver/config/sps_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sps_cfg.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONF * @prefix SPS * @@ -156,26 +157,26 @@ #define SPS_BITMASK_DIAGNOSTIC_ONDEMAND_OUTPUT_CURRENT (0x1FFFu) /** spi block identification numbers */ -typedef enum SPS_WRITE_TYPE { +typedef enum { SPS_replaceCurrentValue, SPS_orWithCurrentValue, SPS_andWithCurrentValue, } SPS_WRITE_TYPE_e; /** sps read types */ -typedef enum SPS_READ_TYPE { +typedef enum { SPS_READ_DIAGNOSTIC_REGISTER, /*!< diagnostic register read */ SPS_READ_CONTROL_REGISTER, /*!< control register read */ } SPS_READ_TYPE_e; /** functional state of a SPS channel */ -typedef enum SPS_CHANNEL_FUNCTION { +typedef enum { SPS_CHANNEL_OFF, /*!< sps channel is switched off */ SPS_CHANNEL_ON, /*!< sps channel is switched on */ } SPS_CHANNEL_FUNCTION_e; /** SPS channel state */ -typedef struct SPS_CHANNEL_STATE { +typedef struct { SPS_CHANNEL_FUNCTION_e channelRequested; /*!< requested state of the channel */ SPS_CHANNEL_FUNCTION_e channel; /*!< state of the channel */ float current_mA; /*!< current flow in this channel in mA */ @@ -185,7 +186,7 @@ typedef struct SPS_CHANNEL_STATE { } SPS_CHANNEL_STATE_s; /** SPS channel mapping to feedback pin */ -typedef struct SPS_CHANNEL_FEEDBACK_MAPPING { +typedef struct { const uint8_t pexDevice; /*!< port expander number */ const uint8_t pexChannel; /*!< pin number on the addresses port expander */ } SPS_CHANNEL_FEEDBACK_MAPPING_s; @@ -195,7 +196,7 @@ typedef struct SPS_CHANNEL_FEEDBACK_MAPPING { /*========== Extern Constant and Variable Declarations ======================*/ /** State for the CONT handling */ -typedef enum SPS_STATE { +typedef enum { SPS_START, SPS_RESET_LOW, SPS_RESET_HIGH, @@ -209,7 +210,7 @@ typedef enum SPS_STATE { } SPS_STATE_e; /** Actions to do for the Smart Power Switch IC */ -typedef enum SPS_ACTION { +typedef enum { SPS_ACTION_CONFIGURE_CONTROL_REGISTER, SPS_ACTION_TRIGGER_CURRENT_MEASUREMENT, SPS_ACTION_READ_CURRENT_MEASUREMENT1, diff --git a/src/app/driver/config/tsi_plausibility_cfg.h b/src/app/driver/config/tsi_plausibility_cfg.h index 3e930127..bf769baa 100644 --- a/src/app/driver/config/tsi_plausibility_cfg.h +++ b/src/app/driver/config/tsi_plausibility_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file tsi_plausibility_cfg.h * @author foxBMS Team * @date 2019-01-24 (date of creation) - * @updated 2021-01-20 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup MODULES * @prefix TSI * diff --git a/src/app/driver/contactor/contactor.c b/src/app/driver/contactor/contactor.c index efdb4d19..e956343b 100644 --- a/src/app/driver/contactor/contactor.c +++ b/src/app/driver/contactor/contactor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file contactor.c * @author foxBMS Team * @date 2020-02-11 (date of creation) - * @updated 2021-10-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CONT * @@ -111,7 +112,7 @@ static CONT_CONTACTOR_INDEX CONT_ResolveContactorName(const CONT_NAMES_e name) { } while ((contactor < BS_NR_OF_CONTACTORS) && (true != hit)); /* an unknown contactor may not exist */ - FAS_ASSERT(true == hit); + FAS_ASSERT(hit == true); return contactor; } @@ -146,15 +147,19 @@ static void CONT_InitializationCheckOfContactorRegistry(void) { /* iterate over each contactor and compare found name with resolved name (if a name is used double this would always return the first entry and we would have the second entry from iterating here) */ for (CONT_CONTACTOR_INDEX contactor = 0u; contactor < BS_NR_OF_CONTACTORS; contactor++) { - FAS_ASSERT(contactor == CONT_ResolveContactorName(cont_contactorStates[contactor].name)); - FAS_ASSERT(cont_contactorStates[contactor].name == CONT_GetContactorName(contactor)); + const CONT_CONTACTOR_INDEX resolvedContactor = CONT_ResolveContactorName(cont_contactorStates[contactor].name); + FAS_ASSERT(contactor == resolvedContactor); + const CONT_NAMES_e contactorName = CONT_GetContactorName(contactor); + FAS_ASSERT(cont_contactorStates[contactor].name == contactorName); /* convention at the moment: sps channel index has to be the same as contactor index; this may change in future implementations */ FAS_ASSERT(contactor == cont_contactorStates[contactor].spsChannel); /* every contactor channel has to be affiliated with contactor */ - FAS_ASSERT(SPS_AFF_CONTACTOR == SPS_GetChannelAffiliation(cont_contactorStates[contactor].spsChannel)); + const SPS_CHANNEL_AFFILIATION_e channelAffiliation = + SPS_GetChannelAffiliation(cont_contactorStates[contactor].spsChannel); + FAS_ASSERT(SPS_AFF_CONTACTOR == channelAffiliation); } } @@ -191,8 +196,8 @@ extern STD_RETURN_TYPE_e CONT_SetContactorState( CONT_CONTACTOR_INDEX contactor = CONT_ResolveContactorName(name); FAS_ASSERT(contactor < BS_NR_OF_CONTACTORS); FAS_ASSERT( - (CONT_SWITCH_OFF == requestedContactorState) || (CONT_SWITCH_ON == requestedContactorState) || - (CONT_SWITCH_UNDEF == requestedContactorState)); + (requestedContactorState == CONT_SWITCH_OFF) || (requestedContactorState == CONT_SWITCH_ON) || + (requestedContactorState == CONT_SWITCH_UNDEF)); STD_RETURN_TYPE_e retVal = STD_OK; @@ -240,7 +245,7 @@ extern STD_RETURN_TYPE_e CONT_ClosePrecharge(uint8_t stringNumber) { FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retVal = STD_NOT_OK; uint8_t prechargeContactorNumber = 0u; - static_assert((BS_NR_OF_STRINGS <= (uint8_t)UINT8_MAX), "This code assumes BS_NR_OF_STRINGS fits into uint8_t"); + f_static_assert((BS_NR_OF_STRINGS <= (uint8_t)UINT8_MAX), "This code assumes BS_NR_OF_STRINGS fits into uint8_t"); /* Precharge contactors in the list stay after string contactors * so it has index (number of contactors)-1 diff --git a/src/app/driver/contactor/contactor.h b/src/app/driver/contactor/contactor.h index 9797cfdc..daa20d26 100644 --- a/src/app/driver/contactor/contactor.h +++ b/src/app/driver/contactor/contactor.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file contactor.h * @author foxBMS Team * @date 2020-02-11 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix CONT * @@ -109,15 +110,6 @@ typedef enum { CONT_CHECK_REQUESTS, } CONT_STATEMACH_SUB_e; -/** @brief Names for connected power paths */ -typedef enum CONT_POWER_LINE_e { - CONT_POWER_PATH_NONE, /*!< no power line is connected, contactors are open */ - CONT_POWER_PATH_0, /*!< power line 0, e.g. used for the power train */ -#if BS_SEPARATE_POWER_PATHS == 1 - CONT_POWER_PATH_1, /*!< power line 1, e.g. used for charging */ -#endif -} CONT_POWER_LINE_e; - /** * @brief Gets the current state. * @details This function is used in the functioning of the CONT state machine. diff --git a/src/app/driver/crc/crc.c b/src/app/driver/crc/crc.c new file mode 100644 index 00000000..4ca9f177 --- /dev/null +++ b/src/app/driver/crc/crc.c @@ -0,0 +1,165 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file crc.c + * @author foxBMS Team + * @date 2022-02-22 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS + * @prefix CRC + * + * @brief crc module implementation + * + * @details Uses the system CRC hardware for data integrity calculation + */ + +/*========== Includes =======================================================*/ +#include "crc.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ + +extern STD_RETURN_TYPE_e CRC_CalculateCrc(uint64_t *pCrc, uint8_t *pData, uint32_t lengthInBytes) { + static uint16_t crcCalls = 0u; + CRC_REGISTER_SIDE_e registerSide = CRC_REGISTER_LOW; + uint32_t dataBufferLow = 0u; + uint32_t dataBufferHigh = 0u; + uint32_t remainingBytes = lengthInBytes; + uint32_t remainingData = 0u; + STD_RETURN_TYPE_e retVal = STD_OK; + + FAS_ASSERT(pCrc != NULL_PTR); + FAS_ASSERT(pData != NULL_PTR); + + uint8_t *pRead = pData; + + if (crcCalls == 0u) { + crcCalls++; + + /* Set mode to Data Capture Mode, otherwise writing the seed + starts the computation */ + crcREG1->CTRL2 &= CRC_DATA_CAPTURE_MODE_CLEAR_MASK; + /* Set seed*/ + crcREG1->PSA_SIGREGH1 = CRC_SEED_HIGH; + crcREG1->PSA_SIGREGL1 = CRC_SEED_LOW; + /* Set mode to Full-CPU Mode to start the computation when writing the data*/ + crcREG1->CTRL2 |= CRC_FULL_CPU_MODE_SET_MASK; + + /* AXIVION Disable Style MisraC2012-11.3: 64 bit access needed, partial 32 bit access starts computation */ + /* Pointer to access the two signature registers, where input data will be written */ + volatile uint64_t *pCrcRegister = (volatile uint64 *)(&crcREG1->PSA_SIGREGL1); + /* AXIVION Enable Style MisraC2012-11.3: */ + + /* Treat packets of 64 bit data */ + while (remainingBytes >= CRC_REGISTER_SIZE_IN_BYTES) { + /* Invert two 32 bit chunks before 64 bit write, due to big endian */ + if (registerSide == CRC_REGISTER_LOW) { + dataBufferLow = 0u; + for (uint8_t i = 0u; i < CRC_REGISTER_SIZE_IN_BYTES; i++) { + uint8_t dataBuffer = *(pRead + i); + dataBufferLow |= ((uint32_t)dataBuffer) << ((CRC_REVERSE_BYTES_ORDER - i) * CRC_BYTE_SIZE_IN_BITS); + } + registerSide = CRC_REGISTER_HIGH; + } else { /* registerSide is CRC_REGISTER_HIGH */ + dataBufferHigh = 0u; + for (uint8_t i = 0u; i < CRC_REGISTER_SIZE_IN_BYTES; i++) { + uint8_t dataBuffer = *(pRead + i); + dataBufferHigh |= ((uint32_t)dataBuffer) << ((CRC_REVERSE_BYTES_ORDER - i) * CRC_BYTE_SIZE_IN_BITS); + } + /* Signature low and high available, write to hardware register */ + uint64_t crcData = (((uint64_t)dataBufferHigh) << CRC_REGISTER_SIZE_IN_BITS) | dataBufferLow; + *pCrcRegister = crcData; + registerSide = CRC_REGISTER_LOW; + } + pRead = (pRead + CRC_REGISTER_SIZE_IN_BYTES); + remainingBytes -= CRC_REGISTER_SIZE_IN_BYTES; + } + + if (remainingBytes > 0u) { + /* Now treat last packet that is less than 32 bits if existing */ + /* Get data in a 32 bit variable, pad with 0 */ + while (remainingBytes > 0u) { + uint8_t dataBuffer = *pRead; + remainingData |= ((uint32_t)(dataBuffer)) << (CRC_BYTE_SIZE_IN_BITS * remainingBytes); + pRead++; + remainingBytes--; + } + if (registerSide == CRC_REGISTER_LOW) { + dataBufferLow = remainingData; + registerSide = CRC_REGISTER_HIGH; + } else { /* registerSide is CRC_REGISTER_HIGH */ + dataBufferHigh = remainingData; + /* Signature low and high available, write to hardware register */ + uint64_t crcData = (((uint64_t)dataBufferHigh) << CRC_REGISTER_SIZE_IN_BITS) | dataBufferLow; + *pCrcRegister = crcData; + registerSide = CRC_REGISTER_LOW; + } + } + + /* No data remaining but only low register data available: compute CRC */ + if (registerSide == CRC_REGISTER_HIGH) { + crcREG1->PSA_SIGREGL1 = dataBufferLow; + } + + *pCrc = crcREG1->PSA_SIGREGL1; + *pCrc |= ((uint64_t)crcREG1->PSA_SIGREGH1) << CRC_REGISTER_SIZE_IN_BITS; + crcCalls--; + } else { + *pCrc = 0u; + retVal = STD_NOT_OK; + } + + return retVal; +} +/*================== Static functions ======================================*/ + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/crc/crc.h b/src/app/driver/crc/crc.h new file mode 100644 index 00000000..e2329067 --- /dev/null +++ b/src/app/driver/crc/crc.h @@ -0,0 +1,111 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file crc.h + * @author foxBMS Team + * @date 2022-02-22 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS + * @prefix CRC + * + * @brief crc module header + * + * @details Uses the system CRC hardware for data integrity calculation + */ + +#ifndef FOXBMS__CRC_H_ +#define FOXBMS__CRC_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +#include "HL_crc.h" + +/*========== Macros and Definitions =========================================*/ + +/** High 32 bit part of the seed used for CRC calculation */ +#define CRC_SEED_HIGH (0xBADC0DEDu) +/** Low 32 bit part of the seed used for CRC calculation */ +#define CRC_SEED_LOW (0xDEADBEEFu) +/** Mask used to clear bits in config register to set CRC module to Data Capture Mode */ +#define CRC_DATA_CAPTURE_MODE_CLEAR_MASK (0xFFFFFFFCu) +/** Mask used to set bits in config register to set CRC module to Full-CPU Mode */ +#define CRC_FULL_CPU_MODE_SET_MASK (0x3u) + +/* Size in bits of a byte, used for shift operations */ +#define CRC_BYTE_SIZE_IN_BITS (8u) +/* Size in bytes of a register, used for shift operations */ +#define CRC_REGISTER_SIZE_IN_BYTES (4u) +/* Size in bits of a register, used for shift operations */ +#define CRC_REGISTER_SIZE_IN_BITS (32u) +/* Literal used to reverse byte order */ +#define CRC_REVERSE_BYTES_ORDER (3u) + +/** CRC signature register, low of high part to be used . + * The register is 64 bit wide but the data is read in + * 32 bit chunks. This indicates if the low or the high part + * has to be written. + */ +typedef enum { + CRC_REGISTER_LOW, /* low part of register to be written */ + CRC_REGISTER_HIGH, /* high part of register to be written */ +} CRC_REGISTER_SIDE_e; + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/** + * @brief Computes CRC of data flow + * @details This function uses the hardware of the MCU. + * Data must be given in byte chunks. + * @param[in] pCrc uint64_t pointer to the calculated CRC + * @param[in] pData uint8_t pointer to the start of the data flow + * @param[in] lengthInBytes length in bytes of the data flow + * @returns #STD_OK if CRC hardware available, #STD_NOT_OK otherwise + */ +extern STD_RETURN_TYPE_e CRC_CalculateCrc(uint64_t *pCrc, uint8_t *pData, uint32_t lengthInBytes); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__CRC_H_ */ diff --git a/src/app/driver/dma/dma.c b/src/app/driver/dma/dma.c index 1610d1cb..4cdeebed 100644 --- a/src/app/driver/dma/dma.c +++ b/src/app/driver/dma/dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file dma.c * @author foxBMS Team * @date 2019-12-12 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix DMA * @@ -220,6 +221,9 @@ void DMA_Initialize(void) { /** Function called on DMA complete interrupts (TX and RX). Defined as weak in HAL. */ /* AXIVION Next Line Style Linker-Multiple_Definition: TI HAL only provides a weak implementation */ void UNIT_TEST_WEAK_IMPL dmaGroupANotification(dmaInterrupt_t inttype, uint32 channel) { + /* AXIVION Routine Generic-MissingParameterAssert: inttype: unchecked in interrupt */ + /* AXIVION Routine Generic-MissingParameterAssert: channel: unchecked in interrupt */ + if (inttype == (dmaInterrupt_t)BTC) { uint16_t timeoutIterations = 0u; uint8_t spiIndex = 0u; @@ -231,7 +235,7 @@ void UNIT_TEST_WEAK_IMPL dmaGroupANotification(dmaInterrupt_t inttype, uint32 ch case DMA_CHANNEL_SPI5_TX: /* Search for SPI index with DMA TX channel */ for (uint8_t i = 0u; i < DMA_NUMBER_SPI_INTERFACES; i++) { - if ((uint32_t)dma_spiDmaChannels[i].txChannel == channel) { + if (channel == (uint32_t)dma_spiDmaChannels[i].txChannel) { spiIndex = i; break; } @@ -257,7 +261,7 @@ void UNIT_TEST_WEAK_IMPL dmaGroupANotification(dmaInterrupt_t inttype, uint32 ch case DMA_CHANNEL_SPI5_RX: /* Search for SPI index with DMA RX channel */ for (uint8_t i = 0u; i < DMA_NUMBER_SPI_INTERFACES; i++) { - if ((uint32_t)dma_spiDmaChannels[i].rxChannel == channel) { + if (channel == (uint32_t)dma_spiDmaChannels[i].rxChannel) { spiIndex = i; break; } diff --git a/src/app/driver/dma/dma.h b/src/app/driver/dma/dma.h index 322dd0ee..2c5194d0 100644 --- a/src/app/driver/dma/dma.h +++ b/src/app/driver/dma/dma.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file dma.h * @author foxBMS Team * @date 2019-12-12 (date of creation) - * @updated 2019-12-12 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix DMA * @@ -85,11 +86,6 @@ extern void DMA_Initialize(void); */ extern void DMA_ReInit(void); -/** - * @brief Sends and receives data over SPI with DMA. - */ -extern STD_RETURN_TYPE_e DMA_TransmitReceive_SPIwithDMA(void); - /** * @brief gets the SPI transmit status. * @return retval true if transmission still ongoing, false otherwise @@ -143,11 +139,6 @@ void DMA_ReInitN775Tx(void); */ void DMA_ReInitN775Rx(void); -/** - * @brief Sends data over SPI with DMA. - */ -STD_RETURN_TYPE_e DMA_TransmitSPiWithDmaN775(void); - /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #endif /* FOXBMS__DMA_H_ */ diff --git a/src/app/driver/foxmath/foxmath.c b/src/app/driver/foxmath/foxmath.c index 9f4a149b..86e85e43 100644 --- a/src/app/driver/foxmath/foxmath.c +++ b/src/app/driver/foxmath/foxmath.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file foxmath.c * @author foxBMS Team * @date 2018-01-18 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MATH * diff --git a/src/app/driver/foxmath/foxmath.h b/src/app/driver/foxmath/foxmath.h index 8e9b0f7a..7690c94f 100644 --- a/src/app/driver/foxmath/foxmath.h +++ b/src/app/driver/foxmath/foxmath.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file foxmath.h * @author foxBMS Team * @date 2018-01-18 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MATH * diff --git a/src/app/driver/fram/fram.c b/src/app/driver/fram/fram.c index 21c146b2..c30043cf 100644 --- a/src/app/driver/fram/fram.c +++ b/src/app/driver/fram/fram.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fram.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FRAM * @@ -55,9 +56,10 @@ /*========== Includes =======================================================*/ #include "fram.h" +#include "crc.h" +#include "diag.h" #include "io.h" #include "mcu.h" -#include "os.h" #include "spi.h" /*========== Macros and Definitions =========================================*/ @@ -86,105 +88,129 @@ /*========== Extern Function Implementations ================================*/ extern void FRAM_Initialize(void) { - uint32_t address = 0; + uint32_t address = 0u; + /* Reset error flag at startup */ + (void)DIAG_Handler(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); /* find address of all variables in FRAM by parsing length of data*/ for (uint16_t i = 0u; i < FRAM_BLOCK_MAX; i++) { - (&fram_base_header[0u] + i)->address = address; - address += (&fram_base_header[0u] + i)->datalength; + (fram_base_header[i]).address = address; + address += (fram_base_header[i]).datalength + FRAM_CRC_HEADER_SIZE; } /* ASSERT that size of variables does not exceed FRAM size */ FAS_ASSERT(!(address > FRAM_MAX_ADDRESS)); } -extern STD_RETURN_TYPE_e FRAM_Write(FRAM_BLOCK_ID_e blockId) { - uint8_t *wrt_ptr = NULL_PTR; - uint32_t address = 0; - uint16_t write = 0; - uint16_t read = 0; - uint16_t size = 0; - STD_RETURN_TYPE_e retVal = STD_NOT_OK; +extern STD_RETURN_TYPE_e FRAM_ReinitializeAllEntries(void) { + STD_RETURN_TYPE_e retVal = STD_OK; + for (uint16_t i = 0u; i < FRAM_BLOCK_MAX; i++) { + if (FRAM_WriteData((FRAM_BLOCK_ID_e)i) != FRAM_ACCESS_OK) { + retVal = STD_OK; + } + } + return retVal; +} + +extern FRAM_RETURN_TYPE_e FRAM_WriteData(FRAM_BLOCK_ID_e blockId) { + FAS_ASSERT(blockId < FRAM_BLOCK_MAX); + + uint16_t read = 0u; + uint64_t crc = 0u; + FRAM_RETURN_TYPE_e retVal = FRAM_ACCESS_OK; /* FRAM must use SW Chip Select configuration*/ FAS_ASSERT(spi_framInterface.csType == SPI_CHIP_SELECT_SOFTWARE); - retVal = SPI_Lock(SPI_GetSpiIndex(spi_framInterface.pNode)); - - if (retVal == STD_OK) { - address = (&fram_base_header[0] + blockId)->address; + uint32_t address = (fram_base_header[blockId]).address; + uint32_t size = (fram_base_header[blockId]).datalength; + uint8_t *pWrite = (uint8_t *)(fram_base_header[blockId].blockptr); - wrt_ptr = (uint8_t *)((&fram_base_header[0] + blockId)->blockptr); - size = (&fram_base_header[0] + blockId)->datalength; + STD_RETURN_TYPE_e crcRetVal = CRC_CalculateCrc(&crc, pWrite, size); - /* send write enable command */ - IO_PinReset(spi_framInterface.pGioPort, spi_framInterface.csPin); - write = FRAM_WRITEENABLECOMMAND; - SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - IO_PinSet(spi_framInterface.pGioPort, spi_framInterface.csPin); - MCU_delay_us(FRAM_DELAY_AFTER_WRITE_ENABLE_US); + if (crcRetVal == STD_OK) { + STD_RETURN_TYPE_e spiRetVal = SPI_Lock(SPI_GetSpiIndex(spi_framInterface.pNode)); - /* send data to write */ - /* set chip select low to start transmission */ - IO_PinReset(spi_framInterface.pGioPort, spi_framInterface.csPin); + if (spiRetVal == STD_OK) { + /* send write enable command */ + IO_PinReset(spi_framInterface.pGioPort, spi_framInterface.csPin); + uint16_t write = FRAM_WRITEENABLECOMMAND; + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + IO_PinSet(spi_framInterface.pGioPort, spi_framInterface.csPin); + MCU_Delay_us(FRAM_DELAY_AFTER_WRITE_ENABLE_US); - /* send write command */ - write = FRAM_WRITECOMMAND; - SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + /* send data to write */ + /* set chip select low to start transmission */ + IO_PinReset(spi_framInterface.pGioPort, spi_framInterface.csPin); - /* send upper part of address */ - write = (address & 0x3F0000u) >> 16u; - SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - - /* send middle part of address */ - write = (address & 0xFF00u) >> 8u; - SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + /* send write command */ + write = FRAM_WRITECOMMAND; + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - /* send lower part of address */ - write = address & 0xFFu; - SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + /* send upper part of address */ + write = (address & 0x3F0000u) >> 16u; + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - while (size > 0u) { - write = (uint16_t)(*wrt_ptr); + /* send middle part of address */ + write = (address & 0xFF00u) >> 8u; SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - wrt_ptr++; - size--; - } - /* set chip select high to start transmission */ - IO_PinSet(spi_framInterface.pGioPort, spi_framInterface.csPin); + /* send lower part of address */ + write = address & 0xFFu; + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - SPI_Unlock(SPI_GetSpiIndex(spi_framInterface.pNode)); + /* send CRC */ + pWrite = (uint8_t *)(&crc); + for (uint8_t i = 0u; i < FRAM_CRC_HEADER_SIZE; i++) { + write = (uint16_t)(*pWrite); + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + pWrite++; + } + + pWrite = (uint8_t *)(fram_base_header[blockId].blockptr); + + /* send data */ + while (size > 0u) { + write = (uint16_t)(*pWrite); + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + pWrite++; + size--; + } + + /* set chip select high to start transmission */ + IO_PinSet(spi_framInterface.pGioPort, spi_framInterface.csPin); + + SPI_Unlock(SPI_GetSpiIndex(spi_framInterface.pNode)); + } else { + retVal = FRAM_ACCESS_SPI_BUSY; + } + } else { + retVal = FRAM_ACCESS_CRC_BUSY; } - return retVal; } -extern STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId) { - uint8_t *rd_ptr = NULL_PTR; - uint32_t address = 0; - uint16_t write = 0; - uint16_t read = 0; - uint16_t size = 0; - STD_RETURN_TYPE_e retVal = STD_NOT_OK; +extern FRAM_RETURN_TYPE_e FRAM_ReadData(FRAM_BLOCK_ID_e blockId) { + FAS_ASSERT(blockId < FRAM_BLOCK_MAX); + + uint16_t read = 0u; + FRAM_RETURN_TYPE_e retVal = FRAM_ACCESS_OK; /* FRAM must use SW Chip Select configuration*/ FAS_ASSERT(spi_framInterface.csType == SPI_CHIP_SELECT_SOFTWARE); - retVal = SPI_Lock(SPI_GetSpiIndex(spi_framInterface.pNode)); - - if (retVal == STD_OK) { - address = (&fram_base_header[0] + blockId)->address; + STD_RETURN_TYPE_e spiRetVal = SPI_Lock(SPI_GetSpiIndex(spi_framInterface.pNode)); - rd_ptr = (uint8_t *)((&fram_base_header[0] + blockId)->blockptr); - size = (&fram_base_header[0] + blockId)->datalength; + if (spiRetVal == STD_OK) { + uint32_t address = (fram_base_header[blockId]).address; + uint32_t size = (fram_base_header[blockId]).datalength; /* get data to be read */ /* set chip select low to start transmission */ IO_PinReset(spi_framInterface.pGioPort, spi_framInterface.csPin); /* send write command */ - write = FRAM_READCOMMAND; + uint16_t write = FRAM_READCOMMAND; SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); /* send upper part of address */ @@ -199,11 +225,23 @@ extern STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId) { write = address & 0xFFu; SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + /* read CRC */ + uint64_t crcRead = 0u; + uint8_t *pRead = (uint8_t *)(&crcRead); + for (uint8_t i = 0u; i < FRAM_CRC_HEADER_SIZE; i++) { + SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); + *pRead = (uint8_t)read; + pRead++; + } + + pRead = (uint8_t *)(fram_base_header[blockId].blockptr); + + /* read data */ write = 0; while (size > 0u) { SPI_FramTransmitReceiveData(&spi_framInterface, &write, &read, 1u); - *rd_ptr = read; - rd_ptr++; + *pRead = read & (uint8_t)UINT8_MAX; + pRead++; size--; } @@ -211,6 +249,22 @@ extern STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId) { IO_PinSet(spi_framInterface.pGioPort, spi_framInterface.csPin); SPI_Unlock(SPI_GetSpiIndex(spi_framInterface.pNode)); + + pRead = (uint8_t *)(fram_base_header[blockId].blockptr); + size = (fram_base_header[blockId]).datalength; + uint64_t crcCalculated = 0u; + STD_RETURN_TYPE_e crcRetVal = CRC_CalculateCrc(&crcCalculated, pRead, size); + + if (crcRetVal == STD_OK) { + if (crcRead != crcCalculated) { + (void)DIAG_Handler(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, blockId); + retVal = FRAM_ACCESS_CRC_ERROR; + } + } else { + retVal = FRAM_ACCESS_CRC_BUSY; + } + } else { + retVal = FRAM_ACCESS_SPI_BUSY; } return retVal; diff --git a/src/app/driver/fram/fram.h b/src/app/driver/fram/fram.h index fcdc7458..8be328f5 100644 --- a/src/app/driver/fram/fram.h +++ b/src/app/driver/fram/fram.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fram.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2024-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix FRAM * @@ -70,15 +71,23 @@ */ extern void FRAM_Initialize(void); +/** + * @brief Reinitialize all entries in the FRAM. + * @details This function must be called if the alignment in the FRAM is + * wrong due to a change in the FRAM data structue. + * @return #STD_OK if all writes successfull, otherwise #STD_NOT_OK + */ +extern STD_RETURN_TYPE_e FRAM_ReinitializeAllEntries(void); + /* The variable corrresponding to the block_ID is written */ /** * @brief Writes a variable to the FRAM. * @details This function stores the variable corresponding to the ID passed as * parameter. Write can fail if SPI interface was locked. * @param blockId ID of variable to write to FRAM - * @return #STD_OK if write was successful, #STD_NOT_OK otherwise + * @return one of the values of the FRAM_RETURN_TYPE_e enum */ -extern STD_RETURN_TYPE_e FRAM_Write(FRAM_BLOCK_ID_e blockId); +extern FRAM_RETURN_TYPE_e FRAM_WriteData(FRAM_BLOCK_ID_e blockId); /* The variable corrresponding to the block_ID is written */ /** @@ -86,9 +95,9 @@ extern STD_RETURN_TYPE_e FRAM_Write(FRAM_BLOCK_ID_e blockId); * @details This function reads the variable corresponding to the ID passed as * parameter. Read can fail if SPI interface was locked. * @param blockId ID of variable to read from FRAM - * @return #STD_OK if read was successful, #STD_NOT_OK otherwise + * @return one of the values of the FRAM_RETURN_TYPE_e enum */ -extern STD_RETURN_TYPE_e FRAM_Read(FRAM_BLOCK_ID_e blockId); +extern FRAM_RETURN_TYPE_e FRAM_ReadData(FRAM_BLOCK_ID_e blockId); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/htsensor/htsensor.c b/src/app/driver/htsensor/htsensor.c index ac9ff395..f371c978 100644 --- a/src/app/driver/htsensor/htsensor.c +++ b/src/app/driver/htsensor/htsensor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file htsensor.c * @author foxBMS Team * @date 2021-08-05 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix HTSEN * @@ -170,25 +171,25 @@ static DATA_BLOCK_HTSEN_s htsen_data = {.header.uniqueId = DATA_BLOCK_ID_HTSEN}; * @param[in] length: length of data * @return 8-bit CRC value */ -static uint8_t HTSENS_CalculateCrc8(const uint8_t *data, uint32_t length); +static uint8_t HTSEN_CalculateCrc8(const uint8_t *data, uint32_t length); /** * @brief computes temperature measurement from raw value. * @param[in] data: raw temperature value * @return temperature measurement in deci °C */ -static int16_t HTSENS_ConvertRawTemperature(uint16_t data); +static int16_t HTSEN_ConvertRawTemperature(uint16_t data); /** * @brief computes humidity measurement from raw value. * @param[in] data: raw humidity value * @return humidity measurement in % */ -static uint8_t HTSENS_ConvertRawHumidity(uint16_t data); +static uint8_t HTSEN_ConvertRawHumidity(uint16_t data); /*========== Static Function Implementations ================================*/ -static uint8_t HTSENS_CalculateCrc8(const uint8_t *data, uint32_t length) { +static uint8_t HTSEN_CalculateCrc8(const uint8_t *data, uint32_t length) { FAS_ASSERT(data != NULL_PTR); FAS_ASSERT(length <= UINT32_MAX); @@ -207,13 +208,14 @@ static uint8_t HTSENS_CalculateCrc8(const uint8_t *data, uint32_t length) { return (uint8_t)(crc & HTSEN_CRC_8BIT_MASK); } -static int16_t HTSENS_ConvertRawTemperature(uint16_t data) { +static int16_t HTSEN_ConvertRawTemperature(uint16_t data) { + /* AXIVION Routine Generic-MissingParameterAssert: data: parameter accepts whole range */ float temperature_ddeg = HTSEN_TEMP_DEG_TO_DDEG * (HTSEN_TEMP_OFFSET + (HTSEN_TEMP_SCALING * (((float)data) / HTSEN_FULL_SCALE))); return (int16_t)temperature_ddeg; } -static uint8_t HTSENS_ConvertRawHumidity(uint16_t data) { +static uint8_t HTSEN_ConvertRawHumidity(uint16_t data) { float humidity_perc = (HTSEN_HUMIDITY_SCALING * (((float)data) / HTSEN_FULL_SCALE)); return (uint8_t)humidity_perc; } @@ -258,15 +260,15 @@ extern void HTSEN_Trigger(void) { /* If measurement finished, retrieve values */ /* Only take temperature value if CRC valid */ if (i2cReadBuffer[HTSEN_TEMPERATURE_BYTE_CRC] == - HTSENS_CalculateCrc8(&i2cReadBuffer[HTSEN_TEMPERATURE_MSB], HTSEN_MEASUREMENT_LENGTH_IN_BYTES)) { - htsen_data.temperature_ddegC = HTSENS_ConvertRawTemperature( + HTSEN_CalculateCrc8(&i2cReadBuffer[HTSEN_TEMPERATURE_MSB], HTSEN_MEASUREMENT_LENGTH_IN_BYTES)) { + htsen_data.temperature_ddegC = HTSEN_ConvertRawTemperature( (((uint16_t)i2cReadBuffer[HTSEN_TEMPERATURE_MSB]) << HTSEN_BYTE_SHIFT) | (uint16_t)i2cReadBuffer[HTSEN_TEMPERATURE_LSB]); } /* Only take humidity value if CRC valid */ if (i2cReadBuffer[HTSEN_HUMIDITY_BYTE_CRC] == - HTSENS_CalculateCrc8(&i2cReadBuffer[HTSEN_HUMIDITY_MSB], HTSEN_MEASUREMENT_LENGTH_IN_BYTES)) { - htsen_data.humidity_perc = HTSENS_ConvertRawHumidity( + HTSEN_CalculateCrc8(&i2cReadBuffer[HTSEN_HUMIDITY_MSB], HTSEN_MEASUREMENT_LENGTH_IN_BYTES)) { + htsen_data.humidity_perc = HTSEN_ConvertRawHumidity( (((uint16_t)i2cReadBuffer[HTSEN_HUMIDITY_MSB]) << HTSEN_BYTE_SHIFT) | (uint16_t)i2cReadBuffer[HTSEN_HUMIDITY_LSB]); } @@ -287,6 +289,6 @@ extern void HTSEN_Trigger(void) { /*========== Externalized Static Function Implementations (Unit Test) =======*/ #ifdef UNITY_UNIT_TEST extern uint8_t TEST_HTSEN_TestCalculateCrc8(uint8_t *data, uint32_t length) { - return HTSENS_CalculateCrc8(data, 2u); + return HTSEN_CalculateCrc8(data, 2u); } #endif /* UNITY_UNIT_TEST */ diff --git a/src/app/driver/htsensor/htsensor.h b/src/app/driver/htsensor/htsensor.h index fd2d6a57..eeb49326 100644 --- a/src/app/driver/htsensor/htsensor.h +++ b/src/app/driver/htsensor/htsensor.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file htsensor.h * @author foxBMS Team * @date 2021-08-05 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix HTSEN * diff --git a/src/app/driver/i2c/i2c.c b/src/app/driver/i2c/i2c.c index 1373a2d1..fd2c94a3 100644 --- a/src/app/driver/i2c/i2c.c +++ b/src/app/driver/i2c/i2c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file i2c.c * @author foxBMS Team * @date 2021-07-22 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix I2C * @@ -439,7 +440,9 @@ extern STD_RETURN_TYPE_e I2C_ReadDma(uint32_t slaveAddress, uint8_t readAddress, if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { OS_EnterTaskCritical(); - FAS_ASSERT(FSYS_RaisePrivilege() == 0); /* Go to privileged mode to write DMA config registers */ + /* Go to privileged mode to write DMA config registers */ + const int32_t raisePrivilegeResult = FSYS_RaisePrivilege(); + FAS_ASSERT(raisePrivilegeResult == 0); /* Set Tx buffer address */ /* AXIVION Disable Style MisraC2012-1.1: Cast necessary for DMA configuration */ @@ -509,7 +512,9 @@ extern STD_RETURN_TYPE_e I2C_WriteDma( if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { OS_EnterTaskCritical(); - FAS_ASSERT(FSYS_RaisePrivilege() == 0); /* Go to privileged mode to write DMA config registers */ + /* Go to privileged mode to write DMA config registers */ + const int32_t raisePrivilegeResult = FSYS_RaisePrivilege(); + FAS_ASSERT(raisePrivilegeResult == 0); /* Set Tx buffer address */ /* AXIVION Disable Style MisraC2012-1.1: Cast necessary for DMA configuration */ diff --git a/src/app/driver/i2c/i2c.h b/src/app/driver/i2c/i2c.h index 5f1a4f02..56e5bd35 100644 --- a/src/app/driver/i2c/i2c.h +++ b/src/app/driver/i2c/i2c.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file i2c.h * @author foxBMS Team * @date 2021-07-22 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix I2C * diff --git a/src/app/driver/imd/bender/ir155/bender_ir155.c b/src/app/driver/imd/bender/ir155/bender_ir155.c index bab223a3..2b2f2987 100644 --- a/src/app/driver/imd/bender/ir155/bender_ir155.c +++ b/src/app/driver/imd/bender/ir155/bender_ir155.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bender_ir155.c * @author foxBMS Team * @date 2014-02-11 (date of creation) - * @updated 2021-09-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix IR155 * @@ -53,36 +54,175 @@ /*========== Includes =======================================================*/ #include "bender_ir155.h" +#include "bender_ir155_cfg.h" + +#include "bender_ir155_helper.h" #include "database.h" +#include "fram.h" +#include "io.h" /*========== Macros and Definitions =========================================*/ +/** + * Dutycycle - resistance table + * for Bender IR155-3204 (Art. No. B91068139) + * + * dc | resistance/kOhm | description | + * ---|------------------|------------------------| + * 100| -63,16 | not valid | + * 98 | -38,71 | invalid | + * 95 | =0,00 | invalid | + * 95 | >0,00 | shortcut | + * 90 | 70,59 | very low resistance | + * 80 | 240,00 | low resistance | + * 70 | 461,54 | low resistance | + * 60 | 763,64 | lowmid resistance | + * 50 | 1200,00 | highmid resistance | + * 40 | 1885,71 | highmid resistance | + * 30 | 3120,00 | high resistance | + * 20 | 6000,00 | high resistance | + * 10 | 20400,00 | very high resistance | + * 5 | oo | very high resistance | + * 3 |-55200,00 | invalid | + * 0 |-22800,00 | invalid | + * + */ +#define IR155_MINIMUM_INSULATION_RESISTANCE_kOhm (0u) + /*========== Static Constant and Variable Definitions =======================*/ -/** internal handle for the database table of the insulation monitoring driver */ -static DATA_BLOCK_INSULATION_MONITORING_s ir155_insulationMeasurement = { - .header.uniqueId = DATA_BLOCK_ID_INSULATION_MONITORING}; /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ -static STD_RETURN_TYPE_e IR155_MeasureInsulation(void); +/** Initialize function for Bender IR155 driver */ +static IMD_FSM_STATES_e IR155_InitializeModule(void); + +/** Acquire measurement results from Bender IR155 and write them into the database */ +static IMD_FSM_STATES_e IR155_MeasureInsulation(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring); /*========== Static Function Implementations ================================*/ -static STD_RETURN_TYPE_e IR155_MeasureInsulation(void) { - ir155_insulationMeasurement.valid = 0; - ir155_insulationMeasurement.state = 0; - ir155_insulationMeasurement.insulationResistance_kOhm = 10000000; - ir155_insulationMeasurement.insulationFault = 0; - ir155_insulationMeasurement.chassisFault = 0; - ir155_insulationMeasurement.systemFailure = 0; - ir155_insulationMeasurement.insulationWarning = 0; - DATA_WRITE_DATA(&ir155_insulationMeasurement); - return STD_OK; +static IMD_FSM_STATES_e IR155_InitializeModule(void) { + /* Initialize Software-Module */ + IR155_Initialize(IMD_PERIODIC_CALL_TIME_ms); + return IMD_FSM_STATE_IMD_ENABLE; +} + +static IMD_FSM_STATES_e IR155_MeasureInsulation(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR); + pTableInsulationMonitoring->isInsulationMeasurementValid = true; + pTableInsulationMonitoring->insulationResistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + pTableInsulationMonitoring->areDeviceFlagsValid = true; + pTableInsulationMonitoring->dfIsCriticalResistanceDetected = false; + pTableInsulationMonitoring->dfIsChassisFaultDetected = false; + pTableInsulationMonitoring->dfIsDeviceErrorDetected = false; + /* Bender IR155 does not support a digital warning threshold -> check measured insulation resistance */ + pTableInsulationMonitoring->dfIsWarnableResistanceDetected = false; + + /* Evaluate input pwm signal */ + ir155_state.measurement = IR155_GetMeasurementValues(); + + /* Measurement is not valid, either because of startup delay or detected ground error before startup */ + if (ir155_state.timeUntilValidMeasurement_ms > 0u) { + if (ir155_state.timeUntilValidMeasurement_ms >= ir155_state.periodTriggerTime_ms) { + ir155_state.timeUntilValidMeasurement_ms -= ir155_state.periodTriggerTime_ms; + ir155_state.measurement.measurementState = IR155_MEASUREMENT_NOT_VALID; + } else { + /* 0 < hysteresisCounter < measCycleTime + * Measurement is valid from that moment on */ + ir155_state.timeUntilValidMeasurement_ms = 0u; + } + + if (ir155_state.timeUntilValidMeasurement_ms == 0u) { + /* If hysteresis is over, reset diag flag and reset grounderror flag */ + /* TODO: How to handle the ground error fault after reset? Do this in diag callback?*/ + /* Reset non-volatile ground error flag - Do this in diag callback? */ + fram_insulationFlags.groundErrorDetected = false; + } + } + + /* Evaluate if resistance measurement is valid or not */ + if (ir155_state.measurement.measurementState == IR155_MEASUREMENT_NOT_VALID) { + /* Measurement result is not valid */ + pTableInsulationMonitoring->isInsulationMeasurementValid = false; + } else { + pTableInsulationMonitoring->isInsulationMeasurementValid = true; + } + + /* Set measured resistance value */ + pTableInsulationMonitoring->insulationResistance_kOhm = ir155_state.measurement.resistance_kOhm; + + /* Evaluate device state */ + if ((ir155_state.measurement.measurementState == IR155_IMD_ERROR_MEASUREMENT) || + (ir155_state.measurement.measurementState == IR155_IMD_ERROR_MEASUREMENT_UNKNOWN)) { + /* Mark device flags and insulation measurement as invalid if a device error is detected */ + pTableInsulationMonitoring->areDeviceFlagsValid = false; + pTableInsulationMonitoring->isInsulationMeasurementValid = false; + } else { + pTableInsulationMonitoring->areDeviceFlagsValid = true; + } + + /* Set error flag if Pin OHKS detects an error + * Pin state high: No fault; Insulation resistance > response value + * Pin state low: Insulation resistance <= response value detected; + * Device error; Fault in the earth connection + * Undervoltage detected or device switched off + */ + if (ir155_state.measurement.digitalStatusPin == STD_PIN_LOW) { + pTableInsulationMonitoring->dfIsCriticalResistanceDetected = true; + } else { + pTableInsulationMonitoring->dfIsCriticalResistanceDetected = false; + } + + /* Check for device error: invalid measurement period or duty-cycle detected */ + if ((ir155_state.measurement.measurementState == IR155_RESISTANCE_MEASUREMENT_UNKNOWN) || + (ir155_state.measurement.measurementState == IR155_RESISTANCE_ESTIMATION_UNKNOWN) || + (ir155_state.measurement.measurementState == IR155_UNDERVOLTAGE_MEASUREMENT_UNKNOWN) || + (ir155_state.measurement.measurementState == IR155_GROUND_ERROR_MODE_UNKNOWN)) { + pTableInsulationMonitoring->dfIsDeviceErrorDetected = true; + } else { + pTableInsulationMonitoring->dfIsDeviceErrorDetected = false; + } + + /* Check for chassis fault */ + pTableInsulationMonitoring->dfIsChassisShortToHvPlus = false; /* This feature is not supported by the device */ + pTableInsulationMonitoring->dfIsChassisShortToHvMinus = false; /* This feature is not supported by the device */ + if (ir155_state.measurement.measurementState == IR155_GROUND_ERROR_MODE) { + pTableInsulationMonitoring->dfIsChassisFaultDetected = true; + } else { + pTableInsulationMonitoring->dfIsDeviceErrorDetected = false; + } + + /* No digital signal for warning threshold available for this device -> use measured insulation resistance */ + if (pTableInsulationMonitoring->insulationResistance_kOhm <= IMD_WARNING_THRESHOLD_INSULATION_RESISTANCE_kOhm) { + pTableInsulationMonitoring->dfIsWarnableResistanceDetected = true; + } else { + pTableInsulationMonitoring->dfIsWarnableResistanceDetected = false; + } + + /* TODO: bool dfIsMeasurmentedUpToDate; Check if measurement result is up to data */ + return IMD_FSM_STATE_RUNNING; } /*========== Extern Function Implementations ================================*/ -extern void IMD_Trigger(void) { - IR155_MeasureInsulation(); +extern IMD_FSM_STATES_e IMD_ProcessInitializationState(void) { + return IR155_InitializeModule(); +} + +extern IMD_FSM_STATES_e IMD_ProcessEnableState(void) { + /* Enable supply for Bender */ + IO_PinSet(&IR155_SUPPLY_ENABLE_PORT->DOUT, IR155_SUPPLY_ENABLE_PIN); + return IMD_FSM_STATE_RUNNING; +} + +extern IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR); + return IR155_MeasureInsulation(pTableInsulationMonitoring); +} + +extern IMD_FSM_STATES_e IMD_ProcessShutdownState(void) { + /* Disable supply for Bender */ + IO_PinReset(&IR155_SUPPLY_ENABLE_PORT->DOUT, IR155_SUPPLY_ENABLE_PIN); + return IMD_FSM_STATE_IMD_ENABLE; } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/imd/bender/ir155/bender_ir155.h b/src/app/driver/imd/bender/ir155/bender_ir155.h index 6b36d0f7..65a661b1 100644 --- a/src/app/driver/imd/bender/ir155/bender_ir155.h +++ b/src/app/driver/imd/bender/ir155/bender_ir155.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bender_ir155.h * @author foxBMS Team * @date 2021-09-06 (date of creation) - * @updated 2021-09-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix IR155 * diff --git a/src/app/driver/imd/bender/ir155/bender_ir155_helper.c b/src/app/driver/imd/bender/ir155/bender_ir155_helper.c new file mode 100644 index 00000000..50f89b50 --- /dev/null +++ b/src/app/driver/imd/bender/ir155/bender_ir155_helper.c @@ -0,0 +1,378 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file bender_ir155_helper.c + * @author foxBMS Team + * @date 2021-09-17 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS + * @prefix IR155 + * + * @brief Driver for the insulation monitoring + */ + +/*========== Includes =======================================================*/ +#include "bender_ir155_helper.h" + +#include "bender_ir155_cfg.h" + +#include "fram.h" + +/*========== Macros and Definitions =========================================*/ +/** Maximum measurable resistance according to formula: + * ((90 * 1200kOhm) / (dc - 5) ) - 1200kOhm + * with dc ]5%,95%[ */ +#define IR155_MAXIMUM_INSULATION_RESISTANCE_kOhm (106800u) +#define IR155_MINIMUM_INSULATION_RESISTANCE_kOhm (0u) + +/* Normal mode: duty cycle limits */ +#define IR155_NORMAL_MODE_LOWER_DUTY_CYCLE_LIMIT_perc (4.0f) +#define IR155_NORMAL_MODE_UPPER_DUTY_CYCLE_LIMIT_perc (96.0f) + +/* Speed start mode: duty cycle limits */ +#define IR155_SPEED_START_ESTIMATION_GOOD_LOWER_DUTY_CYCLE_LIMIT_perc (4.0f) +#define IR155_SPEED_START_ESTIMATION_GOOD_UPPER_DUTY_CYCLE_LIMIT_perc (11.0f) + +#define IR155_SPEED_START_ESTIMATION_BAD_LOWER_DUTY_CYCLE_LIMIT_perc (89.0f) +#define IR155_SPEED_START_ESTIMATION_BAD_UPPER_DUTY_CYCLE_LIMIT_perc (96.0f) + +/* Undervoltage mode: duty cycle limits */ +#define IR155_UNDERVOLTAGE_MODE_LOWER_DUTY_CYCLE_LIMIT_perc (4.0f) +#define IR155_UNDERVOLTAGE_MODE_UPPER_DUTY_CYCLE_LIMIT_perc (96.0f) + +/* Device error mode: duty cycle limits */ +#define IR155_DEVICE_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc (46.5f) +#define IR155_DEVICE_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc (53.5f) + +/* Device error mode: duty cycle limits */ +#define IR155_GROUND_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc (46.5f) +#define IR155_GROUND_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc (53.5f) + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ +extern IR155_STATE_s ir155_state = { + .ir155Initialized = false, + .measurement.isMeasurementValid = false, + .measurement.isUndervoltageDetected = false, + .measurement.measurementState = IR155_UNINITIALIZED, + .measurement.measurementMode = IR155_UNKNOWN, + .measurement.digitalStatusPin = STD_PIN_LOW, + .measurement.resistance_kOhm = 0, + .measurement.pwmSignal.dutyCycle_perc = 0.0f, + .measurement.pwmSignal.frequency_Hz = 0.0f, + .periodTriggerTime_ms = IMD_PERIODIC_CALL_TIME_ms, +}; + +/*========== Static Function Prototypes =====================================*/ +/** + * @brief Determines frequency-dependent measurement state. + * @details Use of intervals because of measuring and signal inaccuracy. This + * interval is configurable via define #IR155_MEASUREMENT_INTERVAL_RANGE_Hz + * @param[in] frequency_Hz measured signal frequency in Hz + * @return #IR155_MEASUREMENT_MODE_e bender measurement mode + */ +static IR155_MEASUREMENT_MODE_e IR155_GetMeasurementMode(float frequency_Hz); + +/** + * @brief Calculate insulation resistance from measured dutycycle. + * @details Function check, that passed duty-cycle lies within allowed range. + * Otherwise, the calculated resistance will be limited to the next + * reasonable value. + * @param[in] dutyCycle_perc measured signal duty-cycle in percentage + * @return measured insulation resistance in kOhm + */ +static uint32_t IR155_CalculateResistance(float dutyCycle_perc); + +/** + * @brief Check if passed duty cycle is within interval limits + * @param[in] dutyCycle_perc measured signal duty-cycle in percentage + * @param[in] lowerLimit_perc lower interval limit + * @param[in] upperLimit_perc upper interval limit + * @return measured insulation resistance in kOhm + */ +static bool IR155_IsDutyCycleWithinInterval(float dutyCycle_perc, float lowerLimit_perc, float upperLimit_perc); + +/*========== Static Function Implementations ================================*/ +static IR155_MEASUREMENT_MODE_e IR155_GetMeasurementMode(float frequency_Hz) { + FAS_ASSERT(frequency_Hz >= 0.0f); + IR155_MEASUREMENT_MODE_e retVal = IR155_UNKNOWN; + + if ((frequency_Hz >= IR155_NORMAL_CONDITION_LOWER_FREQUENCY_Hz) && + (frequency_Hz < IR155_NORMAL_CONDITION_UPPER_FREQUENCY_Hz)) { + retVal = IR155_NORMAL_MODE; + } else if ( + (frequency_Hz >= IR155_UNDERVOLTAGE_LOWER_FREQUENCY_Hz) && + (frequency_Hz < IR155_UNDERVOLTAGE_UPPER_FREQUENCY_Hz)) { + retVal = IR155_UNDERVOLTAGE_MODE; /* should not be detected as default threshold 0V, EOL Bender configurable! */ + } else if ( + (frequency_Hz >= IR155_SPEEDSTART_LOWER_FREQUENCY_Hz) && (frequency_Hz < IR155_SPEEDSTART_UPPER_FREQUENCY_Hz)) { + retVal = IR155_SPEEDSTART_MODE; + } else if ( + (frequency_Hz >= IR155_IMD_DEVICE_ERROR_LOWER_FREQUENCY_Hz) && + (frequency_Hz < IR155_IMD_DEVICE_ERROR_UPPER_FREQUENCY_Hz)) { + retVal = IR155_IMD_ERROR_MODE; + } else if ( + (frequency_Hz >= IR155_GROUND_ERROR_LOWER_FREQUENCY_Hz) && + (frequency_Hz < IR155_GROUND_ERROR_UPPER_FREQUENCY_Hz)) { + retVal = IR155_GROUNDERROR_MODE; + } else if (frequency_Hz <= IR155_MINIMUM_FREQUENCY_Hz) { + retVal = IR155_SHORT_CLAMP; + } else { + retVal = IR155_UNDEFINED_FREQUENCY; + } + return retVal; +} + +static uint32_t IR155_CalculateResistance(float dutyCycle_perc) { + FAS_ASSERT(dutyCycle_perc <= 100.0f); + FAS_ASSERT(dutyCycle_perc > 0.0f); + + float insulationResistance_kOhm = 0.0f; + if (dutyCycle_perc <= 5.0f) { + insulationResistance_kOhm = (float)IR155_MAXIMUM_INSULATION_RESISTANCE_kOhm; + } else if (dutyCycle_perc > 95.0f) { + insulationResistance_kOhm = (float)IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + } else { + insulationResistance_kOhm = ((90.0f * 1200.0f) / (dutyCycle_perc - 5.0f)) - 1200.0f; + } + return (uint32_t)insulationResistance_kOhm; +} + +static bool IR155_IsDutyCycleWithinInterval(float dutyCycle_perc, float lowerLimit_perc, float upperLimit_perc) { + bool retval = false; + if ((lowerLimit_perc < dutyCycle_perc) && (upperLimit_perc > dutyCycle_perc)) { + retval = true; + } else { + retval = false; + } + return retval; +} + +/*========== Extern Function Implementations ================================*/ + +void IR155_Initialize(uint8_t triggerTime_ms) { + /* Timer peripheral initialization if not already done. */ + if (false == PWM_IsEcapModuleInitialized()) { + PWM_Initialize(); /* TODO: split PWM_Init function in a dedicated function for ecap and etpwm module */ + } + + /* Read non-volatile FRAM */ + FRAM_ReadData(FRAM_BLOCK_ID_INSULATION_FLAG); + + /* Check grounderror flag */ + if (fram_insulationFlags.groundErrorDetected == true) { + /* GROUND ERROR occurred before shutting down */ + ir155_state.timeUntilValidMeasurement_ms = IR155_WAIT_TIME_AFTER_GROUND_ERROR_ms; + } else { + /* Normal startup delay -> wait 2.2s until first measurement is trustworthy */ + ir155_state.timeUntilValidMeasurement_ms = IR155_STARTUP_TIME_ms; + } + + ir155_state.periodTriggerTime_ms = triggerTime_ms; + ir155_state.ir155Initialized = true; +} + +void IR155_Deinitialize(void) { + /* Reset cycle time */ + ir155_state.periodTriggerTime_ms = 0u; + + /* Reset timer duty cycle struct */ + ir155_state.measurement.pwmSignal.dutyCycle_perc = 0.0f; + ir155_state.measurement.pwmSignal.frequency_Hz = 0.0f; + + ir155_state.ir155Initialized = false; + + /* Set diagnosis message that measurement is not trustworthy */ + /* TODO: do it really like this? DIAG_Handler(DIAG_CH_ISOMETER_MEAS_INVALID, DIAG_EVENT_NOK, 0); */ +} + +IR155_MEASUREMENT_s IR155_GetMeasurementValues(void) { + /* Initialize struct */ + IR155_MEASUREMENT_s measurementResult = { + .isMeasurementValid = false, + .isUndervoltageDetected = true, + .pwmSignal.dutyCycle_perc = 0.0f, + .pwmSignal.frequency_Hz = 0.0f, + .resistance_kOhm = 0u, + .digitalStatusPin = STD_PIN_UNDEFINED, + .measurementMode = IR155_UNKNOWN, + .measurementState = IR155_UNINITIALIZED, + }; + + /* read value of Bender IR155 digital status pin (OHKS) */ + measurementResult.digitalStatusPin = IR155_GET_DIGITAL_STATUS_PIN_STATE(); + + /* get duty-cycle and frequency from PWM input measurement */ + measurementResult.pwmSignal = ECAP_GetPwmData(); + + /* TODO: How-to check valid data? */ + bool isPwmMeasurementValid = true; + if (isPwmMeasurementValid == true) { + /* TODO: Throw error? */ + isPwmMeasurementValid = true; + } else { + /* Invalid values measurement */ + + /* Invalidate data? */ + isPwmMeasurementValid = false; + } + + /* Get measurement mode */ + if (isPwmMeasurementValid == true) { + measurementResult.measurementMode = IR155_GetMeasurementMode(measurementResult.pwmSignal.frequency_Hz); + } else { + measurementResult.measurementMode = IR155_UNKNOWN; + /* TODO: Throw what error? */ + } + + switch (measurementResult.measurementMode) { + case IR155_NORMAL_MODE: + ir155_state.measurement.isUndervoltageDetected = false; + if (true == IR155_IsDutyCycleWithinInterval( + measurementResult.pwmSignal.dutyCycle_perc, + IR155_NORMAL_MODE_LOWER_DUTY_CYCLE_LIMIT_perc, + IR155_NORMAL_MODE_UPPER_DUTY_CYCLE_LIMIT_perc)) { + measurementResult.resistance_kOhm = + IR155_CalculateResistance(measurementResult.pwmSignal.dutyCycle_perc); + measurementResult.isMeasurementValid = true; + measurementResult.measurementState = IR155_RESISTANCE_MEASUREMENT; + } else { + measurementResult.measurementState = IR155_RESISTANCE_MEASUREMENT_UNKNOWN; + measurementResult.isMeasurementValid = false; + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + } + break; + + case IR155_SPEEDSTART_MODE: + measurementResult.isUndervoltageDetected = false; + if (true == IR155_IsDutyCycleWithinInterval( + measurementResult.pwmSignal.dutyCycle_perc, + IR155_SPEED_START_ESTIMATION_GOOD_LOWER_DUTY_CYCLE_LIMIT_perc, + IR155_SPEED_START_ESTIMATION_GOOD_UPPER_DUTY_CYCLE_LIMIT_perc)) { + measurementResult.resistance_kOhm = IR155_MAXIMUM_INSULATION_RESISTANCE_kOhm; + measurementResult.isMeasurementValid = true; + measurementResult.measurementState = IR155_RESISTANCE_ESTIMATION; + } else if ( + true == IR155_IsDutyCycleWithinInterval( + measurementResult.pwmSignal.dutyCycle_perc, + IR155_SPEED_START_ESTIMATION_BAD_LOWER_DUTY_CYCLE_LIMIT_perc, + IR155_SPEED_START_ESTIMATION_BAD_UPPER_DUTY_CYCLE_LIMIT_perc)) { + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + measurementResult.isMeasurementValid = true; + measurementResult.measurementState = IR155_RESISTANCE_ESTIMATION; + } else { + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + measurementResult.isMeasurementValid = false; + measurementResult.measurementState = IR155_RESISTANCE_ESTIMATION_UNKNOWN; + } + break; + + case IR155_UNDERVOLTAGE_MODE: + measurementResult.isUndervoltageDetected = true; + if (true == IR155_IsDutyCycleWithinInterval( + measurementResult.pwmSignal.dutyCycle_perc, + IR155_UNDERVOLTAGE_MODE_LOWER_DUTY_CYCLE_LIMIT_perc, + IR155_UNDERVOLTAGE_MODE_UPPER_DUTY_CYCLE_LIMIT_perc)) { + measurementResult.resistance_kOhm = + IR155_CalculateResistance(measurementResult.pwmSignal.dutyCycle_perc); + measurementResult.isMeasurementValid = true; + measurementResult.measurementState = IR155_UNDERVOLTAGE_MEASUREMENT; + } else { + measurementResult.isMeasurementValid = false; + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + measurementResult.measurementState = IR155_UNDERVOLTAGE_MEASUREMENT_UNKNOWN; + } + break; + + case IR155_IMD_ERROR_MODE: + measurementResult.isUndervoltageDetected = false; + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + if (true == IR155_IsDutyCycleWithinInterval( + measurementResult.pwmSignal.dutyCycle_perc, + IR155_DEVICE_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc, + IR155_DEVICE_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc)) { + /* Error detected and verified with duty cycle */ + measurementResult.isMeasurementValid = true; + measurementResult.measurementState = IR155_IMD_ERROR_MEASUREMENT; + } else { + /* Error detected but invalid duty cycle */ + measurementResult.measurementState = IR155_IMD_ERROR_MEASUREMENT_UNKNOWN; + measurementResult.isMeasurementValid = false; + } + break; + case IR155_GROUNDERROR_MODE: + measurementResult.isUndervoltageDetected = false; + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + if (true == IR155_IsDutyCycleWithinInterval( + measurementResult.pwmSignal.dutyCycle_perc, + IR155_GROUND_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc, + IR155_GROUND_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc)) { + /* Error detected and verified with duty cycle */ + measurementResult.isMeasurementValid = true; + measurementResult.measurementState = IR155_GROUND_ERROR_MODE; + } else { + /* Error detected but invalid duty cycle */ + measurementResult.measurementState = IR155_GROUND_ERROR_MODE_UNKNOWN; + measurementResult.isMeasurementValid = false; + } + break; + + case IR155_SHORT_CLAMP: + measurementResult.isUndervoltageDetected = false; + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + measurementResult.measurementState = IR155_SIGNAL_SHORT; + measurementResult.isMeasurementValid = true; + break; + + default: + measurementResult.resistance_kOhm = IR155_MINIMUM_INSULATION_RESISTANCE_kOhm; + measurementResult.measurementState = IR155_MEASUREMENT_NOT_VALID; + measurementResult.isMeasurementValid = false; + break; + } + + return measurementResult; +} + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/imd/bender/ir155/bender_ir155_helper.h b/src/app/driver/imd/bender/ir155/bender_ir155_helper.h new file mode 100644 index 00000000..90f40510 --- /dev/null +++ b/src/app/driver/imd/bender/ir155/bender_ir155_helper.h @@ -0,0 +1,156 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file bender_ir155_helper.h + * @author foxBMS Team + * @date 2021-09-17 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS + * @prefix IR155 + * + * @brief Headers for the configuration for the insulation monitoring + * + * + */ + +#ifndef FOXBMS__BENDER_IR155_HELPER_H_ +#define FOXBMS__BENDER_IR155_HELPER_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +/* clang-format off */ +#include "imd.h" +/* clang-format on */ + +#include "io.h" +#include "pwm.h" + +/*========== Macros and Definitions =========================================*/ + +/* Read pin state of digital status pin (OKHS) */ +#define IR155_GET_DIGITAL_STATUS_PIN_STATE() \ + IO_PinGet(&IR155_DIGITAL_STATUS_INPUT_PORT->DIN, IR155_DIGITAL_STATUS_INPUT_PIN) + +/** + * symbolic names for the different measurement modes of Bender Isometer. + * Defined through the frequency of the measurement signal. + */ +typedef enum IR155_MEASUREMENT_MODE { + IR155_NORMAL_MODE, /*!< PWM frequency: 10Hz */ + IR155_SPEEDSTART_MODE, /*!< PWM frequency: 30Hz */ + IR155_UNDERVOLTAGE_MODE, /*!< PWM frequency: 20Hz */ + IR155_IMD_ERROR_MODE, /*!< PWM frequency: 40Hz */ + IR155_GROUNDERROR_MODE, /*!< PWM frequency: 50Hz */ + IR155_SHORT_CLAMP, /*!< PWM frequency: 0Hz */ + IR155_UNDEFINED_FREQUENCY, /*!< illegal frequency detected*/ + IR155_DUTY_CYCLE_MEASUREMENT, /*!< corrupt signal measurement (e.g. T_on > T_periode,)*/ + IR155_NOSIGNAL, /*!< no signal (e.g. if 100% -> wire break, if 0% -> shortcut to GND */ + IR155_UNKNOWN, +} IR155_MEASUREMENT_MODE_e; + +/** + * symbolic names for the different operating states Bender Isometer. + * Defined through the duty cycle of the measurement signal. + */ +typedef enum IR155_MEASUREMENT_STATE { + IR155_RESISTANCE_MEASUREMENT, /*!< valid normal measurement working */ + IR155_RESISTANCE_MEASUREMENT_UNKNOWN, /*!< normal measurement with undefined duty cycle */ + IR155_RESISTANCE_ESTIMATION, /*!< SPEEDSTART estimation working */ + IR155_RESISTANCE_ESTIMATION_UNKNOWN, /*!< SPEEDSTART estimation with undefined duty cycle */ + IR155_UNDERVOLTAGE_MEASUREMENT, /*!< SPEEDSTART estimation working */ + IR155_UNDERVOLTAGE_MEASUREMENT_UNKNOWN, /*!< SPEEDSTART estimation with undefined duty cycle */ + IR155_GROUND_ERROR_MODE, /*!< ground error detected */ + IR155_GROUND_ERROR_MODE_UNKNOWN, /*!< ground error detected with undefined duty cycle */ + IR155_IMD_ERROR_MEASUREMENT, /*!< device error detected */ + IR155_IMD_ERROR_MEASUREMENT_UNKNOWN, /*!< device error detected with unkown duty cycle*/ + IR155_SIGNAL_SHORT, /*!< signal short detected */ + IR155_MEASUREMENT_NOT_VALID, /*!< Invalid measurement detected */ + IR155_UNINITIALIZED, /*!< Uninitialized state */ +} IR155_MEASUREMENT_STATE_e; + +/** type definition for structure of insulation measurement */ +typedef struct { + bool isMeasurementValid; /*!< flag if measurement value is valid or not */ + bool isUndervoltageDetected; /*!< flag if undervoltage has been detected */ + PWM_SIGNAL_s pwmSignal; /*!< duty cycle and frequency of measured pwm signal */ + uint32_t resistance_kOhm; /*!< measured insulation resistance in kOhm */ + STD_PIN_STATE_e digitalStatusPin; /*!< pin state of Status output (OK_HS) */ + IR155_MEASUREMENT_MODE_e measurementMode; /*!< IR155 measurement mode */ + IR155_MEASUREMENT_STATE_e measurementState; /*!< IR155 measurement state */ +} IR155_MEASUREMENT_s; + +/** IR155 state struct */ +typedef struct { + bool ir155Initialized; /*!< flag if IR155 module is initialied */ + IR155_MEASUREMENT_s measurement; /*!< latest measurement */ + uint32_t timeUntilValidMeasurement_ms; /*!< time until valid measurement result is valid */ + uint16_t periodTriggerTime_ms; /*!< periodic call time of IR155 module */ +} IR155_STATE_s; + +/*========== Extern Constant and Variable Declarations ======================*/ +extern IR155_STATE_s ir155_state; + +/*========== Extern Function Prototypes =====================================*/ +/** + * @brief Software initialization of Timer-module + * @param triggerTime_ms cyclic call time of IR155_GetMeasurementValues function + */ +extern void IR155_Initialize(uint8_t triggerTime_ms); + +/** + * @brief Software deinitialization of Timer-module + */ +extern void IR155_Deinitialize(void); + +/** + * @brief Interface function which delivers the actual signal measurement (duty cyle) and evaluation. + * Use of intervals because of measuring and signal inaccuracy. The evaluated results are + * finally written in the database. + * @return #IR155_MEASUREMENT_s measurement result of IR155 measurement + */ +extern IR155_MEASUREMENT_s IR155_GetMeasurementValues(void); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__BENDER_IR155_HELPER_H_ */ diff --git a/src/app/driver/imd/bender/ir155/config/bender_ir155_cfg.h b/src/app/driver/imd/bender/ir155/config/bender_ir155_cfg.h new file mode 100644 index 00000000..662ab242 --- /dev/null +++ b/src/app/driver/imd/bender/ir155/config/bender_ir155_cfg.h @@ -0,0 +1,166 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file bender_ir155_cfg.h + * @author foxBMS Team + * @date 2021-09-17 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS_CONFIGURATION + * @prefix IR155 + * + * @brief Headers for the configuration for the insulation monitoring + * + * + */ + +#ifndef FOXBMS__BENDER_IR155_CFG_H_ +#define FOXBMS__BENDER_IR155_CFG_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +#include "HL_het.h" + +/* clang-format off */ +#include "imd.h" +/* clang-format on */ + +/*========== Macros and Definitions =========================================*/ + +/** + * During this time, the results of Bender Isometer aren't to be trusted + * wait time in [ms] <= 65535; + * IR155_WAIT_TIME_AFTER_GNDERROR + * \par Type: + * int + * \par Range: + * 0 < x <=65535 + * \par Unit: + * ms + * \par Default: + * 25000 +*/ +#define IR155_WAIT_TIME_AFTER_GROUND_ERROR_ms (25000u) + +/** Time after startup, until the first valid measurement result is available */ +#define IR155_STARTUP_TIME_ms (2200u) + +/* Symbolic names for the different measurement modes of Bender Isometer. */ + +/** 0 Hz -> Hi > short-circuit to Ub + (Kl. 15); Low > IMD off or short-circuit + * to Kl. 31 */ +#define IR155_MINIMUM_FREQUENCY_Hz (5.0f) /* Define a minimum frequency as 0 Hz can not be measured by PWM module */ + +/** 10 Hz -> Normal condition. Insulation measurement DCP starts two seconds + * after power on; First successful insulation measurement at ? 17.5 s. + * PWM active 5...95 % */ +#define IR155_NORMAL_CONDITION_FREQUENCY_Hz (10.0f) + +/** 20 Hz -> undervoltage condition. Insulation measurement DCP (continuous + * measurement); starts two seconds after power on; PWM active 5...95 %; + * First successful insulation measurement at ? 17.5 s, Undervoltage detection + * 0...500 V (Bender configurable) */ +#define IR155_UNDERVOLTAGE_FREQUENCY_Hz (20.0f) + +/** 30 Hz -> Speed start measurement. Insulation measurement (only good/bad + * evaluation), starts directly after power on ? 2 s; PWM 5...10 % (good) and + * 90...95 % (bad) */ +#define IR155_SPEEDSTART_FREQUENCY_Hz (30.0f) + +/** 40 Hz -> Device error */ +#define IR155_IMD_DEVICE_ERROR_FREQUENCY_Hz (40.0f) + +/** 50 Hz -> Connection fault earth. Fault detected on the earth connection + * (Kl. 31), PWM 47.5...52.5 % */ +#define IR155_GROUND_ERROR_FREQUENCY_Hz (50.0f) + +/** The exact frequency of the pwm signal cannot be measured due to inaccuracies. + * Thus, a interval is used to detect any deviations. The interval is for example + * selected as 50 Hz +/- IR155_MEASUREMENT_INTERVAL_RANGE_Hz */ +#define IR155_MEASUREMENT_INTERVAL_RANGE_Hz (1.0f) + +/* Min and max values are defined for tolerance purposes of the measurement. */ +#define IR155_NORMAL_CONDITION_UPPER_FREQUENCY_Hz \ + (IR155_NORMAL_CONDITION_FREQUENCY_Hz + IR155_MEASUREMENT_INTERVAL_RANGE_Hz) +#define IR155_NORMAL_CONDITION_LOWER_FREQUENCY_Hz \ + (IR155_NORMAL_CONDITION_FREQUENCY_Hz - IR155_MEASUREMENT_INTERVAL_RANGE_Hz) + +#define IR155_UNDERVOLTAGE_UPPER_FREQUENCY_Hz (IR155_UNDERVOLTAGE_FREQUENCY_Hz + IR155_MEASUREMENT_INTERVAL_RANGE_Hz) +#define IR155_UNDERVOLTAGE_LOWER_FREQUENCY_Hz (IR155_UNDERVOLTAGE_FREQUENCY_Hz - IR155_MEASUREMENT_INTERVAL_RANGE_Hz) + +#define IR155_SPEEDSTART_UPPER_FREQUENCY_Hz (IR155_SPEEDSTART_FREQUENCY_Hz + IR155_MEASUREMENT_INTERVAL_RANGE_Hz) +#define IR155_SPEEDSTART_LOWER_FREQUENCY_Hz (IR155_SPEEDSTART_FREQUENCY_Hz - IR155_MEASUREMENT_INTERVAL_RANGE_Hz) + +#define IR155_IMD_DEVICE_ERROR_UPPER_FREQUENCY_Hz \ + (IR155_IMD_DEVICE_ERROR_FREQUENCY_Hz + IR155_MEASUREMENT_INTERVAL_RANGE_Hz) +#define IR155_IMD_DEVICE_ERROR_LOWER_FREQUENCY_Hz \ + (IR155_IMD_DEVICE_ERROR_FREQUENCY_Hz - IR155_MEASUREMENT_INTERVAL_RANGE_Hz) + +#define IR155_GROUND_ERROR_UPPER_FREQUENCY_Hz (IR155_GROUND_ERROR_FREQUENCY_Hz + IR155_MEASUREMENT_INTERVAL_RANGE_Hz) +#define IR155_GROUND_ERROR_LOWER_FREQUENCY_Hz (IR155_GROUND_ERROR_FREQUENCY_Hz - IR155_MEASUREMENT_INTERVAL_RANGE_Hz) + +/** Register that the supply enable pin is connected to. */ +#define IR155_SUPPLY_ENABLE_PORT (hetREG1) + +/** Pin that the supply enable pin is connected to. */ +#define IR155_SUPPLY_ENABLE_PIN (25u) + +/** Register that the input status pin (OHKS) is connected to. */ +#define IR155_DIGITAL_STATUS_INPUT_PORT (hetREG1) + +/** Pin that the input status pin (IM_OK) is connected to. */ +#define IR155_DIGITAL_STATUS_INPUT_PIN (27u) + +/** Register that the input PWM signal (IM_PWM) is connected to. */ +#define IR155_PWM_SIGNAL_PORT (hetREG2) /* TODO: this is correct? */ + +/** Pin that the input PWM signal pin (IM_PWM) is connected to. */ +#define IR155_PWM_SIGNAL_PIN (27u) /* TODO: this is correct? */ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__BENDER_IR155_CFG_H_ */ diff --git a/src/app/driver/imd/bender/ir155/wscript b/src/app/driver/imd/bender/ir155/wscript index 740143ca..dee4ac02 100644 --- a/src/app/driver/imd/bender/ir155/wscript +++ b/src/app/driver/imd/bender/ir155/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -47,11 +47,20 @@ import os def build(bld): """Builds the Bender IR155 monitoring device""" + source = [ + os.path.join("bender_ir155.c"), + os.path.join("bender_ir155_helper.c"), + ] includes = [ ".", + os.path.join("config"), os.path.join("..", ".."), os.path.join("..", "..", "..", "can"), os.path.join("..", "..", "..", "config"), + os.path.join("..", "..", "..", "fram"), + os.path.join("..", "..", "..", "io"), + os.path.join("..", "..", "..", "mcu"), + os.path.join("..", "..", "..", "pwm"), os.path.join("..", "..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "..", "engine", "config"), os.path.join("..", "..", "..", "..", "engine", "database"), @@ -62,9 +71,12 @@ def build(bld): os.path.join("..", "..", "..", "..", "task", "ftask"), ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) + cflags = bld.env.CFLAGS_FOXBMS bld( features="c", - source="bender_ir155.c", + source=source, + use="imd-device", includes=includes, target=f"{bld.env.APPNAME}-imd", + cflags=cflags, ) diff --git a/src/app/driver/imd/bender/iso165c/bender_iso165c.c b/src/app/driver/imd/bender/iso165c/bender_iso165c.c index 1131eebb..93586cc9 100644 --- a/src/app/driver/imd/bender/iso165c/bender_iso165c.c +++ b/src/app/driver/imd/bender/iso165c/bender_iso165c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bender_iso165c.c * @author foxBMS Team * @date 2019-04-07 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix I165C * @@ -59,79 +60,286 @@ #include "database_cfg.h" #include "can.h" +#include "can_helper.h" #include "database.h" #include "ftask.h" /*========== Macros and Definitions =========================================*/ +/** statemachine short time definition in trigger calls until next state is processed */ +#define I165C_FSM_SHORT_TIME (1u) -#define RESISTANCE_THRESHOLD (50000u) -#define I165C_CAN_NODE (CAN1_NODE) +/* -------------- State defines ---------------------------------------------*/ + +/** States of the initialization state machine */ +typedef enum { + I165C_FSM_STATE_INITIALIZATION_DUMMY, /*!< dummy state - always the first state */ + I165C_FSM_STATE_INITIALIZATION_HAS_NEVER_RUN, /*!< never run state - always the second state - unlock device */ + I165C_FSM_STATE_INITIALIZATION_UNLOCK_WAIT_ACK, /*!< wait acknowledge of unlocking */ + I165C_FSM_STATE_INITIALIZATION_CHECK_MEASUREMENT_STATE, /*!< check if measurement is enabled. if not enable it */ + I165C_FSM_STATE_INITIALIZATION_ENABLE_MEASUREMENT_WAIT_ACK, /*!< wait for acknowledge for enabling of measurement */ + I165C_FSM_STATE_INITIALIZATION_REQUEST_HV_RELAY_OPENING, /*!< request HV relay state: open */ + I165C_FSM_STATE_INITIALIZATION_REQUEST_NEGATIVE_HV_RELAY_STATE, /*!< check HV relay state */ + I165C_FSM_STATE_INITIALIZATION_CHECK_NEGATIVE_HV_RELAY_STATE, /*!< check negative HV relay state */ + I165C_FSM_STATE_INITIALIZATION_CHECK_POSITIVE_HV_RELAY_STATE, /*!< check positive HV relay state */ + I165C_FSM_STATE_INITIALIZATION_REQUEST_SELF_TEST, /*!< request self-test */ + I165C_FSM_STATE_INITIALIZATION_SELF_TEST_WAIT_ACK, /*!< wait acknowledge of self-test */ + I165C_FSM_STATE_INITIALIZATION_WAIT_SELF_TEST, /*!< wait until self-test is finished */ + I165C_FSM_STATE_INITIALIZATION_SET_AVERAGING_FACTOR, /*!< set averaging factor */ + I165C_FSM_STATE_INITIALIZATION_AVERAGING_FACTOR_WAIT_ACK, /*!< wait acknowledge of averaging factor */ + I165C_FSM_STATE_INITIALIZATION_SET_ERROR_THRESHOLD, /*!< configuration of error threshold */ + I165C_FSM_STATE_INITIALIZATION_ERROR_THRESHOLD_WAIT_ACK, /*!< wait acknowledge of error threshold */ + I165C_FSM_STATE_INITIALIZATION_SET_WARNING_THRESHOLD, /*!< configuration of warning threshold */ + I165C_FSM_STATE_INITIALIZATION_WARNING_THRESHOLD_WAIT_ACK, /*!< wait acknowledge of warning threshold */ + I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT, /*!< disable measurement */ + I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT_WAIT_ACK, /*!< wait acknowledge of disable measurement */ +} I165C_FSM_INITIALIZATION_STATES_e; + +/** States of the enable state machine */ +typedef enum { + I165C_FSM_STATE_ENABLE_DUMMY, /*!< dummy state - always the first state */ + I165C_FSM_STATE_ENABLE_HAS_NEVER_RUN, /*!< never run state - always the second state - unlock device */ + I165C_FSM_STATE_ENABLE_REQUEST_NEGATIVE_HV_RELAY_STATE, /*!< check negative HV relay state */ + I165C_FSM_STATE_ENABLE_CHECK_NEGATIVE_HV_RELAY_STATE, /*!< check negative HV relay state */ + I165C_FSM_STATE_ENABLE_CHECK_POSITIVE_HV_RELAY_STATE, /*!< check positive HV relay state */ + I165C_FSM_STATE_ENABLE_START_MEASUREMENT, /*!< start insulation measurement */ + I165C_FSM_STATE_ENABLE_START_MEASUREMENT_WAIT_ACK, /*!< check for acknowledge of start measurement request */ +} I165C_FSM_ENABLE_STATES_e; + +/** States of the running state machine */ +typedef enum { + I165C_FSM_STATE_RUNNING_DUMMY, /*!< dummy state - always the first state */ + I165C_FSM_STATE_RUNNING_HAS_NEVER_RUN, /*!< never run state - always the second state */ + I165C_FSM_STATE_RUNNING_READ_RESISTANCE, + I165C_FSM_STATE_RUNNING_READ_RESISTANCE_WAIT_ACK, + I165C_FSM_STATE_RUNNING_GET_MEASUREMENT, +} I165C_FSM_RUNNING_STATES_e; + +/** States of the disable state machine */ +typedef enum { + I165C_FSM_STATE_DISABLE_DUMMY, /*!< dummy state - always the first state */ + I165C_FSM_STATE_DISABLE_HAS_NEVER_RUN, /*!< never run state - always the second state - unlock device */ + I165C_FSM_STATE_MEASUREMENT_STOPPED_WAIT_ACK, /*!< wait for acknowledge of stop measurement request */ + I165C_FSM_STATE_DISABLE_SET_HV_RELAY_STATE, /*!< request state of HV relays */ + I165C_FSM_STATE_DISABLE_REQUEST_NEGATIVE_HV_RELAY_STATE, /*!< request state of negative */ + I165C_FSM_STATE_DISABLE_CHECK_NEGATIVE_HV_RELAY_STATE, /*!< check negative HV relay state */ + I165C_FSM_STATE_DISABLE_CHECK_POSITIVE_HV_RELAY_STATE, /*!< check positive HV relay state */ +} I165C_FSM_DISABLE_STATES_e; + +/* -------------- State variables -------------------------------------------*/ + +/** This struct describes the state of the initialization state machine */ +typedef struct { + uint16_t timer; /*!< timer of the state */ + uint8_t triggerEntry; /*!< trigger entry of the state */ + I165C_FSM_INITIALIZATION_STATES_e currentState; /*!< current state of the FSM */ + I165C_FSM_INITIALIZATION_STATES_e previousState; /*!< previous state of the FSM */ + uint8_t receptionTries; + uint8_t receptionTriesMessage; + bool negativeRelayClosed; + bool positiveRelayClosed; +} I165C_INITIALIZATION_STATE_s; + +typedef struct { + uint16_t timer; /*!< timer of the state */ + uint8_t triggerEntry; /*!< trigger entry of the state */ + I165C_FSM_ENABLE_STATES_e currentState; /*!< current state of the FSM */ + I165C_FSM_ENABLE_STATES_e previousState; /*!< previous state of the FSM */ + uint8_t receptionTries; + uint8_t receptionTriesMessage; +} I165C_ENABLE_STATE_s; + +typedef struct { + uint16_t timer; /*!< timer of the state */ + uint8_t triggerEntry; /*!< trigger entry of the state */ + I165C_FSM_RUNNING_STATES_e currentState; /*!< current state of the FSM */ + I165C_FSM_RUNNING_STATES_e previousState; /*!< previous state of the FSM */ + uint8_t receptionTries; + uint8_t receptionTriesMessage; +} I165C_RUNNING_STATE_s; + +typedef struct { + uint16_t timer; /*!< timer of the state */ + uint8_t triggerEntry; /*!< trigger entry of the state */ + I165C_FSM_DISABLE_STATES_e currentState; /*!< current state of the FSM */ + I165C_FSM_DISABLE_STATES_e previousState; /*!< previous state of the FSM */ + uint8_t receptionTries; + uint8_t receptionTriesMessage; +} I165C_DISABLE_STATE_s; /*========== Static Constant and Variable Definitions =======================*/ +static I165C_INITIALIZATION_STATE_s i165c_initializationState = { + .timer = 0u, + .triggerEntry = 0u, + .currentState = I165C_FSM_STATE_INITIALIZATION_HAS_NEVER_RUN, + .previousState = I165C_FSM_STATE_INITIALIZATION_DUMMY, + .receptionTries = 0u, + .receptionTriesMessage = 0u, +#if false == I165C_IS_165C_USED + /* Default state after startup is closed for iso165C-1 */ + .negativeRelayClosed = true, + .positiveRelayClosed = true, +#else + /* Default state after startup is open for iso165C */ + .negativeRelayClosed = false, + .positiveRelayClosed = false, +#endif +}; + +static I165C_ENABLE_STATE_s i165c_enableState = { + .timer = 0u, + .triggerEntry = 0u, + .currentState = I165C_FSM_STATE_ENABLE_HAS_NEVER_RUN, + .previousState = I165C_FSM_STATE_ENABLE_DUMMY, + .receptionTries = 0u, + .receptionTriesMessage = 0u, +}; + +static I165C_RUNNING_STATE_s i165c_runningState = { + .timer = 0u, + .triggerEntry = 0u, + .currentState = I165C_FSM_STATE_RUNNING_HAS_NEVER_RUN, + .previousState = I165C_FSM_STATE_RUNNING_DUMMY, + .receptionTries = 0u, + .receptionTriesMessage = 0u, + +}; + +static I165C_DISABLE_STATE_s i165c_disableState = { + .timer = 0u, + .triggerEntry = 0u, + .currentState = I165C_FSM_STATE_DISABLE_HAS_NEVER_RUN, + .previousState = I165C_FSM_STATE_DISABLE_DUMMY, + .receptionTries = 0u, + .receptionTriesMessage = 0u, + +}; + static CAN_BUFFERELEMENT_s i165c_canTxMessage = {0u}; static CAN_BUFFERELEMENT_s i165c_canRxMessage = {0u}; -static DATA_BLOCK_INSULATION_MONITORING_s i165c_insulationMeasurementData = { - .header.uniqueId = DATA_BLOCK_ID_INSULATION_MONITORING}; - /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** + * @brief Sets the next state the timer value + * of the initialization state variable. + * @param[in,out] pImdState state of the initialization state machine + * @param[in] nextState state to be transferred into + * @param[in] idleTime wait time for the state machine + */ +static void I165C_SetInitializationState( + I165C_INITIALIZATION_STATE_s *pImdState, + I165C_FSM_INITIALIZATION_STATES_e nextState, + uint16_t idleTime); + +/** + * @brief Sets the next state the timer value + * of the enable state variable. + * @param[in,out] pImdState state of the enable state machine + * @param[in] nextState state to be transferred into + * @param[in] idleTime wait time for the state machine + */ +static void I165C_SetEnableState( + I165C_ENABLE_STATE_s *pImdState, + I165C_FSM_ENABLE_STATES_e nextState, + uint16_t idleTime); + +/** + * @brief Sets the next state the timer value + * of the running state variable. + * @param[in,out] pImdState state of the enable state machine + * @param[in] nextState state to be transferred into + * @param[in] idleTime wait time for the state machine + */ +static void I165C_SetRunningState( + I165C_RUNNING_STATE_s *pImdState, + I165C_FSM_RUNNING_STATES_e nextState, + uint16_t idleTime); + +/** + * @brief Sets the next state the timer value + * of the disable state variable. + * @param[in,out] pImdState state of the enable state machine + * @param[in] nextState state to be transferred into + * @param[in] idleTime wait time for the state machine + */ +static void I165C_SetDisableState( + I165C_DISABLE_STATE_s *pImdState, + I165C_FSM_DISABLE_STATES_e nextState, + uint16_t idleTime); + +/** Initialization state machine */ +static IMD_FSM_STATES_e I165C_Initialize(void); + +/** Enable state machine */ +static IMD_FSM_STATES_e I165C_Enable(void); + +/** Disable state machine */ +static IMD_FSM_STATES_e I165C_Disable(void); + +/** + * @brief trigger function for the i165c driver state machine. + * @details This function contains the sequence of events in the i165c state + * machine. + * It must be called time-triggered, every 100ms. + * @param pTableInsulationMonitoring pointer to insulation database entry + */ +static IMD_FSM_STATES_e I165C_Running(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring); /** * @brief Reset CAN data. * @details Used before starting a new transmission. - * @param canMessage CAN data to be reset + * @param[in,out] pCanMessage pointer to CAN data to be reset */ -static void I165C_ResetCanData(CAN_BUFFERELEMENT_s *canMessage); +static void I165C_ResetCanData(CAN_BUFFERELEMENT_s *pCanMessage); /** * @brief Write data in data word for CAN transmission. * @param dataWord data word ("position") in CAN structure to be written * to (see data sheet page 15) * @param data data to be written in data word - * @param canMessage CAN structure to be used for transmission + * @param[in] pCanMessage CAN structure to be used for transmission */ -static void I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFERELEMENT_s *canMessage); +static void I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFERELEMENT_s *pCanMessage); /** * @brief Get data in data word from CAN transmission. - * @param dataWord data word ("position") in CAN structure to be read from - * (see data sheet page 15) - * @param data data to be read from data word - * @param canMessage CAN structure used for transmission + * @param dataWord data word ("position") in CAN structure to be read from + * (see data sheet page 15) + * @param[out] pData pointer where to put read data from data word + * @param canMessage CAN structure used for transmission */ -static void I165C_ReadDataWord(uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage); +static void I165C_ReadDataWord(uint8_t dataWord, uint16_t *pData, CAN_BUFFERELEMENT_s canMessage); /** * @brief Get data in data word from CAN transmission, for the specific * IMD_Info message. * @param dataWord data word ("position") in CAN structure to be read from * (see data sheet page 15) - * @param data data to be read from data word + * @param[out] pData pointer where to put read data from data word * @param canMessage CAN structure used for transmission */ -static void I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage); +static void I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *pData, CAN_BUFFERELEMENT_s canMessage); /** * @brief Get data in data byte from CAN transmission. - * @param dataWord data byte ("position") in CAN structure to be read from + * @param dataByte data byte ("position") in CAN structure to be read from * (see data sheet page 15) - * @param data data to be read from data byte + * @param[out] pData pointer where to put read data from data byte * @param canMessage CAN structure used for transmission */ -static void I165C_ReadDataByte(uint8_t dataByte, uint8_t *data, CAN_BUFFERELEMENT_s canMessage); +static void I165C_ReadDataByte(uint8_t dataByte, uint8_t *pData, CAN_BUFFERELEMENT_s canMessage); /** * @brief Compose CAN message for CAN transmission. * @details Write CMD byte. * @param id CAN ID to use - * @param cmd command to be used (see data page 15 section 6.3 and + * @param command command to be used (see data page 15 section 6.3 and * further) - * @param canMessage CAN structure to be used for transmission + * @param[out] pCanMessage pointer to CAN structure to be used for transmission */ -static void I165C_WriteCmd(uint8_t id, uint8_t cmd, CAN_BUFFERELEMENT_s *canMessage); +static void I165C_WriteCmd(uint8_t id, uint8_t command, CAN_BUFFERELEMENT_s *pCanMessage); /** * @brief Check if iso165c acknowledged reception of sent message @@ -139,156 +347,256 @@ static void I165C_WriteCmd(uint8_t id, uint8_t cmd, CAN_BUFFERELEMENT_s *canMess * @details Gets data from the CAN module through a queue. * @param command check if this command is sent by iso165c to acknowledge * reception - * @param canMessage CAN data sent by the iso165c + * @param[in] pCanMessage pointer to CAN data sent by the iso165c * @return true if transmission acknowledged, false otherwise */ -static bool I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *canMessage); +static bool I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *pCanMessage); /** * @brief Get IMD Info from iso165c * @details Gets data from the CAN module through a queue. - * @param canMessage CAN data sent by the iso165c - * @return true if IMD_Info was received, false otherwise + * @param[in] pCanMessage pointer to CAN data sent by the iso165c + * @return true if IMD_Info message was received, false otherwise */ -static bool I165C_GetImdInfo(CAN_BUFFERELEMENT_s *canMessage); +static bool I165C_GetImdInfo(CAN_BUFFERELEMENT_s *pCanMessage); /** * @brief Check if iso165c was initialized and is running - * @details Check is made and the CAN IMD_Info data sent by the iso165c. - * @param canMessage IMD_Info to be checked, sent by the iso165c + * @details Check is made using the CAN IMD_Info data sent by the iso165c. + * - the IMC is up and running with no errors: + * - insulation measurement deactivated + * - self-test executed + * @param[in] canMessage IMD_Info to be checked, sent by the iso165c * @return true if IMD_Info was received, false otherwise */ -static bool I165C_IsInitialized(CAN_BUFFERELEMENT_s canMessage); +static bool I165C_IsSelfTestFinished(CAN_BUFFERELEMENT_s canMessage); /** - * @brief Check if iso165c acknowledged reception of command - * - * @details If acknowledged, currentState is set to nextState. - * If not acknowledged after allowed number of tries, restart - * initialization procedure: currentState is set to - * #I165C_STATE_SELFTEST. - * - * @param command command to be acknowledged - * @param currentState current state of the state machine - * @param nextState next state to go to if command acknowledged - * @param tries variable counting the number of tries for reception - * @param canMessage CAN data sent by the iso165c - * + * @brief Check if iso165c has already been performed previously + * @details Check is made using the CAN IMD_Info data sent by the iso165c. + * - self-test executed + * @param[in] canMessage IMD_Info to be checked, sent by the iso165c + * @return true if self-test has already been executed, false otherwise */ -static void I165C_CheckAcknowledgeArrived( - uint8_t command, - I165C_STATE_e *currentState, - I165C_STATE_e nextState, - uint8_t *tries, - CAN_BUFFERELEMENT_s *canMessage); +static bool I165C_HasSelfTestBeenExecuted(CAN_BUFFERELEMENT_s canMessage); /** - * @brief trigger function for the i165c driver state machine. - * @details This function contains the sequence of events in the i165c state - * machine. - * It must be called time-triggered, every 100ms. + * @brief Set state of HV relay + * @param[in] relay set state of positive or negative relay + * @param[in] relayState open or close relay + */ +static void I165C_SetRelayState(uint8_t relay, uint8_t relayState); + +/** + * @brief Request state of HV relay + * @param[in] relay positive or negative relay */ -static void I165C_Trigger(void); +static void I165C_RequestRelayState(uint8_t relay); + +/** + * @brief Check state of HV relay + * @param[in] canMessage IMD_Info to be checked, sent by the iso165c + * @param[in] relay positive or negative relay + * @param[in] relayState relay opened or closed + * @return true if state matches, otherwise false + */ +static bool I165C_CheckRelayState(CAN_BUFFERELEMENT_s canMessage, uint8_t relay, uint8_t relayState); + +/** + * @brief Set measurement mode + * @param[in] mode set IMD measurement mode + */ +static void I165C_SetMeasurementMode(uint8_t mode); + +/** + * @brief Check measurement mode + * @param[in] canMessage IMD_Info to be checked, sent by the iso165c + * @param[in] mode IMD measurement mode (activated or deactivated) + * @return true, if measurement mode matches, otherwise false + */ +static bool I165C_CheckMeasurementMode(CAN_BUFFERELEMENT_s canMessage, uint8_t mode); + +/** + * @brief Set average factor of the insulation resistance averaging algorithm + * @param[in] averagingFactor set IMD averaging factor + */ +static void I165C_SetAveragingFactor(uint8_t averagingFactor); + +/** + * @brief Check if iso165c acknowledged reception of command + * @param command command to be acknowledged + * @param[out] pTries pointer to variable counting the number of tries for reception + * @param[in] pCanMessage pointer to CAN data sent by the iso165c + * @return true if Acknowledge has been received, otherwise false + */ +static bool I165C_CheckAcknowledgeArrived(uint8_t command, uint8_t *pTries, CAN_BUFFERELEMENT_s *pCanMessage); /*========== Static Function Implementations ================================*/ +static void I165C_SetInitializationState( + I165C_INITIALIZATION_STATE_s *pImdState, + I165C_FSM_INITIALIZATION_STATES_e nextState, + uint16_t idleTime) { + FAS_ASSERT(pImdState != NULL_PTR); + /* Set time */ + pImdState->timer = idleTime; + /* Set state */ + if (nextState != pImdState->currentState) { + /* Next state is different: switch to it and set substate to entry value */ + pImdState->previousState = pImdState->currentState; + pImdState->currentState = nextState; + } else { + /* Next state equal to current state: nothing to do */ + } +} + +static void I165C_SetEnableState( + I165C_ENABLE_STATE_s *pImdState, + I165C_FSM_ENABLE_STATES_e nextState, + uint16_t idleTime) { + FAS_ASSERT(pImdState != NULL_PTR); + /* Set time */ + pImdState->timer = idleTime; + /* Set state */ + if (nextState != pImdState->currentState) { + /* Next state is different: switch to it and set substate to entry value */ + pImdState->previousState = pImdState->currentState; + pImdState->currentState = nextState; + } else { + /* Next state equal to current state: nothing to do */ + } +} + +static void I165C_SetRunningState( + I165C_RUNNING_STATE_s *pImdState, + I165C_FSM_RUNNING_STATES_e nextState, + uint16_t idleTime) { + FAS_ASSERT(pImdState != NULL_PTR); + /* Set time */ + pImdState->timer = idleTime; + /* Set state */ + if (nextState != pImdState->currentState) { + /* Next state is different: switch to it and set substate to entry value */ + pImdState->previousState = pImdState->currentState; + pImdState->currentState = nextState; + } else { + /* Next state equal to current state: nothing to do */ + } +} + +static void I165C_SetDisableState( + I165C_DISABLE_STATE_s *pImdState, + I165C_FSM_DISABLE_STATES_e nextState, + uint16_t idleTime) { + FAS_ASSERT(pImdState != NULL_PTR); + /* Set time */ + pImdState->timer = idleTime; + /* Set state */ + if (nextState != pImdState->currentState) { + /* Next state is different: switch to it and set substate to entry value */ + pImdState->previousState = pImdState->currentState; + pImdState->currentState = nextState; + } else { + /* Next state equal to current state: nothing to do */ + } +} -static void I165C_ResetCanData(CAN_BUFFERELEMENT_s *canMessage) { - FAS_ASSERT(canMessage != NULL_PTR); - for (uint8_t i = 0; i < 8u; i++) { - canMessage->data[i] = 0u; +static void I165C_ResetCanData(CAN_BUFFERELEMENT_s *pCanMessage) { + FAS_ASSERT(pCanMessage != NULL_PTR); + for (uint8_t i = 0u; i < CAN_DLC; i++) { + pCanMessage->data[i] = 0u; } } -static void I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFERELEMENT_s *canMessage) { - FAS_ASSERT(canMessage != NULL_PTR); +static void I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFERELEMENT_s *pCanMessage) { + FAS_ASSERT(pCanMessage != NULL_PTR); /* See data sheet section 6.1 page 15 */ if (dataWord == I165C_DW1) { - canMessage->data[1u] = data & 0xFFu; - canMessage->data[2u] = (data >> 8u) & 0xFFu; + pCanMessage->data[CAN_BYTE_1_POSITION] = (uint8_t)(data & 0xFFu); + pCanMessage->data[CAN_BYTE_2_POSITION] = (uint8_t)((data >> 8u) & 0xFFu); } if (dataWord == I165C_DW2) { - canMessage->data[3u] = data & 0xFFu; - canMessage->data[4u] = (data >> 8u) & 0xFFu; + pCanMessage->data[CAN_BYTE_3_POSITION] = (uint8_t)(data & 0xFFu); + pCanMessage->data[CAN_BYTE_4_POSITION] = (uint8_t)((data >> 8u) & 0xFFu); } } -static void I165C_ReadDataWord(uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage) { - FAS_ASSERT(data != NULL_PTR); +static void I165C_ReadDataWord(uint8_t dataWord, uint16_t *pData, CAN_BUFFERELEMENT_s canMessage) { + FAS_ASSERT(pData != NULL_PTR); /* See data sheet section 6.1 page 15 */ if (dataWord == I165C_DW1) { - *data = canMessage.data[1u]; - *data |= (((uint16_t)canMessage.data[2u]) << 8u) & 0xFF00u; + *pData = canMessage.data[CAN_BYTE_1_POSITION]; + *pData |= (((uint16_t)canMessage.data[CAN_BYTE_2_POSITION]) << 8u) & 0xFF00u; } if (dataWord == I165C_DW2) { - *data = canMessage.data[3u]; - *data |= (((uint16_t)canMessage.data[4u]) << 8u) & 0xFF00u; + *pData = canMessage.data[CAN_BYTE_3_POSITION]; + *pData |= (((uint16_t)canMessage.data[CAN_BYTE_4_POSITION]) << 8u) & 0xFF00u; } if (dataWord == I165C_DW3) { - *data = canMessage.data[5u]; - *data |= (((uint16_t)canMessage.data[6u]) << 8u) & 0xFF00u; + *pData = canMessage.data[CAN_BYTE_5_POSITION]; + *pData |= (((uint16_t)canMessage.data[CAN_BYTE_6_POSITION]) << 8u) & 0xFF00u; } } -static void I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage) { - FAS_ASSERT(data != NULL_PTR); +static void I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *pData, CAN_BUFFERELEMENT_s canMessage) { + FAS_ASSERT(pData != NULL_PTR); /* See data sheet section 6.1 page 15 */ if (dataWord == I165C_DW1) { - *data = canMessage.data[0u]; - *data |= (((uint16_t)canMessage.data[1u]) << 8u) & 0xFF00u; + *pData = canMessage.data[CAN_BYTE_0_POSITION]; + *pData |= (((uint16_t)canMessage.data[CAN_BYTE_1_POSITION]) << 8u) & 0xFF00u; } if (dataWord == I165C_DW2) { - *data = canMessage.data[2u]; - *data |= (((uint16_t)canMessage.data[3u]) << 8u) & 0xFF00u; + *pData = canMessage.data[CAN_BYTE_2_POSITION]; + *pData |= (((uint16_t)canMessage.data[CAN_BYTE_3_POSITION]) << 8u) & 0xFF00u; } if (dataWord == I165C_DW3) { - *data = canMessage.data[4u]; - *data |= (((uint16_t)canMessage.data[5u]) << 8u) & 0xFF00u; + *pData = canMessage.data[CAN_BYTE_4_POSITION]; + *pData |= (((uint16_t)canMessage.data[CAN_BYTE_5_POSITION]) << 8u) & 0xFF00u; } } -static void I165C_ReadDataByte(uint8_t dataByte, uint8_t *data, CAN_BUFFERELEMENT_s canMessage) { - FAS_ASSERT(data != NULL_PTR); +static void I165C_ReadDataByte(uint8_t dataByte, uint8_t *pData, CAN_BUFFERELEMENT_s canMessage) { + FAS_ASSERT(pData != NULL_PTR); /* See data sheet section 6.1 page 15 */ switch (dataByte) { case I165C_DB1: - *data = canMessage.data[1u]; + *pData = canMessage.data[CAN_BYTE_1_POSITION]; break; case I165C_DB2: - *data = canMessage.data[2u]; + *pData = canMessage.data[CAN_BYTE_2_POSITION]; break; case I165C_DB3: - *data = canMessage.data[3u]; + *pData = canMessage.data[CAN_BYTE_3_POSITION]; break; case I165C_DB4: - *data = canMessage.data[4u]; + *pData = canMessage.data[CAN_BYTE_4_POSITION]; break; default: - *data = 0u; + *pData = 0u; break; } } -static void I165C_WriteCmd(uint8_t id, uint8_t cmd, CAN_BUFFERELEMENT_s *canMessage) { - FAS_ASSERT(canMessage != NULL_PTR); +static void I165C_WriteCmd(uint8_t id, uint8_t command, CAN_BUFFERELEMENT_s *pCanMessage) { + FAS_ASSERT(pCanMessage != NULL_PTR); /* CAN message is a request, set ID accordingly */ - canMessage->id = id; + pCanMessage->id = id; /* First byte contains the CMD field */ - canMessage->data[0] = cmd; + pCanMessage->data[CAN_BYTE_0_POSITION] = command; } -static bool I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *canMessage) { - FAS_ASSERT(canMessage != NULL_PTR); +static bool I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *pCanMessage) { + FAS_ASSERT(pCanMessage != NULL_PTR); bool messageReceived = false; uint8_t numberItems = 0u; uint8_t queueReadTries = I165C_MAX_QUEUE_READS; /* Use loop on queue because IMD_info message could come meanwhile */ do { - numberItems = uxQueueMessagesWaiting(ftsk_imdCanDataQueue); + numberItems = OS_GetNumberOfStoredMessagesInQueue(ftsk_imdCanDataQueue); if (numberItems > 0u) { - if (OS_ReceiveFromQueue(ftsk_imdCanDataQueue, (void *)canMessage, 0u) == OS_SUCCESS) { + if (OS_ReceiveFromQueue(ftsk_imdCanDataQueue, (void *)pCanMessage, 0u) == OS_SUCCESS) { /* data queue was no empty */ - if (canMessage->data[0] == command) { + if ((command == pCanMessage->data[CAN_BYTE_0_POSITION]) && (pCanMessage->id == CAN_ID_IMD_RESPONSE)) { messageReceived = true; break; } @@ -300,19 +608,19 @@ static bool I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *canMessage return messageReceived; } -static bool I165C_GetImdInfo(CAN_BUFFERELEMENT_s *canMessage) { - FAS_ASSERT(canMessage != NULL_PTR); +static bool I165C_GetImdInfo(CAN_BUFFERELEMENT_s *pCanMessage) { + FAS_ASSERT(pCanMessage != NULL_PTR); bool imdInfoReceived = false; uint8_t numberItems = 0u; uint8_t queueReadTries = I165C_MAX_QUEUE_READS; /* Use loop on queue because other messages could come meanwhile */ do { - numberItems = uxQueueMessagesWaiting(ftsk_imdCanDataQueue); + numberItems = OS_GetNumberOfStoredMessagesInQueue(ftsk_imdCanDataQueue); if (numberItems > 0u) { - if (OS_ReceiveFromQueue(ftsk_imdCanDataQueue, (void *)canMessage, 0u) == OS_SUCCESS) { + if (OS_ReceiveFromQueue(ftsk_imdCanDataQueue, (void *)pCanMessage, 0u) == OS_SUCCESS) { /* data queue was no empty */ - if (canMessage->id == I165C_MESSAGETYPE_IMD_INFO) { + if (pCanMessage->id == I165C_MESSAGETYPE_IMD_INFO) { imdInfoReceived = true; break; } @@ -324,247 +632,859 @@ static bool I165C_GetImdInfo(CAN_BUFFERELEMENT_s *canMessage) { return imdInfoReceived; } -static bool I165C_IsInitialized(CAN_BUFFERELEMENT_s canMessage) { +static bool I165C_IsSelfTestFinished(CAN_BUFFERELEMENT_s canMessage) { bool initialized = true; uint16_t data = 0u; + /* Extract D_IMC_STATUS */ I165C_ReadDataWordImdInfo(I165C_DW2, &data, canMessage); - /* I165C_SELFTEST_RUNNING bit = 1 in IMD_Info DW2: selft test running */ - if (0u != (data & (1u << I165C_SELFTEST_RUNNING))) { + /* I165C_SELFTEST_RUNNING bit = 1 in IMD_Info DW2: self test running */ + uint16_t selfTestState = (data & (1u << I165C_SELFTEST_RUNNING_SHIFT)); + if (selfTestState != (1u << I165C_SELFTEST_RUNNING_SHIFT)) { + /* self test not running */ initialized = false; } + /* Extract D_VIFC_STATUS */ I165C_ReadDataWordImdInfo(I165C_DW3, &data, canMessage); - /** - * I165C_INSULATION_MEASUREMENT bit = 1 in IMD_Info DW3: - * insulation measurement deactivated - */ - if (0u != (data & (1u << I165C_INSULATION_MEASUREMENT))) { + /* I165C_INSULATION_MEASUREMENT bit = 0 in IMD_Info DW3: insulation measurement active */ + uint16_t insulationMeasurementState = (data & (1u << I165C_INSULATION_MEASUREMENT_STATUS_SHIFT)); + if (insulationMeasurementState != 0u) { + /* insulation measurement active */ initialized = false; } - /** - * I165C_IMC_SELFTEST_OVERALL_SCENARIO bit = 1 in IMD_Info DW3: - * selftest overall scenario not executed - */ - if (0u != (data & (1u << I165C_IMC_SELFTEST_OVERALL_SCENARIO))) { +#ifdef I165C_SELF_TEST_LONG + /* I165C_IMC_SELFTEST_OVERALL_SCENARIO bit = 1 in IMD_Info DW3: selftest overall scenario not executed */ + uint16_t selfTestExecuted = (data & (1u << I165C_IMC_SELFTEST_OVERALL_SCENARIO_SHIFT)); + if (selfTestExecuted != 0u) { /* selftest overall scenario not executed */ initialized = false; } - +#else + /* I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO bit = 1 in IMD_Info DW3: selftest parameter config not executed */ + uint16_t selfTestExecuted = (data & (1u << I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO_SHIFT)); + if (selfTestExecuted != 0u) { + /* selftest parameter scenario not executed */ + initialized = false; + } +#endif return initialized; } -static void I165C_CheckAcknowledgeArrived( - uint8_t command, - I165C_STATE_e *currentState, - I165C_STATE_e nextState, - uint8_t *tries, - CAN_BUFFERELEMENT_s *canMessage) { - FAS_ASSERT(currentState != NULL_PTR); - FAS_ASSERT(tries != NULL_PTR); - FAS_ASSERT(canMessage != NULL_PTR); +static bool I165C_HasSelfTestBeenExecuted(CAN_BUFFERELEMENT_s canMessage) { + bool anySelfTestExecuted = false; + uint16_t data = 0u; - if (false == I165C_CheckResponse(command, canMessage)) { - (*tries)++; - } else { - *tries = 0u; - *currentState = nextState; + /* Extract D_VIFC_STATUS */ + I165C_ReadDataWordImdInfo(I165C_DW3, &data, canMessage); + + /* I165C_IMC_SELFTEST_OVERALL_SCENARIO bit = 1 in IMD_Info DW3: selftest overall scenario not executed */ + uint16_t overallSelfTestExecuted = (data & (1u << I165C_IMC_SELFTEST_OVERALL_SCENARIO_SHIFT)); + if (overallSelfTestExecuted == 0u) { + /* selftest overall scenario has been executed */ + anySelfTestExecuted = true; } - if ((*tries) >= I165C_TRANSMISSION_TRIES) { - /* Transmission not acknowledged: restart initialization procedure */ - *currentState = I165C_STATE_SELFTEST; + /* I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO bit = 1 in IMD_Info DW3: selftest parameter config not executed */ + uint16_t parameterSelfTestExecuted = (data & (1u << I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO_SHIFT)); + if (parameterSelfTestExecuted == 0u) { + /* selftest parameter scenario has been executed */ + anySelfTestExecuted = true; } + return anySelfTestExecuted; } -static void I165C_Trigger(void) { - static I165C_STATE_e i165cState = I165C_STATE_UNINITIALIZED; - static uint8_t i165c_receptionTries = 0u; - static uint8_t i165c_receptionTriesImdInfo = 0u; - static uint16_t dataImdInfo = 0u; - static uint16_t data0 = 0u; - static uint8_t data1 = 0u; - static uint8_t data2 = 0u; +static void I165C_SetRelayState(uint8_t relay, uint8_t relayState) { + FAS_ASSERT((relay == I165C_D_VIFC_HV_RELAIS_NEGATIVE) || (relay == I165C_D_VIFC_HV_RELAIS_POSITIVE)); + FAS_ASSERT((relayState == I165C_RELAY_STATE_OPEN) || (relayState == I165C_RELAY_STATE_CLOSED)); + /* Reset CAN message buffer */ + I165C_ResetCanData(&i165c_canTxMessage); + /* Assemble CAN message */ + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_VIFC_SET_HV_RELAIS, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_D_VIFC_HV_RELAIS_SET_REQUEST, relay, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_D_VIFC_HV_RELAIS_STATE_SET_REQUEST, relayState, &i165c_canTxMessage); + /* Transmit CAN message */ + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); +} - switch (i165cState) { - case I165C_STATE_UNINITIALIZED: - i165cState = I165C_STATE_SELFTEST; - break; - case I165C_STATE_SELFTEST: - I165C_ResetCanData(&i165c_canTxMessage); - I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_CTL_SELFTEST, &i165c_canTxMessage); - I165C_WriteDataWord( - I165C_D_IMC_SELFTEST_SCR_CTL_REQUEST, I165C_SELFTEST_SCENARIO_OVERALL, &i165c_canTxMessage); - CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); - i165c_receptionTries = 0u; - i165cState = I165C_STATE_SELFTEST_WAIT_ACK; - break; - case I165C_STATE_SELFTEST_WAIT_ACK: - I165C_CheckAcknowledgeArrived( - I165C_CMD_S_IMC_CTL_SELFTEST, - &i165cState, - I165C_STATE_WAIT_SELFTEST, - &i165c_receptionTries, - &i165c_canRxMessage); - break; - case I165C_STATE_WAIT_SELFTEST: - if (true == I165C_GetImdInfo(&i165c_canRxMessage)) { - if (false == I165C_IsInitialized(i165c_canRxMessage)) { - i165c_receptionTries++; +static void I165C_RequestRelayState(uint8_t relay) { + FAS_ASSERT((relay == I165C_D_VIFC_HV_RELAIS_NEGATIVE) || (relay == I165C_D_VIFC_HV_RELAIS_POSITIVE)); + /* Reset CAN message buffer */ + I165C_ResetCanData(&i165c_canTxMessage); + /* Assemble CAN message */ + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_D_VIFC_HV_RELAIS_GET_REQUEST, relay, &i165c_canTxMessage); + /* Transmit CAN message */ + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); +} + +static bool I165C_CheckRelayState(CAN_BUFFERELEMENT_s canMessage, uint8_t relay, uint8_t relayState) { + FAS_ASSERT((relay == I165C_D_VIFC_HV_RELAIS_NEGATIVE) || (relay == I165C_D_VIFC_HV_RELAIS_POSITIVE)); + FAS_ASSERT((relayState == I165C_RELAY_STATE_OPEN) || (relayState == I165C_RELAY_STATE_CLOSED)); + bool checkSuccess = true; + uint16_t data = 0u; + + I165C_ReadDataWord(I165C_D_VIFC_HV_RELAIS_GET_RESPONSE, &data, canMessage); + /* IMD_Response DW1: relay */ + if (relay != data) { + /* not request relay */ + checkSuccess = false; + } + + I165C_ReadDataWord(I165C_D_VIFC_HV_RELAIS_STATE_GET_RESPONSE, &data, canMessage); + /* IMD_Response DW2: relay state */ + if (relayState != data) { + /* relay state does not match expected state */ + checkSuccess = false; + } + return checkSuccess; +} + +static void I165C_SetMeasurementMode(uint8_t mode) { + FAS_ASSERT((mode == I165C_ENABLE_MEASUREMENT) || (mode == I165C_DISABLE_MEASUREMENT)); + /* Reset CAN message buffer */ + I165C_ResetCanData(&i165c_canTxMessage); + /* Assemble CAN message */ + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_VIFC_CTL_MEASUREMENT, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_DW_VIFC_CTL_MEASUREMENT_REQUEST, mode, &i165c_canTxMessage); + /* Transmit CAN message */ + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); +} + +static bool I165C_CheckMeasurementMode(CAN_BUFFERELEMENT_s canMessage, uint8_t mode) { + FAS_ASSERT((mode == I165C_ENABLE_MEASUREMENT) || (mode == I165C_DISABLE_MEASUREMENT)); + bool measurementModeMatches = false; + uint16_t dVIFCStatus = 0u; + + /* Extract D_VIFC_STATUS word */ + I165C_ReadDataWordImdInfo(I165C_DW3, &dVIFCStatus, i165c_canRxMessage); + /* Extract measurement mode from D_VIFC_STATUS word */ + uint8_t actualMeasurementMode = dVIFCStatus & (1u << I165C_INSULATION_MEASUREMENT_STATUS_SHIFT); + + /* Check if actual measurement mode matches passed measurement mode */ + if (actualMeasurementMode == mode) { + /* Insulation measurement deactivated*/ + measurementModeMatches = true; + } + return measurementModeMatches; +} + +static void I165C_SetAveragingFactor(uint8_t averagingFactor) { + /* Averaging factor must be in the range 1...20 */ + FAS_ASSERT(averagingFactor != 0u); + FAS_ASSERT(averagingFactor <= 20u); + + /* Reset CAN message buffer */ + I165C_ResetCanData(&i165c_canTxMessage); + /* Assemble CAN message */ + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_SET_MEAN_FACTOR, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_D_IMC_MEAN_FACTOR_SET_REQUEST, I165C_MEASUREMENT_AVERAGING_FACTOR, &i165c_canTxMessage); + /* Transmit CAN message */ + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); +} + +static bool I165C_CheckAcknowledgeArrived(uint8_t command, uint8_t *pTries, CAN_BUFFERELEMENT_s *pCanMessage) { + FAS_ASSERT(pTries != NULL_PTR); + FAS_ASSERT(pCanMessage != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: command: parameter accepts whole range */ + + bool acknowledgeReceived = false; + if (I165C_CheckResponse(command, pCanMessage) == false) { + (*pTries)++; + } else { + *pTries = 0u; + acknowledgeReceived = true; + } + return acknowledgeReceived; +} + +static IMD_FSM_STATES_e I165C_Initialize(void) { + IMD_FSM_STATES_e nextState = IMD_FSM_STATE_INITIALIZATION; /* stay in initialization state */ + bool earlyExit = false; + + if (i165c_initializationState.timer > 0u) { + if ((--i165c_initializationState.timer) > 0u) { + i165c_initializationState.triggerEntry--; + earlyExit = true; + } + } + + if (earlyExit == false) { + switch (i165c_initializationState.currentState) { + case I165C_FSM_STATE_INITIALIZATION_HAS_NEVER_RUN: + /* Unlock device in case it was locked */ + I165C_ResetCanData(&i165c_canTxMessage); + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_VIFC_CTL_LOCK, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_D_VIFC_LOCK_MODE_CTL_REQUEST, I165C_LOCKMODE_UNLOCKED, &i165c_canTxMessage); + I165C_WriteDataWord(I165C_D_VIFC_LOCK_PWD_CTL_REQUEST, I165C_UNLOCK_PASSWORD, &i165c_canTxMessage); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + I165C_SetInitializationState( + &i165c_initializationState, I165C_FSM_STATE_INITIALIZATION_UNLOCK_WAIT_ACK, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_INITIALIZATION_UNLOCK_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_VIFC_CTL_LOCK, &i165c_initializationState.receptionTries, &i165c_canRxMessage) == + true) { + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_CHECK_MEASUREMENT_STATE, + I165C_FSM_SHORT_TIME); } else { - i165c_receptionTries = 0u; - i165c_receptionTriesImdInfo = 0u; - i165cState = I165C_STATE_INITIALIZATION_FINISHED; - break; + /* Issue: 621 */ } - } else { - i165c_receptionTries++; - } - if (i165c_receptionTries >= I165C_INITIALIZATION_TRIES) { - /* Initialization not working: restart initialization procedure */ - i165cState = I165C_STATE_SELFTEST; break; - } - break; - case I165C_STATE_INITIALIZATION_FINISHED: - i165cState = I165C_STATE_READ_RESISTANCE; - break; - case I165C_STATE_READ_RESISTANCE: - I165C_ResetCanData(&i165c_canTxMessage); - I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_GET_R_ISO, &i165c_canTxMessage); - CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); - i165c_receptionTries = 0u; - i165cState = I165C_STATE_READ_RESISTANCE_WAIT_ACK; - break; - case I165C_STATE_READ_RESISTANCE_WAIT_ACK: - I165C_CheckAcknowledgeArrived( - I165C_CMD_S_IMC_GET_R_ISO, &i165cState, I165C_STATE_UNLOCK, &i165c_receptionTries, &i165c_canRxMessage); - if (i165cState == I165C_STATE_UNLOCK) { - /* Response arrived */ - I165C_ReadDataWord(I165C_DW1, &data0, i165c_canRxMessage); - I165C_ReadDataByte(I165C_DB1, &data1, i165c_canRxMessage); - I165C_ReadDataByte(I165C_DB2, &data2, i165c_canRxMessage); - } - break; - case I165C_STATE_UNLOCK: - I165C_ResetCanData(&i165c_canTxMessage); - I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_VIFC_CTL_LOCK, &i165c_canTxMessage); - I165C_WriteDataWord(I165C_D_VIFC_LOCK_MODE_CTL_REQUEST, I165C_LOCKMODE_UNLOCKED, &i165c_canTxMessage); - I165C_WriteDataWord(I165C_D_VIFC_LOCK_PWD_CTL_REQUEST, I165C_UNLOCK_PASSWD, &i165c_canTxMessage); - CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); - i165c_receptionTries = 0u; - i165cState = I165C_STATE_UNLOCK_WAIT_ACK; - break; - case I165C_STATE_UNLOCK_WAIT_ACK: - I165C_CheckAcknowledgeArrived( - I165C_CMD_S_VIFC_CTL_LOCK, - &i165cState, - I165C_STATE_SET_ERROR_THRESHOLD, - &i165c_receptionTries, - &i165c_canRxMessage); - break; - case I165C_STATE_SET_ERROR_THRESHOLD: - I165C_ResetCanData(&i165c_canTxMessage); - I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_SET_R_ISO_ERR_THR, &i165c_canTxMessage); - I165C_WriteDataWord(I165C_D_IMC_R_ISO_ERR_THR_SET_REQUEST, I165C_ERROR_THRESHOLD_KOHM, &i165c_canTxMessage); - CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); - i165c_receptionTries = 0u; - i165cState = I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK; - break; - case I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK: - I165C_CheckAcknowledgeArrived( - I165C_CMD_S_IMC_SET_R_ISO_ERR_THR, - &i165cState, - I165C_STATE_SET_WARNING_THRESHOLD, - &i165c_receptionTries, - &i165c_canRxMessage); - break; - case I165C_STATE_SET_WARNING_THRESHOLD: - I165C_ResetCanData(&i165c_canTxMessage); - I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_SET_R_ISO_ERR_WRN, &i165c_canTxMessage); - I165C_WriteDataWord( - I165C_D_IMC_R_ISO_ERR_WRN_SET_REQUEST, I165C_WARNING_THRESHOLD_KOHM, &i165c_canTxMessage); - CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); - i165c_receptionTries = 0u; - i165cState = I165C_STATE_SET_WARNING_THRESHOLD_WAIT_ACK; - break; - case I165C_STATE_SET_WARNING_THRESHOLD_WAIT_ACK: - I165C_CheckAcknowledgeArrived( - I165C_CMD_S_IMC_SET_R_ISO_ERR_WRN, - &i165cState, - I165C_STATE_GET_MEASUREMENT, - &i165c_receptionTries, - &i165c_canRxMessage); - break; - case I165C_STATE_GET_MEASUREMENT: - if (false == I165C_GetImdInfo(&i165c_canRxMessage)) { - i165c_receptionTriesImdInfo++; - } else { - i165c_receptionTriesImdInfo = 0u; - /* Get measured resistance */ - I165C_ReadDataWordImdInfo(I165C_DW1, &dataImdInfo, i165c_canRxMessage); - i165c_insulationMeasurementData.insulationResistance_kOhm = dataImdInfo; - /* Get IMD status */ - I165C_ReadDataWordImdInfo(I165C_DW2, &dataImdInfo, i165c_canRxMessage); - if (0u != (dataImdInfo & (1u << I165C_INSULATION_FAULT))) { - /* Insulation fault */ - i165c_insulationMeasurementData.insulationFault = 1u; + + case I165C_FSM_STATE_INITIALIZATION_CHECK_MEASUREMENT_STATE: + if (I165C_GetImdInfo(&i165c_canRxMessage) == true) { + if (I165C_CheckMeasurementMode(i165c_canRxMessage, I165C_ENABLE_MEASUREMENT) == false) { + /* Measurement is not enabled -> Enable measurement as otherwise the following + * initialization procedure would fail */ + I165C_SetMeasurementMode(I165C_ENABLE_MEASUREMENT); + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_ENABLE_MEASUREMENT_WAIT_ACK, + I165C_FSM_SHORT_TIME); + } else { + /* Measurement enabled -> continue with initialization procedure */ + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_REQUEST_HV_RELAY_OPENING, + I165C_FSM_SHORT_TIME); + } + } + break; + + case I165C_FSM_STATE_INITIALIZATION_ENABLE_MEASUREMENT_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_VIFC_CTL_MEASUREMENT, + &i165c_initializationState.receptionTries, + &i165c_canRxMessage) == true) { + /* Measurement enabled -> continue with initialization procedure */ + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_REQUEST_HV_RELAY_OPENING, + I165C_FSM_SHORT_TIME); } else { - i165c_insulationMeasurementData.insulationFault = 0u; + /* Issue: 621 */ } - if (0u != (dataImdInfo & (1u << I165C_CHASSIS_FAULT))) { - /* Chassis fault */ - i165c_insulationMeasurementData.chassisFault = 1u; + break; + + case I165C_FSM_STATE_INITIALIZATION_REQUEST_HV_RELAY_OPENING: + /* Open negative relay */ + I165C_SetRelayState(I165C_D_VIFC_HV_RELAIS_NEGATIVE, I165C_RELAY_STATE_OPEN); + /* Open positive relay */ + I165C_SetRelayState(I165C_D_VIFC_HV_RELAIS_POSITIVE, I165C_RELAY_STATE_OPEN); + /* Switch to next state */ + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_REQUEST_NEGATIVE_HV_RELAY_STATE, + I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_INITIALIZATION_REQUEST_NEGATIVE_HV_RELAY_STATE: + I165C_RequestRelayState(I165C_D_VIFC_HV_RELAIS_NEGATIVE); + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_CHECK_NEGATIVE_HV_RELAY_STATE, + I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_INITIALIZATION_CHECK_NEGATIVE_HV_RELAY_STATE: + /* Check if HV relay is open and measurement has been stopped */ + if (I165C_CheckResponse(I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canRxMessage) == true) { + if (I165C_CheckRelayState( + i165c_canRxMessage, I165C_D_VIFC_HV_RELAIS_NEGATIVE, I165C_RELAY_STATE_OPEN) == true) { + i165c_initializationState.receptionTries = 0u; + i165c_initializationState.receptionTriesMessage = 0u; + + /* Request state of positive HV relay */ + I165C_RequestRelayState(I165C_D_VIFC_HV_RELAIS_POSITIVE); + + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_CHECK_POSITIVE_HV_RELAY_STATE, + I165C_FSM_SHORT_TIME); + } else { + i165c_initializationState.receptionTries++; + /* Issue: 621 */ + } } else { - i165c_insulationMeasurementData.chassisFault = 0u; + i165c_initializationState.receptionTriesMessage++; + /* Issue: 621 */ } - if (0u != (dataImdInfo & (1u << I165C_SYSTEM_FAILURE))) { - /* System failure */ - i165c_insulationMeasurementData.systemFailure = 1u; + break; + + case I165C_FSM_STATE_INITIALIZATION_CHECK_POSITIVE_HV_RELAY_STATE: + /* Check if HV relays are open and measurement has been stopped */ + if (I165C_CheckResponse(I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canRxMessage) == true) { + if (I165C_CheckRelayState( + i165c_canRxMessage, I165C_D_VIFC_HV_RELAIS_POSITIVE, I165C_RELAY_STATE_OPEN) == true) { + i165c_initializationState.receptionTries = 0u; + i165c_initializationState.receptionTriesMessage = 0u; + + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_REQUEST_SELF_TEST, + I165C_FSM_SHORT_TIME); + } else { + i165c_initializationState.receptionTries++; + /* Issue: 621 */ + } } else { - i165c_insulationMeasurementData.systemFailure = 0u; + i165c_initializationState.receptionTriesMessage++; + /* Issue: 621 */ } - if (0u != (dataImdInfo & (1u << I165C_INSULATION_WARNING))) { - /* Insulation warning */ - i165c_insulationMeasurementData.insulationWarning = 1u; + break; + + case I165C_FSM_STATE_INITIALIZATION_REQUEST_SELF_TEST: + /* A self test must be requested and can only be carried out + when the coupling relays are open. */ + + if (I165C_GetImdInfo(&i165c_canRxMessage) == true) { + if (I165C_HasSelfTestBeenExecuted(i165c_canRxMessage) == false) { + I165C_ResetCanData(&i165c_canTxMessage); + I165C_WriteCmd( + I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_CTL_SELFTEST, &i165c_canTxMessage); +#ifdef I165C_SELF_TEST_LONG + I165C_WriteDataWord( + I165C_D_IMC_SELFTEST_SCR_CTL_REQUEST, I165C_SELFTEST_SCENARIO_OVERALL, &i165c_canTxMessage); +#else /* I165C_SELF_TEST_SHORT */ + I165C_WriteDataWord( + I165C_D_IMC_SELFTEST_SCR_CTL_REQUEST, + I165C_SELFTEST_SCENARIO_PARAMETERCONFIG, + &i165c_canTxMessage); +#endif + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + i165c_initializationState.receptionTries = 0u; + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_SELF_TEST_WAIT_ACK, + I165C_FSM_SHORT_TIME); + } else { + /* Self-test has already been performed -> skip following initialization steps as the device + has previously been successfully configured. */ + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT, + I165C_FSM_SHORT_TIME); + } + } + + break; + + case I165C_FSM_STATE_INITIALIZATION_SELF_TEST_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_IMC_CTL_SELFTEST, &i165c_initializationState.receptionTries, &i165c_canRxMessage) == + true) { + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_WAIT_SELF_TEST, + I165C_FSM_SHORT_TIME); } else { - i165c_insulationMeasurementData.insulationWarning = 0u; + /* Issue: 621 */ + if (i165c_initializationState.receptionTries > I165C_TRANSMISSION_ATTEMPTS) { + /* Issue: 621 */ + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_HAS_NEVER_RUN, + I165C_FSM_SHORT_TIME); + i165c_initializationState.receptionTries = 0; + } } - /* Get VIFC status */ - I165C_ReadDataWordImdInfo(I165C_DW3, &dataImdInfo, i165c_canRxMessage); - if (0u != (dataImdInfo & (1u << I165C_INSULATION_MEASUREMENT))) { - /* Insulation measurement deactivated*/ + break; + case I165C_FSM_STATE_INITIALIZATION_WAIT_SELF_TEST: + if (I165C_GetImdInfo(&i165c_canRxMessage) == true) { + if (I165C_IsSelfTestFinished(i165c_canRxMessage) == false) { + i165c_initializationState.receptionTries++; + } else { + i165c_initializationState.receptionTries = 0u; + i165c_initializationState.receptionTriesMessage = 0u; + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_SET_AVERAGING_FACTOR, + I165C_FSM_SHORT_TIME); + } + } else { + /* Issue: 621 */ + i165c_initializationState.receptionTriesMessage++; + if (i165c_initializationState.receptionTriesMessage >= I165C_IMD_INFO_RECEIVE_ATTEMPTS) { + /* Initialization not working: restart initialization procedure */ + /* Issue: 621 */ + } } - if (0u != (dataImdInfo & (1u << I165C_IMC_ALIVE_STATUS_DETECTION))) { - /* VIFC status failure */ + break; + + case I165C_FSM_STATE_INITIALIZATION_SET_AVERAGING_FACTOR: + I165C_SetAveragingFactor(I165C_MEASUREMENT_AVERAGING_FACTOR); + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_AVERAGING_FACTOR_WAIT_ACK, + I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_INITIALIZATION_AVERAGING_FACTOR_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_IMC_SET_MEAN_FACTOR, + &i165c_initializationState.receptionTries, + &i165c_canRxMessage) == true) { + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_SET_ERROR_THRESHOLD, + I165C_FSM_SHORT_TIME); + } else { + /* Issue: 621 */ } - if (0u != (dataImdInfo & (1u << I165C_INSULATION_RESISTANCE_VALUE))) { - /* Insulation resistance value outdated */ + break; + + case I165C_FSM_STATE_INITIALIZATION_SET_ERROR_THRESHOLD: + I165C_ResetCanData(&i165c_canTxMessage); + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_SET_R_ISO_ERR_THR, &i165c_canTxMessage); + I165C_WriteDataWord( + I165C_D_IMC_R_ISO_ERR_THR_SET_REQUEST, I165C_ERROR_THRESHOLD_kOhm, &i165c_canTxMessage); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_ERROR_THRESHOLD_WAIT_ACK, + I165C_FSM_SHORT_TIME); + break; + case I165C_FSM_STATE_INITIALIZATION_ERROR_THRESHOLD_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_IMC_SET_R_ISO_ERR_THR, + &i165c_initializationState.receptionTries, + &i165c_canRxMessage) == true) { + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_SET_WARNING_THRESHOLD, + I165C_FSM_SHORT_TIME); + } else { + /* Issue: 621 */ } - if (0u != (dataImdInfo & (1u << I165C_IMC_SELFTEST_OVERALL_SCENARIO))) { - /* selftest overall scenario not executed */ + break; + case I165C_FSM_STATE_INITIALIZATION_SET_WARNING_THRESHOLD: + I165C_ResetCanData(&i165c_canTxMessage); + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_SET_R_ISO_ERR_WRN, &i165c_canTxMessage); + I165C_WriteDataWord( + I165C_D_IMC_R_ISO_ERR_WRN_SET_REQUEST, I165C_WARNING_THRESHOLD_kOhm, &i165c_canTxMessage); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_WARNING_THRESHOLD_WAIT_ACK, + I165C_FSM_SHORT_TIME); + break; + case I165C_FSM_STATE_INITIALIZATION_WARNING_THRESHOLD_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_IMC_SET_R_ISO_ERR_WRN, + &i165c_initializationState.receptionTries, + &i165c_canRxMessage) == true) { + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT, + I165C_FSM_SHORT_TIME); + } else { + /* Issue: 621 */ } - if (0u != (dataImdInfo & (1u << I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO))) { - /* selftest parameterconfig scenario not executed */ + break; + + case I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT: + I165C_SetMeasurementMode(I165C_DISABLE_MEASUREMENT); + I165C_SetInitializationState( + &i165c_initializationState, + I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT_WAIT_ACK, + I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_INITIALIZATION_DISABLE_MEASUREMENT_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_VIFC_CTL_MEASUREMENT, + &i165c_initializationState.receptionTries, + &i165c_canRxMessage) == true) { + /* Initialized -> switch to next state in IMD state machine */ + nextState = IMD_FSM_STATE_IMD_ENABLE; + /* Reset state machine in case a re-initialization is necessary */ + I165C_SetInitializationState( + &i165c_initializationState, I165C_FSM_STATE_INITIALIZATION_HAS_NEVER_RUN, I165C_FSM_SHORT_TIME); + + } else { + /* Issue: 621 */ } - DATA_WRITE_DATA(&i165c_insulationMeasurementData); - } - if (i165c_receptionTriesImdInfo >= I165C_IMD_INFO_RECEIVE_TRIES) { - /* IMD_Info not comming: restart initialization procedure */ - i165cState = I165C_STATE_SELFTEST; break; - } - break; - default: - /* invalid state */ - FAS_ASSERT(FAS_TRAP); - break; + + default: + FAS_ASSERT(FAS_TRAP); + break; + } + i165c_initializationState.triggerEntry--; } + return nextState; +} + +static IMD_FSM_STATES_e I165C_Enable(void) { + IMD_FSM_STATES_e nextState = IMD_FSM_STATE_IMD_ENABLE; /* stay in enable state */ + bool earlyExit = false; + + if (i165c_enableState.timer > 0u) { + if ((--i165c_enableState.timer) > 0u) { + i165c_enableState.triggerEntry--; + earlyExit = true; + } + } + + if (earlyExit == false) { + switch (i165c_enableState.currentState) { + case I165C_FSM_STATE_ENABLE_HAS_NEVER_RUN: + /* Close negative relay */ + I165C_SetRelayState(I165C_D_VIFC_HV_RELAIS_NEGATIVE, I165C_RELAY_STATE_CLOSED); + /* Close positive relay */ + I165C_SetRelayState(I165C_D_VIFC_HV_RELAIS_POSITIVE, I165C_RELAY_STATE_CLOSED); + /* Switch to next state */ + I165C_SetEnableState( + &i165c_enableState, I165C_FSM_STATE_ENABLE_REQUEST_NEGATIVE_HV_RELAY_STATE, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_ENABLE_REQUEST_NEGATIVE_HV_RELAY_STATE: + I165C_RequestRelayState(I165C_D_VIFC_HV_RELAIS_NEGATIVE); + I165C_SetEnableState( + &i165c_enableState, I165C_FSM_STATE_ENABLE_CHECK_NEGATIVE_HV_RELAY_STATE, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_ENABLE_CHECK_NEGATIVE_HV_RELAY_STATE: + if (I165C_CheckResponse(I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canRxMessage) == true) { + if (I165C_CheckRelayState( + i165c_canRxMessage, I165C_D_VIFC_HV_RELAIS_NEGATIVE, I165C_RELAY_STATE_CLOSED) == true) { + i165c_enableState.receptionTries = 0u; + i165c_enableState.receptionTriesMessage = 0u; + + /* Request state of positive HV relay */ + I165C_RequestRelayState(I165C_D_VIFC_HV_RELAIS_POSITIVE); + I165C_SetEnableState( + &i165c_enableState, + I165C_FSM_STATE_ENABLE_CHECK_POSITIVE_HV_RELAY_STATE, + I165C_FSM_SHORT_TIME); + } else { + i165c_enableState.receptionTries++; + /* Issue: 621 */ + } + } else { + i165c_enableState.receptionTriesMessage++; + /* Issue: 621 */ + if (i165c_enableState.receptionTriesMessage > I165C_TRANSMISSION_ATTEMPTS) { + I165C_SetEnableState( + &i165c_enableState, + I165C_FSM_STATE_ENABLE_REQUEST_NEGATIVE_HV_RELAY_STATE, + I165C_FSM_SHORT_TIME); + i165c_enableState.receptionTriesMessage = 0u; + } + /* Issue: 621 */ + } + break; + + case I165C_FSM_STATE_ENABLE_CHECK_POSITIVE_HV_RELAY_STATE: + if (I165C_CheckResponse(I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canRxMessage) == true) { + if (I165C_CheckRelayState( + i165c_canRxMessage, I165C_D_VIFC_HV_RELAIS_POSITIVE, I165C_RELAY_STATE_CLOSED) == true) { + i165c_enableState.receptionTries = 0u; + i165c_enableState.receptionTriesMessage = 0u; + + I165C_SetEnableState( + &i165c_enableState, I165C_FSM_STATE_ENABLE_START_MEASUREMENT, I165C_FSM_SHORT_TIME); + } else { + i165c_enableState.receptionTries++; + /* Issue: 621 */ + } + } else { + i165c_enableState.receptionTriesMessage++; + /* Issue: 621 */ + } + break; + + case I165C_FSM_STATE_ENABLE_START_MEASUREMENT: + I165C_SetMeasurementMode(I165C_ENABLE_MEASUREMENT); + I165C_SetEnableState( + &i165c_enableState, I165C_FSM_STATE_ENABLE_START_MEASUREMENT_WAIT_ACK, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_ENABLE_START_MEASUREMENT_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_VIFC_CTL_MEASUREMENT, &i165c_enableState.receptionTries, &i165c_canRxMessage) == + true) { + /* Enabled -> switch to next state in IMD state machine */ + nextState = IMD_FSM_STATE_RUNNING; + /* Reset state machine in case a re-enabling is necessary */ + I165C_SetEnableState( + &i165c_enableState, I165C_FSM_STATE_ENABLE_HAS_NEVER_RUN, I165C_FSM_SHORT_TIME); + } else { + /* Issue: 621 */ + } + break; + } + } + return nextState; +} + +static IMD_FSM_STATES_e I165C_Running(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR); + IMD_FSM_STATES_e nextState = IMD_FSM_STATE_RUNNING; /* stay in running state */ + bool earlyExit = false; + uint16_t resistance_kOhm = 0u; + uint16_t statusFlags = 0u; + uint8_t data1 = 0u; + uint8_t data2 = 0u; + + if (i165c_runningState.timer > 0u) { + if ((--i165c_runningState.timer) > 0u) { + i165c_runningState.triggerEntry--; + earlyExit = true; + } + } + + if (earlyExit == false) { + switch (i165c_runningState.currentState) { + case I165C_FSM_STATE_RUNNING_HAS_NEVER_RUN: + /* Switch to next state */ + I165C_SetRunningState( + &i165c_runningState, I165C_FSM_STATE_RUNNING_READ_RESISTANCE, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_RUNNING_READ_RESISTANCE: + I165C_ResetCanData(&i165c_canTxMessage); + I165C_WriteCmd(I165C_MESSAGETYPE_IMD_REQUEST, I165C_CMD_S_IMC_GET_R_ISO, &i165c_canTxMessage); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + i165c_runningState.receptionTries = 0u; + I165C_SetRunningState( + &i165c_runningState, I165C_FSM_STATE_RUNNING_READ_RESISTANCE_WAIT_ACK, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_RUNNING_READ_RESISTANCE_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_IMC_GET_R_ISO, &i165c_runningState.receptionTries, &i165c_canRxMessage) == true) { + /* Extract resistance value from response */ + I165C_ReadDataWord(I165C_DW1, &resistance_kOhm, i165c_canRxMessage); + pTableInsulationMonitoring->insulationResistance_kOhm = resistance_kOhm; + + /* Extract bias/tendency to the location of the insulation fault (error), if detected */ + I165C_ReadDataByte(I165C_D_IMC_R_ISO_BIAS_GET_RESPONSE, &data1, i165c_canRxMessage); + if (data1 == I165C_BIAS_TO_HV_PLUS) { + pTableInsulationMonitoring->dfIsChassisShortToHvPlus = true; + pTableInsulationMonitoring->dfIsChassisShortToHvMinus = false; + } else if (data1 == I165C_BIAS_TO_HV_MINUS) { + pTableInsulationMonitoring->dfIsChassisShortToHvMinus = true; + pTableInsulationMonitoring->dfIsChassisShortToHvPlus = false; + } else { + pTableInsulationMonitoring->dfIsChassisShortToHvPlus = false; + pTableInsulationMonitoring->dfIsChassisShortToHvMinus = false; + } + + /* Extract counter value */ + I165C_ReadDataByte(I165C_D_IMC_R_ISO_CNT_GET_RESPONSE, &data2, i165c_canRxMessage); + /* TODO: What to do with this info? */ + + I165C_SetRunningState( + &i165c_runningState, I165C_FSM_STATE_RUNNING_GET_MEASUREMENT, I165C_FSM_SHORT_TIME); + } else { + /* Issue: 621 */ + } + break; + + case I165C_FSM_STATE_RUNNING_GET_MEASUREMENT: + if (I165C_GetImdInfo(&i165c_canRxMessage) == false) { + i165c_runningState.receptionTriesMessage++; + /* Issue: 621 */ + /* IMD_Info not comming: restart initialization procedure? + if (i165c_runningState.receptionTriesMessage >= I165C_IMD_INFO_RECEIVE_ATTEMPTS) {*/ + } else { + i165c_runningState.receptionTriesMessage = 0u; + + /* Get measured resistance */ + I165C_ReadDataWordImdInfo(I165C_DW1, &resistance_kOhm, i165c_canRxMessage); + pTableInsulationMonitoring->insulationResistance_kOhm = resistance_kOhm; + + /* Get IMC status */ + I165C_ReadDataWordImdInfo(I165C_DW2, &statusFlags, i165c_canRxMessage); + if (0u != (statusFlags & (1u << I165C_INSULATION_FAULT_SHIFT))) { + /* Insulation fault */ + pTableInsulationMonitoring->dfIsCriticalResistanceDetected = true; + } else { + pTableInsulationMonitoring->dfIsCriticalResistanceDetected = false; + } + if (0u != (statusFlags & (1u << I165C_CHASSIS_FAULT_SHIFT))) { + /* Chassis fault */ + pTableInsulationMonitoring->dfIsChassisFaultDetected = true; + } else { + pTableInsulationMonitoring->dfIsChassisFaultDetected = false; + } + if (0u != (statusFlags & (1u << I165C_SYSTEM_FAILURE_SHIFT))) { + /* System failure */ + pTableInsulationMonitoring->dfIsDeviceErrorDetected = true; + pTableInsulationMonitoring->areDeviceFlagsValid = false; + } else { + pTableInsulationMonitoring->dfIsDeviceErrorDetected = false; + pTableInsulationMonitoring->areDeviceFlagsValid = true; + } + if (0u != (statusFlags & (1u << I165C_INSULATION_WARNING_SHIFT))) { + /* Insulation warning */ + pTableInsulationMonitoring->dfIsWarnableResistanceDetected = true; + } else { + pTableInsulationMonitoring->dfIsWarnableResistanceDetected = false; + } + + /* Get VIFC status */ + I165C_ReadDataWordImdInfo(I165C_DW3, &statusFlags, i165c_canRxMessage); + if (0u != (statusFlags & (1u << I165C_INSULATION_MEASUREMENT_STATUS_SHIFT))) { + /* Insulation measurement deactivated*/ + pTableInsulationMonitoring->isImdRunning = false; + } else { + pTableInsulationMonitoring->isImdRunning = true; + } + if (0u != (statusFlags & (1u << I165C_RESISTANCE_VALUE_OUTDATED_SHIFT))) { + /* Insulation resistance value outdated */ + pTableInsulationMonitoring->dfIsMeasurmentedUpToDate = false; + } else { + pTableInsulationMonitoring->dfIsMeasurmentedUpToDate = true; + } + if ((pTableInsulationMonitoring->areDeviceFlagsValid == true) && + (pTableInsulationMonitoring->isImdRunning == true) && + (pTableInsulationMonitoring->dfIsMeasurmentedUpToDate == true)) { + pTableInsulationMonitoring->isInsulationMeasurementValid = true; + } else { + pTableInsulationMonitoring->isInsulationMeasurementValid = false; + } + } + /* Restart measurement cycle */ + I165C_SetRunningState( + &i165c_runningState, I165C_FSM_STATE_RUNNING_READ_RESISTANCE, I165C_FSM_SHORT_TIME); + break; + + default: + /* invalid state */ + nextState = IMD_FSM_STATE_ERROR; + FAS_ASSERT(FAS_TRAP); + break; + } + } + return nextState; +} + +/** Disable state machine */ +static IMD_FSM_STATES_e I165C_Disable(void) { + IMD_FSM_STATES_e nextState = IMD_FSM_STATE_SHUTDOWN; /* stay in shutdown state */ + bool earlyExit = false; + + if (i165c_disableState.timer > 0u) { + if ((--i165c_disableState.timer) > 0u) { + i165c_disableState.triggerEntry--; + earlyExit = true; + } + } + + if (earlyExit == false) { + switch (i165c_disableState.currentState) { + case I165C_FSM_STATE_DISABLE_HAS_NEVER_RUN: + /* The I165C_Running state-machine, does not know when the + * disable command is received by the superimposed IMD state + * machine. Thus, the I165C_Running state machine needs to be + * reset at this point to correctly call the running state + * machine after re-enabling. */ + I165C_SetRunningState(&i165c_runningState, I165C_FSM_STATE_RUNNING_HAS_NEVER_RUN, I165C_FSM_SHORT_TIME); + + /* Request stop of measurement */ + I165C_SetMeasurementMode(I165C_DISABLE_MEASUREMENT); + I165C_SetDisableState( + &i165c_disableState, I165C_FSM_STATE_MEASUREMENT_STOPPED_WAIT_ACK, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_MEASUREMENT_STOPPED_WAIT_ACK: + if (I165C_CheckAcknowledgeArrived( + I165C_CMD_S_VIFC_CTL_MEASUREMENT, &i165c_disableState.receptionTries, &i165c_canRxMessage) == + true) { + I165C_SetDisableState( + &i165c_disableState, I165C_FSM_STATE_DISABLE_SET_HV_RELAY_STATE, I165C_FSM_SHORT_TIME); + } else { + /* Issue: 621 */ + } + break; + + case I165C_FSM_STATE_DISABLE_SET_HV_RELAY_STATE: + /* Open negative relay */ + I165C_SetRelayState(I165C_D_VIFC_HV_RELAIS_NEGATIVE, I165C_RELAY_STATE_OPEN); + /* Open positive relay */ + I165C_SetRelayState(I165C_D_VIFC_HV_RELAIS_POSITIVE, I165C_RELAY_STATE_OPEN); + I165C_SetDisableState( + &i165c_disableState, I165C_FSM_STATE_DISABLE_REQUEST_NEGATIVE_HV_RELAY_STATE, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_DISABLE_REQUEST_NEGATIVE_HV_RELAY_STATE: + I165C_RequestRelayState(I165C_D_VIFC_HV_RELAIS_NEGATIVE); + I165C_SetDisableState( + &i165c_disableState, I165C_FSM_STATE_DISABLE_CHECK_NEGATIVE_HV_RELAY_STATE, I165C_FSM_SHORT_TIME); + break; + + case I165C_FSM_STATE_DISABLE_CHECK_NEGATIVE_HV_RELAY_STATE: + if (I165C_CheckResponse(I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canRxMessage) == true) { + if (I165C_CheckRelayState( + i165c_canRxMessage, I165C_D_VIFC_HV_RELAIS_NEGATIVE, I165C_RELAY_STATE_OPEN) == true) { + i165c_disableState.receptionTries = 0u; + i165c_disableState.receptionTriesMessage = 0u; + + /* Request state of positive HV relay */ + I165C_RequestRelayState(I165C_D_VIFC_HV_RELAIS_POSITIVE); + I165C_SetDisableState( + &i165c_disableState, + I165C_FSM_STATE_DISABLE_CHECK_POSITIVE_HV_RELAY_STATE, + I165C_FSM_SHORT_TIME); + } else { + i165c_disableState.receptionTries++; + /* Issue: 621 */ + } + } else { + i165c_disableState.receptionTriesMessage++; + /* Issue: 621 */ + } + break; + + case I165C_FSM_STATE_DISABLE_CHECK_POSITIVE_HV_RELAY_STATE: + if (I165C_CheckResponse(I165C_CMD_S_VIFC_GET_HV_RELAIS, &i165c_canRxMessage) == true) { + if (I165C_CheckRelayState( + i165c_canRxMessage, I165C_D_VIFC_HV_RELAIS_POSITIVE, I165C_RELAY_STATE_OPEN) == true) { + i165c_disableState.receptionTries = 0u; + i165c_disableState.receptionTriesMessage = 0u; + + /* Reset disable state machine in case a another disabling is necessary */ + I165C_SetDisableState( + &i165c_disableState, I165C_FSM_STATE_DISABLE_HAS_NEVER_RUN, I165C_FSM_SHORT_TIME); + + /* IMD successfully disabled -> switch to next state in superimposed IMD state machine */ + nextState = IMD_FSM_STATE_IMD_ENABLE; + } else { + i165c_disableState.receptionTries++; + /* Issue: 621 */ + } + } else { + i165c_disableState.receptionTriesMessage++; + /* Issue: 621 */ + } + break; + } + } + return nextState; } /*========== Extern Function Implementations ================================*/ -extern void IMD_Trigger(void) { - I165C_Trigger(); +extern IMD_FSM_STATES_e IMD_ProcessInitializationState(void) { + return I165C_Initialize(); +} + +extern IMD_FSM_STATES_e IMD_ProcessEnableState(void) { + return I165C_Enable(); +} + +extern IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR); + return I165C_Running(pTableInsulationMonitoring); +} + +extern IMD_FSM_STATES_e IMD_ProcessShutdownState(void) { + return I165C_Disable(); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ @@ -584,8 +1504,8 @@ extern void TEST_I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *data, CAN extern void TEST_I165C_ReadDataByte(uint8_t dataByte, uint8_t *data, CAN_BUFFERELEMENT_s canMessage) { I165C_ReadDataByte(dataByte, data, canMessage); } -extern void TEST_I165C_WriteCmd(uint8_t id, uint8_t cmd, CAN_BUFFERELEMENT_s *canMessage) { - I165C_WriteCmd(id, cmd, canMessage); +extern void TEST_I165C_WriteCmd(uint8_t id, uint8_t command, CAN_BUFFERELEMENT_s *canMessage) { + I165C_WriteCmd(id, command, canMessage); } extern bool TEST_I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *canMessage) { return I165C_CheckResponse(command, canMessage); @@ -593,16 +1513,11 @@ extern bool TEST_I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *canMe extern bool TEST_I165C_GetImdInfo(CAN_BUFFERELEMENT_s *canMessage) { return I165C_GetImdInfo(canMessage); } -extern bool TEST_I165C_IsInitialized(CAN_BUFFERELEMENT_s canMessage) { - return I165C_IsInitialized(canMessage); +extern bool TEST_I165C_IsSelfTestFinished(CAN_BUFFERELEMENT_s canMessage) { + return I165C_IsSelfTestFinished(canMessage); } -extern void TEST_I165C_CheckAcknowledgeArrived( - uint8_t command, - I165C_STATE_e *currentState, - I165C_STATE_e nextState, - uint8_t *tries, - CAN_BUFFERELEMENT_s *canMessage) { - I165C_CheckAcknowledgeArrived(command, currentState, nextState, tries, canMessage); +extern bool TEST_I165C_CheckAcknowledgeArrived(uint8_t command, uint8_t *tries, CAN_BUFFERELEMENT_s *canMessage) { + return I165C_CheckAcknowledgeArrived(command, tries, canMessage); } #endif diff --git a/src/app/driver/imd/bender/iso165c/bender_iso165c.h b/src/app/driver/imd/bender/iso165c/bender_iso165c.h index 0bea8b0a..970e999b 100644 --- a/src/app/driver/imd/bender/iso165c/bender_iso165c.h +++ b/src/app/driver/imd/bender/iso165c/bender_iso165c.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bender_iso165c.h * @author foxBMS Team * @date 2019-04-07 (date of creation) - * @updated 2021-09-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix I165C * @@ -66,27 +67,6 @@ /*========== Macros and Definitions =========================================*/ -/** - * symbolic names for the different operating states Bender Isometer. - * Defined through the duty cycle of the measurement signal. - */ -typedef enum I165C_STATE { - I165C_STATE_UNINITIALIZED, - I165C_STATE_SELFTEST, - I165C_STATE_SELFTEST_WAIT_ACK, - I165C_STATE_WAIT_SELFTEST, - I165C_STATE_INITIALIZATION_FINISHED, - I165C_STATE_READ_RESISTANCE, - I165C_STATE_READ_RESISTANCE_WAIT_ACK, - I165C_STATE_UNLOCK, - I165C_STATE_UNLOCK_WAIT_ACK, - I165C_STATE_SET_ERROR_THRESHOLD, - I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK, - I165C_STATE_SET_WARNING_THRESHOLD, - I165C_STATE_SET_WARNING_THRESHOLD_WAIT_ACK, - I165C_STATE_GET_MEASUREMENT, -} I165C_STATE_e; - /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ @@ -98,16 +78,11 @@ extern void TEST_I165C_WriteDataWord(uint8_t dataWord, uint16_t data, CAN_BUFFER extern void TEST_I165C_ReadDataWord(uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage); extern void TEST_I165C_ReadDataWordImdInfo(uint8_t dataWord, uint16_t *data, CAN_BUFFERELEMENT_s canMessage); extern void TEST_I165C_ReadDataByte(uint8_t dataByte, uint8_t *data, CAN_BUFFERELEMENT_s canMessage); -extern void TEST_I165C_WriteCmd(uint8_t id, uint8_t cmd, CAN_BUFFERELEMENT_s *canMessage); +extern void TEST_I165C_WriteCmd(uint8_t id, uint8_t command, CAN_BUFFERELEMENT_s *canMessage); extern bool TEST_I165C_CheckResponse(uint8_t command, CAN_BUFFERELEMENT_s *canMessage); extern bool TEST_I165C_GetImdInfo(CAN_BUFFERELEMENT_s *canMessage); -extern bool TEST_I165C_IsInitialized(CAN_BUFFERELEMENT_s canMessage); -extern void TEST_I165C_CheckAcknowledgeArrived( - uint8_t command, - I165C_STATE_e *currentState, - I165C_STATE_e nextState, - uint8_t *tries, - CAN_BUFFERELEMENT_s *canMessage); +extern bool TEST_I165C_IsSelfTestFinished(CAN_BUFFERELEMENT_s canMessage); +extern bool TEST_I165C_CheckAcknowledgeArrived(uint8_t command, uint8_t *tries, CAN_BUFFERELEMENT_s *canMessage); #endif #endif /* FOXBMS__BENDER_ISO165C_H_ */ diff --git a/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.c b/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.c index 8717c154..c260e779 100644 --- a/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.c +++ b/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file bender_iso165c_cfg.c * @author foxBMS Team * @date 2021-03-17 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix I165C * diff --git a/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.h b/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.h index fc310d7c..f3b0f21c 100644 --- a/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.h +++ b/src/app/driver/imd/bender/iso165c/config/bender_iso165c_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,13 +43,18 @@ * @file bender_iso165c_cfg.h * @author foxBMS Team * @date 2021-03-17 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix I165C * * @brief Headers for the configuration for the insulation monitoring * + * Please see the manual and data sheet for detailed information about the + * specifications and defines used within this file. * + * docref: iso165C_C1_D00154_06_M_XXEN - 03/2021 - Manual + * docref: iso165Cx_D00154_04_D_XXEN - 03/2021 - Data sheet */ #ifndef FOXBMS__BENDER_ISO165C_CFG_H_ @@ -62,33 +67,49 @@ #include "imd.h" /* clang-format on */ -#include "battery_system_cfg.h" - -#include "can.h" -#include "os.h" +#include "can_cfg.h" /*========== Macros and Definitions =========================================*/ +/** CAN Node the IMD device is connected to */ +#define I165C_CAN_NODE (CAN1_NODE) + +/** Switch if bender iso165C or iso165C-1 is used + * true: iso165C + * false: iso165C-1 + */ +#define I165C_IS_165C_USED (false) + +/** Select if self-test scenario overall (I165C_SELF_TEST_LONG) or ParameterConfig + * self-test scenario (I165C_SELF_TEST_SHORT) shall be executed */ +#define I165C_SELF_TEST_LONG /** Measured resistance threshold under which a warning is issued by i165c */ -#define I165C_WARNING_THRESHOLD_KOHM (400u) +#define I165C_WARNING_THRESHOLD_kOhm IMD_WARNING_THRESHOLD_INSULATION_RESISTANCE_kOhm /** Measured resistance threshold under which an error is issued by i165c */ -#define I165C_ERROR_THRESHOLD_KOHM (250u) +#define I165C_ERROR_THRESHOLD_kOhm IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm -/** Number of attempts to get acknowledgement of message reception by i165c */ -#define I165C_TRANSMISSION_TRIES (3u) +#if ((I165C_WARNING_THRESHOLD_kOhm > 2000u) || (I165C_WARNING_THRESHOLD_kOhm < 40u)) +#error "Warning threshold outside of possible measurement 40-2000 kOhm" +#endif +#if ((I165C_ERROR_THRESHOLD_kOhm > 1000u) || (I165C_ERROR_THRESHOLD_kOhm < 30u)) +#error "Warning threshold outside of possible measurement 40-2000 kOhm" +#endif + +/** Measurement averaging factor */ +#define I165C_MEASUREMENT_AVERAGING_FACTOR (10u) /* Recommended value for EVs according to data sheet: 10 */ -/** Number of attempts to get IMD_Info message from iso165c */ -#define I165C_IMD_INFO_RECEIVE_TRIES (50u) +/** Number of attempts to get acknowledgement of message reception by i165c */ +#define I165C_TRANSMISSION_ATTEMPTS (3u) -/** Number of attempts to wait for iso165c initialization */ -#define I165C_INITIALIZATION_TRIES (5000u) +/** Number of attempts to receive the IMD_Info message from iso165c */ +#define I165C_IMD_INFO_RECEIVE_ATTEMPTS (50u) /** Max number of attempts to read CAN queue */ #define I165C_MAX_QUEUE_READS (5u) /** Maximum queue timeout time in milliseconds */ -#define I165C_QUEUE_TIMEOUT_MS ((TickType_t)0u) +#define I165C_QUEUE_TIMEOUT_ms ((TickType_t)0u) /** datsheet version: iso165C_D00154_03_M_XXEN/01.2019 */ @@ -130,25 +151,31 @@ /** trigger self test */ #define I165C_CMD_S_IMC_CTL_SELFTEST (0x21u) -#define I165C_D_IMC_SELFTEST_SCR_CTL_REQUEST I165C_DW1 -#define I165C_D_IMC_SELFTEST_SCR_CTL_RESPONSE I165C_DW1 +#define I165C_D_IMC_SELFTEST_SCR_CTL_REQUEST (I165C_DW1) +#define I165C_D_IMC_SELFTEST_SCR_CTL_RESPONSE (I165C_DW1) #define I165C_SELFTEST_SCENARIO_NO_ACTION (0u) #define I165C_SELFTEST_SCENARIO_OVERALL (1u) #define I165C_SELFTEST_SCENARIO_PARAMETERCONFIG (2u) /** reset I165C */ #define I165C_CMD_S_VIFC_CTL_IMC_RESET (0xC8u) + /** lock and unlock possibility to make changes to I165C */ #define I165C_CMD_S_VIFC_CTL_LOCK (0xCAu) -#define I165C_D_VIFC_LOCK_MODE_CTL_REQUEST I165C_DW1 -#define I165C_D_VIFC_LOCK_MODE_CTL_RESPONSE I165C_DW1 -#define I165C_D_VIFC_LOCK_PWD_CTL_REQUEST I165C_DW2 +#define I165C_D_VIFC_LOCK_MODE_CTL_REQUEST (I165C_DW1) +#define I165C_D_VIFC_LOCK_MODE_CTL_RESPONSE (I165C_DW1) +#define I165C_D_VIFC_LOCK_PWD_CTL_REQUEST (I165C_DW2) #define I165C_LOCKMODE_UNLOCKED (0u) #define I165C_LOCKMODE_LOCKED (1u) #define I165C_LOCKMODE_UNKNOWN (100u) -#define I165C_UNLOCK_PASSWD (0u) -#define I165C_LOCK_PASSWD (0xFFFFu) +#define I165C_UNLOCK_PASSWORD (0u) +#define I165C_LOCK_PASSWORD (0xFFFFu) + /** change measurement mode */ -#define I165C_CMD_S_VIFC_CTL_MEASUREMENT (0xCBu) +#define I165C_CMD_S_VIFC_CTL_MEASUREMENT (0xCBu) +#define I165C_DW_VIFC_CTL_MEASUREMENT_REQUEST (I165C_DW1) +#define I165C_DISABLE_MEASUREMENT (0u) +#define I165C_ENABLE_MEASUREMENT (1u) +#define I165C_MEASUREMENT_MODE_UNKNOWN (100u) /** * set commands (SET) @@ -160,22 +187,26 @@ /** set error threshold */ #define I165C_CMD_S_IMC_SET_R_ISO_ERR_THR (0x28u) -#define I165C_D_IMC_R_ISO_ERR_THR_SET_REQUEST I165C_DW1 -#define I165C_D_IMC_R_ISO_ERR_THR_SET_RESPONSE I165C_DW1 +#define I165C_D_IMC_R_ISO_ERR_THR_SET_REQUEST (I165C_DW1) +#define I165C_D_IMC_R_ISO_ERR_THR_SET_RESPONSE (I165C_DW1) /** set warning threshold */ #define I165C_CMD_S_IMC_SET_R_ISO_ERR_WRN (0x29u) -#define I165C_D_IMC_R_ISO_ERR_WRN_SET_REQUEST I165C_DW1 -#define I165C_D_IMC_R_ISO_ERR_WRN_SET_RESPONSE I165C_DW1 +#define I165C_D_IMC_R_ISO_ERR_WRN_SET_REQUEST (I165C_DW1) +#define I165C_D_IMC_R_ISO_ERR_WRN_SET_RESPONSE (I165C_DW1) /** set the mean factor of the insulation resistance averaging algorithm */ #define I165C_CMD_S_IMC_SET_MEAN_FACTOR (0x2Bu) -#define I165C_D_IMC_MEAN_FACTOR_SET_REQUEST I165C_DW1 -#define I165C_D_IMC_MEAN_FACTOR_SET_RESPONSE I165C_DW1 +#define I165C_D_IMC_MEAN_FACTOR_SET_REQUEST (I165C_DW1) +#define I165C_D_IMC_MEAN_FACTOR_SET_RESPONSE (I165C_DW1) /** change the state of the HV relays in the HV coupling network */ #define I165C_CMD_S_VIFC_SET_HV_RELAIS (0xD2u) -#define I165C_D_VIFC_HV_RELAIS_SET_REQUEST I165C_DW1 -#define I165C_D_VIFC_HV_RELAIS_STATE_SET_REQUEST I165C_DW2 -#define I165C_D_VIFC_HV_RELAIS_SET_RESPONSE I165C_DW1 -#define I165C_D_VIFC_HV_RELAIS_STATE_SET_RESPONSE I165C_DW2 +#define I165C_D_VIFC_HV_RELAIS_SET_REQUEST (I165C_DW1) +#define I165C_D_VIFC_HV_RELAIS_STATE_SET_REQUEST (I165C_DW2) +#define I165C_D_VIFC_HV_RELAIS_NEGATIVE (0u) +#define I165C_D_VIFC_HV_RELAIS_POSITIVE (1u) +#define I165C_D_VIFC_HV_RELAIS_SET_RESPONSE (I165C_DW1) +#define I165C_D_VIFC_HV_RELAIS_STATE_SET_RESPONSE (I165C_DW2) +#define I165C_RELAY_STATE_OPEN (0u) +#define I165C_RELAY_STATE_CLOSED (1u) /** * get commands (GET) @@ -187,93 +218,112 @@ /** dummy command (ping the I165C) */ #define I165C_CMD_S_VIFC_DUMMY (0x00u) -/** get internal status of the I165C */ -#define I165C_CMD_S_IMC_GET_STATUS (0x37u) -#define I165C_D_IMC_STATUS_GET_RESPONSE I165C_DW1 -#define I165C_INSULATION_FAULT (0u) -#define I165C_CHASSIS_FAULT (1u) -#define I165C_SYSTEM_FAILURE (2u) -#define I165C_CALIBRATION_RUNNING (3u) -#define I165C_SELFTEST_RUNNING (4u) -#define I165C_INSULATION_WARNING (5u) -#define I165C_D_IMC_STATUS_EXT_GET_RESPONSE I165C_DW2 -#define I165C_CALIBRATION_PARAMETER (0u) -#define I165C_HARDWARE_FAILURE (1u) -#define I165C_EEPROM_PARAMETER (2u) -#define I165C_FLASH_PARAMETER (3u) -#define I165C_RAM_PARAMETER (4u) -#define I165C_STACK_OVERFLOW (5u) -#define I165C_PARAMETER_VALUE (7u) -#define I165C_TEST_PULSEVOLTAGE_AREF (8u) -#define I165C_VOLTAGE_LEVEL_PLUS12V (9u) -#define I165C_VOLTAGE_LEVEL_MINUS12V (10u) -#define I165C_FUSE_BIT_VALID_INVALID (11u) -#define I165C_HV1_VOLTAGE (12u) -#define I165C_HV2_VOLTAGE (13u) -#define I165C_MANUFACTURER_STRING_VALID_INVALID (14u) + +/** get the D_IMC_STATUS internal status of the I165C */ +#define I165C_CMD_S_IMC_GET_STATUS (0x37u) +#define I165C_D_IMC_STATUS_GET_RESPONSE (I165C_DW1) +#define I165C_INSULATION_FAULT_SHIFT (0u) +#define I165C_CHASSIS_FAULT_SHIFT (1u) +#define I165C_SYSTEM_FAILURE_SHIFT (2u) +#define I165C_CALIBRATION_RUNNING_SHIFT (3u) +#define I165C_SELFTEST_RUNNING_SHIFT (4u) +#define I165C_INSULATION_WARNING_SHIFT (5u) + +/** get the D_IMC_STATUS_EXT device-internal IMC self-test results */ +#define I165C_D_IMC_STATUS_EXT_GET_RESPONSE (I165C_DW2) +#define I165C_CALIBRATION_PARAMETER_SHIFT (0u) +#define I165C_HARDWARE_FAILURE_SHIFT (1u) +#define I165C_EEPROM_PARAMETER_SHIFT (2u) +#define I165C_FLASH_PARAMETER_SHIFT (3u) +#define I165C_RAM_PARAMETER_SHIFT (4u) +#define I165C_STACK_OVERFLOW_SHIFT (5u) +#define I165C_PARAMETER_VALUE_SHIFT (7u) +#define I165C_TEST_PULSE_VOLTAGE_A_REF_SHIFT (8u) +#define I165C_VOLTAGE_LEVEL_PLUS12V_SHIFT (9u) +#define I165C_VOLTAGE_LEVEL_MINUS12V_SHIFT (10u) +#define I165C_FUSE_BIT_VALID_INVALID_SHIFT (11u) +#define I165C_HV1_VOLTAGE_SHIFT (12u) +#define I165C_HV2_VOLTAGE_SHIFT (13u) +#define I165C_MANUFACTURER_STRING_VALID_INVALID_SHIFT (14u) + /** get the insulation resistance */ #define I165C_CMD_S_IMC_GET_R_ISO (0x35u) -#define I165C_D_IMC_R_ISO_GET_RESPONSE I165C_DW1 -#define I165C_D_IMC_R_ISO_BIAS_GET_RESPONSE I165C_DB3 -#define I165C_D_IMC_R_ISO_CNT_GET_RESPONSE I165C_DB4 +#define I165C_D_IMC_R_ISO_GET_RESPONSE (I165C_DW1) +#define I165C_D_IMC_R_ISO_BIAS_GET_RESPONSE (I165C_DB1) +#define I165C_BIAS_TO_HV_MINUS (1u) +#define I165C_BIAS_TO_HV_PLUS (2u) +#define I165C_D_IMC_R_ISO_CNT_GET_RESPONSE (I165C_DB2) + /** get error threshold */ #define I165C_CMD_S_IMC_GET_R_ISO_ERR_THR (0x32u) -#define I165C_D_IMC_R_ISO_ERR_THR_GET_RESPONSE I165C_DW1 +#define I165C_D_IMC_R_ISO_ERR_THR_GET_RESPONSE (I165C_DW1) + /** get warning threshold */ #define I165C_CMD_S_IMC_GET_R_ISO_WRN_THR (0x39u) -#define I165C_D_IMC_R_ISO_WRN_THR_GET_RESPONSE I165C_DW1 +#define I165C_D_IMC_R_ISO_WRN_THR_GET_RESPONSE (I165C_DW1) + /** get mean factor */ #define I165C_CMD_S_IMC_GET_MEAN_FACTOR (0x3Cu) -#define I165C_D_IMC_MEAN_FACTOR_GET_RESPONSE I165C_DW1 +#define I165C_D_IMC_MEAN_FACTOR_GET_RESPONSE (I165C_DW1) + /** get HV1, HV value between HV1_POS and HV1_NEG */ #define I165C_CMD_S_IMC_GET_HV_1 (0x36u) -#define I165C_D_IMC_HV_1_GET_RESPONSE I165C_DW1 +#define I165C_D_IMC_HV_1_GET_RESPONSE (I165C_DW1) + /** get HV2, HV value between HV2_POS and HV2_NEG */ #define I165C_CMD_S_IMC_GET_HV_2 (0x3Au) -#define I165C_D_IMC_HV_2_GET_RESPONSE I165C_DW1 +#define I165C_D_IMC_HV_2_GET_RESPONSE (I165C_DW1) + /** get software version of the IMC */ #define I165C_CMD_S_IMC_GET_VERSION (0x33u) -#define I165C_D_IMC_VERSION_INDEX_GET_REQUEST I165C_DW1 +#define I165C_D_IMC_VERSION_INDEX_GET_REQUEST (I165C_DW1) #define I165C_IMC_BOOTLOADER (0u) #define I165C_IMC_FIRMWARE (1u) #define I165C_IMC_FIRMWARE_ID (2u) #define I165C_IMC_FIRMWARE_HASH (3u) -#define I165C_D_IMC_VERSION_INDEX_GET_RESPONSE I165C_DW1 -#define I165C_D_IMC_VERSION_GET_RESPONSE I165C_DW2 +#define I165C_D_IMC_VERSION_INDEX_GET_RESPONSE (I165C_DW1) +#define I165C_D_IMC_VERSION_GET_RESPONSE (I165C_DW2) + /** get insulation monitoring counter value */ #define I165C_CMD_S_IMC_GET_TEST_CNT (0x5Au) -#define I165C_D_IMC_TEST_CNT_GET_RESPONSE I165C_DW1 +#define I165C_D_IMC_TEST_CNT_GET_RESPONSE (I165C_DW1) + /** get manufacturer information */ #define I165C_CMD_S_IMC_GET_MANUFACTURER (0x3Du) -#define I165C_D_IMC_MANUFACT_INDEX_GET_REQUEST I165C_DW1 -#define I165C_D_IMC_MANUFACT_INDEX_GET_RESPONSE I165C_DW1 -#define I165C_D_IMC_MANUFACT_DATA_GET_RESPONSE I165C_DW2 -/** get internal status of the VIFC */ -#define I165C_CMD_S_VIFC_GET_STATUS (0xDCu) -#define I165C_D_VIFC_STATUS_GET_RESPONSE I165C_DW1 -#define I165C_INSULATION_MEASUREMENT (0u) -#define I165C_IMC_CONNECTIVITY (1u) -#define I165C_IMC_ALIVE_STATUS_DETECTION (2u) -#define I165C_VIFC_COMMAND (4u) -#define I165C_INSULATION_RESISTANCE_VALUE (8u) -#define I165C_IMC_SELFTEST_OVERALL_SCENARIO (12u) -#define I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO (13u) +#define I165C_D_IMC_MANUFACT_INDEX_GET_REQUEST (I165C_DW1) +#define I165C_D_IMC_MANUFACT_INDEX_GET_RESPONSE (I165C_DW1) +#define I165C_D_IMC_MANUFACT_DATA_GET_RESPONSE (I165C_DW2) + +/** get internal status of the D_VIFC_STATUS */ +#define I165C_CMD_S_VIFC_GET_STATUS (0xDCu) +#define I165C_D_VIFC_STATUS_GET_RESPONSE (I165C_DW1) +#define I165C_INSULATION_MEASUREMENT_STATUS_SHIFT (0u) +#define I165C_IMC_CONNECTIVITY_SHIFT (1u) +#define I165C_IMC_ALIVE_STATUS_DETECTION_SHIFT (2u) +#define I165C_VIFC_COMMAND_SHIFT (4u) +#define I165C_RESISTANCE_VALUE_OUTDATED_SHIFT (8u) +#define I165C_IMC_SELFTEST_OVERALL_SCENARIO_SHIFT (12u) +#define I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO_SHIFT (13u) + /** get state of the HV relays in the HV coupling network */ #define I165C_CMD_S_VIFC_GET_HV_RELAIS (0xDDu) -#define I165C_D_VIFC_HV_RELAIS_GET_REQUEST I165C_DW1 -#define I165C_D_VIFC_HV_RELAIS_GET_RESPONSE I165C_DW1 -#define I165C_D_VIFC_HV_RELAIS_STATE_GET_RESPONSE I165C_DW2 +#define I165C_D_VIFC_HV_RELAIS_GET_REQUEST (I165C_DW1) +#define I165C_D_VIFC_HV_RELAIS_GET_RESPONSE (I165C_DW1) +#define I165C_D_VIFC_HV_RELAIS_STATE_GET_RESPONSE (I165C_DW2) + /** get "Alive" state of the IMC */ #define I165C_CMD_S_VIFC_GET_IMC_ALIVE (0xE2u) -#define I165C_D_VIFC_IMC_ALIVE_GET_RESPONSE I165C_DW1 +#define I165C_D_VIFC_IMC_ALIVE_GET_RESPONSE (I165C_DW1) + /** get software version of the VIFC */ #define I165C_CMD_S_VIFC_GET_VERSION (0xDEu) -#define I165C_D_IMC_VERSION_INDEX_GET_REQUEST I165C_DW1 -#define I165C_D_VIFC_VERSION_INDEX_GET_RESPONSE I165C_DW1 -#define I165C_D_VIFC_VERSION_GET_RESPONSE I165C_DW2 +#define I165C_D_IMC_VERSION_INDEX_GET_REQUEST (I165C_DW1) +#define I165C_D_VIFC_VERSION_INDEX_GET_RESPONSE (I165C_DW1) +#define I165C_D_VIFC_VERSION_GET_RESPONSE (I165C_DW2) + /** get locking state of the iso165C */ #define I165C_CMD_S_VIFC_GET_LOCK (0xE0u) -#define I165C_D_VIFC_LOCK_MODE_GET_RESPONSE I165C_DW1 +#define I165C_D_VIFC_LOCK_MODE_GET_RESPONSE (I165C_DW1) /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/driver/imd/bender/iso165c/wscript b/src/app/driver/imd/bender/iso165c/wscript index 94c2afb8..5a6eea3f 100644 --- a/src/app/driver/imd/bender/iso165c/wscript +++ b/src/app/driver/imd/bender/iso165c/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -56,8 +56,10 @@ def build(bld): os.path.join("..", ".."), os.path.join("config"), os.path.join("..", "..", "..", "can"), + os.path.join("..", "..", "..", "can", "cbs"), os.path.join("..", "..", "..", "config"), os.path.join("..", "..", "..", "..", "application", "config"), + os.path.join("..", "..", "..", "..", "driver", "mcu"), os.path.join("..", "..", "..", "..", "engine", "config"), os.path.join("..", "..", "..", "..", "engine", "database"), os.path.join("..", "..", "..", "..", "main", "include"), @@ -66,9 +68,12 @@ def build(bld): os.path.join("..", "..", "..", "..", "task", "ftask"), ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) + cflags = bld.env.CFLAGS_FOXBMS bld( features="c", source=source, + use="imd-device", includes=includes, target=f"{bld.env.APPNAME}-imd", + cflags=cflags, ) diff --git a/src/app/driver/imd/bender/wscript b/src/app/driver/imd/bender/wscript index a83be206..d5d3247e 100644 --- a/src/app/driver/imd/bender/wscript +++ b/src/app/driver/imd/bender/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/app/driver/imd/imd.c b/src/app/driver/imd/imd.c new file mode 100644 index 00000000..48b2d4a4 --- /dev/null +++ b/src/app/driver/imd/imd.c @@ -0,0 +1,551 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file imd.c + * @author foxBMS Team + * @date 2021-11-04 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup DRIVERS + * @prefix IMD + * + * @brief Main driver state machine for insulation monitoring driver + * + * @details This superimposed state machine initializes, enables and disables + * the selected Insulation Monitoring Device. Furthermore, the + * measurement results are evaluated and saved in the database. + * Requests are used to control the IMD state machine and with that + * the behavior of the IMDs. + */ + +/*========== Includes =======================================================*/ +#include "imd.h" + +#include "diag.h" +#include "os.h" + +/*========== Macros and Definitions =========================================*/ + +/** + * statemachine short time definition in #IMD_Trigger calls until next state is + * processed + */ +#define IMD_FSM_SHORT_TIME (1u) + +/** Substates of the state machine */ +typedef enum { + IMD_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */ + IMD_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */ + IMD_FSM_SUBSTATE_INITIALIZATION_0, /*!< fist initialization substate */ + IMD_FSM_SUBSTATE_INITIALIZATION_1, /*!< second initialization substate */ + IMD_FSM_SUBSTATE_INITIALIZATION_EXIT, /*!< last initialization substate */ + IMD_FSM_SUBSTATE_RUNNING_0, /*!< fist running substate */ + IMD_FSM_SUBSTATE_RUNNING_1, /*!< second running substate */ + IMD_FSM_SUBSTATE_RUNNING_2, /*!< third running substate */ +} IMD_FSM_SUBSTATES_e; + +/** Symbolic names to check for multiple calls of #IMD_Trigger */ +typedef enum { + IMD_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */ + IMD_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */ +} IMD_CHECK_MULTIPLE_CALLS_e; + +/** some struct with some information */ +typedef struct { + bool isStatemachineInitialized; /*!< true if initialized, otherwise false */ + bool switchImdDeviceOn; /*!< true if enabling process is ongoing */ +} IMD_INFORMATION_s; + +/** This struct describes the state of the monitoring instance */ +typedef struct { + uint8_t counter; /*!< general purpose counter */ + uint16_t timer; /*!< timer of the state */ + uint8_t triggerEntry; /*!< trigger entry of the state */ + IMD_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */ + IMD_FSM_STATES_e nextState; /*!< next state of the FSM */ + IMD_FSM_STATES_e currentState; /*!< current state of the FSM */ + IMD_FSM_STATES_e previousState; /*!< previous state of the FSM */ + IMD_FSM_SUBSTATES_e nextSubstate; /*!< next substate of the FSM */ + IMD_FSM_SUBSTATES_e currentSubstate; /*!< current substate of the FSM */ + IMD_FSM_SUBSTATES_e previousSubstate; /*!< previous substate of the FSM */ + IMD_INFORMATION_s information; /*!< Some information to be stored */ + DATA_BLOCK_INSULATION_MONITORING_s *pTableImd; /*!< Pointer to IMD database entry */ +} IMD_STATE_s; + +/*========== Static Constant and Variable Definitions =======================*/ +static DATA_BLOCK_INSULATION_MONITORING_s imd_tableInsulationMonitoring = { + .header.uniqueId = DATA_BLOCK_ID_INSULATION_MONITORING}; + +static IMD_STATE_s imd_state = { + .timer = 0u, + .triggerEntry = 0u, + .nextState = IMD_FSM_STATE_DUMMY, + .stateRequest = IMD_STATE_NO_REQUEST, + .currentState = IMD_FSM_STATE_HAS_NEVER_RUN, + .previousState = IMD_FSM_STATE_DUMMY, + .nextSubstate = IMD_FSM_SUBSTATE_DUMMY, + .currentSubstate = IMD_FSM_SUBSTATE_DUMMY, + .previousSubstate = IMD_FSM_SUBSTATE_DUMMY, + .information.isStatemachineInitialized = false, + .information.switchImdDeviceOn = false, + .pTableImd = &imd_tableInsulationMonitoring, +}; + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ +/** + * @brief sets the current state request of the state variable #imd_state. + * @details This function is used to make a state request to the state machine, + * e.g, initialize state machine or shut-down state machine. + * It calls #IMD_CheckStateRequest() to check if the request is valid. + * The state request is rejected if is not valid. The result of the + * check is returned immediately, so that the requester can act in + * case it made a non-valid state request. + * @param[in] stateRequest state request to set + * @param[in,out] pImdState pointer to state variable of IMD state machine + * @return OK if request has been accepted, otherwise error reason + */ +static IMD_RETURN_TYPE_e IMD_SetStateRequest(IMD_STATE_s *pImdState, IMD_STATE_REQUEST_e stateRequest); + +/** + * @brief checks the state requests that are made. + * @details This function checks the validity of the state requests. The + * results of the checked staterequest is returned immediately. + * @param[in] stateRequest state request to be checked + * @param[in,out] pImdState pointer to state variable of IMD state machine + * @return result of the state request that was made + */ +static IMD_RETURN_TYPE_e IMD_CheckStateRequest(IMD_STATE_s *pImdState, IMD_STATE_REQUEST_e stateRequest); + +/** + * @brief transfers the current state request to the state machine. + * @details This function takes the current state request from #imd_state + * transfers it to the state machine. It resets the value from + * #imd_state to #IMD_STATE_NO_REQUEST + * @param[in,out] pImdState pointer to state variable of IMD state machine + * @return current state request + */ +static IMD_STATE_REQUEST_e IMD_TransferStateRequest(IMD_STATE_s *pImdState); + +/** + * @brief check for multiple calls of state machine trigger function + * @details The trigger function is not reentrant, which means it cannot + * be called multiple times. This functions increments the + * triggerEntry counter once and must be called each time the + * trigger function is called. If triggerEntry is greater than + * one, there were multiple calls. For this function to work, + * triggerEntry must be decremented each time the trigger function + * is called, even if no processing do because the timer is + * non-zero. + * @param[in,out] pImdState pointer to state variable of IMD state machine + * @return #IMD_MULTIPLE_CALLS_YES if there were multiple calls, + * #IMD_MULTIPLE_CALLS_NO otherwise + */ +static IMD_CHECK_MULTIPLE_CALLS_e IMD_CheckMultipleCalls(IMD_STATE_s *pImdState); + +/** + * @brief Sets the next state, the next substate and the timer value + * of the state variable. + * @param[in,out] pImdState state of the example state machine + * @param[in] nextState state to be transferred into + * @param[in] nextSubstate substate to be transferred into + * @param[in] idleTime wait time for the state machine + */ +static void IMD_SetState( + IMD_STATE_s *pImdState, + IMD_FSM_STATES_e nextState, + IMD_FSM_SUBSTATES_e nextSubstate, + uint16_t idleTime); + +/** + * @brief Sets the next substate and the timer value + * of the state variable. + * @param[in,out] pImdState state of the example state machine + * @param[in] nextSubstate substate to be transferred into + * @param[in] idleTime wait time for the state machine + */ +static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime); + +/** + * @brief Defines the state transitions + * @details This function contains the implementation of the state + * machine, i.e., the sequence of states and substates. + * It is called by the trigger function every time + * the state machine timer has a non-zero value. + * @param[in,out] pImdState state of the example state machine + * @return Always #STD_OK + */ +static STD_RETURN_TYPE_e IMD_RunStateMachine(IMD_STATE_s *pImdState); + +/** + * @brief Evaluates measurement perform by IMD driver + * @details This function evaluates the insulation measurement performed by the + * selected IMD driver and updates the database entry. + * @param[in,out] pTableInsulationMonitoring pointer to insulation monitoring + * database entry + * @return Always #IMD_REQUEST_OK + */ +static STD_RETURN_TYPE_e IMD_EvaluateInsulationMeasurement( + DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring); + +/*========== Static Function Implementations ================================*/ +static IMD_RETURN_TYPE_e IMD_SetStateRequest(IMD_STATE_s *pImdState, IMD_STATE_REQUEST_e stateRequest) { + FAS_ASSERT(pImdState != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */ + IMD_RETURN_TYPE_e retVal = IMD_REQUEST_OK; + + OS_EnterTaskCritical(); + retVal = IMD_CheckStateRequest(pImdState, stateRequest); + + if (retVal == IMD_REQUEST_OK) { + pImdState->stateRequest = stateRequest; + } + OS_ExitTaskCritical(); + + return retVal; +} + +static IMD_RETURN_TYPE_e IMD_CheckStateRequest(IMD_STATE_s *pImdState, IMD_STATE_REQUEST_e stateRequest) { + FAS_ASSERT(pImdState != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: stateRequest: parameter accepts whole range */ + IMD_RETURN_TYPE_e retval = IMD_REQUEST_PENDING; + if (pImdState->stateRequest == IMD_STATE_NO_REQUEST) { + /* init only allowed from the uninitialized state */ + if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) { + if (pImdState->currentState == IMD_FSM_STATE_UNINITIALIZED) { + retval = IMD_REQUEST_OK; + } else { + retval = IMD_ALREADY_INITIALIZED; + } + } else if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) { + if (pImdState->currentState == IMD_FSM_STATE_SHUTDOWN) { + retval = IMD_REQUEST_OK; + } else if (pImdState->currentState == IMD_FSM_STATE_IMD_ENABLE) { + retval = IMD_REQUEST_OK; + } else { + retval = IMD_ILLEGAL_REQUEST; + } + } else { + retval = IMD_ILLEGAL_REQUEST; + } + } else { + /* Request pending */ + } + return retval; +} + +static IMD_STATE_REQUEST_e IMD_TransferStateRequest(IMD_STATE_s *pImdState) { + FAS_ASSERT(pImdState != NULL_PTR); + OS_EnterTaskCritical(); + IMD_STATE_REQUEST_e retval = pImdState->stateRequest; + pImdState->stateRequest = IMD_STATE_NO_REQUEST; + OS_ExitTaskCritical(); + return retval; +} + +static IMD_CHECK_MULTIPLE_CALLS_e IMD_CheckMultipleCalls(IMD_STATE_s *pImdState) { + FAS_ASSERT(pImdState != NULL_PTR); + IMD_CHECK_MULTIPLE_CALLS_e multipleCalls = IMD_MULTIPLE_CALLS_NO; + OS_EnterTaskCritical(); + if (pImdState->triggerEntry == 0u) { + pImdState->triggerEntry++; + } else { + multipleCalls = IMD_MULTIPLE_CALLS_YES; /* multiple call of function IMD_Trigger for instance pImdState */ + } + OS_ExitTaskCritical(); + return multipleCalls; +} + +static void IMD_SetState( + IMD_STATE_s *pImdState, + IMD_FSM_STATES_e nextState, + IMD_FSM_SUBSTATES_e nextSubstate, + uint16_t idleTime) { + FAS_ASSERT(pImdState != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: nextState: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */ + bool earlyExit = false; + + pImdState->timer = idleTime; + + if ((pImdState->currentState == nextState) && (pImdState->currentSubstate == nextSubstate)) { + /* Next state and next substate equal to current state and substate: nothing to do */ + pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transistion required -> reset */ + pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */ + earlyExit = true; + } + + if (earlyExit == false) { + if (pImdState->currentState != nextState) { + /* Next state is different: switch to it and set substate to entry value */ + pImdState->previousState = pImdState->currentState; + pImdState->currentState = nextState; + pImdState->previousSubstate = pImdState->currentSubstate; + pImdState->currentSubstate = IMD_FSM_SUBSTATE_ENTRY; /* Use entry state after a top level state change */ + pImdState->nextState = IMD_FSM_STATE_DUMMY; /* no state transistion required -> reset */ + pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* no substate transistion required -> reset */ + } else if (pImdState->currentSubstate != nextSubstate) { + /* Only the next substate is different, switch to it */ + IMD_SetSubstate(pImdState, nextSubstate, idleTime); + } else { + ; + } + } +} + +static void IMD_SetSubstate(IMD_STATE_s *pImdState, IMD_FSM_SUBSTATES_e nextSubstate, uint16_t idleTime) { + FAS_ASSERT(pImdState != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: nextSubstate: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: idleTime: parameter accepts whole range */ + pImdState->timer = idleTime; + pImdState->previousSubstate = pImdState->currentSubstate; + pImdState->currentSubstate = nextSubstate; + pImdState->nextSubstate = IMD_FSM_SUBSTATE_DUMMY; /* substate has been set, now reset value for nextSubstate */ +} + +static STD_RETURN_TYPE_e IMD_RunStateMachine(IMD_STATE_s *pImdState) { + FAS_ASSERT(pImdState != NULL_PTR); + STD_RETURN_TYPE_e ranStateMachine = STD_OK; + IMD_FSM_STATES_e nextState = IMD_FSM_STATE_DUMMY; + IMD_STATE_REQUEST_e stateRequest = IMD_STATE_NO_REQUEST; + switch (pImdState->currentState) { + /********************************************** STATE: HAS NEVER RUN */ + case IMD_FSM_STATE_HAS_NEVER_RUN: + /* Nothing to do, just transfer */ + IMD_SetState(pImdState, IMD_FSM_STATE_UNINITIALIZED, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + break; + + /********************************************** STATE: UNINITIALIZED */ + case IMD_FSM_STATE_UNINITIALIZED: + /* Transition to initialization state, one the state request has been received */ + stateRequest = IMD_TransferStateRequest(pImdState); + if (stateRequest == IMD_STATE_INITIALIZE_REQUEST) { + IMD_SetState(pImdState, IMD_FSM_STATE_INITIALIZATION, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else { + /* Do nothing. Stay in state. */ + } + break; + + /********************************************* STATE: INITIALIZATION */ + case IMD_FSM_STATE_INITIALIZATION: + nextState = IMD_ProcessInitializationState(); + if (nextState == IMD_FSM_STATE_INITIALIZATION) { + /* staying in state, processed by state function */ + } else if (nextState == IMD_FSM_STATE_ERROR) { + IMD_SetState(pImdState, IMD_FSM_STATE_ERROR, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else if (nextState == IMD_FSM_STATE_IMD_ENABLE) { + pImdState->information.isStatemachineInitialized = true; + IMD_SetState(pImdState, IMD_FSM_STATE_IMD_ENABLE, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else { + FAS_ASSERT(FAS_TRAP); /* Something went wrong */ + } + break; + + case IMD_FSM_STATE_IMD_ENABLE: + /* Transition to running state, once the state request has been received */ + stateRequest = IMD_TransferStateRequest(pImdState); + if (stateRequest == IMD_STATE_SWITCH_ON_REQUEST) { + pImdState->information.switchImdDeviceOn = true; + } + if (pImdState->information.switchImdDeviceOn == true) { + nextState = IMD_ProcessEnableState(); + if (nextState == IMD_FSM_STATE_RUNNING) { + /* Set flag that IMD is running. Do not update the database entry here. The database entry will be + * updated after first successful measurement in IMD_FSM_STATE_RUNNING state */ + pImdState->pTableImd->isImdRunning = true; + pImdState->information.switchImdDeviceOn = false; + IMD_SetState(pImdState, IMD_FSM_STATE_RUNNING, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else if (nextState == IMD_FSM_STATE_ERROR) { + IMD_SetState(pImdState, IMD_FSM_STATE_ERROR, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else { + /* Do nothing as the process to activate the IMD device is ongoing */ + } + } else { + /* Do nothing. Stay in state. */ + } + break; + + /**************************************************** STATE: RUNNING */ + case IMD_FSM_STATE_RUNNING: + stateRequest = IMD_TransferStateRequest(pImdState); + if (stateRequest == IMD_STATE_SHUTDOWN_REQUEST) { + IMD_SetState(pImdState, IMD_FSM_STATE_SHUTDOWN, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else { + nextState = IMD_ProcessRunningState(pImdState->pTableImd); + /* Evaluate measurement results */ + IMD_EvaluateInsulationMeasurement(pImdState->pTableImd); + if (nextState == IMD_FSM_STATE_RUNNING) { + /* staying in state, processed by state function */ + } else { + IMD_SetState(pImdState, IMD_FSM_STATE_ERROR, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } + } + break; + + case IMD_FSM_STATE_SHUTDOWN: + nextState = IMD_ProcessShutdownState(); + if (nextState == IMD_FSM_STATE_IMD_ENABLE) { + /* Set flag, that IMD is deactivated. Update database entry */ + pImdState->pTableImd->isImdRunning = false; + (void)DATA_WRITE_DATA(&imd_tableInsulationMonitoring); + IMD_SetState(pImdState, IMD_FSM_STATE_IMD_ENABLE, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else if (nextState == IMD_FSM_STATE_ERROR) { + IMD_SetState(pImdState, IMD_FSM_STATE_ERROR, IMD_FSM_SUBSTATE_ENTRY, IMD_FSM_SHORT_TIME); + } else { + /* staying in state, processed by state function */ + } + break; + + /****************************************************** STATE: ERROR */ + case IMD_FSM_STATE_ERROR: + /* Issue: 621 */ + FAS_ASSERT(FAS_TRAP); + break; + + /**************************************************** STATE: DEFAULT */ + default: + /* all cases must be processed, trap if unknown state arrives */ + FAS_ASSERT(FAS_TRAP); + break; + } + /* Increment general purpose counter */ + pImdState->counter++; + return ranStateMachine; +} + +static STD_RETURN_TYPE_e IMD_EvaluateInsulationMeasurement( + DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR); + /* Assume resistance value as good if no valid measurement values are detected */ + bool lowResistanceDetected = false; + + /* Check if measured resistance value is valid */ + if (pTableInsulationMonitoring->isInsulationMeasurementValid == true) { + (void)DIAG_Handler(DIAG_ID_INSULATION_MEASUREMENT_VALID, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); + if (pTableInsulationMonitoring->insulationResistance_kOhm < IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm) { + lowResistanceDetected = true; + } + } else { + (void)DIAG_Handler(DIAG_ID_INSULATION_MEASUREMENT_VALID, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); + } + + /* Check if flags of IMD are valid, e.g. status pin */ + if (pTableInsulationMonitoring->areDeviceFlagsValid == true) { + if (pTableInsulationMonitoring->dfIsCriticalResistanceDetected == true) { + lowResistanceDetected = true; + } + if (pTableInsulationMonitoring->dfIsChassisFaultDetected == true) { + (void)DIAG_Handler(DIAG_ID_INSULATION_GROUND_ERROR, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); + } else { + (void)DIAG_Handler(DIAG_ID_INSULATION_GROUND_ERROR, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); + } + } + + /* Set diagnosis entry depending on measured insulation resistance and critical threshold flag */ + if (lowResistanceDetected == true) { + (void)DIAG_Handler(DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); + } else { + (void)DIAG_Handler(DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); + } + + /* Set warning threshold flag depending on flag */ + if (pTableInsulationMonitoring->dfIsWarnableResistanceDetected == true) { + (void)DIAG_Handler(DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); + } else { + (void)DIAG_Handler(DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); + } + + /* Write database entry */ + DATA_WRITE_DATA(pTableInsulationMonitoring); + + /* Issue: 621 */ + + return STD_OK; +} + +/*========== Extern Function Implementations ================================*/ +extern IMD_RETURN_TYPE_e IMD_RequestInitialization(void) { + return IMD_SetStateRequest(&imd_state, IMD_STATE_INITIALIZE_REQUEST); +} + +extern IMD_RETURN_TYPE_e IMD_RequestInsulationMeasurement(void) { + return IMD_SetStateRequest(&imd_state, IMD_STATE_SWITCH_ON_REQUEST); +} + +extern IMD_RETURN_TYPE_e IMD_RequestMeasurementStop(void) { + return IMD_SetStateRequest(&imd_state, IMD_STATE_SHUTDOWN_REQUEST); +} + +extern bool IMD_GetInitializationState(void) { + return imd_state.information.isStatemachineInitialized; +} + +extern STD_RETURN_TYPE_e IMD_Trigger(void) { + bool earlyExit = false; + STD_RETURN_TYPE_e returnValue = STD_OK; + + /* Check multiple calls of function */ + if (IMD_MULTIPLE_CALLS_YES == IMD_CheckMultipleCalls(&imd_state)) { + returnValue = STD_NOT_OK; + earlyExit = true; + } + + if (earlyExit == false) { + if (imd_state.timer > 0u) { + if ((--imd_state.timer) > 0u) { + imd_state.triggerEntry--; + returnValue = STD_OK; + earlyExit = true; + } + } + } + + if (earlyExit == false) { + IMD_RunStateMachine(&imd_state); + imd_state.triggerEntry--; + } + return returnValue; +} + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/imd/imd.h b/src/app/driver/imd/imd.h index 8816071b..55206478 100644 --- a/src/app/driver/imd/imd.h +++ b/src/app/driver/imd/imd.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file imd.h * @author foxBMS Team * @date 2020-11-20 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix IMD * @@ -58,21 +59,132 @@ #include "general.h" #include "can_cfg.h" +#include "ftask_cfg.h" -#include "os.h" +#include "database.h" /*========== Macros and Definitions =========================================*/ +#define IMD_PERIODIC_CALL_TIME_ms (FTSK_TASK_CYCLIC_100MS_CYCLE_TIME) + +/** Minimum required insulation resistance - Error threshold */ +#define IMD_ERROR_THRESHOLD_INSULATION_RESISTANCE_kOhm (500u) + +/** Minimum required insulation resistance - Warning threshold */ +#define IMD_WARNING_THRESHOLD_INSULATION_RESISTANCE_kOhm (750u) + +/** Possible return values when state requests are made to the IMD statemachine */ +typedef enum { + IMD_REQUEST_OK, /*!< request was successful */ + IMD_REQUEST_PENDING, /*!< requested to be executed */ + IMD_ILLEGAL_REQUEST, /*!< Request can not be executed */ + IMD_ALREADY_INITIALIZED, /*!< IMD statemachine already initialized */ +} IMD_RETURN_TYPE_e; + +/** State requests for the IMD statemachine */ +typedef enum { + IMD_STATE_INITIALIZE_REQUEST, /*!< request for initialization */ + IMD_STATE_SWITCH_ON_REQUEST, /*!< request to switch on IMD device */ + IMD_STATE_SHUTDOWN_REQUEST, /*!< request for shut down */ + IMD_STATE_NO_REQUEST, /*!< dummy request for no request */ +} IMD_STATE_REQUEST_e; + +/** States of the state machine */ +typedef enum { + IMD_FSM_STATE_DUMMY, /*!< dummy state - always the first state */ + IMD_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */ + IMD_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */ + IMD_FSM_STATE_INITIALIZATION, /*!< initializing the state machine */ + IMD_FSM_STATE_IMD_ENABLE, /*!< switch on IMD */ + IMD_FSM_STATE_SHUTDOWN, /*!< shut down state of IMD state machine */ + IMD_FSM_STATE_RUNNING, /*!< operational mode of the state machine */ + IMD_FSM_STATE_ERROR, /*!< state for error processing */ +} IMD_FSM_STATES_e; /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ +/** + * @brief Request initialization of IMD statemachine + * @return Always #IMD_REQUEST_OK + */ +extern IMD_RETURN_TYPE_e IMD_RequestInitialization(void); + +/** + * @brief Request to activate the actual IMD measurement + * @return Always #IMD_REQUEST_OK + */ +extern IMD_RETURN_TYPE_e IMD_RequestInsulationMeasurement(void); + +/** + * @brief Request to deactivate the actual IMD measurement + * @return Always #IMD_REQUEST_OK + */ +extern IMD_RETURN_TYPE_e IMD_RequestMeasurementStop(void); + +/** + * @brief Gets the initialization state. + * @details This function is used for getting the IMD initialization state. + * @return true if statemachine initialized, otherwise false + */ +extern bool IMD_GetInitializationState(void); /** * @brief trigger function for the IMD driver state machine. * @details This function contains the sequence of events in the IMD state * machine. It must be called time-triggered, every 100ms. + * @returns returns #STD_OK if trigger called successfully + */ +extern STD_RETURN_TYPE_e IMD_Trigger(void); + +/**************************************************** FOLLOWING FUNCTIONS NEED TO BE IMPLEMENTED BY THE IMD DRIVER */ +/* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE imd-documentation */ +/** + * @brief Processes the initialization state + * @details This function needs to be implemented in the dedicated driver. This + * function initializes the required SW modules and peripherals but + * does not start the actual IMD measurement. + * @return #IMD_FSM_STATE_INITIALIZATION if initialization not fininished and + * another call is required. #IMD_FSM_STATE_IMD_ENABLE if + * initialization is finished and #IMD_FSM_STATE_ERROR if an error is + * detected that prohibits a working IMD driver. + */ +extern IMD_FSM_STATES_e IMD_ProcessInitializationState(void); + +/** + * @brief Processes the IMD enable state + * @details This function needs to be implemented in the dedicated driver. This + * function enables the actual IMD device to start the insulation + * measurement. Functionality need to be fullfilled after one call. + * @return #IMD_FSM_STATE_RUNNING if startup has been completed. Returns #IMD_FSM_STATE_ERROR if an error is + * detected that prohibits a working IMD driver. */ -extern void IMD_Trigger(void); +extern IMD_FSM_STATES_e IMD_ProcessEnableState(void); + +/** + * @brief Processes the running state + * @details This function needs to be implemented in the dedicated driver + * @param pTableInsulationMonitoring pointer to insulation monitoring + * database entry + * @return #IMD_FSM_STATE_RUNNING if measurement works as expected, otherwise + * #IMD_FSM_STATE_ERROR if an error is detected that prohibits a + * further execution of the IMD driver. + */ +extern IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring); + +/** + * @brief Processes the shutdown state + * @details This function needs to be implemented in the dedicated driver. This + * function disables the actual IMD device to stop the insulation + * measurement. + * @return #IMD_FSM_STATE_SHUTDOWN if shutdown state is not fininished and + * another call is required. #IMD_FSM_STATE_IMD_ENABLE if shut down + * has been completed and #IMD_FSM_STATE_ERROR if an error is detected + * that prohibits a working IMD driver. + */ +extern IMD_FSM_STATES_e IMD_ProcessShutdownState(void); + +/* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE imd-documentation */ +/*******************************************************************************************************************/ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/imd/none/no-imd.c b/src/app/driver/imd/none/no-imd.c index a60aafb1..1d7bef2d 100644 --- a/src/app/driver/imd/none/no-imd.c +++ b/src/app/driver/imd/none/no-imd.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,13 +43,15 @@ * @file no-imd.c * @author foxBMS Team * @date 2020-11-20 (date of creation) - * @updated 2021-09-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix NOIMD * * @brief Driver for the dummy insulation monitoring driver * - * @details TODO + * @details Dummy driver that provides a default resistance and returns that + * the measurement is always valid. */ /*========== Includes =======================================================*/ @@ -60,36 +62,79 @@ /*========== Macros and Definitions =========================================*/ /*========== Static Constant and Variable Definitions =======================*/ -/** internal handle for the database table of the insulation monitoring driver */ -static DATA_BLOCK_INSULATION_MONITORING_s noimd_insulationMeasurement = { - .header.uniqueId = DATA_BLOCK_ID_INSULATION_MONITORING}; /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ -static STD_RETURN_TYPE_e NOIMD_MeasureInsulation(void); +/** Initialize function */ +static IMD_FSM_STATES_e NOIMD_Initialize(void); + +/** Enable IMD function */ +static IMD_FSM_STATES_e NOIMD_EnableImd(void); + +/** + * @brief Function to write dummy values into the database + * @param pTableInsulationMonitoring pointer to database entry + */ +static IMD_FSM_STATES_e NOIMD_MeasureInsulation(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring); + +/** Enable IMD function */ +static IMD_FSM_STATES_e NOIMD_DisableImd(void); /*========== Static Function Implementations ================================*/ -static STD_RETURN_TYPE_e NOIMD_MeasureInsulation(void) { - noimd_insulationMeasurement.valid = 0; - noimd_insulationMeasurement.state = 0; - noimd_insulationMeasurement.insulationResistance_kOhm = 10000000; - noimd_insulationMeasurement.insulationFault = 0; - noimd_insulationMeasurement.chassisFault = 0; - noimd_insulationMeasurement.systemFailure = 0; - noimd_insulationMeasurement.insulationWarning = 0; - DATA_WRITE_DATA(&noimd_insulationMeasurement); - return STD_OK; +static IMD_FSM_STATES_e NOIMD_Initialize(void) { + return IMD_FSM_STATE_IMD_ENABLE; +} + +static IMD_FSM_STATES_e NOIMD_EnableImd(void) { + return IMD_FSM_STATE_RUNNING; +} + +static IMD_FSM_STATES_e NOIMD_MeasureInsulation(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + pTableInsulationMonitoring->isInsulationMeasurementValid = true; + pTableInsulationMonitoring->areDeviceFlagsValid = true; + pTableInsulationMonitoring->insulationResistance_kOhm = 1000u; + pTableInsulationMonitoring->dfIsCriticalResistanceDetected = false; + pTableInsulationMonitoring->dfIsChassisFaultDetected = false; + pTableInsulationMonitoring->dfIsDeviceErrorDetected = false; + pTableInsulationMonitoring->dfIsWarnableResistanceDetected = false; + return IMD_FSM_STATE_RUNNING; +} + +static IMD_FSM_STATES_e NOIMD_DisableImd(void) { + return IMD_FSM_STATE_IMD_ENABLE; } /*========== Extern Function Implementations ================================*/ -extern void IMD_Trigger(void) { - NOIMD_MeasureInsulation(); +extern IMD_FSM_STATES_e IMD_ProcessInitializationState(void) { + return NOIMD_Initialize(); +} + +extern IMD_FSM_STATES_e IMD_ProcessEnableState(void) { + return NOIMD_EnableImd(); +} + +extern IMD_FSM_STATES_e IMD_ProcessRunningState(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + FAS_ASSERT(pTableInsulationMonitoring != NULL_PTR); + return NOIMD_MeasureInsulation(pTableInsulationMonitoring); +} + +extern IMD_FSM_STATES_e IMD_ProcessShutdownState(void) { + return NOIMD_DisableImd(); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ #ifdef UNITY_UNIT_TEST -extern STD_RETURN_TYPE_e TEST_NOIMD_MeasureInsulation() { - return NOIMD_MeasureInsulation(); +extern IMD_FSM_STATES_e TEST_NOIMD_Initialize(void) { + return NOIMD_Initialize(); +} +extern IMD_FSM_STATES_e TEST_NOIMD_EnableImd(void) { + return NOIMD_EnableImd(); +} +extern IMD_FSM_STATES_e TEST_NOIMD_MeasureInsulation(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring) { + return NOIMD_MeasureInsulation(pTableInsulationMonitoring); +} +extern IMD_FSM_STATES_e TEST_NOIMD_DisableImd(void) { + return NOIMD_DisableImd(); } #endif diff --git a/src/app/driver/imd/none/no-imd.h b/src/app/driver/imd/none/no-imd.h index 8258e492..31ec3eda 100644 --- a/src/app/driver/imd/none/no-imd.h +++ b/src/app/driver/imd/none/no-imd.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,13 +43,16 @@ * @file no-imd.h * @author foxBMS Team * @date 2020-11-20 (date of creation) - * @updated 2021-09-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix NONE * - * @brief Headers for the driver for the dummy insulation monitoring + * @brief Header for the driver for the dummy insulation monitoring * - * @details TODO + * @details This header provides the wrappers to make the static + * implementations of the IMD functionalities available in the unit + * tests. */ #ifndef FOXBMS__NO_IMD_H_ @@ -68,7 +71,10 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST -extern STD_RETURN_TYPE_e TEST_NOIMD_MeasureInsulation(); +extern IMD_FSM_STATES_e TEST_NOIMD_Initialize(void); +extern IMD_FSM_STATES_e TEST_NOIMD_EnableImd(void); +extern IMD_FSM_STATES_e TEST_NOIMD_MeasureInsulation(DATA_BLOCK_INSULATION_MONITORING_s *pTableInsulationMonitoring); +extern IMD_FSM_STATES_e TEST_NOIMD_DisableImd(void); #endif #endif /* FOXBMS__NO_IMD_H_ */ diff --git a/src/app/driver/imd/none/wscript b/src/app/driver/imd/none/wscript index 881fecd2..1df904aa 100644 --- a/src/app/driver/imd/none/wscript +++ b/src/app/driver/imd/none/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -52,16 +52,22 @@ def build(bld): "..", os.path.join("..", "..", "can"), os.path.join("..", "..", "config"), + os.path.join("..", "..", "mcu"), os.path.join("..", "..", "..", "application", "config"), os.path.join("..", "..", "..", "engine", "config"), os.path.join("..", "..", "..", "engine", "database"), os.path.join("..", "..", "..", "main", "include"), + os.path.join("..", "..", "..", "task", "config"), os.path.join("..", "..", "..", "task", "os"), + os.path.join("..", "..", "..", "task", "ftask"), ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) + cflags = bld.env.CFLAGS_FOXBMS bld( features="c", source="no-imd.c", + use="imd-device", includes=includes, target=f"{bld.env.APPNAME}-imd", + cflags=cflags, ) diff --git a/src/app/driver/imd/wscript b/src/app/driver/imd/wscript index b9a0f670..e97958cb 100644 --- a/src/app/driver/imd/wscript +++ b/src/app/driver/imd/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,33 @@ Helper script to build the insulation measurement device""" +import os + def build(bld): - """selects the insulation monitoring device""" + """Build Insulation Monitoring Device Driver""" + includes = [ + os.path.join("..", "can"), + os.path.join("..", "config"), + os.path.join("..", "..", "application", "config"), + os.path.join("..", "..", "driver", "mcu"), + os.path.join("..", "..", "engine", "config"), + os.path.join("..", "..", "engine", "database"), + os.path.join("..", "..", "engine", "diag"), + os.path.join("..", "..", "main", "include"), + os.path.join("..", "..", "task", "config"), + os.path.join("..", "..", "task", "os"), + ] + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) + cflags = bld.env.CFLAGS_FOXBMS + + # Build imd.c as object + bld.objects( + source="imd.c", + includes=includes, + cflags=cflags, + target="imd-device", + ) + + # Build selected IMD bld.recurse(bld.env.imd_manufacturer) diff --git a/src/app/driver/interlock/interlock.c b/src/app/driver/interlock/interlock.c index d65b6b9e..29b2aee9 100644 --- a/src/app/driver/interlock/interlock.c +++ b/src/app/driver/interlock/interlock.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file interlock.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-10-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix ILCK * diff --git a/src/app/driver/interlock/interlock.h b/src/app/driver/interlock/interlock.h index 1080a384..9d445632 100644 --- a/src/app/driver/interlock/interlock.h +++ b/src/app/driver/interlock/interlock.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file interlock.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-10-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix ILCK * diff --git a/src/app/driver/io/io.c b/src/app/driver/io/io.c index 64a9e70c..20d2e830 100644 --- a/src/app/driver/io/io.c +++ b/src/app/driver/io/io.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file io.c * @author foxBMS Team * @date 2020-06-05 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix IO * @@ -55,6 +56,8 @@ /*========== Includes =======================================================*/ #include "io.h" +#include "mcu.h" + /*========== Macros and Definitions =========================================*/ /*========== Static Constant and Variable Definitions =======================*/ @@ -103,7 +106,7 @@ extern STD_PIN_STATE_e IO_PinGet(const volatile uint32_t *pRegisterAddress, uint uint8_t pinState = (uint8_t)((*pRegisterAddress & ((uint32_t)1u << (pin))) >> pin); /* pinState 0 equals a low level */ - if (0u == pinState) { + if (pinState == 0u) { retval = STD_PIN_LOW; } else { retval = STD_PIN_HIGH; diff --git a/src/app/driver/io/io.h b/src/app/driver/io/io.h index 394a1138..b7486c72 100644 --- a/src/app/driver/io/io.h +++ b/src/app/driver/io/io.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file io.h * @author foxBMS Team * @date 2020-03-19 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix IO * diff --git a/src/app/driver/led/led.c b/src/app/driver/led/led.c index 5d4a8596..4fca42b7 100644 --- a/src/app/driver/led/led.c +++ b/src/app/driver/led/led.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file led.c * @author foxBMS Team * @date 2021-09-28 (date of creation) - * @updated 2021-10-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix LED * @@ -80,7 +81,7 @@ uint32_t led_onOffTime_ms = 0u; /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void LED_SetDebugLED(void) { +extern void LED_SetDebugLed(void) { IO_PinSet(&LED_PORT->DOUT, LED_PIN); } diff --git a/src/app/driver/led/led.h b/src/app/driver/led/led.h index 9c22de86..e0ebcb7a 100644 --- a/src/app/driver/led/led.h +++ b/src/app/driver/led/led.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file led.h * @author foxBMS Team * @date 2021-09-28 (date of creation) - * @updated 2021-10-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix LED * @@ -81,7 +82,7 @@ * @details This function is intended to be called once during startup before * #LED_SetToggleTime() is called (after startup). */ -extern void LED_SetDebugLED(void); +extern void LED_SetDebugLed(void); /** * @brief Trigger function to periodically toggle debug LED. Frequency can be diff --git a/src/app/driver/mcu/mcu.c b/src/app/driver/mcu/mcu.c index fafddc54..7e08f425 100644 --- a/src/app/driver/mcu/mcu.c +++ b/src/app/driver/mcu/mcu.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mcu.c * @author foxBMS Team * @date 2019-02-19 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MCU * @@ -68,6 +69,11 @@ #define MCU_US_WAIT_TIMEOUT (10000U) /*========== Static Constant and Variable Definitions =======================*/ +/** + * @brief frequency of the FRC0 counter + * @details refer to data sheet SPNU563A-March 2018 p. 585 formula 23 + */ +static const uint32_t mcu_frcClock_Hz = (uint32_t)((RTI_FREQ)*1000000.0f) / ((MCU_RTI_CNT0_CPUC0_REG) + 1u); /*========== Extern Constant and Variable Definitions =======================*/ @@ -77,21 +83,11 @@ /*========== Extern Function Implementations ================================*/ -void MCU_delay_us(uint32_t delay_us) { - uint32_t timeOut = 0; - uint32_t startValue = 0; - uint32_t rti_clock = 0; - uint32_t rti_nrOfCounts_us = 0; - - /** - * This is the frequency of the FRC0 counter - * data sheet SPNU563A-March 2018 p. 585 formula 23 - */ - rti_clock = (uint32_t)((AVCLK1_FREQ)*1000000.0f) / ((MCU_RTI_CNT0_CPUC0_REG) + 1u); - +void MCU_Delay_us(uint32_t delay_us) { + /* AXIVION Routine Generic-MissingParameterAssert: delay_us: parameter accepts whole range */ /** * First the time of one FRC0 increment in microseconds is computed with - * increment_time = (1/rti_clock)*1e6 + * increment_time = (1/mcu_frcClock_Hz)*1e6 * The 1e6 factor is to get the period in microseconds. * * The number of increments needed to reach 1 microsecond is then @@ -101,22 +97,34 @@ void MCU_delay_us(uint32_t delay_us) { * To avoid floating point computation problems, the number of * increments needed to reach 1 microsecond is computed at once with: */ - rti_nrOfCounts_us = (uint32_t)(((float)rti_clock) / 1e6f); + const uint32_t rti_nrOfCounts_us = (uint32_t)(((float)mcu_frcClock_Hz) / 1e6f); /* Get current value of FRC0 counter */ - startValue = (uint32_t)MCU_RTI_CNT0_FRC0_REG; + const uint32_t startValue = MCU_RTI_CNT0_FRC0_REG; + uint32_t timeOut = 0; while (timeOut < MCU_US_WAIT_TIMEOUT) { /** * Poll FRC0 value until the value corresponding to the desired * waiting timing has been reached. * The timeout is to ensure the code does not get trapped here. */ - if (((uint32_t)MCU_RTI_CNT0_FRC0_REG - startValue) >= (delay_us * rti_nrOfCounts_us)) { + const uint32_t checkValue = MCU_RTI_CNT0_FRC0_REG; + if ((checkValue - startValue) >= (delay_us * rti_nrOfCounts_us)) { break; } timeOut++; } } +extern uint32_t MCU_GetFreeRunningCount(void) { + return MCU_RTI_CNT0_FRC0_REG; +} + +extern uint32_t MCU_ConvertFrcDifferenceToTimespan_us(uint32_t count) { + /* AXIVION Routine Generic-MissingParameterAssert: count: parameter accepts whole range */ + const uint32_t rti_nrOfCounts_us = (uint32_t)(((float)mcu_frcClock_Hz) / 1e6f); + return count / rti_nrOfCounts_us; +} + /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/mcu/mcu.h b/src/app/driver/mcu/mcu.h index 9940e8b9..32c8c5fa 100644 --- a/src/app/driver/mcu/mcu.h +++ b/src/app/driver/mcu/mcu.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file mcu.h * @author foxBMS Team * @date 2019-02-19 (date of creation) - * @updated 2019-02-19 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MCU * @@ -55,13 +56,28 @@ #define FOXBMS__MCU_H_ /*========== Includes =======================================================*/ -#include "general.h" +#include "HL_sys_common.h" + +#include /* include stdint.h instead of general.h to avoid cyclic include */ /*========== Macros and Definitions =========================================*/ +/** + * @brief largest pin number that exists in TMS570LC4357 + * @details Checked in the data sheet spnu563a: The largest pin number that is + * used is 31. +*/ +#define LARGEST_PIN_NUMBER (31u) + +/** + * @brief maximum number of channels measured by the ADC1 + * @details Checked in the data sheet spnu563a: ADC1 supports 32 channels + */ +#define ADC_ADC1_MAX_NR_CHANNELS (32U) + #ifndef UNITY_UNIT_TEST /** Address of Free Running Counter 0 (FRC0) */ -#define MCU_RTI_CNT0_FRC0_REG (*((volatile uint32_t *)0xFFFFFC10)) +#define MCU_RTI_CNT0_FRC0_REG (*((volatile uint32_t *)0xFFFFFC10u)) #else extern volatile uint32_t MCU_RTI_CNT0_FRC0_REG; #endif @@ -77,7 +93,27 @@ extern volatile uint32_t MCU_RTI_CNT0_FRC0_REG; * counter. This counter is already used by FreeRTOS. * @param delay_us time in microseconds to wait */ -extern void MCU_delay_us(uint32_t delay_us); +extern void MCU_Delay_us(uint32_t delay_us); + +/** + * @brief Get the current value of the Free Running Counter 0 (FRC0) + * @details This function returns the current value of the Free Running + * Counter 0 (FRC0). This counter is already used by FreeRTOS and this + * function does nothing more than accessing this value. + * @returns the current counter value of FRC0 + */ +extern uint32_t MCU_GetFreeRunningCount(void); + +/** + * @brief Convert the counter value FRC0 to a time in microseconds + * @details This function applies a scaling factor to the FRC0 counter value, + * which can be retrieved with #MCU_GetFreeRunningCount() so that this + * value represents microseconds. Typically this used with counter + * differences in order to get timing estimates on microsecond-level. + * @param[in] count counter value of the FRC0 + * @returns equivalent time in microseconds + */ +extern uint32_t MCU_ConvertFrcDifferenceToTimespan_us(uint32_t count); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/meas/meas.c b/src/app/driver/meas/meas.c index f8041518..0e833440 100644 --- a/src/app/driver/meas/meas.c +++ b/src/app/driver/meas/meas.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file meas.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MEAS * diff --git a/src/app/driver/meas/meas.h b/src/app/driver/meas/meas.h index ceb47af2..e114c3f4 100644 --- a/src/app/driver/meas/meas.h +++ b/src/app/driver/meas/meas.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file meas.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix MEAS * diff --git a/src/app/driver/pex/pex.c b/src/app/driver/pex/pex.c index 2cabe225..ad493202 100644 --- a/src/app/driver/pex/pex.c +++ b/src/app/driver/pex/pex.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pex.c * @author foxBMS Team * @date 2021-08-02 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix PEX * diff --git a/src/app/driver/pex/pex.h b/src/app/driver/pex/pex.h index 8747e391..652e6571 100644 --- a/src/app/driver/pex/pex.h +++ b/src/app/driver/pex/pex.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pex.h * @author foxBMS Team * @date 2021-08-02 (date of creation) - * @updated 2021-10-04 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix PEX * diff --git a/src/app/driver/pwm/pwm.c b/src/app/driver/pwm/pwm.c index 21684a3a..88b2532c 100644 --- a/src/app/driver/pwm/pwm.c +++ b/src/app/driver/pwm/pwm.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pwm.c * @author foxBMS Team * @date 2021-10-07 (date of creation) - * @updated 2021-10-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix PWM * @@ -54,7 +55,9 @@ /*========== Includes =======================================================*/ #include "pwm.h" +#include "HL_ecap.h" #include "HL_etpwm.h" +#include "HL_system.h" #include "fsystem.h" @@ -68,10 +71,22 @@ /** full period in promill */ #define PWM_FULL_PERIOD_PERM (1000u) +typedef struct { + bool ecapInitialized; + bool etpwmInitialized; +} PWM_INITIALIZATION_STATE_s; + /*========== Static Constant and Variable Definitions =======================*/ +static PWM_INITIALIZATION_STATE_s pwm_state = { + .ecapInitialized = false, + .etpwmInitialized = false, +}; + /** linear offset (through output circuit) */ static const int16_t pwm_kLinearOffset = 0; +static PWM_SIGNAL_s ecap_inputPwmSignal = {.dutyCycle_perc = 0.0f, .frequency_Hz = 0.0f}; + /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ @@ -104,9 +119,17 @@ static uint16_t PWM_ComputeCounterValueFromDutyCycle(uint16_t dutyCycle_perm) { } /*========== Extern Function Implementations ================================*/ +extern void PWM_Initialize(void) { + etpwmInit(); + pwm_state.etpwmInitialized = true; + ecapInit(); + pwm_state.ecapInitialized = true; +} + extern void PWM_StartPwm(void) { /* go to privileged mode in order to access control register */ - FAS_ASSERT(FSYS_RaisePrivilege() == 0); + const int32_t raisePrivilegeResult = FSYS_RaisePrivilege(); + FAS_ASSERT(raisePrivilegeResult == 0); etpwmStartTBCLK(); /* done; go back to user mode */ FSYS_SwitchToUserMode(); @@ -114,7 +137,8 @@ extern void PWM_StartPwm(void) { extern void PWM_StopPwm(void) { /* go to privileged mode in order to access control register */ - FAS_ASSERT(FSYS_RaisePrivilege() == 0); + const int32_t raisePrivilegeResult = FSYS_RaisePrivilege(); + FAS_ASSERT(raisePrivilegeResult == 0); etpwmStopTBCLK(); /* done; go back to user mode */ FSYS_SwitchToUserMode(); @@ -140,6 +164,31 @@ extern void PWM_SetDutyCycle(uint16_t dutyCycle_perm) { etpwmSetCmpA(etpwmREG1, PWM_ComputeCounterValueFromDutyCycle(correctedDutyCycle_perm)); } +extern void ecapNotification(ecapBASE_t *ecap, uint16 flags) { + /* Counter value of rising edge */ + uint32_t capture1 = ecapGetCAP1(ecapREG1); + /* Counter value of falling edge */ + uint32_t capture2 = ecapGetCAP2(ecapREG1); + /* Counter value of next rising edge */ + uint32_t capture3 = ecapGetCAP3(ecapREG1); + + /* Counter 3 - Counter 1: Period in counter ticks */ + /* Convert MHz to Hz */ + ecap_inputPwmSignal.frequency_Hz = 1.0f / ((float)(capture3 - capture1) / (HCLK_FREQ * 1000000.0f)); + + /* Counter 2 - Counter 1: Duty cycle in counter ticks */ + ecap_inputPwmSignal.dutyCycle_perc = (float)(capture2 - capture1) / (float)(capture3 - capture1) * 100.0f; +} + +bool PWM_IsEcapModuleInitialized(void) { + return pwm_state.ecapInitialized; +} + +extern PWM_SIGNAL_s ECAP_GetPwmData(void) { + /* TODO: how to ensure that values have been updated? add timestamp? Add counter?*/ + return ecap_inputPwmSignal; +} + /*========== Getter for static Variables (Unit Test) ========================*/ #ifdef UNITY_UNIT_TEST extern int16_t TEST_PWM_GetLinearOffset(void) { diff --git a/src/app/driver/pwm/pwm.h b/src/app/driver/pwm/pwm.h index d7f35954..b2cea071 100644 --- a/src/app/driver/pwm/pwm.h +++ b/src/app/driver/pwm/pwm.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pwm.h * @author foxBMS Team * @date 2021-10-07 (date of creation) - * @updated 2021-10-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix PWM * @@ -61,15 +62,26 @@ /*========== Includes =======================================================*/ #include "general.h" +#include "HL_reg_ecap.h" + /*========== Macros and Definitions =========================================*/ +typedef struct { + float dutyCycle_perc; + float frequency_Hz; +} PWM_SIGNAL_s; + /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ +/** @brief Initializes the ETPWM and the ECAP module + */ +extern void PWM_Initialize(void); + /** @brief Start the PWM (starts all configured ePWM channels) * @details In order for this function to work, it is absolutely necessary that * etpwmInit() is called first. -*/ + */ extern void PWM_StartPwm(void); /** @brief Stop the PWM (stops all configured ePWM channels) */ @@ -79,9 +91,18 @@ extern void PWM_StopPwm(void); * @details Duty cycle values that are out of the range that is supported are * limited to the threshold values. * @param[in] dutyCycle_perm duty cycle in permill -*/ + */ extern void PWM_SetDutyCycle(uint16_t dutyCycle_perm); +/** @brief Get dutycycle and frequency of input PWM signal */ +extern PWM_SIGNAL_s ECAP_GetPwmData(void); + +/** + * @brief Get initialization state of ecap module + * @return true if module is initialized, otherwise false + */ +extern bool PWM_IsEcapModuleInitialized(void); + /*========== Getter for static Variables (Unit Test) ========================*/ #ifdef UNITY_UNIT_TEST extern int16_t TEST_PWM_GetLinearOffset(void); diff --git a/src/app/driver/rtc/rtc.c b/src/app/driver/rtc/rtc.c index 0fed04fd..cc93c6ba 100644 --- a/src/app/driver/rtc/rtc.c +++ b/src/app/driver/rtc/rtc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file rtc.c * @author foxBMS Team * @date 2021-02-22 (date of creation) - * @updated 2021-02-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix RTC * diff --git a/src/app/driver/rtc/rtc.h b/src/app/driver/rtc/rtc.h index 858ba1c5..5b0255e6 100644 --- a/src/app/driver/rtc/rtc.h +++ b/src/app/driver/rtc/rtc.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file rtc.h * @author foxBMS Team * @date 2021-02-22 (date of creation) - * @updated 2021-02-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix RTC * diff --git a/src/app/driver/sbc/fs8x_driver/.clang-format b/src/app/driver/sbc/fs8x_driver/.clang-format new file mode 100644 index 00000000..9d159247 --- /dev/null +++ b/src/app/driver/sbc/fs8x_driver/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: false diff --git a/src/app/driver/sbc/nxpfs85xx.c b/src/app/driver/sbc/nxpfs85xx.c index b065be69..05508582 100644 --- a/src/app/driver/sbc/nxpfs85xx.c +++ b/src/app/driver/sbc/nxpfs85xx.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file nxpfs85xx.c * @author foxBMS Team * @date 2020-03-18 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SBC * @@ -69,7 +70,7 @@ /*========== Macros and Definitions =========================================*/ /*========== Static Constant and Variable Definitions =======================*/ -typedef enum SBC_INIT_PHASE { +typedef enum { SBC_UNINITIALIZED, SBC_FIN_TEST, SBC_RSTB_ASSERTION_TEST, @@ -77,7 +78,7 @@ typedef enum SBC_INIT_PHASE { } SBC_INIT_PHASE_e; /*========== Extern Constant and Variable Definitions =======================*/ -FS85xx_STATE_s fs85xx_mcuSupervisor = { +FS85_STATE_s fs85xx_mcuSupervisor = { .pSpiInterface = &spi_kSbcMcuInterface, .configValues.watchdogSeed = FS8x_WD_SEED_DEFAULT, .configValues.communicationMode = fs8xSPI, @@ -115,7 +116,7 @@ static STD_RETURN_TYPE_e SBC_CheckRegisterValues(uint32_t registerValue, uint32_ * @param[in] registerValue register value */ static void SBC_UpdateRegister( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, bool isFailSafe, uint32_t registerAddress, uint32_t registerValue); @@ -130,7 +131,7 @@ static void SBC_UpdateRegister( * @param[in] registerAddress address of register that is read from * @return #STD_OK if reading was successful, otherwise #STD_NOT_OK */ -static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85xx_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress); +static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress); /** * @brief Write to fail-safe register @@ -142,7 +143,7 @@ static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85xx_STATE_s *pInstance, bool is * @return #STD_OK if writting was successful, other #STD_NOT_OK */ static STD_RETURN_TYPE_e SBC_WriteRegisterFsInit( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue); @@ -157,7 +158,7 @@ static STD_RETURN_TYPE_e SBC_WriteRegisterFsInit( * @return #STD_OK if writting was successful, other #STD_NOT_OK */ static STD_RETURN_TYPE_e SBC_WriteBackRegisterFsInit( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue); @@ -173,12 +174,12 @@ static STD_RETURN_TYPE_e SBC_WriteBackRegisterFsInit( * @return #STD_OK if writting was successful, other #STD_NOT_OK */ static STD_RETURN_TYPE_e SBC_ClearRegisterFlags( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, uint8_t registerAddress, bool isFailSafe, uint16_t registerValue); -static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85xx_STATE_s *pInstance); +static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85_STATE_s *pInstance); /** * @brief Perform RSTB safety path check @@ -189,7 +190,7 @@ static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85xx_STATE_s *pInstance); * @param[in,out] pInstance SBC instance for which the RSTB path is checked * @return #STD_OK if path check was successful, other #STD_NOT_OK */ -static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance); +static STD_RETURN_TYPE_e SBC_PerformPathCheckRstb(FS85_STATE_s *pInstance); /** * @brief Perform FS0B safety path check @@ -199,10 +200,12 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance); * operation. * @param[in,out] pInstance SBC instance for which the FS0B path is checked */ -static STD_RETURN_TYPE_e SBC_PerformPathCheckFS0B(FS85xx_STATE_s *pInstance); +static STD_RETURN_TYPE_e SBC_PerformPathCheckFs0b(FS85_STATE_s *pInstance); /*========== Static Function Implementations ================================*/ static STD_RETURN_TYPE_e SBC_CheckRegisterValues(uint32_t registerValue, uint32_t expectedRegisterValue) { + /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: expectedRegisterValue: parameter accepts whole range */ STD_RETURN_TYPE_e retval = STD_OK; if (registerValue != expectedRegisterValue) { retval = STD_NOT_OK; @@ -211,11 +214,14 @@ static STD_RETURN_TYPE_e SBC_CheckRegisterValues(uint32_t registerValue, uint32_ } static void SBC_UpdateRegister( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, bool isFailSafe, uint32_t registerAddress, uint32_t registerValue) { FAS_ASSERT(pInstance != NULL_PTR); + FAS_ASSERT((isFailSafe == true) || (isFailSafe == false)); + FAS_ASSERT(registerAddress <= FS8X_M_DEVICEID_ADDR); + /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */ /* Check if fail-safe or main register needs to be updated */ if (isFailSafe == true) { @@ -359,7 +365,11 @@ static void SBC_UpdateRegister( } } -static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85xx_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress) { +static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85_STATE_s *pInstance, bool isFailSafe, uint8_t registerAddress) { + FAS_ASSERT(pInstance != NULL_PTR); + FAS_ASSERT((isFailSafe == true) || (isFailSafe == false)); + /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */ + STD_RETURN_TYPE_e retval = STD_NOT_OK; fs8x_rx_frame_t rxTemp = {0}; @@ -376,9 +386,13 @@ static STD_RETURN_TYPE_e SBC_ReadBackRegister(FS85xx_STATE_s *pInstance, bool is } static STD_RETURN_TYPE_e SBC_WriteRegisterFsInit( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue) { + FAS_ASSERT(pInstance != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */ + STD_RETURN_TYPE_e retval = STD_OK; FAS_ASSERT(pInstance != NULL_PTR); @@ -394,9 +408,13 @@ static STD_RETURN_TYPE_e SBC_WriteRegisterFsInit( } static STD_RETURN_TYPE_e SBC_WriteBackRegisterFsInit( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, uint8_t registerAddress, uint16_t registerValue) { + FAS_ASSERT(pInstance != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */ + STD_RETURN_TYPE_e retval = STD_OK; fs8x_rx_frame_t rxTemp = {0}; @@ -424,10 +442,15 @@ static STD_RETURN_TYPE_e SBC_WriteBackRegisterFsInit( } static STD_RETURN_TYPE_e SBC_ClearRegisterFlags( - FS85xx_STATE_s *pInstance, + FS85_STATE_s *pInstance, uint8_t registerAddress, bool isFailSafe, uint16_t registerValue) { + FAS_ASSERT(pInstance != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: registerAddress: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: isFailSafe: parameter accepts whole range */ + /* AXIVION Routine Generic-MissingParameterAssert: registerValue: parameter accepts whole range */ + STD_RETURN_TYPE_e retval = STD_OK; fs8x_rx_frame_t rxTemp = {0}; @@ -458,7 +481,9 @@ static STD_RETURN_TYPE_e SBC_ClearRegisterFlags( } /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e FS85X_InitFS(FS85xx_STATE_s *pInstance) { +extern STD_RETURN_TYPE_e FS85_InitializeFsPhase(FS85_STATE_s *pInstance) { + FAS_ASSERT(pInstance != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; uint16_t registerMask = 0u; uint16_t expRegisterValue = 0u; @@ -776,7 +801,7 @@ extern STD_RETURN_TYPE_e FS85X_InitFS(FS85xx_STATE_s *pInstance) { } /** 2.: Execute ABIST2 and verify it is pass */ /** ABIST2 is executed automatically after closing of INIT_FS, duration: 1.2ms max */ - MCU_delay_us(1200u); + MCU_Delay_us(1200u); if (STD_OK != SBC_ReadBackRegister(pInstance, true, FS8X_FS_DIAG_SAFETY_ADDR)) { retval = STD_NOT_OK; @@ -841,10 +866,13 @@ extern STD_RETURN_TYPE_e FS85X_InitFS(FS85xx_STATE_s *pInstance) { return retval; } -extern STD_RETURN_TYPE_e FS85X_Init_ReqWDGRefreshes(FS85xx_STATE_s *pInstance, uint8_t *requiredWatchdogRefreshes) { - STD_RETURN_TYPE_e retval = STD_OK; - +extern STD_RETURN_TYPE_e FS85_InitializeNumberOfRequiredWatchdogRefreshes( + FS85_STATE_s *pInstance, + uint8_t *requiredWatchdogRefreshes) { FAS_ASSERT(pInstance != NULL_PTR); + FAS_ASSERT(requiredWatchdogRefreshes != NULL_PTR); + + STD_RETURN_TYPE_e retval = STD_OK; /** Clear the fault error counter to 0 with consecutive good WD refreshes. * The watchdog refresh counter is used to decrement the fault error counter. Each time the watchdog is properly @@ -895,7 +923,10 @@ extern STD_RETURN_TYPE_e FS85X_Init_ReqWDGRefreshes(FS85xx_STATE_s *pInstance, u return retval; } -extern STD_RETURN_TYPE_e FS85X_CheckFaultErrorCounter(FS85xx_STATE_s *pInstance) { +extern STD_RETURN_TYPE_e FS85_CheckFaultErrorCounter(FS85_STATE_s *pInstance) { + FAS_ASSERT(pInstance != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: parameters without assertion accept whole range of data type */ + STD_RETURN_TYPE_e retval = STD_OK; /* Check fault error counter */ @@ -907,13 +938,13 @@ extern STD_RETURN_TYPE_e FS85X_CheckFaultErrorCounter(FS85xx_STATE_s *pInstance) return retval; } -extern STD_RETURN_TYPE_e FS85X_SafetyPathChecks(FS85xx_STATE_s *pInstance) { - STD_RETURN_TYPE_e retval = STD_OK; - +extern STD_RETURN_TYPE_e FS85_SafetyPathChecks(FS85_STATE_s *pInstance) { FAS_ASSERT(pInstance != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; + /* Perform RSTB path check (repeat steps 1 to 4 after RSTB is released) */ - if (STD_OK != SBC_PerformPathCheckRSTB(pInstance)) { + if (STD_OK != SBC_PerformPathCheckRstb(pInstance)) { retval = STD_NOT_OK; } @@ -926,30 +957,33 @@ extern STD_RETURN_TYPE_e FS85X_SafetyPathChecks(FS85xx_STATE_s *pInstance) { } /* Perform FS0B safety path check */ - if (STD_OK != SBC_PerformPathCheckFS0B(pInstance)) { + if (STD_OK != SBC_PerformPathCheckFs0b(pInstance)) { retval = STD_NOT_OK; } /* Init finished successfully if retval still okay */ if (retval == STD_OK) { pInstance->nvram.data->phase = (uint8_t)SBC_INITIALIZED; - FRAM_Write(pInstance->nvram.entry); + FRAM_WriteData(pInstance->nvram.entry); } return retval; } +/* AXIVION Next Line Style CodingStyle-Naming: The function name is pre-defined by the driver provided by NXP */ extern UNIT_TEST_WEAK_IMPL fs8x_status_t MCU_SPI_TransferData( SPI_INTERFACE_CONFIG_s *pSpiInterface, uint8_t *txFrame, uint16_t frameLengthBytes, uint8_t *rxFrame) { + FAS_ASSERT(pSpiInterface != NULL_PTR); + FAS_ASSERT(txFrame != NULL_PTR); + FAS_ASSERT(rxFrame != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: frameLengthBytes: parameter accepts whole range */ + uint16_t sbc_txBuffer[FS8x_COMM_FRAME_SIZE]; uint16_t sbc_rxBuffer[FS8x_COMM_FRAME_SIZE]; fs8x_status_t spiCommunicationState = fs8xStatusError; - FAS_ASSERT(txFrame != NULL_PTR); - FAS_ASSERT(rxFrame != NULL_PTR); - /* Copy TX data in TX array, reset RX array */ for (uint8_t i = 0u; i < FS8x_COMM_FRAME_SIZE; i++) { sbc_txBuffer[FS8x_COMM_FRAME_SIZE - 1u - i] = (uint16_t)txFrame[i]; /* txFrame[0] will be sent last */ @@ -970,7 +1004,9 @@ extern UNIT_TEST_WEAK_IMPL fs8x_status_t MCU_SPI_TransferData( return spiCommunicationState; } -extern STD_RETURN_TYPE_e SBC_TriggerWatchdog(FS85xx_STATE_s *pInstance) { +extern STD_RETURN_TYPE_e SBC_TriggerWatchdog(FS85_STATE_s *pInstance) { + FAS_ASSERT(pInstance != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_NOT_OK; if (fs8xStatusOk == FS8x_WD_Refresh(pInstance->pSpiInterface, &(pInstance->configValues))) { /* Check GRL_FLAGS register if watchdog refresh was valid */ @@ -1002,7 +1038,9 @@ extern STD_RETURN_TYPE_e SBC_TriggerWatchdog(FS85xx_STATE_s *pInstance) { return retval; } -static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85xx_STATE_s *pInstance) { +static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85_STATE_s *pInstance) { + FAS_ASSERT(pInstance != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; /* Read all fail-safe registers */ @@ -1042,7 +1080,9 @@ static STD_RETURN_TYPE_e SBC_ReadBackAllRegisters(FS85xx_STATE_s *pInstance) { return retval; } -static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { +static STD_RETURN_TYPE_e SBC_PerformPathCheckRstb(FS85_STATE_s *pInstance) { + FAS_ASSERT(pInstance != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; resetSource_t rstReason = MINFO_GetResetSource(); bool test_assertionRSTB = false; /* Do not test RSTB assertion on default */ @@ -1055,7 +1095,7 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { /** Write to NVRAM to determine after reset and if short-circuit * between RSTB and FIN present what exactly caused the reset. */ pInstance->nvram.data->phase = (uint8_t)SBC_FIN_TEST; - FRAM_Write(pInstance->nvram.entry); + FRAM_WriteData(pInstance->nvram.entry); /** MCU SBC is connected to ECLK1 -> privilege mode is required to access register */ FSYS_RaisePrivilege(); @@ -1066,7 +1106,7 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { /** Pulses longer than 2000ns trigger reset -> wait 10us to check if reset is triggered by short between RSTB and FIN */ - MCU_delay_us(10u); + MCU_Delay_us(10u); /** If we reach this line of code, no reset has taken place. Everything okay. Set level of FIN pin back to high */ @@ -1089,7 +1129,7 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { } else if (rstReason == EXT_RESET) { /** Last reset reason was external reset via nRST pin (EXT_RESET) Readout FRAM to determine in which state the SBC was prior to reset */ - FRAM_Read(pInstance->nvram.entry); + FRAM_ReadData(pInstance->nvram.entry); if ((SBC_INIT_PHASE_e)pInstance->nvram.data->phase == SBC_FIN_TEST) { /** Short-circuit between FIN and RSTB: Do not apply CLK on FIN */ /** Update nvram FIN state */ @@ -1143,7 +1183,7 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { } else { /** Reset was not caused by power-cycle or SBC. SBC has already been initialized successfully after detected * power-cycle. Everything okay. Read FIN state from NVRAM and continue with normal operation */ - FRAM_Read(pInstance->nvram.entry); + FRAM_ReadData(pInstance->nvram.entry); test_assertionRSTB = false; pInstance->fin.finState = pInstance->nvram.data->finState; if (pInstance->fin.finState == STD_OK) { @@ -1157,14 +1197,14 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { if (test_assertionRSTB == true) { /** Write to NVRAM to determine after reset and if RSTB was asserted correctly */ pInstance->nvram.data->phase = (uint8_t)SBC_RSTB_ASSERTION_TEST; - FRAM_Write(pInstance->nvram.entry); + FRAM_WriteData(pInstance->nvram.entry); SBC_ReadBackRegister(pInstance, true, FS8X_FS_STATES_ADDR); uint16_t registerValue = FS8X_FS_RSTB_REQ_RSTB_ASSERTION; SBC_WriteRegisterFsInit(pInstance, FS8X_FS_SAFE_IOS_ADDR, registerValue); - while (1) { + while (true) { ; } @@ -1173,7 +1213,9 @@ static STD_RETURN_TYPE_e SBC_PerformPathCheckRSTB(FS85xx_STATE_s *pInstance) { return retval; } -static STD_RETURN_TYPE_e SBC_PerformPathCheckFS0B(FS85xx_STATE_s *pInstance) { +static STD_RETURN_TYPE_e SBC_PerformPathCheckFs0b(FS85_STATE_s *pInstance) { + FAS_ASSERT(pInstance != NULL_PTR); + STD_RETURN_TYPE_e retval = STD_OK; /* TBD */ return retval; diff --git a/src/app/driver/sbc/nxpfs85xx.h b/src/app/driver/sbc/nxpfs85xx.h index 6f34b640..dea66e5f 100644 --- a/src/app/driver/sbc/nxpfs85xx.h +++ b/src/app/driver/sbc/nxpfs85xx.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,9 +43,10 @@ * @file nxpfs85xx.h * @author foxBMS Team * @date 2020-03-18 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS - * @prefix FS85X + * @prefix FS85 * * @brief Header for the driver for the FRAM module * @@ -67,7 +68,7 @@ /*========== Macros and Definitions =========================================*/ /** struct for fail-safe registers * for register description see data sheet FS84_FS85 - Rev. 3.0 - 9 April 2019 */ -typedef struct FS85X_FS_REGISTERS { +typedef struct { uint16_t grl_flags; /*!< FS8X_FS_GRL_FLAGS_ADDR */ uint16_t iOvervoltageUndervolateSafeReaction1; /*!< FS8X_FS_I_OVUV_SAFE_REACTION1_ADDR */ uint16_t iOvervoltageUndervolateSafeReaction2; /*!< FS8X_FS_I_OVUV_SAFE_REACTION2_ADDR */ @@ -84,11 +85,11 @@ typedef struct FS85X_FS_REGISTERS { uint16_t diag_safety; /*!< FS8X_FS_DIAG_SAFETY_ADDR */ uint16_t intb_mask; /*!< FS8X_FS_INTB_MASK_ADDR */ uint16_t states; /*!< FS8X_FS_STATES_ADDR */ -} FS85X_FS_REGISTER_s; +} FS85_FS_REGISTER_s; /** struct for main registers * for register description see data sheet FS84_FS85 - Rev. 3.0 - 9 April 2019 */ -typedef struct FS85X_MAIN_REGISTERS { +typedef struct { uint16_t flag; /*!< FS8X_M_FLAG_ADDR */ uint16_t mode; /*!< FS8X_M_MODE_ADDR */ uint16_t registerControl1; /*!< FS8X_M_REG_CTRL1_ADDR */ @@ -104,40 +105,40 @@ typedef struct FS85X_MAIN_REGISTERS { uint16_t memory0; /*!< FS8X_M_MEMORY0_ADDR */ uint16_t memory1; /*!< FS8X_M_MEMORY1_ADDR */ uint16_t deviceId; /*!< FS8X_M_DEVICEID_ADDR */ -} FS85X_MAIN_REGISTERS_s; +} FS85_MAIN_REGISTERS_s; -typedef enum FS85X_OPERATION_MODE { +typedef enum { SBC_NORMAL_MODE, SBC_DEBUG_MODE, -} FS85X_OPERATION_MODE_e; +} FS85_OPERATION_MODE_e; /** struct for FIN configuration */ -typedef struct FS85X_FIN_CONFIGURATION { +typedef struct { bool finUsed; /*!< flag if FIN feature of SBC is used */ STD_RETURN_TYPE_e finState; /*!< Is set to STD_NOT_OK if short circuit between FIN and RSTB pin detected */ volatile uint32_t *pGIOport; /*!< pointer to port where FIN pin of SBC is connected to */ uint32_t pin; /*!< pin where FIN pin of SBC is connected to */ -} FS85X_FIN_CONFIGURATION_s; +} FS85_FIN_CONFIGURATION_s; /** stores a pointer to the persistent entry in the FRAM */ -typedef struct SBC_NVRAM_INFO { - FRAM_BLOCK_ID_e entry; /*!< FRAM ID of persistant SBC entry in FRAM */ +typedef struct { + FRAM_BLOCK_ID_e entry; /*!< FRAM ID of persistent SBC entry in FRAM */ FRAM_SBC_INIT_s *data; /*!< pointer to SBC entry in FRAM module */ -} SBC_NVRAM_INFO_s; +} FS85_NVRAM_INFO_s; /** state struct to create SBC instance */ -typedef struct FS85xx_STATE { +typedef struct { SPI_INTERFACE_CONFIG_s *pSpiInterface; /*< pointer to used SPI interface configuration */ fs8x_drv_data_t configValues; /*!< configuration of used communication interface */ - FS85X_FIN_CONFIGURATION_s fin; /*!< configurations for FIN functionality */ - FS85X_MAIN_REGISTERS_s mainRegister; /*!< FS85xx main registers */ - FS85X_FS_REGISTER_s fsRegister; /*!< FS85xx safety registers */ - SBC_NVRAM_INFO_s nvram; /*!< configuration and data for persistant memory required for initialization */ - FS85X_OPERATION_MODE_e mode; /*!< current operation mode of FS85xx */ -} FS85xx_STATE_s; + FS85_FIN_CONFIGURATION_s fin; /*!< configurations for FIN functionality */ + FS85_MAIN_REGISTERS_s mainRegister; /*!< FS85xx main registers */ + FS85_FS_REGISTER_s fsRegister; /*!< FS85xx safety registers */ + FS85_NVRAM_INFO_s nvram; /*!< configuration and data for persistent memory required for initialization */ + FS85_OPERATION_MODE_e mode; /*!< current operation mode of FS85xx */ +} FS85_STATE_s; /*========== Extern Constant and Variable Declarations ======================*/ -extern FS85xx_STATE_s fs85xx_mcuSupervisor; +extern FS85_STATE_s fs85xx_mcuSupervisor; /*========== Extern Function Prototypes =====================================*/ /** @@ -150,7 +151,7 @@ extern FS85xx_STATE_s fs85xx_mcuSupervisor; * @return #STD_OK if all checks were successful and SBC configured * correctly, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e FS85X_InitFS(FS85xx_STATE_s *pInstance); +extern STD_RETURN_TYPE_e FS85_InitializeFsPhase(FS85_STATE_s *pInstance); /** * @brief Calculates the number of required watchdog refresh to reset @@ -162,7 +163,9 @@ extern STD_RETURN_TYPE_e FS85X_InitFS(FS85xx_STATE_s *pInstance); * @return #STD_OK if required watchdog refreshes were calculated * successfully, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e FS85X_Init_ReqWDGRefreshes(FS85xx_STATE_s *pInstance, uint8_t *requiredWatchdogRefreshes); +extern STD_RETURN_TYPE_e FS85_InitializeNumberOfRequiredWatchdogRefreshes( + FS85_STATE_s *pInstance, + uint8_t *requiredWatchdogRefreshes); /** * @brief Checks if fault error counter is zero @@ -171,7 +174,7 @@ extern STD_RETURN_TYPE_e FS85X_Init_ReqWDGRefreshes(FS85xx_STATE_s *pInstance, u * @return #STD_OK if fault error counter equals zero, otherwise * #STD_NOT_OK */ -extern STD_RETURN_TYPE_e FS85X_CheckFaultErrorCounter(FS85xx_STATE_s *pInstance); +extern STD_RETURN_TYPE_e FS85_CheckFaultErrorCounter(FS85_STATE_s *pInstance); /** * @brief Performs SBC safety path checks @@ -181,7 +184,7 @@ extern STD_RETURN_TYPE_e FS85X_CheckFaultErrorCounter(FS85xx_STATE_s *pInstance) * @return #STD_OK if safety path check successful, otherwise * #STD_NOT_OK */ -extern STD_RETURN_TYPE_e FS85X_SafetyPathChecks(FS85xx_STATE_s *pInstance); +extern STD_RETURN_TYPE_e FS85_SafetyPathChecks(FS85_STATE_s *pInstance); /** * @brief Trigger watchdog @@ -191,7 +194,7 @@ extern STD_RETURN_TYPE_e FS85X_SafetyPathChecks(FS85xx_STATE_s *pInstance); * @return #STD_OK if watchdog has been triggered successfully, * otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e SBC_TriggerWatchdog(FS85xx_STATE_s *pInstance); +extern STD_RETURN_TYPE_e SBC_TriggerWatchdog(FS85_STATE_s *pInstance); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/sbc/sbc.c b/src/app/driver/sbc/sbc.c index 4ce5c5b9..2cabd84a 100644 --- a/src/app/driver/sbc/sbc.c +++ b/src/app/driver/sbc/sbc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sbc.c * @author foxBMS Team * @date 2020-07-14 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SBC * @@ -63,7 +64,7 @@ /*========== Macros and Definitions =========================================*/ /** Symbolic names to check re-entrance in #SBC_Trigger */ -typedef enum SBC_CHECK_REENTRANCE { +typedef enum { SBC_REENTRANCE_NO, /*!< no re-entrance */ SBC_REENTRANCE_YES, /*!< re-entrance*/ } SBC_CHECK_REENTRANCE_e; @@ -291,7 +292,7 @@ extern void SBC_Trigger(SBC_STATE_s *pInstance) { if (pInstance->substate == SBC_ENTRY) { /* Init SBC */ - if (STD_NOT_OK == FS85X_InitFS(pInstance->pFs85xxInstance)) { + if (STD_NOT_OK == FS85_InitializeFsPhase(pInstance->pFs85xxInstance)) { /* Retry init if it fails */ pInstance->retryCounter++; if (pInstance->retryCounter > 3u) { @@ -313,7 +314,8 @@ extern void SBC_Trigger(SBC_STATE_s *pInstance) { /* Fault error counter is reset with valid watchdog refreshes * -> first get required numbers of refreshes */ uint8_t requiredWatchdogTrigger = 0; - if (STD_OK != FS85X_Init_ReqWDGRefreshes(pInstance->pFs85xxInstance, &requiredWatchdogTrigger)) { + if (STD_OK != FS85_InitializeNumberOfRequiredWatchdogRefreshes( + pInstance->pFs85xxInstance, &requiredWatchdogTrigger)) { /* Retry init if it fails */ pInstance->retryCounter++; if (pInstance->retryCounter > 3u) { @@ -331,7 +333,7 @@ extern void SBC_Trigger(SBC_STATE_s *pInstance) { } } else if (pInstance->substate == SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART2) { /* Check if fault error counter is zero */ - if (STD_OK != FS85X_CheckFaultErrorCounter(pInstance->pFs85xxInstance)) { + if (STD_OK != FS85_CheckFaultErrorCounter(pInstance->pFs85xxInstance)) { pInstance->retryCounter++; if (pInstance->retryCounter > 3u) { /* Goto error state */ @@ -345,7 +347,7 @@ extern void SBC_Trigger(SBC_STATE_s *pInstance) { pInstance->timer = SBC_STATEMACHINE_SHORTTIME; } } else if (pInstance->substate == SBC_INITIALIZE_SAFETY_PATH_CHECK) { - if (STD_NOT_OK == FS85X_SafetyPathChecks(pInstance->pFs85xxInstance)) { + if (STD_NOT_OK == FS85_SafetyPathChecks(pInstance->pFs85xxInstance)) { pInstance->retryCounter++; if (pInstance->retryCounter > 3u) { /* Goto error state */ diff --git a/src/app/driver/sbc/sbc.h b/src/app/driver/sbc/sbc.h index 1db91b23..078fd773 100644 --- a/src/app/driver/sbc/sbc.h +++ b/src/app/driver/sbc/sbc.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sbc.h * @author foxBMS Team * @date 2020-07-14 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SBC * @@ -105,20 +106,20 @@ #define SBC_WINDOW_WATCHDOG_PERIOD_MS (100u) /** State requests for the SYS statemachine */ -typedef enum SBC_STATE_REQUEST { +typedef enum { SBC_STATE_INIT_REQUEST, /*!< request to begin SBC initialization */ SBC_STATE_ERROR_REQUEST, /*!< request to switch SBC into error state */ SBC_STATE_NO_REQUEST, /*!< enum to clarify that currently no new request needs to be processed */ } SBC_STATE_REQUEST_e; /** State of watchdog state */ -typedef enum SBC_PERIODIC_WATCHDOG_STATE { +typedef enum { SBC_PERIODIC_WATCHDOG_ACTIVATED, SBC_PERIODIC_WATCHDOG_DEACTIVATED, } SBC_PERIODIC_WATCHDOG_STATE_e; /** Possible return values when state requests are made to the SYS statemachine */ -typedef enum SBC_RETURN_TYPE { +typedef enum { SBC_OK, /*!< sys --> ok */ SBC_BUSY_OK, /*!< sys busy --> ok */ SBC_REQUEST_PENDING, /*!< requested to be executed */ @@ -128,7 +129,7 @@ typedef enum SBC_RETURN_TYPE { } SBC_RETURN_TYPE_e; /** States of the SBC state machine */ -typedef enum SBC_STATEMACHINE { +typedef enum { /* Init-Sequence */ SBC_STATEMACHINE_UNINITIALIZED, /*!< statemachien start value */ SBC_STATEMACHINE_INITIALIZATION, /*!< SBC startup initialization process */ @@ -138,7 +139,7 @@ typedef enum SBC_STATEMACHINE { } SBC_STATEMACHINE_e; /** Substates of the SBC state machine */ -typedef enum SBC_STATEMACHINE_SUB { +typedef enum { SBC_ENTRY, /*!< Substate entry state */ SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART1, /*!< Substate during initialization to reset fault-error counter */ SBC_INIT_RESET_FAULT_ERROR_COUNTER_PART2, /*!< Substate during initialization to reset fault-error counter */ @@ -151,7 +152,7 @@ typedef enum SBC_STATEMACHINE_SUB { * This structure contains all the variables relevant for the SBC state machine. * The user can get the current state of the SBC state machine with this variable */ -typedef struct SBC_STATE { +typedef struct { uint16_t timer; /*!< time in ms before the state machine processes the next state, in counts of 10ms */ uint16_t watchdogTrigger; /*!< time in ms before the state machine triggers watchdog, in counts of 10ms */ SBC_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */ @@ -164,7 +165,7 @@ typedef struct SBC_STATE { uint8_t requestWatchdogTrigger; /*!< required watchdog triggers during init to correctly initialize SBC */ uint8_t triggerEntry; /*!< counter for re-entrance protection (function running flag) */ SBC_PERIODIC_WATCHDOG_STATE_e watchdogState; /*!< state if periodic watchdog trigger is required or not */ - FS85xx_STATE_s *pFs85xxInstance; /*!< pointer to FS85xx instance */ + FS85_STATE_s *pFs85xxInstance; /*!< pointer to FS85xx instance */ uint16_t watchdogPeriod_10ms; /*!< watchdog trigger frequency in 10ms */ } SBC_STATE_s; diff --git a/src/app/driver/spi/spi.c b/src/app/driver/spi/spi.c index 822f8526..37a4dd64 100644 --- a/src/app/driver/spi/spi.c +++ b/src/app/driver/spi/spi.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file spi.c * @author foxBMS Team * @date 2019-12-12 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SPI * @@ -61,7 +62,6 @@ #include "dma.h" #include "fsystem.h" #include "io.h" -#include "mcu.h" #include "os.h" static uint32_t spi_txLastWord[DMA_NUMBER_SPI_INTERFACES] = {0}; @@ -82,9 +82,11 @@ static uint32_t spi_txLastWord[DMA_NUMBER_SPI_INTERFACES] = {0}; extern STD_RETURN_TYPE_e SPI_TransmitDummyByte(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay) { FAS_ASSERT(pSpiInterface != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: delay: parameter accepts whole range */ + uint16_t txDummy[1] = {0x00}; STD_RETURN_TYPE_e retVal = SPI_TransmitData(pSpiInterface, txDummy, 1u); - MCU_delay_us(delay); + MCU_Delay_us(delay); return retVal; } @@ -222,17 +224,33 @@ extern STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma( FAS_ASSERT(pRxBuff != NULL_PTR); /** SPI over DMA currently only compatible with HW Chip Select */ FAS_ASSERT(pSpiInterface->csType == SPI_CHIP_SELECT_HARDWARE); - FAS_ASSERT(SPI_GetSpiIndex(pSpiInterface->pNode) < spi_nrBusyFlags); + const uint8_t spiIndex = SPI_GetSpiIndex(pSpiInterface->pNode); + FAS_ASSERT(spiIndex < spi_nrBusyFlags); STD_RETURN_TYPE_e retVal = STD_NOT_OK; OS_EnterTaskCritical(); /* Lock SPI hardware to prevent concurrent read/write commands */ - if (spi_busyFlags[SPI_GetSpiIndex(pSpiInterface->pNode)] == SPI_IDLE) { - spi_busyFlags[SPI_GetSpiIndex(pSpiInterface->pNode)] = SPI_BUSY; + if (spi_busyFlags[spiIndex] == SPI_IDLE) { + spi_busyFlags[spiIndex] = SPI_BUSY; /* Check that not SPI transmission over DMA is taking place */ if ((pSpiInterface->pNode->INT0 & DMAREQEN_BIT) == 0x0) { + /** + * Activate HW Chip Select according to bitmask register CSNR + * by setting pins as SPI functional pins + */ + /** First deactivate all HW Chip Selects */ + pSpiInterface->pNode->PC0 &= SPI_PC0_CLEAR_HW_CS_MASK; + for (uint8_t csNumber = 0u; csNumber < SPI_MAX_NUMBER_HW_CS; csNumber++) { + if (((pSpiInterface->pConfig->CSNR >> csNumber) & 0x1u) == 0u) { + /** Bitmask = 0 --> HW CS active + * --> write to PC0 to set pin as SPI pin (and not GIO) + */ + pSpiInterface->pNode->PC0 |= (uint32_t)1u << csNumber; + } + } + /* The upper 16 bits will be written in the SPI DAT1 register where they serve as configuration */ uint32 Chip_Select_Hold = 0u; if (pSpiInterface->pConfig->CS_HOLD == TRUE) { @@ -252,36 +270,29 @@ extern STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma( /* Go to privilege mode to write DMA config registers */ (void)FSYS_RaisePrivilege(); - spi_txLastWord[SPI_GetSpiIndex(pSpiInterface->pNode)] = pTxBuff[frameLength - 1u]; - spi_txLastWord[SPI_GetSpiIndex(pSpiInterface->pNode)] |= - ((uint32)DataFormat << SPI_DATA_FORMAT_FIELD_POSITION) | - ((uint32)ChipSelect << SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION) | (WDelay); + spi_txLastWord[spiIndex] = pTxBuff[frameLength - 1u]; + spi_txLastWord[spiIndex] |= ((uint32)DataFormat << SPI_DATA_FORMAT_FIELD_POSITION) | + ((uint32)ChipSelect << SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION) | (WDelay); /* Set Tx buffer address */ - dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel].ISADDR = + dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].txChannel].ISADDR = (uint32_t)(&pTxBuff[1u]); /* First word sent manually to write configuration in SPIDAT1 register */ /** * Set number of Tx words to send * Last word sent in ISR to set CSHOLD = 0 */ - dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel].ITCOUNT = + dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].txChannel].ITCOUNT = ((frameLength - 2u) << 16U) | 1U; /* Last word sent manually to write CSHOLD in SPIDAT1 register */ /* Set Rx buffer address */ - dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].rxChannel].IDADDR = - (uint32_t)pRxBuff; + dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].rxChannel].IDADDR = (uint32_t)pRxBuff; /* Set number of Rx words to receive */ - dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].rxChannel].ITCOUNT = - (frameLength << 16U) | 1U; + dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].rxChannel].ITCOUNT = (frameLength << 16U) | 1U; /* Re-enable channels; because auto-init is disabled */ /* Disable otherwise transmission is constantly ongoing */ - dmaSetChEnable( - (dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel, - (dmaTriggerType_t)DMA_HW); - dmaSetChEnable( - (dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].rxChannel, - (dmaTriggerType_t)DMA_HW); + dmaSetChEnable((dmaChannel_t)dma_spiDmaChannels[spiIndex].txChannel, (dmaTriggerType_t)DMA_HW); + dmaSetChEnable((dmaChannel_t)dma_spiDmaChannels[spiIndex].rxChannel, (dmaTriggerType_t)DMA_HW); /* DMA config registers written, leave privilege mode */ FSYS_SwitchToUserMode(); @@ -313,12 +324,14 @@ extern STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma( } extern STD_RETURN_TYPE_e SPI_Lock(uint8_t spi) { + /* AXIVION Routine Generic-MissingParameterAssert: spi: parameter accepts whole range */ + STD_RETURN_TYPE_e retVal = STD_NOT_OK; OS_EnterTaskCritical(); - if ((*(spi_busyFlags + spi) == SPI_IDLE) && (spi < spi_nrBusyFlags)) { - *(spi_busyFlags + spi) = SPI_BUSY; - retVal = STD_OK; + if ((spi < spi_nrBusyFlags) && (spi_busyFlags[spi] == SPI_IDLE)) { + spi_busyFlags[spi] = SPI_BUSY; + retVal = STD_OK; } else { retVal = STD_NOT_OK; } @@ -328,9 +341,11 @@ extern STD_RETURN_TYPE_e SPI_Lock(uint8_t spi) { } extern void SPI_Unlock(uint8_t spi) { + /* AXIVION Routine Generic-MissingParameterAssert: spi: parameter accepts whole range */ + OS_EnterTaskCritical(); if (spi < spi_nrBusyFlags) { - *(spi_busyFlags + spi) = SPI_IDLE; + spi_busyFlags[spi] = SPI_IDLE; } OS_ExitTaskCritical(); } @@ -406,7 +421,7 @@ extern STD_RETURN_TYPE_e SPI_SlaveSetReceiveDataDma( (frameLength << 16U) | 1U; /* Re-enable channels; because auto-init is disabled */ - /* Disable otherwise transmission is constantly ongoping */ + /* Disable otherwise transmission is constantly on going */ dmaSetChEnable( (dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel, (dmaTriggerType_t)DMA_HW); dmaSetChEnable( diff --git a/src/app/driver/spi/spi.h b/src/app/driver/spi/spi.h index 904b7521..64f25869 100644 --- a/src/app/driver/spi/spi.h +++ b/src/app/driver/spi/spi.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file spi.h * @author foxBMS Team * @date 2019-12-12 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SPI * diff --git a/src/app/driver/spi/spi_cfg-helper.h b/src/app/driver/spi/spi_cfg-helper.h index 8a80e5ec..5516c49c 100644 --- a/src/app/driver/spi/spi_cfg-helper.h +++ b/src/app/driver/spi/spi_cfg-helper.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file spi_cfg-helper.h * @author foxBMS Team * @date 2021-12-08 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS_CONFIGURATION * @prefix SPI * @@ -56,7 +57,7 @@ #define FOXBMS__SPI_CFG_HELPER_H_ /*========== Includes =======================================================*/ -#include "stdint.h" +#include /*========== Macros and Definitions =========================================*/ /** HW chip select bit position, TMS570LC4357 has maximum of six hardware chip diff --git a/src/app/driver/sps/sps.c b/src/app/driver/sps/sps.c index 64c995a4..2e71675b 100644 --- a/src/app/driver/sps/sps.c +++ b/src/app/driver/sps/sps.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sps.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SPS * @@ -432,9 +433,9 @@ static STD_RETURN_TYPE_e SPS_Transmit(void) { &spi_spsInterface, sps_spiTxRegisterBuffer, sps_spiRxRegisterBuffer, SPS_SPI_BUFFERSIZE); /* The chip select has to be high for at least 300ns according to data sheet. This code delays - for the smallest time available in #MCU_delay_us() which is 1us. After this time we can + for the smallest time available in #MCU_Delay_us() which is 1us. After this time we can be sure that the SPI interface is able to receive again. */ - MCU_delay_us(1u); + MCU_Delay_us(1u); STD_RETURN_TYPE_e retVal2 = SPI_TransmitReceiveData( &spi_spsInterface, @@ -443,7 +444,7 @@ static STD_RETURN_TYPE_e SPS_Transmit(void) { SPS_SPI_BUFFERSIZE); STD_RETURN_TYPE_e retVal = STD_NOT_OK; - if ((STD_OK == retVal1) && (STD_OK == retVal2)) { + if ((retVal1 == STD_OK) && (retVal2 == STD_OK)) { retVal = STD_OK; } return retVal; @@ -464,7 +465,7 @@ static void SPS_GlobalReadCurrent(const uint8_t outputAllDevices) { static void SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction) { FAS_ASSERT(channelIndex < SPS_NR_OF_AVAILABLE_SPS_CHANNELS); - FAS_ASSERT((SPS_CHANNEL_OFF == channelFunction) || (SPS_CHANNEL_ON == channelFunction)); + FAS_ASSERT((channelFunction == SPS_CHANNEL_OFF) || (channelFunction == SPS_CHANNEL_ON)); OS_EnterTaskCritical(); sps_channelStatus[channelIndex].channelRequested = channelFunction; @@ -503,7 +504,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_CONFIGURE_CONTROL_REGISTER); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_TRIGGER_CURRENT_MEASUREMENT; /* we have successfully configured the control registers to strong drive mode and can now go to high speed communication */ @@ -517,7 +518,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_TRIGGER_CURRENT_MEASUREMENT); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_READ_EN_IRQ_PIN; } else { sps_state = SPS_START; @@ -528,7 +529,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_READ_EN_IRQ_PIN); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_READ_MEASURED_CURRENT1; } else { sps_state = SPS_START; @@ -539,7 +540,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_READ_CURRENT_MEASUREMENT1); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_READ_MEASURED_CURRENT2; } else { sps_state = SPS_START; @@ -551,7 +552,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_READ_CURRENT_MEASUREMENT2); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_READ_MEASURED_CURRENT3; } else { sps_state = SPS_START; @@ -563,7 +564,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_READ_CURRENT_MEASUREMENT3); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_READ_MEASURED_CURRENT4; } else { sps_state = SPS_START; @@ -575,7 +576,7 @@ extern void SPS_Ctrl(void) { SPS_SetCommandTxBuffer(SPS_ACTION_READ_CURRENT_MEASUREMENT4); SPS_SetContactorsTxBuffer(); transmitRetval = SPS_Transmit(); - if (STD_OK == transmitRetval) { + if (transmitRetval == STD_OK) { sps_state = SPS_TRIGGER_CURRENT_MEASUREMENT; } else { sps_state = SPS_START; @@ -594,12 +595,14 @@ extern void SPS_Initialize(void) { } extern void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction) { - FAS_ASSERT(SPS_AFF_CONTACTOR == SPS_GetChannelAffiliation(channelIndex)); + const SPS_CHANNEL_AFFILIATION_e channelAffiliation = SPS_GetChannelAffiliation(channelIndex); + FAS_ASSERT(SPS_AFF_CONTACTOR == channelAffiliation); SPS_RequestChannelState(channelIndex, channelFunction); } -extern void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction) { - FAS_ASSERT(SPS_AFF_GENERAL_IO == SPS_GetChannelAffiliation(channelIndex)); +extern void SPS_RequestGeneralIoState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction) { + const SPS_CHANNEL_AFFILIATION_e channelAffiliation = SPS_GetChannelAffiliation(channelIndex); + FAS_ASSERT(SPS_AFF_GENERAL_IO == channelAffiliation); SPS_RequestChannelState(channelIndex, channelFunction); } diff --git a/src/app/driver/sps/sps.h b/src/app/driver/sps/sps.h index a496e5ea..806388b7 100644 --- a/src/app/driver/sps/sps.h +++ b/src/app/driver/sps/sps.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sps.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-10-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SPS * @@ -99,7 +100,7 @@ extern void SPS_RequestContactorState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNE * a SPS channel and it has to be affiliated with #SPS_AFF_GENERAL_IO * @param[in] channelFunction requested functional state of the channel */ -extern void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction); +extern void SPS_RequestGeneralIoState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_FUNCTION_e channelFunction); /** * @brief Get feedback value diff --git a/src/app/driver/sps/sps_types.h b/src/app/driver/sps/sps_types.h index 0a03acf3..feb3048b 100644 --- a/src/app/driver/sps/sps_types.h +++ b/src/app/driver/sps/sps_types.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sps_types.h * @author foxBMS Team * @date 2020-12-01 (date of creation) - * @updated 2020-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVERS * @prefix SPS * @@ -68,7 +69,7 @@ typedef uint8_t SPS_CHANNEL_INDEX; * general IO (or possibly something else in the future). This has * implication on the type of interface that may access the channel. */ -typedef enum SPS_CHANNEL_AFFILIATION { +typedef enum { SPS_AFF_CONTACTOR, /*!< affiliation of channel is contactor */ SPS_AFF_GENERAL_IO, /*!< affiliation of channel is general IO */ } SPS_CHANNEL_AFFILIATION_e; diff --git a/src/app/driver/ts/api/tsi.h b/src/app/driver/ts/api/tsi.h index a3eb1db6..6ba10843 100644 --- a/src/app/driver/ts/api/tsi.h +++ b/src/app/driver/ts/api/tsi.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file tsi.h * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix TSI * diff --git a/src/app/driver/ts/api/tsi_limits.c b/src/app/driver/ts/api/tsi_limits.c index 745dd69f..71f250a1 100644 --- a/src/app/driver/ts/api/tsi_limits.c +++ b/src/app/driver/ts/api/tsi_limits.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file tsi_limits.c * @author foxBMS Team * @date 2021-01-15 (date of creation) - * @updated 2021-01-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DRIVER * @prefix TSI * diff --git a/src/app/driver/ts/beta.c b/src/app/driver/ts/beta.c index 3d13eb12..3b2cf19b 100644 --- a/src/app/driver/ts/beta.c +++ b/src/app/driver/ts/beta.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file beta.c * @author foxBMS Team * @date 2020-01-17 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix BETA * @@ -80,9 +81,9 @@ (float)((BETA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * BETA_ResistanceFromTemperature(-400)) / (BETA_ResistanceFromTemperature(-400) + BETA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) #else /* BETA_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ #define BETA_ADC_VOLTAGE_V_MIN_V \ - (float)((BETA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * BETA_ResistanceFromTemperature(1400)) / (BETA_ResistanceFromTemperature(1400) + BETA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((BETA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * BETA_ResistanceFromTemperature(1400)) / (BETA_ResistanceFromTemperature(1400) + BETA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #define BETA_ADC_VOLTAGE_V_MAX_V \ - (float)((BETA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * BETA_ResistanceFromTemperature(-400)) / (BETA_ResistanceFromTemperature(-400) + BETA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((BETA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * BETA_ResistanceFromTemperature(-400)) / (BETA_ResistanceFromTemperature(-400) + BETA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #endif /**@}*/ @@ -94,7 +95,7 @@ extern int16_t BETA_GetTemperatureFromBeta(uint16_t adcVoltage_mV) { int16_t temperature_ddegC = 0; - float resistance_Ohm = 0.0; + float resistance_Ohm = 0.0f; float adcVoltage_V = (float)adcVoltage_mV / 1000.0f; /* Convert mV to V */ /* Check for valid ADC measurements to prevent undefined behavior */ @@ -126,8 +127,8 @@ extern int16_t BETA_GetTemperatureFromBeta(uint16_t adcVoltage_mV) { extern int16_t BETA_TemperatureFromResistance(float resistance_Ohm) { int16_t temperature_ddegC = 0; if (resistance_Ohm > 0.0f) { - float temperature_degC = (1.0 / ((log(resistance_Ohm / BETA_R_REF_Ohm) / BETA_BETACOEFFICIENT) + - (1.0 / (BETA_T_REF_C + BETA_KELVIN)))) - + float temperature_degC = (1.0f / ((log(resistance_Ohm / BETA_R_REF_Ohm) / BETA_BETACOEFFICIENT) + + (1.0f / (BETA_T_REF_C + BETA_KELVIN)))) - BETA_KELVIN; temperature_ddegC = (int16_t)(10.0f * temperature_degC); /* Convert to deci °C */ } else { diff --git a/src/app/driver/ts/beta.h b/src/app/driver/ts/beta.h index 855118bc..798c88f4 100644 --- a/src/app/driver/ts/beta.h +++ b/src/app/driver/ts/beta.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file beta.h * @author foxBMS Team * @date 2020-01-17 (date of creation) - * @updated 2021-02-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix BETA * diff --git a/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.c b/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.c index 373817a2..5442c2f4 100644 --- a/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.c +++ b/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57251v5103j060.c * @author foxBMS Team * @date 2018-10-30 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * @@ -125,14 +126,14 @@ static uint16_t b57251v5103j060LutSize = sizeof(ts_b57251v5103j060Lut) / sizeof( /**@{*/ #if TS_EPCOS_B57251V5103J060_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == true #define TS_EPCOS_B57251V5103J060_ADC_VOLTAGE_V_MAX_V \ - (float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm) / (ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm) / (ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #define TS_EPCOS_B57251V5103J060_ADC_VOLTAGE_V_MIN_V \ - (float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[0].resistance_Ohm) / (ts_b57251v5103j060Lut[0].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[0].resistance_Ohm) / (ts_b57251v5103j060Lut[0].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #else /* TS_EPCOS_B57251V5103J060_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ #define TS_EPCOS_B57251V5103J060_ADC_VOLTAGE_V_MIN_V \ - (float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm) / (ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm) / (ts_b57251v5103j060Lut[b57251v5103j060LutSize-1].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #define TS_EPCOS_B57251V5103J060_ADC_VOLTAGE_V_MAX_V \ - (float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[0].resistance_Ohm) / (ts_b57251v5103j060Lut[0].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57251v5103j060Lut[0].resistance_Ohm) / (ts_b57251v5103j060Lut[0].resistance_Ohm+TS_EPCOS_B57251V5103J060_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #endif /**@}*/ @@ -143,6 +144,8 @@ static uint16_t b57251v5103j060LutSize = sizeof(ts_b57251v5103j060Lut) / sizeof( /*========== Extern Function Implementations ================================*/ extern int16_t TS_Epc00GetTemperatureFromLut(uint16_t adcVoltage_mV) { + /* AXIVION Routine Generic-MissingParameterAssert: adcVoltage_mV: parameter accepts whole range */ + int16_t temperature_ddegC = 0; float resistance_Ohm = 0.0f; float adcVoltage_V = adcVoltage_mV / 1000.0f; /* Convert mV to V */ @@ -193,6 +196,8 @@ extern int16_t TS_Epc00GetTemperatureFromLut(uint16_t adcVoltage_mV) { } extern int16_t TS_Epc00GetTemperatureFromPolynomial(uint16_t adcVoltage_mV) { + /* AXIVION Routine Generic-MissingParameterAssert: adcVoltage_mV: parameter accepts whole range */ + float temperature_degC = 0.0; float vadc_V = adcVoltage_mV / 1000.0; float vadc2 = vadc_V * vadc_V; diff --git a/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.h b/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.h index 2b4072d6..f36ebcea 100644 --- a/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.h +++ b/src/app/driver/ts/epcos/b57251v5103j060/epcos_b57251v5103j060.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57251v5103j060.h * @author foxBMS Team * @date 2018-10-30 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/epcos/b57251v5103j060/lookup-table/epcos_b57251v5103j060_lookup-table.c b/src/app/driver/ts/epcos/b57251v5103j060/lookup-table/epcos_b57251v5103j060_lookup-table.c index 7338b453..e6e80ca7 100644 --- a/src/app/driver/ts/epcos/b57251v5103j060/lookup-table/epcos_b57251v5103j060_lookup-table.c +++ b/src/app/driver/ts/epcos/b57251v5103j060/lookup-table/epcos_b57251v5103j060_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57251v5103j060_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/epcos/b57251v5103j060/polynomial/epcos_b57251v5103j060_polynomial.c b/src/app/driver/ts/epcos/b57251v5103j060/polynomial/epcos_b57251v5103j060_polynomial.c index 95536bc4..6f6f20b7 100644 --- a/src/app/driver/ts/epcos/b57251v5103j060/polynomial/epcos_b57251v5103j060_polynomial.c +++ b/src/app/driver/ts/epcos/b57251v5103j060/polynomial/epcos_b57251v5103j060_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57251v5103j060_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.c b/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.c index 17f4cae7..ab3d5ff5 100644 --- a/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.c +++ b/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57861s0103f045.c * @author foxBMS Team * @date 2018-10-30 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * @@ -131,9 +132,9 @@ static uint16_t ts_b57861s0103f045LutSize = sizeof(ts_b57861s0103f045Lut) / size (float)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[0].resistance_Ohm) / (ts_b57861s0103f045Lut[0].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) #else /* TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ #define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MIN_V \ - (float)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize-1].resistance_Ohm) / (ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize-1].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize-1].resistance_Ohm) / (ts_b57861s0103f045Lut[ts_b57861s0103f045LutSize-1].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #define TS_EPCOS_B57861S0103F045_ADC_VOLTAGE_V_MAX_V \ - (float)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[0].resistance_Ohm) / (ts_b57861s0103f045Lut[0].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_b57861s0103f045Lut[0].resistance_Ohm) / (ts_b57861s0103f045Lut[0].resistance_Ohm+TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #endif /**@}*/ @@ -157,15 +158,15 @@ extern int16_t TS_Epc01GetTemperatureFromLut(uint16_t adcVoltage_mV) { temperature_ddegC = INT16_MAX; } else { /* Calculate NTC resistance based on measured ADC voltage */ -#if B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == true +#if TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == true /* R_1 = R_2 * ( ( V_supply / V_adc ) - 1 ) */ resistance_Ohm = TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm * ((TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V / adcVoltage_V) - 1); -#else /* B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ +#else /* TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ /* R_2 = R_1 * ( V_2 / ( V_supply - V_adc ) ) */ resistance_Ohm = TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm * (adcVoltage_V / (TS_EPCOS_B57861S0103F045_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V - adcVoltage_V)); -#endif /* B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 */ +#endif /* TS_EPCOS_B57861S0103F045_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 */ /* Variables for interpolating LUT value */ uint16_t between_high = 0; diff --git a/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.h b/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.h index dce49d02..6ad40089 100644 --- a/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.h +++ b/src/app/driver/ts/epcos/b57861s0103f045/epcos_b57861s0103f045.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57861s0103f045.h * @author foxBMS Team * @date 2018-10-30 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/epcos/b57861s0103f045/lookup-table/epcos_b57861s0103f045_lookup-table.c b/src/app/driver/ts/epcos/b57861s0103f045/lookup-table/epcos_b57861s0103f045_lookup-table.c index d5b83c8d..743ae2b9 100644 --- a/src/app/driver/ts/epcos/b57861s0103f045/lookup-table/epcos_b57861s0103f045_lookup-table.c +++ b/src/app/driver/ts/epcos/b57861s0103f045/lookup-table/epcos_b57861s0103f045_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57861s0103f045_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/epcos/b57861s0103f045/polynomial/epcos_b57861s0103f045_polynomial.c b/src/app/driver/ts/epcos/b57861s0103f045/polynomial/epcos_b57861s0103f045_polynomial.c index 94e99120..edf3aa9d 100644 --- a/src/app/driver/ts/epcos/b57861s0103f045/polynomial/epcos_b57861s0103f045_polynomial.c +++ b/src/app/driver/ts/epcos/b57861s0103f045/polynomial/epcos_b57861s0103f045_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file epcos_b57861s0103f045_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/fake/none/fake_none.c b/src/app/driver/ts/fake/none/fake_none.c index 6901b7f5..87d0deec 100644 --- a/src/app/driver/ts/fake/none/fake_none.c +++ b/src/app/driver/ts/fake/none/fake_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fake_none.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/fake/none/fake_none.h b/src/app/driver/ts/fake/none/fake_none.h index 6f4e71ae..0fdfe912 100644 --- a/src/app/driver/ts/fake/none/fake_none.h +++ b/src/app/driver/ts/fake/none/fake_none.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fake_none.h * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/fake/none/lookup-table/fake_none_lookup-table.c b/src/app/driver/ts/fake/none/lookup-table/fake_none_lookup-table.c index dbf15d9f..b7fd7c98 100644 --- a/src/app/driver/ts/fake/none/lookup-table/fake_none_lookup-table.c +++ b/src/app/driver/ts/fake/none/lookup-table/fake_none_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fake_none_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/fake/none/polynomial/fake_none_polynomial.c b/src/app/driver/ts/fake/none/polynomial/fake_none_polynomial.c index cf14848d..ac15d0fd 100644 --- a/src/app/driver/ts/fake/none/polynomial/fake_none_polynomial.c +++ b/src/app/driver/ts/fake/none/polynomial/fake_none_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fake_none_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/temperature_sensor_defs.h b/src/app/driver/ts/temperature_sensor_defs.h index 776d2bf5..185fe205 100644 --- a/src/app/driver/ts/temperature_sensor_defs.h +++ b/src/app/driver/ts/temperature_sensor_defs.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file temperature_sensor_defs.h * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * @@ -62,7 +63,7 @@ #define TS_SCALING_FACTOR_1V_IN_MV_FLOAT (1000.0f) /** temperature-resistance lookup table*/ -typedef struct TS_TEMPERATURE_SENSOR_LUT { +typedef struct { int16_t temperature_ddegC; /*!< temperature in deci °C */ float resistance_Ohm; /*!< resistance in ohms */ } TS_TEMPERATURE_SENSOR_LUT_s; diff --git a/src/app/driver/ts/vishay/ntcalug01a103g/lookup-table/vishay_ntcalug01a103g_lookup-table.c b/src/app/driver/ts/vishay/ntcalug01a103g/lookup-table/vishay_ntcalug01a103g_lookup-table.c index 36a7a2d7..2133f9dc 100644 --- a/src/app/driver/ts/vishay/ntcalug01a103g/lookup-table/vishay_ntcalug01a103g_lookup-table.c +++ b/src/app/driver/ts/vishay/ntcalug01a103g/lookup-table/vishay_ntcalug01a103g_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcalug01a103g_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/vishay/ntcalug01a103g/polynomial/vishay_ntcalug01a103g_polynomial.c b/src/app/driver/ts/vishay/ntcalug01a103g/polynomial/vishay_ntcalug01a103g_polynomial.c index 497f7731..dea1da52 100644 --- a/src/app/driver/ts/vishay/ntcalug01a103g/polynomial/vishay_ntcalug01a103g_polynomial.c +++ b/src/app/driver/ts/vishay/ntcalug01a103g/polynomial/vishay_ntcalug01a103g_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcalug01a103g_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-02-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.c b/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.c index 23ed7c4f..2ab7c0d5 100644 --- a/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.c +++ b/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcalug01a103g.c * @author foxBMS Team * @date 2018-10-30 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * @@ -234,9 +235,9 @@ static const uint16_t ts_ntcalug01a103gLutSize = sizeof(ts_ntcalug01a103gLut) / (float)((TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_ntcalug01a103gLut[0].resistance_Ohm) / (ts_ntcalug01a103gLut[0].resistance_Ohm+TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) #else /* TS_VISHAY_NTCALUG01A103G_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ #define TS_VISHAY_NTCALUG01A103G_ADC_VOLTAGE_V_MIN_V \ - (float)((TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_ntcalug01a103gLut[ts_ntcalug01a103gLutSize-1].resistance_Ohm) / (ts_ntcalug01a103gLut[ts_ntcalug01a103gLutSize-1].resistance_Ohm+TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_ntcalug01a103gLut[ts_ntcalug01a103gLutSize-1].resistance_Ohm) / (ts_ntcalug01a103gLut[ts_ntcalug01a103gLutSize-1].resistance_Ohm+TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #define TS_VISHAY_NTCALUG01A103G_ADC_VOLTAGE_V_MAX_V \ - (float)((TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_ntcalug01a103gLut[0].resistance_Ohm) / (ts_ntcalug01a103gLut[0].resistance_Ohm+TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm)) + ((float)((TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V * ts_ntcalug01a103gLut[0].resistance_Ohm) / (ts_ntcalug01a103gLut[0].resistance_Ohm+TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm))) #endif /**@}*/ @@ -248,7 +249,7 @@ static const uint16_t ts_ntcalug01a103gLutSize = sizeof(ts_ntcalug01a103gLut) / extern int16_t TS_Vis00GetTemperatureFromLut(uint16_t adcVoltage_mV) { int16_t temperature_ddegC = 0; - float resistance_Ohm = 0.0; + float resistance_Ohm = 0.0f; float adcVoltage_V = adcVoltage_mV / 1000.0f; /* Convert mV to V */ /* Check for valid ADC measurements to prevent undefined behavior */ @@ -264,11 +265,11 @@ extern int16_t TS_Vis00GetTemperatureFromLut(uint16_t adcVoltage_mV) { /* R_1 = R_2 * ( ( V_supply / V_adc ) - 1 ) */ resistance_Ohm = TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm * ((TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V / adcVoltage_V) - 1); -#else /* NTCALUG01A103G_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ +#else /* TS_VISHAY_NTCALUG01A103G_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 == false */ /* R_2 = R_1 * ( V_2 / ( V_supply - V_adc ) ) */ resistance_Ohm = TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm * (adcVoltage_V / (TS_VISHAY_NTCALUG01A103G_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V - adcVoltage_V)); -#endif /* NTCALUG01A103G_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 */ +#endif /* TS_VISHAY_NTCALUG01A103G_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 */ /* Variables for interpolating LUT value */ uint16_t between_high = 0; diff --git a/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.h b/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.h index 29af280c..7fb0eadb 100644 --- a/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.h +++ b/src/app/driver/ts/vishay/ntcalug01a103g/vishay_ntcalug01a103g.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcalug01a103g.h * @author foxBMS Team * @date 2018-10-30 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/vishay_ntcle317e4103sba_lookup-table.c b/src/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/vishay_ntcle317e4103sba_lookup-table.c index 7afa0471..61f2deec 100644 --- a/src/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/vishay_ntcle317e4103sba_lookup-table.c +++ b/src/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/vishay_ntcle317e4103sba_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcle317e4103sba_lookup-table.c * @author foxBMS Team * @date 2021-11-03 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.c b/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.c index 54f5497b..a5481b19 100644 --- a/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.c +++ b/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcle317e4103sba.c * @author foxBMS Team * @date 2021-11-03 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * @@ -151,12 +152,12 @@ extern int16_t TS_Vis01GetTemperatureFromLut(uint16_t adcVoltage_mV) { const float resistance_Ohm = TS_VISHAY_NTCLE317E4103SBA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm * ((TS_VISHAY_NTCLE317E4103SBA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V / adcVoltage_V) - 1); -#else /* NTCLE317E4103SBA_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 is false */ +#else /* TS_VISHAY_NTCLE317E4103SBA_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 is false */ /* formula: R_2 = R_1 * ( V_2 / ( V_supply - V_adc ) ) */ const float resistance_Ohm = TS_VISHAY_NTCLE317E4103SBA_RESISTOR_DIVIDER_RESISTANCE_R_1_R_2_Ohm * (adcVoltage_V / (TS_VISHAY_NTCLE317E4103SBA_RESISTOR_DIVIDER_SUPPLY_VOLTAGE_V - adcVoltage_V)); -#endif /* NTCLE317E4103SBA_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 */ +#endif /* TS_VISHAY_NTCLE317E4103SBA_POSITION_IN_RESISTOR_DIVIDER_IS_R_1 */ /* Variables for interpolating LUT value */ uint16_t between_high = 0; diff --git a/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.h b/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.h index 43c69791..ed549f17 100644 --- a/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.h +++ b/src/app/driver/ts/vishay/ntcle317e4103sba/vishay_ntcle317e4103sba.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file vishay_ntcle317e4103sba.h * @author foxBMS Team * @date 2021-10-29 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TEMPERATURE_SENSORS * @prefix TS * diff --git a/src/app/driver/wscript b/src/app/driver/wscript index 3a86e274..7906cb5d 100644 --- a/src/app/driver/wscript +++ b/src/app/driver/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -64,6 +64,7 @@ def build(bld): os.path.join("can", "cbs", "can_cbs_tx_temperature.c"), os.path.join("can", "cbs", "can_cbs_tx_minmax.c"), os.path.join("checksum", "checksum.c"), + os.path.join("crc", "crc.c"), os.path.join("config", "contactor_cfg.c"), os.path.join("config", "can_cfg.c"), os.path.join("config", "dma_cfg.c"), @@ -115,6 +116,7 @@ def build(bld): "config", "checksum", "contactor", + "crc", "dma", "foxmath", "fram", @@ -150,6 +152,7 @@ def build(bld): os.path.join("..", "engine", "database"), os.path.join("..", "engine", "diag"), os.path.join("..", "engine", "hwinfo"), + os.path.join("..", "engine", "sys_mon"), os.path.join("..", "main", "include", "config"), os.path.join("..", "main", "include"), os.path.join("..", "main"), diff --git a/src/app/engine/config/database_cfg.c b/src/app/engine/config/database_cfg.c index 85eb0776..e3b8cbe0 100644 --- a/src/app/engine/config/database_cfg.c +++ b/src/app/engine/config/database_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file database_cfg.c * @author foxBMS Team * @date 2015-08-18 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix DATA * diff --git a/src/app/engine/config/database_cfg.h b/src/app/engine/config/database_cfg.h index 7f74fb25..2eb5779c 100644 --- a/src/app/engine/config/database_cfg.h +++ b/src/app/engine/config/database_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file database_cfg.h * @author foxBMS Team * @date 2015-08-18 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix DATA * @@ -61,15 +62,17 @@ #include "battery_system_cfg.h" +#include "mcu.h" + /*========== Macros and Definitions =========================================*/ /** configuration struct of database channel (data block) */ -typedef struct DATA_BASE { +typedef struct { void *pDatabaseEntry; /*!< pointer to the database entry */ - uint32_t datalength; /*!< length of the entry */ + uint32_t dataLength; /*!< length of the entry */ } DATA_BASE_s; /** data block identification numbers */ -typedef enum DATA_BLOCK_ID { +typedef enum { DATA_BLOCK_ID_CELL_VOLTAGE, DATA_BLOCK_ID_CELL_TEMPERATURE, DATA_BLOCK_ID_MIN_MAX, @@ -106,44 +109,50 @@ typedef enum DATA_BLOCK_ID { DATA_BLOCK_ID_MAX, /**< DO NOT CHANGE, MUST BE THE LAST ENTRY */ } DATA_BLOCK_ID_e; +f_static_assert( + (int16_t)DATA_BLOCK_ID_MAX < UINT8_MAX, + "Maximum number of database entries exceeds UINT8_MAX; adapted length " + "checking in DATA_Initialize and DATA_IterateOverDatabaseEntries"); + /** data block header */ -typedef struct DATA_BLOCKHEADER { +typedef struct { DATA_BLOCK_ID_e uniqueId; /*!< uniqueId of database entry */ uint32_t timestamp; /*!< timestamp of last database update */ uint32_t previousTimestamp; /*!< timestamp of previous database update */ } DATA_BLOCK_HEADER_s; /** data block struct of cell voltage */ -typedef struct DATA_BLOCK_CELL_VOLTAGE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t state; /*!< for future use */ - int32_t packVoltage_mV[BS_NR_OF_STRINGS]; /*!< uint: mV */ - int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]; /*!< unit: mV */ - uint64_t invalidCellVoltage[BS_NR_OF_STRINGS] - [BS_NR_OF_MODULES]; /*!< bitmask if voltages are valid. 0->valid, 1->invalid */ - uint16_t nrValidCellVoltages[BS_NR_OF_STRINGS]; /*!< number of valid voltages */ - uint32_t moduleVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_MODULES]; /*!< unit: mV */ - bool validModuleVoltage[BS_NR_OF_STRINGS][BS_NR_OF_MODULES]; /*!< 0 -> if PEC okay; 1 -> PEC error */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t state; /*!< for future use */ + int32_t packVoltage_mV[BS_NR_OF_STRINGS]; /*!< uint: mV */ + int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_CELL_BLOCKS_PER_STRING]; /*!< unit: mV */ + uint64_t + invalidCellVoltage[BS_NR_OF_STRINGS] + [BS_NR_OF_MODULES_PER_STRING]; /*!< bitmask if voltages are valid. 0->valid, 1->invalid */ + uint16_t nrValidCellVoltages[BS_NR_OF_STRINGS]; /*!< number of valid voltages */ + uint32_t moduleVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]; /*!< unit: mV */ + bool validModuleVoltage[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]; /*!< 0 -> if PEC okay; 1 -> PEC error */ } DATA_BLOCK_CELL_VOLTAGE_s; /** data block struct of cell temperatures */ -typedef struct DATA_BLOCK_CELL_TEMPERATURE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ DATA_BLOCK_HEADER_s header; /*!< Data block header */ uint8_t state; /*!< for future use */ int16_t cellTemperature_ddegC[BS_NR_OF_STRINGS][BS_NR_OF_TEMP_SENSORS_PER_STRING]; /*!< unit: deci °C */ - uint16_t invalidCellTemperature[BS_NR_OF_STRINGS] - [BS_NR_OF_MODULES]; /*!< bitmask if temperatures are valid. 0->valid, 1->invalid */ - uint16_t nrValidTemperatures[BS_NR_OF_STRINGS]; /*!< number of valid temperatures in each string */ + uint16_t invalidCellTemperature + [BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]; /*!< bitmask if temperatures are valid. 0->valid, 1->invalid */ + uint16_t nrValidTemperatures[BS_NR_OF_STRINGS]; /*!< number of valid temperatures in each string */ } DATA_BLOCK_CELL_TEMPERATURE_s; /** data block struct of minimum and maximum values */ -typedef struct DATA_BLOCK_MIN_MAX { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -171,7 +180,7 @@ typedef struct DATA_BLOCK_MIN_MAX { } DATA_BLOCK_MIN_MAX_s; /** data block struct of pack measurement values */ -typedef struct DATA_BLOCK_PACK_VALUES { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -195,7 +204,7 @@ typedef struct DATA_BLOCK_PACK_VALUES { } DATA_BLOCK_PACK_VALUES_s; /** data block struct of current measurement */ -typedef struct DATA_BLOCK_CURRENT_SENSOR { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -231,59 +240,62 @@ typedef struct DATA_BLOCK_CURRENT_SENSOR { } DATA_BLOCK_CURRENT_SENSOR_s; /** data structure declaration of DATA_BLOCK_BALANCING_CONTROL */ -typedef struct DATA_BLOCK_BALANCING_CONTROL { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t enableBalancing; /*!< Switch for enabling/disabling balancing */ - uint8_t threshold_mV; /*!< balancing threshold in mV */ - uint8_t request; /*!< balancing request per CAN */ - uint8_t balancingState[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]; /*!< 0: no balancing, 1: balancing active */ - uint32_t deltaCharge_mAs[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]; /*!< Difference in Depth-of-Discharge in mAs */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t enableBalancing; /*!< Switch for enabling/disabling balancing */ + uint8_t threshold_mV; /*!< balancing threshold in mV */ + uint8_t request; /*!< balancing request per CAN */ + uint8_t balancingState[BS_NR_OF_STRINGS] + [BS_NR_OF_CELL_BLOCKS_PER_STRING]; /*!< 0: no balancing, 1: balancing active */ + uint32_t deltaCharge_mAs[BS_NR_OF_STRINGS] + [BS_NR_OF_CELL_BLOCKS_PER_STRING]; /*!< Difference in Depth-of-Discharge in mAs */ uint16_t nrBalancedCells[BS_NR_OF_STRINGS]; } DATA_BLOCK_BALANCING_CONTROL_s; /** data structure declaration of DATA_BLOCK_USER_IO_CONTROL */ -typedef struct DATA_BLOCK_SLAVE_CONTROL { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t state; /*!< for future use */ - uint32_t eepromReadAddressToUse; /*!< address to read from for slave EEPROM */ - uint32_t eepromReadAddressLastUsed; /*!< last address used to read fromfor slave EEPROM */ - uint32_t eepromWriteAddressToUse; /*!< address to write to for slave EEPROM */ - uint32_t eepromWriteAddressLastUsed; /*!< last address used to write to for slave EEPROM */ - uint8_t ioValueOut[BS_NR_OF_MODULES]; /*!< data to be written to the port expander */ - uint8_t ioValueIn[BS_NR_OF_MODULES]; /*!< data read from to the port expander */ - uint8_t eepromValueWrite[BS_NR_OF_MODULES]; /*!< data to be written to the slave EEPROM */ - uint8_t eepromValueRead[BS_NR_OF_MODULES]; /*!< data read from to the slave EEPROM */ - uint8_t externalTemperatureSensor[BS_NR_OF_MODULES]; /*!< temperature from the external sensor on slave */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t state; /*!< for future use */ + uint32_t eepromReadAddressToUse; /*!< address to read from for slave EEPROM */ + uint32_t eepromReadAddressLastUsed; /*!< last address used to read fromfor slave EEPROM */ + uint32_t eepromWriteAddressToUse; /*!< address to write to for slave EEPROM */ + uint32_t eepromWriteAddressLastUsed; /*!< last address used to write to for slave EEPROM */ + uint8_t ioValueOut[BS_NR_OF_MODULES_PER_STRING]; /*!< data to be written to the port expander */ + uint8_t ioValueIn[BS_NR_OF_MODULES_PER_STRING]; /*!< data read from to the port expander */ + uint8_t eepromValueWrite[BS_NR_OF_MODULES_PER_STRING]; /*!< data to be written to the slave EEPROM */ + uint8_t eepromValueRead[BS_NR_OF_MODULES_PER_STRING]; /*!< data read from to the slave EEPROM */ + uint8_t + externalTemperatureSensor[BS_NR_OF_MODULES_PER_STRING]; /*!< temperature from the external sensor on slave */ } DATA_BLOCK_SLAVE_CONTROL_s; /** data block struct of cell balancing feedback */ -typedef struct DATA_BLOCK_BALANCING_FEEDBACK { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t state; /*!< for future use */ - uint16_t value[BS_NR_OF_STRINGS][BS_NR_OF_MODULES]; /*!< unit: mV (optocoupler output) */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t state; /*!< for future use */ + uint16_t value[BS_NR_OF_STRINGS][BS_NR_OF_MODULES_PER_STRING]; /*!< unit: mV (optocoupler output) */ } DATA_BLOCK_BALANCING_FEEDBACK_s; /** data block struct of user multiplexer values */ -typedef struct DATA_BLOCK_USER_MUX { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t state; /*!< for future use */ - uint16_t value[BS_NR_OF_STRINGS][8u * 2u * BS_NR_OF_MODULES]; /*!< unit: mV (mux voltage input) */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t state; /*!< for future use */ + uint16_t value[BS_NR_OF_STRINGS][8u * 2u * BS_NR_OF_MODULES_PER_STRING]; /*!< unit: mV (mux voltage input) */ } DATA_BLOCK_USER_MUX_s; /** data block struct of cell open wire */ -typedef struct DATA_BLOCK_OPENWIRE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -291,48 +303,57 @@ typedef struct DATA_BLOCK_OPENWIRE { uint8_t state; /*!< for future use */ uint16_t nrOpenWires[BS_NR_OF_STRINGS]; /*!< number of open wires */ uint8_t openwire[BS_NR_OF_STRINGS] - [BS_NR_OF_MODULES * (BS_NR_OF_CELLS_PER_MODULE + 1u)]; /*!< 1 -> open wire, 0 -> everything ok */ + [BS_NR_OF_MODULES_PER_STRING * + (BS_NR_OF_CELL_BLOCKS_PER_MODULE + 1u)]; /*!< 1 -> open wire, 0 -> everything ok */ } DATA_BLOCK_OPEN_WIRE_s; /** data block struct of GPIO voltage */ -typedef struct DATA_BLOCK_ALL_GPIO_VOLTAGES { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t state; /*!< for future use */ - uint16_t gpioVoltages_mV[BS_NR_OF_STRINGS][BS_NR_OF_MODULES * BS_NR_OF_GPIOS_PER_MODULE]; /*!< unit: mV */ - uint16_t invalidGpioVoltages[BS_NR_OF_STRINGS] - [BS_NR_OF_MODULES]; /*!< bitmask if voltages are valid. 0->valid, 1->invalid */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t state; /*!< for future use */ + uint16_t gpioVoltages_mV[BS_NR_OF_STRINGS] + [BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_GPIOS_PER_MODULE]; /*!< unit: mV */ + uint16_t + invalidGpioVoltages[BS_NR_OF_STRINGS] + [BS_NR_OF_MODULES_PER_STRING]; /*!< bitmask if voltages are valid. 0->valid, 1->invalid */ } DATA_BLOCK_ALL_GPIO_VOLTAGES_s; /** data block struct of error flags */ -typedef struct DATA_BLOCK_ERRORSTATE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t currentSensor[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error, not responding */ - uint8_t stringContactor[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error, not responding */ - uint8_t prechargeContactor[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error, not responding */ - uint8_t interlock; /*!< 0 -> no error, 1 -> error */ - uint8_t crcError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t muxError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t spiError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t afeConfigurationError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t afeCellvoltageError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t afeCellTemperatureError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t baseCellVoltageMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ - uint8_t redundancy0CellVoltageMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ - uint8_t baseCellTemperatureMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ - uint8_t redundancy0CellTemperatureMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ - uint8_t currentMeasurementTimeout[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t currentMeasurementError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t currentSensorTimeoutV1[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t currentSensorTimeoutV3[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t currentSensorPowerTimeout[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t powerMeasurementError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t insulationError; /*!< 0 -> no error, 1 -> error */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t currentSensor[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error, not responding */ + uint8_t stringContactor[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error, not responding */ + uint8_t prechargeContactor[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error, not responding */ + uint8_t interlock; /*!< 0 -> no error, 1 -> error */ + uint8_t crcError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t muxError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t spiError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t afeConfigurationError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t afeCellvoltageError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t afeCellTemperatureError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t baseCellVoltageMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ + uint8_t redundancy0CellVoltageMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ + uint8_t baseCellTemperatureMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ + uint8_t redundancy0CellTemperatureMeasurementTimeout; /*!< 0 -> no error, 1 -> error */ + uint8_t currentMeasurementTimeout[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t currentMeasurementError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t currentSensorTimeoutV1[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t currentSensorTimeoutV3[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t currentSensorPowerTimeout[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + uint8_t powerMeasurementError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ + bool insulationMeasurementValid; /*!< false -> not valid, true -> valid */ + bool + criticalLowInsulationResistance; /*!< false -> no critical resistance measured, true -> critical low resistance measured */ + bool + warnableLowInsulationResistance; /*!< false -> no warnable resistance measured, true -> warnable low resistance measured */ + bool + insulationGroundFaultDetected; /*!< false -> no insulation fault between HV and chassis detected, true -> insulation fault detected */ uint8_t fuseStateNormal[BS_NR_OF_STRINGS]; /*!< 0 -> fuse ok, 1 -> fuse tripped */ uint8_t fuseStateCharge[BS_NR_OF_STRINGS]; /*!< 0 -> fuse ok, 1 -> fuse tripped */ uint8_t open_wire[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ @@ -349,13 +370,19 @@ typedef struct DATA_BLOCK_ERRORSTATE { uint8_t plausibilityCheckCelltemperature[BS_NR_OF_STRINGS]; /*!< 0 -> no error, else: error */ uint8_t deepDischargeDetected[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ uint8_t currentOnOpenString[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t sbcFinState; /*!< 0 -> okay, 1 -> error: short-circuit to RSTB */ - uint8_t sbcRstbState; /*!< 0 -> okay, 1 -> error: RSTB not working */ - uint8_t i2cPexError; /*!< the I2C port expander does not work as expected */ + uint8_t sbcFinState; /*!< 0 -> okay, 1 -> error: short-circuit to RSTB */ + uint8_t sbcRstbState; /*!< 0 -> okay, 1 -> error: RSTB not working */ + uint8_t i2cPexError; /*!< the I2C port expander does not work as expected */ + uint8_t framReadCrcError; /*!< 0 if read CRC matches with CRC of read data , 1 otherwise */ + bool timingViolationEngine; /*!< timing violation in engine task */ + bool timingViolation1ms; /*!< timing violation in 1ms task */ + bool timingViolation10ms; /*!< timing violation in 10ms task */ + bool timingViolation100ms; /*!< timing violation in 100ms task */ + bool timingViolation100msAlgo; /*!< timing violation in 100ms algorithm task */ } DATA_BLOCK_ERRORSTATE_s; /** data block struct of contactor feedback */ -typedef struct DATA_BLOCK_CONTFEEDBACK { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -364,7 +391,7 @@ typedef struct DATA_BLOCK_CONTFEEDBACK { } DATA_BLOCK_CONTACTOR_FEEDBACK_s; /** data block struct of interlock feedback */ -typedef struct DATA_BLOCK_INTERLOCK_FEEDBACK { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -377,7 +404,7 @@ typedef struct DATA_BLOCK_INTERLOCK_FEEDBACK { } DATA_BLOCK_INTERLOCK_FEEDBACK_s; /** data block struct of sof limits */ -typedef struct DATA_BLOCK_SOF { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -416,7 +443,7 @@ typedef struct { } DATA_BLOCK_SYSTEMSTATE_s; /** data block struct of the maximum safe limits */ -typedef struct DATA_BLOCK_MSL_FLAG { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -438,7 +465,7 @@ typedef struct DATA_BLOCK_MSL_FLAG { } DATA_BLOCK_MSL_FLAG_s; /** data block struct of the recommended safety limit */ -typedef struct DATA_BLOCK_RSL_FLAG { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -458,7 +485,7 @@ typedef struct DATA_BLOCK_RSL_FLAG { } DATA_BLOCK_RSL_FLAG_s; /** data block struct of the maximum operating limit */ -typedef struct DATA_BLOCK_MOL_FLAG { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -478,7 +505,7 @@ typedef struct DATA_BLOCK_MOL_FLAG { } DATA_BLOCK_MOL_FLAG_s; /** data block struct of sox */ -typedef struct DATA_BLOCK_SOX { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -489,13 +516,16 @@ typedef struct DATA_BLOCK_SOX { float averageSoe_perc[BS_NR_OF_STRINGS]; /*!< 0.0 <= averageSoe <= 100.0 */ float minimumSoe_perc[BS_NR_OF_STRINGS]; /*!< 0.0 <= minimumSoe <= 100.0 */ float maximumSoe_perc[BS_NR_OF_STRINGS]; /*!< 0.0 <= maximumSoe <= 100.0 */ + float averageSoh_perc[BS_NR_OF_STRINGS]; /*!< 0.0 <= averageSoh <= 100.0 */ + float minimumSoh_perc[BS_NR_OF_STRINGS]; /*!< 0.0 <= minimumSoh <= 100.0 */ + float maximumSoh_perc[BS_NR_OF_STRINGS]; /*!< 0.0 <= maximumSoh <= 100.0 */ uint32_t maximumSoe_Wh[BS_NR_OF_STRINGS]; /*!< maximum string energy in Wh */ uint32_t averageSoe_Wh[BS_NR_OF_STRINGS]; /*!< average string energy in Wh */ uint32_t minimumSoe_Wh[BS_NR_OF_STRINGS]; /*!< minimum string energy in Wh */ } DATA_BLOCK_SOX_s; /** data block struct of can state request */ -typedef struct DATA_BLOCK_STATEREQUEST { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -503,7 +533,7 @@ typedef struct DATA_BLOCK_STATEREQUEST { uint8_t stateRequestViaCan; /*!< state request */ uint8_t previousStateRequestViaCan; /*!< previous state request */ uint8_t stateRequestViaCanPending; /*!< pending state request */ - uint8_t state; /*!< state */ + uint8_t stateCounter; /*!< counts state updates */ } DATA_BLOCK_STATEREQUEST_s; /** data block struct of the moving average algorithm */ @@ -527,29 +557,28 @@ typedef struct { } DATA_BLOCK_MOVING_AVERAGE_s; /** data block struct of insulation monitoring device measurement */ -typedef struct DATA_BLOCK_INSULATION_MONITORING { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ - DATA_BLOCK_HEADER_s header; /*!< Data block header */ - uint8_t valid; /*!< 0 -> valid, 1 -> resistance unreliable */ - uint8_t state; /*!< 0 -> ok , 1 -> resistance too low/error */ - uint32_t insulationResistance_kOhm; /*!< insulation resistance measured in kOhm */ - uint8_t insulationFault; /*!< 0 = no error, 1 = error */ - uint8_t insulationWarning; /*!< 0 = no warning, 1 = warning */ - uint8_t chassisFault; /*!< 0 = no error, 1 = error */ - uint8_t systemFailure; /*!< 0 = no error, 1 = error */ - uint8_t calibrationRunning; /*!< 0 = not running, 1 = running */ - uint8_t selfTestRunning; /*!< 0 = not running, 1 = running */ - uint8_t insulationMeasurements; /*!< 0 = Active, 1 = Inactive */ - uint8_t aliveStatusDetection; /*!< 0 = Ok, 1 = Failure */ - uint8_t outdatedInsulationResistanceValue; /*!< 0 = Valid, 1 = Outdated */ - uint8_t testImcOverAll; /*!< 0 = NotRunning, 1 = Running */ - uint8_t testImcParameterConfiguration; /*!< 0 = NotWarning, 1 = Warning */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + bool isImdRunning; /*!< true -> Insulation resistance measurement active, false -> not active */ + bool isInsulationMeasurementValid; /*!< true -> resistance value valid, false -> resistance unreliable */ + uint32_t insulationResistance_kOhm; /*!< insulation resistance measured in kOhm */ + bool + areDeviceFlagsValid; /*!< true -> flags below this database entry valid, false -> flags unreliable e.g. if device error detected */ + bool + dfIsCriticalResistanceDetected; /*!< device status flag: false -> resistance value okay, true -> resistance value too low/error */ + bool dfIsWarnableResistanceDetected; /*!< true: warning threshold violated, false: no warning active */ + bool dfIsChassisFaultDetected; /*!< true: short between HV potential and chassis detected, false: no error */ + bool dfIsChassisShortToHvPlus; /*!< true: bias/tendency to the location of the insulation fault to HV plus */ + bool dfIsChassisShortToHvMinus; /*!< true: bias/tendency to the location of the insulation fault to HV minus */ + bool dfIsDeviceErrorDetected; /*!< true: device error detected, false: no error detected */ + bool dfIsMeasurmentedUpToDate; /*!< true: measurement up to-date, false: outdated */ } DATA_BLOCK_INSULATION_MONITORING_s; /** data block struct for the I2C humidity/temperature sensor */ -typedef struct DATA_BLOCK_HTSEN { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -559,7 +588,7 @@ typedef struct DATA_BLOCK_HTSEN { } DATA_BLOCK_HTSEN_s; /** data block struct of internal ADC voltage measurement */ -typedef struct DATA_BLOCK_ADC_VOLTAGE { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ @@ -568,7 +597,7 @@ typedef struct DATA_BLOCK_ADC_VOLTAGE { } DATA_BLOCK_ADC_VOLTAGE_s; /** data block struct for the database built-in self-test */ -typedef struct DATA_BLOCK_DUMMY_FOR_SELF_TEST { +typedef struct { /* This struct needs to be at the beginning of every database entry. During * the initialization of a database struct, uniqueId must be set to the * respective database entry representation in enum DATA_BLOCK_ID_e. */ diff --git a/src/app/engine/config/diag_cfg.c b/src/app/engine/config/diag_cfg.c index 60b366f7..70419ed0 100644 --- a/src/app/engine/config/diag_cfg.c +++ b/src/app/engine/config/diag_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cfg.c * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix DIAG * @@ -83,9 +84,9 @@ /*========== Macros and Definitions =========================================*/ /** value of #DIAG_ID_MAX (as a define for the pre-processor) */ -#define DIAG_ID_MAX_FOR_INIT (73u) +#define DIAG_ID_MAX_FOR_INIT (75u) -static_assert(DIAG_ID_MAX_FOR_INIT == (uint16_t)DIAG_ID_MAX, "Both values need to be identical."); +f_static_assert(DIAG_ID_MAX_FOR_INIT == (uint16_t)DIAG_ID_MAX, "Both values need to be identical."); /*========== Static Constant and Variable Definitions =======================*/ /** local copy of the #DATA_BLOCK_ERRORSTATE_s table */ @@ -164,11 +165,11 @@ DIAG_ID_CFG_s DIAG_ID_cfg[] = { {DIAG_ID_CURRENT_ON_OPEN_STRING, DIAG_ERROR_CURRENT_SENSITIVITY_MSL, DIAG_FATAL_ERROR, DIAG_DELAY_OVERCURRENT_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorCurrentOnOpenString}, - {DIAG_ID_LTC_SPI, DIAG_ERROR_LTC_SPI_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_LTC_PEC, DIAG_ERROR_LTC_PEC_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_LTC_MUX, DIAG_ERROR_LTC_MUX_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_LTC_CONFIG, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_OPEN_WIRE, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, + {DIAG_ID_AFE_SPI, DIAG_ERROR_LTC_SPI_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfeDriver}, + {DIAG_ID_AFE_COM_INTEGRITY, DIAG_ERROR_LTC_PEC_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfeDriver}, + {DIAG_ID_AFE_MUX, DIAG_ERROR_LTC_MUX_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfeDriver}, + {DIAG_ID_AFE_CONFIG, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_FATAL_ERROR, DIAG_DELAY_AFE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfeDriver}, + {DIAG_ID_AFE_OPEN_WIRE, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfeDriver}, /* Communication events */ {DIAG_ID_CAN_TIMING, DIAG_ERROR_CAN_TIMING_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_CAN_TIMING_ms, DIAG_RECORDING_ENABLED, DIAG_CAN_TIMING, DIAG_ErrorCanTiming}, @@ -202,19 +203,22 @@ DIAG_ID_CFG_s DIAG_ID_cfg[] = { {DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_FATAL_ERROR, DIAG_DELAY_REDUNDANCY_MEAS_TIMEOUT_ms, DIAG_RECORDING_ENABLED, DIAG_CAN_SENSOR_PRESENT, DIAG_ErrorPowerMeasurement}, {DIAG_ID_POWER_MEASUREMENT_ERROR, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_FATAL_ERROR, DIAG_DELAY_REDUNDANCY_MEAS_ERROR_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorPowerMeasurement}, - {DIAG_ID_INSULATION_MEASUREMENT_INVALID, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_Insulation}, - {DIAG_ID_INSULATION_ERROR, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_Insulation}, + {DIAG_ID_INSULATION_MEASUREMENT_VALID, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_Insulation}, + {DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, DIAG_ERROR_SENSITIVITY_FIFTH_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_Insulation}, + {DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING, DIAG_ERROR_SENSITIVITY_FIFTH_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_Insulation}, {DIAG_ID_INSULATION_GROUND_ERROR, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_Insulation}, {DIAG_ID_I2C_PEX_ERROR, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_INFO, DIAG_NO_DELAY, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_I2cPex}, + + {DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_INFO, DIAG_NO_DELAY, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_FramError}, /* clang-format on */ }; DIAG_DEV_s diag_device = { - .nr_of_ch = sizeof(DIAG_ID_cfg) / sizeof(DIAG_ID_CFG_s), - .ch_cfg = &DIAG_ID_cfg[0], - .numberOfFatalErrors = 0u, - .pFatalErrorLinkTable = {REPEAT_U(NULL_PTR, STRIP(DIAG_ID_MAX_FOR_INIT))}, + .nrOfConfiguredDiagnosisEntries = sizeof(DIAG_ID_cfg) / sizeof(DIAG_ID_CFG_s), + .pConfigurationOfDiagnosisEntries = &DIAG_ID_cfg[0], + .numberOfFatalErrors = 0u, + .pFatalErrorLinkTable = {REPEAT_U(NULL_PTR, STRIP(DIAG_ID_MAX_FOR_INIT))}, }; /*========== Static Function Implementations ================================*/ diff --git a/src/app/engine/config/diag_cfg.h b/src/app/engine/config/diag_cfg.h index cb2582af..b44d2896 100644 --- a/src/app/engine/config/diag_cfg.h +++ b/src/app/engine/config/diag_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cfg.h * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-10-19 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix DIAG * @@ -64,8 +65,8 @@ /*========== Macros and Definitions =========================================*/ #define DIAG_ERROR_SENSITIVITY_FIRST_EVENT (0) /*!< logging at first event */ -#define DIAG_ERROR_SENSITIVITY_THIRD_EVENT (2) /*!< logging at first event */ -#define DIAG_ERROR_SENSITIVITY_FIFTH_EVENT (4) /*!< logging at first event */ +#define DIAG_ERROR_SENSITIVITY_THIRD_EVENT (2) /*!< logging at third event */ +#define DIAG_ERROR_SENSITIVITY_FIFTH_EVENT (4) /*!< logging at fifth event */ #define DIAG_ERROR_SENSITIVITY_TENTH_EVENT (9) /*!< logging at tenth event */ #define DIAG_ERROR_SENSITIVITY_HIGH (0) /*!< logging at first event */ @@ -142,7 +143,7 @@ #define DIAG_MAX_ENTRIES_OF_ERROR (5) /** composite type for storing and passing on the local database table handles */ -typedef struct DIAG_DATABASE_SHIM { +typedef struct { DATA_BLOCK_ERRORSTATE_s *pTableError; /*!< database table with errorstates */ DATA_BLOCK_MOL_FLAG_s *pTableMol; /*!< database table with MOL flags */ DATA_BLOCK_RSL_FLAG_s *pTableRsl; /*!< database table with RSL flags */ @@ -153,98 +154,100 @@ typedef struct DIAG_DATABASE_SHIM { extern const DIAG_DATABASE_SHIM_s diag_kDatabaseShim; /** list of diag IDs */ -typedef enum DIAG_ID { - DIAG_ID_FLASHCHECKSUM, /**< TODO */ - DIAG_ID_SYSTEMMONITORING, /**< TODO */ - DIAG_ID_CONFIGASSERT, /**< TODO*/ - DIAG_ID_LTC_SPI, - DIAG_ID_LTC_PEC, - DIAG_ID_LTC_MUX, - DIAG_ID_LTC_CONFIG, - DIAG_ID_CAN_TIMING, - DIAG_ID_CAN_RX_QUEUE_FULL, - DIAG_ID_CAN_CC_RESPONDING, - DIAG_ID_CAN_EC_RESPONDING, - DIAG_ID_CURRENT_SENSOR_RESPONDING, - DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE, - DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, - DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, - DIAG_ID_PLAUSIBILITY_CELL_TEMP, - DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE_SPREAD, - DIAG_ID_PLAUSIBILITY_CELL_TEMPERATURE_SPREAD, - DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, /* Cell voltage limits violated */ - DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, /* Cell voltage limits violated */ - DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MOL, /* Cell voltage limits violated */ - DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MSL, /* Cell voltage limits violated */ - DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_RSL, /* Cell voltage limits violated */ - DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MOL, /* Cell voltage limits violated */ - DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, /* Temperature limits violated */ - DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, /* Temperature limits violated */ - DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, /* Temperature limits violated */ - DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, /* Temperature limits violated */ - DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, /* Temperature limits violated */ - DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, /* Temperature limits violated */ - DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, /* Temperature limits violated */ - DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, /* Temperature limits violated */ - DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, /* Temperature limits violated */ - DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, /* Temperature limits violated */ - DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, /* Temperature limits violated */ - DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, /* Temperature limits violated */ - DIAG_ID_OVERCURRENT_CHARGE_CELL_MSL, /* Overcurrent on cell-level */ - DIAG_ID_OVERCURRENT_CHARGE_CELL_RSL, /* Overcurrent on cell-level */ - DIAG_ID_OVERCURRENT_CHARGE_CELL_MOL, /* Overcurrent on cell-level */ - DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MSL, /* Overcurrent on cell-level */ - DIAG_ID_OVERCURRENT_DISCHARGE_CELL_RSL, /* Overcurrent on cell-level */ - DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MOL, /* Overcurrent on cell-level */ - DIAG_ID_STRING_OVERCURRENT_CHARGE_MSL, /* Overcurrent on string-level */ - DIAG_ID_STRING_OVERCURRENT_CHARGE_RSL, /* Overcurrent on string-level */ - DIAG_ID_STRING_OVERCURRENT_CHARGE_MOL, /* Overcurrent on string-level */ - DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MSL, /* Overcurrent on string-level */ - DIAG_ID_STRING_OVERCURRENT_DISCHARGE_RSL, /* Overcurrent on string-level */ - DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MOL, /* Overcurrent on string-level */ - DIAG_ID_PACK_OVERCURRENT_CHARGE_MSL, /* Overcurrent on string-level */ - DIAG_ID_PACK_OVERCURRENT_DISCHARGE_MSL, /* Overcurrent on pack-level */ - DIAG_ID_CURRENT_ON_OPEN_STRING, /* Current flowing on open string */ - DIAG_ID_DEEP_DISCHARGE_DETECTED, - DIAG_ID_OPEN_WIRE, - DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, - DIAG_ID_INTERLOCK_FEEDBACK, - DIAG_ID_STRING_CONTACTOR_FEEDBACK, - DIAG_ID_PRECHARGE_CONTACTOR_FEEDBACK, - DIAG_ID_SBC_FIN_STATE, - DIAG_ID_SBC_RSTB_STATE, - DIAG_ID_BASE_CELL_VOLTAGE_MESUREMENT_TIMEOUT, - DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MESUREMENT_TIMEOUT, - DIAG_ID_BASE_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, - DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, - DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT, - DIAG_ID_CURRENT_MEASUREMENT_ERROR, - DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT, - DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT, - DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT, - DIAG_ID_POWER_MEASUREMENT_ERROR, - DIAG_ID_INSULATION_MEASUREMENT_INVALID, - DIAG_ID_INSULATION_ERROR, - DIAG_ID_INSULATION_GROUND_ERROR, - DIAG_ID_I2C_PEX_ERROR, /**< general error with the port expanders */ - DIAG_ID_MAX, /**< MAX indicator - do not change */ +typedef enum { + DIAG_ID_FLASHCHECKSUM, /*!< the checksum of the flashed software could not be validated */ + DIAG_ID_SYSTEMMONITORING, /*!< the system monitoring module has detected a deviation from task timing limits */ + DIAG_ID_CONFIGASSERT, /*!< TODO */ + DIAG_ID_AFE_SPI, /*!< issues with the SPI communication of the AFE */ + DIAG_ID_AFE_COM_INTEGRITY, /*!< error on the communication integrity of the AFE, e.g. PEC error for LTC */ + DIAG_ID_AFE_MUX, /*!< the multiplexer that is connected to the AFE does not react in an expected way */ + DIAG_ID_AFE_CONFIG, /*!< the AFE driver has recognized a configuration error */ + DIAG_ID_CAN_TIMING, /*!< the BMS does not receive CAN messages or they are not inside the excpected timing constraints */ + DIAG_ID_CAN_RX_QUEUE_FULL, /*!< the reception queue of the driver is full; no new messages can be received */ + DIAG_ID_CAN_CC_RESPONDING, /*!< current counter measurements on the CAN bus are missing or not inside expected timing constraints */ + DIAG_ID_CAN_EC_RESPONDING, /*!< energy counter measurements on the CAN bus are missing or not inside expected timing constraints */ + DIAG_ID_CURRENT_SENSOR_RESPONDING, /*!< current sensor measurements on the CAN bus are missing or not inside expected timing constraints */ + DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE, /*!< redundant measurement of the cell voltages has returned implausible values */ + DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, /*!< the AFE driver has determined a cell voltage measurement to be implausible */ + DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, /*!< the AFE driver has determined a cell temperature measurement to be implausible */ + DIAG_ID_PLAUSIBILITY_CELL_TEMP, /*!< redundant measurement of the cell temperatures has returned implausible values */ + DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE_SPREAD, /*!< the spread (difference between min and max values) of the cell voltages is implausibly high */ + DIAG_ID_PLAUSIBILITY_CELL_TEMPERATURE_SPREAD, /*!< the spread (difference between min and max values) of the cell temperatures is implausibly high */ + DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, /*!< Cell voltage limits violated */ + DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, /*!< Cell voltage limits violated */ + DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MOL, /*!< Cell voltage limits violated */ + DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MSL, /*!< Cell voltage limits violated */ + DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_RSL, /*!< Cell voltage limits violated */ + DIAG_ID_CELLVOLTAGE_UNDERVOLTAGE_MOL, /*!< Cell voltage limits violated */ + DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_RSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_OVERTEMPERATURE_CHARGE_MOL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_RSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_OVERTEMPERATURE_DISCHARGE_MOL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_RSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_UNDERTEMPERATURE_CHARGE_MOL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_RSL, /*!< Temperature limits violated */ + DIAG_ID_TEMP_UNDERTEMPERATURE_DISCHARGE_MOL, /*!< Temperature limits violated */ + DIAG_ID_OVERCURRENT_CHARGE_CELL_MSL, /*!< Overcurrent on cell-level */ + DIAG_ID_OVERCURRENT_CHARGE_CELL_RSL, /*!< Overcurrent on cell-level */ + DIAG_ID_OVERCURRENT_CHARGE_CELL_MOL, /*!< Overcurrent on cell-level */ + DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MSL, /*!< Overcurrent on cell-level */ + DIAG_ID_OVERCURRENT_DISCHARGE_CELL_RSL, /*!< Overcurrent on cell-level */ + DIAG_ID_OVERCURRENT_DISCHARGE_CELL_MOL, /*!< Overcurrent on cell-level */ + DIAG_ID_STRING_OVERCURRENT_CHARGE_MSL, /*!< Overcurrent on string-level */ + DIAG_ID_STRING_OVERCURRENT_CHARGE_RSL, /*!< Overcurrent on string-level */ + DIAG_ID_STRING_OVERCURRENT_CHARGE_MOL, /*!< Overcurrent on string-level */ + DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MSL, /*!< Overcurrent on string-level */ + DIAG_ID_STRING_OVERCURRENT_DISCHARGE_RSL, /*!< Overcurrent on string-level */ + DIAG_ID_STRING_OVERCURRENT_DISCHARGE_MOL, /*!< Overcurrent on string-level */ + DIAG_ID_PACK_OVERCURRENT_CHARGE_MSL, /*!< Overcurrent on string-level */ + DIAG_ID_PACK_OVERCURRENT_DISCHARGE_MSL, /*!< Overcurrent on pack-level */ + DIAG_ID_CURRENT_ON_OPEN_STRING, /*!< Current flowing on open string */ + DIAG_ID_DEEP_DISCHARGE_DETECTED, /*!< the deep discharge flag has been set in persistent memory */ + DIAG_ID_AFE_OPEN_WIRE, /*!< an open (broken) sense wire has been detected on the battery cell measurement */ + DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, /*!< the plausibility module has decided that the pack voltage is implausible */ + DIAG_ID_INTERLOCK_FEEDBACK, /*!< the interlock feedback indicates it to be open (but it is expected to be closed) */ + DIAG_ID_STRING_CONTACTOR_FEEDBACK, /*!< the feedback on a string contactor does not match the expected value */ + DIAG_ID_PRECHARGE_CONTACTOR_FEEDBACK, /*!< the feedback on a precharge contactor does not match the expected value */ + DIAG_ID_SBC_FIN_STATE, /*!< the state of the FIN signal in the SBC is not ok */ + DIAG_ID_SBC_RSTB_STATE, /*!< an activation of the RSTB pin of the SBC has been detected */ + DIAG_ID_BASE_CELL_VOLTAGE_MESUREMENT_TIMEOUT, /*!< the redundancy module has detected that the base cell voltage measurements are missing */ + DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MESUREMENT_TIMEOUT, /*!< the redundancy module has detected that the redundancy0 cell voltage measurements are missing */ + DIAG_ID_BASE_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, /*!< the redundancy module has detected that the base cell temperature measurements are missing */ + DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, /*!< the redundancy module has detected that the redundancy0 temperature measurements are missing */ + DIAG_ID_CURRENT_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the current measurement on a string is not updated */ + DIAG_ID_CURRENT_MEASUREMENT_ERROR, /*!< the redundancy module has detected a current measurement to be invalid */ + DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the voltage 1 measurement of a current sensor is not updated */ + DIAG_ID_CURRENT_SENSOR_V3_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the voltage 3 measurement of a current sensor is not updated */ + DIAG_ID_CURRENT_SENSOR_POWER_MEASUREMENT_TIMEOUT, /*!< the redundancy module has detected that the power measurement of a current sensor is not updated */ + DIAG_ID_POWER_MEASUREMENT_ERROR, /*!< the redundancy module has detected a power measurement to be invalid */ + DIAG_ID_INSULATION_MEASUREMENT_VALID, /*!< the insulation measurement is valid or invalid */ + DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, /*!< a critical low insulation resistance has been measured */ + DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING, /*!< a warnable low insulation resistance has been measured */ + DIAG_ID_INSULATION_GROUND_ERROR, /*!< insulation monitoring has detected a ground error */ + DIAG_ID_I2C_PEX_ERROR, /*!< general error with the port expanders */ + DIAG_ID_FRAM_READ_CRC_ERROR, /*!< CRC does not match when reading from the FRAM */ + DIAG_ID_MAX, /*!< MAX indicator - do not change */ } DIAG_ID_e; /** diagnosis check result (event) */ -typedef enum DIAG_EVENT { +typedef enum { DIAG_EVENT_OK, /**< diag channel event OK */ DIAG_EVENT_NOT_OK, /**< diag channel event NOK */ DIAG_EVENT_RESET, /**< reset diag channel eventcounter to 0 */ } DIAG_EVENT_e; /** enable or disable the diagnosis handling for an event */ -typedef enum DIAG_EVALUATE { +typedef enum { DIAG_EVALUATION_ENABLED, /**< enables evaluation of diagnosis handling */ DIAG_EVALUATION_DISABLED, /**< disables evaluation of diagnosis handling */ } DIAG_EVALUATE_e; /** impact level of diagnosis event, e.g., influences the event the whole system or only a string */ -typedef enum DIAG_IMPACT_LEVEL { +typedef enum { DIAG_SYSTEM, /**< diag event impact is system related e.g., can timing */ DIAG_STRING, /**< diag event impact is string related e.g., overvoltage in string x */ } DIAG_IMPACT_LEVEL_e; @@ -272,14 +275,14 @@ typedef enum DIAG_IMPACT_LEVEL { #endif /* CURRENT_SENSOR_PRESENT */ /** diagnosis severity level */ -typedef enum DIAG_SEVERITY_LEVEL { +typedef enum { DIAG_FATAL_ERROR, /*!< severity level fatal error */ DIAG_WARNING, /*!< severity level warning */ DIAG_INFO, /*!< severity level info */ } DIAG_SEVERITY_LEVEL_e; /** diagnosis recording activation */ -typedef enum DIAG_RECORDING { +typedef enum { DIAG_RECORDING_ENABLED, /**< enable diagnosis event recording */ DIAG_RECORDING_DISABLED, /**< disable diagnosis event recording */ } DIAG_RECORDING_e; @@ -298,7 +301,7 @@ typedef void DIAG_CALLBACK_FUNCTION_f( uint32_t data); /** Channel configuration of one diag channel */ -typedef struct DIAG_CH_CFG { +typedef struct { DIAG_ID_e id; /**< diagnosis event id diag_id */ uint16_t threshold; /**< threshold for number of events which will be * tolerated before generating a notification in both directions: @@ -317,9 +320,9 @@ typedef struct DIAG_CH_CFG { } DIAG_ID_CFG_s; /** struct for device Configuration of diag module */ -typedef struct DIAG_DEV { - uint8_t nr_of_ch; /*!< number of entries in DIAG_ID_CFG_s */ - DIAG_ID_CFG_s *ch_cfg; /*!< pointer to diag channel config struct */ +typedef struct { + uint8_t nrOfConfiguredDiagnosisEntries; /*!< number of entries in DIAG_ID_CFG_s */ + DIAG_ID_CFG_s *pConfigurationOfDiagnosisEntries; /*!< pointer to configuration array for all diagnosis entries */ uint16_t numberOfFatalErrors; /*!< number of configured diagnosis entries with severity #DIAG_FATAL_ERROR */ DIAG_ID_CFG_s *pFatalErrorLinkTable [DIAG_ID_MAX]; /*!< list with pointers to all diagnosis entries with severity #DIAG_FATAL_ERROR */ diff --git a/src/app/engine/config/sys_cfg.c b/src/app/engine/config/sys_cfg.c index b88f9b1c..6f157c49 100644 --- a/src/app/engine/config/sys_cfg.c +++ b/src/app/engine/config/sys_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sys_cfg.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-07-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix SYS * @@ -70,6 +71,7 @@ void SYS_SendBootMessage(void) { /* the system can do not much with the result of the function at this stage therefore discard it */ (void)CAN_TransmitBootMessage(); + (void)CAN_TransmitDieId(); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/engine/config/sys_cfg.h b/src/app/engine/config/sys_cfg.h index c263ee34..0e13fe0f 100644 --- a/src/app/engine/config/sys_cfg.h +++ b/src/app/engine/config/sys_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sys_cfg.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-06-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix SYS * @@ -80,24 +81,24 @@ #define SYS_FSM_MEDIUM_TIME (5u) /** - * SYS statemachine long time definition in #SYS_Trigger() calls until next + * SYS state machine long time definition in #SYS_Trigger() calls until next * state/substate is processed */ #define SYS_FSM_LONG_TIME (10u) -/** - * SYS statemachine initialization timeout - */ +/** SYS state machine initialization request retry counter */ +#define SYS_STATEMACH_INITIALIZATION_REQUEST_RETRY_COUNTER (3u) + +/** SYS state machine initialization timeout */ #define SYS_STATEMACH_INITIALIZATION_TIMEOUT_MS (200u) -/** - * SYS statemachine BAL initialization timeout - */ +/** SYS state machine IMD initialization timeout */ +#define SYS_STATEMACH_IMD_INITIALIZATION_TIMEOUT_MS (500u) + +/** SYS state machine BAL initialization timeout */ #define SYS_STATEMACH_BAL_INITIALIZATION_TIMEOUT_MS (500u) -/** - * SYS statemachine SBC initialization timeout - */ +/** SYS state machine SBC initialization timeout */ #define SYS_STATEMACHINE_SBC_INIT_TIMEOUT_MS (1000u) /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/engine/config/sys_mon_cfg.c b/src/app/engine/config/sys_mon_cfg.c index 12dfde8e..088ecab3 100644 --- a/src/app/engine/config/sys_mon_cfg.c +++ b/src/app/engine/config/sys_mon_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,11 +43,12 @@ * @file sys_mon_cfg.c * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix SYSM * - * @brief TODO + * @brief configuration of the system monitoring module */ /*========== Includes =======================================================*/ @@ -55,6 +56,8 @@ #include "ftask_cfg.h" +#include "fram.h" + /*========== Macros and Definitions =========================================*/ /*========== Static Constant and Variable Definitions =======================*/ @@ -63,6 +66,7 @@ static void SYSM_DummyCallback(SYSM_TASK_ID_e taskId); /*========== Extern Constant and Variable Definitions =======================*/ +/* DOCUMENTATION marker - sys_mon config entry */ SYSM_MONITORING_CFG_s sysm_ch_cfg[] = { {SYSM_TASK_ID_ENGINE, SYSM_ENABLED, @@ -100,28 +104,23 @@ SYSM_MONITORING_CFG_s sysm_ch_cfg[] = { SYSM_HANDLING_SWITCHOFFCONTACTOR, SYSM_DummyCallback}, }; +/* DOCUMENTATION marker - sys_mon config exit */ + +f_static_assert( + (sizeof(sysm_ch_cfg) / sizeof(SYSM_MONITORING_CFG_s)) == (uint32_t)SYSM_TASK_ID_MAX, + "invalid sys_mon configuration!"); /*========== Static Function Implementations ================================*/ /** * @brief dummy callback function of system monitoring error events */ -/* this is a dummy implementation and not using the argument here is fine */ -#pragma diag_push -#pragma diag_suppress 880 -void SYSM_DummyCallback(SYSM_TASK_ID_e taskId) { - /* Dummy function -> empty */ +static void SYSM_DummyCallback(SYSM_TASK_ID_e taskId) { + /* this is a dummy implementation and not using the argument here is fine */ + (void)taskId; + /* Dummy function therefore it is empty */ } -#pragma diag_pop /*========== Extern Function Implementations ================================*/ -STD_RETURN_TYPE_e SYSM_Init(void) { - STD_RETURN_TYPE_e retval = STD_OK; - if ((sizeof(sysm_ch_cfg) / sizeof(SYSM_MONITORING_CFG_s)) != (unsigned long)SYSM_TASK_ID_MAX) { - /* Configuration error - invalid configuration of task/modules */ - retval = STD_NOT_OK; - } - return retval; -} /*========== Externalized Static Function Implementations (Unit Test) =======*/ #ifdef UNITY_UNIT_TEST diff --git a/src/app/engine/config/sys_mon_cfg.h b/src/app/engine/config/sys_mon_cfg.h index 42f7faaf..4d967bcf 100644 --- a/src/app/engine/config/sys_mon_cfg.h +++ b/src/app/engine/config/sys_mon_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,11 +43,12 @@ * @file sys_mon_cfg.h * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE_CONFIGURATION * @prefix SYSM * - * @brief TODO + * @brief configuration of the system monitoring module */ #ifndef FOXBMS__SYS_MON_CFG_H_ @@ -60,16 +61,16 @@ /*========== Macros and Definitions =========================================*/ /** diagnosis handling type for system monitoring */ -typedef enum SYSM_HANDLING_TYPE { - SYSM_HANDLING_DONOTHING, /**< */ - SYSM_HANDLING_SWITCHOFFCONTACTOR /**< */ +typedef enum { + SYSM_HANDLING_DONOTHING, /*!< take no action */ + SYSM_HANDLING_SWITCHOFFCONTACTOR /*!< open contactors */ } SYSM_HANDLING_TYPE_e; /** * listing of system-relevant tasks or functions which are checked by * the system monitoring */ -typedef enum SYSM_TASK_ID { +typedef enum { SYSM_TASK_ID_ENGINE, /**< diag entry for engine task */ SYSM_TASK_ID_CYCLIC_1ms, /**< diag entry for engine cyclic 1ms task */ SYSM_TASK_ID_CYCLIC_10ms, /**< diag entry for engine cyclic 10ms task */ @@ -79,26 +80,26 @@ typedef enum SYSM_TASK_ID { } SYSM_TASK_ID_e; /** recording activation */ -typedef enum SYSM_RECORDING { +typedef enum { SYSM_RECORDING_ENABLED, /*!< enable event recording */ SYSM_RECORDING_DISABLED, /*!< disable event recording */ } SYSM_RECORDING_e; /** enable diagnosis entry for system monitoring */ -typedef enum SYSM_ACTIVATE { - SYSM_ENABLED, /**< TODO */ - SYSM_DISABLED, /**< TODO */ +typedef enum { + SYSM_ENABLED, /*!< entry enabled */ + SYSM_DISABLED, /*!< entry disabled */ } SYSM_ACTIVATE_e; /** Channel configuration of one system monitoring channel */ -typedef struct SYSM_CH_CFG { - SYSM_TASK_ID_e id; /**< the task id by its symbolic name */ - SYSM_ACTIVATE_e enable; /**< enable or disable system monitoring */ - uint8_t cycleTime; /**< max. delay time in ms until #SYSM_Notify has to be called */ - uint8_t maxJitter; /**< max. jitter in ms */ - SYSM_RECORDING_e enableRecording; /**< enabled if set to DIAG_RECORDING_ENABLED */ - SYSM_HANDLING_TYPE_e handlingType; /**< type of handling of system monitoring errors */ - void (*callbackfunc)(SYSM_TASK_ID_e taskID); /**< callback in case of error */ +typedef struct { + SYSM_TASK_ID_e id; /*!< the task id by its symbolic name */ + SYSM_ACTIVATE_e enable; /*!< enable or disable system monitoring */ + uint8_t cycleTime; /*!< max. delay time in ms until #SYSM_Notify has to be called */ + uint8_t maxJitter; /*!< max. jitter in ms */ + SYSM_RECORDING_e enableRecording; /*!< enabled if set to DIAG_RECORDING_ENABLED */ + SYSM_HANDLING_TYPE_e handlingType; /*!< type of handling of system monitoring errors */ + void (*callbackfunc)(SYSM_TASK_ID_e taskID); /*!< callback in case of error */ } SYSM_MONITORING_CFG_s; /*========== Extern Constant and Variable Declarations ======================*/ @@ -106,13 +107,6 @@ typedef struct SYSM_CH_CFG { extern SYSM_MONITORING_CFG_s sysm_ch_cfg[]; /*========== Extern Function Prototypes =====================================*/ -/** - * @brief initialization function for system monitoring - * @details Has to be called once after startup to initialize and check system - * monitoring related functionality - * @return #STD_OK if no configuration error detected, otherwise #STD_NOT_OK - */ -extern STD_RETURN_TYPE_e SYSM_Init(void); /*========== Externalized Static Function Implementations (Unit Test) =======*/ #ifdef UNITY_UNIT_TEST diff --git a/src/app/engine/database/database.c b/src/app/engine/database/database.c index 3fd9c73a..419958d5 100644 --- a/src/app/engine/database/database.c +++ b/src/app/engine/database/database.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,13 +43,25 @@ * @file database.c * @author foxBMS Team * @date 2015-08-18 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DATA * * @brief Database module implementation * - * @details Implementation of database module + * @details The database read/write functions put references to the database + * entries to be read/written in the database queue. The function + * DATA_Task() reads the queue to get the database entries to be + * read/written. Up to DATA_MAX_ENTRIES_PER_ACCESS entries can be + * read/written with the same function call. To avoid code + * duplication, the functions to read/write 1 to + * DATA_MAX_ENTRIES_PER_ACCESS-1 entries call the function to + * read/write DATA_MAX_ENTRIES_PER_ACCESS entries and use NULL_PTR + * for the entries that are not to be read/written. DATA_Task() + * checks that the first entry is not a NULL_PTR and asserts if it + * is not the case. If subsequent entries are found in the database + * queue, they are simply ignored if they are NULL_PTR. */ /*========== Includes =======================================================*/ @@ -61,15 +73,15 @@ #include /*========== Macros and Definitions =========================================*/ -/** - * Maximum queue timeout time in milliseconds - */ -#define DATA_QUEUE_TIMEOUT_MS ((TickType_t)10u) +/** Maximum queue timeout time in milliseconds */ +#define DATA_MAX_QUEUE_TIMEOUT_MS (10u) -/** - * configuration struct of database device - */ -typedef struct DATA_BASE_HEADER { +#define DATA_QUEUE_TIMEOUT_MS (DATA_MAX_QUEUE_TIMEOUT_MS / OS_TICK_RATE_MS) + +f_static_assert(DATA_QUEUE_TIMEOUT_MS > 0u, "invalid database queue timeout!"); + +/** configuration struct of database device */ +typedef struct { uint8_t nrDatabaseEntries; /*!< number of database entries */ DATA_BASE_s *pDatabase; /*!< pointer to the array with the database entries */ } DATA_BASE_HEADER_s; @@ -89,27 +101,139 @@ static const DATA_BASE_HEADER_s data_baseHeader = { /** * @brief uniqueId to respective database entry selector * @details This array is the link between the uniqueId of a database entry and - * the actual position of the database entry in data_database[] + * the actual position of the database entry in data_database[]. + * The IDs are set to its final value, when Data_Initialize is called. */ -static uint16_t uniqueIdToDatabaseEntry[DATA_BLOCK_ID_MAX]; +static uint8_t data_uniqueIdToDatabaseEntry[DATA_BLOCK_ID_MAX] = {0}; /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +static void DATA_IterateOverDatabaseEntries(const DATA_QUEUE_MESSAGE_s *kpReceiveMessage); + +static STD_RETURN_TYPE_e DATA_AccessDatabaseEntries( + DATA_BLOCK_ACCESS_TYPE_e accessType, + void *pData0, + void *pData1, + void *pData2, + void *pData3); + +static void DATA_CopyData( + DATA_BLOCK_ACCESS_TYPE_e accessType, + uint32_t dataLength, + void *pDatabaseStruct, + void *pPassedDataStruct); /*========== Static Function Implementations ================================*/ +static STD_RETURN_TYPE_e DATA_AccessDatabaseEntries( + DATA_BLOCK_ACCESS_TYPE_e accessType, + void *pData0, + void *pData1, + void *pData2, + void *pData3) { + FAS_ASSERT((accessType == DATA_WRITE_ACCESS) || (accessType == DATA_READ_ACCESS)); + FAS_ASSERT(pData0 != NULL_PTR); + /* AXIVION Routine Generic-MissingParameterAssert: pData1: pointer might be NULL_PTR (i.e., if the caller + * is DATA_Read1DataBlock/DATA_Write1DataBlock). The DATA_Task function checks the pointer being not NULL_PTR prior + * to usage. */ + /* AXIVION Routine Generic-MissingParameterAssert: pData2: pointer might be NULL_PTR (i.e., if the caller + * is DATA_Read1DataBlock/DATA_Write1DataBlock or DATA_Read2DataBlocks/DATA_Write2DataBlocks). The DATA_Task + * function checks the pointer being not NULL_PTR prior to usage. */ + /* AXIVION Routine Generic-MissingParameterAssert: pData3: pointer might be NULL_PTR (i.e., if the caller + * is DATA_Read1DataBlock/DATA_Write1DataBlock, DATA_Read2DataBlocks/DATA_Write2DataBlocks or + * DATA_Read3DataBlocks/DATA_Write3DataBlocks). The DATA_Task function checks the pointer being not NULL_PTR prior + * to usage. */ + STD_RETURN_TYPE_e retval = STD_NOT_OK; + /* prepare send message with attributes of data block */ + DATA_QUEUE_MESSAGE_s data_sendMessage = { + .pDatabaseEntry[DATA_ENTRY_0] = pData0, + .pDatabaseEntry[DATA_ENTRY_1] = pData1, + .pDatabaseEntry[DATA_ENTRY_2] = pData2, + .pDatabaseEntry[DATA_ENTRY_3] = pData3, + .accessType = accessType, + }; + /* Send a pointer to a message object and maximum block time: DATA_QUEUE_TIMEOUT_MS */ + if (OS_SendToBackOfQueue(ftsk_databaseQueue, (void *)&data_sendMessage, DATA_QUEUE_TIMEOUT_MS) == OS_SUCCESS) { + retval = STD_OK; + } + return retval; +} + +static void DATA_CopyData( + DATA_BLOCK_ACCESS_TYPE_e accessType, + uint32_t dataLength, + void *pDatabaseStruct, + void *pPassedDataStruct) { + FAS_ASSERT((accessType == DATA_WRITE_ACCESS) || (accessType == DATA_READ_ACCESS)); + /* AXIVION Routine Generic-MissingParameterAssert: dataLength: parameter accepts whole range */ + /* Copy data either into database or passed database struct */ + FAS_ASSERT(pDatabaseStruct != NULL_PTR); + FAS_ASSERT(pPassedDataStruct != NULL_PTR); + + if (accessType == DATA_WRITE_ACCESS) { + /* Pointer on data block header of passed struct */ + /* AXIVION Next Line Style MisraC2012-11.5 this casted is required in order to have a generic interface + * for all database entries. */ + DATA_BLOCK_HEADER_s *pHeader = (DATA_BLOCK_HEADER_s *)pPassedDataStruct; + /* Update timestamps in passed database struct and then copy this struct into database */ + pHeader->previousTimestamp = pHeader->timestamp; + pHeader->timestamp = OS_GetTickCount(); + /* Copy passed struct in database struct */ + /* memcpy has no return value therefore there is nothing to check: casting to void */ + /* AXIVION Next Line Style MisraC2012-21.18 + * */ + (void)memcpy(pDatabaseStruct, pPassedDataStruct, dataLength); + } else if (accessType == DATA_READ_ACCESS) { + /* Copy database entry in passed struct */ + /* memcpy has no return value therefore there is nothing to check: casting to void */ + (void)memcpy(pPassedDataStruct, pDatabaseStruct, dataLength); + } else { + /* invalid database operation */ + FAS_ASSERT(FAS_TRAP); + } +} + +static void DATA_IterateOverDatabaseEntries(const DATA_QUEUE_MESSAGE_s *kpReceiveMessage) { + FAS_ASSERT(kpReceiveMessage != NULL_PTR); + for (uint8_t queueEntry = 0u; queueEntry < DATA_MAX_ENTRIES_PER_ACCESS; queueEntry++) { + /* Iterate over pointer array and handle all access operations if pointer != NULL_PTR + * All pointers in the array, expect the first one, might be NULL_PTR, which is valid. + * Again, to understand explanation see the comments in DATA_Read1DataBlock, DATA_Read2DataBlocks, + * DATA_Read3DataBlocks and DATA_Read4DataBlocks as well as DATA_Write1DataBlock, + * DATA_Write2DataBlocks, DATA_Write3DataBlocks and DATA_Write4DataBlocks */ + if (kpReceiveMessage->pDatabaseEntry[queueEntry] != NULL_PTR) { + /* pointer to passed database struct */ + void *pPassedDataStruct = kpReceiveMessage->pDatabaseEntry[queueEntry]; + /* Get access type (read or write) of passed data struct */ + DATA_BLOCK_ACCESS_TYPE_e accessType = kpReceiveMessage->accessType; + + /* Get pointer to database header entry */ + const DATA_BLOCK_HEADER_s *kpHeader = (DATA_BLOCK_HEADER_s *)kpReceiveMessage->pDatabaseEntry[queueEntry]; + uint8_t uniqueId = (uint8_t)(kpHeader->uniqueId); + FAS_ASSERT(uniqueId < (uint8_t)DATA_BLOCK_ID_MAX); + uint8_t entryIndex = data_uniqueIdToDatabaseEntry[uniqueId]; + /* Pointer to database struct representation of passed struct */ + void *pDatabaseStruct = (void *)data_baseHeader.pDatabase[entryIndex].pDatabaseEntry; + /* Get dataLength of database entry */ + uint32_t dataLength = data_baseHeader.pDatabase[entryIndex].dataLength; + + DATA_CopyData(accessType, dataLength, pDatabaseStruct, pPassedDataStruct); + } + } +} /*========== Extern Function Implementations ================================*/ -STD_RETURN_TYPE_e DATA_Init(void) { +STD_RETURN_TYPE_e DATA_Initialize(void) { STD_RETURN_TYPE_e retval = STD_OK; /* Check that database queue has been created */ - FAS_ASSERT(true == ftsk_allQueuesCreated); + const bool allQueuesCreatedCopyForAssert = ftsk_allQueuesCreated; + FAS_ASSERT(allQueuesCreatedCopyForAssert == true); - static_assert((sizeof(data_database) != 0u), "No database defined"); + f_static_assert((sizeof(data_database) != 0u), "No database defined"); /* make sure that no basic assumptions are broken -- since data_database is declared with length DATA_BLOCK_ID_MAX, this assert should never fail */ - static_assert( - ((sizeof(data_database) / sizeof(DATA_BASE_s)) == (DATA_BLOCK_ID_MAX)), "Database array length error"); + f_static_assert( + ((sizeof(data_database) / sizeof(DATA_BASE_s)) == (uint8_t)(DATA_BLOCK_ID_MAX)), "Database array length error"); /* Iterate over database and set respective read/write pointer for each database entry */ for (uint16_t i = 0u; i < data_baseHeader.nrDatabaseEntries; i++) { @@ -117,7 +241,7 @@ STD_RETURN_TYPE_e DATA_Init(void) { uint8_t *pStartDatabaseEntryWR = (uint8_t *)data_baseHeader.pDatabase[i].pDatabaseEntry; /* Start after uniqueId entry. Set j'th byte to zero in database entry */ - for (uint32_t j = 0u; j < (data_baseHeader.pDatabase + i)->datalength; j++) { + for (uint32_t j = 0u; j < (data_baseHeader.pDatabase + i)->dataLength; j++) { if (j >= sizeof(DATA_BLOCK_ID_e)) { *pStartDatabaseEntryWR = 0; } @@ -126,7 +250,7 @@ STD_RETURN_TYPE_e DATA_Init(void) { } /* Configure link between uniqueId and database entry array position */ - for (uint16_t databaseEntry = 0u; databaseEntry < data_baseHeader.nrDatabaseEntries; databaseEntry++) { + for (uint8_t databaseEntry = 0u; databaseEntry < data_baseHeader.nrDatabaseEntries; databaseEntry++) { /* Get pointer to database header entry */ DATA_BLOCK_HEADER_s *pHeader = (DATA_BLOCK_HEADER_s *)data_baseHeader.pDatabase[databaseEntry].pDatabaseEntry; /* make sure that the database entry is not a null pointer (which would happen if an entry is missing @@ -135,8 +259,8 @@ STD_RETURN_TYPE_e DATA_Init(void) { /* Get uniqueId */ DATA_BLOCK_ID_e blockId = pHeader->uniqueId; if ((blockId < DATA_BLOCK_ID_MAX) && (databaseEntry < DATA_BLOCK_ID_MAX)) { - uniqueIdToDatabaseEntry[blockId] = - databaseEntry; /* e.g. uniqueIdToDatabaseEntry[] = configured database entry index */ + /* e.g., data_uniqueIdToDatabaseEntry[] = configured database entry index */ + data_uniqueIdToDatabaseEntry[blockId] = databaseEntry; } else { /* Configuration error -> set retval to #STD_NOT_OK */ retval = STD_NOT_OK; @@ -144,56 +268,24 @@ STD_RETURN_TYPE_e DATA_Init(void) { } if (ftsk_databaseQueue == NULL_PTR) { - /* Failed to create the queue */ - retval = STD_NOT_OK; + retval = STD_NOT_OK; /* Failed to create the queue */ } return retval; } void DATA_Task(void) { - DATA_QUEUE_MESSAGE_s receiveMessage; - if (ftsk_databaseQueue != NULL_PTR) { + DATA_QUEUE_MESSAGE_s receiveMessage = { + .accessType = DATA_READ_ACCESS, .pDatabaseEntry = {REPEAT_U(NULL_PTR, STRIP(DATA_MAX_ENTRIES_PER_ACCESS))}}; /* scan queue and wait for a message up to a maximum amount of 1ms (block time) */ if (OS_ReceiveFromQueue(ftsk_databaseQueue, (&receiveMessage), 1u) == OS_SUCCESS) { - /* plausibility check, error if first pointer NULL_PTR */ + /* plausibility check, error whether the first pointer is a NULL_PTR, as this must not happen. + * See the comments in DATA_Read1DataBlock, DATA_Read2DataBlocks, DATA_Read3DataBlocks and + * DATA_Read4DataBlocks as well as DATA_Write1DataBlock, DATA_Write2DataBlocks, + * DATA_Write3DataBlocks and DATA_Write4DataBlocks */ FAS_ASSERT(receiveMessage.pDatabaseEntry[0] != NULL_PTR); - /* Iterate over pointer array and handle all access operations if pointer != NULL_PTR */ - for (uint8_t queueEntry = 0u; queueEntry < DATA_MAX_ENTRIES_PER_ACCESS; queueEntry++) { - if (receiveMessage.pDatabaseEntry[queueEntry] != NULL_PTR) { - /* pointer to passed database struct */ - void *pPassedDataStruct = receiveMessage.pDatabaseEntry[queueEntry]; - /* Get access type (read or write) of passed data struct */ - DATA_BLOCK_ACCESS_TYPE_e accesstype = receiveMessage.accesstype; - - /* Get pointer to database header entry */ - DATA_BLOCK_HEADER_s *pHeader1 = (DATA_BLOCK_HEADER_s *)receiveMessage.pDatabaseEntry[queueEntry]; - uint16_t entryIndex = uniqueIdToDatabaseEntry[(uint16_t)pHeader1->uniqueId]; - /* Pointer to database struct representation of passed struct */ - void *pDatabaseStruct = (void *)data_baseHeader.pDatabase[entryIndex].pDatabaseEntry; - /* Get datalength of database entry */ - uint32_t datalength = data_baseHeader.pDatabase[entryIndex].datalength; - - /* Copy data either into database or passed database struct */ - if (accesstype == DATA_WRITE_ACCESS) { - /* Pointer on datablock header of passed struct */ - DATA_BLOCK_HEADER_s *pHeader = (DATA_BLOCK_HEADER_s *)pPassedDataStruct; - /* Update timestamps in passed database struct and then copy this struct into database */ - pHeader->previousTimestamp = pHeader->timestamp; - pHeader->timestamp = OS_GetTickCount(); - /* Copy passed struct in database struct */ - /* memcpy has no return value therefore there is nothing to check: casting to void */ - (void)memcpy(pDatabaseStruct, pPassedDataStruct, datalength); - } else if (accesstype == DATA_READ_ACCESS) { - /* Copy database entry in passed struct */ - /* memcpy has no return value therefore there is nothing to check: casting to void */ - (void)memcpy(pPassedDataStruct, pDatabaseStruct, datalength); - } else { - /* invalid database operation */ - FAS_ASSERT(FAS_TRAP); - } - } - } + /* ready to start reading/writing database entries */ + DATA_IterateOverDatabaseEntries(&receiveMessage); } } } @@ -201,95 +293,70 @@ void DATA_Task(void) { void DATA_DummyFunction(void) { } -STD_RETURN_TYPE_e DATA_Read_1_DataBlock(void *pDataToReceiver0) { - /* Call write function with maximum number of database entries to prevent duplicated code */ - return DATA_Read_4_DataBlocks(pDataToReceiver0, NULL_PTR, NULL_PTR, NULL_PTR); +STD_RETURN_TYPE_e DATA_Read1DataBlock(void *pDataToReceiver0) { + FAS_ASSERT(pDataToReceiver0 != NULL_PTR); + return DATA_AccessDatabaseEntries(DATA_READ_ACCESS, pDataToReceiver0, NULL_PTR, NULL_PTR, NULL_PTR); } -STD_RETURN_TYPE_e DATA_Read_2_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1) { - /* Call write function with maximum number of database entries to prevent duplicated code */ - return DATA_Read_4_DataBlocks(pDataToReceiver0, pDataToReceiver1, NULL_PTR, NULL_PTR); +STD_RETURN_TYPE_e DATA_Read2DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1) { + FAS_ASSERT(pDataToReceiver0 != NULL_PTR); + FAS_ASSERT(pDataToReceiver1 != NULL_PTR); + return DATA_AccessDatabaseEntries(DATA_READ_ACCESS, pDataToReceiver0, pDataToReceiver1, NULL_PTR, NULL_PTR); } -STD_RETURN_TYPE_e DATA_Read_3_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2) { - /* Call write function with maximum number of database entries to prevent duplicated code */ - return DATA_Read_4_DataBlocks(pDataToReceiver0, pDataToReceiver1, pDataToReceiver2, NULL_PTR); +STD_RETURN_TYPE_e DATA_Read3DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2) { + FAS_ASSERT(pDataToReceiver0 != NULL_PTR); + FAS_ASSERT(pDataToReceiver1 != NULL_PTR); + FAS_ASSERT(pDataToReceiver2 != NULL_PTR); + return DATA_AccessDatabaseEntries(DATA_READ_ACCESS, pDataToReceiver0, pDataToReceiver1, pDataToReceiver2, NULL_PTR); } -STD_RETURN_TYPE_e DATA_Read_4_DataBlocks( +STD_RETURN_TYPE_e DATA_Read4DataBlocks( void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2, void *pDataToReceiver3) { - STD_RETURN_TYPE_e retval = STD_NOT_OK; - DATA_QUEUE_MESSAGE_s data_send_msg; - TickType_t queuetimeout; - - queuetimeout = DATA_QUEUE_TIMEOUT_MS / portTICK_RATE_MS; - if (queuetimeout == 0) { - queuetimeout = 1; - } - - /* prepare send message with attributes of data block */ - data_send_msg.pDatabaseEntry[0] = pDataToReceiver0; - data_send_msg.pDatabaseEntry[1] = pDataToReceiver1; - data_send_msg.pDatabaseEntry[2] = pDataToReceiver2; - data_send_msg.pDatabaseEntry[3] = pDataToReceiver3; - data_send_msg.accesstype = DATA_READ_ACCESS; - - /* Send a pointer to a message object and */ - /* maximum block time: queuetimeout */ - if (OS_SendToBackOfQueue(ftsk_databaseQueue, (void *)&data_send_msg, queuetimeout) == OS_SUCCESS) { - retval = STD_OK; - } - return retval; + FAS_ASSERT(pDataToReceiver0 != NULL_PTR); + FAS_ASSERT(pDataToReceiver1 != NULL_PTR); + FAS_ASSERT(pDataToReceiver2 != NULL_PTR); + FAS_ASSERT(pDataToReceiver3 != NULL_PTR); + return DATA_AccessDatabaseEntries( + DATA_READ_ACCESS, pDataToReceiver0, pDataToReceiver1, pDataToReceiver2, pDataToReceiver3); } -STD_RETURN_TYPE_e DATA_Write_1_DataBlock(void *pDataFromSender0) { - /* Call write function with maximum number of database entries to prevent duplicated code */ - return DATA_Write_4_DataBlocks(pDataFromSender0, NULL_PTR, NULL_PTR, NULL_PTR); +STD_RETURN_TYPE_e DATA_Write1DataBlock(void *pDataFromSender0) { + FAS_ASSERT(pDataFromSender0 != NULL_PTR); + return DATA_AccessDatabaseEntries(DATA_WRITE_ACCESS, pDataFromSender0, NULL_PTR, NULL_PTR, NULL_PTR); } -STD_RETURN_TYPE_e DATA_Write_2_DataBlocks(void *pDataFromSender0, void *pDataFromSender1) { - /* Call write function with maximum number of database entries to prevent duplicated code */ - return DATA_Write_4_DataBlocks(pDataFromSender0, pDataFromSender1, NULL_PTR, NULL_PTR); +STD_RETURN_TYPE_e DATA_Write2DataBlocks(void *pDataFromSender0, void *pDataFromSender1) { + FAS_ASSERT(pDataFromSender0 != NULL_PTR); + FAS_ASSERT(pDataFromSender1 != NULL_PTR); + return DATA_AccessDatabaseEntries(DATA_WRITE_ACCESS, pDataFromSender0, pDataFromSender1, NULL_PTR, NULL_PTR); } -STD_RETURN_TYPE_e DATA_Write_3_DataBlocks(void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2) { - /* Call write function with maximum number of database entries to prevent duplicated code */ - return DATA_Write_4_DataBlocks(pDataFromSender0, pDataFromSender1, pDataFromSender2, NULL_PTR); +STD_RETURN_TYPE_e DATA_Write3DataBlocks(void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2) { + FAS_ASSERT(pDataFromSender0 != NULL_PTR); + FAS_ASSERT(pDataFromSender1 != NULL_PTR); + FAS_ASSERT(pDataFromSender2 != NULL_PTR); + return DATA_AccessDatabaseEntries( + DATA_WRITE_ACCESS, pDataFromSender0, pDataFromSender1, pDataFromSender2, NULL_PTR); } -STD_RETURN_TYPE_e DATA_Write_4_DataBlocks( +STD_RETURN_TYPE_e DATA_Write4DataBlocks( void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2, void *pDataFromSender3) { - STD_RETURN_TYPE_e retval = STD_NOT_OK; - DATA_QUEUE_MESSAGE_s data_send_msg; - TickType_t queuetimeout; - - queuetimeout = DATA_QUEUE_TIMEOUT_MS / portTICK_RATE_MS; - if (queuetimeout == (TickType_t)0) { - queuetimeout = 1; - } - - /* prepare send message with attributes of data block */ - data_send_msg.pDatabaseEntry[0] = pDataFromSender0; - data_send_msg.pDatabaseEntry[1] = pDataFromSender1; - data_send_msg.pDatabaseEntry[2] = pDataFromSender2; - data_send_msg.pDatabaseEntry[3] = pDataFromSender3; - - data_send_msg.accesstype = DATA_WRITE_ACCESS; - /* Send a pointer to a message object and - maximum block time: queuetimeout */ - if (OS_SendToBackOfQueue(ftsk_databaseQueue, (void *)&data_send_msg, queuetimeout) == OS_SUCCESS) { - retval = STD_OK; - } - return retval; + FAS_ASSERT(pDataFromSender0 != NULL_PTR); + FAS_ASSERT(pDataFromSender1 != NULL_PTR); + FAS_ASSERT(pDataFromSender2 != NULL_PTR); + FAS_ASSERT(pDataFromSender3 != NULL_PTR); + return DATA_AccessDatabaseEntries( + DATA_WRITE_ACCESS, pDataFromSender0, pDataFromSender1, pDataFromSender2, pDataFromSender3); } -extern void DATA_ExecuteDataBIST(void) { +extern void DATA_ExecuteDataBist(void) { /* compile database entry */ DATA_BLOCK_DUMMY_FOR_SELF_TEST_s dummyWriteTable = {.header.uniqueId = DATA_BLOCK_ID_DUMMY_FOR_SELF_TEST}; dummyWriteTable.member1 = UINT8_MAX; diff --git a/src/app/engine/database/database.h b/src/app/engine/database/database.h index 9d3caba9..7c699138 100644 --- a/src/app/engine/database/database.h +++ b/src/app/engine/database/database.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file database.h * @author foxBMS Team * @date 2015-08-18 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DATA * @@ -70,33 +71,39 @@ */ #define DATA_MAX_ENTRIES_PER_ACCESS (4u) +#define DATA_ENTRY_0 (0u) +#define DATA_ENTRY_1 (1u) +#define DATA_ENTRY_2 (2u) +#define DATA_ENTRY_3 (3u) + /** helper macro for the variadic macros for read and write functions */ -#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME +/* AXIVION Next Line Style Generic-NoUnsafeMacro: unsafe macro is needed for variadic macro magic */ +#define GET_MACRO(_1, _2, _3, _4, NAME, ...) (NAME) /** variadic macro for read access to the database */ -#define DATA_READ_DATA(...) \ - GET_MACRO( \ - __VA_ARGS__, \ - DATA_Read_4_DataBlocks, \ - DATA_Read_3_DataBlocks, \ - DATA_Read_2_DataBlocks, \ - DATA_Read_1_DataBlock, \ - DATA_DummyFunction) \ +#define DATA_READ_DATA(...) \ + GET_MACRO( \ + __VA_ARGS__, \ + DATA_Read4DataBlocks, \ + DATA_Read3DataBlocks, \ + DATA_Read2DataBlocks, \ + DATA_Read1DataBlock, \ + DATA_DummyFunction) \ (__VA_ARGS__) /** variadic macro for write access to the database */ -#define DATA_WRITE_DATA(...) \ - GET_MACRO( \ - __VA_ARGS__, \ - DATA_Write_4_DataBlocks, \ - DATA_Write_3_DataBlocks, \ - DATA_Write_2_DataBlocks, \ - DATA_Write_1_DataBlock, \ - DATA_DummyFunction) \ +#define DATA_WRITE_DATA(...) \ + GET_MACRO( \ + __VA_ARGS__, \ + DATA_Write4DataBlocks, \ + DATA_Write3DataBlocks, \ + DATA_Write2DataBlocks, \ + DATA_Write1DataBlock, \ + DATA_DummyFunction) \ (__VA_ARGS__) /** * @brief data block access types (read or write) */ -typedef enum DATA_BLOCK_ACCESS_TYPE { +typedef enum { DATA_WRITE_ACCESS, /**< write access to data block */ DATA_READ_ACCESS, /**< read access to data block */ } DATA_BLOCK_ACCESS_TYPE_e; @@ -107,8 +114,8 @@ typedef enum DATA_BLOCK_ACCESS_TYPE { /** * struct for database queue, contains pointer to data, database entry and access type */ -typedef struct DATA_QUEUE_MESSAGE { - DATA_BLOCK_ACCESS_TYPE_e accesstype; /*!< read or write access type */ +typedef struct { + DATA_BLOCK_ACCESS_TYPE_e accessType; /*!< read or write access type */ void *pDatabaseEntry[DATA_MAX_ENTRIES_PER_ACCESS]; /*!< reference by general pointer */ } DATA_QUEUE_MESSAGE_s; @@ -126,12 +133,12 @@ typedef struct DATA_QUEUE_MESSAGE { * the most simple case, that #DATA_READ_DATA() and #DATA_WRITE_DATA() are * only called with one argument, a violation of the standard would * appear if the #DATA_DummyFunction() would be omitted: - * GET_MACRO(databaseVaribale, - * DATA_Read_4_DataBlocks, - * DATA_Read_3_DataBlocks, - * DATA_Read_2_DataBlocks, - * DATA_Read_2_DataBlocks, - * DATA_Read_1_DataBlock)(databaseVaribale) + * GET_MACRO(databaseVariable, + * DATA_Read4DataBlocks, + * DATA_Read3DataBlocks, + * DATA_Read2DataBlocks, + * DATA_Read2DataBlocks, + * DATA_Read1DataBlock)(databaseVariable) * So the macro invocation has six parameters, but it needs seven and * an ISO C99 violation would appear. Adding the #DATA_DummyFunction() * fixes this violation. @@ -144,7 +151,7 @@ extern void DATA_DummyFunction(void); * * @return #STD_OK if initialization successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Init(void); +extern STD_RETURN_TYPE_e DATA_Initialize(void); /** * @brief trigger of database manager @@ -153,7 +160,7 @@ extern STD_RETURN_TYPE_e DATA_Init(void); extern void DATA_Task(void); /** - * @brief Stores a datablock in database + * @brief Stores one data block in database * @details This function stores passed data in database and updates timestamp * and previous timestamp in passed struct * @warning Do not call this function from inside a critical section, as it is @@ -161,10 +168,10 @@ extern void DATA_Task(void); * @param[in,out] pDataFromSender0 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Write_1_DataBlock(void *pDataFromSender0); +extern STD_RETURN_TYPE_e DATA_Write1DataBlock(void *pDataFromSender0); /** - * @brief Stores a datablock in database + * @brief Stores two data blocks in database * @details This function stores passed data in database and updates timestamp * and previous timestamp in passed struct * @warning Do not call this function from inside a critical section, as it is @@ -173,9 +180,9 @@ extern STD_RETURN_TYPE_e DATA_Write_1_DataBlock(void *pDataFromSender0); * @param[in,out] pDataFromSender1 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Write_2_DataBlocks(void *pDataFromSender0, void *pDataFromSender1); +extern STD_RETURN_TYPE_e DATA_Write2DataBlocks(void *pDataFromSender0, void *pDataFromSender1); /** - * @brief Stores a datablock in database + * @brief Stores three data blocks in database * @details This function stores passed data in database and updates timestamp * and previous timestamp in passed struct * @warning Do not call this function from inside a critical section, as it is @@ -185,12 +192,9 @@ extern STD_RETURN_TYPE_e DATA_Write_2_DataBlocks(void *pDataFromSender0, void *p * @param[in,out] pDataFromSender2 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Write_3_DataBlocks( - void *pDataFromSender0, - void *pDataFromSender1, - void *pDataFromSender2); +extern STD_RETURN_TYPE_e DATA_Write3DataBlocks(void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2); /** - * @brief Stores a datablock in database + * @brief Stores four data blocks in database * @details This function stores passed data in database and updates timestamp * and previous timestamp in passed struct * @warning Do not call this function from inside a critical section, as it is @@ -201,14 +205,14 @@ extern STD_RETURN_TYPE_e DATA_Write_3_DataBlocks( * @param[in,out] pDataFromSender3 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Write_4_DataBlocks( +extern STD_RETURN_TYPE_e DATA_Write4DataBlocks( void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2, void *pDataFromSender3); /** - * @brief Reads a datablock in database by value. + * @brief Reads one data block in database by value. * @details This function reads data from database and copy this content in * passed struct * @warning Do not call this function from inside a critical section, as it is @@ -216,9 +220,9 @@ extern STD_RETURN_TYPE_e DATA_Write_4_DataBlocks( * @param[out] pDataToReceiver0 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Read_1_DataBlock(void *pDataToReceiver0); +extern STD_RETURN_TYPE_e DATA_Read1DataBlock(void *pDataToReceiver0); /** - * @brief Reads a datablock in database by value. + * @brief Reads two data blocks in database by value. * @details This function reads data from database and copy this content in * passed struct * @warning Do not call this function from inside a critical section, as it is @@ -227,9 +231,9 @@ extern STD_RETURN_TYPE_e DATA_Read_1_DataBlock(void *pDataToReceiver0); * @param[out] pDataToReceiver1 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Read_2_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1); +extern STD_RETURN_TYPE_e DATA_Read2DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1); /** - * @brief Reads a datablock in database by value. + * @brief Reads three data blocks in database by value. * @details This function reads data from database and copy this content in * passed struct * @warning Do not call this function from inside a critical section, as it is @@ -239,9 +243,9 @@ extern STD_RETURN_TYPE_e DATA_Read_2_DataBlocks(void *pDataToReceiver0, void *pD * @param[out] pDataToReceiver2 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Read_3_DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2); +extern STD_RETURN_TYPE_e DATA_Read3DataBlocks(void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2); /** - * @brief Reads a datablock in database by value. + * @brief Reads four data blocks in database by value. * @details This function reads data from database and copy this content in * passed struct * @warning Do not call this function from inside a critical section, as it is @@ -252,7 +256,7 @@ extern STD_RETURN_TYPE_e DATA_Read_3_DataBlocks(void *pDataToReceiver0, void *pD * @param[out] pDataToReceiver3 (type: void *) * @return #STD_OK if access was successful, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e DATA_Read_4_DataBlocks( +extern STD_RETURN_TYPE_e DATA_Read4DataBlocks( void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2, @@ -264,7 +268,7 @@ extern STD_RETURN_TYPE_e DATA_Read_4_DataBlocks( * the database module is working as expected. If the test fails, it * will fail an assertion. */ -extern void DATA_ExecuteDataBIST(void); +extern void DATA_ExecuteDataBist(void); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/engine/database/database_helper.c b/src/app/engine/database/database_helper.c index e8cff424..a6c64236 100644 --- a/src/app/engine/database/database_helper.c +++ b/src/app/engine/database/database_helper.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file database_helper.c * @author foxBMS Team * @date 2021-05-05 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DATA * @@ -115,20 +116,21 @@ extern bool DATA_EntryUpdatedPeriodicallyWithinInterval(DATA_BLOCK_HEADER_s data } extern uint8_t DATA_GetStringNumberFromVoltageIndex(uint16_t cellIndex) { - FAS_ASSERT(cellIndex < (BS_NR_OF_BAT_CELLS * BS_NR_OF_STRINGS)); - return (uint8_t)(cellIndex / BS_NR_OF_BAT_CELLS); + FAS_ASSERT(cellIndex < (BS_NR_OF_CELL_BLOCKS_PER_STRING * BS_NR_OF_STRINGS)); + return (uint8_t)(cellIndex / BS_NR_OF_CELL_BLOCKS_PER_STRING); } extern uint8_t DATA_GetModuleNumberFromVoltageIndex(uint16_t cellIndex) { - FAS_ASSERT(cellIndex < (BS_NR_OF_BAT_CELLS * BS_NR_OF_STRINGS)); + FAS_ASSERT(cellIndex < (BS_NR_OF_CELL_BLOCKS_PER_STRING * BS_NR_OF_STRINGS)); uint8_t stringNumber = DATA_GetStringNumberFromVoltageIndex(cellIndex); - uint8_t moduleNumber = (uint8_t)((cellIndex / BS_NR_OF_CELLS_PER_MODULE) - (stringNumber * BS_NR_OF_MODULES)); + uint8_t moduleNumber = + (uint8_t)((cellIndex / BS_NR_OF_CELL_BLOCKS_PER_MODULE) - (stringNumber * BS_NR_OF_MODULES_PER_STRING)); return moduleNumber; } extern uint8_t DATA_GetCellNumberFromVoltageIndex(uint16_t cellIndex) { - FAS_ASSERT(cellIndex < (BS_NR_OF_BAT_CELLS * BS_NR_OF_STRINGS)); - return (uint8_t)(cellIndex % BS_NR_OF_CELLS_PER_MODULE); + FAS_ASSERT(cellIndex < (BS_NR_OF_CELL_BLOCKS_PER_STRING * BS_NR_OF_STRINGS)); + return (uint8_t)(cellIndex % BS_NR_OF_CELL_BLOCKS_PER_MODULE); } extern uint8_t DATA_GetStringNumberFromTemperatureIndex(uint16_t sensorIndex) { @@ -140,7 +142,7 @@ extern uint8_t DATA_GetModuleNumberFromTemperatureIndex(uint16_t sensorIndex) { FAS_ASSERT(sensorIndex < BS_NR_OF_TEMP_SENSORS); uint8_t stringNumber = DATA_GetStringNumberFromTemperatureIndex(sensorIndex); uint8_t moduleNumber = - (uint8_t)((sensorIndex / BS_NR_OF_TEMP_SENSORS_PER_MODULE) - (stringNumber * BS_NR_OF_MODULES)); + (uint8_t)((sensorIndex / BS_NR_OF_TEMP_SENSORS_PER_MODULE) - (stringNumber * BS_NR_OF_MODULES_PER_STRING)); return moduleNumber; } diff --git a/src/app/engine/database/database_helper.h b/src/app/engine/database/database_helper.h index 45984f5f..4ca55e2f 100644 --- a/src/app/engine/database/database_helper.h +++ b/src/app/engine/database/database_helper.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file database_helper.h * @author foxBMS Team * @date 2021-05-05 (date of creation) - * @updated 2021-05-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DATA * diff --git a/src/app/engine/diag/cbs/diag_cbs.h b/src/app/engine/diag/cbs/diag_cbs.h index c7389b8d..03c453d0 100644 --- a/src/app/engine/diag/cbs/diag_cbs.h +++ b/src/app/engine/diag/cbs/diag_cbs.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs.h * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -274,13 +275,13 @@ extern void DIAG_ErrorCanRxQueueFull( uint32_t data); /** - * @brief diagnosis callback function for LTC module related events + * @brief diagnosis callback function for AFE module related events * @param[in] ch_id ID of diag entry * @param[in] event OK, NOK or RESET * @param[in] kpkDiagShim shim to the database entries - * @param[in] stringNumber stringNumber where LTC event occurred + * @param[in] stringNumber stringNumber where AFE event occurred */ -extern void DIAG_ErrorLtc( +extern void DIAG_ErrorAfeDriver( DIAG_ID_e ch_id, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, @@ -391,19 +392,19 @@ extern void DIAG_ErrorDeepDischarge( * @param[in] ch_id ID of diag entry * @param[in] event OK, NOK or RESET * @param[in] kpkDiagShim shim to the database entries - * @param[in] data TODO + * @param[in] stringNumber TODO */ extern void DIAG_ErrorPowerMeasurement( DIAG_ID_e ch_id, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, - uint32_t data); + uint32_t stringNumber); extern void DIAG_Insulation( DIAG_ID_e ch_id, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, - uint32_t data); + uint32_t stringNumber); /** * @brief diagnosis callback function for I2C port expander related events @@ -418,6 +419,19 @@ extern void DIAG_I2cPex( const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t data); +/** + * @brief diagnosis callback function for FRAM related events + * @param[in] ch_id ID of diag entry + * @param[in] event OK, NOK or RESET + * @param[in] kpkDiagShim shim to the database entries + * @param[in] data not relevant + */ +extern void DIAG_FramError( + DIAG_ID_e ch_id, + DIAG_EVENT_e event, + const DIAG_DATABASE_SHIM_s *const kpkDiagShim, + uint32_t data); + /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #endif /* FOXBMS__DIAG_CBS_H_ */ diff --git a/src/app/engine/diag/cbs/diag_cbs_afe.c b/src/app/engine/diag/cbs/diag_cbs_afe.c index d34e9469..986a5858 100644 --- a/src/app/engine/diag/cbs/diag_cbs_afe.c +++ b/src/app/engine/diag/cbs/diag_cbs_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_afe.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -120,4 +121,54 @@ extern void DIAG_ErrorAfe( } } +extern void DIAG_ErrorAfeDriver( + DIAG_ID_e ch_id, + DIAG_EVENT_e event, + const DIAG_DATABASE_SHIM_s *const kpkDiagShim, + uint32_t stringNumber) { + FAS_ASSERT(ch_id < DIAG_ID_MAX); + FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET)); + FAS_ASSERT(kpkDiagShim != NULL_PTR); + FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); + + if (ch_id == DIAG_ID_AFE_SPI) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->spiError[stringNumber] = 0; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->spiError[stringNumber] = 1; + } + } else if (ch_id == DIAG_ID_AFE_COM_INTEGRITY) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->crcError[stringNumber] = 0; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->crcError[stringNumber] = 1; + } + } else if (ch_id == DIAG_ID_AFE_MUX) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->muxError[stringNumber] = 0; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->muxError[stringNumber] = 1; + } + } else if (ch_id == DIAG_ID_AFE_CONFIG) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->afeConfigurationError[stringNumber] = 0; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->afeConfigurationError[stringNumber] = 1; + } + } else if (ch_id == DIAG_ID_AFE_OPEN_WIRE) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->open_wire[stringNumber] = 0; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->open_wire[stringNumber] = 1; + } + } else { /* unknown DIAG_ID, assert */ + FAS_ASSERT(FAS_TRAP); + } +} + /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/engine/diag/cbs/diag_cbs_can.c b/src/app/engine/diag/cbs/diag_cbs_can.c index 3c1bbe2a..01c93f07 100644 --- a/src/app/engine/diag/cbs/diag_cbs_can.c +++ b/src/app/engine/diag/cbs/diag_cbs_can.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_can.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_contactor.c b/src/app/engine/diag/cbs/diag_cbs_contactor.c index e93b57a0..64c55997 100644 --- a/src/app/engine/diag/cbs/diag_cbs_contactor.c +++ b/src/app/engine/diag/cbs/diag_cbs_contactor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_contactor.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_current-sensor.c b/src/app/engine/diag/cbs/diag_cbs_current-sensor.c index b227ab2c..2e0e2ddd 100644 --- a/src/app/engine/diag/cbs/diag_cbs_current-sensor.c +++ b/src/app/engine/diag/cbs/diag_cbs_current-sensor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_current-sensor.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_current.c b/src/app/engine/diag/cbs/diag_cbs_current.c index 2905c89f..ff8c24d2 100644 --- a/src/app/engine/diag/cbs/diag_cbs_current.c +++ b/src/app/engine/diag/cbs/diag_cbs_current.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_current.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-05-19 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_deep-discharge.c b/src/app/engine/diag/cbs/diag_cbs_deep-discharge.c index 06740220..0cc9ad35 100644 --- a/src/app/engine/diag/cbs/diag_cbs_deep-discharge.c +++ b/src/app/engine/diag/cbs/diag_cbs_deep-discharge.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_deep-discharge.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -85,7 +86,7 @@ void DIAG_ErrorDeepDischarge( kpkDiagShim->pTableError->deepDischargeDetected[stringNumber] = 1; fram_deepDischargeFlags.deepDischargeFlag[stringNumber] = true; } - FRAM_Write(FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG); + FRAM_WriteData(FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG); } } diff --git a/src/app/engine/diag/cbs/diag_cbs_dummy.c b/src/app/engine/diag/cbs/diag_cbs_dummy.c index a671f97f..4a90524f 100644 --- a/src/app/engine/diag/cbs/diag_cbs_dummy.c +++ b/src/app/engine/diag/cbs/diag_cbs_dummy.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_dummy.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_ltc.c b/src/app/engine/diag/cbs/diag_cbs_fram.c similarity index 65% rename from src/app/engine/diag/cbs/diag_cbs_ltc.c rename to src/app/engine/diag/cbs/diag_cbs_fram.c index 647579bd..ad7bc740 100644 --- a/src/app/engine/diag/cbs/diag_cbs_ltc.c +++ b/src/app/engine/diag/cbs/diag_cbs_fram.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -40,15 +40,15 @@ */ /** - * @file diag_cbs_ltc.c + * @file diag_cbs_fram.c * @author foxBMS Team - * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @date 2022-02-24 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * - * @brief Diagnosis driver implementation - * @details TODO + * @brief Diagnosis callbacks for FRAM errors */ /*========== Includes =======================================================*/ @@ -65,50 +65,22 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void DIAG_ErrorLtc( +extern void DIAG_FramError( DIAG_ID_e ch_id, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, - uint32_t stringNumber) { + uint32_t data) { FAS_ASSERT(ch_id < DIAG_ID_MAX); FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET)); FAS_ASSERT(kpkDiagShim != NULL_PTR); - FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); + (void)data; /* data is unused */ - if (ch_id == DIAG_ID_LTC_SPI) { + if (ch_id == DIAG_ID_FRAM_READ_CRC_ERROR) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->spiError[stringNumber] = 0; + kpkDiagShim->pTableError->framReadCrcError = 0; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->spiError[stringNumber] = 1; - } - } else if (ch_id == DIAG_ID_LTC_PEC) { - if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->crcError[stringNumber] = 0; - } - if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->crcError[stringNumber] = 1; - } - } else if (ch_id == DIAG_ID_LTC_MUX) { - if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->muxError[stringNumber] = 0; - } - if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->muxError[stringNumber] = 1; - } - } else if (ch_id == DIAG_ID_LTC_CONFIG) { - if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->afeConfigurationError[stringNumber] = 0; - } - if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->afeConfigurationError[stringNumber] = 1; - } - } else if (ch_id == DIAG_ID_OPEN_WIRE) { - if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->open_wire[stringNumber] = 0; - } - if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->open_wire[stringNumber] = 1; + kpkDiagShim->pTableError->framReadCrcError = 1; } } } diff --git a/src/app/engine/diag/cbs/diag_cbs_i2c.c b/src/app/engine/diag/cbs/diag_cbs_i2c.c index 65f51fd6..d1559877 100644 --- a/src/app/engine/diag/cbs/diag_cbs_i2c.c +++ b/src/app/engine/diag/cbs/diag_cbs_i2c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_i2c.c * @author foxBMS Team * @date 2021-09-29 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_insulation.c b/src/app/engine/diag/cbs/diag_cbs_insulation.c index 2b2ab275..744b48e9 100644 --- a/src/app/engine/diag/cbs/diag_cbs_insulation.c +++ b/src/app/engine/diag/cbs/diag_cbs_insulation.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_insulation.c * @author foxBMS Team * @date 2021-02-22 (date of creation) - * @updated 2021-02-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -75,26 +76,33 @@ extern void DIAG_Insulation( FAS_ASSERT(kpkDiagShim != NULL_PTR); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); - if (ch_id == DIAG_ID_INSULATION_MEASUREMENT_INVALID) { + if (ch_id == DIAG_ID_INSULATION_MEASUREMENT_VALID) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->insulationError = 0; + kpkDiagShim->pTableError->insulationMeasurementValid = true; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->insulationError = 1; + kpkDiagShim->pTableError->insulationMeasurementValid = false; } - } else if (ch_id == DIAG_ID_INSULATION_ERROR) { + } else if (ch_id == DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->insulationError = 0; + kpkDiagShim->pTableError->criticalLowInsulationResistance = false; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->insulationError = 1; + kpkDiagShim->pTableError->criticalLowInsulationResistance = true; + } + } else if (ch_id == DIAG_ID_LOW_INSULATION_RESISTANCE_WARNING) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->warnableLowInsulationResistance = false; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->warnableLowInsulationResistance = true; } } else if (ch_id == DIAG_ID_INSULATION_GROUND_ERROR) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->insulationError = 0; + kpkDiagShim->pTableError->insulationGroundFaultDetected = false; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->insulationError = 1; + kpkDiagShim->pTableError->insulationGroundFaultDetected = true; } } } diff --git a/src/app/engine/diag/cbs/diag_cbs_interlock.c b/src/app/engine/diag/cbs/diag_cbs_interlock.c index 5b251c94..ef85665d 100644 --- a/src/app/engine/diag/cbs/diag_cbs_interlock.c +++ b/src/app/engine/diag/cbs/diag_cbs_interlock.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_interlock.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_plausibility.c b/src/app/engine/diag/cbs/diag_cbs_plausibility.c index 06233822..ffd55a60 100644 --- a/src/app/engine/diag/cbs/diag_cbs_plausibility.c +++ b/src/app/engine/diag/cbs/diag_cbs_plausibility.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_plausibility.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_power-measurement.c b/src/app/engine/diag/cbs/diag_cbs_power-measurement.c index ee8d6b9e..eafa480d 100644 --- a/src/app/engine/diag/cbs/diag_cbs_power-measurement.c +++ b/src/app/engine/diag/cbs/diag_cbs_power-measurement.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_power-measurement.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_sbc.c b/src/app/engine/diag/cbs/diag_cbs_sbc.c index 51ad3c1d..53c1567f 100644 --- a/src/app/engine/diag/cbs/diag_cbs_sbc.c +++ b/src/app/engine/diag/cbs/diag_cbs_sbc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_sbc.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_sys-mon.c b/src/app/engine/diag/cbs/diag_cbs_sys-mon.c index 6fe90827..7867f6b8 100644 --- a/src/app/engine/diag/cbs/diag_cbs_sys-mon.c +++ b/src/app/engine/diag/cbs/diag_cbs_sys-mon.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_sys-mon.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -63,8 +64,25 @@ /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** + * @brief convert a #DIAG_EVENT_e to a boolean for the violation flags in the database + * @param[in] event diag event + * @returns boolean indicating the error flag + */ +static bool DIAG_EventToBool(DIAG_EVENT_e event); /*========== Static Function Implementations ================================*/ +static bool DIAG_EventToBool(DIAG_EVENT_e event) { + FAS_ASSERT((event == DIAG_EVENT_OK) || (event == DIAG_EVENT_NOT_OK) || (event == DIAG_EVENT_RESET)); + + bool returnValue = false; + if (event == DIAG_EVENT_NOT_OK) { + /* event is not ok, set output to true */ + returnValue = true; + } + + return returnValue; +} /*========== Extern Function Implementations ================================*/ extern void DIAG_ErrorSystemMonitoring( @@ -78,10 +96,15 @@ extern void DIAG_ErrorSystemMonitoring( if (ch_id == DIAG_ID_SYSTEMMONITORING) { if ((SYSM_TASK_ID_e)data == SYSM_TASK_ID_ENGINE) { + kpkDiagShim->pTableError->timingViolationEngine = DIAG_EventToBool(event); } else if ((SYSM_TASK_ID_e)data == SYSM_TASK_ID_CYCLIC_1ms) { + kpkDiagShim->pTableError->timingViolation1ms = DIAG_EventToBool(event); } else if ((SYSM_TASK_ID_e)data == SYSM_TASK_ID_CYCLIC_10ms) { + kpkDiagShim->pTableError->timingViolation10ms = DIAG_EventToBool(event); } else if ((SYSM_TASK_ID_e)data == SYSM_TASK_ID_CYCLIC_100ms) { + kpkDiagShim->pTableError->timingViolation100ms = DIAG_EventToBool(event); } else if ((SYSM_TASK_ID_e)data == SYSM_TASK_ID_CYCLIC_ALGORITHM_100ms) { + kpkDiagShim->pTableError->timingViolation100msAlgo = DIAG_EventToBool(event); } else { FAS_ASSERT(FAS_TRAP); } diff --git a/src/app/engine/diag/cbs/diag_cbs_temperature.c b/src/app/engine/diag/cbs/diag_cbs_temperature.c index cfff03d4..9258a9df 100644 --- a/src/app/engine/diag/cbs/diag_cbs_temperature.c +++ b/src/app/engine/diag/cbs/diag_cbs_temperature.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_temperature.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/cbs/diag_cbs_voltage.c b/src/app/engine/diag/cbs/diag_cbs_voltage.c index a8c48124..f94d54e7 100644 --- a/src/app/engine/diag/cbs/diag_cbs_voltage.c +++ b/src/app/engine/diag/cbs/diag_cbs_voltage.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag_cbs_voltage.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * diff --git a/src/app/engine/diag/diag.c b/src/app/engine/diag/diag.c index 923cc77c..440e007a 100644 --- a/src/app/engine/diag/diag.c +++ b/src/app/engine/diag/diag.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag.c * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-11-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -63,7 +64,7 @@ /*========== Static Constant and Variable Definitions =======================*/ /** state-variable of the diag module */ -static DIAG_s diag; +static DIAG_DIAGNOSIS_STATE_s diag; /** pointer to the device configuration of the diag module */ static DIAG_DEV_s *diag_devptr; @@ -128,8 +129,8 @@ STD_RETURN_TYPE_e DIAG_Initialize(DIAG_DEV_s *diag_dev_pointer) { } /* Fill lookup table id2ch */ - for (uint8_t c = 0; c < diag_dev_pointer->nr_of_ch; c++) { - id_nr = diag_dev_pointer->ch_cfg[c].id; + for (uint8_t c = 0; c < diag_dev_pointer->nrOfConfiguredDiagnosisEntries; c++) { + id_nr = diag_dev_pointer->pConfigurationOfDiagnosisEntries[c].id; if (id_nr < (uint16_t)DIAG_ID_MAX) { diag.id2ch[id_nr] = c; /* e.g. diag.id2ch[DIAG_ID_90] = configured channel index */ } else { @@ -144,10 +145,11 @@ STD_RETURN_TYPE_e DIAG_Initialize(DIAG_DEV_s *diag_dev_pointer) { } /* Fill enable array err_enableflag */ - for (uint8_t i = 0; i < diag_dev_pointer->nr_of_ch; i++) { - if (diag_dev_pointer->ch_cfg[i].enable_evaluate == DIAG_EVALUATION_DISABLED) { + for (uint8_t i = 0; i < diag_dev_pointer->nrOfConfiguredDiagnosisEntries; i++) { + if (diag_dev_pointer->pConfigurationOfDiagnosisEntries[i].enable_evaluate == DIAG_EVALUATION_DISABLED) { /* Disable diagnosis entry */ - tmperr_Check[diag_dev_pointer->ch_cfg[i].id / 32] |= (1 << (diag_dev_pointer->ch_cfg[i].id % 32)); + tmperr_Check[diag_dev_pointer->pConfigurationOfDiagnosisEntries[i].id / 32] |= + (1 << (diag_dev_pointer->pConfigurationOfDiagnosisEntries[i].id % 32)); } } @@ -171,8 +173,9 @@ STD_RETURN_TYPE_e DIAG_Initialize(DIAG_DEV_s *diag_dev_pointer) { } STD_RETURN_TYPE_e DIAG_GetDiagnosisEntryState(DIAG_ID_e diagnosisEntry) { - STD_RETURN_TYPE_e retval = STD_OK; - const uint16_t errorThreshold = diag_devptr->ch_cfg[diag.id2ch[(uint16_t)diagnosisEntry]].threshold; + STD_RETURN_TYPE_e retval = STD_OK; + const uint16_t errorThreshold = + diag_devptr->pConfigurationOfDiagnosisEntries[diag.id2ch[(uint16_t)diagnosisEntry]].threshold; /* Error if active if threshold counter is larger than configured error threshold */ for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { @@ -252,7 +255,7 @@ DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPAC } /* Determine a stringID, for impact level #DIAG_SYSTEM this is - always 0. This stringID is used to access the #DIAG_s::occurrenceCounter + always 0. This stringID is used to access the #DIAG_DIAGNOSIS_STATE_s::occurrenceCounter 2D-array. */ uint8_t stringID = 0u; @@ -266,9 +269,9 @@ DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPAC u32ptr_errCodemsk = &diag.errflag[err_enable_idx]; u32ptr_warnCodemsk = &diag.warnflag[err_enable_idx]; u16ptr_threshcounter = &diag.occurrenceCounter[stringID][diag_id]; - cfg_threshold = diag_devptr->ch_cfg[diag.id2ch[diag_id]].threshold; - recording_enabled = diag_devptr->ch_cfg[diag.id2ch[diag_id]].enable_recording; - evaluate_enabled = diag_devptr->ch_cfg[diag.id2ch[diag_id]].enable_evaluate; + cfg_threshold = diag_devptr->pConfigurationOfDiagnosisEntries[diag.id2ch[diag_id]].threshold; + recording_enabled = diag_devptr->pConfigurationOfDiagnosisEntries[diag.id2ch[diag_id]].enable_recording; + evaluate_enabled = diag_devptr->pConfigurationOfDiagnosisEntries[diag.id2ch[diag_id]].enable_evaluate; if (event == DIAG_EVENT_OK) { if ((diag.err_enableflag[err_enable_idx] & err_enable_bitmask) > 0u) { diff --git a/src/app/engine/diag/diag.h b/src/app/engine/diag/diag.h index fa0de51f..ff7c9420 100644 --- a/src/app/engine/diag/diag.h +++ b/src/app/engine/diag/diag.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file diag.h * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix DIAG * @@ -60,7 +61,7 @@ /*========== Macros and Definitions =========================================*/ /** diagnosis handler return types */ -typedef enum DIAG_RETURNTYPE { +typedef enum { DIAG_HANDLER_RETURN_OK, /*!< error not occurred or occurred but threshold not reached */ DIAG_HANDLER_RETURN_ERR_OCCURRED, /*!< error occurred and enabled */ DIAG_HANDLER_RETURN_WARNING_OCCURRED, /*!< warning occurred (error occurred but not enabled) */ @@ -72,28 +73,26 @@ typedef enum DIAG_RETURNTYPE { DIAG_HANDLER_RETURN_NOT_READY, /*!< diagnosis handler not ready */ } DIAG_RETURNTYPE_e; -/** - * state of diagnosis module - */ +/** possible states of the diagnosis module */ typedef enum { DIAG_STATE_UNINITIALIZED, /*!< diagnosis module not initialized */ DIAG_STATE_INITIALIZED, /*!< diagnosis module initialized (ready for use) */ -} DIAG_STATE_e; +} DIAG_MODULE_STATE_e; /** central state struct of the diag module */ -typedef struct DIAG { - DIAG_STATE_e state; /*!< actual state of diagnosis module */ +typedef struct { + DIAG_MODULE_STATE_e state; /*!< actual state of diagnosis module */ uint16_t errcnttotal; /*!< total counts of diagnosis entry records*/ uint16_t errcntreported; /*!< reported error counts to external tool*/ uint32_t entry_event[DIAG_ID_MAX]; /*!< last detected entry event*/ uint8_t entry_cnt[DIAG_ID_MAX]; /*!< reported event counter used for limitation */ uint16_t occurrenceCounter[BS_NR_OF_STRINGS][DIAG_ID_MAX]; /*!< counter for the occurrence of diag events */ uint8_t id2ch[DIAG_ID_MAX]; /*!< diagnosis-id to configuration channel selector*/ - uint8_t nr_of_ch; /*!< number of configured channels*/ + uint8_t nrOfConfiguredDiagnosisEntries; /*!< number of configured diagnosis entries */ uint32_t errflag[(DIAG_ID_MAX + 31) / 32]; /*!< detected error flags (bit_nr = diag_id) */ uint32_t warnflag[(DIAG_ID_MAX + 31) / 32]; /*!< detected warning flags (bit_nr = diag_id) */ uint32_t err_enableflag[(DIAG_ID_MAX + 31) / 32]; /*!< enabled error flags (bit_nr = diag_id) */ -} DIAG_s; +} DIAG_DIAGNOSIS_STATE_s; /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/engine/hwinfo/masterinfo.c b/src/app/engine/hwinfo/masterinfo.c index af7843db..194488c7 100644 --- a/src/app/engine/hwinfo/masterinfo.c +++ b/src/app/engine/hwinfo/masterinfo.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file masterinfo.c * @author foxBMS Team * @date 2020-07-08 (date of creation) - * @updated 2020-07-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL * @prefix MINFO * diff --git a/src/app/engine/hwinfo/masterinfo.h b/src/app/engine/hwinfo/masterinfo.h index 7f5aeddb..116ec714 100644 --- a/src/app/engine/hwinfo/masterinfo.h +++ b/src/app/engine/hwinfo/masterinfo.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file masterinfo.h * @author foxBMS Team * @date 2020-07-08 (date of creation) - * @updated 2020-07-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL * @prefix MINFO * @@ -62,7 +63,7 @@ /*========== Macros and Definitions =========================================*/ /** values describing the connection state of the debug probe */ -typedef enum MINFO_DEBUG_PROBE_CONNECTION_STATE { +typedef enum { MINFO_DEBUG_PROBE_NOT_CONNECTED, /*!< no debug probe connected */ MINFO_DEBUG_PROBE_CONNECTED, /*!< debug probe connected */ } MINFO_DEBUG_PROBE_CONNECTION_STATE_e; @@ -72,7 +73,7 @@ typedef enum MINFO_DEBUG_PROBE_CONNECTION_STATE { * @details This currently describes the source of the last reset and whether a * debug probe is attached or not. */ -typedef struct MINFO_MASTER_STATE { +typedef struct { resetSource_t resetSource; /*!< source of the last system reset */ MINFO_DEBUG_PROBE_CONNECTION_STATE_e debugProbe; /*!< connection state of debug probe */ } MINFO_MASTER_STATE_s; diff --git a/src/app/engine/sys/sys.c b/src/app/engine/sys/sys.c index d670f39e..77aed4d2 100644 --- a/src/app/engine/sys/sys.c +++ b/src/app/engine/sys/sys.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sys.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-10-12 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix SYS * @@ -83,7 +84,7 @@ /*========== Extern Constant and Variable Definitions =======================*/ /** Symbolic names to check for multiple calls of #SYS_Trigger() */ -typedef enum SYS_CHECK_MULTIPLE_CALLS { +typedef enum { SYS_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */ SYS_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */ } SYS_CHECK_MULTIPLE_CALLS_e; @@ -199,13 +200,14 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { STD_RETURN_TYPE_e balancingInitializationState = STD_OK; BAL_RETURN_TYPE_e balancingGlobalEnableState = BAL_ERROR; STD_RETURN_TYPE_e bmsState = STD_NOT_OK; + bool imdInitialized = false; switch (pSystemState->state) { /****************************UNINITIALIZED***********************************/ case SYS_STATEMACH_UNINITIALIZED: /* waiting for Initialization Request */ stateRequest = SYS_TransferStateRequest(); - if (stateRequest == SYS_STATE_INIT_REQUEST) { + if (stateRequest == SYS_STATE_INITIALIZATION_REQUEST) { SYS_SAVELASTSTATES(pSystemState); pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_INITIALIZATION; @@ -221,10 +223,10 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { SYS_SAVELASTSTATES(pSystemState); /* Initializations done here */ - FRAM_Read(FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (fram_deepDischargeFlags.deepDischargeFlag[stringNumber] == true) { - DIAG_Handler(DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_EVENT_NOT_OK, DIAG_STRING, stringNumber); + FRAM_ReadData(FRAM_BLOCK_ID_DEEP_DISCHARGE_FLAG); + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (fram_deepDischargeFlags.deepDischargeFlag[s] == true) { + DIAG_Handler(DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_EVENT_NOT_OK, DIAG_STRING, s); } } @@ -255,13 +257,15 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { (SYS_STATEMACHINE_SBC_INIT_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_ERROR; - pSystemState->substate = SYS_SBC_INIT_ERROR; + pSystemState->substate = SYS_SBC_INITIALIZATION_ERROR; break; } pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->initializationTimeout++; break; } + } else { + FAS_ASSERT(FAS_TRAP); /* substate does not exist in this state */ } break; @@ -278,7 +282,7 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { SYS_SAVELASTSTATES(pSystemState); /* run BIST functions */ SYS_GeneralMacroBist(); - DATA_ExecuteDataBIST(); + DATA_ExecuteDataBist(); pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_INITIALIZED; @@ -329,7 +333,7 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { (SYS_STATEMACH_BAL_INITIALIZATION_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_ERROR; - pSystemState->substate = SYS_BAL_INIT_ERROR; + pSystemState->substate = SYS_BAL_INITIALIZATION_ERROR; break; } pSystemState->timer = SYS_FSM_SHORT_TIME; @@ -352,7 +356,7 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { (SYS_STATEMACH_INITIALIZATION_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_ERROR; - pSystemState->substate = SYS_BAL_INIT_ERROR; + pSystemState->substate = SYS_BAL_INITIALIZATION_ERROR; break; } pSystemState->timer = SYS_FSM_SHORT_TIME; @@ -387,7 +391,7 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { (SYS_STATEMACH_INITIALIZATION_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_ERROR; - pSystemState->substate = SYS_MEAS_INIT_ERROR; + pSystemState->substate = SYS_MEAS_INITIALIZATION_ERROR; break; } else { pSystemState->timer = SYS_FSM_MEDIUM_TIME; @@ -405,31 +409,32 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { if (pSystemState->substate == SYS_ENTRY) { pSystemState->initializationTimeout = 0; CAN_EnablePeriodic(true); -#if CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED +#if defined(CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED) /* If triggered mode is used, CAN trigger message needs to * be transmitted and current sensor response has to be * received afterwards. This may take some time, therefore * delay has to be increased. */ pSystemState->timer = SYS_FSM_LONG_TIME_MS; -#else /* CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED */ +#else /* defined(CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED) */ pSystemState->timer = SYS_FSM_LONG_TIME; -#endif /* CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED */ +#endif /* defined(CURRENT_SENSOR_ISABELLENHUETTE_TRIGGERED) */ pSystemState->substate = SYS_WAIT_CURRENT_SENSOR_PRESENCE; } else if (pSystemState->substate == SYS_WAIT_CURRENT_SENSOR_PRESENCE) { bool allSensorsPresent = true; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - if (CAN_IsCurrentSensorPresent(stringNumber) == true) { - if (CAN_IsCurrentSensorCcPresent(stringNumber) == true) { - SE_SocInit(true, stringNumber); + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + if (CAN_IsCurrentSensorPresent(s) == true) { + if (CAN_IsCurrentSensorCcPresent(s) == true) { + SE_InitializeSoc(true, s); } else { - SE_SocInit(false, stringNumber); + SE_InitializeSoc(false, s); } - if (CAN_IsCurrentSensorEcPresent(stringNumber) == true) { - SE_SoeInit(true, stringNumber); + if (CAN_IsCurrentSensorEcPresent(s) == true) { + SE_InitializeSoe(true, s); } else { - SE_SoeInit(false, stringNumber); + SE_InitializeSoe(false, s); } + SE_InitializeSoh(s); } else { allSensorsPresent = false; } @@ -455,6 +460,8 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { break; } } + } else { + FAS_ASSERT(FAS_TRAP); /* substate does not exist in this state */ } break; @@ -464,15 +471,65 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { if (CURRENT_SENSOR_PRESENT == false) { CAN_EnablePeriodic(true); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - SE_SocInit(false, stringNumber); - SE_SoeInit(false, stringNumber); + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + SE_InitializeSoc(false, s); + SE_InitializeSoe(false, s); + SE_InitializeSoh(s); } } - pSystemState->timer = SYS_FSM_MEDIUM_TIME; - pSystemState->state = SYS_STATEMACH_INITIALIZE_BMS; - pSystemState->substate = SYS_ENTRY; + pSystemState->initializationTimeout = 0u; + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->state = SYS_STATEMACH_INITIALIZE_IMD; + pSystemState->substate = SYS_ENTRY; + break; + + /****************************INITIALIZED_IMD*************************************/ + + case SYS_STATEMACH_INITIALIZE_IMD: + SYS_SAVELASTSTATES(pSystemState); + + if (pSystemState->substate == SYS_ENTRY) { + if (IMD_REQUEST_OK == IMD_RequestInitialization()) { + /* Request inquired successfully */ + pSystemState->timer = SYS_FSM_MEDIUM_TIME; + pSystemState->state = SYS_STATEMACH_INITIALIZE_BMS; + pSystemState->substate = SYS_ENTRY; + pSystemState->initializationTimeout = 0u; + } else { + /* Request declined -> retry max. 3 times */ + pSystemState->initializationTimeout++; + pSystemState->timer = SYS_FSM_SHORT_TIME; + if (pSystemState->initializationTimeout >= SYS_STATEMACH_INITIALIZATION_REQUEST_RETRY_COUNTER) { + /* Switch to error state */ + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->state = SYS_STATEMACH_ERROR; + pSystemState->substate = SYS_IMD_INITIALIZATION_ERROR; + } + } + break; + } else if (pSystemState->substate == SYS_WAIT_INITIALIZATION_IMD) { + imdInitialized = IMD_GetInitializationState(); + if (imdInitialized == true) { + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->state = SYS_STATEMACH_INITIALIZE_BMS; + pSystemState->substate = SYS_ENTRY; + break; + } else { + if (pSystemState->initializationTimeout > + (SYS_STATEMACH_IMD_INITIALIZATION_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->state = SYS_STATEMACH_ERROR; + pSystemState->substate = SYS_IMD_INITIALIZATION_ERROR; + break; + } + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->initializationTimeout++; + break; + } + } else { + FAS_ASSERT(FAS_TRAP); /* substate does not exist in this state */ + } break; /****************************INITIALIZE BMS*************************************/ @@ -497,13 +554,15 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { (SYS_STATEMACH_INITIALIZATION_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->state = SYS_STATEMACH_ERROR; - pSystemState->substate = SYS_BMS_INIT_ERROR; + pSystemState->substate = SYS_BMS_INITIALIZATION_ERROR; break; } pSystemState->timer = SYS_FSM_SHORT_TIME; pSystemState->initializationTimeout++; break; } + } else { + FAS_ASSERT(FAS_TRAP); /* substate does not exist in this state */ } break; @@ -578,7 +637,7 @@ static SYS_RETURN_TYPE_e SYS_CheckStateRequest(SYS_STATE_REQUEST_e stateRequest) } else { if (sys_state.stateRequest == SYS_STATE_NO_REQUEST) { /* init only allowed from the uninitialized state */ - if (stateRequest == SYS_STATE_INIT_REQUEST) { + if (stateRequest == SYS_STATE_INITIALIZATION_REQUEST) { if (sys_state.state == SYS_STATEMACH_UNINITIALIZED) { retval = SYS_OK; } else { @@ -600,7 +659,7 @@ extern void SYS_GeneralMacroBist(void) { const uint8_t dummy[REPEAT_MAXIMUM_REPETITIONS] = { REPEAT_U(SYS_BIST_GENERAL_MAGIC_NUMBER, STRIP(REPEAT_MAXIMUM_REPETITIONS))}; for (uint8_t i = 0u; i < REPEAT_MAXIMUM_REPETITIONS; i++) { - FAS_ASSERT(SYS_BIST_GENERAL_MAGIC_NUMBER == dummy[i]); + FAS_ASSERT(dummy[i] == SYS_BIST_GENERAL_MAGIC_NUMBER); } } diff --git a/src/app/engine/sys/sys.h b/src/app/engine/sys/sys.h index a1221407..c1e0a187 100644 --- a/src/app/engine/sys/sys.h +++ b/src/app/engine/sys/sys.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file sys.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-10-12 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix SYS * @@ -61,14 +62,14 @@ /*========== Macros and Definitions =========================================*/ /** Symbolic names for busyness of the system */ -typedef enum SYS_CHECK { +typedef enum { SYS_CHECK_OK, /*!< system ok */ SYS_CHECK_BUSY, /*!< system busy */ SYS_CHECK_NOT_OK, /*!< system not ok */ } SYS_CHECK_e; /** States of the state machine */ -typedef enum SYS_FSM_STATES { +typedef enum { SYS_FSM_STATE_DUMMY, /*!< dummy state - always the first state */ SYS_FSM_STATE_HAS_NEVER_RUN, /*!< never run state - always the second state */ SYS_FSM_STATE_UNINITIALIZED, /*!< uninitialized state */ @@ -78,7 +79,7 @@ typedef enum SYS_FSM_STATES { } SYS_FSM_STATES_e; /** Substates of the state machine */ -typedef enum SYS_FSM_SUBSTATES { +typedef enum { SYS_FSM_SUBSTATE_DUMMY, /*!< dummy state - always the first substate */ SYS_FSM_SUBSTATE_ENTRY, /*!< entry state - always the second substate */ SYS_FSM_SUBSTATE_INITIALIZATION_SBC, /*!< TODO */ @@ -97,7 +98,7 @@ typedef enum SYS_FSM_SUBSTATES { /*================== Constant and Variable Definitions ======================*/ /** States of the SYS state machine */ -typedef enum SYS_STATEMACH { +typedef enum { /* Init-Sequence */ SYS_STATEMACH_UNINITIALIZED, /*!< */ SYS_STATEMACH_INITIALIZATION, /*!< */ @@ -113,12 +114,12 @@ typedef enum SYS_STATEMACH { SYS_STATEMACH_FIRST_MEASUREMENT_CYCLE, /*!< */ SYS_STATEMACH_INITIALIZE_MISC, /*!< */ SYS_STATEMACH_CHECK_CURRENT_SENSOR_PRESENCE, /*!< */ - SYS_STATEMACH_INITIALIZE_ISOGUARD, /*!< */ + SYS_STATEMACH_INITIALIZE_IMD, /*!< initialize IMD module */ SYS_STATEMACH_ERROR, /*!< Error-State */ } SYS_STATEMACH_e; /** Substates of the SYS state machine */ -typedef enum SYS_STATEMACH_SUB { +typedef enum { SYS_ENTRY, /*!< Substate entry state */ SYS_CHECK_ERROR_FLAGS, /*!< Substate check if any error flag set */ SYS_CHECK_STATE_REQUESTS, /*!< Substate check if there is a state request */ @@ -127,27 +128,29 @@ typedef enum SYS_STATEMACH_SUB { SYS_WAIT_INITIALIZATION_CONT, /*!< Substate to wait for initialization of the contactor state machine */ SYS_WAIT_INITIALIZATION_BAL, /*!< Substate to wait for initialization of the balancing state machine */ SYS_WAIT_INITIALIZATION_BAL_GLOBAL_ENABLE, /*!< Substate to enable/disable balancing globally */ + SYS_WAIT_INITIALIZATION_IMD, /*!< Substate to wait for initialization of the imd state machine */ SYS_WAIT_INITIALIZATION_BMS, /*!< Substate to wait for initialization of the bms state machine */ SYS_WAIT_FIRST_MEASUREMENT_CYCLE, /*!< Substate to wait for first measurement cycle to complete */ SYS_WAIT_CURRENT_SENSOR_PRESENCE, /*!< Substate to wait for first measurement cycle to complete */ - SYS_SBC_INIT_ERROR, /*!< Substate error of SBC initialization */ - SYS_CONT_INIT_ERROR, /*!< Substate error of contactor state machine initialization */ - SYS_BAL_INIT_ERROR, /*!< Substate error of balancing state machine initialization */ - SYS_ILCK_INIT_ERROR, /*!< Substate error of contactor state machine initialization */ - SYS_BMS_INIT_ERROR, /*!< Substate error of bms state machine initialization */ - SYS_MEAS_INIT_ERROR, /*!< Substate error if first measurement cycle does not complete */ + SYS_SBC_INITIALIZATION_ERROR, /*!< Substate error of SBC initialization */ + SYS_CONT_INITIALIZATION_ERROR, /*!< Substate error of contactor state machine initialization */ + SYS_BAL_INITIALIZATION_ERROR, /*!< Substate error of balancing state machine initialization */ + SYS_ILCK_INITIALIZATION_ERROR, /*!< Substate error of contactor state machine initialization */ + SYS_IMD_INITIALIZATION_ERROR, /*!< Substate error of bms state machine initialization */ + SYS_BMS_INITIALIZATION_ERROR, /*!< Substate error of bms state machine initialization */ + SYS_MEAS_INITIALIZATION_ERROR, /*!< Substate error if first measurement cycle does not complete */ SYS_CURRENT_SENSOR_PRESENCE_ERROR, /*!< Substate error if first measurement cycle does not complete */ } SYS_STATEMACH_SUB_e; /** State requests for the SYS statemachine */ -typedef enum SYS_STATE_REQUEST { - SYS_STATE_INIT_REQUEST, /*!< initialization request */ - SYS_STATE_ERROR_REQUEST, /*!< error state requested */ - SYS_STATE_NO_REQUEST, /*!< no request */ +typedef enum { + SYS_STATE_INITIALIZATION_REQUEST, /*!< initialization request */ + SYS_STATE_ERROR_REQUEST, /*!< error state requested */ + SYS_STATE_NO_REQUEST, /*!< no request */ } SYS_STATE_REQUEST_e; /** Possible return values when state requests are made to the SYS statemachine */ -typedef enum SYS_RETURN_TYPE { +typedef enum { SYS_OK, /*!< sys --> ok */ SYS_BUSY_OK, /*!< sys busy --> ok */ SYS_REQUEST_PENDING, /*!< requested to be executed */ @@ -160,7 +163,7 @@ typedef enum SYS_RETURN_TYPE { * This structure contains all the variables relevant for the CONT state machine. * The user can get the current state of the CONT state machine with this variable */ -typedef struct SYS_STATE { +typedef struct { uint16_t timer; /*!< time in ms before the state machine processes the next state, e.g. in counts of 1ms */ SYS_STATE_REQUEST_e stateRequest; /*!< current state request made to the state machine */ SYS_STATEMACH_e state; /*!< state of Driver State Machine */ diff --git a/src/app/engine/sys_mon/sys_mon.c b/src/app/engine/sys_mon/sys_mon.c index f33cfd29..bb04162f 100644 --- a/src/app/engine/sys_mon/sys_mon.c +++ b/src/app/engine/sys_mon/sys_mon.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,17 +43,19 @@ * @file sys_mon.c * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2020-05-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix SYSM * - * @brief TODO + * @brief system monitoring module */ /*========== Includes =======================================================*/ #include "sys_mon.h" #include "diag.h" +#include "fram.h" #include "os.h" /*========== Macros and Definitions =========================================*/ @@ -62,13 +64,89 @@ /** tracking variable for System monitoring notifications */ static SYSM_NOTIFICATION_s sysm_notifications[SYSM_TASK_ID_MAX]; +/** local shadow copy of the FRAM entry */ +static FRAM_SYS_MON_RECORD_s sysm_localFramCopy = {0}; + +/** flag, indicating that the FRAM entry has been changed and should be written */ +static volatile bool sysm_flagFramCopyHasChanges = false; + /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** + * @brief Records the violation of a timing in non volatile memory + * + * @param[in] taskId id of the violating task + * @param[in] taskDuration duration of the task when recording the violation + * @param[in] timestampEnter timestamp that the task has entered + */ +static void SYSM_RecordTimingViolation(SYSM_TASK_ID_e taskId, uint32_t taskDuration, uint32_t timestampEnter); + +/** + * @brief Convert recorded timings into a decision (bool) whether the timing has been violated or not + * @details Timing has been violated if both duration or timestamp are not equal to zero + * @param[in] duration duration in ticks + * @param[in] timestampEnter entry timestamp in ticks + * @returns bool describing whether this is a violation (true) or not (false) + */ +static bool SYSM_ConvertRecordedTimingsToViolation(uint32_t duration, uint32_t timestampEnter); /*========== Static Function Implementations ================================*/ +static void SYSM_RecordTimingViolation(SYSM_TASK_ID_e taskId, uint32_t taskDuration, uint32_t timestampEnter) { + FAS_ASSERT(taskId < SYSM_TASK_ID_MAX); + + sysm_flagFramCopyHasChanges = true; + sysm_localFramCopy.anyTimingIssueOccurred = true; + + switch (taskId) { + case SYSM_TASK_ID_ENGINE: + sysm_localFramCopy.taskEngineViolatingDuration = taskDuration; + sysm_localFramCopy.taskEngineEnterTimestamp = timestampEnter; + break; + case SYSM_TASK_ID_CYCLIC_1ms: + sysm_localFramCopy.task1msViolatingDuration = taskDuration; + sysm_localFramCopy.task1msEnterTimestamp = timestampEnter; + break; + case SYSM_TASK_ID_CYCLIC_10ms: + sysm_localFramCopy.task10msViolatingDuration = taskDuration; + sysm_localFramCopy.task10msEnterTimestamp = timestampEnter; + break; + case SYSM_TASK_ID_CYCLIC_100ms: + sysm_localFramCopy.task100msViolatingDuration = taskDuration; + sysm_localFramCopy.task100msEnterTimestamp = timestampEnter; + break; + case SYSM_TASK_ID_CYCLIC_ALGORITHM_100ms: + sysm_localFramCopy.task100msAlgorithmViolatingDuration = taskDuration; + sysm_localFramCopy.task100msAlgorithmEnterTimestamp = timestampEnter; + break; + default: + /* this should not be possible to happen */ + FAS_ASSERT(FAS_TRAP); + break; + } +} + +static bool SYSM_ConvertRecordedTimingsToViolation(uint32_t duration, uint32_t timestampEnter) { + bool returnValue = false; + if ((duration != 0u) || (timestampEnter != 0u)) { + returnValue = true; + } + return returnValue; +} /*========== Extern Function Implementations ================================*/ +STD_RETURN_TYPE_e SYSM_Init(void) { + /* no need to check for the configuration as it is already checked with a + static assert */ + + /* read from FRAM interface the sys mon violations */ + (void)FRAM_ReadData(FRAM_BLOCK_ID_SYS_MON_RECORD); + /* copy FRAM into local shadow copy */ + SYSM_CopyFramStruct(&fram_sys_mon_record, &sysm_localFramCopy); + + return STD_OK; +} + void SYSM_CheckNotifications(void) { static uint32_t sysm_timestamp = 0; @@ -91,9 +169,10 @@ void SYSM_CheckNotifications(void) { if ((time_since_last_call > max_allowed_jitter) && (sysm_notifications[taskId].duration > sysm_ch_cfg[taskId].cycleTime)) { /* module not running within its timed limits */ - DIAG_Handler(DIAG_ID_SYSTEMMONITORING, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, taskId); + DIAG_Handler(DIAG_ID_SYSTEMMONITORING, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, (uint32_t)taskId); if (sysm_ch_cfg[taskId].enableRecording == SYSM_RECORDING_ENABLED) { - /* TODO add recording function (when MRAM/FRAM are available) */ + SYSM_RecordTimingViolation( + taskId, sysm_notifications[taskId].duration, sysm_notifications[taskId].timestampEnter); } sysm_ch_cfg[taskId].callbackfunc(taskId); } @@ -101,23 +180,111 @@ void SYSM_CheckNotifications(void) { } } -void SYSM_Notify(SYSM_TASK_ID_e taskId, SYSM_NOTIFY_TYPE_e state, uint32_t time) { - if (taskId < SYSM_TASK_ID_MAX) { - sysm_notifications[taskId].state = state; +void SYSM_Notify(SYSM_TASK_ID_e taskId, SYSM_NOTIFY_TYPE_e state, uint32_t timestamp) { + FAS_ASSERT(taskId < SYSM_TASK_ID_MAX); + FAS_ASSERT((state == SYSM_NOTIFY_ENTER) || (state == SYSM_NOTIFY_EXIT)); + OS_EnterTaskCritical(); + sysm_notifications[taskId].state = state; + if (state == SYSM_NOTIFY_ENTER) { + sysm_notifications[taskId].timestampEnter = timestamp; + } else if (state == SYSM_NOTIFY_EXIT) { + sysm_notifications[taskId].timestampExit = timestamp; + sysm_notifications[taskId].duration = timestamp - sysm_notifications[taskId].timestampEnter; + } else { + /* state has an illegal value */ + FAS_ASSERT(FAS_TRAP); + } + OS_ExitTaskCritical(); +} + +extern void SYSM_GetRecordedTimingViolations(SYSM_TIMING_VIOLATION_RESPONSE_s *pAnswer) { + FAS_ASSERT(pAnswer != NULL_PTR); + + OS_EnterTaskCritical(); + FRAM_SYS_MON_RECORD_s localSysMonRecord = {0}; + SYSM_CopyFramStruct(&fram_sys_mon_record, &localSysMonRecord); + OS_ExitTaskCritical(); + + if (localSysMonRecord.anyTimingIssueOccurred == false) { + /* no timing violations recorded, abort */ + pAnswer->recordedViolationAny = false; + pAnswer->recordedViolationEngine = false; + pAnswer->recordedViolation1ms = false; + pAnswer->recordedViolation10ms = false; + pAnswer->recordedViolation100ms = false; + pAnswer->recordedViolation100msAlgo = false; + } else { + /* timing violation, find it */ + pAnswer->recordedViolationAny = true; + pAnswer->recordedViolationEngine = SYSM_ConvertRecordedTimingsToViolation( + localSysMonRecord.taskEngineViolatingDuration, localSysMonRecord.taskEngineEnterTimestamp); + pAnswer->recordedViolation1ms = SYSM_ConvertRecordedTimingsToViolation( + localSysMonRecord.task1msViolatingDuration, localSysMonRecord.task1msEnterTimestamp); + pAnswer->recordedViolation10ms = SYSM_ConvertRecordedTimingsToViolation( + localSysMonRecord.task10msViolatingDuration, localSysMonRecord.task10msEnterTimestamp); + pAnswer->recordedViolation100ms = SYSM_ConvertRecordedTimingsToViolation( + localSysMonRecord.task100msViolatingDuration, localSysMonRecord.task100msEnterTimestamp); + pAnswer->recordedViolation100msAlgo = SYSM_ConvertRecordedTimingsToViolation( + localSysMonRecord.task100msAlgorithmViolatingDuration, localSysMonRecord.task100msAlgorithmEnterTimestamp); + } +} + +extern void SYSM_ClearAllTimingViolations(void) { + /* clear all diag entries */ + for (SYSM_TASK_ID_e taskId = (SYSM_TASK_ID_e)0; taskId < SYSM_TASK_ID_MAX; taskId++) { + DIAG_Handler(DIAG_ID_SYSTEMMONITORING, DIAG_EVENT_OK, DIAG_SYSTEM, (uint32_t)taskId); + } + /* clear local FRAM copy */ + OS_EnterTaskCritical(); + sysm_localFramCopy.anyTimingIssueOccurred = false; + sysm_localFramCopy.taskEngineEnterTimestamp = 0u; + sysm_localFramCopy.taskEngineViolatingDuration = 0u; + sysm_localFramCopy.task1msEnterTimestamp = 0u; + sysm_localFramCopy.task1msViolatingDuration = 0u; + sysm_localFramCopy.task10msEnterTimestamp = 0u; + sysm_localFramCopy.task10msViolatingDuration = 0u; + sysm_localFramCopy.task100msEnterTimestamp = 0u; + sysm_localFramCopy.task100msViolatingDuration = 0u; + sysm_localFramCopy.task100msAlgorithmEnterTimestamp = 0u; + sysm_localFramCopy.task100msAlgorithmViolatingDuration = 0u; + sysm_flagFramCopyHasChanges = true; + OS_ExitTaskCritical(); + /* commit to FRAM */ + SYSM_UpdateFramData(); +} + +extern void SYSM_UpdateFramData(void) { + OS_EnterTaskCritical(); + const bool updateNecessary = sysm_flagFramCopyHasChanges; + OS_ExitTaskCritical(); + if (updateNecessary == true) { OS_EnterTaskCritical(); - if (SYSM_NOTIFY_ENTER == state) { - sysm_notifications[taskId].timestampEnter = time; - } else if (SYSM_NOTIFY_EXIT == state) { - sysm_notifications[taskId].timestampExit = time; - sysm_notifications[taskId].duration = time - sysm_notifications[taskId].timestampEnter; - } else { - /* state has an illegal value */ - FAS_ASSERT(FAS_TRAP); - } + SYSM_CopyFramStruct(&sysm_localFramCopy, &fram_sys_mon_record); + sysm_flagFramCopyHasChanges = false; OS_ExitTaskCritical(); + + FRAM_WriteData(FRAM_BLOCK_ID_SYS_MON_RECORD); } } +extern void SYSM_CopyFramStruct(const FRAM_SYS_MON_RECORD_s *const kpkFrom, FRAM_SYS_MON_RECORD_s *pTo) { + FAS_ASSERT(kpkFrom != NULL_PTR); + FAS_ASSERT(pTo != NULL_PTR); + + /* copy all elements in order to make sure that we are always compatible (independently of C-version) */ + pTo->anyTimingIssueOccurred = kpkFrom->anyTimingIssueOccurred; + pTo->task100msAlgorithmEnterTimestamp = kpkFrom->task100msAlgorithmEnterTimestamp; + pTo->task100msAlgorithmViolatingDuration = kpkFrom->task100msAlgorithmViolatingDuration; + pTo->task100msEnterTimestamp = kpkFrom->task100msEnterTimestamp; + pTo->task100msViolatingDuration = kpkFrom->task100msViolatingDuration; + pTo->task10msEnterTimestamp = kpkFrom->task10msEnterTimestamp; + pTo->task10msViolatingDuration = kpkFrom->task10msViolatingDuration; + pTo->task1msEnterTimestamp = kpkFrom->task1msEnterTimestamp; + pTo->task1msViolatingDuration = kpkFrom->task1msViolatingDuration; + pTo->taskEngineEnterTimestamp = kpkFrom->taskEngineEnterTimestamp; + pTo->taskEngineViolatingDuration = kpkFrom->taskEngineViolatingDuration; +} + /*========== Getter for static Variables (Unit Test) ========================*/ #ifdef UNITY_UNIT_TEST extern SYSM_NOTIFICATION_s *TEST_SYSM_GetNotifications(void) { diff --git a/src/app/engine/sys_mon/sys_mon.h b/src/app/engine/sys_mon/sys_mon.h index 54cb85a8..ef98c78e 100644 --- a/src/app/engine/sys_mon/sys_mon.h +++ b/src/app/engine/sys_mon/sys_mon.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,11 +43,12 @@ * @file sys_mon.h * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ENGINE * @prefix SYSM * - * @brief TODO + * @brief system monitoring module */ #ifndef FOXBMS__SYS_MON_H_ @@ -56,24 +57,44 @@ /*========== Includes =======================================================*/ #include "sys_mon_cfg.h" +#include "fram.h" + /*========== Macros and Definitions =========================================*/ /** defines entry or exit */ -typedef enum SYSM_NOTIFY_TYPE { +typedef enum { SYSM_NOTIFY_ENTER, /**< entry into a task */ SYSM_NOTIFY_EXIT, /**< exit from a task */ } SYSM_NOTIFY_TYPE_e; /** state (in summary) used for task or function notification */ -typedef struct SYSM_NOTIFICATION { +typedef struct { SYSM_NOTIFY_TYPE_e state; /**< state of the task */ uint32_t timestampEnter; /**< timestamp of entry into state */ uint32_t timestampExit; /**< timestamp of exit from state */ uint32_t duration; /**< duration between last complete entry and exit cycle */ } SYSM_NOTIFICATION_s; +/** compact data fromat for reporting violation states */ +typedef struct { + bool recordedViolationAny; /*!< compound flag indicating if any violation occurred */ + bool recordedViolationEngine; /*!< flag indicating if a engine violation is recorded */ + bool recordedViolation1ms; /*!< flag indicating if a 1ms violation is recorded */ + bool recordedViolation10ms; /*!< flag indicating if a 10ms violation is recorded */ + bool recordedViolation100ms; /*!< flag indicating if a 100ms violation is recorded */ + bool recordedViolation100msAlgo; /*!< flag indicating if a 100ms algorithm violation is recorded */ +} SYSM_TIMING_VIOLATION_RESPONSE_s; + /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ +/** + * @brief initialization function for system monitoring + * @details Has to be called once after startup to initialize and check system + * monitoring related functionality + * @return #STD_OK if no configuration error detected, otherwise #STD_NOT_OK + */ +extern STD_RETURN_TYPE_e SYSM_Init(void); + /** * @brief overall system monitoring * @details checks notifications (state and timestamps) of all system-relevant @@ -87,9 +108,41 @@ extern void SYSM_CheckNotifications(void); * @details Has to be called in every function using the system monitoring. * @param taskId task id to notify system monitoring * @param state whether function has been called at entry or exit - * @param time time + * @param timestamp time + */ +extern void SYSM_Notify(SYSM_TASK_ID_e taskId, SYSM_NOTIFY_TYPE_e state, uint32_t timestamp); + +/** + * @brief Returns the timing violation flags determined from fram state + * @details This function reads the timing states and determines if a violation + * has occurred. + * @param[out] pAnswer pointer to a #SYSM_TIMING_VIOLATION_RESPONSE_s struct that will be filled by the function + */ +extern void SYSM_GetRecordedTimingViolations(SYSM_TIMING_VIOLATION_RESPONSE_s *pAnswer); + +/** + * @brief Clears all timing violations (both current and recorded) + * @details This function clears all indicators that a timing violation has + * happened. + */ +extern void SYSM_ClearAllTimingViolations(void); + +/** + * @brief Commits the stored changes to FRAM if necessary + * @details Writing to FRAM is costly (in terms of computation time), therefore + * it is decoupled from the main task of the sys mon module. + * When called, this function checks the flag sysm_flagFramCopyHasChanges + * and writes to FRAM if there are changes. + */ +extern void SYSM_UpdateFramData(void); + +/** + * @brief Copy from the from entry to the to entry. + * + * @param[in] kpkFrom pointer to the origin struct + * @param[out] pTo pointer to the destination struct */ -extern void SYSM_Notify(SYSM_TASK_ID_e taskId, SYSM_NOTIFY_TYPE_e state, uint32_t time); +extern void SYSM_CopyFramStruct(const FRAM_SYS_MON_RECORD_s *const kpkFrom, FRAM_SYS_MON_RECORD_s *pTo); /*========== Getter for static Variables (Unit Test) ========================*/ #ifdef UNITY_UNIT_TEST diff --git a/src/app/engine/wscript b/src/app/engine/wscript index 4b678dbc..fd0bf4cd 100644 --- a/src/app/engine/wscript +++ b/src/app/engine/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -61,10 +61,10 @@ def build(bld): os.path.join("diag", "cbs", "diag_cbs_current-sensor.c"), os.path.join("diag", "cbs", "diag_cbs_deep-discharge.c"), os.path.join("diag", "cbs", "diag_cbs_dummy.c"), + os.path.join("diag", "cbs", "diag_cbs_fram.c"), os.path.join("diag", "cbs", "diag_cbs_i2c.c"), os.path.join("diag", "cbs", "diag_cbs_insulation.c"), os.path.join("diag", "cbs", "diag_cbs_interlock.c"), - os.path.join("diag", "cbs", "diag_cbs_ltc.c"), os.path.join("diag", "cbs", "diag_cbs_afe.c"), os.path.join("diag", "cbs", "diag_cbs_plausibility.c"), os.path.join("diag", "cbs", "diag_cbs_power-measurement.c"), @@ -107,6 +107,7 @@ def build(bld): os.path.join("..", "driver", "sbc", "fs8x_driver"), os.path.join("..", "driver", "spi"), os.path.join("..", "driver", "sps"), + os.path.join("..", "driver", "mcu"), os.path.join("..", "main", "include"), os.path.join("..", "task", "os"), os.path.join("..", "task", "config"), diff --git a/src/app/main/fassert.c b/src/app/main/fassert.c index c521f949..194c87e7 100644 --- a/src/app/main/fassert.c +++ b/src/app/main/fassert.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fassert.c * @author foxBMS Team * @date 2020-05-26 (date of creation) - * @updated 2020-05-26 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ASSERT * @prefix FAS * @@ -60,19 +61,23 @@ /*========== Static Constant and Variable Definitions =======================*/ /*========== Extern Constant and Variable Definitions =======================*/ -ASSERT_LOC_s fas_assertLocation = {0}; /*========== Static Function Prototypes =====================================*/ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void fas_storeAssertLoc(uint32_t *pc, uint32_t line) { - fas_assertLocation.pc = (uint32_t *)pc; +extern void FAS_StoreAssertLocation(uint32_t *pc, uint32_t line) { + /* AXIVION Routine Generic-MissingParameterAssert: pc: asserting does not make sense as we come from an assert */ + /* AXIVION Routine Generic-MissingParameterAssert: line: line creating the assertion can be any line in uint32_t */ /* Storing the line number is redundant if we have pc and lr. It is kept nevertheless in order to make each assert call unique and thus avoid optimization (which makes it more confusing). */ - fas_assertLocation.line = (uint32_t)line; + FAS_ASSERT_LOCATION_s fas_assertLocation = { + .pc = pc, + .line = line, + }; + (void)fas_assertLocation; } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/main/fstartup.c b/src/app/main/fstartup.c index 1092bbf1..cfa3dafa 100644 --- a/src/app/main/fstartup.c +++ b/src/app/main/fstartup.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,16 +43,17 @@ * @file fstartup.c * @author foxBMS Team * @date 2020-07-09 (date of creation) - * @updated 2020-07-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL - * @prefix NONE + * @prefix STU * * @brief Startup code * * @details This file contains startup code mostly identical to TI code. * Function "_c_int00" is extracted from file "HL_sys_startup.c" and - * function "getResetSourceWithoutFlagReset" is taken from file - * "HL_system.c". Both files are generated by Halcogen under the + * function "STU_GetResetSourceWithoutFlagReset" is taken from file + * "HL_system.c". Both files are generated by TI HALCoGen under the * following license: * * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com @@ -89,6 +90,7 @@ /*========== Includes =======================================================*/ /* clang-format off */ +/* keep include order as suggested by TI HALCoGen */ #include "HL_sys_common.h" #include "HL_system.h" #include "HL_sys_vim.h" @@ -97,90 +99,72 @@ #include "HL_sys_mpu.h" #include "HL_errata_SSWF021_45.h" +#include "fstartup.h" #include "main.h" - +/* clang-format on */ /*========== Macros and Definitions =========================================*/ -/* --------- START - Must be consistent with HL_sys_startup.c - START -------*/ - -/** initialize global variable and constructors */ -extern void __TI_auto_init(void); -/** exit application */ -extern void exit(int _status); -/** handler for a failed PLL lock */ -void handlePLLLockFail(void); -/* Startup Routine */ -void _c_int00(void); /** number of retries for the PLL to come up */ -#define PLL_RETRIES 5U - -/* ----------- END - Must be consistent with HL_sys_startup.c - END ---------*/ +#define STU_PLL_RETRIES 5U /*========== Static Constant and Variable Definitions =======================*/ /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** + * @brief Handler for a failed PLL lock + * @details If the PLL can not be locked the, this function shall be called to + * ensure that the application no further starts. + * @return This function never returns */ +static void STU_HandlePllLockFail(void); + /** * @brief Get reset flag * @details Get reset source without reseting respective the flag in SYSESR * register * @return returns reset reason */ -static resetSource_t getResetSourceWithoutFlagReset(void); +static resetSource_t STU_GetResetSourceWithoutFlagReset(void); /*========== Static Function Implementations ================================*/ -resetSource_t getResetSourceWithoutFlagReset(void) -{ + +void STU_HandlePllLockFail(void) { + while (1) { + } +} +resetSource_t STU_GetResetSourceWithoutFlagReset(void) { register resetSource_t rst_source; - if ((SYS_EXCEPTION & (uint32)POWERON_RESET) != 0U) - { + if ((SYS_EXCEPTION & (uint32)POWERON_RESET) != 0U) { /* power-on reset condition */ rst_source = POWERON_RESET; - } - else if ((SYS_EXCEPTION & (uint32)EXT_RESET) != 0U) - { + } else if ((SYS_EXCEPTION & (uint32)EXT_RESET) != 0U) { /*** Check for other causes of EXT_RESET that would take precedence **/ - if ((SYS_EXCEPTION & (uint32)OSC_FAILURE_RESET) != 0U) - { + if ((SYS_EXCEPTION & (uint32)OSC_FAILURE_RESET) != 0U) { /* Reset caused due to oscillator failure. Add user code here to handle oscillator failure */ rst_source = OSC_FAILURE_RESET; - } - else if ((SYS_EXCEPTION & (uint32)WATCHDOG_RESET) !=0U) - { + } else if ((SYS_EXCEPTION & (uint32)WATCHDOG_RESET) != 0U) { /* Reset caused due watchdog violation */ rst_source = WATCHDOG_RESET; - } - else if ((SYS_EXCEPTION & (uint32)WATCHDOG2_RESET) !=0U) - { + } else if ((SYS_EXCEPTION & (uint32)WATCHDOG2_RESET) != 0U) { /* Reset caused due watchdog violation */ rst_source = WATCHDOG2_RESET; - } - else if ((SYS_EXCEPTION & (uint32)SW_RESET) != 0U) - { + } else if ((SYS_EXCEPTION & (uint32)SW_RESET) != 0U) { /* Reset caused due to software reset. */ rst_source = SW_RESET; - } - else - { + } else { /* Reset caused due to External reset. */ rst_source = EXT_RESET; } - } - else if ((SYS_EXCEPTION & (uint32)DEBUG_RESET) !=0U) - { + } else if ((SYS_EXCEPTION & (uint32)DEBUG_RESET) != 0U) { /* Reset caused due Debug reset request */ rst_source = DEBUG_RESET; - } - else if ((SYS_EXCEPTION & (uint32)CPU0_RESET) !=0U) - { + } else if ((SYS_EXCEPTION & (uint32)CPU0_RESET) != 0U) { /* Reset caused due to CPU0 reset. CPU reset can be caused by CPU self-test completion, or by toggling the "CPU RESET" bit of the CPU Reset Control Register. */ rst_source = CPU0_RESET; - } - else - { - /* No_reset occured. */ + } else { + /* No_reset occurred. */ rst_source = NO_RESET; } return rst_source; @@ -193,8 +177,7 @@ resetSource_t getResetSourceWithoutFlagReset(void) /* SourceId : STARTUP_SourceId_001 */ /* DesignId : STARTUP_DesignId_001 */ /* Requirements : HL_CONQ_STARTUP_SR1 */ -void _c_int00(void) -{ +void _c_int00(void) { register resetSource_t rstSrc; /* Initialize Core Registers to avoid CCM Error */ @@ -207,79 +190,75 @@ void _c_int00(void) * to identify the cause of the CPU reset. */ /* Changed in comparison to TI _c_int00 implementation. Readout flags but do NOT clear them! */ - rstSrc = getResetSourceWithoutFlagReset(); - switch(rstSrc) - { + rstSrc = STU_GetResetSourceWithoutFlagReset(); + switch (rstSrc) { case POWERON_RESET: - /* Initialize L2RAM to avoid ECC errors right after power on */ - _memInit_(); - - /* Add condition to check whether PLL can be started successfully */ - if (_errata_SSWF021_45_both_plls(PLL_RETRIES) != 0U) - { - /* Put system in a safe state */ - handlePLLLockFail(); - } + /* Initialize L2RAM to avoid ECC errors right after power on */ + _memInit_(); + + /* Add condition to check whether PLL can be started successfully */ + if (_errata_SSWF021_45_both_plls(STU_PLL_RETRIES) != 0U) { + /* Put system in a safe state */ + STU_HandlePllLockFail(); + } case DEBUG_RESET: case EXT_RESET: - /* Initialize L2RAM to avoid ECC errors right after power on */ - if(rstSrc != POWERON_RESET) - { - _memInit_(); - } + /* Initialize L2RAM to avoid ECC errors right after power on */ + if (rstSrc != POWERON_RESET) { + _memInit_(); + } - /* Enable CPU Event Export */ - /* This allows the CPU to signal any single-bit or double-bit errors detected + /* Enable CPU Event Export */ + /* This allows the CPU to signal any single-bit or double-bit errors detected * by its ECC logic for accesses to program flash or data RAM. */ - _coreEnableEventBusExport_(); + _coreEnableEventBusExport_(); - /* Check if there were ESM group3 errors during power-up. + /* Check if there were ESM group3 errors during power-up. * These could occur during eFuse auto-load or during reads from flash OTP * during power-up. Device operation is not reliable and not recommended * in this case. */ - if ((esmREG->SR1[2]) != 0U) - { - esmGroup3Notification(esmREG,esmREG->SR1[2]); - } + if ((esmREG->SR1[2]) != 0U) { + esmGroup3Notification(esmREG, esmREG->SR1[2]); + } - /* Initialize System - Clock, Flash settings with Efuse self check */ - systemInit(); + /* Initialize System - Clock, Flash settings with Efuse self check */ + systemInit(); - /* Enable IRQ offset via Vic controller */ - _coreEnableIrqVicOffset_(); + /* Enable IRQ offset via Vic controller */ + _coreEnableIrqVicOffset_(); - /* Initialize VIM table */ - vimInit(); + /* Initialize VIM table */ + vimInit(); - /* Configure system response to error conditions signaled to the ESM group1 */ - /* This function can be configured from the ESM tab of HALCoGen */ - esmInit(); - break; + /* Configure system response to error conditions signaled to the ESM group1 */ + /* This function can be configured from the ESM tab of HALCoGen */ + esmInit(); + break; case OSC_FAILURE_RESET: - break; + break; case WATCHDOG_RESET: case WATCHDOG2_RESET: - break; + break; case CPU0_RESET: - /* Enable CPU Event Export */ - /* This allows the CPU to signal any single-bit or double-bit errors detected + /* Enable CPU Event Export */ + /* This allows the CPU to signal any single-bit or double-bit errors detected * by its ECC logic for accesses to program flash or data RAM. */ - _coreEnableEventBusExport_(); - break; + _coreEnableEventBusExport_(); + break; case SW_RESET: - break; + break; default: - break; + break; } _mpuInit_(); @@ -294,18 +273,4 @@ void _c_int00(void) exit(0); } - -/** @fn void handlePLLLockFail(void) -* @brief This function handles PLL lock fail. -*/ -void handlePLLLockFail(void) -{ - while(1) - { - - } -} - /*========== Externalized Static Function Implementations (Unit Test) =======*/ - -/* clang-format on */ diff --git a/src/app/main/include/config/version_cfg.h b/src/app/main/include/config/version_cfg.h index 0f50beb2..5ad186c9 100644 --- a/src/app/main/include/config/version_cfg.h +++ b/src/app/main/include/config/version_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file version_cfg.h * @author foxBMS Team * @date 2021-07-14 (date of creation) - * @updated 2021-10-19 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL * @prefix NONE * @@ -74,7 +75,7 @@ #define VERSION_INFORMATION __attribute__((section(".versionInformation"))) /** struct type that describes the version information of the system */ -typedef struct VERSION { +typedef struct { const bool underVersionControl; /*!< indicates whether the toolchain has detected version control */ const bool isDirty; /*!< indicates whether the code deviates from the last versioned state */ const uint8_t major; /*!< major release version */ diff --git a/src/app/main/include/fassert.h b/src/app/main/include/fassert.h index f85cb7b5..5463dac1 100644 --- a/src/app/main/include/fassert.h +++ b/src/app/main/include/fassert.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fassert.h * @author foxBMS Team * @date 2020-03-20 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup ASSERT * @prefix FAS * @@ -64,11 +65,11 @@ * on the configuration this might lead to a watchdog reset. This mode is * intended for investigation of problems by a developer. * - * - When ASSERT_LEVEL symbol is defined as ASSERT_LEVEL_NO_OP, the FAS_ASSERT - * macro is defined as empty and does nothing. It might be necessary to - * activate this mode in ressource-constrained situations. Generally it is - * not recommended to use this option as it will not notice the undefined - * system-states that the assert should catch. + * - When ASSERT_LEVEL symbol is defined as ASSERT_LEVEL_NO_OPERATION, the + * FAS_ASSERT macro is defined as empty and does nothing. It might be + * necessary to activate this mode in ressource-constrained situations. + * Generally it is not recommended to use this option as it will not notice + * the undefined system-states that the assert should catch. * * * Generally assertions should be used for asserting states and values that @@ -86,9 +87,14 @@ #define FOXBMS__FASSERT_H_ /*========== Includes =======================================================*/ +#include #include /*========== Macros and Definitions =========================================*/ + +/* AXIVION Disable Style MisraC2012-1.2 MisraC2012Directive-4.1: Function is + * implemented in Assembler (see swiPortDisableInterrupts) and this is the way + * to tell it the TI compiler */ /** * @brief Disable interrupts * @details This alias is mapped to an ASM function and disables all interrupts @@ -96,10 +102,9 @@ * through the control field mask byte PSR[7:0] (privileged * software execution) */ -/* AXIVION Disable Style MisraC2012Directive-4.1: Function is implemented in Assembler see swiPortDisableInterrupts */ #pragma SWI_ALIAS(FAS_DisableInterrupts, 5) extern void FAS_DisableInterrupts(void); -/* AXIVION Enable Style MisraC2012Directive-4.1: */ +/* AXIVION Enable Style MisraC2012-1.2 MisraC2012Directive-4.1: */ /** * @brief Define that evaluates to essential boolean false thus tripping @@ -114,20 +119,15 @@ extern void FAS_DisableInterrupts(void); * @details This struct is intended for storing, information on the place * in the code where an assert has been violated. */ -typedef struct ASSERT_LOC { +typedef struct { uint32_t *pc; /*!< value of the program counter register */ uint32_t line; /*!< line number where an assert has triggered */ -} ASSERT_LOC_s; - -/** - * @brief Stores the information on the last assert - */ -extern ASSERT_LOC_s fas_assertLocation; +} FAS_ASSERT_LOCATION_s; /** * @brief Copy the assert location into the assert struct. - * @details Takes the location of the last assertion and writes it into - * #fas_assertLocation. + * @details Takes the location of the last assertion and stores it into the + * static fas_assertLocation. * This definition has to be at this position in order to be used by * the macros below. * If you get issues in a unit test with this being not defined, try @@ -136,7 +136,7 @@ extern ASSERT_LOC_s fas_assertLocation; * occurred * @param[in] line line where the assertion occurred */ -extern void fas_storeAssertLoc(uint32_t *pc, uint32_t line); +extern void FAS_StoreAssertLocation(uint32_t *pc, uint32_t line); /** * @def ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS @@ -147,13 +147,13 @@ extern void fas_storeAssertLoc(uint32_t *pc, uint32_t line); * @brief This assert level traps the current task by going into an * infinite loop. * - * @def ASSERT_LEVEL_NO_OP + * @def ASSERT_LEVEL_NO_OPERATION * @brief This assert level does nothing (except for the standard recording * of the assert location which does every level). */ #define ASSERT_LEVEL_INF_LOOP_AND_DISABLE_INTERRUPTS (0u) #define ASSERT_LEVEL_INF_LOOP_FOR_DEBUG (1u) -#define ASSERT_LEVEL_NO_OP (2u) +#define ASSERT_LEVEL_NO_OPERATION (2u) /** * @def ASSERT_LEVEL @@ -169,17 +169,18 @@ extern void fas_storeAssertLoc(uint32_t *pc, uint32_t line); static inline void FAS_InfiniteLoop(void) { /* disable IRQ interrupts */ FAS_DisableInterrupts(); - while (1) { /* Stay here until watchdog reset happens */ + /* AXIVION Next Line Style MisraC2012-2.2: an infinite loop is intended to stop further code execution */ + while (true) { /* Stay here until watchdog reset happens */ } } #elif ASSERT_LEVEL == ASSERT_LEVEL_INF_LOOP_FOR_DEBUG /** Assert macro will stay in infinite loop */ static inline void FAS_InfiniteLoop(void) { - while (1) { + while (true) { /* Stay here to ease debugging */ } } -#elif ASSERT_LEVEL == ASSERT_LEVEL_NO_OP +#elif ASSERT_LEVEL == ASSERT_LEVEL_NO_OPERATION static inline void FAS_InfiniteLoop(void) { } #else @@ -201,15 +202,17 @@ static inline uint32_t __curpc(void) { /** * @brief Record the assert location * @details Retrieves the program counter (with __curpc()) and line-number at - * the current location and passes it to #fas_storeAssertLoc(). + * the current location and passes it to #FAS_StoreAssertLocation(). * * It is important that this is a macro in order to insert it directly * at he assert location in the code */ -#define FAS_ASSERT_RECORD() \ - do { \ - void *pc = __curpc(); \ - fas_storeAssertLoc(pc, __LINE__); \ +#define FAS_ASSERT_RECORD() \ + do { \ + /* AXIVION Next Line Style MisraC2012-11.5: The program counter needs to be casted to platform register + width */ \ + uint32_t *pc = (uint32_t *)__curpc(); \ + FAS_StoreAssertLocation(pc, __LINE__); \ } while (0) /*============= define the assertion-macro =============*/ @@ -245,13 +248,29 @@ static inline uint32_t __curpc(void) { } while (0) #endif -/** - * @brief static assertion macro - * @details This macro maps static_assert to a compiler intrinsic. - * This will fail during compilation if the condition is not - * true. - */ -#define static_assert(cond, msg) _Static_assert(cond, msg) +#if defined(__STDC_VERSION__) /* We have some newer compiler (C94 at least) */ +#if __STDC_VERSION__ == 199409L +#warning "Ignoring static asserts in C94 mode (f_static_assert)." +#define f_static_assert(cond, msg) +#elif __STDC_VERSION__ == 199901L +#if defined(__TI_COMPILER_VERSION__) +/* The TI compiler seems to have hacks to enable static assert see include/sys/cdefs.h */ +#define f_static_assert(cond, msg) _Static_assert(cond, msg) +#else /* for other compilers just ignore the static assert */ +#warning "Ignoring static asserts in C99 mode (f_static_assert)." +#define f_static_assert(...) +#endif +#elif __STDC_VERSION__ == 201112L +#define f_static_assert(cond, msg) _Static_assert(cond, msg) +#elif __STDC_VERSION__ == 201710L +#define f_static_assert(cond, msg) _Static_assert(cond, msg) +#endif +#else +/* if __STDC_VERSION__ is not defined, we have some very old compiler and we + need to ignore static asserting */ +#warning "Ignoring static asserts in C89/C90 mode (f_static_assert)." +#define f_static_assert(cond, msg) +#endif /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/main/include/fstartup.h b/src/app/main/include/fstartup.h new file mode 100644 index 00000000..48b68778 --- /dev/null +++ b/src/app/main/include/fstartup.h @@ -0,0 +1,85 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file fstartup.h + * @author foxBMS Team + * @date 2022-05-18 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup GENERAL + * @prefix STU + * + * @brief Startup code + */ + +#ifndef FOXBMS__FSTARTUP_H_ +#define FOXBMS__FSTARTUP_H_ + +/*========== Includes =======================================================*/ + +/*========== Macros and Definitions =========================================*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ +/** + * @brief initialize global variable and constructors + * @details TI library function */ +extern void __TI_auto_init(void); + +/** + * @brief exit application + * @details C standard exit function + * @param _status the return code to exit with + * */ +extern void exit(int _status); + +/** + * @brief Startup Routine + * @details The name of the startup routine is defined in the TI ARM CGT + * manual. +*/ +extern void _c_int00(void); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__FSTARTUP_H_ */ diff --git a/src/app/main/include/fstd_types.h b/src/app/main/include/fstd_types.h index b1960763..5b6082c1 100644 --- a/src/app/main/include/fstd_types.h +++ b/src/app/main/include/fstd_types.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fstd_types.h * @author foxBMS Team * @date 2015-12-20 (date of creation) - * @updated 2021-11-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL_CONF * @prefix STD * @@ -77,13 +78,13 @@ /*========== Extern Constant and Variable Declarations ======================*/ /** enum for standard return type */ -typedef enum STD_RETURN_TYPE { +typedef enum { STD_OK, /**< ok */ STD_NOT_OK, /**< not ok */ } STD_RETURN_TYPE_e; /** enum for pin state */ -typedef enum STD_PIN_STATE { +typedef enum { STD_PIN_LOW, /*!< electrical pin state: low */ STD_PIN_HIGH, /*!< electrical pin state: high */ STD_PIN_UNDEFINED, /*!< electrical pin state: undefined */ diff --git a/src/app/main/include/fsystem.h b/src/app/main/include/fsystem.h index 2a615951..103ba8ae 100644 --- a/src/app/main/include/fsystem.h +++ b/src/app/main/include/fsystem.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file fsystem.h * @author foxBMS Team * @date 2020-07-21 (date of creation) - * @updated 2021-11-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup SYSTEM * @prefix FSYS * @@ -57,6 +58,10 @@ /*========== Includes =======================================================*/ /*========== Macros and Definitions =========================================*/ + +/* AXIVION Disable Style MisraC2012-1.2 MisraC2012Directive-4.1: Function is + * implemented in Assembler (see swiRaisePrivilege) and this is the way to tell + * it the TI compiler */ /** * @brief raise privilege * @details This alias is mapped to an ASM function and raises to a privileged @@ -94,10 +99,9 @@ * platform and compiler. * @return return value is zero if caller was in user mode (type: long) */ -/* AXIVION Disable Style MisraC2012Directive-4.1: Function is implemented in Assembler see swiRaisePrivilege */ #pragma SWI_ALIAS(FSYS_RaisePrivilege, 1); extern long FSYS_RaisePrivilege(void); -/* AXIVION Enable Style MisraC2012Directive-4.1: */ +/* AXIVION Enable Style MisraC2012-1.2 MisraC2012Directive-4.1: */ /** * @def FSYS_SwitchToUserMode() diff --git a/src/app/main/include/general.h b/src/app/main/include/general.h index 23039180..4f248a01 100644 --- a/src/app/main/include/general.h +++ b/src/app/main/include/general.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file general.h * @author foxBMS Team * @date 2019-09-24 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL_CONF * @prefix NONE * @@ -55,29 +56,15 @@ #define FOXBMS__GENERAL_H_ /*========== Includes =======================================================*/ -#include "HL_sys_common.h" - #include "fassert.h" #include "fstd_types.h" +#include "mcu.h" #include #include /*========== Macros and Definitions =========================================*/ -/** - * @brief largest pin number that exists in TMS570LC4357 - * @details Checked in the data sheet spnu563a: The largest pin number that is - * used is 31. -*/ -#define LARGEST_PIN_NUMBER (31u) - -/** - * @brief maximum number of channels measured by the ADC1 - * @details Checked in the data sheet spnu563a: ADC1 supports 32 channels - */ -#define ADC_ADC1_MAX_NR_CHANNELS (32U) - /** * @brief sets a bit to 1u * @param[in,out] register register on which to set the bit @@ -112,13 +99,13 @@ /* assert that the basic datatypes in fstd_types.h are intact */ /* AXIVION Disable Style MisraC2012-10.4: These assertions have to check the actual values of the enums and defines. */ -static_assert(false == 0, "false seems to have been modified."); -static_assert(true != false, "true seems to have been modified."); -static_assert(true == 1, "true seems to have been modified."); +f_static_assert(false == 0, "false seems to have been modified."); +f_static_assert(true != false, "true seems to have been modified."); +f_static_assert(true == 1, "true seems to have been modified."); -static_assert(STD_OK == 0, "STD_OK seems to have been modified."); -static_assert(STD_OK != STD_NOT_OK, "STD_OK or STD_NOT_OK seem to have been modified."); -static_assert(STD_NOT_OK == 1, "STD_NOT_OK seems to have been modified."); +f_static_assert(STD_OK == 0, "STD_OK seems to have been modified."); +f_static_assert(STD_OK != STD_NOT_OK, "STD_OK or STD_NOT_OK seem to have been modified."); +f_static_assert(STD_NOT_OK == 1, "STD_NOT_OK seems to have been modified."); /* AXIVION Enable Style MisraC2012-10.4: */ /** @@ -274,6 +261,18 @@ static_assert(STD_NOT_OK == 1, "STD_NOT_OK seems to have been modified."); #define STRIP(x) STRIP_PARENS(GET_ARGS x) /* AXIVION Enable Style MisraC2012Directive-4.9 MisraC2012-20.7 Generic-NoUnsafeMacro: */ +/** Defines the word size in bytes of the platform */ +#if defined(__TI_COMPILER_VERSION__) && defined(__ARM_32BIT_STATE) && defined(__TMS470__) +#define BYTES_PER_WORD (4u) +#elif defined(UNITY_UNIT_TEST) +/* since this define only affects the task size, it can be safely set in unit + tests to the value that is used in the embedded platform */ +#define BYTES_PER_WORD (4u) +#else +#warning "Unspecified platform default to 4 bytes per word." +#define BYTES_PER_WORD (4u) +#endif + /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ diff --git a/src/app/main/include/main.h b/src/app/main/include/main.h index 19bf6c7c..382a5510 100644 --- a/src/app/main/include/main.h +++ b/src/app/main/include/main.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file main.h * @author foxBMS Team * @date 2018-10-23 (date of creation) - * @updated 2019-11-21 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL * @prefix TODO * diff --git a/src/app/main/linker_script_elf.cmd b/src/app/main/linker_script_elf.cmd index e70abbe0..735de23b 100644 --- a/src/app/main/linker_script_elf.cmd +++ b/src/app/main/linker_script_elf.cmd @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -39,68 +39,131 @@ * */ +/* docref: SPNU118Y - September 1995 - Revised February 2020, p. 133 + * never remove intvecs during linking */ --retain="*(.intvecs)" -/* length of VERSIONINFO (has to be large enough to accomodate the version struct) */ -#define LENGTH_VERSIONINFO 0xC0 -/* length of the VECTORS table */ -#define LENGTH_VECTORS 0x20 -/* length of KERNEL (accomodates the OS) */ -#define LENGTH_KERNEL 0x8000 -/* length of FLASH0 (flash section 1 of 2) */ -#define LENGHT_FLASH0 0x1F7FE0 - -/* global size of the FLASH memory in the MCU */ -#define GLOBAL_FLASH_SIZE 0x400000 - -/* The length of the stacks has to be exactly the same as DRIVER.SYSTEM.VAR.RAM_STACK_LENGTH.VALUE from HalCoGen! */ -#define LENGTH_STACKS 0x800 -/* length of the FreeRTOS RAM; TODO does this have to fit to another value? */ -#define LENGTH_KRAM 0x800 -/* length of sharedram section for dma */ -#define LENGTH_SHAREDRAM 0x1000 - -/* global size of the RAM hardware on this MCU */ -#define GLOBAL_RAM_SIZE 0x80000 -/* global start address of RAM hardware on this MCU */ -#define GLOBAL_RAM_START 0x8000000 +/*========== TMS570LC43xx Memory Map ========================================*/ +/* docref: SPNS195C - FEBRUARY 2014 - REVISED JUNE 2016 + * TMS570LC4357 Hercules™ Microcontroller Based on the ARM® Cortex®-R Core SPNS195C + * 6.9.1 Memory Map Diagram (Page 90) + * - Figure 6-9. Memory Map: Flash ECC, OTP and EEPROM accesses) from 0xF000 0000 to 0xF047 FFFF + * 6.9.2 Memory Map Table (Page 91) + * - Table 6-25. Module Registers / Memories Memory Map: + * Flash Data Space ECC start: 0xF040 0000 + * Flash Data Space ECC end: 0xF05F FFFF (but only usable till 0xF047 FFFF, see also memory map) + */ + +/* size of flash banks in TMS570LC43xx */ +#define FLASH_BANK_SIZE (0x200000) + +/* global size of the FLASH memory in the MCU (TMS570LC43xx has 2 flash banks) */ +#define GLOBAL_FLASH_SIZE (2 * FLASH_BANK_SIZE) + +#define FLASH_BANK0_START_ADDRESS (0x00000000) +#define FLASH_BANK0_END_ADDRESS (0x001FFFFF) +#define FLASH_BANK1_START_ADDRESS (0x00200000) +#define FLASH_BANK1_END_ADDRESS (0x003FFFFF) + +/* Data ECC area: 0xF0400000 to 0xF0480000 */ +#define ECC_DATA_START_ADDRESS (0xF0400000) + +/* start address of the vectors table in ARM (if not otherwise defined, i.e., during flashing) */ +#define VECTORS_TABLE_START_ADDRESS (0x00000000) + +/* size of RAM in TMS570LC43xx */ +#define GLOBAL_RAM_SIZE (0x80000) +/* global start address of RAM in TMS570LC43xx */ +#define GLOBAL_RAM_START_ADDRESS (0x08000000) + +/*========== Flash section configuration ====================================*/ + +#define VFILL_FLASH_PATTERN (0xffffffff) + +/* size of VERSION_INFORMATION (has to be large enough to accomodate the version struct) */ +#define VERSION_INFORMATION_SIZE (0xC0) + +/* size of the VECTORS table */ +#define VECTORS_TABLE_SIZE (0x20) + +/* size of KERNEL (accomodates the OS) */ +#define KERNEL_FUNCTIONS_SIZE (0x8000) + +/* remaining size of flash bank 0 as at the beginning of flash bank 0 the vector + * table and version information struct are placed */ +#define REMAINING_FLASH_BANK0_SIZE (FLASH_BANK_SIZE - VECTORS_TABLE_SIZE - KERNEL_FUNCTIONS_SIZE - VERSION_INFORMATION_SIZE) + +/* program usable flash size is "remaining flash bank0 size + complete flash bank 1 size" */ +#define FLASH_SIZE (REMAINING_FLASH_BANK0_SIZE + FLASH_BANK_SIZE) + +/*========== ECC Flash section configuration ================================*/ +/* sizes for ECC */ +#define ECC_VECTORS_TABLE_SIZE (VECTORS_TABLE_SIZE/8) +#define ECC_KERNEL_FUNCTIONS_SIZE (KERNEL_FUNCTIONS_SIZE/8) +#define ECC_FLASH_SIZE (FLASH_SIZE/8) +#define ECC_VERSION_INFORMATION_SIZE (VERSION_INFORMATION_SIZE/8) + +/*========== RAM section configuration ======================================*/ + +/* The size of the stacks has to be exactly the same as DRIVER.SYSTEM.VAR.RAM_STACK_LENGTH.VALUE from HalCoGen! */ +/* The stack consists of: + * - user stack + * - supervisor stack + * - FIQ stack (FIQ: fast interrupt) + * - IRQ stack (IRQ: normal interrupt) + * - Abort stack + * - Undefined stack + */ +#define STACKS_SIZE (0x800) + +/* size of the FreeRTOS RAM; TODO does this have to fit to another value? */ +#define KERNEL_DATA_SIZE (0x800) + +/* size of shared-RAM section for DMA */ +#define SHARED_RAM_SIZE (0x1000) + +/*========== Memory Layout ==================================================*/ MEMORY { - VECTORS (X) : origin=0x00000000 - length=LENGTH_VECTORS - vfill = 0xffffffff - KERNEL (RX) : origin=end(VECTORS) - length=LENGTH_KERNEL - vfill = 0xffffffff - FLASH0 (RX) : origin=end(KERNEL) - length=LENGHT_FLASH0 - vfill = 0xffffffff - FLASH1 (RX) : origin=end(FLASH0) - length=(GLOBAL_FLASH_SIZE - size(VECTORS) - size(KERNEL) - size(FLASH0) - LENGTH_VERSIONINFO) - vfill = 0xffffffff - VERSIONINFO (RX) : origin=end(FLASH1) - length=LENGTH_VERSIONINFO - vfill = 0xffffffff - STACKS (RW) : origin=GLOBAL_RAM_START - length=LENGTH_STACKS - KRAM (RW) : origin=end(STACKS) - length=LENGTH_KRAM - RAM (RW) : origin=end(KRAM) - length=(GLOBAL_RAM_SIZE - size(STACKS) - size(KRAM) - LENGTH_SHAREDRAM) - SHAREDRAM (RW) : origin=end(RAM) - length=LENGTH_SHAREDRAM - - ECC_VEC (R) : origin=0xf0400000 - length=0x4 ECC={ input_range=VECTORS } - ECC_KERN (R) : origin=0xf0400000 + 0x4 - length=0x1000 ECC={ input_range=KERNEL } - ECC_FLA0 (R) : origin=0xf0400000 + 0x4 + 0x1000 - length=0x3EFFC ECC={ input_range=FLASH0 } - ECC_FLA1 (R) : origin=0xf0400000 + 0x4 + 0x1000 + 0x3EFFC - length=0x40000 ECC={ input_range=FLASH1 } + /* FLASH */ + VECTORS_TABLE (X) : origin = VECTORS_TABLE_START_ADDRESS + length = VECTORS_TABLE_SIZE + vfill = VFILL_FLASH_PATTERN + KERNEL_FUNCTIONS (RX) : origin = end(VECTORS_TABLE) + length = KERNEL_FUNCTIONS_SIZE + vfill = VFILL_FLASH_PATTERN + FLASH (RX) : origin = end(KERNEL_FUNCTIONS) + length = FLASH_SIZE + vfill = VFILL_FLASH_PATTERN + VERSION_INFORMATION (RX) : origin = end(FLASH) + length = VERSION_INFORMATION_SIZE + vfill = VFILL_FLASH_PATTERN + /* RAM */ + STACKS (RW) : origin = GLOBAL_RAM_START_ADDRESS + length = STACKS_SIZE + KERNEL_DATA (RW) : origin = end(STACKS) + length = KERNEL_DATA_SIZE + RAM (RW) : origin = end(KERNEL_DATA) + length = (GLOBAL_RAM_SIZE - STACKS_SIZE - KERNEL_DATA_SIZE - SHARED_RAM_SIZE) + SHARED_RAM (RW) : origin = end(RAM) + length = SHARED_RAM_SIZE + + ECC_VECTORS_TABLE (R) : origin = ECC_DATA_START_ADDRESS + length = ECC_VECTORS_TABLE_SIZE + ECC = { input_range = VECTORS_TABLE } + ECC_KERNEL_FUNCTIONS (R) : origin = end(ECC_VECTORS_TABLE) + length = ECC_KERNEL_FUNCTIONS_SIZE + ECC = { input_range = KERNEL_FUNCTIONS } + ECC_FLASH (R) : origin = end(ECC_KERNEL_FUNCTIONS) + length = ECC_FLASH_SIZE + ECC = { input_range = FLASH } + ECC_VERSION_INFORMATION (R) : origin = end(ECC_FLASH) + length = ECC_VERSION_INFORMATION_SIZE + ECC = { input_range = VERSION_INFORMATION } } +/*========== ECC Algorithm Configuration ====================================*/ ECC { algo_name : address_mask = 0xfffffff8 @@ -109,22 +172,22 @@ ECC mirroring = F021 } +/*========== Section Layout =================================================*/ SECTIONS { - .intvecs : {} > VECTORS + .intvecs : {} > VECTORS_TABLE /* FreeRTOS Kernel in protected region of Flash */ - .kernelTEXT align(32) : {} > KERNEL - .cinit align(32) : {} > KERNEL + .kernelTEXT align(32) : {} > KERNEL_FUNCTIONS + .cinit align(32) : {} > KERNEL_FUNCTIONS /* Rest of code to user mode flash region */ - .versionInformation align(32) : {} > VERSIONINFO - .syscallTEXT align(32) : {} > FLASH0 | FLASH1 - .text align(32) : {} > FLASH0 | FLASH1 - .const align(32) : {} > FLASH0 | FLASH1 + .versionInformation align(32) : {} > VERSION_INFORMATION + .syscallTEXT align(32) : {} > FLASH + .text align(32) : {} > FLASH + .const align(32) : {} > FLASH /* FreeRTOS Kernel data in protected region of RAM */ - .kernelBSS : {} > KRAM - .bss : {} > RAM - .data : {} > RAM - .sysmem : {} > RAM - - .sharedRAM : {} > SHAREDRAM + .kernelBSS : {} > KERNEL_DATA + .bss : {} > RAM + .data : {} > RAM + .sysmem : {} > RAM + .sharedRAM : {} > SHARED_RAM } diff --git a/src/app/main/linker_script_hex.cmd b/src/app/main/linker_script_hex.cmd index 12f0a434..8cf7753f 100644 --- a/src/app/main/linker_script_hex.cmd +++ b/src/app/main/linker_script_hex.cmd @@ -1,18 +1,38 @@ -/* fdf552cfcdae551513b4abe184fe9e05 */ +/* 5bdaa91787743532b42ae61d62dcef3d */ + +/* Aligned with names in "MEMORY" in the elf-linker script */ ROMS { - VECTORS : origin=0x00000000 length=0x00000020 - KERNEL : origin=0x00000020 length=0x00008000 - FLASH0 : origin=0x00008020 length=0x001F7FE0 - FLASH1 : origin=0x00200000 length=0x001FFF40 - VERSIONINFO: origin=0x003FFF40 length=0x000000C0 - STACKS : origin=0x08000000 length=0x00000800 - KRAM : origin=0x08000800 length=0x00000800 - RAM : origin=0x08001000 length=0x0007E000 - SHAREDRAM : origin=0x0807F000 length=0x00001000 + /* FLASH */ + VECTORS_TABLE : origin = 0x00000000 + length = 0x20 + fill = 0xFFFFFFFF + KERNEL_FUNCTIONS : origin = 0x00000020 + length = 0x8000 + fill = 0xFFFFFFFF + FLASH : origin = 0x00008020 /*(0x00000000 + 0x20 + 0x8000)*/ + length = 0x3F7F20 + fill = 0xFFFFFFFF + VERSION_INFORMATION : origin = 0x003FFF40 /*(0x00000000 + 0x20 + 0x8000 + 0x3F7F20) */ + length = 0xC0 + fill = 0xFFFFFFFF + /* RAM */ + STACKS : origin = 0x08000000 + length = 0x800 + KERNEL_DATA : origin = 0x08000800 + length = 0x800 + RAM : origin = 0x08001000 + length = 0x7E000 + SHARED_RAM : origin = 0x0807F000 + length = 0x1000 + + ECC_VECTORS_TABLE : origin = 0xF0400000 + length = 0x4 + ECC_KERNEL_FUNCTIONS : origin = 0xF0400004 + length = 0x1000 + ECC_FLASH : origin = 0xF0401004 + length = 0x7EFE4 + ECC_VERSION_INFORMATION : origin = 0xF047FFE8 + length = 0x18 - ECC_VEC : origin=0xf0400000 length=0x4 - ECC_KERN : origin=0xf0400004 length=0x1000 - ECC_FLA0 : origin=0xf0401004 length=0x3EFFC - ECC_FLA1 : origin=0xf0440000 length=0x40000 } diff --git a/src/app/main/main.c b/src/app/main/main.c index b6fc1b03..ff946fca 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file main.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-11-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL * @prefix TODO * @@ -56,6 +57,7 @@ #include "main.h" #include "HL_can.h" +#include "HL_crc.h" #include "HL_etpwm.h" #include "HL_gio.h" #include "HL_het.h" @@ -72,6 +74,7 @@ #include "led.h" #include "masterinfo.h" #include "os.h" +#include "pwm.h" /*========== Macros and Definitions =========================================*/ @@ -94,9 +97,11 @@ int main(void) { adcInit(); hetInit(); etpwmInit(); - LED_SetDebugLED(); + crcInit(); + LED_SetDebugLed(); I2C_Initialize(); DMA_Initialize(); + PWM_Initialize(); DIAG_Initialize(&diag_device); MATH_StartupSelfTest(); const STD_RETURN_TYPE_e checkTimeHasPassedSelfTestReturnValue = OS_CheckTimeHasPassedSelfTest(); @@ -104,7 +109,7 @@ int main(void) { OS_InitializeOperatingSystem(); if (OS_INIT_PRE_OS != os_boot) { - while (1) { + while (true) { /* Could not create Queues, Mutexes, Events and Tasks do not boot further from this point on*/ } @@ -112,7 +117,7 @@ int main(void) { if (STD_OK != CHK_ValidateChecksum()) { if (DIAG_HANDLER_RETURN_OK != DIAG_Handler(DIAG_ID_FLASHCHECKSUM, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u)) { - while (1) { + while (true) { /* Could not validate checksum do not boot further from this point on */ } } @@ -121,8 +126,9 @@ int main(void) { os_schedulerStartTime = OS_GetTickCount(); OS_StartScheduler(); - while (1) { - } + /* we must never get here; there is no way to determine the exit state of this program, + * but for the sake of correctness we exit with an errorcode */ + return 1; } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/main/wscript b/src/app/main/wscript index 77a4da39..eb181a08 100644 --- a/src/app/main/wscript +++ b/src/app/main/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -70,8 +70,10 @@ def build(bld): os.path.join("..", "driver", "io"), os.path.join("..", "driver", "led"), os.path.join("..", "driver", "meas"), + os.path.join("..", "driver", "pwm"), os.path.join("..", "driver", "spi"), os.path.join("..", "driver", "sps"), + os.path.join("..", "driver", "mcu"), os.path.join("..", "engine", "config"), os.path.join("..", "engine", "database"), os.path.join("..", "engine", "diag"), diff --git a/src/app/task/config/ftask_cfg.c b/src/app/task/config/ftask_cfg.c index 29a1df50..4a8fd34d 100644 --- a/src/app/task/config/ftask_cfg.c +++ b/src/app/task/config/ftask_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ftask_cfg.c * @author foxBMS Team * @date 2019-08-26 (date of creation) - * @updated 2021-11-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TASK_CONFIGURATION * @prefix FTSK * @@ -103,35 +104,41 @@ * likely break the system. */ OS_TASK_DEFINITION_s ftsk_taskDefinitionEngine = { - OS_PRIORITY_REAL_TIME, + FTSK_TASK_ENGINE_PRIORITY, FTSK_TASK_ENGINE_PHASE, FTSK_TASK_ENGINE_CYCLE_TIME, - FTSK_TASK_ENGINE_STACK_SIZE, + FTSK_TASK_ENGINE_STACK_SIZE_IN_BYTES, FTSK_TASK_ENGINE_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic1ms = { - OS_PRIORITY_ABOVE_HIGH, + FTSK_TASK_CYCLIC_1MS_PRIORITY, FTSK_TASK_CYCLIC_1MS_PHASE, FTSK_TASK_CYCLIC_1MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_1MS_STACK_SIZE, + FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_1MS_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic10ms = { - OS_PRIORITY_HIGH, + FTSK_TASK_CYCLIC_10MS_PRIORITY, FTSK_TASK_CYCLIC_10MS_PHASE, FTSK_TASK_CYCLIC_10MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_10MS_STACK_SIZE, + FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_10MS_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic100ms = { - OS_PRIORITY_ABOVE_NORMAL, + FTSK_TASK_CYCLIC_100MS_PRIORITY, FTSK_TASK_CYCLIC_100MS_PHASE, FTSK_TASK_CYCLIC_100MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_100MS_STACK_SIZE, + FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_100MS_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclicAlgorithm100ms = { - OS_PRIORITY_NORMAL, + FTSK_TASK_CYCLIC_ALGORITHM_100MS_PRIORITY, FTSK_TASK_CYCLIC_ALGORITHM_100MS_PHASE, FTSK_TASK_CYCLIC_ALGORITHM_100MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACKSIZE, + FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_ALGORITHM_100MS_PV_PARAMETERS}; +OS_TASK_DEFINITION_s ftsk_taskDefinitionAfe = { + FTSK_TASK_AFE_PRIORITY, + FTSK_TASK_AFE_PHASE, + FTSK_TASK_AFE_CYCLE_TIME, + FTSK_TASK_AFE_STACK_SIZE_IN_BYTES, + FTSK_TASK_AFE_PV_PARAMETERS}; /*========== Static Function Prototypes =====================================*/ @@ -141,13 +148,19 @@ OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclicAlgorithm100ms = { extern void FTSK_InitializeUserCodeEngine(void) { /* Warning: Do not change the content of this function */ /* See function definition doxygen comment for details */ - STD_RETURN_TYPE_e retval = DATA_Init(); + STD_RETURN_TYPE_e retval = DATA_Initialize(); if (retval == E_NOT_OK) { /* Fatal error! */ FAS_ASSERT(FAS_TRAP); } + /* Suspend AFE task if unused, otherwise it will preempt all lower priority tasks */ + vTaskSuspend(ftsk_taskHandleAfe); + + /* Init FRAM */ + FRAM_Initialize(); + retval = SYSM_Init(); if (retval == E_NOT_OK) { @@ -173,10 +186,7 @@ extern void FTSK_InitializeUserCodePreCyclicTasks(void) { SYS_RETURN_TYPE_e sys_retVal = SYS_ILLEGAL_REQUEST; /* Init Sys */ - sys_retVal = SYS_SetStateRequest(SYS_STATE_INIT_REQUEST); - - /* Init FRAM */ - FRAM_Initialize(); + sys_retVal = SYS_SetStateRequest(SYS_STATE_INITIALIZATION_REQUEST); /* Init port expander */ PEX_Initialize(); @@ -216,6 +226,7 @@ extern void FTSK_RunUserCodeCyclic1ms(void) { extern void FTSK_RunUserCodeCyclic10ms(void) { static uint8_t ftsk_cyclic10msCounter = 0; /* user code */ + SYSM_UpdateFramData(); SYS_Trigger(&sys_state); BMS_Trigger(); ILCK_Trigger(); @@ -244,7 +255,7 @@ extern void FTSK_RunUserCodeCyclic100ms(void) { * requires a higher frequency. */ if (ftsk_cyclic100msCounter == TASK_100MS_COUNTER_FOR_1S) { - SE_StateEstimations(); + SE_RunStateEstimations(); ftsk_cyclic100msCounter = 0; } @@ -264,6 +275,10 @@ extern void FTSK_RunUserCodeCyclicAlgorithm100ms(void) { ftsk_cyclicAlgorithm100msCounter++; } +void FTSK_RunUserCodeAfe(void) { + /* user code */ +} + extern void FTSK_RunUserCodeIdle(void) { /* user code */ } diff --git a/src/app/task/config/ftask_cfg.h b/src/app/task/config/ftask_cfg.h index c12c3712..4af4b865 100644 --- a/src/app/task/config/ftask_cfg.h +++ b/src/app/task/config/ftask_cfg.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ftask_cfg.h * @author foxBMS Team * @date 2019-08-26 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TASK_CONFIGURATION * @prefix FTSK * @@ -61,7 +62,10 @@ /*========== Macros and Definitions =========================================*/ /** @brief Stack size of engine task */ -#define FTSK_TASK_ENGINE_STACK_SIZE (1024u / 4u) +#define FTSK_TASK_ENGINE_STACK_SIZE_IN_BYTES (1024u) + +/** @brief Phase of engine task */ +#define FTSK_TASK_ENGINE_PRIORITY (OS_PRIORITY_REAL_TIME) /** @brief Phase of engine task */ #define FTSK_TASK_ENGINE_PHASE (0u) @@ -76,7 +80,10 @@ #define FTSK_TASK_ENGINE_PV_PARAMETERS (NULL_PTR) /** @brief Stack size of cyclic 1 ms task */ -#define FTSK_TASK_CYCLIC_1MS_STACK_SIZE (1024u / 4u) +#define FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_BYTES (1024u) + +/** @brief Priority of cyclic 1ms task */ +#define FTSK_TASK_CYCLIC_1MS_PRIORITY (OS_PRIORITY_ABOVE_HIGH) /** @brief Phase of cyclic 1ms task */ #define FTSK_TASK_CYCLIC_1MS_PHASE (0u) @@ -91,7 +98,10 @@ #define FTSK_TASK_CYCLIC_1MS_PV_PARAMETERS (NULL_PTR) /** @brief Stack size of cyclic 10 ms task */ -#define FTSK_TASK_CYCLIC_10MS_STACK_SIZE ((5120u) / 4u) +#define FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_BYTES (5120u) + +/** @brief Priority of cyclic 10 ms task */ +#define FTSK_TASK_CYCLIC_10MS_PRIORITY (OS_PRIORITY_HIGH) /** @brief Phase of cyclic 10 ms task */ #define FTSK_TASK_CYCLIC_10MS_PHASE (2u) @@ -106,7 +116,10 @@ #define FTSK_TASK_CYCLIC_10MS_PV_PARAMETERS (NULL_PTR) /** @brief Stack size of cyclic 100 ms task */ -#define FTSK_TASK_CYCLIC_100MS_STACK_SIZE (1024u / 4u) +#define FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_BYTES (1024u) + +/** @brief Priority of cyclic 100 ms task */ +#define FTSK_TASK_CYCLIC_100MS_PRIORITY (OS_PRIORITY_ABOVE_NORMAL) /** @brief Phase of cyclic 100 ms task */ #define FTSK_TASK_CYCLIC_100MS_PHASE (56u) @@ -121,7 +134,10 @@ #define FTSK_TASK_CYCLIC_100MS_PV_PARAMETERS (NULL_PTR) /** @brief Stack size of cyclic 100 ms task for algorithms */ -#define FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACKSIZE (1024u / 4u) +#define FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_BYTES (1024u) + +/** @brief Priority of cyclic 100 ms task for algorithms */ +#define FTSK_TASK_CYCLIC_ALGORITHM_100MS_PRIORITY (OS_PRIORITY_NORMAL) /** @brief Phase of cyclic 100 ms task for algorithms */ #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_PHASE (64u) @@ -135,6 +151,24 @@ /** @brief pvParameters of the 100ms task for algorithms */ #define FTSK_TASK_CYCLIC_ALGORITHM_100MS_PV_PARAMETERS (NULL_PTR) +/** @brief Stack size of continuously running task for AFEs */ +#define FTSK_TASK_AFE_STACK_SIZE_IN_BYTES (2048u / 4u) + +/** @brief Priority of continuously running task for AFEs */ +#define FTSK_TASK_AFE_PRIORITY (OS_PRIORITY_ABOVE_HIGH) + +/** @brief Phase of continuously running task for AFEs */ +#define FTSK_TASK_AFE_PHASE (0u) + +/** @brief Cycle time of continuously running task for AFEs */ +#define FTSK_TASK_AFE_CYCLE_TIME (0u) + +/** @brief Maximum allowed jitter of continuously running task for AFEs */ +#define FTSK_TASK_AFE_MAXIMUM_JITTER (5u) + +/** @brief pvParameters of the continuously running task for AFEs */ +#define FTSK_TASK_AFE_PV_PARAMETERS (NULL_PTR) + /*========== Extern Constant and Variable Declarations ======================*/ /** * @brief Task configuration of the engine task @@ -171,6 +205,19 @@ extern OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic100ms; */ extern OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclicAlgorithm100ms; +/** + * @brief Task configuration of the continuously running task for AFEs + * @details Continuously running task for AFEs + * @ingroup API_OS + */ +extern OS_TASK_DEFINITION_s ftsk_taskDefinitionAfe; + +/** + * @brief Definition of task handles + * @ingroup API_OS + */ +extern TaskHandle_t ftsk_taskHandleAfe; + /*========== Extern Function Prototypes =====================================*/ /** * @brief Initializes the database @@ -230,6 +277,14 @@ extern void FTSK_RunUserCodeCyclic100ms(void); */ extern void FTSK_RunUserCodeCyclicAlgorithm100ms(void); +/** + * @brief Continuously running task for AFEs + * @details Used to implement the communications with AFEs, + * for drivers that do not use a cyclic task. + * @ingroup API_OS + */ +extern void FTSK_RunUserCodeAfe(void); + /** * @brief Idle task * @details Called by #vApplicationIdleHook() if configUSE_IDLE_HOOK in diff --git a/src/app/task/ftask/freertos/ftask_freertos.c b/src/app/task/ftask/freertos/ftask_freertos.c index a2ee3123..79205455 100644 --- a/src/app/task/ftask/freertos/ftask_freertos.c +++ b/src/app/task/ftask/freertos/ftask_freertos.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ftask_freertos.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TASK * @prefix FTSK * @@ -61,10 +62,36 @@ #include "ftask.h" /*========== Macros and Definitions =========================================*/ +/** helper macro to translate the stack sizes from bytes into words as FreeRTOS requires words and not bytes */ +#define FTSK_BYTES_TO_WORDS(VARIABALE_IN_BYTES) ((VARIABALE_IN_BYTES) / BYTES_PER_WORD) +/** Stack size of engine task in words */ +#define FTSK_TASK_ENGINE_STACK_SIZE_IN_WORDS FTSK_BYTES_TO_WORDS(FTSK_TASK_ENGINE_STACK_SIZE_IN_BYTES) +/** @brief Stack size of cyclic 1 ms task in words */ +#define FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_WORDS FTSK_BYTES_TO_WORDS(FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_BYTES) +/** @brief Stack size of cyclic 10 ms task in words */ +#define FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_WORDS FTSK_BYTES_TO_WORDS(FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_BYTES) +/** @brief Stack size of cyclic 100 ms task in words */ +#define FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_WORDS FTSK_BYTES_TO_WORDS(FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_BYTES) +/** @brief Stack size of cyclic 100 ms task for algorithms in words */ +#define FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_WORDS \ + FTSK_BYTES_TO_WORDS(FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_BYTES) +/** @brief Stack size of continuously running task for AFEs */ +#define FTSK_TASK_AFE_STACK_SIZE_IN_WORDS FTSK_BYTES_TO_WORDS(FTSK_TASK_AFE_STACK_SIZE_IN_BYTES) + +/** size of storage area for the database queue */ +#define FTSK_DATABASE_QUEUE_STORAGE_AREA (FTSK_DATABASE_QUEUE_LENGTH * FTSK_DATABASE_QUEUE_ITEM_SIZE_IN_BYTES) + +/** size of storage area for the IMD queue*/ +#define FTSK_IMD_QUEUE_STORAGE_AREA (FTSK_IMD_QUEUE_LENGTH * FTSK_IMD_QUEUE_ITEM_SIZE_IN_BYTES) + +/** size of storage area for the CAN Rx queue*/ +#define FTSK_CAN_RX_QUEUE_STORAGE_AREA (FTSK_CAN_RX_QUEUE_LENGTH * FTSK_CAN_RX_QUEUE_ITEM_SIZE_IN_BYTES) /*========== Static Constant and Variable Definitions =======================*/ /*========== Extern Constant and Variable Definitions =======================*/ +TaskHandle_t ftsk_taskHandleAfe; + volatile bool ftsk_allQueuesCreated = false; QueueHandle_t ftsk_databaseQueue = NULL_PTR; @@ -82,52 +109,40 @@ QueueHandle_t ftsk_canRxQueue = NULL_PTR; /*========== Extern Function Implementations ================================*/ extern void FTSK_CreateQueues(void) { - /** - * @brief size of storage area for the database queue - * @details The array that is used for the queue's storage area. - * This must be at least - * #FTSK_DATABASE_QUEUE_LENGTH * #FTSK_DATABASE_QUEUE_ITEM_SIZE - */ - static uint8_t ftsk_databaseQueueStorageArea[FTSK_DATABASE_QUEUE_LENGTH * FTSK_DATABASE_QUEUE_ITEM_SIZE] = {0}; - static StaticQueue_t ftsk_databaseQueueStructure = {0}; /*!< structure for static database queue */ + /* structure and array for static database queue */ + static uint8_t ftsk_databaseQueueStorageArea[FTSK_DATABASE_QUEUE_STORAGE_AREA] = {0}; + static StaticQueue_t ftsk_databaseQueueStructure = {0}; /* Create a queue capable of containing a pointer of type DATA_QUEUE_MESSAGE_s Data of Messages are passed by pointer as they contain a lot of data. */ ftsk_databaseQueue = xQueueCreateStatic( FTSK_DATABASE_QUEUE_LENGTH, - FTSK_DATABASE_QUEUE_ITEM_SIZE, + FTSK_DATABASE_QUEUE_ITEM_SIZE_IN_BYTES, ftsk_databaseQueueStorageArea, &ftsk_databaseQueueStructure); FAS_ASSERT(ftsk_databaseQueue != NULL); vQueueAddToRegistry(ftsk_databaseQueue, "Database Queue"); - /** - * @brief size of storage area for the IMD queue - * @details The array that is used for the queue's storage area. - * This must be at least - * #FTSK_IMD_QUEUE_LENGTH * #FTSK_IMD_QUEUE_ITEM_SIZE - */ - static uint8_t ftsk_imdQueueStorageArea[FTSK_IMD_QUEUE_LENGTH * FTSK_IMD_QUEUE_ITEM_SIZE] = {0}; - static StaticQueue_t ftsk_imdQueueStructure = {0}; /*!< structure for static data queue */ + /* structure and array for static IMD queue */ + static uint8_t ftsk_imdQueueStorageArea[FTSK_IMD_QUEUE_STORAGE_AREA] = {0}; + static StaticQueue_t ftsk_imdQueueStructure = {0}; ftsk_imdCanDataQueue = xQueueCreateStatic( - FTSK_IMD_QUEUE_LENGTH, FTSK_IMD_QUEUE_ITEM_SIZE, ftsk_imdQueueStorageArea, &ftsk_imdQueueStructure); + FTSK_IMD_QUEUE_LENGTH, FTSK_IMD_QUEUE_ITEM_SIZE_IN_BYTES, ftsk_imdQueueStorageArea, &ftsk_imdQueueStructure); vQueueAddToRegistry(ftsk_imdCanDataQueue, "IMD CAN Data Queue"); FAS_ASSERT(ftsk_imdCanDataQueue != NULL); /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE can-documentation-rx-queue-vars-start-include */ - static StaticQueue_t ftsk_canRxQueueStructure = {0}; /*!< structure for static data queue */ - /** - * @brief size of storage area for the CAN Rx queue - * @details The array that is used for the queue's storage area. - * This must be at least - * #FTSK_CAN_RX_QUEUE_LENGTH * #FTSK_CAN_RX_QUEUE_ITEM_SIZE - */ - static uint8_t ftsk_canRxQueueStorageArea[FTSK_CAN_RX_QUEUE_LENGTH * FTSK_CAN_RX_QUEUE_ITEM_SIZE] = {0}; + /* structure and array for static CAN RX queue */ + static uint8_t ftsk_canRxQueueStorageArea[FTSK_CAN_RX_QUEUE_STORAGE_AREA] = {0}; + static StaticQueue_t ftsk_canRxQueueStructure = {0}; /* INCLUDE MARKER FOR THE DOCUMENTATION; DO NOT MOVE can-documentation-rx-queue-vars-stop-include */ ftsk_canRxQueue = xQueueCreateStatic( - FTSK_CAN_RX_QUEUE_LENGTH, FTSK_CAN_RX_QUEUE_ITEM_SIZE, ftsk_canRxQueueStorageArea, &ftsk_canRxQueueStructure); + FTSK_CAN_RX_QUEUE_LENGTH, + FTSK_CAN_RX_QUEUE_ITEM_SIZE_IN_BYTES, + ftsk_canRxQueueStorageArea, + &ftsk_canRxQueueStructure); vQueueAddToRegistry(ftsk_canRxQueue, "CAN Receive Queue"); FAS_ASSERT(ftsk_canRxQueue != NULL); @@ -138,74 +153,88 @@ extern void FTSK_CreateQueues(void) { extern void FTSK_CreateTasks(void) { /* Engine Task */ - static StaticTask_t ftsk_taskEngine = {0}; - static StackType_t ftsk_stackSizeEngine[FTSK_TASK_ENGINE_STACK_SIZE] = {0}; + static StaticTask_t ftsk_taskEngine = {0}; + static StackType_t ftsk_stackEngine[FTSK_TASK_ENGINE_STACK_SIZE_IN_WORDS] = {0}; const TaskHandle_t ftsk_taskHandleEngine = xTaskCreateStatic( (TaskFunction_t)FTSK_CreateTaskEngine, (const portCHAR *)"TaskEngine", - ftsk_taskDefinitionEngine.stackSize, + FTSK_BYTES_TO_WORDS(ftsk_taskDefinitionEngine.stackSize_B), (void *)ftsk_taskDefinitionEngine.pvParameters, (UBaseType_t)ftsk_taskDefinitionEngine.priority, - ftsk_stackSizeEngine, + ftsk_stackEngine, &ftsk_taskEngine); FAS_ASSERT(ftsk_taskHandleEngine != NULL); /* Trap if initialization failed */ /* Cyclic Task 1ms */ - static StaticTask_t ftsk_taskCyclic1ms = {0}; - static StackType_t ftsk_stackSizeCyclic1ms[FTSK_TASK_CYCLIC_1MS_STACK_SIZE] = {0}; + static StaticTask_t ftsk_taskCyclic1ms = {0}; + static StackType_t ftsk_stackCyclic1ms[FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_WORDS] = {0}; const TaskHandle_t ftsk_taskHandleCyclic1ms = xTaskCreateStatic( (TaskFunction_t)FTSK_CreateTaskCyclic1ms, (const portCHAR *)"TaskCyclic1ms", - ftsk_taskDefinitionCyclic1ms.stackSize, + FTSK_BYTES_TO_WORDS(ftsk_taskDefinitionCyclic1ms.stackSize_B), (void *)ftsk_taskDefinitionCyclic1ms.pvParameters, (UBaseType_t)ftsk_taskDefinitionCyclic1ms.priority, - ftsk_stackSizeCyclic1ms, + ftsk_stackCyclic1ms, &ftsk_taskCyclic1ms); FAS_ASSERT(ftsk_taskHandleCyclic1ms != NULL); /* Trap if initialization failed */ /* Cyclic Task 10ms */ - static StaticTask_t ftsk_taskCyclic10ms = {0}; - static StackType_t ftsk_stackSizeCyclic10ms[FTSK_TASK_CYCLIC_10MS_STACK_SIZE] = {0}; + static StaticTask_t ftsk_taskCyclic10ms = {0}; + static StackType_t ftsk_stackCyclic10ms[FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_WORDS] = {0}; const TaskHandle_t ftsk_taskHandleCyclic10ms = xTaskCreateStatic( (TaskFunction_t)FTSK_CreateTaskCyclic10ms, (const portCHAR *)"TaskCyclic10ms", - ftsk_taskDefinitionCyclic10ms.stackSize, + FTSK_BYTES_TO_WORDS(ftsk_taskDefinitionCyclic10ms.stackSize_B), (void *)ftsk_taskDefinitionCyclic10ms.pvParameters, (UBaseType_t)ftsk_taskDefinitionCyclic10ms.priority, - ftsk_stackSizeCyclic10ms, + ftsk_stackCyclic10ms, &ftsk_taskCyclic10ms); FAS_ASSERT(ftsk_taskHandleCyclic10ms != NULL); /* Trap if initialization failed */ /* Cyclic Task 100ms */ - static StaticTask_t ftsk_taskCyclic100ms = {0}; - static StackType_t ftsk_stackSizeCyclic100ms[FTSK_TASK_CYCLIC_100MS_STACK_SIZE] = {0}; + static StaticTask_t ftsk_taskCyclic100ms = {0}; + static StackType_t ftsk_stackCyclic100ms[FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_WORDS] = {0}; const TaskHandle_t ftsk_taskHandleCyclic100ms = xTaskCreateStatic( (TaskFunction_t)FTSK_CreateTaskCyclic100ms, (const portCHAR *)"TaskCyclic100ms", - ftsk_taskDefinitionCyclic100ms.stackSize, + FTSK_BYTES_TO_WORDS(ftsk_taskDefinitionCyclic100ms.stackSize_B), (void *)ftsk_taskDefinitionCyclic100ms.pvParameters, (UBaseType_t)ftsk_taskDefinitionCyclic100ms.priority, - ftsk_stackSizeCyclic100ms, + ftsk_stackCyclic100ms, &ftsk_taskCyclic100ms); FAS_ASSERT(ftsk_taskHandleCyclic100ms != NULL); /* Trap if initialization failed */ /* Cyclic Task 100ms for algorithms */ - static StaticTask_t ftsk_taskCyclicAlgorithm100ms = {0}; - static StackType_t ftsk_stackSizeCyclicAlgorithm100ms[FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACKSIZE] = {0}; + static StaticTask_t ftsk_taskCyclicAlgorithm100ms = {0}; + static StackType_t ftsk_stackCyclicAlgorithm100ms[FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_WORDS] = {0}; const TaskHandle_t ftsk_taskHandleCyclicAlgorithm100ms = xTaskCreateStatic( (TaskFunction_t)FTSK_CreateTaskCyclicAlgorithm100ms, (const portCHAR *)"TaskCyclicAlgorithm100ms", - ftsk_taskDefinitionCyclicAlgorithm100ms.stackSize, + FTSK_BYTES_TO_WORDS(ftsk_taskDefinitionCyclicAlgorithm100ms.stackSize_B), (void *)ftsk_taskDefinitionCyclicAlgorithm100ms.pvParameters, (UBaseType_t)ftsk_taskDefinitionCyclicAlgorithm100ms.priority, - ftsk_stackSizeCyclicAlgorithm100ms, + ftsk_stackCyclicAlgorithm100ms, &ftsk_taskCyclicAlgorithm100ms); FAS_ASSERT(ftsk_taskHandleCyclicAlgorithm100ms != NULL); /* Trap if initialization failed */ + + /* Continuously running Task for AFE */ + static StaticTask_t ftsk_taskAfe = {0}; + static StackType_t ftsk_stackSizeAfe[FTSK_TASK_AFE_STACK_SIZE_IN_WORDS] = {0}; + + ftsk_taskHandleAfe = xTaskCreateStatic( + (TaskFunction_t)FTSK_CreateTaskAfe, + (const portCHAR *)"TaskAfe", + FTSK_BYTES_TO_WORDS(ftsk_taskDefinitionAfe.stackSize_B), + (void *)ftsk_taskDefinitionAfe.pvParameters, + (UBaseType_t)ftsk_taskDefinitionAfe.priority, + ftsk_stackSizeAfe, + &ftsk_taskAfe); + FAS_ASSERT(ftsk_taskHandleAfe != NULL); /* Trap if initialization failed */ } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/task/ftask/ftask.c b/src/app/task/ftask/ftask.c index dbc45e1a..b5218de3 100644 --- a/src/app/task/ftask/ftask.c +++ b/src/app/task/ftask/ftask.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ftask.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TASK * @prefix FTSK * @@ -203,4 +204,22 @@ extern void FTSK_CreateTaskCyclicAlgorithm100ms(void *const pvParameters) { } } +/* AXIVION Next Line Style MisraC2012Directive-1.1 MisraC2012-1.2 FaultDetection-DeadBranches: tell the CCS compiler + * tell compiler this function is a task, context save not necessary */ +#pragma TASK(FTSK_CreateTaskAfe) +extern void FTSK_CreateTaskAfe(void *const pvParameters) { + FAS_ASSERT(pvParameters == NULL_PTR); + OS_MarkTaskAsRequiringFpuContext(); + + while (os_boot != OS_PRECYCLIC_INIT_HAS_FINISHED) { + } + + /* AXIVION Next Line Style MisraC2012-2.2 FaultDetection-DeadBranches: FreeRTOS task setup requires an infinite + * loop for the user code (see www.freertos.org/a00125.html)*/ + while (true) { + /* user code implementation */ + FTSK_RunUserCodeAfe(); + } +} + /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/task/ftask/ftask.h b/src/app/task/ftask/ftask.h index a3f3d186..4ef0fcce 100644 --- a/src/app/task/ftask/ftask.h +++ b/src/app/task/ftask/ftask.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file ftask.h * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup TASK * @prefix FTSK * @@ -65,17 +66,17 @@ #define FTSK_DATABASE_QUEUE_LENGTH (1u) /** Size of queue item that is used in the database */ -#define FTSK_DATABASE_QUEUE_ITEM_SIZE (sizeof(DATA_QUEUE_MESSAGE_s)) +#define FTSK_DATABASE_QUEUE_ITEM_SIZE_IN_BYTES (sizeof(DATA_QUEUE_MESSAGE_s)) /** Length of queue that is used in the insulation measurement device (IMD) */ #define FTSK_IMD_QUEUE_LENGTH (5u) /** Size of queue item that is used in the IMD driver */ -#define FTSK_IMD_QUEUE_ITEM_SIZE (sizeof(CAN_BUFFERELEMENT_s)) +#define FTSK_IMD_QUEUE_ITEM_SIZE_IN_BYTES (sizeof(CAN_BUFFERELEMENT_s)) /** Length of queue that is used in the can module for receiving messages */ #define FTSK_CAN_RX_QUEUE_LENGTH (50u) /** Size of queue item that is used in the can driver */ -#define FTSK_CAN_RX_QUEUE_ITEM_SIZE (sizeof(CAN_BUFFERELEMENT_s)) +#define FTSK_CAN_RX_QUEUE_ITEM_SIZE_IN_BYTES (sizeof(CAN_BUFFERELEMENT_s)) /*========== Extern Constant and Variable Declarations ======================*/ /** handle of the database queue */ @@ -161,6 +162,11 @@ extern void FTSK_CreateTaskCyclic100ms(void *const pvParameters); */ extern void FTSK_CreateTaskCyclicAlgorithm100ms(void *const pvParameters); +/** + * @brief Creation of continuously running task for AFEs + */ +extern void FTSK_CreateTaskAfe(void *const pvParameters); + /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #endif /* FOXBMS__FTASK_H_ */ diff --git a/src/app/task/os/freertos/os_freertos.c b/src/app/task/os/freertos/os_freertos.c index 2fa2aa20..ffa4840e 100644 --- a/src/app/task/os/freertos/os_freertos.c +++ b/src/app/task/os/freertos/os_freertos.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file os_freertos.c * @author foxBMS Team * @date 2021-11-18 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup OS * @prefix OS * @@ -54,6 +55,8 @@ /*========== Includes =======================================================*/ #include "os.h" +#include "HL_sys_core.h" + #include "ftask.h" /*========== Macros and Definitions =========================================*/ @@ -67,9 +70,16 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ +extern void OS_InitializeScheduler(void) { + if (OS_ENABLE_CACHE == true) { + _cacheEnable_(); + } +} void OS_StartScheduler(void) { vTaskStartScheduler(); + /* This function should never return */ + FAS_ASSERT(FAS_TRAP); } void vApplicationGetIdleTaskMemory( @@ -131,29 +141,13 @@ uint32_t OS_GetTickCount(void) { } void OS_DelayTaskUntil(uint32_t *pPreviousWakeTime, uint32_t milliseconds) { -#if INCLUDE_vTaskDelayUntil FAS_ASSERT(pPreviousWakeTime != NULL_PTR); FAS_ASSERT(milliseconds > 0u); - TickType_t ticks = ((TickType_t)milliseconds / portTICK_PERIOD_MS); + uint32_t ticks = (milliseconds / OS_TICK_RATE_MS); if ((uint32_t)ticks < 1u) { ticks = 1u; /* Minimum delay is 1 tick */ } - vTaskDelayUntil((TickType_t *)pPreviousWakeTime, ticks); - -#else -#error "Can't use OS_taskDelayUntil." -#endif -} - -void OS_SystemTickHandler(void) { -#if (INCLUDE_xTaskGetSchedulerState == 1) - /* Only increment operating systick timer if scheduler started */ - if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { - xTaskIncrementTick(); - } -#else - xTaskIncrementTick(); -#endif /* INCLUDE_xTaskGetSchedulerState */ + vTaskDelayUntil((TickType_t *)pPreviousWakeTime, (TickType_t)ticks); } extern void OS_MarkTaskAsRequiringFpuContext(void) { @@ -163,26 +157,26 @@ extern void OS_MarkTaskAsRequiringFpuContext(void) { extern OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer, uint32_t ticksToWait) { FAS_ASSERT(pvBuffer != NULL_PTR); - OS_STD_RETURN_e queueReceiveSucessfull = OS_FAIL; + OS_STD_RETURN_e queueReceiveSuccessfully = OS_FAIL; /* FreeRTOS: This function must not be used in an interrupt service routine. */ BaseType_t xQueueReceiveSuccess = xQueueReceive(xQueue, pvBuffer, (TickType_t)ticksToWait); /* FreeRTOS:xQueueReceive returns pdTRUE if an item was successfully received from the queue (otherwise pdFALSE). */ if (xQueueReceiveSuccess == pdTRUE) { - queueReceiveSucessfull = OS_SUCCESS; + queueReceiveSuccessfully = OS_SUCCESS; } - return queueReceiveSucessfull; + return queueReceiveSuccessfully; } -extern OS_STD_RETURN_e OS_SendToBackOfQueue(OS_QUEUE xQueue, const void *const pvItemToQueue, TickType_t ticksToWait) { +extern OS_STD_RETURN_e OS_SendToBackOfQueue(OS_QUEUE xQueue, const void *const pvItemToQueue, uint32_t ticksToWait) { FAS_ASSERT(pvItemToQueue != NULL_PTR); - OS_STD_RETURN_e queueSendSucessfull = OS_FAIL; - BaseType_t xQueueSendSuccess = xQueueSendToBack(xQueue, pvItemToQueue, ticksToWait); + OS_STD_RETURN_e queueSendSuccessfully = OS_FAIL; + BaseType_t xQueueSendSuccess = xQueueSendToBack(xQueue, pvItemToQueue, (TickType_t)ticksToWait); /* FreeRTOS:xQueueSendToBack returns pdTRUE if the item was successfully posted (otherwise errQUEUE_FULL). */ if (xQueueSendSuccess == pdTRUE) { - queueSendSucessfull = OS_SUCCESS; + queueSendSuccessfully = OS_SUCCESS; } - return queueSendSucessfull; + return queueSendSuccessfully; } extern OS_STD_RETURN_e OS_SendToBackOfQueueFromIsr( @@ -191,14 +185,19 @@ extern OS_STD_RETURN_e OS_SendToBackOfQueueFromIsr( long *const pxHigherPriorityTaskWoken) { FAS_ASSERT(pvItemToQueue != NULL_PTR); - OS_STD_RETURN_e queueSendSucessfull = OS_FAIL; + OS_STD_RETURN_e queueSendSuccessfully = OS_FAIL; BaseType_t xQueueSendSuccess = xQueueSendToBackFromISR(xQueue, pvItemToQueue, (BaseType_t *)pxHigherPriorityTaskWoken); /* FreeRTOS:xQueueSendToBackFromISR returns pdTRUE if the item was successfully posted (otherwise errQUEUE_FULL). */ if (xQueueSendSuccess == pdTRUE) { - queueSendSucessfull = OS_SUCCESS; + queueSendSuccessfully = OS_SUCCESS; } - return queueSendSucessfull; + return queueSendSuccessfully; +} + +extern uint32_t OS_GetNumberOfStoredMessagesInQueue(OS_QUEUE xQueue) { + long numberOfMessages = uxQueueMessagesWaiting(xQueue); + return (uint32_t)numberOfMessages; } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/task/os/freertos/os_freertos_config-validation.h b/src/app/task/os/freertos/os_freertos_config-validation.h new file mode 100644 index 00000000..ee4602ff --- /dev/null +++ b/src/app/task/os/freertos/os_freertos_config-validation.h @@ -0,0 +1,102 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file os_freertos_config-validation.h + * @author foxBMS Team + * @date 2019-08-27 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup OS + * @prefix OS + * + * @brief Declaration of the OS wrapper interface + * @details This module describes the interface to different operating systems + */ + +#ifndef FOXBMS__OS_FREERTOS_CONFIG_VALIDATION_H_ +#define FOXBMS__OS_FREERTOS_CONFIG_VALIDATION_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +#include "ftask_cfg.h" + +#include "FreeRTOSConfig.h" + +/*========== Macros and Definitions =========================================*/ + +#if !defined(INCLUDE_vTaskDelayUntil) +#error \ + "foxBMS requires using FreeRTOS 'vTaskDelayUntil' (wrapped in 'OS_taskDelayUntil'), therefore 'INCLUDE_vTaskDelayUntil' must be defined to '1'." +#endif /* INCLUDE_vTaskDelayUntil */ + +#if !defined(INCLUDE_xTaskGetSchedulerState) +#error \ + "foxBMS requires using FreeRTOS 'xTaskGetSchedulerState' therefore 'INCLUDE_xTaskGetSchedulerState' must be defined to '1'." +#endif /* INCLUDE_xTaskGetSchedulerState */ + +f_static_assert( + (configMINIMAL_STACK_SIZE * BYTES_PER_WORD) < (StackType_t)FTSK_TASK_ENGINE_STACK_SIZE_IN_BYTES, + "Size of the 'Engine' task is too small."); +f_static_assert( + (configMINIMAL_STACK_SIZE * BYTES_PER_WORD) < (StackType_t)FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_BYTES, + "Size of the '1ms cyclic' task is too small."); +f_static_assert( + (configMINIMAL_STACK_SIZE * BYTES_PER_WORD) < (StackType_t)FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_BYTES, + "Size of the '10ms cyclic' task is too small."); +f_static_assert( + (configMINIMAL_STACK_SIZE * BYTES_PER_WORD) < (StackType_t)FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_BYTES, + "Size of the '100ms cyclic' task is too small."); +f_static_assert( + (configMINIMAL_STACK_SIZE * BYTES_PER_WORD) < (StackType_t)FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_BYTES, + "Size of the '100ms cyclic algorithm' task is too small."); +f_static_assert((sizeof(StackType_t) == sizeof(uint32_t)), "Assumptions on the size of StackType_t have been broken."); + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ +#ifdef UNITY_UNIT_TEST +#endif /* UNITY_UNIT_TEST */ + +#endif /* FOXBMS__OS_FREERTOS_CONFIG_VALIDATION_H_ */ diff --git a/src/app/task/os/os.c b/src/app/task/os/os.c index e7a4ecc7..bd4f5c12 100644 --- a/src/app/task/os/os.c +++ b/src/app/task/os/os.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file os.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup OS * @prefix OS * @@ -76,6 +77,9 @@ uint32_t os_schedulerStartTime = 0u; /*========== Extern Function Implementations ================================*/ void OS_InitializeOperatingSystem(void) { + /* Initialize the scheduler */ + os_boot = OS_INITIALIZE_SCHEDULER; + OS_InitializeScheduler(); /* operating system configuration (Queues, Tasks) */ os_boot = OS_CREATE_QUEUES; FTSK_CreateQueues(); diff --git a/src/app/task/os/os.h b/src/app/task/os/os.h index fbdbfe96..27a41cd7 100644 --- a/src/app/task/os/os.h +++ b/src/app/task/os/os.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file os.h * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup OS * @prefix OS * @@ -60,29 +61,29 @@ #if defined(FOXBMS_USES_FREERTOS) #include "FreeRTOS.h" #include "queue.h" -#define OS_QUEUE QueueHandle_t +#define OS_QUEUE QueueHandle_t +#define OS_IDLE_TASK_STACK_SIZE (configMINIMAL_STACK_SIZE) /**< stack size of the idle task */ +#define OS_TICK_RATE_MS (portTICK_RATE_MS) /**< FreeRTOS name of the tick rate */ +#define OS_ENABLE_CACHE (false) /**< true: Enable cache, false: Disable cache */ #endif /*========== Macros and Definitions =========================================*/ -/** stack size of the idle task */ -#define OS_IDLE_TASK_STACK_SIZE configMINIMAL_STACK_SIZE - #if (configUSE_TIMERS > 0) && (configSUPPORT_STATIC_ALLOCATION == 1) #define OS_TIMER_TASK_STACK_SIZE configTIMER_TASK_STACK_DEPTH #endif /* configUSE_TIMERS */ /** enum to encapsulate function returns from the OS-wrapper layer */ -typedef enum OS_STD_RETURN { - OS_SUCCESS, /**< OS-dependent operation successfull */ - OS_FAIL, /**< OS-dependent operation unsuccessfull */ +typedef enum { + OS_SUCCESS, /**< OS-dependent operation successful */ + OS_FAIL, /**< OS-dependent operation unsuccessful */ } OS_STD_RETURN_e; /** * @brief typedef for thread priority. The higher the value, the higher the * priority. */ -typedef enum OS_PRIORITY { +typedef enum { OS_PRIORITY_IDLE, /**< priority: idle (lowest) */ OS_PRIORITY_LOW, /**< priority: low */ OS_PRIORITY_BELOW_NORMAL, /**< priority: below normal */ @@ -96,8 +97,9 @@ typedef enum OS_PRIORITY { } OS_PRIORITY_e; /** @brief enum of OS boot states */ -typedef enum OS_BOOT_STATE { +typedef enum { OS_OFF, /**< system is off */ + OS_INITIALIZE_SCHEDULER, /**< state right before initalizing the scheduler */ OS_CREATE_QUEUES, /**< state right before queues are created */ OS_CREATE_TASKS, /**< state right before tasks are created */ OS_INIT_PRE_OS, /**< state right after tasks are created */ @@ -111,7 +113,7 @@ typedef enum OS_BOOT_STATE { } OS_BOOT_STATE_e; /** @brief OS timer */ -typedef struct OS_TIMER { +typedef struct { uint8_t timer_1ms; /**< milliseconds */ uint8_t timer_10ms; /**< 10 milliseconds */ uint8_t timer_100ms; /**< 100 milliseconds */ @@ -122,11 +124,11 @@ typedef struct OS_TIMER { } OS_TIMER_s; /** @brief struct for FreeRTOS task definition */ -typedef struct OS_TASK_DEFINITION { +typedef struct { OS_PRIORITY_e priority; /*!< priority of the task */ uint32_t phase; /*!< shift in ms of the first start of the task */ uint32_t cycleTime; /*!< time in ms that will be waited between each task cycle */ - uint16_t stackSize; /*!< Defines the size, in words, of the stack allocated to the task */ + uint32_t stackSize_B; /*!< Defines the size, in bytes, of the stack allocated to the task */ void *pvParameters; /*!< value that is passed as the parameter to the task. */ } OS_TASK_DEFINITION_s; @@ -139,6 +141,11 @@ extern uint32_t os_schedulerStartTime; /*========== Extern Function Prototypes =====================================*/ +/** + * @brief Initialization function for the scheduler + */ +extern void OS_InitializeScheduler(void); + /** * @brief Starts the operating system scheduler */ @@ -146,7 +153,8 @@ extern void OS_StartScheduler(void); /** * @brief Initialization the RTOS interface - * @details This function initializes the mutexes, eventgroups and tasks. + * @details This function initializes the scheduler and then creates queues and + * tasks. */ extern void OS_InitializeOperatingSystem(void); @@ -265,15 +273,13 @@ extern OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer * @param ticksToWait ticks to wait * @return #OS_SUCCESS if the item was successfully posted, otherwise #OS_FAIL. */ -extern OS_STD_RETURN_e OS_SendToBackOfQueue(OS_QUEUE xQueue, const void *const pvItemToQueue, TickType_t ticksToWait); +extern OS_STD_RETURN_e OS_SendToBackOfQueue(OS_QUEUE xQueue, const void *const pvItemToQueue, uint32_t ticksToWait); /** * @brief Post an item to the back the provided queue during an ISR * @details This function needs to implement the wrapper to OS specfic queue * posting. - * The queue needs to be implement in a FreeRTOS compatible way. - * @param xQueue FreeRTOS compatible queue handle that - * should be posted to. + * @param xQueue queue handle that should be posted to. * @param pvItemToQueue Pointer to the item to be posted in the * queue. * @param pxHigherPriorityTaskWoken Indicates whether a context switch is @@ -288,6 +294,15 @@ extern OS_STD_RETURN_e OS_SendToBackOfQueueFromIsr( const void *const pvItemToQueue, long *const pxHigherPriorityTaskWoken); +/** + * @brief Check if messages are waiting for queue + * @details This function needs to implement the wrapper to OS specfic queue + * posting. + * @param xQueue queue handle that should be posted to. + * @return number of message currently stored in xQueue + */ +extern uint32_t OS_GetNumberOfStoredMessagesInQueue(OS_QUEUE xQueue); + /** * @brief This function checks if timeToPass has passed since the last timestamp to now * @details This function retrieves the current time stamp with #OS_GetTickCount(), diff --git a/src/app/task/wscript b/src/app/task/wscript index 72f9724d..1ee76da6 100644 --- a/src/app/task/wscript +++ b/src/app/task/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -77,6 +77,7 @@ def build(bld): os.path.join("..", "driver", "can"), os.path.join("..", "driver", "config"), os.path.join("..", "driver", "contactor"), + os.path.join("..", "driver", "crc"), os.path.join("..", "driver", "dma"), os.path.join("..", "driver", "fram"), os.path.join("..", "driver", "htsensor"), @@ -94,6 +95,7 @@ def build(bld): os.path.join("..", "driver", "sbc", "fs8x_driver"), os.path.join("..", "driver", "spi"), os.path.join("..", "driver", "sps"), + os.path.join("..", "driver", "mcu"), os.path.join("..", "engine"), os.path.join("..", "engine", "config"), os.path.join("..", "engine", "database"), @@ -112,3 +114,22 @@ def build(bld): cflags=cflags, target=target, ) + + if os_name.lower() == "freertos": + c_fragment = '#include "os.h"\n#include "os_freertos_config-validation.h"\n' + config_source = bld.path.find_or_declare(f"{os_name.lower()}-config-test.c") + config_source.parent.mkdir() + config_source.write(c_fragment, encoding="utf-8") + config_includes = bld.env.INCLUDES_OPERATING_SYSTEM + [ + "os", + os.path.join("..", "driver", "mcu"), + os.path.join("..", "main", "include"), + os.path.join("config"), + os.path.join("os", "freertos"), + ] + bld.objects( + source=[config_source], + includes=config_includes, + cflags=cflags, + target=f"{os_name.lower()}-config-test", + ) diff --git a/src/app/wscript b/src/app/wscript index 16baad31..94edc711 100644 --- a/src/app/wscript +++ b/src/app/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/doxygen_src.h b/src/doxygen_src.h index 4e349fb4..8ec8ccd6 100644 --- a/src/doxygen_src.h +++ b/src/doxygen_src.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file doxygen_src.h * @author foxBMS Team * @date 2019-06-02 (date of creation) - * @updated 2019-06-26 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup DOXYGEN * @prefix DX * diff --git a/src/hal/wscript b/src/hal/wscript index 0ad14c2c..8f2f4b92 100644 --- a/src/hal/wscript +++ b/src/hal/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/opt/cells/config/lg_inr18650mj1.c b/src/opt/cells/config/lg_inr18650mj1.c index 72847f7e..9702eb0d 100644 --- a/src/opt/cells/config/lg_inr18650mj1.c +++ b/src/opt/cells/config/lg_inr18650mj1.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file lg_inr18650mj1.c * @author foxBMS Team * @date 2017-11-07 (date of creation) - * @updated 2020-07-31 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_CELL_CONF * @prefix BC * diff --git a/src/opt/cells/config/lg_inr18650mj1.h b/src/opt/cells/config/lg_inr18650mj1.h index 8d867019..08dcafac 100644 --- a/src/opt/cells/config/lg_inr18650mj1.h +++ b/src/opt/cells/config/lg_inr18650mj1.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file lg_inr18650mj1.h * @author foxBMS Team * @date 2017-11-07 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_CELL_CONF * @prefix BC * @@ -211,7 +212,7 @@ #endif /** structure for lookup table */ -typedef struct BC_LUT { +typedef struct { const int16_t voltage_mV; /*!< cell voltage in mV */ const float value; /*!< corresponding value, can be SOC/SOE in % or capacity/energy */ } BC_LUT_s; diff --git a/src/opt/cells/config/pana_ncr18650bd.h b/src/opt/cells/config/pana_ncr18650bd.h index 87e59d99..d2d96ba8 100644 --- a/src/opt/cells/config/pana_ncr18650bd.h +++ b/src/opt/cells/config/pana_ncr18650bd.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file pana_ncr18650bd.h * @author foxBMS Team * @date 2018-10-02 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup BATTERY_CELL_CONF * @prefix BC * diff --git a/src/os/freertos/uncrustify.cfg b/src/os/freertos/.github/uncrustify.cfg similarity index 100% rename from src/os/freertos/uncrustify.cfg rename to src/os/freertos/.github/uncrustify.cfg diff --git a/src/os/freertos/History.txt b/src/os/freertos/History.txt index 3dd34f03..dc6c8d57 100644 --- a/src/os/freertos/History.txt +++ b/src/os/freertos/History.txt @@ -1,7 +1,77 @@ Documentation and download available at https://www.FreeRTOS.org/ +Changes between FreeRTOS V10.4.4 and FreeRTOS V10.4.5 released September 10 2021 + + See https://www.FreeRTOS.org/FreeRTOS-V10.4.5.html + + + Introduce configRUN_TIME_COUNTER_TYPE which enables developers to define + the type used to hold run time statistic counters. Defaults to uint32_t + for backward compatibility. #define configRUN_TIME_COUNTER_TYPE to a type + (for example, uint64_t) in FreeRTOSConfig.h to override the default. + + Introduce ulTaskGetIdleRunTimePercent() to complement the pre-existing + ulTaskGetIdleRunTimeCounter(). Whereas the pre-existing function returns + the raw run time counter value, the new function returns the percentage of + the entire run time consumed by the idle task. Note the amount of idle + time is only a good measure of the slack time in a system if there are no + other tasks executing at the idle priority, tickless idle is not used, and + configIDLE_SHOULD_YIELD is set to 0. + + ARMv8-M secure-side port: Tasks that call secure functions from the + non-secure side of an ARMv8-M MCU (ARM Cortex-M23 and Cortex-M33) have two + contexts – one on the non-secure side and one on the secure-side. Previous + versions of the FreeRTOS ARMv8-M secure-side ports allocated the structures + that reference secure-side contexts at run time. Now the structures are + allocated statically at compile time. The change necessitates the + introduction of the secureconfigMAX_SECURE_CONTEXTS configuration constant, + which sets the number of statically allocated secure contexts. + secureconfigMAX_SECURE_CONTEXTS defaults to 8 if left undefined. + Applications that only use FreeRTOS code on the non-secure side, such as + those running third-party code on the secure side, are not affected by + this change. + + +Changes between FreeRTOS V10.4.3 and FreeRTOS V10.4.4 released May 28 2021 + + Minor performance improvements to xTaskIncrementTick() achieved by providing + macro versions of uxListRemove() and vListInsertEnd(). + + Minor refactor of timers.c that obsoletes the need for the + tmrCOMMAND_START_DONT_TRACE macro and removes the need for timers.c to + post to its own event queue. A consequence of this change is that auto- + reload timers that miss their intended next execution time will execute + again immediately rather than executing again the next time the command + queue is processed. (thanks Jeff Tenney). + + Fix a race condition in the message buffer implementation. The + underlying cause was that length and data bytes are written and read as + two distinct operations, which both modify the size of the buffer. If a + context switch occurs after adding or removing the length bytes, but + before adding or removing the data bytes, then another task may observe + the message buffer in an invalid state. + + The xTaskCreate() and xTaskCreateStatic() functions accept a task priority + as an input parameter. The priority has always been silently capped to + (configMAX_PRIORITIES - 1) should it be set to a value above that priority. + Now values above that priority will also trigger a configASSERT() failure. + + Replace configASSERT( pcQueueName ) in vQueueAddToRegistry with a NULL + pointer check. + + Introduce the configSTACK_ALLOCATION_FROM_SEPARATE_HEAP configuration + constant that enables the stack allocated to tasks to come from a heap other + than the heap used by other memory allocations. This enables stacks to be + placed within special regions, such as fast tightly coupled memory. + + If there is an attempt to add the same queue or semaphore handle to the + queue registry more than once then prior versions would create two separate + entries. Now if this is done the first entry is overwritten rather than + duplicated. + + Update the ESP32 port and TF-M (Trusted Firmware M)code to the latest from + their respective repositories. + + Correct a build error in the POSIX port. + + Additional minor formatting updates, including replacing tabs with spaces + in more files. + + Other minor updates include adding additional configASSERT() checks and + correcting and improving code comments. + + Go look at the smp branch to see the progress towards the Symetric + Multiprocessing Kernel. https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/smp + Changes between FreeRTOS V10.4.2 and FreeRTOS V10.4.3 released December 14 2020 + V10.4.3 is included in the 202012.00 LTS release. Learn more at https:/freertos.org/lts-libraries.html + See https://www.FreeRTOS.org/FreeRTOS-V10.4.x.html + Changes to improve robustness and consistency for buffer allocation in @@ -13,14 +83,14 @@ Changes between FreeRTOS V10.4.2 and FreeRTOS V10.4.3 released December 14 2020 Changes between FreeRTOS V10.4.1 and FreeRTOS V10.4.2 released November 10 2020 - + See https://www.FreeRTOS.org/FreeRTOS-V10.4.x.html - + Fix an issue in the ARMv8-M ports that caused BASEPRI to be masked - between the first task starting to execute and that task making + + Fix an issue in the ARMv8-M ports that caused BASEPRI to be masked + between the first task starting to execute and that task making a FreeRTOS API call. + Introduced xTaskDelayUntil(), which is functionally equivalent to - vTaskDelayUntil(), with the addition of returning a value to + vTaskDelayUntil(), with the addition of returning a value to indicating whether or not the function placed the calling task into the Blocked state or not. + Update WolfSSL to 4.5.0 and add the FIPS ready demo. @@ -34,8 +104,8 @@ Changes between FreeRTOS V10.4.0 and FreeRTOS V10.4.1 released September 17 2020 See https://www.FreeRTOS.org/FreeRTOS-V10.4.x.html - + Fixed an incorrectly named parameter that prevented the - ulTaskNotifyTakeIndexed macro compiling, and the name space clash in the + + Fixed an incorrectly named parameter that prevented the + ulTaskNotifyTakeIndexed macro compiling, and the name space clash in the test code that prevented this error causing test failures. @@ -76,8 +146,8 @@ Changes between FreeRTOS V10.3.1 and FreeRTOS V10.4.0 released September 10 2020 + Added new POSIX port layer that allows FreeRTOS to run on Linux hosts in the same way the Windows port layer enables FreeRTOS to run on Windows hosts. - + Many other minor optimisations and enhancements. For full details - see https://github.com/FreeRTOS/FreeRTOS-Kernel/commits/master + + Many other minor optimisations and enhancements. For full details + see https://github.com/FreeRTOS/FreeRTOS-Kernel/commits/main Changes between FreeRTOS V10.3.0 and FreeRTOS V10.3.1 released February 18 2020 diff --git a/src/os/freertos/README.md b/src/os/freertos/README.md index 1cc1b84c..52d78dd7 100644 --- a/src/os/freertos/README.md +++ b/src/os/freertos/README.md @@ -31,7 +31,7 @@ See the readme file in the ```./portable``` directory for more information. - The ```./include``` directory contains the real time kernel header files. ### Code Formatting -FreeRTOS files are formatted using the "uncrustify" tool. The configuration file used by uncrustify can be found in the [FreeRTOS/FreeRTOS repository](https://github.com/FreeRTOS/FreeRTOS/blob/master/tools/uncrustify.cfg). +FreeRTOS files are formatted using the "uncrustify" tool. The configuration file used by uncrustify can be found in the [FreeRTOS/FreeRTOS repository](https://github.com/FreeRTOS/FreeRTOS/blob/main/tools/uncrustify.cfg). ### Spelling *lexicon.txt* contains words that are not traditionally found in an English dictionary. It is used by the spellchecker to verify the various jargon, variable names, and other odd words used in the FreeRTOS code base. If your pull request fails to pass the spelling and you believe this is a mistake, then add the word to *lexicon.txt*. diff --git a/src/os/freertos/README.ti-halcogen.md b/src/os/freertos/README.ti-halcogen.md index a9bbb817..0a58b6ae 100644 --- a/src/os/freertos/README.ti-halcogen.md +++ b/src/os/freertos/README.ti-halcogen.md @@ -7,7 +7,7 @@ FreeRTOS working on the ``TI TMS570LC43x`` in a project specific way. ## Basis The basis for FreeRTOS within the foxBMS 2 project is -``FreeRTOS Kernel V10.4.3``. +``FreeRTOS Kernel V10.4.5``. ## Changes diff --git a/src/os/freertos/croutine.c b/src/os/freertos/croutine.c index c4c0fab4..2881c4ce 100644 --- a/src/os/freertos/croutine.c +++ b/src/os/freertos/croutine.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/event_groups.c b/src/os/freertos/event_groups.c index d3f2d1f7..713a5911 100644 --- a/src/os/freertos/event_groups.c +++ b/src/os/freertos/event_groups.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -626,7 +628,11 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, void vEventGroupDelete( EventGroupHandle_t xEventGroup ) { EventGroup_t * pxEventBits = xEventGroup; - const List_t * pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits ); + const List_t * pxTasksWaitingForBits; + + configASSERT( pxEventBits ); + + pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits ); vTaskSuspendAll(); { diff --git a/src/os/freertos/include/FreeRTOS.h b/src/os/freertos/include/FreeRTOS.h index 2b06619b..811f35c5 100644 --- a/src/os/freertos/include/FreeRTOS.h +++ b/src/os/freertos/include/FreeRTOS.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -905,6 +907,14 @@ #define configSTACK_DEPTH_TYPE uint16_t #endif +#ifndef configRUN_TIME_COUNTER_TYPE + +/* Defaults to uint32_t for backward compatibility, but can be overridden in + * FreeRTOSConfig.h if uint32_t is too restrictive. */ + + #define configRUN_TIME_COUNTER_TYPE uint32_t +#endif + #ifndef configMESSAGE_BUFFER_LENGTH_TYPE /* Defaults to size_t for backward compatibility, but can be overridden @@ -981,7 +991,7 @@ #ifndef configMIN -/* The application writer has not provided their own MAX macro, so define +/* The application writer has not provided their own MIN macro, so define * the following generic implementation. */ #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) #endif @@ -1056,6 +1066,11 @@ #define configRUN_FREERTOS_SECURE_ONLY 0 #endif +#ifndef configRUN_ADDITIONAL_TESTS + #define configRUN_ADDITIONAL_TESTS 0 +#endif + + /* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using * dynamically allocated RAM, in which case when any task is deleted it is known * that both the task's stack and TCB need to be freed. Sometimes the @@ -1107,7 +1122,7 @@ * data hiding policy, so the real structures used by FreeRTOS to maintain the * state of tasks, queues, semaphores, etc. are not accessible to the application * code. However, if the application writer wants to statically allocate such - * an object then the size of the object needs to be know. Dummy structures + * an object then the size of the object needs to be known. Dummy structures * that are guaranteed to have the same size and alignment requirements of the * real objects are used for this purpose. The dummy list and list item * structures below are used for inclusion in such a dummy structure. @@ -1156,7 +1171,7 @@ typedef struct xSTATIC_LIST * strict data hiding policy. This means the Task structure used internally by * FreeRTOS is not accessible to application code. However, if the application * writer wants to statically allocate the memory required to create a task then - * the size of the task object needs to be know. The StaticTask_t structure + * the size of the task object needs to be known. The StaticTask_t structure * below is provided for this purpose. Its sizes and alignment requirements are * guaranteed to match those of the genuine structure, no matter which * architecture is being used, and no matter how the values in FreeRTOSConfig.h @@ -1192,7 +1207,7 @@ typedef struct xSTATIC_TCB void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; #endif #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulDummy16; + configRUN_TIME_COUNTER_TYPE ulDummy16; #endif #if ( configUSE_NEWLIB_REENTRANT == 1 ) struct _reent xDummy17; @@ -1219,7 +1234,7 @@ typedef struct xSTATIC_TCB * strict data hiding policy. This means the Queue structure used internally by * FreeRTOS is not accessible to application code. However, if the application * writer wants to statically allocate the memory required to create a queue - * then the size of the queue object needs to be know. The StaticQueue_t + * then the size of the queue object needs to be known. The StaticQueue_t * structure below is provided for this purpose. Its sizes and alignment * requirements are guaranteed to match those of the genuine structure, no * matter which architecture is being used, and no matter how the values in @@ -1290,7 +1305,7 @@ typedef struct xSTATIC_EVENT_GROUP * strict data hiding policy. This means the software timer structure used * internally by FreeRTOS is not accessible to application code. However, if * the application writer wants to statically allocate the memory required to - * create a software timer then the size of the queue object needs to be know. + * create a software timer then the size of the queue object needs to be known. * The StaticTimer_t structure below is provided for this purpose. Its sizes * and alignment requirements are guaranteed to match those of the genuine * structure, no matter which architecture is being used, and no matter how the @@ -1318,12 +1333,12 @@ typedef struct xSTATIC_TIMER * internally by FreeRTOS is not accessible to application code. However, if * the application writer wants to statically allocate the memory required to * create a stream buffer then the size of the stream buffer object needs to be - * know. The StaticStreamBuffer_t structure below is provided for this purpose. - * Its size and alignment requirements are guaranteed to match those of the - * genuine structure, no matter which architecture is being used, and no matter - * how the values in FreeRTOSConfig.h are set. Its contents are somewhat - * obfuscated in the hope users will recognise that it would be unwise to make - * direct use of the structure members. + * known. The StaticStreamBuffer_t structure below is provided for this + * purpose. Its size and alignment requirements are guaranteed to match those + * of the genuine structure, no matter which architecture is being used, and + * no matter how the values in FreeRTOSConfig.h are set. Its contents are + * somewhat obfuscated in the hope users will recognise that it would be unwise + * to make direct use of the structure members. */ typedef struct xSTATIC_STREAM_BUFFER { diff --git a/src/os/freertos/include/FreeRTOSConfig.h b/src/os/freertos/include/FreeRTOSConfig.h index 5f8818d5..6c527349 100644 --- a/src/os/freertos/include/FreeRTOSConfig.h +++ b/src/os/freertos/include/FreeRTOSConfig.h @@ -59,6 +59,8 @@ #define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) #define configMAX_TASK_NAME_LEN ( 40 ) #define configIDLE_SHOULD_YIELD ( 1 ) +#define configUSE_TASK_NOTIFICATIONS ( 1 ) +#define configTASK_NOTIFICATION_ARRAY_ENTRIES ( 3 ) #define configGENERATE_RUN_TIME_STATS ( 0 ) #define configUSE_MALLOC_FAILED_HOOK ( 0 ) diff --git a/src/os/freertos/include/StackMacros.h b/src/os/freertos/include/StackMacros.h index 8d09f10c..acac8a0f 100644 --- a/src/os/freertos/include/StackMacros.h +++ b/src/os/freertos/include/StackMacros.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/include/atomic.h b/src/os/freertos/include/atomic.h index a47b9672..5f8cf5c0 100644 --- a/src/os/freertos/include/atomic.h +++ b/src/os/freertos/include/atomic.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/include/croutine.h b/src/os/freertos/include/croutine.h index 9463f353..f17c9ed1 100644 --- a/src/os/freertos/include/croutine.h +++ b/src/os/freertos/include/croutine.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/include/deprecated_definitions.h b/src/os/freertos/include/deprecated_definitions.h index d3b94266..522d9d09 100644 --- a/src/os/freertos/include/deprecated_definitions.h +++ b/src/os/freertos/include/deprecated_definitions.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/include/event_groups.h b/src/os/freertos/include/event_groups.h index 70ba8d1b..ee676343 100644 --- a/src/os/freertos/include/event_groups.h +++ b/src/os/freertos/include/event_groups.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -102,10 +104,10 @@ typedef TickType_t EventBits_t; * * Internally, within the FreeRTOS implementation, event groups use a [small] * block of memory, in which the event group's structure is stored. If an event - * groups is created using xEventGropuCreate() then the required memory is + * groups is created using xEventGroupCreate() then the required memory is * automatically dynamically allocated inside the xEventGroupCreate() function. * (see https://www.FreeRTOS.org/a00111.html). If an event group is created - * using xEventGropuCreateStatic() then the application writer must instead + * using xEventGroupCreateStatic() then the application writer must instead * provide the memory that will get used by the event group. * xEventGroupCreateStatic() therefore allows an event group to be created * without using any dynamic memory allocation. @@ -158,10 +160,10 @@ typedef TickType_t EventBits_t; * * Internally, within the FreeRTOS implementation, event groups use a [small] * block of memory, in which the event group's structure is stored. If an event - * groups is created using xEventGropuCreate() then the required memory is + * groups is created using xEventGroupCreate() then the required memory is * automatically dynamically allocated inside the xEventGroupCreate() function. * (see https://www.FreeRTOS.org/a00111.html). If an event group is created - * using xEventGropuCreateStatic() then the application writer must instead + * using xEventGroupCreateStatic() then the application writer must instead * provide the memory that will get used by the event group. * xEventGroupCreateStatic() therefore allows an event group to be created * without using any dynamic memory allocation. diff --git a/src/os/freertos/include/list.h b/src/os/freertos/include/list.h index efcb5115..9dcf6676 100644 --- a/src/os/freertos/include/list.h +++ b/src/os/freertos/include/list.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -31,7 +33,7 @@ * * list_ts can only store pointers to list_item_ts. Each ListItem_t contains a * numeric value (xItemValue). Most of the time the lists are sorted in - * descending item value order. + * ascending item value order. * * Lists are created already containing one list item. The value of this * item is the maximum possible that can be stored, it is therefore always at @@ -142,7 +144,7 @@ struct xLIST; struct xLIST_ITEM { listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ - configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ + configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in ascending order. */ struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ @@ -192,7 +194,7 @@ typedef struct xLIST /* * Access macro to set the value of the list item. In most cases the value is - * used to sort the list in descending order. + * used to sort the list in ascending order. * * \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE * \ingroup LinkedList @@ -289,6 +291,86 @@ typedef struct xLIST ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ } +/* + * Version of uxListRemove() that does not return a value. Provided as a slight + * optimisation for xTaskIncrementTick() by being inline. + * + * Remove an item from a list. The list item has a pointer to the list that + * it is in, so only the list item need be passed into the function. + * + * @param uxListRemove The item to be removed. The item will remove itself from + * the list pointed to by it's pxContainer parameter. + * + * @return The number of items that remain in the list after the list item has + * been removed. + * + * \page listREMOVE_ITEM listREMOVE_ITEM + * \ingroup LinkedList + */ +#define listREMOVE_ITEM( pxItemToRemove ) \ + { \ + /* The list item knows which list it is in. Obtain the list from the list \ + * item. */ \ + List_t * const pxList = ( pxItemToRemove )->pxContainer; \ + \ + ( pxItemToRemove )->pxNext->pxPrevious = ( pxItemToRemove )->pxPrevious; \ + ( pxItemToRemove )->pxPrevious->pxNext = ( pxItemToRemove )->pxNext; \ + /* Make sure the index is left pointing to a valid item. */ \ + if( pxList->pxIndex == ( pxItemToRemove ) ) \ + { \ + pxList->pxIndex = ( pxItemToRemove )->pxPrevious; \ + } \ + \ + ( pxItemToRemove )->pxContainer = NULL; \ + ( pxList->uxNumberOfItems )--; \ + } + +/* + * Inline version of vListInsertEnd() to provide slight optimisation for + * xTaskIncrementTick(). + * + * Insert a list item into a list. The item will be inserted in a position + * such that it will be the last item within the list returned by multiple + * calls to listGET_OWNER_OF_NEXT_ENTRY. + * + * The list member pxIndex is used to walk through a list. Calling + * listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list. + * Placing an item in a list using vListInsertEnd effectively places the item + * in the list position pointed to by pxIndex. This means that every other + * item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before + * the pxIndex parameter again points to the item being inserted. + * + * @param pxList The list into which the item is to be inserted. + * + * @param pxNewListItem The list item to be inserted into the list. + * + * \page listINSERT_END listINSERT_END + * \ingroup LinkedList + */ +#define listINSERT_END( pxList, pxNewListItem ) \ + { \ + ListItem_t * const pxIndex = ( pxList )->pxIndex; \ + \ + /* Only effective when configASSERT() is also defined, these tests may catch \ + * the list data structures being overwritten in memory. They will not catch \ + * data errors caused by incorrect configuration or use of FreeRTOS. */ \ + listTEST_LIST_INTEGRITY( ( pxList ) ); \ + listTEST_LIST_ITEM_INTEGRITY( ( pxNewListItem ) ); \ + \ + /* Insert a new list item into ( pxList ), but rather than sort the list, \ + * makes the new list item the last item to be removed by a call to \ + * listGET_OWNER_OF_NEXT_ENTRY(). */ \ + ( pxNewListItem )->pxNext = pxIndex; \ + ( pxNewListItem )->pxPrevious = pxIndex->pxPrevious; \ + \ + pxIndex->pxPrevious->pxNext = ( pxNewListItem ); \ + pxIndex->pxPrevious = ( pxNewListItem ); \ + \ + /* Remember which list the item is in. */ \ + ( pxNewListItem )->pxContainer = ( pxList ); \ + \ + ( ( pxList )->uxNumberOfItems )++; \ + } /* * Access function to obtain the owner of the first entry in a list. Lists @@ -359,7 +441,7 @@ void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION; /* * Insert a list item into a list. The item will be inserted into the list in - * a position determined by its item value (descending item value order). + * a position determined by its item value (ascending item value order). * * @param pxList The list into which the item is to be inserted. * diff --git a/src/os/freertos/include/message_buffer.h b/src/os/freertos/include/message_buffer.h index ed795456..fbe1ceca 100644 --- a/src/os/freertos/include/message_buffer.h +++ b/src/os/freertos/include/message_buffer.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -630,7 +632,7 @@ typedef void * MessageBufferHandle_t; /** * message_buffer.h *
- * BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer ) );
+ * BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer );
  * 
* * Tests to see if a message buffer is full. A message buffer is full if it @@ -648,7 +650,7 @@ typedef void * MessageBufferHandle_t; /** * message_buffer.h *
- * BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer ) );
+ * BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer );
  * 
* * Tests to see if a message buffer is empty (does not contain any messages). @@ -690,7 +692,7 @@ typedef void * MessageBufferHandle_t; /** * message_buffer.h *
- * size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) );
+ * size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer );
  * 
* Returns the number of bytes of free space in the message buffer. * @@ -714,7 +716,7 @@ typedef void * MessageBufferHandle_t; /** * message_buffer.h *
- * size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer ) );
+ * size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer );
  * 
* Returns the length (in bytes) of the next message in a message buffer. * Useful if xMessageBufferReceive() returned 0 because the size of the buffer diff --git a/src/os/freertos/include/mpu_prototypes.h b/src/os/freertos/include/mpu_prototypes.h index 0ca4a594..7f4d63b6 100644 --- a/src/os/freertos/include/mpu_prototypes.h +++ b/src/os/freertos/include/mpu_prototypes.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -95,8 +97,9 @@ BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL; UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, - uint32_t * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; -uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; + configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL; +configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL; +configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercent( void ) FREERTOS_SYSTEM_CALL; void MPU_vTaskList( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) FREERTOS_SYSTEM_CALL; BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, diff --git a/src/os/freertos/include/mpu_wrappers.h b/src/os/freertos/include/mpu_wrappers.h index ecd26196..b98fa150 100644 --- a/src/os/freertos/include/mpu_wrappers.h +++ b/src/os/freertos/include/mpu_wrappers.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -29,7 +31,7 @@ /* This file redefines API functions to be called through a wrapper macro, but * only for ports that are using the MPU. */ -#ifdef portUSING_MPU_WRAPPERS +#if ( portUSING_MPU_WRAPPERS == 1 ) /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is * included from queue.c or task.c to prevent it from having an effect within @@ -79,6 +81,7 @@ #define vTaskList MPU_vTaskList #define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats #define ulTaskGetIdleRunTimeCounter MPU_ulTaskGetIdleRunTimeCounter + #define ulTaskGetIdleRunTimePercent MPU_ulTaskGetIdleRunTimePercent #define xTaskGenericNotify MPU_xTaskGenericNotify #define xTaskGenericNotifyWait MPU_xTaskGenericNotifyWait #define ulTaskGenericNotifyTake MPU_ulTaskGenericNotifyTake @@ -181,7 +184,6 @@ #define PRIVILEGED_FUNCTION #define PRIVILEGED_DATA #define FREERTOS_SYSTEM_CALL - #define portUSING_MPU_WRAPPERS 0 #endif /* portUSING_MPU_WRAPPERS */ diff --git a/src/os/freertos/include/portable.h b/src/os/freertos/include/portable.h index 5434cbf1..37a024ba 100644 --- a/src/os/freertos/include/portable.h +++ b/src/os/freertos/include/portable.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -53,30 +55,22 @@ #if portBYTE_ALIGNMENT == 32 #define portBYTE_ALIGNMENT_MASK ( 0x001f ) -#endif - -#if portBYTE_ALIGNMENT == 16 +#elif portBYTE_ALIGNMENT == 16 #define portBYTE_ALIGNMENT_MASK ( 0x000f ) -#endif - -#if portBYTE_ALIGNMENT == 8 +#elif portBYTE_ALIGNMENT == 8 #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) -#endif - -#if portBYTE_ALIGNMENT == 4 +#elif portBYTE_ALIGNMENT == 4 #define portBYTE_ALIGNMENT_MASK ( 0x0003 ) -#endif - -#if portBYTE_ALIGNMENT == 2 +#elif portBYTE_ALIGNMENT == 2 #define portBYTE_ALIGNMENT_MASK ( 0x0001 ) -#endif - -#if portBYTE_ALIGNMENT == 1 +#elif portBYTE_ALIGNMENT == 1 #define portBYTE_ALIGNMENT_MASK ( 0x0000 ) -#endif - -#ifndef portBYTE_ALIGNMENT_MASK +#else /* if portBYTE_ALIGNMENT == 32 */ #error "Invalid portBYTE_ALIGNMENT definition" +#endif /* if portBYTE_ALIGNMENT == 32 */ + +#ifndef portUSING_MPU_WRAPPERS + #define portUSING_MPU_WRAPPERS 0 #endif #ifndef portNUM_CONFIGURABLE_REGIONS @@ -91,6 +85,11 @@ #define portARCH_NAME NULL #endif +#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP + /* Defaults to 0 for backward compatibility. */ + #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0 +#endif + /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { @@ -179,6 +178,14 @@ void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; +#if ( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 ) + void * pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION; + void vPortFreeStack( void * pv ) PRIVILEGED_FUNCTION; +#else + #define pvPortMallocStack pvPortMalloc + #define vPortFreeStack vPortFree +#endif + /* * Setup the hardware ready for the scheduler to take control. This generally * sets up a tick interrupt and sets timers for the correct tick frequency. diff --git a/src/os/freertos/include/projdefs.h b/src/os/freertos/include/projdefs.h index 5a24244b..6e04fdf9 100644 --- a/src/os/freertos/include/projdefs.h +++ b/src/os/freertos/include/projdefs.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/include/queue.h b/src/os/freertos/include/queue.h index 37ad23c7..2b2c9994 100644 --- a/src/os/freertos/include/queue.h +++ b/src/os/freertos/include/queue.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -1491,6 +1493,10 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; * does not effect the number of queues, semaphores and mutexes that can be * created - just the number that the registry can hold. * + * If vQueueAddToRegistry is called more than once with the same xQueue + * parameter, the registry will store the pcQueueName parameter from the + * most recent call to vQueueAddToRegistry. + * * @param xQueue The handle of the queue being added to the registry. This * is the handle returned by a call to xQueueCreate(). Semaphore and mutex * handles can also be passed in here. diff --git a/src/os/freertos/include/semphr.h b/src/os/freertos/include/semphr.h index 466f917f..c1431379 100644 --- a/src/os/freertos/include/semphr.h +++ b/src/os/freertos/include/semphr.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -1170,4 +1172,18 @@ typedef QueueHandle_t SemaphoreHandle_t; */ #define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) ) +/** + * semphr.h + *
+ * UBaseType_t uxSemaphoreGetCountFromISR( SemaphoreHandle_t xSemaphore );
+ * 
+ * + * If the semaphore is a counting semaphore then uxSemaphoreGetCountFromISR() returns + * its current count value. If the semaphore is a binary semaphore then + * uxSemaphoreGetCountFromISR() returns 1 if the semaphore is available, and 0 if the + * semaphore is not available. + * + */ +#define uxSemaphoreGetCountFromISR( xSemaphore ) uxQueueMessagesWaitingFromISR( ( QueueHandle_t ) ( xSemaphore ) ) + #endif /* SEMAPHORE_H */ diff --git a/src/os/freertos/include/stack_macros.h b/src/os/freertos/include/stack_macros.h index cb76f284..edb98d79 100644 --- a/src/os/freertos/include/stack_macros.h +++ b/src/os/freertos/include/stack_macros.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -43,13 +45,21 @@ /*-----------------------------------------------------------*/ +/* + * portSTACK_LIMIT_PADDING is a number of extra words to consider to be in + * use on the stack. + */ +#ifndef portSTACK_LIMIT_PADDING + #define portSTACK_LIMIT_PADDING 0 +#endif + #if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) ) /* Only the current stack state is to be checked. */ #define taskCHECK_FOR_STACK_OVERFLOW() \ { \ /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \ + if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \ { \ vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ } \ @@ -65,7 +75,7 @@ { \ \ /* Is the currently saved stack pointer within the stack limit? */ \ - if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \ + if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \ { \ vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ } \ diff --git a/src/os/freertos/include/stdint.readme b/src/os/freertos/include/stdint.readme index 20a8d663..098365fb 100644 --- a/src/os/freertos/include/stdint.readme +++ b/src/os/freertos/include/stdint.readme @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -49,4 +51,8 @@ typedef unsigned short uint16_t; typedef long int32_t; typedef unsigned long uint32_t; +#ifndef SIZE_MAX + #define SIZE_MAX ( ( size_t ) -1 ) +#endif + #endif /* FREERTOS_STDINT */ diff --git a/src/os/freertos/include/stream_buffer.h b/src/os/freertos/include/stream_buffer.h index 96c6d9ac..837bae05 100644 --- a/src/os/freertos/include/stream_buffer.h +++ b/src/os/freertos/include/stream_buffer.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/include/task.h b/src/os/freertos/include/task.h index 8d0d6a2a..ee9119d7 100644 --- a/src/os/freertos/include/task.h +++ b/src/os/freertos/include/task.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -44,10 +46,17 @@ * MACROS AND DEFINITIONS *----------------------------------------------------------*/ -#define tskKERNEL_VERSION_NUMBER "V10.4.3" +/* + * If tskKERNEL_VERSION_NUMBER ends with + it represents the version in development + * after the numbered release. + * + * The tskKERNEL_VERSION_MAJOR, tskKERNEL_VERSION_MINOR, tskKERNEL_VERSION_BUILD + * values will reflect the last released version number. + */ +#define tskKERNEL_VERSION_NUMBER "V10.4.5" #define tskKERNEL_VERSION_MAJOR 10 #define tskKERNEL_VERSION_MINOR 4 -#define tskKERNEL_VERSION_BUILD 3 +#define tskKERNEL_VERSION_BUILD 5 /* MPU region parameters passed in ulParameters * of MemoryRegion_t struct. */ @@ -87,7 +96,7 @@ typedef BaseType_t (* TaskHookFunction_t)( void * ); typedef enum { eRunning = 0, /* A task is querying the state of itself, so must be running. */ - eReady, /* The task being queried is in a read or pending ready list. */ + eReady, /* The task being queried is in a ready or pending ready list. */ eBlocked, /* The task being queried is in the Blocked state. */ eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */ eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */ @@ -144,21 +153,21 @@ typedef struct xTASK_PARAMETERS * in the system. */ typedef struct xTASK_STATUS { - TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */ - const char * pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ - UBaseType_t xTaskNumber; /* A number unique to the task. */ - eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */ - UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ - UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ - uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See https://www.FreeRTOS.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ - StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */ - configSTACK_DEPTH_TYPE usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ + TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */ + const char * pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + UBaseType_t xTaskNumber; /* A number unique to the task. */ + eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */ + UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ + UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */ + configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See https://www.FreeRTOS.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */ + StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */ + configSTACK_DEPTH_TYPE usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ } TaskStatus_t; /* Possible return values for eTaskConfirmSleepModeStatus(). */ typedef enum { - eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ + eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */ eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ } eSleepModeStatus; @@ -246,12 +255,12 @@ typedef enum * task. h *
  * BaseType_t xTaskCreate(
- *                            TaskFunction_t pvTaskCode,
- *                            const char * const pcName,
+ *                            TaskFunction_t pxTaskCode,
+ *                            const char *pcName,
  *                            configSTACK_DEPTH_TYPE usStackDepth,
  *                            void *pvParameters,
  *                            UBaseType_t uxPriority,
- *                            TaskHandle_t *pvCreatedTask
+ *                            TaskHandle_t *pxCreatedTask
  *                        );
  * 
* @@ -275,7 +284,7 @@ typedef enum * support can alternatively create an MPU constrained task using * xTaskCreateRestricted(). * - * @param pvTaskCode Pointer to the task entry function. Tasks + * @param pxTaskCode Pointer to the task entry function. Tasks * must be implemented to never return (i.e. continuous loop). * * @param pcName A descriptive name for the task. This is mainly used to @@ -296,7 +305,7 @@ typedef enum * example, to create a privileged task at priority 2 the uxPriority parameter * should be set to ( 2 | portPRIVILEGE_BIT ). * - * @param pvCreatedTask Used to pass back a handle by which the created task + * @param pxCreatedTask Used to pass back a handle by which the created task * can be referenced. * * @return pdPASS if the task was successfully created and added to a ready @@ -348,12 +357,12 @@ typedef enum /** * task. h *
- * TaskHandle_t xTaskCreateStatic( TaskFunction_t pvTaskCode,
- *                               const char * const pcName,
+ * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
+ *                               const char *pcName,
  *                               uint32_t ulStackDepth,
  *                               void *pvParameters,
  *                               UBaseType_t uxPriority,
- *                               StackType_t *pxStackBuffer,
+ *                               StackType_t *puxStackBuffer,
  *                               StaticTask_t *pxTaskBuffer );
  * 
* @@ -369,7 +378,7 @@ typedef enum * memory. xTaskCreateStatic() therefore allows a task to be created without * using any dynamic memory allocation. * - * @param pvTaskCode Pointer to the task entry function. Tasks + * @param pxTaskCode Pointer to the task entry function. Tasks * must be implemented to never return (i.e. continuous loop). * * @param pcName A descriptive name for the task. This is mainly used to @@ -386,7 +395,7 @@ typedef enum * * @param uxPriority The priority at which the task will run. * - * @param pxStackBuffer Must point to a StackType_t array that has at least + * @param puxStackBuffer Must point to a StackType_t array that has at least * ulStackDepth indexes - the array will then be used as the task's stack, * removing the need for the stack to be allocated dynamically. * @@ -394,15 +403,15 @@ typedef enum * then be used to hold the task's data structures, removing the need for the * memory to be allocated dynamically. * - * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will - * be created and a handle to the created task is returned. If either - * pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and + * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task + * will be created and a handle to the created task is returned. If either + * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and * NULL is returned. * * Example usage: *
  *
- *  // Dimensions the buffer that the task being created will use as its stack.
+ *  // Dimensions of the buffer that the task being created will use as its stack.
  *  // NOTE:  This is the number of words the stack will hold, not the number of
  *  // bytes.  For example, if each stack item is 32-bits, and this is set to 100,
  *  // then 400 bytes (100 * 32-bits) will be allocated.
@@ -643,7 +652,7 @@ typedef enum
  *
  * @param xTask The handle of the task being updated.
  *
- * @param xRegions A pointer to an MemoryRegion_t structure that contains the
+ * @param xRegions A pointer to a MemoryRegion_t structure that contains the
  * new memory region definitions.
  *
  * Example usage:
@@ -684,7 +693,7 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask,
 /**
  * task. h
  * 
- * void vTaskDelete( TaskHandle_t xTask );
+ * void vTaskDelete( TaskHandle_t xTaskToDelete );
  * 
* * INCLUDE_vTaskDelete must be defined as 1 for this function to be available. @@ -703,7 +712,7 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, * See the demo application file death.c for sample code that utilises * vTaskDelete (). * - * @param xTask The handle of the task to be deleted. Passing NULL will + * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will * cause the calling task to be deleted. * * Example usage: @@ -748,7 +757,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; * period of 100 ticks will cause the task to unblock 100 ticks after * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method * of controlling the frequency of a periodic task as the path taken through the - * code, as well as other task and interrupt activity, will effect the frequency + * code, as well as other task and interrupt activity, will affect the frequency * at which vTaskDelay() gets called and therefore the time at which the task * next executes. See xTaskDelayUntil() for an alternative API function designed * to facilitate fixed frequency execution. It does this by specifying an @@ -1640,7 +1649,7 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION * * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer - * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer */ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, @@ -1716,7 +1725,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; * { * TaskStatus_t *pxTaskStatusArray; * volatile UBaseType_t uxArraySize, x; - * uint32_t ulTotalRunTime, ulStatsAsPercentage; + * configRUN_TIME_COUNTER_TYPE ulTotalRunTime, ulStatsAsPercentage; * * // Make sure the write buffer does not contain a string. * pcWriteBuffer = 0x00; @@ -1772,7 +1781,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION; */ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, - uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; + configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION; /** * task. h @@ -1797,8 +1806,10 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, * demo applications. Do not consider it to be part of the scheduler. * * vTaskList() calls uxTaskGetSystemState(), then formats part of the - * uxTaskGetSystemState() output into a human readable table that displays task - * names, states and stack usage. + * uxTaskGetSystemState() output into a human readable table that displays task: + * names, states, priority, stack usage and task number. + * Stack usage specified as the number of unused StackType_t words stack can hold + * on top of stack - not the number of bytes. * * vTaskList() has a dependency on the sprintf() C library function that might * bloat the code size, use a lot of stack, and provide different results on @@ -1877,11 +1888,12 @@ void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e /** * task. h - *
uint32_t ulTaskGetIdleRunTimeCounter( void );
+ *
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void );
+ *
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
* - * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS - * must both be defined as 1 for this function to be available. The application - * must also then provide definitions for + * configGENERATE_RUN_TIME_STATS, configUSE_STATS_FORMATTING_FUNCTIONS and + * INCLUDE_xTaskGetIdleTaskHandle must all be defined as 1 for these functions + * to be available. The application must also then provide definitions for * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() * to configure a peripheral timer/counter and return the timers current count * value respectively. The counter should be at least 10 times the frequency of @@ -1893,9 +1905,16 @@ void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() - * returns the total execution time of just the idle task. + * returns the total execution time of just the idle task and + * ulTaskGetIdleRunTimePercent() returns the percentage of the CPU time used by + * just the idle task. + * + * Note the amount of idle time is only a good measure of the slack time in a + * system if there are no other tasks executing at the idle priority, tickless + * idle is not used, and configIDLE_SHOULD_YIELD is set to 0. * - * @return The total run time of the idle task. This is the amount of time the + * @return The total run time of the idle task or the percentage of the total + * run time consumed by the idle task. This is the amount of time the * idle task has actually been executing. The unit of time is dependent on the * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and * portGET_RUN_TIME_COUNTER_VALUE() macros. @@ -1903,7 +1922,8 @@ void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter * \ingroup TaskUtils */ -uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; +configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; +configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ) PRIVILEGED_FUNCTION; /** * task. h @@ -1934,9 +1954,8 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * that way task notifications can be used to send data to a task, or be used as * light weight and fast binary or counting semaphores. * - * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a - * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block - * to wait for a notification value to have a non-zero value. The task does + * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to + * [optionally] block to wait for a notification to be pending. The task does * not consume any CPU time while it is in the Blocked state. * * A notification sent to a task will remain pending until it is cleared by the @@ -1978,7 +1997,7 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * * eSetBits - * The target notification value is bitwise ORed with ulValue. - * xTaskNofifyIndexed() always returns pdPASS in this case. + * xTaskNotifyIndexed() always returns pdPASS in this case. * * eIncrement - * The target notification value is incremented. ulValue is not used and @@ -2121,7 +2140,7 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, * value, if at all. Valid values for eAction are as follows: * * eSetBits - - * The task's notification value is bitwise ORed with ulValue. xTaskNofify() + * The task's notification value is bitwise ORed with ulValue. xTaskNotify() * always returns pdPASS in this case. * * eIncrement - @@ -2291,7 +2310,7 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, * the Blocked state for a notification to be received, should a notification * not already be pending when xTaskNotifyWait() was called. The task * will not consume any processing time while it is in the Blocked state. This - * is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be + * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be * used to convert a time specified in milliseconds to a time specified in * ticks. * @@ -2522,8 +2541,8 @@ void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, * value acts like a counting semaphore. * * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for - * the task's notification value to be non-zero. The task does not consume any - * CPU time while it is in the Blocked state. + * a notification. The task does not consume any CPU time while it is in the + * Blocked state. * * Where as xTaskNotifyWaitIndexed() will return when a notification is pending, * ulTaskNotifyTakeIndexed() will return when the task's notification value is @@ -2561,7 +2580,7 @@ void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, * should the count not already be greater than zero when * ulTaskNotifyTake() was called. The task will not consume any processing * time while it is in the Blocked state. This is specified in kernel ticks, - * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time + * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time * specified in milliseconds to a time specified in ticks. * * @return The task's notification count before it is either cleared to zero or @@ -2740,7 +2759,7 @@ void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; * @param pxTicksToWait The number of ticks to check for timeout i.e. if * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred. - * If the timeout has not occurred, pxTIcksToWait is updated to reflect the + * If the timeout has not occurred, pxTicksToWait is updated to reflect the * number of remaining ticks. * * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is @@ -2760,7 +2779,7 @@ void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This * // continues until either the buffer contains at least uxWantedBytes bytes, * // or the total amount of time spent in the Blocked state reaches - * // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are + * // MAX_TIME_TO_WAIT - at which point the task reads however many bytes are * // available up to a maximum of uxWantedBytes. * * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes ) @@ -2877,7 +2896,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * xItemValue value, and inserts the list item at the end of the list. * * The 'ordered' version uses the existing event list item value (which is the - * owning tasks priority) to insert the list item into the event list is task + * owning task's priority) to insert the list item into the event list in task * priority order. * * @param pxEventList The list containing tasks that are blocked waiting @@ -2887,7 +2906,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION; * event list is not ordered by task priority. * * @param xTicksToWait The maximum amount of time that the task should wait - * for the event to occur. This is specified in kernel ticks,the constant + * for the event to occur. This is specified in kernel ticks, the constant * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time * period. */ diff --git a/src/os/freertos/include/timers.h b/src/os/freertos/include/timers.h index 13993dcd..54f870a9 100644 --- a/src/os/freertos/include/timers.h +++ b/src/os/freertos/include/timers.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/list.c b/src/os/freertos/list.c index ed6109a2..49e68118 100644 --- a/src/os/freertos/list.c +++ b/src/os/freertos/list.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -158,6 +160,9 @@ void vListInsert( List_t * const pxList, * 4) Using a queue or semaphore before it has been initialised or * before the scheduler has been started (are interrupts firing * before vTaskStartScheduler() has been called?). + * 5) If the FreeRTOS port supports interrupt nesting then ensure that + * the priority of the tick interrupt is at or below + * configMAX_SYSCALL_INTERRUPT_PRIORITY. **********************************************************************/ for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */ diff --git a/src/os/freertos/portable/ccs/arm_cortex-r5/port.c b/src/os/freertos/portable/ccs/arm_cortex-r5/port.c index e5719d1d..03e35dd4 100644 --- a/src/os/freertos/portable/ccs/arm_cortex-r5/port.c +++ b/src/os/freertos/portable/ccs/arm_cortex-r5/port.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -22,7 +24,6 @@ * https://www.FreeRTOS.org * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE /* required for Cortex-R5 MPU port - generated by TI HALCoGen - see src/os/freertos/README.ti-halcogen.md for details */ diff --git a/src/os/freertos/portable/ccs/arm_cortex-r5/portasm.asm b/src/os/freertos/portable/ccs/arm_cortex-r5/portasm.asm index e2b8b1e0..d295c124 100644 --- a/src/os/freertos/portable/ccs/arm_cortex-r5/portasm.asm +++ b/src/os/freertos/portable/ccs/arm_cortex-r5/portasm.asm @@ -1,6 +1,8 @@ ;/* -; * FreeRTOS Kernel V10.4.3 -; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * FreeRTOS Kernel V10.4.5 +; * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +; * +; * SPDX-License-Identifier: MIT ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in @@ -22,7 +24,6 @@ ; * https://www.FreeRTOS.org ; * https://github.com/FreeRTOS ; * -; * 1 tab == 4 spaces! ; */ .sect ".kernelTEXT" diff --git a/src/os/freertos/portable/ccs/arm_cortex-r5/portmacro.h b/src/os/freertos/portable/ccs/arm_cortex-r5/portmacro.h index 949e542f..fdcc2876 100644 --- a/src/os/freertos/portable/ccs/arm_cortex-r5/portmacro.h +++ b/src/os/freertos/portable/ccs/arm_cortex-r5/portmacro.h @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -22,7 +24,6 @@ * https://www.FreeRTOS.org * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ #ifndef __PORTMACRO_H__ @@ -94,7 +95,7 @@ extern void vPortYield( void ); #define portSYS_SSIR1_REG ( *( ( volatile uint32_t * ) 0xFFFFFFB0 ) ) #define portSYS_SSIR1_SSKEY ( 0x7500UL ) #define portYIELD_WITHIN_API() { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY; __asm( " DSB " ); __asm( " ISB " ); } -#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY; ( void ) portSYS_SSIR1_REG; } +#define portYIELD_FROM_ISR( x ) do { if( x != pdFALSE ) { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY; ( void ) portSYS_SSIR1_REG; } } while( 0 ) #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 diff --git a/src/os/freertos/portable/common/mpu_wrappers.c b/src/os/freertos/portable/common/mpu_wrappers.c index 011867aa..d91ce96d 100644 --- a/src/os/freertos/portable/common/mpu_wrappers.c +++ b/src/os/freertos/portable/common/mpu_wrappers.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -63,7 +65,7 @@ extern BaseType_t xPortRaisePrivilege( void ) FREERTOS_SYSTEM_CALL; /* vPortResetPrivilege implemented in assembler */ /* Set the privilege level to user mode if xRunningPrivileged is false. */ /* TCJ: check must be against zero, see prvRaisePrivilege in portasm.asm */ -#define vPortResetPrivilege( xRunningPrivileged ) if( xRunningPrivileged == 0 ) portSWITCH_TO_USER_MODE() +#define vPortResetPrivilege( xRunningPrivileged ) if( xRunningPrivileged == 0 ) portSWITCH_TO_USER_MODE( ) /* end: required for Cortex-R5 MPU port - generated by TI HALCoGen - see src/os/freertos/README.ti-halcogen.md for details */ /*-----------------------------------------------------------*/ @@ -372,9 +374,22 @@ char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* FREERTOS_SYSTEM_CALL */ /*-----------------------------------------------------------*/ #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) - uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */ + configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercent( void ) /* FREERTOS_SYSTEM_CALL */ + { + configRUN_TIME_COUNTER_TYPE xReturn; + BaseType_t xRunningPrivileged = xPortRaisePrivilege(); + + xReturn = ulTaskGetIdleRunTimePercent(); + vPortResetPrivilege( xRunningPrivileged ); + return xReturn; + } +#endif +/*-----------------------------------------------------------*/ + +#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) + configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */ { - uint32_t xReturn; + configRUN_TIME_COUNTER_TYPE xReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); xReturn = ulTaskGetIdleRunTimeCounter(); @@ -453,7 +468,7 @@ char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* FREERTOS_SYSTEM_CALL */ #if ( configUSE_TRACE_FACILITY == 1 ) UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * pxTaskStatusArray, UBaseType_t uxArraySize, - uint32_t * pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */ + configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */ { UBaseType_t uxReturn; BaseType_t xRunningPrivileged = xPortRaisePrivilege(); diff --git a/src/os/freertos/portable/memmang/heap_1.c b/src/os/freertos/portable/memmang/heap_1.c index 56446dd6..194d7e9c 100644 --- a/src/os/freertos/portable/memmang/heap_1.c +++ b/src/os/freertos/portable/memmang/heap_1.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/portable/memmang/heap_2.c b/src/os/freertos/portable/memmang/heap_2.c index 02795202..86c33981 100644 --- a/src/os/freertos/portable/memmang/heap_2.c +++ b/src/os/freertos/portable/memmang/heap_2.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/portable/memmang/heap_3.c b/src/os/freertos/portable/memmang/heap_3.c index 138002ca..c8d0b5d1 100644 --- a/src/os/freertos/portable/memmang/heap_3.c +++ b/src/os/freertos/portable/memmang/heap_3.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -22,7 +24,6 @@ * https://www.FreeRTOS.org * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ diff --git a/src/os/freertos/portable/memmang/heap_4.c b/src/os/freertos/portable/memmang/heap_4.c index 06e8419d..9d8bd3c9 100644 --- a/src/os/freertos/portable/memmang/heap_4.c +++ b/src/os/freertos/portable/memmang/heap_4.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in diff --git a/src/os/freertos/portable/memmang/heap_5.c b/src/os/freertos/portable/memmang/heap_5.c index eaea9704..0a7a285e 100644 --- a/src/os/freertos/portable/memmang/heap_5.c +++ b/src/os/freertos/portable/memmang/heap_5.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -45,8 +47,8 @@ * * typedef struct HeapRegion * { - * uint8_t *pucStartAddress; << Start address of a block of memory that will be part of the heap. - * size_t xSizeInBytes; << Size of the block of memory. + * uint8_t *pucStartAddress; << Start address of a block of memory that will be part of the heap. + * size_t xSizeInBytes; << Size of the block of memory. * } HeapRegion_t; * * The array is terminated using a NULL zero sized region definition, and the @@ -180,7 +182,7 @@ void * pvPortMalloc( size_t xWantedSize ) if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { - /* Traverse the list from the start (lowest address) block until + /* Traverse the list from the start (lowest address) block until * one of adequate size is found. */ pxPreviousBlock = &xStart; pxBlock = xStart.pxNextFreeBlock; diff --git a/src/os/freertos/queue.c b/src/os/freertos/queue.c index b8fcdaca..fd48681e 100644 --- a/src/os/freertos/queue.c +++ b/src/os/freertos/queue.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -264,31 +266,42 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) { + BaseType_t xReturn = pdPASS; Queue_t * const pxQueue = xQueue; configASSERT( pxQueue ); - taskENTER_CRITICAL(); + if( ( pxQueue != NULL ) && + ( pxQueue->uxLength >= 1U ) && + /* Check for multiplication overflow. */ + ( ( SIZE_MAX / pxQueue->uxLength ) >= pxQueue->uxItemSize ) ) { - pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ - pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; - pxQueue->pcWriteTo = pxQueue->pcHead; - pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ - pxQueue->cRxLock = queueUNLOCKED; - pxQueue->cTxLock = queueUNLOCKED; - - if( xNewQueue == pdFALSE ) + taskENTER_CRITICAL(); { - /* If there are tasks blocked waiting to read from the queue, then - * the tasks will remain blocked as after this function exits the queue - * will still be empty. If there are tasks blocked waiting to write to - * the queue, then one should be unblocked as after this function exits - * it will be possible to write to it. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; + pxQueue->pcWriteTo = pxQueue->pcHead; + pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + pxQueue->cRxLock = queueUNLOCKED; + pxQueue->cTxLock = queueUNLOCKED; + + if( xNewQueue == pdFALSE ) { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + /* If there are tasks blocked waiting to read from the queue, then + * the tasks will remain blocked as after this function exits the queue + * will still be empty. If there are tasks blocked waiting to write to + * the queue, then one should be unblocked as after this function exits + * it will be possible to write to it. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { - queueYIELD_IF_USING_PREEMPTION(); + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } else { @@ -297,21 +310,23 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { - mtCOVERAGE_TEST_MARKER(); + /* Ensure the event queues start in the correct state. */ + vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); + vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); } } - else - { - /* Ensure the event queues start in the correct state. */ - vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); - } + taskEXIT_CRITICAL(); } - taskEXIT_CRITICAL(); + else + { + xReturn = pdFAIL; + } + + configASSERT( xReturn != pdFAIL ); /* A value is returned for calling semantic consistency with previous * versions. */ - return pdPASS; + return xReturn; } /*-----------------------------------------------------------*/ @@ -323,37 +338,38 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, StaticQueue_t * pxStaticQueue, const uint8_t ucQueueType ) { - Queue_t * pxNewQueue; - - configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); + Queue_t * pxNewQueue = NULL; /* The StaticQueue_t structure and the queue storage area must be * supplied. */ - configASSERT( pxStaticQueue != NULL ); + configASSERT( pxStaticQueue ); - /* A queue storage area should be provided if the item size is not 0, and - * should not be provided if the item size is 0. */ - configASSERT( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ); - configASSERT( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ); + if( ( uxQueueLength > ( UBaseType_t ) 0 ) && + ( pxStaticQueue != NULL ) && - #if ( configASSERT_DEFINED == 1 ) - { - /* Sanity check that the size of the structure used to declare a - * variable of type StaticQueue_t or StaticSemaphore_t equals the size of - * the real queue and semaphore structures. */ - volatile size_t xSize = sizeof( StaticQueue_t ); - configASSERT( xSize == sizeof( Queue_t ) ); - ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ - } - #endif /* configASSERT_DEFINED */ + /* A queue storage area should be provided if the item size is not 0, and + * should not be provided if the item size is 0. */ + ( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ) && + ( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ) ) + { + #if ( configASSERT_DEFINED == 1 ) + { + /* Sanity check that the size of the structure used to declare a + * variable of type StaticQueue_t or StaticSemaphore_t equals the size of + * the real queue and semaphore structures. */ + volatile size_t xSize = sizeof( StaticQueue_t ); + + /* This assertion cannot be branch covered in unit tests */ + configASSERT( xSize == sizeof( Queue_t ) ); /* LCOV_EXCL_BR_LINE */ + ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ + } + #endif /* configASSERT_DEFINED */ - /* The address of a statically allocated queue was passed in, use it. - * The address of a statically allocated storage area was also passed in - * but is already set. */ - pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ + /* The address of a statically allocated queue was passed in, use it. + * The address of a statically allocated storage area was also passed in + * but is already set. */ + pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ - if( pxNewQueue != NULL ) - { #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) { /* Queues can be allocated wither statically or dynamically, so @@ -367,7 +383,7 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { - traceQUEUE_CREATE_FAILED( ucQueueType ); + configASSERT( pxNewQueue ); mtCOVERAGE_TEST_MARKER(); } @@ -383,55 +399,59 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) { - Queue_t * pxNewQueue; + Queue_t * pxNewQueue = NULL; size_t xQueueSizeInBytes; uint8_t * pucQueueStorage; - configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); - - /* Allocate enough space to hold the maximum number of items that - * can be in the queue at any time. It is valid for uxItemSize to be - * zero in the case the queue is used as a semaphore. */ - xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ - - /* Check for multiplication overflow. */ - configASSERT( ( uxItemSize == 0 ) || ( uxQueueLength == ( xQueueSizeInBytes / uxItemSize ) ) ); - - /* Check for addition overflow. */ - configASSERT( ( sizeof( Queue_t ) + xQueueSizeInBytes ) > xQueueSizeInBytes ); - - /* Allocate the queue and storage area. Justification for MISRA - * deviation as follows: pvPortMalloc() always ensures returned memory - * blocks are aligned per the requirements of the MCU stack. In this case - * pvPortMalloc() must return a pointer that is guaranteed to meet the - * alignment requirements of the Queue_t structure - which in this case - * is an int8_t *. Therefore, whenever the stack alignment requirements - * are greater than or equal to the pointer to char requirements the cast - * is safe. In other cases alignment requirements are not strict (one or - * two bytes). */ - pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); /*lint !e9087 !e9079 see comment above. */ - - if( pxNewQueue != NULL ) - { - /* Jump past the queue structure to find the location of the queue - * storage area. */ - pucQueueStorage = ( uint8_t * ) pxNewQueue; - pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ - - #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) - { - /* Queues can be created either statically or dynamically, so - * note this task was created dynamically in case it is later - * deleted. */ - pxNewQueue->ucStaticallyAllocated = pdFALSE; - } - #endif /* configSUPPORT_STATIC_ALLOCATION */ + if( ( uxQueueLength > ( UBaseType_t ) 0 ) && + /* Check for multiplication overflow. */ + ( ( SIZE_MAX / uxQueueLength ) >= uxItemSize ) && + /* Check for addition overflow. */ + ( ( SIZE_MAX - sizeof( Queue_t ) ) >= ( uxQueueLength * uxItemSize ) ) ) + { + /* Allocate enough space to hold the maximum number of items that + * can be in the queue at any time. It is valid for uxItemSize to be + * zero in the case the queue is used as a semaphore. */ + xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + + /* Allocate the queue and storage area. Justification for MISRA + * deviation as follows: pvPortMalloc() always ensures returned memory + * blocks are aligned per the requirements of the MCU stack. In this case + * pvPortMalloc() must return a pointer that is guaranteed to meet the + * alignment requirements of the Queue_t structure - which in this case + * is an int8_t *. Therefore, whenever the stack alignment requirements + * are greater than or equal to the pointer to char requirements the cast + * is safe. In other cases alignment requirements are not strict (one or + * two bytes). */ + pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes ); /*lint !e9087 !e9079 see comment above. */ + + if( pxNewQueue != NULL ) + { + /* Jump past the queue structure to find the location of the queue + * storage area. */ + pucQueueStorage = ( uint8_t * ) pxNewQueue; + pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + + #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + /* Queues can be created either statically or dynamically, so + * note this task was created dynamically in case it is later + * deleted. */ + pxNewQueue->ucStaticallyAllocated = pdFALSE; + } + #endif /* configSUPPORT_STATIC_ALLOCATION */ - prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); + prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); + } + else + { + traceQUEUE_CREATE_FAILED( ucQueueType ); + mtCOVERAGE_TEST_MARKER(); + } } else { - traceQUEUE_CREATE_FAILED( ucQueueType ); + configASSERT( pxNewQueue ); mtCOVERAGE_TEST_MARKER(); } @@ -561,6 +581,8 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, TaskHandle_t pxReturn; Queue_t * const pxSemaphore = ( Queue_t * ) xSemaphore; + configASSERT( xSemaphore ); + /* This function is called by xSemaphoreGetMutexHolder(), and should not * be called directly. Note: This is a good way of determining if the * calling task is the mutex holder, but not a good way of determining the @@ -715,22 +737,28 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseType_t uxInitialCount, StaticQueue_t * pxStaticQueue ) { - QueueHandle_t xHandle; - - configASSERT( uxMaxCount != 0 ); - configASSERT( uxInitialCount <= uxMaxCount ); - - xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); + QueueHandle_t xHandle = NULL; - if( xHandle != NULL ) + if( ( uxMaxCount != 0 ) && + ( uxInitialCount <= uxMaxCount ) ) { - ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + xHandle = xQueueGenericCreateStatic( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticQueue, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); - traceCREATE_COUNTING_SEMAPHORE(); + if( xHandle != NULL ) + { + ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + + traceCREATE_COUNTING_SEMAPHORE(); + } + else + { + traceCREATE_COUNTING_SEMAPHORE_FAILED(); + } } else { - traceCREATE_COUNTING_SEMAPHORE_FAILED(); + configASSERT( xHandle ); + mtCOVERAGE_TEST_MARKER(); } return xHandle; @@ -744,22 +772,28 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) { - QueueHandle_t xHandle; - - configASSERT( uxMaxCount != 0 ); - configASSERT( uxInitialCount <= uxMaxCount ); - - xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); + QueueHandle_t xHandle = NULL; - if( xHandle != NULL ) + if( ( uxMaxCount != 0 ) && + ( uxInitialCount <= uxMaxCount ) ) { - ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE ); - traceCREATE_COUNTING_SEMAPHORE(); + if( xHandle != NULL ) + { + ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount; + + traceCREATE_COUNTING_SEMAPHORE(); + } + else + { + traceCREATE_COUNTING_SEMAPHORE_FAILED(); + } } else { - traceCREATE_COUNTING_SEMAPHORE_FAILED(); + configASSERT( xHandle ); + mtCOVERAGE_TEST_MARKER(); } return xHandle; @@ -944,15 +978,15 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); /* Unlocking the queue means queue events can effect the - * event list. It is possible that interrupts occurring now + * event list. It is possible that interrupts occurring now * remove this task from the event list again - but as the * scheduler is suspended the task will go onto the pending - * ready last instead of the actual ready list. */ + * ready list instead of the actual ready list. */ prvUnlockQueue( pxQueue ); /* Resuming the scheduler will move tasks from the pending * ready list into the ready list - so it is feasible that this - * task is already in a ready list before it yields - in which + * task is already in the ready list before it yields - in which * case the yield will not cause a context switch unless there * is also a higher priority task in the pending ready list. */ if( xTaskResumeAll() == pdFALSE ) @@ -1774,7 +1808,7 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue, taskEXIT_CRITICAL(); /* Interrupts and other tasks can send to and receive from the queue - * now the critical section has been exited. */ + * now that the critical section has been exited. */ vTaskSuspendAll(); prvLockQueue( pxQueue ); @@ -2723,24 +2757,42 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) { UBaseType_t ux; - /* See if there is an empty space in the registry. A NULL name denotes - * a free slot. */ - for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) - { - if( xQueueRegistry[ ux ].pcQueueName == NULL ) - { - /* Store the information on this queue. */ - xQueueRegistry[ ux ].pcQueueName = pcQueueName; - xQueueRegistry[ ux ].xHandle = xQueue; + configASSERT( xQueue ); - traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ); - break; - } - else + QueueRegistryItem_t * pxEntryToWrite = NULL; + + if( pcQueueName != NULL ) + { + /* See if there is an empty space in the registry. A NULL name denotes + * a free slot. */ + for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) { - mtCOVERAGE_TEST_MARKER(); + /* Replace an existing entry if the queue is already in the registry. */ + if( xQueue == xQueueRegistry[ ux ].xHandle ) + { + pxEntryToWrite = &( xQueueRegistry[ ux ] ); + break; + } + /* Otherwise, store in the next empty location */ + else if( ( pxEntryToWrite == NULL ) && ( xQueueRegistry[ ux ].pcQueueName == NULL ) ) + { + pxEntryToWrite = &( xQueueRegistry[ ux ] ); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } } + + if( pxEntryToWrite != NULL ) + { + /* Store the information on this queue. */ + pxEntryToWrite->pcQueueName = pcQueueName; + pxEntryToWrite->xHandle = xQueue; + + traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ); + } } #endif /* configQUEUE_REGISTRY_SIZE */ @@ -2753,6 +2805,8 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) UBaseType_t ux; const char * pcReturn = NULL; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + configASSERT( xQueue ); + /* Note there is nothing here to protect against another task adding or * removing entries from the registry while it is being searched. */ @@ -2781,6 +2835,8 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) { UBaseType_t ux; + configASSERT( xQueue ); + /* See if the handle of the queue being unregistered in actually in the * registry. */ for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ ) @@ -2967,7 +3023,10 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) /* This function must be called form a critical section. */ - configASSERT( pxQueueSetContainer ); + /* The following line is not reachable in unit tests because every call + * to prvNotifyQueueSetContainer is preceded by a check that + * pxQueueSetContainer != NULL */ + configASSERT( pxQueueSetContainer ); /* LCOV_EXCL_BR_LINE */ configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ); if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ) diff --git a/src/os/freertos/stream_buffer.c b/src/os/freertos/stream_buffer.c index 33f551de..1262feee 100644 --- a/src/os/freertos/stream_buffer.c +++ b/src/os/freertos/stream_buffer.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -49,7 +51,7 @@ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */ /* If the user has not provided application specific Rx notification macros, - * or #defined the notification macros away, them provide default implementations + * or #defined the notification macros away, then provide default implementations * that uses task notifications. */ /*lint -save -e9026 Function like macros allowed and needed here so they can be overridden. */ #ifndef sbRECEIVE_COMPLETED @@ -159,14 +161,20 @@ typedef struct StreamBufferDef_t /*lint !e9058 Style convention static size_t prvBytesInBuffer( const StreamBuffer_t * const pxStreamBuffer ) PRIVILEGED_FUNCTION; /* - * Add xCount bytes from pucData into the pxStreamBuffer message buffer. - * Returns the number of bytes written, which will either equal xCount in the - * success case, or 0 if there was not enough space in the buffer (in which case - * no data is written into the buffer). + * Add xCount bytes from pucData into the pxStreamBuffer's data storage area. + * This function does not update the buffer's xHead pointer, so multiple writes + * may be chained together "atomically". This is useful for Message Buffers where + * the length and data bytes are written in two separate chunks, and we don't want + * the reader to see the buffer as having grown until after all data is copied over. + * This function takes a custom xHead value to indicate where to write to (necessary + * for chaining) and returns the the resulting xHead position. + * To mark the write as complete, manually set the buffer's xHead field with the + * returned xHead from this function. */ static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, const uint8_t * pucData, - size_t xCount ) PRIVILEGED_FUNCTION; + size_t xCount, + size_t xHead ) PRIVILEGED_FUNCTION; /* * If the stream buffer is being used as a message buffer, then reads an entire @@ -178,8 +186,7 @@ static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, static size_t prvReadMessageFromBuffer( StreamBuffer_t * pxStreamBuffer, void * pvRxData, size_t xBufferLengthBytes, - size_t xBytesAvailable, - size_t xBytesToStoreMessageLength ) PRIVILEGED_FUNCTION; + size_t xBytesAvailable ) PRIVILEGED_FUNCTION; /* * If the stream buffer is being used as a message buffer, then writes an entire @@ -195,13 +202,21 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer, size_t xRequiredSpace ) PRIVILEGED_FUNCTION; /* - * Read xMaxCount bytes from the pxStreamBuffer message buffer and write them - * to pucData. + * Copies xCount bytes from the pxStreamBuffer's data storage area to pucData. + * This function does not update the buffer's xTail pointer, so multiple reads + * may be chained together "atomically". This is useful for Message Buffers where + * the length and data bytes are read in two separate chunks, and we don't want + * the writer to see the buffer as having more free space until after all data is + * copied over, especially if we have to abort the read due to insufficient receiving space. + * This function takes a custom xTail value to indicate where to read from (necessary + * for chaining) and returns the the resulting xTail position. + * To mark the read as complete, manually set the buffer's xTail field with the + * returned xTail from this function. */ static size_t prvReadBytesFromBuffer( StreamBuffer_t * pxStreamBuffer, uint8_t * pucData, - size_t xMaxCount, - size_t xBytesAvailable ) PRIVILEGED_FUNCTION; + size_t xCount, + size_t xTail ) PRIVILEGED_FUNCTION; /* * Called by both pxStreamBufferCreate() and pxStreamBufferCreateStatic() to @@ -465,7 +480,7 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, /* The trigger level is the number of bytes that must be in the stream * buffer before a task that is waiting for data is unblocked. */ - if( xTriggerLevel <= pxStreamBuffer->xLength ) + if( xTriggerLevel < pxStreamBuffer->xLength ) { pxStreamBuffer->xTriggerLevelBytes = xTriggerLevel; xReturn = pdPASS; @@ -483,11 +498,20 @@ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) { const StreamBuffer_t * const pxStreamBuffer = xStreamBuffer; size_t xSpace; + size_t xOriginalTail; configASSERT( pxStreamBuffer ); - xSpace = pxStreamBuffer->xLength + pxStreamBuffer->xTail; - xSpace -= pxStreamBuffer->xHead; + /* The code below reads xTail and then xHead. This is safe if the stream + * buffer is updated once between the two reads - but not if the stream buffer + * is updated more than once between the two reads - hence the loop. */ + do + { + xOriginalTail = pxStreamBuffer->xTail; + xSpace = pxStreamBuffer->xLength + pxStreamBuffer->xTail; + xSpace -= pxStreamBuffer->xHead; + } while( xOriginalTail != pxStreamBuffer->xTail ); + xSpace -= ( size_t ) 1; if( xSpace >= pxStreamBuffer->xLength ) @@ -524,14 +548,15 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, size_t xReturn, xSpace = 0; size_t xRequiredSpace = xDataLengthBytes; TimeOut_t xTimeOut; - - /* The maximum amount of space a stream buffer will ever report is its length - * minus 1. */ - const size_t xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1; + size_t xMaxReportedSpace = 0; configASSERT( pvTxData ); configASSERT( pxStreamBuffer ); + /* The maximum amount of space a stream buffer will ever report is its length + * minus 1. */ + xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1; + /* This send function is used to write to both message buffers and stream * buffers. If this is a message buffer then the space needed must be * increased by the amount of bytes needed to store the length of the @@ -702,49 +727,40 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer, size_t xSpace, size_t xRequiredSpace ) { - BaseType_t xShouldWrite; - size_t xReturn; + size_t xNextHead = pxStreamBuffer->xHead; - if( xSpace == ( size_t ) 0 ) + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) { - /* Doesn't matter if this is a stream buffer or a message buffer, there - * is no space to write. */ - xShouldWrite = pdFALSE; + /* This is a message buffer, as opposed to a stream buffer. */ + + if( xSpace >= xRequiredSpace ) + { + /* There is enough space to write both the message length and the message + * itself into the buffer. Start by writing the length of the data, the data + * itself will be written later in this function. */ + xNextHead = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xDataLengthBytes ), sbBYTES_TO_STORE_MESSAGE_LENGTH, xNextHead ); + } + else + { + /* Not enough space, so do not write data to the buffer. */ + xDataLengthBytes = 0; + } } - else if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) == ( uint8_t ) 0 ) + else { /* This is a stream buffer, as opposed to a message buffer, so writing a - * stream of bytes rather than discrete messages. Write as many bytes as - * possible. */ - xShouldWrite = pdTRUE; + * stream of bytes rather than discrete messages. Plan to write as many + * bytes as possible. */ xDataLengthBytes = configMIN( xDataLengthBytes, xSpace ); } - else if( xSpace >= xRequiredSpace ) - { - /* This is a message buffer, as opposed to a stream buffer, and there - * is enough space to write both the message length and the message itself - * into the buffer. Start by writing the length of the data, the data - * itself will be written later in this function. */ - xShouldWrite = pdTRUE; - ( void ) prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) &( xDataLengthBytes ), sbBYTES_TO_STORE_MESSAGE_LENGTH ); - } - else - { - /* There is space available, but not enough space. */ - xShouldWrite = pdFALSE; - } - if( xShouldWrite != pdFALSE ) - { - /* Writes the data itself. */ - xReturn = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) pvTxData, xDataLengthBytes ); /*lint !e9079 Storage buffer is implemented as uint8_t for ease of sizing, alignment and access. */ - } - else + if( xDataLengthBytes != ( size_t ) 0 ) { - xReturn = 0; + /* Write the data to the buffer. */ + pxStreamBuffer->xHead = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) pvTxData, xDataLengthBytes, xNextHead ); /*lint !e9079 Storage buffer is implemented as uint8_t for ease of sizing, alignment and access. */ } - return xReturn; + return xDataLengthBytes; } /*-----------------------------------------------------------*/ @@ -829,7 +845,7 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, * read bytes from the buffer. */ if( xBytesAvailable > xBytesToStoreMessageLength ) { - xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength ); + xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable ); /* Was a task waiting for space in the buffer? */ if( xReceivedLength != ( size_t ) 0 ) @@ -855,7 +871,7 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) { StreamBuffer_t * const pxStreamBuffer = xStreamBuffer; - size_t xReturn, xBytesAvailable, xOriginalTail; + size_t xReturn, xBytesAvailable; configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn; configASSERT( pxStreamBuffer ); @@ -869,14 +885,9 @@ size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) { /* The number of bytes available is greater than the number of bytes * required to hold the length of the next message, so another message - * is available. Return its length without removing the length bytes - * from the buffer. A copy of the tail is stored so the buffer can be - * returned to its prior state as the message is not actually being - * removed from the buffer. */ - xOriginalTail = pxStreamBuffer->xTail; - ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable ); + * is available. */ + ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, pxStreamBuffer->xTail ); xReturn = ( size_t ) xTempReturn; - pxStreamBuffer->xTail = xOriginalTail; } else { @@ -931,7 +942,7 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, * read bytes from the buffer. */ if( xBytesAvailable > xBytesToStoreMessageLength ) { - xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable, xBytesToStoreMessageLength ); + xReceivedLength = prvReadMessageFromBuffer( pxStreamBuffer, pvRxData, xBufferLengthBytes, xBytesAvailable ); /* Was a task waiting for space in the buffer? */ if( xReceivedLength != ( size_t ) 0 ) @@ -957,34 +968,28 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, static size_t prvReadMessageFromBuffer( StreamBuffer_t * pxStreamBuffer, void * pvRxData, size_t xBufferLengthBytes, - size_t xBytesAvailable, - size_t xBytesToStoreMessageLength ) + size_t xBytesAvailable ) { - size_t xOriginalTail, xReceivedLength, xNextMessageLength; + size_t xCount, xNextMessageLength; configMESSAGE_BUFFER_LENGTH_TYPE xTempNextMessageLength; + size_t xNextTail = pxStreamBuffer->xTail; - if( xBytesToStoreMessageLength != ( size_t ) 0 ) + if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) { /* A discrete message is being received. First receive the length - * of the message. A copy of the tail is stored so the buffer can be - * returned to its prior state if the length of the message is too - * large for the provided buffer. */ - xOriginalTail = pxStreamBuffer->xTail; - ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable ); + * of the message. */ + xNextTail = prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempNextMessageLength, sbBYTES_TO_STORE_MESSAGE_LENGTH, xNextTail ); xNextMessageLength = ( size_t ) xTempNextMessageLength; /* Reduce the number of bytes available by the number of bytes just * read out. */ - xBytesAvailable -= xBytesToStoreMessageLength; + xBytesAvailable -= sbBYTES_TO_STORE_MESSAGE_LENGTH; /* Check there is enough space in the buffer provided by the * user. */ if( xNextMessageLength > xBufferLengthBytes ) { - /* The user has provided insufficient space to read the message - * so return the buffer to its previous state (so the length of - * the message is in the buffer again). */ - pxStreamBuffer->xTail = xOriginalTail; + /* The user has provided insufficient space to read the message. */ xNextMessageLength = 0; } else @@ -999,10 +1004,16 @@ static size_t prvReadMessageFromBuffer( StreamBuffer_t * pxStreamBuffer, xNextMessageLength = xBufferLengthBytes; } - /* Read the actual data. */ - xReceivedLength = prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) pvRxData, xNextMessageLength, xBytesAvailable ); /*lint !e9079 Data storage area is implemented as uint8_t array for ease of sizing, indexing and alignment. */ + /* Use the minimum of the wanted bytes and the available bytes. */ + xCount = configMIN( xNextMessageLength, xBytesAvailable ); - return xReceivedLength; + if( xCount != ( size_t ) 0 ) + { + /* Read the actual data and update the tail to mark the data as officially consumed. */ + pxStreamBuffer->xTail = prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) pvRxData, xCount, xNextTail ); /*lint !e9079 Data storage area is implemented as uint8_t array for ease of sizing, indexing and alignment. */ + } + + return xCount; } /*-----------------------------------------------------------*/ @@ -1129,22 +1140,21 @@ BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuf static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, const uint8_t * pucData, - size_t xCount ) + size_t xCount, + size_t xHead ) { - size_t xNextHead, xFirstLength; + size_t xFirstLength; configASSERT( xCount > ( size_t ) 0 ); - xNextHead = pxStreamBuffer->xHead; - /* Calculate the number of bytes that can be added in the first write - * which may be less than the total number of bytes that need to be added if * the buffer will wrap back to the beginning. */ - xFirstLength = configMIN( pxStreamBuffer->xLength - xNextHead, xCount ); + xFirstLength = configMIN( pxStreamBuffer->xLength - xHead, xCount ); /* Write as many bytes as can be written in the first write. */ - configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength ); - ( void ) memcpy( ( void * ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */ + configASSERT( ( xHead + xFirstLength ) <= pxStreamBuffer->xLength ); + ( void ) memcpy( ( void * ) ( &( pxStreamBuffer->pucBuffer[ xHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */ /* If the number of bytes written was less than the number that could be * written in the first write... */ @@ -1159,78 +1169,62 @@ static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, mtCOVERAGE_TEST_MARKER(); } - xNextHead += xCount; + xHead += xCount; - if( xNextHead >= pxStreamBuffer->xLength ) + if( xHead >= pxStreamBuffer->xLength ) { - xNextHead -= pxStreamBuffer->xLength; + xHead -= pxStreamBuffer->xLength; } else { mtCOVERAGE_TEST_MARKER(); } - pxStreamBuffer->xHead = xNextHead; - - return xCount; + return xHead; } /*-----------------------------------------------------------*/ static size_t prvReadBytesFromBuffer( StreamBuffer_t * pxStreamBuffer, uint8_t * pucData, - size_t xMaxCount, - size_t xBytesAvailable ) + size_t xCount, + size_t xTail ) { - size_t xCount, xFirstLength, xNextTail; - - /* Use the minimum of the wanted bytes and the available bytes. */ - xCount = configMIN( xBytesAvailable, xMaxCount ); - - if( xCount > ( size_t ) 0 ) - { - xNextTail = pxStreamBuffer->xTail; - - /* Calculate the number of bytes that can be read - which may be - * less than the number wanted if the data wraps around to the start of - * the buffer. */ - xFirstLength = configMIN( pxStreamBuffer->xLength - xNextTail, xCount ); - - /* Obtain the number of bytes it is possible to obtain in the first - * read. Asserts check bounds of read and write. */ - configASSERT( xFirstLength <= xMaxCount ); - configASSERT( ( xNextTail + xFirstLength ) <= pxStreamBuffer->xLength ); - ( void ) memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xNextTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */ + size_t xFirstLength; - /* If the total number of wanted bytes is greater than the number - * that could be read in the first read... */ - if( xCount > xFirstLength ) - { - /*...then read the remaining bytes from the start of the buffer. */ - configASSERT( xCount <= xMaxCount ); - ( void ) memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */ - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + configASSERT( xCount != ( size_t ) 0 ); - /* Move the tail pointer to effectively remove the data read from - * the buffer. */ - xNextTail += xCount; + /* Calculate the number of bytes that can be read - which may be + * less than the number wanted if the data wraps around to the start of + * the buffer. */ + xFirstLength = configMIN( pxStreamBuffer->xLength - xTail, xCount ); - if( xNextTail >= pxStreamBuffer->xLength ) - { - xNextTail -= pxStreamBuffer->xLength; - } + /* Obtain the number of bytes it is possible to obtain in the first + * read. Asserts check bounds of read and write. */ + configASSERT( xFirstLength <= xCount ); + configASSERT( ( xTail + xFirstLength ) <= pxStreamBuffer->xLength ); + ( void ) memcpy( ( void * ) pucData, ( const void * ) &( pxStreamBuffer->pucBuffer[ xTail ] ), xFirstLength ); /*lint !e9087 memcpy() requires void *. */ - pxStreamBuffer->xTail = xNextTail; + /* If the total number of wanted bytes is greater than the number + * that could be read in the first read... */ + if( xCount > xFirstLength ) + { + /* ...then read the remaining bytes from the start of the buffer. */ + ( void ) memcpy( ( void * ) &( pucData[ xFirstLength ] ), ( void * ) ( pxStreamBuffer->pucBuffer ), xCount - xFirstLength ); /*lint !e9087 memcpy() requires void *. */ } else { mtCOVERAGE_TEST_MARKER(); } - return xCount; + /* Move the tail pointer to effectively remove the data read from the buffer. */ + xTail += xCount; + + if( xTail >= pxStreamBuffer->xLength ) + { + xTail -= pxStreamBuffer->xLength; + } + + return xTail; } /*-----------------------------------------------------------*/ diff --git a/src/os/freertos/tasks.c b/src/os/freertos/tasks.c index d3280e0f..85f2b6ec 100644 --- a/src/os/freertos/tasks.c +++ b/src/os/freertos/tasks.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -76,7 +78,7 @@ */ #define tskSTACK_FILL_BYTE ( 0xa5U ) -/* Bits used to recored how a task's stack and TCB were allocated. */ +/* Bits used to record how a task's stack and TCB were allocated. */ #define tskDYNAMICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 0 ) #define tskSTATICALLY_ALLOCATED_STACK_ONLY ( ( uint8_t ) 1 ) #define tskSTATICALLY_ALLOCATED_STACK_AND_TCB ( ( uint8_t ) 2 ) @@ -100,8 +102,8 @@ #define tskSUSPENDED_CHAR ( 'S' ) /* - * Some kernel aware debuggers require the data the debugger needs access to be - * global, rather than file scope. + * Some kernel aware debuggers require the data the debugger needs access to to + * be global, rather than file scope. */ #ifdef portREMOVE_STATIC_QUALIFIER #define static @@ -219,12 +221,12 @@ #define prvAddTaskToReadyList( pxTCB ) \ traceMOVED_TASK_TO_READY_STATE( pxTCB ); \ taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \ - vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \ + listINSERT_END( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xStateListItem ) ); \ tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB ) /*-----------------------------------------------------------*/ /* - * Several functions take an TaskHandle_t parameter that can optionally be NULL, + * Several functions take a TaskHandle_t parameter that can optionally be NULL, * where NULL is used to indicate that the handle of the currently executing * task should be used in place of the parameter. This macro simply checks to * see if the parameter is NULL and returns a pointer to the appropriate TCB. @@ -291,7 +293,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to #endif #if ( configGENERATE_RUN_TIME_STATS == 1 ) - uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ + configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ #endif #if ( configUSE_NEWLIB_REENTRANT == 1 ) @@ -338,7 +340,7 @@ typedef tskTCB TCB_t; PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL; /* Lists for ready and blocked tasks. -------------------- - * xDelayedTaskList1 and xDelayedTaskList2 could be move to function scople but + * xDelayedTaskList1 and xDelayedTaskList2 could be moved to function scope but * doing so breaks some kernel aware debuggers and debuggers that rely on removing * the static qualifier. */ PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ]; /*< Prioritised ready tasks. */ @@ -398,8 +400,8 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t /* Do not move these variables to function scope as doing so prevents the * code working with debuggers that need to remove the static qualifier. */ - PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ - PRIVILEGED_DATA static volatile uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ + PRIVILEGED_DATA static configRUN_TIME_COUNTER_TYPE ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */ + PRIVILEGED_DATA static volatile configRUN_TIME_COUNTER_TYPE ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ #endif @@ -748,7 +750,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION; /* Allocate space for the stack used by the task being created. * The base of the stack memory stored in the TCB so the task can * be deleted later if required. */ - pxNewTCB->pxStack = ( StackType_t * ) pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ + pxNewTCB->pxStack = ( StackType_t * ) pvPortMallocStack( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ if( pxNewTCB->pxStack == NULL ) { @@ -763,7 +765,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION; StackType_t * pxStack; /* Allocate space for the stack used by the task being created. */ - pxStack = pvPortMalloc( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */ + pxStack = pvPortMallocStack( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ) ); /*lint !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack and this allocation is the stack. */ if( pxStack != NULL ) { @@ -779,7 +781,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION; { /* The stack cannot be used as the TCB was not created. Free * it again. */ - vPortFree( pxStack ); + vPortFreeStack( pxStack ); } } else @@ -913,8 +915,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, pxNewTCB->pcTaskName[ 0 ] = 0x00; } - /* This is used as an array index so must ensure it's not too large. First - * remove the privilege bit if one is present. */ + /* This is used as an array index so must ensure it's not too large. */ + configASSERT( uxPriority < configMAX_PRIORITIES ); + if( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) { uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U; @@ -957,7 +960,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode, #if ( configGENERATE_RUN_TIME_STATS == 1 ) { - pxNewTCB->ulRunTimeCounter = 0UL; + pxNewTCB->ulRunTimeCounter = ( configRUN_TIME_COUNTER_TYPE ) 0; } #endif /* configGENERATE_RUN_TIME_STATS */ @@ -1216,7 +1219,6 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) { --uxCurrentNumberOfTasks; traceTASK_DELETE( pxTCB ); - prvDeleteTCB( pxTCB ); /* Reset the next expected unblock time in case it referred to * the task that has just been deleted. */ @@ -1225,6 +1227,14 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) } taskEXIT_CRITICAL(); + /* If the task is not deleting itself, call prvDeleteTCB from outside of + * critical section. If a task deletes itself, prvDeleteTCB is called + * from prvCheckTasksWaitingTermination which is called from Idle task. */ + if( pxTCB != pxCurrentTCB ) + { + prvDeleteTCB( pxTCB ); + } + /* Force a reschedule if it is the currently running task that has just * been deleted. */ if( xSchedulerRunning != pdFALSE ) @@ -1544,7 +1554,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) UBaseType_t uxCurrentBasePriority, uxPriorityUsedOnEntry; BaseType_t xYieldRequired = pdFALSE; - configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) ); + configASSERT( uxNewPriority < configMAX_PRIORITIES ); /* Ensure the new priority is valid. */ if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) @@ -1660,7 +1670,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE ) { /* The task is currently in its ready list - remove before - * adding it to it's new ready list. As we are in a critical + * adding it to its new ready list. As we are in a critical * section we can do this even if the scheduler is suspended. */ if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) { @@ -2234,12 +2244,13 @@ BaseType_t xTaskResumeAll( void ) while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE ) { pxTCB = listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); - ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxTCB->xEventListItem ) ); + portMEMORY_BARRIER(); + listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); - /* If the moved task has a priority higher than the current - * task then a yield must be performed. */ + /* If the moved task has a priority higher than or equal to + * the current task then a yield must be performed. */ if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { xYieldPending = pdTRUE; @@ -2521,7 +2532,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, - uint32_t * const pulTotalRunTime ) + configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) { UBaseType_t uxTask = 0, uxQueue = configMAX_PRIORITIES; @@ -2694,8 +2705,8 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) #if ( configUSE_PREEMPTION == 1 ) { /* Preemption is on, but a context switch should only be - * performed if the unblocked task has a priority that is - * equal to or higher than the currently executing task. */ + * performed if the unblocked task has a priority that is + * higher than the currently executing task. */ if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) { /* Pend the yield to be performed when the scheduler @@ -2787,7 +2798,7 @@ BaseType_t xTaskIncrementTick( void ) * state - so record the item value in * xNextTaskUnblockTime. */ xNextTaskUnblockTime = xItemValue; - break; /*lint !e9011 Code structure here is deedmed easier to understand with multiple breaks. */ + break; /*lint !e9011 Code structure here is deemed easier to understand with multiple breaks. */ } else { @@ -2795,13 +2806,13 @@ BaseType_t xTaskIncrementTick( void ) } /* It is time to remove the item from the Blocked state. */ - ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); /* Is the task waiting on an event also? If so remove * it from the event list. */ if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL ) { - ( void ) uxListRemove( &( pxTCB->xEventListItem ) ); + listREMOVE_ITEM( &( pxTCB->xEventListItem ) ); } else { @@ -3093,8 +3104,15 @@ void vTaskPlaceOnEventList( List_t * const pxEventList, /* Place the event list item of the TCB in the appropriate event list. * This is placed in the list in priority order so the highest priority task - * is the first to be woken by the event. The queue that contains the event - * list is locked, preventing simultaneous access from interrupts. */ + * is the first to be woken by the event. + * + * Note: Lists are sorted in ascending order by ListItem_t.xItemValue. + * Normally, the xItemValue of a TCB's ListItem_t members is: + * xItemValue = ( configMAX_PRIORITIES - uxPriority ) + * Therefore, the event list is sorted in descending priority order. + * + * The queue that contains the event list is locked, preventing + * simultaneous access from interrupts. */ vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) ); prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); @@ -3121,7 +3139,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, * event group implementation - and interrupts don't access event groups * directly (instead they access them indirectly by pending function calls to * the task level). */ - vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); + listINSERT_END( pxEventList, &( pxCurrentTCB->xEventListItem ) ); prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE ); } @@ -3145,7 +3163,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, * In this case it is assume that this is the only task that is going to * be waiting on this event list, so the faster vListInsertEnd() function * can be used in place of vListInsert. */ - vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) ); + listINSERT_END( pxEventList, &( pxCurrentTCB->xEventListItem ) ); /* If the task should block indefinitely then set the block time to a * value that will be recognised as an indefinite delay inside the @@ -3182,11 +3200,11 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) * pxEventList is not empty. */ pxUnblockedTCB = listGET_OWNER_OF_HEAD_ENTRY( pxEventList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ configASSERT( pxUnblockedTCB ); - ( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) ); + listREMOVE_ITEM( &( pxUnblockedTCB->xEventListItem ) ); if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxUnblockedTCB->xStateListItem ) ); prvAddTaskToReadyList( pxUnblockedTCB ); #if ( configUSE_TICKLESS_IDLE != 0 ) @@ -3207,7 +3225,7 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) { /* The delayed and ready lists cannot be accessed, so hold this task * pending until the scheduler is resumed. */ - vListInsertEnd( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); + listINSERT_END( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) ); } if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) @@ -3246,7 +3264,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, * event flags. */ pxUnblockedTCB = listGET_LIST_ITEM_OWNER( pxEventListItem ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ configASSERT( pxUnblockedTCB ); - ( void ) uxListRemove( pxEventListItem ); + listREMOVE_ITEM( pxEventListItem ); #if ( configUSE_TICKLESS_IDLE != 0 ) { @@ -3265,7 +3283,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, /* Remove the task from the delayed list and add it to the ready list. The * scheduler is suspended so interrupts will not be accessing the ready * lists. */ - ( void ) uxListRemove( &( pxUnblockedTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxUnblockedTCB->xStateListItem ) ); prvAddTaskToReadyList( pxUnblockedTCB ); if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority ) @@ -3739,7 +3757,7 @@ static void prvCheckTasksWaitingTermination( void ) } #else { - pxTaskStatus->ulRunTimeCounter = 0; + pxTaskStatus->ulRunTimeCounter = ( configRUN_TIME_COUNTER_TYPE ) 0; } #endif @@ -3950,7 +3968,7 @@ static void prvCheckTasksWaitingTermination( void ) { /* The task can only have been allocated dynamically - free both * the stack and TCB. */ - vPortFree( pxTCB->pxStack ); + vPortFreeStack( pxTCB->pxStack ); vPortFree( pxTCB ); } #elif ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ @@ -3962,7 +3980,7 @@ static void prvCheckTasksWaitingTermination( void ) { /* Both the stack and TCB were allocated dynamically, so both * must be freed. */ - vPortFree( pxTCB->pxStack ); + vPortFreeStack( pxTCB->pxStack ); vPortFree( pxTCB ); } else if( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_ONLY ) @@ -4434,7 +4452,9 @@ static void prvResetNextTaskUnblockTime( void ) * * vTaskList() calls uxTaskGetSystemState(), then formats part of the * uxTaskGetSystemState() output into a human readable table that - * displays task names, states and stack usage. + * displays task: names, states, priority, stack usage and task number. + * Stack usage specified as the number of unused StackType_t words stack can hold + * on top of stack - not the number of bytes. * * vTaskList() has a dependency on the sprintf() C library function that * might bloat the code size, use a lot of stack, and provide different @@ -4527,7 +4547,7 @@ static void prvResetNextTaskUnblockTime( void ) { TaskStatus_t * pxTaskStatusArray; UBaseType_t uxArraySize, x; - uint32_t ulTotalTime, ulStatsAsPercentage; + configRUN_TIME_COUNTER_TYPE ulTotalTime, ulStatsAsPercentage; #if ( configUSE_TRACE_FACILITY != 1 ) { @@ -4588,7 +4608,7 @@ static void prvResetNextTaskUnblockTime( void ) { /* What percentage of the total run time has the task used? * This will always be rounded down to the nearest integer. - * ulTotalRunTimeDiv100 has already been divided by 100. */ + * ulTotalRunTime has already been divided by 100. */ ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalTime; /* Write the task name to the string, padding with @@ -4914,7 +4934,7 @@ TickType_t uxTaskResetEventItemValue( void ) * notification then unblock it now. */ if( ucOriginalNotifyState == taskWAITING_NOTIFICATION ) { - ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); /* The task should not have been on an event list. */ @@ -5061,14 +5081,14 @@ TickType_t uxTaskResetEventItemValue( void ) if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); } else { /* The delayed and ready lists cannot be accessed, so hold * this task pending until the scheduler is resumed. */ - vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); + listINSERT_END( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); } if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) @@ -5152,14 +5172,14 @@ TickType_t uxTaskResetEventItemValue( void ) if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE ) { - ( void ) uxListRemove( &( pxTCB->xStateListItem ) ); + listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); } else { /* The delayed and ready lists cannot be accessed, so hold * this task pending until the scheduler is resumed. */ - vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); + listINSERT_END( &( xPendingReadyList ), &( pxTCB->xEventListItem ) ); } if( pxTCB->uxPriority > pxCurrentTCB->uxPriority ) @@ -5252,7 +5272,7 @@ TickType_t uxTaskResetEventItemValue( void ) #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) - uint32_t ulTaskGetIdleRunTimeCounter( void ) + configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void ) { return xIdleTaskHandle->ulRunTimeCounter; } @@ -5260,6 +5280,33 @@ TickType_t uxTaskResetEventItemValue( void ) #endif /*-----------------------------------------------------------*/ +#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) + + configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ) + { + configRUN_TIME_COUNTER_TYPE ulTotalTime, ulReturn; + + ulTotalTime = portGET_RUN_TIME_COUNTER_VALUE(); + + /* For percentage calculations. */ + ulTotalTime /= ( configRUN_TIME_COUNTER_TYPE ) 100; + + /* Avoid divide by zero errors. */ + if( ulTotalTime > ( configRUN_TIME_COUNTER_TYPE ) 0 ) + { + ulReturn = xIdleTaskHandle->ulRunTimeCounter / ulTotalTime; + } + else + { + ulReturn = 0; + } + + return ulReturn; + } + +#endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */ +/*-----------------------------------------------------------*/ + static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) { @@ -5295,7 +5342,7 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, /* Add the task to the suspended task list instead of a delayed task * list to ensure it is not woken by a timing event. It will block * indefinitely. */ - vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) ); + listINSERT_END( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) ); } else { diff --git a/src/os/freertos/timers.c b/src/os/freertos/timers.c index 62e48122..b09b237b 100644 --- a/src/os/freertos/timers.c +++ b/src/os/freertos/timers.c @@ -1,6 +1,8 @@ /* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * FreeRTOS Kernel V10.4.5 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -55,7 +57,8 @@ #if ( configUSE_TIMERS == 1 ) /* Misc definitions. */ - #define tmrNO_DELAY ( TickType_t ) 0U + #define tmrNO_DELAY ( ( TickType_t ) 0U ) + #define tmrMAX_TIME_BEFORE_OVERFLOW ( ( TickType_t ) -1 ) /* The name assigned to the timer service task. This can be overridden by * defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */ @@ -172,6 +175,15 @@ const TickType_t xTimeNow, const TickType_t xCommandTime ) PRIVILEGED_FUNCTION; +/* + * Reload the specified auto-reload timer. If the reloading is backlogged, + * clear the backlog, calling the callback for each additional reload. When + * this function returns, the next expiry time is after xTimeNow. + */ + static void prvReloadTimer( Timer_t * const pxTimer, + TickType_t xExpiredTime, + const TickType_t xTimeNow ) PRIVILEGED_FUNCTION; + /* * An active timer has reached its expire time. Reload the timer if it is an * auto-reload timer, then call its callback. @@ -350,27 +362,24 @@ /* 0 is not a valid value for xTimerPeriodInTicks. */ configASSERT( ( xTimerPeriodInTicks > 0 ) ); - if( pxNewTimer != NULL ) - { - /* Ensure the infrastructure used by the timer service task has been - * created/initialised. */ - prvCheckForValidListAndQueue(); - - /* Initialise the timer structure members using the function - * parameters. */ - pxNewTimer->pcTimerName = pcTimerName; - pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks; - pxNewTimer->pvTimerID = pvTimerID; - pxNewTimer->pxCallbackFunction = pxCallbackFunction; - vListInitialiseItem( &( pxNewTimer->xTimerListItem ) ); + /* Ensure the infrastructure used by the timer service task has been + * created/initialised. */ + prvCheckForValidListAndQueue(); - if( uxAutoReload != pdFALSE ) - { - pxNewTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD; - } + /* Initialise the timer structure members using the function + * parameters. */ + pxNewTimer->pcTimerName = pcTimerName; + pxNewTimer->xTimerPeriodInTicks = xTimerPeriodInTicks; + pxNewTimer->pvTimerID = pvTimerID; + pxNewTimer->pxCallbackFunction = pxCallbackFunction; + vListInitialiseItem( &( pxNewTimer->xTimerListItem ) ); - traceTIMER_CREATE( pxNewTimer ); + if( uxAutoReload != pdFALSE ) + { + pxNewTimer->ucStatus |= tmrSTATUS_IS_AUTORELOAD; } + + traceTIMER_CREATE( pxNewTimer ); } /*-----------------------------------------------------------*/ @@ -453,7 +462,7 @@ } else { - pxTimer->ucStatus &= ~tmrSTATUS_IS_AUTORELOAD; + pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_AUTORELOAD ); } } taskEXIT_CRITICAL(); @@ -505,45 +514,48 @@ } /*-----------------------------------------------------------*/ + static void prvReloadTimer( Timer_t * const pxTimer, + TickType_t xExpiredTime, + const TickType_t xTimeNow ) + { + /* Insert the timer into the appropriate list for the next expiry time. + * If the next expiry time has already passed, advance the expiry time, + * call the callback function, and try again. */ + while( prvInsertTimerInActiveList( pxTimer, ( xExpiredTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xExpiredTime ) != pdFALSE ) + { + /* Advance the expiry time. */ + xExpiredTime += pxTimer->xTimerPeriodInTicks; + + /* Call the timer callback. */ + traceTIMER_EXPIRED( pxTimer ); + pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); + } + } +/*-----------------------------------------------------------*/ + static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow ) { - BaseType_t xResult; Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ /* Remove the timer from the list of active timers. A check has already * been performed to ensure the list is not empty. */ ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); - traceTIMER_EXPIRED( pxTimer ); /* If the timer is an auto-reload timer then calculate the next * expiry time and re-insert the timer in the list of active timers. */ if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 ) { - /* The timer is inserted into a list using a time relative to anything - * other than the current time. It will therefore be inserted into the - * correct list relative to the time this task thinks it is now. */ - if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) != pdFALSE ) - { - /* The timer expired before it was added to the active timer - * list. Reload it now. */ - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + prvReloadTimer( pxTimer, xNextExpireTime, xTimeNow ); } else { - pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE; - mtCOVERAGE_TEST_MARKER(); + pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE ); } /* Call the timer callback. */ + traceTIMER_EXPIRED( pxTimer ); pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); } /*-----------------------------------------------------------*/ @@ -744,7 +756,7 @@ { DaemonTaskMessage_t xMessage; Timer_t * pxTimer; - BaseType_t xTimerListsWereSwitched, xResult; + BaseType_t xTimerListsWereSwitched; TickType_t xTimeNow; while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */ @@ -805,7 +817,6 @@ case tmrCOMMAND_START_FROM_ISR: case tmrCOMMAND_RESET: case tmrCOMMAND_RESET_FROM_ISR: - case tmrCOMMAND_START_DONT_TRACE: /* Start or restart a timer. */ pxTimer->ucStatus |= tmrSTATUS_IS_ACTIVE; @@ -813,19 +824,18 @@ { /* The timer expired before it was added to the active * timer list. Process it now. */ - pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); - traceTIMER_EXPIRED( pxTimer ); - if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 ) { - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; + prvReloadTimer( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow ); } else { - mtCOVERAGE_TEST_MARKER(); + pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE ); } + + /* Call the timer callback. */ + traceTIMER_EXPIRED( pxTimer ); + pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); } else { @@ -837,7 +847,7 @@ case tmrCOMMAND_STOP: case tmrCOMMAND_STOP_FROM_ISR: /* The timer has already been removed from the active list. */ - pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE; + pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE ); break; case tmrCOMMAND_CHANGE_PERIOD: @@ -867,7 +877,7 @@ } else { - pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE; + pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE ); } } #else /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ @@ -876,7 +886,7 @@ * could not have been dynamically allocated. So there is * no need to free the memory - just mark the timer as * "not active". */ - pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE; + pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE ); } #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ break; @@ -892,10 +902,8 @@ static void prvSwitchTimerLists( void ) { - TickType_t xNextExpireTime, xReloadTime; + TickType_t xNextExpireTime; List_t * pxTemp; - Timer_t * pxTimer; - BaseType_t xResult; /* The tick count has overflowed. The timer lists must be switched. * If there are any timers still referenced from the current timer list @@ -905,43 +913,10 @@ { xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); - /* Remove the timer from the list. */ - pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ - ( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); - traceTIMER_EXPIRED( pxTimer ); - - /* Execute its callback, then send a command to restart the timer if - * it is an auto-reload timer. It cannot be restarted here as the lists - * have not yet been switched. */ - pxTimer->pxCallbackFunction( ( TimerHandle_t ) pxTimer ); - - if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 ) - { - /* Calculate the reload value, and if the reload value results in - * the timer going into the same timer list then it has already expired - * and the timer should be re-inserted into the current list so it is - * processed again within this loop. Otherwise a command should be sent - * to restart the timer to ensure it is only inserted into a list after - * the lists have been swapped. */ - xReloadTime = ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ); - - if( xReloadTime > xNextExpireTime ) - { - listSET_LIST_ITEM_VALUE( &( pxTimer->xTimerListItem ), xReloadTime ); - listSET_LIST_ITEM_OWNER( &( pxTimer->xTimerListItem ), pxTimer ); - vListInsert( pxCurrentTimerList, &( pxTimer->xTimerListItem ) ); - } - else - { - xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY ); - configASSERT( xResult ); - ( void ) xResult; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } + /* Process the expired timer. For auto-reload timers, be careful to + * process only expirations that occur on the current list. Further + * expirations must wait until after the lists are switched. */ + prvProcessExpiredTimer( xNextExpireTime, tmrMAX_TIME_BEFORE_OVERFLOW ); } pxTemp = pxCurrentTimerList; diff --git a/src/os/freertos/wscript b/src/os/freertos/wscript index 023c7d81..fdfa3f6e 100644 --- a/src/os/freertos/wscript +++ b/src/os/freertos/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -60,13 +60,7 @@ def build(bld): os.path.join("portable", "ccs", "arm_cortex-r5", "portasm.asm"), os.path.join("portable", "common", "mpu_wrappers.c"), ] - includes = [ - "include", - os.path.join("portable", "ccs", "arm_cortex-r5"), - os.path.join("..", "..", "app", "main", "include"), - os.path.join("..", "..", "app", "task"), - os.path.join("..", "..", "app", "task", "config"), - ] + includes = ["include", os.path.join("portable", "ccs", "arm_cortex-r5")] target = f"{bld.env.APPNAME.lower()}-os" cflags = bld.env.CFLAGS_OS diff --git a/src/os/wscript b/src/os/wscript index 140516c2..55a14529 100644 --- a/src/os/wscript +++ b/src/os/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/src/wscript b/src/wscript index ebaa3759..e52c1aff 100644 --- a/src/wscript +++ b/src/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/axivion/.axivion.preinc b/tests/axivion/.axivion.preinc index 63349a2f..17aef3bb 100644 --- a/tests/axivion/.axivion.preinc +++ b/tests/axivion/.axivion.preinc @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/axivion/.gitignore b/tests/axivion/.gitignore index fb4311b1..09430a7e 100644 --- a/tests/axivion/.gitignore +++ b/tests/axivion/.gitignore @@ -1,3 +1,3 @@ -enable_id_output.json -races.txt -pdfs/ +**/enable_id_output.json +**/races.txt +**/pdfs/ diff --git a/tests/axivion/README.md b/tests/axivion/README.md index 08054e44..e6755c74 100644 --- a/tests/axivion/README.md +++ b/tests/axivion/README.md @@ -2,42 +2,54 @@ ## Directory Description - -- ``.axivion.preinc``, ``predefined_macros.txt`` and ``predefined_sizes.txt`` - describe compiler built-ins for the TI ARM CGT compiler for TMS570LC4357. -- ``architecture.gxl``, ``architecture.json`` and ``mapping.gxl`` describe the - software architecture of foxBMS 2. -- ``axivion_config.json``, ``cafeCC.config``, ``ci_config.json``, - ``rule_config_c.json``, ``rule_config_c.py`` provide project specific - settings. -- ``start_analysis.bat``, ``start_local_analysis.bat``, - ``start_local_analysis.sh``, ``start_local_dashserver.bat`` are helper - scripts to run axivion. Files here might need to be updated to your local - Axivion setup. -- ``wrapper_make_race_pdfs.bat`` wrapper script to simplify creating the - report. +- This directory contains the Axivion setup for the TI ARM CGT compiler for TI + TMS570LC4357 and the project architecture. + The Axivion setup is done in the following files: + - ``.axivion.preinc`` and ``compiler_config.json`` + describe compiler built-ins for the TI ARM CGT compiler for TMS570LC4357. + - ``architecture.gxl``, ``architecture_config.json`` and ``mapping.gxl`` + describe the software architecture of foxBMS 2. + - ``axivion_config.json``, ``ci_config.json``, ``compiler_config.json``, + ``rule_config_c.json``, ``rule_config_c.py`` provide project specific + settings. +- The subdirectory ``forbidden-violations`` contains a list of rules that shall + be followed, i.e., it is not possible to introduce source code, that creates + an Axivion warning/error for that type (``forbidden-violations.txt``). + A script is included to verify that such source code can not be introduced to + the default branch (``check_forbidden_violations.py``). +- The subdirectory ``scripts`` contains a set of helper scripts to + interact with Axivion or the output of an Axivion build. + See [scripts/README.md](scripts/README.md) for a detailed description. ``` -(repository-root) -└── tests - └── axivion - ├── .axivion.preinc - ├── .clang-format - ├── .gitignore - ├── architecture.gxl - ├── architecture.json - ├── axivion_config.json - ├── cafeCC.config - ├── ci_config.json - ├── mapping.gxl - ├── predefined_macros.txt - ├── predefined_sizes.txt - ├── README.md - ├── rule_config_c.json - ├── rule_config_c.py - ├── start_analysis.bat - ├── start_local_analysis.bat - ├── start_local_analysis.sh - ├── start_local_dashserver.bat - └── wrapper_make_race_pdfs.bat +(repository-root)/tests/axivion +│ .axivion.preinc +│ .clang-format +│ .gitignore +│ architecture.gxl +│ architecture_config.json +│ architecture_hierarchy_belongs_to_layout.gvl +│ axivion_config.json +│ ci_config.json +│ compiler_config.json +│ mapping.gxl +│ README.md +│ rule_config_c.json +│ rule_config_c.py +│ rule_config_names.json +│ rule_config_names.py +│ +├───forbidden-violations +│ check_forbidden_violations.py +│ forbidden-violations.txt +│ +└───scripts + ci_check_freshness_of_architecture_svg.py + dep_analysis.py + gravis_export_architecture_svg.py + start_analysis.bat + start_local_analysis.bat + start_local_analysis.sh + start_local_dashserver.bat + wrapper_make_race_pdfs.bat ``` diff --git a/tests/axivion/architecture.gxl b/tests/axivion/architecture.gxl index 28e8b3be..8024f6da 100644 --- a/tests/axivion/architecture.gxl +++ b/tests/axivion/architecture.gxl @@ -2,7 +2,7 @@ - + HAL @@ -11,7 +11,7 @@ ce57c8ae-5258-43b6-9961-b8eab70b4233 - + Driver @@ -20,7 +20,7 @@ 7834bbf9-71da-4cea-9104-67ecd2558f56 - + OS @@ -29,7 +29,7 @@ 73570489-fadd-4b30-b7a7-4640f5f844f8 - + Application @@ -38,7 +38,7 @@ 806c54d7-9be9-4760-afd3-8a0d8b62a609 - + Balancing @@ -47,7 +47,7 @@ 27d7a7c4-00ca-48b0-b107-688cdcaf71ef - + BMS @@ -56,7 +56,7 @@ 1d321303-9120-4897-a5a0-2397c1e7293a - + Plausibility @@ -65,7 +65,7 @@ f6e881ac-babd-463c-b6ec-348d990d4e76 - + SOX @@ -74,7 +74,7 @@ e7e42410-6388-46c2-807f-5ee60a251396 - + Engine @@ -83,7 +83,7 @@ 999b8969-10b6-4739-bd2c-f8e269f113a0 - + Main @@ -92,7 +92,7 @@ a3e03d08-3b41-4a56-9f03-103a52c90548 - + Database @@ -101,7 +101,7 @@ 3b5c26dc-b3a5-4423-a961-3f39dc0a5ed9 - + Diagnosis @@ -110,7 +110,7 @@ f19bedfe-54a4-4f01-a486-c94e529ced58 - + System @@ -119,7 +119,7 @@ 75fe3254-d162-432e-ae16-eaa70619f50f - + System Monitoring @@ -128,7 +128,7 @@ 3eff9945-c2ad-4073-bd82-dc7d5405452a - + CAN @@ -137,7 +137,7 @@ df9e1298-e967-4ee3-a903-55f1632284fc - + Analog Front-End @@ -146,7 +146,7 @@ 515b9069-5530-4897-9777-6af92794f278 - + Measurement @@ -155,7 +155,7 @@ 027cc519-176f-4c70-960c-6505ea5ddd1c - + Contactor @@ -164,7 +164,7 @@ 69d80159-eb51-4788-ad91-72171eef7461 - + ADC @@ -173,7 +173,7 @@ 8c5c9da5-b98b-4f3d-abc2-3c8d12fd96bc - + DMA @@ -182,7 +182,7 @@ 051a17d1-7a79-41f5-83a4-588da5d9eff2 - + FRAM @@ -191,7 +191,7 @@ 3823ea61-02b8-457c-b028-b1d5fbb9256e - + Interlock @@ -200,7 +200,7 @@ 2f24952b-2688-46c5-b9db-6b0b400f9312 - + IO @@ -209,7 +209,7 @@ ec782c10-d1d9-4c3a-966a-a6e755cc611d - + MCU @@ -218,7 +218,7 @@ b1a1861d-1d0e-4b8b-855e-d500c5fde734 - + SPI @@ -227,7 +227,7 @@ 01ccfcfe-7c45-4177-9508-f423ae8a5cd0 - + Temperature Sensors @@ -236,7 +236,7 @@ 3bf2fe9c-629b-41b6-a544-1afe67eb9daa - + Task Configuration @@ -245,7 +245,7 @@ 130d48ab-422a-42cf-a6a5-517ed0d81e12 - + OS Interface @@ -254,7 +254,7 @@ 608c1594-8d27-4812-89d8-8f0954583fd6 - + Task Setup @@ -263,7 +263,7 @@ 6d62c3ee-039e-4ad7-a231-4fce2b23a145 - + Common @@ -272,7 +272,7 @@ 57d0dee1-8103-40c2-9dc6-e4e6feb88b9e - + main @@ -281,7 +281,7 @@ 2f136d68-9615-4fe5-a2ac-b24e727d4452 - + core components @@ -290,7 +290,7 @@ 0b546284-b270-48d4-ba42-12b5921159ef - + version information @@ -299,7 +299,7 @@ f6f89ed6-60cb-46ee-9623-bbb2bf8182cd - + fassert @@ -308,7 +308,7 @@ 85311c57-46cb-4255-91aa-4cfb1b9d98fb - + Power Supply @@ -317,250 +317,253 @@ ee3eb6b6-d536-4c33-887b-e5130795c242 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + diff --git a/tests/axivion/architecture.json b/tests/axivion/architecture_config.json similarity index 89% rename from tests/axivion/architecture.json rename to tests/axivion/architecture_config.json index bd6f7660..8a4dbf24 100644 --- a/tests/axivion/architecture.json +++ b/tests/axivion/architecture_config.json @@ -24,5 +24,11 @@ } }, "_Format": "1.0", - "_Version": "trunk-r3870" + "_Version": "7.4.0", + "_VersionNum": [ + 7, + 4, + 0, + 9870 + ] } diff --git a/tests/axivion/axivion_config.json b/tests/axivion/axivion_config.json index 8aaac129..4c05d766 100644 --- a/tests/axivion/axivion_config.json +++ b/tests/axivion/axivion_config.json @@ -1,10 +1,12 @@ { "_Layers": [ + "compiler_config.json", "ci_config.json", - "architecture.json", + "architecture_config.json", "rule_config_c.py", "rule_config_c.json", "rule_config_names.py", - "rule_config_names.json" + "rule_config_names.json", + "rule_config_include_guard.py" ] } diff --git a/tests/axivion/cafeCC.config b/tests/axivion/cafeCC.config deleted file mode 100644 index a9c5e437..00000000 --- a/tests/axivion/cafeCC.config +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/axivion/ci_config.json b/tests/axivion/ci_config.json index 576913a7..48281976 100644 --- a/tests/axivion/ci_config.json +++ b/tests/axivion/ci_config.json @@ -38,6 +38,14 @@ "directory": "../..", "ir": "build/axivion/foxbms.elf", "name": "$(env:analysisProjectName=foxbms-2)" + }, + "Shadow": { + "_active": true, + "include_globbings": [ + "*.[ch]" + ], + "rootpath": "build/axivion/src/app/main", + "shadow_directory": "$(builtin:AXIVION_CONFDIR)/../../build/axivion/src/app/main" } }, "Results": { @@ -56,11 +64,11 @@ } }, "_Format": "1.0", - "_Version": "7.2.6", + "_Version": "7.4.0", "_VersionNum": [ 7, - 2, - 6, - 7576 + 4, + 0, + 9870 ] } diff --git a/tests/axivion/compiler_config.json b/tests/axivion/compiler_config.json new file mode 100644 index 00000000..fc30e047 --- /dev/null +++ b/tests/axivion/compiler_config.json @@ -0,0 +1,458 @@ +{ + "Project": { + "TIARMToolchain": { + "_active": true, + "file_extensions": { + "assembler": [ + ".asm" + ], + "c": [ + ".c", + ".h" + ], + "ignore": [ + ".cmd", + ".res" + ], + "library": [ + ".a", + ".lib" + ], + "object": ".obj" + }, + "language_c": { + "default_options": [ + "--unsigned_chars", + "--short_enums", + "--diag_suppress=1819" + ], + "emulated_compiler_version": 90000, + "features": { + "clang_feature_test_macros": true, + "variadic_macros": "enabled" + }, + "language_version": "C11", + "native_compiler": "C:\\ti\\ccs1100\\ccs\\tools\\compiler\\ti-cgt-arm_20.2.5.LTS\\bin\\armcl.exe", + "preprocessing": { + "predefined_macros": { + "_INLINE": "1", + "_OPTIMIZE_FOR_SPACE": "1", + "__32bis__": "1", + "__ARM_32BIT_STATE": "1", + "__ARM_ACLE": "200", + "__ARM_ARCH": "7", + "__ARM_ARCH_ISA_ARM": "1", + "__ARM_ARCH_ISA_THUMB": "2", + "__ARM_ARCH_PROFILE": "82", + "__ARM_BIG_ENDIAN": "1", + "__ARM_FEATURE_CLZ": "1", + "__ARM_FEATURE_DSP": "1", + "__ARM_FEATURE_LDREX": "15", + "__ARM_FEATURE_SAT": "1", + "__ARM_FEATURE_SIMD32": "1", + "__ARM_FEATURE_UNALIGNED": "1", + "__ARM_FP": "12", + "__ARM_FP16_ARGS": "1", + "__ARM_FP16_FORMAT_IEEE": "1", + "__ARM_PCS": "1", + "__ARM_PCS_VFP": "1", + "__ARM_SIZEOF_MINIMAL_ENUM": "1", + "__ARM_SIZEOF_WCHAR_T": "2", + "__BIG_ENDIAN__": "1", + "__CHAR_BIT__": "8", + "__COMPILER_VERSION__": "20002005", + "__EDG_VERSION__": "413", + "__ELF__": "1", + "__INT_MAX__": "2147483647", + "__LONG_LONG_MAX__": "9223372036854775807", + "__LONG_MAX__": "2147483647", + "__PRAGMA_REDEFINE_EXTNAME": "1", + "__PTRDIFF_T_TYPE__": "int", + "__SCHAR_MAX__": "127", + "__SHRT_MAX__": "32767", + "__SIZEOF_DOUBLE__": "8", + "__SIZEOF_FLOAT__": "4", + "__SIZEOF_INT__": "4", + "__SIZEOF_LONG_DOUBLE__": "8", + "__SIZEOF_LONG_LONG__": "8", + "__SIZEOF_LONG__": "4", + "__SIZEOF_PTRDIFF_T__": "4", + "__SIZEOF_SHORT__": "2", + "__SIZEOF_SIZE_T__": "4", + "__SIZEOF_WCHAR_T__": "2", + "__SIZEOF_WINT_T__": "2", + "__SIZE_T_TYPE__": "unsigned", + "__STDC_NO_THREADS__": "1", + "__TI_ARM_V7R4__": "1", + "__TI_ARM_V7R5__": "1", + "__TI_ARM_V7__": "1", + "__TI_ARM__": "1", + "__TI_C99_COMPLEX_ENABLED__": "1", + "__TI_COMPILER_VERSION_QUAL_ID__": "21103", + "__TI_COMPILER_VERSION_QUAL__": "QUAL_LETTER", + "__TI_COMPILER_VERSION__": "20002005", + "__TI_EABI_SUPPORT__": "1", + "__TI_EABI__": "1", + "__TI_GNU_ATTRIBUTE_SUPPORT__": "1", + "__TI_STRICT_ANSI_MODE__": "0", + "__TI_STRICT_FP_MODE__": "1", + "__TI_TMS470_V7R4__": "1", + "__TI_TMS470_V7R5__": "1", + "__TI_TMS470_V7__": "1", + "__TI_VFPV3D16_SUPPORT__": "1", + "__TI_VFP_SUPPORT__": "1", + "__TI_WCHAR_T_BITS__": "16", + "__TMS470__": "1", + "__WCHAR_T_TYPE__": "unsigned short", + "__big_endian__": "1", + "__eabi__": "1", + "__edg_front_end__": "1", + "__unsigned_chars__": "1" + }, + "sys_include_envvar": null, + "sys_include_path": [ + "C:\\ti\\ccs1100\\ccs\\tools\\compiler\\ti-cgt-arm_20.2.5.LTS\\include" + ] + } + }, + "language_c.command.#": "C:\\ti\\ccs1100\\ccs\\tools\\compiler\\ti-cgt-arm_20.2.5.LTS\\bin\\armcl.exe", + "language_c.info.#": "20.2.5\n", + "linker": { + "advanced": { + "ignore_input_files": { + "$(delta:+)": [ + "*.cmd" + ] + } + } + }, + "preincludes": { + "$(delta:+)": [ + ".axivion.preinc" + ], + "$(delta:-)": [ + "$(builtin:AXIVION_INSTALLDIR)\\profiles\\ti\\axivion_preinc.h" + ] + }, + "switches": { + "mapping": { + "$(delta:+)": { + "--abi": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--advice:performance": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--asm_directory": { + "action": "OutputDirectory", + "parameter_mode": "mandatory_space_or_equal" + }, + "--be32": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--cmd_file": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--code_state": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--compile_only": { + "action": "CompileMode", + "parameter_mode": "none" + }, + "--define": { + "action": "DefineMacro", + "parameter_mode": "mandatory_space_or_equal" + }, + "--diag_warning": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--diag_wrap": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--display_error_number": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--emit_warnings_as_errors": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--end-group": { + "action": "-larg --end_group", + "parameter_mode": "none" + }, + "--endian": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--enum_type=int": { + "action": "--no_short_enums", + "parameter_mode": "none" + }, + "--enum_type=packed": { + "action": "--short_enums", + "parameter_mode": "none" + }, + "--exceptions": { + "action": "-carg --exceptions --rtti", + "parameter_mode": "none" + }, + "--float_support": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--fp_mode": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--gen_cross_reference_listing": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--gen_func_info_listing": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--gen_preprocessor_listing": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--heap_size": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--include_path": { + "action": "IncludeDirectoryList", + "parameter_mode": "mandatory_space_or_equal" + }, + "--issue_remarks": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--library": { + "action": "LinkLibrary", + "parameter_mode": "mandatory_space_or_equal" + }, + "--neon": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--obj_directory": { + "action": "OutputDirectory", + "parameter_mode": "mandatory_space_or_equal" + }, + "--opt_for_speed": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--optimize_with_debug": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--output_file": { + "action": "OutputFile", + "parameter_mode": "mandatory_space_or_equal" + }, + "--plain_char=signed": { + "action": "--signed_chars", + "parameter_mode": "none" + }, + "--plain_char=unsigned": { + "action": "--unsigned_chars", + "parameter_mode": "none" + }, + "--preproc_dependency": { + "action": "DependencyFile", + "parameter_mode": "mandatory_space_or_equal" + }, + "--preproc_with_compile": { + "action": "CompileMode", + "parameter_mode": "none" + }, + "--ram_model": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--reread_libs": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--rom_model": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--run_linker": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--scan_libraries": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--search_path": { + "action": "LibraryDirectory", + "parameter_mode": "mandatory_space_or_equal" + }, + "--silicon_version": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--stack_size": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--start-group": { + "action": "-larg --start_group", + "parameter_mode": "none" + }, + "--strict_ansi": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--strict_compatibility": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--symdebug:dwarf": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--unaligned_access": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--undef_sym": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--unused_section_elimination": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--vcu_support": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--warn_sections": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "--wchar_t": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--xml_link_info": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "--zero_init": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_equal" + }, + "-@": { + "action": "CompilerResponseFile", + "parameter_mode": "mandatory_space_or_immediate" + }, + "-O": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_immediate" + }, + "-g": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "-i": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_immediate" + }, + "-me": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "-mv": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_immediate" + }, + "-o": { + "action": "IgnoreSwitch", + "parameter_mode": "mandatory_space_or_immediate" + }, + "-qq": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + }, + "-rtti": { + "action": "--rtti", + "parameter_mode": "none" + }, + "-with_ir_suffix;": { + "action": "WithIRSuffix", + "parameter_mode": "mandatory_immediate" + }, + "-z": { + "action": "IgnoreSwitch", + "parameter_mode": "none" + } + }, + "$(delta:-)": [] + }, + "passthrough_double_minus": true + }, + "types": { + "char_bits": 8, + "char_unsigned": true, + "double_type": { + "alignof": 8, + "sizeof": 8 + }, + "float_type": { + "alignof": 4, + "sizeof": 4 + }, + "int_type": { + "alignof": 4, + "sizeof": 4 + }, + "long_double_type": { + "alignof": 8, + "sizeof": 8 + }, + "long_long_type": { + "alignof": 8, + "sizeof": 8 + }, + "long_type": { + "alignof": 4, + "sizeof": 4 + }, + "pointer_type": { + "alignof": 4, + "sizeof": 4 + }, + "ptrdiff_t_type": "signed int", + "short_type": { + "alignof": 2, + "sizeof": 2 + }, + "size_t_type": "unsigned int", + "wchar_t_type": "unsigned short" + } + } + }, + "_Format": "1.0", + "_Version": "7.4.0", + "_VersionNum": [ + 7, + 4, + 0, + 9870 + ] +} diff --git a/tests/axivion/check_forbidden_violations.py b/tests/axivion/forbidden-violations/check_forbidden_violations.py similarity index 96% rename from tests/axivion/check_forbidden_violations.py rename to tests/axivion/forbidden-violations/check_forbidden_violations.py index bc8ed36c..f011f4b4 100644 --- a/tests/axivion/check_forbidden_violations.py +++ b/tests/axivion/forbidden-violations/check_forbidden_violations.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,9 +40,9 @@ """Simple script that searches for the names of 'eliminated' violations in codebase""" -import logging import argparse import json +import logging import sys @@ -65,7 +65,7 @@ def main(): "--file", dest="forbidden", action="store", - default="forbidden_violations.txt", + default="forbidden-violations.txt", help="List of forbidden rules (one rule per line)", ) parser.add_argument( @@ -89,6 +89,8 @@ def main(): lines = forbidden.readlines() lines = [rule.rstrip() for rule in lines] for rule in lines: + if not rule: + continue if not rule.lstrip().startswith("#"): forbidden_rules.append(rule) logging.info(f"loaded the following rules as forbidden: {forbidden_rules}") diff --git a/tests/axivion/forbidden_violations.txt b/tests/axivion/forbidden-violations/forbidden-violations.txt similarity index 59% rename from tests/axivion/forbidden_violations.txt rename to tests/axivion/forbidden-violations/forbidden-violations.txt index bba454b5..0e597eb0 100644 --- a/tests/axivion/forbidden_violations.txt +++ b/tests/axivion/forbidden-violations/forbidden-violations.txt @@ -1,6 +1,16 @@ # Add rule names that shall be forbidden line-by-line + +# Misra +MisraC2012-1.1 +#MisraC2012-1.2 MisraC2012-1.3 +#MisraC2012-2.1 +#MisraC2012-2.2 +#MisraC2012-2.3 +MisraC2012-2.4 +#MisraC2012-2.5 MisraC2012-2.6 +#MisraC2012-2.7 MisraC2012-3.1 MisraC2012-3.2 MisraC2012-4.1 @@ -8,6 +18,7 @@ MisraC2012-4.2 MisraC2012-5.1 MisraC2012-5.2 MisraC2012-5.3 +#MisraC2012-5.4 MisraC2012-5.5 MisraC2012-5.6 MisraC2012-5.7 @@ -16,37 +27,62 @@ MisraC2012-5.9 MisraC2012-6.1 MisraC2012-6.2 MisraC2012-7.1 +#MisraC2012-7.2 MisraC2012-7.3 MisraC2012-7.4 MisraC2012-8.1 MisraC2012-8.2 +MisraC2012-8.3 +#MisraC2012-8.4 +#MisraC2012-8.5 +#MisraC2012-8.6 +#MisraC2012-8.7 +#MisraC2012-8.8 +#MisraC2012-8.9 MisraC2012-8.10 MisraC2012-8.12 +#MisraC2012-8.13 MisraC2012-8.14 +#MisraC2012-9.1 MisraC2012-9.2 +#MisraC2012-9.3 MisraC2012-9.4 MisraC2012-9.5 +#MisraC2012-10.1 MisraC2012-10.2 MisraC2012-11.2 MisraC2012-11.3 +#MisraC2012-11.4 +#MisraC2012-11.5 MisraC2012-11.6 MisraC2012-11.7 +#MisraC2012-11.8 +#MisraC2012-11.9 MisraC2012-12.1 +#MisraC2012-12.2 MisraC2012-12.3 MisraC2012-12.4 MisraC2012-13.1 MisraC2012-13.2 MisraC2012-13.3 MisraC2012-13.4 +#MisraC2012-13.5 MisraC2012-13.6 MisraC2012-14.1 MisraC2012-14.2 +#MisraC2012-14.3 +#MisraC2012-14.4 MisraC2012-15.1 MisraC2012-15.2 MisraC2012-15.3 MisraC2012-15.4 +#MisraC2012-15.5 MisraC2012-15.6 +#MisraC2012-15.7 +#MisraC2012-16.1 MisraC2012-16.2 +#MisraC2012-16.3 +#MisraC2012-16.4 MisraC2012-16.5 MisraC2012-16.6 MisraC2012-16.7 @@ -56,9 +92,12 @@ MisraC2012-17.3 MisraC2012-17.4 MisraC2012-17.5 MisraC2012-17.6 +#MisraC2012-17.7 MisraC2012-17.8 +#MisraC2012-18.1 MisraC2012-18.2 MisraC2012-18.3 +#MisraC2012-18.4 MisraC2012-18.5 MisraC2012-18.6 MisraC2012-18.7 @@ -71,11 +110,16 @@ MisraC2012-20.3 MisraC2012-20.4 MisraC2012-20.5 MisraC2012-20.6 +MisraC2012-20.7 MisraC2012-20.8 +MisraC2012-20.9 +#MisraC2012-20.10 MisraC2012-20.11 MisraC2012-20.12 MisraC2012-20.13 MisraC2012-20.14 +#MisraC2012-21.1 +#MisraC2012-21.2 MisraC2012-21.3 MisraC2012-21.4 MisraC2012-21.5 @@ -92,3 +136,21 @@ MisraC2012-22.3 MisraC2012-22.4 MisraC2012-22.5 MisraC2012-22.6 + +# Generic +Generic-IncludeKind +Generic-NoConstOnLHS +Generic-NoUnsafeMacro + +# CertC +CertC-PRE31 + +# Style +CodingStyle-FilenameNaming +CodingStyle-FileExtensionNaming +#CodingStyle-MaximumLineLength +CodingStyle-MaxOneStmtPerLine +CodingStyle-NoBlankLinesAtBraces +CodingStyle-NoSingleCharIdentifier +CodingStyle-NoTabs +CodingStyle-NoTrailingWhitespace diff --git a/tests/axivion/predefined_macros.txt b/tests/axivion/predefined_macros.txt deleted file mode 100644 index 1c27c1f5..00000000 --- a/tests/axivion/predefined_macros.txt +++ /dev/null @@ -1,137 +0,0 @@ -# EDG C/C++ predefined macro definition file. -# -# based on ti-cgt-arm_20.2.4.LTS -# generated by copying the content from "predefined defines" step when -# configuring the project -# -# C compiler information -# command: C:\ti\ccs1031\ccs\tools\compiler\ti-cgt-arm_20.2.4.LTS\bin\armcl.exe -version -# out: TI ARM C/C++ Compiler v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# -# TI ARM EABI C/C++ Parser v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM C/C++ File Merge v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM C/C++ Optimizer v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM G3 C/C++ Codegen v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Assembler v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Embed Utility v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM C Source Interlister v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Linker v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Absolute Lister v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Strip Utility v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM XREF Utility v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM C++ Demangler v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Hex Converter v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Name Utility v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Object File Display v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D -# TI ARM Archiver v20.2.4.LTS -# Build Number 1UM9J-2LI-RZASS-TAQ-C08D - -# Build information -# predefined_defines.c file content: -# int main() { -# return 0; -# } -# command: C:\ti\ccs1031\ccs\tools\compiler\ti-cgt-arm_20.2.4.LTS\bin\armcl.exe -# --silicon_version=7R5 -# --code_state=32 -# --float_support=VFPv3D16 -g -# --diag_wrap=off -# --display_error_number -# --enum_type=packed -# --abi=eabi -# --c11 -# --preproc_macros -# --compile_only -# --obj_directory=. -# --output_file=predefined_defines.obj -# predefined_defines.c - -all no __32bis__ 1 -all no __ARM_32BIT_STATE 1 -all no __ARM_ACLE 200 -all no __ARM_ARCH 7 -all no __ARM_ARCH_ISA_ARM 1 -all no __ARM_ARCH_ISA_THUMB 2 -all no __ARM_ARCH_PROFILE 82 -all no __ARM_BIG_ENDIAN 1 -all no __ARM_FEATURE_CLZ 1 -all no __ARM_FEATURE_DSP 1 -all no __ARM_FEATURE_LDREX 15 -all no __ARM_FEATURE_SAT 1 -all no __ARM_FEATURE_SIMD32 1 -all no __ARM_FEATURE_UNALIGNED 1 -all no __ARM_FP 12 -all no __ARM_FP16_ARGS 1 -all no __ARM_FP16_FORMAT_IEEE 1 -all no __ARM_PCS 1 -all no __ARM_PCS_VFP 1 -all no __ARM_SIZEOF_MINIMAL_ENUM 1 -all no __ARM_SIZEOF_WCHAR_T 2 -all no __big_endian__ 1 -all no __BIG_ENDIAN__ 1 -all no __CHAR_BIT__ 8 -all no __COMPILER_VERSION__ 20002004 -all no __eabi__ 1 -all no __edg_front_end__ 1 -all no __EDG_VERSION__ 413 -all no __ELF__ 1 -all no __INT_MAX__ 2147483647 -all no __LONG_LONG_MAX__ 9223372036854775807 -all no __LONG_MAX__ 2147483647 -all no __PRAGMA_REDEFINE_EXTNAME 1 -all no __PTRDIFF_T_TYPE__ int -all no __SCHAR_MAX__ 127 -all no __SHRT_MAX__ 32767 -all no __SIZE_T_TYPE__ unsigned -all no __SIZEOF_DOUBLE__ 8 -all no __SIZEOF_FLOAT__ 4 -all no __SIZEOF_INT__ 4 -all no __SIZEOF_LONG__ 4 -all no __SIZEOF_LONG_DOUBLE__ 8 -all no __SIZEOF_LONG_LONG__ 8 -all no __SIZEOF_PTRDIFF_T__ 4 -all no __SIZEOF_SHORT__ 2 -all no __SIZEOF_SIZE_T__ 4 -all no __SIZEOF_WCHAR_T__ 2 -all no __SIZEOF_WINT_T__ 2 -all no __STDC_NO_THREADS__ 1 -all no __TI_ARM__ 1 -all no __TI_ARM_V7__ 1 -all no __TI_ARM_V7R4__ 1 -all no __TI_ARM_V7R5__ 1 -all no __TI_C99_COMPLEX_ENABLED__ 1 -all no __TI_COMPILER_VERSION__ 20002004 -all no __TI_COMPILER_VERSION_QUAL__ QUAL_LETTER -all no __TI_COMPILER_VERSION_QUAL_ID__ 20344 -all no __TI_EABI__ 1 -all no __TI_EABI_SUPPORT__ 1 -all no __TI_GNU_ATTRIBUTE_SUPPORT__ 1 -all no __TI_STRICT_ANSI_MODE__ 0 -all no __TI_STRICT_FP_MODE__ 1 -all no __TI_TMS470_V7__ 1 -all no __TI_TMS470_V7R4__ 1 -all no __TI_TMS470_V7R5__ 1 -all no __TI_VFP_SUPPORT__ 1 -all no __TI_VFPV3D16_SUPPORT__ 1 -all no __TI_WCHAR_T_BITS__ 16 -all no __TMS470__ 1 -all no __unsigned_chars__ 1 -all no __WCHAR_T_TYPE__ unsigned short -all no _OPTIMIZE_FOR_SPACE 1 -all no _INLINE 1 diff --git a/tests/axivion/predefined_sizes.txt b/tests/axivion/predefined_sizes.txt deleted file mode 100644 index 3dc3238a..00000000 --- a/tests/axivion/predefined_sizes.txt +++ /dev/null @@ -1,21 +0,0 @@ -[ti] -sizeof(char) = 1 -sizeof(short) = 2 -sizeof(int) = 4 -sizeof(long) = 4 -sizeof(long long) = 8 -sizeof(float) = 4 -sizeof(double) = 8 -sizeof(long double) = 8 - -alignof(short) = 2 -alignof(int) = 4 -alignof(long) = 4 -alignof(long long) = 8 -alignof(float) = 4 -alignof(double) = 8 -alignof(long double) = 8 - -wchar_t = unsigned short int -size_t = unsigned int -ptrdiff_t = int diff --git a/tests/axivion/rule_config_c.json b/tests/axivion/rule_config_c.json index 5b64e33b..7e80772f 100644 --- a/tests/axivion/rule_config_c.json +++ b/tests/axivion/rule_config_c.json @@ -7,12 +7,11 @@ "side_effects": { "effect_free_functions": [ "__curpc", - "MPU_xTaskGetTickCount", - "xPortRaisePrivilege" + "MPU_xTaskGetTickCount" ], "local_effect_functions": [ "FAS_ASSERT", - "fas_storeAssertLoc" + "FAS_StoreAssertLocation" ], "side_effect_functions": [ "FAS_DisableInterrupts", @@ -21,8 +20,10 @@ "fprintf", "fputs", "freopen", + "FSYS_RaisePrivilege", "printf", - "tmpfile" + "tmpfile", + "xPortRaisePrivilege" ] }, "types": { @@ -89,7 +90,10 @@ "Architecture-SaveRFG": { "_active": true }, - "AutosarC++17_03-A15.4.1": { + "CWE-Bad-Coding-Practices-562": { + "_active": true + }, + "CWE-Error-Conditions-617": { "_active": true }, "CWE-Pointer-Issues-467": { @@ -104,6 +108,12 @@ "FAS_ASSERT" ] }, + "CertC-DCL03": { + "_active": true + }, + "CertC-PRE31": { + "_active": true + }, "CloneDetection": { "_active": true, "no_sequences": true, @@ -119,11 +129,26 @@ "_active": false }, "CodingStyle-FileExtensionNaming": { + "_active": true, + "allowed_extensions": [ + ".asm", + ".c", + ".h" + ], "languages": [ - "C++", - "C++/CLI" + "C", + "Assembler" ] }, + "CodingStyle-FilenameNaming": { + "_active": true, + "allowed_charset": "a-z0-9\\-_", + "languages": [ + "C", + "Assembler" + ], + "show_charset": true + }, "CodingStyle-MaxOneStmtPerLine": { "_active": true, "ignore_stmts": [ @@ -132,6 +157,14 @@ "Switch_Case_Label" ] }, + "CodingStyle-MaximumLineLength": { + "_active": true, + "languages": [ + "C", + "Assembler" + ], + "maximum_length": 120 + }, "CodingStyle-Naming.Enum": { "_active": false, "naming_convention": "^[A-Z][A-Z0-9]*_e$" @@ -140,7 +173,7 @@ "_active": false }, "CodingStyle-Naming.Function": { - "_active": false + "_active": true }, "CodingStyle-Naming.GlobalVariable": { "_active": false @@ -217,6 +250,15 @@ "vApplicationStackOverflowHook" ] }, + "Externals-CStdLib.NoReturn": { + "functions": [ + "__assert_fail", + "_wassert", + "abort", + "exit", + "FAS_InfiniteLoop" + ] + }, "FaultDetection-BadEnumValue": { "_active": true }, @@ -234,7 +276,12 @@ "_active": true }, "FaultDetection-RemovableStatements": { - "_active": true + "_active": true, + "exclude_in_macros": { + "$(delta:+)": [ + "assert" + ] + } }, "FaultDetection-UninitializedVariable": { "_active": true @@ -264,6 +311,13 @@ "Generic-DuplicateIncludeGuard": { "_active": true }, + "Generic-FinalNewline": { + "_active": true, + "_copy_from": "Generic-NoCompilerWarnings", + "reported_severities": [ + "remark" + ] + }, "Generic-ForbiddenFunctions": { "_active": true }, @@ -345,6 +399,9 @@ "Generic-NoConstCasts": { "_active": true }, + "Generic-NoConstOnLHS": { + "_active": true + }, "Generic-NoConstOnRHS": { "_active": false }, @@ -1236,6 +1293,17 @@ "nested_critical_regions": false, "strict_priorities": true }, + "SameRoutine": { + "_active": true, + "entity": { + "group": 2, + "value": "ENTITY_AS_GLOBBING" + }, + "format": "\\s*AXIVION\\s+Routine\\s+([^:]*):\\s+([^:]*)(:.*)?", + "justification": { + "group": 3 + } + }, "SaveRFG": { "_active": true }, @@ -1250,11 +1318,11 @@ } }, "_Format": "1.0", - "_Version": "7.2.6", + "_Version": "7.4.0", "_VersionNum": [ 7, - 2, - 6, - 7576 + 4, + 0, + 9870 ] } diff --git a/tests/axivion/rule_config_c.py b/tests/axivion/rule_config_c.py index 2f112c70..15a36c05 100644 --- a/tests/axivion/rule_config_c.py +++ b/tests/axivion/rule_config_c.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -89,7 +89,7 @@ def disallow_unjustified_deviations(issue): """forbid suppressing without justification""" - if issue.disabled: + if issue.disabled: # TODO: see mail #9172 if not issue.justification: issue.disabled = False @@ -97,3 +97,7 @@ def disallow_unjustified_deviations(issue): for rule_name in analysis.get_active_rules(): if hasattr(analysis[rule_name], "justification_checker"): analysis[rule_name].justification_checker = disallow_unjustified_deviations + + +# force a single finale newline POSIX 3.206 +analysis["Generic-FinalNewline"].reported_messages = {1} diff --git a/tests/axivion/rule_config_include_guard.py b/tests/axivion/rule_config_include_guard.py new file mode 100644 index 00000000..73a77bf8 --- /dev/null +++ b/tests/axivion/rule_config_include_guard.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +"""foxBMS specific rules setting for Axivion analysis of include guards.""" + +from typing import Union +from pathlib import Path + +import axivion.config # pylint: disable=import-error +from bauhaus import ir # pylint: disable=import-error +from bauhaus import scanner # pylint: disable=import-error + +ANALYSIS = axivion.config.get_analysis() + + +def create_include_guard(file_name: str) -> str: + """Creates foxBMS project specific include guard""" + prefix = "FOXBMS__" + suffix = "_H_" + sanitized_file_name = "".join( + ch.upper() if ch.isalnum() else "_" for ch in file_name + ) + return prefix + sanitized_file_name + suffix + + +def check_include_guard( + node: ir.Node, + define: scanner.Token, # pylint: disable=unused-argument + macro: Union[str, None], +) -> bool: + """check that header file uses the correct include guard.""" + if node: + expected_include_guard = create_include_guard(Path(node.Name).stem) + if not expected_include_guard == macro: + return f"Expected include guard is '{expected_include_guard}', but found {macro}." + return None + + +RULE_NAME = "Generic-MissingIncludeGuard" +ANALYSIS[RULE_NAME].macro_name_restrictions.append((check_include_guard)) diff --git a/tests/axivion/rule_config_names.json b/tests/axivion/rule_config_names.json index a6de8896..a54a671f 100644 --- a/tests/axivion/rule_config_names.json +++ b/tests/axivion/rule_config_names.json @@ -2,12 +2,28 @@ "Analysis": { "CodingStyle-Naming.Function": { "_active": true, + "exceptions": [ + "__TI_auto_init", + "_c_int00", + "canMessageNotification", + "DllMain", + "dmaGroupANotification", + "ecapNotification", + "exit", + "main", + "spiNotification", + "vApplicationGetIdleTaskMemory", + "vApplicationIdleHook", + "WinMain", + "wmain", + "wWinMain" + ], "msg": { "non_compliant_name": { "text": "Function names shall use the naming convention (prefix.upper())_PascalCase." } }, - "naming_convention": "^[A-Z][A-Z0-9]{1,4}_([A-Z][a-z0-9]+)*[A-Z][a-z0-9]*$" + "naming_convention": "^[A-Z][A-Z0-9]{1,4}_([A-Z]([a-z]|[0-9]{1,}[A-Za-z]))[A-Za-z0-9_]{0,}" }, "CodingStyle-Naming.GlobalVariable": { "_active": true, @@ -40,6 +56,8 @@ "_active": true, "_copy_from": "CodingStyle-Naming.UserType", "apply_to_renaming_of_classes": false, + "apply_to_renaming_of_enums": true, + "apply_to_renaming_of_other_types": false, "apply_to_renaming_of_structs": false, "apply_to_renaming_of_unions": false, "msg": { @@ -49,11 +67,28 @@ }, "naming_convention": "^[A-Z][A-Z0-9]{1,4}_([A-Z0-9_]*)_e" }, + "CodingStyle-Naming.TypedefedFuncPtr": { + "_active": true, + "_copy_from": "CodingStyle-Naming.UserType", + "apply_to_renaming_of_classes": false, + "apply_to_renaming_of_enums": false, + "apply_to_renaming_of_other_types": true, + "apply_to_renaming_of_structs": false, + "apply_to_renaming_of_unions": false, + "msg": { + "non_compliant_name": { + "text": "Names of user-defined function ptr types shall use the naming convention (prefix.upper())_ALL_CAPS_f." + } + }, + "naming_convention": "^[A-Z][A-Z0-9]{1,4}_([A-Za-z0-9_]*)_f" + }, "CodingStyle-Naming.TypedefedStruct": { "_active": true, "_copy_from": "CodingStyle-Naming.UserType", "apply_to_renaming_of_classes": false, "apply_to_renaming_of_enums": false, + "apply_to_renaming_of_other_types": false, + "apply_to_renaming_of_structs": true, "apply_to_renaming_of_unions": false, "msg": { "non_compliant_name": { @@ -63,5 +98,12 @@ "naming_convention": "^[A-Z][A-Z0-9]{1,4}_([A-Z0-9_]*)_s" } }, - "_Format": "1.0" + "_Format": "1.0", + "_Version": "7.4.0", + "_VersionNum": [ + 7, + 4, + 0, + 9870 + ] } diff --git a/tests/axivion/rule_config_names.py b/tests/axivion/rule_config_names.py index d06f5d9a..e36093ce 100644 --- a/tests/axivion/rule_config_names.py +++ b/tests/axivion/rule_config_names.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,18 +40,25 @@ """foxBMS specific rules settings for Axivion analysis.""" -import pathlib import re import axivion.config # pylint: disable=import-error - from bauhaus import ir # pylint: disable=import-error from bauhaus import style # pylint: disable=import-error from bauhaus.ir.common.scanner import comments # pylint: disable=import-error - ANALYSIS = axivion.config.get_analysis() +VALID_FUNCTION_SUFFIXES = [ + "us", # microseconds + "perc", # percentage + "mV", # millivolt + "V", # volt + "mA", # milliampere + "A", # ampere + "t", # "typedef" +] + def get_rule_type_from_name(rule_name: str) -> str: """returns the rule in a nicer human readable format.""" @@ -75,7 +82,13 @@ class ModulePrefixLookup(style.WorkItem): # pylint: disable=too-many-nested-blocks def __init__(self, ir_graph, cached_comments): self._map = {} - for file_node in ir_graph.nodes_of_type(ir.Physical, "Primary_File"): + for file_node in ir_graph.nodes_of_type( + ir.Physical, + ( + "Primary_File", + "User_Include_File", + ), + ): for comment in cached_comments.get(file_node, ()): if not comment.at_beginning: break @@ -83,21 +96,6 @@ def __init__(self, ir_graph, cached_comments): if match: self._map[file_node] = match[1] break - header_mapping = [] - for user_file, prefix in self._map.items(): - user_stem = pathlib.Path(user_file.Full_Name).stem - for user_contents in user_file.Versions: - for include in user_contents.Sorted_Includes: - if include.is_of_type("Include_Declaration"): - # filter out irregular includes - included_file = include.Contents.enclosing_of_type( - "User_Include_File" - ) - if included_file: - # filter out all except user include files - if pathlib.Path(included_file.Full_Name).stem == user_stem: - header_mapping.append((included_file, prefix)) - self._map.update(header_mapping) def __contains__(self, item): return item in self._map @@ -108,14 +106,16 @@ def __getitem__(self, item): def containing_modules(node): """yields the file""" - nodes = node.Definitions - # if no definitions available, go for the declartions - if len(node.Definitions) == 0: - # use declarations if aviable, otherwise fallback - if len(node.Declarations): + if node.part() == ir.Logical: + nodes = node.Definitions + # if no definitions available, go for the declarations + if len(nodes) == 0: + # use declarations if available, otherwise fallback nodes = node.Declarations - else: - nodes = (node.Physical,) + if len(nodes) == 0: + nodes = (node.Physical,) + else: + nodes = (node,) for pir_node in nodes: if pir_node: @@ -146,10 +146,65 @@ def check_uppercase_prefix(node: ir.Node, module_prefixes: ModulePrefixLookup) - return True +def check_prefix_known(node: ir.Node, module_prefixes: ModulePrefixLookup) -> bool: + """check that a module prefix exists for the current node.""" + if node.Name: + for file in containing_modules(node): + if file in module_prefixes: + return True + return False + return True + + +def check_function_name(node: ir.Node, module_prefixes: ModulePrefixLookup) -> bool: + """Checks that a function name consists of PascalName base name and an + optional suffix that indicates the unit.""" + prefix = None + if node.Name: + for file in containing_modules(node): + if file in module_prefixes: + prefix = module_prefixes[file].upper() + "_" + if not prefix: # something went wrong + return False + + base_name = "" + if node.Name.startswith(prefix): + base_name = node.Name[len(prefix) :] + else: + return False + + base_name_splitted = base_name.split("_", maxsplit=1) + function_name = base_name_splitted[0] + try: + function_name_suffix = base_name_splitted[1] + except IndexError: + function_name_suffix = None + + idx = [] + for i, val in enumerate(function_name): + if val.isupper(): + idx.append(i) + + valid_pascal_case = True + for i in range(1, len(idx)): + # if the difference between two indexes is 1, we are not seeing PascalCase + if idx[i] - idx[i - 1] == 1: + valid_pascal_case = False + break + + valid_suffix = True + if function_name_suffix: + valid_suffix = False + if function_name_suffix in VALID_FUNCTION_SUFFIXES: + valid_suffix = True + return valid_pascal_case and valid_suffix + + #: list: List of things that MUST start with the upper-case module prefix upper_case = ( "CodingStyle-Naming.Function", "CodingStyle-Naming.Macro", + "CodingStyle-Naming.TypedefedFuncPtr", "CodingStyle-Naming.TypedefedEnum", "CodingStyle-Naming.TypedefedStruct", ) @@ -161,6 +216,13 @@ def check_uppercase_prefix(node: ir.Node, module_prefixes: ModulePrefixLookup) - f"Please use upper-case module prefix for {get_rule_type_from_name(name)}.", ) ) + ANALYSIS[name].additional_checks.append( + (check_prefix_known, "Unknown which module prefix to check.") + ) + +ANALYSIS["CodingStyle-Naming.Function"].additional_checks.append( + (check_function_name, "The function name is not PascalCase.") +) #: list: List of things that MUST start with the lower-case module prefix lower_case = ( @@ -174,3 +236,21 @@ def check_uppercase_prefix(node: ir.Node, module_prefixes: ModulePrefixLookup) - f"Please use lower-case module prefix for {get_rule_type_from_name(name)}.", ) ) + ANALYSIS[name].additional_checks.append( + (check_prefix_known, "Unknown which module prefix to check.") + ) + + +# Only check function pointers with rule CodingStyle-Naming.TypedefedFuncPtr +def is_function_pointer_type(type_node: ir.Node) -> bool: + """Filter function to only check function pointers""" + original_type = type_node.skip_typedefs(True) + if original_type.is_of_type("Pointer_Type"): + element_type = original_type.Pointed_To_Type.skip_typedefs(True) + return element_type.is_of_type("Routine_Type") + return False + + +ANALYSIS[ + "CodingStyle-Naming.TypedefedFuncPtr" +].filter_predicate = is_function_pointer_type diff --git a/tests/axivion/scripts/README.md b/tests/axivion/scripts/README.md new file mode 100644 index 00000000..d02b19eb --- /dev/null +++ b/tests/axivion/scripts/README.md @@ -0,0 +1,25 @@ +# Helper Scripts to Interact with Axivion Bauhaus Suite + +These are helper scripts for the interaction with the Axivion Bauhaus Suite +in the foxBMS 2 project +(The Axivion configuration is described in this [README.md](../README.md)). + +- ``scripts/start_analysis.bat``, ``scripts/start_local_analysis.bat``, +``scripts/start_local_dashserver.bat`` are helper scripts to run Axivion. +Files here might need to be updated to the local Axivion setup. +- ``gravis_export_architecture_svg.py`` is a startup script for ``gravis`` to + create a SVG of the architecture. + The script needs to be invoked by as follows: + ``` + gravis --script tests/axivion/scripts/gravis_export_architecture_svg.py + ``` +- ``scripts/ci_check_freshness_of_architecture_svg.py`` is used to check whether the + git timestamps of the architecture documentation and the rendered SVG are aligned, i.e., + one can not change the architecture without updating the architecture image + in the documentation. + The script needs to be invoked by as follows: + ``` + tools/utils/cmd/run-python-script.bat tests/axivion/scripts ci_check_freshness_of_architecture_svg.py + ``` +- ``scripts/wrapper_make_race_pdfs.bat`` wrapper script to simplify creating the +race condition report. diff --git a/tests/axivion/ci_check_freshness_of_architecture_svg.py b/tests/axivion/scripts/ci_check_freshness_of_architecture_svg.py similarity index 91% rename from tests/axivion/ci_check_freshness_of_architecture_svg.py rename to tests/axivion/scripts/ci_check_freshness_of_architecture_svg.py index 05e00666..cff14702 100644 --- a/tests/axivion/ci_check_freshness_of_architecture_svg.py +++ b/tests/axivion/scripts/ci_check_freshness_of_architecture_svg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -47,11 +47,12 @@ In order to fix a failure, check the documentation on how to update the architecture SVG. """ -import os -import logging import argparse import datetime +import logging +import os import sys +from pathlib import Path from git import Repo @@ -87,18 +88,28 @@ def main(): print("Searching for the file change dates.") - basepath = "" + script_dir = Path(__file__).parent + file_architecture = os.path.abspath( - os.path.join(basepath, "tests", "axivion", "architecture.gxl") + os.path.join( + script_dir, + "..", + "architecture.gxl", + ) ) file_layout = os.path.abspath( os.path.join( - basepath, "tests", "axivion", "architecture_hierarchy_belongs_to_layout.gvl" + script_dir, + "..", + "architecture_hierarchy_belongs_to_layout.gvl", ) ) file_output = os.path.abspath( os.path.join( - basepath, + script_dir, + "..", + "..", + "..", "docs", "software", "architecture", diff --git a/tests/axivion/scripts/dep_analysis.py b/tests/axivion/scripts/dep_analysis.py new file mode 100644 index 00000000..d1fc35a8 --- /dev/null +++ b/tests/axivion/scripts/dep_analysis.py @@ -0,0 +1,240 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +"""Generate a json file based on an RFG input file.""" + +import argparse +import json +import logging +import os +import sys +from pathlib import Path + +HAVE_GIT = False +try: + from git import Repo + from git.exc import InvalidGitRepositoryError + + HAVE_GIT = True +except ImportError: + pass + + +def get_git_root(path: str) -> str: + """helper function to find the repository root + + Args: + path (string): path of test_f_guidelines + + Returns: + root (string): root path of the git repository + """ + root = os.path.join(os.path.dirname(path), "..", "..", "..") + if HAVE_GIT: + try: + repo = Repo(path, search_parent_directories=True) + root = repo.git.rev_parse("--show-toplevel") + except InvalidGitRepositoryError: + pass + return root + + +ROOT = Path(get_git_root(os.path.realpath(__file__))) + + +def find_axivion(): + """Checks for Axivion Bauhaus installation.""" + axivion_scripts = "" + default_path = Path( + os.path.join( + os.environ.get( + "ProgramFiles(x86)", os.path.join("C:", "Program Files (x86)") + ), + "Bauhaus", + "lib", + "scripts", + ) + ) + if default_path.is_dir(): + axivion_scripts = default_path + else: + versioned_base_path = os.path.join("C:", os.sep, "Bauhaus") + all_installs = [] + if os.path.exists(versioned_base_path): + all_installs = os.listdir(versioned_base_path) + all_install_paths = [] + for i in all_installs: + all_install_paths.append(os.path.join(versioned_base_path, i)) + latest_version = "" + if all_install_paths: + latest_version = os.path.join(all_install_paths[-1], "lib", "scripts") + axivion_scripts = latest_version + return axivion_scripts + + +ax_install = find_axivion() +if not ax_install: + sys.exit("Could not find an Axivion installation.") + +sys.path.append(ax_install) +from bauhaus import rfg # pylint: disable=import-error,wrong-import-position + + +class RfgParsing: + """Helper class to parse the rfg file""" + + def __init__(self, rfg_graph) -> None: + self.rfg_graph = rfg_graph + self.graph_to_json = {} + + @staticmethod + def get_name(node): + """Returns the name of the source""" + try: + return node["Source.Name"] + except Exception: # pylint: disable=broad-except + return None + + @staticmethod + def get_sloc(elem): + """Returns the source code location""" + try: + return f"{elem['Source.Path']}{elem['Source.File']}:{elem['Source.Line']}" + except Exception: # pylint: disable=broad-except + return None + + def export_dependencies(self, ignore): + """Generates a dictionary based on the graph""" + for edge in self.rfg_graph.view("Code Facts").edges( + edge_matcher=lambda e: not e.is_of_subtype("Belongs_To") + ): + dependency_type = edge.edge_type().name() + entity_name = self.get_name(edge.target()) + entity_sloc = self.get_sloc(edge.target()) + usage_sloc = self.get_sloc(edge) + if ( + entity_name + and entity_sloc + and usage_sloc + and not os.path.isabs(entity_sloc) + ): + if "HL_" in entity_sloc or any(ext in usage_sloc for ext in ignore): + continue + if self.graph_to_json.get(entity_name, None): + self.graph_to_json[entity_name]["usage"].append(usage_sloc) + else: + self.graph_to_json[entity_name] = { + "entity": entity_name, + "type": dependency_type, + "impl": entity_sloc, + "usage": [usage_sloc], + } + + def save(self, out=Path("out.json")): + """Saves the json output to a file.""" + with open(out.resolve(), "w", encoding="utf-8") as outfile: + outfile.write(json.dumps(self.graph_to_json, indent=4, sort_keys=True)) + outfile.write("\n") + + +def main(): + """This script transforms some Axivion rfg information into a json file.""" + parser = argparse.ArgumentParser() + parser.add_argument( + "-i", + "--rfg-file", + dest="rfg_file", + action="store", + default=Path( + os.path.join( + os.environ["USERPROFILE"], + ".bauhaus", + "localbuild", + "projects", + "foxbms-2.rfg", + ) + ), + help="Axivion rfg file to analysed.", + ) + parser.add_argument( + "-o", + dest="out", + action="store", + default=Path(os.path.join(ROOT, "build", "axivion", "foxbms-2.rfg.json")), + help="Output file", + ) + parser.add_argument( + "--ignore-locs", + dest="ignore_locs", + default=[".axivion.preinc", "/os/", "HL_"], + nargs="+", + help="usage locs to be ignored", + ) + parser.add_argument( + "-v", + "--verbosity", + dest="verbosity", + action="count", + default=0, + help="set verbosity level", + ) + args = parser.parse_args() + + if args.verbosity == 1: + logging.basicConfig(level=logging.INFO) + elif args.verbosity > 1: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.ERROR) + args.rfg_file = Path(args.rfg_file) + if not args.rfg_file.is_file(): + sys.exit(f"Could not find input file '{args.rfg_file.resolve()}'.") + logging.debug(f"Found input file '{args.rfg_file.resolve()}'.") + logging.info("Analysing rfg file...") + rfg_analysis = RfgParsing(rfg.Graph(args.rfg_file.resolve())) + rfg_analysis.export_dependencies(ignore=args.ignore_locs) + logging.info("Done...") + logging.info(f"Saving output to '{args.out.resolve()}'") + rfg_analysis.save(args.out.resolve()) + logging.info("Done...") + + +if __name__ == "__main__": + main() diff --git a/tests/axivion/gravis_export_architecture_svg.py b/tests/axivion/scripts/gravis_export_architecture_svg.py similarity index 89% rename from tests/axivion/gravis_export_architecture_svg.py rename to tests/axivion/scripts/gravis_export_architecture_svg.py index 48e481ee..f659e8a2 100644 --- a/tests/axivion/gravis_export_architecture_svg.py +++ b/tests/axivion/scripts/gravis_export_architecture_svg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -45,8 +45,8 @@ layout that is stored under version control and exporting this view as a replacement to the original architecture svg. """ -import sys import os +import sys try: from bauhaus import gravis @@ -68,13 +68,23 @@ # gravis documentation) sys.exit(1) - # extract where the axivion directory is - basedir = os.path.dirname(gravis.argv()[0]) + # extract where the script directory is + script_dir = os.path.dirname(gravis.argv()[0]) + # derive file names - file_architecture = os.path.join(basedir, "architecture.gxl") - file_layout = os.path.join(basedir, "architecture_hierarchy_belongs_to_layout.gvl") + file_architecture = os.path.join( + script_dir, + "..", + "architecture.gxl", + ) + file_layout = os.path.join( + script_dir, + "..", + "architecture_hierarchy_belongs_to_layout.gvl", + ) file_output_architecture = os.path.join( - basedir, + script_dir, + "..", "..", "..", "docs", diff --git a/tests/axivion/start_analysis.bat b/tests/axivion/scripts/start_analysis.bat similarity index 89% rename from tests/axivion/start_analysis.bat rename to tests/axivion/scripts/start_analysis.bat index 646ec092..40929e65 100644 --- a/tests/axivion/start_analysis.bat +++ b/tests/axivion/scripts/start_analysis.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -44,12 +44,9 @@ set SKIP_POSTBUILD_CLEAN=%AXIVION_INCREMENTAL_BUILD% ) -@if NOT DEFINED REQUESTS_CA_BUNDLE ( - @SET REQUESTS_CA_BUNDLE=\\axivion-dash\Axivion_share\dashboard\config\cert\auto.crt -) -@SET AXIVION_BUILD_DIR=%~dp0\..\..\build\axivion +@SET AXIVION_BUILD_DIR=%~dp0\..\..\..\build\axivion @IF NOT EXIST %AXIVION_BUILD_DIR% ( @mkdir %AXIVION_BUILD_DIR% ) -@SET BAUHAUS_CONFIG=%~dp0 +@SET BAUHAUS_CONFIG=%~dp0\..\ @axivion_ci diff --git a/tests/axivion/start_local_analysis.bat b/tests/axivion/scripts/start_local_analysis.bat similarity index 94% rename from tests/axivion/start_local_analysis.bat rename to tests/axivion/scripts/start_local_analysis.bat index a495853c..85d4c83c 100644 --- a/tests/axivion/start_local_analysis.bat +++ b/tests/axivion/scripts/start_local_analysis.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -39,5 +39,4 @@ @set AXIVION=TRUE @set AXIVION_LOCAL_BUILD=TRUE -@set REQUESTS_CA_BUNDLE=%USERPROFILE%\.bauhaus\auto.crt @call %~dp0start_analysis.bat diff --git a/tests/axivion/start_local_dashserver.bat b/tests/axivion/scripts/start_local_dashserver.bat similarity index 97% rename from tests/axivion/start_local_dashserver.bat rename to tests/axivion/scripts/start_local_dashserver.bat index dad78921..8282271c 100644 --- a/tests/axivion/start_local_dashserver.bat +++ b/tests/axivion/scripts/start_local_dashserver.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/axivion/wrapper_make_race_pdfs.bat b/tests/axivion/scripts/wrapper_make_race_pdfs.bat similarity index 92% rename from tests/axivion/wrapper_make_race_pdfs.bat rename to tests/axivion/scripts/wrapper_make_race_pdfs.bat index ccd745ef..b09c6cd7 100644 --- a/tests/axivion/wrapper_make_race_pdfs.bat +++ b/tests/axivion/scripts/wrapper_make_race_pdfs.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -37,6 +37,6 @@ @SETLOCAL EnableExtensions EnableDelayedExpansion -@SET BAUHAUS_CONFIG=%~dp0 -@SET PATH=%PATH%;C:\Bauhaus\7.2.3\doc\html\_downloads\309ace4c1e28cca5a965200324624eec +@SET BAUHAUS_CONFIG=%~dp0\..\ +@SET PATH=%PATH%;C:\Bauhaus\7.4.0\doc\html\_downloads\87991abe35fa881bf14ce6d55f075d2d @call make_race_pdfs.bat %USERPROFILE%\.bauhaus\localbuild\projects\foxbms-2.ir %USERPROFILE%\.bauhaus\localbuild\projects\foxbms-2.rfg diff --git a/tests/c-std/.gitignore b/tests/c-std/.gitignore new file mode 100644 index 00000000..b883f1fd --- /dev/null +++ b/tests/c-std/.gitignore @@ -0,0 +1 @@ +*.exe diff --git a/tests/c-std/c-std-test-inline-helper.h b/tests/c-std/c-std-test-inline-helper.h new file mode 100644 index 00000000..8a6f2f85 --- /dev/null +++ b/tests/c-std/c-std-test-inline-helper.h @@ -0,0 +1,76 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file c-std-test-inline-helper.h + * @author foxBMS Team + * @date 2022-03-16 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup TESTS + * @prefix TEST + * + * @brief Helper file to test assert macro + */ + +#ifndef FOXBMS__C_STD_TEST_INLINE_HELPER_H_ +#define FOXBMS__C_STD_TEST_INLINE_HELPER_H_ + +/*========== Includes =======================================================*/ + +/*========== Macros and Definitions =========================================*/ +#if defined(__STDC_VERSION__) /* We have some newer compiler (C94 at least) */ +#if __STDC_VERSION__ == 199409L && defined(__GNUC__) +#define inline __inline__ +#endif +#else +/* if __STDC_VERSION__ is not defined, we have some very old compiler and we + need to define the inline keyword for this test */ +#define inline __inline__ +#endif + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__C_STD_TEST_INLINE_HELPER_H_ */ diff --git a/tests/c-std/c-std-test.c b/tests/c-std/c-std-test.c new file mode 100644 index 00000000..badd922a --- /dev/null +++ b/tests/c-std/c-std-test.c @@ -0,0 +1,82 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file c-std-test.c + * @author foxBMS Team + * @date 2022-03-16 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup TESTS + * @prefix TEST + * + * @brief Dummy file to test assert macro + */ + +/*========== Includes =======================================================*/ +/* clang-format off */ +#include "c-std-test-inline-helper.h" +#include "fassert.h" +/* clang-format on */ + +#include + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ +int main(void) { +#if defined(__STDC__) && !defined(__STDC_VERSION__) /* C90 */ + printf("__STDC__: %i\n", __STDC__); +#else /*at least C94*/ + printf("__STDC_VERSION__: %i\n", __STDC_VERSION__); +#endif + return 0; +} + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/tests/c-std/c-std-test.json b/tests/c-std/c-std-test.json new file mode 100644 index 00000000..217f5703 --- /dev/null +++ b/tests/c-std/c-std-test.json @@ -0,0 +1,16 @@ +{ + "c89": [ + "#warning \"Ignoring static asserts in C89/C90 mode (f_static_assert).\"" + ], + "c90": [ + "#warning \"Ignoring static asserts in C89/C90 mode (f_static_assert).\"" + ], + "iso9899:199409": [ + "#warning \"Ignoring static asserts in C94 mode (f_static_assert).\"" + ], + "c99": [ + "#warning \"Ignoring static asserts in C99 mode (f_static_assert).\"" + ], + "c11": [], + "c17": [] +} diff --git a/tests/c-std/c-std-test.py b/tests/c-std/c-std-test.py new file mode 100644 index 00000000..57522749 --- /dev/null +++ b/tests/c-std/c-std-test.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +# pylint: disable=invalid-name + +"""Template for Python scripts""" +import argparse +import json +import logging +import os +import sys +from pathlib import Path +from shutil import which +from subprocess import PIPE, Popen + +import git +from git.exc import InvalidGitRepositoryError + +SCRIPT_DIR = Path(__file__).parent.resolve() + +try: + repo = git.Repo(SCRIPT_DIR, search_parent_directories=True) + REPO_ROOT = Path(repo.git.rev_parse("--show-toplevel")) +except InvalidGitRepositoryError: + sys.exit("Test can only be run in a git repository.") + + +def main(): + """This script compiles the c standard test suite and runs the tests""" + parser = argparse.ArgumentParser() + parser.add_argument( + "-v", + "--verbosity", + dest="verbosity", + action="count", + default=0, + help="set verbosity level", + ) + args = parser.parse_args() + + if args.verbosity == 1: + logging.basicConfig(level=logging.INFO) + elif args.verbosity > 1: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.ERROR) + + gcc = which("gcc") + source = SCRIPT_DIR / "c-std-test.c" + include_specifier = "-I" + include = ( + Path(REPO_ROOT / os.path.join("src", "app", "main", "include")) + .resolve() + .as_posix() + ) + standard_specifier = "--std=" + standards = ["c89", "c90", "iso9899:199409", "c99", "c11", "c17"] + out_specifier = "-o" + + outs = {} + for i in standards: + cmd = [ + gcc, + f"{include_specifier}{include}", + f"{standard_specifier}{i}", + "-DASSERT_LEVEL=0", + str(source.absolute().as_posix()), + out_specifier, + f"{SCRIPT_DIR.as_posix()}/test-{i.replace(':', '-')}", + ] + cwd = SCRIPT_DIR + logging.debug(" ".join(cmd)) + + with Popen(cmd, cwd=cwd, stdout=PIPE, stderr=PIPE) as p: + _, err = p.communicate() + err = [ + i.strip() + for i in err.decode("utf-8").splitlines() + if i.strip().startswith("#warning") + ] + outs[i] = err + + with open(Path(SCRIPT_DIR / "c-std-test.json"), "r", encoding="utf-8") as f: + expected_output = json.load(f) + + test_errors = 0 + for std, warning in outs.items(): + expected_warning = expected_output[std] + if not warning == expected_warning: + logging.error(f"Warning did not match for {std}.") + logging.error(f"Expected: {warning}") + logging.error(f"Got: {expected_warning}") + test_errors += 1 + else: + logging.debug(f"Got expected warning for {std}.") + sys.exit(test_errors) + + +if __name__ == "__main__": + main() diff --git a/tests/can/check_implemented.py b/tests/can/check_implemented.py index 022c62ab..7e39cc87 100644 --- a/tests/can/check_implemented.py +++ b/tests/can/check_implemented.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,12 +40,13 @@ """Python script to check if all callbacks defined in the .dbc file are implemented in callback functions.""" -import os -import sys -import logging import argparse +import logging +import os import re +import sys from pathlib import Path + import cantools HAVE_GIT = False diff --git a/tests/ccs/ccs1000/ccs1000_cc-options.yaml b/tests/ccs/ccs1000/ccs1000_cc-options.yaml index 3116b19f..48239c4e 100644 --- a/tests/ccs/ccs1000/ccs1000_cc-options.yaml +++ b/tests/ccs/ccs1000/ccs1000_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.0.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/ccs/ccs1000/ccs1000_linker_pulls.json b/tests/ccs/ccs1000/ccs1000_linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/tests/ccs/ccs1000/ccs1000_linker_pulls.json +++ b/tests/ccs/ccs1000/ccs1000_linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/tests/ccs/ccs1000/ccs1000_paths_linux.txt b/tests/ccs/ccs1000/ccs1000_paths_linux.txt new file mode 100644 index 00000000..7b4ab745 --- /dev/null +++ b/tests/ccs/ccs1000/ccs1000_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1000/ccs/tools/compiler/ti-cgt-arm_20.2.0.LTS/bin +/opt/ti/ccs1000/ccs/tools/compiler/ti-cgt-arm_20.2.0.LTS/lib +/opt/ti/ccs1000/ccs/utils/bin +/opt/ti/ccs1000/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1000/ccs1000_paths_win32.txt b/tests/ccs/ccs1000/ccs1000_paths_win32.txt index 2110472c..f5c13260 100644 --- a/tests/ccs/ccs1000/ccs1000_paths_win32.txt +++ b/tests/ccs/ccs1000/ccs1000_paths_win32.txt @@ -4,8 +4,7 @@ C:\ti\ccs1000\ccs\utils\bin C:\ti\ccs1000\ccs\utils\cygwin C:\ti\ccs1000\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1011/ccs1011_cc-options.yaml b/tests/ccs/ccs1011/ccs1011_cc-options.yaml index 3116b19f..f920d3a7 100644 --- a/tests/ccs/ccs1011/ccs1011_cc-options.yaml +++ b/tests/ccs/ccs1011/ccs1011_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.1.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/ccs/ccs1011/ccs1011_linker_pulls.json b/tests/ccs/ccs1011/ccs1011_linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/tests/ccs/ccs1011/ccs1011_linker_pulls.json +++ b/tests/ccs/ccs1011/ccs1011_linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/tests/ccs/ccs1011/ccs1011_paths_linux.txt b/tests/ccs/ccs1011/ccs1011_paths_linux.txt new file mode 100644 index 00000000..aecc3e07 --- /dev/null +++ b/tests/ccs/ccs1011/ccs1011_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1011/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/bin +/opt/ti/ccs1011/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/lib +/opt/ti/ccs1011/ccs/utils/bin +/opt/ti/ccs1011/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1011/ccs1011_paths_win32.txt b/tests/ccs/ccs1011/ccs1011_paths_win32.txt index 634d733a..d644a353 100644 --- a/tests/ccs/ccs1011/ccs1011_paths_win32.txt +++ b/tests/ccs/ccs1011/ccs1011_paths_win32.txt @@ -4,8 +4,7 @@ C:\ti\ccs1011\ccs\utils\bin C:\ti\ccs1011\ccs\utils\cygwin C:\ti\ccs1011\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1020/ccs1020_cc-options.yaml b/tests/ccs/ccs1020/ccs1020_cc-options.yaml index 3116b19f..afb9334b 100644 --- a/tests/ccs/ccs1020/ccs1020_cc-options.yaml +++ b/tests/ccs/ccs1020/ccs1020_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.2.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/ccs/ccs1020/ccs1020_linker_pulls.json b/tests/ccs/ccs1020/ccs1020_linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/tests/ccs/ccs1020/ccs1020_linker_pulls.json +++ b/tests/ccs/ccs1020/ccs1020_linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/tests/ccs/ccs1020/ccs1020_paths_linux.txt b/tests/ccs/ccs1020/ccs1020_paths_linux.txt new file mode 100644 index 00000000..8a53861a --- /dev/null +++ b/tests/ccs/ccs1020/ccs1020_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1020/ccs/tools/compiler/ti-cgt-arm_20.2.2.LTS/bin +/opt/ti/ccs1020/ccs/tools/compiler/ti-cgt-arm_20.2.2.LTS/lib +/opt/ti/ccs1020/ccs/utils/bin +/opt/ti/ccs1020/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1020/ccs1020_paths_win32.txt b/tests/ccs/ccs1020/ccs1020_paths_win32.txt index 78c89a00..895ee8da 100644 --- a/tests/ccs/ccs1020/ccs1020_paths_win32.txt +++ b/tests/ccs/ccs1020/ccs1020_paths_win32.txt @@ -4,8 +4,7 @@ C:\ti\ccs1020\ccs\utils\bin C:\ti\ccs1020\ccs\utils\cygwin C:\ti\ccs1020\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1030/ccs1030_cc-options.yaml b/tests/ccs/ccs1030/ccs1030_cc-options.yaml index 3116b19f..f5f6750f 100644 --- a/tests/ccs/ccs1030/ccs1030_cc-options.yaml +++ b/tests/ccs/ccs1030/ccs1030_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.4.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/ccs/ccs1030/ccs1030_linker_pulls.json b/tests/ccs/ccs1030/ccs1030_linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/tests/ccs/ccs1030/ccs1030_linker_pulls.json +++ b/tests/ccs/ccs1030/ccs1030_linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/tests/ccs/ccs1030/ccs1030_paths_linux.txt b/tests/ccs/ccs1030/ccs1030_paths_linux.txt new file mode 100644 index 00000000..fb70c856 --- /dev/null +++ b/tests/ccs/ccs1030/ccs1030_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1030/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/bin +/opt/ti/ccs1030/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/lib +/opt/ti/ccs1030/ccs/utils/bin +/opt/ti/ccs1030/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1030/ccs1030_paths_win32.txt b/tests/ccs/ccs1030/ccs1030_paths_win32.txt index 631cdbe0..3773bec9 100644 --- a/tests/ccs/ccs1030/ccs1030_paths_win32.txt +++ b/tests/ccs/ccs1030/ccs1030_paths_win32.txt @@ -4,8 +4,7 @@ C:\ti\ccs1030\ccs\utils\bin C:\ti\ccs1030\ccs\utils\cygwin C:\ti\ccs1030\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1031/ccs1031_cc-options.yaml b/tests/ccs/ccs1031/ccs1031_cc-options.yaml index 3116b19f..f5f6750f 100644 --- a/tests/ccs/ccs1031/ccs1031_cc-options.yaml +++ b/tests/ccs/ccs1031/ccs1031_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.4.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/ccs/ccs1031/ccs1031_linker_pulls.json b/tests/ccs/ccs1031/ccs1031_linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/tests/ccs/ccs1031/ccs1031_linker_pulls.json +++ b/tests/ccs/ccs1031/ccs1031_linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/tests/ccs/ccs1031/ccs1031_paths_linux.txt b/tests/ccs/ccs1031/ccs1031_paths_linux.txt new file mode 100644 index 00000000..936f5551 --- /dev/null +++ b/tests/ccs/ccs1031/ccs1031_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1031/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/bin +/opt/ti/ccs1031/ccs/tools/compiler/ti-cgt-arm_20.2.4.LTS/lib +/opt/ti/ccs1031/ccs/utils/bin +/opt/ti/ccs1031/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1031/ccs1031_paths_win32.txt b/tests/ccs/ccs1031/ccs1031_paths_win32.txt index e94eccab..130086aa 100644 --- a/tests/ccs/ccs1031/ccs1031_paths_win32.txt +++ b/tests/ccs/ccs1031/ccs1031_paths_win32.txt @@ -4,8 +4,7 @@ C:\ti\ccs1031\ccs\utils\bin C:\ti\ccs1031\ccs\utils\cygwin C:\ti\ccs1031\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1040/ccs1040_cc-options.yaml b/tests/ccs/ccs1040/ccs1040_cc-options.yaml index 3116b19f..34ba329a 100644 --- a/tests/ccs/ccs1040/ccs1040_cc-options.yaml +++ b/tests/ccs/ccs1040/ccs1040_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -35,6 +35,8 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.5.LTS" + INCLUDE_PATHS: win32: linux: @@ -81,7 +83,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/ccs/ccs1040/ccs1040_linker_pulls.json b/tests/ccs/ccs1040/ccs1040_linker_pulls.json index 752c7230..b3cf64d3 100644 --- a/tests/ccs/ccs1040/ccs1040_linker_pulls.json +++ b/tests/ccs/ccs1040/ccs1040_linker_pulls.json @@ -1,6 +1,5 @@ { "_c_int00": "src/app/main/fstartup.c.1.obj", "canMessageNotification": "src/app/driver/libfoxbms-driver.a", - "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a", - "handlePLLLockFail": "src/app/main/fstartup.c.1.obj" + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" } diff --git a/tests/ccs/ccs1040/ccs1040_paths_linux.txt b/tests/ccs/ccs1040/ccs1040_paths_linux.txt new file mode 100644 index 00000000..cb0680b4 --- /dev/null +++ b/tests/ccs/ccs1040/ccs1040_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS//bin +/opt/ti/ccs1040/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS//lib +/opt/ti/ccs1040/ccs/utils/bin +/opt/ti/ccs1040/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1040/ccs1040_paths_win32.txt b/tests/ccs/ccs1040/ccs1040_paths_win32.txt index b9b93bc2..e634000d 100644 --- a/tests/ccs/ccs1040/ccs1040_paths_win32.txt +++ b/tests/ccs/ccs1040/ccs1040_paths_win32.txt @@ -4,8 +4,7 @@ C:\ti\ccs1040\ccs\utils\bin C:\ti\ccs1040\ccs\utils\cygwin C:\ti\ccs1040\ccs\utils\tiobj2bin C:\ti\Hercules\HALCoGen\v04.07.01 -C:\Program Files\Cppcheck\Cppcheck-2.2-x64 -C:\Program Files\LLVM\11.0.1\bin +C:\Program Files\LLVM\13.0.0\bin C:\Ruby\Ruby272-x64\bin C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1100-c99/ccs1100-c99_cc-options.yaml b/tests/ccs/ccs1100-c99/ccs1100-c99_cc-options.yaml new file mode 100644 index 00000000..a469da97 --- /dev/null +++ b/tests/ccs/ccs1100-c99/ccs1100-c99_cc-options.yaml @@ -0,0 +1,112 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.5.LTS" + +INCLUDE_PATHS: + win32: + linux: + +LIBRARY_PATHS: + win32: + linux: + +LIBRARIES: + ST: # libraries following the pattern "lib.a" + TARGET: # libraries following the pattern ".lib" + - rtsv7R4_A_be_v3D16_eabi + +CFLAGS: + # flags that are used for ALL source files (foxBMS, Operating System, HAL) + common: + - --silicon_version=7R5 + - --code_state=32 + - --float_support=VFPv3D16 + - -g + - --diag_wrap=off + - --display_error_number + - --enum_type=packed + - --abi=eabi + - --c99 + # these flags are not used when generating ppi/ppd/ppm information + common_compile_only: + - --emit_warnings_as_errors + # additional flags that are ONLY applied to foxBMS sources + foxbms: + - -Ooff + - -DASSERT_LEVEL=0 + - --issue_remarks + - --strict_ansi + # additional flags that are ONLY applied to hal sources + hal: + - -O3 # default + # additional flags that are ONLY applied to operating system sources + operating_system: + - -O3 # default + - --strict_ansi + +LINKFLAGS: + - --emit_warnings_as_errors + - --be32 + - --rom_model + - --heap_size=0x800 + - --stack_size=0x800 + - --undef_sym=__TI_static_base__ + - --undef_sym=resetEntry + - -o4 + - --unused_section_elimination + - --strict_compatibility=on + - --zero_init=on + - --scan_libraries + +HEXGENFLAGS: + - --memwidth=32 + - --tektronix + - -image + - --load_image + - --load_image:combine_sections=true + - --load_image:endian=big + - --load_image:file_type=executable + - --load_image:format=elf + - --load_image:machine=ARM + - --load_image:output_symbols=true + - --load_image:section_addresses=false + +NMFLAGS: + - --all + - -f + - -l diff --git a/tests/ccs/ccs1100-c99/ccs1100-c99_linker_pulls.json b/tests/ccs/ccs1100-c99/ccs1100-c99_linker_pulls.json new file mode 100644 index 00000000..b3cf64d3 --- /dev/null +++ b/tests/ccs/ccs1100-c99/ccs1100-c99_linker_pulls.json @@ -0,0 +1,5 @@ +{ + "_c_int00": "src/app/main/fstartup.c.1.obj", + "canMessageNotification": "src/app/driver/libfoxbms-driver.a", + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" +} diff --git a/tests/ccs/ccs1100-c99/ccs1100-c99_paths_linux.txt b/tests/ccs/ccs1100-c99/ccs1100-c99_paths_linux.txt new file mode 100644 index 00000000..25a51a0f --- /dev/null +++ b/tests/ccs/ccs1100-c99/ccs1100-c99_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin +/opt/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/lib +/opt/ti/ccs1100/ccs/utils/bin +/opt/ti/ccs1100/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1100-c99/ccs1100-c99_paths_win32.txt b/tests/ccs/ccs1100-c99/ccs1100-c99_paths_win32.txt new file mode 100644 index 00000000..5affa8b4 --- /dev/null +++ b/tests/ccs/ccs1100-c99/ccs1100-c99_paths_win32.txt @@ -0,0 +1,10 @@ +C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-arm_20.2.5.LTS\bin +C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-arm_20.2.5.LTS\lib +C:\ti\ccs1100\ccs\utils\bin +C:\ti\ccs1100\ccs\utils\cygwin +C:\ti\ccs1100\ccs\utils\tiobj2bin +C:\ti\Hercules\HALCoGen\v04.07.01 +C:\Program Files\LLVM\13.0.0\bin +C:\Ruby\Ruby272-x64\bin +C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin +C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1100-c99/ccs1100-c99_remarks.txt b/tests/ccs/ccs1100-c99/ccs1100-c99_remarks.txt new file mode 100644 index 00000000..a9030778 --- /dev/null +++ b/tests/ccs/ccs1100-c99/ccs1100-c99_remarks.txt @@ -0,0 +1,28 @@ +/* entries in this file are ordered by ascending order */ + +/* define has no value, and will be treated as if equal 0 */ +"--"diag_suppress=195 + +/* function has no prototype */ +"--"diag_error=225 + +/* unnecessary semicolon at line end */ +"--"diag_error=383 + +/* not referenced */ +"--"diag_remark=880 + +/* signed and unsigned comparison */ +"--"diag_error=2142 + +/* shadowing variable */ +"--"diag_remark=2710 + +/* enum comparison of different enum types */ +"--"diag_error=2912 + +/* automatic Runtime Support library selection */ +"--"diag_error=10205 + +/* Symbol defined multiple times */ +"--"diag_remark=10252 diff --git a/tests/ccs/ccs1100/ccs1100_cc-options.yaml b/tests/ccs/ccs1100/ccs1100_cc-options.yaml new file mode 100644 index 00000000..34ba329a --- /dev/null +++ b/tests/ccs/ccs1100/ccs1100_cc-options.yaml @@ -0,0 +1,112 @@ +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# We kindly request you to use one or more of the following phrases to refer to +# foxBMS in your hardware, software, documentation or advertising materials: +# +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" + +FOXBMS_2_CCS_VERSION_STRICT: "v20.2.5.LTS" + +INCLUDE_PATHS: + win32: + linux: + +LIBRARY_PATHS: + win32: + linux: + +LIBRARIES: + ST: # libraries following the pattern "lib.a" + TARGET: # libraries following the pattern ".lib" + - rtsv7R4_A_be_v3D16_eabi + +CFLAGS: + # flags that are used for ALL source files (foxBMS, Operating System, HAL) + common: + - --silicon_version=7R5 + - --code_state=32 + - --float_support=VFPv3D16 + - -g + - --diag_wrap=off + - --display_error_number + - --enum_type=packed + - --abi=eabi + - --c11 + # these flags are not used when generating ppi/ppd/ppm information + common_compile_only: + - --emit_warnings_as_errors + # additional flags that are ONLY applied to foxBMS sources + foxbms: + - -Ooff + - -DASSERT_LEVEL=0 + - --issue_remarks + - --strict_ansi + # additional flags that are ONLY applied to hal sources + hal: + - -O3 # default + # additional flags that are ONLY applied to operating system sources + operating_system: + - -O3 # default + - --strict_ansi + +LINKFLAGS: + - --emit_warnings_as_errors + - --be32 + - --rom_model + - --heap_size=0x800 + - --stack_size=0x800 + - --undef_sym=__TI_static_base__ + - --undef_sym=resetEntry + - -o4 + - --unused_section_elimination + - --strict_compatibility=on + - --zero_init=on + - --scan_libraries + +HEXGENFLAGS: + - --memwidth=32 + - --tektronix + - -image + - --load_image + - --load_image:combine_sections=true + - --load_image:endian=big + - --load_image:file_type=executable + - --load_image:format=elf + - --load_image:machine=ARM + - --load_image:output_symbols=true + - --load_image:section_addresses=false + +NMFLAGS: + - --all + - -f + - -l diff --git a/tests/ccs/ccs1100/ccs1100_linker_pulls.json b/tests/ccs/ccs1100/ccs1100_linker_pulls.json new file mode 100644 index 00000000..b3cf64d3 --- /dev/null +++ b/tests/ccs/ccs1100/ccs1100_linker_pulls.json @@ -0,0 +1,5 @@ +{ + "_c_int00": "src/app/main/fstartup.c.1.obj", + "canMessageNotification": "src/app/driver/libfoxbms-driver.a", + "dmaGroupANotification": "src/app/driver/libfoxbms-driver.a" +} diff --git a/tests/ccs/ccs1100/ccs1100_paths_linux.txt b/tests/ccs/ccs1100/ccs1100_paths_linux.txt new file mode 100644 index 00000000..25a51a0f --- /dev/null +++ b/tests/ccs/ccs1100/ccs1100_paths_linux.txt @@ -0,0 +1,4 @@ +/opt/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin +/opt/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/lib +/opt/ti/ccs1100/ccs/utils/bin +/opt/ti/ccs1100/ccs/utils/tiobj2bin diff --git a/tests/ccs/ccs1100/ccs1100_paths_win32.txt b/tests/ccs/ccs1100/ccs1100_paths_win32.txt new file mode 100644 index 00000000..5affa8b4 --- /dev/null +++ b/tests/ccs/ccs1100/ccs1100_paths_win32.txt @@ -0,0 +1,10 @@ +C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-arm_20.2.5.LTS\bin +C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-arm_20.2.5.LTS\lib +C:\ti\ccs1100\ccs\utils\bin +C:\ti\ccs1100\ccs\utils\cygwin +C:\ti\ccs1100\ccs\utils\tiobj2bin +C:\ti\Hercules\HALCoGen\v04.07.01 +C:\Program Files\LLVM\13.0.0\bin +C:\Ruby\Ruby272-x64\bin +C:\MinGW64\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\bin +C:\Bauhaus\7.2.0\bin diff --git a/tests/ccs/ccs1100/ccs1100_remarks.txt b/tests/ccs/ccs1100/ccs1100_remarks.txt new file mode 100644 index 00000000..a9030778 --- /dev/null +++ b/tests/ccs/ccs1100/ccs1100_remarks.txt @@ -0,0 +1,28 @@ +/* entries in this file are ordered by ascending order */ + +/* define has no value, and will be treated as if equal 0 */ +"--"diag_suppress=195 + +/* function has no prototype */ +"--"diag_error=225 + +/* unnecessary semicolon at line end */ +"--"diag_error=383 + +/* not referenced */ +"--"diag_remark=880 + +/* signed and unsigned comparison */ +"--"diag_error=2142 + +/* shadowing variable */ +"--"diag_remark=2710 + +/* enum comparison of different enum types */ +"--"diag_error=2912 + +/* automatic Runtime Support library selection */ +"--"diag_error=10205 + +/* Symbol defined multiple times */ +"--"diag_remark=10252 diff --git a/tests/env/packages/env_test__libgcc_mutex_linux.py b/tests/env/packages/env_test__libgcc_mutex_linux.py index 4447f77d..f2b2e7ef 100644 --- a/tests/env/packages/env_test__libgcc_mutex_linux.py +++ b/tests/env/packages/env_test__libgcc_mutex_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing '_libgcc_mutex' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test__openmp_mutex_linux.py b/tests/env/packages/env_test__openmp_mutex_linux.py index 3af69fad..a1685059 100644 --- a/tests/env/packages/env_test__openmp_mutex_linux.py +++ b/tests/env/packages/env_test__openmp_mutex_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing '_openmp_mutex' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_alabaster.py b/tests/env/packages/env_test_alabaster.py index 005d1a6d..ac8e66c1 100644 --- a/tests/env/packages/env_test_alabaster.py +++ b/tests/env/packages/env_test_alabaster.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'alabaster' package""" -import logging import argparse +import logging # package to test import alabaster diff --git a/tests/env/packages/env_test_alsa-lib_linux.py b/tests/env/packages/env_test_alsa-lib_linux.py index f388dc37..2fbf3319 100644 --- a/tests/env/packages/env_test_alsa-lib_linux.py +++ b/tests/env/packages/env_test_alsa-lib_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'alsa-lib' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_appdirs.py b/tests/env/packages/env_test_appdirs.py index 62591761..7aec09fa 100644 --- a/tests/env/packages/env_test_appdirs.py +++ b/tests/env/packages/env_test_appdirs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'appdirs' package""" -import logging import argparse +import logging # package to test import appdirs diff --git a/tests/env/packages/env_test_argon2-cffi.py b/tests/env/packages/env_test_argon2-cffi.py index e2895d97..d359226e 100644 --- a/tests/env/packages/env_test_argon2-cffi.py +++ b/tests/env/packages/env_test_argon2-cffi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'argon2-cffi' package""" -import logging import argparse +import logging # package to test import argon2 diff --git a/tests/env/packages/env_test_argparse-addons.py b/tests/env/packages/env_test_argparse-addons.py index 66cb764c..1f360ca6 100644 --- a/tests/env/packages/env_test_argparse-addons.py +++ b/tests/env/packages/env_test_argparse-addons.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'argparse-addons' package""" -import logging import argparse +import logging # package to test import argparse_addons # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_arpeggio.py b/tests/env/packages/env_test_arpeggio.py index d7d38064..4b6357c2 100644 --- a/tests/env/packages/env_test_arpeggio.py +++ b/tests/env/packages/env_test_arpeggio.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'arpeggio' package""" -import logging import argparse +import logging # package to test import arpeggio diff --git a/tests/env/packages/env_test_astroid.py b/tests/env/packages/env_test_astroid.py index 9946d449..be8ca6db 100644 --- a/tests/env/packages/env_test_astroid.py +++ b/tests/env/packages/env_test_astroid.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'astroid' package""" -import logging import argparse +import logging import unittest # package to test diff --git a/tests/env/packages/env_test_atk-1.0_linux.py b/tests/env/packages/env_test_atk-1.0_linux.py index 295795d7..9c442824 100644 --- a/tests/env/packages/env_test_atk-1.0_linux.py +++ b/tests/env/packages/env_test_atk-1.0_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'env_test_atk-1.0_linux' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_attrs.py b/tests/env/packages/env_test_attrs.py index 34a747f9..c5af9aea 100644 --- a/tests/env/packages/env_test_attrs.py +++ b/tests/env/packages/env_test_attrs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'attrs' package""" -import logging import argparse +import logging # package to test import attr diff --git a/tests/env/packages/env_test_babel.py b/tests/env/packages/env_test_babel.py index b2b93da5..0c298aa5 100644 --- a/tests/env/packages/env_test_babel.py +++ b/tests/env/packages/env_test_babel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'babel' package""" -import logging import argparse +import logging # package to test import babel # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_backcall.py b/tests/env/packages/env_test_backcall.py index 34d75dcb..24532847 100644 --- a/tests/env/packages/env_test_backcall.py +++ b/tests/env/packages/env_test_backcall.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'backcall' package""" -import logging import argparse +import logging # package to test import backcall # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_beautifulsoup4.py b/tests/env/packages/env_test_beautifulsoup4.py index 59c38470..8a472318 100644 --- a/tests/env/packages/env_test_beautifulsoup4.py +++ b/tests/env/packages/env_test_beautifulsoup4.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'beautifulsoup4' package""" -import logging import argparse +import logging # package to test import bs4 diff --git a/tests/env/packages/env_test_bitstruct.py b/tests/env/packages/env_test_bitstruct.py index d23eb818..0555a917 100644 --- a/tests/env/packages/env_test_bitstruct.py +++ b/tests/env/packages/env_test_bitstruct.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'bitstruct' package""" -import logging import argparse +import logging # package to test import bitstruct diff --git a/tests/env/packages/env_test_black.py b/tests/env/packages/env_test_black.py index bbae1644..6ca04baa 100644 --- a/tests/env/packages/env_test_black.py +++ b/tests/env/packages/env_test_black.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,13 +40,12 @@ """Testing 'black' package""" -import logging import argparse - -from click.testing import CliRunner +import logging # package to test import black +from click.testing import CliRunner def main(): diff --git a/tests/env/packages/env_test_bleach.py b/tests/env/packages/env_test_bleach.py index 325d63de..b0f6ddcc 100644 --- a/tests/env/packages/env_test_bleach.py +++ b/tests/env/packages/env_test_bleach.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'bleach' package""" -import logging import argparse +import logging # package to test import bleach # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_bokeh.py b/tests/env/packages/env_test_bokeh.py index 6179eb95..2fa1ccd2 100644 --- a/tests/env/packages/env_test_bokeh.py +++ b/tests/env/packages/env_test_bokeh.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'bokeh' package""" -import logging import argparse +import logging # package to test import bokeh # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_bottle.py b/tests/env/packages/env_test_bottle.py index 5edf9ff0..af986cf6 100644 --- a/tests/env/packages/env_test_bottle.py +++ b/tests/env/packages/env_test_bottle.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'bottle' package""" -import logging import argparse +import logging # package to test import bottle # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_brotlipy_linux.py b/tests/env/packages/env_test_brotlipy_linux.py index 52944b5e..95948047 100644 --- a/tests/env/packages/env_test_brotlipy_linux.py +++ b/tests/env/packages/env_test_brotlipy_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'brotlipy' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_ca-certificates.py b/tests/env/packages/env_test_ca-certificates.py index 45653712..3c9a1d8e 100644 --- a/tests/env/packages/env_test_ca-certificates.py +++ b/tests/env/packages/env_test_ca-certificates.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'ca-certificates' package""" -import logging import argparse +import logging # tested by certifi diff --git a/tests/env/packages/env_test_cairo_linux.py b/tests/env/packages/env_test_cairo_linux.py index 229c83b6..80677d1a 100644 --- a/tests/env/packages/env_test_cairo_linux.py +++ b/tests/env/packages/env_test_cairo_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cairo' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_cantools.py b/tests/env/packages/env_test_cantools.py index 6018942a..8efed052 100644 --- a/tests/env/packages/env_test_cantools.py +++ b/tests/env/packages/env_test_cantools.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cantools' package""" -import logging import argparse +import logging # package to test import cantools # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_certifi.py b/tests/env/packages/env_test_certifi.py index 36f4c149..252293b6 100644 --- a/tests/env/packages/env_test_certifi.py +++ b/tests/env/packages/env_test_certifi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'certifi' package""" -import logging import argparse +import logging # package to test import certifi diff --git a/tests/env/packages/env_test_cffconvert.py b/tests/env/packages/env_test_cffconvert.py index 937a1440..ce0d01c6 100644 --- a/tests/env/packages/env_test_cffconvert.py +++ b/tests/env/packages/env_test_cffconvert.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cffconvert' package""" -import logging import argparse +import logging # package to test import cffconvert.cli.cli # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_cffi.py b/tests/env/packages/env_test_cffi.py index ac8eac3c..65c9ca69 100644 --- a/tests/env/packages/env_test_cffi.py +++ b/tests/env/packages/env_test_cffi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cffi' package""" -import logging import argparse +import logging # package to test import cffi # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_charset-normalizer.py b/tests/env/packages/env_test_charset-normalizer.py index bccb5cf2..b80be135 100644 --- a/tests/env/packages/env_test_charset-normalizer.py +++ b/tests/env/packages/env_test_charset-normalizer.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'charset-normalizer' package""" -import logging import argparse +import logging # package to test import charset_normalizer diff --git a/tests/env/packages/env_test_click.py b/tests/env/packages/env_test_click.py index 394116fb..5fc306a1 100644 --- a/tests/env/packages/env_test_click.py +++ b/tests/env/packages/env_test_click.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'click' package""" -import logging import argparse +import logging # package to test import click # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_cloudpickle.py b/tests/env/packages/env_test_cloudpickle.py index 70b1dc1d..634d6e38 100644 --- a/tests/env/packages/env_test_cloudpickle.py +++ b/tests/env/packages/env_test_cloudpickle.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cloudpickle' package""" -import logging import argparse +import logging # package to test import cloudpickle # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_colorama.py b/tests/env/packages/env_test_colorama.py index bd3df878..f7b4f579 100644 --- a/tests/env/packages/env_test_colorama.py +++ b/tests/env/packages/env_test_colorama.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'colorama' package""" -import logging import argparse +import logging # package to test import colorama # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_console_shortcut_win32.py b/tests/env/packages/env_test_console_shortcut_win32.py index 954cb5e0..e3196467 100644 --- a/tests/env/packages/env_test_console_shortcut_win32.py +++ b/tests/env/packages/env_test_console_shortcut_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'console_shortcut' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_coverage.py b/tests/env/packages/env_test_coverage.py index d796bf2a..e043f862 100644 --- a/tests/env/packages/env_test_coverage.py +++ b/tests/env/packages/env_test_coverage.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'coverage' package""" -import logging import argparse +import logging # package to test import coverage # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_crcmod.py b/tests/env/packages/env_test_crcmod.py index 90ccaf72..de02ffd5 100644 --- a/tests/env/packages/env_test_crcmod.py +++ b/tests/env/packages/env_test_crcmod.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'crcmod' package""" -import logging import argparse +import logging # package to test import crcmod # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_cryptography_linux.py b/tests/env/packages/env_test_cryptography_linux.py index db7ec3ae..a9f56127 100644 --- a/tests/env/packages/env_test_cryptography_linux.py +++ b/tests/env/packages/env_test_cryptography_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cryptography' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_cycler.py b/tests/env/packages/env_test_cycler.py index 4098c378..0ba699bb 100644 --- a/tests/env/packages/env_test_cycler.py +++ b/tests/env/packages/env_test_cycler.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'cycler' package""" -import logging import argparse +import logging # package to test import cycler # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_dask.py b/tests/env/packages/env_test_dask.py index cef3dc6c..190a33b4 100644 --- a/tests/env/packages/env_test_dask.py +++ b/tests/env/packages/env_test_dask.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'dask' package""" -import logging import argparse +import logging # package to test import dask # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_debugpy.py b/tests/env/packages/env_test_debugpy.py index 8bdadc41..aecd1f45 100644 --- a/tests/env/packages/env_test_debugpy.py +++ b/tests/env/packages/env_test_debugpy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'debugpy' package""" -import logging import argparse +import logging # package to test import debugpy diff --git a/tests/env/packages/env_test_decorator.py b/tests/env/packages/env_test_decorator.py index acc4d054..18e51692 100644 --- a/tests/env/packages/env_test_decorator.py +++ b/tests/env/packages/env_test_decorator.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'decorator' package""" -import logging import argparse +import logging # package to test import decorator # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_defusedxml.py b/tests/env/packages/env_test_defusedxml.py index 2dfd349e..f919d732 100644 --- a/tests/env/packages/env_test_defusedxml.py +++ b/tests/env/packages/env_test_defusedxml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'defusedxml' package""" -import logging import argparse +import logging # package to test import defusedxml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_diskcache.py b/tests/env/packages/env_test_diskcache.py index ba0aeddc..461048ef 100644 --- a/tests/env/packages/env_test_diskcache.py +++ b/tests/env/packages/env_test_diskcache.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'diskcache' package""" -import logging import argparse +import logging # package to test import diskcache # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_docopt.py b/tests/env/packages/env_test_docopt.py index ef31c2f3..24576552 100644 --- a/tests/env/packages/env_test_docopt.py +++ b/tests/env/packages/env_test_docopt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'docopt' package""" -import logging import argparse +import logging # package to test import docopt # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_docutils.py b/tests/env/packages/env_test_docutils.py index abea6f01..8ac0caf0 100644 --- a/tests/env/packages/env_test_docutils.py +++ b/tests/env/packages/env_test_docutils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'docutils' package""" -import logging import argparse +import logging # package to test import docutils # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_doorstop.py b/tests/env/packages/env_test_doorstop.py index 7084a3c9..d353084c 100644 --- a/tests/env/packages/env_test_doorstop.py +++ b/tests/env/packages/env_test_doorstop.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'doorstop' package""" -import logging import argparse +import logging # package to test import doorstop # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_doxygen_win32.py b/tests/env/packages/env_test_doxygen_win32.py index 78576eee..9710f073 100644 --- a/tests/env/packages/env_test_doxygen_win32.py +++ b/tests/env/packages/env_test_doxygen_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'doxygen' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_entrypoints.py b/tests/env/packages/env_test_entrypoints.py index ed1e01b5..752ff104 100644 --- a/tests/env/packages/env_test_entrypoints.py +++ b/tests/env/packages/env_test_entrypoints.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'entrypoints' package""" -import logging import argparse +import logging # package to test import entrypoints # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_et-xmlfile.py b/tests/env/packages/env_test_et-xmlfile.py index 1b3a2d8d..d33eb3b4 100644 --- a/tests/env/packages/env_test_et-xmlfile.py +++ b/tests/env/packages/env_test_et-xmlfile.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'et-xmlfile' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_expat_linux.py b/tests/env/packages/env_test_expat_linux.py index aa397ccf..1faa1c06 100644 --- a/tests/env/packages/env_test_expat_linux.py +++ b/tests/env/packages/env_test_expat_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'expat' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_filterpy.py b/tests/env/packages/env_test_filterpy.py index 388218f4..a479d816 100644 --- a/tests/env/packages/env_test_filterpy.py +++ b/tests/env/packages/env_test_filterpy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'filterpy' package""" -import logging import argparse +import logging # package to test import filterpy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_font-ttf-dejavu-sans-mono_linux.py b/tests/env/packages/env_test_font-ttf-dejavu-sans-mono_linux.py index c031700a..849306ce 100644 --- a/tests/env/packages/env_test_font-ttf-dejavu-sans-mono_linux.py +++ b/tests/env/packages/env_test_font-ttf-dejavu-sans-mono_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'font-ttf-dejavu-sans-mono' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_font-ttf-inconsolata_linux.py b/tests/env/packages/env_test_font-ttf-inconsolata_linux.py index abb4e3a6..f36a6349 100644 --- a/tests/env/packages/env_test_font-ttf-inconsolata_linux.py +++ b/tests/env/packages/env_test_font-ttf-inconsolata_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'font-ttf-inconsolata' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_font-ttf-source-code-pro_linux.py b/tests/env/packages/env_test_font-ttf-source-code-pro_linux.py index e0cea4ea..5bed96fe 100644 --- a/tests/env/packages/env_test_font-ttf-source-code-pro_linux.py +++ b/tests/env/packages/env_test_font-ttf-source-code-pro_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'font-ttf-source-code-pro' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_font-ttf-ubuntu_linux.py b/tests/env/packages/env_test_font-ttf-ubuntu_linux.py index 08f45fe2..aac0b14f 100644 --- a/tests/env/packages/env_test_font-ttf-ubuntu_linux.py +++ b/tests/env/packages/env_test_font-ttf-ubuntu_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'font-ttf-ubuntu' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_fontconfig_linux.py b/tests/env/packages/env_test_fontconfig_linux.py index cdc07b39..4ffe6f8f 100644 --- a/tests/env/packages/env_test_fontconfig_linux.py +++ b/tests/env/packages/env_test_fontconfig_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'fontconfig' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_fonts-anaconda_linux.py b/tests/env/packages/env_test_fonts-anaconda_linux.py index 20728246..5056e624 100644 --- a/tests/env/packages/env_test_fonts-anaconda_linux.py +++ b/tests/env/packages/env_test_fonts-anaconda_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'fonts-anaconda' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_fonts-conda-ecosystem_linux.py b/tests/env/packages/env_test_fonts-conda-ecosystem_linux.py index a2f8acae..f0141b1a 100644 --- a/tests/env/packages/env_test_fonts-conda-ecosystem_linux.py +++ b/tests/env/packages/env_test_fonts-conda-ecosystem_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'fonts-conda-ecosystem' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_freetype_linux.py b/tests/env/packages/env_test_freetype_linux.py index 434e4493..86e4aac4 100644 --- a/tests/env/packages/env_test_freetype_linux.py +++ b/tests/env/packages/env_test_freetype_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'freetype' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_fribidi_linux.py b/tests/env/packages/env_test_fribidi_linux.py index 77c96c94..09b1c1e7 100644 --- a/tests/env/packages/env_test_fribidi_linux.py +++ b/tests/env/packages/env_test_fribidi_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'fribidi' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_fsspec.py b/tests/env/packages/env_test_fsspec.py index 0748d17b..8df2caa6 100644 --- a/tests/env/packages/env_test_fsspec.py +++ b/tests/env/packages/env_test_fsspec.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'fsspec' package""" -import logging import argparse +import logging # package to test import fsspec # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_gcovr.py b/tests/env/packages/env_test_gcovr.py index ba65b11b..9c620881 100644 --- a/tests/env/packages/env_test_gcovr.py +++ b/tests/env/packages/env_test_gcovr.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gcovr' package""" -import logging import argparse +import logging # package to test import gcovr # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_gdk-pixbuf_linux.py b/tests/env/packages/env_test_gdk-pixbuf_linux.py index 0bff86f7..95775e19 100644 --- a/tests/env/packages/env_test_gdk-pixbuf_linux.py +++ b/tests/env/packages/env_test_gdk-pixbuf_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'gdk-pixbuf' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_gettext_linux.py b/tests/env/packages/env_test_gettext_linux.py index cf02c677..13c922fd 100644 --- a/tests/env/packages/env_test_gettext_linux.py +++ b/tests/env/packages/env_test_gettext_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gettext' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_gitdb.py b/tests/env/packages/env_test_gitdb.py index 9a46ce4d..226a6ff1 100644 --- a/tests/env/packages/env_test_gitdb.py +++ b/tests/env/packages/env_test_gitdb.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gitdb' package""" -import logging import argparse +import logging # package to test import gitdb # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_gitpython.py b/tests/env/packages/env_test_gitpython.py index b04a1db3..1023aa49 100644 --- a/tests/env/packages/env_test_gitpython.py +++ b/tests/env/packages/env_test_gitpython.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gitpython' package""" -import logging import argparse +import logging # package to test import git # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_glib_linux.py b/tests/env/packages/env_test_glib_linux.py index def19d30..ad532f1a 100644 --- a/tests/env/packages/env_test_glib_linux.py +++ b/tests/env/packages/env_test_glib_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'glib' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_gobject-introspection_linux.py b/tests/env/packages/env_test_gobject-introspection_linux.py index 453bf276..713dd341 100644 --- a/tests/env/packages/env_test_gobject-introspection_linux.py +++ b/tests/env/packages/env_test_gobject-introspection_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'gobject-introspection' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_gprof2dot.py b/tests/env/packages/env_test_gprof2dot.py index 72d25618..0f8a3a93 100644 --- a/tests/env/packages/env_test_gprof2dot.py +++ b/tests/env/packages/env_test_gprof2dot.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gprof2dot' package""" -import logging import argparse +import logging # package to test import gprof2dot # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_graphite2_linux.py b/tests/env/packages/env_test_graphite2_linux.py index 30bff984..701abe47 100644 --- a/tests/env/packages/env_test_graphite2_linux.py +++ b/tests/env/packages/env_test_graphite2_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'graphite2' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_graphviz_win32.py b/tests/env/packages/env_test_graphviz_win32.py index 655e1bf4..4a3bd036 100644 --- a/tests/env/packages/env_test_graphviz_win32.py +++ b/tests/env/packages/env_test_graphviz_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'graphviz' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_gst-plugins-base_linux.py b/tests/env/packages/env_test_gst-plugins-base_linux.py index 52679399..7aa4df15 100644 --- a/tests/env/packages/env_test_gst-plugins-base_linux.py +++ b/tests/env/packages/env_test_gst-plugins-base_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'gst-plugins-base' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_gstreamer_linux.py b/tests/env/packages/env_test_gstreamer_linux.py index 42b78f7c..b9db21ca 100644 --- a/tests/env/packages/env_test_gstreamer_linux.py +++ b/tests/env/packages/env_test_gstreamer_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gstreamer' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_gtk2_linux.py b/tests/env/packages/env_test_gtk2_linux.py index abe18d2f..40407629 100644 --- a/tests/env/packages/env_test_gtk2_linux.py +++ b/tests/env/packages/env_test_gtk2_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'gtk2' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_harfbuzz_linux.py b/tests/env/packages/env_test_harfbuzz_linux.py index b2356ad0..17314c85 100644 --- a/tests/env/packages/env_test_harfbuzz_linux.py +++ b/tests/env/packages/env_test_harfbuzz_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'harfbuzz' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_httplib2.py b/tests/env/packages/env_test_httplib2.py index 298a15a7..5dc02c0d 100644 --- a/tests/env/packages/env_test_httplib2.py +++ b/tests/env/packages/env_test_httplib2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'httplib2' package""" -import logging import argparse +import logging # package to test import httplib2 # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_icu_linux.py b/tests/env/packages/env_test_icu_linux.py index 0438313a..ead74eb2 100644 --- a/tests/env/packages/env_test_icu_linux.py +++ b/tests/env/packages/env_test_icu_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'icu' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_idna.py b/tests/env/packages/env_test_idna.py index a940ac50..4cc8a3d9 100644 --- a/tests/env/packages/env_test_idna.py +++ b/tests/env/packages/env_test_idna.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'idna' package""" -import logging import argparse +import logging # package to test import idna # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_imagesize.py b/tests/env/packages/env_test_imagesize.py index 5601ca90..dbfd784e 100644 --- a/tests/env/packages/env_test_imagesize.py +++ b/tests/env/packages/env_test_imagesize.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'imagesize' package""" -import logging import argparse +import logging # package to test import imagesize # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ipykernel.py b/tests/env/packages/env_test_ipykernel.py index 50b36058..4b666584 100644 --- a/tests/env/packages/env_test_ipykernel.py +++ b/tests/env/packages/env_test_ipykernel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ipykernel' package""" -import logging import argparse +import logging # package to test import ipykernel # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ipython-genutils.py b/tests/env/packages/env_test_ipython-genutils.py index a1838073..e8d54393 100644 --- a/tests/env/packages/env_test_ipython-genutils.py +++ b/tests/env/packages/env_test_ipython-genutils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'ipython_genutils' package""" -import logging import argparse +import logging # package to test import ipython_genutils # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ipython.py b/tests/env/packages/env_test_ipython.py index 445f0247..8407bc56 100644 --- a/tests/env/packages/env_test_ipython.py +++ b/tests/env/packages/env_test_ipython.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ipython' package""" -import logging import argparse +import logging # package to test import IPython # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ipywidgets.py b/tests/env/packages/env_test_ipywidgets.py index f31e92c5..92011eb1 100644 --- a/tests/env/packages/env_test_ipywidgets.py +++ b/tests/env/packages/env_test_ipywidgets.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ipywidgets' package""" -import logging import argparse +import logging # package to test import ipywidgets # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_isort.py b/tests/env/packages/env_test_isort.py index c121fe86..5ec135ee 100644 --- a/tests/env/packages/env_test_isort.py +++ b/tests/env/packages/env_test_isort.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'isort' package""" -import logging import argparse +import logging # package to test import isort # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jdcal.py b/tests/env/packages/env_test_jdcal.py index 36283d13..c4433898 100644 --- a/tests/env/packages/env_test_jdcal.py +++ b/tests/env/packages/env_test_jdcal.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'jdcal' package""" -import logging import argparse +import logging # package to test import jdcal # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jedi.py b/tests/env/packages/env_test_jedi.py index de37ab66..1170c6b5 100644 --- a/tests/env/packages/env_test_jedi.py +++ b/tests/env/packages/env_test_jedi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'jedi' package""" -import logging import argparse +import logging # package to test import jedi # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jinja2.py b/tests/env/packages/env_test_jinja2.py index c2e71017..bf36ad50 100644 --- a/tests/env/packages/env_test_jinja2.py +++ b/tests/env/packages/env_test_jinja2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'jinja2' package""" -import logging import argparse +import logging # package to test import jinja2 # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_joblib.py b/tests/env/packages/env_test_joblib.py index 5a7f5ad6..51284477 100644 --- a/tests/env/packages/env_test_joblib.py +++ b/tests/env/packages/env_test_joblib.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'joblib' package""" -import logging import argparse +import logging # package to test import joblib # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jpeg_linux.py b/tests/env/packages/env_test_jpeg_linux.py index b95640ed..684bc23f 100644 --- a/tests/env/packages/env_test_jpeg_linux.py +++ b/tests/env/packages/env_test_jpeg_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'jpeg' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_jsonschema.py b/tests/env/packages/env_test_jsonschema.py index 027b153c..223a9740 100644 --- a/tests/env/packages/env_test_jsonschema.py +++ b/tests/env/packages/env_test_jsonschema.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'jsonschema' package""" -import logging import argparse +import logging # package to test import jsonschema # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jupyter-client.py b/tests/env/packages/env_test_jupyter-client.py index bc1bd06b..649d7bc0 100644 --- a/tests/env/packages/env_test_jupyter-client.py +++ b/tests/env/packages/env_test_jupyter-client.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import jupyter_client # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jupyter-console.py b/tests/env/packages/env_test_jupyter-console.py index 363a65e1..279dcace 100644 --- a/tests/env/packages/env_test_jupyter-console.py +++ b/tests/env/packages/env_test_jupyter-console.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -43,8 +43,8 @@ """Testing 'jupyter_console' package""" -import logging import argparse +import logging # package to test import jupyter_console # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jupyter-core.py b/tests/env/packages/env_test_jupyter-core.py index d6ce2017..7560edf3 100644 --- a/tests/env/packages/env_test_jupyter-core.py +++ b/tests/env/packages/env_test_jupyter-core.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'jupyter_core' package""" -import logging import argparse +import logging # package to test import jupyter_core # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jupyter.py b/tests/env/packages/env_test_jupyter.py index a95b26ee..0589468b 100644 --- a/tests/env/packages/env_test_jupyter.py +++ b/tests/env/packages/env_test_jupyter.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'jupyter' package""" -import logging import argparse +import logging # package to test import jupyter # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jupyterlab-pygments.py b/tests/env/packages/env_test_jupyterlab-pygments.py index 5e599336..7eff8043 100644 --- a/tests/env/packages/env_test_jupyterlab-pygments.py +++ b/tests/env/packages/env_test_jupyterlab-pygments.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'jupyterlab_pygments' package""" -import logging import argparse +import logging # package to test import jupyterlab_pygments # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_jupyterlab-widgets.py b/tests/env/packages/env_test_jupyterlab-widgets.py index 3c12b59f..a07bd500 100644 --- a/tests/env/packages/env_test_jupyterlab-widgets.py +++ b/tests/env/packages/env_test_jupyterlab-widgets.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import jupyterlab_widgets diff --git a/tests/env/packages/env_test_kiwisolver.py b/tests/env/packages/env_test_kiwisolver.py index ad6760ff..40e0fc08 100644 --- a/tests/env/packages/env_test_kiwisolver.py +++ b/tests/env/packages/env_test_kiwisolver.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'kiwisolver' package""" -import logging import argparse +import logging # package to test import kiwisolver # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_latexcodec.py b/tests/env/packages/env_test_latexcodec.py index 0086536a..0c9dd0e3 100644 --- a/tests/env/packages/env_test_latexcodec.py +++ b/tests/env/packages/env_test_latexcodec.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'latexcodec' package""" -import logging import argparse +import logging # package to test import latexcodec # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_lazy-object-proxy.py b/tests/env/packages/env_test_lazy-object-proxy.py index 3fe3d4c1..d1d59da5 100644 --- a/tests/env/packages/env_test_lazy-object-proxy.py +++ b/tests/env/packages/env_test_lazy-object-proxy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'lazy-object-proxy' package""" -import logging import argparse +import logging # package to test import lazy_object_proxy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ld_impl_linux-64_linux.py b/tests/env/packages/env_test_ld_impl_linux-64_linux.py index 794897ad..4490d920 100644 --- a/tests/env/packages/env_test_ld_impl_linux-64_linux.py +++ b/tests/env/packages/env_test_ld_impl_linux-64_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'ld_impl_linux-64' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libffi_linux.py b/tests/env/packages/env_test_libffi_linux.py index 7d371cef..4f94c6ce 100644 --- a/tests/env/packages/env_test_libffi_linux.py +++ b/tests/env/packages/env_test_libffi_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libffi' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libgcc-ng_linux.py b/tests/env/packages/env_test_libgcc-ng_linux.py index d7184389..3cd87c72 100644 --- a/tests/env/packages/env_test_libgcc-ng_linux.py +++ b/tests/env/packages/env_test_libgcc-ng_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'libgcc-ng' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libglib_linux.py b/tests/env/packages/env_test_libglib_linux.py index 8eec5c35..35eb9e06 100644 --- a/tests/env/packages/env_test_libglib_linux.py +++ b/tests/env/packages/env_test_libglib_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libglib' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libglu_linux.py b/tests/env/packages/env_test_libglu_linux.py index f370debb..99b9ee0a 100644 --- a/tests/env/packages/env_test_libglu_linux.py +++ b/tests/env/packages/env_test_libglu_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libglu' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libgomp_linux.py b/tests/env/packages/env_test_libgomp_linux.py index 3717cb80..780be706 100644 --- a/tests/env/packages/env_test_libgomp_linux.py +++ b/tests/env/packages/env_test_libgomp_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libgomp' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libiconv_linux.py b/tests/env/packages/env_test_libiconv_linux.py index 611e4866..e2b3efe5 100644 --- a/tests/env/packages/env_test_libiconv_linux.py +++ b/tests/env/packages/env_test_libiconv_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libiconv' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libogg_linux.py b/tests/env/packages/env_test_libogg_linux.py index 83a0c3d2..15b7b3ef 100644 --- a/tests/env/packages/env_test_libogg_linux.py +++ b/tests/env/packages/env_test_libogg_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libogg' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libopus_linux.py b/tests/env/packages/env_test_libopus_linux.py index f93e7bd3..c252c7ed 100644 --- a/tests/env/packages/env_test_libopus_linux.py +++ b/tests/env/packages/env_test_libopus_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libopus' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libpng_linux.py b/tests/env/packages/env_test_libpng_linux.py index 81b8c3a4..6ab8e239 100644 --- a/tests/env/packages/env_test_libpng_linux.py +++ b/tests/env/packages/env_test_libpng_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libpng' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libstdcxx-ng_linux.py b/tests/env/packages/env_test_libstdcxx-ng_linux.py index aad09fdb..d520d346 100644 --- a/tests/env/packages/env_test_libstdcxx-ng_linux.py +++ b/tests/env/packages/env_test_libstdcxx-ng_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'libstdcxx-ng' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libtiff_linux.py b/tests/env/packages/env_test_libtiff_linux.py index 77805e3a..47ab4301 100644 --- a/tests/env/packages/env_test_libtiff_linux.py +++ b/tests/env/packages/env_test_libtiff_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libtiff' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libuuid_linux.py b/tests/env/packages/env_test_libuuid_linux.py index c970cf36..187b5a73 100644 --- a/tests/env/packages/env_test_libuuid_linux.py +++ b/tests/env/packages/env_test_libuuid_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libuuid' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libvorbis_linux.py b/tests/env/packages/env_test_libvorbis_linux.py index 8ebb02a0..ab04cf84 100644 --- a/tests/env/packages/env_test_libvorbis_linux.py +++ b/tests/env/packages/env_test_libvorbis_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libvorbis' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libwebp-base_linux.py b/tests/env/packages/env_test_libwebp-base_linux.py index 04723a6a..a2450c36 100644 --- a/tests/env/packages/env_test_libwebp-base_linux.py +++ b/tests/env/packages/env_test_libwebp-base_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'libwebp-base' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libxcb_linux.py b/tests/env/packages/env_test_libxcb_linux.py index e67dac51..a34a12ed 100644 --- a/tests/env/packages/env_test_libxcb_linux.py +++ b/tests/env/packages/env_test_libxcb_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libxcb' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_libxml2_linux.py b/tests/env/packages/env_test_libxml2_linux.py index d86f61f0..435cff9e 100644 --- a/tests/env/packages/env_test_libxml2_linux.py +++ b/tests/env/packages/env_test_libxml2_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'libxml2' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_locket.py b/tests/env/packages/env_test_locket.py index 8475c421..72a90c3e 100644 --- a/tests/env/packages/env_test_locket.py +++ b/tests/env/packages/env_test_locket.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'locket' package""" -import logging import argparse +import logging # package to test import locket # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_lxml.py b/tests/env/packages/env_test_lxml.py index 004e6fd7..0d953360 100644 --- a/tests/env/packages/env_test_lxml.py +++ b/tests/env/packages/env_test_lxml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'lxml' package""" -import logging import argparse +import logging # package to test import lxml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_lz4-c_linux.py b/tests/env/packages/env_test_lz4-c_linux.py index 63b4582d..49e43a38 100644 --- a/tests/env/packages/env_test_lz4-c_linux.py +++ b/tests/env/packages/env_test_lz4-c_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'lz4-c' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_markdown.py b/tests/env/packages/env_test_markdown.py index 4f7d38f6..c2bc3d41 100644 --- a/tests/env/packages/env_test_markdown.py +++ b/tests/env/packages/env_test_markdown.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'markdown' package""" -import logging import argparse +import logging # package to test import markdown # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_markupsafe.py b/tests/env/packages/env_test_markupsafe.py index 65db4a63..4e980707 100644 --- a/tests/env/packages/env_test_markupsafe.py +++ b/tests/env/packages/env_test_markupsafe.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'markupsafe' package""" -import logging import argparse +import logging # package to test import markupsafe # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_matplotlib-inline.py b/tests/env/packages/env_test_matplotlib-inline.py index 5673628e..91394b1b 100644 --- a/tests/env/packages/env_test_matplotlib-inline.py +++ b/tests/env/packages/env_test_matplotlib-inline.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import matplotlib # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_matplotlib.py b/tests/env/packages/env_test_matplotlib.py index 499bcd88..a12a4d9c 100644 --- a/tests/env/packages/env_test_matplotlib.py +++ b/tests/env/packages/env_test_matplotlib.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'matplotlib' package""" -import logging import argparse +import logging # package to test import matplotlib # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_mccabe.py b/tests/env/packages/env_test_mccabe.py index e9f4b87e..56199519 100644 --- a/tests/env/packages/env_test_mccabe.py +++ b/tests/env/packages/env_test_mccabe.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'mccabe' package""" -import logging import argparse +import logging # package to test import mccabe # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_mistune.py b/tests/env/packages/env_test_mistune.py index 5b30a1ad..3034be0b 100644 --- a/tests/env/packages/env_test_mistune.py +++ b/tests/env/packages/env_test_mistune.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'mistune' package""" -import logging import argparse +import logging # package to test import mistune # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_msgpack_linux.py b/tests/env/packages/env_test_msgpack_linux.py index e2c6d983..544dc159 100644 --- a/tests/env/packages/env_test_msgpack_linux.py +++ b/tests/env/packages/env_test_msgpack_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'msgpack' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_mypy-extensions.py b/tests/env/packages/env_test_mypy-extensions.py index 00a22a4e..11411b8f 100644 --- a/tests/env/packages/env_test_mypy-extensions.py +++ b/tests/env/packages/env_test_mypy-extensions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'mypy-extensions' package""" -import logging import argparse +import logging # package to test import mypy_extensions # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_mypy.py b/tests/env/packages/env_test_mypy.py index 9c71452d..776e360b 100644 --- a/tests/env/packages/env_test_mypy.py +++ b/tests/env/packages/env_test_mypy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'mypy' package""" -import logging import argparse +import logging # package to test import mypy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_nbclient.py b/tests/env/packages/env_test_nbclient.py index 74e1db50..80352dd3 100644 --- a/tests/env/packages/env_test_nbclient.py +++ b/tests/env/packages/env_test_nbclient.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'nbclient' package""" -import logging import argparse +import logging # package to test import nbclient # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_nbconvert.py b/tests/env/packages/env_test_nbconvert.py index 1dea4969..a5573ba0 100644 --- a/tests/env/packages/env_test_nbconvert.py +++ b/tests/env/packages/env_test_nbconvert.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'nbconvert' package""" -import logging import argparse +import logging # package to test import nbconvert # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_nbformat.py b/tests/env/packages/env_test_nbformat.py index c7ca6b4f..93b0dd04 100644 --- a/tests/env/packages/env_test_nbformat.py +++ b/tests/env/packages/env_test_nbformat.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'nbformat' package""" -import logging import argparse +import logging # package to test import nbformat # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ncurses_linux.py b/tests/env/packages/env_test_ncurses_linux.py index 3873249c..c6cfb79c 100644 --- a/tests/env/packages/env_test_ncurses_linux.py +++ b/tests/env/packages/env_test_ncurses_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ncurses' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_nest-asyncio.py b/tests/env/packages/env_test_nest-asyncio.py index 6c41ba66..27ae1b47 100644 --- a/tests/env/packages/env_test_nest-asyncio.py +++ b/tests/env/packages/env_test_nest-asyncio.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'nest-asyncio' package""" -import logging import argparse +import logging # package to test import nest_asyncio # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ninja_linux.py b/tests/env/packages/env_test_ninja_linux.py index 1f95c7b0..e714237e 100644 --- a/tests/env/packages/env_test_ninja_linux.py +++ b/tests/env/packages/env_test_ninja_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ninja' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_notebook.py b/tests/env/packages/env_test_notebook.py index 886bc25b..043ee652 100644 --- a/tests/env/packages/env_test_notebook.py +++ b/tests/env/packages/env_test_notebook.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'notebook' package""" -import logging import argparse +import logging # package to test import notebook # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_numpy.py b/tests/env/packages/env_test_numpy.py index accce7f9..4d5354fe 100644 --- a/tests/env/packages/env_test_numpy.py +++ b/tests/env/packages/env_test_numpy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'numpy' package""" -import logging import argparse +import logging # package to test import numpy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_openpyxl.py b/tests/env/packages/env_test_openpyxl.py index 69821091..0473eb53 100644 --- a/tests/env/packages/env_test_openpyxl.py +++ b/tests/env/packages/env_test_openpyxl.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'openpyxl' package""" -import logging import argparse +import logging # package to test import openpyxl # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_openssl.py b/tests/env/packages/env_test_openssl.py index eb386f42..2b3929ec 100644 --- a/tests/env/packages/env_test_openssl.py +++ b/tests/env/packages/env_test_openssl.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'openssl' package""" -import logging import argparse +import logging # package to test # nothing to test diff --git a/tests/env/packages/env_test_packaging.py b/tests/env/packages/env_test_packaging.py index 8b087560..280cd820 100644 --- a/tests/env/packages/env_test_packaging.py +++ b/tests/env/packages/env_test_packaging.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'packaging' package""" -import logging import argparse +import logging # package to test import packaging # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pandas-stubs.py b/tests/env/packages/env_test_pandas-stubs.py index 94cc6f79..e24a9007 100644 --- a/tests/env/packages/env_test_pandas-stubs.py +++ b/tests/env/packages/env_test_pandas-stubs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import pandas # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pandas.py b/tests/env/packages/env_test_pandas.py index d2b6fb7d..a09f0758 100644 --- a/tests/env/packages/env_test_pandas.py +++ b/tests/env/packages/env_test_pandas.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pandas' package""" -import logging import argparse +import logging # package to test import pandas # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pandoc.py b/tests/env/packages/env_test_pandoc.py index 498faa1f..bf60eead 100644 --- a/tests/env/packages/env_test_pandoc.py +++ b/tests/env/packages/env_test_pandoc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pandoc' package""" -import logging import argparse +import logging import shutil diff --git a/tests/env/packages/env_test_pandocfilters.py b/tests/env/packages/env_test_pandocfilters.py index 22dfaa0c..92897617 100644 --- a/tests/env/packages/env_test_pandocfilters.py +++ b/tests/env/packages/env_test_pandocfilters.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pandocfilters' package""" -import logging import argparse +import logging # package to test import pandocfilters # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pango_linux.py b/tests/env/packages/env_test_pango_linux.py index ec53c084..0984062f 100644 --- a/tests/env/packages/env_test_pango_linux.py +++ b/tests/env/packages/env_test_pango_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pango' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_parso.py b/tests/env/packages/env_test_parso.py index dae49635..e4185396 100644 --- a/tests/env/packages/env_test_parso.py +++ b/tests/env/packages/env_test_parso.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'parso' package""" -import logging import argparse +import logging # package to test import parso # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_partd.py b/tests/env/packages/env_test_partd.py index b9c3a23e..1ec8ff04 100644 --- a/tests/env/packages/env_test_partd.py +++ b/tests/env/packages/env_test_partd.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'partd' package""" -import logging import argparse +import logging # package to test import partd # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pathlib2_linux.py b/tests/env/packages/env_test_pathlib2_linux.py index 87e4f7a1..a8997c96 100644 --- a/tests/env/packages/env_test_pathlib2_linux.py +++ b/tests/env/packages/env_test_pathlib2_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pathlib2' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pathspec.py b/tests/env/packages/env_test_pathspec.py index 12d8cbcb..ca0e16aa 100644 --- a/tests/env/packages/env_test_pathspec.py +++ b/tests/env/packages/env_test_pathspec.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pathspec' package""" -import logging import argparse +import logging # package to test import pathspec # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_patsy.py b/tests/env/packages/env_test_patsy.py index e5c535d0..c13bb1fa 100644 --- a/tests/env/packages/env_test_patsy.py +++ b/tests/env/packages/env_test_patsy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'patsy' package""" -import logging import argparse +import logging # package to test import patsy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pcre_linux.py b/tests/env/packages/env_test_pcre_linux.py index d8597491..22b7ca61 100644 --- a/tests/env/packages/env_test_pcre_linux.py +++ b/tests/env/packages/env_test_pcre_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pcre' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pexpect_linux.py b/tests/env/packages/env_test_pexpect_linux.py index a6401302..6fd626af 100644 --- a/tests/env/packages/env_test_pexpect_linux.py +++ b/tests/env/packages/env_test_pexpect_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pexpect' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pickleshare.py b/tests/env/packages/env_test_pickleshare.py index 1c63e5c0..738b34a8 100644 --- a/tests/env/packages/env_test_pickleshare.py +++ b/tests/env/packages/env_test_pickleshare.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pickleshare' package""" -import logging import argparse +import logging # package to test import pickleshare # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pillow.py b/tests/env/packages/env_test_pillow.py index 2c035033..d0ff542d 100644 --- a/tests/env/packages/env_test_pillow.py +++ b/tests/env/packages/env_test_pillow.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pillow' package""" -import logging import argparse +import logging # package to test import PIL # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pip-licenses.py b/tests/env/packages/env_test_pip-licenses.py index 113263fa..6f008fdc 100644 --- a/tests/env/packages/env_test_pip-licenses.py +++ b/tests/env/packages/env_test_pip-licenses.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'pip-licenses' package""" -import logging import argparse +import logging # package to test import piplicenses # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pip.py b/tests/env/packages/env_test_pip.py index 131830f0..88c5c480 100644 --- a/tests/env/packages/env_test_pip.py +++ b/tests/env/packages/env_test_pip.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pip' package""" -import logging import argparse +import logging # package to test import pip # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pixman_linux.py b/tests/env/packages/env_test_pixman_linux.py index eff26081..060b8f7c 100644 --- a/tests/env/packages/env_test_pixman_linux.py +++ b/tests/env/packages/env_test_pixman_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pixman' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_plantuml-markdown.py b/tests/env/packages/env_test_plantuml-markdown.py index 15d4b92a..12d132b5 100644 --- a/tests/env/packages/env_test_plantuml-markdown.py +++ b/tests/env/packages/env_test_plantuml-markdown.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'plantuml-markdown' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_plantuml.py b/tests/env/packages/env_test_plantuml.py index 9155a4bc..283e696d 100644 --- a/tests/env/packages/env_test_plantuml.py +++ b/tests/env/packages/env_test_plantuml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'plantuml' package""" -import logging import argparse +import logging # package to test import plantuml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_platformdirs.py b/tests/env/packages/env_test_platformdirs.py index 7d8c72ae..a531681b 100644 --- a/tests/env/packages/env_test_platformdirs.py +++ b/tests/env/packages/env_test_platformdirs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'platformdirs' package""" -import logging import argparse +import logging # package to test import platformdirs # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_plotly.py b/tests/env/packages/env_test_plotly.py index 3e4c603c..d8f69991 100644 --- a/tests/env/packages/env_test_plotly.py +++ b/tests/env/packages/env_test_plotly.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'plotly' package""" -import logging import argparse +import logging # package to test import plotly # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_powershell_shortcut_win32.py b/tests/env/packages/env_test_powershell_shortcut_win32.py index f0eb3842..dd213fc1 100644 --- a/tests/env/packages/env_test_powershell_shortcut_win32.py +++ b/tests/env/packages/env_test_powershell_shortcut_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'powershell_shortcut' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_prometheus-client.py b/tests/env/packages/env_test_prometheus-client.py index 20dffcee..071a6e5e 100644 --- a/tests/env/packages/env_test_prometheus-client.py +++ b/tests/env/packages/env_test_prometheus-client.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import prometheus_client # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_prompt-toolkit.py b/tests/env/packages/env_test_prompt-toolkit.py index 2be5963c..692355cc 100644 --- a/tests/env/packages/env_test_prompt-toolkit.py +++ b/tests/env/packages/env_test_prompt-toolkit.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'prompt-toolkit' package""" -import logging import argparse +import logging # package to test import prompt_toolkit # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_psutil.py b/tests/env/packages/env_test_psutil.py index 2e0fa7a6..a450370d 100644 --- a/tests/env/packages/env_test_psutil.py +++ b/tests/env/packages/env_test_psutil.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'psutil' package""" -import logging import argparse +import logging # package to test import psutil # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ptable.py b/tests/env/packages/env_test_ptable.py index 59e1e325..da895b08 100644 --- a/tests/env/packages/env_test_ptable.py +++ b/tests/env/packages/env_test_ptable.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ptable' package""" -import logging import argparse +import logging # package to test import prettytable # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pthread-stubs_linux.py b/tests/env/packages/env_test_pthread-stubs_linux.py index 167d9a9f..ed51d3f9 100644 --- a/tests/env/packages/env_test_pthread-stubs_linux.py +++ b/tests/env/packages/env_test_pthread-stubs_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'pthread-stubs' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_ptyprocess_linux.py b/tests/env/packages/env_test_ptyprocess_linux.py index ce1ecaa5..1a1cac8b 100644 --- a/tests/env/packages/env_test_ptyprocess_linux.py +++ b/tests/env/packages/env_test_ptyprocess_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'ptyprocess' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pybtex-docutils.py b/tests/env/packages/env_test_pybtex-docutils.py index b5024911..6e3eb8a9 100644 --- a/tests/env/packages/env_test_pybtex-docutils.py +++ b/tests/env/packages/env_test_pybtex-docutils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,9 +42,9 @@ """Testing 'pybtex-docutils' package""" -import logging import argparse import io +import logging # package to test import pybtex.database.input.bibtex diff --git a/tests/env/packages/env_test_pybtex.py b/tests/env/packages/env_test_pybtex.py index afa8657b..5172820e 100644 --- a/tests/env/packages/env_test_pybtex.py +++ b/tests/env/packages/env_test_pybtex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pybtex' package""" -import logging import argparse +import logging # package to test import pybtex # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pycparser.py b/tests/env/packages/env_test_pycparser.py index 32a5bda3..e334bd57 100644 --- a/tests/env/packages/env_test_pycparser.py +++ b/tests/env/packages/env_test_pycparser.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pycparser' package""" -import logging import argparse +import logging # package to test import pycparser # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pyenchant.py b/tests/env/packages/env_test_pyenchant.py index d44d62aa..ff898f79 100644 --- a/tests/env/packages/env_test_pyenchant.py +++ b/tests/env/packages/env_test_pyenchant.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyenchant' package""" -import logging import argparse +import logging # package to test import enchant # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pygments.py b/tests/env/packages/env_test_pygments.py index 2c50610d..576a29ae 100644 --- a/tests/env/packages/env_test_pygments.py +++ b/tests/env/packages/env_test_pygments.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pygments' package""" -import logging import argparse +import logging # package to test import pygments # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pykwalify.py b/tests/env/packages/env_test_pykwalify.py index 041e2b0c..8d861a57 100644 --- a/tests/env/packages/env_test_pykwalify.py +++ b/tests/env/packages/env_test_pykwalify.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pykwalify' package""" -import logging import argparse +import logging # package to test import pykwalify # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pylint.py b/tests/env/packages/env_test_pylint.py index 7a644e49..201727a4 100644 --- a/tests/env/packages/env_test_pylint.py +++ b/tests/env/packages/env_test_pylint.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pylint' package""" -import logging import argparse +import logging # package to test import pylint # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pyopenssl_linux.py b/tests/env/packages/env_test_pyopenssl_linux.py index bf76bf8c..2fd3fc2a 100644 --- a/tests/env/packages/env_test_pyopenssl_linux.py +++ b/tests/env/packages/env_test_pyopenssl_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyopenssl' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pyparsing.py b/tests/env/packages/env_test_pyparsing.py index 555d256c..75d8bd2d 100644 --- a/tests/env/packages/env_test_pyparsing.py +++ b/tests/env/packages/env_test_pyparsing.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyparsing' package""" -import logging import argparse +import logging # package to test import pyparsing # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pypubsub_linux.py b/tests/env/packages/env_test_pypubsub_linux.py index ddc088c1..5d384a74 100644 --- a/tests/env/packages/env_test_pypubsub_linux.py +++ b/tests/env/packages/env_test_pypubsub_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pypubsub' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pyrsistent.py b/tests/env/packages/env_test_pyrsistent.py index d2632b93..32bc2fa3 100644 --- a/tests/env/packages/env_test_pyrsistent.py +++ b/tests/env/packages/env_test_pyrsistent.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyrsistent' package""" -import logging import argparse +import logging # package to test import pyrsistent # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pyserial.py b/tests/env/packages/env_test_pyserial.py index c7d85223..64b631db 100644 --- a/tests/env/packages/env_test_pyserial.py +++ b/tests/env/packages/env_test_pyserial.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyserial' package""" -import logging import argparse +import logging # package to test import serial # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pysimplegui.py b/tests/env/packages/env_test_pysimplegui.py index 7f4c7738..9d7ab39d 100644 --- a/tests/env/packages/env_test_pysimplegui.py +++ b/tests/env/packages/env_test_pysimplegui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pysimplegui' package""" -import logging import argparse +import logging # package to test import PySimpleGUI # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pysocks_linux.py b/tests/env/packages/env_test_pysocks_linux.py index 48a52349..817c3b54 100644 --- a/tests/env/packages/env_test_pysocks_linux.py +++ b/tests/env/packages/env_test_pysocks_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pysocks' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_python-can.py b/tests/env/packages/env_test_python-can.py index d61faaea..3d84d0f9 100644 --- a/tests/env/packages/env_test_python-can.py +++ b/tests/env/packages/env_test_python-can.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'python-can' package""" -import logging import argparse +import logging # package to test import can # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_python-datauri.py b/tests/env/packages/env_test_python-datauri.py index b71c86b5..ae0f8e14 100644 --- a/tests/env/packages/env_test_python-datauri.py +++ b/tests/env/packages/env_test_python-datauri.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'python-datauri' package""" -import logging import argparse +import logging # package to test import datauri diff --git a/tests/env/packages/env_test_python-dateutil.py b/tests/env/packages/env_test_python-dateutil.py index 1a46c60f..c748eb53 100644 --- a/tests/env/packages/env_test_python-dateutil.py +++ b/tests/env/packages/env_test_python-dateutil.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,11 +42,11 @@ """Testing 'python-dateutil' package""" -import logging import argparse # packages needed for tests import datetime +import logging # package to test import dateutil diff --git a/tests/env/packages/env_test_python-lin.py b/tests/env/packages/env_test_python-lin.py index d042ea18..d2e561b6 100644 --- a/tests/env/packages/env_test_python-lin.py +++ b/tests/env/packages/env_test_python-lin.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import lin # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_python-markdown-math.py b/tests/env/packages/env_test_python-markdown-math.py index c83a3dc9..667aa9d0 100644 --- a/tests/env/packages/env_test_python-markdown-math.py +++ b/tests/env/packages/env_test_python-markdown-math.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'python-markdown-math' package""" -import logging import argparse +import logging # package to test import markdown # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_python-uds.py b/tests/env/packages/env_test_python-uds.py index e411c5ec..26791074 100644 --- a/tests/env/packages/env_test_python-uds.py +++ b/tests/env/packages/env_test_python-uds.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import uds # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_python.py b/tests/env/packages/env_test_python.py index 98131383..15df55ec 100644 --- a/tests/env/packages/env_test_python.py +++ b/tests/env/packages/env_test_python.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -39,9 +39,9 @@ # - "This product is derived from foxBMS®" """Testing 'python' package""" -import sys -import logging import argparse +import logging +import sys # nothing to test diff --git a/tests/env/packages/env_test_python_abi_linux.py b/tests/env/packages/env_test_python_abi_linux.py index 62bfb559..058c0ee6 100644 --- a/tests/env/packages/env_test_python_abi_linux.py +++ b/tests/env/packages/env_test_python_abi_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'python_abi' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_pytz.py b/tests/env/packages/env_test_pytz.py index b85e6d01..f1bbc1e2 100644 --- a/tests/env/packages/env_test_pytz.py +++ b/tests/env/packages/env_test_pytz.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pytz' package""" -import logging import argparse +import logging # package to test import pytz # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pyvisa.py b/tests/env/packages/env_test_pyvisa.py index e9158699..01fd1aa8 100644 --- a/tests/env/packages/env_test_pyvisa.py +++ b/tests/env/packages/env_test_pyvisa.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyvisa' package""" -import logging import argparse +import logging # package to test import pyvisa # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pywin32_win32.py b/tests/env/packages/env_test_pywin32_win32.py index 544c8c3e..717d744a 100644 --- a/tests/env/packages/env_test_pywin32_win32.py +++ b/tests/env/packages/env_test_pywin32_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pywin32' package""" -import logging import argparse +import logging # package to test import win32api # pylint: disable=unused-import,import-error diff --git a/tests/env/packages/env_test_pywinpty_win32.py b/tests/env/packages/env_test_pywinpty_win32.py index bb15fb18..f17418cf 100644 --- a/tests/env/packages/env_test_pywinpty_win32.py +++ b/tests/env/packages/env_test_pywinpty_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pywinpty' package""" -import logging import argparse +import logging # package to test import winpty # pylint: disable=unused-import,import-error diff --git a/tests/env/packages/env_test_pyyaml.py b/tests/env/packages/env_test_pyyaml.py index 198de5a5..53bd3930 100644 --- a/tests/env/packages/env_test_pyyaml.py +++ b/tests/env/packages/env_test_pyyaml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyyaml' package""" -import logging import argparse +import logging # package to test import yaml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_pyzmq.py b/tests/env/packages/env_test_pyzmq.py index 048efd10..161e7a26 100644 --- a/tests/env/packages/env_test_pyzmq.py +++ b/tests/env/packages/env_test_pyzmq.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'pyzmq' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_qtconsole.py b/tests/env/packages/env_test_qtconsole.py index 452a7c13..7b92f65f 100644 --- a/tests/env/packages/env_test_qtconsole.py +++ b/tests/env/packages/env_test_qtconsole.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'qtconsole' package""" -import logging import argparse +import logging # package to test import qtconsole # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_qtpy.py b/tests/env/packages/env_test_qtpy.py index 07c4d599..09e3318b 100644 --- a/tests/env/packages/env_test_qtpy.py +++ b/tests/env/packages/env_test_qtpy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'qtpy' package""" -import logging import argparse +import logging # package to test # import qtpy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_readline_linux.py b/tests/env/packages/env_test_readline_linux.py index 9804630d..c71a6bf2 100644 --- a/tests/env/packages/env_test_readline_linux.py +++ b/tests/env/packages/env_test_readline_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'readline' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_regex.py b/tests/env/packages/env_test_regex.py index 6762539c..6cfcc377 100644 --- a/tests/env/packages/env_test_regex.py +++ b/tests/env/packages/env_test_regex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'regex' package""" -import logging import argparse +import logging # package to test import regex # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_requests-file.py b/tests/env/packages/env_test_requests-file.py index 98111b7b..d55d9398 100644 --- a/tests/env/packages/env_test_requests-file.py +++ b/tests/env/packages/env_test_requests-file.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import requests diff --git a/tests/env/packages/env_test_requests.py b/tests/env/packages/env_test_requests.py index 88cda7ad..4a531257 100644 --- a/tests/env/packages/env_test_requests.py +++ b/tests/env/packages/env_test_requests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'requests' package""" -import logging import argparse +import logging # package to test import requests # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_rope.py b/tests/env/packages/env_test_rope.py index 9d056746..ad04c0cb 100644 --- a/tests/env/packages/env_test_rope.py +++ b/tests/env/packages/env_test_rope.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'rope' package""" -import logging import argparse +import logging # package to test import rope # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_rsinstrument.py b/tests/env/packages/env_test_rsinstrument.py index 0ee8e475..175742d3 100644 --- a/tests/env/packages/env_test_rsinstrument.py +++ b/tests/env/packages/env_test_rsinstrument.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'rsinstrument' package""" -import logging import argparse +import logging # package to test import RsInstrument # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ruamel-yaml-clib.py b/tests/env/packages/env_test_ruamel-yaml-clib.py index 01b8d227..cbf95e81 100644 --- a/tests/env/packages/env_test_ruamel-yaml-clib.py +++ b/tests/env/packages/env_test_ruamel-yaml-clib.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'ruamel_yaml' package""" -import logging import argparse +import logging # package to test import yaml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_ruamel-yaml.py b/tests/env/packages/env_test_ruamel-yaml.py index 366749ea..b512105d 100644 --- a/tests/env/packages/env_test_ruamel-yaml.py +++ b/tests/env/packages/env_test_ruamel-yaml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import yaml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_scikit-learn.py b/tests/env/packages/env_test_scikit-learn.py index 69dab3fe..e3fe2f83 100644 --- a/tests/env/packages/env_test_scikit-learn.py +++ b/tests/env/packages/env_test_scikit-learn.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'scikit-learn' package""" -import logging import argparse +import logging # package to test import sklearn # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_scipy.py b/tests/env/packages/env_test_scipy.py index 452fc111..5d75b639 100644 --- a/tests/env/packages/env_test_scipy.py +++ b/tests/env/packages/env_test_scipy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'scipy' package""" -import logging import argparse +import logging # package to test import scipy # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_seaborn.py b/tests/env/packages/env_test_seaborn.py index 7de41f65..13a82877 100644 --- a/tests/env/packages/env_test_seaborn.py +++ b/tests/env/packages/env_test_seaborn.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'seaborn' package""" -import logging import argparse +import logging # package to test import seaborn # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_send2trash.py b/tests/env/packages/env_test_send2trash.py index 00d7c2c3..895bfc69 100644 --- a/tests/env/packages/env_test_send2trash.py +++ b/tests/env/packages/env_test_send2trash.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'send2trash' package""" -import logging import argparse +import logging # package to test import send2trash # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_setuptools.py b/tests/env/packages/env_test_setuptools.py index fc4e0228..6a03c979 100644 --- a/tests/env/packages/env_test_setuptools.py +++ b/tests/env/packages/env_test_setuptools.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'setuptools' package""" -import logging import argparse +import logging # package to test import setuptools # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_six.py b/tests/env/packages/env_test_six.py index b79ffccd..a3725abe 100644 --- a/tests/env/packages/env_test_six.py +++ b/tests/env/packages/env_test_six.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'six' package""" -import logging import argparse +import logging # package to test import six # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_smmap.py b/tests/env/packages/env_test_smmap.py index 6c5e541c..5a71bc8c 100644 --- a/tests/env/packages/env_test_smmap.py +++ b/tests/env/packages/env_test_smmap.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'smmap' package""" -import logging import argparse +import logging # package to test import smmap # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_snowballstemmer.py b/tests/env/packages/env_test_snowballstemmer.py index fb2a9adc..cff9540b 100644 --- a/tests/env/packages/env_test_snowballstemmer.py +++ b/tests/env/packages/env_test_snowballstemmer.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'snowballstemmer' package""" -import logging import argparse +import logging # package to test import snowballstemmer # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_soupsieve.py b/tests/env/packages/env_test_soupsieve.py index 1ff155fc..a5b2a567 100644 --- a/tests/env/packages/env_test_soupsieve.py +++ b/tests/env/packages/env_test_soupsieve.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'soupsieve' package""" -import logging import argparse +import logging # package to test import soupsieve diff --git a/tests/env/packages/env_test_sphinx-copybutton.py b/tests/env/packages/env_test_sphinx-copybutton.py index 3f8e467e..79dedf60 100644 --- a/tests/env/packages/env_test_sphinx-copybutton.py +++ b/tests/env/packages/env_test_sphinx-copybutton.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import sphinx_copybutton # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinx-panels.py b/tests/env/packages/env_test_sphinx-panels.py index 041615b5..3752dd5e 100644 --- a/tests/env/packages/env_test_sphinx-panels.py +++ b/tests/env/packages/env_test_sphinx-panels.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import sphinx_panels # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinx-plotly-directive.py b/tests/env/packages/env_test_sphinx-plotly-directive.py index 6071ecc3..afb166c6 100644 --- a/tests/env/packages/env_test_sphinx-plotly-directive.py +++ b/tests/env/packages/env_test_sphinx-plotly-directive.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinx-plotly_directive' package""" -import logging import argparse +import logging # package to test import sphinx_plotly_directive # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinx-rtd-theme.py b/tests/env/packages/env_test_sphinx-rtd-theme.py index e977193e..77a06c81 100644 --- a/tests/env/packages/env_test_sphinx-rtd-theme.py +++ b/tests/env/packages/env_test_sphinx-rtd-theme.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinx-rtd-theme' package""" -import logging import argparse +import logging # package to test import sphinx_rtd_theme # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinx.py b/tests/env/packages/env_test_sphinx.py index b8b1ef73..b76def30 100644 --- a/tests/env/packages/env_test_sphinx.py +++ b/tests/env/packages/env_test_sphinx.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'sphinx' package""" -import logging import argparse +import logging # package to test import sphinx # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-applehelp.py b/tests/env/packages/env_test_sphinxcontrib-applehelp.py index d7092d7e..f565d10a 100644 --- a/tests/env/packages/env_test_sphinxcontrib-applehelp.py +++ b/tests/env/packages/env_test_sphinxcontrib-applehelp.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-applehelp' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import applehelp # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-bibtex.py b/tests/env/packages/env_test_sphinxcontrib-bibtex.py index c894fbd9..d52f8414 100644 --- a/tests/env/packages/env_test_sphinxcontrib-bibtex.py +++ b/tests/env/packages/env_test_sphinxcontrib-bibtex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-bibtex' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import bibtex # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-devhelp.py b/tests/env/packages/env_test_sphinxcontrib-devhelp.py index 223d5bc2..a41992bd 100644 --- a/tests/env/packages/env_test_sphinxcontrib-devhelp.py +++ b/tests/env/packages/env_test_sphinxcontrib-devhelp.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-devhelp' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import devhelp # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-htmlhelp.py b/tests/env/packages/env_test_sphinxcontrib-htmlhelp.py index d70e46ab..1f01faed 100644 --- a/tests/env/packages/env_test_sphinxcontrib-htmlhelp.py +++ b/tests/env/packages/env_test_sphinxcontrib-htmlhelp.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-htmlhelp' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import htmlhelp # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-jsmath.py b/tests/env/packages/env_test_sphinxcontrib-jsmath.py index 7aea8845..782cfd2f 100644 --- a/tests/env/packages/env_test_sphinxcontrib-jsmath.py +++ b/tests/env/packages/env_test_sphinxcontrib-jsmath.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-jsmath' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import jsmath # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-mermaid.py b/tests/env/packages/env_test_sphinxcontrib-mermaid.py index 98a74c13..b654cd1d 100644 --- a/tests/env/packages/env_test_sphinxcontrib-mermaid.py +++ b/tests/env/packages/env_test_sphinxcontrib-mermaid.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test from sphinxcontrib import mermaid # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-needs.py b/tests/env/packages/env_test_sphinxcontrib-needs.py index c66656d0..44285fd0 100644 --- a/tests/env/packages/env_test_sphinxcontrib-needs.py +++ b/tests/env/packages/env_test_sphinxcontrib-needs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-needs' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import needs # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-plantuml.py b/tests/env/packages/env_test_sphinxcontrib-plantuml.py index 7c100bd2..ec287c2a 100644 --- a/tests/env/packages/env_test_sphinxcontrib-plantuml.py +++ b/tests/env/packages/env_test_sphinxcontrib-plantuml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-plantuml' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import plantuml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-programoutput.py b/tests/env/packages/env_test_sphinxcontrib-programoutput.py index d6be42c3..61b3b3d0 100644 --- a/tests/env/packages/env_test_sphinxcontrib-programoutput.py +++ b/tests/env/packages/env_test_sphinxcontrib-programoutput.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test from sphinxcontrib import programoutput # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-qthelp.py b/tests/env/packages/env_test_sphinxcontrib-qthelp.py index 2c0cbe6f..b4f8d8b3 100644 --- a/tests/env/packages/env_test_sphinxcontrib-qthelp.py +++ b/tests/env/packages/env_test_sphinxcontrib-qthelp.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-qthelp' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import qthelp # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-serializinghtml.py b/tests/env/packages/env_test_sphinxcontrib-serializinghtml.py index ab895ee4..67f76617 100644 --- a/tests/env/packages/env_test_sphinxcontrib-serializinghtml.py +++ b/tests/env/packages/env_test_sphinxcontrib-serializinghtml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-serializinghtml' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import serializinghtml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sphinxcontrib-spelling.py b/tests/env/packages/env_test_sphinxcontrib-spelling.py index 57fa749d..eebe9d5e 100644 --- a/tests/env/packages/env_test_sphinxcontrib-spelling.py +++ b/tests/env/packages/env_test_sphinxcontrib-spelling.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ """Testing 'sphinxcontrib-spelling' package""" -import logging import argparse +import logging # package to test from sphinxcontrib import spelling # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_sqlite.py b/tests/env/packages/env_test_sqlite.py index 34389d5d..9c26bf8d 100644 --- a/tests/env/packages/env_test_sqlite.py +++ b/tests/env/packages/env_test_sqlite.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'sqlite' package""" -import logging import argparse +import logging # package to test import sqlite3 # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_statsmodels.py b/tests/env/packages/env_test_statsmodels.py index 737d70d8..cd976b03 100644 --- a/tests/env/packages/env_test_statsmodels.py +++ b/tests/env/packages/env_test_statsmodels.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'statsmodels' package""" -import logging import argparse +import logging # package to test import statsmodels # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_strictdoc.py b/tests/env/packages/env_test_strictdoc.py index 97c75014..14599370 100644 --- a/tests/env/packages/env_test_strictdoc.py +++ b/tests/env/packages/env_test_strictdoc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'zlib' package""" -import logging import argparse +import logging import subprocess # binary package diff --git a/tests/env/packages/env_test_tabulate.py b/tests/env/packages/env_test_tabulate.py index d4e42dcf..adc6979b 100644 --- a/tests/env/packages/env_test_tabulate.py +++ b/tests/env/packages/env_test_tabulate.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'tabulate' package""" -import logging import argparse +import logging # package to test import tabulate # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_tenacity.py b/tests/env/packages/env_test_tenacity.py index 940c3532..1c10de01 100644 --- a/tests/env/packages/env_test_tenacity.py +++ b/tests/env/packages/env_test_tenacity.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,14 +40,13 @@ """Testing 'tenacity' package""" -import logging import argparse +import logging import random # package to test from tenacity import retry - # test case based on # https://github.com/jd/tenacity/blob/a7f548520e4ee871ad8aeb354ecfa1a324c8ca19/doc/source/index.rst diff --git a/tests/env/packages/env_test_terminado.py b/tests/env/packages/env_test_terminado.py index 410aab50..08944adf 100644 --- a/tests/env/packages/env_test_terminado.py +++ b/tests/env/packages/env_test_terminado.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'terminado' package""" -import logging import argparse +import logging # package to test import terminado # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_testpath.py b/tests/env/packages/env_test_testpath.py index 5ffe1349..0e00f4fa 100644 --- a/tests/env/packages/env_test_testpath.py +++ b/tests/env/packages/env_test_testpath.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'testpath' package""" -import logging import argparse +import logging # package to test import testpath # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_textparser.py b/tests/env/packages/env_test_textparser.py index 22e878f6..5d39bc93 100644 --- a/tests/env/packages/env_test_textparser.py +++ b/tests/env/packages/env_test_textparser.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'textparser' package""" -import logging import argparse +import logging # package to test import textparser # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_textx.py b/tests/env/packages/env_test_textx.py index 71c99b7e..9a36b504 100644 --- a/tests/env/packages/env_test_textx.py +++ b/tests/env/packages/env_test_textx.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'textx' package""" -import logging import argparse +import logging # package to test import textx diff --git a/tests/env/packages/env_test_threadpoolctl.py b/tests/env/packages/env_test_threadpoolctl.py index 90917a48..1fcf3040 100644 --- a/tests/env/packages/env_test_threadpoolctl.py +++ b/tests/env/packages/env_test_threadpoolctl.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'threadpoolctl' package""" -import logging import argparse +import logging # package to test import threadpoolctl # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_tk_linux.py b/tests/env/packages/env_test_tk_linux.py index 925b7fa8..53f90692 100644 --- a/tests/env/packages/env_test_tk_linux.py +++ b/tests/env/packages/env_test_tk_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'tk' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_toml.py b/tests/env/packages/env_test_toml.py index b8963a59..672996e2 100644 --- a/tests/env/packages/env_test_toml.py +++ b/tests/env/packages/env_test_toml.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'toml' package""" -import logging import argparse +import logging # package to test import toml # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_tomli.py b/tests/env/packages/env_test_tomli.py index dd2edc71..1f18b74c 100644 --- a/tests/env/packages/env_test_tomli.py +++ b/tests/env/packages/env_test_tomli.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'tomli' package""" -import logging import argparse +import logging # package to test import tomli diff --git a/tests/env/packages/env_test_toolz.py b/tests/env/packages/env_test_toolz.py index 29ab778b..f5e13b04 100644 --- a/tests/env/packages/env_test_toolz.py +++ b/tests/env/packages/env_test_toolz.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'toolz' package""" -import logging import argparse +import logging # package to test import toolz # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_tornado.py b/tests/env/packages/env_test_tornado.py index 208851de..f45aec06 100644 --- a/tests/env/packages/env_test_tornado.py +++ b/tests/env/packages/env_test_tornado.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'tornado' package""" -import logging import argparse +import logging # package to test import tornado # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_traitlets.py b/tests/env/packages/env_test_traitlets.py index 09b16483..ab8cea1a 100644 --- a/tests/env/packages/env_test_traitlets.py +++ b/tests/env/packages/env_test_traitlets.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'traitlets' package""" -import logging import argparse +import logging # package to test import traitlets # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_typing-extensions.py b/tests/env/packages/env_test_typing-extensions.py index 519d97e9..ba3ea720 100644 --- a/tests/env/packages/env_test_typing-extensions.py +++ b/tests/env/packages/env_test_typing-extensions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,8 +42,8 @@ # pylint: disable=invalid-name -import logging import argparse +import logging # package to test import typing_extensions # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_tzdata.py b/tests/env/packages/env_test_tzdata.py index 5e407a9c..19d9f3c1 100644 --- a/tests/env/packages/env_test_tzdata.py +++ b/tests/env/packages/env_test_tzdata.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'tzdata' package""" -import logging import argparse +import logging # package to test from datetime import datetime diff --git a/tests/env/packages/env_test_uptime.py b/tests/env/packages/env_test_uptime.py index 2544ca19..daebc931 100644 --- a/tests/env/packages/env_test_uptime.py +++ b/tests/env/packages/env_test_uptime.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'uptime' package""" -import logging import argparse +import logging # package to test import uptime # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_urllib3.py b/tests/env/packages/env_test_urllib3.py index 7668fd84..68672ccb 100644 --- a/tests/env/packages/env_test_urllib3.py +++ b/tests/env/packages/env_test_urllib3.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'urllib3' package""" -import logging import argparse +import logging # package to test import urllib3 # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_vc_win32.py b/tests/env/packages/env_test_vc_win32.py index 5b3f722d..bea25481 100644 --- a/tests/env/packages/env_test_vc_win32.py +++ b/tests/env/packages/env_test_vc_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'vc' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_vs2015_runtime_win32.py b/tests/env/packages/env_test_vs2015_runtime_win32.py index cc5009b3..5f5a19ce 100644 --- a/tests/env/packages/env_test_vs2015_runtime_win32.py +++ b/tests/env/packages/env_test_vs2015_runtime_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'vs2015_runtime' package""" -import logging import argparse +import logging # nothing to test diff --git a/tests/env/packages/env_test_wcwidth.py b/tests/env/packages/env_test_wcwidth.py index 0fa1e417..cef3e4c8 100644 --- a/tests/env/packages/env_test_wcwidth.py +++ b/tests/env/packages/env_test_wcwidth.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'wcwidth' package""" -import logging import argparse +import logging # package to test import wcwidth # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_webencodings.py b/tests/env/packages/env_test_webencodings.py index 22823efb..e00df803 100644 --- a/tests/env/packages/env_test_webencodings.py +++ b/tests/env/packages/env_test_webencodings.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'webencodings' package""" -import logging import argparse +import logging # package to test import webencodings # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_wheel.py b/tests/env/packages/env_test_wheel.py index 15ea6c4e..a838273f 100644 --- a/tests/env/packages/env_test_wheel.py +++ b/tests/env/packages/env_test_wheel.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'wheel' package""" -import logging import argparse +import logging # package to test import wheel # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_widgetsnbextension.py b/tests/env/packages/env_test_widgetsnbextension.py index a415b773..155333ca 100644 --- a/tests/env/packages/env_test_widgetsnbextension.py +++ b/tests/env/packages/env_test_widgetsnbextension.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'widgetsnbextension' package""" -import logging import argparse +import logging # package to test import widgetsnbextension # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_wincertstore_win32.py b/tests/env/packages/env_test_wincertstore_win32.py index 9cc92f56..63d219d3 100644 --- a/tests/env/packages/env_test_wincertstore_win32.py +++ b/tests/env/packages/env_test_wincertstore_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'wincertstore' package""" -import logging import argparse +import logging # package to test import wincertstore # pylint: disable=unused-import,import-error diff --git a/tests/env/packages/env_test_windows-curses_win32.py b/tests/env/packages/env_test_windows-curses_win32.py index 0bedd035..444d89ad 100644 --- a/tests/env/packages/env_test_windows-curses_win32.py +++ b/tests/env/packages/env_test_windows-curses_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,11 +42,11 @@ """Testing 'windows-curses' package""" -import logging import argparse # package to test import curses # pylint: disable=unused-import +import logging def main(): diff --git a/tests/env/packages/env_test_winpty_win32.py b/tests/env/packages/env_test_winpty_win32.py index 96b822e0..a7680a57 100644 --- a/tests/env/packages/env_test_winpty_win32.py +++ b/tests/env/packages/env_test_winpty_win32.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'winpty' package""" -import logging import argparse +import logging # package to test import winpty # pylint: disable=unused-import,import-error diff --git a/tests/env/packages/env_test_wrapt.py b/tests/env/packages/env_test_wrapt.py index 6530f9a9..eecee0dc 100644 --- a/tests/env/packages/env_test_wrapt.py +++ b/tests/env/packages/env_test_wrapt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'wrapt' package""" -import logging import argparse +import logging # package to test import wrapt # pylint: disable=unused-import diff --git a/tests/env/packages/env_test_wxpython.py b/tests/env/packages/env_test_wxpython.py index ae1c6dfb..f81ed493 100644 --- a/tests/env/packages/env_test_wxpython.py +++ b/tests/env/packages/env_test_wxpython.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,10 +40,10 @@ """Testing 'wxpython' package""" -import sys -import os -import logging import argparse +import logging +import os +import sys # package to test import wx diff --git a/tests/env/packages/env_test_xlsxwriter.py b/tests/env/packages/env_test_xlsxwriter.py index b4598b2b..0a996697 100644 --- a/tests/env/packages/env_test_xlsxwriter.py +++ b/tests/env/packages/env_test_xlsxwriter.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'xlsxwriter' package""" -import logging import argparse +import logging # package to test import xlsxwriter diff --git a/tests/env/packages/env_test_xz_linux.py b/tests/env/packages/env_test_xz_linux.py index 88b040fd..330b3e6b 100644 --- a/tests/env/packages/env_test_xz_linux.py +++ b/tests/env/packages/env_test_xz_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'xz' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages/env_test_zlib.py b/tests/env/packages/env_test_zlib.py index df4e4f17..eb4b10af 100644 --- a/tests/env/packages/env_test_zlib.py +++ b/tests/env/packages/env_test_zlib.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'zlib' package""" -import logging import argparse +import logging # package to test import zlib diff --git a/tests/env/packages/env_test_zstd_linux.py b/tests/env/packages/env_test_zstd_linux.py index 30bd0be8..063a6762 100644 --- a/tests/env/packages/env_test_zstd_linux.py +++ b/tests/env/packages/env_test_zstd_linux.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Testing 'zstd' package""" -import logging import argparse +import logging def main(): diff --git a/tests/env/packages_test.py b/tests/env/packages_test.py index 6a461236..1ab1f8c4 100644 --- a/tests/env/packages_test.py +++ b/tests/env/packages_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -39,15 +39,15 @@ # - "This product is derived from foxBMS®" """Basic test of all packages in conda environment""" -import sys -import os -import logging import argparse import glob import json +import logging +import os import pathlib -import subprocess import shutil +import subprocess +import sys SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/os-includes/README.md b/tests/os-includes/README.md deleted file mode 100644 index 56dd489c..00000000 --- a/tests/os-includes/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Checking Operating System Specific Implementations - -Including operating system headers should be avoided. -Instead the alternatives defined in the ``task``-wrapper layer (``src/app/task``) should be used. - -## FreeRTOS - -Only the ``FreeRTOS`` specific implementations - -- ``src/app/task/os/freertos/os_freertos.c`` -- ``src/app/task/ftask/freertos/ftask_freertos.c`` - -might use ``FreeRTOS`` specific includes, types etc. - -### Includes - -The following regular expression can be used to check for ``FreeRTOS`` specific -includes: - -``` -#include.*"(atomic.h|croutine.h|deprecated_definitions.h|event_groups.h|FreeRTOS.h|FreeRTOSConfig.h|list.h|message_buffer.h|mpu_prototypes.h|mpu_wrappers.h|portable.h|projdefs.h|queue.h|semphr.h|StackMacros.h|stack_macros.h|stream_buffer.h|task.h|timers.h) -``` - -### Types and Defines - -The following regular expression can be used to check for ``FreeRTOS`` specific -types and defines: - -``` -(pdFALSE|pdTRUE|pdPASS|pdFAIL) -``` diff --git a/tests/os-information/README.md b/tests/os-information/README.md new file mode 100644 index 00000000..b4e99d50 --- /dev/null +++ b/tests/os-information/README.md @@ -0,0 +1,54 @@ +# Checking Operating System Specific Implementations + +Including operating system headers should be avoided. +Instead the alternatives defined in the ``task``-wrapper layer +(``src/app/task``) should be used. + +## FreeRTOS + +Only the ``FreeRTOS`` specific implementations + +- ``src/app/task/os/freertos/os_freertos.c`` +- ``src/app/task/ftask/freertos/ftask_freertos.c`` + +might use ``FreeRTOS`` specific includes, types etc. + +### Functions + +The following regular expression can be used to check for ``FreeRTOS`` specific +functions: + +``` +(taskENTER_CRITICAL|taskEXIT_CRITICAL|uxQueueMessagesWaiting|vTaskDelayUntil|xQueueReceive|xQueueSendToBack|xQueueSendToBackFromISR|xTaskGetTickCount) +``` + +The corresponding OS agnostic functions are listed below: + +| FreeRTOS | foxBMS | +|-------------------------------|-----------------------------------| +| ``taskENTER_CRITICAL`` | ``OS_EnterTaskCritical`` | +| ``taskEXIT_CRITICAL`` | ``OS_ExitTaskCritical`` | +| ``uxQueueMessagesWaiting`` | ``OS_GetTickCount`` | +| ``vTaskDelayUntil`` | ``OS_DelayTaskUntil`` | +| ``xQueueReceive`` | ``OS_ReceiveFromQueue`` | +| ``xQueueSendToBack`` | ``OS_SendToBackOfQueue`` | +| ``xQueueSendToBackFromISR`` | ``OS_SendToBackOfQueueFromIsr`` | +| ``xTaskGetTickCount`` | ``OS_GetTickCount`` | + +### Includes + +The following regular expression can be used to check for ``FreeRTOS`` specific +includes: + +``` +#include.*"(atomic.h|croutine.h|deprecated_definitions.h|event_groups.h|FreeRTOS.h|FreeRTOSConfig.h|list.h|message_buffer.h|mpu_prototypes.h|mpu_wrappers.h|portable.h|projdefs.h|queue.h|semphr.h|StackMacros.h|stack_macros.h|stream_buffer.h|task.h|timers.h) +``` + +### Types and Defines + +The following regular expression can be used to check for ``FreeRTOS`` specific +types and defines: + +``` +(pdFALSE|pdTRUE|pdPASS|pdFAIL) +``` diff --git a/tests/re-names/function.json b/tests/re-names/function.json index 256d9144..30cd7f68 100644 --- a/tests/re-names/function.json +++ b/tests/re-names/function.json @@ -1,8 +1,8 @@ { "valid": [ - "ABC_A", "ABC_Az", - "ABC_A1", + "ABC_Az1", + "ABC_I2c", "ABC_Function", "ABC_Function0", "ABC_MyFunction", @@ -17,6 +17,9 @@ "a", "ABC", "ABC_", + "ABC_A", + "ABC_A1", + "ABC_I2", "PREFIXONLY", "PREFIXBUTNOUNDERSCORE", "noprefix", diff --git a/tests/re-names/test_names_regex.py b/tests/re-names/test_names_regex.py index 0dd5debc..37dd7b1a 100644 --- a/tests/re-names/test_names_regex.py +++ b/tests/re-names/test_names_regex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/gui/__init__.py b/tests/scripts/gui/__init__.py index e15328f0..5ea98b5d 100644 --- a/tests/scripts/gui/__init__.py +++ b/tests/scripts/gui/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/gui/test_foxbms_gui.py b/tests/scripts/gui/test_foxbms_gui.py index a5935a4a..a828374b 100644 --- a/tests/scripts/gui/test_foxbms_gui.py +++ b/tests/scripts/gui/test_foxbms_gui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,9 +41,10 @@ """Implements tests for the foxBMS 2 GUI. """ -import unittest -import sys import os +import sys +import unittest + import wx HAVE_GIT = False diff --git a/tests/scripts/gui/test_info_dialog.py b/tests/scripts/gui/test_info_dialog.py index 2e7c8fab..200a4571 100644 --- a/tests/scripts/gui/test_info_dialog.py +++ b/tests/scripts/gui/test_info_dialog.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,9 +41,10 @@ """Implements tests for the foxBMS 2 info dialog. """ -import unittest -import sys import os +import sys +import unittest + import wx HAVE_GIT = False diff --git a/tests/scripts/run_tests.bat b/tests/scripts/run_tests.bat index 728e40d8..dc7d5afd 100644 --- a/tests/scripts/run_tests.bat +++ b/tests/scripts/run_tests.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/waf-core/run_waf_core_unit_tests.sh b/tests/scripts/waf-core/run_waf_core_unit_tests.sh index 73fbc410..b7de2b8e 100755 --- a/tests/scripts/waf-core/run_waf_core_unit_tests.sh +++ b/tests/scripts/waf-core/run_waf_core_unit_tests.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/waf-tools/__init__.py b/tests/scripts/waf-tools/__init__.py index e15328f0..5ea98b5d 100644 --- a/tests/scripts/waf-tools/__init__.py +++ b/tests/scripts/waf-tools/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/waf-tools/f_guidelines/__init__.py b/tests/scripts/waf-tools/f_guidelines/__init__.py index de2b6d8f..80877f87 100644 --- a/tests/scripts/waf-tools/f_guidelines/__init__.py +++ b/tests/scripts/waf-tools/f_guidelines/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/waf-tools/f_guidelines/test_f_guidelines.py b/tests/scripts/waf-tools/f_guidelines/test_f_guidelines.py index d7642672..639fc2e2 100644 --- a/tests/scripts/waf-tools/f_guidelines/test_f_guidelines.py +++ b/tests/scripts/waf-tools/f_guidelines/test_f_guidelines.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,11 +41,11 @@ """Implements tests for the waf tool ``f_guidelines``. """ -import unittest -import sys +import json import os import re -import json +import sys +import unittest HAVE_GIT = False try: @@ -304,7 +304,13 @@ def test_doxygen(self): for test_file, result in results["default_regex"].items(): txt = get_txt(os.path.join("c-004_tests", test_file)) self.general_tester( - result, f_guidelines.c_check_doxygen.test(test_file, txt, config) + result, + f_guidelines.c_check_doxygen.test( + test_file, + txt, + config, + "1.0.0", + ), ) # Tests for changed doxygen regular expressions @@ -313,7 +319,13 @@ def test_doxygen(self): for test_file, result in results["changed_regex"].items(): txt = get_txt(os.path.join("c-004_tests", test_file)) self.general_tester( - result, f_guidelines.c_check_doxygen.test(test_file, txt, config) + result, + f_guidelines.c_check_doxygen.test( + test_file, + txt, + config, + "1.0.0", + ), ) def test_c_sections(self): diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test0.c b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test0.c index fdbb5c93..34547026 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test0.c +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test0.c @@ -3,7 +3,8 @@ * @file c-004_test0.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-02-22 (date of last update) + * @version v1.0.0 * @ingroup TEMPERATURE_SENSORS * @prefix TSEN * diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test1.c b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test1.c index 97d62633..8a9271d1 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test1.c +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test1.c @@ -3,7 +3,8 @@ * @file c-004_test1.c * @date 2020-08-25 (date of creation) * @author foxBMS Team - * @updated 2020-08-25 (date of last update) + * @updated 2022-02-22 (date of last update) + * @version v1.0.0 * @ingroup TEMPERATURE_SENSORS * @prefix TSEN * diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test2.c b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test2.c index 97f6d40c..108e60b1 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test2.c +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test2.c @@ -3,7 +3,8 @@ * @file c-004_test2.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-02-22 (date of last update) + * @version v1.0.0 * @ingroup TEMPERATURE_SENSORS * @prefx TSEN * diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test3.c b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test3.c index 6fec3de8..4e963b54 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test3.c +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test3.c @@ -3,7 +3,8 @@ * @file c-004_test3.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-02-22 (date of last update) + * @version v1.0.0 * @ingroup TEMPERATURE_SENSORS * @prefix TSEN * diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test4.c b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test4.c index 7b02c082..847103e2 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test4.c +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test4.c @@ -3,7 +3,8 @@ * @file c-004_test4.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-02-22 (date of last update) + * @version v1.0.0 * @ingroup TEMPERATURE_SENSORS * @prefix TSEN * diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test5.c b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test5.c index 785602d6..6efb8832 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test5.c +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test5.c @@ -3,7 +3,8 @@ * @file c-004_test0.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-02-22 (date of last update) + * @version v1.0.0 * @ingroup TEMPERATURE_SENSORS * @prefix TSEN * diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_configured_rules.json b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_configured_rules.json index 6d5c0d76..9eb10a5e 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_configured_rules.json +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_configured_rules.json @@ -5,6 +5,7 @@ "[ ]\\* (@author)[ ]{2}foxBMS Team$", "[ ]\\* (@date)[ ]{4}[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]\\(date of creation\\)$", "[ ]\\* (@updated)[ ][0-9]{4}-[0-9]{2}-[0-9]{2}[ ]\\(date of last update\\)$", + "[ ]\\* (@version)[ ]v@VERSION@", "[ ]\\* (@ingroup)[ ][A-Za-z_]+$", "[ ]\\* (@prefix)[ ]{2}[A-Z][0-9A-Z]{1,4}$", "([ ]\\*)", diff --git a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_results.json b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_results.json index bd9f5bb7..a24d51a8 100644 --- a/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_results.json +++ b/tests/scripts/waf-tools/f_guidelines/tests/c-004_tests/c-004_test_results.json @@ -16,7 +16,7 @@ "c-004_test2.c": [ [ "C_DOXYGEN", - 8, + 9, "Line does not match with required File Level Doxygen @prefix comment" ] ], @@ -40,7 +40,7 @@ "c-004_test4.c": [ [ "C_DOXYGEN", - 12, + 13, "Line does not match with required File Level Doxygen @UTest comment" ] ] diff --git a/tests/scripts/waf-tools/f_hcg/__init__.py b/tests/scripts/waf-tools/f_hcg/__init__.py index 5fe6b6ec..902715b6 100644 --- a/tests/scripts/waf-tools/f_hcg/__init__.py +++ b/tests/scripts/waf-tools/f_hcg/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/waf-tools/f_hcg/test_f_hcg.py b/tests/scripts/waf-tools/f_hcg/test_f_hcg.py index bf226b7d..0360528d 100644 --- a/tests/scripts/waf-tools/f_hcg/test_f_hcg.py +++ b/tests/scripts/waf-tools/f_hcg/test_f_hcg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,10 +41,10 @@ """Implements tests for the waf tool ``f_hcg``. """ -import unittest -import sys -import os import json +import os +import sys +import unittest HAVE_GIT = False try: diff --git a/tests/scripts/waf-tools/f_ti_arm_cgt/__init__.py b/tests/scripts/waf-tools/f_ti_arm_cgt/__init__.py index 165f7cdd..a82a6a05 100644 --- a/tests/scripts/waf-tools/f_ti_arm_cgt/__init__.py +++ b/tests/scripts/waf-tools/f_ti_arm_cgt/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/scripts/waf-tools/f_ti_arm_cgt/test_f_ti_arm_cgt.py b/tests/scripts/waf-tools/f_ti_arm_cgt/test_f_ti_arm_cgt.py index 62afd0ff..ad1527b9 100644 --- a/tests/scripts/waf-tools/f_ti_arm_cgt/test_f_ti_arm_cgt.py +++ b/tests/scripts/waf-tools/f_ti_arm_cgt/test_f_ti_arm_cgt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,10 +41,10 @@ """Implements tests for the waf tool ``f_ti_arm_cgt``. """ -import unittest -import sys -import os import json +import os +import sys +import unittest HAVE_GIT = False try: diff --git a/tests/unit/app/application/algorithm/config/test_algorithm_cfg.c b/tests/unit/app/application/algorithm/config/test_algorithm_cfg.c index 4246e3e5..12892e46 100644 --- a/tests/unit/app/application/algorithm/config/test_algorithm_cfg.c +++ b/tests/unit/app/application/algorithm/config/test_algorithm_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_algorithm_cfg.c * @author foxBMS Team * @date 2020-06-30 (date of creation) - * @updated 2020-06-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -92,3 +93,17 @@ void testResetToReadyFromBlocked(void) { ALGO_MarkAsDone(0); TEST_ASSERT_EQUAL(ALGO_BLOCKED, algo_algorithms[0].state); } + +void testIllegalAccessInMarkAsReinit(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + TEST_ASSERT_FAIL_ASSERT(ALGO_MarkAsReinit(UINT32_MAX)); +} + +void testReinitFromRunning(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + algo_algorithms[0].state = ALGO_RUNNING; + ALGO_MarkAsReinit(0); + TEST_ASSERT_EQUAL(ALGO_REINIT_REQUESTED, algo_algorithms[0].state); +} diff --git a/tests/unit/app/application/algorithm/moving_average/test_moving_average.c b/tests/unit/app/application/algorithm/moving_average/test_moving_average.c index 6fcc067b..21cea9b7 100644 --- a/tests/unit/app/application/algorithm/moving_average/test_moving_average.c +++ b/tests/unit/app/application/algorithm/moving_average/test_moving_average.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_moving_average.c * @author foxBMS Team * @date 2020-07-01 (date of creation) - * @updated 2020-07-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting.c b/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting.c index 0ba97c24..1990e3ca 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting.c +++ b/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soc_counting.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting_cfg.c index 80237587..ac2d2234 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/soc/counting/test_soc_counting_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soc_counting_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug.c b/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug.c index a0cd6d7e..faa43886 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug.c +++ b/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soc_debug.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug_cfg.c index 60aab697..3e831882 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/soc/debug/test_soc_debug_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soc_debug_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none.c b/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none.c index 907f14d0..aaa372de 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none.c +++ b/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soc_none.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none_cfg.c index 1b88334b..46102e8a 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/soc/none/test_soc_none_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soc_none_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting.c b/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting.c index 80ef0408..e9359a34 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting.c +++ b/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soe_counting.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting_cfg.c index 6a1eff88..455b99b7 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/soe/counting/test_soe_counting_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soe_counting_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug.c b/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug.c index 84e303ce..780d02ee 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug.c +++ b/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soe_debug.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug_cfg.c index d1ce5ac1..d366a46d 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/soe/debug/test_soe_debug_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soe_debug_cfg.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none.c b/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none.c index 2764326c..684ccbeb 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none.c +++ b/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soe_none.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none_cfg.c index bd250489..daff9366 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/soe/none/test_soe_none_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soe_none_cfg.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof.c b/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof.c index c6c77128..41acef4d 100644 --- a/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof.c +++ b/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sof.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof_cfg.c b/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof_cfg.c index 3c2f18af..809b7d8c 100644 --- a/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof_cfg.c +++ b/tests/unit/app/application/algorithm/state_estimation/sof/trapezoid/test_sof_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sof_cfg.c * @author foxBMS Team * @date 2020-10-07 (date of creation) - * @updated 2020-10-07 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug.c b/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug.c index fc1c2219..1cc3a7aa 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug.c +++ b/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soh_debug.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,8 +54,10 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockdatabase.h" #include "soh_debug.h" +#include "test_assert_helper.h" /*========== Definitions and Implementations for Unit Test ==================*/ @@ -65,7 +68,12 @@ void setUp(void) { void tearDown(void) { } -void testDummy(void) { -} - /*========== Test Cases =====================================================*/ +/** test invalid input values */ +void testInvalidInput(void) { + DATA_BLOCK_SOX_s table_test = {.header.uniqueId = DATA_BLOCK_ID_SOX}; + TEST_ASSERT_FAIL_ASSERT(SOH_Init(NULL_PTR, BS_NR_OF_STRINGS - 1u)); + TEST_ASSERT_FAIL_ASSERT(SOH_Init(&table_test, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SOH_Calculation(NULL_PTR)); +} diff --git a/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug_cfg.c new file mode 100644 index 00000000..f8293ea6 --- /dev/null +++ b/tests/unit/app/application/algorithm/state_estimation/soh/debug/test_soh_debug_cfg.c @@ -0,0 +1,72 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file test_soh_debug_cfg.c + * @author foxBMS Team + * @date 2021-12-14 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Test for the configuration for SOH + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" + +#include "soh_debug_cfg.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +/** empty dummy test */ +void testDummy(void) { +} diff --git a/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none.c b/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none.c index 4e4408f7..24daec89 100644 --- a/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none.c +++ b/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soh_none.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,8 +54,10 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockdatabase.h" #include "soh_none.h" +#include "test_assert_helper.h" /*========== Definitions and Implementations for Unit Test ==================*/ @@ -65,7 +68,12 @@ void setUp(void) { void tearDown(void) { } -void testDummy(void) { -} - /*========== Test Cases =====================================================*/ +/** test invalid input values */ +void testInvalidInput(void) { + DATA_BLOCK_SOX_s table_test = {.header.uniqueId = DATA_BLOCK_ID_SOX}; + TEST_ASSERT_FAIL_ASSERT(SOH_Init(NULL_PTR, BS_NR_OF_STRINGS - 1u)); + TEST_ASSERT_FAIL_ASSERT(SOH_Init(&table_test, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SOH_Calculation(NULL_PTR)); +} diff --git a/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none_cfg.c b/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none_cfg.c new file mode 100644 index 00000000..8ee16bf6 --- /dev/null +++ b/tests/unit/app/application/algorithm/state_estimation/soh/none/test_soh_none_cfg.c @@ -0,0 +1,72 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file test_soh_none_cfg.c + * @author foxBMS Team + * @date 2021-12-14 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Test for the configuration for SOH + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" + +#include "soh_none_cfg.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +/** empty dummy test */ +void testDummy(void) { +} diff --git a/tests/unit/app/application/algorithm/state_estimation/test_state_estimation.c b/tests/unit/app/application/algorithm/state_estimation/test_state_estimation.c index d2817575..eca75608 100644 --- a/tests/unit/app/application/algorithm/state_estimation/test_state_estimation.c +++ b/tests/unit/app/application/algorithm/state_estimation/test_state_estimation.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_state_estimation.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -57,7 +58,9 @@ #include "soc_none.h" #include "soe_none.h" +#include "soh_none.h" #include "state_estimation.h" +#include "test_assert_helper.h" /*========== Definitions and Implementations for Unit Test ==================*/ @@ -68,7 +71,28 @@ void setUp(void) { void tearDown(void) { } -void testDummy(void) { -} - /*========== Test Cases =====================================================*/ +/** test invalid input on interfaces */ +void testInvalidInput(void) { + DATA_BLOCK_SOX_s table_test = {.header.uniqueId = DATA_BLOCK_ID_SOX}; + TEST_ASSERT_FAIL_ASSERT(SE_InitializeSoc(true, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SE_InitializeSoe(true, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SE_InitializeSoh(BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SOC_Init(NULL_PTR, true, BS_NR_OF_STRINGS - 1u)); + TEST_ASSERT_FAIL_ASSERT(SOC_Init(&table_test, true, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SOC_Calculation(NULL_PTR)); + + TEST_ASSERT_FAIL_ASSERT(SOE_Init(NULL_PTR, true, BS_NR_OF_STRINGS - 1u)); + TEST_ASSERT_FAIL_ASSERT(SOE_Init(&table_test, true, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SOE_Calculation(NULL_PTR)); + + TEST_ASSERT_FAIL_ASSERT(SOH_Init(NULL_PTR, BS_NR_OF_STRINGS - 1u)); + TEST_ASSERT_FAIL_ASSERT(SOH_Init(&table_test, BS_NR_OF_STRINGS)); + + TEST_ASSERT_FAIL_ASSERT(SOH_Calculation(NULL_PTR)); +} diff --git a/tests/unit/app/application/algorithm/test_algorithm.c b/tests/unit/app/application/algorithm/test_algorithm.c index 6dac31fd..92d02336 100644 --- a/tests/unit/app/application/algorithm/test_algorithm.c +++ b/tests/unit/app/application/algorithm/test_algorithm.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_algorithm.c * @author foxBMS Team * @date 2020-06-30 (date of creation) - * @updated 2020-06-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/bal/history/test_bal_strategy_history.c b/tests/unit/app/application/bal/history/test_bal_strategy_history.c index 28b19aa4..15623f47 100644 --- a/tests/unit/app/application/bal/history/test_bal_strategy_history.c +++ b/tests/unit/app/application/bal/history/test_bal_strategy_history.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bal_strategy_history.c * @author foxBMS Team * @date 2020-06-05 (date of creation) - * @updated 2020-08-03 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,6 +54,7 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockbal_cfg.h" #include "Mockbattery_system_cfg.h" #include "Mockbms.h" #include "Mockdatabase.h" @@ -82,8 +84,8 @@ void tearDown(void) { void testCheckBalancingInitByDisablingBalancing(void) { DATA_BLOCK_BALANCING_CONTROL_s *pBalancing = TEST_BAL_GetBalancingControl(); pBalancing->enableBalancing = 1; - DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); BAL_Init(pBalancing); TEST_ASSERT_EQUAL(0, pBalancing->enableBalancing); } diff --git a/tests/unit/app/application/bal/none/test_bal_strategy_none.c b/tests/unit/app/application/bal/none/test_bal_strategy_none.c index 24c7f523..f941b669 100644 --- a/tests/unit/app/application/bal/none/test_bal_strategy_none.c +++ b/tests/unit/app/application/bal/none/test_bal_strategy_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bal_strategy_none.c * @author foxBMS Team * @date 2020-08-03 (date of creation) - * @updated 2020-08-03 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/bal/test_bal.c b/tests/unit/app/application/bal/test_bal.c index 54b9986f..6006b71d 100644 --- a/tests/unit/app/application/bal/test_bal.c +++ b/tests/unit/app/application/bal/test_bal.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bal.c * @author foxBMS Team * @date 2020-08-05 (date of creation) - * @updated 2020-08-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/bal/voltage/test_bal_strategy_voltage.c b/tests/unit/app/application/bal/voltage/test_bal_strategy_voltage.c index bb89a860..358b8b84 100644 --- a/tests/unit/app/application/bal/voltage/test_bal_strategy_voltage.c +++ b/tests/unit/app/application/bal/voltage/test_bal_strategy_voltage.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bal_strategy_voltage.c * @author foxBMS Team * @date 2020-06-05 (date of creation) - * @updated 2020-08-03 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,6 +54,7 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockbal_cfg.h" #include "Mockbattery_system_cfg.h" #include "Mockbms.h" #include "Mockdatabase.h" @@ -81,8 +83,8 @@ void tearDown(void) { void testCheckBalancingInitByDisablingBalancing(void) { DATA_BLOCK_BALANCING_CONTROL_s *pBalancing = TEST_BAL_GetBalancingControl(); pBalancing->enableBalancing = 1; - DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); BAL_Init(pBalancing); TEST_ASSERT_EQUAL(0, pBalancing->enableBalancing); } diff --git a/tests/unit/app/application/bms/test_bms.c b/tests/unit/app/application/bms/test_bms.c index 5462a84e..4b506edd 100644 --- a/tests/unit/app/application/bms/test_bms.c +++ b/tests/unit/app/application/bms/test_bms.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bms.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-10-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -59,6 +60,7 @@ #include "Mockdatabase.h" #include "Mockdiag.h" #include "Mockfassert.h" +#include "Mockimd.h" #include "Mockinterlock.h" #include "Mockled.h" #include "Mockmeas.h" @@ -74,15 +76,13 @@ DIAG_ID_CFG_s DIAG_ID_cfg[] = {}; DIAG_DEV_s diag_device = { - .nr_of_ch = sizeof(DIAG_ID_cfg) / sizeof(DIAG_ID_CFG_s), - .ch_cfg = &DIAG_ID_cfg[0], - .numberOfFatalErrors = 0u, + .nrOfConfiguredDiagnosisEntries = sizeof(DIAG_ID_cfg) / sizeof(DIAG_ID_CFG_s), + .pConfigurationOfDiagnosisEntries = &DIAG_ID_cfg[0], + .numberOfFatalErrors = 0u, }; BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS] = { BS_STRING_WITH_PRECHARGE, - BS_STRING_WITH_PRECHARGE, - BS_STRING_WITH_PRECHARGE, }; /*========== Setup and Teardown =============================================*/ @@ -98,7 +98,7 @@ STD_RETURN_TYPE_e prechargeExpectedResults[BS_NR_OF_STRINGS][NUM_PRECHARGE_TESTS /* * mock callback in order to provide custom values to current_tab */ -STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback(void *dataptrtoReceiver, int num_calls) { +STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback(void *pDataToReceiver, int num_calls) { int32_t current = 0; int32_t voltage_1 = 0; int32_t voltage_2 = 0; @@ -212,10 +212,10 @@ STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback(void *dataptrtoReceiver, int num_c prechargeExpectedResults[s][testNumber] = prechargeExpectedResults[0][testNumber]; } - ((DATA_BLOCK_PACK_VALUES_s *)dataptrtoReceiver)->stringCurrent_mA[0] = current; - ((DATA_BLOCK_PACK_VALUES_s *)dataptrtoReceiver)->stringVoltage_mV[0] = voltage_1; + ((DATA_BLOCK_PACK_VALUES_s *)pDataToReceiver)->stringCurrent_mA[0] = current; + ((DATA_BLOCK_PACK_VALUES_s *)pDataToReceiver)->stringVoltage_mV[0] = voltage_1; } - ((DATA_BLOCK_PACK_VALUES_s *)dataptrtoReceiver)->highVoltageBusVoltage_mV = voltage_2; + ((DATA_BLOCK_PACK_VALUES_s *)pDataToReceiver)->highVoltageBusVoltage_mV = voltage_2; return STD_OK; } @@ -229,7 +229,7 @@ STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback(void *dataptrtoReceiver, int num_c */ void testCheckPrechargeIterateStub(void) { /* tell CMock to use our callback */ - DATA_Read_1_DataBlock_Stub(MockDATA_ReadBlock_Callback); + DATA_Read1DataBlock_Stub(MockDATA_ReadBlock_Callback); DATA_BLOCK_PACK_VALUES_s tablePackValues = {.header.uniqueId = DATA_BLOCK_ID_PACK_VALUES}; diff --git a/tests/unit/app/application/config/test_bal_cfg.c b/tests/unit/app/application/config/test_bal_cfg.c new file mode 100644 index 00000000..78a44300 --- /dev/null +++ b/tests/unit/app/application/config/test_bal_cfg.c @@ -0,0 +1,104 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file test_bal_cfg.c + * @author foxBMS Team + * @date 2022-02-26 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Test for the balancing configuration + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "Mockos.h" + +#include "bal_cfg.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + BAL_SetBalancingThreshold(BAL_DEFAULT_THRESHOLD_mV); +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ + +/** test #BAL_SetBalancingThreshold() and #BAL_GetBalancingThreshold_mV() */ +void testSetAndGetBalancingThreshold(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + int32_t expectedThreshold_mV = 50; + BAL_SetBalancingThreshold(expectedThreshold_mV); + TEST_ASSERT_EQUAL(expectedThreshold_mV, BAL_GetBalancingThreshold_mV()); + + expectedThreshold_mV = 150; + BAL_SetBalancingThreshold(expectedThreshold_mV); + TEST_ASSERT_EQUAL(expectedThreshold_mV, BAL_GetBalancingThreshold_mV()); +} + +/** test #BAL_SetBalancingThreshold() with maximum values */ +void testSetBalancingThresholdMaxValue(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + int32_t expectedThreshold_mV = BAL_MAXIMUM_THRESHOLD_mV + 1; + BAL_SetBalancingThreshold(expectedThreshold_mV); + TEST_ASSERT_EQUAL(expectedThreshold_mV - 1, BAL_GetBalancingThreshold_mV()); +} + +/** test #BAL_SetBalancingThreshold() with minimum values */ +void testSetBalancingThresholdMinValue(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + int32_t expectedThreshold_mV = BAL_MINIMUM_THRESHOLD_mV - 1; + BAL_SetBalancingThreshold(expectedThreshold_mV); + TEST_ASSERT_EQUAL(expectedThreshold_mV + 1, BAL_GetBalancingThreshold_mV()); +} diff --git a/tests/unit/app/application/config/test_battery_cell_cfg.c b/tests/unit/app/application/config/test_battery_cell_cfg.c index 1991bb19..61bde7ea 100644 --- a/tests/unit/app/application/config/test_battery_cell_cfg.c +++ b/tests/unit/app/application/config/test_battery_cell_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_battery_cell_cfg.c * @author foxBMS Team * @date 2020-10-08 (date of creation) - * @updated 2020-10-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/config/test_battery_system_cfg.c b/tests/unit/app/application/config/test_battery_system_cfg.c index bf0ed450..f782184c 100644 --- a/tests/unit/app/application/config/test_battery_system_cfg.c +++ b/tests/unit/app/application/config/test_battery_system_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_battery_system_cfg.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2020-04-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/config/test_soa_cfg.c b/tests/unit/app/application/config/test_soa_cfg.c index 2b94bb5e..8e166851 100644 --- a/tests/unit/app/application/config/test_soa_cfg.c +++ b/tests/unit/app/application/config/test_soa_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soa_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/plausibility/test_plausibility.c b/tests/unit/app/application/plausibility/test_plausibility.c index efa4500c..eb9bc94f 100644 --- a/tests/unit/app/application/plausibility/test_plausibility.c +++ b/tests/unit/app/application/plausibility/test_plausibility.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_plausibility.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/application/redundancy/test_redundancy.c b/tests/unit/app/application/redundancy/test_redundancy.c index f55c6f63..ad5da592 100644 --- a/tests/unit/app/application/redundancy/test_redundancy.c +++ b/tests/unit/app/application/redundancy/test_redundancy.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_redundancy.c * @author foxBMS Team * @date 2020-07-31 (date of creation) - * @updated 2020-07-31 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -66,36 +67,36 @@ /*========== Definitions and Implementations for Unit Test ==================*/ -DATA_BLOCK_CELL_VOLTAGE_s testCellvoltageBase = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}; -DATA_BLOCK_CELL_VOLTAGE_s testCellvoltageRedundancy0 = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_REDUNDANCY0}; +DATA_BLOCK_CELL_VOLTAGE_s testCellVoltageBase = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}; +DATA_BLOCK_CELL_VOLTAGE_s testCellVoltageRedundancy0 = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_REDUNDANCY0}; -DATA_BLOCK_CELL_TEMPERATURE_s testCelltemperatureBase = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE}; -DATA_BLOCK_CELL_TEMPERATURE_s testCelltemperatureRedundancy0 = { +DATA_BLOCK_CELL_TEMPERATURE_s testCellTemperatureBase = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE}; +DATA_BLOCK_CELL_TEMPERATURE_s testCellTemperatureRedundancy0 = { .header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_REDUNDANCY0}; static inline void injectDatabaseEntries(void) { - DATA_Read_4_DataBlocks_ExpectAndReturn( - &testCellvoltageBase, - &testCellvoltageRedundancy0, - &testCelltemperatureBase, - &testCelltemperatureRedundancy0, + DATA_Read4DataBlocks_ExpectAndReturn( + &testCellVoltageBase, + &testCellVoltageRedundancy0, + &testCellTemperatureBase, + &testCellTemperatureRedundancy0, STD_OK); - DATA_Read_4_DataBlocks_IgnoreArg_pDataToReceiver0(); - DATA_Read_4_DataBlocks_IgnoreArg_pDataToReceiver1(); - DATA_Read_4_DataBlocks_IgnoreArg_pDataToReceiver2(); - DATA_Read_4_DataBlocks_IgnoreArg_pDataToReceiver3(); - DATA_Read_4_DataBlocks_ReturnThruPtr_pDataToReceiver0(&testCellvoltageBase); - DATA_Read_4_DataBlocks_ReturnThruPtr_pDataToReceiver1(&testCellvoltageRedundancy0); - DATA_Read_4_DataBlocks_ReturnThruPtr_pDataToReceiver2(&testCelltemperatureBase); - DATA_Read_4_DataBlocks_ReturnThruPtr_pDataToReceiver3(&testCelltemperatureRedundancy0); + DATA_Read4DataBlocks_IgnoreArg_pDataToReceiver0(); + DATA_Read4DataBlocks_IgnoreArg_pDataToReceiver1(); + DATA_Read4DataBlocks_IgnoreArg_pDataToReceiver2(); + DATA_Read4DataBlocks_IgnoreArg_pDataToReceiver3(); + DATA_Read4DataBlocks_ReturnThruPtr_pDataToReceiver0(&testCellVoltageBase); + DATA_Read4DataBlocks_ReturnThruPtr_pDataToReceiver1(&testCellVoltageRedundancy0); + DATA_Read4DataBlocks_ReturnThruPtr_pDataToReceiver2(&testCellTemperatureBase); + DATA_Read4DataBlocks_ReturnThruPtr_pDataToReceiver3(&testCellTemperatureRedundancy0); } /*========== Setup and Teardown =============================================*/ void setUp(void) { - testCellvoltageBase.header.timestamp = 0; - testCellvoltageRedundancy0.header.timestamp = 0; - testCelltemperatureBase.header.timestamp = 0; - testCelltemperatureRedundancy0.header.timestamp = 0; + testCellVoltageBase.header.timestamp = 0; + testCellVoltageRedundancy0.header.timestamp = 0; + testCellTemperatureBase.header.timestamp = 0; + testCellTemperatureRedundancy0.header.timestamp = 0; } void tearDown(void) { diff --git a/tests/unit/app/application/soa/test_soa.c b/tests/unit/app/application/soa/test_soa.c index 636e7b61..11e5fba0 100644 --- a/tests/unit/app/application/soa/test_soa.c +++ b/tests/unit/app/application/soa/test_soa.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_soa.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/adc/test_adc.c b/tests/unit/app/driver/adc/test_adc.c index ddc21928..30e0cc81 100644 --- a/tests/unit/app/driver/adc/test_adc.c +++ b/tests/unit/app/driver/adc/test_adc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_adc.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/api/test_afe_plausibility.c b/tests/unit/app/driver/afe/api/test_afe_plausibility.c index 4789d2d0..abbedec3 100644 --- a/tests/unit/app/driver/afe/api/test_afe_plausibility.c +++ b/tests/unit/app/driver/afe/api/test_afe_plausibility.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_afe_plausibility.c * @author foxBMS Team * @date 2020-07-13 (date of creation) - * @updated 2021-01-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c index 0f4fff56..0300d7cc 100644 --- a/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c +++ b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_debug_default_afe.c * @author foxBMS Team * @date 2020-05-25 (date of creation) - * @updated 2020-06-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c index 5028953e..fb16444b 100644 --- a/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c +++ b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_debug_default_afe_dma.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/debug/default/config/test_debug_default_cfg.c b/tests/unit/app/driver/afe/debug/default/config/test_debug_default_cfg.c index 6ad28d98..e9315ba7 100644 --- a/tests/unit/app/driver/afe/debug/default/config/test_debug_default_cfg.c +++ b/tests/unit/app/driver/afe/debug/default/config/test_debug_default_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_debug_default_cfg.c * @author foxBMS Team * @date 2020-09-29 (date of creation) - * @updated 2020-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/debug/default/test_debug_default.c b/tests/unit/app/driver/afe/debug/default/test_debug_default.c index d5b0dcda..78f794a0 100644 --- a/tests/unit/app/driver/afe/debug/default/test_debug_default.c +++ b/tests/unit/app/driver/afe/debug/default/test_debug_default.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_debug_default.c * @author foxBMS Team * @date 2020-09-17 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -137,8 +138,8 @@ void testTEST_FAKE_CheckMultipleCalls(void) { void testFAKE_SetFirstMeasurementCycleFinished(void) { OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); - DATA_Write_2_DataBlocks_IgnoreAndReturn(STD_OK); - DATA_Write_4_DataBlocks_IgnoreAndReturn(STD_OK); + DATA_Write2DataBlocks_IgnoreAndReturn(STD_OK); + DATA_Write4DataBlocks_IgnoreAndReturn(STD_OK); static DATA_BLOCK_CELL_VOLTAGE_s test_fake_cellVoltage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}; static DATA_BLOCK_CELL_TEMPERATURE_s test_fake_cellTemperature = { @@ -152,22 +153,22 @@ void testFAKE_SetFirstMeasurementCycleFinished(void) { .header.uniqueId = DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_BASE}; static DATA_BLOCK_OPEN_WIRE_s test_fake_openWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE}; FAKE_STATE_s test_fake_state = { - .timer = 0, - .firstMeasurementFinished = false, - .triggerEntry = 0, - .nextState = FAKE_FSM_STATE_HAS_NEVER_RUN, - .currentState = FAKE_FSM_STATE_HAS_NEVER_RUN, - .previousState = FAKE_FSM_STATE_HAS_NEVER_RUN, - .nextSubstate = FAKE_FSM_SUBSTATE_DUMMY, - .currentSubstate = FAKE_FSM_SUBSTATE_DUMMY, - .previousSubstate = FAKE_FSM_SUBSTATE_DUMMY, - .data.allGpioVoltages = &test_fake_allGpioVoltage, - .data.balancingControl = &test_fake_balancingControl, - .data.balancingFeedback = &test_fake_balancingFeedback, - .data.cellTemperature = &test_fake_cellTemperature, - .data.cellVoltage = &test_fake_cellVoltage, - .data.openWire = &test_fake_openWire, - .data.slaveControl = &test_fake_slaveControl, + .timer = 0, + .firstMeasurementFinished = false, + .triggerEntry = 0, + .nextState = FAKE_FSM_STATE_HAS_NEVER_RUN, + .currentState = FAKE_FSM_STATE_HAS_NEVER_RUN, + .previousState = FAKE_FSM_STATE_HAS_NEVER_RUN, + .nextSubstate = FAKE_FSM_SUBSTATE_DUMMY, + .currentSubstate = FAKE_FSM_SUBSTATE_DUMMY, + .previousSubstate = FAKE_FSM_SUBSTATE_DUMMY, + .data.allGpioVoltages = &test_fake_allGpioVoltage, + .data.balancingControl = &test_fake_balancingControl, + .data.balancingFeedback = &test_fake_balancingFeedback, + .data.cellTemperature = &test_fake_cellTemperature, + .data.cellVoltage = &test_fake_cellVoltage, + .data.openWire = &test_fake_openWire, + .data.slaveControl = &test_fake_slaveControl, }; static DATA_BLOCK_CELL_VOLTAGE_s test_fake_cellVoltageCompare = { @@ -204,16 +205,15 @@ void testFAKE_SetFirstMeasurementCycleFinished(void) { uint16_t i = 0; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - for (i = 0; i < BS_NR_OF_BAT_CELLS; i++) { - test_fake_stateCompare.data.cellVoltage->cellVoltage_mV[stringNumber][i] = FAKE_CELL_VOLTAGE_mV; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + for (i = 0; i < BS_NR_OF_CELL_BLOCKS_PER_STRING; i++) { + test_fake_stateCompare.data.cellVoltage->cellVoltage_mV[s][i] = FAKE_CELL_VOLTAGE_mV; } - test_fake_stateCompare.data.cellVoltage->packVoltage_mV[stringNumber] = FAKE_CELL_VOLTAGE_mV * - BS_NR_OF_BAT_CELLS; + test_fake_stateCompare.data.cellVoltage->packVoltage_mV[s] = FAKE_CELL_VOLTAGE_mV * + BS_NR_OF_CELL_BLOCKS_PER_STRING; for (i = 0; i < BS_NR_OF_TEMP_SENSORS_PER_STRING; i++) { - test_fake_stateCompare.data.cellTemperature->cellTemperature_ddegC[stringNumber][i] = - FAKE_CELL_TEMPERATURE_ddegC; + test_fake_stateCompare.data.cellTemperature->cellTemperature_ddegC[s][i] = FAKE_CELL_TEMPERATURE_ddegC; } test_fake_stateCompare.data.slaveControl->eepromReadAddressLastUsed = 0xFFFFFFFF; diff --git a/tests/unit/app/driver/afe/ltc/6806/config/test_ltc_6806_cfg.c b/tests/unit/app/driver/afe/ltc/6806/config/test_ltc_6806_cfg.c index 4a510761..8973f3aa 100644 --- a/tests/unit/app/driver/afe/ltc/6806/config/test_ltc_6806_cfg.c +++ b/tests/unit/app/driver/afe/ltc/6806/config/test_ltc_6806_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_6806_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c index c2ac47b9..c98ec272 100644 --- a/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c +++ b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_6806.c * @author foxBMS Team * @date 2020-07-13 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -83,20 +84,6 @@ static const spiDAT1_t spi_kLtcDataConfig[BS_NR_OF_STRINGS] = { .DFSEL = SPI_FMT_0, /* Data word format selection */ .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, /* CS2 enabled */ }, - { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = FALSE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, /* CS2 enabled */ - }, - { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = TRUE, /* If true, HW chip select kept active */ - .WDEL = FALSE, /* Activation of delay between words */ - .DFSEL = SPI_FMT_0, /* Data word format selection */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, /* CS2 enabled */ - }, }; /** @@ -111,20 +98,6 @@ SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS] = { .csPin = 2u, .csType = SPI_CHIP_SELECT_HARDWARE, }, - { - .pConfig = &spi_kLtcDataConfig[1u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, - { - .pConfig = &spi_kLtcDataConfig[2u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, }; SPI_INTERFACE_CONFIG_s spi_ltcInterfaceSecondary[BS_NR_OF_STRINGS] = { diff --git a/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c index ac0f3ce2..8ba4534e 100644 --- a/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c +++ b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_6806_pec_in_arrays.c * @author foxBMS Team * @date 2020-12-16 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/ltc/6813-1/config/test_ltc_6813-1_cfg.c b/tests/unit/app/driver/afe/ltc/6813-1/config/test_ltc_6813-1_cfg.c index a7465659..61c22929 100644 --- a/tests/unit/app/driver/afe/ltc/6813-1/config/test_ltc_6813-1_cfg.c +++ b/tests/unit/app/driver/afe/ltc/6813-1/config/test_ltc_6813-1_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_6813-1_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c b/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c index 6073edf1..a6175632 100644 --- a/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c +++ b/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_6813-1.c * @author foxBMS Team * @date 2020-03-30 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -134,12 +135,12 @@ void testLTC_SetFirstMeasurementCycleFinished(void) { TEST_ASSERT_EQUAL_UINT8(true, test_ltc_state.first_measurement_made); } -void testLTC_Convert_MuxVoltages_to_Temperatures() { +void testLTC_ConvertMuxVoltagesToTemperatures() { TSI_GetTemperature_ExpectAndReturn(0, 0u); int16_t x = 0; - x = LTC_Convert_MuxVoltages_to_Temperatures(0); + x = LTC_ConvertMuxVoltagesToTemperatures(0); TEST_ASSERT_EQUAL_INT16(0, x); TSI_GetTemperature_ExpectAndReturn(11, 11u); - x = LTC_Convert_MuxVoltages_to_Temperatures(11); + x = LTC_ConvertMuxVoltagesToTemperatures(11); TEST_ASSERT_EQUAL_INT16(11, x); } diff --git a/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1_pec_in_arrays.c b/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1_pec_in_arrays.c index f3e32c86..d5140ff6 100644 --- a/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1_pec_in_arrays.c +++ b/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1_pec_in_arrays.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_6813-1_pec_in_arrays.c * @author foxBMS Team * @date 2020-03-30 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c b/tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c index e91f2e48..43a0476c 100644 --- a/tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c +++ b/tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_afe.c * @author foxBMS Team * @date 2020-05-25 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c b/tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c index b379d674..d9e73bac 100644 --- a/tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c +++ b/tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_afe_dma_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c b/tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c index b944e71e..4cc947f6 100644 --- a/tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c +++ b/tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ltc_afe_dma.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/maxim/api/test_mxm_afe.c b/tests/unit/app/driver/afe/maxim/api/test_mxm_afe.c index e340e101..f2332a32 100644 --- a/tests/unit/app/driver/afe/maxim/api/test_mxm_afe.c +++ b/tests/unit/app/driver/afe/maxim/api/test_mxm_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_afe.c * @author foxBMS Team * @date 2020-06-17 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/maxim/common/config/test_mxm_cfg.c b/tests/unit/app/driver/afe/maxim/common/config/test_mxm_cfg.c index 312371c0..0efade7c 100644 --- a/tests/unit/app/driver/afe/maxim/common/config/test_mxm_cfg.c +++ b/tests/unit/app/driver/afe/maxim/common/config/test_mxm_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_cfg.c * @author foxBMS Team * @date 2020-06-24 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,6 +54,7 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockdiag.h" #include "Mockfassert.h" #include "Mockio.h" #include "Mockspi.h" @@ -113,6 +115,7 @@ void testMXM_SendData(void) { uint16_t bufferLength = 1; SPI_TransmitData_ExpectAndReturn(&spi_MxmInterface, &buffer, bufferLength, STD_OK); + DIAG_CheckEvent_ExpectAndReturn(STD_OK, DIAG_ID_AFE_SPI, DIAG_STRING, 0u, STD_OK); TEST_ASSERT_EQUAL(STD_OK, MXM_SendData(&buffer, bufferLength)); } @@ -122,5 +125,6 @@ void testMXM_ReceiveData(void) { uint16_t bufferLength = 1; SPI_TransmitReceiveData_ExpectAndReturn(&spi_MxmInterface, &buffer, &buffer, bufferLength, STD_OK); + DIAG_CheckEvent_ExpectAndReturn(STD_OK, DIAG_ID_AFE_SPI, DIAG_STRING, 0u, STD_OK); TEST_ASSERT_EQUAL(STD_OK, MXM_ReceiveData(&buffer, &buffer, bufferLength)); } diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c index 770b1cce..a06cba4a 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_17841b.c * @author foxBMS Team * @date 2020-06-22 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x.c index 4e0ffd3d..ddb34357 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_1785x.c * @author foxBMS Team * @date 2020-07-02 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * @@ -57,6 +58,7 @@ #include "unity.h" #include "Mockafe_plausibility.h" #include "Mockdatabase.h" +#include "Mockdiag.h" #include "Mockfassert.h" #include "Mockmxm_17841b.h" #include "Mockmxm_41b_register_map.h" @@ -149,6 +151,19 @@ void testMXM_ParseVoltageReadallTest(void) { TEST_ASSERT_PASS_ASSERT(TEST_ASSERT_EQUAL(STD_OK, TEST_MXM_ParseVoltageReadallTest(&mxm_instance))); } +/** This test aims to provoke the assertion that checks if the battery system fits the internal configuration */ +void testMXM_ConstructBalancingBufferTest(void) { + /* skip this test if the BMS configuration does not fit to this test + (we cannot run with more cells than Maxim supports) */ + if ((BS_NR_OF_CELL_BLOCKS_PER_MODULE > MXM_MAXIMUM_NR_OF_CELLS_PER_MODULE)) { + TEST_PASS_MESSAGE("This test is skipped due to the configuration of the BMS."); + } + TEST_ASSERT_FAIL_ASSERT(MXM_ConstructBalancingBuffer(NULL_PTR)); + DATA_BLOCK_BALANCING_CONTROL_s balancingTable = {.header.uniqueId = DATA_BLOCK_ID_BALANCING_CONTROL}; + MXM_BALANCING_STATE_s balancingInstance = {.pBalancingControl_table = &balancingTable}; + TEST_ASSERT_PASS_ASSERT(MXM_ConstructBalancingBuffer(&balancingInstance)); +} + void testTEST_MXM_ParseVoltageReadallNullPointer(void) { uint8_t voltRxBuffer = 0; MXM_DATA_STORAGE_s datastorage = {0}; @@ -277,7 +292,7 @@ void testMXM_ProcessOpenWire1SatelliteAlternatingPattern(void) { /* simulate 1 satellite */ MXM_5XGetNumberOfSatellites_ExpectAndReturn(mxm_instance.pInstance5X, 1); /* don't care about the database call */ - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); TEST_ASSERT_PASS_ASSERT(MXM_ProcessOpenWire(&mxm_instance)); /* check for the injected pattern */ diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x_tools.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x_tools.c index c9d6143d..f971764f 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x_tools.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x_tools.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_1785x_tools.c * @author foxBMS Team * @date 2020-07-15 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * @@ -183,7 +184,7 @@ void testMXM_ConvertHalfScale(void) { } void testMXM_ConvertSelfCheck(void) { - fas_storeAssertLoc_Ignore(); + FAS_StoreAssertLocation_Ignore(); TEST_ASSERT_PASS_ASSERT(TEST_ASSERT_EQUAL(STD_OK, MXM_ConvertTest())); } @@ -301,7 +302,7 @@ void testConversionExtractAndInsertRoundTripSomeValue(void) { /* WARNING: in order for the MXM_ConvertModuleToString tests to work as expected, make sure that both test and source have been rebuilt (clear the build) after - changing system defines such as BS_NR_OF_MODULES */ + changing system defines such as BS_NR_OF_MODULES_PER_STRING */ void testMXM_ConvertModuleToStringNullPointer(void) { uint8_t stringNumber = 0u; @@ -320,9 +321,9 @@ void testMXM_ConvertModuleToStringTooManyForMaxim(void) { void testMXM_ConvertModuleToStringTooManyForSystem(void) { uint8_t stringNumber = 0u; uint16_t moduleNumberInString = 0u; - /* The system cannot have more modules than BS_NR_OF_STRINGS*BS_NR_OF_MODULES */ - TEST_ASSERT_FAIL_ASSERT( - MXM_ConvertModuleToString((BS_NR_OF_STRINGS * BS_NR_OF_MODULES), &stringNumber, &moduleNumberInString)); + /* The system cannot have more modules than BS_NR_OF_STRINGS*BS_NR_OF_MODULES_PER_STRING */ + TEST_ASSERT_FAIL_ASSERT(MXM_ConvertModuleToString( + (BS_NR_OF_STRINGS * BS_NR_OF_MODULES_PER_STRING), &stringNumber, &moduleNumberInString)); } void testMXM_ConvertModuleToStringFirstInFirstString(void) { @@ -330,8 +331,8 @@ void testMXM_ConvertModuleToStringFirstInFirstString(void) { uint8_t stringNumber = 42u; const uint16_t expectedModuleNumberInString = 0u; uint16_t moduleNumberInString = 42u; - TEST_ASSERT_PASS_ASSERT( - MXM_ConvertModuleToString((expectedStringNumber * BS_NR_OF_MODULES), &stringNumber, &moduleNumberInString)); + TEST_ASSERT_PASS_ASSERT(MXM_ConvertModuleToString( + (expectedStringNumber * BS_NR_OF_MODULES_PER_STRING), &stringNumber, &moduleNumberInString)); TEST_ASSERT_EQUAL(expectedStringNumber, stringNumber); TEST_ASSERT_EQUAL(expectedModuleNumberInString, moduleNumberInString); @@ -346,8 +347,8 @@ void testMXM_ConvertModuleToStringFirstInSecondString(void) { uint8_t stringNumber = 0u; const uint16_t expectedModuleNumberInString = 0u; uint16_t moduleNumberInString = 42u; - TEST_ASSERT_PASS_ASSERT( - MXM_ConvertModuleToString((expectedStringNumber * BS_NR_OF_MODULES), &stringNumber, &moduleNumberInString)); + TEST_ASSERT_PASS_ASSERT(MXM_ConvertModuleToString( + (expectedStringNumber * BS_NR_OF_MODULES_PER_STRING), &stringNumber, &moduleNumberInString)); TEST_ASSERT_EQUAL(expectedStringNumber, stringNumber); TEST_ASSERT_EQUAL(expectedModuleNumberInString, moduleNumberInString); @@ -355,7 +356,7 @@ void testMXM_ConvertModuleToStringFirstInSecondString(void) { void testMXM_ConvertModuleToStringSecondInFirstString(void) { /* skip this test if the BMS configuration does not fit to this test (we need a second module) */ - if (BS_NR_OF_MODULES < 2u) { + if (BS_NR_OF_MODULES_PER_STRING < 2u) { TEST_PASS_MESSAGE("This test is skipped due to the configuration of the BMS."); } const uint8_t expectedStringNumber = 0u; @@ -363,7 +364,7 @@ void testMXM_ConvertModuleToStringSecondInFirstString(void) { const uint16_t expectedModuleNumberInString = 1u; uint16_t moduleNumberInString = 42u; TEST_ASSERT_PASS_ASSERT(MXM_ConvertModuleToString( - ((expectedStringNumber * BS_NR_OF_MODULES) + expectedModuleNumberInString), + ((expectedStringNumber * BS_NR_OF_MODULES_PER_STRING) + expectedModuleNumberInString), &stringNumber, &moduleNumberInString)); @@ -373,7 +374,7 @@ void testMXM_ConvertModuleToStringSecondInFirstString(void) { void testMXM_ConvertModuleToStringSecondInSecondString(void) { /* skip this test if the BMS configuration does not fit to this test (we need a second module) */ - if ((BS_NR_OF_MODULES < 2u) || (BS_NR_OF_STRINGS < 2u)) { + if ((BS_NR_OF_MODULES_PER_STRING < 2u) || (BS_NR_OF_STRINGS < 2u)) { TEST_PASS_MESSAGE("This test is skipped due to the configuration of the BMS."); } const uint8_t expectedStringNumber = 1u; @@ -381,7 +382,7 @@ void testMXM_ConvertModuleToStringSecondInSecondString(void) { const uint16_t expectedModuleNumberInString = 1u; uint16_t moduleNumberInString = 42u; TEST_ASSERT_PASS_ASSERT(MXM_ConvertModuleToString( - (expectedModuleNumberInString + (expectedStringNumber * BS_NR_OF_MODULES)), + (expectedModuleNumberInString + (expectedStringNumber * BS_NR_OF_MODULES_PER_STRING)), &stringNumber, &moduleNumberInString)); diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c index 5a474c52..769b42df 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_afe_dma.c * @author foxBMS Team * @date 2020-06-17 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_battery_management.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_battery_management.c index 851026b7..891616f1 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_battery_management.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_battery_management.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_battery_management.c * @author foxBMS Team * @date 2020-07-02 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * @@ -55,6 +56,7 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockdiag.h" #include "Mockfassert.h" #include "Mockmxm_17841b.h" #include "Mockmxm_41b_register_map.h" diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_bitextract.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_bitextract.c index e398fd1e..5e40af48 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_bitextract.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_bitextract.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_bitextract.c * @author foxBMS Team * @date 2020-04-07 (date of creation) - * @updated 2020-05-14 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_crc8.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_crc8.c index 53986d66..792cee6c 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_crc8.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_crc8.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_crc8.c * @author foxBMS Team * @date 2020-03-13 (date of creation) - * @updated 2020-04-27 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_register_map.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_register_map.c index 166f2321..d6607e87 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_register_map.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_register_map.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_register_map.c * @author foxBMS Team * @date 2020-04-07 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/maxim/common/test_mxm_registry.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_registry.c index ac2b2e27..7811b9a5 100644 --- a/tests/unit/app/driver/afe/maxim/common/test_mxm_registry.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_registry.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_registry.c * @author foxBMS Team * @date 2020-07-16 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * @@ -124,7 +125,7 @@ void testRegistryInitiated(void) { TEST_ASSERT_EQUAL(0u, mxm_state.registry[i].deviceAddress); TEST_ASSERT_EQUAL(0u, mxm_state.registry[i].deviceID); TEST_ASSERT_EQUAL(MXM_MODEL_ID_NONE, mxm_state.registry[i].model); - TEST_ASSERT_EQUAL(MXM_siliconVersion_0, mxm_state.registry[i].siliconVersion); + TEST_ASSERT_EQUAL(MXM_SILICON_VERSION_0, mxm_state.registry[i].siliconVersion); } /* set some values to the registry */ @@ -143,7 +144,7 @@ void testRegistryInitiated(void) { TEST_ASSERT_EQUAL(0u, mxm_state.registry[i].deviceAddress); TEST_ASSERT_EQUAL(0u, mxm_state.registry[i].deviceID); TEST_ASSERT_EQUAL(MXM_MODEL_ID_NONE, mxm_state.registry[i].model); - TEST_ASSERT_EQUAL(MXM_siliconVersion_0, mxm_state.registry[i].siliconVersion); + TEST_ASSERT_EQUAL(MXM_SILICON_VERSION_0, mxm_state.registry[i].siliconVersion); } } diff --git a/tests/unit/app/driver/afe/maxim/max17852/test_mxm_17852.c b/tests/unit/app/driver/afe/maxim/max17852/test_mxm_17852.c index 5c89fda4..6cd39212 100644 --- a/tests/unit/app/driver/afe/maxim/max17852/test_mxm_17852.c +++ b/tests/unit/app/driver/afe/maxim/max17852/test_mxm_17852.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mxm_17852.c * @author foxBMS Team * @date 2021-11-30 (date of creation) - * @updated 2021-12-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix MXM * @@ -57,6 +58,7 @@ #include "unity.h" #include "Mockafe_plausibility.h" #include "Mockdatabase.h" +#include "Mockdiag.h" #include "Mockfassert.h" #include "Mockmxm_17841b.h" #include "Mockmxm_41b_register_map.h" diff --git a/tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c b/tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c index af7c5743..f6b0a20b 100644 --- a/tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c +++ b/tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_nxp_afe.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2020-06-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/nxp/common/config/test_n775_cfg.c b/tests/unit/app/driver/afe/nxp/common/config/test_n775_cfg.c index 16c51669..a22c6d10 100644 --- a/tests/unit/app/driver/afe/nxp/common/config/test_n775_cfg.c +++ b/tests/unit/app/driver/afe/nxp/common/config/test_n775_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_n775_cfg.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2020-06-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c b/tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c index 0c76c9ab..899c0514 100644 --- a/tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c +++ b/tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_nxp_afe_dma_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/afe/nxp/common/test_n775.c b/tests/unit/app/driver/afe/nxp/common/test_n775.c index f9e891b6..1e1b9c73 100644 --- a/tests/unit/app/driver/afe/nxp/common/test_n775.c +++ b/tests/unit/app/driver/afe/nxp/common/test_n775.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_n775.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -73,18 +74,6 @@ static const spiDAT1_t spi_kNxp775DataConfigTx[BS_NR_OF_STRINGS] = { .DFSEL = SPI_FMT_0, /*!< Data word format select */ .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, /* CS2 enabled */ }, - { - .CS_HOLD = TRUE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_0, /*!< Data word format select */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, /*!< CS2 enabled */ - }, - { - .CS_HOLD = TRUE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_0, /*!< Data word format select */ - .CSNR = SPI_HARDWARE_CHIP_SELECT_2_ACTIVE, /* CS2 enabled */ - }, }; /** SPI interface configuration for N775 communication Tx part */ @@ -96,20 +85,6 @@ SPI_INTERFACE_CONFIG_s spi_nxp775InterfaceTx[BS_NR_OF_STRINGS] = { .csPin = 2u, .csType = SPI_CHIP_SELECT_HARDWARE, }, - { - .pConfig = &spi_kNxp775DataConfigTx[1u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, - { - .pConfig = &spi_kNxp775DataConfigTx[2u], - .pNode = spiREG1, - .pGioPort = &(spiREG1->PC3), - .csPin = 2u, - .csType = SPI_CHIP_SELECT_HARDWARE, - }, }; /*========== Setup and Teardown =============================================*/ diff --git a/tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c b/tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c index dc8d3600..d047cd2b 100644 --- a/tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c +++ b/tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_nxp_afe_dma.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2020-06-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_command.c b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_command.c index 6499a47c..f18b917d 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_command.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_command.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_rx_command.c * @author foxBMS Team * @date 2021-07-28 (date of creation) - * @updated 2021-07-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -54,6 +55,8 @@ /*========== Includes =======================================================*/ #include "unity.h" #include "Mockbal.h" +#include "Mockbal_cfg.h" +#include "Mockbms_cfg.h" #include "Mockcan.h" #include "Mockdatabase.h" #include "Mockdiag.h" @@ -61,11 +64,13 @@ #include "Mockimd.h" #include "Mockmpu_prototypes.h" #include "Mockos.h" +#include "Mocksys_mon.h" #include "database_cfg.h" #include "can_cbs.h" #include "can_helper.h" +#include "test_assert_helper.h" TEST_FILE("can_cbs_rx_command.c") @@ -111,11 +116,142 @@ static uint8_t muxId = 0u; /*========== Setup and Teardown =============================================*/ void setUp(void) { + can_tableStateRequest.previousStateRequestViaCan = 0u; + can_tableStateRequest.stateRequestViaCan = 0u; + can_tableStateRequest.stateRequestViaCanPending = 0u; + can_tableStateRequest.stateCounter = 0u; } void tearDown(void) { } /*========== Test Cases =====================================================*/ -void testDummy(void) { +/** test the handling of illegal input by callback */ +void testRxRequestIllegalInput(void) { + uint32_t id = 0u; + uint8_t dlc = 0u; + CAN_ENDIANNESS_e endianness = CAN_LITTLE_ENDIAN; + uint8_t canData[CAN_MAX_DLC] = {0}; + TEST_ASSERT_FAIL_ASSERT(CAN_RxRequest(CAN_MAX_11BIT_ID, dlc, endianness, canData, &can_kShim)); + TEST_ASSERT_FAIL_ASSERT(CAN_RxRequest(id, (CAN_DLC + 1u), endianness, canData, &can_kShim)); + TEST_ASSERT_FAIL_ASSERT(CAN_RxRequest(id, dlc, endianness, NULL_PTR, &can_kShim)); + TEST_ASSERT_FAIL_ASSERT(CAN_RxRequest(id, dlc, endianness, canData, NULL_PTR)); +} + +/** test mode request */ +void testRxRequestModeRequest(void) { + uint32_t id = 0u; + uint8_t dlc = 0u; + CAN_ENDIANNESS_e endianness = CAN_BIG_ENDIAN; + uint8_t canData[CAN_MAX_DLC] = {0}; + + /* ignore reads that are not used in this test */ + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + BAL_GetInitializationState_IgnoreAndReturn(STD_NOT_OK); + BAL_SetBalancingThreshold_Ignore(); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); + + /* request disconnect (STANDBY) */ + canData[0u] = 0u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(BMS_REQ_ID_STANDBY, can_tableStateRequest.stateRequestViaCan); + + /* request discharge (NORMAL) */ + canData[0u] = 1u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(BMS_REQ_ID_NORMAL, can_tableStateRequest.stateRequestViaCan); + + /* request charge (CHARGE) */ + canData[0u] = 2u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(BMS_REQ_ID_CHARGE, can_tableStateRequest.stateRequestViaCan); + + /* no valid request */ + canData[0u] = 3u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(BMS_REQ_ID_NOREQ, can_tableStateRequest.stateRequestViaCan); + + /* state counter overflow */ + can_tableStateRequest.stateCounter = UINT8_MAX; + canData[0u] = 0u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(0u, can_tableStateRequest.stateCounter); + + /* state: no update without change an no time */ + canData[0u] = 0u; + OS_CheckTimeHasPassed_ExpectAndReturn(0u, 0u, false); + OS_CheckTimeHasPassed_IgnoreArg_oldTimeStamp_ms(); + OS_CheckTimeHasPassed_IgnoreArg_timeToPass_ms(); + can_tableStateRequest.stateRequestViaCanPending = 42u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(42u, can_tableStateRequest.stateRequestViaCanPending); + + /* state: update with change of time */ + canData[0u] = 0u; + OS_CheckTimeHasPassed_ExpectAndReturn(0u, 0u, true); + OS_CheckTimeHasPassed_IgnoreArg_oldTimeStamp_ms(); + OS_CheckTimeHasPassed_IgnoreArg_timeToPass_ms(); + can_tableStateRequest.stateRequestViaCanPending = 42u; + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + TEST_ASSERT_EQUAL(BMS_REQ_ID_STANDBY, can_tableStateRequest.stateRequestViaCanPending); +} + +/** test balancing request */ +void testRxRequestBalancingRequest(void) { + uint32_t id = 0u; + uint8_t dlc = 0u; + CAN_ENDIANNESS_e endianness = CAN_BIG_ENDIAN; + uint8_t canData[CAN_MAX_DLC] = {0}; + + /* ignore reads that are not used in this test */ + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); + OS_CheckTimeHasPassed_IgnoreAndReturn(false); + + /* request no balancing */ + canData[1u] = 0u; + canData[2u] = 0u; + BAL_GetInitializationState_ExpectAndReturn(STD_OK); + BAL_SetStateRequest_ExpectAndReturn(BAL_STATE_GLOBAL_DISABLE_REQUEST, BAL_OK); + BAL_SetBalancingThreshold_Expect(0u); + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + + /* request balancing */ + canData[1u] = 1u; + canData[2u] = 0x42; + BAL_GetInitializationState_ExpectAndReturn(STD_OK); + BAL_SetStateRequest_ExpectAndReturn(BAL_STATE_GLOBAL_ENABLE_REQUEST, BAL_OK); + BAL_SetBalancingThreshold_Expect(0x42u); + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); + + /* balancing not initialized */ + canData[1u] = 1u; + canData[2u] = 0x33u; + BAL_GetInitializationState_ExpectAndReturn(STD_NOT_OK); + BAL_SetBalancingThreshold_Expect(0x33u); + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); +} + +/** test reset flags request */ +void testRxRequestResetFlags(void) { + uint32_t id = 0u; + uint8_t dlc = 0u; + CAN_ENDIANNESS_e endianness = CAN_BIG_ENDIAN; + uint8_t canData[CAN_MAX_DLC] = {0}; + + /* ignore reads that are not used in this test */ + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); + OS_CheckTimeHasPassed_IgnoreAndReturn(false); + BAL_SetBalancingThreshold_Ignore(); + BAL_GetInitializationState_IgnoreAndReturn(STD_NOT_OK); + + /* request to reset flags */ + canData[0u] = 4u; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + DIAG_Handler_ExpectAndReturn( + DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_EVENT_OK, DIAG_STRING, s, DIAG_HANDLER_RETURN_OK); + } + SYSM_ClearAllTimingViolations_Expect(); + CAN_RxRequest(id, dlc, endianness, canData, &can_kShim); } diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_current_sensor.c b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_current_sensor.c index c559a238..1d2dd2a3 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_current_sensor.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_current_sensor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_rx_current_sensor.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_imd.c b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_imd.c index e8c9c1de..16d44cbe 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_imd.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_imd.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_rx_imd.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_misc.c b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_misc.c index cd104c98..e2fd9e2a 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_rx_misc.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_rx_misc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_rx_misc.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_limits.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_limits.c index fc497c53..36dc7a56 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_limits.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_limits.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_limits.c * @author foxBMS Team * @date 2021-07-27 (date of creation) - * @updated 2021-07-27 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -120,12 +121,12 @@ void tearDown(void) { void testCAN_TxLimitValues(void) { uint8_t data[8] = {0}; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { can_kShim.pTableSof->recommendedContinuousPackDischargeCurrent_mA = 270000.0f; can_kShim.pTableSof->recommendedContinuousPackChargeCurrent_mA = 240000.0f; } - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); CAN_TxLimitValues(CAN_ID_TX_LIMIT_VALUES, 8, CAN_BIG_ENDIAN, data, NULL_PTR, &can_kShim); @@ -138,8 +139,8 @@ void testCAN_TxLimitValues(void) { * min. battery voltage: 208V */ - uint8_t minimumBatteryVoltage = (uint8_t)((BS_NR_OF_BAT_CELLS * BC_VOLTAGE_MIN_MSL_mV) / 4000u); - uint8_t maximumBatteryVoltage = (uint8_t)((BS_NR_OF_BAT_CELLS * BC_VOLTAGE_MAX_MSL_mV) / 4000u); + uint8_t minimumBatteryVoltage = (uint8_t)((BS_NR_OF_CELL_BLOCKS_PER_STRING * BC_VOLTAGE_MIN_MSL_mV) / 4000u); + uint8_t maximumBatteryVoltage = (uint8_t)((BS_NR_OF_CELL_BLOCKS_PER_STRING * BC_VOLTAGE_MAX_MSL_mV) / 4000u); TEST_ASSERT_EQUAL(0x43, data[0]); TEST_ASSERT_EQUAL(0x83, data[1]); diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_minmax.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_minmax.c index 766a9045..b453efce 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_minmax.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_minmax.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_minmax.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -120,14 +121,14 @@ void tearDown(void) { void testCAN_TxMinimumMaximumValuesAllStringsOpen(void) { uint8_t data[8] = {0}; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - can_kShim.pTableMinMax->minimumCellVoltage_mV[stringNumber] = 2000; - can_kShim.pTableMinMax->maximumCellVoltage_mV[stringNumber] = 3000; - can_kShim.pTableMinMax->minimumTemperature_ddegC[stringNumber] = -150; - can_kShim.pTableMinMax->maximumTemperature_ddegC[stringNumber] = 350; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + can_kShim.pTableMinMax->minimumCellVoltage_mV[s] = 2000; + can_kShim.pTableMinMax->maximumCellVoltage_mV[s] = 3000; + can_kShim.pTableMinMax->minimumTemperature_ddegC[s] = -150; + can_kShim.pTableMinMax->maximumTemperature_ddegC[s] = 350; } - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); BMS_GetNumberOfConnectedStrings_IgnoreAndReturn(0u); CAN_TxMinimumMaximumValues(CAN_ID_TX_MINIMUM_MAXIMUM_VALUES, 8, CAN_BIG_ENDIAN, data, NULL_PTR, &can_kShim); @@ -150,16 +151,16 @@ void testCAN_TxMinimumMaximumValuesAllStringsOpen(void) { void testCAN_TxMinimumMaximumValuesAllStringsClosed(void) { uint8_t data[8] = {0}; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - can_kShim.pTableMinMax->minimumCellVoltage_mV[stringNumber] = 2000 + stringNumber; - can_kShim.pTableMinMax->maximumCellVoltage_mV[stringNumber] = 3000 - stringNumber; - can_kShim.pTableMinMax->minimumTemperature_ddegC[stringNumber] = -150 + stringNumber; - can_kShim.pTableMinMax->maximumTemperature_ddegC[stringNumber] = 350 - stringNumber; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + can_kShim.pTableMinMax->minimumCellVoltage_mV[s] = 2000 + s; + can_kShim.pTableMinMax->maximumCellVoltage_mV[s] = 3000 - s; + can_kShim.pTableMinMax->minimumTemperature_ddegC[s] = -150 + s; + can_kShim.pTableMinMax->maximumTemperature_ddegC[s] = 350 - s; } - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); BMS_GetNumberOfConnectedStrings_IgnoreAndReturn(BS_NR_OF_STRINGS); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { BMS_IsStringClosed_IgnoreAndReturn(true); } CAN_TxMinimumMaximumValues(CAN_ID_TX_MINIMUM_MAXIMUM_VALUES, 8, CAN_BIG_ENDIAN, data, NULL_PTR, &can_kShim); diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state.c index 6da99cc6..83cfdd03 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_state.c * @author foxBMS Team * @date 2021-07-27 (date of creation) - * @updated 2021-07-27 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -61,6 +62,7 @@ #include "Mockimd.h" #include "Mockmpu_prototypes.h" #include "Mockos.h" +#include "Mocksys_mon.h" #include "database_cfg.h" diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state_estimation.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state_estimation.c index 818ef1e7..ce72fcdb 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state_estimation.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_state_estimation.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_state_estimation.c * @author foxBMS Team * @date 2021-07-27 (date of creation) - * @updated 2021-07-27 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -120,15 +121,15 @@ void tearDown(void) { void testCAN_TxStateEstimationCharging(void) { uint8_t data[8] = {0}; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - can_kShim.pTableSox->minimumSoc_perc[stringNumber] = 71.2f; - can_kShim.pTableSox->maximumSoc_perc[stringNumber] = 74.2f; - can_kShim.pTableSox->minimumSoe_perc[stringNumber] = 74.6f; - can_kShim.pTableSox->maximumSoe_perc[stringNumber] = 78.1f; - can_kShim.pTableSox->minimumSoe_Wh[stringNumber] = 19200 / BS_NR_OF_STRINGS; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + can_kShim.pTableSox->minimumSoc_perc[s] = 71.2f; + can_kShim.pTableSox->maximumSoc_perc[s] = 74.2f; + can_kShim.pTableSox->minimumSoe_perc[s] = 74.6f; + can_kShim.pTableSox->maximumSoe_perc[s] = 78.1f; + can_kShim.pTableSox->minimumSoe_Wh[s] = 19200 / BS_NR_OF_STRINGS; } - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); /* System is currently charging */ BMS_GetBatterySystemState_IgnoreAndReturn(BMS_CHARGING); /* All strings connected */ @@ -162,15 +163,15 @@ void testCAN_TxStateEstimationCharging(void) { void testCAN_TxStateEstimationDischarging(void) { uint8_t data[8] = {0}; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - can_kShim.pTableSox->minimumSoc_perc[stringNumber] = 74.2f; - can_kShim.pTableSox->maximumSoc_perc[stringNumber] = 78.2f; - can_kShim.pTableSox->minimumSoe_perc[stringNumber] = 78.1f; - can_kShim.pTableSox->maximumSoe_perc[stringNumber] = 83.1f; - can_kShim.pTableSox->minimumSoe_Wh[stringNumber] = 19200 / BS_NR_OF_STRINGS; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + can_kShim.pTableSox->minimumSoc_perc[s] = 74.2f; + can_kShim.pTableSox->maximumSoc_perc[s] = 78.2f; + can_kShim.pTableSox->minimumSoe_perc[s] = 78.1f; + can_kShim.pTableSox->maximumSoe_perc[s] = 83.1f; + can_kShim.pTableSox->minimumSoe_Wh[s] = 19200 / BS_NR_OF_STRINGS; } - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); /* System is currently charging */ BMS_GetBatterySystemState_IgnoreAndReturn(BMS_DISCHARGING); /* All strings connected */ diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_system_values.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_system_values.c index 11eb90c8..bc970ad8 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_system_values.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_system_values.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_system_values.c * @author foxBMS Team * @date 2021-07-27 (date of creation) - * @updated 2021-07-27 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -124,7 +125,7 @@ void testCAN_TxPackValues(void) { can_kShim.pTablePackValues->highVoltageBusVoltage_mV = 325100; can_kShim.pTablePackValues->packPower_W = -65100; - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); CAN_TxPackValues(CAN_ID_TX_PACK_VALUES, 8, CAN_BIG_ENDIAN, data, NULL_PTR, &can_kShim); /** Values of: diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_temperature.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_temperature.c index 4ead390b..1c6e4dd7 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_temperature.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_temperature.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_temperature.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -120,15 +121,15 @@ void tearDown(void) { void testCAN_TxCellTemperature(void) { uint8_t data[8] = {0}; - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - can_kShim.pTableCellTemperature->cellTemperature_ddegC[stringNumber][0] = 100; - can_kShim.pTableCellTemperature->cellTemperature_ddegC[stringNumber][1] = 110; - can_kShim.pTableCellTemperature->cellTemperature_ddegC[stringNumber][2] = 120; - can_kShim.pTableCellTemperature->cellTemperature_ddegC[stringNumber][3] = 250; - can_kShim.pTableCellTemperature->cellTemperature_ddegC[stringNumber][4] = 400; - can_kShim.pTableCellTemperature->cellTemperature_ddegC[stringNumber][5] = -100; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + can_kShim.pTableCellTemperature->cellTemperature_ddegC[s][0] = 100; + can_kShim.pTableCellTemperature->cellTemperature_ddegC[s][1] = 110; + can_kShim.pTableCellTemperature->cellTemperature_ddegC[s][2] = 120; + can_kShim.pTableCellTemperature->cellTemperature_ddegC[s][3] = 250; + can_kShim.pTableCellTemperature->cellTemperature_ddegC[s][4] = 400; + can_kShim.pTableCellTemperature->cellTemperature_ddegC[s][5] = -100; } CAN_TxCellTemperature(0x111, 8, CAN_BIG_ENDIAN, data, &muxId, &can_kShim); diff --git a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_voltage.c b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_voltage.c index f7c3a773..af4add0f 100644 --- a/tests/unit/app/driver/can/cbs/test_can_cbs_tx_voltage.c +++ b/tests/unit/app/driver/can/cbs/test_can_cbs_tx_voltage.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cbs_tx_voltage.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -120,13 +121,13 @@ void tearDown(void) { void testCAN_TxVoltage(void) { uint8_t data[8] = {0}; - DATA_Read_1_DataBlock_IgnoreAndReturn(0u); + DATA_Read1DataBlock_IgnoreAndReturn(0u); - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - can_kShim.pTableCellVoltage->cellVoltage_mV[stringNumber][0] = 2000; - can_kShim.pTableCellVoltage->cellVoltage_mV[stringNumber][1] = 2100; - can_kShim.pTableCellVoltage->cellVoltage_mV[stringNumber][2] = 3000; - can_kShim.pTableCellVoltage->cellVoltage_mV[stringNumber][3] = 3700; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + can_kShim.pTableCellVoltage->cellVoltage_mV[s][0] = 2000; + can_kShim.pTableCellVoltage->cellVoltage_mV[s][1] = 2100; + can_kShim.pTableCellVoltage->cellVoltage_mV[s][2] = 3000; + can_kShim.pTableCellVoltage->cellVoltage_mV[s][3] = 3700; } CAN_TxVoltage(CAN_ID_TX_VOLTAGES, 8, CAN_BIG_ENDIAN, data, &muxId, &can_kShim); diff --git a/tests/unit/app/driver/can/cbs/test_can_helper.c b/tests/unit/app/driver/can/cbs/test_can_helper.c index a2aa8d96..76d33b95 100644 --- a/tests/unit/app/driver/can/cbs/test_can_helper.c +++ b/tests/unit/app/driver/can/cbs/test_can_helper.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_helper.c * @author foxBMS Team * @date 2021-04-22 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -247,3 +248,8 @@ void testCAN_RxGetSignalDataFromMessageData64BitMessage(void) { TEST_ASSERT_EQUAL_UINT64(0x3u, canSignal); } + +void testCAN_ConvertBooleanToInteger(void) { + TEST_ASSERT_EQUAL(0u, CAN_ConvertBooleanToInteger(false)); + TEST_ASSERT_EQUAL(1u, CAN_ConvertBooleanToInteger(true)); +} diff --git a/tests/unit/app/driver/can/test_can.c b/tests/unit/app/driver/can/test_can.c index cc058355..9d0e8c16 100644 --- a/tests/unit/app/driver/can/test_can.c +++ b/tests/unit/app/driver/can/test_can.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -138,9 +139,9 @@ void setUp(void) { canTestState->periodicEnable = false; - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { - canTestState->currentSensorPresent[stringNumber] = false; - canTestState->currentSensorCCPresent[stringNumber] = false; + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { + canTestState->currentSensorPresent[s] = false; + canTestState->currentSensorCCPresent[s] = false; } } @@ -208,34 +209,47 @@ void testEnablePeriodic(void) { } void testIsCurrentSensorPresent(void) { - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* check state before */ - TEST_ASSERT_EQUAL(false, canTestState->currentSensorPresent[stringNumber]); + TEST_ASSERT_EQUAL(false, canTestState->currentSensorPresent[s]); - TEST_ASSERT_EQUAL(false, CAN_IsCurrentSensorPresent(stringNumber)); + TEST_ASSERT_EQUAL(false, CAN_IsCurrentSensorPresent(s)); /* set state to true */ - canTestState->currentSensorPresent[stringNumber] = true; + canTestState->currentSensorPresent[s] = true; /* check state again */ - TEST_ASSERT_EQUAL(true, canTestState->currentSensorPresent[stringNumber]); + TEST_ASSERT_EQUAL(true, canTestState->currentSensorPresent[s]); } } void testIsCurrentSensorCcPresent(void) { - for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) { + for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) { /* check state before */ - TEST_ASSERT_EQUAL(false, canTestState->currentSensorCCPresent[stringNumber]); - - TEST_ASSERT_EQUAL(false, CAN_IsCurrentSensorCcPresent(stringNumber)); + TEST_ASSERT_EQUAL(false, canTestState->currentSensorCCPresent[s]); + TEST_ASSERT_EQUAL(false, CAN_IsCurrentSensorCcPresent(s)); /* set state to true */ - canTestState->currentSensorCCPresent[stringNumber] = true; + canTestState->currentSensorCCPresent[s] = true; /* check state again */ - TEST_ASSERT_EQUAL(true, canTestState->currentSensorCCPresent[stringNumber]); + TEST_ASSERT_EQUAL(true, canTestState->currentSensorCCPresent[s]); } } void testCAN_TransmitBootMessage(void) { } + +/** + * @brief test #CAN_TransmitDieId() + * @details Currently not implemented. Implementing a test for this function + * would require implementing a harness that mocks away the + * systemREG1 (defined in HAL) as otherwise the test would attempt to + * read random memory addresses. + * Since the benefit of testing this function on unit level is rather + * low (next to no interaction with rest of code base), it should be + * tested in the integration test. + * +*/ +void testCAN_TransmitDieId(void) { +} diff --git a/tests/unit/app/driver/checksum/test_checksum.c b/tests/unit/app/driver/checksum/test_checksum.c index 2adfc221..603731e0 100644 --- a/tests/unit/app/driver/checksum/test_checksum.c +++ b/tests/unit/app/driver/checksum/test_checksum.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_checksum.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-05-25 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_can_cfg.c b/tests/unit/app/driver/config/test_can_cfg.c index cd665d3c..dcf466f0 100644 --- a/tests/unit/app/driver/config/test_can_cfg.c +++ b/tests/unit/app/driver/config/test_can_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_cfg.c * @author foxBMS Team * @date 2020-07-28 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_contactor_cfg.c b/tests/unit/app/driver/config/test_contactor_cfg.c index 4c3fecbd..dff9cd9e 100644 --- a/tests/unit/app/driver/config/test_contactor_cfg.c +++ b/tests/unit/app/driver/config/test_contactor_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_contactor_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_dma_cfg.c b/tests/unit/app/driver/config/test_dma_cfg.c index 18034fbd..1e7d586e 100644 --- a/tests/unit/app/driver/config/test_dma_cfg.c +++ b/tests/unit/app/driver/config/test_dma_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_dma_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_fram_cfg.c b/tests/unit/app/driver/config/test_fram_cfg.c index f20ad6c1..ba475bfe 100644 --- a/tests/unit/app/driver/config/test_fram_cfg.c +++ b/tests/unit/app/driver/config/test_fram_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fram_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-09-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_interlock_cfg.c b/tests/unit/app/driver/config/test_interlock_cfg.c index 97f1f56c..fc4abb67 100644 --- a/tests/unit/app/driver/config/test_interlock_cfg.c +++ b/tests/unit/app/driver/config/test_interlock_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_interlock_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_nxpfs85xx_cfg.c b/tests/unit/app/driver/config/test_nxpfs85xx_cfg.c index 2787119f..92184beb 100644 --- a/tests/unit/app/driver/config/test_nxpfs85xx_cfg.c +++ b/tests/unit/app/driver/config/test_nxpfs85xx_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_nxpfs85xx_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_pex_cfg.c b/tests/unit/app/driver/config/test_pex_cfg.c index 120749a8..d0579cf4 100644 --- a/tests/unit/app/driver/config/test_pex_cfg.c +++ b/tests/unit/app/driver/config/test_pex_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_pex_cfg.c * @author foxBMS Team * @date 2021-08-03 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_spi_cfg.c b/tests/unit/app/driver/config/test_spi_cfg.c index fcd6fbc9..1e33a609 100644 --- a/tests/unit/app/driver/config/test_spi_cfg.c +++ b/tests/unit/app/driver/config/test_spi_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_spi_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/config/test_sps_cfg.c b/tests/unit/app/driver/config/test_sps_cfg.c index 0cb61e0f..3a3b0626 100644 --- a/tests/unit/app/driver/config/test_sps_cfg.c +++ b/tests/unit/app/driver/config/test_sps_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sps_cfg.c * @author foxBMS Team * @date 2020-10-28 (date of creation) - * @updated 2020-10-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/contactor/test_contactor.c b/tests/unit/app/driver/contactor/test_contactor.c index ca198754..828717f3 100644 --- a/tests/unit/app/driver/contactor/test_contactor.c +++ b/tests/unit/app/driver/contactor/test_contactor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_contactor.c * @author foxBMS Team * @date 2020-03-31 (date of creation) - * @updated 2020-03-31 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -65,19 +66,13 @@ /*========== Definitions and Implementations for Unit Test ==================*/ BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge[BS_NR_OF_STRINGS] = { - BS_STRING_WITHOUT_PRECHARGE, BS_STRING_WITH_PRECHARGE, - BS_STRING_WITHOUT_PRECHARGE, }; CONT_CONTACTOR_STATE_s cont_contactorStates[BS_NR_OF_CONTACTORS] = { {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 0u, CONT_STRING0_PLUS}, {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 1u, CONT_STRING0_MINUS}, {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 2u, CONT_STRING1_PLUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 3u, CONT_STRING1_MINUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 4u, CONT_STRING2_PLUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 5u, CONT_STRING2_MINUS}, - {CONT_SWITCH_OFF, CONT_SWITCH_OFF, CONT_FEEDBACK_THROUGH_CURRENT, 6u, CONT_PRECHARGE}, }; /*========== Setup and Teardown =============================================*/ diff --git a/tests/unit/app/driver/crc/test_crc.c b/tests/unit/app/driver/crc/test_crc.c new file mode 100644 index 00000000..a146e2db --- /dev/null +++ b/tests/unit/app/driver/crc/test_crc.c @@ -0,0 +1,72 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file test_crc.c + * @author foxBMS Team + * @date 2022-02-23 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Test of the crc module + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "Mockfassert.h" + +#include "crc.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +void testDummy(void) { +} diff --git a/tests/unit/app/driver/dma/test_dma.c b/tests/unit/app/driver/dma/test_dma.c index 57da6170..45be2b72 100644 --- a/tests/unit/app/driver/dma/test_dma.c +++ b/tests/unit/app/driver/dma/test_dma.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_dma.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/foxmath/test_foxmath.c b/tests/unit/app/driver/foxmath/test_foxmath.c index c1a1af48..653f86b5 100644 --- a/tests/unit/app/driver/foxmath/test_foxmath.c +++ b/tests/unit/app/driver/foxmath/test_foxmath.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_foxmath.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/fram/test_fram.c b/tests/unit/app/driver/fram/test_fram.c index 44851d12..fd960861 100644 --- a/tests/unit/app/driver/fram/test_fram.c +++ b/tests/unit/app/driver/fram/test_fram.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fram.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -54,6 +55,8 @@ /*========== Includes =======================================================*/ #include "unity.h" #include "MockHL_spi.h" +#include "Mockcrc.h" +#include "Mockdiag.h" #include "Mockio.h" #include "Mockmcu.h" #include "Mockspi.h" diff --git a/tests/unit/app/driver/htsensor/test_htsensor.c b/tests/unit/app/driver/htsensor/test_htsensor.c index d3c6c42b..62688f45 100644 --- a/tests/unit/app/driver/htsensor/test_htsensor.c +++ b/tests/unit/app/driver/htsensor/test_htsensor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_htsensor.c * @author foxBMS Team * @date 2021-08-05 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/i2c/test_i2c.c b/tests/unit/app/driver/i2c/test_i2c.c index 88233373..1f32c06f 100644 --- a/tests/unit/app/driver/i2c/test_i2c.c +++ b/tests/unit/app/driver/i2c/test_i2c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_i2c.c * @author foxBMS Team * @date 2021-07-23 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c b/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c index bc703dfb..82ca1a57 100644 --- a/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c +++ b/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bender_ir155.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155_helper.c b/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155_helper.c new file mode 100644 index 00000000..5bef0ed7 --- /dev/null +++ b/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155_helper.c @@ -0,0 +1,75 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file test_bender_ir155_helper.c + * @author foxBMS Team + * @date 2020-11-02 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the Bender IR155 driver + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "Mockfram.h" +#include "Mockio.h" +#include "Mockpwm.h" + +#include "bender_ir155_helper.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ +FRAM_INSULATION_FLAG_s fram_insulationFlags; + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +void testNoTestsAvailable(void) { +} diff --git a/tests/unit/app/driver/imd/bender/iso165c/config/test_bender_iso165c_cfg.c b/tests/unit/app/driver/imd/bender/iso165c/config/test_bender_iso165c_cfg.c index 38ea1230..6a28c835 100644 --- a/tests/unit/app/driver/imd/bender/iso165c/config/test_bender_iso165c_cfg.c +++ b/tests/unit/app/driver/imd/bender/iso165c/config/test_bender_iso165c_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bender_iso165c_cfg.c * @author foxBMS Team * @date 2021-03-29 (date of creation) - * @updated 2021-03-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c b/tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c index 90ae6990..8a81783f 100644 --- a/tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c +++ b/tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_bender_iso165c.c * @author foxBMS Team * @date 2021-01-19 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -94,12 +95,10 @@ void testMessageComposition(void) { uint8_t data8; uint8_t command; uint8_t id; - I165C_STATE_e currentState; - I165C_STATE_e nextState; uint8_t tries; /* Do as if there is a message in the queue */ - MPU_uxQueueMessagesWaiting_IgnoreAndReturn(1u); + OS_GetNumberOfStoredMessagesInQueue_IgnoreAndReturn(1u); MPU_xQueueReceive_IgnoreAndReturn(1u); OS_ReceiveFromQueue_IgnoreAndReturn(OS_SUCCESS); @@ -188,11 +187,31 @@ void testMessageComposition(void) { TEST_ASSERT_EQUAL(0xAu, canMessage.id); TEST_ASSERT_EQUAL(0xBu, canMessage.data[0u]); + /* Check assertion of invalid parameter */ canMessage.data[0u] = 0xA; command = 0xA; TEST_ASSERT_FAIL_ASSERT(TEST_I165C_CheckResponse(command, NULL_PTR)); + /* Check that response ID corresponds to awaited acknowledge */ + canMessage.id = CAN_ID_IMD_RESPONSE; + canMessage.data[0u] = 0xA; + command = 0xA; TEST_ASSERT_EQUAL(true, TEST_I165C_CheckResponse(command, &canMessage)); + + /* Check that response ID does not correspond to awaited acknowledge */ + canMessage.id = CAN_ID_IMD_RESPONSE; + canMessage.data[0u] = 0xA; + command = 0xB; + TEST_ASSERT_EQUAL(false, TEST_I165C_CheckResponse(command, &canMessage)); + + /* Check that response failed if ID is not CAN_ID_IMD_RESPONSE, even if response matches command */ + canMessage.id = CAN_ID_IMD_INFO; + canMessage.data[0u] = 0xA; + command = 0xA; + TEST_ASSERT_EQUAL(false, TEST_I165C_CheckResponse(command, &canMessage)); + + /* Check that response failed if ID is not CAN_ID_IMD_RESPONSE, if respose does not match command */ + canMessage.id = CAN_ID_IMD_INFO; canMessage.data[0u] = 0xA; command = 0xB; TEST_ASSERT_EQUAL(false, TEST_I165C_CheckResponse(command, &canMessage)); @@ -204,48 +223,68 @@ void testMessageComposition(void) { canMessage.id = I165C_MESSAGETYPE_IMD_INFO + 1u; TEST_ASSERT_EQUAL(false, TEST_I165C_GetImdInfo(&canMessage)); + /* Test if CAN data indicated that iso165c is not initialized */ for (uint8_t i = 0u; i < 8u; i++) { canMessage.data[i] = 0u; } - /* Test if CAN data indicated that iso165c is initialized */ - TEST_ASSERT_EQUAL(true, TEST_I165C_IsInitialized(canMessage)); + TEST_ASSERT_EQUAL(false, TEST_I165C_IsSelfTestFinished(canMessage)); + + /* Test if CAN data indicated that iso165c is not initialized */ for (uint8_t i = 0u; i < 8u; i++) { - canMessage.data[i] = 0xFFu; + canMessage.data[i] = 0x00u; } - TEST_ASSERT_EQUAL(false, TEST_I165C_IsInitialized(canMessage)); + /* + * D_IMC_STATUS is located in byte 2 and byte 3 of CAN message: + * Bit 4: Self test running -> set to 1 */ + canMessage.data[2u] |= (1u << I165C_SELFTEST_RUNNING_SHIFT); + /* D_VIFC_STATUS is located in byte 4 and byte 5 of CAN message + * Bit 0: Insulation measurement active -> set to 0 + * Bit 12: Self-test long executed -> set to 0 + * Bit 13: Self-test short executed -> set to 0 + */ + canMessage.data[4u] |= (0u << I165C_INSULATION_MEASUREMENT_STATUS_SHIFT); + canMessage.data[5u] |= + (0u << (I165C_IMC_SELFTEST_OVERALL_SCENARIO_SHIFT - 8u)); /* Subtract 8 because upper byte is used */ + canMessage.data[5u] |= + (0u << (I165C_IMC_SELFTEST_PARAMETERCONFIG_SCENARIO_SHIFT - 8u)); /* Subtract 8 because upper byte is used */ + + TEST_ASSERT_EQUAL(true, TEST_I165C_IsSelfTestFinished(canMessage)); + + /* ----------- Test function that waits for acknowledge -----------------*/ + /* Check for invalid function parameters */ + TEST_ASSERT_FAIL_ASSERT(TEST_I165C_CheckAcknowledgeArrived(command, NULL_PTR, NULL_PTR)); + TEST_ASSERT_FAIL_ASSERT(TEST_I165C_CheckAcknowledgeArrived(command, NULL_PTR, &canMessage)); + TEST_ASSERT_FAIL_ASSERT(TEST_I165C_CheckAcknowledgeArrived(command, &tries, NULL_PTR)); + + /* Acknowledge arrived */ + canMessage.id = CAN_ID_IMD_RESPONSE; tries = 0u; command = 0xA; canMessage.data[0] = 0xA; - I165C_STATE_SELFTEST; - nextState = I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK; - currentState = I165C_STATE_SET_ERROR_THRESHOLD; - /* Test function that waits for acknowledge and switches state */ - - TEST_ASSERT_FAIL_ASSERT(TEST_I165C_CheckAcknowledgeArrived(command, NULL_PTR, nextState, &tries, &canMessage)); - TEST_ASSERT_FAIL_ASSERT( - TEST_I165C_CheckAcknowledgeArrived(command, ¤tState, nextState, NULL_PTR, &canMessage)); - TEST_ASSERT_FAIL_ASSERT(TEST_I165C_CheckAcknowledgeArrived(command, ¤tState, nextState, &tries, NULL_PTR)); - /* Acknowledge arrived, switch to next state */ - TEST_I165C_CheckAcknowledgeArrived(command, ¤tState, nextState, &tries, &canMessage); - TEST_ASSERT_EQUAL(I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK, currentState); + bool ackReceived = false; + + ackReceived = TEST_I165C_CheckAcknowledgeArrived(command, &tries, &canMessage); + TEST_ASSERT_EQUAL(true, ackReceived); + TEST_ASSERT_EQUAL(0u, tries); + + /* Acknowledge not arrived, increment try counter */ + canMessage.id = CAN_ID_IMD_RESPONSE; tries = 0u; command = 0xA; canMessage.data[0] = 0xB; - nextState = I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK; - currentState = I165C_STATE_SET_ERROR_THRESHOLD; - /* Acknowledge not arrived, increment try counter */ - TEST_I165C_CheckAcknowledgeArrived(command, ¤tState, nextState, &tries, &canMessage); - TEST_ASSERT_EQUAL(tries, 1u); - tries = I165C_TRANSMISSION_TRIES - 1u; + + ackReceived = TEST_I165C_CheckAcknowledgeArrived(command, &tries, &canMessage); + TEST_ASSERT_EQUAL(1u, tries); + TEST_ASSERT_EQUAL(false, ackReceived); + + /* Acknowledge not arrived, and allowed number of tries made, restart + * Initialization (go to self test) */ + tries = I165C_TRANSMISSION_ATTEMPTS - 1u; command = 0xA; canMessage.data[0] = 0xB; - nextState = I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK; - currentState = I165C_STATE_SET_ERROR_THRESHOLD; - /** - * Acknowledge not arrived, and allowed number of tries made, restart - * Initialization (go to self test) - */ - TEST_I165C_CheckAcknowledgeArrived(command, ¤tState, nextState, &tries, &canMessage); - TEST_ASSERT_EQUAL(I165C_STATE_SELFTEST, currentState); + + ackReceived = TEST_I165C_CheckAcknowledgeArrived(command, &tries, &canMessage); + TEST_ASSERT_EQUAL(I165C_TRANSMISSION_ATTEMPTS, tries); + TEST_ASSERT_EQUAL(false, ackReceived); } diff --git a/tests/unit/app/driver/imd/none/test_no-imd.c b/tests/unit/app/driver/imd/none/test_no-imd.c index 64002b71..82862d9b 100644 --- a/tests/unit/app/driver/imd/none/test_no-imd.c +++ b/tests/unit/app/driver/imd/none/test_no-imd.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_no-imd.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-09-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -70,8 +71,14 @@ void setUp(void) { void tearDown(void) { } +DATA_BLOCK_INSULATION_MONITORING_s noimd_tableInsulationValues = { + .header.uniqueId = DATA_BLOCK_ID_INSULATION_MONITORING}; + /*========== Test Cases =====================================================*/ +void testImdDummyInitialize(void) { + TEST_ASSERT_EQUAL(IMD_FSM_STATE_IMD_ENABLE, TEST_NOIMD_Initialize()); +} + void testImdDummyFunctions(void) { - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - TEST_ASSERT_EQUAL(STD_OK, TEST_NOIMD_MeasureInsulation()); + TEST_ASSERT_EQUAL(IMD_FSM_STATE_RUNNING, TEST_NOIMD_MeasureInsulation(&noimd_tableInsulationValues)); } diff --git a/tests/unit/app/driver/imd/test_imd.c b/tests/unit/app/driver/imd/test_imd.c new file mode 100644 index 00000000..bfd55942 --- /dev/null +++ b/tests/unit/app/driver/imd/test_imd.c @@ -0,0 +1,75 @@ +/** + * + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * We kindly request you to use one or more of the following phrases to refer to + * foxBMS in your hardware, software, documentation or advertising materials: + * + * - ″This product uses parts of foxBMS®″ + * - ″This product includes parts of foxBMS®″ + * - ″This product is derived from foxBMS®″ + * + */ + +/** + * @file test_imd.c + * @author foxBMS Team + * @date 2021-11-15 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the Insulation Monitoring Device (IMD) driver + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "Mockdatabase.h" +#include "Mockdiag.h" +#include "Mockos.h" + +#include "imd.h" +#include "no-imd.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +void testNoTestsAvailable(void) { +} diff --git a/tests/unit/app/driver/interlock/test_interlock.c b/tests/unit/app/driver/interlock/test_interlock.c index 62fc75f6..970ea61b 100644 --- a/tests/unit/app/driver/interlock/test_interlock.c +++ b/tests/unit/app/driver/interlock/test_interlock.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_interlock.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-10-18 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -184,8 +185,8 @@ void testInitializeStatemachine(void) { IO_SetPinDirectionToInput_Ignore(); IO_PinReset_Ignore(); - DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); DIAG_CheckEvent_IgnoreAndReturn(STD_OK); TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); @@ -232,8 +233,8 @@ void testILCK_GetInterlockFeedbackFeedbackOn(void) { IO_PinReset_Ignore(); IO_PinGet_ExpectAndReturn(&ILCK_IO_REG_PORT->DIN, ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE, STD_PIN_LOW); /* gioGetBit_ExpectAndReturn(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 1u); */ - DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); TEST_ASSERT_EQUAL(ILCK_SWITCH_ON, TEST_ILCK_GetInterlockFeedback()); } @@ -249,8 +250,8 @@ void testILCK_GetInterlockFeedbackFeedbackOff(void) { /* set the return value to 0, which means interlock off */ IO_PinGet_ExpectAndReturn(&ILCK_IO_REG_PORT->DIN, ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE, STD_PIN_HIGH); /* gioGetBit_ExpectAndReturn(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 0u); */ - DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Read1DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write1DataBlock_IgnoreAndReturn(STD_OK); TEST_ASSERT_EQUAL(ILCK_SWITCH_OFF, TEST_ILCK_GetInterlockFeedback()); } diff --git a/tests/unit/app/driver/io/test_io.c b/tests/unit/app/driver/io/test_io.c index a513e2a4..d0da03f3 100644 --- a/tests/unit/app/driver/io/test_io.c +++ b/tests/unit/app/driver/io/test_io.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_io.c * @author foxBMS Team * @date 2020-06-10 (date of creation) - * @updated 2020-06-10 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/led/test_led.c b/tests/unit/app/driver/led/test_led.c index 9a7e590c..10d91d39 100644 --- a/tests/unit/app/driver/led/test_led.c +++ b/tests/unit/app/driver/led/test_led.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_led.c * @author foxBMS Team * @date 2020-10-05 (date of creation) - * @updated 2020-10-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/mcu/test_mcu.c b/tests/unit/app/driver/mcu/test_mcu.c index 0889f8fd..32a8a6a0 100644 --- a/tests/unit/app/driver/mcu/test_mcu.c +++ b/tests/unit/app/driver/mcu/test_mcu.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_mcu.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -57,16 +58,31 @@ #include "mcu.h" /*========== Definitions and Implementations for Unit Test ==================*/ -volatile uint32_t MCU_RTI_CNT0_FRC0_REG = 0; +volatile uint32_t MCU_RTI_CNT0_FRC0_REG = 0u; /*========== Setup and Teardown =============================================*/ void setUp(void) { + MCU_RTI_CNT0_FRC0_REG = 0u; } void tearDown(void) { } /*========== Test Cases =====================================================*/ -void testMCU_delay_us(void) { - MCU_delay_us(1); +void testMCU_Delay_us(void) { + MCU_Delay_us(1); +} + +/** test whether #MCU_GetFreeRunningCount() returns the correct value */ +void testMCU_GetFreeRunningCount(void) { + TEST_ASSERT_EQUAL(0u, MCU_GetFreeRunningCount()); + MCU_RTI_CNT0_FRC0_REG = 42u; + TEST_ASSERT_EQUAL(42u, MCU_GetFreeRunningCount()); +} + +/** test conversion function for FRC #MCU_ConvertFrcDifferenceToTimespan_us() */ +void testMCU_ConvertFrcDifferenceToTimespan_us(void) { + TEST_ASSERT_EQUAL(0u, MCU_ConvertFrcDifferenceToTimespan_us(0u)); + + TEST_ASSERT_EQUAL(977u, MCU_ConvertFrcDifferenceToTimespan_us(0xBEEFu)); } diff --git a/tests/unit/app/driver/meas/test_meas.c b/tests/unit/app/driver/meas/test_meas.c index 6cfa9c03..d1d109c2 100644 --- a/tests/unit/app/driver/meas/test_meas.c +++ b/tests/unit/app/driver/meas/test_meas.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_meas.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/pex/test_pex.c b/tests/unit/app/driver/pex/test_pex.c index 5b78ec10..62e9e776 100644 --- a/tests/unit/app/driver/pex/test_pex.c +++ b/tests/unit/app/driver/pex/test_pex.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_pex.c * @author foxBMS Team * @date 2021-09-29 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/pwm/test_pwm.c b/tests/unit/app/driver/pwm/test_pwm.c index 308bbaa2..bcb68337 100644 --- a/tests/unit/app/driver/pwm/test_pwm.c +++ b/tests/unit/app/driver/pwm/test_pwm.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_pwm.c * @author foxBMS Team * @date 2021-10-08 (date of creation) - * @updated 2021-10-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -55,6 +56,13 @@ #include "unity.h" #include "MockHL_etpwm.h" +/* HL_ecap.h can not be mocked, due to 'ecapNotification' is implemented in + 'pwm.c' and this would then lead to multiple defintions. + The solution is to only include the real HAL header, and then implement + stubs for the required functions (ecapInit, ecapGetCAP1, ecapGetCAP2, + ecapGetCAP3). */ +#include "HL_ecap.h" + #include "pwm.h" #include "test_assert_helper.h" @@ -64,6 +72,17 @@ long FSYS_RaisePrivilege(void) { return fsysRaisePrivilegeReturnValue; } +void ecapInit(void){}; + +uint32_t ecapGetCAP1(ecapBASE_t *ecap) { + return ecap->CAP1; +} +uint32_t ecapGetCAP2(ecapBASE_t *ecap) { + return ecap->CAP2; +} +uint32_t ecapGetCAP3(ecapBASE_t *ecap) { + return ecap->CAP3; +} /** wraps the duty cycle function for test * * The output duty cycle is tested against the value computed by the function. diff --git a/tests/unit/app/driver/rtc/test_rtc.c b/tests/unit/app/driver/rtc/test_rtc.c index 89a0e930..29ed206b 100644 --- a/tests/unit/app/driver/rtc/test_rtc.c +++ b/tests/unit/app/driver/rtc/test_rtc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_rtc.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/sbc/test_nxpfs85xx.c b/tests/unit/app/driver/sbc/test_nxpfs85xx.c index 642f870f..d274f67c 100644 --- a/tests/unit/app/driver/sbc/test_nxpfs85xx.c +++ b/tests/unit/app/driver/sbc/test_nxpfs85xx.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_nxpfs85xx.c * @author foxBMS Team * @date 2020-04-06 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix SBC * diff --git a/tests/unit/app/driver/sbc/test_sbc.c b/tests/unit/app/driver/sbc/test_sbc.c index 44a0efd3..6f6e9aec 100644 --- a/tests/unit/app/driver/sbc/test_sbc.c +++ b/tests/unit/app/driver/sbc/test_sbc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sbc.c * @author foxBMS Team * @date 2020-07-15 (date of creation) - * @updated 2020-07-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix SBC * @@ -69,7 +70,7 @@ TEST_FILE("sbc.c") /*========== Definitions and Implementations for Unit Test ==================*/ -FS85xx_STATE_s fs85xx_mcuSupervisor = {}; +FS85_STATE_s fs85xx_mcuSupervisor = {}; /*========== Setup and Teardown =============================================*/ void setUp(void) { diff --git a/tests/unit/app/driver/spi/test_spi.c b/tests/unit/app/driver/spi/test_spi.c index 80dc70b2..0c5f4dc0 100644 --- a/tests/unit/app/driver/spi/test_spi.c +++ b/tests/unit/app/driver/spi/test_spi.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_spi.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-12-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/sps/test_sps.c b/tests/unit/app/driver/sps/test_sps.c index 2e751321..802e0912 100644 --- a/tests/unit/app/driver/sps/test_sps.c +++ b/tests/unit/app/driver/sps/test_sps.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sps.c * @author foxBMS Team * @date 2020-10-28 (date of creation) - * @updated 2021-12-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -196,19 +197,19 @@ void testSPS_RequestContactorStateCorrectAffiliation(void) { void testSPS_RequestGeneralIOStateWrongAffiliation(void) { /* watch out, the channel here has to have an affiliation that is not SPS_AFF_GENERAL_IO */ - TEST_ASSERT_FAIL_ASSERT(SPS_RequestGeneralIOState(0u, SPS_CHANNEL_OFF)); + TEST_ASSERT_FAIL_ASSERT(SPS_RequestGeneralIoState(0u, SPS_CHANNEL_OFF)); } void testSPS_RequestGeneralIOStateWrongIndex(void) { /* a wrong index should also lead here to an assertion */ - TEST_ASSERT_FAIL_ASSERT(SPS_RequestGeneralIOState(42u, SPS_CHANNEL_OFF)); + TEST_ASSERT_FAIL_ASSERT(SPS_RequestGeneralIoState(42u, SPS_CHANNEL_OFF)); } void testSPS_RequestGIOStateCorrectAffiliation(void) { OS_EnterTaskCritical_Ignore(); OS_ExitTaskCritical_Ignore(); /* watch out, the channel here has to have an affiliation that is SPS_AFF_GENERAL_IO */ - TEST_ASSERT_PASS_ASSERT(SPS_RequestGeneralIOState(7u, SPS_CHANNEL_ON)); + TEST_ASSERT_PASS_ASSERT(SPS_RequestGeneralIoState(7u, SPS_CHANNEL_ON)); TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested); } @@ -260,7 +261,7 @@ void testSPS_CtrlStartupProcedure(void) { /* transition through state-machine: SPS_CONFIGURE_CONTROL_REGISTER */ /* check that we transmit the first set of commands */ SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK); - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); /* Since the transaction is successful, we should switch to high-speed */ SPI_SpsInterfaceSwitchToHighSpeed_Expect(&spi_spsInterface); SPS_Ctrl(); @@ -273,7 +274,7 @@ void testSPS_CtrlResetOnFailedFirstTransaction(void) { TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); /* run state and let first transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_NOT_OK); SPI_TransmitReceiveData_IgnoreArg_pSpiInterface(); SPI_TransmitReceiveData_IgnoreArg_pTxBuff(); @@ -292,7 +293,7 @@ void testSPS_CtrlResetOnFailedSecondTransaction(void) { TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); /* run state and let second transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, 0u, STD_OK); SPI_TransmitReceiveData_IgnoreArg_pSpiInterface(); SPI_TransmitReceiveData_IgnoreArg_pTxBuff(); @@ -311,7 +312,7 @@ void testSPS_CtrlResetOnFailedBothTransactions(void) { TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); } @@ -321,7 +322,7 @@ void testSPS_CtrlResetFromStateSPS_CONFIGURE_CONTROL_REGISTER(void) { TEST_SPS_SetSpsState(SPS_CONFIGURE_CONTROL_REGISTER); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -332,7 +333,7 @@ void testSPS_CtrlResetFromStateSPS_TRIGGER_CURRENT_MEASUREMENT(void) { TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -343,7 +344,7 @@ void testSPS_CtrlResetFromStateSPS_READ_EN_IRQ_PIN(void) { TEST_SPS_SetSpsState(SPS_READ_EN_IRQ_PIN); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -354,7 +355,7 @@ void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT1(void) { TEST_SPS_SetSpsState(SPS_READ_MEASURED_CURRENT1); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -365,7 +366,7 @@ void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT2(void) { TEST_SPS_SetSpsState(SPS_READ_MEASURED_CURRENT2); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -376,7 +377,7 @@ void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT3(void) { TEST_SPS_SetSpsState(SPS_READ_MEASURED_CURRENT3); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -387,7 +388,7 @@ void testSPS_CtrlResetFromStateSPS_READ_MEASURED_CURRENT4(void) { TEST_SPS_SetSpsState(SPS_READ_MEASURED_CURRENT4); /* run state and let both transaction "fail" */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_NOT_OK); SPS_Ctrl(); TEST_ASSERT_EQUAL(SPS_START, TEST_SPS_GetSpsState()); @@ -398,7 +399,7 @@ void testSPS_CtrlNormalOperationCycle(void) { TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); /* let transactions always succeed */ - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK); /* run state chain */ @@ -451,7 +452,7 @@ void testContactorSwitchOnAndOff(void) { /* cycle over one state that handles channels */ TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK); - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPS_Ctrl(); /* check that channels have been marked as on */ @@ -484,7 +485,7 @@ void testContactorSwitchOnAndOff(void) { /* cycle over one state that handles channels */ TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); SPI_TransmitReceiveData_IgnoreAndReturn(STD_OK); - MCU_delay_us_Ignore(); + MCU_Delay_us_Ignore(); SPS_Ctrl(); /* check that channels have been marked as off */ diff --git a/tests/unit/app/driver/ts/api/test_tsi_limits.c b/tests/unit/app/driver/ts/api/test_tsi_limits.c index 57563528..f7a2f94d 100644 --- a/tests/unit/app/driver/ts/api/test_tsi_limits.c +++ b/tests/unit/app/driver/ts/api/test_tsi_limits.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_tsi_limits.c * @author foxBMS Team * @date 2021-01-15 (date of creation) - * @updated 2021-01-15 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TSI * diff --git a/tests/unit/app/driver/ts/epcos/b57251v5103j060/lookup-table/test_epcos_b57251v5103j060_lookup-table.c b/tests/unit/app/driver/ts/epcos/b57251v5103j060/lookup-table/test_epcos_b57251v5103j060_lookup-table.c index ef866dc4..2b6a4cee 100644 --- a/tests/unit/app/driver/ts/epcos/b57251v5103j060/lookup-table/test_epcos_b57251v5103j060_lookup-table.c +++ b/tests/unit/app/driver/ts/epcos/b57251v5103j060/lookup-table/test_epcos_b57251v5103j060_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_epcos_b57251v5103j060_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/epcos/b57251v5103j060/polynomial/test_epcos_b57251v5103j060_polynomial.c b/tests/unit/app/driver/ts/epcos/b57251v5103j060/polynomial/test_epcos_b57251v5103j060_polynomial.c index e6b91526..f7c41e53 100644 --- a/tests/unit/app/driver/ts/epcos/b57251v5103j060/polynomial/test_epcos_b57251v5103j060_polynomial.c +++ b/tests/unit/app/driver/ts/epcos/b57251v5103j060/polynomial/test_epcos_b57251v5103j060_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_epcos_b57251v5103j060_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/epcos/b57251v5103j060/test_epcos_b57251v5103j060.c b/tests/unit/app/driver/ts/epcos/b57251v5103j060/test_epcos_b57251v5103j060.c index 5e8aa065..f41de8ba 100644 --- a/tests/unit/app/driver/ts/epcos/b57251v5103j060/test_epcos_b57251v5103j060.c +++ b/tests/unit/app/driver/ts/epcos/b57251v5103j060/test_epcos_b57251v5103j060.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_epcos_b57251v5103j060.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/epcos/b57861s0103f045/lookup-table/test_epcos_b57861s0103f045_lookup-table.c b/tests/unit/app/driver/ts/epcos/b57861s0103f045/lookup-table/test_epcos_b57861s0103f045_lookup-table.c index d9ce73bd..557895c3 100644 --- a/tests/unit/app/driver/ts/epcos/b57861s0103f045/lookup-table/test_epcos_b57861s0103f045_lookup-table.c +++ b/tests/unit/app/driver/ts/epcos/b57861s0103f045/lookup-table/test_epcos_b57861s0103f045_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_epcos_b57861s0103f045_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/epcos/b57861s0103f045/polynomial/test_epcos_b57861s0103f045_polynomial.c b/tests/unit/app/driver/ts/epcos/b57861s0103f045/polynomial/test_epcos_b57861s0103f045_polynomial.c index 70ee5cef..0f0ba557 100644 --- a/tests/unit/app/driver/ts/epcos/b57861s0103f045/polynomial/test_epcos_b57861s0103f045_polynomial.c +++ b/tests/unit/app/driver/ts/epcos/b57861s0103f045/polynomial/test_epcos_b57861s0103f045_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_epcos_b57861s0103f045_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/epcos/b57861s0103f045/test_epcos_b57861s0103f045.c b/tests/unit/app/driver/ts/epcos/b57861s0103f045/test_epcos_b57861s0103f045.c index bd71261e..225ba838 100644 --- a/tests/unit/app/driver/ts/epcos/b57861s0103f045/test_epcos_b57861s0103f045.c +++ b/tests/unit/app/driver/ts/epcos/b57861s0103f045/test_epcos_b57861s0103f045.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_epcos_b57861s0103f045.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/fake/none/lookup-table/test_fake_none_lookup-table.c b/tests/unit/app/driver/ts/fake/none/lookup-table/test_fake_none_lookup-table.c index c650fe2f..070d98f7 100644 --- a/tests/unit/app/driver/ts/fake/none/lookup-table/test_fake_none_lookup-table.c +++ b/tests/unit/app/driver/ts/fake/none/lookup-table/test_fake_none_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fake_none_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/fake/none/polynomial/test_fake_none_polynomial.c b/tests/unit/app/driver/ts/fake/none/polynomial/test_fake_none_polynomial.c index 15e0c9b7..b98a90a9 100644 --- a/tests/unit/app/driver/ts/fake/none/polynomial/test_fake_none_polynomial.c +++ b/tests/unit/app/driver/ts/fake/none/polynomial/test_fake_none_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fake_none_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2020-08-25 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/fake/none/test_fake_none.c b/tests/unit/app/driver/ts/fake/none/test_fake_none.c index ffd608a3..6f753cdb 100644 --- a/tests/unit/app/driver/ts/fake/none/test_fake_none.c +++ b/tests/unit/app/driver/ts/fake/none/test_fake_none.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fake_none.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/test_beta.c b/tests/unit/app/driver/ts/test_beta.c index 239d43b5..7b91cd87 100644 --- a/tests/unit/app/driver/ts/test_beta.c +++ b/tests/unit/app/driver/ts/test_beta.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_beta.c * @author foxBMS Team * @date 2020-03-13 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix BETA * diff --git a/tests/unit/app/driver/ts/vishay/ntcalug01a103g/lookup-table/test_vishay_ntcalug01a103g_lookup-table.c b/tests/unit/app/driver/ts/vishay/ntcalug01a103g/lookup-table/test_vishay_ntcalug01a103g_lookup-table.c index c04a7055..c1b2c871 100644 --- a/tests/unit/app/driver/ts/vishay/ntcalug01a103g/lookup-table/test_vishay_ntcalug01a103g_lookup-table.c +++ b/tests/unit/app/driver/ts/vishay/ntcalug01a103g/lookup-table/test_vishay_ntcalug01a103g_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_vishay_ntcalug01a103g_lookup-table.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/vishay/ntcalug01a103g/polynomial/test_vishay_ntcalug01a103g_polynomial.c b/tests/unit/app/driver/ts/vishay/ntcalug01a103g/polynomial/test_vishay_ntcalug01a103g_polynomial.c index a107434d..dfd3e3c5 100644 --- a/tests/unit/app/driver/ts/vishay/ntcalug01a103g/polynomial/test_vishay_ntcalug01a103g_polynomial.c +++ b/tests/unit/app/driver/ts/vishay/ntcalug01a103g/polynomial/test_vishay_ntcalug01a103g_polynomial.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_vishay_ntcalug01a103g_polynomial.c * @author foxBMS Team * @date 2020-08-25 (date of creation) - * @updated 2021-03-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/vishay/ntcalug01a103g/test_vishay_ntcalug01a103g.c b/tests/unit/app/driver/ts/vishay/ntcalug01a103g/test_vishay_ntcalug01a103g.c index 691618fb..96de4dd4 100644 --- a/tests/unit/app/driver/ts/vishay/ntcalug01a103g/test_vishay_ntcalug01a103g.c +++ b/tests/unit/app/driver/ts/vishay/ntcalug01a103g/test_vishay_ntcalug01a103g.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_vishay_ntcalug01a103g.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/test_vishay_ntcle317e4103sba_lookup-table.c b/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/test_vishay_ntcle317e4103sba_lookup-table.c index b1dae0f2..2237685b 100644 --- a/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/test_vishay_ntcle317e4103sba_lookup-table.c +++ b/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/lookup-table/test_vishay_ntcle317e4103sba_lookup-table.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_vishay_ntcle317e4103sba_lookup-table.c * @author foxBMS Team * @date 2021-11-02 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/test_vishay_ntcle317e4103sba.c b/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/test_vishay_ntcle317e4103sba.c index 123e5f50..9debb7da 100644 --- a/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/test_vishay_ntcle317e4103sba.c +++ b/tests/unit/app/driver/ts/vishay/ntcle317e4103sba/test_vishay_ntcle317e4103sba.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_vishay_ntcle317e4103sba.c * @author foxBMS Team * @date 2021-11-02 (date of creation) - * @updated 2021-11-08 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/config/test_database_cfg.c b/tests/unit/app/engine/config/test_database_cfg.c index 5a234296..9f51d052 100644 --- a/tests/unit/app/engine/config/test_database_cfg.c +++ b/tests/unit/app/engine/config/test_database_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_database_cfg.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2020-04-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/config/test_diag_cfg.c b/tests/unit/app/engine/config/test_diag_cfg.c index aab1bc74..9e89ae9a 100644 --- a/tests/unit/app/engine/config/test_diag_cfg.c +++ b/tests/unit/app/engine/config/test_diag_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -69,10 +70,10 @@ void tearDown(void) { /*========== Test Cases =====================================================*/ void testDIAG_UpdateFlagsInDatabase(void) { - DATA_Write_4_DataBlocks_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR, STD_OK); - DATA_Write_4_DataBlocks_IgnoreArg_pDataFromSender0(); - DATA_Write_4_DataBlocks_IgnoreArg_pDataFromSender1(); - DATA_Write_4_DataBlocks_IgnoreArg_pDataFromSender2(); - DATA_Write_4_DataBlocks_IgnoreArg_pDataFromSender3(); + DATA_Write4DataBlocks_ExpectAndReturn(NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR, STD_OK); + DATA_Write4DataBlocks_IgnoreArg_pDataFromSender0(); + DATA_Write4DataBlocks_IgnoreArg_pDataFromSender1(); + DATA_Write4DataBlocks_IgnoreArg_pDataFromSender2(); + DATA_Write4DataBlocks_IgnoreArg_pDataFromSender3(); DIAG_UpdateFlags(); } diff --git a/tests/unit/app/engine/config/test_sys_cfg.c b/tests/unit/app/engine/config/test_sys_cfg.c index 2d864136..62da0736 100644 --- a/tests/unit/app/engine/config/test_sys_cfg.c +++ b/tests/unit/app/engine/config/test_sys_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sys_cfg.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2020-04-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -69,5 +70,6 @@ void tearDown(void) { /*========== Test Cases =====================================================*/ void testSysSendBootMessageExists(void) { CAN_TransmitBootMessage_IgnoreAndReturn(STD_OK); + CAN_TransmitDieId_IgnoreAndReturn(STD_OK); SYS_SendBootMessage(); } diff --git a/tests/unit/app/engine/config/test_sys_mon_cfg.c b/tests/unit/app/engine/config/test_sys_mon_cfg.c index 5bd3fc03..6605922d 100644 --- a/tests/unit/app/engine/config/test_sys_mon_cfg.c +++ b/tests/unit/app/engine/config/test_sys_mon_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sys_mon_cfg.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2020-04-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/database/test_database.c b/tests/unit/app/engine/database/test_database.c index 9ceea05d..bd90982c 100644 --- a/tests/unit/app/engine/database/test_database.c +++ b/tests/unit/app/engine/database/test_database.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_database.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -67,9 +68,9 @@ /*========== Definitions and Implementations for Unit Test ==================*/ /** - * struct for message injection in database queue in #testDATA_ExecuteDataBIST() + * struct for message injection in database queue in #testDATA_ExecuteDataBist() */ -typedef struct DATA_QUEUE_BIST_INJECTED_MESSAGE { +typedef struct { DATA_BLOCK_ACCESS_TYPE_e accesstype; /*!< read or write access type */ DATA_BLOCK_DUMMY_FOR_SELF_TEST_s *pDatabaseEntry[1u]; /*!< reference to table */ } DATA_QUEUE_BIST_INJECTED_MESSAGE_s; @@ -89,7 +90,7 @@ void tearDown(void) { void testDummy(void) { } -/** callback for #testDATA_ExecuteDataBIST(); this not work for other instances */ +/** callback for #testDATA_ExecuteDataBist(); this not work for other instances */ OS_STD_RETURN_e DATA_mpuInjectValuesForExecuteBISTTestCallback( OS_QUEUE xQueue, const void *const pvItemToQueue, @@ -105,13 +106,13 @@ OS_STD_RETURN_e DATA_mpuInjectValuesForExecuteBISTTestCallback( return OS_SUCCESS; } -void testDATA_ExecuteDataBIST(void) { +void testDATA_ExecuteDataBist(void) { DATA_BLOCK_DUMMY_FOR_SELF_TEST_s dummyTable = {.header.uniqueId = DATA_BLOCK_ID_DUMMY_FOR_SELF_TEST}; const uint8_t testValue = DATA_DUMMY_VALUE_UINT8_T_ALTERNATING_BIT_PATTERN; dummyTable.member1 = UINT8_MAX; dummyTable.member2 = testValue; OS_SendToBackOfQueue_Stub(&DATA_mpuInjectValuesForExecuteBISTTestCallback); - TEST_ASSERT_PASS_ASSERT(DATA_ExecuteDataBIST()); + TEST_ASSERT_PASS_ASSERT(DATA_ExecuteDataBist()); } /*========== Test Cases =====================================================*/ diff --git a/tests/unit/app/engine/database/test_database_helper.c b/tests/unit/app/engine/database/test_database_helper.c index 94316cc8..ba2b9d37 100644 --- a/tests/unit/app/engine/database/test_database_helper.c +++ b/tests/unit/app/engine/database/test_database_helper.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_database_helper.c * @author foxBMS Team * @date 2021-05-05 (date of creation) - * @updated 2021-05-05 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -243,43 +244,43 @@ void testDATA_EntryUpdatedPeriodicallyWithinInterval(void) { * #DATA_GetStringNumberFromVoltageIndex */ void testDATA_GetStringNumberFromVoltageIndex(void) { /* Last cell in string 0 */ - uint16_t voltageIndex = (BS_NR_OF_CELLS_PER_MODULE * BS_NR_OF_MODULES) - 1u; + uint16_t voltageIndex = (BS_NR_OF_CELL_BLOCKS_PER_MODULE * BS_NR_OF_MODULES_PER_STRING) - 1u; TEST_ASSERT_EQUAL(DATA_GetStringNumberFromVoltageIndex(voltageIndex), 0u); /* Last cell in last string */ - voltageIndex = (BS_NR_OF_CELLS_PER_MODULE * BS_NR_OF_MODULES * BS_NR_OF_STRINGS) - 1u; + voltageIndex = (BS_NR_OF_CELL_BLOCKS_PER_MODULE * BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_STRINGS) - 1u; TEST_ASSERT_EQUAL(DATA_GetStringNumberFromVoltageIndex(voltageIndex), BS_NR_OF_STRINGS - 1u); /* Test is function passes if index 0 is passed */ TEST_ASSERT_PASS_ASSERT(DATA_GetStringNumberFromVoltageIndex(0u)); /* Test is function asserts if invalid index is passed */ - TEST_ASSERT_FAIL_ASSERT( - DATA_GetStringNumberFromVoltageIndex(BS_NR_OF_MODULES * BS_NR_OF_CELLS_PER_MODULE * BS_NR_OF_STRINGS)); + TEST_ASSERT_FAIL_ASSERT(DATA_GetStringNumberFromVoltageIndex( + BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_CELL_BLOCKS_PER_MODULE * BS_NR_OF_STRINGS)); TEST_ASSERT_FAIL_ASSERT(DATA_GetStringNumberFromVoltageIndex(UINT16_MAX)); } /** This function tests various inputs for database helper function * #DATA_GetModuleNumberFromVoltageIndex */ void testDATA_GetModuleNumberFromVoltageIndex(void) { - uint16_t voltageIndex = (BS_NR_OF_CELLS_PER_MODULE * BS_NR_OF_MODULES) - 1u; - TEST_ASSERT_EQUAL(DATA_GetModuleNumberFromVoltageIndex(voltageIndex), BS_NR_OF_MODULES - 1u); + uint16_t voltageIndex = (BS_NR_OF_CELL_BLOCKS_PER_MODULE * BS_NR_OF_MODULES_PER_STRING) - 1u; + TEST_ASSERT_EQUAL(DATA_GetModuleNumberFromVoltageIndex(voltageIndex), BS_NR_OF_MODULES_PER_STRING - 1u); /* Test is function passes if index 0 is passed */ TEST_ASSERT_PASS_ASSERT(DATA_GetModuleNumberFromVoltageIndex(0u)); /* Test is function asserts if invalid index is passed */ - TEST_ASSERT_FAIL_ASSERT( - DATA_GetModuleNumberFromVoltageIndex(BS_NR_OF_MODULES * BS_NR_OF_CELLS_PER_MODULE * BS_NR_OF_STRINGS)); + TEST_ASSERT_FAIL_ASSERT(DATA_GetModuleNumberFromVoltageIndex( + BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_CELL_BLOCKS_PER_MODULE * BS_NR_OF_STRINGS)); TEST_ASSERT_FAIL_ASSERT(DATA_GetModuleNumberFromVoltageIndex(UINT16_MAX)); } /** This function tests various inputs for database helper function * #testDATA_GetCellNumberFromVoltageIndex */ void testDATA_GetCellNumberFromVoltageIndex(void) { - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { - for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++) { - uint16_t voltageIndex = (m * BS_NR_OF_CELLS_PER_MODULE) + c; + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { + for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) { + uint16_t voltageIndex = (m * BS_NR_OF_CELL_BLOCKS_PER_MODULE) + c; TEST_ASSERT_EQUAL(DATA_GetCellNumberFromVoltageIndex(voltageIndex), c); } } @@ -288,8 +289,8 @@ void testDATA_GetCellNumberFromVoltageIndex(void) { TEST_ASSERT_PASS_ASSERT(DATA_GetCellNumberFromVoltageIndex(0u)); /* Test is function asserts if invalid index is passed */ - TEST_ASSERT_FAIL_ASSERT( - DATA_GetCellNumberFromVoltageIndex(BS_NR_OF_MODULES * BS_NR_OF_CELLS_PER_MODULE * BS_NR_OF_STRINGS)); + TEST_ASSERT_FAIL_ASSERT(DATA_GetCellNumberFromVoltageIndex( + BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_CELL_BLOCKS_PER_MODULE * BS_NR_OF_STRINGS)); TEST_ASSERT_FAIL_ASSERT(DATA_GetCellNumberFromVoltageIndex(UINT16_MAX)); } @@ -297,11 +298,11 @@ void testDATA_GetCellNumberFromVoltageIndex(void) { * #DATA_GetStringNumberFromTemperatureIndex */ void testDATA_GetStringNumberFromTemperatureIndex(void) { /* last sensor in string 0 */ - uint16_t sensorIndex = (BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_MODULES) - 1u; + uint16_t sensorIndex = (BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_MODULES_PER_STRING) - 1u; TEST_ASSERT_EQUAL(DATA_GetStringNumberFromTemperatureIndex(sensorIndex), 0u); /* last sensor in last string */ - sensorIndex = (BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_MODULES * BS_NR_OF_STRINGS) - 1u; + sensorIndex = (BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_STRINGS) - 1u; TEST_ASSERT_EQUAL(DATA_GetStringNumberFromTemperatureIndex(sensorIndex), BS_NR_OF_STRINGS - 1u); /* Test is function passes if index 0 is passed */ @@ -309,29 +310,29 @@ void testDATA_GetStringNumberFromTemperatureIndex(void) { /* Test is function asserts if invalid index is passed */ TEST_ASSERT_FAIL_ASSERT(DATA_GetStringNumberFromTemperatureIndex( - BS_NR_OF_MODULES * BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_STRINGS)); + BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_STRINGS)); TEST_ASSERT_FAIL_ASSERT(DATA_GetStringNumberFromTemperatureIndex(UINT16_MAX)); } /** This function tests various inputs for database helper function * #DATA_GetModuleNumberFromTemperatureIndex */ void testDATA_GetModuleNumberFromTemperatureIndex(void) { - uint16_t sensorIndex = (BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_MODULES) - 1u; - TEST_ASSERT_EQUAL(DATA_GetModuleNumberFromTemperatureIndex(sensorIndex), BS_NR_OF_MODULES - 1u); + uint16_t sensorIndex = (BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_MODULES_PER_STRING) - 1u; + TEST_ASSERT_EQUAL(DATA_GetModuleNumberFromTemperatureIndex(sensorIndex), BS_NR_OF_MODULES_PER_STRING - 1u); /* Test is function passes if index 0 is passed */ TEST_ASSERT_PASS_ASSERT(DATA_GetModuleNumberFromTemperatureIndex(0u)); /* Test is function asserts if invalid index is passed */ TEST_ASSERT_FAIL_ASSERT(DATA_GetModuleNumberFromTemperatureIndex( - BS_NR_OF_MODULES * BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_STRINGS)); + BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_STRINGS)); TEST_ASSERT_FAIL_ASSERT(DATA_GetModuleNumberFromTemperatureIndex(UINT16_MAX)); } /** This function tests various inputs for database helper function * #DATA_GetSensorNumberFromTemperatureIndex */ void testDATA_GetSensorNumberFromTemperatureIndex(void) { - for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++) { + for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) { for (uint8_t sensor = 0u; sensor < BS_NR_OF_TEMP_SENSORS_PER_MODULE; sensor++) { uint16_t sensorIndex = (m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + sensor; TEST_ASSERT_EQUAL(DATA_GetSensorNumberFromTemperatureIndex(sensorIndex), sensor); @@ -343,6 +344,6 @@ void testDATA_GetSensorNumberFromTemperatureIndex(void) { /* Test is function asserts if invalid index is passed */ TEST_ASSERT_FAIL_ASSERT(DATA_GetSensorNumberFromTemperatureIndex( - BS_NR_OF_MODULES * BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_STRINGS)); + BS_NR_OF_MODULES_PER_STRING * BS_NR_OF_TEMP_SENSORS_PER_MODULE * BS_NR_OF_STRINGS)); TEST_ASSERT_FAIL_ASSERT(DATA_GetSensorNumberFromTemperatureIndex(UINT16_MAX)); } diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c index 2fa5dfaa..3a35bffb 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_afe.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -96,3 +97,14 @@ void testDIAG_ErrorAfeInvalidInput(void) { TEST_ASSERT_FAIL_ASSERT( DIAG_ErrorAfe(DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, DIAG_EVENT_OK, &diag_kpkDatabaseShim, BS_NR_OF_STRINGS)); } + +/** tests invalid input values */ +void testDIAG_ErrorAfeDriverInvalidInput(void) { + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfeDriver(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfeDriver(DIAG_ID_AFE_SPI, 42, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfeDriver(DIAG_ID_AFE_SPI, DIAG_EVENT_OK, NULL_PTR, 0u)); + TEST_ASSERT_FAIL_ASSERT( + DIAG_ErrorAfeDriver(DIAG_ID_AFE_SPI, DIAG_EVENT_OK, &diag_kpkDatabaseShim, BS_NR_OF_STRINGS)); + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfeDriver( + DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, DIAG_EVENT_OK, &diag_kpkDatabaseShim, BS_NR_OF_STRINGS)); +} diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_can.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_can.c index 42ec53ce..f65ed54d 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_can.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_can.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_can.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_contactor.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_contactor.c index 9908c749..678fff40 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_contactor.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_contactor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_contactor.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_current-sensor.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_current-sensor.c index 3a6f4f71..1ff272fd 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_current-sensor.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_current-sensor.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_current-sensor.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_current.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_current.c index f3ae367c..23ed4a15 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_current.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_current.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_current.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_deep-discharge.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_deep-discharge.c index 4d81e032..947598cb 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_deep-discharge.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_deep-discharge.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_deep-discharge.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_dummy.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_dummy.c index ba783bcc..53556d61 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_dummy.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_dummy.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_dummy.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_ltc.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_fram.c similarity index 61% rename from tests/unit/app/engine/diag/cbs/test_diag_cbs_ltc.c rename to tests/unit/app/engine/diag/cbs/test_diag_cbs_fram.c index 2f2a7fe1..c9a3610c 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_ltc.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_fram.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -40,14 +40,15 @@ */ /** - * @file test_diag_cbs_ltc.c + * @file test_diag_cbs_fram.c * @author foxBMS Team - * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @date 2022-02-24 (date of creation) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the LTC diag handler implementation. + * @brief Test of the FRAM diag handler implementation. * */ @@ -58,7 +59,7 @@ #include "diag_cbs.h" #include "test_assert_helper.h" -TEST_FILE("diag_cbs_ltc.c") +TEST_FILE("diag_cbs_fram.c") /*========== Definitions and Implementations for Unit Test ==================*/ /** local copy of the #DATA_BLOCK_ERRORSTATE_s table */ @@ -82,16 +83,41 @@ const DIAG_DATABASE_SHIM_s diag_kpkDatabaseShim = { /*========== Setup and Teardown =============================================*/ void setUp(void) { + diag_kpkDatabaseShim.pTableError->framReadCrcError = 0; } void tearDown(void) { } /*========== Test Cases =====================================================*/ -/** tests invalid input values */ -void testDIAG_ErrorLtcInvalidInput(void) { - TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorLtc(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); - TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorLtc(DIAG_ID_LTC_SPI, 42, &diag_kpkDatabaseShim, 0u)); - TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorLtc(DIAG_ID_LTC_SPI, DIAG_EVENT_OK, NULL_PTR, 0u)); - TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorLtc(DIAG_ID_LTC_SPI, DIAG_EVENT_OK, &diag_kpkDatabaseShim, BS_NR_OF_STRINGS)); +void testDIAGFramError(void) { + /* reset event sets the FRAM in ok mode */ + DIAG_FramError(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_RESET, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(0, diag_kpkDatabaseShim.pTableError->framReadCrcError); + /* ok event must not change the FRAM state */ + DIAG_FramError(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(0, diag_kpkDatabaseShim.pTableError->framReadCrcError); + + /* not ok event sets the FRAM crc error back in not ok mode */ + DIAG_FramError(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_NOT_OK, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(1, diag_kpkDatabaseShim.pTableError->framReadCrcError); + + /* reset event sets the FRAM error back in ok mode */ + DIAG_FramError(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_RESET, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(0, diag_kpkDatabaseShim.pTableError->framReadCrcError); +} + +/** test against invalid input */ +void testDIAG_FramErrorInvalidInput(void) { + TEST_ASSERT_FAIL_ASSERT(DIAG_FramError(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_FramError(DIAG_ID_FRAM_READ_CRC_ERROR, 42, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_FramError(DIAG_ID_FRAM_READ_CRC_ERROR, DIAG_EVENT_OK, NULL_PTR, 0u)); +} + +void testDIAG_FramErrorDoNothingOnWrongId(void) { + /* Use a wrong ID to make sure, that this does not alter the FRAM entry */ + uint8_t testValue = 42; + diag_kpkDatabaseShim.pTableError->framReadCrcError = testValue; + DIAG_FramError(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_EVENT_RESET, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(testValue, diag_kpkDatabaseShim.pTableError->framReadCrcError); } diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_i2c.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_i2c.c index 8677a212..a8b0f9b7 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_i2c.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_i2c.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_i2c.c * @author foxBMS Team * @date 2021-09-29 (date of creation) - * @updated 2021-09-29 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_insulation.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_insulation.c index 5b16e374..efe687d1 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_insulation.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_insulation.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_insulation.c * @author foxBMS Team * @date 2021-02-22 (date of creation) - * @updated 2021-02-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -82,7 +83,7 @@ const DIAG_DATABASE_SHIM_s diag_kpkDatabaseShim = { /*========== Setup and Teardown =============================================*/ void setUp(void) { - diag_kpkDatabaseShim.pTableError->insulationError = 0; + diag_kpkDatabaseShim.pTableError->criticalLowInsulationResistance = false; } void tearDown(void) { @@ -95,6 +96,6 @@ void testDiagInsulation(void) { /** tests invalid input values */ void testDIAG_ErrorInsulationInvalidInput(void) { TEST_ASSERT_FAIL_ASSERT(DIAG_Insulation(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); - TEST_ASSERT_FAIL_ASSERT(DIAG_Insulation(DIAG_ID_INSULATION_ERROR, 42, &diag_kpkDatabaseShim, 0u)); - TEST_ASSERT_FAIL_ASSERT(DIAG_Insulation(DIAG_ID_INSULATION_ERROR, DIAG_EVENT_OK, NULL_PTR, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_Insulation(DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, 42, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_Insulation(DIAG_ID_LOW_INSULATION_RESISTANCE_ERROR, DIAG_EVENT_OK, NULL_PTR, 0u)); } diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_interlock.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_interlock.c index 3b93a1b6..67cfa851 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_interlock.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_interlock.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_interlock.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_plausibility.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_plausibility.c index caea5f74..6082ecb0 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_plausibility.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_plausibility.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_plausibility.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_power-measurement.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_power-measurement.c index 37923a5a..ce2c52b9 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_power-measurement.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_power-measurement.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_power-measurement.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_sbc.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_sbc.c index a57e6917..8d4489e3 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_sbc.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_sbc.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_sbc.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_sys-mon.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_sys-mon.c index 6904a3eb..dfca9cbd 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_sys-mon.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_sys-mon.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_sys-mon.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -54,8 +55,7 @@ /*========== Includes =======================================================*/ #include "unity.h" #include "Mockdiag_cfg.h" - -#include "sys_mon_cfg.h" +#include "Mocksys_mon_cfg.h" #include "diag_cbs.h" #include "test_assert_helper.h" diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_temperature.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_temperature.c index 1339d4f0..3be7ae23 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_temperature.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_temperature.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_temperature.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_voltage.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_voltage.c index 59c1737d..29e46ed8 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_voltage.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_voltage.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag_cbs_voltage.c * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-02-17 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/diag/test_diag.c b/tests/unit/app/engine/diag/test_diag.c index e6105838..00750ed5 100644 --- a/tests/unit/app/engine/diag/test_diag.c +++ b/tests/unit/app/engine/diag/test_diag.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_diag.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2020-04-02 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/hwinfo/test_masterinfo.c b/tests/unit/app/engine/hwinfo/test_masterinfo.c index 9569be7e..4c4538dc 100644 --- a/tests/unit/app/engine/hwinfo/test_masterinfo.c +++ b/tests/unit/app/engine/hwinfo/test_masterinfo.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_masterinfo.c * @author foxBMS Team * @date 2020-07-09 (date of creation) - * @updated 2020-07-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/sys/test_sys.c b/tests/unit/app/engine/sys/test_sys.c index 33be4b5e..cd364ad9 100644 --- a/tests/unit/app/engine/sys/test_sys.c +++ b/tests/unit/app/engine/sys/test_sys.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sys.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2021-05-19 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/engine/sys_mon/test_sys_mon.c b/tests/unit/app/engine/sys_mon/test_sys_mon.c index 0cc75154..86d02cb0 100644 --- a/tests/unit/app/engine/sys_mon/test_sys_mon.c +++ b/tests/unit/app/engine/sys_mon/test_sys_mon.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_sys_mon.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2020-05-28 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -54,6 +55,8 @@ /*========== Includes =======================================================*/ #include "unity.h" #include "Mockdiag.h" +#include "Mockfram.h" +#include "Mockfram_cfg.h" #include "Mockos.h" #include "Mocksys_mon_cfg.h" @@ -64,6 +67,7 @@ /*========== Definitions and Implementations for Unit Test ==================*/ #define DUMMY_TASK_ID_0 0 #define DUMMY_TASK_ID_1 1 +#define DUMMY_TASK_ID_2 2 #define DUMMY_CYCLETIME 10 #define DUMMY_MAX_JITTER 1 @@ -75,7 +79,11 @@ void TEST_SYSM_DummyCallback_1(SYSM_TASK_ID_e taskId) { TEST_ASSERT_EQUAL(DUMMY_TASK_ID_1, taskId); } -SYSM_MONITORING_CFG_s sysm_ch_cfg[2] = { +void TEST_SYSM_DummyCallback_2(SYSM_TASK_ID_e taskId) { + TEST_ASSERT_EQUAL(DUMMY_TASK_ID_2, taskId); +} + +SYSM_MONITORING_CFG_s sysm_ch_cfg[3] = { {DUMMY_TASK_ID_0, SYSM_ENABLED, DUMMY_CYCLETIME, @@ -90,14 +98,42 @@ SYSM_MONITORING_CFG_s sysm_ch_cfg[2] = { SYSM_RECORDING_ENABLED, SYSM_HANDLING_SWITCHOFFCONTACTOR, TEST_SYSM_DummyCallback_1}, + {DUMMY_TASK_ID_2, + SYSM_ENABLED, + DUMMY_CYCLETIME, + DUMMY_MAX_JITTER, + SYSM_RECORDING_DISABLED, + SYSM_HANDLING_SWITCHOFFCONTACTOR, + TEST_SYSM_DummyCallback_2}, }; +/** placeholder variable for the FRAM entry of sys mon */ +FRAM_SYS_MON_RECORD_s fram_sys_mon_record = {0}; + /*========== Setup and Teardown =============================================*/ void setUp(void) { SYSM_NOTIFICATION_s *notifications = TEST_SYSM_GetNotifications(); notifications[DUMMY_TASK_ID_0].timestampEnter = 0; notifications[DUMMY_TASK_ID_0].timestampExit = 0; notifications[DUMMY_TASK_ID_0].duration = 0; + notifications[DUMMY_TASK_ID_1].timestampEnter = 0; + notifications[DUMMY_TASK_ID_1].timestampExit = 0; + notifications[DUMMY_TASK_ID_1].duration = 0; + notifications[DUMMY_TASK_ID_2].timestampEnter = 0; + notifications[DUMMY_TASK_ID_2].timestampExit = 0; + notifications[DUMMY_TASK_ID_2].duration = 0; + + fram_sys_mon_record.anyTimingIssueOccurred = false; + fram_sys_mon_record.taskEngineViolatingDuration = 0u; + fram_sys_mon_record.taskEngineEnterTimestamp = 0u; + fram_sys_mon_record.task1msViolatingDuration = 0u; + fram_sys_mon_record.task1msEnterTimestamp = 0u; + fram_sys_mon_record.task10msViolatingDuration = 0u; + fram_sys_mon_record.task10msEnterTimestamp = 0u; + fram_sys_mon_record.task100msViolatingDuration = 0u; + fram_sys_mon_record.task100msEnterTimestamp = 0u; + fram_sys_mon_record.task100msAlgorithmViolatingDuration = 0u; + fram_sys_mon_record.task100msAlgorithmEnterTimestamp = 0u; } void tearDown(void) { @@ -127,6 +163,29 @@ void testSYSM_CheckNotificationsSYSMDisabled(void) { } void testSYSM_CheckNotificationsProvokeDurationViolation(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + + /* provoke the violation of the task duration */ + OS_GetTickCount_ExpectAndReturn(0u); + SYSM_CheckNotifications(); + + SYSM_NOTIFICATION_s *notifications = TEST_SYSM_GetNotifications(); + notifications[DUMMY_TASK_ID_0].timestampEnter = 0; + notifications[DUMMY_TASK_ID_0].timestampExit = 100; + notifications[DUMMY_TASK_ID_0].duration = 100; + + OS_GetTickCount_ExpectAndReturn(100u); + DIAG_Handler_ExpectAndReturn( + DIAG_ID_SYSTEMMONITORING, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, DUMMY_TASK_ID_0, DIAG_HANDLER_RETURN_OK); + SYSM_CheckNotifications(); +} + +/** same test as #testSYSM_CheckNotificationsProvokeDurationViolation() but with recording enabled */ +void testSYSM_CheckNotificationsProvokeDurationViolationWithRecording(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + /* provoke the violation of the task duration */ OS_GetTickCount_ExpectAndReturn(0u); SYSM_CheckNotifications(); @@ -140,11 +199,16 @@ void testSYSM_CheckNotificationsProvokeDurationViolation(void) { DIAG_Handler_ExpectAndReturn( DIAG_ID_SYSTEMMONITORING, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, DUMMY_TASK_ID_0, DIAG_HANDLER_RETURN_OK); SYSM_CheckNotifications(); + + /* check if violation has been recorded */ + FRAM_WriteData_ExpectAndReturn(FRAM_BLOCK_ID_SYS_MON_RECORD, STD_OK); + SYSM_UpdateFramData(); + TEST_ASSERT_EQUAL(true, fram_sys_mon_record.anyTimingIssueOccurred); } void testSYSM_NotifyInvalidTaskID(void) { /* give an invalid Task ID to Notify */ - TEST_ASSERT_PASS_ASSERT(SYSM_Notify(SYSM_TASK_ID_MAX + 1u, SYSM_NOTIFY_ENTER, 424242)); + TEST_ASSERT_FAIL_ASSERT(SYSM_Notify(SYSM_TASK_ID_MAX + 1u, SYSM_NOTIFY_ENTER, 424242)); SYSM_NOTIFICATION_s *notifications = TEST_SYSM_GetNotifications(); TEST_ASSERT_NOT_EQUAL(424242, notifications[SYSM_TASK_ID_MAX + 1u].timestampEnter); } @@ -192,3 +256,81 @@ void testSYSM_NotifyHitAssertWithIllegalNotifyType(void) { TEST_ASSERT_NOT_EQUAL(UINT32_MAX, notifications[DUMMY_TASK_ID_0].timestampEnter); TEST_ASSERT_NOT_EQUAL(UINT32_MAX, notifications[DUMMY_TASK_ID_0].timestampExit); } + +/** test the edge cases of the function that can return recorded violations */ +void testSYSM_GetRecordedTimingViolations(void) { + OS_EnterTaskCritical_Ignore(); + OS_ExitTaskCritical_Ignore(); + + /* default state is no violation, therefore no flag should be set */ + SYSM_TIMING_VIOLATION_RESPONSE_s violationResponse = {0}; + SYSM_GetRecordedTimingViolations(&violationResponse); + TEST_ASSERT_FALSE(violationResponse.recordedViolationEngine); + TEST_ASSERT_FALSE(violationResponse.recordedViolation1ms); + TEST_ASSERT_FALSE(violationResponse.recordedViolation10ms); + TEST_ASSERT_FALSE(violationResponse.recordedViolation100ms); + TEST_ASSERT_FALSE(violationResponse.recordedViolation100msAlgo); + + /* when the general flag is set and one deviates in duration or entry, the violation should be set */ + fram_sys_mon_record.anyTimingIssueOccurred = true; + fram_sys_mon_record.taskEngineEnterTimestamp = 100u; + fram_sys_mon_record.task1msViolatingDuration = 5u; + SYSM_GetRecordedTimingViolations(&violationResponse); + TEST_ASSERT_TRUE(violationResponse.recordedViolationAny); + TEST_ASSERT_TRUE(violationResponse.recordedViolationEngine); + TEST_ASSERT_TRUE(violationResponse.recordedViolation1ms); + TEST_ASSERT_FALSE(violationResponse.recordedViolation10ms); + TEST_ASSERT_FALSE(violationResponse.recordedViolation100ms); + TEST_ASSERT_FALSE(violationResponse.recordedViolation100msAlgo); +} + +/** test #SYSM_CopyFramStruct() and its reaction to invalid input */ +void testSYSM_CopyFramStructInvalidInput(void) { + FRAM_SYS_MON_RECORD_s dummy = {0}; + TEST_ASSERT_FAIL_ASSERT(SYSM_CopyFramStruct(NULL_PTR, &dummy)); + TEST_ASSERT_FAIL_ASSERT(SYSM_CopyFramStruct(&dummy, NULL_PTR)); +} + +/** test copy function of #SYSM_CopyFramStruct() */ +void testSYSM_CopyFramStruct(void) { + FRAM_SYS_MON_RECORD_s input = { + .anyTimingIssueOccurred = true, + .task100msAlgorithmEnterTimestamp = 1, + .task100msAlgorithmViolatingDuration = 2, + .task100msEnterTimestamp = 3, + .task100msViolatingDuration = 4, + .task10msEnterTimestamp = 5, + .task10msViolatingDuration = 6, + .task1msEnterTimestamp = 7, + .task1msViolatingDuration = 8, + .taskEngineEnterTimestamp = 9, + .taskEngineViolatingDuration = 10, + }; + FRAM_SYS_MON_RECORD_s output = { + .anyTimingIssueOccurred = false, + .task100msAlgorithmEnterTimestamp = 0, + .task100msAlgorithmViolatingDuration = 0, + .task100msEnterTimestamp = 0, + .task100msViolatingDuration = 0, + .task10msEnterTimestamp = 0, + .task10msViolatingDuration = 0, + .task1msEnterTimestamp = 0, + .task1msViolatingDuration = 0, + .taskEngineEnterTimestamp = 0, + .taskEngineViolatingDuration = 0, + }; + + TEST_ASSERT_NOT_EQUAL(input.anyTimingIssueOccurred, output.anyTimingIssueOccurred); + SYSM_CopyFramStruct(&input, &output); + TEST_ASSERT_EQUAL(input.anyTimingIssueOccurred, output.anyTimingIssueOccurred); + TEST_ASSERT_EQUAL(input.task100msAlgorithmEnterTimestamp, output.task100msAlgorithmEnterTimestamp); + TEST_ASSERT_EQUAL(input.task100msAlgorithmViolatingDuration, output.task100msAlgorithmViolatingDuration); + TEST_ASSERT_EQUAL(input.task100msEnterTimestamp, output.task100msEnterTimestamp); + TEST_ASSERT_EQUAL(input.task100msViolatingDuration, output.task100msViolatingDuration); + TEST_ASSERT_EQUAL(input.task10msEnterTimestamp, output.task10msEnterTimestamp); + TEST_ASSERT_EQUAL(input.task10msViolatingDuration, output.task10msViolatingDuration); + TEST_ASSERT_EQUAL(input.task1msEnterTimestamp, output.task1msEnterTimestamp); + TEST_ASSERT_EQUAL(input.task1msViolatingDuration, output.task1msViolatingDuration); + TEST_ASSERT_EQUAL(input.taskEngineEnterTimestamp, output.taskEngineEnterTimestamp); + TEST_ASSERT_EQUAL(input.taskEngineViolatingDuration, output.taskEngineViolatingDuration); +} diff --git a/tests/unit/app/main/test_fassert.c b/tests/unit/app/main/test_fassert.c index bdde6eb0..ad15db9a 100644 --- a/tests/unit/app/main/test_fassert.c +++ b/tests/unit/app/main/test_fassert.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fassert.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/main/test_fstartup.c b/tests/unit/app/main/test_fstartup.c index 935fcb0c..e0bbce76 100644 --- a/tests/unit/app/main/test_fstartup.c +++ b/tests/unit/app/main/test_fstartup.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_fstartup.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/main/test_main.c b/tests/unit/app/main/test_main.c index ed9ec16d..c4e68db4 100644 --- a/tests/unit/app/main/test_main.c +++ b/tests/unit/app/main/test_main.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_main.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/app/task/config/test_ftask_cfg.c b/tests/unit/app/task/config/test_ftask_cfg.c index d5052308..b0949e47 100644 --- a/tests/unit/app/task/config/test_ftask_cfg.c +++ b/tests/unit/app/task/config/test_ftask_cfg.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ftask_cfg.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2021-09-30 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -92,6 +93,8 @@ #include "imd.h" /*========== Definitions and Implementations for Unit Test ==================*/ +TaskHandle_t ftsk_taskHandleAfe; + #define FTSK_DATA_QUEUE_LENGTH (1u) #define FTSK_DATA_QUEUE_ITEM_SIZE (sizeof(DATA_QUEUE_MESSAGE_s)) #define FTSK_IMD_QUEUE_LENGTH (5u) diff --git a/tests/unit/app/task/ftask/freertos/test_ftask_freertos.c b/tests/unit/app/task/ftask/freertos/test_ftask_freertos.c index b879bd7c..f70e9901 100644 --- a/tests/unit/app/task/ftask/freertos/test_ftask_freertos.c +++ b/tests/unit/app/task/ftask/freertos/test_ftask_freertos.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ftask_freertos.c * @author foxBMS Team * @date 2021-11-26 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -67,32 +68,38 @@ OS_TASK_DEFINITION_s ftsk_taskDefinitionEngine = { OS_PRIORITY_REAL_TIME, FTSK_TASK_ENGINE_PHASE, FTSK_TASK_ENGINE_CYCLE_TIME, - FTSK_TASK_ENGINE_STACK_SIZE, + FTSK_TASK_ENGINE_STACK_SIZE_IN_BYTES, FTSK_TASK_ENGINE_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic1ms = { OS_PRIORITY_ABOVE_HIGH, FTSK_TASK_CYCLIC_1MS_PHASE, FTSK_TASK_CYCLIC_1MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_1MS_STACK_SIZE, + FTSK_TASK_CYCLIC_1MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_1MS_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic10ms = { OS_PRIORITY_HIGH, FTSK_TASK_CYCLIC_10MS_PHASE, FTSK_TASK_CYCLIC_10MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_10MS_STACK_SIZE, + FTSK_TASK_CYCLIC_10MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_10MS_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclic100ms = { OS_PRIORITY_ABOVE_NORMAL, FTSK_TASK_CYCLIC_100MS_PHASE, FTSK_TASK_CYCLIC_100MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_100MS_STACK_SIZE, + FTSK_TASK_CYCLIC_100MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_100MS_PV_PARAMETERS}; OS_TASK_DEFINITION_s ftsk_taskDefinitionCyclicAlgorithm100ms = { OS_PRIORITY_NORMAL, FTSK_TASK_CYCLIC_ALGORITHM_100MS_PHASE, FTSK_TASK_CYCLIC_ALGORITHM_100MS_CYCLE_TIME, - FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACKSIZE, + FTSK_TASK_CYCLIC_ALGORITHM_100MS_STACK_SIZE_IN_BYTES, FTSK_TASK_CYCLIC_ALGORITHM_100MS_PV_PARAMETERS}; +OS_TASK_DEFINITION_s ftsk_taskDefinitionAfe = { + FTSK_TASK_AFE_PRIORITY, + FTSK_TASK_AFE_PHASE, + FTSK_TASK_AFE_CYCLE_TIME, + FTSK_TASK_AFE_STACK_SIZE_IN_BYTES, + FTSK_TASK_AFE_PV_PARAMETERS}; /** boot state of the OS */ volatile OS_BOOT_STATE_e os_boot = OS_OFF; @@ -126,5 +133,6 @@ void testFTSK_CreateTasks(void) { helperCreateStatic("TaskCyclic10ms", dummyHandleSuccess); helperCreateStatic("TaskCyclic100ms", dummyHandleSuccess); helperCreateStatic("TaskCyclicAlgorithm100ms", dummyHandleSuccess); + helperCreateStatic("TaskAfe", dummyHandleSuccess); FTSK_CreateTasks(); } diff --git a/tests/unit/app/task/ftask/test_ftask.c b/tests/unit/app/task/ftask/test_ftask.c index 6786f34a..85925b0c 100644 --- a/tests/unit/app/task/ftask/test_ftask.c +++ b/tests/unit/app/task/ftask/test_ftask.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_ftask.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -91,6 +92,8 @@ #include "ftask.h" /*========== Definitions and Implementations for Unit Test ==================*/ +TaskHandle_t ftsk_taskHandleAfe; + #define FTSK_DATA_QUEUE_LENGTH (1u) #define FTSK_DATA_QUEUE_ITEM_SIZE (sizeof(DATA_QUEUE_MESSAGE_s)) #define FTSK_IMD_QUEUE_LENGTH (5u) diff --git a/tests/unit/app/task/os/freertos/test_os_freertos.c b/tests/unit/app/task/os/freertos/test_os_freertos.c index 4aaeb268..437fe288 100644 --- a/tests/unit/app/task/os/freertos/test_os_freertos.c +++ b/tests/unit/app/task/os/freertos/test_os_freertos.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_os_freertos.c * @author foxBMS Team * @date 2021-11-26 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -77,7 +78,7 @@ void tearDown(void) { /** test that #OS_StartScheduler calls the relevant FreeRTOS function */ void testOS_StartScheduler(void) { vTaskStartScheduler_Expect(); - OS_StartScheduler(); + TEST_ASSERT_FAIL_ASSERT(OS_StartScheduler()); } void testvApplicationIdleHookCallsUserCodeIdle(void) { diff --git a/tests/unit/app/task/os/test_os.c b/tests/unit/app/task/os/test_os.c index ccbc29a5..2752e069 100644 --- a/tests/unit/app/task/os/test_os.c +++ b/tests/unit/app/task/os/test_os.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_os.c * @author foxBMS Team * @date 2020-03-13 (date of creation) - * @updated 2021-12-01 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix OS * diff --git a/tests/unit/doxygen_tests.h b/tests/unit/doxygen_tests.h index fd26ec61..8e58fe33 100644 --- a/tests/unit/doxygen_tests.h +++ b/tests/unit/doxygen_tests.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file doxygen_tests.h * @author foxBMS Team * @date 2019-06-02 (date of creation) - * @updated 2019-06-26 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix DX * diff --git a/tests/unit/opt/cells/config/test_lg_inr18650mj1.c b/tests/unit/opt/cells/config/test_lg_inr18650mj1.c index 6556d9d7..da68fb75 100644 --- a/tests/unit/opt/cells/config/test_lg_inr18650mj1.c +++ b/tests/unit/opt/cells/config/test_lg_inr18650mj1.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_lg_inr18650mj1.c * @author foxBMS Team * @date 2020-07-31 (date of creation) - * @updated 2020-07-31 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/support/test_algorithm_stubs.h b/tests/unit/support/test_algorithm_stubs.h index 91a74f86..df54202c 100644 --- a/tests/unit/support/test_algorithm_stubs.h +++ b/tests/unit/support/test_algorithm_stubs.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_algorithm_stubs.h * @author foxBMS Team * @date 2020-12-09 (date of creation) - * @updated 2020-12-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/support/test_assert_helper.h b/tests/unit/support/test_assert_helper.h index 0e0f5809..1d25f1db 100644 --- a/tests/unit/support/test_assert_helper.h +++ b/tests/unit/support/test_assert_helper.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_assert_helper.h * @author foxBMS Team * @date 2020-07-22 (date of creation) - * @updated 2020-07-22 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/support/test_can_mpu_prototype_queue_create_stub.h b/tests/unit/support/test_can_mpu_prototype_queue_create_stub.h index 099323f7..d22089b2 100644 --- a/tests/unit/support/test_can_mpu_prototype_queue_create_stub.h +++ b/tests/unit/support/test_can_mpu_prototype_queue_create_stub.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_can_mpu_prototype_queue_create_stub.h * @author foxBMS Team * @date 2021-06-09 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/unit/support/test_pec_helper.h b/tests/unit/support/test_pec_helper.h index 320d1fe3..dc345643 100644 --- a/tests/unit/support/test_pec_helper.h +++ b/tests/unit/support/test_pec_helper.h @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file test_pec_helper.h * @author foxBMS Team * @date 2020-12-16 (date of creation) - * @updated 2020-12-16 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * diff --git a/tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_bender-ir155.json similarity index 90% rename from tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_none-no-imd.json rename to tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_bender-ir155.json index c1d29fac..d530979c 100644 --- a/tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_bender-ir155.json @@ -20,8 +20,8 @@ } }, "insulation-monitoring-device": { - "manufacturer": "none", - "model": "" + "manufacturer": "bender", + "model": "ir155" } }, "operating-system": { diff --git a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_bender-iso165c.json similarity index 84% rename from tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json rename to tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_bender-iso165c.json index 9f303436..bcba15dd 100644 --- a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_ltc-6813-1_vbb_cc-cc-none_bender-iso165c.json @@ -4,7 +4,7 @@ "manufacturer": "ltc", "chip": "6813-1" }, - "balancing-strategy": "history", + "balancing-strategy": "voltage", "temperature-sensor": { "manufacturer": "epcos", "model": "b57251v5103j060", @@ -20,8 +20,8 @@ } }, "insulation-monitoring-device": { - "manufacturer": "none", - "model": "" + "manufacturer": "bender", + "model": "iso165c" } }, "operating-system": { diff --git a/tests/variants/freertos_maxim-common_vbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_maxim-max17852_vbb_cc-cc-none_none-no-imd.json similarity index 100% rename from tests/variants/freertos_maxim-common_vbb_cc-cc-none_none-no-imd.json rename to tests/variants/freertos_maxim-max17852_vbb_cc-cc-none_none-no-imd.json diff --git a/tests/variants/freertos_nxp-mc33775a_hbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_nxp-mc33775a_hbb_cc-cc-none_none-no-imd.json deleted file mode 100644 index cfbef701..00000000 --- a/tests/variants/freertos_nxp-mc33775a_hbb_cc-cc-none_none-no-imd.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "slave-unit": { - "analog-front-end": { - "manufacturer": "nxp", - "chip": "common" - }, - "balancing-strategy": "history", - "temperature-sensor": { - "manufacturer": "epcos", - "model": "b57251v5103j060", - "method": "polynomial" - } - }, - "application": { - "algorithm": { - "state-estimation": { - "soc": "counting", - "soe": "counting", - "soh": "none" - } - }, - "insulation-monitoring-device": { - "manufacturer": "none", - "model": "" - } - }, - "operating-system": { - "name": "freertos" - } -} diff --git a/tests/variants/lib-build/lib-build.bat b/tests/variants/lib-build/lib-build.bat index 473d0c05..b91e10b5 100644 --- a/tests/variants/lib-build/lib-build.bat +++ b/tests/variants/lib-build/lib-build.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tests/variants/lib-build/lib-build_cc-options.yaml b/tests/variants/lib-build/lib-build_cc-options.yaml index 5d51103e..2349865a 100644 --- a/tests/variants/lib-build/lib-build_cc-options.yaml +++ b/tests/variants/lib-build/lib-build_cc-options.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -91,7 +91,6 @@ LINKFLAGS: - --emit_warnings_as_errors - --be32 - --rom_model - - --reread_libs - --heap_size=0x800 - --stack_size=0x800 - --undef_sym=__TI_static_base__ diff --git a/tests/variants/lib-build/lib-build_main.c b/tests/variants/lib-build/lib-build_main.c index d8396194..890645ca 100644 --- a/tests/variants/lib-build/lib-build_main.c +++ b/tests/variants/lib-build/lib-build_main.c @@ -1,6 +1,6 @@ /** * - * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. + * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -43,7 +43,8 @@ * @file lib-build_main.c * @author foxBMS Team * @date 2020-10-06 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2022-05-30 (date of last update) + * @version v1.3.0 * @ingroup GENERAL * @prefix TODO * @@ -101,7 +102,7 @@ int main(void) { OS_InitializeOperatingSystem(); if (OS_INIT_PRE_OS != os_boot) { - while (1) { + while (true) { /* Could not create Queues, Mutexes, Events and Tasks do not boot further from this point on*/ } @@ -109,7 +110,7 @@ int main(void) { if (STD_OK != CHK_ValidateChecksum()) { if (DIAG_HANDLER_RETURN_OK != DIAG_Handler(DIAG_ID_FLASHCHECKSUM, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u)) { - while (1) { + while (true) { /* Could not validate checksum do not boot further from this point on */ } } @@ -118,7 +119,7 @@ int main(void) { os_schedulerStartTime = OS_GetTickCount(); OS_StartScheduler(); - while (1) { + while (true) { } } diff --git a/tools/crc/crc.bat b/tools/crc/crc.bat index 396a0cac..3d996ce3 100644 --- a/tools/crc/crc.bat +++ b/tools/crc/crc.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/dbc/foxbms.dbc b/tools/dbc/foxbms.dbc index f7c2c0c2..1c92c6b3 100644 --- a/tools/dbc/foxbms.dbc +++ b/tools/dbc/foxbms.dbc @@ -894,6 +894,7 @@ SG_ foxBMS_Error_Insulation : 23|1@0+ (1,0) [0|1] "" Vector__XXX SG_ foxBMS_Error_Cantiming : 24|1@0+ (1,0) [0|1] "" Vector__XXX SG_ foxBMS_Error_PackOvercurr_Charge : 25|1@0+ (1,0) [0|1] "" Vector__XXX SG_ foxBMS_Error_PackOvercur_Dischrg : 26|1@0+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_SysMonError : 12|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 545 foxBMS_StringState: 8 Vector__XXX @@ -1348,6 +1349,26 @@ SG_ foxBMS_releaseDistance : 31|5@0+ (1,0) [0|31] "" Vector__XXX SG_ foxBMS_releaseDistanceOverflow : 26|1@1+ (1,0) [0|1] "" Vector__XXX +BO_ 550 foxBMS_DetailState: 8 Vector__XXX +SG_ foxBMS_TimingViolationEngine : 0|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation1ms : 1|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation10ms : 2|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation100ms : 3|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation100msAlgo : 4|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation10msRec : 10|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation100msRec : 11|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation100msAlgoR : 12|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolationEngineRec : 8|1@1+ (1,0) [0|1] "" Vector__XXX +SG_ foxBMS_TimingViolation1msRec : 9|1@1+ (1,0) [0|1] "" Vector__XXX + + +BO_ 551 foxBMS_DieId: 8 Vector__XXX +SG_ MCU_lotNumber : 15|24@0+ (1,0) [0|1] "" Vector__XXX +SG_ MCU_waferNumber : 39|8@0+ (1,0) [0|1] "" Vector__XXX +SG_ MCU_xWaferCoordinate : 51|12@0+ (1,0) [0|1] "" Vector__XXX +SG_ MCU_yWaferCoordinate : 47|12@0+ (1,0) [0|1] "" Vector__XXX + + CM_ BO_ 546 "(in:can_cbs_tx_system_values.c:CAN_TxPackValues)"; CM_ SG_ 546 foxBMS_packCurrent "Battery pack current"; CM_ SG_ 546 foxBMS_batteryVoltage "Battery voltage between negative and positive pole of the battery"; @@ -1401,6 +1422,7 @@ CM_ SG_ 544 foxBMS_Error_Insulation "0x00: No error, 0x01: Error detected"; CM_ SG_ 544 foxBMS_Error_Cantiming "0x00: No error, 0x01: Error detected"; CM_ SG_ 544 foxBMS_Error_PackOvercurr_Charge "0x00: No error, 0x01: Error detected"; CM_ SG_ 544 foxBMS_Error_PackOvercur_Dischrg "0x00: No error, 0x01: Error detected"; +CM_ SG_ 544 foxBMS_SysMonError "If this bit is set, it indicates that a task has violated its timing requirements."; CM_ BO_ 545 "Message contains string related error and warning flags (in:can_cbs_tx_state.c:CAN_TxStringState)"; CM_ SG_ 545 String0_stringConnected "0x00: String not connected, 0x01: String connected to HV bus"; CM_ SG_ 545 String0_balancing_active "0x00: No balancing active, 0x01: Balancing in this string active"; @@ -1542,6 +1564,22 @@ CM_ BO_ 1831 "Current sensor string 2: coulomb counting (in:can_cbs_rx_current_s CM_ BO_ 1832 "Current sensor string 2: energy counting (in:can_cbs_rx_current_sensor.c:CAN_RxCurrentSensor)"; CM_ BO_ 409 "(in:can.c:CAN_TransmitBootMessage)"; CM_ SG_ 409 foxBMS_uniqueId "Content of Device Identification Register (DEVID)"; +CM_ BO_ 550 "Transmits details on flags transmitted by foxBMS_State (in:can_cbs_tx_state.c:CAN_TxDetailState)"; +CM_ SG_ 550 foxBMS_TimingViolationEngine "Indicates whether the timing of the engine task has been violated."; +CM_ SG_ 550 foxBMS_TimingViolation1ms "Indicates whether the timing of the 1ms task has been violated."; +CM_ SG_ 550 foxBMS_TimingViolation10ms "Indicates whether the timing of the 10ms task has been violated."; +CM_ SG_ 550 foxBMS_TimingViolation100ms "Indicates whether the timing of the 100ms task has been violated."; +CM_ SG_ 550 foxBMS_TimingViolation100msAlgo "Indicates whether the timing of the 100ms algorithm task has been violated."; +CM_ SG_ 550 foxBMS_TimingViolation10msRec "Indicates whether a violation of the timing of the 10ms task has been recorded."; +CM_ SG_ 550 foxBMS_TimingViolation100msRec "Indicates whether a violation of the timing of the 100ms task has been recorded."; +CM_ SG_ 550 foxBMS_TimingViolation100msAlgoR "Indicates whether a violation of the timing of the 100ms algorithm task has been recorded."; +CM_ SG_ 550 foxBMS_TimingViolationEngineRec "Indicates whether a violation of the timing of the engine task has been recorded."; +CM_ SG_ 550 foxBMS_TimingViolation1msRec "Indicates whether a violation of the timing of the 1ms task has been recorded."; +CM_ BO_ 551 "Transmits the unique die id of the MCU on which foxBMS is currently running (in:can.c:CAN_TransmitDieId)"; +CM_ SG_ 551 MCU_lotNumber "lot number of the MCU (read from DIEIDH register)"; +CM_ SG_ 551 MCU_waferNumber "wafer number of the MCU (read from DIEDL register)"; +CM_ SG_ 551 MCU_xWaferCoordinate "x coordinate of the MCU die on the wafer (read from DIEIDL register)"; +CM_ SG_ 551 MCU_yWaferCoordinate "y coordinate of the MCU die on the wafer (read from DIEIDL register)"; BA_DEF_ "BusType" STRING ; BA_DEF_ SG_ "GenSigStartValue" FLOAT -3.4E+038 3.4E+038; @@ -2406,6 +2444,7 @@ BA_ "GenSigStartValue" SG_ 544 foxBMS_Error_Insulation 0; BA_ "GenSigStartValue" SG_ 544 foxBMS_Error_Cantiming 0; BA_ "GenSigStartValue" SG_ 544 foxBMS_Error_PackOvercurr_Charge 0; BA_ "GenSigStartValue" SG_ 544 foxBMS_Error_PackOvercur_Dischrg 0; +BA_ "GenSigStartValue" SG_ 544 foxBMS_SysMonError 0; BA_ "GenSigStartValue" SG_ 545 String0_stringConnected 0; BA_ "GenSigStartValue" SG_ 545 String0_balancing_active 0; BA_ "GenSigStartValue" SG_ 545 String0_Err_overtemp_charge 0; @@ -2768,6 +2807,20 @@ BA_ "GenSigStartValue" SG_ 409 foxBMS_underVersionControl 0; BA_ "GenSigStartValue" SG_ 409 foxBMS_dirtyFlag 0; BA_ "GenSigStartValue" SG_ 409 foxBMS_releaseDistance 0; BA_ "GenSigStartValue" SG_ 409 foxBMS_releaseDistanceOverflow 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolationEngine 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation1ms 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation10ms 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation100ms 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation100msAlgo 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation10msRec 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation100msRec 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation100msAlgoR 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolationEngineRec 0; +BA_ "GenSigStartValue" SG_ 550 foxBMS_TimingViolation1msRec 0; +BA_ "GenSigStartValue" SG_ 551 MCU_lotNumber 0; +BA_ "GenSigStartValue" SG_ 551 MCU_waferNumber 0; +BA_ "GenSigStartValue" SG_ 551 MCU_xWaferCoordinate 0; +BA_ "GenSigStartValue" SG_ 551 MCU_yWaferCoordinate 0; VAL_ 640 foxBMS_StringValues_Mux 0 "mux_valuesString_0" 1 "mux_valuesString_1" 2 "mux_valuesString_2" ; VAL_ 643 foxBMS_StringValues2_Mux 0 "mux_values2String_0" 1 "mux_values2String_1" 2 "mux_values2String_2" ; diff --git a/tools/dbc/foxbms.sym b/tools/dbc/foxbms.sym index 01a4d455..3d8b40bb 100644 --- a/tools/dbc/foxbms.sym +++ b/tools/dbc/foxbms.sym @@ -1257,6 +1257,7 @@ Var=foxBMS_Error_Insulation bit 16,1 -m // 0x00: No error, 0x01: Error detected Var=foxBMS_Error_Cantiming bit 31,1 -m // 0x00: No error, 0x01: Error detected Var=foxBMS_Error_PackOvercurr_Charge bit 30,1 -m // 0x00: No error, 0x01: Error detected Var=foxBMS_Error_PackOvercur_Dischrg bit 29,1 -m // 0x00: No error, 0x01: Error detected +Var=foxBMS_SysMonError bit 12,1 /ln:"system monitoring error" // If this bit is set, it indicates that a task has violated its timing requirements. [foxBMS_StringState] ID=221h // Message contains string related error and warning flags (in:can_cbs_tx_state.c:CAN_TxStringState) @@ -1762,3 +1763,25 @@ Var=foxBMS_underVersionControl bit 24,1 Var=foxBMS_dirtyFlag bit 25,1 Var=foxBMS_releaseDistance unsigned 24,5 -m Var=foxBMS_releaseDistanceOverflow bit 26,1 + +[foxBMS_DetailState] +ID=226h // Transmits details on flags transmitted by foxBMS_State (in:can_cbs_tx_state.c:CAN_TxDetailState) +DLC=8 +Var=foxBMS_TimingViolationEngine bit 0,1 /ln:"timing violation engine task" // Indicates whether the timing of the engine task has been violated. +Var=foxBMS_TimingViolation1ms bit 1,1 /ln:"timing violation 1ms task" // Indicates whether the timing of the 1ms task has been violated. +Var=foxBMS_TimingViolation10ms bit 2,1 /ln:"timing violation 10ms task" // Indicates whether the timing of the 10ms task has been violated. +Var=foxBMS_TimingViolation100ms bit 3,1 /ln:"timing violation 100ms task" // Indicates whether the timing of the 100ms task has been violated. +Var=foxBMS_TimingViolation100msAlgo bit 4,1 /ln:"timing violation 100ms algorithm task" // Indicates whether the timing of the 100ms algorithm task has been violated. +Var=foxBMS_TimingViolation10msRec bit 10,1 /ln:"timing violation 10ms task recorded" // Indicates whether a violation of the timing of the 10ms task has been recorded. +Var=foxBMS_TimingViolation100msRec bit 11,1 /ln:"timing violation 100ms task recorded" // Indicates whether a violation of the timing of the 100ms task has been recorded. +Var=foxBMS_TimingViolation100msAlgoR bit 12,1 /ln:"timing violation 100ms algorithm task recorded" // Indicates whether a violation of the timing of the 100ms algorithm task has been recorded. +Var=foxBMS_TimingViolationEngineRec bit 8,1 /ln:"timing violation engine task recorded" // Indicates whether a violation of the timing of the engine task has been recorded. +Var=foxBMS_TimingViolation1msRec bit 9,1 /ln:"timing violation 1ms task recorded" // Indicates whether a violation of the timing of the 1ms task has been recorded. + +[foxBMS_DieId] +ID=227h // Transmits the unique die id of the MCU on which foxBMS is currently running (in:can.c:CAN_TransmitDieId) +DLC=8 +Var=MCU_lotNumber unsigned 8,24 -m /max:1 /ln:"lot number of the MCU" // lot number of the MCU (read from DIEIDH register) +Var=MCU_waferNumber unsigned 32,8 -m /max:1 /ln:"wafer number of the MCU" // wafer number of the MCU (read from DIEDL register) +Var=MCU_xWaferCoordinate unsigned 52,12 -m /max:1 /ln:"x wafer coordinate" // x coordinate of the MCU die on the wafer (read from DIEIDL register) +Var=MCU_yWaferCoordinate unsigned 40,12 -m /max:1 /ln:"y wafer coordinate" // y coordinate of the MCU die on the wafer (read from DIEIDL register) diff --git a/tools/dbc/symbol_creator.py b/tools/dbc/symbol_creator.py index 3e945388..67a85139 100644 --- a/tools/dbc/symbol_creator.py +++ b/tools/dbc/symbol_creator.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,8 +40,8 @@ """Template for Python scripts""" -import logging import argparse +import logging from pathlib import Path SCRIPT_PATH = Path(__file__).parent.resolve() diff --git a/tools/deploy/deploy_internal_server.sh b/tools/deploy/deploy_internal_server.sh index a439d5f1..589a95cf 100644 --- a/tools/deploy/deploy_internal_server.sh +++ b/tools/deploy/deploy_internal_server.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/gui/fgui/__init__.py b/tools/gui/fgui/__init__.py index 65e8ce38..7066c0a7 100644 --- a/tools/gui/fgui/__init__.py +++ b/tools/gui/fgui/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,9 +40,9 @@ """sets the version package etc.""" -__version__ = "1.2.1" +__version__ = "1.3.0" __appname__ = "foxBMS 2" __author__ = "The foxBMS Team" -__copyright__ = "(c) 2010 - 2021 foxBMS" +__copyright__ = "(c) 2010 - 2022 foxBMS" __author__ = "The foxBMS Team" __email__ = "info@foxbms.org" diff --git a/tools/gui/foxbms_gui.py b/tools/gui/foxbms_gui.py index 2dde15a7..d60dccc6 100644 --- a/tools/gui/foxbms_gui.py +++ b/tools/gui/foxbms_gui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -45,13 +45,12 @@ import os import webbrowser -import wx -import wx.adv import fgui - -from log_parser import LogParserFrame +import wx +import wx.adv from info_dialog import FoxbmsInfoDialog +from log_parser import LogParserFrame __version__ = fgui.__version__ __appname__ = fgui.__appname__ diff --git a/tools/gui/gui.bat b/tools/gui/gui.bat index 982290ea..5d319d2b 100644 --- a/tools/gui/gui.bat +++ b/tools/gui/gui.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/gui/info_dialog.py b/tools/gui/info_dialog.py index 57363207..57fe7467 100644 --- a/tools/gui/info_dialog.py +++ b/tools/gui/info_dialog.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -42,14 +42,14 @@ import os import pathlib + +import fgui +import markdown import wx import wx.adv -import wx.html import wx.grid +import wx.html import wx.lib.agw.hyperlink as hl -import markdown - -import fgui __version__ = fgui.__version__ __appname__ = fgui.__appname__ diff --git a/tools/gui/log_parser.py b/tools/gui/log_parser.py index b75d9cd7..90431ed3 100644 --- a/tools/gui/log_parser.py +++ b/tools/gui/log_parser.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -43,12 +43,12 @@ import os import webbrowser -import cantools -import wx -import pandas -import matplotlib.pyplot as plt +import cantools import fgui +import matplotlib.pyplot as plt +import pandas +import wx from info_dialog import FoxbmsInfoDialog __version__ = fgui.__version__ diff --git a/tools/ide/vscode/c_cpp_properties.json.jinja2 b/tools/ide/vscode/c_cpp_properties.json.jinja2 index 885682b3..2efd3fb5 100644 --- a/tools/ide/vscode/c_cpp_properties.json.jinja2 +++ b/tools/ide/vscode/c_cpp_properties.json.jinja2 @@ -1,10 +1,10 @@ { "env": { "ProjectIncludePath": [ - "${workspaceFolder}/build", "${workspaceFolder}/build/bin/src/app/main", "${workspaceFolder}/build/bin/src/hal/include", "${workspaceFolder}/build/bin/src/hal/source", + "${workspaceFolder}/build/unit_test/test/mocks", "${workspaceFolder}/src/app/application/algorithm", "${workspaceFolder}/src/app/application/algorithm/config", "${workspaceFolder}/src/app/application/algorithm/moving_average", @@ -33,9 +33,11 @@ "${workspaceFolder}/src/app/driver/i2c", "${workspaceFolder}/src/app/driver/interlock", "${workspaceFolder}/src/app/driver/imd", - "${workspaceFolder}/src/app/driver/imd/{{ IMD_MANUFACTURER }}", + "${workspaceFolder}/src/app/driver/imd/{{ IMD_MANUFACTURER }}",{% if IMD_MODEL|length%} + {% if IMD_MODEL != "" -%} "${workspaceFolder}/src/app/driver/imd/{{ IMD_MANUFACTURER }}/{{ IMD_MODEL }}", - "${workspaceFolder}/src/app/driver/imd/{{ IMD_MANUFACTURER }}/{{ IMD_MODEL }}/config", + "${workspaceFolder}/src/app/driver/imd/{{ IMD_MANUFACTURER }}/{{ IMD_MODEL }}/config",{% endif %} + {%- endif %} "${workspaceFolder}/src/app/driver/io", "${workspaceFolder}/src/app/driver/led", "${workspaceFolder}/src/app/driver/mcu", @@ -74,14 +76,11 @@ "${workspaceFolder}/src/app/task/os", "${workspaceFolder}/src/app/task/os/{{ OS }}", "${workspaceFolder}/src/os/{{ OS }}", - "${workspaceFolder}/src/os/{{ OS }}/include", - "${workspaceFolder}/src/os/{{ OS }}/portable/ccs/arm_cortex-r5", - "${workspaceFolder}/src/os/{{ OS }}/portable/common", - "${workspaceFolder}/src/os/{{ OS }}/portable/memmang", + {% for os_include in OS_INCLUDES %}"${workspaceFolder}/{{ os_include }}", + {% endfor -%} "${workspaceFolder}/tools/vendor/ceedling/vendor/unity/src", "${workspaceFolder}/tools/vendor/ceedling/vendor/c_exception/lib", - "${workspaceFolder}/tests/unit/support", - "${workspaceFolder}/build/unit_test/test/mocks" + "${workspaceFolder}/tests/unit/support" ], "forcedInclude": [], "ProjectCompiler": "{{ ARMCL }}" diff --git a/tools/ide/vscode/cspell.json.jinja2 b/tools/ide/vscode/cspell.json.jinja2 index 5b54ea61..34d7d890 100644 --- a/tools/ide/vscode/cspell.json.jinja2 +++ b/tools/ide/vscode/cspell.json.jinja2 @@ -1,7 +1,7 @@ // cSpell Settings { - // Version of the setting file. Always 0.1 - "version": "0.1", + // Version of the setting file. Always 0.2 + "version": "0.2", // language - current active spelling language "language": "en", // words - list of words to be always considered correct @@ -26,6 +26,7 @@ "pinout", "pinouts", "phosphane", + "precharge", "precharged", "prepend", "prepending", @@ -47,7 +48,11 @@ "toolset", "undervoltage", "unversioned", - "vendored" + "vendored", + // Abbreviations + "pdfs", // plural PDF + "pkgs", // plural packages + "Mbit" // megabit ], "enabled": true, "allowCompoundWords": false, @@ -83,8 +88,6 @@ "fstartup", "foxmath", "portasm", - "cppchecksuppression", - "cppcheckmisra", // prefixes we use in our embedded sources "AFE", // Analog Front-End "AFES", // Analog Front-Ends @@ -130,7 +133,6 @@ "relpath", "abspath", "printf", - "nolint", "memset", "memwidth", "threadsafe", @@ -154,7 +156,7 @@ "SIMO", "SOMI", // bender - "OKHS", + "VIFC", // Vehicle Interface Controller // ARM "curpc", "SPSR", @@ -174,6 +176,8 @@ "INTA", "IOUT", "Oport", + "DIEIDL", + "DIEIDH", "DMAREQEN", "EEPROM", "FAS_ASSERT", @@ -190,7 +194,9 @@ "PORTA", "PORTASGN", "PORTB", + "HCLK", "SYSPC", + "ecap", "ECLK", "etpwm", "TBPRD", @@ -389,6 +395,7 @@ "mram", // Magnetoresistive Random Access Memory "ntcalug", // temperature sensor form vishay "ntcle", // temperature sensor form vishay + "OHKS", // digital status pin from Bender IR155 // Axivion "axivion", "cafecc", @@ -455,7 +462,6 @@ "Mockdatabase", "Mockepcos", "Mockmath", - "cppcheck", "freertos", "safertos", "rtos", @@ -617,7 +623,6 @@ "conf/spa/.pylintrc", "conf/hcg/**", "conf/guidelines/rules.json", - "conf/spa/cppchecksuppression.txt", "conf/unit/ceedling.cmd", "conf/unit/project.yml", "conf/unit/vsc-settings.yml", @@ -653,6 +658,7 @@ "src/app/driver/sbc/fs8x_driver/**", "src/app/driver/afe/ltc/common/ltc_pec.*", "src/os/**", + "tests/axivion/predefined_macros.txt", "tests/axivion/.axivion.preinc", "tests/axivion/rule_config_c.json", "tests/axivion/ci_config.json", diff --git a/tools/ide/vscode/settings.json.jinja2 b/tools/ide/vscode/settings.json.jinja2 index b986078b..796f5650 100644 --- a/tools/ide/vscode/settings.json.jinja2 +++ b/tools/ide/vscode/settings.json.jinja2 @@ -1,4 +1,5 @@ { + "terminal.integrated.persistentSessionReviveProcess": "never", "files.encoding": "utf8", "files.autoGuessEncoding": true, "files.exclude": { @@ -9,10 +10,30 @@ "**/.DS_Store": true, "**/LLVM/**": true, "**/__pycache__/**": true, + "**/build/**/*.swi.json": true, + "**/build/**/*.a": true, + "**/build/**/*.crl": true, + "**/build/**/*.rl": true, + "**/build/**/*.obj": true, + "**/build/**/*.log": true, + "**/build/**/*.aux": true, "**/build/**/*.pp": true, + "**/build/**/*.ppd": true, + "**/build/**/*.ppi": true, + "**/build/**/*.ppm": true, "**/build/**/*.ppr": true, "**/build/**/*.pprs": true, - "**/conf/hcg/include/**":true + "**/conf/hcg/include/**":true, + ".github/**": true, + ".gitlab/**": true, + ".vscode/**": true, + "build/tmp**": true, + "build/c4che/**": true, + "build/axivion/**": true, + "build/conf_check_*/**": true, + "build/predefined_defines/**": true, + "**/.lock-waf_*_build":true, + "**/.wafpickle-*":true, }, "files.watcherExclude": { "**/.git/objects/**": true, @@ -23,19 +44,28 @@ "**/build/**/*.pp": true, "**/build/**/*.ppr": true, "**/build/**/*.pprs": true, - "**/conf/hcg/include/**":true + "**/conf/hcg/include/**": true }, "search.exclude": { "**/node_modules": true, "**/bower_components": true, "**/*.code-search": true, "**/LLVM/**": true, - "**/build/**/*.pp": true, - "**/build/**/*.ppr": true, - "**/build/**/*.pprs": true, - "**/conf/hcg/include/**":true + "**build/**/*.obj": true, + "**build/**/*.pp": true, + "**build/**/*.ppr": true, + "**build/**/*.pprs": true, + "**/conf/hcg/include/**": true }, "css.validate": false, + "json.schemas": [ + { + "fileMatch": [ + "conf/bms/bms.json" + ], + "url": "./conf/bms/schema/bms.schema.json" + } + ], "restructuredtext.linter.disabled": true, "restructuredtext.preview.sphinx.disabled": true, "restructuredtext.preview.docutil.disabled": true, @@ -63,11 +93,13 @@ "python.terminal.activateEnvironment": false, "python.pythonPath": "{{ PYTHONPATH }}", "python.analysis.extraPaths": [ - "{{ WAF_DIR }}", - "{{ WAF_TOOLS_DIR }}", - "{{ AXIVION_MODULES }}" + {% for EXTRA_PATH in PYTHON_ANALYSIS_EXTRA_PATHS %} + "{{ EXTRA_PATH }}" + {%- if not loop.last -%} + , + {% endif %} + {% endfor %} ], - "python.condaPath": "{{ CONDA_PATH }}", "python.formatting.provider": "black", "python.formatting.blackPath": "{{ BLACKPATH }}", "python.formatting.blackArgs": [ @@ -83,6 +115,8 @@ "files.eol": "\n", }, "editor.formatOnSave": true, + "editor.bracketPairColorization.enabled": true, + "editor.guides.bracketPairs": "active", "[restructuredtext]": { "editor.formatOnSave": true, "editor.rulers": [ @@ -129,7 +163,6 @@ "*.ppm": "c", "*.ppr": "c", "*.pprs": "c", - "*.cppcheck": "xml", "tests/axivion/cafeCC.config": "xml", "tests/axivion/architecture.gxl": "xml", "tests/axivion/mapping.gxl": "xml" @@ -137,8 +170,7 @@ "axivion.pathMappings": [ { "analysisProject": "{{ AXIVION_VS_CONFIG['analysisProject'] }}", - "localPath": "{{ AXIVION_VS_CONFIG['localPath'] }}", - "analysisPath": "{{ AXIVION_VS_CONFIG['analysisPath'] }}" + "localPath": "{{ AXIVION_VS_CONFIG['localPath'] }}" } ] } diff --git a/tools/ide/vscode/snippets/c.json b/tools/ide/vscode/snippets/c.json index 68459c63..d742410e 100644 --- a/tools/ide/vscode/snippets/c.json +++ b/tools/ide/vscode/snippets/c.json @@ -14,17 +14,17 @@ "for-modules" ], "body": [ - "for (uint8_t m = 0u; m < BS_NR_OF_MODULES; m++)", + "for (uint8_t m = 0u; m < BS_NR_OF_MODULES_PER_STRING; m++) {", "}" ], - "description": "For loop to iterate over the number of module." + "description": "For loop to iterate over the number of modules per string." }, "For Cells per Module Loop": { "prefix": [ "for-cells-per-module" ], "body": [ - "for (uint8_t c = 0u; c < BS_NR_OF_CELLS_PER_MODULE; c++)", + "for (uint8_t c = 0u; c < BS_NR_OF_CELL_BLOCKS_PER_MODULE; c++) {", "}" ], "description": "For loop to iterate over the number of cells per module." diff --git a/tools/ide/vscode/tasks.json.jinja2 b/tools/ide/vscode/tasks.json.jinja2 index aacc6303..22d1ccf2 100644 --- a/tools/ide/vscode/tasks.json.jinja2 +++ b/tools/ide/vscode/tasks.json.jinja2 @@ -114,30 +114,6 @@ } ] }, - { - "label": "Build:Static Program Analysis (Embedded SW)", - "type": "process", - "group": "build", - "command": "{{ WAF_WRAPPER_SCRIPT }}", - "args": [ - "build_static_analysis", - "-c", - "yes" - ], - "problemMatcher": [] - }, - { - "label": "Clean:Static Program Analysis (Embedded SW)", - "type": "process", - "group": "build", - "command": "{{ WAF_WRAPPER_SCRIPT }}", - "args": [ - "clean_static_analysis", - "-c", - "yes" - ], - "problemMatcher": [] - }, { "label": "Build:Unit test", "type": "process", @@ -235,6 +211,19 @@ ], "problemMatcher": [] }, + {% if AXIVION_CONFIG is not none %} + { + "label": "Run:Axivion configuration", + "type": "process", + "group": "build", + "command": "{{ AXIVION_CONFIG_EXE }}", + "args": [ + "${workspaceFolder}/tests/axivion" + ], + "problemMatcher": [] + }, + {% endif %} + {% if AXIVION_START_ANALYSIS is not none %} { "label": "Run:Axivion Analysis", "type": "process", @@ -242,6 +231,16 @@ "command": "{{ AXIVION_START_ANALYSIS }}", "problemMatcher": [] }, + {% endif %} + {% if AXIVION_START_DASHBOARD is not none %} + { + "label": "Run:Start Axivion Dashboard", + "type": "process", + "group": "build", + "command": "{{ AXIVION_START_DASHBOARD }}", + "problemMatcher": [] + }, + {% endif %} { "label": "Run:Guidelines and style guide check", "type": "process", @@ -271,6 +270,7 @@ } } ] + {% if JFLASH|length >= 1 %} }, { "label": "Flash:Binary", @@ -316,6 +316,7 @@ } } ] + {% endif %} } ] } diff --git a/tools/utils/bash/find_base_conda.sh b/tools/utils/bash/find_base_conda.sh index beed9954..fdeb71ca 100755 --- a/tools/utils/bash/find_base_conda.sh +++ b/tools/utils/bash/find_base_conda.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/bash/find_ccs.sh b/tools/utils/bash/find_ccs.sh index 6fdbf64d..4027cfa1 100644 --- a/tools/utils/bash/find_ccs.sh +++ b/tools/utils/bash/find_ccs.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/bash/run-python-script.sh b/tools/utils/bash/run-python-script.sh index ca89e1aa..b5b1283c 100755 --- a/tools/utils/bash/run-python-script.sh +++ b/tools/utils/bash/run-python-script.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/bash/run-python.sh b/tools/utils/bash/run-python.sh index 28a52253..0bf9a296 100644 --- a/tools/utils/bash/run-python.sh +++ b/tools/utils/bash/run-python.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/bash/run-script.sh b/tools/utils/bash/run-script.sh index 08112173..cf88fc74 100644 --- a/tools/utils/bash/run-script.sh +++ b/tools/utils/bash/run-script.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/find_base_conda.bat b/tools/utils/cmd/find_base_conda.bat index 8d264fcd..9c2033af 100644 --- a/tools/utils/cmd/find_base_conda.bat +++ b/tools/utils/cmd/find_base_conda.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/find_ccs.bat b/tools/utils/cmd/find_ccs.bat index d5664c7e..4ca2c333 100644 --- a/tools/utils/cmd/find_ccs.bat +++ b/tools/utils/cmd/find_ccs.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/find_git.bat b/tools/utils/cmd/find_git.bat index 2ba201bd..d62c8e27 100644 --- a/tools/utils/cmd/find_git.bat +++ b/tools/utils/cmd/find_git.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/find_vs-code.bat b/tools/utils/cmd/find_vs-code.bat index 323f8844..6b53ee9a 100644 --- a/tools/utils/cmd/find_vs-code.bat +++ b/tools/utils/cmd/find_vs-code.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/run-python-coverage.bat b/tools/utils/cmd/run-python-coverage.bat index e1a37843..66591b65 100644 --- a/tools/utils/cmd/run-python-coverage.bat +++ b/tools/utils/cmd/run-python-coverage.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/run-python-script.bat b/tools/utils/cmd/run-python-script.bat index 7c9315e6..1454a47b 100644 --- a/tools/utils/cmd/run-python-script.bat +++ b/tools/utils/cmd/run-python-script.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/run-python.bat b/tools/utils/cmd/run-python.bat index 831a424a..1f3d0046 100644 --- a/tools/utils/cmd/run-python.bat +++ b/tools/utils/cmd/run-python.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/cmd/run-script.bat b/tools/utils/cmd/run-script.bat index 9c4884b0..39cd0712 100644 --- a/tools/utils/cmd/run-script.bat +++ b/tools/utils/cmd/run-script.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/conda-init.bat b/tools/utils/conda-init.bat index f7c39ebb..9b2f4277 100644 --- a/tools/utils/conda-init.bat +++ b/tools/utils/conda-init.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -51,8 +51,9 @@ @ECHO Created "%DOTCONDARC%" @ECHO Open "%DOTCONDARC%" and enter your proxy information ) ELSE ( - @ECHO "%DOTCONDARC%" already exists. + @ECHO %DOTCONDARC% already exists. @ECHO Maybe you need to add "foxbms" to your channels list. + @ECHO See https://docs.foxbms.org/getting-started/miniconda-installation/conda-configuration.html#condarc-configuration @PAUSE @exit /b 1 ) diff --git a/tools/utils/conda-update-env.bat b/tools/utils/conda-update-env.bat index bbd44450..9897c204 100644 --- a/tools/utils/conda-update-env.bat +++ b/tools/utils/conda-update-env.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/conda-update-env.sh b/tools/utils/conda-update-env.sh index 04a008b1..05cf52d4 100644 --- a/tools/utils/conda-update-env.sh +++ b/tools/utils/conda-update-env.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/generate_license_list.py b/tools/utils/generate_license_list.py index b2d98145..971ff215 100644 --- a/tools/utils/generate_license_list.py +++ b/tools/utils/generate_license_list.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,19 +40,18 @@ """Generates the list of conda packages for the documentation""" -from typing import Dict, List, Tuple, Union - -import logging import argparse +import json +import logging import os import shutil -import sys import subprocess +import sys from datetime import date from io import StringIO -import json -import pandas as pd +from typing import Dict, List, Tuple, Union +import pandas as pd NAME_COLUMN_WIDTH = 36 VERSION_COLUMN_WIDTH = 20 diff --git a/tools/utils/llvm-install.bat b/tools/utils/llvm-install.bat index bb09216d..efacb4e1 100644 --- a/tools/utils/llvm-install.bat +++ b/tools/utils/llvm-install.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -37,17 +37,47 @@ @SETLOCAL EnableExtensions EnableDelayedExpansion +@NET FILE 1>NUL 2>NUL +@IF %errorlevel% NEQ 0 ( + @ECHO Installing LLVM with this script requires an elevated terminal. + @ECHO Open cmd.exe again with administrative privilges ^("Run as administrator"^) and run the script again. + @ECHO Exiting... + @PAUSE + @EXIT /b 1 +) + @TITLE Installing LLVM @SET LLVM_BASE_INSTALL_DIRECTORY=C:\Program Files\LLVM -@SET LLVM_VERSION=11.0.1 +@SET LLVM_VERSION=13.0.0 +@SET LLVM_TEMP_DIR=%TEMP%\LLVM @SET LLVM_INSTALL_DIRECTORY=%LLVM_BASE_INSTALL_DIRECTORY%\%LLVM_VERSION% -@SET LLVM_DOWNLOAD_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.1/LLVM-11.0.1-win64.exe +@SET LLVM_DOWNLOAD_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%/LLVM-%LLVM_VERSION%-win64.exe @SET LLVM_INSTALLER="%USERPROFILE%\Downloads\llvm-%LLVM_VERSION%-win64.exe" +@IF NOT EXIST "%LLVM_TEMP_DIR%" ( + @MKDIR "%LLVM_TEMP_DIR%" +) + +@IF EXIST "%LLVM_BASE_INSTALL_DIRECTORY%" ( + @XCOPY "%LLVM_BASE_INSTALL_DIRECTORY%" "%LLVM_TEMP_DIR%" /s /y + @IF %ERRORLEVEL% NEQ 0 ( + @EXIT /b %ERRORLEVEL% + ) +) + +@RMDIR /s /q "%LLVM_BASE_INSTALL_DIRECTORY%" + @ECHO Downloading LLVM -@curl.exe -fsSL %LLVM_DOWNLOAD_URL% -o %LLVM_INSTALLER% +@curl.exe -fsSL %LLVM_DOWNLOAD_URL% -o "%LLVM_INSTALLER%" @ECHO Done @ECHO Installing LLVM %LLVM_VERSION% @%LLVM_INSTALLER% /S /tasks="noassocfiles,nomodpath" /D=%LLVM_INSTALL_DIRECTORY% @ECHO Done + +@ECHO Restoring old LLVM versions +@XCOPY "%LLVM_TEMP_DIR%" "%LLVM_BASE_INSTALL_DIRECTORY%" /s /e /y +@IF %ERRORLEVEL% EQU 0 ( + @RMDIR /s /q "%LLVM_TEMP_DIR%" +) +@ECHO Done diff --git a/tools/utils/mingw64-install.bat b/tools/utils/mingw64-install.bat index 0ce1ebee..641d2948 100644 --- a/tools/utils/mingw64-install.bat +++ b/tools/utils/mingw64-install.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/miniconda3-install.bat b/tools/utils/miniconda3-install.bat index 8d49b348..f5649287 100644 --- a/tools/utils/miniconda3-install.bat +++ b/tools/utils/miniconda3-install.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/ruby-install.bat b/tools/utils/ruby-install.bat index 5d930b81..c3a8fbf9 100644 --- a/tools/utils/ruby-install.bat +++ b/tools/utils/ruby-install.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/utils/run-uncrustify.bat b/tools/utils/run-uncrustify.bat index b3e93a9b..01ce8e16 100644 --- a/tools/utils/run-uncrustify.bat +++ b/tools/utils/run-uncrustify.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -39,11 +39,11 @@ @SET UNCRUSTIFY_BIN=uncrustify @WHERE %UNCRUSTIFY_BIN% 1>NUL 2>NUL @IF %ERRORLEVEL% NEQ 0 ( - @echo Could not found uncrusitfy binary^. + @echo Could not find uncrustify binary. @EXIT /b 1 ) -@REM we found the uncrusitfy binary, therefore we set the variable properly +@REM we found the uncrustify binary, therefore we set the variable properly @FOR /F "usebackq tokens=*" %%i in (`@where uncrustify`) do @( @SET UNCRUSTIFY_BIN=%%i ) diff --git a/tools/utils/update_doxygen_header.py b/tools/utils/update_doxygen_header.py index 27a16f8b..4be96dfd 100644 --- a/tools/utils/update_doxygen_header.py +++ b/tools/utils/update_doxygen_header.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -43,11 +43,11 @@ import argparse import logging import os +import re +import subprocess import sys from datetime import date -import re from pathlib import Path -import subprocess UPDATED_RE_COMPILED = re.compile( "[ ]\\* (@updated)[ ][0-9]{4}-[0-9]{2}-[0-9]{2}[ ]\\(date of last update\\)$" @@ -92,7 +92,19 @@ def main(): logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.ERROR) - cmd = ["git", "diff", "--name-only", "master"] + + # get merge base + cmd = ["git", "merge-base", "HEAD", "origin/master"] + tmp = [] + with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p: + tmp = p.communicate()[0].decode("utf-8").strip().splitlines() + logging.debug(f"cmd: {cmd}, out:\n{tmp}") + if not tmp: + logging.warning("Could not find merge base.") + sys.exit(0) + merge_base = tmp[0] + + cmd = ["git", "diff", "--name-only", merge_base] tmp = [] with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p: tmp = p.communicate()[0].decode("utf-8").strip().splitlines() @@ -120,7 +132,7 @@ def main(): i.write_text(txt, encoding="ascii") break if not m: - logging.error(f"Something went wrong, check file '{i.a_path}'.") + logging.error(f"Something went wrong, check file '{i.resolve()}'.") m = False any_file = True @@ -131,11 +143,6 @@ def main(): with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p: p.communicate() - if changed_files: - cmd = ["git", "add"] + [i.relative_to(ROOT).as_posix() for i in changed_files] - with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p: - p.communicate() - if __name__ == "__main__": main() diff --git a/tools/vendor/.clang-format b/tools/vendor/.clang-format new file mode 100644 index 00000000..9d159247 --- /dev/null +++ b/tools/vendor/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: false diff --git a/tools/waf-tools/f_axivion.py b/tools/waf-tools/f_axivion.py index 0f418e17..748a8281 100644 --- a/tools/waf-tools/f_axivion.py +++ b/tools/waf-tools/f_axivion.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -44,7 +44,7 @@ """ import os -from waflib import Logs +from waflib import Context, Errors, Utils, Logs from waflib.Tools.ccroot import link_task from waflib import TaskGen from waflib.TaskGen import taskgen_method @@ -58,7 +58,10 @@ def configure(configure_context): """Searches the Axivion cafeCC compiler""" if os.getenv("AXIVION", None): + configure_context.find_program("axivion_config", var="AXIVION_CONFIG") configure_context.find_program("cafecc", var="AXIVION_CC") + configure_context.find_program("irdump", var="AXIVION_IR_DUMP") + configure_context.env.append_unique("AXIVION_IR_DUMP_ARGS", "-m") @conf @@ -102,13 +105,34 @@ def create_compiled_task_c(self, t_name, node): class cprogram(link_task): # pylint: disable=invalid-name,unused-variable """class to run the Axivion CC compiler in linker mode""" - run_str = ( - "${LINK_CC} ${CFLAGS} ${RUN_LINKER} ${LINKFLAGS} " - "${CCLINK_TGT_F}${TGT[0].abspath()} ${SRC} ${LINKER_SCRIPT} " - "${LIBPATH_ST:LIBPATH} ${STLIBPATH_ST:STLIBPATH} " - "-Wl,--start-group ${LIB_ST:LIB} ${STLIB_ST:STLIB} " - "-Wl,--end-group ${LDFLAGS}" - ) + def run_ir_dump(self): + """Runs irdump on the create IR file""" + cmd = [ + Utils.subst_vars("${AXIVION_IR_DUMP}", self.generator.bld.env), + Utils.subst_vars("${AXIVION_IR_DUMP_ARGS}", self.generator.bld.env), + self.outputs[0].abspath(), + ] + try: + std = self.generator.bld.cmd_and_log( + cmd, output=Context.BOTH, quiet=Context.BOTH + ) + except Errors.WafError as env_search: + Logs.error(env_search.msg.strip()) + self.generator.bld.fatal("Running irdump failed") + self.outputs[1].write(std[0], encoding="utf-8") + + run_str = [ + ( + "${LINK_CC} ${CFLAGS} ${RUN_LINKER} ${LINKFLAGS} " + "${CCLINK_TGT_F}${TGT[0].abspath()} ${SRC} ${LINKER_SCRIPT} " + "${LIBPATH_ST:LIBPATH} ${STLIBPATH_ST:STLIBPATH} " + "${TI_ARM_CGT_LINKER_START_GROUP} " + "${LIB_ST:LIB} ${STLIB_ST:STLIB} " + "${TI_ARM_CGT_LINKER_END_GROUP} " + "${LDFLAGS}" + ), + run_ir_dump, + ] ext_out = [".elf"] vars = ["LINKDEPS"] @@ -122,7 +146,8 @@ def tiprogram(bld, *k, **kw): # pylint: disable=unused-variable bld.env.LINKER_SCRIPT = kw["linker_script"].abspath() kw["features"] = "c cprogram" tgt_elf = bld.path.find_or_declare(f"{kw['target']}.{bld.env.DEST_BIN_FMT}") - kw["target"] = [tgt_elf] + irdump_out = bld.path.find_or_declare(f"{kw['target']}.irdump") + kw["target"] = [tgt_elf, irdump_out] bld.add_manual_dependency(tgt_elf, kw["linker_script"]) return bld(*k, **kw) diff --git a/tools/waf-tools/f_black.py b/tools/waf-tools/f_black.py index a6b062a6..94366d91 100644 --- a/tools/waf-tools/f_black.py +++ b/tools/waf-tools/f_black.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_bootstrap_library_project.py b/tools/waf-tools/f_bootstrap_library_project.py index 3c371955..f45fcf13 100644 --- a/tools/waf-tools/f_bootstrap_library_project.py +++ b/tools/waf-tools/f_bootstrap_library_project.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -50,11 +50,10 @@ import tarfile from tempfile import NamedTemporaryFile +import black from waflib import Context from waflib.Build import BuildContext -import black - HAVE_GIT = False try: from git import Repo diff --git a/tools/waf-tools/f_check_db_vars.py b/tools/waf-tools/f_check_db_vars.py index a07be6f3..ed121af8 100644 --- a/tools/waf-tools/f_check_db_vars.py +++ b/tools/waf-tools/f_check_db_vars.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -60,8 +60,8 @@ def build: import os import re -import tabulate +import tabulate from waflib import Logs, Task, TaskGen diff --git a/tools/waf-tools/f_clang_format.py b/tools/waf-tools/f_clang_format.py index e25c3110..e06c706f 100644 --- a/tools/waf-tools/f_clang_format.py +++ b/tools/waf-tools/f_clang_format.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -61,6 +61,7 @@ def build: """ import os + from waflib import Task, TaskGen, Utils diff --git a/tools/waf-tools/f_cppcheck.py b/tools/waf-tools/f_cppcheck.py deleted file mode 100644 index 9f9161d1..00000000 --- a/tools/waf-tools/f_cppcheck.py +++ /dev/null @@ -1,282 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. -# All rights reserved. -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# We kindly request you to use one or more of the following phrases to refer to -# foxBMS in your hardware, software, documentation or advertising materials: -# -# - "This product uses parts of foxBMS®" -# - "This product includes parts of foxBMS®" -# - "This product is derived from foxBMS®" - -"""Implements a waf tool to configure Cppcheck - -For information on Cppcheck see http://cppcheck.sourceforge.net/. -""" - -import os -import pathlib -from waflib import Node, Utils, Task, TaskGen - - -class compile_cppcheck_config(Task.Task): # pylint: disable=invalid-name - """Compiles the cppcheck template for the provided setup""" - - def run(self): - """Replaces the configuration variables""" - txt = self.inputs[0].read() - txt = txt.replace("@root@", self.generator.root_val) - txt = txt.replace("@paths@", self.generator.paths_val) - txt = txt.replace("@exclude@", self.generator.exclude_val) - txt = txt.replace("@addons@", self.generator.addons_val) - self.outputs[0].write(txt) - - -class copy_cppcheck_suppressions(Task.Task): # pylint: disable=invalid-name - """Copies the suppression file to the build directory""" - - def run(self): - """Copies the file""" - self.outputs[0].write(self.inputs[0].read()) - - -class configure_misra(Task.Task): # pylint: disable=invalid-name - """Configures the misra addon""" - - vars = ["RULES_FILE", "MISRA_ARGS"] - - def run(self): - """Actual configuration step""" - misra_args = self.misra_args # pylint: disable=no-member - if self.env.RULES_FILE: - misra_args = misra_args + [ # pylint: disable=no-member - f"--rule-texts={self.env.RULES_FILE[0]}".replace("\\", "\\\\") - ] - tmp = "" - if len(misra_args) == 1: - tmp = "".join(misra_args) - else: - for i, val in enumerate(misra_args): - if i == 0: - tmp += f'{val}",\n' - elif i == len(misra_args) - 1: - tmp += f' "{val}' - else: - tmp += f' "{val}",\n' - tmp = tmp.rstrip() - misra_args = tmp - - txt = self.inputs[0].read() - txt = txt.replace("@misra_args@", misra_args) - self.outputs[0].write(txt) - - -class cppcheck(Task.Task): # pylint: disable=invalid-name - """The actual cppcheck task""" - - vars = ["CPPCHECK_OPTIONS", "RULES_FILE", "MISRA_ARGS"] - - def run(self): - """Runs cppcheck with the provided configuration.""" - cmd = self.generator.bld.env.CPPCHECK + [ - f"--project={self.inputs[0].abspath()}", - f"--cppcheck-build-dir={self.generator.bld.bldnode.abspath()}", - ] - if hasattr(self.generator, "suppressions"): - cmd.extend( - [ - f"--exitcode-suppressions={self.generator.suppressions.abspath()}", - f"--suppressions-list={self.generator.suppressions.abspath()}", - ] - ) - if hasattr(self.generator, "exit_code"): - cmd.append(f"--error-exitcode={self.generator.exit_code}") - if hasattr(self.generator, "misra") and hasattr(self, "comp_misra"): - cmd.append(f"--addon={self.comp_misra}") # pylint: disable=no-member - cmd.extend(self.generator.options) - return self.exec_command(cmd, cwd=self.generator.bld.bldnode.abspath()) - - -@TaskGen.feature("cppcheck") -def add_cppcheck_task(self): - """Task creator for cppcheck - Attributes to be processed are: - - - config: str or node where the cppcheck configuration is stored - - root (optional): str or node where the project root is (default: '.') - - paths (optional): list of str or nodes that should be checked - (default: '.') - - exclude (optional): list of str or nodes that should be excluded - (default: none) - - addons (optional): list of addon that should be used - - options (optional): list of options that should be passed to tool - - misra (optional): configuration of the misra tool - - suppressions (optional): str or node that includes warnings that should - be suppressed - - exit_code: int that should be used as exit code in error case""" - - # validate that all required settings have been and fill optional inputs - # with defaults - if not hasattr(self, "config"): - self.bld.fatal("A cppcheck configuration must be provided.") - self.config = self.convert_to_node(self.config) - if not hasattr(self, "config"): - self.bld.fatal("Could not find cppcheck configuration.") - - if not hasattr(self, "root"): - self.root = self.path.find_node(".") - self.root = self.convert_to_node(self.root) - if not self.root: - self.bld.fatal("invalid root directory.") - - root_pattern = ' ' - self.root_val = root_pattern.format(pathlib.Path(self.root.abspath()).as_posix()) - - if not hasattr(self, "paths"): - self.paths = self.path.find_node(".") - self.paths = self.convert_to_nodes(self.paths) - if not self.paths: - self.fatal("invalid paths.") - - dir_pattern = ' \n' - self.paths_val = "" - for i in self.paths: - self.paths_val += dir_pattern.format(pathlib.Path(i.abspath()).as_posix()) - self.paths_val = self.paths_val.rstrip() - - self.exclude_val = "" - if hasattr(self, "exclude"): - self.exclude = self.convert_to_nodes(self.exclude) - for i in self.exclude: - self.exclude_val += dir_pattern.format(pathlib.Path(i.abspath()).as_posix()) - self.exclude_val = self.exclude_val.rstrip() - - if not hasattr(self, "addons"): - self.addons = "" - self.addons = Utils.to_list(self.addons) - addon_pattern = " {}\n" - self.addons_val = "" - for i in self.addons: - self.addons_val += addon_pattern.format(i) - self.addons_val = self.addons_val.rstrip() - - if hasattr(self, "options"): - self.options = Utils.to_list(self.options) - else: - self.options = [""] - self.env.CPPCHECK_OPTIONS = hash("".join(self.options)) - self.compile_cppcheck_config = self.create_task( - "compile_cppcheck_config", - src=self.config, - tgt=self.bld.path.find_or_declare(self.config.name), - ) - src = self.compile_cppcheck_config.outputs - if hasattr(self, "suppressions"): - if not isinstance(self.suppressions, Node.Node): - self.suppressions = self.path.find_node(self.suppressions) - if not self.suppressions: - self.bld.fatal("invalid suppressions file.") - self.copy_cppcheck_suppressions = self.create_task( - "copy_cppcheck_suppressions", - src=self.suppressions, - tgt=self.bld.path.find_or_declare(self.suppressions.name), - ) - src = src + self.copy_cppcheck_suppressions.outputs - if hasattr(self, "misra"): - if not isinstance(self.misra, Node.Node): - self.misra = self.path.find_node(self.misra) - if getattr(self, "misra_args", ""): - if isinstance(self.misra_args, list): - self.misra_args = " ".join(self.misra_args) - self.env.MISRA_ARGS = hash(self.misra_args) - self.configure_misra = self.create_task( - "configure_misra", - src=self.misra, - tgt=self.bld.path.find_or_declare(self.misra.name), - misra_args=Utils.to_list(getattr(self, "misra_args", "")), - ) - src = src + self.configure_misra.outputs - self.create_task( - "cppcheck", - src=src, - comp_misra=self.configure_misra.outputs[0].name, - ) - - -def options(opt): - """Defines options that can be passed to cppcheck tool""" - opt.add_option( - "--misra-rules-text", - action="store", - dest="misra_rules_text", - help="Sets the path to the MISRA rules file for cppcheck", - ) - - -def configure(conf): - """configuration step of the Cppcheck waf tool - - - Find cppcheck - - Search for the MISRA-C rules text""" - # for static analysis - conf.find_program("cppcheck", mandatory=False) - if not conf.env.CPPCHECK: - return - - conf.start_msg("Checking for MISRA-C rules file") - - rules_file = None - if conf.options.misra_rules_text: - if not conf.root.find_node(os.path.abspath(conf.options.misra_rules_text)): - conf.fatal( - f"{os.path.abspath(conf.options.misra_rules_text)} does not exist." - ) - rules_file = [ - conf.root.find_node(os.path.abspath(conf.options.misra_rules_text)) - ] - else: - if Utils.is_win32: - doc_paths = [ - os.path.join(os.path.expanduser("~"), "Documents", "MISRA-C"), - os.path.join(os.environ["PUBLIC"], "Documents", "MISRA-C"), - ] - else: - doc_paths = [ - os.path.join(os.path.expanduser("~"), "MISRA-C"), - ] - rules_file = [ - conf.root.find_node(os.path.join(x, "rules-2012.txt")) for x in doc_paths - ] - rules_file = list(filter(None, rules_file)) - if any(rules_file): - conf.env.append_unique("RULES_FILE", rules_file[0].abspath()) - conf.end_msg(conf.env.get_flat("RULES_FILE")) diff --git a/tools/waf-tools/f_git_hooks.py b/tools/waf-tools/f_git_hooks.py index 9dc3e367..beaab8fd 100644 --- a/tools/waf-tools/f_git_hooks.py +++ b/tools/waf-tools/f_git_hooks.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -44,6 +44,8 @@ import os import shutil +import git +from git.exc import InvalidGitRepositoryError def options(opt): @@ -61,6 +63,11 @@ def options(opt): def configure(conf): # pylint: disable=too-many-statements,too-many-branches """Use foxBMS specific git hooks in that repository.""" + try: + _ = git.Repo(os.path.realpath(__file__)).git_dir + except InvalidGitRepositoryError: + return + # create a VS Code workspace if code is installed on this platform if not (os.environ.get("FOXBMS_USE_GIT_HOOKS") or conf.options.USE_GIT_HOOKS): return diff --git a/tools/waf-tools/f_guidelines.py b/tools/waf-tools/f_guidelines.py index a72104ba..a623758f 100644 --- a/tools/waf-tools/f_guidelines.py +++ b/tools/waf-tools/f_guidelines.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -40,16 +40,16 @@ """Implements a waf tool to check for foxBMS project guidelines""" -import os -import re -import pathlib import collections import datetime import json +import os +import pathlib +import re from codecs import BOM_UTF8, BOM_UTF16_BE, BOM_UTF16_LE, BOM_UTF32_BE, BOM_UTF32_LE from enum import Enum -from waflib import Context, Task, TaskGen, Logs +from waflib import Context, Logs, Task, TaskGen from waflib.Build import BuildContext # pylint: disable-msg=invalid-name @@ -616,6 +616,7 @@ def run(self): self.inputs[0].name, self.inputs[0].read(), self.regex, + self.generator.bld.env.VERSION, ) if errors: for err in errors: @@ -627,7 +628,7 @@ def run(self): return GuidelineViolations.NO_VIOLATION.value @staticmethod - def test(filename, txt, regex): + def test(filename, txt, regex, version): """Implements check that the file level doxygen comments are correct This function checks whether the FILE LEVEL Doxygen comment @@ -658,6 +659,7 @@ def test(filename, txt, regex): doxygen_regex = [] for i, regex_string in enumerate(regex): # compile all doxygen regex regex_string = regex_string.replace("@FILENAME@", filename) + regex_string = regex_string.replace("@VERSION@", version) compiled_regex = re.compile(regex_string) doxygen_regex.append(compiled_regex) diff --git a/tools/waf-tools/f_hcg.py b/tools/waf-tools/f_hcg.py index 7e0726f1..608c5c4d 100644 --- a/tools/waf-tools/f_hcg.py +++ b/tools/waf-tools/f_hcg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -41,12 +41,11 @@ """Implements a waf tool to use TI HALCoGen (https://www.ti.com/tool/HALCOGEN) """ +import binascii import os -import re import pathlib +import re import shutil -import binascii - from xml.etree import ElementTree from waflib import Errors, Task, TaskGen, Utils @@ -184,15 +183,16 @@ def process_hcg(self, node): self.create_task( "hcg_compiler", src=[node, dil_file], tgt=tgt, remove_files=hcg.removes ) - no_clang_node = self.path.find_resource(".clang-format") - if not no_clang_node: - no_clang_node = self.path.find_or_declare(".clang-format") + no_clang_node = self.path.find_or_declare(".clang-format") + if not no_clang_node.exists(): no_clang_node.write( f"DisableFormat: true{os.linesep}SortIncludes: false{os.linesep}" ) if not hasattr(self, "unit_test"): - self.source.extend(gen_sources) + for i in gen_sources: + if not i.name == "HL_sys_startup.c": + self.source.append(i) try: self.includes.append("include") except AttributeError: diff --git a/tests/axivion/start_local_analysis.sh b/tools/waf-tools/f_helpers.py similarity index 59% rename from tests/axivion/start_local_analysis.sh rename to tools/waf-tools/f_helpers.py index 2113f6c1..2ccc0e5b 100644 --- a/tests/axivion/start_local_analysis.sh +++ b/tools/waf-tools/f_helpers.py @@ -1,6 +1,7 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -33,10 +34,40 @@ # We kindly request you to use one or more of the following phrases to refer to # foxBMS in your hardware, software, documentation or advertising materials: # -# - "This product uses parts of foxBMS®" -# - "This product includes parts of foxBMS®" -# - "This product is derived from foxBMS®" +# - "This product uses parts of foxBMS®" +# - "This product includes parts of foxBMS®" +# - "This product is derived from foxBMS®" -set -e +"""Various helper functions used in the foxBMS waf toolchain +""" -echo "Axivion currently only supported through cmd.exe." +import pathlib +import json +import jsonschema + +from waflib.Configure import conf +from waflib import Utils + + +@conf +def f_validator( + ctx, # pylint: disable=unused-argument + schema_path, + validator_version=jsonschema.Draft7Validator, +): + """Returns a validator with resolved relative references""" + schema_path = pathlib.Path(schema_path).resolve().as_posix() + with open(schema_path, mode="r", encoding="utf-8") as filepointer: + schema = json.load(filepointer) + if Utils.is_win32: + uri_template = "file:///{0}" + else: + uri_template = "file:{0}" + base_uri = uri_template.format(schema_path) + validator_version.check_schema(schema) + resolver = jsonschema.RefResolver( + base_uri=base_uri, + referrer=schema, + ) + validator = validator_version(schema, resolver=resolver, format_checker=None) + return validator diff --git a/tools/waf-tools/f_j_flash.py b/tools/waf-tools/f_j_flash.py index 87125bbf..2ba02477 100644 --- a/tools/waf-tools/f_j_flash.py +++ b/tools/waf-tools/f_j_flash.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -46,7 +46,6 @@ from waflib import Context, Errors, Logs, Task, Utils from waflib.Configure import conf - MINIMUM_J_FLASH_VERSION = "V7.22" JFLASH_ENV_VAR = "JFLASH" diff --git a/tools/waf-tools/f_lauterbach.py b/tools/waf-tools/f_lauterbach.py index 59e16777..ff2873f9 100644 --- a/tools/waf-tools/f_lauterbach.py +++ b/tools/waf-tools/f_lauterbach.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_miniconda_env.py b/tools/waf-tools/f_miniconda_env.py index 215711f1..e6de31d5 100644 --- a/tools/waf-tools/f_miniconda_env.py +++ b/tools/waf-tools/f_miniconda_env.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -55,12 +55,12 @@ def configure(conf): conf.load("f_miniconda_env") """ -import sys -import os import json -import yaml +import os +import sys -from waflib import Context, Errors, Utils, Logs +import yaml +from waflib import Context, Errors, Logs, Utils if Utils.is_win32: CONDA_BASE = [ diff --git a/tools/waf-tools/f_node_helper.py b/tools/waf-tools/f_node_helper.py index 005f183f..4ffb53be 100644 --- a/tools/waf-tools/f_node_helper.py +++ b/tools/waf-tools/f_node_helper.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_ozone.py b/tools/waf-tools/f_ozone.py index 53ba3fb2..dd967a9c 100644 --- a/tools/waf-tools/f_ozone.py +++ b/tools/waf-tools/f_ozone.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_pylint.py b/tools/waf-tools/f_pylint.py index 9a132d22..c9afee62 100644 --- a/tools/waf-tools/f_pylint.py +++ b/tools/waf-tools/f_pylint.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_sphinx_build.py b/tools/waf-tools/f_sphinx_build.py index 5c87cc6f..761c6eeb 100644 --- a/tools/waf-tools/f_sphinx_build.py +++ b/tools/waf-tools/f_sphinx_build.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_ti_arm_cgt.py b/tools/waf-tools/f_ti_arm_cgt.py index 23eb75d6..6e685622 100644 --- a/tools/waf-tools/f_ti_arm_cgt.py +++ b/tools/waf-tools/f_ti_arm_cgt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -521,8 +521,12 @@ class cprogram(link_task): # pylint: disable-msg=invalid-name,too-few-public-me "${LINK_CC} ${CFLAGS} ${CMD_FILES_ST:CMD_FILES} ${RUN_LINKER} " "${LINKFLAGS} ${MAP_FILE}${TGT[2].abspath()} " "${XML_LINK_INFO}${TGT[1].abspath()} ${CCLINK_TGT_F}${TGT[0].abspath()} " - "${SRC} ${LINKER_SCRIPT} ${LIBPATH_ST:LIBPATH} ${STLIBPATH_ST:STLIBPATH} " - "${LIB_ST:LIB} ${STLIB_ST:STLIB} ${TARGETLIB_ST:TARGETLIB} ${LDFLAGS}" + "${SRC} ${LINKER_SCRIPT} " + "${LIBPATH_ST:LIBPATH} ${STLIBPATH_ST:STLIBPATH} " # library search paths + " ${TI_ARM_CGT_LINKER_START_GROUP} " + "${LIB_ST:LIB} ${STLIB_ST:STLIB} " + "${TI_ARM_CGT_LINKER_END_GROUP} " + "${TARGETLIB_ST:TARGETLIB} ${LDFLAGS}" ) #: list of str: values that effect the signature calculation vars = ["LINKDEPS", "CMD_FILES_HASH"] @@ -675,7 +679,8 @@ class copy_elf(Task.Task): # pylint: disable-msg=invalid-name def run(self): """copy the generated elf file to build directory of the variant""" - shutil.copy2(self.inputs[0].abspath(), self.outputs[0].abspath()) + for in_file, out_file in zip(self.inputs, self.outputs): + shutil.copy2(in_file.abspath(), out_file.abspath()) def keyword(self): # pylint: disable=no-self-use """displayed keyword when copying the elf file""" @@ -683,7 +688,7 @@ def keyword(self): # pylint: disable=no-self-use def __str__(self): """additional information appended to the keyword""" - return f"{self.inputs[0]} -> {self.outputs[0]}" + return f"{self.inputs} -> {self.outputs}" @TaskGen.feature("cprogram") @@ -702,11 +707,10 @@ def add_copy_elf_task(self): out_dir = self.bld.path.get_bld() self.copy_elf_task = self.create_task( "copy_elf", - src=self.link_task.outputs[0], + src=self.link_task.outputs, tgt=[ - self.bld.path.find_or_declare( - os.path.join(out_dir, self.link_task.outputs[0].name) - ) + self.bld.path.find_or_declare(os.path.join(out_dir, i.name)) + for i in self.link_task.outputs ], ) @@ -1125,7 +1129,7 @@ def get_version_from_git(self): if dirty: version = f"{version}-dirty" - # assemble information into a dict for later useage + # assemble information into a dict for later usage version_output = { "version": version, "dirty": dirty, @@ -1385,10 +1389,18 @@ def find_armcl(conf): # pylint: disable-msg=redefined-outer-name for line in std_out.splitlines(): full_ver = version_pattern.search(line) if full_ver: - conf.env.CC_VERSION_FULL = full_ver.group(1) + conf.env.append_unique("CC_VERSION_FULL", full_ver.group(1)) break if not conf.env.CC_VERSION or not conf.env.CC_VERSION_FULL: conf.fatal("Could not determine compiler version") + force_ccs_version = os.environ.get("FOXBMS_2_CCS_VERSION_STRICT", False) + if force_ccs_version: + if not conf.env.FOXBMS_2_CCS_VERSION_STRICT == conf.env.CC_VERSION_FULL: + conf.fatal( + "Strict CCS version checking was set, and compiler version does not match.\n" + f"(searched for {conf.env.FOXBMS_2_CCS_VERSION_STRICT[0]}, but " + f"found {conf.env.CC_VERSION_FULL[0]})." + ) @conf @@ -1426,12 +1438,14 @@ def cgt_flags(conf): # pylint: disable-msg=redefined-outer-name env.PPM = "--preproc_macros" env.PPI = "--preproc_includes" env.PPD = "--preproc_dependency" - conf.env.ARMSIZE_OPTS = [ + env.ARMSIZE_OPTS = [ "--common", "--arch=arm", "--format=berkeley", "--totals", ] + env.TI_ARM_CGT_LINKER_END_GROUP = "--end-group" + env.TI_ARM_CGT_LINKER_START_GROUP = "--start-group" def configure(conf): # pylint: disable-msg=redefined-outer-name diff --git a/tools/waf-tools/f_ti_arm_cgt_cc_options.py b/tools/waf-tools/f_ti_arm_cgt_cc_options.py index 823e1f3a..96e464d0 100644 --- a/tools/waf-tools/f_ti_arm_cgt_cc_options.py +++ b/tools/waf-tools/f_ti_arm_cgt_cc_options.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -129,3 +129,8 @@ def load_cc_options(conf): # pylint: disable-msg=redefined-outer-name conf.env.append_unique("CFLAGS_HAL", cflags_hal) if cflags_os: conf.env.append_unique("CFLAGS_OS", cflags_os) + + conf.env.append_unique( + "FOXBMS_2_CCS_VERSION_STRICT", + conf.env.cc_options.get("FOXBMS_2_CCS_VERSION_STRICT", "NOT SET"), + ) diff --git a/tools/waf-tools/f_ti_arm_helper.py b/tools/waf-tools/f_ti_arm_helper.py index ded87aa7..8965236a 100644 --- a/tools/waf-tools/f_ti_arm_helper.py +++ b/tools/waf-tools/f_ti_arm_helper.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_ti_arm_tools.py b/tools/waf-tools/f_ti_arm_tools.py index 7e2a4c23..bb6b95df 100644 --- a/tools/waf-tools/f_ti_arm_tools.py +++ b/tools/waf-tools/f_ti_arm_tools.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_ti_color_arm_cgt.py b/tools/waf-tools/f_ti_color_arm_cgt.py index f0a2d41d..d92128f6 100644 --- a/tools/waf-tools/f_ti_color_arm_cgt.py +++ b/tools/waf-tools/f_ti_color_arm_cgt.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -48,12 +48,14 @@ WARNING_INDICATORS = [ "warning #", ": warning", + "warning:", ": remark", "remark #", ] ERROR_INDICATORS = [ "error #", ": error", + "error:", ": fatal error", "catastrophic error", ] @@ -79,7 +81,9 @@ def format(self, rec): while frame: if frame.f_code.co_name == "exec_command": cmd = frame.f_locals.get("cmd") - if isinstance(cmd, list) and ("armcl" in cmd[0]): + if isinstance(cmd, list) and ( + any(i in cmd[0] for i in ("armcl", "armhex")) + ): rec.msg = armclFormatter.colorize(rec.msg) frame = frame.f_back return Logs.formatter.format(self, rec) diff --git a/tools/waf-tools/f_unit_test.py b/tools/waf-tools/f_unit_test.py index 38c8c079..2db72e9d 100644 --- a/tools/waf-tools/f_unit_test.py +++ b/tools/waf-tools/f_unit_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause diff --git a/tools/waf-tools/f_vscode.py b/tools/waf-tools/f_vscode.py index 12eba107..9f06494c 100644 --- a/tools/waf-tools/f_vscode.py +++ b/tools/waf-tools/f_vscode.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -44,16 +44,14 @@ For information on VS Code see https://code.visualstudio.com/. """ +import json import os +from pathlib import Path import re -import pathlib -import json -import jsonschema import jinja2 - -from waflib import Utils -from waflib import Context +import jsonschema +from waflib import Context, Utils # This tool uses slash as path separator for the sake of simplicity as it # - works on both, Windows and unix-like systems (see @@ -107,21 +105,30 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches template_env = jinja2.Environment(loader=template_loader) if Utils.is_win32: - waf_wrapper_script = pathlib.Path(conf.path.abspath()).as_posix() + "/waf.bat" + waf_wrapper_script = Path(conf.path.abspath()).as_posix() + "/waf.bat" else: - waf_wrapper_script = pathlib.Path(conf.path.abspath()) / "waf.sh" - axivion_base_path = pathlib.Path( + waf_wrapper_script = Path(conf.path.abspath()) / "waf.sh" + axivion_base_path = Path( os.path.join(conf.path.abspath(), "tests", "axivion") ).as_posix() + axivion_start_analysis = None + axivion_start_dashboard = None + axivion_config_exe = None if Utils.is_win32: - axivion_start_analysis = axivion_base_path + "/start_local_analysis.bat" - else: - axivion_start_analysis = axivion_base_path + "/start_local_analysis.sh" + axivion_start_analysis = axivion_base_path + "/scripts/start_local_analysis.bat" + axivion_start_dashboard = ( + axivion_base_path + "/scripts/start_local_dashserver.bat" + ) + if conf.env.AXIVION_CONFIG: + axivion_config_exe = Path(conf.env.AXIVION_CONFIG[0]).as_posix() template = template_env.get_template("tasks.json.jinja2") tasks = template.render( WAF_WRAPPER_SCRIPT=waf_wrapper_script, + AXIVION_CONFIG_EXE=axivion_config_exe, AXIVION_START_ANALYSIS=axivion_start_analysis, + AXIVION_START_DASHBOARD=axivion_start_dashboard, + JFLASH=conf.env.JFLASH, ) vsc_tasks_file = os.path.join(vscode_dir.relpath(), "tasks.json") conf.path.make_node(vsc_tasks_file).write(fix_jinja(tasks)) @@ -140,37 +147,34 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches # Python and friends: Python, conda, pylint, black py_exe = "python" if conf.env.PYTHON: - py_exe = pathlib.Path(conf.env.PYTHON[0]).as_posix() - conda_exe = "conda" - if conf.env.CONDA: - conda_exe = pathlib.Path(conf.env.CONDA[0]).as_posix() + py_exe = Path(conf.env.PYTHON[0]).as_posix() pylint_exe = "pylint" if conf.env.PYLINT: - pylint_exe = pathlib.Path(conf.env.PYLINT[0]).as_posix() + pylint_exe = Path(conf.env.PYLINT[0]).as_posix() pylint_cfg = "" if conf.env.PYLINT_CONFIG: - pylint_cfg = pathlib.Path(conf.env.PYLINT_CONFIG[0]).as_posix() + pylint_cfg = Path(conf.env.PYLINT_CONFIG[0]).as_posix() black_exe = "black" if conf.env.BLACK: - black_exe = pathlib.Path(conf.env.BLACK[0]).as_posix() + black_exe = Path(conf.env.BLACK[0]).as_posix() black_cfg = "" if conf.env.BLACK_CONFIG: - black_cfg = pathlib.Path(conf.env.BLACK_CONFIG[0]).as_posix() + black_cfg = Path(conf.env.BLACK_CONFIG[0]).as_posix() # directory of waf and waf-tools - waf_dir = pathlib.Path(Context.waf_dir).as_posix() - waf_tools_dir = pathlib.Path( + waf_dir = Path(Context.waf_dir).as_posix() + waf_tools_dir = Path( os.path.join(conf.path.abspath(), "tools", "waf-tools") ).as_posix() # Clang-format clang_format_executable = "" if conf.env.CLANG_FORMAT: - clang_format_executable = pathlib.Path(conf.env.CLANG_FORMAT[0]).as_posix() + clang_format_executable = Path(conf.env.CLANG_FORMAT[0]).as_posix() - ax_modules_rel = pathlib.Path(os.path.join("lib", "scripts")) + ax_modules_rel = Path(os.path.join("lib", "scripts")) if Utils.is_win32: axivion_modules = ( - pathlib.Path(os.environ.get("ProgramFiles(x86)", "C:\\Program Files(x86)")) + Path(os.environ.get("ProgramFiles(x86)", "C:\\Program Files(x86)")) / "Bauhaus" / ax_modules_rel ).as_posix() @@ -179,31 +183,28 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches ) else: axivion_modules = ( - pathlib.Path(os.environ.get("HOME", "/")) / "bauhaus-suite" / ax_modules_rel + Path(os.environ.get("HOME", "/")) / "bauhaus-suite" / ax_modules_rel ) userprofile = os.environ.get("HOME", "~") axivion_vs_config = { "analysisProject": "foxbms-2", - "localPath": pathlib.Path(conf.path.abspath()).as_posix(), - "analysisPath": pathlib.Path(userprofile).as_posix(), + "localPath": Path(conf.path.abspath()).as_posix(), + "analysisPath": Path(userprofile).as_posix(), } if conf.env.AXIVION_CC: projects_path = os.path.join(userprofile, ".bauhaus", "localbuild", "projects") - axivion_vs_config["analysisPath"] = pathlib.Path(projects_path).as_posix() + axivion_vs_config["analysisPath"] = Path(projects_path).as_posix() try: axivion_modules = ( - pathlib.Path(conf.env.AXIVION_CC[0]).parent.parent / ax_modules_rel + Path(conf.env.AXIVION_CC[0]).parent.parent / ax_modules_rel ).as_posix() except IndexError: pass settings = template.render( PYTHONPATH=py_exe, - WAF_DIR=waf_dir, - WAF_TOOLS_DIR=waf_tools_dir, - AXIVION_MODULES=axivion_modules, - CONDA_PATH=conda_exe, + PYTHON_ANALYSIS_EXTRA_PATHS=[waf_dir, waf_tools_dir, axivion_modules], PYLINT_PATH=pylint_exe, PYLINT_CONFIG=pylint_cfg, BLACKPATH=black_exe, @@ -239,19 +240,30 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches bms_config = json.loads( conf.path.find_node(os.path.join("conf", "bms", "bms.json")).read() ) - bms_config_schema = json.loads( + validator = conf.f_validator( conf.path.find_node( os.path.join("conf", "bms", "schema", "bms.schema.json") - ).read() + ).abspath() ) try: - jsonschema.validate(instance=bms_config, schema=bms_config_schema) + validator.validate(bms_config) except jsonschema.exceptions.ValidationError as err: good_values = ", ".join([f"'{i}'" for i in err.validator_value]) conf.fatal( f"Setting '{err.instance}' in '{'/'.join(list(err.path))}' is not " f"supported.\nUse one of these: {good_values}." ) + os_name = bms_config["operating-system"]["name"] + rtos_details = json.loads( + conf.path.find_node( + os.path.join("src", "os", os_name, f"{os_name}_cfg.json") + ).read() + ) + + os_includes = [ + Path(os.path.join("src", "os", os_name, i)).as_posix() + for i in rtos_details["include"] + ] bal = bms_config["slave-unit"]["balancing-strategy"] soc = bms_config["application"]["algorithm"]["state-estimation"]["soc"] soe = bms_config["application"]["algorithm"]["state-estimation"]["soe"] @@ -265,8 +277,9 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches if chip in ("6804-1", "6811-1", "6812-1"): chip = "6813-1" c_cpp_properties = template.render( - ARMCL=pathlib.Path(conf.env.CC[0]).as_posix(), - OS=bms_config["operating-system"]["name"], + ARMCL=Path(conf.env.CC[0]).as_posix(), + OS=os_name, + OS_INCLUDES=os_includes, BALANCING_STRATEGY=bal, AFE_MANUFACTURER=bms_config["slave-unit"]["analog-front-end"]["manufacturer"], AFE_CHIP=chip, @@ -284,7 +297,7 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches STATE_ESTIMATOR_SOH=soh, IMD_MANUFACTURER=imd_manufacturer, IMD_MODEL=imd_model, - INCLUDES=[pathlib.Path(x).as_posix() for x in conf.env.INCLUDES], + INCLUDES=[Path(x).as_posix() for x in conf.env.INCLUDES], CSTANDARD="c11", DEFINES=vscode_defines, ) @@ -298,7 +311,7 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches template = template_env.get_template("launch.json.jinja2") gdb_exe = "gdb" if conf.env.GDB: - gdb_exe = pathlib.Path(conf.env.GDB[0]).as_posix() + gdb_exe = Path(conf.env.GDB[0]).as_posix() launch = template.render(GDB=gdb_exe) vsc_launch_file = os.path.join(vscode_dir.relpath(), "launch.json") diff --git a/waf.bat b/waf.bat index 022dd9f8..c05b1bd5 100644 --- a/waf.bat +++ b/waf.bat @@ -1,4 +1,4 @@ -@REM Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +@REM Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. @REM All rights reserved. @REM @REM SPDX-License-Identifier: BSD-3-Clause @@ -83,14 +83,18 @@ @SET ARMCL_AVAILABLE=%%~$PATH:X ) -@IF NOT DEFINED ARMCL_AVAILABLE @( - @ECHO Could not find pinned compiler. Try to use any available in 'C:\ti\'. - @SET CCS_COMPILER_BIN= - @CALL %~dp0\tools\utils\cmd\find_ccs.bat - @FOR %%x in (!CCS_COMPILER_BIN! !CCS_COMPILER_LIB! !CCS_UTILS_BIN! !CCS_UTILS_CYGWIN! !CCS_UTILS_TIOBJ2BIN!) do @( - @CALL SET "CCS_PATHS=%%CCS_PATHS%%%%x;" +@REM if FOXBMS_2_CCS_VERSION_STRICT is not set and armcl was not found in +@REM path, we try to find any CCS installation in the known installation paths +@IF NOT DEFINED FOXBMS_2_CCS_VERSION_STRICT @( + @IF NOT DEFINED ARMCL_AVAILABLE @( + @ECHO Could not find pinned compiler. Try to use any available in 'C:\ti\'. + @SET CCS_COMPILER_BIN= + @CALL %~dp0\tools\utils\cmd\find_ccs.bat + @FOR %%x in (!CCS_COMPILER_BIN! !CCS_COMPILER_LIB! !CCS_UTILS_BIN! !CCS_UTILS_CYGWIN! !CCS_UTILS_TIOBJ2BIN!) do @( + @CALL SET "CCS_PATHS=%%CCS_PATHS%%%%x;" + ) + @SET PATH=!CCS_PATHS:~0,-1!;!PATH! ) - @SET PATH=!CCS_PATHS:~0,-1!;!PATH! ) @SET CONDA_BASE_ENVIRONMENT_ACTIVATE_SCRIPT="" diff --git a/waf.sh b/waf.sh index aef69dab..657283e1 100755 --- a/waf.sh +++ b/waf.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -58,11 +58,11 @@ elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then ARMCL_TEST=`which armcl > /dev/null 2>&1` if [ $? -ne 0 ]; then set -e - echo "Could not find pinned compiler. Try to use any available in '/opt/ti'". - CCS_VARS=$($SCRIPTDIR/tools/utils/bash/find_ccs.sh || echo $?) - CCS_VARS_ARRAY=($CCS_VARS) - CCS_PATHS_TO_ADD=`echo $CCS_VARS | sed "s/ /:/g"` - export PATH=$CCS_PATHS_TO_ADD:$PATH + echo "Could not find pinned compiler. Try to use any available in '/opt/ti'". + CCS_VARS=$($SCRIPTDIR/tools/utils/bash/find_ccs.sh || echo $?) + CCS_VARS_ARRAY=($CCS_VARS) + CCS_PATHS_TO_ADD=`echo $CCS_VARS | sed "s/ /:/g"` + export PATH=$CCS_PATHS_TO_ADD:$PATH else set -e fi @@ -110,14 +110,18 @@ elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] || [ "$(expr substr $ PATHS_TO_ADD=$(echo "${PATHS_TO_ADD#?}" | tr '\\' '/') export PATH=$PATHS_TO_ADD:$PATH set +e + # if FOXBMS_2_CCS_VERSION_STRICT is not set and armcl was not found in + # path, we try to find any CCS installation in the known installation paths ARMCL_TEST=`which armcl > /dev/null 2>&1` - if [ $? -ne 0 ]; then - set -e - echo "Could not find pinned compiler. Try to use any available in 'C:\ti\'". - CCS_VARS=$($SCRIPTDIR/tools/utils/bash/find_ccs.sh || echo $?) - CCS_VARS_ARRAY=($CCS_VARS) - CCS_PATHS_TO_ADD=`echo $CCS_VARS | sed "s/ /:/g"` - export PATH=$CCS_PATHS_TO_ADD:$PATH + if [ $? -ne 0 ] ; then + if [[ -z $FOXBMS_2_CCS_VERSION_STRICT ]]; then + set -e + echo "Could not find pinned compiler. Try to use any available in 'C:\ti\'". + CCS_VARS=$($SCRIPTDIR/tools/utils/bash/find_ccs.sh || echo $?) + CCS_VARS_ARRAY=($CCS_VARS) + CCS_PATHS_TO_ADD=`echo $CCS_VARS | sed "s/ /:/g"` + export PATH=$CCS_PATHS_TO_ADD:$PATH + fi else set -e fi diff --git a/wscript b/wscript index 782676d5..51fb1c2f 100644 --- a/wscript +++ b/wscript @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Copyright (c) 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. +# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause @@ -47,16 +47,17 @@ and running various checks on the source files. """ +import json import os +import pathlib +import shlex import sys import tarfile -import shlex -import pathlib -import json +import linecache + import jsonschema import tabulate - -from waflib import Build, Configure, Context, Errors, Logs, Options, Utils, Scripting +from waflib import Build, Configure, Context, Errors, Logs, Options, Scripting, Utils from waflib.Build import ( BuildContext, CleanContext, @@ -76,7 +77,7 @@ top = "." # pylint:disable=invalid-name APPNAME = "foxBMS" """name of the application. This is used in various waf functions""" -VERSION = "1.2.1" +VERSION = "1.3.0" """version of the application. This is used in various waf functions. This version must match the version number defined in ``macros.txt``. Otherwise a configuration error is thrown.""" @@ -85,7 +86,7 @@ BIN_VARIANTS = ["bin", "axivion"] """Binary build command variations that are supported. The commands are then generated by concatenating the command + the variant, e.g., ``build_bin``""" -MISC_VARIANTS = ["docs", "unit_test", "static_analysis"] +MISC_VARIANTS = ["docs", "unit_test"] """Additional commands, that do not need more contexts than build and clean""" ALL_VARIANTS = {"binary": BIN_VARIANTS, "misc": MISC_VARIANTS} @@ -182,6 +183,25 @@ def version_consistency_checker(ctx): ] if not all(i.read().find(f'__version__ = "{VERSION}"') > 0 for i in pys): ctx.fatal(f"Version information in {pys} is not correct.") + all_c_sources = ctx.path.ant_glob( + "docs/**/*.c docs/**/*.h src/**/*.c src/**/*.c tests/**/*.c tests/**/*.c" + ) + version_line = -1 + main_txt = ctx.path.find_node("src/app/main/main.c").read() + for i, line in enumerate(main_txt.splitlines()): + if line.startswith(" * @version "): + version_line = i + 1 + break + expected_line = f"* @version v{VERSION}" + for i in all_c_sources: + version_line_txt = linecache.getline(i.abspath(), version_line) + if version_line_txt.startswith(" * @version "): + if not version_line_txt.strip() == expected_line: + ctx.fatal( + f"Version information in {i.abspath()}:{version_line} is " + f"not correct (expected '{expected_line}', but found " + f"'{version_line_txt.strip()}')." + ) def options(opt): @@ -194,7 +214,6 @@ def options(opt): opt.load("f_axivion", tooldir=TOOLDIR) opt.load("f_sphinx_build", tooldir=TOOLDIR) opt.load("doxygen", tooldir=TOOLDIR) - opt.load("f_cppcheck", tooldir=TOOLDIR) opt.load("f_ti_arm_cgt", tooldir=TOOLDIR) # load db-check-tool opt.load("f_check_db_vars", tooldir=TOOLDIR) @@ -271,7 +290,7 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches conf.msg("Checking project path", conf.path.abspath()) version_consistency_checker(conf) - + conf.load("f_helpers", tooldir=TOOLDIR) conf.find_program("git", var="GIT") conf.load("f_node_helper", tooldir=TOOLDIR) conf.load("f_ti_arm_cgt", tooldir=TOOLDIR) @@ -359,7 +378,6 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches conf.load("f_sphinx_build", tooldir=TOOLDIR) conf.load("doxygen", tooldir=TOOLDIR) conf.load("f_unit_test", tooldir=TOOLDIR) - conf.load("f_cppcheck", tooldir=TOOLDIR) conf.env.VSCODE_MK_DIRS = [ os.path.join(out, "unit_test", "test", "mocks"), os.path.join(out, "bin", "src", "app", "main"), @@ -374,13 +392,14 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches bms_config = json.loads( conf.path.find_node(os.path.join("conf", "bms", "bms.json")).read() ) - bms_config_schema = json.loads( + + validator = conf.f_validator( conf.path.find_node( os.path.join("conf", "bms", "schema", "bms.schema.json") - ).read() + ).abspath() ) try: - jsonschema.validate(instance=bms_config, schema=bms_config_schema) + validator.validate(bms_config) except jsonschema.exceptions.ValidationError as err: good_values = ", ".join([f"'{i}'" for i in err.validator_value]) conf.fatal( @@ -452,13 +471,13 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements bms_config = json.loads( bld.path.find_node(os.path.join("conf", "bms", "bms.json")).read() ) - bms_config_schema = json.loads( + validator = bld.f_validator( bld.path.find_node( os.path.join("conf", "bms", "schema", "bms.schema.json") - ).read() + ).abspath() ) try: - jsonschema.validate(instance=bms_config, schema=bms_config_schema) + validator.validate(bms_config) except jsonschema.exceptions.ValidationError as err: good_values = ", ".join([f"'{i}'" for i in err.validator_value]) bld.fatal( @@ -471,8 +490,8 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements ) if not bld.env.OPERATING_SYSTEM_NAME[0] == bld.env.CONF_OPERATING_SYSTEM_NAME[0]: bld.fatal("The operating system has changed. Re-configure the project.") - # get operatin system includes - freertos_details = json.loads( + # get operating system includes + rtos_details = json.loads( bld.path.find_node( os.path.join( "src", @@ -485,7 +504,7 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements operating_system_includes = [ os.path.join("src", "os", bms_config["operating-system"]["name"], i) - for i in freertos_details["include"] + for i in rtos_details["include"] ] bld.env.append_unique( "INCLUDES_OPERATING_SYSTEM", @@ -634,27 +653,6 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements bld.add_group() bld(features="ceedling") - if bld.variant == "static_analysis": - if bld.cmd.startswith("clean"): - return - if not bld.env.CPPCHECK and bld.cmd.startswith("build"): - bld.fatal("Can not run static analysis as cppcheck is missing.") - bld( - features="cppcheck", - config="conf/spa/cppcheck.cppcheck", - root=".", - paths="src/app src/opt", - exclude="src/hal src/os", - addons="threadsafety y2038 cert misra", - options=[ - "--std=c11", - "--force", - "--enable=warning,style,performance,portability,information,unusedFunction", - ], - misra="conf/spa/cppcheckmisra.json", - suppressions="conf/spa/cppcheck-suppression.txt", - exit_code=42, - ) if bld.variant == "docs": # General documentation build # There are two contexts defined. The first one copies the ``wscript`` files @@ -695,7 +693,6 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements _exclude = [ bld.path.find_node(os.path.join("src", "hal")), bld.path.find_node(os.path.join("src", "os")), - bld.path.find_node(os.path.join("src", "app", "driver", "imd", "bender")), bld.path.find_node(os.path.join("src", "app", "driver", "afe", "ltc", "common", "ltc_pec.c")), bld.path.find_node(os.path.join("src", "app", "driver", "afe", "ltc", "common", "ltc_pec.h")), bld.path.find_node(os.path.join("src", "app", "driver", "afe", "nxp", "common", "MC33775A.h")), @@ -798,6 +795,7 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements os.path.join(doc_dir, "hardware", "hardware.rst"), os.path.join(doc_dir, "hardware", "design-resources.rst"), os.path.join(doc_dir, "hardware", "connectors.rst"), + os.path.join(doc_dir, "hardware", "interfaces","maxim-max17841b-vx.x.x", "maxim-max17841b-v1.0.0.rst"), os.path.join(doc_dir, "misc", "bibliography.rst"), os.path.join(doc_dir, "misc", "definitions.csv"), os.path.join(doc_dir, "misc", "developer-manual-nomenclature.csv"), @@ -829,6 +827,7 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements os.path.join(doc_dir, "software", "modules", "application", "redundancy", "redundancy.rst"), os.path.join(doc_dir, "software", "modules", "driver", "adc", "adc.rst"), os.path.join(doc_dir, "software", "modules", "driver", "can", "can.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "crc", "crc.rst"), os.path.join(doc_dir, "software", "modules", "driver", "contactor", "contactor.rst"), os.path.join(doc_dir, "software", "modules", "driver", "dma", "dma.rst"), os.path.join(doc_dir, "software", "modules", "driver", "foxmath", "foxmath.rst"), @@ -877,13 +876,11 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements os.path.join(doc_dir, "software", "unit-tests", "unit-tests_how-to.rst"), os.path.join(doc_dir, "tools", "halcogen", "halcogen.rst"), os.path.join(doc_dir, "tools", "static-analysis", "axivion.rst"), - os.path.join(doc_dir, "tools", "static-analysis", "cppcheck.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_axivion.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_black.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_bootstrap_library_project.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_check_db_vars.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_clang_format.rst"), - os.path.join(doc_dir, "tools", "waf-tools", "f_cppcheck.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_git_hooks.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_guidelines.rst"), os.path.join(doc_dir, "tools", "waf-tools", "f_hcg.rst"),