diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000..ce400406 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,47 @@ +# YAML 1.2 +--- +authors: + - family-names: "Lorentz" + given-names: "Vincent R. H." + orcid: "https://orcid.org/0000-0003-2391-4406" + - family-names: "Schwarz" + given-names: "Radu" + orcid: "https://orcid.org/0000-0002-8400-8143" + - family-names: "Kanzler" + given-names: "Patrick" + orcid: "https://orcid.org/0000-0001-7911-1528" + - family-names: "Waldhör" + given-names: "Stefan" + orcid: "https://orcid.org/0000-0002-8756-652X" + - family-names: "Wenger" + given-names: "Martin" + orcid: "https://orcid.org/0000-0002-2988-2559" + - family-names: "Geus" + given-names: "Markus" + orcid: "https://orcid.org/0000-0002-9494-4437" + - family-names: "Koffel" + given-names: "Stéphane" + orcid: "https://orcid.org/0000-0001-6836-4917" + - family-names: "Wacker" + given-names: "Sebastian" + orcid: "https://orcid.org/0000-0002-5364-4999" + - family-names: "Wachtler" + given-names: "Johannes" + orcid: "https://orcid.org/0000-0002-0479-9564" + - family-names: "Huf" + given-names: "Tobias" + orcid: "https://orcid.org/0000-0002-9334-5344" + - family-names: "Ochs" + given-names: "Andreas" + orcid: "https://orcid.org/0000-0002-0904-0012" + - family-names: "Bockrath" + given-names: "Steffen" + orcid: "https://orcid.org/0000-0003-4452-532X" +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.0" +date-released: 2021-10-21 diff --git a/conf/bms/bms.json b/conf/bms/bms.json index 0815de6f..f8d8a73d 100644 --- a/conf/bms/bms.json +++ b/conf/bms/bms.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6813-1" }, diff --git a/conf/bms/schema/bms.schema.json b/conf/bms/schema/bms.schema.json index 9921b2f8..9efa8bbc 100644 --- a/conf/bms/schema/bms.schema.json +++ b/conf/bms/schema/bms.schema.json @@ -120,6 +120,7 @@ "properties": { "model": { "enum": [ + "ir155", "iso165c" ] } @@ -133,15 +134,15 @@ "$id": "/properties/slave-unit", "title": "Configuration of Slave Unit", "required": [ - "measurement-ic", + "analog-front-end", "balancing-strategy", "temperature-sensor" ], "additionalProperties": false, "properties": { - "measurement-ic": { - "$id": "/properties/slave-unit/measurement-ic", - "title": "Configuration of the measurement IC", + "analog-front-end": { + "$id": "/properties/slave-unit/analog-front-end", + "title": "Configuration of the Analog Front-End", "required": [ "manufacturer", "chip" @@ -149,21 +150,19 @@ "additionalProperties": false, "properties": { "manufacturer": { - "$id": "/properties/slave-unit/measurement-ic/manufacturer", - "title": "Manufacturer of the measurement IC (must correspond to the directory name)", + "$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", - "adi", - "ti" + "debug" ] }, "chip": { - "$id": "/properties/slave-unit/measurement-ic/chip", - "title": "Name of the chip (must correspond to the directory name)", + "$id": "/properties/slave-unit/analog-front-end/chip", + "title": "Name of the Analog Front-End (must correspond to the directory name)", "type": "string" } }, diff --git a/conf/guidelines/rules.json b/conf/guidelines/rules.json index 38f2e9c9..43f51dda 100644 --- a/conf/guidelines/rules.json +++ b/conf/guidelines/rules.json @@ -60,6 +60,7 @@ "exclude": [ ".github/PULL_REQUEST_TEMPLATE.md", ".gitlab/**", + "CITATION.cff", "BSD-3-Clause.txt", "CC-BY-4.0.txt", "CHANGELOG.md", @@ -69,7 +70,7 @@ "conf/hcg/**/*.cmd", "conf/hcg/**/*.c", "conf/hcg/**/*.h", - "src/app/driver/mic/nxp/common/MC33775A.h", + "src/app/driver/afe/nxp/common/MC33775A.h", "src/os/freertos/README.ti-halcogen.md", "tests/axivion/cafeCC.config" ] @@ -111,7 +112,8 @@ "exclude": [ "**/*.patch", "**/*.sym", - "**/*.dbc" + "**/*.dbc", + "tools/utils/git-hooks/pre-commit" ] }, "trailing_whitespace": { @@ -141,8 +143,8 @@ "name": "C:002", "exclude": [ "src/app/driver/sbc/fs8x_driver/**", - "src/app/driver/mic/ltc/common/ltc_pec.*", - "src/app/driver/mic/nxp/common/MC33775A.h" + "src/app/driver/afe/ltc/common/ltc_pec.*", + "src/app/driver/afe/nxp/common/MC33775A.h" ], "text": [ "/**", @@ -194,8 +196,8 @@ "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/mic/ltc/common/ltc_pec.*", - "src/app/driver/mic/nxp/common/MC33775A.h", + "src/app/driver/afe/ltc/common/ltc_pec.*", + "src/app/driver/afe/nxp/common/MC33775A.h", "src/os/**" ], "regex": [ @@ -219,8 +221,8 @@ ], "exclude": [ "src/app/driver/sbc/fs8x_driver/**", - "src/app/driver/mic/ltc/common/ltc_pec.*", - "src/app/driver/mic/nxp/common/MC33775A.h", + "src/app/driver/afe/ltc/common/ltc_pec.*", + "src/app/driver/afe/nxp/common/MC33775A.h", "src/os/**" ], "prefix": "FOXBMS__", @@ -234,9 +236,9 @@ }, "sections": { "exclude": [ - "src/app/driver/mic/ltc/common/ltc_pec.*", + "src/app/driver/afe/ltc/common/ltc_pec.*", "src/app/driver/sbc/fs8x_driver/**", - "src/app/driver/mic/nxp/common/MC33775A.h" + "src/app/driver/afe/nxp/common/MC33775A.h" ], "name": "C:006", "header": { @@ -563,7 +565,9 @@ ], "header": { "name": "BATCH:002", - "exclude": [], + "exclude": [ + "tests/axivion/racepdfs/make_race_pdfs.bat" + ], "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 f73f2676..2d848a14 100644 --- a/conf/hcg/hcg.dil +++ b/conf/hcg/hcg.dil @@ -1,4 +1,4 @@ -# TMS570LC4357ZWT 06/18/21 16:40:36 +# TMS570LC4357ZWT 10/12/21 09:48:42 # ARCH=TMS570LC4357ZWT # @@ -119,7 +119,7 @@ DRIVER.SYSTEM.VAR.CAN3_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.CLKT_AVCLK1_SOURCE.VALUE=VCLK DRIVER.SYSTEM.VAR.CORE_MPU_REGION_16_SUB_2_DISABLE.VALUE=0 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_6_SUB_5_DISABLE.VALUE=0 -DRIVER.SYSTEM.VAR.ETPWM4_ENABLE.VALUE=1 +DRIVER.SYSTEM.VAR.ETPWM4_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.DCC2_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.CLKT_PLL1_RESET_ON_OSCILLATOR_FAIL.VALUE=0x00800000 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_2_PERMISSION_VALUE.VALUE=0x0500 @@ -167,7 +167,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_62_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_57_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_54_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_49_INT_TYPE.VALUE=IRQ -DRIVER.SYSTEM.VAR.VIM_CHANNEL_46_INT_ENABLE.VALUE=0 +DRIVER.SYSTEM.VAR.VIM_CHANNEL_46_INT_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_38_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.EMAC_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_8_MAPPING.VALUE=8 @@ -312,7 +312,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_68_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_67_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_59_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_8_INT_ENABLE.VALUE=0 -DRIVER.SYSTEM.VAR.ETPWM2_ENABLE.VALUE=1 +DRIVER.SYSTEM.VAR.ETPWM2_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.HET1_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.CLKT_RTI1_PRE_SOURCE.VALUE=PLL1 DRIVER.SYSTEM.VAR.FLASH_MODE_VALUE.VALUE=3 @@ -489,7 +489,7 @@ DRIVER.SYSTEM.VAR.CLKT_VCLK3_DOMAIN_ENABLE.VALUE=FALSE DRIVER.SYSTEM.VAR.CORE_MPU_REGION_9_SUB_2_DISABLE.VALUE=0 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_7_END_ADDRESS.VALUE=0xf07fffff DRIVER.SYSTEM.VAR.CORE_MPU_REGION_2_SUB_0_DISABLE.VALUE=0 -DRIVER.SYSTEM.VAR.ETPWM7_ENABLE.VALUE=1 +DRIVER.SYSTEM.VAR.ETPWM7_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.ERRATA_WORKAROUND_1.VALUE=0 DRIVER.SYSTEM.VAR.ERRATA_WORKAROUND_2.VALUE=0 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_16_SUB_0_DISABLE.VALUE=0 @@ -549,7 +549,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_82_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_74_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_74_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_66_INT_PRAGMA_ENABLE.VALUE=1 -DRIVER.SYSTEM.VAR.VIM_CHANNEL_66_INT_ENABLE.VALUE=0 +DRIVER.SYSTEM.VAR.VIM_CHANNEL_66_INT_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_58_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_58_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.CLKT_PLL2_RESET_ON_SLIP.VALUE=0x00000000 @@ -674,7 +674,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_111_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_106_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_103_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_10_INT_TYPE.VALUE=IRQ -DRIVER.SYSTEM.VAR.ETPWM5_ENABLE.VALUE=1 +DRIVER.SYSTEM.VAR.ETPWM5_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.ETPWM_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.CLKT_PLL2_MUL.VALUE=40 DRIVER.SYSTEM.VAR.CLKT_RTI2_FREQ.VALUE=0.0 @@ -815,7 +815,7 @@ DRIVER.SYSTEM.VAR.CORE_MPU_REGION_2_SUB_5_DISABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_100_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_51_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_43_INT_ENABLE.VALUE=0 -DRIVER.SYSTEM.VAR.VIM_CHANNEL_35_INT_ENABLE.VALUE=0 +DRIVER.SYSTEM.VAR.VIM_CHANNEL_35_INT_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_27_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_21_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_19_INT_ENABLE.VALUE=0 @@ -837,7 +837,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_108_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_94_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_86_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_78_INT_TYPE.VALUE=IRQ -DRIVER.SYSTEM.VAR.CAN2_ENABLE.VALUE=0 +DRIVER.SYSTEM.VAR.CAN2_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.ECLK_PORT_BIT0_DOUT.VALUE=1 DRIVER.SYSTEM.VAR.PBIST_ALGO_1.VALUE=0 DRIVER.SYSTEM.VAR.FLASH_DATA_0_WAIT_STATE_FREQ.VALUE=45.0 @@ -855,7 +855,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_119_INT_TYPE.VALUE=IRQ DRIVER.SYSTEM.VAR.VIM_CHANNEL_30_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_22_INT_PRAGMA_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_14_INT_PRAGMA_ENABLE.VALUE=1 -DRIVER.SYSTEM.VAR.ETPWM3_ENABLE.VALUE=1 +DRIVER.SYSTEM.VAR.ETPWM3_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.DCC1_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.HET2_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.CLKT_VCLK3_FREQ.VALUE=100.000 @@ -1026,7 +1026,7 @@ DRIVER.SYSTEM.VAR.CLKT_PLL1_SPEADING_RATE.VALUE=255 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_13_SUB_5_DISABLE.VALUE=0 DRIVER.SYSTEM.VAR.CORE_MPU_REGION_13_END_ADDRESS.VALUE=0x0000001f DRIVER.SYSTEM.VAR.VIM_CHANNEL_50_INT_ENABLE.VALUE=0 -DRIVER.SYSTEM.VAR.VIM_CHANNEL_42_INT_ENABLE.VALUE=0 +DRIVER.SYSTEM.VAR.VIM_CHANNEL_42_INT_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_34_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_26_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_18_INT_ENABLE.VALUE=0 @@ -1210,7 +1210,7 @@ DRIVER.SYSTEM.VAR.VIM_CHANNEL_63_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_55_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_47_INT_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.VIM_CHANNEL_39_INT_ENABLE.VALUE=0 -DRIVER.SYSTEM.VAR.ETPWM6_ENABLE.VALUE=1 +DRIVER.SYSTEM.VAR.ETPWM6_ENABLE.VALUE=0 DRIVER.SYSTEM.VAR.DCC_ENABLE.VALUE=1 DRIVER.SYSTEM.VAR.VIM_CHANNEL_20_MAPPING.VALUE=20 DRIVER.SYSTEM.VAR.VIM_CHANNEL_12_MAPPING.VALUE=12 @@ -3411,12 +3411,12 @@ DRIVER.SPI.VAR.SPI5_PORT_BIT1_DIR.VALUE=1 DRIVER.SPI.VAR.SPI4_PORT_BIT5_PULL.VALUE=0 DRIVER.SPI.VAR.SPI1_PORT_BIT2_PULL.VALUE=0 DRIVER.SPI.VAR.SPI1_CHARLEN0.VALUE=8 -DRIVER.SPI.VAR.SPI1_CHARLEN1.VALUE=16 +DRIVER.SPI.VAR.SPI1_CHARLEN1.VALUE=8 DRIVER.SPI.VAR.SPI4_PORT_BIT8_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI3_PORT_BIT3_PDR.VALUE=0 DRIVER.SPI.VAR.SPI1_PORT_BIT5_DOUT.VALUE=1 -DRIVER.SPI.VAR.SPI1_CHARLEN2.VALUE=16 -DRIVER.SPI.VAR.SPI1_CHARLEN3.VALUE=16 +DRIVER.SPI.VAR.SPI1_CHARLEN2.VALUE=8 +DRIVER.SPI.VAR.SPI1_CHARLEN3.VALUE=8 DRIVER.SPI.VAR.SPI5_PORT_BIT3_PULL.VALUE=0 DRIVER.SPI.VAR.SPI3_PORT_BIT10_DIR.VALUE=1 DRIVER.SPI.VAR.SPI2_PORT_BIT0_PULL.VALUE=0 @@ -3445,12 +3445,12 @@ DRIVER.SPI.VAR.SPI3_PORT_BIT2_PSL.VALUE=1 DRIVER.SPI.VAR.SPI3_PORT_BIT1_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI3_CLKMOD.VALUE=1 DRIVER.SPI.VAR.SPI1_PHASE0.VALUE=1 -DRIVER.SPI.VAR.SPI1_PHASE1.VALUE=0 +DRIVER.SPI.VAR.SPI1_PHASE1.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT27_FUN.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT19_FUN.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT0_FUN.VALUE=1 -DRIVER.SPI.VAR.SPI1_PHASE2.VALUE=0 -DRIVER.SPI.VAR.SPI1_PHASE3.VALUE=0 +DRIVER.SPI.VAR.SPI1_PHASE2.VALUE=1 +DRIVER.SPI.VAR.SPI1_PHASE3.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT25_PSL.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT17_PSL.VALUE=1 DRIVER.SPI.VAR.SPI2_PORT_BIT11_PSL.VALUE=1 @@ -3507,7 +3507,7 @@ DRIVER.SPI.VAR.SPI3_PORT_BIT5_PDR.VALUE=0 DRIVER.SPI.VAR.SPI3_C2EDELAYACTUAL.VALUE=0.000 DRIVER.SPI.VAR.SPI1_PRESCALE0.VALUE=99 DRIVER.SPI.VAR.SPI4_BASE_RAM.VALUE=0xFF060000 -DRIVER.SPI.VAR.SPI1_PRESCALE1.VALUE=99 +DRIVER.SPI.VAR.SPI1_PRESCALE1.VALUE=24 DRIVER.SPI.VAR.SPI5_PORT_BIT4_PULL.VALUE=0 DRIVER.SPI.VAR.SPI4_CHARLEN0.VALUE=8 DRIVER.SPI.VAR.SPI2_PORT_BIT1_PULL.VALUE=0 @@ -3515,12 +3515,12 @@ DRIVER.SPI.VAR.SPI1_PRESCALE2.VALUE=99 DRIVER.SPI.VAR.SPI4_PORT_BIT3_PULDIS.VALUE=1 DRIVER.SPI.VAR.SPI4_CHARLEN1.VALUE=8 DRIVER.SPI.VAR.SPI1_PORT_BIT0_PULDIS.VALUE=1 -DRIVER.SPI.VAR.SPI1_PRESCALE3.VALUE=99 +DRIVER.SPI.VAR.SPI1_PRESCALE3.VALUE=32 DRIVER.SPI.VAR.SPI5_PORT_BIT1_PDR.VALUE=0 DRIVER.SPI.VAR.SPI5_T2CDELAYACTUAL.VALUE=10.000 -DRIVER.SPI.VAR.SPI4_CHARLEN2.VALUE=16 +DRIVER.SPI.VAR.SPI4_CHARLEN2.VALUE=8 DRIVER.SPI.VAR.SPI1_PORT_BIT8_PSL.VALUE=1 -DRIVER.SPI.VAR.SPI4_CHARLEN3.VALUE=16 +DRIVER.SPI.VAR.SPI4_CHARLEN3.VALUE=8 DRIVER.SPI.VAR.SPI1_BASE.VALUE=0xFFF7F400 DRIVER.SPI.VAR.SPI3_BITERRENA.VALUE=1 DRIVER.SPI.VAR.SPI3_OVRNINTENA.VALUE=1 @@ -3655,7 +3655,7 @@ DRIVER.SPI.VAR.SPI4_T2EDELAY.VALUE=0 DRIVER.SPI.VAR.SPI4_PHASE1.VALUE=1 DRIVER.SPI.VAR.SPI5_POLARITY2.VALUE=0 DRIVER.SPI.VAR.SPI4_PORT_BIT8_PULL.VALUE=2 -DRIVER.SPI.VAR.SPI4_PHASE2.VALUE=0 +DRIVER.SPI.VAR.SPI4_PHASE2.VALUE=1 DRIVER.SPI.VAR.SPI3_BITERRLVL.VALUE=0 DRIVER.SPI.VAR.SPI3_OVRNINTLVL.VALUE=0 DRIVER.SPI.VAR.SPI3_RXINTLVL.VALUE=0 @@ -3664,7 +3664,7 @@ DRIVER.SPI.VAR.SPI1_PORT_BIT5_PULL.VALUE=0 DRIVER.SPI.VAR.SPI5_PORT_BIT26_PULDIS.VALUE=0 DRIVER.SPI.VAR.SPI5_PORT_BIT18_PULDIS.VALUE=1 DRIVER.SPI.VAR.SPI5_POLARITY3.VALUE=0 -DRIVER.SPI.VAR.SPI4_PHASE3.VALUE=0 +DRIVER.SPI.VAR.SPI4_PHASE3.VALUE=1 DRIVER.SPI.VAR.SPI2_SHIFTDIR1.VALUE=0 DRIVER.SPI.VAR.SPI3_PORT_BIT9_PDR.VALUE=0 DRIVER.SPI.VAR.SPI3_T2EDELAYACTUAL.VALUE=0.000 @@ -3672,13 +3672,13 @@ DRIVER.SPI.VAR.SPI2_SHIFTDIR2.VALUE=0 DRIVER.SPI.VAR.SPI1_PORT_BIT8_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI1_ACTUALBAUDRATE0.VALUE=1000.000 DRIVER.SPI.VAR.SPI2_SHIFTDIR3.VALUE=0 -DRIVER.SPI.VAR.SPI1_ACTUALBAUDRATE1.VALUE=1000.000 +DRIVER.SPI.VAR.SPI1_ACTUALBAUDRATE1.VALUE=4000.000 DRIVER.SPI.VAR.SPI4_PORT_BIT10_FUN.VALUE=1 DRIVER.SPI.VAR.SPI4_PORT_BIT0_DIR.VALUE=1 DRIVER.SPI.VAR.SPI2_PORT_BIT3_PULL.VALUE=2 DRIVER.SPI.VAR.SPI1_ACTUALBAUDRATE2.VALUE=1000.000 DRIVER.SPI.VAR.SPI5_PORT_BIT11_PULDIS.VALUE=0 -DRIVER.SPI.VAR.SPI1_ACTUALBAUDRATE3.VALUE=1000.000 +DRIVER.SPI.VAR.SPI1_ACTUALBAUDRATE3.VALUE=3030.303 DRIVER.SPI.VAR.SPI5_PORT_BIT9_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT5_PDR.VALUE=0 DRIVER.SPI.VAR.SPI4_C2EDELAYACTUAL.VALUE=0.000 @@ -3686,7 +3686,7 @@ DRIVER.SPI.VAR.SPI2_PORT_BIT2_PDR.VALUE=0 DRIVER.SPI.VAR.SPI3_BASE.VALUE=0xFFF7F800 DRIVER.SPI.VAR.SPI3_PORT_BIT1_PULL.VALUE=0 DRIVER.SPI.VAR.SPI3_PORT_BIT8_PULDIS.VALUE=0 -DRIVER.SPI.VAR.SPI4_PRESCALE0.VALUE=32 +DRIVER.SPI.VAR.SPI4_PRESCALE0.VALUE=99 DRIVER.SPI.VAR.SPI3_PORT_BIT8_PSL.VALUE=1 DRIVER.SPI.VAR.SPI3_PORT_BIT4_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI3_WDELAY0.VALUE=0 @@ -3698,7 +3698,7 @@ DRIVER.SPI.VAR.SPI3_WDELAY1.VALUE=0 DRIVER.SPI.VAR.SPI4_PRESCALE2.VALUE=99 DRIVER.SPI.VAR.SPI3_WDELAY2.VALUE=0 DRIVER.SPI.VAR.SPI2_PORT_BIT3_FUN.VALUE=1 -DRIVER.SPI.VAR.SPI4_PRESCALE3.VALUE=99 +DRIVER.SPI.VAR.SPI4_PRESCALE3.VALUE=32 DRIVER.SPI.VAR.SPI4_TIMEOUTENA.VALUE=1 DRIVER.SPI.VAR.SPI3_PORT_BIT1_PULDIS.VALUE=1 DRIVER.SPI.VAR.SPI3_WDELAY3.VALUE=0 @@ -3884,7 +3884,7 @@ DRIVER.SPI.VAR.SPI1_PORT_BIT0_PDR.VALUE=0 DRIVER.SPI.VAR.SPI2_PORT_BIT8_FUN.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT9_PSL.VALUE=1 DRIVER.SPI.VAR.SPI1_BAUDRATE0.VALUE=1000.000 -DRIVER.SPI.VAR.SPI1_BAUDRATE1.VALUE=1000.000 +DRIVER.SPI.VAR.SPI1_BAUDRATE1.VALUE=4000.000 DRIVER.SPI.VAR.SPI4_PORT_BIT4_FUN.VALUE=0 DRIVER.SPI.VAR.SPI1_PORT_BIT8_PULL.VALUE=2 DRIVER.SPI.VAR.SPI1_PORT_BIT1_FUN.VALUE=0 @@ -3892,7 +3892,7 @@ DRIVER.SPI.VAR.SPI1_BAUDRATE2.VALUE=1000.000 DRIVER.SPI.VAR.SPI3_PORT_BIT4_PULDIS.VALUE=1 DRIVER.SPI.VAR.SPI1_PORT_BIT25_PULDIS.VALUE=0 DRIVER.SPI.VAR.SPI1_PORT_BIT17_PULDIS.VALUE=1 -DRIVER.SPI.VAR.SPI1_BAUDRATE3.VALUE=1000.000 +DRIVER.SPI.VAR.SPI1_BAUDRATE3.VALUE=3000.000 DRIVER.SPI.VAR.SPI5_PORT_BIT11_PDR.VALUE=1 DRIVER.SPI.VAR.SPI4_PORT_BIT2_PSL.VALUE=1 DRIVER.SPI.VAR.SPI1_WDELAY0.VALUE=0 @@ -3934,7 +3934,7 @@ DRIVER.SPI.VAR.SPI2_PORT_BIT9_FUN.VALUE=1 DRIVER.SPI.VAR.SPI5_WAITENA3.VALUE=0 DRIVER.SPI.VAR.SPI4_PORT_BIT9_PULDIS.VALUE=1 DRIVER.SPI.VAR.SPI4_PORT_BIT5_DOUT.VALUE=1 -DRIVER.SPI.VAR.SPI4_ACTUALBAUDRATE0.VALUE=3030.303 +DRIVER.SPI.VAR.SPI4_ACTUALBAUDRATE0.VALUE=1000.000 DRIVER.SPI.VAR.SPI1_PORT_BIT10_PDR.VALUE=0 DRIVER.SPI.VAR.SPI1_PORT_BIT2_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI4_ACTUALBAUDRATE1.VALUE=4000.000 @@ -3946,7 +3946,7 @@ DRIVER.SPI.VAR.SPI4_PORT_BIT5_FUN.VALUE=0 DRIVER.SPI.VAR.SPI4_ACTUALBAUDRATE2.VALUE=1000.000 DRIVER.SPI.VAR.SPI1_PORT_BIT2_FUN.VALUE=0 DRIVER.SPI.VAR.SPI4_PORT_BIT2_PULDIS.VALUE=1 -DRIVER.SPI.VAR.SPI4_ACTUALBAUDRATE3.VALUE=1000.000 +DRIVER.SPI.VAR.SPI4_ACTUALBAUDRATE3.VALUE=3030.303 DRIVER.SPI.VAR.SPI4_TXINTENA.VALUE=0 DRIVER.SPI.VAR.SPI5_PORT_BIT3_DOUT.VALUE=1 DRIVER.SPI.VAR.SPI4_PORT_BIT3_PSL.VALUE=1 @@ -4070,15 +4070,15 @@ DRIVER.SPI.VAR.SPI1_PORT_BIT3_PSL.VALUE=1 DRIVER.SPI.VAR.SPI3_PORT_BIT1_FUN.VALUE=0 DRIVER.SPI.VAR.SPI2_PORT_BIT8_PULL.VALUE=2 DRIVER.SPI.VAR.SPI2_PORT_BIT9_PULDIS.VALUE=1 -DRIVER.SPI.VAR.SPI4_BAUDRATE0.VALUE=3000 +DRIVER.SPI.VAR.SPI4_BAUDRATE0.VALUE=1000.000 DRIVER.SPI.VAR.SPI1_T2EDELAYACTUAL.VALUE=0.000 -DRIVER.SPI.VAR.SPI4_BAUDRATE1.VALUE=4000 +DRIVER.SPI.VAR.SPI4_BAUDRATE1.VALUE=4000.000 DRIVER.SPI.VAR.SPI4_BAUDRATE2.VALUE=1000.000 DRIVER.SPI.VAR.SPI4_TXINTLVL.VALUE=0 DRIVER.SPI.VAR.SPI3_PORT_BIT3_DIR.VALUE=1 DRIVER.SPI.VAR.SPI2_PORT_BIT10_FUN.VALUE=1 DRIVER.SPI.VAR.SPI5_PORT_BIT5_PULDIS.VALUE=1 -DRIVER.SPI.VAR.SPI4_BAUDRATE3.VALUE=1000.000 +DRIVER.SPI.VAR.SPI4_BAUDRATE3.VALUE=3000.000 DRIVER.SPI.VAR.SPI2_PORT_BIT2_PULDIS.VALUE=0 DRIVER.SPI.VAR.SPI1_TIMEOUTENA.VALUE=1 DRIVER.SPI.VAR.SPI5_CLKMOD.VALUE=1 @@ -4119,7 +4119,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_45_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_37_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_29_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_6_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_1_RAM_PARITY_ENA.VALUE=0x00000005 +DRIVER.CAN.VAR.CAN_1_RAM_PARITY_ENA.VALUE=0x0000000A DRIVER.CAN.VAR.CAN_1_MESSAGE_59_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_64_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_56_DLC.VALUE=8 @@ -4139,9 +4139,9 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_24_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_16_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_57_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_49_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_64_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_MESSAGE_56_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_MESSAGE_48_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_64_MASK.VALUE=0x00000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_56_MASK.VALUE=0x00000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_48_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_31_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_23_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_15_BOOL_ENA.VALUE=0 @@ -4151,7 +4151,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_35_INT_ENA.VALUE=0x00000400 DRIVER.CAN.VAR.CAN_1_MESSAGE_27_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_19_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_BAUDRATE.VALUE=500 -DRIVER.CAN.VAR.CAN_2_PORT_RX_PDR.VALUE=1 +DRIVER.CAN.VAR.CAN_2_PORT_RX_PDR.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_63_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_55_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_47_RTR.VALUE=0x00000000 @@ -4229,7 +4229,7 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_44_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_3_MESSAGE_36_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_3_MESSAGE_28_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_PIN_MODE.VALUE=1 -DRIVER.CAN.VAR.CAN_2_PHASE_SEG.VALUE=1 +DRIVER.CAN.VAR.CAN_2_PHASE_SEG.VALUE=2 DRIVER.CAN.VAR.CAN_1_MESSAGE_30_ENA.VALUE=0x80000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_22_ENA.VALUE=0x80000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_20_INT_ENA.VALUE=0x00000000 @@ -4405,7 +4405,7 @@ DRIVER.CAN.VAR.CAN_2_MESSAGE_25_ID.VALUE=25 DRIVER.CAN.VAR.CAN_2_MESSAGE_17_ID.VALUE=17 DRIVER.CAN.VAR.CAN_1_MESSAGE_10_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_2_DLC.VALUE=8 -DRIVER.CAN.VAR.CAN_2_BRP_FREQ.VALUE=10.000 +DRIVER.CAN.VAR.CAN_2_BRP_FREQ.VALUE=4.000 DRIVER.CAN.VAR.CAN_4_MESSAGE_61_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_61_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_53_EOB.VALUE=0x00000000 @@ -4419,7 +4419,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_29_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_6_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_21_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_13_INT_ENA_REF.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_PORT_TX_DIR.VALUE=0 +DRIVER.CAN.VAR.CAN_2_PORT_TX_DIR.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_31_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_31_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_23_EOB.VALUE=0x00000000 @@ -4453,9 +4453,9 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_52_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_44_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_36_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_28_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_57_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_MESSAGE_49_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_NOMINAL_BIT_RATE.VALUE=1000.000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_57_MASK.VALUE=0x00000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_49_MASK.VALUE=0x00000000 +DRIVER.CAN.VAR.CAN_2_NOMINAL_BIT_RATE.VALUE=500.000 DRIVER.CAN.VAR.CAN_1_MESSAGE_64_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_56_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_48_BOOL_ENA.VALUE=1 @@ -4525,7 +4525,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_3_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_58_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_58_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_10_INT_ENA_REF.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_SAMPLE_POINT.VALUE=90.000 +DRIVER.CAN.VAR.CAN_2_SAMPLE_POINT.VALUE=75.000 DRIVER.CAN.VAR.CAN_4_MESSAGE_62_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_54_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_46_ENA.VALUE=0x00000000 @@ -4581,7 +4581,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_16_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_64_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_56_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_48_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_40_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_40_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_32_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_24_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_20_ENA.VALUE=0x00000000 @@ -4621,7 +4621,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_17_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_4_MESSAGE_3_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_1_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_9_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_IDENTIFIER_MODE.VALUE=0x40000000 +DRIVER.CAN.VAR.CAN_2_IDENTIFIER_MODE.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_41_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_33_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_MESSAGE_25_BOOL_ENA.VALUE=1 @@ -4762,7 +4762,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_16_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_4_MESSAGE_4_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_PROP_SEG.VALUE=7 DRIVER.CAN.VAR.CAN_3_MESSAGE_8_BOOL_ENA.VALUE=0 -DRIVER.CAN.VAR.CAN_2_MESSAGE_58_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_58_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_31_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_23_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_15_INT_ENA.VALUE=0x00000000 @@ -4774,7 +4774,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_33_INT_LEVEL.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_25_INT_LEVEL.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_17_INT_LEVEL.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_5_INT_LEVEL.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_PORT_TX_PDR.VALUE=1 +DRIVER.CAN.VAR.CAN_2_PORT_TX_PDR.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_62_ID.VALUE=62 DRIVER.CAN.VAR.CAN_2_MESSAGE_59_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_54_ID.VALUE=54 @@ -4784,7 +4784,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_11_INT_LEVEL.VALUE=0x00000800 DRIVER.CAN.VAR.CAN_4_MESSAGE_64_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_4_MESSAGE_56_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_4_MESSAGE_48_DLC.VALUE=8 -DRIVER.CAN.VAR.CAN_2_NOMINAL_BIT_TIME.VALUE=10 +DRIVER.CAN.VAR.CAN_2_NOMINAL_BIT_TIME.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_50_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_42_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_34_DLC.VALUE=8 @@ -4882,14 +4882,14 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_23_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_3_MESSAGE_19_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_15_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_41_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_MESSAGE_33_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_33_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_30_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_25_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_22_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_17_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_14_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_9_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_TQ.VALUE=100.000 +DRIVER.CAN.VAR.CAN_2_TQ.VALUE=250.000 DRIVER.CAN.VAR.CAN_1_MESSAGE_7_BOOL_ENA.VALUE=1 DRIVER.CAN.VAR.CAN_1_BRPE.VALUE=0 DRIVER.CAN.VAR.CAN_4_MESSAGE_31_ID.VALUE=31 @@ -5096,7 +5096,7 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_49_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_3_MESSAGE_11_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_8_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_ENABLE.VALUE=1 -DRIVER.CAN.VAR.CAN_2_MESSAGE_59_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_59_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_10_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_3_ENA.VALUE=0x80000000 DRIVER.CAN.VAR.CAN_1_PIN_MODE.VALUE=1 @@ -5215,11 +5215,11 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_8_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_SHIFT.VALUE=18 DRIVER.CAN.VAR.CAN_2_MESSAGE_64_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_56_BOOL_ENA.VALUE=0 -DRIVER.CAN.VAR.CAN_2_MESSAGE_50_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_50_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_48_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_42_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_40_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_34_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_34_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_32_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_30_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_26_MASK.VALUE=0x000007FF @@ -5248,7 +5248,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_13_ID.VALUE=0 DRIVER.CAN.VAR.CAN_1_MESSAGE_9_INT_LEVEL.VALUE=0x00000200 DRIVER.CAN.VAR.CAN_4_BASE.VALUE=0xFFF7E200 DRIVER.CAN.VAR.CAN_2_MESSAGE_40_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_40_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_40_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_32_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_32_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_31_INT_ENA_REF.VALUE=0x00000000 @@ -5418,9 +5418,9 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_23_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_15_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_5_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_41_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_41_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_41_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_33_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_33_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_33_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_25_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_25_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_17_EOB.VALUE=0x00000000 @@ -5555,11 +5555,11 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_23_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_15_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_7_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_BRPE.VALUE=0 -DRIVER.CAN.VAR.CAN_2_MESSAGE_51_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_51_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_50_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_43_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_42_ENA.VALUE=0x80000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_35_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_35_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_34_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_27_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_26_ENA.VALUE=0x00000000 @@ -5567,7 +5567,7 @@ DRIVER.CAN.VAR.CAN_2_MESSAGE_19_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_18_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_10_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_5_BOOL_ENA.VALUE=0 -DRIVER.CAN.VAR.CAN_2_MASK.VALUE=0x1FFFFFFF +DRIVER.CAN.VAR.CAN_2_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_4_MESSAGE_63_ID.VALUE=63 DRIVER.CAN.VAR.CAN_4_MESSAGE_55_ID.VALUE=55 DRIVER.CAN.VAR.CAN_4_MESSAGE_47_ID.VALUE=47 @@ -5588,11 +5588,11 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_10_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_2_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_4_MESSAGE_2_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_50_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_50_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_50_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_42_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_42_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_34_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_34_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_34_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_26_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_26_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_18_EOB.VALUE=0x00000000 @@ -5743,11 +5743,11 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_3_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_AUTO_BUS_ON_TIME.VALUE=0 DRIVER.CAN.VAR.CAN_3_PORT_RX_DIR.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_51_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_51_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_51_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_43_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_43_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_43_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_35_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_35_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_35_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_27_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_27_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_19_EOB.VALUE=0x00000000 @@ -5822,7 +5822,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_11_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_3_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_3_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_58_INT_ENA_REF.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_BRP.VALUE=9 +DRIVER.CAN.VAR.CAN_2_BRP.VALUE=24 DRIVER.CAN.VAR.CAN_3_MESSAGE_57_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_3_MESSAGE_49_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_PORT_RX_PULDIS.VALUE=0 @@ -5854,7 +5854,7 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_24_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_16_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_8_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_NOMINAL_AUTO_BUS_ON_TIME.VALUE=0.000 -DRIVER.CAN.VAR.CAN_2_SHIFT.VALUE=0 +DRIVER.CAN.VAR.CAN_2_SHIFT.VALUE=18 DRIVER.CAN.VAR.CAN_1_MESSAGE_64_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_64_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_63_INT_ENA_REF.VALUE=0x00000001 @@ -5872,13 +5872,13 @@ DRIVER.CAN.VAR.CAN_4_BRPE.VALUE=0 DRIVER.CAN.VAR.CAN_3_MESSAGE_10_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MASK.VALUE=0x1FFFFFFF DRIVER.CAN.VAR.CAN_2_MESSAGE_60_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_60_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_60_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_52_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_52_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_52_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_44_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_44_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_36_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_36_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_36_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_28_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_28_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_1_MESSAGE_51_BOOL_ENA.VALUE=1 @@ -5902,13 +5902,13 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_12_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_4_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_58_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_60_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_60_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_60_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_52_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_52_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_52_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_44_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_44_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_44_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_36_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_36_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_36_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_28_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_28_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_1_PORT_TX_PULL.VALUE=2 @@ -6084,16 +6084,16 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_21_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_4_MESSAGE_13_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_5_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_2_MESSAGE_61_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_61_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_61_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_60_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_53_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_53_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_53_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_52_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_45_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_45_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_45_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_44_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_37_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_37_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_37_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_36_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_29_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_29_DIR.VALUE=0x20000000 @@ -6208,13 +6208,13 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_11_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_4_MASK.VALUE=0x1FFFFFFF DRIVER.CAN.VAR.CAN_3_MESSAGE_3_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_62_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_61_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_61_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_54_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_53_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_53_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_46_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_45_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_45_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_38_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_37_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_37_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_29_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_2_MESSAGE_63_INT_LEVEL.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_55_INT_LEVEL.VALUE=0x00000000 @@ -6236,13 +6236,13 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_44_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_36_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_28_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_62_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_62_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_62_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_54_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_54_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_54_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_46_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_46_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_46_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_38_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_38_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_38_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_AUTO_BUS_ON.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_30_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_22_INT_ENA_REF.VALUE=0x00000000 @@ -6316,7 +6316,7 @@ DRIVER.CAN.VAR.CAN_2_MESSAGE_40_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_32_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_24_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_16_BOOL_ENA.VALUE=0 -DRIVER.CAN.VAR.CAN_2_BAUDRATE.VALUE=1000 +DRIVER.CAN.VAR.CAN_2_BAUDRATE.VALUE=500 DRIVER.CAN.VAR.CAN_1_MESSAGE_61_INT_ENA.VALUE=0x00000400 DRIVER.CAN.VAR.CAN_1_MESSAGE_53_INT_ENA.VALUE=0x00000400 DRIVER.CAN.VAR.CAN_1_MESSAGE_45_INT_ENA.VALUE=0x00000400 @@ -6423,13 +6423,13 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_30_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_22_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_14_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_63_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_63_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_63_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_55_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_55_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_55_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_47_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_47_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_47_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_39_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_39_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_39_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_4_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_61_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_4_MESSAGE_53_BOOL_ENA.VALUE=0 @@ -6458,7 +6458,7 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_22_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_19_ID.VALUE=19 DRIVER.CAN.VAR.CAN_3_MESSAGE_14_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_6_RTR.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_SJW.VALUE=1 +DRIVER.CAN.VAR.CAN_2_SJW.VALUE=2 DRIVER.CAN.VAR.CAN_3_MESSAGE_51_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_51_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_43_EOB.VALUE=0x00000000 @@ -6541,12 +6541,12 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_44_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_3_MESSAGE_36_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_3_MESSAGE_28_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_64_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_62_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_62_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_56_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_54_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_54_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_48_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_46_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_MESSAGE_38_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_46_MASK.VALUE=0x00000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_38_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_51_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_43_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_40_INT_LEVEL.VALUE=0x00000000 @@ -6564,14 +6564,14 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_24_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_4_MESSAGE_16_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_8_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_BRP_FREQ.VALUE=10.000 -DRIVER.CAN.VAR.CAN_2_BRPE_FREQ.VALUE=10.000 +DRIVER.CAN.VAR.CAN_2_BRPE_FREQ.VALUE=4.000 DRIVER.CAN.VAR.CAN_1_MESSAGE_10_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_2_MESSAGE_64_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_64_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_64_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_56_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_56_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_56_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_48_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_48_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_48_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_1_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_63_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_4_MESSAGE_55_MASK.VALUE=0x000007FF @@ -6588,7 +6588,7 @@ DRIVER.CAN.VAR.CAN_3_MESSAGE_28_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_6_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_11_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_6_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_PROP_SEG.VALUE=7 +DRIVER.CAN.VAR.CAN_2_PROP_SEG.VALUE=3 DRIVER.CAN.VAR.CAN_1_MESSAGE_41_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_33_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_25_MASK.VALUE=0x00000000 @@ -6715,9 +6715,9 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_17_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_9_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_11_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_2_MESSAGE_57_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_57_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_57_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_49_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_49_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_49_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_58_INT_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_4_MASK.VALUE=0x000007FF DRIVER.CAN.VAR.CAN_4_PHASE_SEG.VALUE=1 @@ -6839,13 +6839,13 @@ DRIVER.CAN.VAR.CAN_2_MESSAGE_2_EOB.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_2_DIR.VALUE=0x20000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_1_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_2_MESSAGE_64_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_63_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_63_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_58_ENA.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_56_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_55_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_55_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_48_INT_ENA.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_47_MASK.VALUE=0x000007FF -DRIVER.CAN.VAR.CAN_2_MESSAGE_39_MASK.VALUE=0x000007FF +DRIVER.CAN.VAR.CAN_2_MESSAGE_47_MASK.VALUE=0x00000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_39_MASK.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_61_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_53_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_45_RTR.VALUE=0x00000000 @@ -6861,7 +6861,7 @@ DRIVER.CAN.VAR.CAN_4_MESSAGE_18_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_20_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_1_MESSAGE_12_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_2_MESSAGE_58_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_58_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_58_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_57_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_49_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_64_MASK.VALUE=0x000007FF @@ -7009,7 +7009,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_13_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_4_MESSAGE_57_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_4_MESSAGE_49_INT_ENA_REF.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_2_MESSAGE_59_EOB.VALUE=0x00000000 -DRIVER.CAN.VAR.CAN_2_MESSAGE_59_DIR.VALUE=0x20000000 +DRIVER.CAN.VAR.CAN_2_MESSAGE_59_DIR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_1_MESSAGE_51_INT_ENA_REF.VALUE=0x00000001 DRIVER.CAN.VAR.CAN_1_MESSAGE_43_INT_ENA_REF.VALUE=0x00000001 DRIVER.CAN.VAR.CAN_1_MESSAGE_35_INT_ENA_REF.VALUE=0x00000001 @@ -7079,8 +7079,8 @@ DRIVER.CAN.VAR.CAN_2_MESSAGE_21_ID.VALUE=21 DRIVER.CAN.VAR.CAN_2_MESSAGE_13_ID.VALUE=13 DRIVER.CAN.VAR.CAN_2_MESSAGE_8_ID.VALUE=8 DRIVER.ADC.VAR.ADC2_GROUP1_DISCHARGE_PRESCALER.VALUE=0 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN21_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN13_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN21_ENABLE.VALUE=0x00200000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN13_ENABLE.VALUE=0x00002000 DRIVER.ADC.VAR.ADC1_GROUP1_ACTUAL_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC2_GROUP1_RESOLUTION.VALUE=12_BIT DRIVER.ADC.VAR.ADC2_GROUP0_PIN3_ENABLE.VALUE=0x00000000 @@ -7096,12 +7096,12 @@ DRIVER.ADC.VAR.ADC1_GROUP2_RAM_PARITY_ENA.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP1_EXTENDED_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC2_GROUP2_PIN0_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_RAM_PARITY_ENA.VALUE=0 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN3_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP0_CHANNEL_TOTAL_TIME.VALUE=1.600000 -DRIVER.ADC.VAR.ADC1_GROUP1_FIFO_SIZE.VALUE=16 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN3_ENABLE.VALUE=0x00000008 +DRIVER.ADC.VAR.ADC1_GROUP0_CHANNEL_TOTAL_TIME.VALUE=0.000000 +DRIVER.ADC.VAR.ADC1_GROUP1_FIFO_SIZE.VALUE=32 DRIVER.ADC.VAR.ADC1_GROUP2_DISCHARGE_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_SAMPLE_PRESCALER.VALUE=1 -DRIVER.ADC.VAR.ADC1_GROUP1_LENGTH.VALUE=16 +DRIVER.ADC.VAR.ADC1_GROUP1_LENGTH.VALUE=64 DRIVER.ADC.VAR.ADC2_GROUP1_ID_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP0_PIN18_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_CONVERSION_TIME.VALUE=1.300 @@ -7113,7 +7113,7 @@ DRIVER.ADC.VAR.ADC1_ALT_TRIG.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP1_PIN23_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP1_PIN15_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN29_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP0_PIN0_ENABLE.VALUE=0x00000001 +DRIVER.ADC.VAR.ADC1_GROUP0_PIN0_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_CONVERSION_TIME.VALUE=1.300 DRIVER.ADC.VAR.ADC2_GROUP2_LENGTH.VALUE=32 DRIVER.ADC.VAR.ADC2_GROUP2_PIN19_ENABLE.VALUE=0x00000000 @@ -7126,10 +7126,10 @@ DRIVER.ADC.VAR.ADC2_GROUP2_ACTUAL_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC2_GROUP2_SAMPLE_PRESCALER.VALUE=1 DRIVER.ADC.VAR.ADC2_GROUP2_PIN20_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN12_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN26_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN18_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN26_ENABLE.VALUE=0x04000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN18_ENABLE.VALUE=0x00040000 DRIVER.ADC.VAR.ADC2_GROUP0_PIN8_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN11_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN11_ENABLE.VALUE=0x00000800 DRIVER.ADC.VAR.ADC1_BND.VALUE=2 DRIVER.ADC.VAR.ADC2_GROUP0_PIN1_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN31_ENABLE.VALUE=0x00000000 @@ -7139,12 +7139,12 @@ DRIVER.ADC.VAR.ADC1_GROUP1_DISCHARGE_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP1_SAMPLE_PRESCALER.VALUE=1 DRIVER.ADC.VAR.ADC2_PORT_BIT0_PULDIS.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP2_PIN5_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN8_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_ID_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN8_ENABLE.VALUE=0x00000100 +DRIVER.ADC.VAR.ADC1_GROUP1_ID_ENABLE.VALUE=0x00000020 DRIVER.ADC.VAR.ADC1_GROUP1_EXTENDED_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC1_GROUP0_CONVERSION_TIME.VALUE=1.300 DRIVER.ADC.VAR.ADC2_GROUP0_RESOLUTION.VALUE=12_BIT -DRIVER.ADC.VAR.ADC1_GROUP1_PIN1_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN1_ENABLE.VALUE=0x00000002 DRIVER.ADC.VAR.ADC1_GROUP1_RESOLUTION.VALUE=12_BIT DRIVER.ADC.VAR.ADC2_GROUP1_TRIGGER_EDGE_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP0_CONVERSION_TIME.VALUE=1.300 @@ -7179,8 +7179,8 @@ DRIVER.ADC.VAR.ADC1_GROUP2_PIN2_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN20_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN12_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN10_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN24_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN16_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN24_ENABLE.VALUE=0x01000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN16_ENABLE.VALUE=0x00010000 DRIVER.ADC.VAR.ADC1_GROUP1_ACTUAL_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC2_GROUP0_PIN6_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN28_ENABLE.VALUE=0x00000000 @@ -7197,11 +7197,11 @@ DRIVER.ADC.VAR.ADC2_GROUP0_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC2_GROUP0_SAMPLE_PRESCALER.VALUE=1 DRIVER.ADC.VAR.ADC1_GROUP0_DISCHARGE_PRESCALER.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP2_PIN3_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN6_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN6_ENABLE.VALUE=0x00000040 DRIVER.ADC.VAR.ADC2_RAMBASE.VALUE=0xFF3A0000 DRIVER.ADC.VAR.ADC2_GROUP0_BND.VALUE=8 DRIVER.ADC.VAR.ADC1_PORT_BIT0_DOUT.VALUE=1 -DRIVER.ADC.VAR.ADC1_GROUP1_SCAN_TIME.VALUE=0.000 +DRIVER.ADC.VAR.ADC1_GROUP1_SCAN_TIME.VALUE=1550.000 DRIVER.ADC.VAR.ADC1_GROUP0_RESOLUTION.VALUE=12_BIT DRIVER.ADC.VAR.ADC2_GROUP2_FIFO_SIZE.VALUE=16 DRIVER.ADC.VAR.ADC2_GROUP1_PIN7_ENABLE.VALUE=0x00000000 @@ -7226,12 +7226,12 @@ DRIVER.ADC.VAR.ADC2_GROUP2_PIN23_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN15_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN0_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_CONTINUOUS_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN29_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN29_ENABLE.VALUE=0x20000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN10_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP1_PINS.VALUE=0 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN30_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN22_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN14_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN30_ENABLE.VALUE=0x40000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN22_ENABLE.VALUE=0x00400000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN14_ENABLE.VALUE=0x00004000 DRIVER.ADC.VAR.ADC2_GROUP0_PIN4_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN26_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN18_ENABLE.VALUE=0x00000000 @@ -7240,7 +7240,7 @@ DRIVER.ADC.VAR.ADC2_GROUP2_TRIGGER_EDGE_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN11_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN1_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_FIFO_SIZE.VALUE=16 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN4_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN4_ENABLE.VALUE=0x00000010 DRIVER.ADC.VAR.ADC1_RAMBASE.VALUE=0xFF3E0000 DRIVER.ADC.VAR.ADC1_BASE.VALUE=0xFFF7C000 DRIVER.ADC.VAR.ADC1_PORT_BIT0_DIR.VALUE=0 @@ -7248,8 +7248,8 @@ DRIVER.ADC.VAR.ADC2_RAM_PARITY_ENA.VALUE=0x0000000A DRIVER.ADC.VAR.ADC2_GROUP2_HW_TRIGGER_SOURCE.VALUE=GIOB1 DRIVER.ADC.VAR.ADC2_GROUP2_ID_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP1_ACTUAL_SAMPLE_TIME.VALUE=300.00 -DRIVER.ADC.VAR.ADC1_GROUP2_LENGTH.VALUE=32 -DRIVER.ADC.VAR.ADC1_GROUP0_BND.VALUE=8 +DRIVER.ADC.VAR.ADC1_GROUP2_LENGTH.VALUE=0 +DRIVER.ADC.VAR.ADC1_GROUP0_BND.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP0_PIN19_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_CHANNEL_TOTAL_TIME.VALUE=0.000000 DRIVER.ADC.VAR.ADC2_GROUP2_CONTINUOUS_ENABLE.VALUE=0x00000000 @@ -7272,19 +7272,19 @@ DRIVER.ADC.VAR.ADC1_GROUP2_PIN5_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN31_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN23_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN15_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_BND.VALUE=8 +DRIVER.ADC.VAR.ADC1_GROUP1_BND.VALUE=32 DRIVER.ADC.VAR.ADC2_GROUP2_PIN21_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN13_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN27_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN19_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN27_ENABLE.VALUE=0x08000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN19_ENABLE.VALUE=0x00080000 DRIVER.ADC.VAR.ADC2_PORT_BIT0_DOUT.VALUE=1 DRIVER.ADC.VAR.ADC2_CYCLE_TIME.VALUE=100.00 DRIVER.ADC.VAR.ADC1_GROUP1_HW_TRIGGER_SOURCE.VALUE=GIOB0 DRIVER.ADC.VAR.ADC1_GROUP1_DISCHARGE_PRESCALER.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP0_PIN9_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_PRESCALE.VALUE=9 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN20_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN12_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN20_ENABLE.VALUE=0x00100000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN12_ENABLE.VALUE=0x00001000 DRIVER.ADC.VAR.ADC1_GROUP0_RAM_PARITY_ENA.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP0_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC2_BASE.VALUE=0xFFF7C200 @@ -7294,18 +7294,18 @@ DRIVER.ADC.VAR.ADC1_GROUP2_PIN24_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN16_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_ID_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN6_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN9_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN9_ENABLE.VALUE=0x00000200 DRIVER.ADC.VAR.ADC1_GROUP1_CONTINUOUS_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_PORT_BIT0_PDR.VALUE=1 DRIVER.ADC.VAR.ADC1_GROUP1_SAMPLE_TIME.VALUE=300.00 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN2_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN2_ENABLE.VALUE=0x00000004 DRIVER.ADC.VAR.ADC1_GROUP1_CONVERSION_TIME.VALUE=1.300 DRIVER.ADC.VAR.ADC1_GROUP0_FIFO_SIZE.VALUE=16 DRIVER.ADC.VAR.ADC1_PORT_BIT0_PULL.VALUE=2 -DRIVER.ADC.VAR.ADC1_GROUP0_LENGTH.VALUE=16 +DRIVER.ADC.VAR.ADC1_GROUP0_LENGTH.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP0_PIN17_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP1_CONVERSION_TIME.VALUE=1.300 -DRIVER.ADC.VAR.ADC1_GROUP0_PINS.VALUE=1 +DRIVER.ADC.VAR.ADC1_GROUP0_PINS.VALUE=0 DRIVER.ADC.VAR.ADC1_GROUP0_ACTUAL_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC2_GROUP1_PIN3_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP0_PIN10_ENABLE.VALUE=0x00000000 @@ -7313,7 +7313,7 @@ DRIVER.ADC.VAR.ADC2_GROUP0_ID_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN6_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_SCAN_TIME.VALUE=0.000 DRIVER.ADC.VAR.ADC2_GROUP1_HW_TRIGGER_SOURCE.VALUE=GIOB1 -DRIVER.ADC.VAR.ADC1_GROUP1_CHANNEL_TOTAL_TIME.VALUE=1.600000 +DRIVER.ADC.VAR.ADC1_GROUP1_CHANNEL_TOTAL_TIME.VALUE=52.750000 DRIVER.ADC.VAR.ADC1_GROUP0_EXTENDED_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC1_GROUP0_HW_TRIGGER_SOURCE_ALT.VALUE=EVENT DRIVER.ADC.VAR.ADC2_GROUP1_PIN22_ENABLE.VALUE=0x00000000 @@ -7331,12 +7331,12 @@ DRIVER.ADC.VAR.ADC2_GROUP0_ACTUAL_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC1_GROUP2_HW_TRIGGER_SOURCE_ALT.VALUE=EVENT DRIVER.ADC.VAR.ADC2_GROUP2_PIN11_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP1_CONTINUOUS_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN25_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN17_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN25_ENABLE.VALUE=0x02000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN17_ENABLE.VALUE=0x00020000 DRIVER.ADC.VAR.ADC2_GROUP1_ACTUAL_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC2_GROUP0_PIN7_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN29_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN10_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN10_ENABLE.VALUE=0x00000400 DRIVER.ADC.VAR.ADC2_GROUP2_ACTUAL_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC2_GROUP0_PIN0_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN30_ENABLE.VALUE=0x00000000 @@ -7345,14 +7345,14 @@ DRIVER.ADC.VAR.ADC1_GROUP2_PIN14_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_CYCLE_TIME.VALUE=100.00 DRIVER.ADC.VAR.ADC2_GROUP0_DISCHARGE_PRESCALER.VALUE=0 DRIVER.ADC.VAR.ADC2_GROUP2_PIN4_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN7_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN7_ENABLE.VALUE=0x00000080 DRIVER.ADC.VAR.ADC1_GROUP2_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC1_GROUP0_HW_TRIGGER_SOURCE.VALUE=GIOB0 DRIVER.ADC.VAR.ADC1_GROUP1_PIN0_ENABLE.VALUE=0x00000001 DRIVER.ADC.VAR.ADC1_GROUP0_ID_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_DISCHARGE_TIME.VALUE=0.00 DRIVER.ADC.VAR.ADC1_GROUP2_SCAN_TIME.VALUE=0.000 -DRIVER.ADC.VAR.ADC1_GROUP1_PINS.VALUE=1 +DRIVER.ADC.VAR.ADC1_GROUP1_PINS.VALUE=32 DRIVER.ADC.VAR.ADC1_GROUP1_TRIGGER_EDGE_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_ALT_TRIG_COMP.VALUE=1 DRIVER.ADC.VAR.ADC1_GROUP0_CONTINUOUS_ENABLE.VALUE=0x00000000 @@ -7377,9 +7377,9 @@ DRIVER.ADC.VAR.ADC2_GROUP2_PIN16_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN1_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN11_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP0_SCAN_TIME.VALUE=0.000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN31_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN23_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN15_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN31_ENABLE.VALUE=0x80000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN23_ENABLE.VALUE=0x00800000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN15_ENABLE.VALUE=0x00008000 DRIVER.ADC.VAR.ADC2_GROUP0_HW_TRIGGER_SOURCE.VALUE=GIOB1 DRIVER.ADC.VAR.ADC2_GROUP0_PIN5_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP2_PIN27_ENABLE.VALUE=0x00000000 @@ -7396,7 +7396,7 @@ DRIVER.ADC.VAR.ADC2_GROUP2_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC2_GROUP1_CHANNEL_TOTAL_TIME.VALUE=0.000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN2_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP0_CONTINUOUS_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN5_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN5_ENABLE.VALUE=0x00000020 DRIVER.ADC.VAR.ADC1_GROUP2_ACTUAL_SAMPLE_TIME.VALUE=300.00 DRIVER.ADC.VAR.ADC1_GROUP0_SCAN_TIME.VALUE=0.000 DRIVER.ADC.VAR.ADC2_GROUP1_PIN6_ENABLE.VALUE=0x00000000 @@ -7414,7 +7414,7 @@ DRIVER.ADC.VAR.ADC1_GROUP0_PIN24_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_PIN16_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN22_ENABLE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC2_GROUP2_PIN14_ENABLE.VALUE=0x00000000 -DRIVER.ADC.VAR.ADC1_GROUP1_PIN28_ENABLE.VALUE=0x00000000 +DRIVER.ADC.VAR.ADC1_GROUP1_PIN28_ENABLE.VALUE=0x10000000 DRIVER.ADC.VAR.ADC1_GROUP1_TRIGGER_MODE.VALUE=0x00000000 DRIVER.ADC.VAR.ADC1_GROUP0_ACTUAL_DISCHARGE_TIME.VALUE=0.00 DRIVER.LIN.VAR.LIN2_PORT_BIT1_PDR.VALUE=0 @@ -7692,7 +7692,7 @@ DRIVER.HET.VAR.HET2_LR_ACTUALTIME.VALUE=1280.000 DRIVER.HET.VAR.HET1_PWM5_DUTYTIME.VALUE=500.480 DRIVER.HET.VAR.HET2_PWM5_PERIOD_LVL.VALUE=0x00000000 DRIVER.HET.VAR.HET2_PWM4_DUTY_PRESCALER.VALUE=50176 -DRIVER.HET.VAR.HET2_BIT9_DIR.VALUE=0x00000000 +DRIVER.HET.VAR.HET2_BIT9_DIR.VALUE=0x00000200 DRIVER.HET.VAR.HET1_PWM3_DUTY_LVL.VALUE=0x00000000 DRIVER.HET.VAR.HET2_PWM0_DUTY_INTENA.VALUE=0x00000000 DRIVER.HET.VAR.HET1_BIT5_PULDIS.VALUE=0x00000000 @@ -7703,7 +7703,7 @@ DRIVER.HET.VAR.HET2_BIT13_PSL.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BIT12_DOUT.VALUE=0 DRIVER.HET.VAR.HET2_EDGE7_BOTH.VALUE=0 DRIVER.HET.VAR.HET2_BIT25_DIR.VALUE=0x00000000 -DRIVER.HET.VAR.HET2_BIT17_DIR.VALUE=0x00000000 +DRIVER.HET.VAR.HET2_BIT17_DIR.VALUE=0x00020000 DRIVER.HET.VAR.HET1_PWM6_DUTY_INTENA.VALUE=0x00000000 DRIVER.HET.VAR.HET1_PWM0_ENA.VALUE=0 DRIVER.HET.VAR.HET1_BIT30_XORSHARE.VALUE=0x00000000 @@ -7931,7 +7931,7 @@ DRIVER.HET.VAR.HET1_INT_X29.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BIT30_DOUT.VALUE=0 DRIVER.HET.VAR.HET2_BIT25_PSL.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BIT22_DOUT.VALUE=0 -DRIVER.HET.VAR.HET2_BIT17_PSL.VALUE=0x00000000 +DRIVER.HET.VAR.HET2_BIT17_PSL.VALUE=0x00020000 DRIVER.HET.VAR.HET2_BIT14_DOUT.VALUE=0 DRIVER.HET.VAR.HET1_PWM3_PERIOD.VALUE=1000.000 DRIVER.HET.VAR.HET2_PWM5_DUTY_PRESCALER.VALUE=50176 @@ -8143,7 +8143,7 @@ DRIVER.HET.VAR.HET1_INT_X7.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BASE_PORT.VALUE=0xFFF7B94C DRIVER.HET.VAR.HET1_INT_X8.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BIT25_PULDIS.VALUE=0x00000000 -DRIVER.HET.VAR.HET2_BIT17_PULDIS.VALUE=0x00000000 +DRIVER.HET.VAR.HET2_BIT17_PULDIS.VALUE=0x00020000 DRIVER.HET.VAR.HET2_BIT2_ANDSHARE.VALUE=0x00000000 DRIVER.HET.VAR.HET1_PWM6_POLARITY.VALUE=3 DRIVER.HET.VAR.HET1_BIT30_HRSHARE.VALUE=0x00008000 @@ -8197,7 +8197,7 @@ DRIVER.HET.VAR.HET2_BIT22_PULL.VALUE=1 DRIVER.HET.VAR.HET2_BIT14_PULL.VALUE=1 DRIVER.HET.VAR.HET1_EDGE7_INTENA.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BIT25_DOUT.VALUE=0 -DRIVER.HET.VAR.HET2_BIT17_DOUT.VALUE=0 +DRIVER.HET.VAR.HET2_BIT17_DOUT.VALUE=1 DRIVER.HET.VAR.HET1_EDGE2_PIN_SELECT.VALUE=13 DRIVER.HET.VAR.HET1_BIT20_PSL.VALUE=0x00000000 DRIVER.HET.VAR.HET1_BIT12_PSL.VALUE=0x00000000 @@ -8468,7 +8468,7 @@ DRIVER.HET.VAR.HET2_HR_FREQUENCY.VALUE=100.000 DRIVER.HET.VAR.HET2_BIT30_DIR.VALUE=0x00000000 DRIVER.HET.VAR.HET2_BIT25_PULL.VALUE=1 DRIVER.HET.VAR.HET2_BIT22_DIR.VALUE=0x00000000 -DRIVER.HET.VAR.HET2_BIT17_PULL.VALUE=1 +DRIVER.HET.VAR.HET2_BIT17_PULL.VALUE=0 DRIVER.HET.VAR.HET2_BIT14_DIR.VALUE=0x00000000 DRIVER.HET.VAR.HET1_PWM5_PERIOD_PRESCALER.VALUE=99968 DRIVER.HET.VAR.HET2_EDGE4_POLARITY.VALUE=0 @@ -8767,7 +8767,7 @@ DRIVER.I2C.VAR.I2C2_ICXRDYINTLVL.VALUE=0 DRIVER.I2C.VAR.I2C2_MODCLK.VALUE=8 DRIVER.I2C.VAR.I2C2_PORT_BIT1_PULL.VALUE=2 DRIVER.I2C.VAR.I2C2_PORT_BIT0_DIR.VALUE=0 -DRIVER.I2C.VAR.I2C1_ALINTENA.VALUE=1 +DRIVER.I2C.VAR.I2C1_ALINTENA.VALUE=0 DRIVER.I2C.VAR.I2C1_PRESCALE.VALUE=12 DRIVER.I2C.VAR.I2C2_ARDYINTENA.VALUE=1 DRIVER.I2C.VAR.I2C2_PORT_BIT1_DIR.VALUE=0 @@ -8783,9 +8783,9 @@ DRIVER.I2C.VAR.I2C2_PORT_BIT1_PDR.VALUE=1 DRIVER.I2C.VAR.I2C2_STPCND.VALUE=1 DRIVER.I2C.VAR.I2C1_ALINTLVL.VALUE=0 DRIVER.I2C.VAR.I2C2_PORT_BIT0_PSL.VALUE=1 -DRIVER.I2C.VAR.I2C1_ARDYINTENA.VALUE=1 +DRIVER.I2C.VAR.I2C1_ARDYINTENA.VALUE=0 DRIVER.I2C.VAR.I2C2_ARDYINTLVL.VALUE=0 -DRIVER.I2C.VAR.I2C1_ICRRDYINTENA.VALUE=1 +DRIVER.I2C.VAR.I2C1_ICRRDYINTENA.VALUE=0 DRIVER.I2C.VAR.I2C2_BASE_PORT.VALUE=0xFFF7D54C DRIVER.I2C.VAR.I2C1_PORT_BIT1_PULDIS.VALUE=0 DRIVER.I2C.VAR.I2C2_PORT_BIT1_PSL.VALUE=1 @@ -8804,12 +8804,12 @@ DRIVER.I2C.VAR.I2C1_PARITYENA.VALUE=0 DRIVER.I2C.VAR.I2C1_BASE.VALUE=0xFFF7D400 DRIVER.I2C.VAR.I2C1_PORT_BIT1_DIR.VALUE=0 DRIVER.I2C.VAR.I2C1_PORT_BIT1_DOUT.VALUE=1 -DRIVER.I2C.VAR.I2C1_ICXRDYINTENA.VALUE=1 +DRIVER.I2C.VAR.I2C1_ICXRDYINTENA.VALUE=0 DRIVER.I2C.VAR.I2C1_PORT_BIT0_FUN.VALUE=0 -DRIVER.I2C.VAR.I2C1_NACKINTENA.VALUE=1 +DRIVER.I2C.VAR.I2C1_NACKINTENA.VALUE=0 DRIVER.I2C.VAR.I2C2_NACKINTLVL.VALUE=0 DRIVER.I2C.VAR.I2C2_BAUDRATE.VALUE=400 -DRIVER.I2C.VAR.I2C1_AAS.VALUE=1 +DRIVER.I2C.VAR.I2C1_AAS.VALUE=0 DRIVER.I2C.VAR.I2C1_BCM.VALUE=1 DRIVER.I2C.VAR.I2C1_PORT_BIT0_PDR.VALUE=1 DRIVER.I2C.VAR.I2C2_MSMODE.VALUE=1 @@ -8842,7 +8842,7 @@ DRIVER.I2C.VAR.I2C2_ICCH.VALUE=5 DRIVER.I2C.VAR.I2C1_NACKINTLVL.VALUE=0 DRIVER.I2C.VAR.I2C2_ICCL.VALUE=5 DRIVER.I2C.VAR.I2C2_PORT_BIT1_DOUT.VALUE=1 -DRIVER.I2C.VAR.I2C1_SCD.VALUE=1 +DRIVER.I2C.VAR.I2C1_SCD.VALUE=0 DRIVER.I2C.VAR.I2C1_TXDMA.VALUE=0 DRIVER.I2C.VAR.I2C2_LENGTH.VALUE=8 DRIVER.I2C.VAR.I2C1_EVENPARITY.VALUE=0 @@ -9001,7 +9001,7 @@ 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.PINMUX23.VALUE="PINMUX_BALL_V5_MIBSPI3NCS_1 | PINMUX_BALL_B2_MIBSPI3NCS_2 | PINMUX_BALL_C3_MIBSPI3NCS_3 | PINMUX_BALL_W9_MIBSPI3NCS_5" +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" DRIVER.PINMUX.VAR.PINMUX24.VALUE="PINMUX_BALL_W8_MIBSPI3SIMO | PINMUX_BALL_V8_MIBSPI3SOMI | PINMUX_BALL_H19_MIBSPI5CLK | PINMUX_BALL_E19_MIBSPI5NCS_0" @@ -9236,7 +9236,7 @@ DRIVER.PINMUX.VAR.SIGNAL14_SELECT.VALUE=0 DRIVER.PINMUX.VAR.MUX129_OPTION3.VALUE=0 DRIVER.PINMUX.VAR.MUX129_OPTION4.VALUE=0 DRIVER.PINMUX.VAR.MUX129_OPTION5.VALUE=0 -DRIVER.PINMUX.VAR.I2C1.VALUE=0 +DRIVER.PINMUX.VAR.I2C1.VALUE=1 DRIVER.PINMUX.VAR.I2C2.VALUE=0 DRIVER.PINMUX.VAR.SIGNAL55_OPTION0.VALUE=1 DRIVER.PINMUX.VAR.SIGNAL47_OPTION0.VALUE=1 @@ -9534,13 +9534,13 @@ DRIVER.PINMUX.VAR.MUX73_OPTION4.VALUE=0 DRIVER.PINMUX.VAR.MUX65_OPTION4.VALUE=0 DRIVER.PINMUX.VAR.MUX57_OPTION4.VALUE=0 DRIVER.PINMUX.VAR.MUX49_OPTION4.VALUE=0 -DRIVER.PINMUX.VAR.MUX4_OPTION0.VALUE=1 +DRIVER.PINMUX.VAR.MUX4_OPTION0.VALUE=0 DRIVER.PINMUX.VAR.MUX81_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX73_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX65_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX57_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.MUX49_OPTION5.VALUE=0 -DRIVER.PINMUX.VAR.MUX4_OPTION1.VALUE=0 +DRIVER.PINMUX.VAR.MUX4_OPTION1.VALUE=1 DRIVER.PINMUX.VAR.GIOB4_DMA_SELECT.VALUE=OFF DRIVER.PINMUX.VAR.GIOA6_DMA_SELECT.VALUE=OFF DRIVER.PINMUX.VAR.ECAP.VALUE=0 @@ -9762,13 +9762,13 @@ DRIVER.PINMUX.VAR.EMIF.VALUE=0 DRIVER.PINMUX.VAR.MUX41_OPTION0.VALUE=0 DRIVER.PINMUX.VAR.MUX33_OPTION0.VALUE=0 DRIVER.PINMUX.VAR.MUX25_OPTION0.VALUE=0 -DRIVER.PINMUX.VAR.MUX17_OPTION0.VALUE=1 +DRIVER.PINMUX.VAR.MUX17_OPTION0.VALUE=0 DRIVER.PINMUX.VAR.MUX3_OPTION4.VALUE=0 DRIVER.PINMUX.VAR.ETPWM_TZ1.VALUE=ASYNC DRIVER.PINMUX.VAR.MUX41_OPTION1.VALUE=0 DRIVER.PINMUX.VAR.MUX33_OPTION1.VALUE=0 DRIVER.PINMUX.VAR.MUX25_OPTION1.VALUE=0 -DRIVER.PINMUX.VAR.MUX17_OPTION1.VALUE=0 +DRIVER.PINMUX.VAR.MUX17_OPTION1.VALUE=1 DRIVER.PINMUX.VAR.MUX3_OPTION5.VALUE=0 DRIVER.PINMUX.VAR.ETPWM_TZ2.VALUE=ASYNC DRIVER.PINMUX.VAR.MUX41_OPTION2.VALUE=0 @@ -9782,7 +9782,7 @@ DRIVER.PINMUX.VAR.MUX16_CONFLICT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_95_SELECT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_87_SELECT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_79_SELECT.VALUE=0 -DRIVER.PINMUX.VAR.PIN_MUX_4_SELECT.VALUE=0 +DRIVER.PINMUX.VAR.PIN_MUX_4_SELECT.VALUE=1 DRIVER.PINMUX.VAR.ETPWM_TZ3.VALUE=ASYNC DRIVER.PINMUX.VAR.MUX41_OPTION3.VALUE=0 DRIVER.PINMUX.VAR.MUX33_OPTION3.VALUE=0 @@ -9819,7 +9819,7 @@ DRIVER.PINMUX.VAR.SIGNAL38_SELECT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_41_SELECT.VALUE=0 DRIVER.PINMUX.VAR.PIN_MUX_33_SELECT.VALUE=4 DRIVER.PINMUX.VAR.PIN_MUX_25_SELECT.VALUE=0 -DRIVER.PINMUX.VAR.PIN_MUX_17_SELECT.VALUE=0 +DRIVER.PINMUX.VAR.PIN_MUX_17_SELECT.VALUE=1 DRIVER.PINMUX.VAR.GIOB5_DMA.VALUE=0 DRIVER.PINMUX.VAR.GIOA7_DMA.VALUE=0 DRIVER.PINMUX.VAR.MUX10_OPTION3.VALUE=0 @@ -10832,7 +10832,7 @@ DRIVER.ETPWM.VAR.ETPWM6_RDELAY_SOURCE.VALUE=0 DRIVER.ETPWM.VAR.ETPWM6_PWMA_DUTYTIME.VALUE=500.000 DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_DUTY_NEW.VALUE=50.0 DRIVER.ETPWM.VAR.ETPWM7_SOCB_PERIOD.VALUE=1 -DRIVER.ETPWM.VAR.ETPWM1_OSHT_ACTUAL_WIDTH.VALUE=100 +DRIVER.ETPWM.VAR.ETPWM1_OSHT_ACTUAL_WIDTH.VALUE=80.000 DRIVER.ETPWM.VAR.ETPWM7_PWMB_FALLING_EDGE_DELAY_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM6_PWMB_COMPARE.VALUE=50 DRIVER.ETPWM.VAR.ETPWM2_PWMB_POLARITY.VALUE=0 @@ -10845,10 +10845,10 @@ DRIVER.ETPWM.VAR.ETPWM4_ENABLE_SOCB.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM1_OSHT4.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_OSHT_WIDTH_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM1_OSHT5.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_PERIOD_REG.VALUE=1000 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_PERIOD_REG.VALUE=4999 DRIVER.ETPWM.VAR.ETPWM1_OSHT6.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_PERIOD.VALUE=100.000 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_PERIOD.VALUE=1000.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_PERIOD.VALUE=50000 DRIVER.ETPWM.VAR.ETPWM2_CBC.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM4_CLKDIV.VALUE=0 DRIVER.ETPWM.VAR.ETPWM2_PWMB_ENA.VALUE=1 @@ -10895,7 +10895,7 @@ DRIVER.ETPWM.VAR.ETPWM3_CHOPPER_PERIOD_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM3_PWMA_DEADBAND_INVERT.VALUE=0 DRIVER.ETPWM.VAR.ETPWM6_PWMB_PERIOD_REG.VALUE=1000.000 DRIVER.ETPWM.VAR.ETPWM5_DCBEVT1.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_OSHT_WIDTH_REG.VALUE=1 +DRIVER.ETPWM.VAR.ETPWM1_OSHT_WIDTH_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM1_PWMA_DUTY.VALUE=50 DRIVER.ETPWM.VAR.ETPWM5_DCBEVT2.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM2_PWMA_ACTUALPERIOD.VALUE=1000.000 @@ -10923,7 +10923,7 @@ DRIVER.ETPWM.VAR.ETPWM6_PWMA_COMPARE.VALUE=50 DRIVER.ETPWM.VAR.ETPWM5_PWMB_ENA.VALUE=1 DRIVER.ETPWM.VAR.ETPWM6_CHOPPER_PERIOD.VALUE=100.000 DRIVER.ETPWM.VAR.ETPWM6_CHOPPER_DUTYTIME.VALUE=50.000 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_FALLING_EDGE_DELAY.VALUE=9.091 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_FALLING_EDGE_DELAY.VALUE=0.000 DRIVER.ETPWM.VAR.ETPWM3_SELECT_EVENT.VALUE=NO_EVENT DRIVER.ETPWM.VAR.ETPWM2_CLKDIV.VALUE=0 DRIVER.ETPWM.VAR.ETPWM6_PWMA_DUTY.VALUE=50 @@ -10991,7 +10991,7 @@ DRIVER.ETPWM.VAR.ETPWM7_OSHT3.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM2_CBC1.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM7_OSHT4.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM2_CBC2.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_HSPCLKDIV.VALUE=0 +DRIVER.ETPWM.VAR.ETPWM1_HSPCLKDIV.VALUE=1 DRIVER.ETPWM.VAR.ETPWM7_OSHT5.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_PWMB_FALLING_EDGE_DELAY_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM2_CBC3.VALUE=0x0000 @@ -11002,8 +11002,8 @@ DRIVER.ETPWM.VAR.ETPWM7_OSHT6.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM2_SOCA_PERIOD.VALUE=1 DRIVER.ETPWM.VAR.ETPWM2_CBC4.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM1_OST.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_ACTUALPERIOD.VALUE=100.000 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_ACTUALPERIOD.VALUE=1000.000 +DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_ACTUALPERIOD.VALUE=80.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_ACTUALPERIOD.VALUE=50000.000 DRIVER.ETPWM.VAR.ETPWM7_PWMB_DUTYTIME.VALUE=500.000 DRIVER.ETPWM.VAR.ETPWM3_FDELAY_SOURCE.VALUE=0 DRIVER.ETPWM.VAR.ETPWM2_CBC5.VALUE=0x0000 @@ -11085,7 +11085,7 @@ DRIVER.ETPWM.VAR.ETPWM3_OSHT5.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM3_HSPCLKDIV_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM4_PWMA_DEADBAND_OUT.VALUE=0 DRIVER.ETPWM.VAR.ETPWM3_OSHT6.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_TB_ACTUALFREQUENCY.VALUE=80.000 +DRIVER.ETPWM.VAR.ETPWM1_TB_ACTUALFREQUENCY.VALUE=100.000 DRIVER.ETPWM.VAR.ETPWM5_CLKDIV.VALUE=0 DRIVER.ETPWM.VAR.ETPWM7_PWMA_COMPARE.VALUE=50 DRIVER.ETPWM.VAR.ETPWM6_PWMB_POLARITY.VALUE=0 @@ -11095,7 +11095,7 @@ DRIVER.ETPWM.VAR.ETPWM4_PWMB_DUTYTIME.VALUE=500.000 DRIVER.ETPWM.VAR.ETPWM7_OSHT_WIDTH_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM2_CHOPPER_PERIOD_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM2_PWMA_PERIOD_REG.VALUE=1000 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_COMPARE.VALUE=50 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_COMPARE.VALUE=2500 DRIVER.ETPWM.VAR.ETPWM1_CLKDIV_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM3_CHOPPER_PERIOD.VALUE=100.000 DRIVER.ETPWM.VAR.ETPWM7_PWMB_FALLING_EDGE_DELAY.VALUE=9.091 @@ -11107,12 +11107,12 @@ DRIVER.ETPWM.VAR.ETPWM2_DCAEVT1.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM4_INTERRUPT_PERIOD.VALUE=1 DRIVER.ETPWM.VAR.ETPWM2_DCAEVT2.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM4_CBC1.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_RISING_EDGE_DELAY.VALUE=9.091 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_RISING_EDGE_DELAY.VALUE=0.000 DRIVER.ETPWM.VAR.ETPWM4_CBC2.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM7_PWMA_ENA.VALUE=1 DRIVER.ETPWM.VAR.ETPWM4_CBC3.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM2_CHOPPER_MODE.VALUE=0 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_FALLING_EDGE_DELAY_REG.VALUE=1 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_FALLING_EDGE_DELAY_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM7_PWMA_PERIOD.VALUE=1000.000 DRIVER.ETPWM.VAR.ETPWM5_OST.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM4_CBC4.VALUE=0x0000 @@ -11129,10 +11129,10 @@ DRIVER.ETPWM.VAR.ETPWM2_CHOPPER_DUTYTIME.VALUE=50.000 DRIVER.ETPWM.VAR.ETPWM2_RDELAY_SOURCE.VALUE=0 DRIVER.ETPWM.VAR.ETPWM2_PWMB_RISING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM2_PWMA_DUTYTIME.VALUE=500.000 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_FALLING_EDGE_DELAY.VALUE=9.091 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_FALLING_EDGE_DELAY.VALUE=0.000 DRIVER.ETPWM.VAR.ETPWM4_HSPCLKDIV.VALUE=0 DRIVER.ETPWM.VAR.ETPWM4_PWMA_COMPARE.VALUE=50 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_FALLING_EDGE_DELAY_REG.VALUE=1 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_FALLING_EDGE_DELAY_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM1_PWMB_DEADBAND_INVERT.VALUE=0 DRIVER.ETPWM.VAR.ETPWM7_PWMA_RISING_EDGE_DELAY_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM2_DCBEVT1.VALUE=0x0000 @@ -11159,16 +11159,16 @@ DRIVER.ETPWM.VAR.ETPWM7_PWMA_DUTY.VALUE=50 DRIVER.ETPWM.VAR.ETPWM3_PWMB_FALLING_EDGE_DELAY_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM6_DEADBAND_OUTPUT.VALUE=PWMA_PWMB_NIL DRIVER.ETPWM.VAR.ETPWM3_INTERRUPT_PERIOD.VALUE=1 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_PERIOD.VALUE=1000.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_PERIOD.VALUE=50000 DRIVER.ETPWM.VAR.ETPWM7_RDELAY_SOURCE.VALUE=0 DRIVER.ETPWM.VAR.ETPWM7_PWMA_DUTYTIME.VALUE=500.000 -DRIVER.ETPWM.VAR.ETPWM1_TB_FREQUENCY.VALUE=110.000 +DRIVER.ETPWM.VAR.ETPWM1_TB_FREQUENCY.VALUE=100000 DRIVER.ETPWM.VAR.ETPWM3_CLKDIV.VALUE=0 DRIVER.ETPWM.VAR.ETPWM2_PWMA_DEADBAND_INVERT.VALUE=0 DRIVER.ETPWM.VAR.ETPWM7_CHOPPER_PERIOD_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM6_CLKDIV_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM4_SOCA_PERIOD.VALUE=1 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_ACTUALPERIOD.VALUE=1000.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_ACTUALPERIOD.VALUE=50000.000 DRIVER.ETPWM.VAR.ETPWM5_CBC1.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_PWMB_RISING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM5_CBC2.VALUE=0x0000 @@ -11177,12 +11177,12 @@ DRIVER.ETPWM.VAR.ETPWM2_OSHT_WIDTH.VALUE=100 DRIVER.ETPWM.VAR.ETPWM5_CBC3.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_CHOPPER_DUTY_NEW.VALUE=50.0 DRIVER.ETPWM.VAR.ETPWM3_PWMB_POLARITY.VALUE=0 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_COMPARE.VALUE=50 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_COMPARE.VALUE=2500 DRIVER.ETPWM.VAR.ETPWM7_OST.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_CBC4.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_CBC5.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_DUTYTIME.VALUE=50.000 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_DUTYTIME.VALUE=500.000 +DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_DUTYTIME.VALUE=40.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_DUTYTIME.VALUE=25000.000 DRIVER.ETPWM.VAR.ETPWM6_PWMA_DEADBAND_INVERT.VALUE=0 DRIVER.ETPWM.VAR.ETPWM5_CBC6.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM3_OSHT_ACTUAL_WIDTH.VALUE=100 @@ -11195,7 +11195,7 @@ DRIVER.ETPWM.VAR.ETPWM4_BASE.VALUE=0xFCF78F00 DRIVER.ETPWM.VAR.ETPWM3_PWMA_FALLING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM4_OSHT1.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM1_DCAEVT1.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_RISING_EDGE_DELAY_REG.VALUE=1 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_RISING_EDGE_DELAY_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM4_OSHT2.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM1_SOCA_PERIOD.VALUE=1 DRIVER.ETPWM.VAR.ETPWM1_DCAEVT2.VALUE=0x0000 @@ -11203,7 +11203,7 @@ DRIVER.ETPWM.VAR.ETPWM4_OSHT3.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM4_OSHT4.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM5_PWMB_PERIOD_REG.VALUE=1000.000 DRIVER.ETPWM.VAR.ETPWM4_OSHT5.VALUE=0x0000 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_RISING_EDGE_DELAY_REG.VALUE=1 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_RISING_EDGE_DELAY_REG.VALUE=0 DRIVER.ETPWM.VAR.ETPWM4_OSHT6.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM7_PWMB_RISING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM5_ENABLE_SOCA.VALUE=0x0000 @@ -11219,7 +11219,7 @@ DRIVER.ETPWM.VAR.ETPWM2_INTERRUPT_PERIOD.VALUE=1 DRIVER.ETPWM.VAR.ETPWM6_PWMB_DUTYTIME.VALUE=500.000 DRIVER.ETPWM.VAR.ETPWM4_PWMA_FALLING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM2_FDELAY_SOURCE.VALUE=0 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_RISING_EDGE_DELAY.VALUE=9.091 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_RISING_EDGE_DELAY.VALUE=0.000 DRIVER.ETPWM.VAR.ETPWM7_PWMB_DUTY.VALUE=50 DRIVER.ETPWM.VAR.ETPWM5_PWMB_COMPARE.VALUE=50 DRIVER.ETPWM.VAR.ETPWM5_PWMA_RISING_EDGE_DELAY_REG.VALUE=1 @@ -11254,7 +11254,7 @@ DRIVER.ETPWM.VAR.ETPWM5_BASE.VALUE=0xFCF79000 DRIVER.ETPWM.VAR.ETPWM3_PWMA_RISING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM7_SELECT_SOCB.VALUE=DCBEVT1 DRIVER.ETPWM.VAR.ETPWM7_OSHT_WIDTH.VALUE=100 -DRIVER.ETPWM.VAR.ETPWM1_CLKDIV.VALUE=0 +DRIVER.ETPWM.VAR.ETPWM1_CLKDIV.VALUE=1 DRIVER.ETPWM.VAR.ETPWM6_CHOPPER_DUTY.VALUE=50 DRIVER.ETPWM.VAR.ETPWM6_PWMA_POLARITY.VALUE=0 DRIVER.ETPWM.VAR.ETPWM3_PWMB_PERIOD_REG.VALUE=1000.000 @@ -11305,7 +11305,7 @@ DRIVER.ETPWM.VAR.ETPWM5_PWMB_POLARITY.VALUE=0 DRIVER.ETPWM.VAR.ETPWM5_PWMA_COMPARE.VALUE=50 DRIVER.ETPWM.VAR.ETPWM3_PWMA_RISING_EDGE_DELAY_REG.VALUE=1 DRIVER.ETPWM.VAR.ETPWM1_CHOPPER_PERIOD_REG.VALUE=0 -DRIVER.ETPWM.VAR.ETPWM1_PWMB_PERIOD_REG.VALUE=1000.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMB_PERIOD_REG.VALUE=4999 DRIVER.ETPWM.VAR.ETPWM7_PWMA_FALLING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM7_PWMA_RISING_EDGE_DELAY.VALUE=9.091 DRIVER.ETPWM.VAR.ETPWM6_BASE.VALUE=0xFCF79100 @@ -11336,7 +11336,7 @@ DRIVER.ETPWM.VAR.ETPWM6_SOCA_PERIOD.VALUE=1 DRIVER.ETPWM.VAR.ETPWM6_DCAEVT2.VALUE=0x0000 DRIVER.ETPWM.VAR.ETPWM4_FDELAY_SOURCE.VALUE=0 DRIVER.ETPWM.VAR.ETPWM1_RDELAY_SOURCE.VALUE=0 -DRIVER.ETPWM.VAR.ETPWM1_PWMA_DUTYTIME.VALUE=500.000 +DRIVER.ETPWM.VAR.ETPWM1_PWMA_DUTYTIME.VALUE=25000.000 DRIVER.ECAP.VAR.ECAP1_PRESCALE_REG.VALUE=0 DRIVER.ECAP.VAR.ECAP2_ENA_PWM.VALUE=0 DRIVER.ECAP.VAR.ECAP4_PRD.VALUE=0x0000 diff --git a/conf/spa/cppcheck-suppression.txt b/conf/spa/cppcheck-suppression.txt index 26b20ddc..aae0a64b 100644 --- a/conf/spa/cppcheck-suppression.txt +++ b/conf/spa/cppcheck-suppression.txt @@ -15,16 +15,16 @@ variableScope knownConditionTrueFalse:*/app/engine/diag/diag.c missingInclude unmatchedSuppression -comparisonError:*/app/driver/mic/ltc/6806/ltc_6806.c -comparisonError:*/app/driver/mic/ltc/6813-1/ltc_6813-1.c +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/mic/ltc/common/ltc_pec.c +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/mic/maxim/common/mxm_17841b.h +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 @@ -40,18 +40,19 @@ 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/mic/maxim/common/mxm_registry.c -misra-c2012-10.6:*/app/driver/mic/maxim/common/mxm_battery_management.c +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.3:*/app/driver/config/spi_cfg.c misra-c2012-18.8:*/app/driver/sbc/nxpfs85xx.c // false positive: -misra-c2012-12.3:*/app/driver/mic/maxim/common/mxm_17841b.c +misra-c2012-12.3:*/app/driver/afe/maxim/common/mxm_17841b.c misra-c2012-12.4:*/app/engine/diag/diag.c misra-c2012-15.5:*/app/application/bal/bal.c misra-c2012-15.5:*/app/application/bal/voltage/bal_strategy_voltage.c @@ -71,22 +72,24 @@ misra-c2012-17.8:*/app/application/algorithm/state_estimation/soc/counting/soc_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-19.2:*/app/driver/mic/nxp/common/MC33775A.h -misra-c2012-20.7:*/app/driver/mic/ltc/6806/ltc_6806.c -misra-c2012-20.7:*/app/driver/mic/ltc/6813-1/ltc_6813-1.c -misra-c2012-20.7:*/app/driver/mic/ltc/common/ltc.h -misra-c2012-20.10:*/app/driver/mic/ltc/6806/ltc_6806.c -misra-c2012-20.10:*/app/driver/mic/ltc/6813-1/ltc_6813-1.c -misra-c2012-20.10:*/app/driver/mic/ltc/common/ltc.h +misra-c2012-18.8:*app/driver/can/can.c:436 +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/bms/bms.c 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/mic/debug/default/debug_default.c:369 +threadsafety-threadsafety:*app/driver/afe/debug/default/debug_default.c:369 // y2038 y2038-unsafe-call:*/app/engine/sys_mon/sys_mon.* @@ -95,9 +98,10 @@ y2038-unsafe-call:*/app/engine/sys_mon/sys_mon.* 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/mic/nxp/common/MC33775A.h +cert-API01-C:*/app/driver/afe/nxp/common/MC33775A.h // 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/unit/project.yml b/conf/unit/project.yml index b59cf466..755da5ca 100644 --- a/conf/unit/project.yml +++ b/conf/unit/project.yml @@ -144,6 +144,7 @@ - Cobertura :abort_on_uncovered: true :uncovered_ignore_list: + - "../../src/app/driver/imd/bender/ir155/bender_ir155.c" - "../../src/app/driver/imd/bender/iso165c/bender_iso165c.c" - "../../src/app/driver/sbc/fs8x_driver/sbc_fs8x.c" - "../../src/app/driver/sbc/fs8x_driver/sbc_fs8x_communication.c" 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 d1589808..fdfa27df 100644 --- a/docs/developer-manual/style-guide/state-machines_how-to.rst +++ b/docs/developer-manual/style-guide/state-machines_how-to.rst @@ -7,9 +7,9 @@ How to Write State Machines =========================== This section demonstrates how state machines are implemented within the -|foxbms| project. A simple, but fully functional, real-world implementation of -this can be found in the debug measurement IC driver -(see :ref:`DEBUG_DEFAULT`). +|foxbms| project. +A simple, but fully functional, real-world implementation of this can be found +in the debug AFE driver (see :ref:`DEBUG_DEFAULT`). The Example ----------- @@ -205,7 +205,7 @@ A state machine always consists of a periodic *trigger* function. The trigger function gets the state variable introduced above (``eg_state`` in this example) as parameter. The trigger function **MUST** use ``Trigger`` as function name infix. This example uses ``EG_Trigger()``. If needed, the name -can be extended (e.g., ``EG_TriggerMeasurementIc()``). +can be extended (e.g., ``EG_TriggerAfe()``). .. code-block:: c :linenos: diff --git a/docs/general/changelog.rst b/docs/general/changelog.rst index afe0732a..ff50d026 100644 --- a/docs/general/changelog.rst +++ b/docs/general/changelog.rst @@ -33,6 +33,69 @@ Versioning follows then these rules: - increasing ``MINOR`` adds functionality in a backwards compatible manner - increasing ``PATCH`` fixes bugs in a backwards compatible manner +******************** +[1.2.0] - 2021-10-21 +******************** + +Added +===== + +- Added stubs for the Bender IR155 insulation monitoring device driver (i.e. + **driver is non-functional**). +- Extended the documentation with a render of the architecture against which + the foxBMS implementation is checked. +- Added driver for I2C communication for MCU. +- Added driver for I2C port expander. +- Added driver for I2C humidity/temperature sensor. +- Implemented feedback through auxiliary contacts for the contactor driver. +- Debug LED is now toggled depending on system state (slow: okay, fast: error) +- Added an option to install a pre-commit hook in the repository. + The pre-commit hook runs the guidelines check (see :ref:`WAF_TOOL_GIT_HOOKS`). +- Added a driver module that allows to use the enhanced PWM features of the MCU. +- Adapted CAN module to receive/transmit messages either via CAN1 or CAN2. +- Annotate maximum stack size in FreeRTOS so that debugger can catch this + information. +- Updated the hardware design files (e.g., schematics, layout, BOM and STEP + file etc.) of the |bms-master| to ``v1.1.1``. +- Added information on citing the project in ``CFF`` format. +- Added driver for interlock. + +Changed +======= + +- The measurement IC (``MIC``) module has been renamed to Analog Front-End + (``AFE``). +- ``build_all`` and ``clean_all`` need to run the Axivion related commands as + last steps. +- The file content of the linker script for the elf file is now hashed using + Unix-style line endings as this is more robust (e.g., downloaded zip files + from GitHub releases). +- Sort the SPI formats so that there are no conflicts between the configuration + on SPI1 and SPI4 (Both are connected to the interface connector). +- Control the pins of the interface for LTC AFEs with the port expander on the + foxBMS 2 master board. +- The documentation build defaults now only to ``html`` and ``spelling``, + .i.e., ``linkcheck`` has been removed. + +Deprecated +========== + +Removed +======= + +- Removed unused code in main build script. + +Fixed +===== + +- Fixed variable name typos in ``moving_average.c``. +- A specific order of build/clean commands related to Axivion build and clean + commands resulted in build errors. + Now the build is early aborted if a wrong order is supplied and a + descriptive error message is printed to stderr. +- The documentation included a wrong statement about how to configure FreeRTOS. +- Battery voltage is now transmitted correctly via CAN (ID: 0x222). + ******************** [1.1.2] - 2021-09-03 ******************** @@ -40,12 +103,12 @@ Versioning follows then these rules: Added ===== -- A basic block diagram and description of a battery system and the voltages +- A basic block diagram and description of a battery system and the voltages. and the currents that need to be measured have been included in the documentation. - Add helper script to run the library test build (``tests/variants/lib-build/lib-build.bat``). -- Updated the Axivion configuration to use version 7.2.3. +- Updated the Axivion configuration to use version ``7.2.3``. - Added minimal documentation for Axivion setup. - Improved the Axivion configuration: @@ -344,7 +407,7 @@ Fixed license is also formally known as *BSD 3-Clause "New" or "Revised" License*. As of this release |foxbms| added the SPDX short identifier to the software sources (``SPDX-License-Identifier: BSD-3-Clause``) according to - `SPDX Specification Version 2.2 `_. + `SPDX Specification Version 2.2 `_. The license text of the `Creative Commons Attribution 4.0 International License `_ has been added to the repository. The SPDX short name of this license is @@ -583,7 +646,6 @@ Removed - Removed the deprecated Anaconda extension from the list of recommended Visual Studio Code plugins that is shipped with the project. -- Suppressed the (uncovered) ADI-driver from the unit-test-report. Fixed ===== diff --git a/docs/general/releases.csv b/docs/general/releases.csv index 1650fb68..aa727237 100644 --- a/docs/general/releases.csv +++ b/docs/general/releases.csv @@ -1,4 +1,5 @@ foxBMS 2; Release Date; Permanent link to documentation +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/ v1.1.1; 2021-08-06; https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/docs/html/v1.1.1/ v1.1.0; 2021-07-29; https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/docs/html/v1.1.0/ diff --git a/docs/general/safety/safety.rst b/docs/general/safety/safety.rst index 9660362d..34dca6c1 100644 --- a/docs/general/safety/safety.rst +++ b/docs/general/safety/safety.rst @@ -37,7 +37,7 @@ users: A list of standards that might fit to the target application can be found here: -- http://www.mpoweruk.com/standards.htm +- https://www.mpoweruk.com/standards.htm Standards diff --git a/docs/getting-started/first-steps-on-hardware.rst b/docs/getting-started/first-steps-on-hardware.rst index 02ddbe16..4e6e908a 100644 --- a/docs/getting-started/first-steps-on-hardware.rst +++ b/docs/getting-started/first-steps-on-hardware.rst @@ -64,5 +64,5 @@ After these steps, it should be possible to halt and re-start the target. The variable ``os_timer`` should show incremented values when halting the target. Central data structures such as ``bms_state``, ``sys_state``, -``cont_contactorStates`` and ``ltc_cellvoltage`` (for -:ref:`MICs ` of the LTC family). +``cont_contactorStates`` and ``ltc_cellVoltage`` (for +:ref:`AFEs ` of the LTC family). diff --git a/docs/getting-started/repository-structure.rst b/docs/getting-started/repository-structure.rst index 3f137f98..187d7539 100644 --- a/docs/getting-started/repository-structure.rst +++ b/docs/getting-started/repository-structure.rst @@ -56,7 +56,7 @@ The ``conf`` directory is structured into the following parts (see | directory | long name | content description | +=================+=============================+======================================+ | ``conf/bms`` | Battery Management System | configuration of the BMS | - | | | (e.g., which measurement IC is used) | + | | | (e.g., which AFE is used) | +-----------------+-----------------------------+--------------------------------------+ | ``conf/cc`` | C compiler | compiler configuration | | | | (e.g., compiler flags) | diff --git a/docs/getting-started/software-installation.rst b/docs/getting-started/software-installation.rst index 6bb921ea..479b6778 100644 --- a/docs/getting-started/software-installation.rst +++ b/docs/getting-started/software-installation.rst @@ -70,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.1.2.zip https://github.com/foxBMS/foxbms-2/archive/v1.1.2.zip - C:\Users\vulpes\Documents>tar -x -f foxbms-2-v1.1.2.zip - C:\Users\vulpes\Documents>ren foxbms-2-1.1.2 foxbms-2 + C:\Users\vulpes\Documents>curl -Ss -L -o foxbms-2-v1.2.0.zip https://github.com/foxBMS/foxbms-2/archive/v1.2.0.zip + C:\Users\vulpes\Documents>tar -x -f foxbms-2-v1.2.0.zip + C:\Users\vulpes\Documents>ren foxbms-2-1.2.0 foxbms-2 C:\Users\vulpes\Documents>cd foxbms-2 .. note:: diff --git a/docs/macros.txt b/docs/macros.txt index 6cad2608..5bfdb169 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.1.2`` +.. |version_foxbms| replace:: ``1.2.0`` .. |github_foxbms| replace:: https://github.com/foxBMS/ .. |foxbms_repository| replace:: https://github.com/foxBMS/foxbms-2 .. _Fraunhofer IISB: https://www.iisb.fraunhofer.de @@ -123,4 +123,6 @@ .. |bms-12-slave| replace:: Slave 12-cell board .. |bms-18-slave| replace:: Slave 18-cell board +.. |I2C| replace:: I\ :sup:`2`\ C + .. |tbc| replace:: This section of the documentation is not yet complete. diff --git a/docs/misc/definitions.csv b/docs/misc/definitions.csv index aa4a5a87..842986a7 100644 --- a/docs/misc/definitions.csv +++ b/docs/misc/definitions.csv @@ -1,4 +1,5 @@ Word; Definition +AFE; Analog Front-End BIST; Built-In Self Test BJB; Battery Junction Box BMS; Battery management system diff --git a/docs/software/architecture/architecture.rst b/docs/software/architecture/architecture.rst index 96ce40ad..146b0d9b 100644 --- a/docs/software/architecture/architecture.rst +++ b/docs/software/architecture/architecture.rst @@ -8,7 +8,11 @@ Software Architecture ##################### The following section describes the diagnostics and safety focused BMS software -architecture as depicted in :numref:`sw-architecture` +architecture as depicted in :numref:`sw-architecture`. +A detailed version of the architecture is shown in +:numref:`axivion_architecture`. +This view is exported from :ref:`AXIVION_BAUHAUS_SUITE` and should be viewed +and verified in the tool itself for best performance. .. figure:: img/sw-architecture.png :alt: Software architecture @@ -16,7 +20,7 @@ architecture as depicted in :numref:`sw-architecture` :width: 65 % :align: center - foxBMS 2 - Software architecture + |foxbms| - Software architecture A **hardware abstraction layer (HAL)** provides various interfaces to directly access the hardware and its peripherals. This enables encapsulation of the @@ -57,3 +61,12 @@ The foxBMS software itself is grouped into three different layers: errors, ...), state estimation functionalities (state-of-charge, state-of- health, state-of-energy) and the vehicle specific BMS application is done within the **application layer**. + + + .. figure:: img/axivion_architecture.svg + :alt: Detailed software architecture + :name: axivion_architecture + :width: 100 % + :align: center + + |foxbms| - Detailed software architecture diff --git a/docs/software/architecture/img/axivion_architecture.svg b/docs/software/architecture/img/axivion_architecture.svg new file mode 100644 index 00000000..904389e1 --- /dev/null +++ b/docs/software/architecture/img/axivion_architecture.svg @@ -0,0 +1,2400 @@ + + +Architecture (Hier.) +Exported from Gravis 7.2.3 (2021-08-16) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +HAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Driver + + + + + + + + + + + + + + + + + +CAN + + + + + + + + + + + + + + + + + +Power Supply + + + + + + + + + + + + + + + + + +Contactor + + + + + + + + + + + + + + + + + +FRAM + + + + + + + + + + + + + + + + + +Common + + + + + + + + + + + + + + + + + +Interlock + + + + + + + + + + + + + + + + + +IO + + + + + + + + + + + + + + + + + +Analog Front-End + + + + + + + + + + + + + + + + + +Temperature Sensors + + + + + + + + + + + + + + + + + +SPI + + + + + + + + + + + + + + + + + +ADC + + + + + + + + + + + + + + + + + +DMA + + + + + + + + + + + + + + + + + +Measurement + + + + + + + + + + + + + + + + + +MCU + + + + + + + + + + + + + + + + + +OS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Application + + + + + + + + + + + + + + + + + +SOX + + + + + + + + + + + + + + + + + +BMS + + + + + + + + + + + + + + + + + +Plausibility + + + + + + + + + + + + + + + + + +Balancing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Engine + + + + + + + + + + + + + + + + + +Database + + + + + + + + + + + + + + + + + +System Monitoring + + + + + + + + + + + + + + + + + +Diagnosis + + + + + + + + + + + + + + + + + +System + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Main + + + + + + + + + + + + + + + + + +fassert + + + + + + + + + + + + + + + + + +version information + + + + + + + + + + + + + + + + + +main + + + + + + + + + + + + + + + + + +core components + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Task Configuration + + + + + + + + + + + + + + + + + +OS Interface + + + + + + + + + + + + + + + + + +Task Setup + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/software/build-process/build-process.rst b/docs/software/build-process/build-process.rst index 15fcc89a..fe4192d8 100644 --- a/docs/software/build-process/build-process.rst +++ b/docs/software/build-process/build-process.rst @@ -56,12 +56,12 @@ This failure is reported by the build system. static DATA_BLOCK_CELL_VOLTAGE_s mrc_tableCellVoltages = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX}; -.. _measurement_ic_library_build: +.. _afe_library_build: -Building the Measurement IC Library ------------------------------------ +Building the Analog Front-End Library +------------------------------------- -In order to easily switch between different measurement ICs the |foxbms| build +In order to easily switch between different AFEs the |foxbms| build system implements a mechanic for swapping implementations through a configuration file. The configuration file is described in :numref:`BMS_APPLICATION`. diff --git a/docs/software/configuration/configuration.rst b/docs/software/configuration/configuration.rst index f5dd8328..0ac193c9 100644 --- a/docs/software/configuration/configuration.rst +++ b/docs/software/configuration/configuration.rst @@ -122,17 +122,17 @@ The Operating System is configured in ``conf/bms/bms.json``. The value for the Operating System sources. Currently only FreeRTOS is supported (option: ``"os": "freertos"``). -Measurement IC -"""""""""""""" +Analog Front-End +"""""""""""""""" -The measurement IC is configured in ``conf/bms/bms.json``. The joint path +The AFE is configured in ``conf/bms/bms.json``. The joint path from the values of ``manufacturer`` and ``chip`` must be the name of the -source directory in ``src/app/driver/mic//`` that includes +source directory in ``src/app/driver/afe//`` that includes the driver implementation. A list of supported ICs is found in -:numref:`SUPPORTED_MEASUREMENT_ICS`. +:numref:`SUPPORTED_ANALOG_FRONT_ENDS`. The build process behind this configuration is documented at -:ref:`measurement_ic_library_build`. +:ref:`afe_library_build`. Balancing Strategy """""""""""""""""" diff --git a/docs/software/configuration/without-halcogen/without-halcogen_diff-includes.diff b/docs/software/configuration/without-halcogen/without-halcogen_diff-includes.diff index cde98307..8bcc82cf 100644 --- a/docs/software/configuration/without-halcogen/without-halcogen_diff-includes.diff +++ b/docs/software/configuration/without-halcogen/without-halcogen_diff-includes.diff @@ -20,12 +20,12 @@ index a9462e21..1fdb5850 100644 os.path.join("..", "task", "os"), + os.path.join("..", "..", "hal", "include"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS -diff --git a/src/app/driver/measurement-ic/ltc/6806/wscript b/src/app/driver/measurement-ic/ltc/6806/wscript +diff --git a/src/app/driver/afe/ltc/6806/wscript b/src/app/driver/afe/ltc/6806/wscript index d7ca3af9..0cc6c777 100644 ---- a/src/app/driver/measurement-ic/ltc/6806/wscript -+++ b/src/app/driver/measurement-ic/ltc/6806/wscript +--- a/src/app/driver/afe/ltc/6806/wscript ++++ b/src/app/driver/afe/ltc/6806/wscript @@ -71,6 +71,7 @@ def build(bld): os.path.join("..", "..", "..", "..", "engine", "diag"), os.path.join("..", "..", "..", "..", "main", "include"), @@ -44,7 +44,7 @@ index c6b42f89..26369502 100644 os.path.join("..", "task", "os"), + os.path.join("..", "..", "hal", "include"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS diff --git a/src/app/engine/wscript b/src/app/engine/wscript index 03873567..118c66b6 100644 @@ -56,7 +56,7 @@ index 03873567..118c66b6 100644 os.path.join("..", "task", "config"), + os.path.join("..", "..", "hal", "include"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) target = f"{bld.env.APPNAME.lower()}-engine" diff --git a/src/app/main/wscript b/src/app/main/wscript index 1945b079..a47c3e20 100644 @@ -68,7 +68,7 @@ index 1945b079..a47c3e20 100644 os.path.join("..", "task", "config"), + os.path.join("..", "..", "hal", "include"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS diff --git a/src/app/task/wscript b/src/app/task/wscript index d2479891..1b584c01 100644 @@ -80,7 +80,7 @@ index d2479891..1b584c01 100644 os.path.join("..", "main", "include"), + os.path.join("..", "..", "hal", "include"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS diff --git a/src/os/freertos/wscript b/src/os/freertos/wscript index 2d91582e..c32227aa 100644 diff --git a/docs/software/how-to/how-to.rst b/docs/software/how-to/how-to.rst index a9bf23e1..3e0b4ed6 100644 --- a/docs/software/how-to/how-to.rst +++ b/docs/software/how-to/how-to.rst @@ -26,7 +26,7 @@ Other .. toctree:: :maxdepth: 1 - ./../modules/driver/mic/adding-a-new-ic_how-to + ./../modules/driver/afe/adding-a-new-ic_how-to ./../modules/driver/ts/adding-a-new-ts_how-to ./../../developer-manual/style-guide/state-machines_how-to ./../configuration/without-halcogen_how-to diff --git a/docs/software/modules/driver/mic/adding-a-new-ic_how-to.rst b/docs/software/modules/driver/afe/adding-a-new-ic_how-to.rst similarity index 72% rename from docs/software/modules/driver/mic/adding-a-new-ic_how-to.rst rename to docs/software/modules/driver/afe/adding-a-new-ic_how-to.rst index b4a6f0e6..023f9e20 100644 --- a/docs/software/modules/driver/mic/adding-a-new-ic_how-to.rst +++ b/docs/software/modules/driver/afe/adding-a-new-ic_how-to.rst @@ -1,17 +1,17 @@ .. include:: ../../../../macros.txt .. include:: ../../../../units.txt -.. _HOW_TO_IMPLEMENT_A_NEW_MEASUREMENT_IC_DRIVER: +.. _HOW_TO_IMPLEMENT_AN_ANALOG_FRONT_END_DRIVER: -How to Implement a New Measurement IC Driver -============================================ +How to Implement an Analog Front-End Driver +=========================================== -This section gives a guideline how add a new measurement IC to the project. +This section gives a guideline how add a new AFE to the project. The Example ----------- -The measurement IC is from the manufacturer called *Super BMS ICs (SB-IC)* and +The AFE is from the manufacturer called *Super BMS ICs (SB-IC)* and the the IC is named *Vulpes G 2000 (VG2000)* from the IC family *VG*. Basic Directory Structure @@ -20,28 +20,28 @@ Basic Directory Structure #. Adapt ``conf/bms/schema/bms.schema.json`` to recognize the new manufacturer and the IC. #. Add the *SB-IC* manufacturer directory ``sb-ic``: - ``src/app/driver/mic/sb-ic``. + ``src/app/driver/afe/sb-ic``. #. Add the API directory ``api`` for *SB-IC* manufacturer: - ``src/app/driver/mic/sb-ic/api``. + ``src/app/driver/afe/sb-ic/api``. #. Add the IC ``vg2`` directory: - ``src/app/driver/mic/sb-ic/vg2000``. + ``src/app/driver/afe/sb-ic/vg2000``. #. Add the ``api`` directory: - ``src/app/driver/mic/sb-ic/vg2000/api``. + ``src/app/driver/afe/sb-ic/vg2000/api``. #. Add the ``config`` directory: - ``src/app/driver/mic/sb-ic/vg2000/config``. + ``src/app/driver/afe/sb-ic/vg2000/config``. #. If there is special code code **from the IC vendor** for that IC: Add the - ``vendor`` directory ``src/app/driver/mic/sb-ic/vg2000/vendor``. + ``vendor`` directory ``src/app/driver/afe/sb-ic/vg2000/vendor``. The vendor code should be placed here verbatim without any changes to the source code or to the source code organization. #. If there is shared code between all ICs or family of ICs from that manufacturer, add the ``common`` directory: - ``src/app/driver/mic/sb-ic/common``. + ``src/app/driver/afe/sb-ic/common``. #. If there is common shared code **from the IC vendor**: Add the ``vendor`` - directory ``src/app/driver/mic/sb-ic/common/vendor``. The vendor + directory ``src/app/driver/afe/sb-ic/common/vendor``. The vendor code should be placed here verbatim without any changes to the source code or to the source code organization. #. If there needs to be common shared code **developed** for the family: Add - the ``vg`` directory ``src/app/driver/mic/sb-ic/common/vg``. + the ``vg`` directory ``src/app/driver/afe/sb-ic/common/vg``. After that the directories are setup correctly. @@ -62,7 +62,7 @@ then the directory structure is as follows: └── app └── src └── driver - └── mic + └── afe └── sb-ic ├── api ├── common @@ -93,10 +93,10 @@ Driver API Files +++++++++ -- ``api/sb-ic_vg2000_mic.h`` -- ``api/sb-ic_vg2000_mic.c`` -- ``api/sb-ic_vg2000_mic_dma.c`` -- ``api/sb-ic_vg2000_mic_dma.h`` +- ``api/sb-ic_vg2000_afe.h`` +- ``api/sb-ic_vg2000_afe.c`` +- ``api/sb-ic_vg2000_afe_dma.c`` +- ``api/sb-ic_vg2000_afe_dma.h`` - There **SHOULD** be no additional files. Configuration Files @@ -104,8 +104,8 @@ Configuration Files - ``sb-ic_vg2000_cfg.c`` - ``sb-ic_vg2000_cfg.h`` -- ``sb-ic_vg2000_mic_dma_cfg.c`` -- ``sb-ic_vg2000_mic_dma_cfg.h`` +- ``sb-ic_vg2000_afe_dma_cfg.c`` +- ``sb-ic_vg2000_afe_dma_cfg.h`` - There **SHOULD** be no additional files. The file structure should look like this (for the sake of simplicity no common @@ -117,19 +117,19 @@ shared code and no vendor code): └── app └── src └── driver - └── mic + └── afe └── sb-ic └── vg2000 ├── api - │ ├──sb-ic_vg2000_mic.h - │ ├──sb-ic_vg2000_mic.c - │ ├──sb-ic_vg2000_mic_dma.c - │ └──sb-ic_vg2000_mic_dma.h + │ ├──sb-ic_vg2000_afe.h + │ ├──sb-ic_vg2000_afe.c + │ ├──sb-ic_vg2000_afe_dma.c + │ └──sb-ic_vg2000_afe_dma.h ├── config │ ├──sb-ic_vg2000_cfg.c │ ├──sb-ic_vg2000_cfg.h - │ ├──sb-ic_vg2000_mic_dma_cfg.c - │ └──sb-ic_vg2000_mic_dma_cfg.h + │ ├──sb-ic_vg2000_afe_dma_cfg.c + │ └──sb-ic_vg2000_afe_dma_cfg.h ├── sb-ic_vg2000.c ├── sb-ic_vg2000.h ├── sb-ic_vg2000.json diff --git a/docs/software/modules/driver/afe/afe.rst b/docs/software/modules/driver/afe/afe.rst new file mode 100644 index 00000000..0bb8073b --- /dev/null +++ b/docs/software/modules/driver/afe/afe.rst @@ -0,0 +1,18 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _ANALOG_FRONT_END_API: + +Analog Front-End API +==================== + +|foxbms| supports various AFE from different manufacturers as shown +in :ref:`SUPPORTED_ANALOG_FRONT_ENDS`. +This is achieved by drivers that implement the Analog Front-End API (AFE API). + +This document describes how the AFE API works. + +An example how to implement a new AFE API compatible driver is shown in +:ref:`HOW_TO_IMPLEMENT_AN_ANALOG_FRONT_END_DRIVER`. + +|tbc| diff --git a/docs/software/modules/driver/mic/debug/default.rst b/docs/software/modules/driver/afe/debug/default.rst similarity index 100% rename from docs/software/modules/driver/mic/debug/default.rst rename to docs/software/modules/driver/afe/debug/default.rst diff --git a/docs/software/modules/driver/afe/ltc/6804-1.rst b/docs/software/modules/driver/afe/ltc/6804-1.rst new file mode 100644 index 00000000..606fcb6b --- /dev/null +++ b/docs/software/modules/driver/afe/ltc/6804-1.rst @@ -0,0 +1,14 @@ +.. include:: ./../../../../../macros.txt +.. include:: ./../../../../../units.txt + +.. _LTC_6804_1: + +LTC 6804-1 +========== + +The *LTC 6804-1* is the third generation AFE by Analog Devices +(formerly Linear Technology). +A *LTC 6804-1* compatible driver is implemented in |foxbms| for the fourth +generation *LTC 6811-1*. + +See :ref:`LTC_6812_1`. diff --git a/docs/software/modules/driver/mic/ltc/6806.rst b/docs/software/modules/driver/afe/ltc/6806.rst similarity index 100% rename from docs/software/modules/driver/mic/ltc/6806.rst rename to docs/software/modules/driver/afe/ltc/6806.rst diff --git a/docs/software/modules/driver/mic/ltc/6811-1.rst b/docs/software/modules/driver/afe/ltc/6811-1.rst similarity index 100% rename from docs/software/modules/driver/mic/ltc/6811-1.rst rename to docs/software/modules/driver/afe/ltc/6811-1.rst diff --git a/docs/software/modules/driver/mic/ltc/6812-1.rst b/docs/software/modules/driver/afe/ltc/6812-1.rst similarity index 100% rename from docs/software/modules/driver/mic/ltc/6812-1.rst rename to docs/software/modules/driver/afe/ltc/6812-1.rst diff --git a/docs/software/modules/driver/mic/ltc/6813-1.rst b/docs/software/modules/driver/afe/ltc/6813-1.rst similarity index 100% rename from docs/software/modules/driver/mic/ltc/6813-1.rst rename to docs/software/modules/driver/afe/ltc/6813-1.rst diff --git a/docs/software/modules/driver/mic/maxim/max1785x.rst b/docs/software/modules/driver/afe/maxim/max1785x.rst similarity index 68% rename from docs/software/modules/driver/mic/maxim/max1785x.rst rename to docs/software/modules/driver/afe/maxim/max1785x.rst index 727e9d2d..afa9f900 100644 --- a/docs/software/modules/driver/mic/maxim/max1785x.rst +++ b/docs/software/modules/driver/afe/maxim/max1785x.rst @@ -14,14 +14,10 @@ MAX1785x uphost downhost -This module supports -`MAX17852 `_ -and -`MAX17853 `_ -monitoring ICs by Maxim Integrated. Communication with these ICs is handled -through a -`MAX17841B `_ -bridge IC. The communication between bridge IC and monitoring IC is encoded +This module supports the `MAX17852` and `MAX17853` monitoring ICs by Maxim +Integrated. +Communication with these ICs is handled through a `MAX17841B` bridge IC. +The communication between bridge IC and monitoring IC is encoded as Maxim Battery Management UART, which is a optimized, differential variant of UART with a focus on robustness. diff --git a/docs/software/modules/driver/mic/nxp/img/775a_balancing.png b/docs/software/modules/driver/afe/nxp/img/775a_balancing.png similarity index 100% rename from docs/software/modules/driver/mic/nxp/img/775a_balancing.png rename to docs/software/modules/driver/afe/nxp/img/775a_balancing.png diff --git a/docs/software/modules/driver/mic/nxp/img/775a_balancing.vsdx b/docs/software/modules/driver/afe/nxp/img/775a_balancing.vsdx similarity index 100% rename from docs/software/modules/driver/mic/nxp/img/775a_balancing.vsdx rename to docs/software/modules/driver/afe/nxp/img/775a_balancing.vsdx diff --git a/docs/software/modules/driver/mic/nxp/mc33775a.rst b/docs/software/modules/driver/afe/nxp/mc33775a.rst similarity index 100% rename from docs/software/modules/driver/mic/nxp/mc33775a.rst rename to docs/software/modules/driver/afe/nxp/mc33775a.rst diff --git a/docs/software/modules/driver/afe/supported-afes.rst b/docs/software/modules/driver/afe/supported-afes.rst new file mode 100644 index 00000000..cbed154a --- /dev/null +++ b/docs/software/modules/driver/afe/supported-afes.rst @@ -0,0 +1,24 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _SUPPORTED_ANALOG_FRONT_ENDS: + +Supported Analog Front-Ends +=========================== + +|foxbms| supports various AFE from different manufacturers as the list below +shows. +This is achieved by drivers that follow the :ref:`ANALOG_FRONT_END_API`. + +.. toctree:: + :maxdepth: 1 + :caption: List of supported AFEs + + ./ltc/6804-1.rst + ./ltc/6806.rst + ./ltc/6811-1.rst + ./ltc/6812-1.rst + ./ltc/6813-1.rst + ./maxim/max1785x.rst + ./nxp/mc33775a.rst + ./debug/default.rst diff --git a/docs/software/modules/driver/htsen/htsen.rst b/docs/software/modules/driver/htsen/htsen.rst new file mode 100644 index 00000000..2da88b8d --- /dev/null +++ b/docs/software/modules/driver/htsen/htsen.rst @@ -0,0 +1,33 @@ +.. include:: ../../../../macros.txt +.. include:: ../../../../units.txt + +.. _HUMIDITY_TEMPERATURE_SENSOR_MODULE: + +Humidity/Temperature Sensor Module +================================== + +Module Files +------------ + +Driver +^^^^^^ + +- ``src/app/driver/htsen/htsen.c`` (`API <../../../../_static/doxygen/src/html/htsen_8c.html>`__, `source <../../../../_static/doxygen/src/html/htsen_8c_source.html>`__) +- ``src/app/driver/htsen/htsen.h`` (`API <../../../../_static/doxygen/src/html/htsen_8h.html>`__, `source <../../../../_static/doxygen/src/html/htsen_8h_source.html>`__) + +Unit Test +^^^^^^^^^ + +- ``tests/unit/app/driver/htsen/test_htsen.c`` (`API <../../../../_static/doxygen/tests/html/test__htsen_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__pex_8c_source.html>`__) + +Detailed Description +-------------------- + +The driver addresses the Sensirion SHT35-DIS I2C humidity/temperature sensor. + +It triggers a humidity and temperature measurement and reads the result. +It checks the read CRC value: if it does not match the one that the +driver computes, the measurement value is discarded. +The result is stored in the corresponding database entry. +The driver does not use clock stretching to avoid problems on the +|I2C| bus. diff --git a/docs/software/modules/driver/i2c/i2c.rst b/docs/software/modules/driver/i2c/i2c.rst new file mode 100644 index 00000000..e515f7d1 --- /dev/null +++ b/docs/software/modules/driver/i2c/i2c.rst @@ -0,0 +1,59 @@ +.. include:: ../../../../macros.txt +.. include:: ../../../../units.txt + +.. _I2C_MODULE: + +I2C Module +========== + +Module Files +------------ + +Driver +^^^^^^ + +- ``src/app/driver/i2c/i2c.c`` (`API <../../../../_static/doxygen/src/html/i2c_8c.html>`__, `source <../../../../_static/doxygen/src/html/i2c_8c_source.html>`__) +- ``src/app/driver/i2c/i2c.h`` (`API <../../../../_static/doxygen/src/html/i2c_8h.html>`__, `source <../../../../_static/doxygen/src/html/i2c_8h_source.html>`__) + +Unit Test +^^^^^^^^^ + +- ``tests/unit/app/driver/can/test_i2c.c`` (`API <../../../../_static/doxygen/tests/html/test__i2c_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__i2c_8c_source.html>`__) + +Detailed Description +-------------------- + +The driver consists of READ functions and WRITE functions. In all cases, +``slaveAddress`` are the seven bits of the |I2C| slave address. + +There are two cases for READ: + +- ``I2C_Read()``: implements the usual way of reading. First a write operation + is made after the START condition, to write the address (``readAddress``) + to read from. Then a REPEATED START condition issued on the bus and + ``nrBytes`` are read. The result is stored in the data pointed by + ``readData``. + +- ``I2C_ReadDirect()``: a START condition is issued on the bus and + ``nrBytes`` are read directly. The result is stored in the data pointed by + ``readData``. + +Similarly, there are two cases for WRITE: + +- ``I2C_WriteDirect()``: a START condition is issued on the bus and + ``nrBytes`` are written directly. The data to be written is pointed by + ``writeData``. + +- ``I2C_Write()``: like the preceding function, a START condition is issued + on the bus and bytes are written. The difference is that ``nrBytes+1`` are + written: first ``writeAddress`` is written, then the data to be written + pointed by ``writeData``. This function is symmetric to ``I2C_Read()``, + where first the register address to access is written. + +Two DMA functions are also implemented, similar to the functions where +the register address is written first before read or write. +``dmaGroupANotification()`` is called after the bytes are written to or +read from |I2C| to deactivate the corresponding DMA transfers. +Currently the DMA functions lack transaction control: in case the |I2C| +transaction does not finish or take place, this is not signaled to the +driver. diff --git a/docs/software/modules/driver/imd/bender/bender_ir155.rst b/docs/software/modules/driver/imd/bender/bender_ir155.rst new file mode 100644 index 00000000..525b7ea8 --- /dev/null +++ b/docs/software/modules/driver/imd/bender/bender_ir155.rst @@ -0,0 +1,35 @@ +.. include:: ./../../../../../macros.txt +.. include:: ./../../../../../units.txt + +.. _BENDER_IR155: + +Bender IR155 +============ + +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>`__) + +Configuration +^^^^^^^^^^^^^ + +*none* + +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>`__) + +Description +----------- + +The driver is currently a stub and not functional. +It behaves like the ``no-imd`` driver +(see :ref:`DUMMY_INSULATION_MEASUREMENT_DEVICE`) + +|tbc| diff --git a/docs/software/modules/driver/imd/imd.rst b/docs/software/modules/driver/imd/imd.rst index 68874a62..1ba7c61c 100644 --- a/docs/software/modules/driver/imd/imd.rst +++ b/docs/software/modules/driver/imd/imd.rst @@ -12,5 +12,6 @@ Several different Insulation Measurement Devices (IMD) are supported. :maxdepth: 1 :caption: List of available Insulation Measurement Devices + ./bender/bender_ir155.rst ./bender/bender_iso165c.rst ./none/no-imd.rst diff --git a/docs/software/modules/driver/imd/none/no-imd.rst b/docs/software/modules/driver/imd/none/no-imd.rst index b2648d59..619291f2 100644 --- a/docs/software/modules/driver/imd/none/no-imd.rst +++ b/docs/software/modules/driver/imd/none/no-imd.rst @@ -28,4 +28,5 @@ Unit Test Description ----------- -|tbc| +The insulation measurement is always set to be valid and an insulation +resistance of :math:`10000000\ k{\Omega}` is written to the database entry. diff --git a/docs/software/modules/driver/interlock/interlock-schematic.dot b/docs/software/modules/driver/interlock/interlock-schematic.dot new file mode 100644 index 00000000..b7c56cda --- /dev/null +++ b/docs/software/modules/driver/interlock/interlock-schematic.dot @@ -0,0 +1,87 @@ +# 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®" + +graph interlock_schematic { + subgraph cluster_main { + label="main interlock circuit"; + + node [shape=rectangle,group=1] + nd_static_supply + nd_interlock_high + nd_interlock_low + nd_low_side_regulation + nd_system_ground; + node [shape=plain,group=1] + nd_low_side_cs + nd_low_side_threshold_cs; + + nd_static_supply [label="static low-power supply"]; + nd_interlock_high [label="interlock connector high"]; + nd_interlock_low [label="interlock connector low"]; + nd_low_side_cs [label="low-side current sense (100mA = 4V)"]; + nd_low_side_regulation [label="low-side current regulation (to 50mA)"]; + nd_low_side_threshold_cs [label="low-side current threshold (low = current above 10mA)"]; + nd_system_ground [label="system ground"]; + + edge[color=blue] + nd_static_supply -- nd_interlock_high [style=bold]; + nd_interlock_high -- nd_interlock_low [style="bold,dashed",label="external connection"]; + nd_interlock_low -- nd_low_side_cs [style=bold]; + nd_low_side_cs -- nd_low_side_regulation [style=bold]; + nd_low_side_regulation -- nd_low_side_threshold_cs [style=bold]; + nd_low_side_threshold_cs -- nd_system_ground [style=bold]; + } + + node [shape=rectangle,group=2] + nd_diagnostic_supply; + node [shape=rectangle,group=3] + nd_high_side_vs + nd_low_side_vs; + node [shape=plain,group=2] + nd_high_side_cs; + + nd_diagnostic_supply [label="diagnostic high-power supply"]; + nd_high_side_cs [label="high-side current sense (133mA range)"]; + nd_high_side_vs [label="high-side voltage sense (resistor divider 3k9/(5k6+3k9))"]; + nd_low_side_vs [label="low-side voltage sense (resistor divider 3k9/(5k6+3k9))"]; + + edge [color=orange] + nd_diagnostic_supply -- nd_high_side_cs; + nd_high_side_cs -- nd_interlock_high; + nd_interlock_high -- nd_high_side_vs; + nd_interlock_low -- nd_low_side_vs; +} diff --git a/docs/software/modules/driver/interlock/interlock.rst b/docs/software/modules/driver/interlock/interlock.rst index a295f01f..9f7d0d3c 100644 --- a/docs/software/modules/driver/interlock/interlock.rst +++ b/docs/software/modules/driver/interlock/interlock.rst @@ -29,4 +29,80 @@ Unit Test Description ----------- -|tbc| +.. graphviz:: interlock-schematic.dot + :caption: Simplified schematic of the interlock circuit + :name: interlock-circuit-simplified + +The purpose of the interlock circuit is that the embedded software can +recognize that an external safety circuit has been opened. +This is achieved through a monitor current that is supplied to an external +connector. +The application expects that the rest of the safety system closes this path +when it is working as expected. +Typically, this is used with emergency stop switches or similar devices. +A simplified schematic of the interlock circuit is shown in +:numref:`interlock-circuit-simplified`. + +Circuit description +^^^^^^^^^^^^^^^^^^^ + +The interlock circuit consists of a main path that is continuously supplied by +the static power supply of the |master|. +In :numref:`interlock-circuit-simplified` this is called +``static low-power supply``. +This supply does not have to be enabled and is powered by the 5V rail of the +peripheral supply. + +The interlock is closed through the connector that makes the external +connection of ``interlock connector high`` with ``interlock connector low``. + +As a diagnostic measure, the ``low-side current sense`` allows to monitor the +current on the low-side of the interlock connector. +The monitoring circuit scales 0mA to 100mA from 0V to 4V with a linear relation. + +For the case that additional diagnostic features are enabled, the +``low-side current regulation`` limits the low-side current to 50mA. + +As a last point in the measurement chain, a ``low-side current threshold`` +comparator circuit, pulls a pin low in the case that the threshold of 10mA +interlock current is surpassed. +This is the main detection method of detecting a closed interlock. + +Additional diagnostic features consist of the voltage measurements of the high +and low pins of the external interlock connector. +Moreover, dedicated current measurements at the low- and high-side of the +interlock connector increase the diagnostic possibilities. + +The ``high-side voltage sense`` and the ``low-side voltage sense`` allow the +measurement of the voltages of the respective interlock connector pins. +Together with the low-side current sense circuit this allows an estimation of +the resistance of the external part of the interlock. +All voltages are measured using a resistor divider consisting of a 5k6 ohm and +a 3k9 ohm resistor. + +An additional switchable power supply imprints a higher current on the +interlock path to increase the robustness of the interlock. This current can +be measured using the ``high-side current sense`` measurement. + +The measurements of voltage and current on both high-side and low-side can be +used for checking the plausibility of measured values. + +Software description +^^^^^^^^^^^^^^^^^^^^ + +The interlock state is read via a feedback input pin. If this pin is low, +then the interlock is closed. If the pin is high, the interlock is +open. + +The feedback is checked in the interlock state machine. It reports an error +via the ``DIAG`` module if the interlock is open. + +The interlock feedback can be deactivated via the define +``BS_IGNORE_INTERLOCK_FEEDBACK``. If set to ``true``, the feedback function +will always return ``ILCK_SWITCH_ON``. + +In addition to the feedback pins, the ADC inputs of the MCU also monitor the +voltages and currents described in the section `Circuit description`_. +Currently, these readings are only stored in the database +(:numref:`DATABASE_MODULE`). +They can be used for further diagnostics. diff --git a/docs/software/modules/driver/mic/ics.rst b/docs/software/modules/driver/mic/ics.rst deleted file mode 100644 index d3a80c3b..00000000 --- a/docs/software/modules/driver/mic/ics.rst +++ /dev/null @@ -1,24 +0,0 @@ -.. include:: ./../../../../macros.txt -.. include:: ./../../../../units.txt - -.. _SUPPORTED_MEASUREMENT_ICS: - -Supported Measurement ICs -========================= - -|foxbms| supports various measurement ICs from different manufacturers as the -list below shows. This is achieved by drivers that follow the -:ref:`MEASUREMENT_IC_API`. - -.. toctree:: - :maxdepth: 1 - :caption: List of supported measurement ICs - - ./ltc/6804-1.rst - ./ltc/6806.rst - ./ltc/6811-1.rst - ./ltc/6812-1.rst - ./ltc/6813-1.rst - ./maxim/max1785x.rst - ./nxp/mc33775a.rst - ./debug/default.rst diff --git a/docs/software/modules/driver/mic/ltc/6804-1.rst b/docs/software/modules/driver/mic/ltc/6804-1.rst deleted file mode 100644 index 7e81b612..00000000 --- a/docs/software/modules/driver/mic/ltc/6804-1.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. include:: ./../../../../../macros.txt -.. include:: ./../../../../../units.txt - -.. _LTC_6804_1: - -LTC 6804-1 -========== - -The *LTC 6804-1* is the third generation measurement IC by Analog Devices -(formerly Linear Technology). A *LTC 6804-1* compatible driver is implemented -in |foxbms| for the fourth generation *LTC 6811-1*. - -See :ref:`LTC_6812_1`. diff --git a/docs/software/modules/driver/mic/mic.rst b/docs/software/modules/driver/mic/mic.rst deleted file mode 100644 index 2ff2789e..00000000 --- a/docs/software/modules/driver/mic/mic.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. include:: ./../../../../macros.txt -.. include:: ./../../../../units.txt - -.. _MEASUREMENT_IC_API: - -Measurement IC API -================== - -|foxbms| supports various measurement ICs from different manufacturers as shown -in :ref:`SUPPORTED_MEASUREMENT_ICS`. -This is achieved by drivers that implement the Measurement IC API (MIC API). - -This document describes how the MIC API works. - -An example how to implement a new MIC API compatible driver is shown in -:ref:`HOW_TO_IMPLEMENT_A_NEW_MEASUREMENT_IC_DRIVER`. - -|tbc| diff --git a/docs/software/modules/driver/pex/pex.rst b/docs/software/modules/driver/pex/pex.rst new file mode 100644 index 00000000..f739b332 --- /dev/null +++ b/docs/software/modules/driver/pex/pex.rst @@ -0,0 +1,35 @@ +.. include:: ../../../../macros.txt +.. include:: ../../../../units.txt + +.. _PORT_EXPANDER_MODULE: + +Port Expander Module +==================== + +Module Files +------------ + +Driver +^^^^^^ + +- ``src/app/driver/pex/pex.c`` (`API <../../../../_static/doxygen/src/html/pex_8c.html>`__, `source <../../../../_static/doxygen/src/html/pex_8c_source.html>`__) +- ``src/app/driver/pex/pex.h`` (`API <../../../../_static/doxygen/src/html/pex_8h.html>`__, `source <../../../../_static/doxygen/src/html/pex_8h_source.html>`__) + +Configuration +^^^^^^^^^^^^^ + +- ``src/app/driver/config/pex_cfg.c`` (`API <../../../../_static/doxygen/src/html/pex__cfg_8c.html>`__, `source <../../../../_static/doxygen/src/html/pex__cfg_8c_source.html>`__) +- ``src/app/driver/config/pex_cfg.h`` (`API <../../../../_static/doxygen/src/html/pex__cfg_8h.html>`__, `source <../../../../_static/doxygen/src/html/pex__cfg_8h_source.html>`__) + +Unit Test +^^^^^^^^^ + +- ``tests/unit/app/driver/pex/test_pex.c`` (`API <../../../../_static/doxygen/tests/html/test__pex_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__pex_8c_source.html>`__) + +Detailed Description +-------------------- + +The driver addresses the port expander devices through getter and setter functions. + +The driver works with the NXP PCA9539 port expander IC, which has 16 GPIOs. +It is also compatible with the TI TCA9539. diff --git a/docs/software/modules/driver/pwm/pwm.rst b/docs/software/modules/driver/pwm/pwm.rst new file mode 100644 index 00000000..1d670321 --- /dev/null +++ b/docs/software/modules/driver/pwm/pwm.rst @@ -0,0 +1,33 @@ +.. include:: ./../../../../macros.txt +.. include:: ./../../../../units.txt + +.. _PWM: + +PWM +=== + +Module Files +------------ + +Driver +^^^^^^ + +- ``src/app/driver/pwm/pwm.c`` (`API <../../../../_static/doxygen/src/html/pwm_8c.html>`__, `source <../../../../_static/doxygen/src/html/pwm_8c_source.html>`__) +- ``src/app/driver/pwm/pwm.h`` (`API <../../../../_static/doxygen/src/html/pwm_8h.html>`__, `source <../../../../_static/doxygen/src/html/pwm_8h_source.html>`__) + +Configuration +^^^^^^^^^^^^^ + +*none* + +Unit Test +^^^^^^^^^ + +- ``tests/unit/app/driver/test_pwm.c`` (`API <../../../../_static/doxygen/tests/html/test__pwm_8c.html>`__, `source <../../../../_static/doxygen/tests/html/test__pwm_8c_source.html>`__) + +Description +----------- + +The PWM module uses the enhanced PWM module in the MCU in order to generate +a PWM clock. Currently, only the PWM channel 1A is used and controlled. +For usage details, please refer to the doxygen documentation of this module. diff --git a/docs/software/modules/driver/ts/ts-sensors.rst b/docs/software/modules/driver/ts/ts-sensors.rst index 650e1044..5d1b9184 100644 --- a/docs/software/modules/driver/ts/ts-sensors.rst +++ b/docs/software/modules/driver/ts/ts-sensors.rst @@ -20,7 +20,7 @@ Supported Temperature Sensors |foxbms| supports various Temperature sensors from different manufacturers as the list below shows. -These temperature sensors can be used inside the measurement IC drivers as they +These temperature sensors can be used inside the AFE drivers as they implement the :ref:`temperature_sensor_api`. .. toctree:: diff --git a/docs/software/modules/engine/diag/diag.rst b/docs/software/modules/engine/diag/diag.rst index 437df863..cc5e66ce 100644 --- a/docs/software/modules/engine/diag/diag.rst +++ b/docs/software/modules/engine/diag/diag.rst @@ -28,7 +28,7 @@ Configuration - ``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_mic.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__mic_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__mic_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>`__) - ``src/app/engine/diag/cbs/diag_cbs_sbc.c`` (`API <../../../../_static/doxygen/src/html/diag__cbs__sbc_8c.html>`__, `source <../../../../_static/doxygen/src/html/diag__cbs__sbc_8c_source.html>`__) @@ -49,7 +49,7 @@ Unit Test - ``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_mic.c`` (`API <../../../../_static/doxygen/tests/html/diag__cbs__mic_8c.html>`__, `source <../../../../_static/doxygen/tests/html/diag__cbs__mic_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>`__) 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 7e22a0e0..273f78e5 100644 --- a/docs/software/modules/engine/sys/sys_state-machine-detailed.dot +++ b/docs/software/modules/engine/sys/sys_state-machine-detailed.dot @@ -42,6 +42,7 @@ digraph sys_fsm_states_detailed { nd_error; node [shape = circle] nd_initialization_check_deep_discharge nd_initialization_sbc + nd_initialization_can nd_initialization_send_boot_message nd_initialization_interlock nd_initialization_contactors @@ -52,6 +53,7 @@ digraph sys_fsm_states_detailed { nd_uninitialized [label=<Uninitialized>]; nd_initialization_check_deep_discharge [label=<ICDDC>]; nd_initialization_sbc [label=<ISBC>]; + nd_initialization_can [label=<ICAN>]; nd_initialization_send_boot_message [label=<IBOOT>]; nd_initialization_interlock [label=<IILCK>]; nd_initialization_contactors [label=<ICONT>]; @@ -65,7 +67,8 @@ digraph sys_fsm_states_detailed { nd_uninitialized -> nd_initialization_check_deep_discharge [label = "Initialize"] nd_initialization_check_deep_discharge -> nd_initialization_sbc - nd_initialization_sbc -> nd_initialization_send_boot_message + nd_initialization_sbc -> nd_initialization_can + nd_initialization_can -> nd_initialization_send_boot_message nd_initialization_send_boot_message -> nd_initialization_interlock nd_initialization_interlock -> nd_initialization_contactors nd_initialization_contactors -> nd_initialization_balancing diff --git a/docs/software/modules/modules.rst b/docs/software/modules/modules.rst index 7aa21c6f..afe1b3e6 100644 --- a/docs/software/modules/modules.rst +++ b/docs/software/modules/modules.rst @@ -44,13 +44,17 @@ Software Modules ./driver/dma/dma.rst ./driver/foxmath/foxmath.rst ./driver/fram/fram.rst + ./driver/htsen/htsen.rst + ./driver/i2c/i2c.rst ./driver/imd/imd.rst ./driver/interlock/interlock.rst ./driver/io/io.rst ./driver/meas/meas.rst ./driver/mcu/mcu.rst - ./driver/mic/mic.rst - ./driver/mic/ics.rst + ./driver/afe/afe.rst + ./driver/afe/supported-afes.rst + ./driver/pex/pex.rst + ./driver/pwm/pwm.rst ./driver/rtc/rtc.rst ./driver/sbc/sbc.rst ./driver/spi/spi.rst diff --git a/docs/software/overview/sw-overview.rst b/docs/software/overview/sw-overview.rst index 4c94fbb4..3fc319eb 100644 --- a/docs/software/overview/sw-overview.rst +++ b/docs/software/overview/sw-overview.rst @@ -50,15 +50,21 @@ are unblocked from there while-loop and run periodically. Operating System **************** -A critical section must be entered with the function -``OS_EnterTaskCritical()`` and exited with the function -``OS_ExitTaskCritical()``. +A critical section must be entered with the function ``OS_EnterTaskCritical()`` +and exited with the function ``OS_ExitTaskCritical()``. The operating system configuration can be found in the file -``FreeRTOSConfig.h``. It should not be written directly. The configuration -has to be made with |halcogen|. Changes to this file will be overwritten by -|halcogen|. A detailed explanation of the parameters is given -at https://www.freertos.org/a00110.html. +``FreeRTOSConfig.h``. +A detailed explanation of the parameters configured in this file is given at +https://www.freertos.org/a00110.html. +|halcogen| generates the FreeRTOS sources on the fly during the build process. +However, |foxbms| ships its own FreeRTOS source tree (in ``src/os/freertos``), +and therefore the FreeRTOS sources generated by the code generator are not +needed and consequently removed. +Only the CPU clock frequency configured with |halcogen| is extracted from the +generated FreeRTOS sources and written into +``config_cpu_clock_hz.h``, which is included in |foxbms|'s own +``FreeRTOSConfig.h``. ********************* Software Architecture diff --git a/docs/software/unit-tests/unit-tests.rst b/docs/software/unit-tests/unit-tests.rst index 2a559477..28fc5fcd 100644 --- a/docs/software/unit-tests/unit-tests.rst +++ b/docs/software/unit-tests/unit-tests.rst @@ -264,10 +264,6 @@ similar to this: Could not find coverage results for ../../src/app/driver/io/io.c - Could not find coverage results for ../../src/app/driver/mic/ltc/common/mic_dma.c - - Could not find coverage results for ../../src/app/driver/mic/nxp/common/mic_dma.c - [...] There were files with no coverage results: aborting. diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 24fa5753..b8b4e1dc 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -1,4 +1,6 @@ ADI +AFE +AFEs addon addons alphanumericals @@ -48,6 +50,7 @@ freeRTOS GitLab goto graphviz +gravis halcogen HALCoGen ifndef @@ -110,6 +113,7 @@ scikit scipy Segger seh +Sensirion SOE SOH SPI diff --git a/docs/tools/static-analysis/axivion.rst b/docs/tools/static-analysis/axivion.rst index e0dd9445..a19d951f 100644 --- a/docs/tools/static-analysis/axivion.rst +++ b/docs/tools/static-analysis/axivion.rst @@ -25,44 +25,45 @@ Setup ----- - Install OpenJDK and make it available in PATH. -- Install Python3.8 from https://www.python.org/downloads/windows/. Use the +- Install Python 3.8 from https://www.python.org/downloads/windows/. Use the user installer and make sure to install the Python launcher. Leave all other options as they are selected. -- Install Axivion Bauhaus Suite from the zip-file in a versioned directory - e.g., ``C:\Bauhaus\x.y.z`` and add ``C:\Bauhaus\x.y.z\bin`` to the user PATH - environment variable. -- Copy the license file into ``%USERPROFILE%\.bauhaus``. -- Copy the certificate of the dashboard server to - ``%USERPROFILE%\.bauhaus\auto.cert``. +- Extract Axivion Bauhaus Suite from the zip-file and copy it in a versioned + directory e.g., ``C:\Bauhaus\x.y.z`` and add ``C:\Bauhaus\x.y.z\bin`` to the + user PATH environment variable. +- Copy the license file into ``%USERPROFILE%\.bauhaus\``. +- Name the certificate of the dashboard server ``auto.cert`` and copy it into + the folder ``%USERPROFILE%\.bauhaus\``. - **Optional:** If there is an Axivion Dashboard server running: Set the user environment variable ``AXIVION_PASSWORD=xyz`` to the user token obtained from the dashboard. -To verify that the install can successfully build run the following commands in -a terminal inside the project root (please make sure that the terminal is -freshly spawned so that it inherits the new environment variables): +To verify the installation and create an initialization of the local database, +the following command has to be run once inside a terminal (please make sure +that the terminal is freshly spawned so that it inherits the previously set +environment variables): .. code-block:: console - C:\Users\vulpes\Documents\foxbms-2>waf build_axivion clean_axivion + C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_analysis.bat Local Builds And Results ------------------------ -- Run the analysis step +- Run the following command to start a local dashserver and **do not** close + the terminal afterwards (follow the instructions printed on the terminal to + see the results): .. code-block:: console - C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_analysis.bat + C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_dashserver.bat -- Run the following command in to start a local dashserver and **do not** close - the terminal afterwards: +- 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 - dashserver start --local --noauth --install_file=%USERPROFILE%\.bauhaus\localbuild\projects\foxbms-2.db - -- Follow the instructions printed on the terminal to see the results. + C:\Users\vulpes\Documents\foxbms-2>tests\axivion\start_local_analysis.bat VS Code Setup ------------- @@ -105,11 +106,34 @@ VS Code User settings: ] Advanced Usage -++++++++++++++ +-------------- Race Condition Analysis -^^^^^^^^^^^^^^^^^^^^^^^ ++++++++++++++++++++++++ Go into the directory `racepdfs` and execute the wrapper batch file. This should generate a directory with call graphs to variables that are accessed in a potential unsafe manner. These can be used for closer investigation. + +Updating the architecture +------------------------- + +The current architecture is described in `architecture.gxl`. +This file is automatically embedded and verified against during the +architecture analysis run by this tool. +In order to update the architecture, it can be changed according to the +user manual of the tool in `gravis` and the exported in place of +`architecture.gxl`. + +When updating the architecture, a new render should be created in order to +update the documentation at :ref:`SOFTWARE_ARCHITECTURE`. +This can be done through the export feature of `gravis`. +For the developer's convenience a helper script has been created. +Call + +.. code-block:: bash + + gravis --script tests/axivion/gravis_export_architecture_svg.py + +from a shell in the root of the project and the image will be +automatically updated. diff --git a/docs/tools/waf-tools/f_git_hooks.rst b/docs/tools/waf-tools/f_git_hooks.rst new file mode 100644 index 00000000..c1d3d502 --- /dev/null +++ b/docs/tools/waf-tools/f_git_hooks.rst @@ -0,0 +1,20 @@ +.. include:: ./../../macros.txt +.. include:: ./../../units.txt + +.. _WAF_TOOL_GIT_HOOKS: + +Git Hooks +========= + +The tool is located in ``tools/waf-tools``. + +For skipping the pre-commit git hook in certain cases, please refer to the +`documentation of git commit `_. +(Use ``--no-verify`` with ``git commit``.) + +Tool Documentation +------------------ + +.. automodule:: f_git_hooks + :members: + :show-inheritance: diff --git a/docs/tools/waf-tools/waf-tools.rst b/docs/tools/waf-tools/waf-tools.rst index 6386bc10..90888d80 100644 --- a/docs/tools/waf-tools/waf-tools.rst +++ b/docs/tools/waf-tools/waf-tools.rst @@ -26,6 +26,7 @@ Waf Tools Implementation Documentation ./f_check_db_vars.rst ./f_clang_format.rst ./f_cppcheck.rst + ./f_git_hooks.rst ./f_guidelines.rst ./f_hcg.rst ./f_miniconda_env.rst diff --git a/hardware/README.md b/hardware/README.md index 0fe8d2bf..d92bb082 100644 --- a/hardware/README.md +++ b/hardware/README.md @@ -4,6 +4,7 @@ The hardware designs of foxBMS 2 can be found at the following address: https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/hardware/release/ The hardware design files belonging to this release are: -| Item | File | -|--------|-------------------------------------------------------------------------------------------------------------------| -| Master | [Master v1.0.2](https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/hardware/release/master-v1.0.2_2021-07-29.zip) | + +| Item | File | +|--------|----------------------------------------------------------------------------------------------------------| +| Master | [Master v1.1.1](https://iisb-foxbms.iisb.fraunhofer.de/foxbms/gen2/hardware/release/master-v1.1.1.zip) | diff --git a/src/app/application/algorithm/moving_average/moving_average.c b/src/app/application/algorithm/moving_average/moving_average.c index 5045ad2f..bd35a447 100644 --- a/src/app/application/algorithm/moving_average/moving_average.c +++ b/src/app/application/algorithm/moving_average/moving_average.c @@ -43,7 +43,7 @@ * @file moving_average.c * @author foxBMS Team * @date 2017-12-18 (date of creation) - * @updated 2020-07-01 (date of last update) + * @updated 2021-09-08 (date of last update) * @ingroup ALGORITHMS * @prefix ALGO * @@ -144,8 +144,8 @@ static uint32_t movingAveragePowerLength = #endif /** Pointer for current moving average calculation @{*/ -static float *pMovingAverageCurrrentNew = &curValues[0]; -static float *pMovingAverageCurrrent_1s = &curValues[0]; +static float *pMovingAverageCurrentNew = &curValues[0]; +static float *pMovingAverageCurrent_1s = &curValues[0]; static float *pMovingAverageCurrent_5s = &curValues[0]; static float *pMovingAverageCurrent_10s = &curValues[0]; static float *pMovingAverageCurrent_30s = &curValues[0]; @@ -205,30 +205,30 @@ extern void ALGO_MovAverage() { } /* Add value to array and calculate new moving average values */ - *pMovingAverageCurrrentNew = packCurrent; + *pMovingAverageCurrentNew = packCurrent; /* Calculate new moving average - first add new value */ divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_1s; - movingAverage_tab.movingAverageCurrent1sInterval_mA += (*pMovingAverageCurrrentNew) / divider; + movingAverage_tab.movingAverageCurrent1sInterval_mA += (*pMovingAverageCurrentNew) / divider; divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_5s; - movingAverage_tab.movingAverageCurrent5sInterval_mA += (*pMovingAverageCurrrentNew) / divider; + movingAverage_tab.movingAverageCurrent5sInterval_mA += (*pMovingAverageCurrentNew) / divider; divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_10s; - movingAverage_tab.movingAverageCurrent10sInterval_mA += (*pMovingAverageCurrrentNew) / divider; + movingAverage_tab.movingAverageCurrent10sInterval_mA += (*pMovingAverageCurrentNew) / divider; divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_30s; - movingAverage_tab.movingAverageCurrent30sInterval_mA += (*pMovingAverageCurrrentNew) / divider; + movingAverage_tab.movingAverageCurrent30sInterval_mA += (*pMovingAverageCurrentNew) / divider; divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_60s; - movingAverage_tab.movingAverageCurrent60sInterval_mA += (*pMovingAverageCurrrentNew) / divider; + movingAverage_tab.movingAverageCurrent60sInterval_mA += (*pMovingAverageCurrentNew) / divider; divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG; - movingAverage_tab.movingAverageCurrentConfigurableInterval_mA += (*pMovingAverageCurrrentNew) / divider; + movingAverage_tab.movingAverageCurrentConfigurableInterval_mA += (*pMovingAverageCurrentNew) / divider; /* Then, increment pointer and substract oldest value when respective window is filled with data */ - pMovingAverageCurrrentNew++; + pMovingAverageCurrentNew++; if ((curInit & 0x01u) == 0x01u) { divider = ALGO_NUMBER_AVERAGE_VALUES_CUR_1s; - movingAverage_tab.movingAverageCurrent1sInterval_mA -= ((*pMovingAverageCurrrent_1s) / divider); - pMovingAverageCurrrent_1s++; + movingAverage_tab.movingAverageCurrent1sInterval_mA -= ((*pMovingAverageCurrent_1s) / divider); + pMovingAverageCurrent_1s++; } else { - if (pMovingAverageCurrrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_1s]) { + if (pMovingAverageCurrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_1s]) { curInit |= 0x01u; } } @@ -237,7 +237,7 @@ extern void ALGO_MovAverage() { movingAverage_tab.movingAverageCurrent5sInterval_mA -= (*pMovingAverageCurrent_5s) / divider; pMovingAverageCurrent_5s++; } else { - if (pMovingAverageCurrrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_5s]) { + if (pMovingAverageCurrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_5s]) { curInit |= 0x02u; } } @@ -246,7 +246,7 @@ extern void ALGO_MovAverage() { movingAverage_tab.movingAverageCurrent10sInterval_mA -= (*pMovingAverageCurrent_10s) / divider; pMovingAverageCurrent_10s++; } else { - if (pMovingAverageCurrrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_10s]) { + if (pMovingAverageCurrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_10s]) { curInit |= 0x04u; } } @@ -255,7 +255,7 @@ extern void ALGO_MovAverage() { movingAverage_tab.movingAverageCurrent30sInterval_mA -= (*pMovingAverageCurrent_30s) / divider; pMovingAverageCurrent_30s++; } else { - if (pMovingAverageCurrrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_30s]) { + if (pMovingAverageCurrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_30s]) { curInit |= 0x08u; } } @@ -264,7 +264,7 @@ extern void ALGO_MovAverage() { movingAverage_tab.movingAverageCurrent60sInterval_mA -= (*pMovingAverageCurrent_60s) / divider; pMovingAverageCurrent_60s++; } else { - if (pMovingAverageCurrrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_60s]) { + if (pMovingAverageCurrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_60s]) { curInit |= 0x10u; } } @@ -273,17 +273,17 @@ extern void ALGO_MovAverage() { movingAverage_tab.movingAverageCurrentConfigurableInterval_mA -= (*pMovingAverageCurrent_cfg) / divider; pMovingAverageCurrent_cfg++; } else { - if (pMovingAverageCurrrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG]) { + if (pMovingAverageCurrentNew == &curValues[ALGO_NUMBER_AVERAGE_VALUES_CUR_CFG]) { curInit |= 0x20u; } } /* Check pointer for buffer overflow */ - if (pMovingAverageCurrrentNew > &curValues[movingAverageCurrentLength - 1u]) { - pMovingAverageCurrrentNew = &curValues[0u]; + if (pMovingAverageCurrentNew > &curValues[movingAverageCurrentLength - 1u]) { + pMovingAverageCurrentNew = &curValues[0u]; } - if (pMovingAverageCurrrent_1s > &curValues[movingAverageCurrentLength - 1u]) { - pMovingAverageCurrrent_1s = &curValues[0u]; + if (pMovingAverageCurrent_1s > &curValues[movingAverageCurrentLength - 1u]) { + pMovingAverageCurrent_1s = &curValues[0u]; } if (pMovingAverageCurrent_5s > &curValues[movingAverageCurrentLength - 1u]) { pMovingAverageCurrent_5s = &curValues[0u]; diff --git a/src/app/application/bms/bms.c b/src/app/application/bms/bms.c index b7592603..ed98a282 100644 --- a/src/app/application/bms/bms.c +++ b/src/app/application/bms/bms.c @@ -43,7 +43,7 @@ * @file bms.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2021-10-18 (date of last update) * @ingroup ENGINE * @prefix BMS * @@ -55,14 +55,14 @@ #include "battery_cell_cfg.h" +#include "afe.h" #include "bal.h" #include "contactor.h" #include "database.h" #include "diag.h" #include "foxmath.h" -#include "interlock.h" +#include "led.h" #include "meas.h" -#include "mic.h" #include "os.h" #include "soa.h" @@ -839,7 +839,6 @@ void BMS_Trigger(void) { BMS_SAVELASTSTATES(); if (bms_state.substate == BMS_ENTRY) { BAL_SetStateRequest(BAL_STATE_ALLOWBALANCING_REQUEST); - ILCK_SetStateRequest(ILCK_STATE_CLOSE_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 */ @@ -1193,17 +1192,18 @@ void BMS_Trigger(void) { BMS_SAVELASTSTATES(); if (bms_state.substate == BMS_ENTRY) { - BAL_SetStateRequest(BAL_STATE_NO_BALANCING_REQUEST); - bms_state.timer = BMS_STATEMACH_SHORTTIME; - bms_state.substate = BMS_OPEN_INTERLOCK; + /* Set BMS System state to error */ DATA_READ_DATA(&systemstate); systemstate.bmsCanState = BMS_CANSTATE_ERROR; DATA_WRITE_DATA(&systemstate); - break; - } else if (bms_state.substate == BMS_OPEN_INTERLOCK) { - ILCK_SetStateRequest(ILCK_STATE_OPEN_REQUEST); - nextOpenWireCheck = timestamp + MIC_ERROR_OPEN_WIRE_PERIOD_ms; - bms_state.timer = BMS_STATEMACH_VERYLONGTIME; + /* Deactivate balancing */ + BAL_SetStateRequest(BAL_STATE_NO_BALANCING_REQUEST); + /* Change LED toggle frequency to indicate an error */ + LED_SetToggleTime(LED_ERROR_OPERATION_ON_OFF_TIME_ms); + /* Set timer for next open wire check */ + nextOpenWireCheck = timestamp + AFE_ERROR_OPEN_WIRE_PERIOD_ms; + /* Switch to next substate */ + bms_state.timer = BMS_STATEMACH_SHORTTIME; bms_state.substate = BMS_CHECK_ERROR_FLAGS; break; } else if (bms_state.substate == BMS_CHECK_ERROR_FLAGS) { @@ -1212,42 +1212,28 @@ void BMS_Trigger(void) { if (nextOpenWireCheck <= timestamp) { /* Perform open-wire check periodically */ /* MEAS_RequestOpenWireCheck(); */ /*TODO: check with strings */ - nextOpenWireCheck = timestamp + MIC_ERROR_OPEN_WIRE_PERIOD_ms; + nextOpenWireCheck = timestamp + AFE_ERROR_OPEN_WIRE_PERIOD_ms; } } else { - /* Reset fatal error related variables */ + /* No error detected anymore - reset fatal error related variables */ bms_state.minimumActiveDelay_ms = BMS_NO_ACTIVE_DELAY_TIME_ms; bms_state.minimumActiveDelay_ms = BMS_NO_ACTIVE_DELAY_TIME_ms; bms_state.transitionToErrorState = false; - + /* Check for STANDBY request */ bms_state.timer = BMS_STATEMACH_SHORTTIME; bms_state.substate = BMS_CHECK_STATE_REQUESTS; break; } } else if (bms_state.substate == BMS_CHECK_STATE_REQUESTS) { if (BMS_CheckCanRequests() == BMS_REQ_ID_STANDBY) { - ILCK_SetStateRequest(ILCK_STATE_CLOSE_REQUEST); - bms_state.substate = BMS_CHECK_INTERLOCK_CLOSE_AFTER_ERROR; - bms_state.timer = BMS_STATEMACH_MEDIUMTIME; - - /** Remove statements below once interlock module is working */ - bms_state.state = BMS_STATEMACH_OPENCONTACTORS; - bms_state.nextstate = BMS_STATEMACH_STANDBY; - bms_state.substate = BMS_ENTRY; - /** Remove statements above once interlock module is working */ - - break; - } else { - bms_state.timer = BMS_STATEMACH_SHORTTIME; - bms_state.substate = BMS_CHECK_ERROR_FLAGS; - break; - } - } else if (bms_state.substate == BMS_CHECK_INTERLOCK_CLOSE_AFTER_ERROR) { - if (ILCK_GetInterlockFeedback() == ILCK_SWITCH_ON) { - /* TODO: check */ + /* Activate balancing again */ BAL_SetStateRequest(BAL_STATE_ALLOWBALANCING_REQUEST); - bms_state.timer = BMS_STATEMACH_SHORTTIME; - /* Only valid as interlock module is not active */ + /* Set LED frequency to normal operation as we leave error + state subsequently */ + LED_SetToggleTime(LED_NORMAL_OPERATION_ON_OFF_TIME_ms); + + /* Verify that all contactors are opened and switch to + * STANDBY state afterwards */ bms_state.state = BMS_STATEMACH_OPENCONTACTORS; bms_state.nextstate = BMS_STATEMACH_STANDBY; bms_state.substate = BMS_ENTRY; @@ -1257,6 +1243,9 @@ void BMS_Trigger(void) { bms_state.substate = BMS_CHECK_ERROR_FLAGS; break; } + } else { + /* invalid state -> this should never be reached */ + FAS_ASSERT(FAS_TRAP); } break; default: diff --git a/src/app/application/bms/bms.h b/src/app/application/bms/bms.h index 16f51d19..8ed98517 100644 --- a/src/app/application/bms/bms.h +++ b/src/app/application/bms/bms.h @@ -117,16 +117,14 @@ typedef enum BMS_CANSTATE { /** Substates of the SYS state machine */ typedef enum BMS_STATEMACH_SUB { - BMS_ENTRY, /*!< Substate entry state */ - BMS_CHECK_ERROR_FLAGS_INTERLOCK, /*!< Substate check measurements after interlock closed */ - BMS_INTERLOCK_CHECKED, /*!< Substate interlocked checked */ - BMS_CHECK_STATE_REQUESTS, /*!< Substate check if there is a state request */ - BMS_CHECK_BALANCING_REQUESTS, /*!< Substate check if there is a balancing request */ - BMS_CHECK_ERROR_FLAGS, /*!< Substate check if any error flag set */ - BMS_CHECK_CONTACTOR_NORMAL_STATE, /*!< Substate in precharge, check if there contactors reached normal */ - BMS_CHECK_CONTACTOR_CHARGE_STATE, /*!< Substate in precharge, check if there contactors reached normal */ - BMS_OPEN_INTERLOCK, /*!< Substate in error to open interlock after contactors have been opened */ - BMS_CHECK_INTERLOCK_CLOSE_AFTER_ERROR, /*!< Substate in error to close interlock after all error flags were reset */ + BMS_ENTRY, /*!< Substate entry state */ + BMS_CHECK_ERROR_FLAGS_INTERLOCK, /*!< Substate check measurements after interlock closed */ + BMS_INTERLOCK_CHECKED, /*!< Substate interlocked checked */ + BMS_CHECK_STATE_REQUESTS, /*!< Substate check if there is a state request */ + BMS_CHECK_BALANCING_REQUESTS, /*!< Substate check if there is a balancing request */ + BMS_CHECK_ERROR_FLAGS, /*!< Substate check if any error flag set */ + BMS_CHECK_CONTACTOR_NORMAL_STATE, /*!< Substate in precharge, check if there contactors reached normal */ + BMS_CHECK_CONTACTOR_CHARGE_STATE, /*!< Substate in precharge, check if there contactors reached normal */ BMS_PRECHARGE_CLOSE_MINUS, BMS_PRECHARGE_CLOSE_PRECHARGE, BMS_PRECHARGE_CHECK_VOLTAGES, diff --git a/src/app/application/config/battery_system_cfg.h b/src/app/application/config/battery_system_cfg.h index c1a97f47..386349d4 100644 --- a/src/app/application/config/battery_system_cfg.h +++ b/src/app/application/config/battery_system_cfg.h @@ -165,9 +165,9 @@ typedef enum BS_STRING_ID { #define BS_NR_OF_TEMP_SENSORS (BS_NR_OF_TEMP_SENSORS_PER_STRING * BS_NR_OF_STRINGS) /** number of temperature sensors on each ADC0 channel of the slave-board */ -#define BS_NR_OF_TEMP_SENSORS_ON_ADC0 (3u) +#define BS_NR_OF_TEMP_SENSORS_ON_SADC0 (3u) /** number of temperature sensors on each ADC1 channel of the slave-board */ -#define BS_NR_OF_TEMP_SENSORS_ON_ADC1 (3u) +#define BS_NR_OF_TEMP_SENSORS_ON_SADC1 (3u) /** * @details - If set to false, foxBMS does not check for the presence of a @@ -212,6 +212,14 @@ typedef enum BS_STRING_ID { */ #define BS_MAXIMUM_PACK_CURRENT_mA (10000u * BS_NR_OF_STRINGS) +/** + * @ingroup CONFIG_BATTERYSYSTEM + * @brief Define if interlock feedback should be discarded or not + * @details True: interlock feedback will be discarded + * False: interlock feedback will evaluated + */ +#define BS_IGNORE_INTERLOCK_FEEDBACK (false) + /** * @details - If set to false, foxBMS does not check CAN timing. * - If set to true, foxBMS checks CAN timing. A valid request must diff --git a/src/app/application/config/bms_cfg.h b/src/app/application/config/bms_cfg.h index 51a450c6..11c9f60e 100644 --- a/src/app/application/config/bms_cfg.h +++ b/src/app/application/config/bms_cfg.h @@ -111,12 +111,6 @@ */ #define BMS_STATEMACH_LONGTIME (10u) -/** - * @brief BMS statemachine very long time definition in #BMS_Trigger() calls - * until next state/substate is processed - */ -#define BMS_STATEMACH_VERYLONGTIME (20u) - /** Time in #BMS_Trigger() calls to wait after closing a string */ #define BMS_TIME_WAIT_AFTER_STRING_CLOSED (20u) diff --git a/src/app/application/config/plausibility_cfg.h b/src/app/application/config/plausibility_cfg.h index a9d2a997..9a3a912e 100644 --- a/src/app/application/config/plausibility_cfg.h +++ b/src/app/application/config/plausibility_cfg.h @@ -61,7 +61,7 @@ /** * @ingroup CONFIG_PLAUSIBILITY * @brief Maximum difference between pack voltage measurement from - * Measurement IC and current sensor + * AFE and current sensor * @ptype int * \par Range: * [0, 10000] diff --git a/src/app/application/plausibility/plausibility.c b/src/app/application/plausibility/plausibility.c index 0696d803..525b0d5d 100644 --- a/src/app/application/plausibility/plausibility.c +++ b/src/app/application/plausibility/plausibility.c @@ -70,11 +70,11 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e PL_CheckStringVoltage(int32_t voltageMic_mV, int32_t voltageCurrentSensor_mV) { +extern STD_RETURN_TYPE_e PL_CheckStringVoltage(int32_t voltageAfe_mV, int32_t voltageCurrentSensor_mV) { STD_RETURN_TYPE_e result = STD_NOT_OK; /* Get deviation between these two measurements */ - int32_t diff_mV = voltageMic_mV - voltageCurrentSensor_mV; + int32_t diff_mV = voltageAfe_mV - voltageCurrentSensor_mV; if (abs(diff_mV) < PL_STRING_VOLTAGE_TOLERANCE_mV) { result = STD_OK; diff --git a/src/app/application/plausibility/plausibility.h b/src/app/application/plausibility/plausibility.h index a0adbc0f..f57aec70 100644 --- a/src/app/application/plausibility/plausibility.h +++ b/src/app/application/plausibility/plausibility.h @@ -67,12 +67,12 @@ /** * @brief Pack voltage plausibility check between LTC and current sensor values * - * @param voltageMic_mV pack voltage measured by MIC + * @param voltageAfe_mV pack voltage measured by AFE * @param voltageCurrentSensor_mV pack voltage measured by current sensor * * @return #STD_OK if pack voltage valid, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e PL_CheckStringVoltage(int32_t voltageMic_mV, int32_t voltageCurrentSensor_mV); +extern STD_RETURN_TYPE_e PL_CheckStringVoltage(int32_t voltageAfe_mV, int32_t voltageCurrentSensor_mV); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/application/redundancy/redundancy.c b/src/app/application/redundancy/redundancy.c index 660addd0..fbcaeeac 100644 --- a/src/app/application/redundancy/redundancy.c +++ b/src/app/application/redundancy/redundancy.c @@ -43,7 +43,7 @@ * @file redundancy.c * @author foxBMS Team * @date 2020-07-31 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-10-14 (date of last update) * @ingroup APPLICATION * @prefix MRC * @@ -148,6 +148,11 @@ static void MRC_ValidateStringVoltageMeasurement( DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor, DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage); +/** + * @brief Function to validate battery voltage measurement + */ +static void MRC_ValidateBatteryVoltageMeasurement(void); + /** * @brief Function to validate results of high voltage measurement and calculate * battery voltage and high voltage bus voltage. @@ -311,7 +316,7 @@ static bool MRC_ValidateCellVoltageMeasurement( useCellvoltageRedundancy = DATA_DatabaseEntryUpdatedAtLeastOnce(pCellVoltageRedundancy0->header); /* ----------------- Check timestamp of base measurements--------------- */ - if (DATA_EntryUpdatedWithinInterval(pCellVoltageBase->header, MRC_MIC_MEASUREMENT_PERIOD_TIMEOUT_ms) == true) { + if (DATA_EntryUpdatedWithinInterval(pCellVoltageBase->header, MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms) == true) { baseCellvoltageMeasurementTimeoutReached = false; (void)DIAG_Handler(DIAG_ID_BASE_CELL_VOLTAGE_MESUREMENT_TIMEOUT, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); } else { @@ -328,7 +333,7 @@ static bool MRC_ValidateCellVoltageMeasurement( } /* ----------------- Check timestamp of redundant measurements --------- */ - if ((DATA_EntryUpdatedWithinInterval(pCellVoltageRedundancy0->header, MRC_MIC_MEASUREMENT_PERIOD_TIMEOUT_ms) == + if ((DATA_EntryUpdatedWithinInterval(pCellVoltageRedundancy0->header, MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms) == false) && (useCellvoltageRedundancy == true)) { redundancy0CellvoltageMeasurementTimeoutReached = true; @@ -438,7 +443,7 @@ static bool MRC_ValidateCellTemperatureMeasurement( useCelltemperatureRedundancy = DATA_DatabaseEntryUpdatedAtLeastOnce(pCellTemperatureRedundancy0->header); /* ----------------- Check timestamp of base measurements--------------- */ - if (DATA_EntryUpdatedWithinInterval(pCellTemperatureBase->header, MRC_MIC_MEASUREMENT_PERIOD_TIMEOUT_ms) == true) { + if (DATA_EntryUpdatedWithinInterval(pCellTemperatureBase->header, MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms) == true) { baseCellTemperatureMeasurementTimeoutReached = false; (void)DIAG_Handler(DIAG_ID_BASE_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); } else { @@ -454,7 +459,7 @@ static bool MRC_ValidateCellTemperatureMeasurement( } /* ----------------- Check timestamp of redundant measurements --------- */ - if ((DATA_EntryUpdatedWithinInterval(pCellTemperatureRedundancy0->header, MRC_MIC_MEASUREMENT_PERIOD_TIMEOUT_ms) == + if ((DATA_EntryUpdatedWithinInterval(pCellTemperatureRedundancy0->header, MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms) == false) && (useCelltemperatureRedundancy == true)) { redundancy0CellTemperatureMeasurementTimeoutReached = true; @@ -603,7 +608,7 @@ static void MRC_ValidateStringVoltageMeasurement( MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms); DIAG_CheckEvent(updatedMeasurement, DIAG_ID_CURRENT_SENSOR_V1_MEASUREMENT_TIMEOUT, DIAG_STRING, stringNumber); - /* Perform plausibility check if MIC and new current sensor measurement is valid */ + /* 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)) { @@ -611,7 +616,7 @@ static void MRC_ValidateStringVoltageMeasurement( pTableCellVoltage->packVoltage_mV[stringNumber], pTableCurrentSensor->highVoltage_mV[stringNumber][0u]); (void)DIAG_CheckEvent(voltagePlausible, DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, DIAG_STRING, stringNumber); - /* Use current sensor measurement */ /* TODO: use really current sensor? Average of both? MIC measurement? */ + /* Use current sensor measurement */ /* TODO: use really current sensor? Average of both? AFE measurement? */ mrc_tablePackValues.stringVoltage_mV[stringNumber] = pTableCurrentSensor->highVoltage_mV[stringNumber][0u]; if (STD_OK == voltagePlausible) { @@ -621,7 +626,7 @@ static void MRC_ValidateStringVoltageMeasurement( } } else { /* Plausibility check cannot be performed if we do not have valid - * values from MIC and current sensor measurement */ + * values from AFE and current sensor measurement */ (void)DIAG_CheckEvent(STD_NOT_OK, DIAG_ID_PLAUSIBILITY_PACK_VOLTAGE, DIAG_STRING, stringNumber); if ((STD_OK == updatedMeasurement) && @@ -631,11 +636,11 @@ static void MRC_ValidateStringVoltageMeasurement( pTableCurrentSensor->highVoltage_mV[stringNumber][0u]; mrc_tablePackValues.invalidStringVoltage[stringNumber] = 0u; } else if (pTableCellVoltage->nrValidCellVoltages[stringNumber] == BS_NR_OF_BAT_CELLS) { - /* MIC measurement valid -> use this measurement */ + /* AFE measurement valid -> use this measurement */ mrc_tablePackValues.stringVoltage_mV[stringNumber] = pTableCellVoltage->packVoltage_mV[stringNumber]; mrc_tablePackValues.invalidStringVoltage[stringNumber] = 0u; } else { - /* MIC and current sensor measurement invalid -> try to construct + /* 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 = @@ -657,6 +662,44 @@ static void MRC_ValidateStringVoltageMeasurement( } } +static void MRC_ValidateBatteryVoltageMeasurement(void) { + int64_t sumOfStringValues_mV = 0; + int8_t numberOfValidStringVoltages = 0; + uint8_t numberOfConnectedStrings = BMS_GetNumberOfConnectedStrings(); + + if (0u != numberOfConnectedStrings) { + /* 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)) { + /* 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++; + /* AXIVION Enable Style MisraC2012Directive-4.1: */ + } + } + } 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]) { + /* 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++; + /* AXIVION Enable Style MisraC2012Directive-4.1: */ + } + } + } + + /* Only calculate average if at least one string voltage is valid */ + if (0 != numberOfValidStringVoltages) { + /* AXIVION Disable Style MisraC2012Directive-4.1: truncation impossible; we sum INT32 values x times and divide by x, resulting in INT32 */ + mrc_tablePackValues.batteryVoltage_mV = (int32_t)(sumOfStringValues_mV / numberOfValidStringVoltages); + /* AXIVION Enable Style MisraC2012Directive-4.1: */ + } else { + mrc_tablePackValues.batteryVoltage_mV = INT32_MAX; + } +} + static void MRC_ValidateHighVoltageBusMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor) { FAS_ASSERT(pTableCurrentSensor != NULL_PTR); @@ -1091,7 +1134,7 @@ extern STD_RETURN_TYPE_e MRC_Initialize(void) { return retval; } -extern STD_RETURN_TYPE_e MRC_ValidateMicMeasurement(void) { +extern STD_RETURN_TYPE_e MRC_ValidateAfeMeasurement(void) { STD_RETURN_TYPE_e retval = STD_OK; DATA_BLOCK_CELL_VOLTAGE_s cellvoltageBase = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE}; @@ -1132,6 +1175,7 @@ extern STD_RETURN_TYPE_e MRC_ValidatePackMeasurement(void) { MRC_ValidateCurrentMeasurement(&tableCurrentSensor); MRC_ValidateStringVoltageMeasurement(&tableCurrentSensor, &mrc_tableCellVoltages); + MRC_ValidateBatteryVoltageMeasurement(); MRC_ValidateHighVoltageBusMeasurement(&tableCurrentSensor); MRC_ValidatePowerMeasurement(&tableCurrentSensor); @@ -1174,6 +1218,9 @@ extern void TEST_MRC_ValidateStringVoltageMeasurement( DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage) { MRC_ValidateStringVoltageMeasurement(pTableCurrentSensor, pTableCellVoltage); } +extern void TEST_MRC_ValidateBatteryVoltageMeasurement(void) { + MRC_ValidateBatteryVoltageMeasurement(); +} extern void TEST_MRC_ValidateHighVoltageMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor) { MRC_ValidateHighVoltageBusMeasurement(pTableCurrentSensor); } diff --git a/src/app/application/redundancy/redundancy.h b/src/app/application/redundancy/redundancy.h index 8c429460..9a55c3a7 100644 --- a/src/app/application/redundancy/redundancy.h +++ b/src/app/application/redundancy/redundancy.h @@ -43,7 +43,7 @@ * @file redundancy.h * @author foxBMS Team * @date 2020-07-31 (date of creation) - * @updated 2020-07-31 (date of last update) + * @updated 2021-10-14 (date of last update) * @ingroup APPLICATION * @prefix MRC * @@ -73,18 +73,18 @@ #define MRC_CURRENT_MEASUREMENT_PERIOD_TIMEOUT_ms (250u) /** - * Maximum time between MIC measurements before the + * Maximum time between AFE measurements before the * redundancy module raises an error because a * measurement is not updated anymore. * * The redundancy module will wait a maximum of this - * time for new values from the base MIC measurement and - * MIC redundant measurements. If no new values are updated + * time for new values from the base AFE measurement and + * AFE redundant measurements. If no new values are updated * from both measurement sources within this timeframe * it will validate the measurement values it has up to * this point if possible. */ -#define MRC_MIC_MEASUREMENT_PERIOD_TIMEOUT_ms (250u) +#define MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms (250u) /** * Maximum time between current sensor high voltage, current @@ -100,7 +100,7 @@ #define MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms (300u) /** - * If both, the current sensor and the MIC measurement have no valid values + * If both, the current sensor and the AFE measurement have no valid values * we try to construct the string voltage by replacing invalid cell voltage * measurements with the average cell voltage in this string. The result of * this estimation will be flagged as invalid if more than the number of @@ -137,7 +137,7 @@ extern STD_RETURN_TYPE_e MRC_Initialize(void); * @return #STD_OK if measurement has been validated successfully, otherwise i.e. * if no new values have been measured since the last call #STD_NOT_OK */ -extern STD_RETURN_TYPE_e MRC_ValidateMicMeasurement(void); +extern STD_RETURN_TYPE_e MRC_ValidateAfeMeasurement(void); /** * @brief Function to validate the measurements of pack values (string values, @@ -166,6 +166,7 @@ extern void TEST_MRC_ValidatePowerMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTabl extern void TEST_MRC_ValidateStringVoltageMeasurement( DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor, DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage); +extern void TEST_MRC_ValidateBatteryVoltageMeasurement(void); extern void TEST_MRC_ValidateHighVoltageMeasurement(DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor); extern STD_RETURN_TYPE_e TEST_MRC_CalculateCellVoltageMinMaxAverage( DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages, diff --git a/src/app/application/wscript b/src/app/application/wscript index aef47fc5..03d18755 100644 --- a/src/app/application/wscript +++ b/src/app/application/wscript @@ -80,6 +80,7 @@ def build(bld): os.path.join("..", "driver", "dma"), os.path.join("..", "driver", "foxmath"), os.path.join("..", "driver", "fram"), + os.path.join("..", "driver", "led"), os.path.join("..", "driver", "meas"), os.path.join("..", "driver", "sbc"), os.path.join("..", "driver", "sbc", "fs8x_driver"), @@ -92,7 +93,7 @@ def build(bld): os.path.join("..", "task", "config"), os.path.join("..", "task", "os"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS target = f"{bld.env.APPNAME.lower()}-application" diff --git a/src/app/driver/adc/adc.c b/src/app/driver/adc/adc.c index ce17ccaf..4dd72363 100644 --- a/src/app/driver/adc/adc.c +++ b/src/app/driver/adc/adc.c @@ -54,25 +54,10 @@ /*========== Includes =======================================================*/ #include "adc.h" -#include "beta.h" #include "database.h" -#include "epcos_b57251v5103j060.h" -#include "io.h" -#include "spi.h" /*========== Macros and Definitions =========================================*/ -/** scaling factor for the conversion of a measurement value to a temperature */ -#define ADC_TEMPERATURE_FACTOR (10.0f) - -/** - * Type of temperature sensors - */ -typedef enum ADC_TEMPERATURE_SENSOR_TYPE { - ADC0_TEMPERATURE_SENSOR, /*!< First ADC (ADC0) */ - ADC1_TEMPERATURE_SENSOR, /*!< Second ADC (ADC1) */ -} ADC_TEMPERATURE_SENSOR_TYPE_e; - /*========== Static Constant and Variable Definitions =======================*/ /** @@ -80,261 +65,62 @@ typedef enum ADC_TEMPERATURE_SENSOR_TYPE { * @details This variable is used as a state-variable for switching through the * steps of a conversion. */ -static uint8_t adc_conversionState = ADC_INIT; +static ADC_STATE_e adc_conversionState = ADC_START_CONVERSION; -/** NULL command sent to initialize the ADC */ -static uint16_t adc_txNull[SINGLE_MESSAGE_LENGTH] = {0x0000u, 0x0000u}; +static adcData_t adc1RawVoltages[ADC_ADC1_MAX_NR_CHANNELS] = {0}; -/** - * Unlock command for the ADC - * When ADC is locked, regsiters cannot be written - */ -static uint16_t adc_txUnlockCommand[SINGLE_MESSAGE_LENGTH] = {0x0655u, 0x0000u}; - -/** - * Lock command the ADC - * When ADC is locked, regsiters cannot be written - */ -static uint16_t adc_txLockCommand[SINGLE_MESSAGE_LENGTH] = {0x0555u, 0x0000u}; - -/** The wake-up command starts the conversions by the ADC */ -static uint16_t adc_txWakeupCommand[SINGLE_MESSAGE_LENGTH] = {0x0033u, 0x0000u}; - -/** This command is used to read registers */ -static uint16_t adc_txReadRegisterCommand[SINGLE_MESSAGE_LENGTH] = {0x2F00u, 0x0000u}; - -/** This command is used to write registers */ -static uint16_t adc_txWriteRegisterCommand[SINGLE_MESSAGE_LENGTH] = {0x4F0Fu, 0x0000u}; - -/** - * This is a generic purpose receive buffer. - * It is used to read the answer of the ADC to the commands - * defined above. - */ -static uint16_t adc_rxReadSingleMessage[SINGLE_MESSAGE_LENGTH] = {0x0000u, 0x0000u}; - -/** - * This message is used to read conversion results - * It consists of NULL commands. When receiving NULL commands, - * the ADC outputs conversion data on the MasterInSlaveOut line. - */ -static uint16_t adc_txConvert[CONVERT_LENGTH] = - {0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u}; - -/** This message is used to get the result of conversions */ -static uint16_t adc_rxConvert[CONVERT_LENGTH] = - {0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u, 0x0000u}; - -/** Voltages measured by the 4 channels of ADC0 */ -static float adc_adc0Voltage[4] = {0.0f, 0.0f, 0.0f, 0.0f}; -/** Voltages measured by the 4 channels of ADC1 */ -static float adc_adc1Voltage[4] = {0.0f, 0.0f, 0.0f, 0.0f}; -/** LSB of ADC0, used to convert raw measurement to voltage in V */ -static float adc_lsb1 = 0.0f; -/** LSB of ADC1, used to convert raw measurement to voltage in V */ -static float adc_lsb2 = 0.0f; - -/** local copy of the adc temperature table */ -static DATA_BLOCK_ADC_TEMPERATURE_s adc_tableTemperature = {.header.uniqueId = DATA_BLOCK_ID_ADC_TEMPERATURE}; +static DATA_BLOCK_ADC_VOLTAGE_s adc1Voltages = {.header.uniqueId = DATA_BLOCK_ID_ADC_VOLTAGE}; /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ -/** transmission wrapper for the SPI communication to the ADC */ -static STD_RETURN_TYPE_e ADC_Transmit( - uint32 blocksize, - uint16 *pTxBuffer, - uint16 *pRxBuffer, - SPI_INTERFACE_CONFIG_s *pSpiInterface); - /** - * @brief converts a raw voltage from ADC to a temperature value in Celsius. - * - * The temperatures are read from NTC elements via voltage dividers. - * This function implements the look-up table between voltage and temperature, - * taking into account the NTC characteristics and the voltage divider. - * - * @param v_adc_V voltage read from ADC in V - * @param TsensorType sensor type, dependent on ADC used (ADC0 or ADC1) - * - * @return temperature value in deci °C + * @brief converts reading from ADC to a voltage in mV. + * @param adcValue_mV value read from ADC + * @return voltage in mV */ -static float ADC_ConvertVoltagesToTemperatures(float v_adc_V, ADC_TEMPERATURE_SENSOR_TYPE_e TsensorType); +static float ADC_ConvertVoltage(float adcValue_mV); /*========== Static Function Implementations ================================*/ -static STD_RETURN_TYPE_e ADC_Transmit( - uint32 blocksize, - uint16 *pTxBuffer, - uint16 *pRxBuffer, - SPI_INTERFACE_CONFIG_s *pSpiInterface) { - FAS_ASSERT(pTxBuffer != NULL_PTR); - FAS_ASSERT(pRxBuffer != NULL_PTR); - FAS_ASSERT(pSpiInterface != NULL_PTR); - - return SPI_TransmitReceiveData(pSpiInterface, pTxBuffer, pRxBuffer, blocksize); -} - -static float ADC_ConvertVoltagesToTemperatures(float v_adc_V, ADC_TEMPERATURE_SENSOR_TYPE_e TsensorType) { - float temperature_degC = 0.0f; - if (TsensorType == ADC0_TEMPERATURE_SENSOR) { - temperature_degC = ADC_TEMPERATURE_FACTOR * TS_Epc00GetTemperatureFromLut((uint16_t)(v_adc_V * 1000.0f)); - } else if (TsensorType == ADC1_TEMPERATURE_SENSOR) { - temperature_degC = ADC_TEMPERATURE_FACTOR * BETA_GetTemperatureFromBeta((uint16_t)(v_adc_V * 1000.0f)); - } else { - temperature_degC = ADC_TEMPERATURE_FACTOR * v_adc_V; - } +static float ADC_ConvertVoltage(float adcValue_mV) { + /** 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; - return (10.0f * temperature_degC); /* Convert to deci °C */ + return result_mV; } /*========== Extern Function Implementations ================================*/ -void ADC_Initialize(void) { - /* set reset pin to output */ - ADC_HET1_GIO->DIR |= (uint32)((uint32)1u << ADC_HET1_RESET_PIN); +extern void ADC_Control(void) { + bool conversionFinished = true; - /* first set reset pin to 0 */ - IO_PinReset(&ADC_HET1_GIO->DOUT, ADC_HET1_RESET_PIN); - /* wait after pin toggle */ - for (uint8_t i = 0u; i < 20u; i++) { - } - /* set reset pin to 1 to go out of reset */ - IO_PinSet(&ADC_HET1_GIO->DOUT, ADC_HET1_RESET_PIN); - - /* LSB computation, datasheet equation 9 page 38 */ - adc_lsb1 = (2 * ADC_VREF_1 / ADC_GAIN) / (16777216.0f); - adc_lsb2 = (2 * ADC_VREF_2 / ADC_GAIN) / (16777216.0f); -} - -void ADC_Control(void) { switch (adc_conversionState) { - case ADC_INIT: - /* set reset pin to output */ - ADC_HET1_GIO->DIR |= (uint32)((uint32)1u << ADC_HET1_RESET_PIN); - /* first set reset pin to 0 */ - IO_PinReset(&ADC_HET1_GIO->DOUT, ADC_HET1_RESET_PIN); - adc_conversionState = ADC_ENDINIT; - break; - - case ADC_ENDINIT: - /* set reset pin to 1 to go out of reset */ - IO_PinSet(&ADC_HET1_GIO->DOUT, ADC_HET1_RESET_PIN); - /* LSB computation, datasheet equation 9 page 38 */ - adc_lsb1 = (2 * ADC_VREF_1 / ADC_GAIN) / (16777216.0f); - adc_lsb2 = (2 * ADC_VREF_2 / ADC_GAIN) / (16777216.0f); - adc_conversionState = ADC_READY; - break; - - /* Start initialization procedure, datasheet figure 106 page 79 */ - case ADC_READY: - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txNull, adc_rxReadSingleMessage, &spi_adc0Interface); - /* if device 1 is ready after startup */ - if (adc_rxReadSingleMessage[0] == 0xFF04u) { - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txNull, adc_rxReadSingleMessage, &spi_adc1Interface); - /* if device 2 is ready after startup */ - if (adc_rxReadSingleMessage[0] == 0xFF04u) { - adc_conversionState = ADC_UNLOCK; - } - } - break; - - case ADC_UNLOCK: - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txUnlockCommand, adc_rxReadSingleMessage, &spi_adc0Interface); - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txUnlockCommand, adc_rxReadSingleMessage, &spi_adc1Interface); - adc_conversionState = ADC_UNLOCKED; - break; - - case ADC_UNLOCKED: - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txNull, adc_rxReadSingleMessage, &spi_adc0Interface); - /* if unlock message received by ADC 1*/ - if (adc_rxReadSingleMessage[0] == 0x0655u) { - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txNull, adc_rxReadSingleMessage, &spi_adc1Interface); - /* if unlock message received by ADC 2*/ - if (adc_rxReadSingleMessage[0] == 0x0655u) { - adc_conversionState = ADC_WRITE_ADC_ENA; - } - } - break; - - case ADC_WRITE_ADC_ENA: - ADC_Transmit( - SINGLE_MESSAGE_LENGTH, adc_txWriteRegisterCommand, adc_rxReadSingleMessage, &spi_adc0Interface); - ADC_Transmit( - SINGLE_MESSAGE_LENGTH, adc_txWriteRegisterCommand, adc_rxReadSingleMessage, &spi_adc1Interface); - adc_conversionState = ADC_READ_ADC_ENA; - break; - - case ADC_READ_ADC_ENA: - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txReadRegisterCommand, adc_rxReadSingleMessage, &spi_adc0Interface); - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txReadRegisterCommand, adc_rxReadSingleMessage, &spi_adc1Interface); - adc_conversionState = ADC_CHECK_ADC_ENA; - break; - - case ADC_CHECK_ADC_ENA: - /* If register not written successfully, retry */ - adc_conversionState = ADC_WRITE_ADC_ENA; - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txNull, adc_rxReadSingleMessage, &spi_adc0Interface); - /* if ADC 1 register written successfully */ - if ((adc_rxReadSingleMessage[0] & 0xFFu) == 0x0Fu) { - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txNull, adc_rxReadSingleMessage, &spi_adc1Interface); - /* if ADC 1 register written successfully */ - if ((adc_rxReadSingleMessage[0] & 0xFFu) == 0x0Fu) { - adc_conversionState = ADC_WAKEUP; - } - } - break; - - case ADC_WAKEUP: - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txWakeupCommand, adc_rxReadSingleMessage, &spi_adc0Interface); - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txWakeupCommand, adc_rxReadSingleMessage, &spi_adc1Interface); - adc_conversionState = ADC_LOCK; + case ADC_START_CONVERSION: + adcStartConversion(adcREG1, adcGROUP1); + adc_conversionState = ADC_WAIT_CONVERSION_FINISHED; break; - case ADC_LOCK: - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txLockCommand, adc_rxReadSingleMessage, &spi_adc0Interface); - ADC_Transmit(SINGLE_MESSAGE_LENGTH, adc_txLockCommand, adc_rxReadSingleMessage, &spi_adc1Interface); - adc_conversionState = ADC_CONVERT_1; - break; - /* end initialization procedure, datasheet figure 106 page 79 */ - - /* To read channel data (i.e., measured voltages), send null message */ - case ADC_CONVERT_1: - /* The first 3 voltages are the NTCs located on the master board */ - ADC_Transmit(CONVERT_LENGTH, adc_txConvert, adc_rxConvert, &spi_adc0Interface); - for (uint8_t i = 0u; i < ADC_NUMBER_OF_CHANNELS; i++) { - /* datasheet SBAS590D -MARCH 2016-REVISED JANUARY 2018 */ - /* ADC in 32 bit mode (M1 tied to IOVDD via 1kOhm), 24 bits output by ADC, datasheet page 38 */ - adc_adc0Voltage[i] = (adc_rxConvert[2u + (2u * i)] << 8u) | - ((adc_rxConvert[3u + (2u * i)] >> 8u) & 0xFFu); - adc_adc0Voltage[i] *= adc_lsb1; + case ADC_WAIT_CONVERSION_FINISHED: + conversionFinished = true; + if (ADC_CONVERSION_ENDDBIT != adcIsConversionComplete(adcREG1, adcGROUP1)) { + conversionFinished = false; } - adc_conversionState = ADC_CONVERT_2; - DATA_READ_DATA(&adc_tableTemperature); - for (uint8_t i = 0u; i < BS_NR_OF_TEMP_SENSORS_ON_ADC0; i++) { - adc_tableTemperature.temperatureAdc0_ddegC[i] = - ADC_ConvertVoltagesToTemperatures(adc_adc0Voltage[i], ADC0_TEMPERATURE_SENSOR); + if (conversionFinished == true) { + adc_conversionState = ADC_CONVERSION_FINISHED; } - DATA_WRITE_DATA(&adc_tableTemperature); break; - case ADC_CONVERT_2: - /* The first 3 voltages are the external NTCs connected to the master board */ - ADC_Transmit(CONVERT_LENGTH, adc_txConvert, adc_rxConvert, &spi_adc1Interface); - for (uint8_t i = 0u; i < ADC_NUMBER_OF_CHANNELS; i++) { - /* ADC in 32 bit mode (M1 tied to IOVDD via 1kOhm), 24 bits output by ADC, datasheet page 38 */ - adc_adc1Voltage[i] = (adc_rxConvert[2u + (2u * i)] << 8u) | - ((adc_rxConvert[3u + (2u * i)] >> 8u) & 0xFFu); - adc_adc1Voltage[i] *= adc_lsb2; - } - adc_conversionState = ADC_CONVERT_1; - DATA_READ_DATA(&adc_tableTemperature); - for (uint8_t i = 0u; i < BS_NR_OF_TEMP_SENSORS_ON_ADC1; i++) { - adc_tableTemperature.temperatureAdc1_ddegC[i] = - ADC_ConvertVoltagesToTemperatures(adc_adc1Voltage[i], ADC1_TEMPERATURE_SENSOR); + /* Start initialization procedure, datasheet figure 106 page 79 */ + case ADC_CONVERSION_FINISHED: + adcGetData(adcREG1, adcGROUP1, &adc1RawVoltages[0]); + for (uint8_t i = 0U; i < ADC_ADC1_MAX_NR_CHANNELS; i++) { + adc1Voltages.adc1ConvertedVoltages_mV[i] = ADC_ConvertVoltage((float)(adc1RawVoltages[i].value)); } - DATA_WRITE_DATA(&adc_tableTemperature); + DATA_WRITE_DATA(&adc1Voltages); + adc_conversionState = ADC_START_CONVERSION; break; default: diff --git a/src/app/driver/adc/adc.h b/src/app/driver/adc/adc.h index 30978e55..4e22b4d3 100644 --- a/src/app/driver/adc/adc.h +++ b/src/app/driver/adc/adc.h @@ -59,49 +59,29 @@ #include "battery_system_cfg.h" -#include "io.h" -#include "spi.h" +#include "HL_adc.h" /*========== Macros and Definitions =========================================*/ -/** HET1 GIO register that the ADC is connected to. */ -#define ADC_HET1_GIO (hetREG1) -/** Pin of HET1 that the ADC Reset is connected to. */ -#define ADC_HET1_RESET_PIN (28U) +/** ADC voltage reference, high */ +#define ADC_VREFHIGH_mV (5000.0f) +/** ADC voltage reference, low */ +#define ADC_VREFLOW_mV (0.0f) +/** ADC conversion factor, 12 bit conversion */ +#define ADC_CONV_FACTOR_12BIT (4096.0f) +/** ADC conversion factor, 10 bit conversion */ +#define ADC_CONV_FACTOR_10BIT (1024.0f) -/** Voltage reference used by ADC0 */ -#define ADC_VREF_1 (2.5f) -/** Voltage reference used by ADC1 */ -#define ADC_VREF_2 (4.096f) -/** ADC digital gain, set in registers 0x11 to 0x14 */ -#define ADC_GAIN (1.0f) - -/** - * Size of SPI messages used to send commands to the ADC - * Example of commands: NULL, read or write register, lock, unlock... - */ -#define SINGLE_MESSAGE_LENGTH (2U) -/** Size of SPI messages used to retrieve conversion results of the ADC */ -#define CONVERT_LENGTH (10U) -/** Number of channels measured by the ADC. ADS131A04 has four channels. */ -#define ADC_NUMBER_OF_CHANNELS (4U) +/** End bit position in ADC Groupx Interrupt Flag Register */ +#define ADC_CONVERSION_ENDDBIT (8U) /** * State for the ADC conversion */ typedef enum { - ADC_INIT, - ADC_ENDINIT, - ADC_READY, - ADC_UNLOCK, - ADC_UNLOCKED, - ADC_WRITE_ADC_ENA, - ADC_READ_ADC_ENA, - ADC_CHECK_ADC_ENA, - ADC_WAKEUP, - ADC_LOCK, - ADC_CONVERT_1, - ADC_CONVERT_2, + ADC_START_CONVERSION, + ADC_WAIT_CONVERSION_FINISHED, + ADC_CONVERSION_FINISHED, } ADC_STATE_e; /*========== Extern Constant and Variable Declarations ======================*/ @@ -109,14 +89,8 @@ typedef enum { /*========== Extern Function Prototypes =====================================*/ /** - * @brief initializes the ADC devices. It is called during startup. - */ -extern void ADC_Initialize(void); - -/** - * @brief determines which ADC is measured and stores result in database. - * @details It alternates between measurement on ADC1 and ADC2. Measurement - * read by SPI. + * @brief controls ADC measurement sequence. + * */ extern void ADC_Control(void); diff --git a/src/app/driver/mic/api/mic.h b/src/app/driver/afe/api/afe.h similarity index 71% rename from src/app/driver/mic/api/mic.h rename to src/app/driver/afe/api/afe.h index b624d376..2fa0402e 100644 --- a/src/app/driver/mic/api/mic.h +++ b/src/app/driver/afe/api/afe.h @@ -40,20 +40,20 @@ */ /** - * @file mic.h + * @file afe.h * @author foxBMS Team * @date 2020-05-08 (date of creation) * @updated 2020-06-17 (date of last update) * @ingroup DRIVER - * @prefix MIC + * @prefix AFE * - * @brief Measurement IC driver header + * @brief AFE driver header * * @details TODO */ -#ifndef FOXBMS__MIC_H_ -#define FOXBMS__MIC_H_ +#ifndef FOXBMS__AFE_H_ +#define FOXBMS__AFE_H_ /*========== Includes =======================================================*/ #include "general.h" @@ -61,82 +61,82 @@ /*========== Macros and Definitions =========================================*/ /** period for open wire measurement */ -#define MIC_ERROR_OPEN_WIRE_PERIOD_ms (30000) +#define AFE_ERROR_OPEN_WIRE_PERIOD_ms (30000) /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ /** tick function, this function is called to advance the state machine */ -extern STD_RETURN_TYPE_e MIC_TriggerIc(void); -/** initializer, this function is called in order to initialize the MIC */ -extern STD_RETURN_TYPE_e MIC_Init(void); -/** this function should tell the MIC that it should start measuring */ -extern STD_RETURN_TYPE_e MIC_StartMeasurement(void); +extern STD_RETURN_TYPE_e AFE_TriggerIc(void); +/** initializer, this function is called in order to initialize the AFE */ +extern STD_RETURN_TYPE_e AFE_Initialize(void); +/** this function should tell the AFE that it should start measuring */ +extern STD_RETURN_TYPE_e AFE_StartMeasurement(void); /** this function returns whether the first measurement cycle has finished */ -extern bool MIC_IsFirstMeasurementCycleFinished(void); +extern bool AFE_IsFirstMeasurementCycleFinished(void); /** - * @brief Checks if the first MIC measurement cycle was made + * @brief Checks if the first AFE measurement cycle was made * @return true is the first measurement cycle was made, false * otherwise */ -extern bool MIC_IsFirstMeasurementCycleFinished(void); +extern bool AFE_IsFirstMeasurementCycleFinished(void); /** - * @brief Makes the initialization request to the MIC state machine + * @brief Makes the initialization request to the AFE state machine * @return true or false */ -extern STD_RETURN_TYPE_e MIC_StartMeasurement(void); +extern STD_RETURN_TYPE_e AFE_StartMeasurement(void); /** - * @brief Makes the request to the MIC state machine to write to the + * @brief Makes the request to the AFE state machine to write to the * IO port-expander * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestIoWrite(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestIoWrite(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read from the + * @brief Makes the request to the AFE state machine to read from the * IO port-expander * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestIoRead(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestIoRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read from the + * @brief Makes the request to the AFE state machine to read from the * external temperature sensor on slaves * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestTemperatureRead(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestTemperatureRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read + * @brief Makes the request to the AFE state machine to read * balancing feedback from the slaves * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestBalancingFeedbackRead(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestBalancingFeedbackRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read from the + * @brief Makes the request to the AFE state machine to read from the * external EEPROM on slaves * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestEepromRead(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestEepromRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to write to the + * @brief Makes the request to the AFE state machine to write to the * external EEPROM on slaves * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestEepromWrite(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestEepromWrite(uint8_t string); /** - * @brief Makes the request to the MIC state machine to perform + * @brief Makes the request to the AFE state machine to perform * open-wire check * @param string string addressed by the request */ -extern STD_RETURN_TYPE_e MIC_RequestOpenWireCheck(uint8_t string); +extern STD_RETURN_TYPE_e AFE_RequestOpenWireCheck(uint8_t string); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__MIC_H_ */ +#endif /* FOXBMS__AFE_H_ */ diff --git a/src/app/driver/mic/api/mic_dma.h b/src/app/driver/afe/api/afe_dma.h similarity index 93% rename from src/app/driver/mic/api/mic_dma.h rename to src/app/driver/afe/api/afe_dma.h index 68860eba..eedd707c 100644 --- a/src/app/driver/mic/api/mic_dma.h +++ b/src/app/driver/afe/api/afe_dma.h @@ -40,19 +40,19 @@ */ /** - * @file mic_dma.h + * @file afe_dma.h * @author foxBMS Team * @date 2020-06-18 (date of creation) * @updated 2020-06-18 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Headers for the driver for the general DMA module of monitoring ICs. * */ -#ifndef FOXBMS__MIC_DMA_H_ -#define FOXBMS__MIC_DMA_H_ +#ifndef FOXBMS__AFE_DMA_H_ +#define FOXBMS__AFE_DMA_H_ /*========== Includes =======================================================*/ #include "dma_cfg.h" @@ -67,8 +67,8 @@ * @param inttype type of DMA interrupt (e.g., block, frame) * @param channel DMA channel that caused the interrupt */ -void MIC_DmaCallback(dmaInterrupt_t inttype, uint32 channel); +void AFE_DmaCallback(dmaInterrupt_t inttype, uint32 channel); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__MIC_DMA_H_ */ +#endif /* FOXBMS__AFE_DMA_H_ */ diff --git a/src/app/driver/mic/api/mic_plausibility.c b/src/app/driver/afe/api/afe_plausibility.c similarity index 92% rename from src/app/driver/mic/api/mic_plausibility.c rename to src/app/driver/afe/api/afe_plausibility.c index a544bedb..f115259f 100644 --- a/src/app/driver/mic/api/mic_plausibility.c +++ b/src/app/driver/afe/api/afe_plausibility.c @@ -40,19 +40,19 @@ */ /** - * @file mic_plausibility.c + * @file afe_plausibility.c * @author foxBMS Team * @date 2019-01-24 (date of creation) * @updated 2021-01-15 (date of last update) * @ingroup MODULES - * @prefix MIC + * @prefix AFE * - * @brief MIC plausibility checks for cell voltage and cell temperatures + * @brief AFE plausibility checks for cell voltage and cell temperatures * */ /*========== Includes =======================================================*/ -#include "mic_plausibility.h" +#include "afe_plausibility.h" #include "tsi.h" @@ -67,9 +67,9 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e MIC_PlausibilityCheckVoltageMeasurementRange( +extern STD_RETURN_TYPE_e AFE_PlausibilityCheckVoltageMeasurementRange( const int16_t cellvoltage_mV, - const MIC_PLAUSIBILITY_VALUES_s plausibleValues) { + const AFE_PLAUSIBILITY_VALUES_s plausibleValues) { STD_RETURN_TYPE_e retval = STD_OK; /* sanity-check: limits have to be ascending and not equal */ @@ -83,7 +83,7 @@ extern STD_RETURN_TYPE_e MIC_PlausibilityCheckVoltageMeasurementRange( return retval; } -extern STD_RETURN_TYPE_e MIC_PlausibilityCheckTempMinMax(const int16_t celltemperature_ddegC) { +extern STD_RETURN_TYPE_e AFE_PlausibilityCheckTempMinMax(const int16_t celltemperature_ddegC) { STD_RETURN_TYPE_e retval = STD_OK; const int16_t plausibleMaximumTemperature_ddegC = TSI_GetMaximumPlausibleTemperature(); diff --git a/src/app/driver/mic/api/mic_plausibility.h b/src/app/driver/afe/api/afe_plausibility.h similarity index 82% rename from src/app/driver/mic/api/mic_plausibility.h rename to src/app/driver/afe/api/afe_plausibility.h index d7b419d8..97a08c83 100644 --- a/src/app/driver/mic/api/mic_plausibility.h +++ b/src/app/driver/afe/api/afe_plausibility.h @@ -40,19 +40,19 @@ */ /** - * @file mic_plausibility.h + * @file afe_plausibility.h * @author foxBMS Team * @date 2019-01-24 (date of creation) * @updated 2021-01-15 (date of last update) * @ingroup MODULES - * @prefix MIC + * @prefix AFE * * @brief plausibility checks for cell voltage and cell temperatures * */ -#ifndef FOXBMS__MIC_PLAUSIBILITY_H_ -#define FOXBMS__MIC_PLAUSIBILITY_H_ +#ifndef FOXBMS__AFE_PLAUSIBILITY_H_ +#define FOXBMS__AFE_PLAUSIBILITY_H_ /*========== Includes =======================================================*/ #include "general.h" @@ -60,22 +60,22 @@ /*========== Macros and Definitions =========================================*/ /** - * @brief struct definition for plausibility values of a MIC - * @details This struct has to be implemented in a variable by each MIC and - * passed to #MIC_PlausibilityCheckVoltageMeasurementRange(). + * @brief struct definition for plausibility values of an AFE + * @details This struct has to be implemented in a variable by each AFE and + * passed to #AFE_PlausibilityCheckVoltageMeasurementRange(). */ -typedef struct MIC_PLAUSIBILITY_VALUES { +typedef struct AFE_PLAUSIBILITY_VALUES { /** largest cell voltage value that is considered plausible in mV * - * This value should be the maximum operating limit of the MIC. + * This value should be the maximum operating limit of the AFE. */ const int16_t maximumPlausibleVoltage_mV; /** smallest cell voltage value that is considered plausible in mV * - * This value should be the minimum operating limit of the MIC. + * This value should be the minimum operating limit of the AFE. */ const int16_t minimumPlausibleVoltage_mV; -} MIC_PLAUSIBILITY_VALUES_s; +} AFE_PLAUSIBILITY_VALUES_s; /*========== Extern Constant and Variable Declarations ======================*/ @@ -84,22 +84,22 @@ typedef struct MIC_PLAUSIBILITY_VALUES { * @brief Cell voltage measurement range plausibility check * * @param cellvoltage_mV cell voltage that is checked in mV - * @param plausibleValues struct of type #MIC_PLAUSIBILITY_VALUES_s with the + * @param plausibleValues struct of type #AFE_PLAUSIBILITY_VALUES_s with the * plausible limits of cell voltages * * @return #STD_OK if no plausibility issue detected, otherwise #STD_NOT_OK */ -extern STD_RETURN_TYPE_e MIC_PlausibilityCheckVoltageMeasurementRange( +extern STD_RETURN_TYPE_e AFE_PlausibilityCheckVoltageMeasurementRange( const int16_t cellvoltage_mV, - const MIC_PLAUSIBILITY_VALUES_s plausibleValues); + const AFE_PLAUSIBILITY_VALUES_s plausibleValues); /** * @brief Cell temperature plausibility check * * @param celltemperature_ddegC cell temperature that is checked in deci °C */ -extern STD_RETURN_TYPE_e MIC_PlausibilityCheckTempMinMax(const int16_t celltemperature_ddegC); +extern STD_RETURN_TYPE_e AFE_PlausibilityCheckTempMinMax(const int16_t celltemperature_ddegC); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__MIC_PLAUSIBILITY_H_ */ +#endif /* FOXBMS__AFE_PLAUSIBILITY_H_ */ diff --git a/src/app/driver/mic/debug/api/README.md b/src/app/driver/afe/debug/api/README.md similarity index 100% rename from src/app/driver/mic/debug/api/README.md rename to src/app/driver/afe/debug/api/README.md diff --git a/src/app/driver/mic/debug/default/api/debug_default_mic.c b/src/app/driver/afe/debug/default/api/debug_default_afe.c similarity index 83% rename from src/app/driver/mic/debug/default/api/debug_default_mic.c rename to src/app/driver/afe/debug/default/api/debug_default_afe.c index 48d65306..8c45fb8f 100644 --- a/src/app/driver/mic/debug/default/api/debug_default_mic.c +++ b/src/app/driver/afe/debug/default/api/debug_default_afe.c @@ -40,20 +40,20 @@ */ /** - * @file debug_default_mic.c + * @file debug_default_afe.c * @author foxBMS Team * @date 2020-09-17 (date of creation) * @updated 2020-09-17 (date of last update) * @ingroup DRIVER * @prefix FAKE * - * @brief Implementation of the fake measurement IC driver + * @brief Implementation of the fake AFE driver */ /*========== Includes =======================================================*/ #include "general.h" -#include "debug_default_mic.h" +#include "debug_default_afe.h" #include "debug_default.h" @@ -68,26 +68,26 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e MIC_TriggerIc(void) { - return FAKE_TriggerMeasurementIc(&fake_state); +extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { + return FAKE_TriggerAfe(&fake_state); } -extern STD_RETURN_TYPE_e MIC_Init(void) { +extern STD_RETURN_TYPE_e AFE_Initialize(void) { return FAKE_Initialize(); } -extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { +extern STD_RETURN_TYPE_e AFE_StartMeasurement(void) { return STD_OK; } -extern bool MIC_IsFirstMeasurementCycleFinished(void) { +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 MIC_RequestIoWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoWrite(uint8_t string) { return STD_OK; } #pragma diag_pop @@ -95,7 +95,7 @@ extern STD_RETURN_TYPE_e MIC_RequestIoWrite(uint8_t string) { /* 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 MIC_RequestIoRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoRead(uint8_t string) { return STD_OK; } #pragma diag_pop @@ -103,7 +103,7 @@ extern STD_RETURN_TYPE_e MIC_RequestIoRead(uint8_t string) { /* 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 MIC_RequestTemperatureRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestTemperatureRead(uint8_t string) { return STD_OK; } #pragma diag_pop @@ -111,7 +111,7 @@ extern STD_RETURN_TYPE_e MIC_RequestTemperatureRead(uint8_t string) { /* 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 MIC_RequestBalancingFeedbackRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestBalancingFeedbackRead(uint8_t string) { return STD_OK; } #pragma diag_pop @@ -119,7 +119,7 @@ extern STD_RETURN_TYPE_e MIC_RequestBalancingFeedbackRead(uint8_t string) { /* 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 MIC_RequestEepromRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromRead(uint8_t string) { return STD_OK; } #pragma diag_pop @@ -127,7 +127,7 @@ extern STD_RETURN_TYPE_e MIC_RequestEepromRead(uint8_t string) { /* 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 MIC_RequestEepromWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromWrite(uint8_t string) { return STD_OK; } #pragma diag_pop @@ -135,7 +135,7 @@ extern STD_RETURN_TYPE_e MIC_RequestEepromWrite(uint8_t string) { /* 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 MIC_RequestOpenWireCheck(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestOpenWireCheck(uint8_t string) { return STD_OK; } #pragma diag_pop diff --git a/src/app/driver/mic/debug/default/api/debug_default_mic.h b/src/app/driver/afe/debug/default/api/debug_default_afe.h similarity index 91% rename from src/app/driver/mic/debug/default/api/debug_default_mic.h rename to src/app/driver/afe/debug/default/api/debug_default_afe.h index 40a4c0ad..57f70160 100644 --- a/src/app/driver/mic/debug/default/api/debug_default_mic.h +++ b/src/app/driver/afe/debug/default/api/debug_default_afe.h @@ -40,23 +40,23 @@ */ /** - * @file debug_default_mic.h + * @file debug_default_afe.h * @author foxBMS Team * @date 2020-09-17 (date of creation) * @updated 2020-09-17 (date of last update) * @ingroup DRIVERS * @prefix FAKE * - * @brief Header for the driver for the fake measurement IC driver + * @brief Header for the driver for the fake AFE driver * */ -#ifndef FOXBMS__DEBUG_DEFAULT_MIC_H_ -#define FOXBMS__DEBUG_DEFAULT_MIC_H_ +#ifndef FOXBMS__DEBUG_DEFAULT_AFE_H_ +#define FOXBMS__DEBUG_DEFAULT_AFE_H_ /*========== Includes =======================================================*/ /* clang-format off */ -#include "mic.h" +#include "afe.h" /* clang-format on */ /*========== Macros and Definitions =========================================*/ @@ -67,4 +67,4 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__DEBUG_DEFAULT_MIC_H_ */ +#endif /* FOXBMS__DEBUG_DEFAULT_AFE_H_ */ diff --git a/src/app/driver/mic/debug/default/api/debug_default_mic_dma.c b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.c similarity index 95% rename from src/app/driver/mic/debug/default/api/debug_default_mic_dma.c rename to src/app/driver/afe/debug/default/api/debug_default_afe_dma.c index 05bfcecc..f2640b63 100644 --- a/src/app/driver/mic/debug/default/api/debug_default_mic_dma.c +++ b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.c @@ -40,7 +40,7 @@ */ /** - * @file debug_default_mic_dma.c + * @file debug_default_afe_dma.c * @author foxBMS Team * @date 2020-09-17 (date of creation) * @updated 2020-09-17 (date of last update) @@ -52,7 +52,7 @@ */ /*========== Includes =======================================================*/ -#include "debug_default_mic_dma.h" +#include "debug_default_afe_dma.h" /*========== Macros and Definitions =========================================*/ @@ -70,7 +70,7 @@ #pragma diag_push #pragma diag_suppress 880 /* Function called on DMA complete interrupts (TX and RX). */ -void MIC_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { +void AFE_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { } #pragma diag_pop diff --git a/src/app/driver/mic/debug/default/api/debug_default_mic_dma.h b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.h similarity index 93% rename from src/app/driver/mic/debug/default/api/debug_default_mic_dma.h rename to src/app/driver/afe/debug/default/api/debug_default_afe_dma.h index 2775f986..6aa7ca93 100644 --- a/src/app/driver/mic/debug/default/api/debug_default_mic_dma.h +++ b/src/app/driver/afe/debug/default/api/debug_default_afe_dma.h @@ -40,24 +40,24 @@ */ /** - * @file debug_default_mic_dma.h + * @file debug_default_afe_dma.h * @author foxBMS Team * @date 2020-09-17 (date of creation) * @updated 2020-09-17 (date of last update) * @ingroup DRIVERS * @prefix FAKE * - * @brief Header for the driver for the DMA module for the fake measurement IC + * @brief Header for the driver for the DMA module for the fake AFE * driver * */ -#ifndef FOXBMS__DEBUG_DEFAULT_MIC_DMA_H_ -#define FOXBMS__DEBUG_DEFAULT_MIC_DMA_H_ +#ifndef FOXBMS__DEBUG_DEFAULT_AFE_DMA_H_ +#define FOXBMS__DEBUG_DEFAULT_AFE_DMA_H_ /*========== Includes =======================================================*/ /* clang-format off */ -#include "mic_dma.h" +#include "afe_dma.h" /* clang-format on */ /*========== Macros and Definitions =========================================*/ @@ -68,4 +68,4 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__DEBUG_DEFAULT_MIC_DMA_H_ */ +#endif /* FOXBMS__DEBUG_DEFAULT_AFE_DMA_H_ */ diff --git a/src/app/driver/mic/debug/default/config/debug_default_cfg.c b/src/app/driver/afe/debug/default/config/debug_default_cfg.c similarity index 98% rename from src/app/driver/mic/debug/default/config/debug_default_cfg.c rename to src/app/driver/afe/debug/default/config/debug_default_cfg.c index 19402f20..01b81859 100644 --- a/src/app/driver/mic/debug/default/config/debug_default_cfg.c +++ b/src/app/driver/afe/debug/default/config/debug_default_cfg.c @@ -47,7 +47,7 @@ * @ingroup DRIVERS_CONFIGURATION * @prefix FAKE * - * @brief Configuration for the fake measurement IC + * @brief Configuration for the fake AFE * */ diff --git a/src/app/driver/mic/debug/default/config/debug_default_cfg.h b/src/app/driver/afe/debug/default/config/debug_default_cfg.h similarity index 97% rename from src/app/driver/mic/debug/default/config/debug_default_cfg.h rename to src/app/driver/afe/debug/default/config/debug_default_cfg.h index c35e8db0..496b7c70 100644 --- a/src/app/driver/mic/debug/default/config/debug_default_cfg.h +++ b/src/app/driver/afe/debug/default/config/debug_default_cfg.h @@ -47,7 +47,7 @@ * @ingroup DRIVERS_CONFIGURATION * @prefix FAKE * - * @brief Header for the configuration for the fake measurement IC + * @brief Header for the configuration for the fake AFE * */ diff --git a/src/app/driver/mic/debug/default/debug_default.c b/src/app/driver/afe/debug/default/debug_default.c similarity index 97% rename from src/app/driver/mic/debug/default/debug_default.c rename to src/app/driver/afe/debug/default/debug_default.c index f83886f9..a693a0ab 100644 --- a/src/app/driver/mic/debug/default/debug_default.c +++ b/src/app/driver/afe/debug/default/debug_default.c @@ -47,7 +47,7 @@ * @ingroup DRIVER * @prefix FAKE * - * @brief Driver implementation for the fake measurement IC + * @brief Driver implementation for the fake AFE * */ @@ -71,24 +71,24 @@ #define FAKE_CELL_TEMPERATURE_ddegC ((BC_TEMPERATURE_MAX_CHARGE_MOL_ddegC + BC_TEMPERATURE_MIN_CHARGE_MOL_ddegC) / 2u) /** - * statemachine short time definition in #FAKE_TriggerMeasurementIc calls + * statemachine short time definition in #FAKE_TriggerAfe calls * until next state is processed */ #define FAKE_FSM_SHORT_TIME (1u) /** - * statemachine medium time definition in #FAKE_TriggerMeasurementIc calls + * statemachine medium time definition in #FAKE_TriggerAfe calls * until next state/substate is processed */ #define FAKE_FSM_MEDIUM_TIME (5u) /** - * statemachine long time definition in #FAKE_TriggerMeasurementIc calls + * statemachine long time definition in #FAKE_TriggerAfe calls * until next state/substate is processed */ #define FAKE_FSM_LONG_TIME (10u) -/** Symbolic names to check for multiple calls of #FAKE_TriggerMeasurementIc */ +/** Symbolic names to check for multiple calls of #FAKE_TriggerAfe */ typedef enum FAKE_CHECK_MULTIPLE_CALLS { FAKE_MULTIPLE_CALLS_NO, /*!< no multiple calls, OK */ FAKE_MULTIPLE_CALLS_YES, /*!< multiple calls, not OK */ @@ -497,7 +497,7 @@ static STD_RETURN_TYPE_e FAKE_RunStateMachine(FAKE_STATE_s *pFakeState) { /****************************************************** STATE: ERROR */ case FAKE_FSM_STATE_ERROR: - /* this case must never happen for the dummy measurement IC, as all cases are processed */ + /* this case must never happen for the dummy AFE, as all cases are processed */ FAS_ASSERT(FAS_TRAP); break; @@ -525,7 +525,7 @@ extern bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState) { return returnValue; } -extern STD_RETURN_TYPE_e FAKE_TriggerMeasurementIc(FAKE_STATE_s *pFakeState) { +extern STD_RETURN_TYPE_e FAKE_TriggerAfe(FAKE_STATE_s *pFakeState) { FAS_ASSERT(pFakeState != NULL_PTR); bool earlyExit = false; STD_RETURN_TYPE_e returnValue = STD_OK; diff --git a/src/app/driver/mic/debug/default/debug_default.h b/src/app/driver/afe/debug/default/debug_default.h similarity index 97% rename from src/app/driver/mic/debug/default/debug_default.h rename to src/app/driver/afe/debug/default/debug_default.h index 8b592675..431095a1 100644 --- a/src/app/driver/mic/debug/default/debug_default.h +++ b/src/app/driver/afe/debug/default/debug_default.h @@ -47,7 +47,7 @@ * @ingroup DRIVERS * @prefix FAKE * - * @brief Header for the driver of the fake measurement IC driver + * @brief Header for the driver of the fake AFE driver * */ @@ -131,7 +131,7 @@ extern bool FAKE_IsFirstMeasurementCycleFinished(FAKE_STATE_s *pFakeState); * @param pFakeState current state of the fake driver * @returns returns always #STD_OK */ -extern STD_RETURN_TYPE_e FAKE_TriggerMeasurementIc(FAKE_STATE_s *pFakeState); +extern STD_RETURN_TYPE_e FAKE_TriggerAfe(FAKE_STATE_s *pFakeState); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST diff --git a/src/app/driver/mic/debug/default/debug_default.json b/src/app/driver/afe/debug/default/debug_default.json similarity index 100% rename from src/app/driver/mic/debug/default/debug_default.json rename to src/app/driver/afe/debug/default/debug_default.json diff --git a/src/app/driver/mic/debug/default/wscript b/src/app/driver/afe/debug/default/wscript similarity index 90% rename from src/app/driver/mic/debug/default/wscript rename to src/app/driver/afe/debug/default/wscript index a4c44830..9bd7fab3 100644 --- a/src/app/driver/mic/debug/default/wscript +++ b/src/app/driver/afe/debug/default/wscript @@ -38,18 +38,18 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Build Script: ./src/app/driver/mic/debug/default +"""Build Script: ./src/app/driver/afe/debug/default -builds the default-variant of the debug measurement IC""" +builds the default-variant of the debug AFE""" import os def build(bld): - """builds the measurement ic driver library for Maxim""" + """builds the AFE driver library for Maxim""" source = [ - os.path.join("api", "debug_default_mic.c"), - os.path.join("api", "debug_default_mic_dma.c"), + os.path.join("api", "debug_default_afe.c"), + os.path.join("api", "debug_default_afe_dma.c"), os.path.join("config", "debug_default_cfg.c"), os.path.join("debug_default.c"), ] @@ -72,7 +72,7 @@ def build(bld): ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) cflags = bld.env.CFLAGS_FOXBMS - target = f"{bld.env.APPNAME.lower()}-mic-driver" + target = f"{bld.env.APPNAME.lower()}-afe-driver" bld.stlib( source=source, includes=includes, diff --git a/src/app/driver/mic/debug/wscript b/src/app/driver/afe/debug/wscript similarity index 92% rename from src/app/driver/mic/debug/wscript rename to src/app/driver/afe/debug/wscript index 7bf65cd0..48d09c4a 100644 --- a/src/app/driver/mic/debug/wscript +++ b/src/app/driver/afe/debug/wscript @@ -38,11 +38,11 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Helper Build Script: ./src/app/driver/mic/debug +"""Helper Build Script: ./src/app/driver/afe/debug -Helper script to recursively build the variant of the debug measurement IC""" +Helper script to recursively build the variant of the debug AFE""" def build(bld): """selects the driver library to be build""" - bld.recurse(bld.env.measurement_ic_chip) + bld.recurse(bld.env.afe_chip) diff --git a/src/app/driver/mic/ltc/6804-1/wscript b/src/app/driver/afe/ltc/6804-1/wscript similarity index 97% rename from src/app/driver/mic/ltc/6804-1/wscript rename to src/app/driver/afe/ltc/6804-1/wscript index f8e485c6..828a12e7 100644 --- a/src/app/driver/mic/ltc/6804-1/wscript +++ b/src/app/driver/afe/ltc/6804-1/wscript @@ -38,7 +38,7 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Helper Build Script: ./src/app/driver/mic/ltc/6804-1/wscript +"""Helper Build Script: ./src/app/driver/afe/ltc/6804-1/wscript Helper script to recursively build the embedded sources""" diff --git a/src/app/driver/mic/ltc/6806/config/ltc_6806_cfg.c b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.c similarity index 100% rename from src/app/driver/mic/ltc/6806/config/ltc_6806_cfg.c rename to src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.c diff --git a/src/app/driver/mic/ltc/6806/config/ltc_6806_cfg.h b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h similarity index 99% rename from src/app/driver/mic/ltc/6806/config/ltc_6806_cfg.h rename to src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h index 76959d8f..2a3579a2 100644 --- a/src/app/driver/mic/ltc/6806/config/ltc_6806_cfg.h +++ b/src/app/driver/afe/ltc/6806/config/ltc_6806_cfg.h @@ -62,7 +62,7 @@ #include "ltc_defs.h" #include "battery_system_cfg.h" -#include "ltc_mic_dma.h" +#include "ltc_afe_dma.h" #include "spi.h" /*========== Macros and Definitions =========================================*/ diff --git a/src/app/driver/mic/ltc/6806/ltc_6806.c b/src/app/driver/afe/ltc/6806/ltc_6806.c similarity index 97% rename from src/app/driver/mic/ltc/6806/ltc_6806.c rename to src/app/driver/afe/ltc/6806/ltc_6806.c index 0d56d0a3..c0e19421 100644 --- a/src/app/driver/mic/ltc/6806/ltc_6806.c +++ b/src/app/driver/afe/ltc/6806/ltc_6806.c @@ -43,7 +43,7 @@ * @file ltc_6806.c * @author foxBMS Team * @date 2019-09-01 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2021-10-04 (date of last update) * @ingroup DRIVERS * @prefix LTC * @@ -64,25 +64,12 @@ #include "diag.h" #include "io.h" #include "ltc_pec.h" +#include "pex.h" #include "os.h" -#include "mic_plausibility.h" +#include "afe_plausibility.h" /*========== Macros and Definitions =========================================*/ -/** - * LTC 6820 GPIO configuration - * @{ - */ -#define LTC_LTC6820CONTROL_GIODIR (hetREG1->DIR) -#define LTC_LTC6820CONTROL_GIOPORT (hetREG1->DOUT) - -#define LTC_LTC6820_FORWARD_ENABLE_PIN (22U) -#define LTC_LTC6820_FORWARD_SPI1_MASTER_PIN (24U) - -#define LTC_LTC6820_REVERSE_ENABLE_PIN (23U) -#define LTC_LTC6820_REVERSE_MASTER_PIN (25U) -/**@}*/ - /** * TI port expander register addresses * @{ @@ -137,7 +124,7 @@ static LTC_OPENWIRE_DETECTION_s ltc_openWireDetection = {0}; static LTC_ERRORTABLE_s ltc_errorTable = {0}; /*!< init in LTC_ResetErrorTable-function */ /** local definition of plausible cell voltage values for the LTC 6806 */ -static const MIC_PLAUSIBILITY_VALUES_s ltc_plausibleCellVoltages6806 = { +static const AFE_PLAUSIBILITY_VALUES_s ltc_plausibleCellVoltages6806 = { .maximumPlausibleVoltage_mV = 5000, .minimumPlausibleVoltage_mV = -5000, }; @@ -428,7 +415,7 @@ extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber) { /* Cell voltage is valid -> perform minimum/maximum plausibility check */ /* ------- 2. Perform minimum/maximum measurement range check ---------- */ - if (STD_OK == MIC_PlausibilityCheckVoltageMeasurementRange( + if (STD_OK == AFE_PlausibilityCheckVoltageMeasurementRange( ltc_state->ltcData.cellVoltage ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELLS_PER_MODULE) + c], ltc_plausibleCellVoltages6806)) { @@ -449,8 +436,7 @@ extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber) { } } } - DIAG_CheckEvent( - cellVoltageMeasurementValid, DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, DIAG_STRING, stringNumber); + DIAG_CheckEvent(cellVoltageMeasurementValid, DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, DIAG_STRING, stringNumber); ltc_state->ltcData.cellVoltage->packVoltage_mV[stringNumber] = stringVoltage_mV; ltc_state->ltcData.cellVoltage->nrValidCellVoltages[stringNumber] = numberValidMeasurements; @@ -474,7 +460,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { /* ------- 2. Perform minimum/maximum measurement range check ---------- */ if (STD_OK == - MIC_PlausibilityCheckTempMinMax( + AFE_PlausibilityCheckTempMinMax( ltc_state->ltcData.cellTemperature ->cellTemperature_ddegC[stringNumber][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c])) { numberValidMeasurements++; @@ -490,7 +476,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { } } DIAG_CheckEvent( - cellTemperatureMeasurementValid, DIAG_ID_MEASUREMENT_IC_CELL_TEMPERATURE_MEAS_ERROR, DIAG_STRING, stringNumber); + cellTemperatureMeasurementValid, DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, DIAG_STRING, stringNumber); ltc_state->ltcData.cellTemperature->nrValidTemperatures[stringNumber] = numberValidMeasurements; ltc_state->ltcData.cellTemperature->state++; @@ -645,7 +631,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } } } else { - if (MIC_IsTransmitOngoing(ltc_state) == true) { + if (AFE_IsTransmitOngoing(ltc_state) == true) { if (ltc_state->timer > 0u) { if ((--ltc_state->timer) > 0u) { ltc_state->triggerentry--; @@ -719,7 +705,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_START_INIT_INITIALIZATION) { LTC_SaveLastStates(ltc_state); ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_Init( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -736,7 +722,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_CHECK_INITIALIZATION) { /* Read values written in config register, currently unused */ LTC_SaveLastStates(ltc_state); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCFG, ltc_state->spiSeqPtr, @@ -824,7 +810,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; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVA_Fuelcell, ltc_state->spiSeqPtr, @@ -849,7 +835,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 0u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVB_Fuelcell, ltc_state->spiSeqPtr, @@ -874,7 +860,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 1u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVC_Fuelcell, ltc_state->spiSeqPtr, @@ -899,7 +885,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 2u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVD_Fuelcell, ltc_state->spiSeqPtr, @@ -924,7 +910,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 3u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVE_Fuelcell, ltc_state->spiSeqPtr, @@ -949,7 +935,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 4u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVF_Fuelcell, ltc_state->spiSeqPtr, @@ -974,7 +960,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 5u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVG_Fuelcell, ltc_state->spiSeqPtr, @@ -999,7 +985,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 6u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVH_Fuelcell, ltc_state->spiSeqPtr, @@ -1024,7 +1010,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_SaveRXtoVoltagebuffer_Fuelcell( ltc_state, ltc_state->ltcData.rxBuffer, 7u, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVI_Fuelcell, ltc_state->spiSeqPtr, @@ -1750,21 +1736,23 @@ static void LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state) { } extern void LTC_monitoringPinInit(void) { - /* set HET Pins to output */ - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_FORWARD_ENABLE_PIN); - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_FORWARD_SPI1_MASTER_PIN); - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_REVERSE_ENABLE_PIN); - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_REVERSE_MASTER_PIN); - - /* set LTC6820 forward enable to 1 */ - IO_PinSet(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_FORWARD_ENABLE_PIN); - /* set LTC6820 forward master to 1 */ - IO_PinSet(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_FORWARD_SPI1_MASTER_PIN); - - /* set LTC6820 reverse enable to 0 */ - IO_PinReset(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_REVERSE_ENABLE_PIN); - /* set LTC6820 reverse master to 0 */ - IO_PinSet(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_REVERSE_MASTER_PIN); + /* Set 3rd PE pins to enable daisy chains */ + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN10); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN11); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN12); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN13); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN14); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN15); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN16); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN17); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN10); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN11); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN12); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN13); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN14); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN15); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN16); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN17); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/mic/ltc/6806/ltc_6806.json b/src/app/driver/afe/ltc/6806/ltc_6806.json similarity index 100% rename from src/app/driver/mic/ltc/6806/ltc_6806.json rename to src/app/driver/afe/ltc/6806/ltc_6806.json diff --git a/src/app/driver/mic/ltc/6806/wscript b/src/app/driver/afe/ltc/6806/wscript similarity index 88% rename from src/app/driver/mic/ltc/6806/wscript rename to src/app/driver/afe/ltc/6806/wscript index 1aa534a5..3c5bc062 100644 --- a/src/app/driver/mic/ltc/6806/wscript +++ b/src/app/driver/afe/ltc/6806/wscript @@ -38,21 +38,21 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Builds the ltc-measurement library: ./src/app/driver/mic/ltc/wscript""" +"""Builds the ltc-measurement library: ./src/app/driver/afe/ltc/wscript""" import os def build(bld): - """builds the measurement ic driver library for LTC""" + """builds the AFE driver library for LTC""" source = [ os.path.join("config", "ltc_6806_cfg.c"), os.path.join("ltc_6806.c"), - os.path.join("..", "api", "ltc_mic.c"), - os.path.join("..", "common", "config", "ltc_mic_dma_cfg.c"), - os.path.join("..", "common", "ltc_mic_dma.c"), + os.path.join("..", "api", "ltc_afe.c"), + os.path.join("..", "common", "config", "ltc_afe_dma_cfg.c"), + os.path.join("..", "common", "ltc_afe_dma.c"), os.path.join("..", "common", "ltc_pec.c"), - os.path.join("..", "..", "api", "mic_plausibility.c"), + os.path.join("..", "..", "api", "afe_plausibility.c"), ] includes = [ ".", @@ -64,6 +64,7 @@ def build(bld): os.path.join("..", "..", "..", "dma"), os.path.join("..", "..", "..", "foxmath"), os.path.join("..", "..", "..", "io"), + os.path.join("..", "..", "..", "pex"), os.path.join("..", "..", "..", "spi"), os.path.join("..", "..", "..", "ts"), os.path.join("..", "..", "..", "ts", "api"), @@ -76,7 +77,7 @@ def build(bld): ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) cflags = bld.env.CFLAGS_FOXBMS - target = f"{bld.env.APPNAME.lower()}-mic-driver" + target = f"{bld.env.APPNAME.lower()}-afe-driver" bld.stlib( source=source, includes=includes, diff --git a/src/app/driver/mic/ltc/6811-1/wscript b/src/app/driver/afe/ltc/6811-1/wscript similarity index 97% rename from src/app/driver/mic/ltc/6811-1/wscript rename to src/app/driver/afe/ltc/6811-1/wscript index 03f09761..b3c827f1 100644 --- a/src/app/driver/mic/ltc/6811-1/wscript +++ b/src/app/driver/afe/ltc/6811-1/wscript @@ -38,7 +38,7 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Helper Build Script: ./src/app/driver/mic/ltc/6811/wscript +"""Helper Build Script: ./src/app/driver/afe/ltc/6811/wscript Helper script to recursively build the embedded sources""" diff --git a/src/app/driver/mic/ltc/6812-1/wscript b/src/app/driver/afe/ltc/6812-1/wscript similarity index 97% rename from src/app/driver/mic/ltc/6812-1/wscript rename to src/app/driver/afe/ltc/6812-1/wscript index 2a1b4022..dae5432f 100644 --- a/src/app/driver/mic/ltc/6812-1/wscript +++ b/src/app/driver/afe/ltc/6812-1/wscript @@ -38,7 +38,7 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Helper Build Script: ./src/app/driver/mic/ltc/6812-1/wscript +"""Helper Build Script: ./src/app/driver/afe/ltc/6812-1/wscript Helper script to recursively build the embedded sources""" diff --git a/src/app/driver/mic/ltc/6813-1/config/ltc_6813-1_cfg.c b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.c similarity index 100% rename from src/app/driver/mic/ltc/6813-1/config/ltc_6813-1_cfg.c rename to src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.c diff --git a/src/app/driver/mic/ltc/6813-1/config/ltc_6813-1_cfg.h b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h similarity index 99% rename from src/app/driver/mic/ltc/6813-1/config/ltc_6813-1_cfg.h rename to src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h index 380b8bbf..a7f725ee 100644 --- a/src/app/driver/mic/ltc/6813-1/config/ltc_6813-1_cfg.h +++ b/src/app/driver/afe/ltc/6813-1/config/ltc_6813-1_cfg.h @@ -63,7 +63,7 @@ #include "ltc_defs.h" #include "battery_system_cfg.h" -#include "ltc_mic_dma.h" +#include "ltc_afe_dma.h" #include "spi.h" /*========== Macros and Definitions =========================================*/ diff --git a/src/app/driver/mic/ltc/6813-1/ltc_6813-1.c b/src/app/driver/afe/ltc/6813-1/ltc_6813-1.c similarity index 97% rename from src/app/driver/mic/ltc/6813-1/ltc_6813-1.c rename to src/app/driver/afe/ltc/6813-1/ltc_6813-1.c index d0a92fb3..255a9692 100644 --- a/src/app/driver/mic/ltc/6813-1/ltc_6813-1.c +++ b/src/app/driver/afe/ltc/6813-1/ltc_6813-1.c @@ -43,7 +43,7 @@ * @file ltc_6813-1.c * @author foxBMS Team * @date 2019-09-01 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup DRIVERS * @prefix LTC * @@ -64,25 +64,12 @@ #include "diag.h" #include "io.h" #include "ltc_pec.h" +#include "pex.h" #include "os.h" -#include "mic_plausibility.h" +#include "afe_plausibility.h" /*========== Macros and Definitions =========================================*/ -/** - * LTC 6820 GPIO configuration - * @{ - */ -#define LTC_LTC6820CONTROL_GIODIR (hetREG1->DIR) -#define LTC_LTC6820CONTROL_GIOPORT (hetREG1->DOUT) - -#define LTC_LTC6820_FORWARD_ENABLE_PIN (22U) -#define LTC_LTC6820_FORWARD_SPI1_MASTER_PIN (24U) - -#define LTC_LTC6820_REVERSE_ENABLE_PIN (23U) -#define LTC_LTC6820_REVERSE_MASTER_PIN (25U) -/**@}*/ - /** * TI port expander register addresses * @{ @@ -137,7 +124,7 @@ static LTC_OPENWIRE_DETECTION_s ltc_openWireDetection = {0}; static LTC_ERRORTABLE_s ltc_errorTable = {0}; /*!< init in LTC_ResetErrorTable-function */ /** local definition of plausible cell voltage values for the LTC6813 (and similar) */ -static const MIC_PLAUSIBILITY_VALUES_s ltc_plausibleCellVoltages681x = { +static const AFE_PLAUSIBILITY_VALUES_s ltc_plausibleCellVoltages681x = { .maximumPlausibleVoltage_mV = 5000, .minimumPlausibleVoltage_mV = 0, }; @@ -176,8 +163,8 @@ LTC_STATE_s ltc_stateBase = { .spiDiagErrorEntry = DIAG_ID_LTC_SPI, .pecDiagErrorEntry = DIAG_ID_LTC_PEC, .muxDiagErrorEntry = DIAG_ID_LTC_MUX, - .voltMeasDiagErrorEntry = DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, - .tempMeasDiagErrorEntry = DIAG_ID_MEASUREMENT_IC_CELL_TEMPERATURE_MEAS_ERROR, + .voltMeasDiagErrorEntry = DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, + .tempMeasDiagErrorEntry = DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, .ltcData.pSpiInterface = spi_ltcInterface, .ltcData.txBuffer = ltc_TxPecBuffer, .ltcData.rxBuffer = ltc_RxPecBuffer, @@ -601,7 +588,7 @@ extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber) { /* Cell voltage is valid -> perform minimum/maximum plausibility check */ /* ------- 2. Perform minimum/maximum measurement range check ---------- */ - if (STD_OK == MIC_PlausibilityCheckVoltageMeasurementRange( + if (STD_OK == AFE_PlausibilityCheckVoltageMeasurementRange( ltc_state->ltcData.cellVoltage ->cellVoltage_mV[stringNumber][(m * BS_NR_OF_CELLS_PER_MODULE) + c], ltc_plausibleCellVoltages681x)) { @@ -648,7 +635,7 @@ extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber) { /* ------- 2. Perform minimum/maximum measurement range check ---------- */ if (STD_OK == - MIC_PlausibilityCheckTempMinMax( + AFE_PlausibilityCheckTempMinMax( ltc_state->ltcData.cellTemperature ->cellTemperature_ddegC[stringNumber][(m * BS_NR_OF_TEMP_SENSORS_PER_MODULE) + c])) { numberValidMeasurements++; @@ -824,7 +811,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } } } else { - if (MIC_IsTransmitOngoing(ltc_state) == true) { + if (AFE_IsTransmitOngoing(ltc_state) == true) { if (ltc_state->timer > 0u) { if ((--ltc_state->timer) > 0u) { ltc_state->triggerentry--; @@ -907,7 +894,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_START_INIT_INITIALIZATION) { LTC_SaveLastStates(ltc_state); ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_Init( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -924,7 +911,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_CHECK_INITIALIZATION) { /* Read values written in config register, currently unused */ LTC_SaveLastStates(ltc_state); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCFG, ltc_state->spiSeqPtr, @@ -1014,7 +1001,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; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVA, ltc_state->spiSeqPtr, @@ -1038,7 +1025,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 0, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVB, ltc_state->spiSeqPtr, @@ -1062,7 +1049,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVC, ltc_state->spiSeqPtr, @@ -1086,7 +1073,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 2, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVD, ltc_state->spiSeqPtr, @@ -1123,7 +1110,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 3, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVE, ltc_state->spiSeqPtr, @@ -1160,7 +1147,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoVoltagebuffer(ltc_state, ltc_state->ltcData.rxBuffer, 4, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCVF, ltc_state->spiSeqPtr, @@ -1236,7 +1223,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SetMuxChannel( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1265,7 +1252,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_SEND_CLOCK_STCOMM_MUXMEASUREMENT_CONFIG) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1273,7 +1260,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); if (LTC_GOTO_MUX_CHECK == true) { LTC_CondBasedStateTransition( @@ -1302,7 +1289,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_I2C_TRANSMISSION_RESULT_RDCOMM_MUXMEASUREMENT_CONFIG) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1310,7 +1297,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, @@ -1330,7 +1317,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_READ_I2C_TRANSMISSION_CHECK_MUXMEASUREMENT_CONFIG) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1362,7 +1349,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else { if (LTC_GOTO_MUX_CHECK == false) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, @@ -1402,7 +1389,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } else if (ltc_state->substate == LTC_STATEMACH_READMUXMEASUREMENT) { ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDAUXA, ltc_state->spiSeqPtr, @@ -1422,7 +1409,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_STATEMACH_STOREMUXMEASUREMENT) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1527,7 +1514,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_CONFIG_BALANCECONTROL) { ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_BalanceControl( ltc_state, ltc_state->spiSeqPtr, @@ -1549,7 +1536,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_CONFIG2_BALANCECONTROL) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1558,7 +1545,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { } if (BS_NR_OF_CELLS_PER_MODULE > 12) { - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_BalanceControl( ltc_state, ltc_state->spiSeqPtr, @@ -1594,7 +1581,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_CONFIG2_BALANCECONTROL_END) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); } else { @@ -1643,7 +1630,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; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDAUXA, ltc_state->spiSeqPtr, @@ -1667,7 +1654,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 0, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDAUXB, ltc_state->spiSeqPtr, @@ -1705,7 +1692,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 1, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDAUXC, ltc_state->spiSeqPtr, @@ -1729,7 +1716,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { DIAG_CheckEvent(retVal, ltc_state->pecDiagErrorEntry, DIAG_STRING, ltc_state->currentString); LTC_SaveRXtoGPIOBuffer(ltc_state, ltc_state->ltcData.rxBuffer, 2, ltc_state->currentString); - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDAUXD, ltc_state->spiSeqPtr, @@ -1791,7 +1778,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; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDAUXA, ltc_state->spiSeqPtr, @@ -1810,7 +1797,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_SHORTTIME); } else if (ltc_state->substate == LTC_SAVE_FEEDBACK_BALANCECONTROL) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -1839,7 +1826,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_TEMP_SENS_SEND_DATA1) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_Send_I2C_Command( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1865,7 +1852,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_TEMP_SENS_SEND_CLOCK_STCOMM1) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -1875,7 +1862,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, @@ -1890,7 +1877,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_TEMP_SENS_READ_DATA1) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -1900,7 +1887,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_Send_I2C_Command( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -1926,7 +1913,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_TEMP_SENS_SEND_CLOCK_STCOMM2) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -1936,7 +1923,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, @@ -1950,7 +1937,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_SHORTTIME); break; } else if (ltc_state->substate == LTC_TEMP_SENS_READ_I2C_TRANSMISSION_RESULT_RDCOMM) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -1960,7 +1947,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, @@ -1980,7 +1967,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_TEMP_SENS_SAVE_TEMP) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2010,7 +1997,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_USER_IO_SET_OUTPUT_REGISTER) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SetPortExpander( ltc_state, ltc_state->spiSeqPtr, @@ -2035,7 +2022,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_SEND_CLOCK_STCOMM_MUXMEASUREMENT_CONFIG) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2067,7 +2054,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_USER_IO_READ_INPUT_REGISTER) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_Send_I2C_Command( ltc_state->spiSeqPtr, ltc_state->ltcData.txBuffer, @@ -2093,7 +2080,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_SEND_CLOCK_STCOMM) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2118,7 +2105,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_READ_I2C_TRANSMISSION_RESULT_RDCOMM) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2128,7 +2115,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, @@ -2148,7 +2135,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_SAVE_DATA) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2179,7 +2166,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_USER_IO_SET_DIRECTION_REGISTER_TI) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SetPortExpanderDirection_TI( ltc_state, ltc_state->spiSeqPtr, @@ -2200,7 +2187,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_SEND_CLOCK_STCOMM_TI) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2227,7 +2214,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; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SetPortExpander_Output_TI( ltc_state, ltc_state->spiSeqPtr, @@ -2247,7 +2234,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_READ_I2C_TRANSMISSION_RESULT_RDCOMM_TI_SECOND) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2279,7 +2266,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_USER_IO_SET_DIRECTION_REGISTER_TI) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SetPortExpanderDirection_TI( ltc_state, ltc_state->spiSeqPtr, @@ -2300,7 +2287,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_SEND_CLOCK_STCOMM_TI) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2327,7 +2314,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; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_GetPortExpander_Input_TI( ltc_state, ltc_state->spiSeqPtr, @@ -2348,7 +2335,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_READ_I2C_TRANSMISSION_RESULT_RDCOMM_TI_SECOND) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2373,7 +2360,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_READ_INPUT_REGISTER_TI_SECOND) { ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_GetPortExpander_Input_TI( ltc_state, ltc_state->spiSeqPtr, @@ -2394,7 +2381,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_READ_I2C_TRANSMISSION_RESULT_RDCOMM_TI_THIRD) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2418,7 +2405,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_SHORTTIME); break; } else if (ltc_state->substate == LTC_USER_IO_READ_I2C_TRANSMISSION_RESULT_RDCOMM_TI_FOURTH) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2428,7 +2415,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, @@ -2448,7 +2435,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_USER_IO_SAVE_DATA_TI) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2479,7 +2466,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_EEPROM_READ_DATA1) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SendEEPROMReadCommand( ltc_state, ltc_state->spiSeqPtr, @@ -2506,7 +2493,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_SEND_CLOCK_STCOMM1) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2516,7 +2503,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, @@ -2531,7 +2518,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_READ_DATA2) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2541,7 +2528,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SendEEPROMReadCommand( ltc_state, ltc_state->spiSeqPtr, @@ -2562,7 +2549,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_SEND_CLOCK_STCOMM2) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2572,7 +2559,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, @@ -2586,7 +2573,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_SHORTTIME); break; } else if (ltc_state->substate == LTC_EEPROM_READ_I2C_TRANSMISSION_RESULT_RDCOMM) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2596,7 +2583,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_RX( ltc_cmdRDCOMM, ltc_state->spiSeqPtr, @@ -2616,7 +2603,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_SAVE_READ) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2646,7 +2633,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { if (ltc_state->substate == LTC_EEPROM_WRITE_DATA1) { ltc_state->spiSeqPtr = ltc_state->ltcData.pSpiInterface + ltc_state->requestedString; ltc_state->check_spi_flag = STD_OK; - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SendEEPROMWriteCommand( ltc_state, ltc_state->spiSeqPtr, @@ -2673,7 +2660,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_SEND_CLOCK_STCOMM3) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2683,7 +2670,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, @@ -2698,7 +2685,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_WRITE_DATA2) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2708,7 +2695,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_SendEEPROMWriteCommand( ltc_state, ltc_state->spiSeqPtr, @@ -2729,7 +2716,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { break; } else if (ltc_state->substate == LTC_EEPROM_SEND_CLOCK_STCOMM4) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -2739,7 +2726,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { ltc_state->spiDiagErrorEntry, DIAG_EVENT_OK, DIAG_STRING, ltc_state->currentString); } - MIC_SetTransmitOngoing(ltc_state); + AFE_SetTransmitOngoing(ltc_state); retVal = LTC_I2CClock(ltc_state->spiSeqPtr); LTC_CondBasedStateTransition( ltc_state, @@ -2753,7 +2740,7 @@ void LTC_Trigger(LTC_STATE_s *ltc_state) { LTC_STATEMACH_SHORTTIME); break; } else if (ltc_state->substate == LTC_EEPROM_FINISHED) { - if ((ltc_state->timer == 0) && (MIC_IsTransmitOngoing(ltc_state) == true)) { + if ((ltc_state->timer == 0) && (AFE_IsTransmitOngoing(ltc_state) == true)) { DIAG_Handler( ltc_state->spiDiagErrorEntry, DIAG_EVENT_NOT_OK, DIAG_STRING, ltc_state->currentString); LTC_StateTransition(ltc_state, LTC_STATEMACH_STARTMEAS, LTC_ENTRY, LTC_STATEMACH_SHORTTIME); @@ -4617,21 +4604,23 @@ static void LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state) { } extern void LTC_monitoringPinInit(void) { - /* set HET Pins to output */ - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_FORWARD_ENABLE_PIN); - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_FORWARD_SPI1_MASTER_PIN); - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_REVERSE_ENABLE_PIN); - SETBIT(LTC_LTC6820CONTROL_GIODIR, LTC_LTC6820_REVERSE_MASTER_PIN); - - /* set LTC6820 forward enable to 1 */ - IO_PinSet(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_FORWARD_ENABLE_PIN); - /* set LTC6820 forward master to 1 */ - IO_PinSet(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_FORWARD_SPI1_MASTER_PIN); - - /* set LTC6820 reverse enable to 0 */ - IO_PinReset(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_REVERSE_ENABLE_PIN); - /* set LTC6820 reverse master to 0 */ - IO_PinReset(<C_LTC6820CONTROL_GIOPORT, LTC_LTC6820_REVERSE_MASTER_PIN); + /* Set 3rd PE pins to enable daisy chains */ + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN10); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN11); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN12); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN13); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN14); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN15); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN16); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN17); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN10); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN11); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN12); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN13); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN14); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN15); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN16); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN17); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/mic/ltc/6813-1/ltc_6813-1.json b/src/app/driver/afe/ltc/6813-1/ltc_6813-1.json similarity index 100% rename from src/app/driver/mic/ltc/6813-1/ltc_6813-1.json rename to src/app/driver/afe/ltc/6813-1/ltc_6813-1.json diff --git a/src/app/driver/mic/ltc/6813-1/wscript b/src/app/driver/afe/ltc/6813-1/wscript similarity index 88% rename from src/app/driver/mic/ltc/6813-1/wscript rename to src/app/driver/afe/ltc/6813-1/wscript index 2e93ccde..65368f42 100644 --- a/src/app/driver/mic/ltc/6813-1/wscript +++ b/src/app/driver/afe/ltc/6813-1/wscript @@ -38,21 +38,21 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Builds the ltc-measurement library: ./src/app/driver/mic/ltc/wscript""" +"""Builds the ltc-measurement library: ./src/app/driver/afe/ltc/wscript""" import os def build(bld): - """builds the measurement ic driver library for LTC""" + """builds the AFE driver library for LTC""" source = [ os.path.join("config", "ltc_6813-1_cfg.c"), os.path.join("ltc_6813-1.c"), - os.path.join("..", "api", "ltc_mic.c"), - os.path.join("..", "common", "config", "ltc_mic_dma_cfg.c"), - os.path.join("..", "common", "ltc_mic_dma.c"), + os.path.join("..", "api", "ltc_afe.c"), + os.path.join("..", "common", "config", "ltc_afe_dma_cfg.c"), + os.path.join("..", "common", "ltc_afe_dma.c"), os.path.join("..", "common", "ltc_pec.c"), - os.path.join("..", "..", "api", "mic_plausibility.c"), + os.path.join("..", "..", "api", "afe_plausibility.c"), ] includes = [ ".", @@ -64,6 +64,7 @@ def build(bld): os.path.join("..", "..", "..", "dma"), os.path.join("..", "..", "..", "foxmath"), os.path.join("..", "..", "..", "io"), + os.path.join("..", "..", "..", "pex"), os.path.join("..", "..", "..", "spi"), os.path.join("..", "..", "..", "ts"), os.path.join("..", "..", "..", "ts", "api"), @@ -76,7 +77,7 @@ def build(bld): ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) cflags = bld.env.CFLAGS_FOXBMS - target = f"{bld.env.APPNAME.lower()}-mic-driver" + target = f"{bld.env.APPNAME.lower()}-afe-driver" bld.stlib( source=source, includes=includes, diff --git a/src/app/driver/mic/ltc/api/ltc_mic.c b/src/app/driver/afe/ltc/api/ltc_afe.c similarity index 87% rename from src/app/driver/mic/ltc/api/ltc_mic.c rename to src/app/driver/afe/ltc/api/ltc_afe.c index e27c8592..6cc40be7 100644 --- a/src/app/driver/mic/ltc/api/ltc_mic.c +++ b/src/app/driver/afe/ltc/api/ltc_afe.c @@ -40,20 +40,20 @@ */ /** - * @file ltc_mic.c + * @file ltc_afe.c * @author foxBMS Team * @date 2020-05-08 (date of creation) * @updated 2021-03-24 (date of last update) * @ingroup DRIVER - * @prefix MIC + * @prefix AFE * - * @brief Measurement IC driver implementation for LTC ICs + * @brief AFE driver implementation for LTC ICs */ /*========== Includes =======================================================*/ #include "general.h" /* clang-format off */ -#include "mic.h" +#include "afe.h" /* clang-format on */ #include "ltc.h" @@ -69,17 +69,17 @@ /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e MIC_TriggerIc(void) { +extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { LTC_Trigger(<c_stateBase); return STD_OK; } -extern STD_RETURN_TYPE_e MIC_Init(void) { +extern STD_RETURN_TYPE_e AFE_Initialize(void) { LTC_monitoringPinInit(); return STD_OK; } -extern STD_RETURN_TYPE_e MIC_RequestEepromRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_OK; LTC_REQUEST_s statereq = {.request = LTC_STATE_EEPROM_READ_REQUEST, .string = string}; @@ -90,7 +90,7 @@ extern STD_RETURN_TYPE_e MIC_RequestEepromRead(uint8_t string) { return retval; } -extern STD_RETURN_TYPE_e MIC_RequestEepromWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromWrite(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_OK; LTC_REQUEST_s statereq = {.request = LTC_STATE_EEPROM_WRITE_REQUEST, .string = string}; @@ -101,7 +101,7 @@ extern STD_RETURN_TYPE_e MIC_RequestEepromWrite(uint8_t string) { return retval; } -extern STD_RETURN_TYPE_e MIC_RequestTemperatureRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestTemperatureRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_OK; LTC_REQUEST_s statereq = {.request = LTC_STATE_TEMP_SENS_READ_REQUEST, .string = string}; @@ -112,7 +112,7 @@ extern STD_RETURN_TYPE_e MIC_RequestTemperatureRead(uint8_t string) { return retval; } -extern STD_RETURN_TYPE_e MIC_RequestBalancingFeedbackRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestBalancingFeedbackRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_NOT_OK; LTC_REQUEST_s statereq = {.request = LTC_STATE_BALANCEFEEDBACK_REQUEST, .string = string}; @@ -124,7 +124,7 @@ extern STD_RETURN_TYPE_e MIC_RequestBalancingFeedbackRead(uint8_t string) { return retval; } -extern STD_RETURN_TYPE_e MIC_RequestOpenWireCheck(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestOpenWireCheck(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_OK; LTC_REQUEST_s statereq = {.request = LTC_STATE_OPENWIRE_CHECK_REQUEST, .string = string}; @@ -135,7 +135,7 @@ extern STD_RETURN_TYPE_e MIC_RequestOpenWireCheck(uint8_t string) { return retval; } -extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { +extern STD_RETURN_TYPE_e AFE_StartMeasurement(void) { STD_RETURN_TYPE_e retval = STD_OK; LTC_REQUEST_s statereq = {.request = LTC_STATE_INIT_REQUEST, .string = 0x0u}; @@ -145,11 +145,11 @@ extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { return retval; } -extern bool MIC_IsFirstMeasurementCycleFinished(void) { +extern bool AFE_IsFirstMeasurementCycleFinished(void) { return LTC_IsFirstMeasurementCycleFinished(<c_stateBase); } -extern STD_RETURN_TYPE_e MIC_RequestIoRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_NOT_OK; @@ -157,7 +157,7 @@ extern STD_RETURN_TYPE_e MIC_RequestIoRead(uint8_t string) { return (retval); } -STD_RETURN_TYPE_e MIC_RequestIoWrite(uint8_t string) { +STD_RETURN_TYPE_e AFE_RequestIoWrite(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_NOT_OK; diff --git a/src/app/driver/mic/ltc/common/config/ltc_mic_dma_cfg.c b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c similarity index 98% rename from src/app/driver/mic/ltc/common/config/ltc_mic_dma_cfg.c rename to src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c index 54532ab8..b87daa2f 100644 --- a/src/app/driver/mic/ltc/common/config/ltc_mic_dma_cfg.c +++ b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.c @@ -40,7 +40,7 @@ */ /** - * @file ltc_mic_dma_cfg.c + * @file ltc_afe_dma_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) * @updated 2020-03-05 (date of last update) @@ -54,7 +54,7 @@ */ /*========== Includes =======================================================*/ -#include "ltc_mic_dma_cfg.h" +#include "ltc_afe_dma_cfg.h" /*========== Macros and Definitions =========================================*/ diff --git a/src/app/driver/mic/ltc/common/config/ltc_mic_dma_cfg.h b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h similarity index 95% rename from src/app/driver/mic/ltc/common/config/ltc_mic_dma_cfg.h rename to src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h index df8ee5e1..15d8447b 100644 --- a/src/app/driver/mic/ltc/common/config/ltc_mic_dma_cfg.h +++ b/src/app/driver/afe/ltc/common/config/ltc_afe_dma_cfg.h @@ -40,7 +40,7 @@ */ /** - * @file ltc_mic_dma_cfg.h + * @file ltc_afe_dma_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) * @updated 2020-03-05 (date of last update) @@ -52,8 +52,8 @@ * */ -#ifndef FOXBMS__LTC_MIC_DMA_CFG_H_ -#define FOXBMS__LTC_MIC_DMA_CFG_H_ +#ifndef FOXBMS__LTC_AFE_DMA_CFG_H_ +#define FOXBMS__LTC_AFE_DMA_CFG_H_ /*========== Includes =======================================================*/ #include "general.h" @@ -66,4 +66,4 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__LTC_MIC_DMA_CFG_H_ */ +#endif /* FOXBMS__LTC_AFE_DMA_CFG_H_ */ diff --git a/src/app/driver/mic/ltc/common/config/ltc_cfg.h b/src/app/driver/afe/ltc/common/config/ltc_cfg.h similarity index 100% rename from src/app/driver/mic/ltc/common/config/ltc_cfg.h rename to src/app/driver/afe/ltc/common/config/ltc_cfg.h diff --git a/src/app/driver/mic/ltc/common/ltc.h b/src/app/driver/afe/ltc/common/ltc.h similarity index 100% rename from src/app/driver/mic/ltc/common/ltc.h rename to src/app/driver/afe/ltc/common/ltc.h diff --git a/src/app/driver/mic/ltc/common/ltc_mic_dma.c b/src/app/driver/afe/ltc/common/ltc_afe_dma.c similarity index 92% rename from src/app/driver/mic/ltc/common/ltc_mic_dma.c rename to src/app/driver/afe/ltc/common/ltc_afe_dma.c index f272a4fe..aa193175 100644 --- a/src/app/driver/mic/ltc/common/ltc_mic_dma.c +++ b/src/app/driver/afe/ltc/common/ltc_afe_dma.c @@ -40,19 +40,19 @@ */ /** - * @file ltc_mic_dma.c + * @file ltc_afe_dma.c * @author foxBMS Team * @date 2020-05-27 (date of creation) * @updated 2020-05-27 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Driver for the DMA module for the LTC. * */ /*========== Includes =======================================================*/ -#include "ltc_mic_dma.h" +#include "ltc_afe_dma.h" #include "io.h" #include "ltc.h" @@ -70,16 +70,16 @@ /*========== Extern Function Implementations ================================*/ -extern bool MIC_IsTransmitOngoing(LTC_STATE_s *pLtcState) { +extern bool AFE_IsTransmitOngoing(LTC_STATE_s *pLtcState) { return pLtcState->transmit_ongoing; } -extern void MIC_SetTransmitOngoing(LTC_STATE_s *pLtcState) { +extern void AFE_SetTransmitOngoing(LTC_STATE_s *pLtcState) { pLtcState->transmit_ongoing = true; } /* Function called on DMA complete interrupts (TX and RX). */ -void MIC_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { +void AFE_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { if (((dmaChannel_t)channel == DMA_CH0) || ((dmaChannel_t)channel == DMA_CH1)) { ltc_stateBase.transmit_ongoing = false; } else { diff --git a/src/app/driver/mic/ltc/common/ltc_mic_dma.h b/src/app/driver/afe/ltc/common/ltc_afe_dma.h similarity index 90% rename from src/app/driver/mic/ltc/common/ltc_mic_dma.h rename to src/app/driver/afe/ltc/common/ltc_afe_dma.h index 70dc3f14..14f9999b 100644 --- a/src/app/driver/mic/ltc/common/ltc_mic_dma.h +++ b/src/app/driver/afe/ltc/common/ltc_afe_dma.h @@ -40,23 +40,23 @@ */ /** - * @file ltc_mic_dma.h + * @file ltc_afe_dma.h * @author foxBMS Team * @date 2020-05-27 (date of creation) * @updated 2020-06-18 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Headers for the driver for the DMA module for the LTC. * */ -#ifndef FOXBMS__LTC_MIC_DMA_H_ -#define FOXBMS__LTC_MIC_DMA_H_ +#ifndef FOXBMS__LTC_AFE_DMA_H_ +#define FOXBMS__LTC_AFE_DMA_H_ /*========== Includes =======================================================*/ /* clang-format off */ -#include "mic_dma.h" +#include "afe_dma.h" /* clang-format on */ #include "dma_cfg.h" #include "ltc_defs.h" @@ -71,7 +71,7 @@ * @brief Sends and receives data over SPI with DMA. * */ -extern STD_RETURN_TYPE_e MIC_TransmitReceiveSpiWithDma(uint16_t *tx, uint16_t *rx, uint32_t length); +extern STD_RETURN_TYPE_e AFE_TransmitReceiveSpiWithDma(uint16_t *tx, uint16_t *rx, uint32_t length); /** * @brief gets the SPI transmit status. @@ -81,15 +81,15 @@ extern STD_RETURN_TYPE_e MIC_TransmitReceiveSpiWithDma(uint16_t *tx, uint16_t *r * @return retval true if transmission still ongoing, false otherwise * */ -extern bool MIC_IsTransmitOngoing(LTC_STATE_s *pLtcState); +extern bool AFE_IsTransmitOngoing(LTC_STATE_s *pLtcState); /** * @brief sets the SPI transmit status. * * @param[in,out] pLtcState pointer to state struct to set transmission state to ongoing */ -extern void MIC_SetTransmitOngoing(LTC_STATE_s *pLtcState); +extern void AFE_SetTransmitOngoing(LTC_STATE_s *pLtcState); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__LTC_MIC_DMA_H_ */ +#endif /* FOXBMS__LTC_AFE_DMA_H_ */ diff --git a/src/app/driver/mic/ltc/common/ltc_defs.h b/src/app/driver/afe/ltc/common/ltc_defs.h similarity index 100% rename from src/app/driver/mic/ltc/common/ltc_defs.h rename to src/app/driver/afe/ltc/common/ltc_defs.h diff --git a/src/app/driver/mic/ltc/common/ltc_pec.c b/src/app/driver/afe/ltc/common/ltc_pec.c similarity index 100% rename from src/app/driver/mic/ltc/common/ltc_pec.c rename to src/app/driver/afe/ltc/common/ltc_pec.c diff --git a/src/app/driver/mic/ltc/common/ltc_pec.h b/src/app/driver/afe/ltc/common/ltc_pec.h similarity index 100% rename from src/app/driver/mic/ltc/common/ltc_pec.h rename to src/app/driver/afe/ltc/common/ltc_pec.h diff --git a/src/app/driver/mic/ltc/wscript b/src/app/driver/afe/ltc/wscript similarity index 95% rename from src/app/driver/mic/ltc/wscript rename to src/app/driver/afe/ltc/wscript index 1543397c..25d2f3e4 100644 --- a/src/app/driver/mic/ltc/wscript +++ b/src/app/driver/afe/ltc/wscript @@ -38,11 +38,11 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Helper Build Script: ./src/app/driver/mic/wscript +"""Helper Build Script: ./src/app/driver/afe/wscript Helper script to recursively build the embedded sources""" def build(bld): """selects the driver library to be build""" - bld.recurse(bld.env.measurement_ic_chip) + bld.recurse(bld.env.afe_chip) diff --git a/src/app/driver/mic/maxim/api/README.md b/src/app/driver/afe/maxim/api/README.md similarity index 100% rename from src/app/driver/mic/maxim/api/README.md rename to src/app/driver/afe/maxim/api/README.md diff --git a/src/app/driver/mic/maxim/common/api/mxm_mic.c b/src/app/driver/afe/maxim/common/api/mxm_afe.c similarity index 91% rename from src/app/driver/mic/maxim/common/api/mxm_mic.c rename to src/app/driver/afe/maxim/common/api/mxm_afe.c index 029185fc..1771111d 100644 --- a/src/app/driver/mic/maxim/common/api/mxm_mic.c +++ b/src/app/driver/afe/maxim/common/api/mxm_afe.c @@ -40,20 +40,20 @@ */ /** - * @file mxm_mic.c + * @file mxm_afe.c * @author foxBMS Team * @date 2020-06-16 (date of creation) * @updated 2021-07-14 (date of last update) * @ingroup DRIVER - * @prefix MIC + * @prefix AFE * - * @brief Measurement IC driver implementation + * @brief AFE driver implementation */ /*========== Includes =======================================================*/ #include "general.h" -#include "mic.h" +#include "afe.h" #include "mxm_17841b.h" #include "mxm_1785x.h" #include "mxm_battery_management.h" @@ -180,17 +180,17 @@ static void MXM_Tick(void) { } /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e MIC_TriggerIc(void) { +extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { MXM_Tick(); return STD_OK; } -extern STD_RETURN_TYPE_e MIC_Init(void) { +extern STD_RETURN_TYPE_e AFE_Initialize(void) { MXM_MonitoringPinInit(); return STD_OK; } -extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { +extern STD_RETURN_TYPE_e AFE_StartMeasurement(void) { STD_RETURN_TYPE_e retval = STD_OK; OS_EnterTaskCritical(); @@ -201,44 +201,44 @@ extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { return retval; } -extern bool MIC_IsFirstMeasurementCycleFinished(void) { +extern bool AFE_IsFirstMeasurementCycleFinished(void) { OS_EnterTaskCritical(); const bool firstMeasurementDone = mxm_state.firstMeasurementDone; OS_ExitTaskCritical(); return firstMeasurementDone; } -extern STD_RETURN_TYPE_e MIC_RequestIoWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoWrite(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); return STD_NOT_OK; } -extern STD_RETURN_TYPE_e MIC_RequestIoRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); return STD_NOT_OK; } -extern STD_RETURN_TYPE_e MIC_RequestTemperatureRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestTemperatureRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); return STD_NOT_OK; } -extern STD_RETURN_TYPE_e MIC_RequestBalancingFeedbackRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestBalancingFeedbackRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); return STD_NOT_OK; } -extern STD_RETURN_TYPE_e MIC_RequestEepromRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); return STD_NOT_OK; } -extern STD_RETURN_TYPE_e MIC_RequestEepromWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromWrite(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); return STD_NOT_OK; } -extern STD_RETURN_TYPE_e MIC_RequestOpenWireCheck(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestOpenWireCheck(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); STD_RETURN_TYPE_e retval = STD_OK; diff --git a/src/app/driver/mic/maxim/common/config/mxm_cfg.c b/src/app/driver/afe/maxim/common/config/mxm_cfg.c similarity index 100% rename from src/app/driver/mic/maxim/common/config/mxm_cfg.c rename to src/app/driver/afe/maxim/common/config/mxm_cfg.c diff --git a/src/app/driver/mic/maxim/common/config/mxm_cfg.h b/src/app/driver/afe/maxim/common/config/mxm_cfg.h similarity index 100% rename from src/app/driver/mic/maxim/common/config/mxm_cfg.h rename to src/app/driver/afe/maxim/common/config/mxm_cfg.h diff --git a/src/app/driver/mic/maxim/common/maxim_common.json b/src/app/driver/afe/maxim/common/maxim_common.json similarity index 100% rename from src/app/driver/mic/maxim/common/maxim_common.json rename to src/app/driver/afe/maxim/common/maxim_common.json diff --git a/src/app/driver/mic/maxim/common/mxm_17841b.c b/src/app/driver/afe/maxim/common/mxm_17841b.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_17841b.c rename to src/app/driver/afe/maxim/common/mxm_17841b.c diff --git a/src/app/driver/mic/maxim/common/mxm_17841b.h b/src/app/driver/afe/maxim/common/mxm_17841b.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_17841b.h rename to src/app/driver/afe/maxim/common/mxm_17841b.h diff --git a/src/app/driver/mic/maxim/common/mxm_1785x.c b/src/app/driver/afe/maxim/common/mxm_1785x.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_1785x.c rename to src/app/driver/afe/maxim/common/mxm_1785x.c diff --git a/src/app/driver/mic/maxim/common/mxm_1785x.h b/src/app/driver/afe/maxim/common/mxm_1785x.h similarity index 99% rename from src/app/driver/mic/maxim/common/mxm_1785x.h rename to src/app/driver/afe/maxim/common/mxm_1785x.h index 894dc8fb..2df726a2 100644 --- a/src/app/driver/mic/maxim/common/mxm_1785x.h +++ b/src/app/driver/afe/maxim/common/mxm_1785x.h @@ -59,7 +59,7 @@ * This module supplies a driver for the Battery Monitoring ICs of the * MAX1785x-family by Maxim Integrated. * - * Entry point for the module is the function #MXM_Tick() in mxm_mic.c. It handles + * Entry point for the module is the function #MXM_Tick() in mxm_afe.c. It handles * the measurement flow and the coordination of the underlying state-machines. * Below this layer two state-machines are implemented. * diff --git a/src/app/driver/mic/maxim/common/mxm_1785x_tools.c b/src/app/driver/afe/maxim/common/mxm_1785x_tools.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_1785x_tools.c rename to src/app/driver/afe/maxim/common/mxm_1785x_tools.c diff --git a/src/app/driver/mic/maxim/common/mxm_1785x_tools.h b/src/app/driver/afe/maxim/common/mxm_1785x_tools.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_1785x_tools.h rename to src/app/driver/afe/maxim/common/mxm_1785x_tools.h diff --git a/src/app/driver/mic/maxim/common/mxm_41b_register_map.h b/src/app/driver/afe/maxim/common/mxm_41b_register_map.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_41b_register_map.h rename to src/app/driver/afe/maxim/common/mxm_41b_register_map.h diff --git a/src/app/driver/mic/maxim/common/mxm_mic_dma.c b/src/app/driver/afe/maxim/common/mxm_afe_dma.c similarity index 95% rename from src/app/driver/mic/maxim/common/mxm_mic_dma.c rename to src/app/driver/afe/maxim/common/mxm_afe_dma.c index dd07406a..dd4c09d4 100644 --- a/src/app/driver/mic/maxim/common/mxm_mic_dma.c +++ b/src/app/driver/afe/maxim/common/mxm_afe_dma.c @@ -40,19 +40,19 @@ */ /** - * @file mxm_mic_dma.c + * @file mxm_afe_dma.c * @author foxBMS Team * @date 2020-06-16 (date of creation) * @updated 2020-06-16 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Driver for the DMA module for the Maxim driver. * */ /*========== Includes =======================================================*/ -#include "mxm_mic_dma.h" +#include "mxm_afe_dma.h" /*========== Macros and Definitions =========================================*/ @@ -67,7 +67,7 @@ /*========== Extern Function Implementations ================================*/ /* Function called on DMA complete interrupts (TX and RX). */ -void MIC_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { +void AFE_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { /* This function is not implemented. */ FAS_ASSERT(FAS_TRAP); } diff --git a/src/app/driver/mic/maxim/common/mxm_mic_dma.h b/src/app/driver/afe/maxim/common/mxm_afe_dma.h similarity index 94% rename from src/app/driver/mic/maxim/common/mxm_mic_dma.h rename to src/app/driver/afe/maxim/common/mxm_afe_dma.h index c79d9860..61ae6b20 100644 --- a/src/app/driver/mic/maxim/common/mxm_mic_dma.h +++ b/src/app/driver/afe/maxim/common/mxm_afe_dma.h @@ -40,23 +40,23 @@ */ /** - * @file mxm_mic_dma.h + * @file mxm_afe_dma.h * @author foxBMS Team * @date 2020-06-16 (date of creation) * @updated 2020-06-16 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Headers for the driver for the DMA module for the Maxim driver. * */ -#ifndef FOXBMS__MXM_MIC_DMA_H_ -#define FOXBMS__MXM_MIC_DMA_H_ +#ifndef FOXBMS__MXM_AFE_DMA_H_ +#define FOXBMS__MXM_AFE_DMA_H_ /*========== Includes =======================================================*/ /* clang-format off */ -#include "mic_dma.h" +#include "afe_dma.h" /* clang-format on */ /*========== Macros and Definitions =========================================*/ @@ -67,4 +67,4 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__MXM_MIC_DMA_H_ */ +#endif /* FOXBMS__MXM_AFE_DMA_H_ */ diff --git a/src/app/driver/mic/maxim/common/mxm_basic_defines.h b/src/app/driver/afe/maxim/common/mxm_basic_defines.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_basic_defines.h rename to src/app/driver/afe/maxim/common/mxm_basic_defines.h diff --git a/src/app/driver/mic/maxim/common/mxm_battery_management.c b/src/app/driver/afe/maxim/common/mxm_battery_management.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_battery_management.c rename to src/app/driver/afe/maxim/common/mxm_battery_management.c diff --git a/src/app/driver/mic/maxim/common/mxm_battery_management.h b/src/app/driver/afe/maxim/common/mxm_battery_management.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_battery_management.h rename to src/app/driver/afe/maxim/common/mxm_battery_management.h diff --git a/src/app/driver/mic/maxim/common/mxm_bitextract.c b/src/app/driver/afe/maxim/common/mxm_bitextract.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_bitextract.c rename to src/app/driver/afe/maxim/common/mxm_bitextract.c diff --git a/src/app/driver/mic/maxim/common/mxm_bitextract.h b/src/app/driver/afe/maxim/common/mxm_bitextract.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_bitextract.h rename to src/app/driver/afe/maxim/common/mxm_bitextract.h diff --git a/src/app/driver/mic/maxim/common/mxm_crc8.c b/src/app/driver/afe/maxim/common/mxm_crc8.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_crc8.c rename to src/app/driver/afe/maxim/common/mxm_crc8.c diff --git a/src/app/driver/mic/maxim/common/mxm_crc8.h b/src/app/driver/afe/maxim/common/mxm_crc8.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_crc8.h rename to src/app/driver/afe/maxim/common/mxm_crc8.h diff --git a/src/app/driver/mic/maxim/common/mxm_register_map.h b/src/app/driver/afe/maxim/common/mxm_register_map.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_register_map.h rename to src/app/driver/afe/maxim/common/mxm_register_map.h diff --git a/src/app/driver/mic/maxim/common/mxm_registry.c b/src/app/driver/afe/maxim/common/mxm_registry.c similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_registry.c rename to src/app/driver/afe/maxim/common/mxm_registry.c diff --git a/src/app/driver/mic/maxim/common/mxm_registry.h b/src/app/driver/afe/maxim/common/mxm_registry.h similarity index 100% rename from src/app/driver/mic/maxim/common/mxm_registry.h rename to src/app/driver/afe/maxim/common/mxm_registry.h diff --git a/src/app/driver/mic/maxim/wscript b/src/app/driver/afe/maxim/wscript similarity index 93% rename from src/app/driver/mic/maxim/wscript rename to src/app/driver/afe/maxim/wscript index 71cd58b7..6d19be46 100644 --- a/src/app/driver/mic/maxim/wscript +++ b/src/app/driver/afe/maxim/wscript @@ -44,9 +44,9 @@ import os def build(bld): - """builds the measurement ic driver library for Maxim""" + """builds the AFE driver library for Maxim""" source = [ - os.path.join(".", "common", "api", "mxm_mic.c"), + os.path.join(".", "common", "api", "mxm_afe.c"), os.path.join(".", "common", "config", "mxm_cfg.c"), os.path.join(".", "common", "mxm_17841b.c"), os.path.join(".", "common", "mxm_1785x.c"), @@ -54,7 +54,7 @@ def build(bld): os.path.join(".", "common", "mxm_battery_management.c"), os.path.join(".", "common", "mxm_bitextract.c"), os.path.join(".", "common", "mxm_crc8.c"), - os.path.join(".", "common", "mxm_mic_dma.c"), + os.path.join(".", "common", "mxm_afe_dma.c"), os.path.join(".", "common", "mxm_registry.c"), ] includes = [ @@ -76,7 +76,7 @@ def build(bld): ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) cflags = bld.env.CFLAGS_FOXBMS - target = f"{bld.env.APPNAME.lower()}-mic-driver" + target = f"{bld.env.APPNAME.lower()}-afe-driver" bld.stlib( source=source, includes=includes, diff --git a/src/app/driver/mic/nxp/api/README.md b/src/app/driver/afe/nxp/api/README.md similarity index 100% rename from src/app/driver/mic/nxp/api/README.md rename to src/app/driver/afe/nxp/api/README.md diff --git a/src/app/driver/mic/nxp/common/MC33775A.h b/src/app/driver/afe/nxp/common/MC33775A.h similarity index 100% rename from src/app/driver/mic/nxp/common/MC33775A.h rename to src/app/driver/afe/nxp/common/MC33775A.h diff --git a/src/app/driver/mic/nxp/common/api/nxp_mic.c b/src/app/driver/afe/nxp/common/api/nxp_afe.c similarity index 82% rename from src/app/driver/mic/nxp/common/api/nxp_mic.c rename to src/app/driver/afe/nxp/common/api/nxp_afe.c index c583b764..9fa6a727 100644 --- a/src/app/driver/mic/nxp/common/api/nxp_mic.c +++ b/src/app/driver/afe/nxp/common/api/nxp_afe.c @@ -40,23 +40,23 @@ */ /** - * @file nxp_mic.c + * @file nxp_afe.c * @author foxBMS Team * @date 2020-05-25 (date of creation) * @updated 2020-06-17 (date of last update) * @ingroup DRIVER - * @prefix MIC + * @prefix AFE * - * @brief Measurement IC driver implementation for NXP ICs + * @brief AFE driver implementation for NXP ICs */ /*========== Includes =======================================================*/ #include "general.h" /* clang-format off */ -#include "mic.h" +#include "afe.h" /* clang-format on */ #include "dma.h" -#include "mic_dma.h" +#include "afe_dma.h" #include "n775.h" /*========== Macros and Definitions =========================================*/ @@ -70,16 +70,16 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern STD_RETURN_TYPE_e MIC_TriggerIc(void) { +extern STD_RETURN_TYPE_e AFE_TriggerIc(void) { N775_Trigger(); return STD_OK; } -extern STD_RETURN_TYPE_e MIC_Init(void) { +extern STD_RETURN_TYPE_e AFE_Initialize(void) { return STD_OK; } -extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { +extern STD_RETURN_TYPE_e AFE_StartMeasurement(void) { STD_RETURN_TYPE_e retval = STD_NOT_OK; if (N775_SetStateRequest(N775_STATE_INIT_REQUEST) == N775_OK) { @@ -89,47 +89,47 @@ extern STD_RETURN_TYPE_e MIC_StartMeasurement(void) { return retval; } -extern bool MIC_IsFirstMeasurementCycleFinished(void) { +extern bool AFE_IsFirstMeasurementCycleFinished(void) { return N775_IsFirstMeasurementCycleFinished(); } -extern STD_RETURN_TYPE_e MIC_RequestIoWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoWrite(uint8_t string) { STD_RETURN_TYPE_e retval = STD_NOT_OK; return (retval); } -extern STD_RETURN_TYPE_e MIC_RequestIoRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestIoRead(uint8_t string) { STD_RETURN_TYPE_e retval = STD_NOT_OK; return (retval); } -extern STD_RETURN_TYPE_e MIC_RequestTemperatureRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestTemperatureRead(uint8_t string) { STD_RETURN_TYPE_e retval = STD_NOT_OK; return (retval); } -extern STD_RETURN_TYPE_e MIC_RequestBalancingFeedbackRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestBalancingFeedbackRead(uint8_t string) { STD_RETURN_TYPE_e retval = STD_NOT_OK; return (retval); } -extern STD_RETURN_TYPE_e MIC_RequestEepromRead(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromRead(uint8_t string) { STD_RETURN_TYPE_e retval = STD_NOT_OK; return (retval); } -extern STD_RETURN_TYPE_e MIC_RequestEepromWrite(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestEepromWrite(uint8_t string) { STD_RETURN_TYPE_e retVal = STD_NOT_OK; return (retVal); } -extern STD_RETURN_TYPE_e MIC_RequestOpenWireCheck(uint8_t string) { +extern STD_RETURN_TYPE_e AFE_RequestOpenWireCheck(uint8_t string) { STD_RETURN_TYPE_e retVal = STD_NOT_OK; return (retVal); diff --git a/src/app/driver/mic/nxp/common/config/n775_cfg.c b/src/app/driver/afe/nxp/common/config/n775_cfg.c similarity index 100% rename from src/app/driver/mic/nxp/common/config/n775_cfg.c rename to src/app/driver/afe/nxp/common/config/n775_cfg.c diff --git a/src/app/driver/mic/nxp/common/config/n775_cfg.h b/src/app/driver/afe/nxp/common/config/n775_cfg.h similarity index 99% rename from src/app/driver/mic/nxp/common/config/n775_cfg.h rename to src/app/driver/afe/nxp/common/config/n775_cfg.h index d1bb3c80..c7c4ca9d 100644 --- a/src/app/driver/mic/nxp/common/config/n775_cfg.h +++ b/src/app/driver/afe/nxp/common/config/n775_cfg.h @@ -58,7 +58,7 @@ #include "battery_system_cfg.h" #include "n775_defs.h" -#include "nxp_mic_dma.h" +#include "nxp_afe_dma.h" #include "spi.h" /*========== Macros and Definitions =========================================*/ diff --git a/src/app/driver/mic/nxp/common/config/nxp_mic_dma_cfg.c b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c similarity index 98% rename from src/app/driver/mic/nxp/common/config/nxp_mic_dma_cfg.c rename to src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c index 3008156a..5e72838d 100644 --- a/src/app/driver/mic/nxp/common/config/nxp_mic_dma_cfg.c +++ b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.c @@ -40,7 +40,7 @@ */ /** - * @file nxp_mic_dma_cfg.c + * @file nxp_afe_dma_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) * @updated 2020-03-05 (date of last update) @@ -54,7 +54,7 @@ */ /*========== Includes =======================================================*/ -#include "nxp_mic_dma_cfg.h" +#include "nxp_afe_dma_cfg.h" #include "n775.h" diff --git a/src/app/driver/mic/nxp/common/config/nxp_mic_dma_cfg.h b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h similarity index 95% rename from src/app/driver/mic/nxp/common/config/nxp_mic_dma_cfg.h rename to src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h index aedb4a7c..a25c01dc 100644 --- a/src/app/driver/mic/nxp/common/config/nxp_mic_dma_cfg.h +++ b/src/app/driver/afe/nxp/common/config/nxp_afe_dma_cfg.h @@ -40,7 +40,7 @@ */ /** - * @file nxp_mic_dma_cfg.h + * @file nxp_afe_dma_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) * @updated 2020-03-05 (date of last update) @@ -52,8 +52,8 @@ * */ -#ifndef FOXBMS__NXP_MIC_DMA_CFG_H_ -#define FOXBMS__NXP_MIC_DMA_CFG_H_ +#ifndef FOXBMS__NXP_AFE_DMA_CFG_H_ +#define FOXBMS__NXP_AFE_DMA_CFG_H_ /*========== Includes =======================================================*/ #include "general.h" @@ -71,4 +71,4 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__NXP_MIC_DMA_CFG_H_ */ +#endif /* FOXBMS__NXP_AFE_DMA_CFG_H_ */ diff --git a/src/app/driver/mic/nxp/common/n775.c b/src/app/driver/afe/nxp/common/n775.c similarity index 99% rename from src/app/driver/mic/nxp/common/n775.c rename to src/app/driver/afe/nxp/common/n775.c index 1301204c..94733b3d 100644 --- a/src/app/driver/mic/nxp/common/n775.c +++ b/src/app/driver/afe/nxp/common/n775.c @@ -57,9 +57,9 @@ #include "HL_system.h" #include "MC33775A.h" +#include "afe_dma.h" #include "database.h" #include "diag.h" -#include "mic_dma.h" #include "os.h" /*========== Macros and Definitions =========================================*/ @@ -371,7 +371,7 @@ void N775_Trigger(void) { } } } else { - if (MIC_IsTxTransmitOngoing() == true) { + if (AFE_IsTxTransmitOngoing() == true) { if (n775_state.timer > 0u) { if ((--n775_state.timer) > 0u) { n775_state.triggerEntry--; @@ -380,7 +380,7 @@ void N775_Trigger(void) { } } } - if (MIC_IsRxTransmitOngoing() == true) { + if (AFE_IsRxTransmitOngoing() == true) { if (n775_state.timer > 0u) { if ((--n775_state.timer) > 0u) { n775_state.triggerEntry--; diff --git a/src/app/driver/mic/nxp/common/n775.h b/src/app/driver/afe/nxp/common/n775.h similarity index 100% rename from src/app/driver/mic/nxp/common/n775.h rename to src/app/driver/afe/nxp/common/n775.h diff --git a/src/app/driver/mic/nxp/common/n775_defs.h b/src/app/driver/afe/nxp/common/n775_defs.h similarity index 100% rename from src/app/driver/mic/nxp/common/n775_defs.h rename to src/app/driver/afe/nxp/common/n775_defs.h diff --git a/src/app/driver/mic/nxp/common/nxp_mic_dma.c b/src/app/driver/afe/nxp/common/nxp_afe_dma.c similarity index 92% rename from src/app/driver/mic/nxp/common/nxp_mic_dma.c rename to src/app/driver/afe/nxp/common/nxp_afe_dma.c index 03147a82..07d79524 100644 --- a/src/app/driver/mic/nxp/common/nxp_mic_dma.c +++ b/src/app/driver/afe/nxp/common/nxp_afe_dma.c @@ -40,19 +40,19 @@ */ /** - * @file nxp_mic_dma.c + * @file nxp_afe_dma.c * @author foxBMS Team * @date 2020-05-27 (date of creation) * @updated 2020-05-27 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Driver for the DMA module for the N775. * */ /*========== Includes =======================================================*/ -#include "nxp_mic_dma.h" +#include "nxp_afe_dma.h" #include "dma.h" #include "io.h" @@ -70,28 +70,28 @@ /*========== Extern Function Implementations ================================*/ -bool MIC_IsTxTransmitOngoing(void) { +bool AFE_IsTxTransmitOngoing(void) { bool retval = false; retval = n775_state.txTransmitOngoing; return retval; } -bool MIC_IsRxTransmitOngoing(void) { +bool AFE_IsRxTransmitOngoing(void) { bool retval = false; retval = n775_state.rxTransmitOngoing; return retval; } -void MIC_SetTxTransmitOngoing(void) { +void AFE_SetTxTransmitOngoing(void) { n775_state.txTransmitOngoing = false; } -void MIC_SetRxTransmitOngoing(void) { +void AFE_SetRxTransmitOngoing(void) { n775_state.rxTransmitOngoing = false; } /* Function called on DMA complete interrupts (TX and RX). */ -void MIC_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { +void AFE_DmaCallback(dmaInterrupt_t inttype, uint32 channel) { } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/mic/nxp/common/nxp_mic_dma.h b/src/app/driver/afe/nxp/common/nxp_afe_dma.h similarity index 87% rename from src/app/driver/mic/nxp/common/nxp_mic_dma.h rename to src/app/driver/afe/nxp/common/nxp_afe_dma.h index 883d995f..40c64048 100644 --- a/src/app/driver/mic/nxp/common/nxp_mic_dma.h +++ b/src/app/driver/afe/nxp/common/nxp_afe_dma.h @@ -40,32 +40,32 @@ */ /** - * @file nxp_mic_dma.h + * @file nxp_afe_dma.h * @author foxBMS Team * @date 2020-05-27 (date of creation) * @updated 2020-05-27 (date of last update) * @ingroup DRIVERS - * @prefix MIC + * @prefix AFE * * @brief Headers for the driver for the DMA module. * */ -#ifndef FOXBMS__NXP_MIC_DMA_H_ -#define FOXBMS__NXP_MIC_DMA_H_ +#ifndef FOXBMS__NXP_AFE_DMA_H_ +#define FOXBMS__NXP_AFE_DMA_H_ /*========== Includes =======================================================*/ #include "general.h" /* clang-format off */ -#include "mic_dma.h" +#include "afe_dma.h" /* clang-format on */ #include "HL_sys_dma.h" /*========== Macros and Definitions =========================================*/ /*========== Extern Constant and Variable Declarations ======================*/ -extern g_dmaCTRL mic_n775DmaControlPacketTx; -extern g_dmaCTRL mic_n775DmaControlPacketRx; +extern g_dmaCTRL afe_n775DmaControlPacketTx; +extern g_dmaCTRL afe_n775DmaControlPacketRx; /*========== Extern Function Prototypes =====================================*/ @@ -75,7 +75,7 @@ extern g_dmaCTRL mic_n775DmaControlPacketRx; * @return retval true if transmission still ongoing, false otherwise * */ -extern bool MIC_IsTxTransmitOngoing(void); +extern bool AFE_IsTxTransmitOngoing(void); /** * @brief gets the SPI transmit status. @@ -83,20 +83,20 @@ extern bool MIC_IsTxTransmitOngoing(void); * @return retval true if transmission still ongoing, false otherwise * */ -extern bool MIC_IsRxTransmitOngoing(void); +extern bool AFE_IsRxTransmitOngoing(void); /** * @brief sets the SPI transmit status. * */ -extern void MIC_SetTxTransmitOngoing(void); +extern void AFE_SetTxTransmitOngoing(void); /** * @brief sets the SPI transmit status. * */ -extern void MIC_SetRxTransmitOngoing(void); +extern void AFE_SetRxTransmitOngoing(void); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ -#endif /* FOXBMS__NXP_MIC_DMA_H_ */ +#endif /* FOXBMS__NXP_AFE_DMA_H_ */ diff --git a/src/app/driver/mic/nxp/common/nxp_common.json b/src/app/driver/afe/nxp/common/nxp_common.json similarity index 100% rename from src/app/driver/mic/nxp/common/nxp_common.json rename to src/app/driver/afe/nxp/common/nxp_common.json diff --git a/src/app/driver/mic/nxp/wscript b/src/app/driver/afe/nxp/wscript similarity index 81% rename from src/app/driver/mic/nxp/wscript rename to src/app/driver/afe/nxp/wscript index a7e43947..095098c3 100644 --- a/src/app/driver/mic/nxp/wscript +++ b/src/app/driver/afe/nxp/wscript @@ -44,18 +44,18 @@ import os def build(bld): - """builds the measurement ic driver library for N775""" + """builds the AFE driver library for N775""" source = [ - os.path.join(bld.env.measurement_ic_chip, "api", "nxp_mic.c"), - os.path.join(bld.env.measurement_ic_chip, "nxp_mic_dma.c"), - os.path.join(bld.env.measurement_ic_chip, "config", "nxp_mic_dma_cfg.c"), - os.path.join(bld.env.measurement_ic_chip, "n775.c"), - os.path.join(bld.env.measurement_ic_chip, "config", "n775_cfg.c"), + os.path.join(bld.env.afe_chip, "api", "nxp_afe.c"), + os.path.join(bld.env.afe_chip, "nxp_afe_dma.c"), + os.path.join(bld.env.afe_chip, "config", "nxp_afe_dma_cfg.c"), + os.path.join(bld.env.afe_chip, "n775.c"), + os.path.join(bld.env.afe_chip, "config", "n775_cfg.c"), ] includes = [ - bld.env.measurement_ic_chip, - os.path.join(bld.env.measurement_ic_chip, "..", "..", "api"), - os.path.join(bld.env.measurement_ic_chip, "config"), + bld.env.afe_chip, + os.path.join(bld.env.afe_chip, "..", "..", "api"), + os.path.join(bld.env.afe_chip, "config"), os.path.join("..", "..", "config"), os.path.join("..", "..", "dma"), os.path.join("..", "..", "foxmath"), @@ -71,7 +71,7 @@ def build(bld): ] includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) cflags = bld.env.CFLAGS_FOXBMS - target = f"{bld.env.APPNAME.lower()}-mic-driver" + target = f"{bld.env.APPNAME.lower()}-afe-driver" bld.stlib( source=source, includes=includes, diff --git a/src/app/driver/mic/wscript b/src/app/driver/afe/wscript similarity index 95% rename from src/app/driver/mic/wscript rename to src/app/driver/afe/wscript index cc8665c3..8afb85a5 100644 --- a/src/app/driver/mic/wscript +++ b/src/app/driver/afe/wscript @@ -38,11 +38,11 @@ # - "This product includes parts of foxBMS®" # - "This product is derived from foxBMS®" -"""Helper Build Script: ./src/app/driver/mic/wscript +"""Helper Build Script: ./src/app/driver/afe/wscript Helper script to recursively build the embedded sources""" def build(bld): """selects the driver library to be build""" - bld.recurse(bld.env.measurement_ic_manufacturer) + bld.recurse(bld.env.afe_manufacturer) diff --git a/src/app/driver/can/can.c b/src/app/driver/can/can.c index c2bbb525..87326cd3 100644 --- a/src/app/driver/can/can.c +++ b/src/app/driver/can/can.c @@ -43,7 +43,7 @@ * @file can.c * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2021-10-12 (date of last update) * @ingroup DRIVERS * @prefix CAN * @@ -67,8 +67,7 @@ #include "diag.h" #include "foxmath.h" #include "ftask.h" -#include "io.h" -#include "mcu.h" +#include "pex.h" /*========== Macros and Definitions =========================================*/ /** lower limit of timestamp counts for a valid CAN timing */ @@ -95,6 +94,9 @@ /** bit position of boot message byte 3 release distance counter */ #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER (3u) +/** return value of function canGetData if no data was lost during reception */ +#define CAN_HAL_RETVAL_NO_DATA_LOST (1u) + /*========== Static Constant and Variable Definitions =======================*/ /** tracks the local state of the can module */ @@ -181,25 +183,17 @@ static void CAN_InitializeTransceiver(void); /*========== Static Function Implementations ================================*/ static void CAN_InitializeTransceiver(void) { - /* set EN and STB pins to output */ - SETBIT(CAN_HET1_GIO->DIR, CAN_HET1_EN_PIN); - SETBIT(CAN_HET1_GIO->DIR, CAN_HET1_STB_PIN); - - /* first set EN and STB pins to 0 */ - IO_PinReset(&CAN_HET1_GIO->DOUT, CAN_HET1_EN_PIN); - IO_PinReset(&CAN_HET1_GIO->DOUT, CAN_HET1_STB_PIN); - /* wait after pin toggle */ - MCU_delay_us(CAN_PIN_TOGGLE_DELAY_US); - - /* set EN pin to 1 */ - IO_PinSet(&CAN_HET1_GIO->DOUT, CAN_HET1_EN_PIN); - /* wait after pin toggle */ - MCU_delay_us(CAN_PIN_TOGGLE_DELAY_US); - - /* set STB pin to 1 */ - IO_PinSet(&CAN_HET1_GIO->DOUT, CAN_HET1_STB_PIN); - /* wait after pin toggle */ - MCU_delay_us(CAN_PIN_TOGGLE_DELAY_US); + /** Initialize transceiver for CAN1 */ + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER2, CAN1_ENABLE_PIN); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER2, CAN1_STANDBY_PIN); + PEX_SetPin(PEX_PORT_EXPANDER2, CAN1_ENABLE_PIN); + PEX_SetPin(PEX_PORT_EXPANDER2, CAN1_STANDBY_PIN); + + /** Initialize transceiver for CAN2 */ + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER2, CAN2_ENABLE_PIN); + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER2, CAN2_STANDBY_PIN); + PEX_SetPin(PEX_PORT_EXPANDER2, CAN2_ENABLE_PIN); + PEX_SetPin(PEX_PORT_EXPANDER2, CAN2_STANDBY_PIN); } /*========== Extern Function Implementations ================================*/ @@ -211,6 +205,7 @@ 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)); STD_RETURN_TYPE_e result = STD_NOT_OK; @@ -261,7 +256,7 @@ static STD_RETURN_TYPE_e CAN_PeriodicTransmit(void) { /* CAN messages are currently discarded if all message boxes * are full. They will not be retransmitted within the next * call of CAN_PeriodicTransmit() */ - CAN_DataSend(CAN0_NODE, can_txMessages[i].id, data); + CAN_DataSend(can_txMessages[i].canNode, can_txMessages[i].id, data); retVal = STD_OK; } } @@ -352,7 +347,7 @@ extern void CAN_ReadRxBuffer(void) { while (pdPASS == xQueueReceive(ftsk_canRxQueue, (void *)&can_rxBuffer, 0u)) { /* data queue was no empty */ for (uint16_t i = 0u; i < can_rxLength; i++) { - if (can_rxBuffer.id == can_rxMessages[i].id) { + if ((can_rxBuffer.canNode == can_rxMessages[i].canNode) && (can_rxBuffer.id == can_rxMessages[i].id)) { if (can_rxMessages[i].callbackFunction != NULL_PTR) { can_rxMessages[i].callbackFunction( can_rxMessages[i].id, @@ -437,34 +432,40 @@ static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox) { static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) { FAS_ASSERT(pNode != NULL_PTR); - CAN_BUFFERELEMENT_s can_rxBuffer = {0}; - uint8_t data[8] = {0}; - /* Read even if queues are not created, otherwise message boxes get full */ - canGetData(pNode, messageBox, (uint8 *)&data[0]); /* copy to RAM */ - - /* Check that CAN RX queue is started before using it */ - if (ftsk_allQueuesCreated == true) { - if (pNode == CAN0_NODE) { - /* id shifted by 18 to use standard frame from IF2ARB register*/ - /* standard frame: bits [28:18] */ - /* extended frame: bits [28:0] */ - uint32_t id = canGetID(pNode, messageBox) >> 18; - can_rxBuffer.id = id; - can_rxBuffer.data[0] = data[0]; - can_rxBuffer.data[1] = data[1]; - can_rxBuffer.data[2] = data[2]; - can_rxBuffer.data[3] = data[3]; - can_rxBuffer.data[4] = data[4]; - can_rxBuffer.data[5] = data[5]; - can_rxBuffer.data[6] = data[6]; - can_rxBuffer.data[7] = data[7]; - if (pdPASS == xQueueSendToBackFromISR(ftsk_canRxQueue, (void *)&can_rxBuffer, NULL)) { - /* queue is not full */ - DIAG_Handler(DIAG_ID_CAN_RX_QUEUE_FULL, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); - } else { - /* queue is full */ - DIAG_Handler(DIAG_ID_CAN_RX_QUEUE_FULL, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); - } + CAN_BUFFERELEMENT_s can_rxBuffer = {0u}; + uint8_t messageData[CAN_DLC] = {0u}; + /** + * Read even if queues are not created, otherwise message boxes get full. + * Possible return values: + * - 0: no new data + * - 1: no data lost + * - 3: data lost */ + 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)) { + /* id shifted by 18 to use standard frame from IF2ARB register*/ + /* standard frame: bits [28:18] */ + /* extended frame: bits [28:0] */ + uint32_t id = canGetID(pNode, messageBox) >> 18u; + + can_rxBuffer.canNode = pNode; + can_rxBuffer.id = id; + can_rxBuffer.data[0] = messageData[0]; + can_rxBuffer.data[1] = messageData[1]; + can_rxBuffer.data[2] = messageData[2]; + can_rxBuffer.data[3] = messageData[3]; + can_rxBuffer.data[4] = messageData[4]; + can_rxBuffer.data[5] = messageData[5]; + can_rxBuffer.data[6] = messageData[6]; + can_rxBuffer.data[7] = messageData[7]; + + if (pdPASS == xQueueSendToBackFromISR(ftsk_canRxQueue, (void *)&can_rxBuffer, NULL)) { + /* queue is not full */ + DIAG_Handler(DIAG_ID_CAN_RX_QUEUE_FULL, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); + } else { + /* queue is full */ + DIAG_Handler(DIAG_ID_CAN_RX_QUEUE_FULL, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); } } } @@ -521,7 +522,7 @@ extern STD_RETURN_TYPE_e CAN_TransmitBootMessage(void) { data[CAN_BYTE_6_POSITION] = (uint8_t)((deviceRegister >> 8u) & 0xFFu); data[CAN_BYTE_7_POSITION] = (uint8_t)(deviceRegister & 0xFFu); - STD_RETURN_TYPE_e retval = CAN_DataSend(CAN0_NODE, CAN_ID_BOOT_MESSAGE, &data[0]); + STD_RETURN_TYPE_e retval = CAN_DataSend(CAN1_NODE, CAN_ID_BOOT_MESSAGE, &data[0]); return retval; } diff --git a/src/app/driver/can/can.h b/src/app/driver/can/can.h index 0f4f961a..8737bb3b 100644 --- a/src/app/driver/can/can.h +++ b/src/app/driver/can/can.h @@ -62,33 +62,18 @@ #include "can_cfg.h" -#include "HL_can.h" - /*========== Macros and Definitions =========================================*/ -/** register on which the CAN interface is connected */ -#define CAN0_NODE (canREG1) - /** Half of the 64 messageboxes are defined for TX * This is used to determined in the CAN interrupt routine if TX or RX case */ #define CAN_NR_OF_TX_MESSAGE_BOX (32U) -/** length of the RX buffer */ -#define CAN0_RX_BUFFER_LENGTH (32U) - /** Task time slot where the CAN TX function is called. Repetition time of * periodic CAN messages must be multiple of this (e.g., 1u, 10u or 100u) */ #define CAN_TICK_MS (10U) -/** Buffer containing all the CAN RX elements */ -typedef struct CAN_RX_BUFFER { - CAN_BUFFERELEMENT_s *pRead; /*!< read pointer */ - CAN_BUFFERELEMENT_s *pWrite; /*!< write pointer */ - uint8_t length; /*!< length of buffer */ -} CAN_RX_BUFFER_s; - /** This structure contains variables relevant for the CAN signal module. */ typedef struct CAN_STATE { bool periodicEnable; /*!< defines if periodic transmit and receive should run */ 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 fe1672a6..e44e4f26 100644 --- a/src/app/driver/can/cbs/can_cbs_tx_state.c +++ b/src/app/driver/can/cbs/can_cbs_tx_state.c @@ -365,12 +365,12 @@ extern uint32_t CAN_TxStringState( /* Error: Daisy-chain redundancy: CRC: TODO */ /* Error: Daisy-chain base: Voltage out of operating range */ - data = kpkCanShim->pTableErrorState->micCellvoltageError[stringNumber]; + data = kpkCanShim->pTableErrorState->afeCellvoltageError[stringNumber]; CAN_TxSetMessageDataWithSignalData(&message, 39u, 1u, data, endianness); /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */ /* Error: Daisy-chain base: Temperature out of operating range */ - data = kpkCanShim->pTableErrorState->micCellTemperatureError[stringNumber]; + data = kpkCanShim->pTableErrorState->afeCellTemperatureError[stringNumber]; CAN_TxSetMessageDataWithSignalData(&message, 41u, 1u, data, endianness); /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */ diff --git a/src/app/driver/config/can_cfg.c b/src/app/driver/config/can_cfg.c index 3ffc61de..fadbd7aa 100644 --- a/src/app/driver/config/can_cfg.c +++ b/src/app/driver/config/can_cfg.c @@ -43,7 +43,7 @@ * @file can_cfg.c * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2021-10-12 (date of last update) * @ingroup DRIVERS_CONFIGURATION * @prefix CAN * @@ -68,7 +68,7 @@ /*========== Static Constant and Variable Definitions =======================*/ -/** Multiplexer values */ +/** Multiplexer values @{*/ static uint8_t voltageMux = 0u; static uint8_t temperatureMux = 0u; static uint8_t stringStateMux = 0u; @@ -76,6 +76,7 @@ static uint8_t stringValuesMux = 0u; static uint8_t stringMinMaxMux = 0u; static uint8_t stringStateEstimationMux = 0u; static uint8_t stringValues2Mux = 0u; +/**@}*/ /*========== Extern Constant and Variable Definitions =======================*/ @@ -85,84 +86,96 @@ static uint8_t stringValues2Mux = 0u; /** registry of CAN TX messages */ const CAN_MSG_TX_TYPE_s can_txMessages[] = { - {CAN_ID_TX_STATE, + {CAN1_NODE, + CAN_ID_TX_STATE, CAN_DLC, CAN_TX_STATE_PERIOD_MS, CAN_TX_STATE_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxState, NULL_PTR}, /*!< State */ - {CAN_ID_TX_VOLTAGES, + {CAN1_NODE, + CAN_ID_TX_VOLTAGES, CAN_DLC, CAN_TX_VOLTAGES_PERIOD_MS, CAN_TX_VOLTAGES_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxVoltage, &voltageMux}, /*!< Cell voltages */ - {CAN_ID_TX_TEMPERATURES, + {CAN1_NODE, + CAN_ID_TX_TEMPERATURES, CAN_DLC, CAN_TX_TEMPERATURES_PERIOD_MS, CAN_TX_TEMPERATURES_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxCellTemperature, &temperatureMux}, /*!< Cell temperatures */ - {CAN_ID_TX_LIMIT_VALUES, + {CAN1_NODE, + CAN_ID_TX_LIMIT_VALUES, CAN_DLC, CAN_TX_LIMIT_VALUES_PERIOD_MS, CAN_TX_LIMIT_VALUES_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxLimitValues, NULL_PTR}, /*!< Limits */ - {CAN_ID_TX_MINIMUM_MAXIMUM_VALUES, + {CAN1_NODE, + CAN_ID_TX_MINIMUM_MAXIMUM_VALUES, CAN_DLC, CAN_TX_MINIMUM_MAXIMUM_VALUES_PERIOD_MS, CAN_TX_MINIMUM_MAXIMUM_VALUES_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxMinimumMaximumValues, NULL_PTR}, /*!< Pack minimum and maximum values */ - {CAN_ID_TX_PACK_STATE_ESTIMATION, + {CAN1_NODE, + CAN_ID_TX_PACK_STATE_ESTIMATION, CAN_DLC, CAN_TX_PACK_STATE_ESTIMATION_PERIOD_MS, CAN_TX_PACK_STATE_ESTIMATION_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxStateEstimation, NULL_PTR}, /*!< Pack state estimation */ - {CAN_ID_TX_PACK_VALUES, + {CAN1_NODE, + CAN_ID_TX_PACK_VALUES, CAN_DLC, CAN_TX_PACK_VALUES_PERIOD_MS, CAN_TX_PACK_VALUES_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxPackValues, NULL_PTR}, /*!< Pack values */ - {CAN_ID_TX_STRING_STATE, + {CAN1_NODE, + CAN_ID_TX_STRING_STATE, CAN_DLC, CAN_TX_STRING_STATE_PERIOD_MS, CAN_TX_STRING_STATE_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxStringState, &stringStateMux}, /*!< String state values */ - {CAN_ID_TX_STRING_VALUES, + {CAN1_NODE, + CAN_ID_TX_STRING_VALUES, CAN_DLC, CAN_TX_STRING_VALUES_PERIOD_MS, CAN_TX_STRING_VALUES_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxStringValues, &stringValuesMux}, /*!< String values */ - {CAN_ID_TX_STRING_MINIMUM_MAXIMUM, + {CAN1_NODE, + CAN_ID_TX_STRING_MINIMUM_MAXIMUM, CAN_DLC, CAN_TX_STRING_MINIMUM_MAXIMUM_PERIOD_MS, CAN_TX_STRING_MINIMUM_MAXIMUM_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxStringMinimumMaximumValues, &stringMinMaxMux}, /*!< String minimum maximum values */ - {CAN_ID_TX_STRING_STATE_ESTIMATION, + {CAN1_NODE, + CAN_ID_TX_STRING_STATE_ESTIMATION, CAN_DLC, CAN_TX_STRING_STATE_ESTIMATION_PERIOD_MS, CAN_TX_STRING_STATE_ESTIMATION_PHASE_MS, CAN_BIG_ENDIAN, &CAN_TxStringStateEstimation, &stringStateEstimationMux}, /*!< String minimum maximum values */ - {CAN_ID_TX_STRING_VALUES_2, + {CAN1_NODE, + CAN_ID_TX_STRING_VALUES_2, CAN_DLC, CAN_TX_STRING_VALUES_2_PERIOD_MS, CAN_TX_STRING_VALUES_2_PHASE_MS, @@ -178,64 +191,137 @@ const CAN_MSG_TX_TYPE_s can_txMessages[] = { /** registry of CAN RX messages */ const CAN_MSG_RX_TYPE_s can_rxMessages[] = { - {CAN_ID_IMD_INFO, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxImdInfo}, /*!< info message from iso165c */ - {CAN_ID_IMD_RESPONSE, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxImdResponse}, /*!< response mesage from iso165c */ + {CAN1_NODE, CAN_ID_IMD_INFO, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxImdInfo}, /*!< info message from iso165c */ + {CAN1_NODE, + CAN_ID_IMD_RESPONSE, + CAN_DLC, + CAN_LITTLE_ENDIAN, + &CAN_RxImdResponse}, /*!< response mesage from iso165c */ - {CAN_ID_COMMAND, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxRequest}, /*!< state request */ - {CAN_ID_SOFTWARE_RESET, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxSwReset}, /*!< software reset */ + {CAN1_NODE, CAN_ID_COMMAND, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxRequest}, /*!< state request */ + {CAN1_NODE, CAN_ID_SOFTWARE_RESET, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxSwReset}, /*!< software reset */ - {CAN_ID_STRING0_CURRENT, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */ - {CAN_ID_STRING0_VOLTAGE1, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */ - {CAN_ID_STRING0_VOLTAGE2, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */ - {CAN_ID_STRING0_VOLTAGE3, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */ - {CAN_ID_STRING0_TEMPERATURE, + {CAN1_NODE, + CAN_ID_STRING0_CURRENT, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING0_VOLTAGE1, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING0_VOLTAGE2, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING0_VOLTAGE3, CAN_DLC, CAN_BIG_ENDIAN, - &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */ - {CAN_ID_STRING0_POWER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */ - {CAN_ID_STRING0_CURRENT_COUNTER, + &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING0_TEMPERATURE, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING0_POWER, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING0_CURRENT_COUNTER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor C-C in cyclic mode */ - {CAN_ID_STRING0_ENERGY_COUNTER, + {CAN1_NODE, + CAN_ID_STRING0_ENERGY_COUNTER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor E-C in cyclic mode */ #if BS_NR_OF_STRINGS > 1u - {CAN_ID_STRING1_CURRENT, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */ - {CAN_ID_STRING1_VOLTAGE1, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */ - {CAN_ID_STRING1_VOLTAGE2, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */ - {CAN_ID_STRING1_VOLTAGE3, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */ - {CAN_ID_STRING1_TEMPERATURE, + {CAN1_NODE, + CAN_ID_STRING1_CURRENT, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING1_VOLTAGE1, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING1_VOLTAGE2, CAN_DLC, CAN_BIG_ENDIAN, - &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */ - {CAN_ID_STRING1_POWER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */ - {CAN_ID_STRING1_CURRENT_COUNTER, + &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING1_VOLTAGE3, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING1_TEMPERATURE, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING1_POWER, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING1_CURRENT_COUNTER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor C-C in cyclic mode */ - {CAN_ID_STRING1_ENERGY_COUNTER, + {CAN1_NODE, + CAN_ID_STRING1_ENERGY_COUNTER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor E-C in cyclic mode */ #if BS_NR_OF_STRINGS > 2u - {CAN_ID_STRING2_CURRENT, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */ - {CAN_ID_STRING2_VOLTAGE1, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */ - {CAN_ID_STRING2_VOLTAGE2, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */ - {CAN_ID_STRING2_VOLTAGE3, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */ - {CAN_ID_STRING2_TEMPERATURE, + {CAN1_NODE, + CAN_ID_STRING2_CURRENT, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING2_VOLTAGE1, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING2_VOLTAGE2, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING2_VOLTAGE3, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING2_TEMPERATURE, + CAN_DLC, + CAN_BIG_ENDIAN, + &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING2_POWER, CAN_DLC, CAN_BIG_ENDIAN, - &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */ - {CAN_ID_STRING2_POWER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */ - {CAN_ID_STRING2_CURRENT_COUNTER, + &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */ + {CAN1_NODE, + CAN_ID_STRING2_CURRENT_COUNTER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor C-C in cyclic mode */ - {CAN_ID_STRING2_ENERGY_COUNTER, + {CAN1_NODE, + CAN_ID_STRING2_ENERGY_COUNTER, CAN_DLC, CAN_BIG_ENDIAN, &CAN_RxCurrentSensor}, /*!< current sensor E-C in cyclic mode */ @@ -243,8 +329,8 @@ const CAN_MSG_RX_TYPE_s can_rxMessages[] = { #endif /* BS_NR_OF_STRINGS > 2 */ #endif /* BS_NR_OF_STRINGS > 1 */ - {CAN_ID_DEBUG, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxDebug}, /*!< debug message */ - {CAN_ID_SW_VERSION, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxSwVersion}, /*!< request SW version */ + {CAN1_NODE, CAN_ID_DEBUG, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxDebug}, /*!< debug message */ + {CAN1_NODE, CAN_ID_SW_VERSION, CAN_DLC, CAN_LITTLE_ENDIAN, &CAN_RxSwVersion}, /*!< request SW version */ }; /** length of CAN message arrays @{*/ diff --git a/src/app/driver/config/can_cfg.h b/src/app/driver/config/can_cfg.h index c4927f1f..83afecac 100644 --- a/src/app/driver/config/can_cfg.h +++ b/src/app/driver/config/can_cfg.h @@ -43,7 +43,7 @@ * @file can_cfg.h * @author foxBMS Team * @date 2019-12-04 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2021-10-12 (date of last update) * @ingroup DRIVERS * @prefix CAN * @@ -60,10 +60,27 @@ /*========== Includes =======================================================*/ #include "general.h" +#include "HL_can.h" + #include "database.h" /*========== Macros and Definitions =========================================*/ +/** register on which the CAN interface is connected @{*/ +#define CAN1_NODE (canREG1) +#define CAN2_NODE (canREG2) +/**@}*/ + +/** + * Configuration of CAN transceiver pins to the respective port expander pins. + * @{ + */ +#define CAN1_ENABLE_PIN (PEX_PIN00) +#define CAN1_STANDBY_PIN (PEX_PIN01) +#define CAN2_ENABLE_PIN (PEX_PIN02) +#define CAN2_STANDBY_PIN (PEX_PIN03) +/**@}*/ + /** Maximum ID if 11 bits are used */ #define CAN_MAX_11BIT_ID (2048u) /** Maximum length of Data Length Code */ @@ -74,8 +91,6 @@ /** TX messages - pack related */ -/** CAN message ID to send voltages */ - /** CAN message ID to send state */ #define CAN_ID_TX_STATE (0x220U) /** Periodicity of CAN state messages in ms */ @@ -83,6 +98,7 @@ /** Phase of CAN state messages in ms */ #define CAN_TX_STATE_PHASE_MS (0U) +/** CAN message ID to send voltages */ #define CAN_ID_TX_VOLTAGES (0x240U) /** Periodicity of CAN voltage messages in ms */ #define CAN_TX_VOLTAGES_PERIOD_MS (100U) @@ -191,8 +207,8 @@ /** CAN message ID for response message from iso165c */ #define CAN_ID_IMD_RESPONSE (0x23U) -/* IDs for the messages from the current sensors */ -/* String 0 */ +/** IDs for the messages from the current sensors */ +/** String 0 @{*/ #define CAN_ID_STRING0_CURRENT (0x521u) #define CAN_ID_STRING0_VOLTAGE1 (0x522u) #define CAN_ID_STRING0_VOLTAGE2 (0x523u) @@ -201,7 +217,8 @@ #define CAN_ID_STRING0_POWER (0x526u) #define CAN_ID_STRING0_CURRENT_COUNTER (0x527u) #define CAN_ID_STRING0_ENERGY_COUNTER (0x528u) -/* String 1 */ +/**@} + * String 1 @{*/ #define CAN_ID_STRING1_CURRENT (0x621u) #define CAN_ID_STRING1_VOLTAGE1 (0x622u) #define CAN_ID_STRING1_VOLTAGE2 (0x623u) @@ -210,7 +227,8 @@ #define CAN_ID_STRING1_POWER (0x626u) #define CAN_ID_STRING1_CURRENT_COUNTER (0x627u) #define CAN_ID_STRING1_ENERGY_COUNTER (0x628u) -/* String 2 */ +/**@} + * String 2 @{*/ #define CAN_ID_STRING2_CURRENT (0x721u) #define CAN_ID_STRING2_VOLTAGE1 (0x722u) #define CAN_ID_STRING2_VOLTAGE2 (0x723u) @@ -219,28 +237,12 @@ #define CAN_ID_STRING2_POWER (0x726u) #define CAN_ID_STRING2_CURRENT_COUNTER (0x727u) #define CAN_ID_STRING2_ENERGY_COUNTER (0x728u) - -/** macro for the register that handles the CAN-interface */ -#define CAN_HET1_GIO (hetREG1) - -/** register pin that handles enable */ -#define CAN_HET1_EN_PIN (14U) -/** register pin that handles standby */ -#define CAN_HET1_STB_PIN (16U) - -/** Buffer element used to store the ID and data of a CAN RX message */ -typedef struct CAN_BUFFERELEMENT { - uint32_t id; /*!< ID of the CAN message */ - uint8_t data[CAN_MAX_DLC]; /*!< payload of the CAN message */ -} CAN_BUFFERELEMENT_s; +/**@}*/ /* ************************************************************************************** * CAN BUFFER OPTIONS *****************************************************************************************/ -/** delay in µs used in #CAN_InitializeTransceiver for pin-toggling */ -#define CAN_PIN_TOGGLE_DELAY_US (5u) - /** Enum for byte order (endianness) * \verbatim * CAN data example: @@ -290,9 +292,16 @@ typedef enum CAN_ENDIANNESS { CAN_BIG_ENDIAN, } CAN_ENDIANNESS_e; +/** Buffer element used to store the ID and data of a CAN RX message */ +typedef struct CAN_BUFFERELEMENT { + 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 { - QueueHandle_t *pQueueImd; + QueueHandle_t *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 */ DATA_BLOCK_MIN_MAX_s *pTableMinMax; /*!< database table with min/max values */ @@ -320,6 +329,7 @@ typedef uint32_t (*can_callback_funcPtr)( /** 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 */ @@ -332,6 +342,7 @@ typedef struct CAN_MSG_TX_TYPE { /** 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) */ diff --git a/src/app/driver/config/dma_cfg.h b/src/app/driver/config/dma_cfg.h index 212339e1..1088a7f7 100644 --- a/src/app/driver/config/dma_cfg.h +++ b/src/app/driver/config/dma_cfg.h @@ -43,7 +43,7 @@ * @file dma_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2021-09-28 (date of last update) * @ingroup DRIVERS_CONFIGURATION * @prefix DMA * @@ -65,10 +65,23 @@ /*========== Macros and Definitions =========================================*/ -/** number of spi interfaces for DMA */ -#define DMA_NUMBER_SPI_INTERFACES 5U +/** defines for the DMA channels */ +/**@{*/ +#define DMA_CHANNEL_SPI1_TX (DMA_CH0) +#define DMA_CHANNEL_SPI1_RX (DMA_CH1) +#define DMA_CHANNEL_SPI2_TX (DMA_CH2) +#define DMA_CHANNEL_SPI2_RX (DMA_CH3) +#define DMA_CHANNEL_SPI3_TX (DMA_CH4) +#define DMA_CHANNEL_SPI3_RX (DMA_CH5) +#define DMA_CHANNEL_SPI4_TX (DMA_CH6) +#define DMA_CHANNEL_SPI4_RX (DMA_CH7) +#define DMA_CHANNEL_SPI5_TX (DMA_CH8) +#define DMA_CHANNEL_SPI5_RX (DMA_CH9) +#define DMA_CHANNEL_I2C_TX (DMA_CH10) +#define DMA_CHANNEL_I2C_RX (DMA_CH11) +/**@}*/ -/** defines for the DMA request lines (and to which SPI they belong) */ +/** defines for the DMA request lines */ /**@{*/ #define DMA_REQ_LINE_SPI1_TX (DMA_REQ1) #define DMA_REQ_LINE_SPI1_RX (DMA_REQ0) @@ -80,12 +93,17 @@ #define DMA_REQ_LINE_SPI4_RX (DMA_REQ24) #define DMA_REQ_LINE_SPI5_TX (DMA_REQ31) #define DMA_REQ_LINE_SPI5_RX (DMA_REQ30) +#define DMA_REQ_LINE_I2C_TX (DMA_REQ11) +#define DMA_REQ_LINE_I2C_RX (DMA_REQ10) /**@}*/ /** define for the shift of an address for big endian 8bit */ #define DMA_BIG_ENDIAN_ADDRESS_8BIT (3U) /** define for the shift of an address for big endian 16bit */ #define DMA_BIG_ENDIAN_ADDRESS_16BIT (2U) + +/** number of spi interfaces for DMA */ +#define DMA_NUMBER_SPI_INTERFACES 5U /** DMA Request enable bit */ #define DMAREQEN_BIT (0x10000U) /** SPI enable bit */ diff --git a/src/app/driver/config/interlock_cfg.c b/src/app/driver/config/interlock_cfg.c index add2c7c0..6620786a 100644 --- a/src/app/driver/config/interlock_cfg.c +++ b/src/app/driver/config/interlock_cfg.c @@ -43,7 +43,7 @@ * @file interlock_cfg.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2021-10-18 (date of last update) * @ingroup DRIVERS_CONFIGURATION * @prefix CONT * @@ -59,9 +59,6 @@ /*========== Static Constant and Variable Definitions =======================*/ /*========== Extern Constant and Variable Definitions =======================*/ -ILCK_CONFIG_s ilck_interlock_config = {ILCK_INTERLOCK_CONTROL, ILCK_INTERLOCK_FEEDBACK, ILCK_FEEDBACK_TYPE_DONT_CARE}; - -ILCK_ELECTRICAL_STATE_s ilck_interlock_state = {ILCK_SWITCH_OFF, ILCK_SWITCH_OFF}; /*========== Static Function Prototypes =====================================*/ diff --git a/src/app/driver/config/interlock_cfg.h b/src/app/driver/config/interlock_cfg.h index 5d5334c8..42d7e469 100644 --- a/src/app/driver/config/interlock_cfg.h +++ b/src/app/driver/config/interlock_cfg.h @@ -43,7 +43,7 @@ * @file interlock_cfg.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2021-10-18 (date of last update) * @ingroup DRIVERS_CONFIGURATION * @prefix ILCK * @@ -57,39 +57,52 @@ /*========== Includes =======================================================*/ #include "general.h" -#include "HL_gio.h" +#include "HL_het.h" /*========== Macros and Definitions =========================================*/ /** IO register to which the interlock is connected */ -#define ILCK_IO_REG (gioPORTA) +#define ILCK_IO_REG_DIR (hetREG1->DIR) +/** IO port for interlock related pins */ +#define ILCK_IO_REG_PORT (hetREG1) -/** - * The number of defines per contactor must be the same as the length - * of the array ilck_contactors_cfg in contactor_cfg.c - * Every contactor consists of 1 control pin and 1 feedback pin - * counting together as 1 contactor. - * E.g. if you have 1 contactor your define has to be: - * \verbatim #define ILCK_INTERLOCK_CONTROL (PIN_MCU_0_INTERLOCK_CONTROL)\endverbatim - * \verbatim #define ILCK_INTERLOCK_FEEDBACK (PIN_MCU_0_INTERLOCK_FEEDBACK)\endverbatim - */ -#define ILCK_INTERLOCK_CONTROL (6U) +/** Enable pin for diagnostic power supply */ +#define ILCK_INTERLOCK_CONTROL_PIN_IL_HS_ENABLE (30u) /** Defines the pin where interlock feedback pin is connected to the mcu */ -#define ILCK_INTERLOCK_FEEDBACK (0U) +#define ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE (29u) + +/* Defines to which ADC input the interlock circuitry is connected to */ +/** High-side voltage sense signal connected to ADC input 2 (IL_HS_VS) */ +#define ILCK_ADC_INPUT_HIGH_SIDE_VOLTAGE_SENSE (2u) +/** Low-side voltage sense signal connected to ADC input 3 (IL_LS_VS) */ +#define ILCK_ADC_INPUT_LOW_SIDE_VOLTAGE_SENSE (3u) +/** High-side current sense signal connected to ADC input 4 (IL_HS_CS) */ +#define ILCK_ADC_INPUT_HIGH_SIDE_CURRENT_SENSE (4u) +/** Low-side current sense signal connected to ADC input 5 (IL_LS_CS) */ +#define ILCK_ADC_INPUT_LOW_SIDE_CURRENT_SENSE (5u) + +/** Factor of resistor divider used for measuring the low- and high-side + * interlock voltages. Used resistor values are 5k6 ohm and 3k9 ohm. */ +#define ILCK_VOLTAGE_DIVIDER_FACTOR ((5.6f + 3.9f) / 3.9f) /** - * This define MUST represent the cycle time of the task in which context the - * functions run, e.g., if the ILCK_Trigger() is running in the 10 ms task - * then the define must be set to 10. - * - * This define also sets the minimum time. + * Conversion factor for interlock current IL_HS_CS + * 2k49 ohm is the resistance through which sense current flows + * 80 is the (output current / sense current) ratio of high-side power switch + * TPS2H000-Q1 Datasheet SLVSD72D ?DECEMBER 2015?REVISED DECEMBER 2019 p.8 */ +#define ILCK_FACTOR_IL_HS_CS_1_ohm (80.0f / 2049.0f) -#define ILCK_TASK_CYCLE_CONTEXT_MS (10) +/** Linear conversion factor for low-side interlock current measurement + * (IL_LS_CS). Measurement performed via 2 ohm shunt with a gain of 20V/V */ +#define ILCK_FACTOR_IL_LS_CS_1_ohm (0.025f) -/** ILCK statemachine short time definition in ms */ -#define ILCK_STATEMACH_SHORTTIME_MS (ILCK_TASK_CYCLE_CONTEXT_MS) +/** + * @brief ILCK statemachine short time definition in #ILCK_Trigger() calls + * until next state/substate is processed + */ +#define ILCK_STATEMACH_SHORTTIME (1u) /** Symbolic names for contactors' possible states */ typedef enum ILCK_ELECTRICAL_STATE_TYPE { @@ -98,35 +111,7 @@ typedef enum ILCK_ELECTRICAL_STATE_TYPE { ILCK_SWITCH_UNDEF, /*!< Contactor undefined --> Contactor state not known */ } ILCK_ELECTRICAL_STATE_TYPE_e; -/** Symbolic names defining the electric behavior of the contactor */ -typedef enum ILCK_FEEDBACK_TYPE { - ILCK_FEEDBACK_NORMALLY_OPEN, /*!< Feedback line of a contactor is normally open */ - ILCK_FEEDBACK_NORMALLY_CLOSED, /*!< Feedback line of a contactor is normally closed */ - ILCK_FEEDBACK_TYPE_DONT_CARE, /*!< Feedback line of the contactor is not used */ -} ILCK_FEEDBACK_TYPE_e; - -/** - * struct describing the electrical state (expected and measured) of the interlock - */ -typedef struct ILCK_ELECTRICAL_STATE { - ILCK_ELECTRICAL_STATE_TYPE_e set; - ILCK_ELECTRICAL_STATE_TYPE_e feedback; -} ILCK_ELECTRICAL_STATE_s; - -/** struct decribing the hardware configuration of the interlock */ -typedef struct ILCK_CONFIG { - /* IO_PORTS_e control_pin; */ - /* IO_PORTS_e feedback_pin; */ - uint32_t control_pin; - uint32_t feedback_pin; - ILCK_FEEDBACK_TYPE_e feedback_pin_type; -} ILCK_CONFIG_s; - /*========== Extern Constant and Variable Declarations ======================*/ -/** configuration of the interlock */ -extern ILCK_CONFIG_s ilck_interlock_config; -/** electrical state of the interlock */ -extern ILCK_ELECTRICAL_STATE_s ilck_interlock_state; /*========== Extern Function Prototypes =====================================*/ diff --git a/src/app/driver/config/pex_cfg.c b/src/app/driver/config/pex_cfg.c new file mode 100644 index 00000000..56ee1c18 --- /dev/null +++ b/src/app/driver/config/pex_cfg.c @@ -0,0 +1,84 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file pex_cfg.c + * @author foxBMS Team + * @date 2021-08-02 (date of creation) + * @updated 2021-09-30 (date of last update) + * @ingroup DRIVERS_CONFIGURATION + * @prefix PEX + * + * @brief Configuration for the NXP PCA9539 port expander module + * + * + * + */ + +/*========== Includes =======================================================*/ +#include "pex_cfg.h" + +/*========== Macros and Definitions =========================================*/ +/** I2C address of port expander 1 */ +#define PEX_PORT_EXPANDER1_I2C_ADDRESS (0x74u) +/** I2C address of port expander 2 */ +#define PEX_PORT_EXPANDER2_I2C_ADDRESS (0x75u) +/** I2C address of port expander 3 */ +#define PEX_PORT_EXPANDER3_I2C_ADDRESS (0x76u) + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/** I2C addresses of the port expanders */ +const uint8_t pex_addressList[PEX_NR_OF_PORT_EXPANDERS] = { + PEX_PORT_EXPANDER1_I2C_ADDRESS, + PEX_PORT_EXPANDER2_I2C_ADDRESS, + PEX_PORT_EXPANDER3_I2C_ADDRESS, +}; + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/config/pex_cfg.h b/src/app/driver/config/pex_cfg.h new file mode 100644 index 00000000..dd45e321 --- /dev/null +++ b/src/app/driver/config/pex_cfg.h @@ -0,0 +1,107 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file pex_cfg.h + * @author foxBMS Team + * @date 2021-08-02 (date of creation) + * @updated 2021-09-30 (date of last update) + * @ingroup DRIVERS_CONFIGURATION + * @prefix PEX + * + * @brief Headers for the configuration for the NXP PCA9539 port expander module + * + * + */ + +#ifndef FOXBMS__PEX_CFG_H_ +#define FOXBMS__PEX_CFG_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +#include "battery_system_cfg.h" + +#include "database.h" + +/*========== Macros and Definitions =========================================*/ + +/** Number of port expanders */ +#define PEX_NR_OF_PORT_EXPANDERS (3u) + +/** Defines to match expander numbering from hardware description */ +/**@{*/ +/* AXIVION Disable Style MisraC2012-2.5: Values are defined even if unused for driver useage. */ +#define PEX_PORT_EXPANDER1 (0u) +#define PEX_PORT_EXPANDER2 (1u) +#define PEX_PORT_EXPANDER3 (2u) +/**@}*/ + +/** Port expander pin positions in registers */ +/**@{*/ +#define PEX_PIN00 (0u) +#define PEX_PIN01 (1u) +#define PEX_PIN02 (2u) +#define PEX_PIN03 (3u) +#define PEX_PIN04 (4u) +#define PEX_PIN05 (5u) +#define PEX_PIN06 (6u) +#define PEX_PIN07 (7u) +#define PEX_PIN10 (8u) +#define PEX_PIN11 (9u) +#define PEX_PIN12 (10u) +#define PEX_PIN13 (11u) +#define PEX_PIN14 (12u) +#define PEX_PIN15 (13u) +#define PEX_PIN16 (14u) +#define PEX_PIN17 (15u) +/* AXIVION Enable Style MisraC2012-2.5: */ +/**@}*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +extern const uint8_t pex_addressList[PEX_NR_OF_PORT_EXPANDERS]; + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__PEX_CFG_H_ */ diff --git a/src/app/driver/config/spi_cfg.c b/src/app/driver/config/spi_cfg.c index a6159dc4..e6fa8f7f 100644 --- a/src/app/driver/config/spi_cfg.c +++ b/src/app/driver/config/spi_cfg.c @@ -43,7 +43,7 @@ * @file spi_cfg.c * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2021-06-16 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup DRIVERS_CONFIGURATION * @prefix SPI * @@ -60,6 +60,27 @@ /*========== Static Constant and Variable Definitions =======================*/ +/** @defgroup spi_data_format SPI data configuration structs + * + * These data configuration structs are used below in the + * #SPI_INTERFACE_CONFIG_s structures. Each data configuration structs refers + * to a format selection (e.g. SPI_FMT_0). These are defined in the HAL for + * each SPI channel (1-5). In order to limit potential confusion the data + * formats on SPI1 and SPI4 (the SPI interfaces that are routed to the + * interface board that contains the AFE) have to be configured the same. + * This way, the developer can switch between SPI1 and SPI4 without having to + * change the SPI data format. + * + * AFE | SPI data format + * ------- | --------------- + * LTC | SPI_FMT_0 + * MXM | SPI_FMT_1 + * NXP | SPI_FMT_2 + * unused | SPI_FMT_3 + * + * @{ + */ + /** SPI data configuration struct for LTC communication */ static const spiDAT1_t spi_kLtcDataConfig = { /* struct is implemented in the TI HAL and uses uppercase true and false */ @@ -69,6 +90,69 @@ static const spiDAT1_t spi_kLtcDataConfig = { .CSNR = 0x0, /* Chip select (CS) number, 0x01h for CS[0] */ }; +/** SPI data configuration struct for MXM communication */ +static const spiDAT1_t spi_kMxmDataConfig = { + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_1, /*!< Data word format select: Data format 1 (SPI1) */ + .CSNR = 0x00, /*!< Chip select (CS) number, 0x01h for CS[0] */ +}; + +/** SPI data configuration struct for NXP MC33775A communication */ +static const spiDAT1_t spi_kNxp775DataConfig = { + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_2, /*!< Data word format select */ + .CSNR = 0x0, /*!< Chip select (CS) number, 0x01h for CS[0] */ +}; + +/** SPI data configuration struct for FRAM communication */ +static const spiDAT1_t spi_kFramDataConfig = { + /* struct is implemented in the TI HAL and uses uppercase true and false */ + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_1, /*!< Data word format select: data format 1 (SPI3) */ + .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ +}; + +/** SPI data configuration struct for SPS communication in low speed (4MHz) */ +static const spiDAT1_t spi_kSpsDataConfigLowSpeed = { + /* struct is implemented in the TI HAL and uses uppercase true and false */ + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_1, /*!< Data word format select: data format 1 (SPI2) */ + .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ +}; + +/** SPI data configuration struct for SPS communication in high speed (10MHz) */ +static const spiDAT1_t spi_kSpsDataConfigHighSpeed = { + /* struct is implemented in the TI HAL and uses uppercase true and false */ + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_2, /*!< Data word format select: data format 1 (SPI2) */ + .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ +}; + +/** SPI data configuration struct for ADC communication */ +static const spiDAT1_t spi_kAdcDataConfig = { + /* struct is implemented in the TI HAL and uses uppercase true and false */ + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_2, /*!< Data word format select: data format 2 (SPI3) */ + .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ +}; + +/** SPI configuration struct for SBC communication */ +static const spiDAT1_t spi_kSbcDataConfig = { + /* struct is implemented in the TI HAL and uses uppercase true and false */ + .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ + .WDEL = TRUE, /*!< No delay will be inserted */ + .DFSEL = SPI_FMT_0, /*!< Data word format select */ + .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ +}; + +/**@}*/ + /*========== Extern Constant and Variable Definitions =======================*/ /** * SPI interface configuration for LTC communication @@ -98,14 +182,6 @@ SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS] = { }, }; -/** SPI data configuration struct for MXM communication */ -static const spiDAT1_t spi_kMxmDataConfig = { - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_1, /*!< Data word format select: Data format 1 (SPI1) */ - .CSNR = 0x00, /*!< Chip select (CS) number, 0x01h for CS[0] */ -}; - /** SPI interface configuration for MXM communication */ SPI_INTERFACE_CONFIG_s spi_MxmInterface = { .channel = SPI_Interface4, @@ -115,14 +191,6 @@ SPI_INTERFACE_CONFIG_s spi_MxmInterface = { .csPin = 0u, }; -/** SPI data configuration struct for NXP MC33775A communication */ -const spiDAT1_t spi_kNxp775DataConfig = { - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_0, /*!< Data word format select */ - .CSNR = 0x0, /*!< Chip select (CS) number, 0x01h for CS[0] */ -}; - /** SPI interface configuration for N775 communication */ SPI_INTERFACE_CONFIG_s spi_nxp775Interface = { .channel = SPI_Interface1, @@ -132,15 +200,6 @@ SPI_INTERFACE_CONFIG_s spi_nxp775Interface = { .csPin = 2u, }; -/** SPI data configuration struct for FRAM communication */ -static const spiDAT1_t spi_kFramDataConfig = { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_1, /*!< Data word format select: data format 1 (SPI3) */ - .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ -}; - /** SPI interface configuration for FRAM communication */ SPI_INTERFACE_CONFIG_s spi_framInterface = { .channel = SPI_Interface3, @@ -150,24 +209,6 @@ SPI_INTERFACE_CONFIG_s spi_framInterface = { .csPin = 0u, }; -/** SPI data configuration struct for SPS communication in low speed (4MHz) */ -static const spiDAT1_t spi_kSpsDataConfigLowSpeed = { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_1, /*!< Data word format select: data format 1 (SPI2) */ - .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ -}; - -/** SPI data configuration struct for SPS communication in high speed (10MHz) */ -static const spiDAT1_t spi_kSpsDataConfigHighSpeed = { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_2, /*!< Data word format select: data format 1 (SPI2) */ - .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ -}; - /** SPI interface configuration for SPS communication */ SPI_INTERFACE_CONFIG_s spi_spsInterface = { .channel = SPI_Interface2, @@ -177,15 +218,6 @@ SPI_INTERFACE_CONFIG_s spi_spsInterface = { .csPin = SPS_SPI_CS_PIN, }; -/** SPI data configuration struct for ADC communication */ -static const spiDAT1_t spi_kAdcDataConfig = { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_2, /*!< Data word format select: data format 2 (SPI3) */ - .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ -}; - /** SPI interface configuration for ADC communication */ SPI_INTERFACE_CONFIG_s spi_adc0Interface = { .channel = SPI_Interface3, @@ -204,15 +236,6 @@ SPI_INTERFACE_CONFIG_s spi_adc1Interface = { .csPin = 5u, }; -/** SPI configuration struct for SBC communication */ -static const spiDAT1_t spi_kSbcDataConfig = { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = FALSE, /*!< The HW chip select signal is deactivated */ - .WDEL = TRUE, /*!< No delay will be inserted */ - .DFSEL = SPI_FMT_0, /*!< Data word format select */ - .CSNR = 0x0, /*!< Chip select (CS) number; 0x01h for CS[0] */ -}; - /** SPI interface configuration for SBC communication */ SPI_INTERFACE_CONFIG_s spi_kSbcMcuInterface = { .channel = SPI_Interface2, diff --git a/src/app/driver/config/spi_cfg.h b/src/app/driver/config/spi_cfg.h index cc0fd106..ff2dd7fe 100644 --- a/src/app/driver/config/spi_cfg.h +++ b/src/app/driver/config/spi_cfg.h @@ -43,7 +43,7 @@ * @file spi_cfg.h * @author foxBMS Team * @date 2020-03-05 (date of creation) - * @updated 2020-03-05 (date of last update) + * @updated 2020-09-30 (date of last update) * @ingroup DRIVERS_CONFIGURATION * @prefix SPI * @@ -113,8 +113,6 @@ typedef struct SPI_INTERFACE_CONFIG { } SPI_INTERFACE_CONFIG_s; /*========== Extern Constant and Variable Declarations ======================*/ -extern const spiDAT1_t spi_kNxp775DataConfig; - extern SPI_INTERFACE_CONFIG_s spi_ltcInterface[BS_NR_OF_STRINGS]; extern SPI_INTERFACE_CONFIG_s spi_MxmInterface; extern SPI_INTERFACE_CONFIG_s spi_nxp775Interface; diff --git a/src/app/driver/config/sps_cfg.c b/src/app/driver/config/sps_cfg.c index 60bbbeda..6c8a6fe1 100644 --- a/src/app/driver/config/sps_cfg.c +++ b/src/app/driver/config/sps_cfg.c @@ -43,7 +43,7 @@ * @file sps_cfg.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2021-10-01 (date of last update) * @ingroup DRIVERS_CONF * @prefix SPS * @@ -54,6 +54,8 @@ /*========== Includes =======================================================*/ #include "sps_cfg.h" +#include "pex_cfg.h" + /*========== Macros and Definitions =========================================*/ /*========== Static Constant and Variable Definitions =======================*/ @@ -69,10 +71,23 @@ SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS] = { {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_CONTACTOR, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_CONTACTOR, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, +}; + +/** mapping of channel states to feedback pins + * + * * IDs are the same as in #sps_channelStatus (#SPS_CHANNEL_INDEX) + * * The mapping is intended to be constant; if a feedback channel shall be + * used, this should also be configured in #sps_channelStatus +*/ +const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS] = { + {PEX_PORT_EXPANDER1, PEX_PIN00}, + {PEX_PORT_EXPANDER1, PEX_PIN01}, + {PEX_PORT_EXPANDER1, PEX_PIN02}, + {PEX_PORT_EXPANDER1, PEX_PIN03}, + {PEX_PORT_EXPANDER1, PEX_PIN04}, + {PEX_PORT_EXPANDER1, PEX_PIN05}, + {PEX_PORT_EXPANDER1, PEX_PIN06}, + {PEX_PORT_EXPANDER1, PEX_PIN07}, }; /*========== Static Function Prototypes =====================================*/ diff --git a/src/app/driver/config/sps_cfg.h b/src/app/driver/config/sps_cfg.h index bc1ffc85..c5234d0f 100644 --- a/src/app/driver/config/sps_cfg.h +++ b/src/app/driver/config/sps_cfg.h @@ -43,7 +43,7 @@ * @file sps_cfg.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2021-10-01 (date of last update) * @ingroup DRIVERS_CONF * @prefix SPS * @@ -64,16 +64,22 @@ /*========== Macros and Definitions =========================================*/ /** GIO defines for pin to drive reset line of SPS @{ */ -#define SPS_RESET_GIOPORT (hetREG2->DOUT) -#define SPS_RESET_GIOPORT_DIR (hetREG2->DIR) -#define SPS_RESET_PIN (16u) +#define SPS_RESET_GIO_PORT (hetREG2->DOUT) +#define SPS_RESET_GIO_PORT_DIR (hetREG2->DIR) +#define SPS_RESET_PIN (16u) +/**@}*/ + +/** GIO defines for pin to drive feedback enable MOSFET of SPS @{ */ +#define SPS_FEEDBACK_GIO_PORT (hetREG2->DOUT) +#define SPS_FEEDBACK_GIO_PORT_DIR (hetREG2->DIR) +#define SPS_FEEDBACK_PIN (9u) /**@}*/ /** Each SPS IC has four outputs */ #define SPS_NR_CONTACTOR_PER_IC (4u) /** Number of SPS IC that are populated on the hardware (in daisy-chain) */ -#define SPS_NR_OF_IC (3u) +#define SPS_NR_OF_IC (2u) /** One channel for each contactor is required in this application */ #define SPS_NR_OF_REQUIRED_CONTACTOR_CHANNELS (BS_NR_OF_CONTACTORS) @@ -178,6 +184,12 @@ typedef struct SPS_CHANNEL_STATE { const float thresholdFeedbackOn_mA; /*!< current threshold in mA above which the channel is considered "on" */ } SPS_CHANNEL_STATE_s; +/** SPS channel mapping to feedback pin */ +typedef struct SPS_CHANNEL_FEEDBACK_MAPPING { + const uint8_t pexDevice; /*!< port expander number */ + const uint8_t pexChannel; /*!< pin number on the addresses port expander */ +} SPS_CHANNEL_FEEDBACK_MAPPING_s; + /*================== Main precharge configuration ====================*/ /*========== Extern Constant and Variable Declarations ======================*/ @@ -209,6 +221,8 @@ typedef enum SPS_ACTION { extern SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]; +extern const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS]; + /*========== Extern Function Prototypes =====================================*/ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ diff --git a/src/app/driver/contactor/contactor.c b/src/app/driver/contactor/contactor.c index e72affef..efdb4d19 100644 --- a/src/app/driver/contactor/contactor.c +++ b/src/app/driver/contactor/contactor.c @@ -43,7 +43,7 @@ * @file contactor.c * @author foxBMS Team * @date 2020-02-11 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-10-01 (date of last update) * @ingroup DRIVERS * @prefix CONT * @@ -173,9 +173,14 @@ extern void CONT_GetContactorFeedback(void) { } else if (CONT_FEEDBACK_THROUGH_CURRENT == cont_contactorStates[contactor].feedbackPinType) { /* feedback from current: ask SPS driver for feedback */ cont_contactorStates[contactor].feedback = - SPS_GetChannelFeedback(CONT_GetSpsChannelIndexFromContactor(contactor)); + SPS_GetChannelCurrentFeedback(CONT_GetSpsChannelIndexFromContactor(contactor)); + } else if (CONT_FEEDBACK_NORMALLY_OPEN == cont_contactorStates[contactor].feedbackPinType) { + cont_contactorStates[contactor].feedback = + SPS_GetChannelPexFeedback(CONT_GetSpsChannelIndexFromContactor(contactor), true); } else { - /* TODO: get feedback through I2C port expander */ + /* CONT_FEEDBACK_NORMALLY_CLOSED */ + cont_contactorStates[contactor].feedback = + SPS_GetChannelPexFeedback(CONT_GetSpsChannelIndexFromContactor(contactor), false); } } } @@ -235,6 +240,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"); /* Precharge contactors in the list stay after string contactors * so it has index (number of contactors)-1 diff --git a/src/app/driver/dma/dma.c b/src/app/driver/dma/dma.c index fceadc02..d6c04500 100644 --- a/src/app/driver/dma/dma.c +++ b/src/app/driver/dma/dma.c @@ -43,7 +43,7 @@ * @file dma.c * @author foxBMS Team * @date 2019-12-12 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2021-09-28 (date of last update) * @ingroup DRIVERS * @prefix DMA * @@ -54,8 +54,9 @@ /*========== Includes =======================================================*/ #include "dma.h" +#include "afe_dma.h" +#include "i2c.h" #include "io.h" -#include "mic_dma.h" #include "spi.h" /*========== Macros and Definitions =========================================*/ @@ -71,8 +72,8 @@ /*========== Extern Function Implementations ================================*/ void DMA_Initialize(void) { - /* - configuring dma control packets */ - g_dmaCTRL dma_controlPacketTx = { + /* DMA control packets configuration for SPI */ + g_dmaCTRL dma_controlPacketSpiTx = { .SADD = (uint32_t)NULL_PTR, /* source address */ .DADD = (uint32_t)NULL_PTR, /* destination address */ .CHCTRL = 0U, /* channel chain control */ @@ -91,7 +92,7 @@ void DMA_Initialize(void) { .AUTOINIT = AUTOINIT_OFF /* autoinit */ }; - g_dmaCTRL dma_controlPacketRx = { + g_dmaCTRL dma_controlPacketSpiRx = { .SADD = (uint32_t)NULL_PTR, /* source address */ .DADD = (uint32_t)NULL_PTR, /* destination address */ .CHCTRL = 0U, /* channel chain control */ @@ -110,8 +111,49 @@ void DMA_Initialize(void) { .AUTOINIT = AUTOINIT_OFF /* autoinit */ }; + /* DMA control packets configuration for I2C1 */ + g_dmaCTRL dma_controlPacketI2cTx = { + .SADD = (uint32_t)NULL_PTR, /* source address */ + .DADD = (uint32_t)NULL_PTR, /* destination address */ + .CHCTRL = 0U, /* channel chain control */ + .FRCNT = 0U, /* frame count */ + .ELCNT = 1U, /* element count */ + .ELDOFFSET = 0U, /* element destination offset */ + .ELSOFFSET = 0U, /* element destination offset */ + .FRDOFFSET = 0U, /* frame destination offset */ + .FRSOFFSET = 0U, /* frame destination offset */ + .PORTASGN = PORTA_READ_PORTB_WRITE, /* port assignment */ + .RDSIZE = ACCESS_8_BIT, /* read size */ + .WRSIZE = ACCESS_8_BIT, /* write size */ + .TTYPE = FRAME_TRANSFER, /* transfer type */ + .ADDMODERD = ADDR_INC1, /* address mode read */ + .ADDMODEWR = ADDR_FIXED, /* address mode write */ + .AUTOINIT = AUTOINIT_OFF /* autoinit */ + }; + + g_dmaCTRL dma_controlPacketI2cRx = { + .SADD = (uint32_t)NULL_PTR, /* source address */ + .DADD = (uint32_t)NULL_PTR, /* destination address */ + .CHCTRL = 0U, /* channel chain control */ + .FRCNT = 0U, /* frame count */ + .ELCNT = 1U, /* element count */ + .ELDOFFSET = 0U, /* element destination offset */ + .ELSOFFSET = 0U, /* element destination offset */ + .FRDOFFSET = 0U, /* frame destination offset */ + .FRSOFFSET = 0U, /* frame destination offset */ + .PORTASGN = PORTB_READ_PORTA_WRITE, /* port assignment */ + .RDSIZE = ACCESS_8_BIT, /* read size */ + .WRSIZE = ACCESS_8_BIT, /* write size */ + .TTYPE = FRAME_TRANSFER, /* transfer type */ + .ADDMODERD = ADDR_FIXED, /* address mode read */ + .ADDMODEWR = ADDR_INC1, /* address mode write */ + .AUTOINIT = AUTOINIT_OFF /* autoinit */ + }; + dmaEnable(); + /* Configuration for SPI */ + for (uint8_t i = 0u; i < DMA_NUMBER_SPI_INTERFACES; i++) { /* assign dma request to Tx channel */ dmaReqAssign((dmaChannel_t)dma_spiDmaChannels[i].txChannel, (dmaRequest_t)dma_spiDmaRequests[i].txRequest); @@ -125,48 +167,110 @@ void DMA_Initialize(void) { dmaEnableInterrupt( (dmaChannel_t)(dmaChannel_t)dma_spiDmaChannels[i].rxChannel, (dmaInterrupt_t)BTC, (dmaIntGroup_t)DMA_INTA); - dma_controlPacketTx.DADD = (uint32_t)(&(dma_spiInterfaces[i]->DAT1)) + DMA_BIG_ENDIAN_ADDRESS_16BIT; - dma_controlPacketRx.SADD = (uint32_t)(&(dma_spiInterfaces[i]->BUF)) + DMA_BIG_ENDIAN_ADDRESS_16BIT; + dma_controlPacketSpiTx.DADD = (uint32_t)(&(dma_spiInterfaces[i]->DAT1)) + DMA_BIG_ENDIAN_ADDRESS_16BIT; + dma_controlPacketSpiRx.SADD = (uint32_t)(&(dma_spiInterfaces[i]->BUF)) + DMA_BIG_ENDIAN_ADDRESS_16BIT; /* Set dma control packet for Tx */ - dmaSetCtrlPacket((dmaChannel_t)dma_spiDmaChannels[i].txChannel, dma_controlPacketTx); + dmaSetCtrlPacket((dmaChannel_t)dma_spiDmaChannels[i].txChannel, dma_controlPacketSpiTx); /* Set dma control packet for Rx */ - dmaSetCtrlPacket((dmaChannel_t)dma_spiDmaChannels[i].rxChannel, dma_controlPacketRx); + dmaSetCtrlPacket((dmaChannel_t)dma_spiDmaChannels[i].rxChannel, dma_controlPacketSpiRx); /* Set the dma channels to trigger on h/w request */ dmaSetChEnable((dmaChannel_t)dma_spiDmaChannels[i].txChannel, (dmaTriggerType_t)DMA_HW); dmaSetChEnable((dmaChannel_t)dma_spiDmaChannels[i].rxChannel, (dmaTriggerType_t)DMA_HW); } + + /* Configuration for I2C1 */ + + /* assign dma request to Tx channel */ + dmaReqAssign((dmaChannel_t)DMA_CHANNEL_I2C_TX, (dmaRequest_t)DMA_REQ_LINE_I2C_TX); + /* assign dma request to Rx channel */ + dmaReqAssign((dmaChannel_t)DMA_CHANNEL_I2C_RX, (dmaRequest_t)DMA_REQ_LINE_I2C_RX); + + /* Enable Interrupt after reception of data + Group A - Interrupts (FTC, LFS, HBC, and BTC) are routed to the ARM CPU + User software should configure only Group A interrupts */ + dmaEnableInterrupt((dmaChannel_t)(dmaChannel_t)DMA_CHANNEL_I2C_TX, (dmaInterrupt_t)BTC, (dmaIntGroup_t)DMA_INTA); + dmaEnableInterrupt((dmaChannel_t)(dmaChannel_t)DMA_CHANNEL_I2C_RX, (dmaInterrupt_t)BTC, (dmaIntGroup_t)DMA_INTA); + + dma_controlPacketI2cTx.DADD = (uint32_t)(&(i2cREG1->DXR)) + DMA_BIG_ENDIAN_ADDRESS_8BIT; + dma_controlPacketI2cRx.SADD = (uint32_t)(&(i2cREG1->DRR)) + DMA_BIG_ENDIAN_ADDRESS_8BIT; + + /* Set dma control packet for Tx */ + dmaSetCtrlPacket((dmaChannel_t)DMA_CHANNEL_I2C_TX, dma_controlPacketI2cTx); + + /* Set dma control packet for Rx */ + dmaSetCtrlPacket((dmaChannel_t)DMA_CHANNEL_I2C_RX, dma_controlPacketI2cRx); + + /* Set the dma channels to trigger on h/w request */ + dmaSetChEnable((dmaChannel_t)DMA_CHANNEL_I2C_TX, (dmaTriggerType_t)DMA_HW); + dmaSetChEnable((dmaChannel_t)DMA_CHANNEL_I2C_RX, (dmaTriggerType_t)DMA_HW); } /** Function called on DMA complete interrupts (TX and RX). Defined as weak in HAL. */ void UNIT_TEST_WEAK_IMPL dmaGroupANotification(dmaInterrupt_t inttype, uint32 channel) { if (inttype == (dmaInterrupt_t)BTC) { - /* Search for SPI index with DAM Rx channel */ uint8_t spiIndex = 0U; - for (uint8_t i = 0u; i < DMA_NUMBER_SPI_INTERFACES; i++) { - if ((uint32_t)dma_spiDmaChannels[i].rxChannel == channel) { - spiIndex = i; - break; - } - } + uint16_t timeout = I2C_TIMEOUT; + switch (channel) { + case DMA_CHANNEL_SPI1_TX: + case DMA_CHANNEL_SPI1_RX: + case DMA_CHANNEL_SPI2_TX: + case DMA_CHANNEL_SPI2_RX: + case DMA_CHANNEL_SPI3_TX: + case DMA_CHANNEL_SPI3_RX: + case DMA_CHANNEL_SPI4_TX: + case DMA_CHANNEL_SPI4_RX: + case DMA_CHANNEL_SPI5_TX: + case DMA_CHANNEL_SPI5_RX: + /* Search for SPI index with DAM Rx channel */ + for (uint8_t i = 0u; i < DMA_NUMBER_SPI_INTERFACES; i++) { + if ((uint32_t)dma_spiDmaChannels[i].rxChannel == channel) { + spiIndex = i; + break; + } + } - /* Software deactivate CS */ - IO_PinSet(spi_dmaTransmission[spiIndex].pGioPort, spi_dmaTransmission[spiIndex].csPin); + /* Software deactivate CS */ + IO_PinSet(spi_dmaTransmission[spiIndex].pGioPort, spi_dmaTransmission[spiIndex].csPin); - /* Disable DMA_REQ_Enable */ - spi_dmaTransmission[spiIndex].pNode->INT0 &= ~DMAREQEN_BIT; - if (spi_dmaTransmission[spiIndex].channel < spi_nrBusyFlags) { - *(spi_busyFlags + spi_dmaTransmission[spiIndex].channel) = SPI_IDLE; - } + /* Disable DMA_REQ_Enable */ + spi_dmaTransmission[spiIndex].pNode->INT0 &= ~DMAREQEN_BIT; + if (spi_dmaTransmission[spiIndex].channel < spi_nrBusyFlags) { + *(spi_busyFlags + spi_dmaTransmission[spiIndex].channel) = SPI_IDLE; + } - /* DMA seems to only be able to use FMT0, restore saved FMT0 values */ - spi_dmaTransmission[spiIndex].pNode->FMT0 = spi_saveFmt0[spiIndex]; + /* DMA seems to only be able to use FMT0, restore saved FMT0 values */ + spi_dmaTransmission[spiIndex].pNode->FMT0 = spi_saveFmt0[spiIndex]; - /* Specific calls for measurement ICs */ - if (spiIndex == 0U) { - MIC_DmaCallback(inttype, channel); + /* Specific calls for AFEs */ + if (spiIndex == 0U) { + AFE_DmaCallback(inttype, channel); + } + break; + case DMA_CHANNEL_I2C_TX: + i2cREG1->DMACR &= ~(uint32)0x2u; + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0) && (timeout > 0u)) { + timeout--; + } + /* Clear the Stop condition */ + i2cClearSCD(i2cREG1); + break; + case DMA_CHANNEL_I2C_RX: + i2cREG1->DMACR &= ~(uint32)0x1u; + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0) && (timeout > 0u)) { + timeout--; + } + /* Clear the Stop condition */ + i2cClearSCD(i2cREG1); + break; + default: + break; } } } diff --git a/src/app/driver/htsensor/htsensor.c b/src/app/driver/htsensor/htsensor.c new file mode 100644 index 00000000..28712e5d --- /dev/null +++ b/src/app/driver/htsensor/htsensor.c @@ -0,0 +1,292 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file htsensor.c + * @author foxBMS Team + * @date 2021-08-05 (date of creation) + * @updated 2021-09-30 (date of last update) + * @ingroup DRIVERS + * @prefix HTSEN + * + * @brief Driver for the Sensirion SHT35-DIS I2C humidity/temperature sensor + * + */ + +/*========== Includes =======================================================*/ +#include "htsensor.h" + +#include "database.h" +#include "i2c.h" + +/*========== Macros and Definitions =========================================*/ + +/** Sensor I2C address */ +#define HTSEN_I2C_ADDRESS (0x44u) + +/** Timeout to avoid infinite loops when waiting for results */ +#define HTSEN_READ_TIMEOUT_10ms (10u) + +/** Timeout to wait for measurement in 10ms */ +#define HTSEN_TIME_MEAS_WAIT_10ms (2u) + +/** Conversion coefficients to get measurement from raw temperature value @{ */ +#define HTSEN_TEMP_SCALING (175.0f) +#define HTSEN_TEMP_OFFSET (-45.0f) +#define HTSEN_TEMP_DEG_TO_DDEG (10.0f) +/**@}*/ + +/** Conversion coefficients to get measurement from raw humidity value @{ */ +#define HTSEN_HUMIDITY_SCALING (100.0f) +#define HTSEN_FULL_SCALE (65535.0f) +/**@}*/ + +/** Defines for byte positions for data handling @{ */ +#define HTSEN_TEMPERATURE_LSB (1u) +#define HTSEN_TEMPERATURE_MSB (0u) +#define HTSEN_TEMPERATURE_BYTE_CRC (2u) +#define HTSEN_HUMIDITY_LSB (4u) +#define HTSEN_HUMIDITY_MSB (3u) +#define HTSEN_HUMIDITY_BYTE_CRC (5u) +#define HTSEN_BYTE_SHIFT (8u) +#define HTSEN_MEASUREMENT_LENGTH_IN_BYTES (2u) +#define HTSEN_TOTAL_DATA_LENGTH_IN_BYTES (6u) +/**@}*/ + +/** Defines for sensor CRC computation @{ */ +#define HTSEN_CRC_POLYNOMIAL (0x31u) +#define HTSEN_CRC_SEED (0xFF) +#define HTSEN_CRC_BYTE_SHIFT (0x8u) +#define HTSEN_CRC_MSB_MASK (0x80u) +#define HTSEN_CRC_8BIT_MASK (0xFFu) +/**@}*/ + +/** + * Definition of single measurement command + * Datasheet February 2019 - Version 6, table 9, page 10 + * + * Clock stretching can be used to let sensor tell that the measurement + * is not finished by pulling the clock low + * Not recommended: if system is stopped during clock stretching, + * sensor could be blocked in this mode and render I2C bus unusable. + * !!!---WARNING---!!!: if clock stretching is used, the timeout in the + * receive loop of the function #I2C_ReadDirect() must be adapted, + * the current value is too small compared to the time the slave will + * make the master wait in the clock stretching mode. + * + * Depending on the clock stretching setting, the code for the instructions + * changes: + * -> With stretching + * - 1 MSB + * - 1 LSB for high repeatability + * - 1 LSB for medium repeatability + * - 1 LSB for low repeatability + * -> Without stretching + * - 1 MSB + * - 1 LSB for high repeatability + * - 1 LSB for medium repeatability + * - 1 LSB for low repeatability + * This results in 6 possible configurations + * Durability changes the measurement duration. + * @{ + */ +#define HTSEN_CLOCK_STRETCHING (false) +#if (HTSEN_CLOCK_STRETCHING == false) +#define HTSEN_SINGLE_MEAS_MSB (0x24u) +#define HTSEN_HIGH_REPEATABILITY (0x00u) +#define HTSEN_MEDIUM_REPEATABILITY (0x0Bu) +#define HTSEN_LOW_REPEATABILITY (0x16u) +#else +#define HTSEN_SINGLE_MEAS_MSB (0x2Cu) +#define HTSEN_HIGH_REPEATABILITY (0x06u) +#define HTSEN_MEDIUM_REPEATABILITY (0x0Du) +#define HTSEN_LOW_REPEATABILITY (0x10u) +#endif + +#define HTSEN_SINGLE_MEAS_LSB (HTSEN_HIGH_REPEATABILITY) +/**@}*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/** + * @brief describes the current state of the measurement + * @details This variable is used as a state-variable for switching through the + * steps of a conversion. + */ +static HTSEN_STATE_e htsen_state = HTSEN_START_MEAS; +/** counter to wait before reading measurements after they were triggered */ +static uint8_t htsen_counter = 0u; +/** timeout to restart measurement cycle if waiting too much to get results */ +static uint8_t htsen_timeout_10ms = 0u; + +/** variable to store the measurement results */ +static DATA_BLOCK_HTSEN_s htsen_data = {.header.uniqueId = DATA_BLOCK_ID_HTSEN}; + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/** + * @brief computes CRC8. + * @param[in] data: data to use to compute CRC + * @param[in] length: length of data + * @return 8-bit CRC value + */ +static uint8_t HTSENS_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); + +/** + * @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 Function Implementations ================================*/ + +static uint8_t HTSENS_CalculateCrc8(const uint8_t *data, uint32_t length) { + FAS_ASSERT(data != NULL_PTR); + FAS_ASSERT(length <= UINT32_MAX); + + uint16_t crc = HTSEN_CRC_SEED; + + for (uint8_t i = 0u; i < length; i++) { + crc ^= data[i]; + for (uint8_t j = 0u; j < HTSEN_CRC_BYTE_SHIFT; j++) { + if ((crc & HTSEN_CRC_MSB_MASK) != 0u) { + crc = ((crc << 1u) & HTSEN_CRC_8BIT_MASK) ^ HTSEN_CRC_POLYNOMIAL; + } else { + crc = (crc & HTSEN_CRC_8BIT_MASK) << 1u; + } + } + } + return (uint8_t)(crc & HTSEN_CRC_8BIT_MASK); +} + +static int16_t HTSENS_ConvertRawTemperature(uint16_t data) { + 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) { + float humidity_perc = (HTSEN_HUMIDITY_SCALING * (((float)data) / HTSEN_FULL_SCALE)); + return (uint8_t)humidity_perc; +} + +/*========== Extern Function Implementations ================================*/ + +extern void HTSEN_Trigger(void) { + uint8_t i2cWriteBuffer[2u] = {HTSEN_SINGLE_MEAS_MSB, HTSEN_SINGLE_MEAS_LSB}; + uint8_t i2cReadBuffer[HTSEN_TOTAL_DATA_LENGTH_IN_BYTES] = {0u, 0u, 0u, 0u, 0u, 0u}; + STD_RETURN_TYPE_e i2cReadReturn = STD_NOT_OK; + + switch (htsen_state) { + case HTSEN_START_MEAS: + /* Write to sensor to start measurement */ + if (STD_OK == I2C_WriteDirect(HTSEN_I2C_ADDRESS, 2u, i2cWriteBuffer)) { + htsen_counter = HTSEN_TIME_MEAS_WAIT_10ms; + htsen_timeout_10ms = HTSEN_READ_TIMEOUT_10ms; + htsen_state = HTSEN_WAIT_FOR_RESULTS; + } + break; + + case HTSEN_WAIT_FOR_RESULTS: + if (htsen_counter > 0u) { + htsen_counter--; + } + if (htsen_counter == 0u) { + htsen_state = HTSEN_READ_RESULTS; + break; + } + break; + + case HTSEN_READ_RESULTS: + i2cReadReturn = I2C_ReadDirect(HTSEN_I2C_ADDRESS, HTSEN_TOTAL_DATA_LENGTH_IN_BYTES, i2cReadBuffer); + if (i2cReadReturn != STD_OK) { + if (htsen_timeout_10ms > 0u) { + htsen_timeout_10ms--; + } + if (htsen_timeout_10ms == 0u) { + htsen_state = HTSEN_START_MEAS; + } + } else { + /* 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( + (((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( + (((uint16_t)i2cReadBuffer[HTSEN_HUMIDITY_MSB]) << HTSEN_BYTE_SHIFT) | + (uint16_t)i2cReadBuffer[HTSEN_HUMIDITY_LSB]); + } + DATA_WRITE_DATA(&htsen_data); + htsen_state = HTSEN_START_MEAS; + } + break; + + default: + /* invalid state */ + FAS_ASSERT(FAS_TRAP); + break; + } +} + +/*========== Getter for static Variables (Unit Test) ========================*/ + +/*========== 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); +} +#endif /* UNITY_UNIT_TEST */ diff --git a/src/app/driver/htsensor/htsensor.h b/src/app/driver/htsensor/htsensor.h new file mode 100644 index 00000000..fd2d6a57 --- /dev/null +++ b/src/app/driver/htsensor/htsensor.h @@ -0,0 +1,87 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file htsensor.h + * @author foxBMS Team + * @date 2021-08-05 (date of creation) + * @updated 2021-09-30 (date of last update) + * @ingroup DRIVERS + * @prefix HTSEN + * + * @brief Header for the driver for the Sensirion SHT35-DIS I2C humidity/temperature sensor + * + */ + +#ifndef FOXBMS__HTSENSOR_H_ +#define FOXBMS__HTSENSOR_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +/*========== Macros and Definitions =========================================*/ + +/** + * States for the sensor readout + */ +typedef enum { + HTSEN_START_MEAS, + HTSEN_WAIT_FOR_RESULTS, + HTSEN_READ_RESULTS, +} HTSEN_STATE_e; + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/** + * @brief triggers a measurement of the I2C humidity/temperature sensor. + * @details This function steps through the state-machine that handles + * the measurement with the I2C sensor. + */ +extern void HTSEN_Trigger(void); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ +#ifdef UNITY_UNIT_TEST +extern uint8_t TEST_HTSEN_TestCalculateCrc8(uint8_t *data, uint32_t length); +#endif + +#endif /* FOXBMS__HTSENSOR_H_ */ diff --git a/src/app/driver/i2c/i2c.c b/src/app/driver/i2c/i2c.c new file mode 100644 index 00000000..8712358d --- /dev/null +++ b/src/app/driver/i2c/i2c.c @@ -0,0 +1,588 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file i2c.c + * @author foxBMS Team + * @date 2021-07-22 (date of creation) + * @updated 2021-09-29 (date of last update) + * @ingroup DRIVERS + * @prefix I2C + * + * @brief Driver for the I2C module + * + */ + +/*========== Includes =======================================================*/ +#include "i2c.h" + +#include "database.h" +#include "diag.h" +#include "dma.h" +#include "fsystem.h" +#include "mcu.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ +extern void I2C_Initialize(void) { + i2cInit(); +} + +extern STD_RETURN_TYPE_e I2C_Read(uint32_t slaveAddress, uint8_t readAddress, uint32_t nrBytes, uint8_t *readData) { + FAS_ASSERT(readData != NULL_PTR); + + STD_RETURN_TYPE_e retVal = STD_OK; + uint16_t timeout = I2C_TIMEOUT; + bool nack = false; + uint8_t *data = readData; + uint32_t count = nrBytes; + + if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { + /* Clear bits */ + i2cREG1->MDR &= ~((uint32_t)I2C_STOP_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_START_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_REPEATMODE); + i2cREG1->STR |= (uint32_t)I2C_TX_INT; + i2cREG1->STR |= (uint32_t)I2C_RX_INT; + + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_TRANSMITTER); /* Set as transmitter */ + i2cSetSlaveAdd(i2cREG1, slaveAddress); /* Set slave address */ + i2cSetCount(i2cREG1, 1u); /* Send 1 byte */ + i2cSetStart(i2cREG1); /* Start write */ + i2cREG1->DXR = (uint32_t)readAddress; /* Send register address */ + + /* Wait until Tx buffer was copied to shift buffer */ + timeout = I2C_TIMEOUT; + while (((i2cREG1->STR & (uint32_t)I2C_TX_INT) == 0u) && (timeout > 0u)) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + nack = true; + break; + } + timeout--; + } + + if (timeout == 0u) { + /* Set repeat flag */ + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; + /* Set Stop condition */ + i2cSetStop(i2cREG1); + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + retVal = STD_NOT_OK; + } else { + /* If slave ACK received, receive data */ + if ((i2cREG1->STR & (uint32_t)I2C_NACK) == 0u) { + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_RECEIVER); /* Set as transmitter */ + i2cSetCount(i2cREG1, nrBytes); /* Send count bytes before STOP condition */ + i2cSetStart(i2cREG1); /* Start write */ + i2cSetStop(i2cREG1); /* Stop condition after sending nrBytes bytes */ + + /* Receive nrBytes bytes in polling mode */ + while (count > 0u) { + timeout = I2C_TIMEOUT; + while (((i2cREG1->STR & (uint32_t)I2C_RX_INT) == 0u) && (timeout > 0u)) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK_INT) != 0u) { + nack = true; + break; + } + timeout--; + } + if ((nack == true) || (timeout == 0u)) { + break; + } + *data = ((uint8)i2cREG1->DRR); + data++; + count--; + } + if ((nack == true) || (timeout == 0u)) { + /* Set repeat flag */ + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; + /* Set Stop condition */ + i2cSetStop(i2cREG1); + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + retVal = STD_NOT_OK; + } else { + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + if (timeout == 0u) { + retVal = STD_NOT_OK; + } else { + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ + } + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + + return retVal; +} + +extern STD_RETURN_TYPE_e I2C_ReadDirect(uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData) { + FAS_ASSERT(readData != NULL_PTR); + + STD_RETURN_TYPE_e retVal = STD_OK; + uint16_t timeout = I2C_TIMEOUT; + bool nack = false; + uint8_t *data = readData; + uint32_t count = nrBytes; + + if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { + /* Clear bits */ + i2cREG1->MDR &= ~((uint32_t)I2C_STOP_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_START_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_REPEATMODE); + i2cREG1->STR |= (uint32_t)I2C_TX_INT; + i2cREG1->STR |= (uint32_t)I2C_RX_INT; + i2cREG1->STR |= (uint32_t)I2C_TX_INT; + i2cREG1->STR |= (uint32_t)I2C_RX_INT; + + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_RECEIVER); /* Set as transmitter */ + i2cSetSlaveAdd(i2cREG1, slaveAddress); /* Set slave address */ + i2cSetCount(i2cREG1, nrBytes); /* Send count bytes before STOP condition */ + i2cSetStart(i2cREG1); /* Start write */ + i2cSetStop(i2cREG1); /* Stop condition after sending nrBytes bytes */ + + /* Receive nrBytes bytes in polling mode */ + while (count > 0u) { + timeout = I2C_TIMEOUT; + while (((i2cREG1->STR & (uint32_t)I2C_RX_INT) == 0u) && (timeout > 0u)) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK_INT) != 0u) { + nack = true; + break; + } + timeout--; + } + if ((nack == true) || (timeout == 0u)) { + break; + } + *data = ((uint8)i2cREG1->DRR); + data++; + count--; + } + if ((nack == true) || (timeout == 0u)) { + /* Set repeat flag */ + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; + /* Set Stop condition */ + i2cSetStop(i2cREG1); + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + retVal = STD_NOT_OK; + } else { + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + if (timeout == 0u) { + retVal = STD_NOT_OK; + } else { + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ + } + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + + return retVal; +} + +extern STD_RETURN_TYPE_e I2C_Write(uint32_t slaveAddress, uint8_t writeAddress, uint32_t nrBytes, uint8_t *writeData) { + FAS_ASSERT(writeData != NULL_PTR); + + STD_RETURN_TYPE_e retVal = STD_OK; + uint16_t timeout = I2C_TIMEOUT; + bool nack = false; + uint8_t *data = writeData; + uint32_t count = nrBytes; + + if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { + /* Clear bits */ + i2cREG1->MDR &= ~((uint32_t)I2C_STOP_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_START_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_REPEATMODE); + i2cREG1->STR |= (uint32_t)I2C_TX_INT; + i2cREG1->STR |= (uint32_t)I2C_RX_INT; + + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_TRANSMITTER); /* Set as transmitter */ + i2cSetSlaveAdd(i2cREG1, slaveAddress); /* Set slave address */ + i2cSetStop(i2cREG1); /* Stop condition after sending nrBytes bytes */ + i2cSetCount(i2cREG1, nrBytes + 1u); /* Send count bytes before STOP condition */ + i2cSetStart(i2cREG1); /* Start write */ + + /* Send register address */ + i2cREG1->DXR = (uint32_t)writeAddress; + /* Wait until Tx buffer was copied to shift buffer */ + timeout = I2C_TIMEOUT; + while (((i2cREG1->STR & (uint32_t)I2C_TX_INT) == 0u) && (timeout > 0u)) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + nack = true; + break; + } + timeout--; + } + + if (timeout == 0u) { + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; /* Set repeat flag */ + i2cSetStop(i2cREG1); /* Set Stop condition */ + + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + retVal = STD_NOT_OK; + } else { + /* If slave ACK received, send data */ + if ((i2cREG1->STR & (uint32_t)I2C_NACK) == 0u) { + /* Send nrBytes bytes in polling mode */ + while (count > 0u) { + /* Wait until Tx buffer was copied to shift buffer */ + timeout = I2C_TIMEOUT; + while (((i2cREG1->STR & (uint32_t)I2C_TX_INT) == 0u) && (timeout > 0u)) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + nack = true; + break; + } + timeout--; + } + if ((nack == true) || (timeout == 0u)) { + break; + } + i2cREG1->DXR = (uint32_t)*data; + data++; + count--; + } + if ((nack == true) || (timeout == 0u)) { + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; /* Set repeat flag */ + i2cSetStop(i2cREG1); /* Set Stop condition */ + + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + retVal = STD_NOT_OK; + } else { + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + if (timeout == 0u) { + retVal = STD_NOT_OK; + } else { + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ + } + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + + return retVal; +} + +extern STD_RETURN_TYPE_e I2C_WriteDirect(uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData) { + FAS_ASSERT(writeData != NULL_PTR); + + STD_RETURN_TYPE_e retVal = STD_OK; + uint16_t timeout = I2C_TIMEOUT; + bool nack = false; + uint8_t *data = writeData; + uint32_t count = nrBytes; + + if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { + /* Clear bits */ + i2cREG1->MDR &= ~((uint32_t)I2C_STOP_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_START_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_REPEATMODE); + i2cREG1->STR |= (uint32_t)I2C_TX_INT; + i2cREG1->STR |= (uint32_t)I2C_RX_INT; + + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_TRANSMITTER); /* Set as transmitter */ + i2cSetSlaveAdd(i2cREG1, slaveAddress); /* Set slave address */ + i2cSetStop(i2cREG1); /* Stop condition after sending nrBytes bytes */ + i2cSetCount(i2cREG1, nrBytes); /* Send count bytes before STOP condition */ + i2cSetStart(i2cREG1); /* Start write */ + + /* If slave ACK received, send data */ + if ((i2cREG1->STR & (uint32_t)I2C_NACK) == 0u) { + /* Send nrBytes bytes in polling mode */ + while (count > 0u) { + /* Wait until Tx buffer was copied to shift buffer */ + timeout = I2C_TIMEOUT; + while (((i2cREG1->STR & (uint32_t)I2C_TX_INT) == 0u) && (timeout > 0u)) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + nack = true; + break; + } + timeout--; + } + if ((nack == true) || (timeout == 0u)) { + break; + } + i2cREG1->DXR = (uint32_t)*data; + data++; + count--; + } + if ((nack == true) || (timeout == 0u)) { + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; /* Set repeat flag */ + i2cSetStop(i2cREG1); /* Set Stop condition */ + + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + retVal = STD_NOT_OK; + } else { + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + if (timeout == 0u) { + retVal = STD_NOT_OK; + } else { + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ + } + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + } else { + I2C_SetStopNow(); + retVal = STD_NOT_OK; + } + + return retVal; +} + +extern STD_RETURN_TYPE_e I2C_ReadDma(uint32_t slaveAddress, uint8_t readAddress, uint32_t nrBytes, uint8_t *readData) { + FAS_ASSERT(readData != NULL_PTR); + + STD_RETURN_TYPE_e retVal = STD_OK; + uint16_t timeout = I2C_TIMEOUT; + + if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { + OS_EnterTaskCritical(); + + FAS_ASSERT(FSYS_RaisePrivilege() == 0); /* Go to privileged mode to write DMA config registers */ + + /* Set Tx buffer address */ + /* AXIVION Disable Style MisraC2012-1.1: Cast necessary for DMA configuration */ + dmaRAMREG->PCP[(dmaChannel_t)DMA_CHANNEL_I2C_RX].IDADDR = (uint32_t)readData; + /* AXIVION Enable Style MisraC2012-1.1: */ + /* Set number of Tx bytes to transmit */ + dmaRAMREG->PCP[(dmaChannel_t)DMA_CHANNEL_I2C_RX].ITCOUNT = (nrBytes << 16U) | 1U; + + dmaSetChEnable((dmaChannel_t)DMA_CHANNEL_I2C_RX, (dmaTriggerType_t)DMA_HW); + + FSYS_SwitchToUserMode(); /* DMA config registers written, leave privileged mode */ + OS_ExitTaskCritical(); + + i2cREG1->DMACR |= (uint32_t)I2C_RXDMAEN; /* Activate I2C DMA RX */ + + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set to master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_TRANSMITTER); /* Set as transmitter */ + i2cSetSlaveAdd(i2cREG1, slaveAddress); /* Set slave address */ + i2cSetCount(i2cREG1, 1u); /* Write one byte to select register address */ + i2cSetStart(i2cREG1); /* Start write */ + i2cSendByte(i2cREG1, readAddress); /* Transmit register address */ + + /* Wait until Tx buffer was copied to shift buffer */ + while ((i2cREG1->STR & (uint32_t)I2C_TX_INT) == 0u) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + break; + } + } + + if ((i2cREG1->STR & (uint32_t)I2C_NACK) == 0u) { + i2cSetDirection(i2cREG1, (uint32_t)I2C_RECEIVER); /* Set as receiver */ + i2cSetCount(i2cREG1, nrBytes); /* Receive nrBytes before STOP condition */ + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetStop(i2cREG1); /* Stop condition after receiving nrBytes bytes */ + i2cSetStart(i2cREG1); /* Set start while bus busy for REPEATED START condition */ + } else { + i2cREG1->STR |= (uint32_t)I2C_NACK; /* Clear NACK flag */ + i2cREG1->STR |= (uint32_t)I2C_TX_INT; /* Set Tx ready flag */ + i2cSetStop(i2cREG1); /* Set Stop condition */ + + /* Wait until Stop is detected */ + timeout = I2C_TIMEOUT; + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ + retVal = STD_NOT_OK; + } + } else { + retVal = STD_NOT_OK; + } + + return retVal; +} + +extern STD_RETURN_TYPE_e I2C_WriteDma( + uint32_t slaveAddress, + uint8_t writeAddress, + uint32_t nrBytes, + uint8_t *writeData) { + FAS_ASSERT(writeData != NULL_PTR); + + STD_RETURN_TYPE_e retVal = STD_OK; + uint16_t timeout = I2C_TIMEOUT; + + if ((i2cREG1->STR & (uint32_t)I2C_BUSBUSY) == 0u) { + OS_EnterTaskCritical(); + + FAS_ASSERT(FSYS_RaisePrivilege() == 0); /* Go to privileged mode to write DMA config registers */ + + /* Set Tx buffer address */ + /* AXIVION Disable Style MisraC2012-1.1: Cast necessary for DMA configuration */ + dmaRAMREG->PCP[(dmaChannel_t)DMA_CHANNEL_I2C_TX].ISADDR = (uint32_t)writeData; + /* AXIVION Enable Style MisraC2012-1.1: */ + /* Set number of Tx bytes to transmit */ + dmaRAMREG->PCP[(dmaChannel_t)DMA_CHANNEL_I2C_TX].ITCOUNT = (nrBytes << 16U) | 1U; + + dmaSetChEnable((dmaChannel_t)DMA_CHANNEL_I2C_TX, (dmaTriggerType_t)DMA_HW); + + FSYS_SwitchToUserMode(); /* DMA config registers written, leave privileged mode */ + OS_ExitTaskCritical(); + + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_TRANSMITTER); /* Set as transmitter */ + i2cSetSlaveAdd(i2cREG1, slaveAddress); /* Set slave address */ + i2cSetStop(i2cREG1); /* Stop condition after sending nrBytes bytes */ + i2cSetCount(i2cREG1, nrBytes + 1u); /* Send (nrBytes+1) before STOP condition (includes register address)*/ + i2cSendByte(i2cREG1, writeAddress); /* Send register address */ + i2cREG1->DMACR |= (uint32_t)I2C_TXDMAEN; /* Activate I2C DMA TX */ + i2cSetStart(i2cREG1); /* Start write */ + + /* Wait until Tx buffer was copied to shift buffer */ + while ((i2cREG1->STR & (uint32_t)I2C_TX_INT) == 0u) { + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + break; + } + } + + if ((i2cREG1->STR & (uint32_t)I2C_NACK) != 0u) { + i2cREG1->STR |= (uint32_t)I2C_NACK; /* Clear NACK flag */ + i2cREG1->STR |= (uint32_t)I2C_TX_INT; /* Set Tx ready flag */ + i2cSetStop(i2cREG1); /* Set Stop condition */ + timeout = I2C_TIMEOUT; /* Wait until Stop is detected */ + + while ((i2cIsStopDetected(i2cREG1) == 0u) && (timeout > 0u)) { + timeout--; + } + + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ + i2cREG1->STR &= ~(uint32_t)I2C_REPEATMODE; + retVal = STD_NOT_OK; + } + } else { + retVal = STD_NOT_OK; + } + + return retVal; +} + +extern void I2C_SetStopNow(void) { + /* Clear bits */ + i2cREG1->MDR &= ~((uint32_t)I2C_STOP_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_START_COND); + i2cREG1->MDR &= ~((uint32_t)I2C_REPEATMODE); + i2cREG1->STR |= (uint32_t)I2C_TX_INT; + i2cREG1->STR |= (uint32_t)I2C_RX_INT; + + i2cREG1->MDR |= (uint32_t)I2C_REPEATMODE; /* Set repeat flag */ + i2cSetMode(i2cREG1, (uint32_t)I2C_MASTER); /* Set as master */ + i2cSetDirection(i2cREG1, (uint32_t)I2C_TRANSMITTER); /* Set as transmitter */ + i2cSetStop(i2cREG1); /* Set Stop condition */ + + while (i2cIsStopDetected(i2cREG1) == 0u) { + } + + i2cREG1->MDR &= ~(uint32_t)I2C_REPEATMODE; /* Reset repeat flag */ + i2cClearSCD(i2cREG1); /* Clear the Stop condition */ +} + +/*========== Getter for static Variables (Unit Test) ========================*/ +#ifdef UNITY_UNIT_TEST + +#endif + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/i2c/i2c.h b/src/app/driver/i2c/i2c.h new file mode 100644 index 00000000..f04cb79c --- /dev/null +++ b/src/app/driver/i2c/i2c.h @@ -0,0 +1,172 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file i2c.h + * @author foxBMS Team + * @date 2021-07-22 (date of creation) + * @updated 2021-09-28 (date of last update) + * @ingroup DRIVERS + * @prefix I2C + * + * @brief Header for the driver for the I2C module + * + */ + +#ifndef FOXBMS__I2C_H_ +#define FOXBMS__I2C_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +#include "HL_i2c.h" + +/*========== Macros and Definitions =========================================*/ + +/** Timeout to avoid infinite loops when waiting for flags */ +#define I2C_TIMEOUT (1000u) + +/** Transmitter DMA enable */ +#define I2C_TXDMAEN (0x2u) +/** Receiver DMA enable */ +#define I2C_RXDMAEN (0x1u) + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ +/** Initialize the I2C hardware + * + * This function has to be called before any call to the rest of this API + */ +extern void I2C_Initialize(void); + +/** + * @brief reads from an I2C slave, blocking. + * + * @param slaveAddress: address of slave to communicate with + * @param readAddress: address of first register to read from + * @param nrBytes: number of registers to read + * @param readData: buffer containing the read data + * + * @return retVal: STD_OK if transmission OK, STD_NOT_OK otherwise + * + */ +extern STD_RETURN_TYPE_e I2C_Read(uint32_t slaveAddress, uint8_t readAddress, uint32_t nrBytes, uint8_t *readData); + +/** + * @brief reads from an I2C slave, no register address written first, blocking. + * + * @param slaveAddress: address of slave to communicate with + * @param nrBytes: number of registers to read + * @param readData: buffer containing the read data + * + * @return retVal: STD_OK if transmission OK, STD_NOT_OK otherwise + * + */ +extern STD_RETURN_TYPE_e I2C_ReadDirect(uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData); + +/** + * @brief writes to an I2C slave, blocking. + * + * @param slaveAddress: address of slave to communicate with + * @param writeAddress: address of first register to write to + * @param nrBytes: number of registers to write + * @param writeData: buffer containing the data to write + * + * @return retVal: STD_OK if transmission OK, STD_NOT_OK otherwise + * + */ +extern STD_RETURN_TYPE_e I2C_Write(uint32_t slaveAddress, uint8_t writeAddress, uint32_t nrBytes, uint8_t *writeData); + +/** + * @brief writes to an I2C slave, no register address written first, blocking. + * + * @param slaveAddress: address of slave to communicate with + * @param nrBytes: number of registers to write + * @param writeData: buffer containing the data to write + * + * @return retVal: STD_OK if transmission OK, STD_NOT_OK otherwise + * + */ +extern STD_RETURN_TYPE_e I2C_WriteDirect(uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData); + +/** + * @brief reads from an I2C slave, using DMA. + * + * @param slaveAddress: address of slave to communicate with + * @param readAddress: address of first register to read from + * @param nrBytes: number of registers to read + * @param readData: buffer containing the read data + * + * @return retVal: STD_OK if transmission OK, STD_NOT_OK otherwise + * + */ +extern STD_RETURN_TYPE_e I2C_ReadDma(uint32_t slaveAddress, uint8_t readAddress, uint32_t nrBytes, uint8_t *readData); + +/** + * @brief writes to an I2C slave, using DMA. + * + * @param slaveAddress: address of slave to communicate with + * @param writeAddress: address of first register to write to + * @param nrBytes: number of registers to write + * @param writeData: buffer containing the data to write + * + * @return retVal: STD_OK if transmission OK, STD_NOT_OK otherwise + * + */ +extern STD_RETURN_TYPE_e I2C_WriteDma( + uint32_t slaveAddress, + uint8_t writeAddress, + uint32_t nrBytes, + uint8_t *writeData); + +/** + * @brief sets stop condition. + * + */ +extern void I2C_SetStopNow(void); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ +#ifdef UNITY_UNIT_TEST + +#endif + +#endif /* FOXBMS__I2C_H_ */ diff --git a/src/app/driver/imd/bender/ir155/bender_ir155.c b/src/app/driver/imd/bender/ir155/bender_ir155.c new file mode 100644 index 00000000..bab223a3 --- /dev/null +++ b/src/app/driver/imd/bender/ir155/bender_ir155.c @@ -0,0 +1,88 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file bender_ir155.c + * @author foxBMS Team + * @date 2014-02-11 (date of creation) + * @updated 2021-09-08 (date of last update) + * @ingroup DRIVERS + * @prefix IR155 + * + * @brief Driver for the insulation monitoring + */ + +/*========== Includes =======================================================*/ +#include "bender_ir155.h" + +#include "database.h" + +/*========== 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 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); + +/*========== 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; +} + +/*========== Extern Function Implementations ================================*/ +extern void IMD_Trigger(void) { + IR155_MeasureInsulation(); +} + +/*========== 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 new file mode 100644 index 00000000..6b36d0f7 --- /dev/null +++ b/src/app/driver/imd/bender/ir155/bender_ir155.h @@ -0,0 +1,69 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file bender_ir155.h + * @author foxBMS Team + * @date 2021-09-06 (date of creation) + * @updated 2021-09-08 (date of last update) + * @ingroup DRIVERS + * @prefix IR155 + * + * @brief Headers for the Bender IR155 driver for the insulation monitoring + */ + +#ifndef FOXBMS__BENDER_IR155_H_ +#define FOXBMS__BENDER_IR155_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +#include "imd.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__BENDER_IR155_H_ */ diff --git a/src/app/driver/imd/bender/ir155/wscript b/src/app/driver/imd/bender/ir155/wscript new file mode 100644 index 00000000..740143ca --- /dev/null +++ b/src/app/driver/imd/bender/ir155/wscript @@ -0,0 +1,70 @@ +#!/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®" + +"""Helper Build Script: ``./src/app/driver/imd/bender/ir155/wscript`` +================================================================= +""" + +import os + + +def build(bld): + """Builds the Bender IR155 monitoring device""" + includes = [ + ".", + os.path.join("..", ".."), + os.path.join("..", "..", "..", "can"), + os.path.join("..", "..", "..", "config"), + os.path.join("..", "..", "..", "..", "application", "config"), + 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"), + os.path.join("..", "..", "..", "..", "task", "ftask"), + ] + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM) + bld( + features="c", + source="bender_ir155.c", + includes=includes, + target=f"{bld.env.APPNAME}-imd", + ) diff --git a/src/app/driver/imd/bender/iso165c/bender_iso165c.c b/src/app/driver/imd/bender/iso165c/bender_iso165c.c index a6174686..2eb5b799 100644 --- a/src/app/driver/imd/bender/iso165c/bender_iso165c.c +++ b/src/app/driver/imd/bender/iso165c/bender_iso165c.c @@ -43,7 +43,7 @@ * @file bender_iso165c.c * @author foxBMS Team * @date 2019-04-07 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2021-10-12 (date of last update) * @ingroup DRIVERS * @prefix I165C * @@ -65,6 +65,7 @@ /*========== Macros and Definitions =========================================*/ #define RESISTANCE_THRESHOLD (50000u) +#define I165C_CAN_NODE (CAN1_NODE) /*========== Static Constant and Variable Definitions =======================*/ @@ -181,6 +182,14 @@ static void I165C_CheckAcknowledgeArrived( uint8_t *tries, 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. + */ +static void I165C_Trigger(void); + /*========== Static Function Implementations ================================*/ static void I165C_ResetCanData(CAN_BUFFERELEMENT_s *canMessage) { @@ -367,13 +376,7 @@ static void I165C_CheckAcknowledgeArrived( } } -/*========== Extern Function Implementations ================================*/ - -extern void IMD_Trigger(void) { - I165C_Trigger(); -} - -extern void I165C_Trigger(void) { +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; @@ -391,7 +394,7 @@ extern void I165C_Trigger(void) { 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(CAN0_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); i165c_receptionTries = 0u; i165cState = I165C_STATE_SELFTEST_WAIT_ACK; break; @@ -428,7 +431,7 @@ extern void I165C_Trigger(void) { 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(CAN0_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); i165c_receptionTries = 0u; i165cState = I165C_STATE_READ_RESISTANCE_WAIT_ACK; break; @@ -447,7 +450,7 @@ extern void I165C_Trigger(void) { 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(CAN0_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); i165c_receptionTries = 0u; i165cState = I165C_STATE_UNLOCK_WAIT_ACK; break; @@ -463,7 +466,7 @@ extern void I165C_Trigger(void) { 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(CAN0_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); i165c_receptionTries = 0u; i165cState = I165C_STATE_SET_ERROR_THRESHOLD_WAIT_ACK; break; @@ -480,7 +483,7 @@ extern void I165C_Trigger(void) { 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(CAN0_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); + CAN_DataSend(I165C_CAN_NODE, i165c_canTxMessage.id, i165c_canTxMessage.data); i165c_receptionTries = 0u; i165cState = I165C_STATE_SET_WARNING_THRESHOLD_WAIT_ACK; break; @@ -558,6 +561,12 @@ extern void I165C_Trigger(void) { } } +/*========== Extern Function Implementations ================================*/ + +extern void IMD_Trigger(void) { + I165C_Trigger(); +} + /*========== Externalized Static Function Implementations (Unit Test) =======*/ #ifdef UNITY_UNIT_TEST extern void TEST_I165C_ResetCanData(CAN_BUFFERELEMENT_s *canMessage) { diff --git a/src/app/driver/imd/bender/iso165c/bender_iso165c.h b/src/app/driver/imd/bender/iso165c/bender_iso165c.h index b97ef2f4..0bea8b0a 100644 --- a/src/app/driver/imd/bender/iso165c/bender_iso165c.h +++ b/src/app/driver/imd/bender/iso165c/bender_iso165c.h @@ -43,7 +43,7 @@ * @file bender_iso165c.h * @author foxBMS Team * @date 2019-04-07 (date of creation) - * @updated 2021-01-19 (date of last update) + * @updated 2021-09-08 (date of last update) * @ingroup DRIVERS * @prefix I165C * @@ -91,14 +91,6 @@ typedef enum I165C_STATE { /*========== Extern Function Prototypes =====================================*/ -/** - * @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. - */ -extern void I165C_Trigger(void); - /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST extern void TEST_I165C_ResetCanData(CAN_BUFFERELEMENT_s *canMessage); diff --git a/src/app/driver/imd/none/no-imd.c b/src/app/driver/imd/none/no-imd.c index ebaa3727..a60aafb1 100644 --- a/src/app/driver/imd/none/no-imd.c +++ b/src/app/driver/imd/none/no-imd.c @@ -43,9 +43,9 @@ * @file no-imd.c * @author foxBMS Team * @date 2020-11-20 (date of creation) - * @updated 2020-11-20 (date of last update) + * @updated 2021-09-08 (date of last update) * @ingroup DRIVERS - * @prefix NONE + * @prefix NOIMD * * @brief Driver for the dummy insulation monitoring driver * @@ -61,35 +61,35 @@ /*========== Static Constant and Variable Definitions =======================*/ /** internal handle for the database table of the insulation monitoring driver */ -static DATA_BLOCK_INSULATION_MONITORING_s iso_insulationMeasurement = { +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 IMD_MeasureInsulation(void); +static STD_RETURN_TYPE_e NOIMD_MeasureInsulation(void); /*========== Static Function Implementations ================================*/ -static STD_RETURN_TYPE_e IMD_MeasureInsulation(void) { - iso_insulationMeasurement.valid = 0; - iso_insulationMeasurement.state = 0; - iso_insulationMeasurement.insulationResistance_kOhm = 10000000; - iso_insulationMeasurement.insulationFault = 0; - iso_insulationMeasurement.chassisFault = 0; - iso_insulationMeasurement.systemFailure = 0; - iso_insulationMeasurement.insulationWarning = 0; - DATA_WRITE_DATA(&iso_insulationMeasurement); +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; } /*========== Extern Function Implementations ================================*/ extern void IMD_Trigger(void) { - IMD_MeasureInsulation(); + NOIMD_MeasureInsulation(); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ #ifdef UNITY_UNIT_TEST -extern STD_RETURN_TYPE_e TEST_IMD_MeasureInsulation() { - return IMD_MeasureInsulation(); +extern STD_RETURN_TYPE_e TEST_NOIMD_MeasureInsulation() { + return NOIMD_MeasureInsulation(); } #endif diff --git a/src/app/driver/imd/none/no-imd.h b/src/app/driver/imd/none/no-imd.h index d8b1e340..8258e492 100644 --- a/src/app/driver/imd/none/no-imd.h +++ b/src/app/driver/imd/none/no-imd.h @@ -43,7 +43,7 @@ * @file no-imd.h * @author foxBMS Team * @date 2020-11-20 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2021-09-08 (date of last update) * @ingroup DRIVERS * @prefix NONE * @@ -68,7 +68,7 @@ /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST -extern STD_RETURN_TYPE_e TEST_IMD_MeasureInsulation(); +extern STD_RETURN_TYPE_e TEST_NOIMD_MeasureInsulation(); #endif #endif /* FOXBMS__NO_IMD_H_ */ diff --git a/src/app/driver/interlock/interlock.c b/src/app/driver/interlock/interlock.c index ce9368e7..89968f11 100644 --- a/src/app/driver/interlock/interlock.c +++ b/src/app/driver/interlock/interlock.c @@ -43,21 +43,35 @@ * @file interlock.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2021-10-18 (date of last update) * @ingroup DRIVERS * @prefix ILCK * * @brief Driver for the interlock. + * @details The interlock driver measures the relevant hardware signals from + * the interlock circuit. For details on available hardware signals + * please refer to the section on this module in the foxBMS + * documentation. + * + * In reference to the names in the foxBMS schematic, this module uses + * the following names: + * + * shorthand | meaning + * --------- | --------- + * IL | interlock + * HS | high-side + * LS | low-side + * VS | voltage sense + * CS | current sense * */ /*========== Includes =======================================================*/ #include "interlock.h" -#include "HL_gio.h" - #include "database.h" #include "diag.h" +#include "io.h" #include "os.h" /*========== Macros and Definitions =========================================*/ @@ -68,11 +82,6 @@ ilck_state.laststate = ilck_state.state; \ ilck_state.lastsubstate = ilck_state.substate -/** provides more clear name for #ILCK_SwitchInterlockOn() */ -#define ILCK_CLOSEINTERLOCK() ILCK_SwitchInterlockOn() -/** provides more clear name for #ILCK_SwitchInterlockOff() */ -#define ILCK_OPENINTERLOCK() ILCK_SwitchInterlockOff() - /*========== Static Constant and Variable Definitions =======================*/ /** * contains the state of the contactor state machine @@ -80,90 +89,83 @@ static ILCK_STATE_s ilck_state = { .timer = 0, .statereq = ILCK_STATE_NO_REQUEST, - .state = ILCK_STATEMACH_UNINITIALIZED, + .state = ILCK_STATEMACHINE_UNINITIALIZED, .substate = ILCK_ENTRY, - .laststate = ILCK_STATEMACH_UNINITIALIZED, + .laststate = ILCK_STATEMACHINE_UNINITIALIZED, .lastsubstate = ILCK_ENTRY, .triggerentry = 0, .ErrRequestCounter = 0, .counter = 0, }; +/** Local variable containing interlock feedback */ +static DATA_BLOCK_INTERLOCK_FEEDBACK_s ilck_tableFeedback = {.header.uniqueId = DATA_BLOCK_ID_INTERLOCK_FEEDBACK}; + /*========== Extern Constant and Variable Definitions =======================*/ /*========== Static Function Prototypes =====================================*/ +/** + * @brief checks the state requests that are made. + * @details This function checks the validity of the state requests. The + * results of the checked is returned immediately. + * @param statereq state request to be checked + * @return result of the state request that was made, taken from + * #ILCK_RETURN_TYPE_e + */ static ILCK_RETURN_TYPE_e ILCK_CheckStateRequest(ILCK_STATE_REQUEST_e statereq); -/* static ILCK_STATE_REQUEST_e ILCK_GetStateRequest(void); */ /* Kept for compatibility */ + +/** + * @brief transfers the current state request to the state machine. + * @details This function takes the current state request from ilck_state and + * transfers it to the state machine. It resets the value from + * ilck_state to ILCK_STATE_NO_REQUEST + * @return current state request, taken from ILCK_STATE_REQUEST_e + */ static ILCK_STATE_REQUEST_e ILCK_TransferStateRequest(void); + +/** + * @brief re-entrance check of ILCK state machine trigger function + * @details This function is not re-entrant and should only be called time- or + * event-triggered. It increments the triggerentry counter from the + * state variable ilck_state. It should never be called by two + * different processes, so if it is the case, triggerentry should + * never be higher than 0 when this function is called. + * @return 0 if no further instance of the function is active, 0xFF else + */ static uint8_t ILCK_CheckReEntrance(void); -static void ILCK_CheckFeedback(void); -static ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockSetValue(void); -static STD_RETURN_TYPE_e ILCK_SetInterlockState(ILCK_ELECTRICAL_STATE_TYPE_e requestedInterlockState); -static STD_RETURN_TYPE_e ILCK_SwitchInterlockOff(void); -static STD_RETURN_TYPE_e ILCK_SwitchInterlockOn(void); -static void ILCK_Init_Pins(void); -/*========== Static Function Implementations ================================*/ /** - * @brief checks the state requests that are made. - * - * This function checks the validity of the state requests. - * The results of the checked is returned immediately. - * - * @param statereq state request to be checked - * - * @return result of the state request that was made, taken from ILCK_RETURN_TYPE_e + * @brief Initializes required pins for interlock evaluation */ -static ILCK_RETURN_TYPE_e ILCK_CheckStateRequest(ILCK_STATE_REQUEST_e statereq) { - if (statereq == ILCK_STATE_ERROR_REQUEST) { - return ILCK_OK; - } +static void ILCK_InitializePins(void); - if (ilck_state.statereq == ILCK_STATE_NO_REQUEST) { +/** + * @brief Reads the feedback pin of the interlock and returns its current value + * (ILCK_SWITCH_OFF/ILCK_SWITCH_ON) + * @return measuredInterlockState (type: ILCK_ELECTRICAL_STATE_TYPE_e) + */ +static ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback(void); + +/*========== Static Function Implementations ================================*/ +static ILCK_RETURN_TYPE_e ILCK_CheckStateRequest(ILCK_STATE_REQUEST_e statereq) { + ILCK_RETURN_TYPE_e stateRequestCheck = ILCK_ILLEGAL_REQUEST; + if (!((statereq == ILCK_STATE_INITIALIZATION_REQUEST) || (statereq == ILCK_STATE_NO_REQUEST))) { + stateRequestCheck = ILCK_ILLEGAL_REQUEST; + } else if (ilck_state.statereq == ILCK_STATE_NO_REQUEST) { /* init only allowed from the uninitialized state */ - if (statereq == ILCK_STATE_INIT_REQUEST) { - if (ilck_state.state == ILCK_STATEMACH_UNINITIALIZED) { - return ILCK_OK; + if (statereq == ILCK_STATE_INITIALIZATION_REQUEST) { + if (ilck_state.state == ILCK_STATEMACHINE_UNINITIALIZED) { + stateRequestCheck = ILCK_OK; } else { - return ILCK_ALREADY_INITIALIZED; + stateRequestCheck = ILCK_ALREADY_INITIALIZED; } } - - if ((statereq == ILCK_STATE_OPEN_REQUEST) || (statereq == ILCK_STATE_CLOSE_REQUEST)) { - return ILCK_OK; - } else { - return ILCK_ILLEGAL_REQUEST; - } } else { - return ILCK_REQUEST_PENDING; + stateRequestCheck = ILCK_REQUEST_PENDING; } + return stateRequestCheck; } -/* TODO: check if code still necessary */ -/** - * @brief gets the current state request. - * @details This function is used in the functioning of the ILCK state machine. - * It is kept as comment for compatibility. - * @return retval current state request, taken from #ILCK_STATE_REQUEST_e - */ -/* static ILCK_STATE_REQUEST_e ILCK_GetStateRequest(void) { - ILCK_STATE_REQUEST_e retval = ILCK_STATE_NO_REQUEST; - - OS_EnterTaskCritical(); - retval = ilck_state.statereq; - OS_ExitTaskCritical(); - - return retval; -} */ - -/** - * @brief transfers the current state request to the state machine. - * - * This function takes the current state request from ilck_state and transfers it to the state machine. - * It resets the value from ilck_state to ILCK_STATE_NO_REQUEST - * - * @return retVal current state request, taken from ILCK_STATE_REQUEST_e - */ static ILCK_STATE_REQUEST_e ILCK_TransferStateRequest(void) { ILCK_STATE_REQUEST_e retval = ILCK_STATE_NO_REQUEST; @@ -175,16 +177,6 @@ static ILCK_STATE_REQUEST_e ILCK_TransferStateRequest(void) { return retval; } -/** - * @brief re-entrance check of ILCK state machine trigger function - * - * This function is not re-entrant and should only be called time- or event-triggered. - * It increments the triggerentry counter from the state variable ilck_state. - * It should never be called by two different processes, so if it is the case, triggerentry - * should never be higher than 0 when this function is called. - * - * @return retval 0 if no further instance of the function is active, 0xff else - */ static uint8_t ILCK_CheckReEntrance(void) { uint8_t retval = 0; @@ -199,117 +191,70 @@ static uint8_t ILCK_CheckReEntrance(void) { return retval; } -/** - * @brief checks interlock feedback - * @details This function is used to check interlock feedback. - */ -static void ILCK_CheckFeedback(void) { - STD_RETURN_TYPE_e result = STD_NOT_OK; - DATA_BLOCK_INTERLOCK_FEEDBACK_s ilckfeedback_tab = {.header.uniqueId = DATA_BLOCK_ID_INTERLOCK_FEEDBACK}; - - ILCK_ELECTRICAL_STATE_TYPE_e interlockFeedback = ILCK_GetInterlockFeedback(); - ilckfeedback_tab.interlockFeedback = interlockFeedback; - - DATA_WRITE_DATA(&ilckfeedback_tab); - - if (interlockFeedback == ILCK_GetInterlockSetValue()) { - result = STD_OK; - } - DIAG_CheckEvent(result, DIAG_ID_INTERLOCK_FEEDBACK, DIAG_SYSTEM, 0u); +static void ILCK_InitializePins(void) { + /* Configure diagnostic supply enable pin as output */ + IO_SetPinDirectionToOutput(&ILCK_IO_REG_DIR, ILCK_INTERLOCK_CONTROL_PIN_IL_HS_ENABLE); + /* Disable diagnostic power supply as component is currently NOT available */ + IO_PinReset(&ILCK_IO_REG_PORT->DOUT, ILCK_INTERLOCK_CONTROL_PIN_IL_HS_ENABLE); + /* Configure interlock feedback pin as input */ + IO_SetPinDirectionToInput(&ILCK_IO_REG_DIR, ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE); } -/** - * @brief Gets the latest value (#ILCK_SWITCH_ON, #ILCK_SWITCH_OFF) the interlock was set to. - * - * Meaning of the return value: - * - #ILCK_SWITCH_OFF means interlock was set to be opened - * - #ILCK_SWITCH_ON means interlock was set to be closed - * - * @return setInformation (type: #ILCK_ELECTRICAL_STATE_TYPE_e) - */ -static ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockSetValue() { - ILCK_ELECTRICAL_STATE_TYPE_e interlockSetInformation = ILCK_SWITCH_UNDEF; +static ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback(void) { + ILCK_ELECTRICAL_STATE_TYPE_e measuredInterlockState = ILCK_SWITCH_UNDEF; + uint8_t pinState = 0U; + OS_EnterTaskCritical(); - interlockSetInformation = ilck_interlock_state.set; + pinState = IO_PinGet(&ILCK_IO_REG_PORT->DIN, ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE); OS_ExitTaskCritical(); - return interlockSetInformation; -} -/** - * @brief Sets the interlock state to its requested state, if the interlock is at that time not in the requested state. - * It returns #STD_OK if the requested state was successfully set or if the interlock was at the requested state before. - * @param requestedInterlockState open or close interlock - * @return retVal #STD_OK if no error, #STD_NOT_OK otherwise - */ -static STD_RETURN_TYPE_e ILCK_SetInterlockState(ILCK_ELECTRICAL_STATE_TYPE_e requestedInterlockState) { - STD_RETURN_TYPE_e retVal = STD_OK; - - if (requestedInterlockState == ILCK_SWITCH_ON) { - ilck_interlock_state.set = ILCK_SWITCH_ON; - /* gioSetBit(ILCK_IO_REG, ilck_interlock_config.control_pin, 1); */ /* TODO: activate if pin wired correctly on HW */ - } else if (requestedInterlockState == ILCK_SWITCH_OFF) { - ilck_interlock_state.set = ILCK_SWITCH_OFF; - /* gioSetBit(ILCK_IO_REG, ilck_interlock_config.control_pin, 0); */ /* TODO: activate if pin wired correctly on HW */ - } else { - retVal = STD_NOT_OK; - } - - return retVal; -} + /** Local variable containing voltages measured on TMS570 ADC1 inputs */ + DATA_BLOCK_ADC_VOLTAGE_s ilck_tableAdcVoltages = {.header.uniqueId = DATA_BLOCK_ID_ADC_VOLTAGE}; + DATA_READ_DATA(&ilck_tableAdcVoltages); -/** - * @brief Switches the interlock off and returns #STD_NOT_OK on success. - * @return retVal (type: #STD_RETURN_TYPE_e) - */ -static STD_RETURN_TYPE_e ILCK_SwitchInterlockOff(void) { - STD_RETURN_TYPE_e retVal = STD_NOT_OK; - retVal = ILCK_SetInterlockState(ILCK_SWITCH_OFF); - return retVal; -} - -/** - * @brief Switches the interlock on and returns STD_OK on success. - * @return retVal (type: #STD_RETURN_TYPE_e) - */ -static STD_RETURN_TYPE_e ILCK_SwitchInterlockOn(void) { - STD_RETURN_TYPE_e retVal = STD_NOT_OK; - retVal = ILCK_SetInterlockState(ILCK_SWITCH_ON); - return retVal; -} - -/** initializes the pins of the interlock to default state */ -static void ILCK_Init_Pins(void) { - gioSetBit(ILCK_IO_REG, ILCK_INTERLOCK_CONTROL, 1u); - gioSetBit(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 0u); -} - -/*========== Extern Function Implementations ================================*/ -ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback(void) { - ILCK_ELECTRICAL_STATE_TYPE_e measuredInterlockState = ILCK_SWITCH_UNDEF; - uint8_t pinstate = 0U; - OS_EnterTaskCritical(); - pinstate = gioGetBit(ILCK_IO_REG, ilck_interlock_config.feedback_pin); - OS_ExitTaskCritical(); - if (pinstate == 1U) { - measuredInterlockState = ILCK_SWITCH_ON; - } else if (pinstate == 0U) { + /** Pin low: interlock closed, pin high: interlock open */ + if (pinState == 1u) { measuredInterlockState = ILCK_SWITCH_OFF; + } else if (pinState == 0u) { + measuredInterlockState = ILCK_SWITCH_ON; } - ilck_interlock_state.feedback = measuredInterlockState; + + ilck_tableFeedback.interlockVoltageFeedback_IL_HS_VS_mV = + ilck_tableAdcVoltages.adc1ConvertedVoltages_mV[ILCK_ADC_INPUT_HIGH_SIDE_VOLTAGE_SENSE] * + ILCK_VOLTAGE_DIVIDER_FACTOR; + ilck_tableFeedback.interlockVoltageFeedback_IL_LS_VS_mV = + ilck_tableAdcVoltages.adc1ConvertedVoltages_mV[ILCK_ADC_INPUT_LOW_SIDE_VOLTAGE_SENSE] * + ILCK_VOLTAGE_DIVIDER_FACTOR; + ilck_tableFeedback.interlockCurrentFeedback_IL_HS_CS_mA = + ilck_tableAdcVoltages.adc1ConvertedVoltages_mV[ILCK_ADC_INPUT_HIGH_SIDE_CURRENT_SENSE] * + ILCK_FACTOR_IL_HS_CS_1_ohm; + ilck_tableFeedback.interlockCurrentFeedback_IL_LS_CS_mA = + ilck_tableAdcVoltages.adc1ConvertedVoltages_mV[ILCK_ADC_INPUT_LOW_SIDE_CURRENT_SENSE] * + ILCK_FACTOR_IL_LS_CS_1_ohm; + + ilck_tableFeedback.interlockFeedback_IL_STATE = measuredInterlockState; + + DATA_WRITE_DATA(&ilck_tableFeedback); + +#if (BS_IGNORE_INTERLOCK_FEEDBACK == true) + measuredInterlockState = ILCK_SWITCH_ON; +#endif + return measuredInterlockState; } +/*========== Extern Function Implementations ================================*/ ILCK_STATEMACH_e ILCK_GetState(void) { return ilck_state.state; } ILCK_RETURN_TYPE_e ILCK_SetStateRequest(ILCK_STATE_REQUEST_e statereq) { - ILCK_RETURN_TYPE_e retVal = ILCK_OK; + ILCK_RETURN_TYPE_e retVal = ILCK_ILLEGAL_REQUEST; OS_EnterTaskCritical(); retVal = ILCK_CheckStateRequest(statereq); - if (retVal == ILCK_OK) { + if (retVal != ILCK_ILLEGAL_REQUEST) { ilck_state.statereq = statereq; } OS_ExitTaskCritical(); @@ -318,18 +263,14 @@ ILCK_RETURN_TYPE_e ILCK_SetStateRequest(ILCK_STATE_REQUEST_e statereq) { } void ILCK_Trigger(void) { - ILCK_STATE_REQUEST_e statereq = ILCK_STATE_NO_REQUEST; + ILCK_STATE_REQUEST_e statereq = ILCK_STATE_NO_REQUEST; + ILCK_ELECTRICAL_STATE_TYPE_e interlockState = ILCK_SWITCH_UNDEF; /* Check re-entrance of function */ if (ILCK_CheckReEntrance() > 0u) { return; } - /****Happens every time the state machine is triggered**************/ - if (ilck_state.state != ILCK_STATEMACH_UNINITIALIZED) { - ILCK_CheckFeedback(); - } - if (ilck_state.timer > 0u) { if ((--ilck_state.timer) > 0u) { ilck_state.triggerentry--; @@ -339,14 +280,14 @@ void ILCK_Trigger(void) { switch (ilck_state.state) { /****************************UNINITIALIZED***********************************/ - case ILCK_STATEMACH_UNINITIALIZED: + case ILCK_STATEMACHINE_UNINITIALIZED: /* waiting for Initialization Request */ statereq = ILCK_TransferStateRequest(); - if (statereq == ILCK_STATE_INIT_REQUEST) { + if (statereq == ILCK_STATE_INITIALIZATION_REQUEST) { ILCK_SAVELASTSTATES(); - ILCK_Init_Pins(); - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_INITIALIZATION; + ILCK_InitializePins(); + ilck_state.timer = ILCK_STATEMACH_SHORTTIME; + ilck_state.state = ILCK_STATEMACHINE_INITIALIZED; ilck_state.substate = ILCK_ENTRY; } else if (statereq == ILCK_STATE_NO_REQUEST) { /* no actual request pending */ @@ -355,66 +296,15 @@ void ILCK_Trigger(void) { } break; - /****************************INITIALIZATION**********************************/ - case ILCK_STATEMACH_INITIALIZATION: - ILCK_SAVELASTSTATES(); - ILCK_OPENINTERLOCK(); - - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_INITIALIZED; - ilck_state.substate = ILCK_ENTRY; - break; - - /****************************INITIALIZED*************************************/ - case ILCK_STATEMACH_INITIALIZED: - ILCK_SAVELASTSTATES(); - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_WAIT_FIRST_REQUEST; - ilck_state.substate = ILCK_ENTRY; - break; - /****************************INITIALIZED*************************************/ - case ILCK_STATEMACH_WAIT_FIRST_REQUEST: + case ILCK_STATEMACHINE_INITIALIZED: ILCK_SAVELASTSTATES(); - statereq = ILCK_TransferStateRequest(); - if (statereq == ILCK_STATE_OPEN_REQUEST) { - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_OPEN; - ilck_state.substate = ILCK_ENTRY; - } else if (statereq == ILCK_STATE_CLOSE_REQUEST) { - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_CLOSED; - ilck_state.substate = ILCK_ENTRY; + ilck_state.timer = ILCK_STATEMACH_SHORTTIME; + interlockState = ILCK_GetInterlockFeedback(); + if (interlockState == ILCK_SWITCH_ON) { + (void)DIAG_Handler(DIAG_ID_INTERLOCK_FEEDBACK, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); } else { - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - } - break; - - /****************************OPEN*************************************/ - case ILCK_STATEMACH_OPEN: - ILCK_SAVELASTSTATES(); - ILCK_OPENINTERLOCK(); - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - statereq = ILCK_TransferStateRequest(); - if (statereq == ILCK_STATE_CLOSE_REQUEST) { - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_CLOSED; - ilck_state.substate = ILCK_ENTRY; - break; - } - break; - - /****************************CLOSED*************************************/ - case ILCK_STATEMACH_CLOSED: - ILCK_SAVELASTSTATES(); - ILCK_CLOSEINTERLOCK(); - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - statereq = ILCK_TransferStateRequest(); - if (statereq == ILCK_STATE_OPEN_REQUEST) { - ilck_state.timer = ILCK_STATEMACH_SHORTTIME_MS; - ilck_state.state = ILCK_STATEMACH_OPEN; - ilck_state.substate = ILCK_ENTRY; - break; + (void)DIAG_Handler(DIAG_ID_INTERLOCK_FEEDBACK, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); } break; @@ -432,6 +322,9 @@ void ILCK_Trigger(void) { extern void TEST_ILCK_SetStateStruct(ILCK_STATE_s state) { ilck_state = state; } +extern ILCK_ELECTRICAL_STATE_TYPE_e TEST_ILCK_GetInterlockFeedback(void) { + return ILCK_GetInterlockFeedback(); +} #endif /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/interlock/interlock.h b/src/app/driver/interlock/interlock.h index bd7196e9..1080a384 100644 --- a/src/app/driver/interlock/interlock.h +++ b/src/app/driver/interlock/interlock.h @@ -43,7 +43,7 @@ * @file interlock.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2020-02-24 (date of last update) + * @updated 2021-10-18 (date of last update) * @ingroup DRIVERS * @prefix ILCK * @@ -64,14 +64,9 @@ */ typedef enum { /* Init-Sequence */ - ILCK_STATEMACH_UNINITIALIZED, /*!< Uninitialized state */ - ILCK_STATEMACH_INITIALIZATION, /*!< Initialization state */ - ILCK_STATEMACH_INITIALIZED, /*!< statemachine initialized */ - ILCK_STATEMACH_WAIT_FIRST_REQUEST, /*!< wait for open/close request */ - ILCK_STATEMACH_OPEN, /*!< state to open interlock */ - ILCK_STATEMACH_CLOSED, /*!< state to close interlock */ - ILCK_STATEMACH_UNDEFINED, /*!< undefined state */ - ILCK_STATEMACH_ERROR, /*!< Error-State: */ + ILCK_STATEMACHINE_UNINITIALIZED, /*!< Uninitialized state */ + ILCK_STATEMACHINE_INITIALIZED, /*!< statemachine initialized */ + ILCK_STATEMACHINE_UNDEFINED, /*!< undefined state */ } ILCK_STATEMACH_e; /** @@ -85,10 +80,7 @@ typedef enum { * State requests for the ILCK statemachine */ typedef enum { - ILCK_STATE_INIT_REQUEST, - ILCK_STATE_OPEN_REQUEST, - ILCK_STATE_CLOSE_REQUEST, - ILCK_STATE_ERROR_REQUEST, + ILCK_STATE_INITIALIZATION_REQUEST, ILCK_STATE_NO_REQUEST, } ILCK_STATE_REQUEST_e; @@ -97,13 +89,9 @@ typedef enum { */ typedef enum { ILCK_OK, /*!< ILCK --> ok */ - ILCK_BUSY_OK, /*!< ILCK under load --> ok */ ILCK_REQUEST_PENDING, /*!< requested to be executed */ - ILCK_ILLEGAL_REQUEST, /*!< Request can not be executed */ - ILCK_INIT_ERROR, /*!< Error state: Source: Initialization */ - ILCK_ERROR, /*!< General error state */ ILCK_ALREADY_INITIALIZED, /*!< Initialization of ilck already finished */ - ILCK_ILLEGAL_TASK_TYPE, /*!< Illegal */ + ILCK_ILLEGAL_REQUEST, /*!< Request can not be executed */ } ILCK_RETURN_TYPE_e; /** @@ -136,13 +124,6 @@ typedef struct { */ extern STD_RETURN_TYPE_e ILCK_Init(void); -/** - * @brief Reads the feedback pin of the interlock and returns its current value - * (ILCK_SWITCH_OFF/ILCK_SWITCH_ON) - * @return measuredInterlockState (type: ILCK_ELECTRICAL_STATE_TYPE_e) - */ -extern ILCK_ELECTRICAL_STATE_TYPE_e ILCK_GetInterlockFeedback(void); - /** * @brief sets the current state request of the state variable ilck_state. * @@ -179,6 +160,7 @@ extern void ILCK_Trigger(void); /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ #ifdef UNITY_UNIT_TEST extern void TEST_ILCK_SetStateStruct(ILCK_STATE_s state); +extern ILCK_ELECTRICAL_STATE_TYPE_e TEST_ILCK_GetInterlockFeedback(void); #endif #endif /* FOXBMS__INTERLOCK_H_ */ diff --git a/src/app/driver/io/io.c b/src/app/driver/io/io.c index ab05fb50..d30a3aaf 100644 --- a/src/app/driver/io/io.c +++ b/src/app/driver/io/io.c @@ -67,6 +67,20 @@ /*========== Extern Function Implementations ================================*/ +extern void IO_SetPinDirectionToOutput(volatile uint32_t *pRegisterAddress, uint32_t pin) { + FAS_ASSERT(pRegisterAddress != NULL_PTR); + FAS_ASSERT(pin <= LARGEST_PIN_NUMBER); + + *pRegisterAddress |= (uint32_t)((uint32_t)1u << pin); +} + +extern void IO_SetPinDirectionToInput(volatile uint32_t *pRegisterAddress, uint32_t pin) { + FAS_ASSERT(pRegisterAddress != NULL_PTR); + FAS_ASSERT(pin <= LARGEST_PIN_NUMBER); + + *pRegisterAddress &= ~(uint32_t)((uint32_t)1u << pin); +} + extern void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin) { FAS_ASSERT(pRegisterAddress != NULL_PTR); FAS_ASSERT(pin <= LARGEST_PIN_NUMBER); diff --git a/src/app/driver/io/io.h b/src/app/driver/io/io.h index 728ad532..04438b7e 100644 --- a/src/app/driver/io/io.h +++ b/src/app/driver/io/io.h @@ -63,6 +63,26 @@ /*========== Extern Constant and Variable Declarations ======================*/ /*========== Extern Function Prototypes =====================================*/ +/** + * @brief Set pin to output by writing in pin direction register. + * @details The TMS570LC43 has only few dedicated GPIO register. Most of the + * time the IOs are controlled by a dedicated register in the + * corresponding peripheral. + * @param pRegisterAddress address of pin direction register + * @param pin bit position corresponding to pin in register + */ +extern void IO_SetPinDirectionToOutput(volatile uint32_t *pRegisterAddress, uint32_t pin); + +/** + * @brief Set pin to input by writing in pin direction register. + * @details The TMS570LC43 has only few dedicated GPIO register. Most of the + * time the IOs are controlled by a dedicated register in the + * corresponding peripheral. + * @param pRegisterAddress address of pin direction register + * @param pin bit position corresponding to pin in register + */ +extern void IO_SetPinDirectionToInput(volatile uint32_t *pRegisterAddress, uint32_t pin); + /** * @brief Set pin by writing in pin output register. * @details The TMS570LC43 has only few dedicated GPIO register. Most of the @@ -74,7 +94,7 @@ extern void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin); /** - * @brief Set pin by writing in pin output register. + * @brief Reset pin by writing in pin output register. * @details The TMS570LC43 has only few dedicated GPIO register. Most of the * time the IOs are controlled by a dedicated register in the * corresponding peripheral. diff --git a/src/app/driver/led/led.c b/src/app/driver/led/led.c new file mode 100644 index 00000000..a67fb2a7 --- /dev/null +++ b/src/app/driver/led/led.c @@ -0,0 +1,115 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file led.c + * @author foxBMS Team + * @date 2021-09-28 (date of creation) + * @updated 2021-10-05 (date of last update) + * @ingroup DRIVERS + * @prefix LED + * + * @brief Implementation of the debug LED driver + * + */ + +/*========== Includes =======================================================*/ +#include "led.h" + +#include "ftask_cfg.h" + +#include "HL_reg_het.h" + +#include "io.h" + +/*========== Macros and Definitions =========================================*/ +/** Periodic call time of function #LED_Trigger */ +#define LED_PERIODIC_CALL_TIME_ms (FTSK_TASK_CYCLIC_100MS_CYCLE_TIME) + +/** HET1 GIO register that the Debug LED is connected to. */ +#define LED_PORT (hetREG1) +/** Pin of HET1 that the Debug LED is connected to. */ +#define LED_PIN (1u) + +/*========== Static Constant and Variable Definitions =======================*/ +/** duration of a half a LED blink cycle in ms */ +uint32_t led_onOffTime_ms = 0u; + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ +extern void LED_SetDebugLED(void) { + IO_PinSet(&LED_PORT->DOUT, LED_PIN); +} + +extern void LED_Trigger(void) { + OS_EnterTaskCritical(); + uint32_t local_led_onOffTime_ms = led_onOffTime_ms; + OS_ExitTaskCritical(); + + static uint32_t counter = 0u; + if (counter == UINT32_MAX) { + /* wrap counter */ + counter = 0u; + } + counter++; + FAS_ASSERT(local_led_onOffTime_ms != 0u); + if (0u == (((uint64_t)counter * LED_PERIODIC_CALL_TIME_ms) % local_led_onOffTime_ms)) { + if (1u == IO_PinGet(&LED_PORT->DIN, LED_PIN)) { + IO_PinReset(&LED_PORT->DOUT, LED_PIN); + } else { + IO_PinSet(&LED_PORT->DOUT, LED_PIN); + } + counter = 0u; + } +} + +extern void LED_SetToggleTime(uint32_t onOffTime_ms) { + FAS_ASSERT(0u == (onOffTime_ms % LED_PERIODIC_CALL_TIME_ms)); + led_onOffTime_ms = onOffTime_ms; + FAS_ASSERT(led_onOffTime_ms != 0u); +} + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/led/led.h b/src/app/driver/led/led.h new file mode 100644 index 00000000..9c22de86 --- /dev/null +++ b/src/app/driver/led/led.h @@ -0,0 +1,100 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file led.h + * @author foxBMS Team + * @date 2021-09-28 (date of creation) + * @updated 2021-10-05 (date of last update) + * @ingroup DRIVERS + * @prefix LED + * + * @brief Header file of the debug LED driver + * @details This module controls the debug LED that is directly connected to a + * MCU pin. It is used to indicate basic operation states. + * + * * During startup the LED is enabled continuously. + * * Once the startup is complete the LED should be called with + * #LED_SetToggleTime() in order to indicate whether the BMS has + * started normal operation (#LED_NORMAL_OPERATION_ON_OFF_TIME_ms, + * slow blinking pattern) or if it is in an error state + * (#LED_ERROR_OPERATION_ON_OFF_TIME_ms, fast blinking pattern). + * * #LED_SetToggleTime() can be called anytime the indicated pattern + * shall change. + */ + +#ifndef FOXBMS__LED_H_ +#define FOXBMS__LED_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +/*========== Macros and Definitions =========================================*/ +/** time span to be used with #LED_SetToggleTime() indicating normal operation */ +#define LED_NORMAL_OPERATION_ON_OFF_TIME_ms (500u) +/** time span to be used with #LED_SetToggleTime() indicating an error state */ +#define LED_ERROR_OPERATION_ON_OFF_TIME_ms (100u) + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ +/** + * @brief Turn debug LED on + * @details This function is intended to be called once during startup before + * #LED_SetToggleTime() is called (after startup). + */ +extern void LED_SetDebugLED(void); + +/** + * @brief Trigger function to periodically toggle debug LED. Frequency can be + * set via function #LED_SetToggleTime() + */ +extern void LED_Trigger(void); + +/** + * @brief Set debug LED with defined frequency + * @param onOffTime_ms requested time for ON/OFF duration in ms + */ +extern void LED_SetToggleTime(uint32_t onOffTime_ms); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__LED_H_ */ diff --git a/src/app/driver/meas/meas.c b/src/app/driver/meas/meas.c index b192603b..f8041518 100644 --- a/src/app/driver/meas/meas.c +++ b/src/app/driver/meas/meas.c @@ -56,7 +56,7 @@ #include "battery_system_cfg.h" -#include "mic.h" +#include "afe.h" /*========== Macros and Definitions =========================================*/ @@ -71,54 +71,54 @@ /*========== Extern Function Implementations ================================*/ void MEAS_Control(void) { - MIC_TriggerIc(); + AFE_TriggerIc(); } extern STD_RETURN_TYPE_e MEAS_RequestIoWrite(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestIoWrite(string); + return AFE_RequestIoWrite(string); } extern STD_RETURN_TYPE_e MEAS_RequestIoRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestIoRead(string); + return AFE_RequestIoRead(string); } extern STD_RETURN_TYPE_e MEAS_RequestTemperatureRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestTemperatureRead(string); + return AFE_RequestTemperatureRead(string); } extern STD_RETURN_TYPE_e MEAS_RequestBalancingFeedbackRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestBalancingFeedbackRead(string); + return AFE_RequestBalancingFeedbackRead(string); } extern STD_RETURN_TYPE_e MEAS_RequestEepromRead(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestEepromRead(string); + return AFE_RequestEepromRead(string); } extern STD_RETURN_TYPE_e MEAS_RequestEepromWrite(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestEepromWrite(string); + return AFE_RequestEepromWrite(string); } extern bool MEAS_IsFirstMeasurementCycleFinished(void) { - return MIC_IsFirstMeasurementCycleFinished(); + return AFE_IsFirstMeasurementCycleFinished(); } extern STD_RETURN_TYPE_e MEAS_StartMeasurement(void) { - return MIC_StartMeasurement(); + return AFE_StartMeasurement(); } extern STD_RETURN_TYPE_e MEAS_Initialize(void) { - return MIC_Init(); + return AFE_Initialize(); } extern STD_RETURN_TYPE_e MEAS_RequestOpenWireCheck(uint8_t string) { FAS_ASSERT(string < BS_NR_OF_STRINGS); - return MIC_RequestOpenWireCheck(string); + return AFE_RequestOpenWireCheck(string); } /*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/meas/meas.h b/src/app/driver/meas/meas.h index c9391bf4..ceb47af2 100644 --- a/src/app/driver/meas/meas.h +++ b/src/app/driver/meas/meas.h @@ -79,60 +79,60 @@ extern STD_RETURN_TYPE_e MEAS_Initialize(void); extern void MEAS_Control(void); /** - * @brief Checks if the first MIC measurement cycle was made + * @brief Checks if the first AFE measurement cycle was made * @return true if the first measurement cycle was made, false otherwise */ extern bool MEAS_IsFirstMeasurementCycleFinished(void); /** - * @brief Makes the initialization request to the MIC state machine + * @brief Makes the initialization request to the AFE state machine */ extern STD_RETURN_TYPE_e MEAS_StartMeasurement(void); /** - * @brief Makes the request to the MIC state machine to write to the IO + * @brief Makes the request to the AFE state machine to write to the IO * port-expander * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestIoWrite(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read from the IO + * @brief Makes the request to the AFE state machine to read from the IO * port-expander * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestIoRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read from the + * @brief Makes the request to the AFE state machine to read from the * external temperature sensor on slaves * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestTemperatureRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read balancing + * @brief Makes the request to the AFE state machine to read balancing * feedback from the slaves * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestBalancingFeedbackRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to read from the + * @brief Makes the request to the AFE state machine to read from the * external EEPROM on slaves * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestEepromRead(uint8_t string); /** - * @brief Makes the request to the MIC state machine to write to the external + * @brief Makes the request to the AFE state machine to write to the external * EEPROM on slaves * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestEepromWrite(uint8_t string); /** - * @brief Makes the request to the MIC state machine to perform open-wire check + * @brief Makes the request to the AFE state machine to perform open-wire check * @param string string addressed by the request */ extern STD_RETURN_TYPE_e MEAS_RequestOpenWireCheck(uint8_t string); diff --git a/src/app/driver/pex/pex.c b/src/app/driver/pex/pex.c new file mode 100644 index 00000000..c68f9a0f --- /dev/null +++ b/src/app/driver/pex/pex.c @@ -0,0 +1,445 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file pex.c + * @author foxBMS Team + * @date 2021-08-02 (date of creation) + * @updated 2021-10-04 (date of last update) + * @ingroup DRIVERS + * @prefix PEX + * + * @brief Driver for the NXP PCA9539 port expander module + * + */ + +/*========== Includes =======================================================*/ +#include "pex.h" + +#include "diag.h" +#include "i2c.h" +#include "os.h" + +/*========== Macros and Definitions =========================================*/ +/** Number of ports per register */ +#define PEX_NR_OF_PORTS_PER_REGISTER (8u) + +/** Initial value: all 1 */ +#define PEX_DEFAULT_VALUE_ALL_1 (0xFFu) +/** Initial value: all 0 */ +#define PEX_DEFAULT_VALUE_ALL_0 (0x0u) + +/** Address of Input Port 0 register (port 1 is one higher, 0x1u) */ +#define PEX_INPUT_PORT0_REGISTER_ADDRESS (0x0u) +/** Address of Output Port 0 register (port 1 is one higher, 0x3u) */ +#define PEX_OUTPUT_PORT0_REGISTER_ADDRESS (0x2u) +/** Address of Polarity Inversion Port 0 register (port 1 is one higher, 0x5u) */ +#define PEX_POL_INV_PORT0_REGISTER_ADDRESS (0x4u) +/** Address of Configuration Port 0 register (port 1 is one higher, 0x7u) */ +#define PEX_DIRECTION_PORT0_REGISTER_ADDRESS (0x6u) + +/** Port expander pin polarity inversion in registers + * @{*/ +#define PEX_PIN_POLARITY_RETAINED (0u) +#define PEX_PIN_POLARITY_INVERTED (1u) +/**@}*/ + +/** Port expander pin direction configuration in registers + * @{*/ +#define PEX_PIN_DIRECTION_OUTPUT (0u) +#define PEX_PIN_DIRECTION_INPUT (1u) +/**@}*/ + +/*========== Static Constant and Variable Definitions =======================*/ +/** I2C write buffer for PEX */ +static uint8_t pex_i2cDataWrite[2u] = {0}; + +/** + * These variables are used to configure the port expanders (input, output, + * configuration) from external modules. + * @{ + */ +static uint8_t pex_inputPort0[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_inputPort1[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_outputPort0[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_outputPort1[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configPolarityPort0[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configPolarityPort1[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configDirectionPort0[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configDirectionPort1[PEX_NR_OF_PORT_EXPANDERS] = {0}; +/**@}*/ + +/** These local variables hold the state of the port expanders (input, output, + * configuration) + * @{ + */ +static uint8_t pex_inputPort0Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_inputPort1Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_outputPort0Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_outputPort1Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configPolarityPort0Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configPolarityPort1Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configDirectionPort0Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +static uint8_t pex_configDirectionPort1Local[PEX_NR_OF_PORT_EXPANDERS] = {0}; +/**@}*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/** + * @brief reads input state of port expander pins over I2C. + * @return #STD_OK if I2C transmission ok, #STD_NOT_OK otherwise + */ +static STD_RETURN_TYPE_e PEX_ReadInputs(void); + +/** + * @brief sets output state of port expander pins over I2C. + * @return #STD_OK if I2C transmission ok, #STD_NOT_OK otherwise + */ +static STD_RETURN_TYPE_e PEX_WriteOutputs(void); + +/** + * @brief sets polarity inversion state of port expander pins over I2C. + * @return #STD_OK if I2C transmission ok, #STD_NOT_OK otherwise + */ +static STD_RETURN_TYPE_e PEX_WriteConfigPolarity(void); + +/** + * @brief sets direction of port expander pins over I2C. + * @return #STD_OK if I2C transmission ok, #STD_NOT_OK otherwise + */ +static STD_RETURN_TYPE_e PEX_WriteConfigDirection(void); + +/** + * @brief copies values from the externally available variables to the + * local ones. + */ +static void PEX_CopyToLocalVariable(void); + +/** + * @brief copies values from the local variables to the + * externally available ones. + */ +static void PEX_GetFromLocalVariable(void); + +/*========== Static Function Implementations ================================*/ + +static STD_RETURN_TYPE_e PEX_ReadInputs(void) { + STD_RETURN_TYPE_e retVal = STD_OK; + + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + /* + * Input Port 0 as address, next read register will be Input Port 1 + * Datasheet: Rev. 9 ? 8 November 2017 + * "After the first byte is read, additional bytes may be read but + * the data will now reflect the information in the other register in the pair. + * For example, if you read Input port 1, then the next byte read would be Input port 0." + */ + uint8_t pex_i2cDataRead[2u] = {0u, 0u}; + STD_RETURN_TYPE_e i2cReadReturn = + I2C_Read(pex_addressList[i], PEX_INPUT_PORT0_REGISTER_ADDRESS, 2u, pex_i2cDataRead); + if (i2cReadReturn == STD_NOT_OK) { + retVal = STD_NOT_OK; + } else { + pex_inputPort0Local[i] = pex_i2cDataRead[0u]; + pex_inputPort1Local[i] = pex_i2cDataRead[1u]; + } + } + return retVal; +} + +static STD_RETURN_TYPE_e PEX_WriteOutputs(void) { + STD_RETURN_TYPE_e retVal = STD_OK; + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + /** + * Outport Port 0 as address, next read register will be Output Port 1 + * Datasheet: Rev. 9 - 8 November 2017 + * Figure 10: one register pair can be written in one transaction + */ + pex_i2cDataWrite[0u] = pex_outputPort0Local[i]; + pex_i2cDataWrite[1u] = pex_outputPort1Local[i]; + STD_RETURN_TYPE_e i2cWriteReturn = + I2C_Write(pex_addressList[i], PEX_OUTPUT_PORT0_REGISTER_ADDRESS, 2u, pex_i2cDataWrite); + if (i2cWriteReturn == STD_NOT_OK) { + retVal = STD_NOT_OK; + } + } + return retVal; +} + +static STD_RETURN_TYPE_e PEX_WriteConfigPolarity(void) { + STD_RETURN_TYPE_e retVal = STD_OK; + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + /** + * Inversion Polarity Port 0 as address, next read register will be Inversion Polarity Port 1 + * Datasheet: Rev. 9 - 8 November 2017 + * Figure 10: one register pair can be written in one transaction + */ + pex_i2cDataWrite[0u] = pex_configPolarityPort0Local[i]; + pex_i2cDataWrite[1u] = pex_configPolarityPort1Local[i]; + STD_RETURN_TYPE_e i2cWriteReturn = + I2C_Write(pex_addressList[i], PEX_POL_INV_PORT0_REGISTER_ADDRESS, 2u, pex_i2cDataWrite); + if (i2cWriteReturn == STD_NOT_OK) { + retVal = STD_NOT_OK; + } + } + return retVal; +} + +static STD_RETURN_TYPE_e PEX_WriteConfigDirection(void) { + STD_RETURN_TYPE_e retVal = STD_OK; + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + /** + * Direction Port 0 as address, next read register will be Direction Port 1 + * Datasheet: Rev. 9 - 8 November 2017 + * Figure 10: one register pair can be written in one transaction + */ + pex_i2cDataWrite[0u] = pex_configDirectionPort0Local[i]; + pex_i2cDataWrite[1u] = pex_configDirectionPort1Local[i]; + STD_RETURN_TYPE_e i2cWriteReturn = + I2C_Write(pex_addressList[i], PEX_DIRECTION_PORT0_REGISTER_ADDRESS, 2u, pex_i2cDataWrite); + if (i2cWriteReturn == STD_NOT_OK) { + retVal = STD_NOT_OK; + } + } + return retVal; +} + +static void PEX_CopyToLocalVariable(void) { + OS_EnterTaskCritical(); + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + pex_outputPort0Local[i] = pex_outputPort0[i]; + pex_outputPort1Local[i] = pex_outputPort1[i]; + pex_configPolarityPort0Local[i] = pex_configPolarityPort0[i]; + pex_configPolarityPort1Local[i] = pex_configPolarityPort1[i]; + pex_configDirectionPort0Local[i] = pex_configDirectionPort0[i]; + pex_configDirectionPort1Local[i] = pex_configDirectionPort1[i]; + } + OS_ExitTaskCritical(); +} + +static void PEX_GetFromLocalVariable(void) { + OS_EnterTaskCritical(); + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + pex_inputPort0[i] = pex_inputPort0Local[i]; + pex_inputPort1[i] = pex_inputPort1Local[i]; + } + OS_ExitTaskCritical(); +} + +/*========== Extern Function Implementations ================================*/ + +/** + * In the datasheet, pins are grouped in two sets, numbered from 00 to 07 and from 10 to 17. + * Each set is handled by a separate register, so pin 00 is numbered 0, pin 01 is numbered 01, .., + * pin 07 is numbered 07. But also pin 10 is numbered 0, pin 11 is numbered 01, .., pin 17 is numbered 07. + * Using defines from 0 to 15, it is possible to get with pin number which register has to be addressed: + * 0 to 7 means register for 00 to 07, 8 to 15 means register for 10 to 17. + * Applying (pin%8) for 8 to 15 gives 0 to 7, so the numbering in register is obtained immediately. + */ +extern void PEX_Initialize(void) { + for (uint8_t i = 0u; i < PEX_NR_OF_PORT_EXPANDERS; i++) { + /** Default state of output registers Datasheet: Rev. 9 - 8 November 2017, Table 7 and 8 */ + pex_outputPort0[i] = PEX_DEFAULT_VALUE_ALL_1; + pex_outputPort1[i] = PEX_DEFAULT_VALUE_ALL_1; + pex_outputPort0Local[i] = PEX_DEFAULT_VALUE_ALL_1; + pex_outputPort1Local[i] = PEX_DEFAULT_VALUE_ALL_1; + /** + * Default state of polarity inversion registers Datasheet: Rev. 9 - 8 November 2017, Table 9 and 10 + */ + pex_configPolarityPort0[i] = PEX_DEFAULT_VALUE_ALL_0; + pex_configPolarityPort1[i] = PEX_DEFAULT_VALUE_ALL_0; + pex_configPolarityPort0Local[i] = PEX_DEFAULT_VALUE_ALL_0; + pex_configPolarityPort1Local[i] = PEX_DEFAULT_VALUE_ALL_0; + /** Default state of direction registers Datasheet: Rev. 9 - 8 November 2017, Table 11 and 12 */ + pex_configDirectionPort0[i] = PEX_DEFAULT_VALUE_ALL_1; + pex_configDirectionPort1[i] = PEX_DEFAULT_VALUE_ALL_1; + pex_configDirectionPort0Local[i] = PEX_DEFAULT_VALUE_ALL_1; + pex_configDirectionPort1Local[i] = PEX_DEFAULT_VALUE_ALL_1; + } +} + +extern void PEX_Trigger(void) { + PEX_CopyToLocalVariable(); + + STD_RETURN_TYPE_e writeConfigDirectionReturn = PEX_WriteConfigDirection(); + STD_RETURN_TYPE_e writeConfigPolarityReturn = PEX_WriteConfigPolarity(); + STD_RETURN_TYPE_e readInputsReturn = PEX_ReadInputs(); + STD_RETURN_TYPE_e writeOutputsReturn = PEX_WriteOutputs(); + + /* notify diag if one of these functions failed, but continue normally */ + if ((writeConfigDirectionReturn == STD_NOT_OK) || (writeConfigPolarityReturn == STD_NOT_OK) || + (readInputsReturn == STD_NOT_OK) || (writeOutputsReturn == STD_NOT_OK)) { + DIAG_Handler(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_NOT_OK, DIAG_SYSTEM, 0u); + } else { + DIAG_Handler(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_OK, DIAG_SYSTEM, 0u); + } + + PEX_GetFromLocalVariable(); +} + +extern void PEX_SetPin(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pex_outputPort0[portExpander] |= PEX_PIN_HIGH << pin; + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pex_outputPort1[portExpander] |= PEX_PIN_HIGH << (pin % PEX_NR_OF_PORTS_PER_REGISTER); + OS_ExitTaskCritical(); + } +} + +extern void PEX_ResetPin(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pex_outputPort0[portExpander] &= ~(PEX_PIN_HIGH << pin); + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pex_outputPort1[portExpander] &= ~(PEX_PIN_HIGH << (pin % PEX_NR_OF_PORTS_PER_REGISTER)); + OS_ExitTaskCritical(); + } +} + +extern uint8_t PEX_GetPin(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + uint8_t pinState = UINT8_MAX; + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pinState = (pex_inputPort0[portExpander] >> pin) & 0x1u; + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pinState = (pex_inputPort1[portExpander] >> (pin % PEX_NR_OF_PORTS_PER_REGISTER)) & 0x1u; + OS_ExitTaskCritical(); + } + + if (pinState == 0u) { + pinState = PEX_PIN_LOW; + } else if (pinState == 1u) { + pinState = PEX_PIN_HIGH; + } else { + /* invalid pin state */ + FAS_ASSERT(FAS_TRAP); + } + + return pinState; +} + +extern void PEX_SetPinDirectionInput(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pex_configDirectionPort0[portExpander] |= PEX_PIN_DIRECTION_INPUT << pin; + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pex_configDirectionPort1[portExpander] |= PEX_PIN_DIRECTION_INPUT << (pin % PEX_NR_OF_PORTS_PER_REGISTER); + OS_ExitTaskCritical(); + } +} + +extern void PEX_SetPinDirectionOutput(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pex_configDirectionPort0[portExpander] &= ~(((~PEX_PIN_DIRECTION_OUTPUT) & 0x1u) << pin); + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pex_configDirectionPort1[portExpander] &= + ~(((~PEX_PIN_DIRECTION_OUTPUT) & 0x1u) << (pin % PEX_NR_OF_PORTS_PER_REGISTER)); + OS_ExitTaskCritical(); + } +} + +extern void PEX_SetPinPolarityInverted(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pex_configPolarityPort0[portExpander] |= PEX_PIN_POLARITY_INVERTED << pin; + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pex_configPolarityPort1[portExpander] |= PEX_PIN_POLARITY_INVERTED << (pin % PEX_NR_OF_PORTS_PER_REGISTER); + OS_ExitTaskCritical(); + } +} + +extern void PEX_SetPinPolarityRetained(uint8_t portExpander, uint8_t pin) { + FAS_ASSERT(portExpander < PEX_NR_OF_PORT_EXPANDERS); + FAS_ASSERT(pin <= PEX_PIN17); + + if (pin <= PEX_PIN07) { + OS_EnterTaskCritical(); + pex_configPolarityPort0[portExpander] &= ~(((~PEX_PIN_POLARITY_RETAINED) & 0x1u) << pin); + OS_ExitTaskCritical(); + } else { /* pin is in range PEX_PIN10 to PEX_PIN17 */ + OS_EnterTaskCritical(); + pex_configPolarityPort1[portExpander] &= + ~(((~PEX_PIN_POLARITY_RETAINED) & 0x1u) << (pin % PEX_NR_OF_PORTS_PER_REGISTER)); + OS_ExitTaskCritical(); + } +} + +/*========== Getter for static Variables (Unit Test) ========================*/ +#ifdef UNITY_UNIT_TEST + +#endif + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/pex/pex.h b/src/app/driver/pex/pex.h new file mode 100644 index 00000000..8747e391 --- /dev/null +++ b/src/app/driver/pex/pex.h @@ -0,0 +1,141 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file pex.h + * @author foxBMS Team + * @date 2021-08-02 (date of creation) + * @updated 2021-10-04 (date of last update) + * @ingroup DRIVERS + * @prefix PEX + * + * @brief Header for the driver for the NXP PCA9539 port expander module + * + */ + +#ifndef FOXBMS__PEX_H_ +#define FOXBMS__PEX_H_ + +/*========== Includes =======================================================*/ + +#include "pex_cfg.h" + +/*========== Macros and Definitions =========================================*/ +/** Port expander pin high levels in registers + * @{*/ +#define PEX_PIN_LOW (0u) +#define PEX_PIN_HIGH (1u) +/**@}*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ + +/** + * @brief initialize local variable containing state of port expander. + * + */ +extern void PEX_Initialize(void); + +/** + * @brief sets pin to high. + * @param portExpander port expander number + * @param pin pin number + */ +extern void PEX_SetPin(uint8_t portExpander, uint8_t pin); + +/** + * @brief sets pin to low. + * @param portExpander port expander number + * @param pin pin number + * + */ +extern void PEX_ResetPin(uint8_t portExpander, uint8_t pin); + +/** + * @brief get pin state of port expander pins. + * @return pin state: #PEX_PIN_LOW or #PEX_PIN_HIGH + */ +extern uint8_t PEX_GetPin(uint8_t portExpander, uint8_t pin); + +/** + * @brief sets pin direction to input. + * @param portExpander port expander number + * @param pin pin number + */ +extern void PEX_SetPinDirectionInput(uint8_t portExpander, uint8_t pin); + +/** + * @brief sets pin to input. + * @param portExpander port expander number + * @param pin pin number + */ +extern void PEX_SetPinDirectionOutput(uint8_t portExpander, uint8_t pin); + +/** + * @brief sets pin polarity to inverted. + * @param portExpander port expander number + * @param pin pin number + */ +extern void PEX_SetPinPolarityInverted(uint8_t portExpander, uint8_t pin); + +/** + * @brief sets pin polarity to retained. + * @param portExpander port expander number + * @param pin pin number + */ +extern void PEX_SetPinPolarityRetained(uint8_t portExpander, uint8_t pin); + +/** + * @brief implements reading/writing to the port expander registers. + * @details This function reads the desired port expander state (outputs, + * configuration) from the externally available variables and stores + * it in the local variable. It then applies this state to the devices + * via the I2C bus. It reads the pin input state via the I2C bus and + * writes it to the externally available port expander state. + */ +extern void PEX_Trigger(void); + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ +#ifdef UNITY_UNIT_TEST +#endif + +#endif /* FOXBMS__PEX_H_ */ diff --git a/src/app/driver/pwm/pwm.c b/src/app/driver/pwm/pwm.c new file mode 100644 index 00000000..21684a3a --- /dev/null +++ b/src/app/driver/pwm/pwm.c @@ -0,0 +1,150 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file pwm.c + * @author foxBMS Team + * @date 2021-10-07 (date of creation) + * @updated 2021-10-08 (date of last update) + * @ingroup DRIVERS + * @prefix PWM + * + * @brief Implementation of the PWM module. + * + */ + +/*========== Includes =======================================================*/ +#include "pwm.h" + +#include "HL_etpwm.h" + +#include "fsystem.h" + +/*========== Macros and Definitions =========================================*/ +/** lower threshold permill */ +#define PWM_LOWER_THRESHOLD_PERM (1u) + +/** upper threshold permill */ +#define PWM_UPPER_THRESHOLD_PERM (999u) + +/** full period in promill */ +#define PWM_FULL_PERIOD_PERM (1000u) + +/*========== Static Constant and Variable Definitions =======================*/ +/** linear offset (through output circuit) */ +static const int16_t pwm_kLinearOffset = 0; + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ +/** returns the ePWM time period (currently for ePWM1A) + * @returns ePWM time period in counter ticks + */ +static uint16_t PWM_GetEtpwmTimePeriod(void); + +/** returns a ePWM counter value based on a duty cycle + * @param[in] dutyCycle_perm duty cycle in permill + * @returns counter value + */ +static uint16_t PWM_ComputeCounterValueFromDutyCycle(uint16_t dutyCycle_perm); + +/*========== Static Function Implementations ================================*/ +static uint16_t PWM_GetEtpwmTimePeriod(void) { + etpwm_config_reg_t etPwmConfig = {0}; + etpwm1GetConfigValue(&etPwmConfig, CurrentValue); /* retrieve the current config */ + return etPwmConfig.CONFIG_TBPRD; +} + +static uint16_t PWM_ComputeCounterValueFromDutyCycle(uint16_t dutyCycle_perm) { + FAS_ASSERT((dutyCycle_perm >= PWM_LOWER_THRESHOLD_PERM) && (dutyCycle_perm <= PWM_UPPER_THRESHOLD_PERM)); + + uint16_t basePeriod = PWM_GetEtpwmTimePeriod(); + uint32_t counterValue = (((uint32_t)basePeriod * (uint32_t)dutyCycle_perm) / PWM_FULL_PERIOD_PERM); + + FAS_ASSERT(counterValue <= (uint16_t)UINT16_MAX); + return (uint16_t)counterValue; +} + +/*========== Extern Function Implementations ================================*/ +extern void PWM_StartPwm(void) { + /* go to privileged mode in order to access control register */ + FAS_ASSERT(FSYS_RaisePrivilege() == 0); + etpwmStartTBCLK(); + /* done; go back to user mode */ + FSYS_SwitchToUserMode(); +} + +extern void PWM_StopPwm(void) { + /* go to privileged mode in order to access control register */ + FAS_ASSERT(FSYS_RaisePrivilege() == 0); + etpwmStopTBCLK(); + /* done; go back to user mode */ + FSYS_SwitchToUserMode(); +} + +extern void PWM_SetDutyCycle(uint16_t dutyCycle_perm) { + FAS_ASSERT(dutyCycle_perm <= (uint16_t)INT16_MAX); + int16_t intermediateDutyCycle_perm = (int16_t)dutyCycle_perm + pwm_kLinearOffset; + /* prevent wrap-around */ + if (intermediateDutyCycle_perm < 0) { + intermediateDutyCycle_perm = 0; + } + uint16_t correctedDutyCycle_perm = (uint16_t)intermediateDutyCycle_perm; + + if (correctedDutyCycle_perm < PWM_LOWER_THRESHOLD_PERM) { + correctedDutyCycle_perm = PWM_LOWER_THRESHOLD_PERM; + } + + if (correctedDutyCycle_perm > PWM_UPPER_THRESHOLD_PERM) { + correctedDutyCycle_perm = PWM_UPPER_THRESHOLD_PERM; + } + + etpwmSetCmpA(etpwmREG1, PWM_ComputeCounterValueFromDutyCycle(correctedDutyCycle_perm)); +} + +/*========== Getter for static Variables (Unit Test) ========================*/ +#ifdef UNITY_UNIT_TEST +extern int16_t TEST_PWM_GetLinearOffset(void) { + return pwm_kLinearOffset; +} +#endif + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/driver/pwm/pwm.h b/src/app/driver/pwm/pwm.h new file mode 100644 index 00000000..d7f35954 --- /dev/null +++ b/src/app/driver/pwm/pwm.h @@ -0,0 +1,92 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file pwm.h + * @author foxBMS Team + * @date 2021-10-07 (date of creation) + * @updated 2021-10-08 (date of last update) + * @ingroup DRIVERS + * @prefix PWM + * + * @brief PWM driver for the TMS570LC43xx. + * @details This module uses the PWM hardware of the MCU in order to generate + * a PWM signal. Currently, the implementation uses only the ePWM + * (not the HET) and supports only setting a duty cycle (in percent). + * For the module to work currently, the function etpwmInit() has to + * be called before using API of this module. + */ + +#ifndef FOXBMS__PWM_H_ +#define FOXBMS__PWM_H_ + +/*========== Includes =======================================================*/ +#include "general.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Extern Constant and Variable Declarations ======================*/ + +/*========== Extern Function Prototypes =====================================*/ +/** @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) */ +extern void PWM_StopPwm(void); + +/** @brief Set the duty cycle of the PWM (currently only channel 1A) + * @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); + +/*========== Getter for static Variables (Unit Test) ========================*/ +#ifdef UNITY_UNIT_TEST +extern int16_t TEST_PWM_GetLinearOffset(void); +#endif + +/*========== Externalized Static Functions Prototypes (Unit Test) ===========*/ + +#endif /* FOXBMS__PWM_H_ */ diff --git a/src/app/driver/sps/sps.c b/src/app/driver/sps/sps.c index c90974a3..48c77e96 100644 --- a/src/app/driver/sps/sps.c +++ b/src/app/driver/sps/sps.c @@ -43,7 +43,7 @@ * @file sps.c * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2021-07-14 (date of last update) + * @updated 2021-10-01 (date of last update) * @ingroup DRIVERS * @prefix SPS * @@ -58,6 +58,7 @@ #include "io.h" #include "mcu.h" #include "os.h" +#include "pex.h" #include "spi.h" /*========== Macros and Definitions =========================================*/ @@ -248,9 +249,14 @@ static void SPS_RequestChannelState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNEL_ /*========== Static Function Implementations ================================*/ static void SPS_InitializeIo(void) { /** Pin to drive reset line of SPS ICs */ - SPS_RESET_GIOPORT_DIR |= (uint32)((uint32)1u << SPS_RESET_PIN); + SPS_RESET_GIO_PORT_DIR |= (uint32)((uint32)1u << SPS_RESET_PIN); /** Pin to drive Chip Select line of SPS ICs */ SPS_SPI_CS_GIOPORT_DIR |= (uint32)((uint32)1u << SPS_SPI_CS_PIN); + + /* set feedback enable as output */ + SETBIT(SPS_FEEDBACK_GIO_PORT_DIR, SPS_FEEDBACK_PIN); + /* enable output on feedback enable */ + IO_PinSet(&SPS_FEEDBACK_GIO_PORT, SPS_FEEDBACK_PIN); } static void SPS_GlobalRegisterRead( @@ -265,8 +271,8 @@ static void SPS_GlobalRegisterRead( } } else if (controlOrDiagnostic == SPS_READ_CONTROL_REGISTER) { for (uint8_t i = 0u; i < SPS_SPI_BUFFERSIZE; i++) { - pSpiTxBuffer[i] = (address << SPS_ADDRESS_BIT_START) | /* Register address */ - (1u << SPS_DIAG_CTRL_BIT_POSITION); /* Select diagnostic register */ + pSpiTxBuffer[i] = (address << SPS_ADDRESS_BIT_START) | /* Register address */ + ((uint16_t)1u << SPS_DIAG_CTRL_BIT_POSITION); /* Select diagnostic register */ } } else { /* Invalid access type */ @@ -277,9 +283,9 @@ static void SPS_GlobalRegisterRead( static void SPS_GlobalRegisterWrite(const uint16_t address, uint8_t writeData, uint16_t *pSpiTxBuffer) { FAS_ASSERT(pSpiTxBuffer != NULL_PTR); for (uint8_t i = 0u; i < SPS_SPI_BUFFERSIZE; i++) { - pSpiTxBuffer[i] = (1u << SPS_RW_BIT_POSITION) | /* R/W bit = 1 to write */ - (address << SPS_ADDRESS_BIT_START) | /* Register address */ - (writeData); /* Data to write */ + pSpiTxBuffer[i] = ((uint16_t)1u << SPS_RW_BIT_POSITION) | /* R/W bit = 1 to write */ + (address << SPS_ADDRESS_BIT_START) | /* Register address */ + (writeData); /* Data to write */ } } @@ -297,19 +303,22 @@ static void SPS_SingleDeviceRegisterWrite( devices 0-1-2 in the daisy-chain, the sequence 2-1-0 has to be sent. */ /* Keep the previous data which lies in the lower 8 bits */ - uint8_t preceedingWriteData = (pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)]) & 0xFFu; + uint8_t preceedingWriteData = (uint8_t)((pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)]) & 0xFFu); /* Clear write data which will be replaced */ pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] &= 0xFF00u; /* Write R/W bit and address in the higher 8 bits */ - pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] = (1u << SPS_RW_BIT_POSITION) | /* R/W bit = 1 to write */ - (address << SPS_ADDRESS_BIT_START); /* Register address */ + pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] = (uint16_t)( + ((uint16_t)1u << SPS_RW_BIT_POSITION) | /* R/W bit = 1 to write */ + (address << SPS_ADDRESS_BIT_START)); /* Register address */ if (writeType == SPS_replaceCurrentValue) { - pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] |= writeData; /* Data to write */ + pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] |= (uint16_t)writeData; /* Data to write */ } else if (writeType == SPS_orWithCurrentValue) { - pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] |= preceedingWriteData | writeData; /* Data to write */ + pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] |= + ((uint16_t)preceedingWriteData | (uint16_t)writeData); /* Data to write */ } else if (writeType == SPS_andWithCurrentValue) { - pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] |= preceedingWriteData & writeData; /* Data to write */ + pSpiTxBuffer[(SPS_SPI_BUFFERSIZE - 1u - device)] |= + ((uint16_t)preceedingWriteData & (uint16_t)writeData); /* Data to write */ } else { /* Invalid write type */ FAS_ASSERT(FAS_TRAP); @@ -366,7 +375,7 @@ static void SPS_SetCommandTxBuffer(const SPS_ACTION_e action) { } } -static void SPS_InitializeBuffers() { +static void SPS_InitializeBuffers(void) { for (uint8_t i = 0u; i < SPS_SPI_BUFFERSIZE; i++) { sps_spiTxRegisterBuffer[i] = 0u; SPS_SingleDeviceRegisterWrite( @@ -403,7 +412,7 @@ static void SPS_SetContactorsTxBuffer(void) { SPS_orWithCurrentValue, /* OR because we want to set additional bits to 1 */ sps_spiTxWriteToChannelChannelControlRegister); } else if (pChannel->channelRequested == SPS_CHANNEL_OFF) { - uint8_t writeData = ~(1u << (channel % SPS_NR_CONTACTOR_PER_IC)); + uint8_t writeData = (~(1u << (channel % SPS_NR_CONTACTOR_PER_IC)) & 0xFFu); SPS_SingleDeviceRegisterWrite( spsDevicePositionInDaisyChain, SPS_OUTPUT_CONTROL_REGISTER_ADDRESS, @@ -479,13 +488,13 @@ extern void SPS_Ctrl(void) { break; case SPS_RESET_LOW: - IO_PinReset(&SPS_RESET_GIOPORT, SPS_RESET_PIN); + IO_PinReset(&SPS_RESET_GIO_PORT, SPS_RESET_PIN); sps_state = SPS_RESET_HIGH; sps_timer = SPS_RESET_WAIT_TIME_TICKS; break; case SPS_RESET_HIGH: - IO_PinSet(&SPS_RESET_GIOPORT, SPS_RESET_PIN); + IO_PinSet(&SPS_RESET_GIO_PORT, SPS_RESET_PIN); sps_state = SPS_CONFIGURE_CONTROL_REGISTER; sps_timer = SPS_RESET_WAIT_TIME_TICKS; break; @@ -594,7 +603,7 @@ extern void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNE SPS_RequestChannelState(channelIndex, channelFunction); } -extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelFeedback(SPS_CHANNEL_INDEX channelIndex) { +extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelCurrentFeedback(const SPS_CHANNEL_INDEX channelIndex) { FAS_ASSERT(channelIndex < SPS_NR_OF_AVAILABLE_SPS_CHANNELS); CONT_ELECTRICAL_STATE_TYPE_e channelFeedback = CONT_SWITCH_OFF; @@ -610,6 +619,29 @@ extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelFeedback(SPS_CHANNEL_INDEX cha return channelFeedback; } +extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelPexFeedback(const SPS_CHANNEL_INDEX channelIndex, bool normallyOpen) { + FAS_ASSERT(channelIndex < SPS_NR_OF_AVAILABLE_SPS_CHANNELS); + FAS_ASSERT((normallyOpen == true) || (normallyOpen == false)); + + SPS_CHANNEL_FEEDBACK_MAPPING_s channelMapping = sps_kChannelFeedbackMapping[channelIndex]; + uint8_t pinState = PEX_GetPin(channelMapping.pexDevice, channelMapping.pexChannel); + + CONT_ELECTRICAL_STATE_TYPE_e channelFeedback = CONT_SWITCH_OFF; + if (normallyOpen == true) { + /* contactor is on if pinstate is high */ + if (pinState != PEX_PIN_LOW) { + channelFeedback = CONT_SWITCH_ON; + } + } else { + /* contactor is on if pinstate is low */ + if (pinState != PEX_PIN_HIGH) { + channelFeedback = CONT_SWITCH_ON; + } + } + + return channelFeedback; +} + extern SPS_CHANNEL_AFFILIATION_e SPS_GetChannelAffiliation(SPS_CHANNEL_INDEX channelIndex) { FAS_ASSERT(channelIndex < SPS_NR_OF_AVAILABLE_SPS_CHANNELS); return sps_channelStatus[channelIndex].affiliation; diff --git a/src/app/driver/sps/sps.h b/src/app/driver/sps/sps.h index bca33deb..a496e5ea 100644 --- a/src/app/driver/sps/sps.h +++ b/src/app/driver/sps/sps.h @@ -43,7 +43,7 @@ * @file sps.h * @author foxBMS Team * @date 2020-10-14 (date of creation) - * @updated 2020-10-14 (date of last update) + * @updated 2021-10-01 (date of last update) * @ingroup DRIVERS * @prefix SPS * @@ -109,7 +109,18 @@ extern void SPS_RequestGeneralIOState(SPS_CHANNEL_INDEX channelIndex, SPS_CHANNE * @param[in] channelIndex index of the channel (contactor) that should be accessed * @returns state of the channel's feedback */ -extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelFeedback(SPS_CHANNEL_INDEX channelIndex); +extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelCurrentFeedback(const SPS_CHANNEL_INDEX channelIndex); + +/** + * @brief Get the feedback state of a channel + * @details Retrieves the feedback state of a sps channel by looking up the + * appropriate channel in #sps_kChannelFeedbackMapping and retrieving + * the value through the PEX API. + * @param[in] channelIndex number of the SPS channel that shall be checked + * @param[in] normallyOpen true if the feedback is normally open, false if not + * @return state of the channel as reported by PEX + */ +extern CONT_ELECTRICAL_STATE_TYPE_e SPS_GetChannelPexFeedback(const SPS_CHANNEL_INDEX channelIndex, bool normallyOpen); /** * @brief Returns the channel affiliation diff --git a/src/app/driver/wscript b/src/app/driver/wscript index cf9e6cf9..5713a151 100644 --- a/src/app/driver/wscript +++ b/src/app/driver/wscript @@ -70,16 +70,22 @@ def build(bld): os.path.join("config", "fram_cfg.c"), os.path.join("config", "interlock_cfg.c"), os.path.join("config", "nxpfs85xx_cfg.c"), + os.path.join("config", "pex_cfg.c"), os.path.join("config", "spi_cfg.c"), os.path.join("config", "sps_cfg.c"), os.path.join("contactor", "contactor.c"), os.path.join("dma", "dma.c"), os.path.join("foxmath", "foxmath.c"), os.path.join("fram", "fram.c"), + os.path.join("htsensor", "htsensor.c"), os.path.join("interlock", "interlock.c"), + os.path.join("i2c", "i2c.c"), os.path.join("io", "io.c"), + os.path.join("led", "led.c"), os.path.join("mcu", "mcu.c"), os.path.join("meas", "meas.c"), + os.path.join("pex", "pex.c"), + os.path.join("pwm", "pwm.c"), os.path.join("rtc", "rtc.c"), os.path.join("sbc", "nxpfs85xx.c"), os.path.join("sbc", "sbc.c"), @@ -111,10 +117,14 @@ def build(bld): "dma", "foxmath", "fram", + "htsensor", "interlock", + "i2c", "io", "meas", "mcu", + "pex", + "pwm", "rtc", "sbc", os.path.join("sbc", "fs8x_driver"), @@ -146,13 +156,11 @@ def build(bld): os.path.join("..", "task", "ftask"), ] includes.extend( - bld.env.INCLUDES_OPERATING_SYSTEM - + bld.env.INCLUDES_MEASUREMENT_IC - + bld.env.INCLUDES_IMD + bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE + bld.env.INCLUDES_IMD ) cflags = bld.env.CFLAGS_FOXBMS target = f"{bld.env.APPNAME.lower()}-driver" - use = [f"{bld.env.APPNAME.lower()}-mic-driver", f"{bld.env.APPNAME}-imd"] + use = [f"{bld.env.APPNAME.lower()}-afe-driver", f"{bld.env.APPNAME}-imd"] bld.stlib( source=source, includes=includes, @@ -161,5 +169,5 @@ def build(bld): target=target, ) - bld.recurse("mic") + bld.recurse("afe") bld.recurse("imd") diff --git a/src/app/engine/config/database_cfg.c b/src/app/engine/config/database_cfg.c index 2e43f6f3..85eb0776 100644 --- a/src/app/engine/config/database_cfg.c +++ b/src/app/engine/config/database_cfg.c @@ -43,7 +43,7 @@ * @file database_cfg.c * @author foxBMS Team * @date 2015-08-18 (date of creation) - * @updated 2021-05-11 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup ENGINE_CONFIGURATION * @prefix DATA * @@ -151,20 +151,23 @@ static DATA_BLOCK_STATEREQUEST_s data_blockStaterequest = {.header.uniqueId = DA /** data block: moving average */ static DATA_BLOCK_MOVING_AVERAGE_s data_blockMovingAverage = {.header.uniqueId = DATA_BLOCK_ID_MOVING_AVERAGE}; -/** data block: adc temperature */ -static DATA_BLOCK_ADC_TEMPERATURE_s data_blockAdcTemperature = {.header.uniqueId = DATA_BLOCK_ID_ADC_TEMPERATURE}; - -/** data block: adc temperature */ +/** data block: insulation monitoring */ static DATA_BLOCK_INSULATION_MONITORING_s data_blockInsulationMonitoring = { .header.uniqueId = DATA_BLOCK_ID_INSULATION_MONITORING}; +/** data block: pack values */ +static DATA_BLOCK_PACK_VALUES_s data_blockPackValues = {.header.uniqueId = DATA_BLOCK_ID_PACK_VALUES}; + +/** data block: adc temperature */ +static DATA_BLOCK_ADC_VOLTAGE_s data_blockAdcVoltage = {.header.uniqueId = DATA_BLOCK_ID_ADC_VOLTAGE}; + +/** data block: I2C humidity/temperature sensor measurements*/ +static DATA_BLOCK_HTSEN_s data_blockHumidityTemperatureSensor = {.header.uniqueId = DATA_BLOCK_ID_HTSEN}; + /** data block: used for self-test */ static DATA_BLOCK_DUMMY_FOR_SELF_TEST_s data_blockDummyForSelfTest = { .header.uniqueId = DATA_BLOCK_ID_DUMMY_FOR_SELF_TEST}; -/** data block: adc temperature */ -static DATA_BLOCK_PACK_VALUES_s data_blockPackValues = {.header.uniqueId = DATA_BLOCK_ID_PACK_VALUES}; - /** * @brief channel configuration of database (data blocks) * @details all data block managed by database are listed here (address, size, @@ -199,9 +202,10 @@ DATA_BASE_s data_database[] = { {(void *)(&data_blockFeedbackBalancingRedundancy0), sizeof(DATA_BLOCK_BALANCING_FEEDBACK_s)}, {(void *)(&data_blockLtcAllGpioVoltagesRedundancy0), sizeof(DATA_BLOCK_ALL_GPIO_VOLTAGES_s)}, {(void *)(&data_blockOpenWireRedundancy0), sizeof(DATA_BLOCK_OPEN_WIRE_s)}, - {(void *)(&data_blockAdcTemperature), sizeof(DATA_BLOCK_ADC_TEMPERATURE_s)}, {(void *)(&data_blockInsulationMonitoring), sizeof(DATA_BLOCK_INSULATION_MONITORING_s)}, {(void *)(&data_blockPackValues), sizeof(DATA_BLOCK_PACK_VALUES_s)}, + {(void *)(&data_blockAdcVoltage), sizeof(DATA_BLOCK_ADC_VOLTAGE_s)}, + {(void *)(&data_blockHumidityTemperatureSensor), sizeof(DATA_BLOCK_HTSEN_s)}, {(void *)(&data_blockDummyForSelfTest), sizeof(DATA_BLOCK_DUMMY_FOR_SELF_TEST_s)}, }; diff --git a/src/app/engine/config/database_cfg.h b/src/app/engine/config/database_cfg.h index 547676b8..7f74fb25 100644 --- a/src/app/engine/config/database_cfg.h +++ b/src/app/engine/config/database_cfg.h @@ -43,7 +43,7 @@ * @file database_cfg.h * @author foxBMS Team * @date 2015-08-18 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup ENGINE_CONFIGURATION * @prefix DATA * @@ -98,9 +98,10 @@ typedef enum DATA_BLOCK_ID { DATA_BLOCK_ID_BALANCING_FEEDBACK_REDUNDANCY0, DATA_BLOCK_ID_ALL_GPIO_VOLTAGES_REDUNDANCY0, DATA_BLOCK_ID_OPEN_WIRE_REDUNDANCY0, - DATA_BLOCK_ID_ADC_TEMPERATURE, DATA_BLOCK_ID_INSULATION_MONITORING, DATA_BLOCK_ID_PACK_VALUES, + DATA_BLOCK_ID_HTSEN, + DATA_BLOCK_ID_ADC_VOLTAGE, DATA_BLOCK_ID_DUMMY_FOR_SELF_TEST, DATA_BLOCK_ID_MAX, /**< DO NOT CHANGE, MUST BE THE LAST ENTRY */ } DATA_BLOCK_ID_e; @@ -141,20 +142,6 @@ typedef struct DATA_BLOCK_CELL_TEMPERATURE { uint16_t nrValidTemperatures[BS_NR_OF_STRINGS]; /*!< number of valid temperatures in each string */ } DATA_BLOCK_CELL_TEMPERATURE_s; -/** data block struct of cell temperatures */ -typedef struct DATA_BLOCK_ADC_TEMPERATURE { - /* 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 */ - int16_t temperatureAdc0_ddegC[BS_NR_OF_TEMP_SENSORS_ON_ADC0]; /*!< unit: deci degree celsius */ - int16_t temperatureAdc1_ddegC[BS_NR_OF_TEMP_SENSORS_ON_ADC1]; /*!< unit: deci degree Celsius */ - uint16_t valid_temperature_ADC0 - [BS_NR_OF_TEMP_SENSORS_ON_ADC0]; /*!< bitmask if temperatures are valid. 0->valid, 1->invalid */ - uint16_t valid_temperature_ADC1 - [BS_NR_OF_TEMP_SENSORS_ON_ADC1]; /*!< bitmask if temperatures are valid. 0->valid, 1->invalid */ -} DATA_BLOCK_ADC_TEMPERATURE_s; - /** data block struct of minimum and maximum values */ typedef struct DATA_BLOCK_MIN_MAX { /* This struct needs to be at the beginning of every database entry. During @@ -332,9 +319,9 @@ typedef struct DATA_BLOCK_ERRORSTATE { 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 micConfigurationError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t micCellvoltageError[BS_NR_OF_STRINGS]; /*!< 0 -> no error, 1 -> error */ - uint8_t micCellTemperatureError[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 */ @@ -364,6 +351,7 @@ typedef struct DATA_BLOCK_ERRORSTATE { 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 */ } DATA_BLOCK_ERRORSTATE_s; /** data block struct of contactor feedback */ @@ -380,8 +368,12 @@ typedef struct DATA_BLOCK_INTERLOCK_FEEDBACK { /* 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 interlockFeedback; /*!< feedback of interlock, without contactors */ + DATA_BLOCK_HEADER_s header; /*!< Data block header */ + uint8_t interlockFeedback_IL_STATE; /*!< feedback of interlock, connected to pin */ + float interlockVoltageFeedback_IL_HS_VS_mV; /*!< voltage feedback of interlock, connected to ADC input 2 */ + float interlockVoltageFeedback_IL_LS_VS_mV; /*!< voltage feedback of interlock, connected to ADC input 3 */ + float interlockCurrentFeedback_IL_HS_CS_mA; /*!< current feedback of interlock, connected to ADC input 4 */ + float interlockCurrentFeedback_IL_LS_CS_mA; /*!< current feedback of interlock, connected to ADC input 5 */ } DATA_BLOCK_INTERLOCK_FEEDBACK_s; /** data block struct of sof limits */ @@ -556,6 +548,25 @@ typedef struct DATA_BLOCK_INSULATION_MONITORING { uint8_t testImcParameterConfiguration; /*!< 0 = NotWarning, 1 = Warning */ } DATA_BLOCK_INSULATION_MONITORING_s; +/** data block struct for the I2C humidity/temperature sensor */ +typedef struct DATA_BLOCK_HTSEN { + /* 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 */ + int16_t temperature_ddegC; + uint8_t humidity_perc; +} DATA_BLOCK_HTSEN_s; + +/** data block struct of internal ADC voltage measurement */ +typedef struct DATA_BLOCK_ADC_VOLTAGE { + /* 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 */ + float adc1ConvertedVoltages_mV[ADC_ADC1_MAX_NR_CHANNELS]; /*!< voltages measured by the internal ADC ADC1 */ +} DATA_BLOCK_ADC_VOLTAGE_s; + /** data block struct for the database built-in self-test */ typedef struct DATA_BLOCK_DUMMY_FOR_SELF_TEST { /* This struct needs to be at the beginning of every database entry. During diff --git a/src/app/engine/config/diag_cfg.c b/src/app/engine/config/diag_cfg.c index fb58777b..60b366f7 100644 --- a/src/app/engine/config/diag_cfg.c +++ b/src/app/engine/config/diag_cfg.c @@ -43,7 +43,7 @@ * @file diag_cfg.c * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2021-09-29 (date of last update) * @ingroup ENGINE_CONFIGURATION * @prefix DIAG * @@ -83,7 +83,7 @@ /*========== Macros and Definitions =========================================*/ /** value of #DIAG_ID_MAX (as a define for the pre-processor) */ -#define DIAG_ID_MAX_FOR_INIT (72u) +#define DIAG_ID_MAX_FOR_INIT (73u) static_assert(DIAG_ID_MAX_FOR_INIT == (uint16_t)DIAG_ID_MAX, "Both values need to be identical."); @@ -116,8 +116,8 @@ DIAG_ID_CFG_s DIAG_ID_cfg[] = { {DIAG_ID_FLASHCHECKSUM, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_FATAL_ERROR, DIAG_NO_DELAY, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_DummyCallback}, {DIAG_ID_SYSTEMMONITORING, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_FATAL_ERROR, DIAG_NO_DELAY, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorSystemMonitoring}, {DIAG_ID_CONFIGASSERT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_FATAL_ERROR, DIAG_NO_DELAY, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_DummyCallback}, - /* TODO: reactivate interlock feedback when HW ready */ - {DIAG_ID_INTERLOCK_FEEDBACK, DIAG_ERROR_INTERLOCK_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_INTERLOCK_ms, DIAG_RECORDING_DISABLED, DIAG_EVALUATION_DISABLED, DIAG_ErrorInterlock}, + + {DIAG_ID_INTERLOCK_FEEDBACK, DIAG_ERROR_INTERLOCK_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_INTERLOCK_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorInterlock}, {DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_MSL, DIAG_ERROR_VOLTAGE_SENSITIVITY_MSL, DIAG_FATAL_ERROR, DIAG_DELAY_OVERVOLTAGE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorOvervoltage}, {DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_ERROR_VOLTAGE_SENSITIVITY_RSL, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorOvervoltage}, @@ -164,10 +164,10 @@ 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_MIC_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_LTC_PEC, DIAG_ERROR_LTC_PEC_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_MIC_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_LTC_MUX, DIAG_ERROR_LTC_MUX_SENSITIVITY, DIAG_FATAL_ERROR, DIAG_DELAY_MIC_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, - {DIAG_ID_LTC_CONFIG, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_FATAL_ERROR, DIAG_DELAY_MIC_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorLtc}, + {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}, /* Communication events */ @@ -185,12 +185,12 @@ DIAG_ID_CFG_s DIAG_ID_cfg[] = { {DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE_SPREAD, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_PlausibilityCheck}, {DIAG_ID_PLAUSIBILITY_CELL_TEMP, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_PlausibilityCheck}, {DIAG_ID_PLAUSIBILITY_CELL_TEMPERATURE_SPREAD, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_PlausibilityCheck}, - {DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorMeasurementIc}, - {DIAG_ID_MEASUREMENT_IC_CELL_TEMPERATURE_MEAS_ERROR, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorMeasurementIc}, - {DIAG_ID_BASE_CELL_VOLTAGE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorMeasurementIc}, - {DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorMeasurementIc}, - {DIAG_ID_BASE_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorMeasurementIc}, - {DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorMeasurementIc}, + {DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfe}, + {DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfe}, + {DIAG_ID_BASE_CELL_VOLTAGE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfe}, + {DIAG_ID_REDUNDANCY0_CELL_VOLTAGE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfe}, + {DIAG_ID_BASE_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfe}, + {DIAG_ID_REDUNDANCY0_CELL_TEMPERATURE_MESUREMENT_TIMEOUT, DIAG_ERROR_SENSITIVITY_FIRST_EVENT, DIAG_WARNING, DIAG_DELAY_DISCARDED, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorAfe}, {DIAG_ID_DEEP_DISCHARGE_DETECTED, DIAG_ERROR_SENSITIVITY_HIGH, DIAG_FATAL_ERROR, DIAG_DELAY_DEEP_DISCHARGE_ms, DIAG_RECORDING_ENABLED, DIAG_EVALUATION_ENABLED, DIAG_ErrorDeepDischarge}, @@ -206,6 +206,7 @@ DIAG_ID_CFG_s DIAG_ID_cfg[] = { {DIAG_ID_INSULATION_ERROR, DIAG_ERROR_SENSITIVITY_HIGH, 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}, /* clang-format on */ }; diff --git a/src/app/engine/config/diag_cfg.h b/src/app/engine/config/diag_cfg.h index 19576645..cb2582af 100644 --- a/src/app/engine/config/diag_cfg.h +++ b/src/app/engine/config/diag_cfg.h @@ -43,7 +43,7 @@ * @file diag_cfg.h * @author foxBMS Team * @date 2019-11-28 (date of creation) - * @updated 2021-07-29 (date of last update) + * @updated 2021-10-19 (date of last update) * @ingroup ENGINE_CONFIGURATION * @prefix DIAG * @@ -117,8 +117,8 @@ #define DIAG_DELAY_TEMPERATURE_ms (1000u) /** delay for overcurrent errors */ #define DIAG_DELAY_OVERCURRENT_ms (100u) -/** delay for mic related errors */ -#define DIAG_DELAY_MIC_ms (100u) +/** delay for AFE related errors */ +#define DIAG_DELAY_AFE_ms (100u) /** delay for can timing error */ #define DIAG_DELAY_CAN_TIMING_ms (200u) /** delay for energy counting/coulomb counting timing error */ @@ -167,8 +167,8 @@ typedef enum DIAG_ID { DIAG_ID_CAN_EC_RESPONDING, DIAG_ID_CURRENT_SENSOR_RESPONDING, DIAG_ID_PLAUSIBILITY_CELL_VOLTAGE, - DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, - DIAG_ID_MEASUREMENT_IC_CELL_TEMPERATURE_MEAS_ERROR, + 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, @@ -226,7 +226,8 @@ typedef enum DIAG_ID { DIAG_ID_INSULATION_MEASUREMENT_INVALID, DIAG_ID_INSULATION_ERROR, DIAG_ID_INSULATION_GROUND_ERROR, - DIAG_ID_MAX, /**< MAX indicator - do not change */ + DIAG_ID_I2C_PEX_ERROR, /**< general error with the port expanders */ + DIAG_ID_MAX, /**< MAX indicator - do not change */ } DIAG_ID_e; /** diagnosis check result (event) */ @@ -272,9 +273,9 @@ typedef enum DIAG_IMPACT_LEVEL { /** diagnosis severity level */ typedef enum DIAG_SEVERITY_LEVEL { - DIAG_FATAL_ERROR, - DIAG_WARNING, - DIAG_INFO, + DIAG_FATAL_ERROR, /*!< severity level fatal error */ + DIAG_WARNING, /*!< severity level warning */ + DIAG_INFO, /*!< severity level info */ } DIAG_SEVERITY_LEVEL_e; /** diagnosis recording activation */ diff --git a/src/app/engine/diag/cbs/diag_cbs.h b/src/app/engine/diag/cbs/diag_cbs.h index b1ba5d11..c7389b8d 100644 --- a/src/app/engine/diag/cbs/diag_cbs.h +++ b/src/app/engine/diag/cbs/diag_cbs.h @@ -43,7 +43,7 @@ * @file diag_cbs.h * @author foxBMS Team * @date 2021-02-17 (date of creation) - * @updated 2021-06-09 (date of last update) + * @updated 2021-09-29 (date of last update) * @ingroup ENGINE * @prefix DIAG * @@ -287,13 +287,13 @@ extern void DIAG_ErrorLtc( uint32_t stringNumber); /** - * @brief diagnosis callback function for measurement IC related events + * @brief diagnosis callback function for AFE 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 event occurred */ -extern void DIAG_ErrorMeasurementIc( +extern void DIAG_ErrorAfe( DIAG_ID_e ch_id, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, @@ -405,6 +405,19 @@ extern void DIAG_Insulation( const DIAG_DATABASE_SHIM_s *const kpkDiagShim, uint32_t data); +/** + * @brief diagnosis callback function for I2C port expander 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_I2cPex( + 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_mic.c b/src/app/engine/diag/cbs/diag_cbs_afe.c similarity index 91% rename from src/app/engine/diag/cbs/diag_cbs_mic.c rename to src/app/engine/diag/cbs/diag_cbs_afe.c index 8bf71f1c..d34e9469 100644 --- a/src/app/engine/diag/cbs/diag_cbs_mic.c +++ b/src/app/engine/diag/cbs/diag_cbs_afe.c @@ -40,7 +40,7 @@ */ /** - * @file diag_cbs_mic.c + * @file diag_cbs_afe.c * @author foxBMS Team * @date 2021-02-17 (date of creation) * @updated 2021-02-17 (date of last update) @@ -65,7 +65,7 @@ /*========== Static Function Implementations ================================*/ /*========== Extern Function Implementations ================================*/ -extern void DIAG_ErrorMeasurementIc( +extern void DIAG_ErrorAfe( DIAG_ID_e ch_id, DIAG_EVENT_e event, const DIAG_DATABASE_SHIM_s *const kpkDiagShim, @@ -75,19 +75,19 @@ extern void DIAG_ErrorMeasurementIc( FAS_ASSERT(kpkDiagShim != NULL_PTR); FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS); - if (ch_id == DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR) { + if (ch_id == DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->micCellvoltageError[stringNumber] = 0; + kpkDiagShim->pTableError->afeCellvoltageError[stringNumber] = 0; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->micCellvoltageError[stringNumber] = 1; + kpkDiagShim->pTableError->afeCellvoltageError[stringNumber] = 1; } - } else if (ch_id == DIAG_ID_MEASUREMENT_IC_CELL_TEMPERATURE_MEAS_ERROR) { + } else if (ch_id == DIAG_ID_AFE_CELL_TEMPERATURE_MEAS_ERROR) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->micCellTemperatureError[stringNumber] = 0; + kpkDiagShim->pTableError->afeCellTemperatureError[stringNumber] = 0; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->micCellTemperatureError[stringNumber] = 1; + kpkDiagShim->pTableError->afeCellTemperatureError[stringNumber] = 1; } } else if (ch_id == DIAG_ID_BASE_CELL_VOLTAGE_MESUREMENT_TIMEOUT) { if (event == DIAG_EVENT_RESET) { diff --git a/src/app/engine/diag/cbs/diag_cbs_i2c.c b/src/app/engine/diag/cbs/diag_cbs_i2c.c new file mode 100644 index 00000000..65f51fd6 --- /dev/null +++ b/src/app/engine/diag/cbs/diag_cbs_i2c.c @@ -0,0 +1,87 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file diag_cbs_i2c.c + * @author foxBMS Team + * @date 2021-09-29 (date of creation) + * @updated 2021-09-29 (date of last update) + * @ingroup ENGINE + * @prefix DIAG + * + * @brief Diagnosis callbacks for I2C errors + */ + +/*========== Includes =======================================================*/ +#include "diag_cbs.h" + +/*========== Macros and Definitions =========================================*/ + +/*========== Static Constant and Variable Definitions =======================*/ + +/*========== Extern Constant and Variable Definitions =======================*/ + +/*========== Static Function Prototypes =====================================*/ + +/*========== Static Function Implementations ================================*/ + +/*========== Extern Function Implementations ================================*/ +extern void DIAG_I2cPex( + DIAG_ID_e ch_id, + DIAG_EVENT_e event, + const DIAG_DATABASE_SHIM_s *const kpkDiagShim, + 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); + (void)data; /* data is unused */ + + if (ch_id == DIAG_ID_I2C_PEX_ERROR) { + if (event == DIAG_EVENT_RESET) { + kpkDiagShim->pTableError->i2cPexError = 0; + } + if (event == DIAG_EVENT_NOT_OK) { + kpkDiagShim->pTableError->i2cPexError = 1; + } + } +} + +/*========== Externalized Static Function Implementations (Unit Test) =======*/ diff --git a/src/app/engine/diag/cbs/diag_cbs_ltc.c b/src/app/engine/diag/cbs/diag_cbs_ltc.c index f79ec520..647579bd 100644 --- a/src/app/engine/diag/cbs/diag_cbs_ltc.c +++ b/src/app/engine/diag/cbs/diag_cbs_ltc.c @@ -98,10 +98,10 @@ extern void DIAG_ErrorLtc( } } else if (ch_id == DIAG_ID_LTC_CONFIG) { if (event == DIAG_EVENT_RESET) { - kpkDiagShim->pTableError->micConfigurationError[stringNumber] = 0; + kpkDiagShim->pTableError->afeConfigurationError[stringNumber] = 0; } if (event == DIAG_EVENT_NOT_OK) { - kpkDiagShim->pTableError->micConfigurationError[stringNumber] = 1; + kpkDiagShim->pTableError->afeConfigurationError[stringNumber] = 1; } } else if (ch_id == DIAG_ID_OPEN_WIRE) { if (event == DIAG_EVENT_RESET) { diff --git a/src/app/engine/sys/sys.c b/src/app/engine/sys/sys.c index 02253ffe..d670f39e 100644 --- a/src/app/engine/sys/sys.c +++ b/src/app/engine/sys/sys.c @@ -43,7 +43,7 @@ * @file sys.c * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-06-24 (date of last update) + * @updated 2021-10-12 (date of last update) * @ingroup ENGINE * @prefix SYS * @@ -196,7 +196,6 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { SYS_STATE_REQUEST_e stateRequest = SYS_STATE_NO_REQUEST; SBC_STATEMACHINE_e sbcState = SBC_STATEMACHINE_UNDEFINED; - ILCK_STATEMACH_e interlockState = ILCK_STATEMACH_UNDEFINED; STD_RETURN_TYPE_e balancingInitializationState = STD_OK; BAL_RETURN_TYPE_e balancingGlobalEnableState = BAL_ERROR; STD_RETURN_TYPE_e bmsState = STD_NOT_OK; @@ -248,7 +247,7 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { sbcState = SBC_GetState(&sbc_stateMcuSupervisor); if (sbcState == SBC_STATEMACHINE_RUNNING) { pSystemState->timer = SYS_FSM_SHORT_TIME; - pSystemState->state = SYS_STATEMACH_SYSTEM_BIST; + pSystemState->state = SYS_STATEMACH_INITIALIZE_CAN; pSystemState->substate = SYS_ENTRY; break; } else { @@ -265,6 +264,15 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { } } break; + + /**************************** INITIALIZE CAN TRANSCEIVER ****************************/ + case SYS_STATEMACH_INITIALIZE_CAN: + CAN_Initialize(); + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->state = SYS_STATEMACH_SYSTEM_BIST; + pSystemState->substate = SYS_ENTRY; + break; + /**************************** EXECUTE STARTUP BIST **********************************/ case SYS_STATEMACH_SYSTEM_BIST: SYS_SAVELASTSTATES(pSystemState); @@ -291,34 +299,11 @@ static STD_RETURN_TYPE_e SYS_RunStateMachine(SYS_STATE_s *pSystemState) { /****************************INITIALIZE INTERLOCK*************************************/ case SYS_STATEMACH_INITIALIZE_INTERLOCK: SYS_SAVELASTSTATES(pSystemState); - - if (pSystemState->substate == SYS_ENTRY) { - ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST); - pSystemState->timer = SYS_FSM_SHORT_TIME; - pSystemState->substate = SYS_WAIT_INITIALIZATION_INTERLOCK; - pSystemState->initializationTimeout = 0; - break; - } else if (pSystemState->substate == SYS_WAIT_INITIALIZATION_INTERLOCK) { - interlockState = ILCK_GetState(); - if (interlockState == ILCK_STATEMACH_WAIT_FIRST_REQUEST) { - ILCK_SetStateRequest(ILCK_STATE_OPEN_REQUEST); - pSystemState->timer = SYS_FSM_SHORT_TIME; - pSystemState->state = SYS_STATEMACH_INITIALIZE_BALANCING; - pSystemState->substate = SYS_ENTRY; - break; - } else { - if (pSystemState->initializationTimeout > - (SYS_STATEMACH_INITIALIZATION_TIMEOUT_MS / SYS_TASK_CYCLE_CONTEXT_MS)) { - pSystemState->timer = SYS_FSM_SHORT_TIME; - pSystemState->state = SYS_STATEMACH_ERROR; - pSystemState->substate = SYS_ILCK_INIT_ERROR; - break; - } - pSystemState->timer = SYS_FSM_SHORT_TIME; - pSystemState->initializationTimeout++; - break; - } - } + ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST); + pSystemState->timer = SYS_FSM_SHORT_TIME; + pSystemState->state = SYS_STATEMACH_INITIALIZE_BALANCING; + pSystemState->substate = SYS_ENTRY; + pSystemState->initializationTimeout = 0; break; /****************************INITIALIZE CONTACTORS*************************************/ diff --git a/src/app/engine/sys/sys.h b/src/app/engine/sys/sys.h index 733c1172..a1221407 100644 --- a/src/app/engine/sys/sys.h +++ b/src/app/engine/sys/sys.h @@ -43,7 +43,7 @@ * @file sys.h * @author foxBMS Team * @date 2020-02-24 (date of creation) - * @updated 2021-05-19 (date of last update) + * @updated 2021-10-12 (date of last update) * @ingroup ENGINE * @prefix SYS * @@ -104,6 +104,7 @@ typedef enum SYS_STATEMACH { SYS_STATEMACH_SYSTEM_BIST, /*!< run a built-in self-test */ SYS_STATEMACH_INITIALIZED, /*!< */ SYS_STATEMACH_INITIALIZE_SBC, /*!< */ + SYS_STATEMACH_INITIALIZE_CAN, /*!< initialize CAN module */ SYS_STATEMACH_INITIALIZE_INTERLOCK, /*!< */ SYS_STATEMACH_INITIALIZE_CONTACTORS, /*!< */ SYS_STATEMACH_INITIALIZE_BALANCING, /*!< */ diff --git a/src/app/engine/wscript b/src/app/engine/wscript index 45d499f5..4b678dbc 100644 --- a/src/app/engine/wscript +++ b/src/app/engine/wscript @@ -61,10 +61,11 @@ 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_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_mic.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"), os.path.join("diag", "cbs", "diag_cbs_sbc.c"), @@ -111,7 +112,7 @@ def build(bld): os.path.join("..", "task", "config"), os.path.join("..", "task", "ftask"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) target = f"{bld.env.APPNAME.lower()}-engine" cflags = bld.env.CFLAGS_FOXBMS diff --git a/src/app/main/include/config/version_cfg.h b/src/app/main/include/config/version_cfg.h index b55c1fbd..0f50beb2 100644 --- a/src/app/main/include/config/version_cfg.h +++ b/src/app/main/include/config/version_cfg.h @@ -43,7 +43,7 @@ * @file version_cfg.h * @author foxBMS Team * @date 2021-07-14 (date of creation) - * @updated 2021-07-15 (date of last update) + * @updated 2021-10-19 (date of last update) * @ingroup GENERAL * @prefix NONE * @@ -75,14 +75,15 @@ /** struct type that describes the version information of the system */ typedef struct VERSION { - const bool underVersionControl; - const bool isDirty; - const uint8_t major; - const uint8_t minor; - const uint8_t patch; - const uint16_t distanceFromLastRelease; - const char commitHash[VERSION_STRUCT_MAXIMUM_COMMIT_HASH_LENGTH]; - const char gitRemote[VERSION_STRUCT_MAXIMUM_REMOTE_STRING_LENGTH]; + 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 */ + const uint8_t minor; /*!< minor release version */ + const uint8_t patch; /*!< patch release version */ + const uint16_t distanceFromLastRelease; /*!< distance in commits from the last tagged release in version control */ + const char commitHash[VERSION_STRUCT_MAXIMUM_COMMIT_HASH_LENGTH]; /*!< hash of the last commit */ + const char gitRemote + [VERSION_STRUCT_MAXIMUM_REMOTE_STRING_LENGTH]; /*!< address of the git remote linked in the repository */ } VERSION_s; /*========== Extern Constant and Variable Declarations ======================*/ diff --git a/src/app/main/include/general.h b/src/app/main/include/general.h index 2c97f895..3fb149fa 100644 --- a/src/app/main/include/general.h +++ b/src/app/main/include/general.h @@ -72,6 +72,12 @@ */ #define LARGEST_PIN_NUMBER (31u) +/** + * @brief maximum number of channels measured by the ADC1 + * @details Checked in the datasheet 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 diff --git a/src/app/main/linker_script_hex.cmd b/src/app/main/linker_script_hex.cmd index f21c44d6..b44587c1 100644 --- a/src/app/main/linker_script_hex.cmd +++ b/src/app/main/linker_script_hex.cmd @@ -1,4 +1,4 @@ -/* 8d9bd9b48faac520addc03aa338f05d6 */ +/* 1e95347e3c6ca5cd1478a000445e3de0 */ ROMS { VECTORS : origin=0x00000000 length=0x00000020 diff --git a/src/app/main/main.c b/src/app/main/main.c index 9986a2c7..c79b2dc0 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c @@ -43,7 +43,7 @@ * @file main.c * @author foxBMS Team * @date 2019-08-27 (date of creation) - * @updated 2021-08-06 (date of last update) + * @updated 2021-10-08 (date of last update) * @ingroup GENERAL * @prefix TODO * @@ -56,21 +56,22 @@ #include "main.h" #include "HL_can.h" +#include "HL_etpwm.h" #include "HL_gio.h" +#include "HL_het.h" +#include "HL_pinmux.h" #include "HL_spi.h" #include "HL_sys_core.h" #include "adc.h" -#include "can.h" #include "checksum.h" -#include "contactor.h" #include "diag.h" #include "dma.h" #include "foxmath.h" +#include "i2c.h" +#include "led.h" #include "masterinfo.h" -#include "meas.h" #include "os.h" -#include "sps.h" /*========== Macros and Definitions =========================================*/ @@ -86,15 +87,17 @@ int main(void) { MINFO_SetResetSource(getResetSource()); /* Get reset source and clear respective flags */ _enable_IRQ_interrupt_(); + muxInit(); gioInit(); canInit(); spiInit(); - CONT_Initialize(); - SPS_Initialize(); - MEAS_Initialize(); + adcInit(); + hetInit(); + etpwmInit(); + LED_SetDebugLED(); + I2C_Initialize(); DMA_Initialize(); DIAG_Initialize(&diag_device); - CAN_Initialize(); MATH_StartupSelfTest(); OS_InitializeOperatingSystem(); diff --git a/src/app/main/wscript b/src/app/main/wscript index bb8dfb51..77a4da39 100644 --- a/src/app/main/wscript +++ b/src/app/main/wscript @@ -66,7 +66,9 @@ def build(bld): os.path.join("..", "driver", "contactor"), os.path.join("..", "driver", "dma"), os.path.join("..", "driver", "foxmath"), + os.path.join("..", "driver", "i2c"), os.path.join("..", "driver", "io"), + os.path.join("..", "driver", "led"), os.path.join("..", "driver", "meas"), os.path.join("..", "driver", "spi"), os.path.join("..", "driver", "sps"), @@ -77,7 +79,7 @@ def build(bld): os.path.join("..", "task", "os"), os.path.join("..", "task", "config"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS use = [ f"{bld.env.APPNAME.lower()}-application", diff --git a/src/app/task/config/ftask_cfg.c b/src/app/task/config/ftask_cfg.c index e587cf62..f7a06aae 100644 --- a/src/app/task/config/ftask_cfg.c +++ b/src/app/task/config/ftask_cfg.c @@ -43,7 +43,7 @@ * @file ftask_cfg.c * @author foxBMS Team * @date 2019-08-26 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup TASK_CONFIGURATION * @prefix FTSK * @@ -62,13 +62,18 @@ #include "bal.h" #include "bms.h" #include "can.h" +#include "contactor.h" #include "database.h" #include "diag.h" #include "dma.h" #include "fram.h" +#include "htsensor.h" +#include "i2c.h" #include "imd.h" #include "interlock.h" +#include "led.h" #include "meas.h" +#include "pex.h" #include "redundancy.h" #include "sbc.h" #include "sof.h" @@ -156,15 +161,23 @@ extern void FTSK_InitializeUserCodePreCyclicTasks(void) { /* user code */ SYS_RETURN_TYPE_e sys_retVal = SYS_ILLEGAL_REQUEST; - /* Set pin linked to debug LED as output */ - hetREG1->DIR |= (uint32)((uint32)1U << 1U); - /* Init Sys */ sys_retVal = SYS_SetStateRequest(SYS_STATE_INIT_REQUEST); /* Init FRAM */ FRAM_Initialize(); + /* Init port expander */ + PEX_Initialize(); + + /* Set 3rd PE pin to activate temperature/humidity sensor */ + PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER3, PEX_PIN00); + PEX_SetPin(PEX_PORT_EXPANDER3, PEX_PIN00); + + CONT_Initialize(); + SPS_Initialize(); + (void)MEAS_Initialize(); /* cast to void as the return value is unused */ + /* Initialize redundancy module */ (void)MRC_Initialize(); @@ -174,6 +187,9 @@ extern void FTSK_InitializeUserCodePreCyclicTasks(void) { * always be #SYS_OK. Therefore we trap otherwise. */ FAS_ASSERT(sys_retVal == SYS_OK); + + /* System started correctly -> Start toggling of debug LED */ + LED_SetToggleTime(LED_NORMAL_OPERATION_ON_OFF_TIME_ms); } extern void FTSK_RunUserCodeCyclic1ms(void) { @@ -192,14 +208,16 @@ extern void FTSK_RunUserCodeCyclic10ms(void) { SYS_Trigger(&sys_state); BMS_Trigger(); ILCK_Trigger(); - ADC_Control(); /* TODO: check for shared SPI */ + ADC_Control(); SPS_Ctrl(); CAN_MainFunction(); SOF_Calculation(); ALGO_MonitorExecutionTime(); SBC_Trigger(&sbc_stateMcuSupervisor); + PEX_Trigger(); + HTSEN_Trigger(); if (cnt == TASK_10MS_COUNTER_FOR_50MS) { - MRC_ValidateMicMeasurement(); + MRC_ValidateAfeMeasurement(); MRC_ValidatePackMeasurement(); cnt = 0; } @@ -221,6 +239,7 @@ extern void FTSK_RunUserCodeCyclic100ms(void) { BAL_Trigger(); IMD_Trigger(); + LED_Trigger(); ftsk_cyclic100msCounter++; } diff --git a/src/app/task/wscript b/src/app/task/wscript index 184e289f..44c88aa6 100644 --- a/src/app/task/wscript +++ b/src/app/task/wscript @@ -76,12 +76,17 @@ def build(bld): os.path.join("..", "driver", "contactor"), os.path.join("..", "driver", "dma"), os.path.join("..", "driver", "fram"), + os.path.join("..", "driver", "htsensor"), + os.path.join("..", "driver", "i2c"), os.path.join("..", "driver", "imd"), os.path.join("..", "driver", "imd", "bender", "iso165c"), os.path.join("..", "driver", "imd", "bender", "iso165c", "config"), os.path.join("..", "driver", "interlock"), os.path.join("..", "driver", "io"), + os.path.join("..", "driver", "led"), os.path.join("..", "driver", "meas"), + os.path.join("..", "driver", "pex"), + os.path.join("..", "driver", "pwm"), os.path.join("..", "driver", "sbc"), os.path.join("..", "driver", "sbc", "fs8x_driver"), os.path.join("..", "driver", "spi"), @@ -94,7 +99,7 @@ def build(bld): os.path.join("..", "engine", "sys"), os.path.join("..", "main", "include"), ] - includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_MEASUREMENT_IC) + includes.extend(bld.env.INCLUDES_OPERATING_SYSTEM + bld.env.INCLUDES_AFE) cflags = bld.env.CFLAGS_FOXBMS target = f"{bld.env.APPNAME.lower()}-task" diff --git a/src/os/freertos/include/FreeRTOSConfig.h b/src/os/freertos/include/FreeRTOSConfig.h index b7c7a4c4..292e1c04 100644 --- a/src/os/freertos/include/FreeRTOSConfig.h +++ b/src/os/freertos/include/FreeRTOSConfig.h @@ -62,7 +62,9 @@ #define configUSE_MALLOC_FAILED_HOOK ( 0 ) #define configCHECK_FOR_STACK_OVERFLOW ( 0 ) +#define configRECORD_STACK_HIGH_ADDRESS ( 1 ) +#define configAPPLICATION_ALLOCATED_HEAP ( 0 ) #define configSUPPORT_STATIC_ALLOCATION ( 1 ) #define configSUPPORT_DYNAMIC_ALLOCATION ( 0 ) diff --git a/tests/axivion/architecture.gxl b/tests/axivion/architecture.gxl index c7627247..28e8b3be 100644 --- a/tests/axivion/architecture.gxl +++ b/tests/axivion/architecture.gxl @@ -140,7 +140,7 @@ - Measurement IC + Analog Front-End 515b9069-5530-4897-9777-6af92794f278 diff --git a/tests/axivion/architecture_hierarchy_belongs_to_layout.gvl b/tests/axivion/architecture_hierarchy_belongs_to_layout.gvl new file mode 100644 index 00000000..f3f5f700 --- /dev/null +++ b/tests/axivion/architecture_hierarchy_belongs_to_layout.gvl @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/axivion/ci_check_freshness_of_architecture_svg.py b/tests/axivion/ci_check_freshness_of_architecture_svg.py new file mode 100644 index 00000000..05e00666 --- /dev/null +++ b/tests/axivion/ci_check_freshness_of_architecture_svg.py @@ -0,0 +1,135 @@ +#!/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®" + +"""This script is intended for CI in order to check if the architecture is recent + +It will check the change date of the architecture SVG in the documentation and +of all files that constitute input to this file and fail if the architecture +SVG is not newer (or at least equally) old as the other files. + +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 sys + +from git import Repo + + +def get_git_change_date(filename): + """extract the commit date of a file as datetime from git""" + repo = Repo(filename, search_parent_directories=True) + extracted_date = repo.git.log("-1", "--date=short", "--pretty=%at", filename) + timestamp = datetime.datetime.fromtimestamp(int(extracted_date)) + logging.debug(f"extracted timestamp from file {filename}: {timestamp}") + return timestamp + + +def main(): + """This script checks the recentness of the architecture svg""" + 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) + + print("Searching for the file change dates.") + + basepath = "" + file_architecture = os.path.abspath( + os.path.join(basepath, "tests", "axivion", "architecture.gxl") + ) + file_layout = os.path.abspath( + os.path.join( + basepath, "tests", "axivion", "architecture_hierarchy_belongs_to_layout.gvl" + ) + ) + file_output = os.path.abspath( + os.path.join( + basepath, + "docs", + "software", + "architecture", + "img", + "axivion_architecture.svg", + ) + ) + + def get_date_helper(filename): + date = get_git_change_date(filename) + logging.debug(f"timestamp for {filename}: {date}") + return date + + date_architecture = get_date_helper(file_architecture) + date_layout = get_date_helper(file_layout) + date_output = get_date_helper(file_output) + + date_oldest_educt = max(date_architecture, date_layout) + logging.info(f"oldest educt is from {date_oldest_educt}.") + + logging.info(f"youngest product is from {date_output}.") + + if date_oldest_educt > date_output: + logging.error( + "The Axivion architecture SVG is not up to date. Refer " + "to the documentation on how to update the architecture SVG." + ) + sys.exit(1) + + print("Architecture SVG is up to date.") + + +if __name__ == "__main__": + main() diff --git a/tests/axivion/ci_config.json b/tests/axivion/ci_config.json index f1469695..3b75f56e 100644 --- a/tests/axivion/ci_config.json +++ b/tests/axivion/ci_config.json @@ -3,7 +3,7 @@ "Analysis-GlobalOptions": { "global_excludes": [ "C:/ti/*", - "*src/app/driver/mic/ltc/common/ltc_pec.*", + "*src/app/driver/afe/ltc/common/ltc_pec.*", "*src/app/driver/sbc/fs8x_driver/*", "*src/hal/*", "*src/os/*" diff --git a/tests/axivion/gravis_export_architecture_svg.py b/tests/axivion/gravis_export_architecture_svg.py new file mode 100644 index 00000000..48e481ee --- /dev/null +++ b/tests/axivion/gravis_export_architecture_svg.py @@ -0,0 +1,93 @@ +#!/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®" + +"""This script is intended to be loaded with gravis --script SCRIPTNAME. + +It replaces the architecture svg in the documentation with a new render +by calling gravis, loading the architecture description, applying the +layout that is stored under version control and exporting this view as a +replacement to the original architecture svg. +""" +import sys +import os + +try: + from bauhaus import gravis +except ImportError: + gravis = None + + +if __name__ == "__main__": + if not gravis: + print("script has to be run as a gravis startup script") + exit(1) # pylint: disable=consider-using-sys-exit; (Described in Axivion docs) + + if gravis.get_script_context() != "Startup": + gravis.warning( + f"wrong context: {gravis.get_script_context()} " + "(run this script with gravis --script SCRIPTNAME)" + ) + # just exit through sys (thus not terminating gravis according to + # gravis documentation) + sys.exit(1) + + # extract where the axivion directory is + basedir = 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_output_architecture = os.path.join( + basedir, + "..", + "..", + "docs", + "software", + "architecture", + "img", + "axivion_architecture.svg", + ) + + gravis.open_file(file_architecture) + gravis.open_view("Architecture", "hierarchy") + gravis.load_layout(file_layout) + gravis.update() + gravis.save_as_svg(file_output_architecture) + print(f"exported architecture to {file_output_architecture}") + exit(0) # pylint: disable=consider-using-sys-exit; (Described in Axivion docs) diff --git a/tests/axivion/mapping.gxl b/tests/axivion/mapping.gxl index 312f5691..41c9613a 100644 --- a/tests/axivion/mapping.gxl +++ b/tests/axivion/mapping.gxl @@ -23,10 +23,10 @@ - mic + afe - D src/app/driver/mic + D src/app/driver/afe @@ -752,7 +752,7 @@ - Measurement IC + Analog Front-End 515b9069-5530-4897-9777-6af92794f278 diff --git a/tests/axivion/rule_config_c.json b/tests/axivion/rule_config_c.json index b046b9c5..d347659c 100644 --- a/tests/axivion/rule_config_c.json +++ b/tests/axivion/rule_config_c.json @@ -212,7 +212,9 @@ "_active": true, "names": [ "*Notification", - "FTSK_TaskCreator*" + "_c_int00", + "vApplicationIdleHook", + "vApplicationStackOverflowHook" ] }, "FaultDetection-BadEnumValue": { @@ -625,7 +627,8 @@ "MisraC2012-1.2": { "_active": true, "exclude_in_macros": [ - "must_check_return" + "must_check_return", + "VERSION_INFORMATION" ] }, "MisraC2012-1.3": { @@ -1194,17 +1197,23 @@ ], "exit_critical_functions": [ "OS_ExitTaskCritical" - ] + ], + "nested_critical_regions": false }, "Parallelism-UnsafeVarAccess": { "_active": true, "enter_critical_functions": [ "OS_EnterTaskCritical" ], + "excluded_routines": [ + "FTSK_InitializeUserCodeEngine", + "FTSK_InitializeUserCodePreCyclicTasks" + ], "exit_critical_functions": [ "OS_ExitTaskCritical" ], "inspect_pointers": true, + "nested_critical_regions": false, "strict_priorities": true }, "SaveRFG": { @@ -1221,11 +1230,11 @@ } }, "_Format": "1.0", - "_Version": "7.2.0", + "_Version": "7.2.3", "_VersionNum": [ 7, 2, - 0, - 7204 + 3, + 7444 ] } diff --git a/tests/axivion/wrapper_make_race_pdfs.bat b/tests/axivion/wrapper_make_race_pdfs.bat index 02e922e3..ccd745ef 100644 --- a/tests/axivion/wrapper_make_race_pdfs.bat +++ b/tests/axivion/wrapper_make_race_pdfs.bat @@ -38,5 +38,5 @@ @SETLOCAL EnableExtensions EnableDelayedExpansion @SET BAUHAUS_CONFIG=%~dp0 -@SET PATH=%PATH%;C:\Bauhaus\7.2.0\doc\html\_downloads\309ace4c1e28cca5a965200324624eec +@SET PATH=%PATH%;C:\Bauhaus\7.2.3\doc\html\_downloads\309ace4c1e28cca5a965200324624eec @call make_race_pdfs.bat %USERPROFILE%\.bauhaus\localbuild\projects\foxbms-2.ir %USERPROFILE%\.bauhaus\localbuild\projects\foxbms-2.rfg diff --git a/tests/unit/app/application/bms/test_bms.c b/tests/unit/app/application/bms/test_bms.c index 40084230..5462a84e 100644 --- a/tests/unit/app/application/bms/test_bms.c +++ b/tests/unit/app/application/bms/test_bms.c @@ -43,7 +43,7 @@ * @file test_bms.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2021-10-05 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -52,6 +52,7 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe.h" #include "Mockbal.h" #include "Mockbattery_system_cfg.h" #include "Mockcontactor.h" @@ -59,8 +60,8 @@ #include "Mockdiag.h" #include "Mockfassert.h" #include "Mockinterlock.h" +#include "Mockled.h" #include "Mockmeas.h" -#include "Mockmic.h" #include "Mockos.h" #include "Mockplausibility.h" #include "Mocksoa.h" diff --git a/tests/unit/app/application/redundancy/test_redundancy.c b/tests/unit/app/application/redundancy/test_redundancy.c index ea85f8b3..f55c6f63 100644 --- a/tests/unit/app/application/redundancy/test_redundancy.c +++ b/tests/unit/app/application/redundancy/test_redundancy.c @@ -213,7 +213,7 @@ void testMRC_UpdateCellTemperatureValidationNullPointer(void) { } /* test main function */ -void testMRC_MicMeasurementValidationTickZeroNothingToDo(void) { +void testMRC_AfeMeasurementValidationTickZeroNothingToDo(void) { /* inject database entries into function */ injectDatabaseEntries(); @@ -226,5 +226,5 @@ void testMRC_MicMeasurementValidationTickZeroNothingToDo(void) { DIAG_Handler_IgnoreAndReturn(STD_OK); - TEST_ASSERT_PASS_ASSERT(TEST_ASSERT_EQUAL(STD_NOT_OK, MRC_ValidateMicMeasurement())); + TEST_ASSERT_PASS_ASSERT(TEST_ASSERT_EQUAL(STD_NOT_OK, MRC_ValidateAfeMeasurement())); } diff --git a/tests/unit/app/driver/adc/test_adc.c b/tests/unit/app/driver/adc/test_adc.c index bb109901..ddc21928 100644 --- a/tests/unit/app/driver/adc/test_adc.c +++ b/tests/unit/app/driver/adc/test_adc.c @@ -53,42 +53,13 @@ /*========== Includes =======================================================*/ #include "unity.h" -#include "Mockbeta.h" +#include "MockHL_adc.h" #include "Mockdatabase.h" -#include "Mockepcos_b57251v5103j060.h" #include "Mockfassert.h" -#include "Mockio.h" -#include "Mockspi.h" #include "adc.h" /*========== Definitions and Implementations for Unit Test ==================*/ -/* SPI data configuration struct for ADC communication */ -static const spiDAT1_t spi_kAdcDataConfig = { - /* struct is implemented in the TI HAL and uses uppercase true and false */ - .CS_HOLD = FALSE, /* The HW chip select signal is deactivated */ - .WDEL = TRUE, /* No delay will be inserted */ - .DFSEL = SPI_FMT_0, /* Data word format select */ - .CSNR = 0x0, /* Chip select (CS) number; 0x01h for CS[0] */ -}; - -/* SPI interface configuration for ADC communication */ -SPI_INTERFACE_CONFIG_s spi_adc0Interface = { - .channel = SPI_Interface3, - .pConfig = &spi_kAdcDataConfig, - .pNode = spiREG3, - .pGioPort = &(spiREG3->PC3), - .csPin = 4u, -}; - -/* SPI interface configuration for ADC communication */ -SPI_INTERFACE_CONFIG_s spi_adc1Interface = { - .channel = SPI_Interface3, - .pConfig = &spi_kAdcDataConfig, - .pNode = spiREG3, - .pGioPort = &(spiREG3->PC3), - .csPin = 5u, -}; /*========== Setup and Teardown =============================================*/ void setUp(void) { diff --git a/tests/unit/app/driver/mic/api/test_mic_plausibility.c b/tests/unit/app/driver/afe/api/test_afe_plausibility.c similarity index 74% rename from tests/unit/app/driver/mic/api/test_mic_plausibility.c rename to tests/unit/app/driver/afe/api/test_afe_plausibility.c index 972cce7d..4789d2d0 100644 --- a/tests/unit/app/driver/mic/api/test_mic_plausibility.c +++ b/tests/unit/app/driver/afe/api/test_afe_plausibility.c @@ -40,14 +40,14 @@ */ /** - * @file test_mic_plausibility.c + * @file test_afe_plausibility.c * @author foxBMS Team * @date 2020-07-13 (date of creation) * @updated 2021-01-15 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Tests for the mic_plausibility module + * @brief Tests for the afe_plausibility.c module * */ @@ -55,19 +55,19 @@ #include "unity.h" #include "Mocktsi.h" -#include "mic_plausibility.h" +#include "afe_plausibility.h" #include "test_assert_helper.h" /*========== Definitions and Implementations for Unit Test ==================*/ /** generic implementation of cell voltage limits */ -MIC_PLAUSIBILITY_VALUES_s testGenericLimits = { +AFE_PLAUSIBILITY_VALUES_s testGenericLimits = { .maximumPlausibleVoltage_mV = 5000, .minimumPlausibleVoltage_mV = 0, }; /** generic implementation of cell voltage limits with negative limits */ -MIC_PLAUSIBILITY_VALUES_s testGenericLimitsNegative = { +AFE_PLAUSIBILITY_VALUES_s testGenericLimitsNegative = { .maximumPlausibleVoltage_mV = 5000, .minimumPlausibleVoltage_mV = -5000, }; @@ -85,26 +85,26 @@ void tearDown(void) { * * limits may not be the same and must be ascending */ -void testMIC_PlausibilityCheckVoltageMeasurementRangeLimitSanity(void) { - MIC_PLAUSIBILITY_VALUES_s limitsEqualValues = { +void testAFE_PlausibilityCheckVoltageMeasurementRangeLimitSanity(void) { + AFE_PLAUSIBILITY_VALUES_s limitsEqualValues = { .maximumPlausibleVoltage_mV = 42, .minimumPlausibleVoltage_mV = 42, }; - MIC_PLAUSIBILITY_VALUES_s limitsDescendingOrder = { + AFE_PLAUSIBILITY_VALUES_s limitsDescendingOrder = { .maximumPlausibleVoltage_mV = INT16_MIN, .minimumPlausibleVoltage_mV = INT16_MAX, }; - MIC_PLAUSIBILITY_VALUES_s limitsAscendingOrder = { + AFE_PLAUSIBILITY_VALUES_s limitsAscendingOrder = { .maximumPlausibleVoltage_mV = INT16_MAX, .minimumPlausibleVoltage_mV = INT16_MIN, }; - TEST_ASSERT_FAIL_ASSERT(MIC_PlausibilityCheckVoltageMeasurementRange(0, limitsEqualValues)); - TEST_ASSERT_FAIL_ASSERT(MIC_PlausibilityCheckVoltageMeasurementRange(0, limitsDescendingOrder)); + TEST_ASSERT_FAIL_ASSERT(AFE_PlausibilityCheckVoltageMeasurementRange(0, limitsEqualValues)); + TEST_ASSERT_FAIL_ASSERT(AFE_PlausibilityCheckVoltageMeasurementRange(0, limitsDescendingOrder)); TEST_ASSERT_PASS_ASSERT( - TEST_ASSERT_EQUAL(STD_OK, MIC_PlausibilityCheckVoltageMeasurementRange(0, limitsAscendingOrder))); + TEST_ASSERT_EQUAL(STD_OK, AFE_PlausibilityCheckVoltageMeasurementRange(0, limitsAscendingOrder))); } /** equivalence input classes for voltage check: @@ -120,84 +120,84 @@ void testMIC_PlausibilityCheckVoltageMeasurementRangeLimitSanity(void) { * * positive values * * zero */ -void testMIC_PlausibilityCheckVoltageMeasurementRange(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_PlausibilityCheckVoltageMeasurementRange(3500, testGenericLimits)); - TEST_ASSERT_EQUAL(STD_NOT_OK, MIC_PlausibilityCheckVoltageMeasurementRange(INT16_MAX, testGenericLimits)); - TEST_ASSERT_EQUAL(STD_NOT_OK, MIC_PlausibilityCheckVoltageMeasurementRange(INT16_MIN, testGenericLimits)); - TEST_ASSERT_EQUAL(STD_OK, MIC_PlausibilityCheckVoltageMeasurementRange(0, testGenericLimits)); +void testAFE_PlausibilityCheckVoltageMeasurementRange(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_PlausibilityCheckVoltageMeasurementRange(3500, testGenericLimits)); + TEST_ASSERT_EQUAL(STD_NOT_OK, AFE_PlausibilityCheckVoltageMeasurementRange(INT16_MAX, testGenericLimits)); + TEST_ASSERT_EQUAL(STD_NOT_OK, AFE_PlausibilityCheckVoltageMeasurementRange(INT16_MIN, testGenericLimits)); + TEST_ASSERT_EQUAL(STD_OK, AFE_PlausibilityCheckVoltageMeasurementRange(0, testGenericLimits)); /* test around the upper threshold with #testGenericLimits */ TEST_ASSERT_EQUAL( STD_NOT_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimits.maximumPlausibleVoltage_mV + 1, testGenericLimits)); TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange(testGenericLimits.maximumPlausibleVoltage_mV, testGenericLimits)); + AFE_PlausibilityCheckVoltageMeasurementRange(testGenericLimits.maximumPlausibleVoltage_mV, testGenericLimits)); TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimits.maximumPlausibleVoltage_mV - 1, testGenericLimits)); /* test around the lower threshold with #testGenericLimits */ TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimits.minimumPlausibleVoltage_mV + 1, testGenericLimits)); TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange(testGenericLimits.minimumPlausibleVoltage_mV, testGenericLimits)); + AFE_PlausibilityCheckVoltageMeasurementRange(testGenericLimits.minimumPlausibleVoltage_mV, testGenericLimits)); TEST_ASSERT_EQUAL( STD_NOT_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimits.minimumPlausibleVoltage_mV - 1, testGenericLimits)); /* test around the upper threshold with #testGenericLimitsNegative */ TEST_ASSERT_EQUAL( STD_NOT_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimitsNegative.maximumPlausibleVoltage_mV + 1, testGenericLimitsNegative)); TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimitsNegative.maximumPlausibleVoltage_mV, testGenericLimitsNegative)); TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimitsNegative.maximumPlausibleVoltage_mV - 1, testGenericLimitsNegative)); /* test around the lower threshold with #testGenericLimitsNegative */ TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimitsNegative.minimumPlausibleVoltage_mV + 1, testGenericLimitsNegative)); TEST_ASSERT_EQUAL( STD_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimitsNegative.minimumPlausibleVoltage_mV, testGenericLimitsNegative)); TEST_ASSERT_EQUAL( STD_NOT_OK, - MIC_PlausibilityCheckVoltageMeasurementRange( + AFE_PlausibilityCheckVoltageMeasurementRange( testGenericLimitsNegative.minimumPlausibleVoltage_mV - 1, testGenericLimitsNegative)); } /** check if the function handles bad input from the API as expected */ -void testMIC_PlausibilityCheckTempMinMaxBadInputFromAPI(void) { +void testAFE_PlausibilityCheckTempMinMaxBadInputFromAPI(void) { TSI_GetMaximumPlausibleTemperature_ExpectAndReturn(50); TSI_GetMinimumPlausibleTemperature_ExpectAndReturn(51); - TEST_ASSERT_FAIL_ASSERT(MIC_PlausibilityCheckTempMinMax(0)); + TEST_ASSERT_FAIL_ASSERT(AFE_PlausibilityCheckTempMinMax(0)); TSI_GetMaximumPlausibleTemperature_ExpectAndReturn(50); TSI_GetMinimumPlausibleTemperature_ExpectAndReturn(50); - TEST_ASSERT_PASS_ASSERT(MIC_PlausibilityCheckTempMinMax(0)); + TEST_ASSERT_PASS_ASSERT(AFE_PlausibilityCheckTempMinMax(0)); TSI_GetMaximumPlausibleTemperature_ExpectAndReturn(-50); TSI_GetMinimumPlausibleTemperature_ExpectAndReturn(-51); - TEST_ASSERT_PASS_ASSERT(MIC_PlausibilityCheckTempMinMax(0)); + TEST_ASSERT_PASS_ASSERT(AFE_PlausibilityCheckTempMinMax(0)); TSI_GetMaximumPlausibleTemperature_ExpectAndReturn(51); TSI_GetMinimumPlausibleTemperature_ExpectAndReturn(50); - TEST_ASSERT_PASS_ASSERT(MIC_PlausibilityCheckTempMinMax(0)); + TEST_ASSERT_PASS_ASSERT(AFE_PlausibilityCheckTempMinMax(0)); } /** check if the function handles plausible and implausible input as expected @@ -208,17 +208,17 @@ void testMIC_PlausibilityCheckTempMinMaxBadInputFromAPI(void) { * on upper limit --> PASS * above upper limit --> FAIL */ -void testMIC_PlausibilityCheckTempMinMaxVerify(void) { +void testAFE_PlausibilityCheckTempMinMaxVerify(void) { const int16_t upperLimit_ddegC = 100; const int16_t lowerLimit_ddegC = -10; TSI_GetMaximumPlausibleTemperature_IgnoreAndReturn(upperLimit_ddegC); TSI_GetMinimumPlausibleTemperature_IgnoreAndReturn(lowerLimit_ddegC); - TEST_ASSERT_EQUAL(STD_NOT_OK, MIC_PlausibilityCheckTempMinMax(INT16_MIN)); - TEST_ASSERT_EQUAL(STD_NOT_OK, MIC_PlausibilityCheckTempMinMax(lowerLimit_ddegC - 1)); - TEST_ASSERT_EQUAL(STD_OK, MIC_PlausibilityCheckTempMinMax(lowerLimit_ddegC)); - TEST_ASSERT_EQUAL(STD_OK, MIC_PlausibilityCheckTempMinMax((lowerLimit_ddegC + upperLimit_ddegC) / 2)); - TEST_ASSERT_EQUAL(STD_OK, MIC_PlausibilityCheckTempMinMax(upperLimit_ddegC)); - TEST_ASSERT_EQUAL(STD_NOT_OK, MIC_PlausibilityCheckTempMinMax(upperLimit_ddegC + 1)); - TEST_ASSERT_EQUAL(STD_NOT_OK, MIC_PlausibilityCheckTempMinMax(INT16_MAX)); + TEST_ASSERT_EQUAL(STD_NOT_OK, AFE_PlausibilityCheckTempMinMax(INT16_MIN)); + TEST_ASSERT_EQUAL(STD_NOT_OK, AFE_PlausibilityCheckTempMinMax(lowerLimit_ddegC - 1)); + TEST_ASSERT_EQUAL(STD_OK, AFE_PlausibilityCheckTempMinMax(lowerLimit_ddegC)); + TEST_ASSERT_EQUAL(STD_OK, AFE_PlausibilityCheckTempMinMax((lowerLimit_ddegC + upperLimit_ddegC) / 2)); + TEST_ASSERT_EQUAL(STD_OK, AFE_PlausibilityCheckTempMinMax(upperLimit_ddegC)); + TEST_ASSERT_EQUAL(STD_NOT_OK, AFE_PlausibilityCheckTempMinMax(upperLimit_ddegC + 1)); + TEST_ASSERT_EQUAL(STD_NOT_OK, AFE_PlausibilityCheckTempMinMax(INT16_MAX)); } diff --git a/tests/unit/app/driver/mic/debug/default/api/test_debug_default_mic.c b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c similarity index 70% rename from tests/unit/app/driver/mic/debug/default/api/test_debug_default_mic.c rename to tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c index 2406d261..0f4fff56 100644 --- a/tests/unit/app/driver/mic/debug/default/api/test_debug_default_mic.c +++ b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe.c @@ -40,14 +40,14 @@ */ /** - * @file test_debug_default_mic.c + * @file test_debug_default_afe.c * @author foxBMS Team * @date 2020-05-25 (date of creation) * @updated 2020-06-17 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the debug_default_mic.c module + * @brief Test of the debug_default_afe.c module * */ @@ -60,11 +60,11 @@ #include "debug_default_cfg.h" -#include "mic.h" +#include "afe.h" -/* it's important to mention the implementation in debug_default_mic.c +/* it's important to mention the implementation in debug_default_afe.c here in order to test the correct implementation */ -TEST_FILE("debug_default_mic.c") +TEST_FILE("debug_default_afe.c") /*========== Definitions and Implementations for Unit Test ==================*/ @@ -78,48 +78,48 @@ void tearDown(void) { } /*========== Test Cases =====================================================*/ -void testMIC_TriggerIcAlwaysOk(void) { - FAKE_TriggerMeasurementIc_ExpectAndReturn(&fake_state, STD_OK); - TEST_ASSERT_EQUAL(STD_OK, MIC_TriggerIc()); +void testAFE_TriggerIcAlwaysOk(void) { + FAKE_TriggerAfe_ExpectAndReturn(&fake_state, STD_OK); + TEST_ASSERT_EQUAL(STD_OK, AFE_TriggerIc()); } -void testMIC_InitializeDummy(void) { +void testAFE_InitializeializeDummy(void) { FAKE_Initialize_ExpectAndReturn(STD_OK); - TEST_ASSERT_EQUAL(STD_OK, MIC_Init()); + TEST_ASSERT_EQUAL(STD_OK, AFE_Initialize()); } -void testMIC_StartMeasurement(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_StartMeasurement()); +void testAFE_StartMeasurement(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_StartMeasurement()); } -void testMIC_IsFirstMeasurementCycleFinished(void) { +void testAFE_IsFirstMeasurementCycleFinished(void) { FAKE_IsFirstMeasurementCycleFinished_ExpectAndReturn(&fake_state, STD_OK); - TEST_ASSERT_EQUAL(STD_OK, MIC_IsFirstMeasurementCycleFinished()); + TEST_ASSERT_EQUAL(STD_OK, AFE_IsFirstMeasurementCycleFinished()); } -void testMIC_RequestIoWrite(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestIoWrite(0)); +void testAFE_RequestIoWrite(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestIoWrite(0)); } -void testMIC_RequestIoRead(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestIoRead(0)); +void testAFE_RequestIoRead(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestIoRead(0)); } -void testMIC_RequestTemperatureRead(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestTemperatureRead(0)); +void testAFE_RequestTemperatureRead(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestTemperatureRead(0)); } -void testMIC_RequestBalancingFeedbackRead(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestBalancingFeedbackRead(0)); +void testAFE_RequestBalancingFeedbackRead(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestBalancingFeedbackRead(0)); } -void testMIC_RequestEepromRead(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestEepromRead(0)); +void testAFE_RequestEepromRead(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestEepromRead(0)); } -void testMIC_RequestEepromWrite(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestEepromWrite(0)); +void testAFE_RequestEepromWrite(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestEepromWrite(0)); } -void testMIC_RequestOpenWireCheck(void) { - TEST_ASSERT_EQUAL(STD_OK, MIC_RequestOpenWireCheck(0)); +void testAFE_RequestOpenWireCheck(void) { + TEST_ASSERT_EQUAL(STD_OK, AFE_RequestOpenWireCheck(0)); } diff --git a/tests/unit/app/driver/mic/debug/default/api/test_debug_default_mic_dma.c b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c similarity index 92% rename from tests/unit/app/driver/mic/debug/default/api/test_debug_default_mic_dma.c rename to tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c index cfbe4c6f..a03f3a90 100644 --- a/tests/unit/app/driver/mic/debug/default/api/test_debug_default_mic_dma.c +++ b/tests/unit/app/driver/afe/debug/default/api/test_debug_default_afe_dma.c @@ -40,14 +40,14 @@ */ /** - * @file test_debug_default_mic_dma.c + * @file test_debug_default_afe_dma.c * @author foxBMS Team * @date 2020-06-10 (date of creation) * @updated 2020-06-10 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the debug_default_mic_dma.c module + * @brief Test of the debug_default_afe_dma.c module * */ @@ -58,11 +58,11 @@ #include "debug_default_cfg.h" -#include "debug_default_mic_dma.h" +#include "debug_default_afe_dma.h" -/* it's important to mention the implementation in debug_default_mic_dma.c +/* it's important to mention the implementation in debug_default_afe_dma.c here in order to test the correct implementation */ -TEST_FILE("debug_default_mic_dma.c") +TEST_FILE("debug_default_afe_dma.c") /*========== Definitions and Implementations for Unit Test ==================*/ @@ -75,6 +75,6 @@ void tearDown(void) { /*========== Test Cases =====================================================*/ -void testMIC_DmaCallback(void) { - MIC_DmaCallback(0, 0); +void testAFE_DmaCallback(void) { + AFE_DmaCallback(0, 0); } diff --git a/tests/unit/app/driver/mic/debug/default/config/test_debug_default_cfg.c b/tests/unit/app/driver/afe/debug/default/config/test_debug_default_cfg.c similarity index 100% rename from tests/unit/app/driver/mic/debug/default/config/test_debug_default_cfg.c rename to tests/unit/app/driver/afe/debug/default/config/test_debug_default_cfg.c diff --git a/tests/unit/app/driver/mic/debug/default/test_debug_default.c b/tests/unit/app/driver/afe/debug/default/test_debug_default.c similarity index 99% rename from tests/unit/app/driver/mic/debug/default/test_debug_default.c rename to tests/unit/app/driver/afe/debug/default/test_debug_default.c index 7de8353d..d5b0dcda 100644 --- a/tests/unit/app/driver/mic/debug/default/test_debug_default.c +++ b/tests/unit/app/driver/afe/debug/default/test_debug_default.c @@ -47,7 +47,7 @@ * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the mic.c module + * @brief Test of the afe.c module * */ @@ -61,8 +61,8 @@ #include "battery_cell_cfg.h" #include "debug_default_cfg.h" +#include "afe.h" #include "debug_default.h" -#include "mic.h" /* it's important to mention the implementation in debug_default.c here in order to test the correct implementation */ @@ -237,5 +237,5 @@ void testFAKE_Initialize(void) { void testFAKE_IsFirstMeasurementCycleFinished(void) { } -void testFAKE_TriggerMeasurementIc(void) { +void testFAKE_TriggerAfe(void) { } diff --git a/tests/unit/app/driver/mic/ltc/6806/config/test_ltc_6806_cfg.c b/tests/unit/app/driver/afe/ltc/6806/config/test_ltc_6806_cfg.c similarity index 100% rename from tests/unit/app/driver/mic/ltc/6806/config/test_ltc_6806_cfg.c rename to tests/unit/app/driver/afe/ltc/6806/config/test_ltc_6806_cfg.c diff --git a/tests/unit/app/driver/mic/ltc/6806/test_ltc_6806.c b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c similarity index 97% rename from tests/unit/app/driver/mic/ltc/6806/test_ltc_6806.c rename to tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c index 1c6bd13f..dafb65d1 100644 --- a/tests/unit/app/driver/mic/ltc/6806/test_ltc_6806.c +++ b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806.c @@ -43,7 +43,7 @@ * @file test_ltc_6806.c * @author foxBMS Team * @date 2020-07-13 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-10-04 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,15 +53,16 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe_plausibility.h" #include "Mockdatabase.h" #include "Mockdiag.h" #include "Mockdma.h" #include "Mockfassert.h" #include "Mockio.h" -#include "Mockltc_mic_dma.h" +#include "Mockltc_afe_dma.h" #include "Mockltc_pec.h" -#include "Mockmic_plausibility.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockspi.h" #include "ltc_6806_cfg.h" diff --git a/tests/unit/app/driver/mic/ltc/6806/test_ltc_6806_pec_in_arrays.c b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c similarity index 97% rename from tests/unit/app/driver/mic/ltc/6806/test_ltc_6806_pec_in_arrays.c rename to tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c index 5d6a7607..5b70fd21 100644 --- a/tests/unit/app/driver/mic/ltc/6806/test_ltc_6806_pec_in_arrays.c +++ b/tests/unit/app/driver/afe/ltc/6806/test_ltc_6806_pec_in_arrays.c @@ -43,7 +43,7 @@ * @file test_ltc_6806_pec_in_arrays.c * @author foxBMS Team * @date 2020-12-16 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-10-04 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,15 +53,16 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe_plausibility.h" #include "Mockdatabase.h" #include "Mockdiag.h" #include "Mockdma.h" #include "Mockfassert.h" #include "Mockio.h" #include "Mockltc_6806_cfg.h" -#include "Mockltc_mic_dma.h" -#include "Mockmic_plausibility.h" +#include "Mockltc_afe_dma.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockspi.h" #include "ltc.h" diff --git a/tests/unit/app/driver/mic/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 similarity index 100% rename from tests/unit/app/driver/mic/ltc/6813-1/config/test_ltc_6813-1_cfg.c rename to tests/unit/app/driver/afe/ltc/6813-1/config/test_ltc_6813-1_cfg.c diff --git a/tests/unit/app/driver/mic/ltc/6813-1/test_ltc_6813-1.c b/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c similarity index 97% rename from tests/unit/app/driver/mic/ltc/6813-1/test_ltc_6813-1.c rename to tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c index df11f48e..499086de 100644 --- a/tests/unit/app/driver/mic/ltc/6813-1/test_ltc_6813-1.c +++ b/tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1.c @@ -43,7 +43,7 @@ * @file test_ltc_6813-1.c * @author foxBMS Team * @date 2020-03-30 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,15 +53,16 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe_plausibility.h" #include "Mockdatabase.h" #include "Mockdiag.h" #include "Mockdma.h" #include "Mockfassert.h" #include "Mockio.h" -#include "Mockltc_mic_dma.h" +#include "Mockltc_afe_dma.h" #include "Mockltc_pec.h" -#include "Mockmic_plausibility.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockspi.h" #include "Mocktsi.h" diff --git a/tests/unit/app/driver/mic/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 similarity index 98% rename from tests/unit/app/driver/mic/ltc/6813-1/test_ltc_6813-1_pec_in_arrays.c rename to tests/unit/app/driver/afe/ltc/6813-1/test_ltc_6813-1_pec_in_arrays.c index 68326eb9..4f2cdb29 100644 --- a/tests/unit/app/driver/mic/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 @@ -43,7 +43,7 @@ * @file test_ltc_6813-1_pec_in_arrays.c * @author foxBMS Team * @date 2020-03-30 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,14 +53,15 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe_plausibility.h" #include "Mockdatabase.h" #include "Mockdiag.h" #include "Mockdma.h" #include "Mockfassert.h" #include "Mockio.h" -#include "Mockltc_mic_dma.h" -#include "Mockmic_plausibility.h" +#include "Mockltc_afe_dma.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockspi.h" #include "Mocktsi.h" diff --git a/tests/unit/app/driver/mic/ltc/api/test_ltc_mic.c b/tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c similarity index 94% rename from tests/unit/app/driver/mic/ltc/api/test_ltc_mic.c rename to tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c index 93458f4b..070b989f 100644 --- a/tests/unit/app/driver/mic/ltc/api/test_ltc_mic.c +++ b/tests/unit/app/driver/afe/ltc/api/test_ltc_afe.c @@ -40,14 +40,14 @@ */ /** - * @file test_ltc_mic.c + * @file test_ltc_afe.c * @author foxBMS Team * @date 2020-05-25 (date of creation) * @updated 2020-06-17 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the mic.c module + * @brief Test of the afe.c module * */ @@ -60,11 +60,11 @@ #include "ltc_cfg.h" -#include "mic.h" +#include "afe.h" -/* it's important to mention the implementation in ltc_mic.c +/* it's important to mention the implementation in ltc_afe.c here in order to test the correct implementation */ -TEST_FILE("ltc_mic.c") +TEST_FILE("ltc_afe.c") /*========== Definitions and Implementations for Unit Test ==================*/ uint8_t ltc_RXPECbuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; @@ -86,7 +86,7 @@ uint8_t ltc_TXPECbuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; #define DMA_REQ_LINE_RX (DMA_REQ_LINE_SPI1_RX) /* - configuring dma control packets */ -g_dmaCTRL mic_ltcDmaControlPacketTx = { +g_dmaCTRL afe_ltcDmaControlPacketTx = { .SADD = 0, /* source address */ .DADD = 0, /* destination address */ .CHCTRL = 0U, /* channel control */ @@ -105,7 +105,7 @@ g_dmaCTRL mic_ltcDmaControlPacketTx = { .AUTOINIT = AUTOINIT_OFF, /* autoinit */ }; -g_dmaCTRL mic_ltcDmaControlPacketRx = { +g_dmaCTRL afe_ltcDmaControlPacketRx = { .SADD = 0, /* source address */ .DADD = 0, /* destination address */ .CHCTRL = 0U, /* channel control */ @@ -134,7 +134,7 @@ void tearDown(void) { } /*========== Test Cases =====================================================*/ -void testMIC_TriggerIcAlwaysReturnsSTD_OK(void) { +void testAFE_TriggerIcAlwaysReturnsSTD_OK(void) { LTC_Trigger_Expect(<c_stateBase); - TEST_ASSERT_EQUAL(STD_OK, MIC_TriggerIc()); + TEST_ASSERT_EQUAL(STD_OK, AFE_TriggerIc()); } diff --git a/tests/unit/app/driver/mic/nxp/common/config/test_nxp_mic_dma_cfg.c b/tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c similarity index 97% rename from tests/unit/app/driver/mic/nxp/common/config/test_nxp_mic_dma_cfg.c rename to tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c index 6048ad80..b379d674 100644 --- a/tests/unit/app/driver/mic/nxp/common/config/test_nxp_mic_dma_cfg.c +++ b/tests/unit/app/driver/afe/ltc/common/config/test_ltc_afe_dma_cfg.c @@ -40,7 +40,7 @@ */ /** - * @file test_nxp_mic_dma_cfg.c + * @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) @@ -54,7 +54,7 @@ /*========== Includes =======================================================*/ #include "unity.h" -#include "nxp_mic_dma_cfg.h" +#include "ltc_afe_dma_cfg.h" /*========== Definitions and Implementations for Unit Test ==================*/ diff --git a/tests/unit/app/driver/mic/ltc/common/test_ltc_mic_dma.c b/tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c similarity index 97% rename from tests/unit/app/driver/mic/ltc/common/test_ltc_mic_dma.c rename to tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c index 7137e882..562bfd39 100644 --- a/tests/unit/app/driver/mic/ltc/common/test_ltc_mic_dma.c +++ b/tests/unit/app/driver/afe/ltc/common/test_ltc_afe_dma.c @@ -40,14 +40,14 @@ */ /** - * @file test_ltc_mic_dma.c + * @file test_ltc_afe_dma.c * @author foxBMS Team * @date 2020-06-10 (date of creation) * @updated 2020-06-10 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the ltc_mic_dma.c module in ltc + * @brief Test of the ltc_afe_dma.c module in ltc * */ @@ -62,7 +62,7 @@ #include "ltc_cfg.h" #include "spi_cfg.h" -#include "ltc_mic_dma.h" +#include "ltc_afe_dma.h" /*========== Definitions and Implementations for Unit Test ==================*/ uint8_t ltc_RXPECbuffer[LTC_N_BYTES_FOR_DATA_TRANSMISSION] = {0}; @@ -115,7 +115,7 @@ LTC_STATE_s ltc_stateBase = { }; /* - configuring dma control packets */ -g_dmaCTRL mic_ltcDmaControlPacketTx = { +g_dmaCTRL afe_ltcDmaControlPacketTx = { .SADD = 0, /* source address */ .DADD = 0, /* destination address */ .CHCTRL = 0U, /* channel control */ @@ -134,7 +134,7 @@ g_dmaCTRL mic_ltcDmaControlPacketTx = { .AUTOINIT = AUTOINIT_OFF, /* autoinit */ }; -g_dmaCTRL mic_ltcDmaControlPacketRx = { +g_dmaCTRL afe_ltcDmaControlPacketRx = { .SADD = 0, /* source address */ .DADD = 0, /* destination address */ .CHCTRL = 0U, /* channel control */ diff --git a/tests/unit/app/driver/mic/maxim/common/api/test_mxm_mic.c b/tests/unit/app/driver/afe/maxim/common/api/test_mxm_afe.c similarity index 94% rename from tests/unit/app/driver/mic/maxim/common/api/test_mxm_mic.c rename to tests/unit/app/driver/afe/maxim/common/api/test_mxm_afe.c index 54185692..d1c7bdb8 100644 --- a/tests/unit/app/driver/mic/maxim/common/api/test_mxm_mic.c +++ b/tests/unit/app/driver/afe/maxim/common/api/test_mxm_afe.c @@ -40,14 +40,14 @@ */ /** - * @file test_mxm_mic.c + * @file test_mxm_afe.c * @author foxBMS Team * @date 2020-06-17 (date of creation) * @updated 2021-07-14 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the mic.c module + * @brief Test of the afe.c module * */ @@ -62,11 +62,11 @@ #include "Mockmxm_cfg.h" #include "Mockos.h" -#include "mic.h" +#include "afe.h" -/* it's important to mention the implementation in mxm_mic.c +/* it's important to mention the implementation in mxm_afe.c here in order to test the correct implementation */ -TEST_FILE("mxm_mic.c") +TEST_FILE("mxm_afe.c") /*========== Definitions and Implementations for Unit Test ==================*/ diff --git a/tests/unit/app/driver/mic/maxim/common/config/test_mxm_cfg.c b/tests/unit/app/driver/afe/maxim/common/config/test_mxm_cfg.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/config/test_mxm_cfg.c rename to tests/unit/app/driver/afe/maxim/common/config/test_mxm_cfg.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_17841b.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_17841b.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_17841b.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_1785x.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_1785x.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_1785x.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_1785x_tools.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_1785x_tools.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_1785x_tools.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_1785x_tools.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_mic_dma.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c similarity index 92% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_mic_dma.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c index dd6b247a..3614631f 100644 --- a/tests/unit/app/driver/mic/maxim/common/test_mxm_mic_dma.c +++ b/tests/unit/app/driver/afe/maxim/common/test_mxm_afe_dma.c @@ -40,14 +40,14 @@ */ /** - * @file test_mxm_mic_dma.c + * @file test_mxm_afe_dma.c * @author foxBMS Team * @date 2020-06-17 (date of creation) * @updated 2020-06-18 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the mic_dma.c module in the Maxim driver + * @brief Test of the afe_dma.c module in the Maxim driver * */ @@ -56,7 +56,7 @@ #include "MockHL_sys_dma.h" #include "Mockfassert.h" -#include "mxm_mic_dma.h" +#include "mxm_afe_dma.h" #include "test_assert_helper.h" /*========== Definitions and Implementations for Unit Test ==================*/ @@ -70,6 +70,6 @@ void tearDown(void) { /*========== Test Cases =====================================================*/ -void testMIC_DmaCallbackNotImplemented(void) { - TEST_ASSERT_FAIL_ASSERT(MIC_DmaCallback(0u, 0u)); +void testAFE_DmaCallbackNotImplemented(void) { + TEST_ASSERT_FAIL_ASSERT(AFE_DmaCallback(0u, 0u)); } diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_battery_management.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_battery_management.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_battery_management.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_battery_management.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_bitextract.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_bitextract.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_bitextract.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_bitextract.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_crc8.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_crc8.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_crc8.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_crc8.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_register_map.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_register_map.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_register_map.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_register_map.c diff --git a/tests/unit/app/driver/mic/maxim/common/test_mxm_registry.c b/tests/unit/app/driver/afe/maxim/common/test_mxm_registry.c similarity index 100% rename from tests/unit/app/driver/mic/maxim/common/test_mxm_registry.c rename to tests/unit/app/driver/afe/maxim/common/test_mxm_registry.c diff --git a/tests/unit/app/driver/mic/nxp/common/api/test_nxp_mic.c b/tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c similarity index 94% rename from tests/unit/app/driver/mic/nxp/common/api/test_nxp_mic.c rename to tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c index e772e965..af7c5743 100644 --- a/tests/unit/app/driver/mic/nxp/common/api/test_nxp_mic.c +++ b/tests/unit/app/driver/afe/nxp/common/api/test_nxp_afe.c @@ -40,14 +40,14 @@ */ /** - * @file test_nxp_mic.c + * @file test_nxp_afe.c * @author foxBMS Team * @date 2020-06-10 (date of creation) * @updated 2020-06-18 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the mic.c module + * @brief Test of the afe.c module * */ @@ -58,11 +58,11 @@ #include "MockHL_sys_dma.h" #include "Mockn775.h" -#include "mic.h" +#include "afe.h" -/* it's important to mention the implementation in nxp_mic.c +/* it's important to mention the implementation in nxp_afe.c here in order to test the correct implementation */ -TEST_FILE("nxp_mic.c") +TEST_FILE("nxp_afe.c") /*========== Definitions and Implementations for Unit Test ==================*/ diff --git a/tests/unit/app/driver/mic/nxp/common/config/test_n775_cfg.c b/tests/unit/app/driver/afe/nxp/common/config/test_n775_cfg.c similarity index 100% rename from tests/unit/app/driver/mic/nxp/common/config/test_n775_cfg.c rename to tests/unit/app/driver/afe/nxp/common/config/test_n775_cfg.c diff --git a/tests/unit/app/driver/mic/ltc/common/config/test_ltc_mic_dma_cfg.c b/tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c similarity index 97% rename from tests/unit/app/driver/mic/ltc/common/config/test_ltc_mic_dma_cfg.c rename to tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c index d258aa5c..0c76c9ab 100644 --- a/tests/unit/app/driver/mic/ltc/common/config/test_ltc_mic_dma_cfg.c +++ b/tests/unit/app/driver/afe/nxp/common/config/test_nxp_afe_dma_cfg.c @@ -40,7 +40,7 @@ */ /** - * @file test_ltc_mic_dma_cfg.c + * @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) @@ -54,7 +54,7 @@ /*========== Includes =======================================================*/ #include "unity.h" -#include "ltc_mic_dma_cfg.h" +#include "nxp_afe_dma_cfg.h" /*========== Definitions and Implementations for Unit Test ==================*/ diff --git a/tests/unit/app/driver/mic/nxp/common/test_n775.c b/tests/unit/app/driver/afe/nxp/common/test_n775.c similarity index 98% rename from tests/unit/app/driver/mic/nxp/common/test_n775.c rename to tests/unit/app/driver/afe/nxp/common/test_n775.c index 3990b34b..39a79bba 100644 --- a/tests/unit/app/driver/mic/nxp/common/test_n775.c +++ b/tests/unit/app/driver/afe/nxp/common/test_n775.c @@ -53,10 +53,10 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe.h" #include "Mockdatabase.h" #include "Mockfassert.h" -#include "Mockmic.h" -#include "Mocknxp_mic_dma.h" +#include "Mocknxp_afe_dma.h" #include "Mockos.h" #include "Mockspi.h" diff --git a/tests/unit/app/driver/mic/nxp/common/test_nxp_mic_dma.c b/tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c similarity index 96% rename from tests/unit/app/driver/mic/nxp/common/test_nxp_mic_dma.c rename to tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c index f7788073..dc8d3600 100644 --- a/tests/unit/app/driver/mic/nxp/common/test_nxp_mic_dma.c +++ b/tests/unit/app/driver/afe/nxp/common/test_nxp_afe_dma.c @@ -40,14 +40,14 @@ */ /** - * @file test_nxp_mic_dma.c + * @file test_nxp_afe_dma.c * @author foxBMS Team * @date 2020-06-10 (date of creation) * @updated 2020-06-10 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the mic_dma.c module in nxp + * @brief Test of the afe_dma.c module in nxp * */ @@ -58,7 +58,7 @@ #include "Mockn775.h" #include "Mockn775_cfg.h" -#include "nxp_mic_dma.h" +#include "nxp_afe_dma.h" /*========== Definitions and Implementations for Unit Test ==================*/ N775_STATE_s n775_state = { diff --git a/tests/unit/app/driver/can/test_can.c b/tests/unit/app/driver/can/test_can.c index 0b5d9b1f..cc058355 100644 --- a/tests/unit/app/driver/can/test_can.c +++ b/tests/unit/app/driver/can/test_can.c @@ -63,6 +63,7 @@ #include "Mockio.h" #include "Mockmcu.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockqueue.h" #include "Mocktest_can_mpu_prototype_queue_create_stub.h" @@ -114,11 +115,11 @@ static uint32_t can_dummy( } const CAN_MSG_TX_TYPE_s can_txMessages[] = { - {0x001, 8, 100, 0, CAN_LITTLE_ENDIAN, &can_dummy, NULL_PTR}, + {CAN1_NODE, 0x001, 8, 100, 0, CAN_LITTLE_ENDIAN, &can_dummy, NULL_PTR}, }; const CAN_MSG_RX_TYPE_s can_rxMessages[] = { - {0x002, 8, CAN_LITTLE_ENDIAN, &can_dummy}, + {CAN1_NODE, 0x002, 8, CAN_LITTLE_ENDIAN, &can_dummy}, }; const uint8_t can_txLength = sizeof(can_txMessages) / sizeof(can_txMessages[0]); @@ -164,35 +165,35 @@ void testDataSendNullPointerAsData(void) { } void testDataSendNoMessagePending(void) { - canBASE_t node = {0}; - uint8_t data = 0; + canBASE_t *pNode = CAN1_NODE; + uint8_t data = 0; canIsTxMessagePending_IgnoreAndReturn(1u); for (uint8_t i = 0u; i < 32; i++) { - TEST_ASSERT_EQUAL(STD_NOT_OK, CAN_DataSend(&node, i, &data)); + TEST_ASSERT_EQUAL(STD_NOT_OK, CAN_DataSend(pNode, i, &data)); } } void testDataSendMessagePending(void) { - canBASE_t node = {0}; - uint8_t data = 0; + canBASE_t *pNode = CAN1_NODE; + uint8_t data = 0; /* simulate first messageBox has pending message */ - canIsTxMessagePending_ExpectAndReturn(&node, 1, 0u); - canUpdateID_Expect(&node, 1, 0x20040000u); - canTransmit_ExpectAndReturn(&node, 1, &data, 0u); - TEST_ASSERT_EQUAL(STD_OK, CAN_DataSend(&node, 0x001, &data)); + canIsTxMessagePending_ExpectAndReturn(pNode, 1, 0u); + canUpdateID_Expect(pNode, 1, 0x20040000u); + canTransmit_ExpectAndReturn(pNode, 1, &data, 0u); + TEST_ASSERT_EQUAL(STD_OK, CAN_DataSend(pNode, 0x001, &data)); /* simulate messageBox until the highest to have no pending messages */ for (uint8_t messageBox = 1u; messageBox < (CAN_NR_OF_TX_MESSAGE_BOX - 1); messageBox++) { - canIsTxMessagePending_ExpectAndReturn(&node, messageBox, 1u); + canIsTxMessagePending_ExpectAndReturn(pNode, messageBox, 1u); } /* last message box has message pending */ - canIsTxMessagePending_ExpectAndReturn(&node, CAN_NR_OF_TX_MESSAGE_BOX - 1, 0u); - canUpdateID_Expect(&node, CAN_NR_OF_TX_MESSAGE_BOX - 1, 0x20040000u); - canTransmit_ExpectAndReturn(&node, CAN_NR_OF_TX_MESSAGE_BOX - 1, &data, 0u); - TEST_ASSERT_EQUAL(STD_OK, CAN_DataSend(&node, 0x001, &data)); + canIsTxMessagePending_ExpectAndReturn(pNode, CAN_NR_OF_TX_MESSAGE_BOX - 1, 0u); + canUpdateID_Expect(pNode, CAN_NR_OF_TX_MESSAGE_BOX - 1, 0x20040000u); + canTransmit_ExpectAndReturn(pNode, CAN_NR_OF_TX_MESSAGE_BOX - 1, &data, 0u); + TEST_ASSERT_EQUAL(STD_OK, CAN_DataSend(pNode, 0x001, &data)); } void testEnablePeriodic(void) { diff --git a/tests/unit/app/driver/config/test_fram_cfg.c b/tests/unit/app/driver/config/test_fram_cfg.c index 98e2bc7f..f20ad6c1 100644 --- a/tests/unit/app/driver/config/test_fram_cfg.c +++ b/tests/unit/app/driver/config/test_fram_cfg.c @@ -43,11 +43,11 @@ * @file test_fram_cfg.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2021-09-28 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Tests for the CAN driver + * @brief Tests for the FRAM driver * */ diff --git a/tests/unit/app/driver/config/test_pex_cfg.c b/tests/unit/app/driver/config/test_pex_cfg.c new file mode 100644 index 00000000..120749a8 --- /dev/null +++ b/tests/unit/app/driver/config/test_pex_cfg.c @@ -0,0 +1,71 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_pex_cfg.c + * @author foxBMS Team + * @date 2021-08-03 (date of creation) + * @updated 2021-09-29 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the port expander driver + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" + +#include "pex_cfg.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 588e2b18..5b0126d4 100644 --- a/tests/unit/app/driver/dma/test_dma.c +++ b/tests/unit/app/driver/dma/test_dma.c @@ -43,7 +43,7 @@ * @file test_dma.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-09-28 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -53,10 +53,11 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "MockHL_i2c.h" #include "MockHL_spi.h" #include "MockHL_sys_dma.h" +#include "Mockafe_dma.h" #include "Mockio.h" -#include "Mockmic_dma.h" #include "Mockspi.h" #include "dma.h" diff --git a/tests/unit/app/driver/htsensor/test_htsensor.c b/tests/unit/app/driver/htsensor/test_htsensor.c new file mode 100644 index 00000000..d3c6c42b --- /dev/null +++ b/tests/unit/app/driver/htsensor/test_htsensor.c @@ -0,0 +1,84 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_htsensor.c + * @author foxBMS Team + * @date 2021-08-05 (date of creation) + * @updated 2021-09-30 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the driver for the I2C humidity/temperature sensor + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "MockHL_i2c.h" +#include "MockHL_sys_dma.h" +#include "Mockdatabase.h" +#include "Mocki2c.h" +#include "Mockos.h" + +#include "htsensor.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +long FSYS_RaisePrivilege(void) { + return 0; +} + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +/** test the CRC8 function with known values */ +void testCalculateCrc8(void) { + uint8_t data[2] = {0}; + data[1u] = 0xEF; + data[0u] = 0xBE; + TEST_ASSERT_EQUAL(0x92, TEST_HTSEN_TestCalculateCrc8(data, 2u)); +} diff --git a/tests/unit/app/driver/i2c/test_i2c.c b/tests/unit/app/driver/i2c/test_i2c.c new file mode 100644 index 00000000..88233373 --- /dev/null +++ b/tests/unit/app/driver/i2c/test_i2c.c @@ -0,0 +1,81 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_i2c.c + * @author foxBMS Team + * @date 2021-07-23 (date of creation) + * @updated 2021-09-29 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the I2C module + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "MockHL_i2c.h" +#include "MockHL_sys_dma.h" +#include "Mockos.h" + +#include "i2c.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +long FSYS_RaisePrivilege(void) { + return 0; +} + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ + +/** I2C Initialize calls the HAL init function */ +void testI2c_Initialize(void) { + i2cInit_Expect(); + I2C_Initialize(); +} 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 new file mode 100644 index 00000000..bc703dfb --- /dev/null +++ b/tests/unit/app/driver/imd/bender/ir155/test_bender_ir155.c @@ -0,0 +1,68 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_bender_ir155.c + * @author foxBMS Team + * @date 2020-04-01 (date of creation) + * @updated 2020-04-01 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the Bender IR155 driver + * + */ + +/*========== Includes =======================================================*/ +#include "unity.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/imd/none/test_no-imd.c b/tests/unit/app/driver/imd/none/test_no-imd.c index 9011918f..64002b71 100644 --- a/tests/unit/app/driver/imd/none/test_no-imd.c +++ b/tests/unit/app/driver/imd/none/test_no-imd.c @@ -43,7 +43,7 @@ * @file test_no-imd.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2021-09-08 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -73,5 +73,5 @@ void tearDown(void) { /*========== Test Cases =====================================================*/ void testImdDummyFunctions(void) { DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - TEST_ASSERT_EQUAL(STD_OK, TEST_IMD_MeasureInsulation()); + TEST_ASSERT_EQUAL(STD_OK, TEST_NOIMD_MeasureInsulation()); } diff --git a/tests/unit/app/driver/interlock/test_interlock.c b/tests/unit/app/driver/interlock/test_interlock.c index db8d5bff..323600eb 100644 --- a/tests/unit/app/driver/interlock/test_interlock.c +++ b/tests/unit/app/driver/interlock/test_interlock.c @@ -43,7 +43,7 @@ * @file test_interlock.c * @author foxBMS Team * @date 2020-04-01 (date of creation) - * @updated 2020-04-01 (date of last update) + * @updated 2021-10-18 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -52,11 +52,14 @@ */ /*========== Includes =======================================================*/ +#include "general.h" + #include "unity.h" -#include "MockHL_gio.h" +#include "MockHL_het.h" #include "Mockdatabase.h" #include "Mockdiag.h" #include "Mockfassert.h" +#include "Mockio.h" #include "Mockos.h" #include "interlock_cfg.h" @@ -71,9 +74,9 @@ void setUp(void) { static ILCK_STATE_s ilck_state = { .timer = 0, .statereq = ILCK_STATE_NO_REQUEST, - .state = ILCK_STATEMACH_UNINITIALIZED, + .state = ILCK_STATEMACHINE_UNINITIALIZED, .substate = ILCK_ENTRY, - .laststate = ILCK_STATEMACH_UNINITIALIZED, + .laststate = ILCK_STATEMACHINE_UNINITIALIZED, .lastsubstate = ILCK_ENTRY, .triggerentry = 0, .ErrRequestCounter = 0, @@ -89,35 +92,14 @@ void tearDown(void) { void testILCK_GetState(void) { /* checks whether GetState returns the state (should be uninitialized when first called) */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_UNINITIALIZED, ILCK_GetState()); + TEST_ASSERT_EQUAL(ILCK_STATEMACHINE_UNINITIALIZED, ILCK_GetState()); } void testILCK_SetStateRequestLegalValuesILCK_STATE_INIT_REQUEST(void) { /* test legal value ILCK_STATE_INIT_REQUEST for the state-request */ OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST)); -} - -void testILCK_SetStateRequestLegalValuesILCK_STATE_OPEN_REQUEST(void) { - /* test legal value ILCK_STATE_OPEN_REQUEST for the state-request */ - OS_EnterTaskCritical_Expect(); - OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_OPEN_REQUEST)); -} - -void testILCK_SetStateRequestLegalValuesILCK_STATE_CLOSE_REQUEST(void) { - /* test legal value ILCK_STATE_CLOSE_REQUEST for the state-request */ - OS_EnterTaskCritical_Expect(); - OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_CLOSE_REQUEST)); -} - -void testILCK_SetStateRequestLegalValuesILCK_STATE_ERROR_REQUEST(void) { - /* test legal value ILCK_STATE_ERROR_REQUEST for the state-request */ - OS_EnterTaskCritical_Expect(); - OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_ERROR_REQUEST)); + TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); } void testILCK_SetStateRequestLegalValuesILCK_STATE_NO_REQUEST(void) { @@ -125,7 +107,7 @@ void testILCK_SetStateRequestLegalValuesILCK_STATE_NO_REQUEST(void) { OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); /* even though this value is legal, it will return illegal request */ - TEST_ASSERT_EQUAL(ILCK_ILLEGAL_REQUEST, ILCK_SetStateRequest(ILCK_STATE_NO_REQUEST)); + TEST_ASSERT_EQUAL(ILCK_ILLEGAL_REQUEST, ILCK_SetStateRequest(INT8_MAX)); } void testILCK_SetStateRequestIllegalValue(void) { @@ -137,19 +119,23 @@ void testILCK_SetStateRequestIllegalValue(void) { void testILCK_SetStateRequestDoubleInitializationWithoutStatemachine(void) { /* run initialization twice, but statemachine not in between */ + IO_SetPinDirectionToOutput_Ignore(); + IO_SetPinDirectionToInput_Ignore(); + IO_PinReset_Ignore(); OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST)); + TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_REQUEST_PENDING, ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST)); + TEST_ASSERT_EQUAL(ILCK_REQUEST_PENDING, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); } void testILCK_SetStateRequestDoubleInitialization(void) { /* run initialization twice and call statemachine between these requests */ OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST)); + + TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); /* This group is called by the reentrance check */ OS_EnterTaskCritical_Expect(); @@ -160,16 +146,17 @@ void testILCK_SetStateRequestDoubleInitialization(void) { OS_ExitTaskCritical_Expect(); /* This is the pin initialization */ - gioSetBit_Expect(ILCK_IO_REG, ILCK_INTERLOCK_CONTROL, 1u); - gioSetBit_Expect(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 0u); + IO_SetPinDirectionToOutput_Ignore(); + IO_SetPinDirectionToInput_Ignore(); + IO_PinReset_Ignore(); ILCK_Trigger(); - TEST_ASSERT_EQUAL(ILCK_STATEMACH_INITIALIZATION, ILCK_GetState()); + TEST_ASSERT_EQUAL(ILCK_STATEMACHINE_INITIALIZED, ILCK_GetState()); OS_EnterTaskCritical_Expect(); OS_ExitTaskCritical_Expect(); - TEST_ASSERT_EQUAL(ILCK_ALREADY_INITIALIZED, ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST)); + TEST_ASSERT_EQUAL(ILCK_ALREADY_INITIALIZED, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); } void testRunStatemachineWithoutRequest(void) { @@ -183,50 +170,35 @@ void testRunStatemachineWithoutRequest(void) { ILCK_Trigger(); - TEST_ASSERT_EQUAL(ILCK_STATEMACH_UNINITIALIZED, ILCK_GetState()); + TEST_ASSERT_EQUAL(ILCK_STATEMACHINE_UNINITIALIZED, ILCK_GetState()); } void testInitializeStatemachine(void) { /* run initialization */ /* since we are checking only for the statemachine passing through these states, we ignore all unnecessary functions */ + OS_EnterTaskCritical_Ignore(); OS_ExitTaskCritical_Ignore(); - gioSetBit_Ignore(); - gioGetBit_IgnoreAndReturn(0u); + IO_SetPinDirectionToOutput_Ignore(); + IO_SetPinDirectionToInput_Ignore(); + IO_PinReset_Ignore(); + + DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); DIAG_CheckEvent_IgnoreAndReturn(STD_OK); - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INIT_REQUEST)); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - TEST_ASSERT_EQUAL(ILCK_STATEMACH_INITIALIZATION, ILCK_GetState()); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - TEST_ASSERT_EQUAL(ILCK_STATEMACH_INITIALIZED, ILCK_GetState()); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } + TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_INITIALIZATION_REQUEST)); - TEST_ASSERT_EQUAL(ILCK_STATEMACH_WAIT_FIRST_REQUEST, ILCK_GetState()); + IO_PinGet_IgnoreAndReturn(0u); + DIAG_Handler_IgnoreAndReturn(DIAG_HANDLER_RETURN_OK); for (uint8_t i = 0u; i < 10; i++) { /* iterate calling this statemachine 10 times (one shorttime) */ ILCK_Trigger(); } - /* when we are initialized, the state-machine will stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_WAIT_FIRST_REQUEST, ILCK_GetState()); + TEST_ASSERT_EQUAL(ILCK_STATEMACHINE_INITIALIZED, ILCK_GetState()); } void testILCK_SetStateRequestIllegalValueAndThenRunStatemachine(void) { @@ -246,7 +218,7 @@ void testILCK_SetStateRequestIllegalValueAndThenRunStatemachine(void) { ILCK_Trigger(); /* Statemachine should stay uninitialized with illegal state request */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_UNINITIALIZED, ILCK_GetState()); + TEST_ASSERT_EQUAL(ILCK_STATEMACHINE_UNINITIALIZED, ILCK_GetState()); } void testILCK_GetInterlockFeedbackFeedbackOn(void) { @@ -256,9 +228,14 @@ void testILCK_GetInterlockFeedbackFeedbackOn(void) { OS_ExitTaskCritical_Ignore(); /* set the return value to 1, which means interlock on */ - gioGetBit_ExpectAndReturn(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 1u); + IO_PinSet_Ignore(); + IO_PinReset_Ignore(); + IO_PinGet_ExpectAndReturn(&ILCK_IO_REG_PORT->DIN, ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE, 0u); + /* gioGetBit_ExpectAndReturn(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 1u); */ + DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); + DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - TEST_ASSERT_EQUAL(ILCK_SWITCH_ON, ILCK_GetInterlockFeedback()); + TEST_ASSERT_EQUAL(ILCK_SWITCH_ON, TEST_ILCK_GetInterlockFeedback()); } void testILCK_GetInterlockFeedbackFeedbackOff(void) { @@ -267,184 +244,13 @@ void testILCK_GetInterlockFeedbackFeedbackOff(void) { OS_EnterTaskCritical_Ignore(); OS_ExitTaskCritical_Ignore(); + IO_PinSet_Ignore(); + IO_PinReset_Ignore(); /* set the return value to 0, which means interlock off */ - gioGetBit_ExpectAndReturn(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 0u); - - TEST_ASSERT_EQUAL(ILCK_SWITCH_OFF, ILCK_GetInterlockFeedback()); -} - -void testStateMachineTransitionWaitForRequestToOpen(void) { - /* ignore port functions and similar */ - OS_EnterTaskCritical_Ignore(); - OS_ExitTaskCritical_Ignore(); - gioSetBit_Ignore(); - gioGetBit_IgnoreAndReturn(0u); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - DIAG_CheckEvent_IgnoreAndReturn(STD_OK); - - /* configure the statemachine in wait for request and transition to open */ - static ILCK_STATE_s ilck_state = { - .timer = 0, - .statereq = ILCK_STATE_NO_REQUEST, - .state = ILCK_STATEMACH_WAIT_FIRST_REQUEST, - .substate = ILCK_ENTRY, - .laststate = ILCK_STATEMACH_INITIALIZED, - .lastsubstate = ILCK_ENTRY, - .triggerentry = 0, - .ErrRequestCounter = 0, - .counter = 0, - }; - TEST_ILCK_SetStateStruct(ilck_state); - - TEST_ASSERT_EQUAL(ILCK_STATEMACH_WAIT_FIRST_REQUEST, ILCK_GetState()); - - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_OPEN_REQUEST)); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* when we are initialized, the state-machine will stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_OPEN, ILCK_GetState()); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* check that we stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_OPEN, ILCK_GetState()); -} - -void testStateMachineTransitionWaitForRequestToClosed(void) { - /* ignore port functions and similar */ - OS_EnterTaskCritical_Ignore(); - OS_ExitTaskCritical_Ignore(); - gioSetBit_Ignore(); - gioGetBit_IgnoreAndReturn(0u); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - DIAG_CheckEvent_IgnoreAndReturn(STD_OK); - - /* configure the statemachine in wait for request and transition to closed */ - static ILCK_STATE_s ilck_state = { - .timer = 0, - .statereq = ILCK_STATE_NO_REQUEST, - .state = ILCK_STATEMACH_WAIT_FIRST_REQUEST, - .substate = ILCK_ENTRY, - .laststate = ILCK_STATEMACH_INITIALIZED, - .lastsubstate = ILCK_ENTRY, - .triggerentry = 0, - .ErrRequestCounter = 0, - .counter = 0, - }; - TEST_ILCK_SetStateStruct(ilck_state); - - TEST_ASSERT_EQUAL(ILCK_STATEMACH_WAIT_FIRST_REQUEST, ILCK_GetState()); - - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_CLOSE_REQUEST)); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* when we are initialized, the state-machine will stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_CLOSED, ILCK_GetState()); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* check that we stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_CLOSED, ILCK_GetState()); -} - -void testStateMachineTransitionOpenToClosed(void) { - /* ignore port functions and similar */ - OS_EnterTaskCritical_Ignore(); - OS_ExitTaskCritical_Ignore(); - gioSetBit_Ignore(); - gioGetBit_IgnoreAndReturn(0u); + IO_PinGet_ExpectAndReturn(&ILCK_IO_REG_PORT->DIN, ILCK_INTERLOCK_FEEDBACK_PIN_IL_STATE, 1u); + /* gioGetBit_ExpectAndReturn(ILCK_IO_REG, ILCK_INTERLOCK_FEEDBACK, 0u); */ + DATA_Read_1_DataBlock_IgnoreAndReturn(STD_OK); DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - DIAG_CheckEvent_IgnoreAndReturn(STD_OK); - - /* configure the statemachine in open and transition to closed */ - static ILCK_STATE_s ilck_state = { - .timer = 0, - .statereq = ILCK_STATE_NO_REQUEST, - .state = ILCK_STATEMACH_OPEN, - .substate = ILCK_ENTRY, - .laststate = ILCK_STATEMACH_WAIT_FIRST_REQUEST, - .lastsubstate = ILCK_ENTRY, - .triggerentry = 0, - .ErrRequestCounter = 0, - .counter = 0, - }; - TEST_ILCK_SetStateStruct(ilck_state); - - TEST_ASSERT_EQUAL(ILCK_STATEMACH_OPEN, ILCK_GetState()); - - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_CLOSE_REQUEST)); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* when we are initialized, the state-machine will stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_CLOSED, ILCK_GetState()); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* check that we stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_CLOSED, ILCK_GetState()); -} - -void testStateMachineTransitionClosedToOpen(void) { - /* ignore port functions and similar */ - OS_EnterTaskCritical_Ignore(); - OS_ExitTaskCritical_Ignore(); - gioSetBit_Ignore(); - gioGetBit_IgnoreAndReturn(0u); - DATA_Write_1_DataBlock_IgnoreAndReturn(STD_OK); - DIAG_CheckEvent_IgnoreAndReturn(STD_OK); - - /* configure the statemachine in closed and transition to open */ - static ILCK_STATE_s ilck_state = { - .timer = 0, - .statereq = ILCK_STATE_NO_REQUEST, - .state = ILCK_STATEMACH_CLOSED, - .substate = ILCK_ENTRY, - .laststate = ILCK_STATEMACH_WAIT_FIRST_REQUEST, - .lastsubstate = ILCK_ENTRY, - .triggerentry = 0, - .ErrRequestCounter = 0, - .counter = 0, - }; - TEST_ILCK_SetStateStruct(ilck_state); - - TEST_ASSERT_EQUAL(ILCK_STATEMACH_CLOSED, ILCK_GetState()); - - TEST_ASSERT_EQUAL(ILCK_OK, ILCK_SetStateRequest(ILCK_STATE_OPEN_REQUEST)); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - - /* when we are initialized, the state-machine will stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_OPEN, ILCK_GetState()); - - for (uint8_t i = 0u; i < 10; i++) { - /* iterate calling this statemachine 10 times (one shorttime) */ - ILCK_Trigger(); - } - /* check that we stay here */ - TEST_ASSERT_EQUAL(ILCK_STATEMACH_OPEN, ILCK_GetState()); + TEST_ASSERT_EQUAL(ILCK_SWITCH_OFF, TEST_ILCK_GetInterlockFeedback()); } diff --git a/tests/unit/app/driver/led/test_led.c b/tests/unit/app/driver/led/test_led.c new file mode 100644 index 00000000..9a7e590c --- /dev/null +++ b/tests/unit/app/driver/led/test_led.c @@ -0,0 +1,73 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_led.c + * @author foxBMS Team + * @date 2020-10-05 (date of creation) + * @updated 2020-10-05 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the led module + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "Mockio.h" +#include "Mockos.h" + +#include "led.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ + +void testDummyFunction() { +} diff --git a/tests/unit/app/driver/meas/test_meas.c b/tests/unit/app/driver/meas/test_meas.c index 1cccc0d3..6cfa9c03 100644 --- a/tests/unit/app/driver/meas/test_meas.c +++ b/tests/unit/app/driver/meas/test_meas.c @@ -53,8 +53,8 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe.h" #include "Mockltc.h" -#include "Mockmic.h" #include "meas.h" diff --git a/tests/unit/app/driver/pex/test_pex.c b/tests/unit/app/driver/pex/test_pex.c new file mode 100644 index 00000000..5b78ec10 --- /dev/null +++ b/tests/unit/app/driver/pex/test_pex.c @@ -0,0 +1,104 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_pex.c + * @author foxBMS Team + * @date 2021-09-29 (date of creation) + * @updated 2021-09-29 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the port expander module + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "MockHL_i2c.h" +#include "Mockdatabase.h" +#include "Mockdiag.h" +#include "Mocki2c.h" +#include "Mockos.h" +#include "Mockportmacro.h" + +#include "pex_cfg.h" + +#include "pex.h" +#include "test_assert_helper.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ + +long FSYS_RaisePrivilege(void) { + return 0; +} + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ + +void testModuleInterfacesWithInvalidValues(void) { + TEST_ASSERT_FAIL_ASSERT(PEX_SetPin(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_SetPin(PEX_PORT_EXPANDER1, 16u)); + + TEST_ASSERT_FAIL_ASSERT(PEX_ResetPin(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_ResetPin(PEX_PORT_EXPANDER1, 16u)); + + TEST_ASSERT_FAIL_ASSERT(PEX_GetPin(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_GetPin(PEX_PORT_EXPANDER1, 16u)); + + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinDirectionInput(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinDirectionInput(PEX_PORT_EXPANDER1, 16u)); + + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinDirectionOutput(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinDirectionOutput(PEX_PORT_EXPANDER1, 16u)); + + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinPolarityInverted(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinPolarityInverted(PEX_PORT_EXPANDER1, 16u)); + + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinPolarityRetained(5, PEX_PIN00)); + TEST_ASSERT_FAIL_ASSERT(PEX_SetPinPolarityRetained(PEX_PORT_EXPANDER1, 16u)); +} diff --git a/tests/unit/app/driver/pwm/test_pwm.c b/tests/unit/app/driver/pwm/test_pwm.c new file mode 100644 index 00000000..308bbaa2 --- /dev/null +++ b/tests/unit/app/driver/pwm/test_pwm.c @@ -0,0 +1,162 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_pwm.c + * @author foxBMS Team + * @date 2021-10-08 (date of creation) + * @updated 2021-10-08 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Tests for the PWM driver + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "MockHL_etpwm.h" + +#include "pwm.h" +#include "test_assert_helper.h" + +/*========== Definitions and Implementations for Unit Test ==================*/ +static uint8_t fsysRaisePrivilegeReturnValue = 0u; +long FSYS_RaisePrivilege(void) { + return fsysRaisePrivilegeReturnValue; +} + +/** wraps the duty cycle function for test + * + * The output duty cycle is tested against the value computed by the function. + * + * @param[in] timeBasePeriod This value will be injected as a time base period + * @param[in] dutyCycleIn This value will be passed as requested duty cycle in permill + * @param[in] dutyCycleOut The expected output duty cycle (in counts) + */ +void PWM_SetDutyCycle_Test(uint16_t timeBasePeriod, uint16_t dutyCycleIn, uint16_t dutyCycleOut) { + etpwm_config_reg_t etPwmConfig = {0}; + etPwmConfig.CONFIG_TBPRD = timeBasePeriod; + + etpwm1GetConfigValue_Expect(NULL_PTR, CurrentValue); + etpwm1GetConfigValue_IgnoreArg_config_reg(); + etpwm1GetConfigValue_ReturnThruPtr_config_reg(&etPwmConfig); + + etpwmSetCmpA_Expect(NULL_PTR, dutyCycleOut); + etpwmSetCmpA_IgnoreArg_etpwm(); + PWM_SetDutyCycle(dutyCycleIn); +} + +/** calculates the PWM counter value + * + * @param[in] timeBasePeriod This time base period will be assumed for the calculation + * @param[in] dutyCycle The requested duty cycle in permill + */ +uint16_t calculateCounterValue(uint16_t timeBasePeriod, uint16_t dutyCycle) { + /* retrieves the tuning value from the module */ + int16_t linearOffset = TEST_PWM_GetLinearOffset(); + + double correctedDutyCycle = ((double)dutyCycle + linearOffset); + if (correctedDutyCycle < 0) { + correctedDutyCycle = 0; + } + + /* bound to upper and lower threshold */ + if (correctedDutyCycle < 1) { + correctedDutyCycle = 1; + } + if (correctedDutyCycle > 999) { + correctedDutyCycle = 999; + } + + uint16_t counterSteps = (((double)timeBasePeriod * correctedDutyCycle) / 1000); + + return counterSteps; +} + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { + fsysRaisePrivilegeReturnValue = 0; +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ + +/** test that the start function calls etPWM API */ +void testPWM_StartPwm(void) { + /* an assertion should happen, when privileges cannot be raised */ + fsysRaisePrivilegeReturnValue = 1; + TEST_ASSERT_FAIL_ASSERT(PWM_StartPwm();) + + /* otherwise the API should be called */ + fsysRaisePrivilegeReturnValue = 0; + etpwmStartTBCLK_Expect(); + PWM_StartPwm(); +} + +/** test that the stop function calls etPWM API */ +void testPWM_StopPwm(void) { + /* an assertion should happen, when privileges cannot be raised */ + fsysRaisePrivilegeReturnValue = 1; + TEST_ASSERT_FAIL_ASSERT(PWM_StopPwm();) + + /* otherwise the API should be called */ + fsysRaisePrivilegeReturnValue = 0; + etpwmStopTBCLK_Expect(); + PWM_StopPwm(); +} + +/** tests the duty cycle function */ +void testPWM_SetDutyCycle(void) { + uint16_t timeBasePeriod = 999u; + for (uint16_t duty = 1u; duty <= 999; duty = duty + 10) { + PWM_SetDutyCycle_Test(timeBasePeriod, duty, calculateCounterValue(timeBasePeriod, duty)); + } + + timeBasePeriod = 4999; + uint16_t duty = 0u; + PWM_SetDutyCycle_Test(timeBasePeriod, duty, calculateCounterValue(timeBasePeriod, duty)); + for (uint16_t duty = 1u; duty <= 999; duty = duty + 10) { + PWM_SetDutyCycle_Test(timeBasePeriod, duty, calculateCounterValue(timeBasePeriod, duty)); + } +} diff --git a/tests/unit/app/driver/sps/test_sps.c b/tests/unit/app/driver/sps/test_sps.c index f705eb75..a0e1e7a5 100644 --- a/tests/unit/app/driver/sps/test_sps.c +++ b/tests/unit/app/driver/sps/test_sps.c @@ -43,7 +43,7 @@ * @file test_sps.c * @author foxBMS Team * @date 2020-10-28 (date of creation) - * @updated 2021-03-24 (date of last update) + * @updated 2021-10-01 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -59,6 +59,8 @@ #include "Mockio.h" #include "Mockmcu.h" #include "Mockos.h" +#include "Mockpex.h" +#include "Mockpex_cfg.h" #include "Mockspi.h" #include "Mockspi_cfg.h" #include "Mocksps_cfg.h" @@ -96,10 +98,17 @@ SPS_CHANNEL_STATE_s sps_channelStatus[SPS_NR_OF_AVAILABLE_SPS_CHANNELS] = { {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, - {SPS_CHANNEL_OFF, SPS_CHANNEL_OFF, 0.0f, SPS_AFF_GENERAL_IO, SPS_CHANNEL_ON_DEFAULT_THRESHOLD_mA}, +}; + +const SPS_CHANNEL_FEEDBACK_MAPPING_s sps_kChannelFeedbackMapping[SPS_NR_OF_AVAILABLE_SPS_CHANNELS] = { + {PEX_PORT_EXPANDER1, PEX_PIN00}, + {PEX_PORT_EXPANDER1, PEX_PIN01}, + {PEX_PORT_EXPANDER1, PEX_PIN02}, + {PEX_PORT_EXPANDER1, PEX_PIN03}, + {PEX_PORT_EXPANDER1, PEX_PIN04}, + {PEX_PORT_EXPANDER1, PEX_PIN05}, + {PEX_PORT_EXPANDER1, PEX_PIN06}, + {PEX_PORT_EXPANDER1, PEX_PIN07}, }; /*========== Setup and Teardown =============================================*/ @@ -137,7 +146,7 @@ void testSPS_RequestChannelStateSwitchOn(void) { } void testSPS_GetChannelFeedbackInvalidChannelIndex(void) { - TEST_ASSERT_FAIL_ASSERT(SPS_GetChannelFeedback(42u)); + TEST_ASSERT_FAIL_ASSERT(SPS_GetChannelCurrentFeedback(42u)); } void testSPS_GetChannelFeedbackChannelLow(void) { @@ -146,7 +155,7 @@ void testSPS_GetChannelFeedbackChannelLow(void) { sps_channelStatus[0].current_mA = 0; - TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelFeedback(0u)); + TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelCurrentFeedback(0u)); } void testSPS_GetChannelFeedbackChannelHigh(void) { @@ -155,7 +164,7 @@ void testSPS_GetChannelFeedbackChannelHigh(void) { sps_channelStatus[0].current_mA = 600.f; - TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelFeedback(0u)); + TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelCurrentFeedback(0u)); } void testSPS_GetChannelAffiliationInvalidIndex(void) { @@ -200,8 +209,8 @@ 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(11u, SPS_CHANNEL_ON)); - TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[11u].channelRequested); + TEST_ASSERT_PASS_ASSERT(SPS_RequestGeneralIOState(7u, SPS_CHANNEL_ON)); + TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested); } void testSPS_CtrlStartupProcedure(void) { @@ -435,10 +444,10 @@ void testContactorSwitchOnAndOff(void) { TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channelRequested); TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel); - TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[11u].channelRequested); - TEST_ASSERT_PASS_ASSERT(TEST_SPS_RequestChannelState(11u, SPS_CHANNEL_ON)); - TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[11u].channelRequested); - TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[11u].channel); + TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested); + TEST_ASSERT_PASS_ASSERT(TEST_SPS_RequestChannelState(7u, SPS_CHANNEL_ON)); + TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested); + TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel); /* cycle over one state that handles channels */ TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); @@ -450,7 +459,7 @@ void testContactorSwitchOnAndOff(void) { TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channel); TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[1u].channel); TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel); - TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[11u].channel); + TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel); /* switch off a first, second, third and fourth channel */ TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[0u].channelRequested); @@ -468,10 +477,10 @@ void testContactorSwitchOnAndOff(void) { TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channelRequested); TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[6u].channel); - TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[11u].channelRequested); - TEST_ASSERT_PASS_ASSERT(TEST_SPS_RequestChannelState(11u, SPS_CHANNEL_OFF)); - TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[11u].channelRequested); - TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[11u].channel); + TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channelRequested); + TEST_ASSERT_PASS_ASSERT(TEST_SPS_RequestChannelState(7u, SPS_CHANNEL_OFF)); + TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channelRequested); + TEST_ASSERT_EQUAL(SPS_CHANNEL_ON, sps_channelStatus[7u].channel); /* cycle over one state that handles channels */ TEST_SPS_SetSpsState(SPS_TRIGGER_CURRENT_MEASUREMENT); @@ -483,5 +492,24 @@ void testContactorSwitchOnAndOff(void) { TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[0u].channel); TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[1u].channel); TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[6u].channel); - TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[11u].channel); + TEST_ASSERT_EQUAL(SPS_CHANNEL_OFF, sps_channelStatus[7u].channel); +} + +/** test the states of PEX feedback function */ +void testSPS_GetChannelPexFeedback(void) { + /* report pin state 0 with normally open --> should report switch off */ + PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u); + TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, true)); + + /* report pin state 1 with normally open --> should report switch on */ + PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u); + TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, true)); + + /* report pin state 0 with normally closed --> should report switch on */ + PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 0u); + TEST_ASSERT_EQUAL(CONT_SWITCH_ON, SPS_GetChannelPexFeedback(0u, false)); + + /* report pin state 1 with normally closed --> should report switch off */ + PEX_GetPin_ExpectAndReturn(PEX_PORT_EXPANDER1, PEX_PIN00, 1u); + TEST_ASSERT_EQUAL(CONT_SWITCH_OFF, SPS_GetChannelPexFeedback(0u, false)); } diff --git a/tests/unit/app/engine/diag/cbs/test_diag_cbs_mic.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c similarity index 83% rename from tests/unit/app/engine/diag/cbs/test_diag_cbs_mic.c rename to tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c index d4f2f390..2fa5dfaa 100644 --- a/tests/unit/app/engine/diag/cbs/test_diag_cbs_mic.c +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_afe.c @@ -40,14 +40,14 @@ */ /** - * @file test_diag_cbs_mic.c + * @file test_diag_cbs_afe.c * @author foxBMS Team * @date 2021-02-17 (date of creation) * @updated 2021-02-17 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * - * @brief Test of the MIC diag handler implementation. + * @brief Test of the AFE diag handler implementation. * */ @@ -58,7 +58,7 @@ #include "diag_cbs.h" #include "test_assert_helper.h" -TEST_FILE("diag_cbs_mic.c") +TEST_FILE("diag_cbs_afe.c") /*========== Definitions and Implementations for Unit Test ==================*/ /** local copy of the #DATA_BLOCK_ERRORSTATE_s table */ @@ -89,12 +89,10 @@ void tearDown(void) { /*========== Test Cases =====================================================*/ /** tests invalid input values */ -void testDIAG_ErrorMeasurementIcInvalidInput(void) { - TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorMeasurementIc(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); +void testDIAG_ErrorAfeInvalidInput(void) { + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfe(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfe(DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, 42, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorAfe(DIAG_ID_AFE_CELL_VOLTAGE_MEAS_ERROR, DIAG_EVENT_OK, NULL_PTR, 0u)); TEST_ASSERT_FAIL_ASSERT( - DIAG_ErrorMeasurementIc(DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, 42, &diag_kpkDatabaseShim, 0u)); - TEST_ASSERT_FAIL_ASSERT( - DIAG_ErrorMeasurementIc(DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, DIAG_EVENT_OK, NULL_PTR, 0u)); - TEST_ASSERT_FAIL_ASSERT(DIAG_ErrorMeasurementIc( - DIAG_ID_MEASUREMENT_IC_CELL_VOLTAGE_MEAS_ERROR, DIAG_EVENT_OK, &diag_kpkDatabaseShim, BS_NR_OF_STRINGS)); + DIAG_ErrorAfe(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_i2c.c b/tests/unit/app/engine/diag/cbs/test_diag_cbs_i2c.c new file mode 100644 index 00000000..8677a212 --- /dev/null +++ b/tests/unit/app/engine/diag/cbs/test_diag_cbs_i2c.c @@ -0,0 +1,122 @@ +/** + * + * @copyright © 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®″ + * + */ + +/** + * @file test_diag_cbs_i2c.c + * @author foxBMS Team + * @date 2021-09-29 (date of creation) + * @updated 2021-09-29 (date of last update) + * @ingroup UNIT_TEST_IMPLEMENTATION + * @prefix TEST + * + * @brief Test of the I2C diag handler implementation. + * + */ + +/*========== Includes =======================================================*/ +#include "unity.h" +#include "Mockdiag_cfg.h" + +#include "diag_cbs.h" +#include "test_assert_helper.h" + +TEST_FILE("diag_cbs_i2c.c") + +/*========== Definitions and Implementations for Unit Test ==================*/ +/** local copy of the #DATA_BLOCK_ERRORSTATE_s table */ +static DATA_BLOCK_ERRORSTATE_s test_tableErrorFlags = {.header.uniqueId = DATA_BLOCK_ID_ERRORSTATE}; + +/** local copy of the #DATA_BLOCK_MOL_FLAG_s table */ +static DATA_BLOCK_MOL_FLAG_s test_tableMolFlags = {.header.uniqueId = DATA_BLOCK_ID_MOL_FLAG}; + +/** local copy of the #DATA_BLOCK_RSL_FLAG_s table */ +static DATA_BLOCK_RSL_FLAG_s test_tableRslFlags = {.header.uniqueId = DATA_BLOCK_ID_RSL_FLAG}; + +/** local copy of the #DATA_BLOCK_MSL_FLAG_s table */ +static DATA_BLOCK_MSL_FLAG_s test_tableMslFlags = {.header.uniqueId = DATA_BLOCK_ID_MSL_FLAG}; + +const DIAG_DATABASE_SHIM_s diag_kpkDatabaseShim = { + .pTableError = &test_tableErrorFlags, + .pTableMol = &test_tableMolFlags, + .pTableRsl = &test_tableRslFlags, + .pTableMsl = &test_tableMslFlags, +}; + +/*========== Setup and Teardown =============================================*/ +void setUp(void) { + diag_kpkDatabaseShim.pTableError->i2cPexError = 0; +} + +void tearDown(void) { +} + +/*========== Test Cases =====================================================*/ +void testDiagI2cPex(void) { + /* reset event sets the I2C in ok mode */ + DIAG_I2cPex(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_RESET, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(0, diag_kpkDatabaseShim.pTableError->i2cPexError); + /* ok event must not change the I2C state */ + DIAG_I2cPex(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(0, diag_kpkDatabaseShim.pTableError->i2cPexError); + + /* not ok event sets the i2c pex error back in not ok mode */ + DIAG_I2cPex(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_NOT_OK, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(1, diag_kpkDatabaseShim.pTableError->i2cPexError); + + /* reset event sets the i2c error back in ok mode */ + DIAG_I2cPex(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_RESET, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(0, diag_kpkDatabaseShim.pTableError->i2cPexError); +} + +/** test against invalid input */ +void testDIAG_I2cPexInvalidInput(void) { + TEST_ASSERT_FAIL_ASSERT(DIAG_I2cPex(DIAG_ID_MAX, DIAG_EVENT_OK, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_I2cPex(DIAG_ID_I2C_PEX_ERROR, 42, &diag_kpkDatabaseShim, 0u)); + TEST_ASSERT_FAIL_ASSERT(DIAG_I2cPex(DIAG_ID_I2C_PEX_ERROR, DIAG_EVENT_OK, NULL_PTR, 0u)); +} + +void testDIAG_I2cPexDoNothingOnWrongId(void) { + /* Use a wrong ID to make sure, that this does not alter the I2C entry */ + uint8_t testValue = 42; + diag_kpkDatabaseShim.pTableError->i2cPexError = testValue; + DIAG_I2cPex(DIAG_ID_CELLVOLTAGE_OVERVOLTAGE_RSL, DIAG_EVENT_RESET, &diag_kpkDatabaseShim, 0u); + TEST_ASSERT_EQUAL(testValue, diag_kpkDatabaseShim.pTableError->i2cPexError); +} diff --git a/tests/unit/app/engine/sys/test_sys.c b/tests/unit/app/engine/sys/test_sys.c index fea1e4e7..33be4b5e 100644 --- a/tests/unit/app/engine/sys/test_sys.c +++ b/tests/unit/app/engine/sys/test_sys.c @@ -53,6 +53,7 @@ /*========== Includes =======================================================*/ #include "unity.h" +#include "Mockafe.h" #include "Mockalgorithm.h" #include "Mockbal.h" #include "Mockbms.h" @@ -65,7 +66,6 @@ #include "Mockimd.h" #include "Mockinterlock.h" #include "Mockmeas.h" -#include "Mockmic.h" #include "Mockos.h" #include "Mocksbc.h" #include "Mocksof.h" diff --git a/tests/unit/app/task/config/test_ftask_cfg.c b/tests/unit/app/task/config/test_ftask_cfg.c index cf170c89..d5052308 100644 --- a/tests/unit/app/task/config/test_ftask_cfg.c +++ b/tests/unit/app/task/config/test_ftask_cfg.c @@ -43,7 +43,7 @@ * @file test_ftask_cfg.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -55,6 +55,7 @@ #include "unity.h" #include "MockHL_gio.h" #include "Mockadc.h" +#include "Mockafe.h" #include "Mockalgorithm.h" #include "Mockbal.h" #include "Mockbms.h" @@ -64,12 +65,15 @@ #include "Mockdiag.h" #include "Mockdiag_cfg.h" #include "Mockfram.h" +#include "Mockhtsensor.h" +#include "Mocki2c.h" #include "Mockimd.h" #include "Mockinterlock.h" +#include "Mockled.h" #include "Mockmeas.h" -#include "Mockmic.h" #include "Mockmpu_prototypes.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockredundancy.h" #include "Mocksbc.h" #include "Mocksof.h" @@ -80,6 +84,7 @@ #include "fram_cfg.h" #include "ftask_cfg.h" +#include "pex_cfg.h" #include "sys_mon_cfg.h" #include "fassert.h" diff --git a/tests/unit/app/task/ftask/test_ftask.c b/tests/unit/app/task/ftask/test_ftask.c index e4a3bfd6..0f7abb1b 100644 --- a/tests/unit/app/task/ftask/test_ftask.c +++ b/tests/unit/app/task/ftask/test_ftask.c @@ -43,7 +43,7 @@ * @file test_ftask.c * @author foxBMS Team * @date 2020-04-02 (date of creation) - * @updated 2021-07-23 (date of last update) + * @updated 2021-09-30 (date of last update) * @ingroup UNIT_TEST_IMPLEMENTATION * @prefix TEST * @@ -57,6 +57,7 @@ #include "unity.h" #include "MockHL_gio.h" #include "Mockadc.h" +#include "Mockafe.h" #include "Mockalgorithm.h" #include "Mockbal.h" #include "Mockbms.h" @@ -66,12 +67,15 @@ #include "Mockdiag.h" #include "Mockdiag_cfg.h" #include "Mockfram.h" +#include "Mockhtsensor.h" +#include "Mocki2c.h" #include "Mockimd.h" #include "Mockinterlock.h" +#include "Mockled.h" #include "Mockmeas.h" -#include "Mockmic.h" #include "Mockmpu_prototypes.h" #include "Mockos.h" +#include "Mockpex.h" #include "Mockredundancy.h" #include "Mocksbc.h" #include "Mocksof.h" diff --git a/tests/variants/README.md b/tests/variants/README.md index 06af279b..5f4c63b0 100644 --- a/tests/variants/README.md +++ b/tests/variants/README.md @@ -2,11 +2,11 @@ The naming schema for simple build variant configuration files is: -1. operating system -1. measurement IC - 1. manufacturer - 1. chip -1. balancing strategy +1. Operating System +1. Analog Front-End + 1. Manufacturer + 1. Chip +1. Balancing strategy 1. SoX algorithms: 1. SoC algorithm 1. SoE algorithm @@ -14,7 +14,7 @@ The naming schema for simple build variant configuration files is: 1. Insulation Measurement Device Therefore for a an **FreeRTOS** based build, using and **LTC 6813-1** -measurement IC with **voltage-based balancing** and **coulomb counting** as +AFE with **voltage-based balancing** and **coulomb counting** as basis for **SoC and SoE** but **no SoH** estimation and IMD, the bms configuration file must be named: diff --git a/tests/variants/freertos_debug-default_none_cc-cc-none_none-no-imd.json b/tests/variants/freertos_debug-default_none_cc-cc-none_none-no-imd.json index e5459fad..b9bba0d2 100644 --- a/tests/variants/freertos_debug-default_none_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_debug-default_none_cc-cc-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "debug", "chip": "default" }, diff --git a/tests/variants/freertos_debug-default_none_debug-debug-debug_none-no-imd.json b/tests/variants/freertos_debug-default_none_debug-debug-debug_none-no-imd.json index d4ece91b..34745e53 100644 --- a/tests/variants/freertos_debug-default_none_debug-debug-debug_none-no-imd.json +++ b/tests/variants/freertos_debug-default_none_debug-debug-debug_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "debug", "chip": "default" }, diff --git a/tests/variants/freertos_debug-default_none_none-none-none_none-no-imd.json b/tests/variants/freertos_debug-default_none_none-none-none_none-no-imd.json index 14cc16a6..a8bc363f 100644 --- a/tests/variants/freertos_debug-default_none_none-none-none_none-no-imd.json +++ b/tests/variants/freertos_debug-default_none_none-none-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "debug", "chip": "default" }, diff --git a/tests/variants/freertos_ltc-6804-1_hbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_ltc-6804-1_hbb_cc-cc-none_none-no-imd.json index f7e9fccd..748b93e3 100644 --- a/tests/variants/freertos_ltc-6804-1_hbb_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_ltc-6804-1_hbb_cc-cc-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6804-1" }, diff --git a/tests/variants/freertos_ltc-6806_none_cc-cc-none_none-no-imd.json b/tests/variants/freertos_ltc-6806_none_cc-cc-none_none-no-imd.json index 8641c4c8..3b15ffbe 100644 --- a/tests/variants/freertos_ltc-6806_none_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_ltc-6806_none_cc-cc-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6806" }, diff --git a/tests/variants/freertos_ltc-6812-1_hbb_cc-cc-none_bender-iso165c.json b/tests/variants/freertos_ltc-6812-1_hbb_cc-cc-none_bender-iso165c.json index 9b89e3ea..972b0d64 100644 --- a/tests/variants/freertos_ltc-6812-1_hbb_cc-cc-none_bender-iso165c.json +++ b/tests/variants/freertos_ltc-6812-1_hbb_cc-cc-none_bender-iso165c.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6813-1" }, diff --git a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-ir155.json b/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-ir155.json new file mode 100644 index 00000000..7e099a2c --- /dev/null +++ b/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-ir155.json @@ -0,0 +1,30 @@ +{ + "slave-unit": { + "analog-front-end": { + "manufacturer": "ltc", + "chip": "6813-1" + }, + "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": "bender", + "model": "ir155" + } + }, + "operating-system": { + "name": "freertos" + } +} diff --git a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-iso165c.json b/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-iso165c.json index 9b89e3ea..972b0d64 100644 --- a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-iso165c.json +++ b/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_bender-iso165c.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6813-1" }, diff --git a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json index d0957551..9f303436 100644 --- a/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_ltc-6813-1_hbb_cc-cc-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6813-1" }, 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_none-no-imd.json index cb08441f..c1d29fac 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_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "ltc", "chip": "6813-1" }, diff --git a/tests/variants/freertos_maxim-common_vbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_maxim-common_vbb_cc-cc-none_none-no-imd.json index d636bd32..5e53ef82 100644 --- a/tests/variants/freertos_maxim-common_vbb_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_maxim-common_vbb_cc-cc-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "maxim", "chip": "common" }, 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 index 48933ff4..cfbef701 100644 --- 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 @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "nxp", "chip": "common" }, diff --git a/tests/variants/freertos_nxp-mc33775a_vbb_cc-cc-none_none-no-imd.json b/tests/variants/freertos_nxp-mc33775a_vbb_cc-cc-none_none-no-imd.json index 554f9872..3aca9ac7 100644 --- a/tests/variants/freertos_nxp-mc33775a_vbb_cc-cc-none_none-no-imd.json +++ b/tests/variants/freertos_nxp-mc33775a_vbb_cc-cc-none_none-no-imd.json @@ -1,6 +1,6 @@ { "slave-unit": { - "measurement-ic": { + "analog-front-end": { "manufacturer": "nxp", "chip": "common" }, diff --git a/tools/gui/fgui/__init__.py b/tools/gui/fgui/__init__.py index bf01534d..7513e3ad 100644 --- a/tools/gui/fgui/__init__.py +++ b/tools/gui/fgui/__init__.py @@ -40,7 +40,7 @@ """sets the version package etc.""" -__version__ = "1.1.2" +__version__ = "1.2.0" __appname__ = "foxBMS 2" __author__ = "The foxBMS Team" __copyright__ = "(c) 2010 - 2021 foxBMS" diff --git a/tools/ide/vscode/c_cpp_properties.json.jinja2 b/tools/ide/vscode/c_cpp_properties.json.jinja2 index aa3e6cef..ff98c32e 100644 --- a/tools/ide/vscode/c_cpp_properties.json.jinja2 +++ b/tools/ide/vscode/c_cpp_properties.json.jinja2 @@ -29,18 +29,23 @@ "${workspaceFolder}/src/app/driver/dma", "${workspaceFolder}/src/app/driver/foxmath", "${workspaceFolder}/src/app/driver/fram", + "${workspaceFolder}/src/app/driver/htsensor", + "${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 }}/{{ IMD_MODEL }}", "${workspaceFolder}/src/app/driver/imd/{{ IMD_MANUFACTURER }}/{{ IMD_MODEL }}/config", "${workspaceFolder}/src/app/driver/io", + "${workspaceFolder}/src/app/driver/led", "${workspaceFolder}/src/app/driver/mcu", "${workspaceFolder}/src/app/driver/meas", - "${workspaceFolder}/src/app/driver/mic/api", - "${workspaceFolder}/src/app/driver/mic/{{ MEASUREMENT_IC_MANUFACTURER }}/api/**", - "${workspaceFolder}/src/app/driver/mic/{{ MEASUREMENT_IC_MANUFACTURER }}/common/**", - "${workspaceFolder}/src/app/driver/mic/{{ MEASUREMENT_IC_MANUFACTURER }}/{{ MEASUREMENT_IC_CHIP }}/**", + "${workspaceFolder}/src/app/driver/afe/api", + "${workspaceFolder}/src/app/driver/afe/{{ AFE_MANUFACTURER }}/api/**", + "${workspaceFolder}/src/app/driver/afe/{{ AFE_MANUFACTURER }}/common/**", + "${workspaceFolder}/src/app/driver/afe/{{ AFE_MANUFACTURER }}/{{ AFE_CHIP }}/**", + "${workspaceFolder}/src/app/driver/pex", + "${workspaceFolder}/src/app/driver/pwm", "${workspaceFolder}/src/app/driver/rtc", "${workspaceFolder}/src/app/driver/sbc", "${workspaceFolder}/src/app/driver/sbc/fs8x_driver", diff --git a/tools/ide/vscode/cspell.json.jinja2 b/tools/ide/vscode/cspell.json.jinja2 index dd6a85f7..1d8c4611 100644 --- a/tools/ide/vscode/cspell.json.jinja2 +++ b/tools/ide/vscode/cspell.json.jinja2 @@ -70,6 +70,7 @@ // Windows related "USERPROFILE", "LOCALAPPDATA", + "APPDATA", "findstr", // file extensions "vsdx", @@ -79,11 +80,15 @@ "cppchecksuppression", "cppcheckmisra", // prefixes we use in our embedded sources + "AFE", // Analog Front-End + "AFES", // Analog Front-Ends "BALS", + "HTSEN", "ILCK", "SYSM", "FTSK", "FTASK", + "NOIMD", "MRC", "fstd", "SHAREDRAM", @@ -148,6 +153,8 @@ "msreq", // Compound words in defines, abbreveations from HAL, etc. "RTSV", // TI: abbrevation for "runtime support library" + "SPNA", // TI prefix for lots of documents (and we reference them) + "SCPS", // TI prefix for lots of documents (and we reference them) "ADDMODERD", "ADDMODEWR", "INTA", @@ -170,6 +177,9 @@ "PORTB", "SYSPC", "ECLK", + "etpwm", + "TBPRD", + "TBCLK", "FRCNT", "ELCNT", "WDEL", @@ -179,6 +189,13 @@ "RDSIZE", "WRSIZE", "POWERON", + "IDADDR", + "ITCOUNT", + "DMACR", + "RXDMAEN", + "ISADDR", + "ITCOUNT", + "TXDMAEN", // LTC related words "REFON", "RDCVA", @@ -348,6 +365,7 @@ "ntcalug", // temperature sensor form vishay // Axivion "axivion", + "gravis", "preinc", "dashserver", "localbuild", @@ -494,6 +512,7 @@ "dask", "scipy", "seaborn", + "qtconsole", //wxpython "wxagg", // matplotlib @@ -589,9 +608,9 @@ "hardware/**/*.mdb", "hardware/**/*.stp", // third party sources - "src/app/driver/mic/nxp/common/MC33775A.h", + "src/app/driver/afe/nxp/common/MC33775A.h", "src/app/driver/sbc/fs8x_driver/**", - "src/app/driver/mic/ltc/common/ltc_pec.*", + "src/app/driver/afe/ltc/common/ltc_pec.*", "src/os/**", "tests/axivion/.axivion.preinc", "tests/axivion/rule_config_c.json", diff --git a/tools/utils/git-hooks/pre-commit b/tools/utils/git-hooks/pre-commit new file mode 100644 index 00000000..81bf0929 --- /dev/null +++ b/tools/utils/git-hooks/pre-commit @@ -0,0 +1,2 @@ +#!/bin/sh +./waf.sh check_guidelines diff --git a/tools/waf-tools/f_git_hooks.py b/tools/waf-tools/f_git_hooks.py new file mode 100644 index 00000000..9dc3e367 --- /dev/null +++ b/tools/waf-tools/f_git_hooks.py @@ -0,0 +1,73 @@ +#!/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 a git repository to use the foxBMS +specific git hooks. +""" + +import os +import shutil + + +def options(opt): + """Options to enable using the foxBMS git hooks. The hook can either be + globally enabled by defining the environment variable + ``FOXBMS_USE_GIT_HOOKS`` or passing --use-git-hooks during the configure + step.""" + opt.add_option( + "--use-git-hooks", + dest="USE_GIT_HOOKS", + action="store_true", + help="Apply foxBMS git hooks to that repository.", + ) + + +def configure(conf): # pylint: disable=too-many-statements,too-many-branches + """Use foxBMS specific git hooks in that repository.""" + # 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 + conf.start_msg("Applying git hooks.") + hooks = [ + conf.path.find_node(os.path.join("tools", "utils", "git-hooks", "pre-commit")) + ] + for i in hooks: + shutil.copyfile(i.abspath(), os.path.join(".git", "hooks", i.name)) + conf.end_msg("ok") diff --git a/tools/waf-tools/f_ti_arm_cgt.py b/tools/waf-tools/f_ti_arm_cgt.py index ff9f33b8..09da55ef 100644 --- a/tools/waf-tools/f_ti_arm_cgt.py +++ b/tools/waf-tools/f_ti_arm_cgt.py @@ -48,6 +48,7 @@ import re import shutil import sys +from hashlib import md5 import waflib.Tools.asm from waflib import Context, Logs, Task, TaskGen, Utils, Errors @@ -750,8 +751,12 @@ def tiprogram(bld, *k, **kw): kw["features"] += " hexgen" bld.env.LINKER_SCRIPT_HEX = kw["linker_script_hex"].abspath() bld.add_manual_dependency(tgt_elf, kw["linker_script_hex"]) - - elf_file_hash = binascii.hexlify(Utils.h_file(kw["linker_script"].abspath())) + # get the file hash assuming Unix-style line endings + elf_file_hash = binascii.hexlify( + md5( + kw["linker_script"].read().replace("\r\n", "\n").encode("utf-8") + ).digest() + ) txt = kw["linker_script_hex"].read().strip().splitlines()[0] txt = re.search(r"\/\*(.*)\*\/", txt) try: @@ -761,11 +766,13 @@ def tiprogram(bld, *k, **kw): known_hash = bytes(txt.strip(), encoding="utf-8") if not elf_file_hash == known_hash: bld.fatal( - f"The hash of {kw['linker_script'].abspath()} has changed from " - f"{known_hash} to {elf_file_hash}. Reflect the changes of " - "the elf file linker script in the hex file linker script and " - "update the file hash of the elf linker script in the hex " - "file linker script." + f"The hash of '{kw['linker_script'].abspath()}' has changed from " + f"'{known_hash.decode('utf-8')}' to '{elf_file_hash.decode('utf-8')}'.\n" + f"Reflect the changes in the elf file linker script " + f"('{kw['linker_script'].name}') in the hex file linker script " + f"('{kw['linker_script_hex'].name}') and then update the file hash " + f"generated based on the content of the elf linker script in the " + f"hex file linker script ('{kw['linker_script_hex'].abspath()}')." ) return bld(*k, **kw) diff --git a/tools/waf-tools/f_vscode.py b/tools/waf-tools/f_vscode.py index 6f91e791..0a1e6ec1 100644 --- a/tools/waf-tools/f_vscode.py +++ b/tools/waf-tools/f_vscode.py @@ -246,8 +246,8 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches except jsonschema.exceptions.ValidationError as err: good_values = ", ".join([f"'{i}'" for i in err.validator_value]) conf.fatal( - f"Measurement IC '{err.instance}' is not supported. Use one of " - f"these: {good_values}." + f"Analog Front-End '{err.instance}' is not supported.\n" + f"Use one of these: {good_values}." ) bal = bms_config["slave-unit"]["balancing-strategy"] soc = bms_config["application"]["algorithm"]["state-estimation"]["soc"] @@ -258,17 +258,15 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches imd_manufacturer = imd["manufacturer"] imd_model = imd["model"] - chip = bms_config["slave-unit"]["measurement-ic"]["chip"] + chip = bms_config["slave-unit"]["analog-front-end"]["chip"] 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"], BALANCING_STRATEGY=bal, - MEASUREMENT_IC_MANUFACTURER=bms_config["slave-unit"]["measurement-ic"][ - "manufacturer" - ], - MEASUREMENT_IC_CHIP=chip, + AFE_MANUFACTURER=bms_config["slave-unit"]["analog-front-end"]["manufacturer"], + AFE_CHIP=chip, TEMPERATURE_SENSOR_MANUFACTURER=bms_config["slave-unit"]["temperature-sensor"][ "manufacturer" ], diff --git a/wscript b/wscript index 93e64035..4432c982 100644 --- a/wscript +++ b/wscript @@ -76,7 +76,7 @@ top = "." # pylint:disable=invalid-name APPNAME = "foxBMS" """name of the application. This is used in various waf functions""" -VERSION = "1.1.2" +VERSION = "1.2.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.""" @@ -242,8 +242,8 @@ def options(opt): opt.add_option( "--why", dest="WHY", action="store_true", help="Loads the 'why' tool." ) - # add flasher tool opt.load("f_j_flash", tooldir=TOOLDIR) + opt.load("f_git_hooks", tooldir=TOOLDIR) def configure(conf): # pylint: disable=too-many-statements,too-many-branches @@ -272,24 +272,6 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches version_consistency_checker(conf) - # load configuration files - conf_dir = conf.path.find_node(os.path.join(conf.path.relpath(), "conf")) - conf_env_dir = conf.path.find_node(os.path.join(conf_dir.relpath(), "env")) - conf_tpl_dir = conf.path.find_node(os.path.join(conf_dir.relpath(), "tpl")) - - conf.env.conf_dir_abs, conf.env.conf_dir_rel = ( - conf_dir.abspath(), - conf_dir.relpath(), - ) - conf.env.conf_env_dir_abs, conf.env.conf_env_dir_rel = ( - conf_env_dir.abspath(), - conf_env_dir.relpath(), - ) - conf.env.conf_tpl_dir_abs, conf.env.conf_tpl_dir_rel = ( - conf_tpl_dir.abspath(), - conf_tpl_dir.relpath(), - ) - conf.find_program("git", var="GIT") conf.load("f_node_helper", tooldir=TOOLDIR) conf.load("f_ti_arm_cgt", tooldir=TOOLDIR) @@ -390,6 +372,7 @@ def configure(conf): # pylint: disable=too-many-statements,too-many-branches # load VS Code setup as last foxBMS specific tool to ensure that all # variables have a meaningful value conf.load("f_vscode", tooldir=TOOLDIR) + conf.load("f_git_hooks", tooldir=TOOLDIR) # the project has been successfully configured, now we can set the # application name and version @@ -407,7 +390,35 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements f"{', '.join(BLD_VARIANTS)}.\nFor more details run 'python " f"tools{os.sep}waf --help'" ) - + # we need to patch the build instructions for the Axivion build, and by + # that the "normal" build using TI ARM CGT gets broken (only in that + # context!), therefore (build|clean)_axivion must only be used as last + # build commands if multiple commands are supplied. + all_commands = [bld.cmd] + Options.commands # current command + remaining + if any(x in all_commands for x in ["build_axivion", "clean_axivion"]): + b_idx = sys.maxsize + try: + b_idx = all_commands.index("build_axivion") + except ValueError: + pass + c_idx = sys.maxsize + try: + c_idx = all_commands.index("clean_axivion") + except ValueError: + pass + min_idx = min([b_idx, c_idx]) + ax_commands = all_commands[min_idx:] + err = 0 + for i in ax_commands: + if not "_axivion" in i: + err += 1 + Logs.error(f"'{i}' must not be used in that order {all_commands!r}.") + if err: + bld.fatal( + "Axivion related commands must be moved to the end of the " + "command list, i.e. all other build commands must precede the " + "axivion commands." + ) version_consistency_checker(bld) bld.env.append_unique( "CMD_FILES", @@ -426,8 +437,8 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements except jsonschema.exceptions.ValidationError as err: good_values = ", ".join([f"'{i}'" for i in err.validator_value]) bld.fatal( - f"Measurement IC '{err.instance}' is not supported. Use one of " - f"these: {good_values}." + f"Analog Front-End '{err.instance}' is not supported.\n" + f"Use one of these: {good_values}." ) bld.env.operating_system = bms_config["operating-system"]["name"] @@ -453,39 +464,28 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements ) slave_config = bms_config["slave-unit"] - config_measurement_ic = slave_config["measurement-ic"] - bld.env.measurement_ic_manufacturer = config_measurement_ic["manufacturer"] - chip = config_measurement_ic["chip"] - if chip in ("6804-1", "6811-1", "6812-1"): - chip = "6813-1" - bld.env.measurement_ic_chip = chip - # get measurement IC includes + afe = slave_config["analog-front-end"] + bld.env.afe_manufacturer = afe["manufacturer"] + bld.env.afe_chip = afe["chip"] + afe_ic_inc = afe["chip"] + if afe["chip"] in ("6804-1", "6811-1", "6812-1"): + afe_ic_inc = "6813-1" + # get AFE includes incs = os.path.join( "src", "app", "driver", - "mic", - bld.env.measurement_ic_manufacturer, - bld.env.measurement_ic_chip, - f"{bld.env.measurement_ic_manufacturer}_{bld.env.measurement_ic_chip}.json", + "afe", + afe["manufacturer"], + afe_ic_inc, + f"{afe['manufacturer']}_{afe_ic_inc}.json", ) - measurement_ic_details = json.loads(bld.path.find_node(incs).read()) - measurement_ic_includes = [ - os.path.join( - "src", - "app", - "driver", - "mic", - config_measurement_ic["manufacturer"], - config_measurement_ic["chip"], - i, - ) - for i in measurement_ic_details["include"] + afe_details = json.loads(bld.path.find_node(incs).read()) + afe_includes = [ + os.path.join("src", "app", "driver", "afe", afe["manufacturer"], afe["chip"], i) + for i in afe_details["include"] ] - bld.env.append_unique( - "INCLUDES_MEASUREMENT_IC", - [bld.path.find_node(i) for i in measurement_ic_includes], - ) + bld.env.append_unique("INCLUDES_AFE", [bld.path.find_node(i) for i in afe_includes]) bld.env.balancing_strategy = slave_config["balancing-strategy"] bld.env.balancing_possible = slave_config["balancing-strategy"] != "none" @@ -540,8 +540,8 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements ["Setting", "Value"], ["Operating system", bld.env.operating_system], [ - "Measurement IC", - f"{bld.env.measurement_ic_manufacturer} {bld.env.measurement_ic_chip}", + "AFE", + f"{bld.env.afe_manufacturer} {bld.env.afe_chip}", ], ["Balancing strategy", balancing_info_str], [ @@ -667,9 +667,9 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements 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", "mic", "ltc", "common", "ltc_pec.c")), - bld.path.find_node(os.path.join("src", "app", "driver", "mic", "ltc", "common", "ltc_pec.h")), - bld.path.find_node(os.path.join("src", "app", "driver", "mic", "nxp", "common", "MC33775A.h")), + 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")), ] _html_footer = bld.path.find_node(os.path.join("docs", "doxygen_footer.html")) _layout_file = bld.path.find_node(os.path.join("docs", "doxygen_layout.xml")) @@ -804,6 +804,7 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements os.path.join(doc_dir, "software", "modules", "driver", "dma", "dma.rst"), os.path.join(doc_dir, "software", "modules", "driver", "foxmath", "foxmath.rst"), os.path.join(doc_dir, "software", "modules", "driver", "fram", "fram.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "imd", "bender", "bender_ir155.rst"), os.path.join(doc_dir, "software", "modules", "driver", "imd", "bender", "bender_iso165c.rst"), os.path.join(doc_dir, "software", "modules", "driver", "imd", "none", "no-imd.rst"), os.path.join(doc_dir, "software", "modules", "driver", "imd", "imd.rst"), @@ -811,13 +812,13 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements os.path.join(doc_dir, "software", "modules", "driver", "io", "io.rst"), os.path.join(doc_dir, "software", "modules", "driver", "mcu", "mcu.rst"), os.path.join(doc_dir, "software", "modules", "driver", "meas", "meas.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "ics.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "ltc", "6806.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "ltc", "6811-1.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "ltc", "6812-1.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "ltc", "6813-1.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "maxim", "max1785x.rst"), - os.path.join(doc_dir, "software", "modules", "driver", "mic", "nxp", "mc33775a.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "supported-afes.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "ltc", "6806.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "ltc", "6811-1.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "ltc", "6812-1.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "ltc", "6813-1.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "maxim", "max1785x.rst"), + os.path.join(doc_dir, "software", "modules", "driver", "afe", "nxp", "mc33775a.rst"), os.path.join(doc_dir, "software", "modules", "driver", "rtc", "rtc.rst"), os.path.join(doc_dir, "software", "modules", "driver", "sbc", "sbc.rst"), os.path.join(doc_dir, "software", "modules", "driver", "spi", "spi.rst"), @@ -853,6 +854,7 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements 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"), os.path.join(doc_dir, "tools", "waf-tools", "f_miniconda_env.rst"), @@ -897,7 +899,7 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements config = bld.path.find_node(os.path.join("docs", "conf.py")) bld( features="sphinx", - builders="html linkcheck spelling", + builders="html spelling", outdir=".", source=source, confpy=config, @@ -908,14 +910,28 @@ def build(bld): # pylint: disable=too-many-branches,too-many-statements def build_all(ctx): # pylint: disable=unused-argument """shortcut to build all variants""" + # axivion, if existing, needs to be inserted at the end of build commands + has_ax = "" for bld_var in BLD_VARIANTS: - Options.commands.insert(0, bld_var) + if "axivion" in bld_var: + has_ax = "axivion" + continue + Options.commands.append(bld_var) + if has_ax: + Options.commands.append("build_axivion") def clean_all(ctx): # pylint: disable=unused-argument """shortcut to clean all variants""" + # axivion, if existing, needs to be inserted at the end of clean commands + has_ax = "" for cln_var in CLN_VARIANTS: - Options.commands.insert(0, cln_var) + if "axivion" in cln_var: + has_ax = "axivion" + continue + Options.commands.append(cln_var) + if has_ax: + Options.commands.append("clean_axivion") def dist(conf): @@ -1002,7 +1018,7 @@ def check_testfiles(ctx): "src/app/**/*.c src/opt/**/*.c", excl=[ "src/app/driver/sbc/fs8x_driver/**", - "src/app/driver/mic/ltc/common/ltc_pec.*", + "src/app/driver/afe/ltc/common/ltc_pec.*", "src/hal/**", "src/os/**", ],