├── .gitattributes ├── .gitignore ├── src ├── application │ ├── sox │ │ └── sox.c │ ├── config │ │ ├── bmsctrl_cfg.c │ │ ├── appltask_cfg.h │ │ └── sox_cfg.c │ ├── bal │ │ ├── bal.h │ │ └── bal.c │ ├── task │ │ └── appltask.h │ └── wscript ├── module │ ├── config │ │ ├── bkpsram_cfg.c │ │ ├── dma_cfg.h │ │ ├── isoguard_cfg.c │ │ ├── uart_cfg.h │ │ ├── intermcu_cfg.h │ │ ├── adc_cfg.h │ │ ├── sdram_cfg.h │ │ ├── spi_cfg.h │ │ ├── uart_cfg.c │ │ ├── timer_cfg.c │ │ ├── adc_cfg.c │ │ ├── sdram_cfg.c │ │ ├── rcc_cfg.c │ │ ├── rtc_cfg.h │ │ ├── io_eval_board_cfg.h │ │ ├── isoguard_cfg.h │ │ ├── rtc_cfg.c │ │ └── dma_cfg.c │ ├── rtc │ │ ├── bkpsram.h │ │ ├── bkpsram.c │ │ ├── rtc.h │ │ └── rtc.c │ ├── io │ │ └── portcheck.h │ ├── intermcu │ │ ├── intermcu.h │ │ └── intermcu.c │ ├── watchdog │ │ ├── wdg.h │ │ └── wdg.c │ ├── rcc │ │ ├── rcc.h │ │ └── rcc.c │ ├── dma │ │ ├── dma.h │ │ └── dma.c │ ├── utils │ │ ├── sdram.h │ │ ├── misc.h │ │ └── led.h │ ├── isoguard │ │ └── isoguard.h │ ├── cansignal │ │ └── cansignal.h │ ├── chksum │ │ └── chksum.h │ ├── mcu │ │ └── timing.h │ ├── adc │ │ └── adc.h │ └── ltc │ │ └── ltc_pec.c ├── general │ ├── config │ │ ├── batterycell_cfg.h │ │ ├── mcu_cfg.h │ │ ├── nvic_cfg.h │ │ └── stm32f4xx_it.h │ ├── includes │ │ └── std_types.h │ ├── nvic.h │ └── main.h ├── wscript ├── os │ └── wscript ├── engine │ ├── config │ │ ├── syscontrol_cfg.c │ │ └── enginetask_cfg.h │ ├── task │ │ ├── enginetask.h │ │ └── enginetask.c │ └── database │ │ └── database.h └── test │ └── wscript ├── .clang-format ├── .travis.yml ├── wscript ├── LICENSE.md └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.h linguist-language=C 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *[wW]orkspace* 2 | Packages 3 | build 4 | *.pyc 5 | *.log 6 | .lock-waf_* 7 | waf-*-* -------------------------------------------------------------------------------- /src/application/sox/sox.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxBMS/foxBMS-primary/HEAD/src/application/sox/sox.c -------------------------------------------------------------------------------- /src/module/config/bkpsram_cfg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxBMS/foxBMS-primary/HEAD/src/module/config/bkpsram_cfg.c -------------------------------------------------------------------------------- /src/general/config/batterycell_cfg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foxBMS/foxBMS-primary/HEAD/src/general/config/batterycell_cfg.h -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | IndentWidth: 4 3 | TabWidth: 4 4 | UseTab: Never 5 | BreakBeforeBraces: Attach 6 | AllowShortIfStatementsOnASingleLine: false 7 | IndentCaseLabels: false 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: required 3 | dist: trusty 4 | 5 | env: 6 | global: 7 | - FOXBMS_SETUP_REPO_URL=https://github.com/foxBMS/foxBMS-setup.git 8 | - FOXBMS_SETUP_REPO_NAME=foxBMS-setup 9 | - FOXBMS_BUILD_ENV_BASE_DOCKER_IMAGE=ubuntu:xenial 10 | - FOXBMS_BUILD_ENV_DOCKER_IMAGE=foxbms-buildenv 11 | - FOXBMS_BUILD_ENV_APT_DEPENDENCIES="python2.7 python-pip git gcc-arm-none-eabi gdb-arm-none-eabi doxygen graphviz" 12 | - FOXBMS_BUILD_ENV_PIP_DEPENDENCIES="bitstring numpy" 13 | 14 | language: generic 15 | 16 | services: 17 | - docker 18 | 19 | install: 20 | - docker pull $FOXBMS_BUILD_ENV_BASE_DOCKER_IMAGE 21 | - docker run -it --name foxbms-buildenv-bootstrap-stage1 $FOXBMS_BUILD_ENV_BASE_DOCKER_IMAGE bash -c "apt update && apt -y install $FOXBMS_BUILD_ENV_APT_DEPENDENCIES" 22 | - docker commit foxbms-buildenv-bootstrap-stage1 $FOXBMS_BUILD_ENV_DOCKER_IMAGE 23 | - docker run -it --name foxbms-buildenv-bootstrap-stage2 foxbms-buildenv bash -c "pip install $FOXBMS_BUILD_ENV_PIP_DEPENDENCIES" 24 | - docker commit foxbms-buildenv-bootstrap-stage2 $FOXBMS_BUILD_ENV_DOCKER_IMAGE 25 | 26 | before_script: 27 | - export FOXBMS_CURRENT_REPO_NAME=$(python -c "from __future__ import print_function; import os; print(os.environ['TRAVIS_REPO_SLUG'].split('/')[1], end='')") 28 | - git clone $FOXBMS_SETUP_REPO_URL $FOXBMS_SETUP_REPO_NAME 29 | - mkdir $FOXBMS_SETUP_REPO_NAME/$FOXBMS_CURRENT_REPO_NAME && rsync -a --exclude $FOXBMS_SETUP_REPO_NAME . $FOXBMS_SETUP_REPO_NAME/$FOXBMS_CURRENT_REPO_NAME 30 | - docker run -it -v $(pwd):/gitroot -w="/gitroot/$FOXBMS_SETUP_REPO_NAME" $FOXBMS_BUILD_ENV_DOCKER_IMAGE python bootstrap.py -dbd -sr $FOXBMS_CURRENT_REPO_NAME foxBMS-tools FreeRTOS hal 31 | 32 | script: 33 | - docker run -it -v $(pwd)/$FOXBMS_SETUP_REPO_NAME:/gitroot -w="/gitroot" $FOXBMS_BUILD_ENV_DOCKER_IMAGE python build.py -p 34 | ... 35 | 36 | -------------------------------------------------------------------------------- /wscript: -------------------------------------------------------------------------------- 1 | # @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 2 | # 3 | # BSD 3-Clause License 4 | # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | # 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. 7 | # 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. 8 | # 9 | # 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. 10 | # 11 | # 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: 12 | # 13 | # ″This product uses parts of foxBMS®″ 14 | # 15 | # ″This product includes parts of foxBMS®″ 16 | # 17 | # ″This product is derived from foxBMS®″ 18 | 19 | """WAF script lists the subdirectories of src/ to be built 20 | """ 21 | 22 | from waflib import Logs, Utils, Context 23 | import os 24 | 25 | 26 | def build(bld): 27 | """Directories listed in dir_build_list are built, when the waf function 28 | "build" is called. 29 | """ 30 | 31 | dir_build_list = ['src'] 32 | for dir in dir_build_list: 33 | bld.recurse(dir) 34 | 35 | # vim: set ft=python : 36 | -------------------------------------------------------------------------------- /src/wscript: -------------------------------------------------------------------------------- 1 | # @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 2 | # 3 | # BSD 3-Clause License 4 | # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | # 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. 7 | # 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. 8 | # 9 | # 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. 10 | # 11 | # 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: 12 | # 13 | # ″This product uses parts of foxBMS®″ 14 | # 15 | # ″This product includes parts of foxBMS®″ 16 | # 17 | # ″This product is derived from foxBMS®″ 18 | 19 | """WAF script lists the subdirectories of src/ to be built 20 | """ 21 | 22 | from waflib import Logs, Utils, Context 23 | import os 24 | 25 | 26 | def build(bld): 27 | """Directories listed in dir_build_list are built, when the waf function 28 | "build" is called. 29 | """ 30 | hal_path = os.path.join(bld.top_dir, 'hal') 31 | dir_build_list = [hal_path, 'os', 'module', 'engine', 'application', 'general'] 32 | for dir in dir_build_list: 33 | bld.recurse(dir) 34 | 35 | # vim: set ft=python : 36 | -------------------------------------------------------------------------------- /src/os/wscript: -------------------------------------------------------------------------------- 1 | # @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 2 | # 3 | # BSD 3-Clause License 4 | # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | # 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. 7 | # 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. 8 | # 9 | # 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. 10 | # 11 | # 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: 12 | # 13 | # ″This product uses parts of foxBMS®″ 14 | # 15 | # ″This product includes parts of foxBMS®″ 16 | # 17 | # ″This product is derived from foxBMS®″ 18 | 19 | """WAF script for building "foxbms-stmhal" library. 20 | location of this wscript: 21 | /src/os/wscript 22 | 23 | library output: 24 | /build/src/os/libfoxbms-os.a 25 | 26 | """ 27 | 28 | from waflib import Logs, Utils, Context 29 | import os 30 | 31 | def build(bld): 32 | """Directories listed in dir_build_list are built, when the waf function 33 | "build" is called. 34 | """ 35 | freertos_path = os.path.join(bld.top_dir, 'FreeRTOS') 36 | dir_build_list = [freertos_path] 37 | for dir in dir_build_list: 38 | bld.recurse(dir) 39 | 40 | # vim: set ft=python : 41 | -------------------------------------------------------------------------------- /src/engine/config/syscontrol_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file syscontrol_cfg.c 25 | * @author foxBMS Team 26 | * @date 21.09.2015 (date of creation) 27 | * @ingroup ENGINE_CONF 28 | * @prefix SYSCTRL 29 | * 30 | * @brief Syscontrol driver configuration 31 | */ 32 | 33 | /*================== Includes =============================================*/ 34 | #include "general.h" 35 | #include "syscontrol_cfg.h" 36 | 37 | /*================== Macros and Definitions ===============================*/ 38 | 39 | /*================== Function Prototypes ==================================*/ 40 | 41 | /*================== Function Implementations =============================*/ 42 | -------------------------------------------------------------------------------- /src/general/config/mcu_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file mcu_cfg.h 25 | * @author foxBMS Team 26 | * @date 21.02.2017 (date of creation) 27 | * @ingroup TODO 28 | * @prefix MCU_CFG 29 | * 30 | * @brief Configuration of the used controller 31 | * 32 | */ 33 | 34 | #ifndef MCU_CFG_H_ 35 | #define MCU_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "stm32f4xx_hal.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | 43 | /*================== Constant and Variable Definitions ====================*/ 44 | 45 | 46 | /*================== Function Prototypes ==================================*/ 47 | 48 | 49 | /*================== Function Implementations =============================*/ 50 | 51 | 52 | #endif /* MCU_CFG_H_ */ 53 | -------------------------------------------------------------------------------- /src/application/config/bmsctrl_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file bmsctrl_cfg.c 25 | * @author foxBMS Team 26 | * @date 28.08.2015 (date of creation) 27 | * @ingroup ENGINE_CONF 28 | * @prefix BMSCTRL 29 | * 30 | * @brief Bmscontrol configuration 31 | * 32 | * Configuration implementation of the BMSCTRL module, empty 33 | * 34 | */ 35 | 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | #include "general.h" 40 | #include "bmsctrl_cfg.h" 41 | 42 | /*================== Macros and Definitions ===============================*/ 43 | 44 | 45 | 46 | /*================== Constant and Variable Definitions ====================*/ 47 | 48 | 49 | 50 | /*================== Function Prototypes ==================================*/ 51 | 52 | 53 | 54 | /*================== Function Implementations =============================*/ 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/module/config/dma_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file dma_cfg.h 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix DMA 29 | * 30 | * @brief Headers for the configuration for the DMA module. 31 | * 32 | */ 33 | 34 | #ifndef DMA_CFG_H_ 35 | #define DMA_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "mcu_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | extern DMA_HandleTypeDef dma_devices[]; 46 | extern const uint8_t dma_number_of_used_streams; 47 | 48 | /*================== Function Implementations =============================*/ 49 | 50 | #endif /* DMA_CFG_H_ */ 51 | -------------------------------------------------------------------------------- /src/module/rtc/bkpsram.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file bkpsram.h 25 | * @author foxBMS Team 26 | * @date 20.11.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix BKP_SRAM 29 | * 30 | * @brief Headers for the driver for static backup RAM 31 | * 32 | */ 33 | 34 | #ifndef BKPSRAM_H_ 35 | #define BKPSRAM_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "general.h" 39 | #include "bkpsram_cfg.h" 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | 46 | /** 47 | * @brief initializes the backup sram 48 | * 49 | * @return void 50 | */ 51 | extern void BKP_SRAM_Init(void); 52 | /*================== Function Implementations =============================*/ 53 | 54 | #endif /* BKPSRAM_H_ */ 55 | -------------------------------------------------------------------------------- /src/module/config/isoguard_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file isoguard_cfg.c 25 | * @author foxBMS Team 26 | * @date 08.12.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix ISO 29 | * 30 | * @brief Configuration for the isolation monitoring. 31 | * 32 | * Configuration source file of isoguard module 33 | */ 34 | 35 | /*================== Includes =============================================*/ 36 | /* recommended include order of header files: 37 | * 38 | * 1. include general.h 39 | * 2. include module's own header 40 | * 3... other headers 41 | * 42 | */ 43 | #include "general.h" 44 | #include "isoguard_cfg.h" 45 | 46 | /*================== Macros and Definitions ===============================*/ 47 | 48 | /*================== Constant and Variable Definitions ====================*/ 49 | 50 | /*================== Function Prototypes ==================================*/ 51 | 52 | /*================== Function Implementations =============================*/ 53 | -------------------------------------------------------------------------------- /src/module/io/portcheck.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file portcheck.h 25 | * @author foxBMS Team 26 | * @date 05.08.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix PORTCHECK 29 | * 30 | * @brief Validity checker for STM32 GPIO Configuration 31 | * 32 | * This module can be used to check if a STM32 port configuration was successfully written to the port's IO registers. 33 | * 34 | * Parts have been taken from the STM32 HAL library code. 35 | * 36 | */ 37 | 38 | #ifndef PORTCHECK_H_ 39 | #define PORTCHECK_H_ 40 | 41 | /*================== Includes =============================================*/ 42 | #include "io_cfg.h" 43 | /*================== Macros and Definitions ===============================*/ 44 | 45 | /*================== Constant and Variable Definitions ====================*/ 46 | 47 | /*================== Function Prototypes ==================================*/ 48 | extern STD_RETURN_TYPE_e GPIO_Check(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init); 49 | 50 | #endif /* PORTCHECK_H_ */ 51 | -------------------------------------------------------------------------------- /src/module/config/uart_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file uart_cfg.h 25 | * @author foxBMS Team 26 | * @date 26.08.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix UART 29 | * 30 | * @brief Headers for the configuration for the UART 31 | * 32 | */ 33 | 34 | #ifndef UART_CFG_H_ 35 | #define UART_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "mcu_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /** 43 | * Number of UART-channels that can be used 44 | */ 45 | #define UART_NUMBER_OF_USED_UART_CHANNELS 1 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | extern UART_HandleTypeDef uart_cfg[]; 49 | extern uint8_t uart_cfg_length; 50 | 51 | /*================== Function Prototypes ==================================*/ 52 | 53 | /*================== Function Implementations =============================*/ 54 | 55 | 56 | 57 | #endif /* UART_CFG_H_ */ 58 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # foxBMS Hardware and Documentation License 2 | 3 | Copyright (c) 2010-2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. 4 | All rights reserved. 5 | 6 | This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 7 | 8 | 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: 9 | 10 | * "This product uses parts of foxBMS" 11 | * "This product includes parts of foxBMS" 12 | * "This product is derived from foxBMS" 13 | 14 | If you use foxBMS in your products, we encourage you to contact us at: 15 | 16 | CONTACT INFORMATION 17 | Fraunhofer IISB 18 | Schottkystrasse 10 19 | 91058 Erlangen, Germany 20 | info@foxbms.org 21 | www.foxbms.org 22 | 23 | # foxBMS Software License 24 | 25 | Copyright (c) 2010-2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. 26 | All rights reserved. 27 | 28 | **BSD 3-Clause License** 29 | 30 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 31 | 32 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 33 | 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. 34 | 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. 35 | 36 | 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. 37 | 38 | 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: 39 | 40 | * "This product uses parts of foxBMS" 41 | * "This product includes parts of foxBMS" 42 | * "This product is derived from foxBMS" 43 | 44 | If you use foxBMS in your products, we encourage you to contact us at: 45 | 46 | CONTACT INFORMATION 47 | Fraunhofer IISB 48 | Schottkystrasse 10 49 | 91058 Erlangen, Germany 50 | info@foxbms.org 51 | www.foxbms.org 52 | -------------------------------------------------------------------------------- /src/module/config/intermcu_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file intermcu_cfg.h 25 | * @author foxBMS Team 26 | * @date 04.03.2016 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix IMC 29 | * 30 | * @brief Headers for the driver for the inter-MCU communication 31 | * 32 | */ 33 | 34 | #ifndef INTERMCU_CFG_H_ 35 | #define INTERMCU_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | #define MCU_MASTER 1 42 | 43 | #define SPI_HANDLE_IMC &spi_devices[2] // main 44 | 45 | #define SPI_INSTANCE_IMC *SPI_HANDLE_IMC.Instance 46 | 47 | #define SPI_PRESCALER_IMC *SPI_HANDLE_IMC.Init.BaudRatePrescaler 48 | 49 | 50 | /*================== Constant and Variable Definitions ====================*/ 51 | 52 | /*================== Function Prototypes ==================================*/ 53 | 54 | /*================== Function Implementations =============================*/ 55 | 56 | #endif /* INTERMCU_CFG_H_ */ 57 | -------------------------------------------------------------------------------- /src/module/intermcu/intermcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file intermcu.h 25 | * @author foxBMS Team 26 | * @date 04.03.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix IMC 29 | * 30 | * @brief Headers for the driver for the inter-MCU communication. 31 | * 32 | */ 33 | 34 | #ifndef INTERMCU_H_ 35 | #define INTERMCU_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "intermcu_cfg.h" 39 | 40 | #include "mcu_cfg.h" 41 | #include "spi.h" 42 | #include "mcu.h" 43 | 44 | /*================== Macros and Definitions ===============================*/ 45 | 46 | /*================== Constant and Variable Definitions ====================*/ 47 | extern uint8_t readArray[]; 48 | 49 | /*================== Function Prototypes ==================================*/ 50 | extern void IMC_sendByte(uint8_t message); 51 | extern void IMC_enableInterrupt(void); 52 | extern uint8_t IMC_readByte(void); 53 | 54 | /*================== Function Implementations =============================*/ 55 | 56 | #endif /* INTERMCU_H_ */ 57 | -------------------------------------------------------------------------------- /src/module/watchdog/wdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file wdg.h 25 | * @author foxBMS Team 26 | * @date 17.03.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix WDG 29 | * 30 | * @brief headers for the driver for the watchdog 31 | * 32 | * Source file implements the watchdog interfaces 33 | */ 34 | 35 | #ifndef WDG_H_ 36 | #define WDG_H_ 37 | 38 | /*================== Includes =============================================*/ 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | /** 46 | * @brief initialization of MCU watchdog 47 | * 48 | * @return void 49 | */ 50 | extern void WDG_Init(void); 51 | 52 | 53 | /** 54 | * @brief refreshes independent watchdog 55 | * 56 | * @return void 57 | */ 58 | extern void WDG_IWDG_Refresh(void); 59 | 60 | /*================== Function Implementations =============================*/ 61 | 62 | #endif /* WDG_H_ */ 63 | -------------------------------------------------------------------------------- /src/module/rcc/rcc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rcc.h 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix RCC 29 | * 30 | * @brief Headers for the driver for the clock system 31 | * 32 | * encapsulation of some HAL functions 33 | * 34 | */ 35 | 36 | #ifndef RCC_H_ 37 | #define RCC_H_ 38 | 39 | /*================== Includes =============================================*/ 40 | #include "rcc_cfg.h" 41 | 42 | /*================== Macros and Definitions ===============================*/ 43 | 44 | /*================== Constant and Variable Definitions ====================*/ 45 | 46 | /*================== Function Prototypes ==================================*/ 47 | 48 | /** 49 | * @brief initializes the clock module. 50 | * 51 | * This function sets the system frequencies according to the configuration 52 | * defined in rcc_cfg.h. 53 | * 54 | * @return none(void) 55 | */ 56 | extern void RCC_ClockConfig(void); 57 | 58 | /*================== Function Implementations =============================*/ 59 | 60 | 61 | #endif /* RCC_H_ */ 62 | -------------------------------------------------------------------------------- /src/module/config/adc_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file adc_cfg.h 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix ADC 29 | * 30 | * @brief Headers for the configuration for the analog to digital converter 31 | * 32 | */ 33 | 34 | #ifndef ADC_CFG_H_ 35 | #define ADC_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "general.h" 39 | #include "mcu_cfg.h" 40 | 41 | /*================== Macros and Definitions ===============================*/ 42 | 43 | /*================== Constant and Variable Definitions ====================*/ 44 | #define ADC_VBAT_VOLTAGE_DIVIDER 4.0 45 | #define ADC_FULL_RANGE 4095.0 // 12bit adc converter --> range [0, ..., 4095] 46 | #define ADC_VREF_EXT 2.5 47 | #define ADC_V25 0.76 48 | #define ADC_AVG_SLOPE 2.5 49 | 50 | /*================== Function Prototypes ==================================*/ 51 | 52 | 53 | /*================== Function Implementations =============================*/ 54 | 55 | #endif /* ADC_CFG_H_ */ 56 | -------------------------------------------------------------------------------- /src/module/config/sdram_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file sdram_cfg.h 25 | * @author foxBMS Team 26 | * @date 24.05.2016 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix SDRAM 29 | * 30 | * @brief Headers for the external SDRAM configuration and data definitions 31 | * 32 | */ 33 | 34 | #ifndef SDRAM_CFG_H_ 35 | #define SDRAM_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include 39 | /*================== Macros and Definitions ===============================*/ 40 | 41 | /*================== Constant and Variable Definitions ====================*/ 42 | extern uint8_t _sidata_ext[]; 43 | extern uint8_t _s_extdata[]; 44 | extern uint8_t _e_extdata[]; 45 | 46 | #if 0 47 | extern uint32_t extsd_testbuffer[100]; 48 | extern volatile uint32_t extsd_test2; 49 | #endif 50 | 51 | /*================== Function Prototypes ==================================*/ 52 | #if 0 53 | extern void SDRAM_testram(void); 54 | #endif 55 | 56 | extern void SDRAM_c_init(void); 57 | 58 | /*================== Function Implementations =============================*/ 59 | 60 | #endif /* SDRAM_CFG_H_ */ 61 | -------------------------------------------------------------------------------- /src/module/rcc/rcc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rcc.c 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix RCC 29 | * 30 | * @brief Driver for the clock system 31 | * 32 | * encapsulation of some HAL functions 33 | * 34 | */ 35 | 36 | /*================== Includes =============================================*/ 37 | /* recommended include order of header files: 38 | * 39 | * 1. include general.h 40 | * 2. include module's own header 41 | * 3... other headers 42 | * 43 | */ 44 | #include "general.h" 45 | #include "rcc.h" 46 | 47 | /*================== Macros and Definitions ===============================*/ 48 | 49 | /*================== Constant and Variable Definitions ====================*/ 50 | 51 | /*================== Function Prototypes ==================================*/ 52 | 53 | /*================== Function Implementations =============================*/ 54 | 55 | void RCC_ClockConfig(void) { 56 | 57 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 58 | 59 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); 60 | 61 | __SYSCFG_CLK_ENABLE(); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/module/dma/dma.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file dma.h 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix DMA 29 | * 30 | * @brief Headers for the driver for the DMA module (encapsulation of the init function). 31 | * 32 | */ 33 | 34 | #ifndef DMA_IF_H_ 35 | #define DMA_IF_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "dma_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | /** 46 | * @brief initializes the DMA module. 47 | * 48 | * This function initializes the DMA streams according to the configuration given as parameter. 49 | * 50 | * @param *hdma pointer to the dma configuration 51 | * 52 | * @return void 53 | * 54 | */ 55 | extern void DMA_Init(DMA_HandleTypeDef *hdma); 56 | 57 | /*================== Function Implementations =============================*/ 58 | 59 | 60 | #endif /* DMA_IF_H_ */ 61 | -------------------------------------------------------------------------------- /src/general/includes/std_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file std_types.h 25 | * @author foxBMS Team 26 | * @date 20.12.2015 (date of creation) 27 | * @ingroup GENERAL_CONF 28 | * @prefix STD 29 | * 30 | * @brief Definition of foxBMS standard types 31 | */ 32 | 33 | #ifndef STD_TYPES_H_ 34 | #define STD_TYPES_H_ 35 | 36 | /*================== Includes =============================================*/ 37 | 38 | /*================== Macros and Definitions ===============================*/ 39 | 40 | #define NULL_PTR (void*)(0) 41 | 42 | #define TRUE 1 43 | #define FALSE 0 44 | 45 | #define STD_HIGH TRUE 46 | #define STD_LOW FALSE 47 | 48 | /*================== Constant and Variable Definitions ====================*/ 49 | 50 | typedef __UINT8_TYPE__ boolean; 51 | 52 | typedef void (*VOID_FUNC_VOID_t)(); 53 | 54 | /** 55 | * enum for standard return type 56 | */ 57 | typedef enum { 58 | E_OK = 0, /*!< ok */ 59 | E_NOT_OK = 1 /*!< not ok */ 60 | } STD_RETURN_TYPE_e; 61 | 62 | /*================== Function Prototypes ==================================*/ 63 | 64 | /*================== Function Implementations =============================*/ 65 | 66 | #endif /* STD_TYPES_H_ */ 67 | -------------------------------------------------------------------------------- /src/test/wscript: -------------------------------------------------------------------------------- 1 | # @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 2 | # 3 | # BSD 3-Clause License 4 | # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | # 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. 7 | # 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. 8 | # 9 | # 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. 10 | # 11 | # 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: 12 | # 13 | # ″This product uses parts of foxBMS®″ 14 | # 15 | # ″This product includes parts of foxBMS®″ 16 | # 17 | # ″This product is derived from foxBMS®″ 18 | 19 | """WAF script for building "foxbms-test" library. 20 | location of this wscript: 21 | /src/test/wscript 22 | """ 23 | 24 | from waflib import Logs, Utils, Context 25 | import os 26 | 27 | 28 | def build(bld): 29 | srcs = bld.path.ant_glob('**/*.c') 30 | 31 | includes = os.path.join(bld.bldnode.abspath()) + ' ' 32 | includes += ' '.join([ 33 | '.', 34 | 35 | os.path.join('..', 'engine', 'config'), 36 | os.path.join('..', 'engine', 'database'), 37 | 38 | os.path.join('..', 'general', 'config'), 39 | os.path.join('..', 'general', 'includes'), 40 | 41 | os.path.join('..', 'hal', 'CMSIS', 'Device', 'ST', 'STM32F4xx', 'Include'), 42 | os.path.join('..', 'hal', 'CMSIS', 'Include'), 43 | os.path.join('..', 'hal', 'STM32F4xx_HAL_Driver', 'Inc'), 44 | os.path.join('..', 'hal', 'STM32F4xx_HAL_Driver', 'Inc', 'Legacy'), 45 | 46 | os.path.join('..', 'module', 'io'), 47 | 48 | os.path.join('..', 'test'), 49 | ]) 50 | 51 | 52 | bld.stlib( 53 | target='foxbms-test', 54 | source=srcs, 55 | includes=includes 56 | ) 57 | 58 | # vim: set ft=python : 59 | -------------------------------------------------------------------------------- /src/module/utils/sdram.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file sdram.h 25 | * @author foxBMS Team 26 | * @date 13.11.2015 (date of creation) 27 | * @ingroup UTIL 28 | * @prefix SDRAM 29 | * 30 | * @brief Headers for the driver for the volatile SDRAM. 31 | * 32 | */ 33 | 34 | #ifndef SDRAM_H_ 35 | #define SDRAM_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "sdram_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | 46 | /** 47 | * @brief flexible memory controller (FMC) initialization for SDRAM 48 | * 49 | * @return void 50 | */ 51 | extern void SDRAM_Init(void); 52 | 53 | /** 54 | * @brief Copying of initialized data from Flash to SDRAM 55 | * 56 | * @return void 57 | */ 58 | extern void EXTSD_c_init(void); 59 | 60 | 61 | /** 62 | * @brief SDRAM memory test 63 | * 64 | * @return void 65 | */ 66 | extern void SDRAM_testram(void); 67 | 68 | /*================== Function Implementations =============================*/ 69 | 70 | #endif /* SDRAM_H_ */ 71 | -------------------------------------------------------------------------------- /src/application/bal/bal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file bal.h 25 | * @author foxBMS Team 26 | * @date 26.02.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix BAL 29 | * 30 | * @brief Header for the driver for balancing 31 | * 32 | */ 33 | 34 | #ifndef BAL_H_ 35 | #define BAL_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | 46 | /** 47 | * @brief Initialization of the balancing module 48 | * 49 | * This function initializes the SOC values with lookup table (mean, minimum 50 | * and maximum). 51 | * 52 | * @return void 53 | * 54 | */ 55 | extern void BAL_Init(void); 56 | 57 | /** 58 | * if balancing is enabled, checks the voltages to determine which cells have to be balanced 59 | * and sets the corresponding data fields in the database. 60 | * 61 | * @return void 62 | * 63 | */ 64 | extern void BAL_Ctrl(void); 65 | 66 | /*================== Function Implementations =============================*/ 67 | 68 | #endif /* BAL_H_ */ 69 | -------------------------------------------------------------------------------- /src/module/config/spi_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file spi_cfg.h 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix SPI 29 | * 30 | * @brief Headers for the configuration for the serial peripheral interface module. 31 | * 32 | */ 33 | 34 | #ifndef SPI_CFG_H_ 35 | #define SPI_CFG_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "mcu_cfg.h" 39 | #include "io.h" 40 | 41 | 42 | /*================== Macros and Definitions ===============================*/ 43 | /** 44 | * Wait time in [us]. Max wait time: 1000us 45 | */ 46 | #define SPI_WAKEUP_WAIT_TIME 0 47 | 48 | #define SPI_NSS_PORT1 IO_PIN_MCU_0_BMS_INTERFACE_SPI_NSS 49 | 50 | 51 | /*================== Constant and Variable Definitions ====================*/ 52 | extern SPI_HandleTypeDef spi_devices[]; 53 | 54 | /** 55 | * Number of SPI-channels that will be used 56 | * Maximum number of usable SPI-Channels is <= 6. 57 | */ 58 | extern uint8_t spi_number_of_used_SPI_channels; 59 | 60 | /*================== Function Prototypes ==================================*/ 61 | 62 | /*================== Function Implementations =============================*/ 63 | 64 | 65 | 66 | #endif /* SPI_CFG_H_ */ 67 | -------------------------------------------------------------------------------- /src/general/config/nvic_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file nvic_cfg.h 25 | * @author foxBMS Team 26 | * @date 10.09.2015 (date of creation) 27 | * @ingroup GENERAL,GENERAL_CONF 28 | * @prefix NVIC 29 | * 30 | * @brief Header for configuration of interrupts 31 | * 32 | */ 33 | 34 | #ifndef NVIC_CFG_H_ 35 | #define NVIC_CFG_H_ 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | #include "stm32f4xx_hal.h" 40 | 41 | 42 | /*================== Macros and Definitions ===============================*/ 43 | 44 | typedef enum { 45 | NVIC_IRQ_ENABLE = 0, 46 | NVIC_IRQ_DISABLE = 1, 47 | } NVIC_IRQ_STATE_e; 48 | 49 | typedef enum { 50 | NVIC_IRQ_LOCK_DISABLE = 0, 51 | NVIC_IRQ_LOCK_ENABLE = 1, 52 | }NVIC_IRQ_LOCK_e; 53 | 54 | typedef struct { 55 | IRQn_Type IRQ; 56 | uint8_t Prio; 57 | NVIC_IRQ_LOCK_e irqlock; 58 | NVIC_IRQ_STATE_e state; 59 | } NVIC_InitStruct_s; 60 | 61 | 62 | /*================== Constant and Variable Definitions ====================*/ 63 | extern NVIC_InitStruct_s nvic_interrupts[]; 64 | extern const uint8_t nvic_cfg_length; 65 | 66 | /*================== Function Prototypes ==================================*/ 67 | 68 | 69 | /*================== Function Implementations =============================*/ 70 | 71 | 72 | #endif /* NVIC_H_ */ 73 | -------------------------------------------------------------------------------- /src/module/utils/misc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file misc.h 25 | * @author foxBMS Team 26 | * @date 23.12.2015 (date of creation) 27 | * @ingroup UTIL 28 | * @prefix none 29 | * 30 | * @brief Headers for the miscellaneous functions 31 | * 32 | */ 33 | 34 | #ifndef MISC_H_ 35 | #define MISC_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "general.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | 43 | /*================== Constant and Variable Definitions ====================*/ 44 | 45 | 46 | /*================== Function Prototypes ==================================*/ 47 | extern uint8_t *U8ToDecascii(uint8_t *destptr, uint8_t *dataptr, uint8_t minDigits); 48 | extern uint8_t *hex2ascii(uint8_t *destptr, uint8_t *srcptr, uint8_t len); 49 | extern uint8_t *U32ToHexascii(uint8_t *destptr, uint32_t *dataptr); 50 | extern uint8_t *U16ToHexascii(uint8_t *destptr, uint16_t *dataptr); 51 | extern uint8_t *U8ToHexascii(uint8_t *destptr, uint8_t *dataptr); 52 | extern uint8_t *I32ToDecascii(uint8_t *destptr, int32_t *dataptr); 53 | extern uint8_t *U16ToDecascii(uint8_t *destptr, uint16_t *dataptr, uint8_t minDigits); 54 | 55 | /*================== Function Implementations =============================*/ 56 | 57 | #endif /* MISC_H_ */ 58 | -------------------------------------------------------------------------------- /src/module/isoguard/isoguard.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file isoguard.h 25 | * @author foxBMS Team 26 | * @date 12.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix ISO 29 | * 30 | * @brief Headers for the driver for the isolation monitoring. 31 | * 32 | * Header file for insulation measurement 33 | */ 34 | 35 | #ifndef ISOGUARD_H_ 36 | #define ISOGUARD_H_ 37 | 38 | /*================== Includes =============================================*/ 39 | #include "isoguard_cfg.h" 40 | 41 | /*================== Macros and Definitions ===============================*/ 42 | 43 | /*================== Constant and Variable Definitions ====================*/ 44 | 45 | /*================== Function Prototypes ==================================*/ 46 | /** 47 | * @brief Initializes SW-Isoguard modul and Enables HW-Bender-Modul 48 | * 49 | * @return void 50 | */ 51 | extern void ISO_Init(void); 52 | 53 | /** 54 | * @brief Resets isometer and timer modul as well as HW-Bender-Modul 55 | * 56 | * @return void 57 | */ 58 | extern void ISO_ReInit(void); 59 | 60 | /** 61 | * @brief Interface function which delivers the actual signal measurement (dutycyle) and writes the result in the database 62 | * 63 | * @return void 64 | */ 65 | extern void ISO_MeasureInsulation(void); 66 | 67 | /*================== Function Implementations =============================*/ 68 | 69 | #endif /* ISOGUARD_H_ */ 70 | -------------------------------------------------------------------------------- /src/module/utils/led.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file led.h 25 | * @author foxBMS Team 26 | * @date 12.11.2015 (date of creation) 27 | * @ingroup UTIL 28 | * @prefix LED 29 | * 30 | * @brief Headers for the driver to control the blinking of the display LEDs. 31 | * 32 | */ 33 | 34 | #ifndef LED_H_ 35 | #define LED_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "general.h" 39 | #include "io.h" 40 | 41 | /*================== Macros and Definitions ===============================*/ 42 | #define LED_DEBUG_0 IO_PIN_MCU_0_DEBUG_LED_0 43 | #define LED_DEBUG_1 IO_PIN_MCU_0_DEBUG_LED_1 44 | 45 | /** 46 | * Blinking time im milliseconds 47 | */ 48 | #define LED_BLINK_TASK_DURATION_MS 10 49 | 50 | /** 51 | * LED off time in milliseconds 52 | */ 53 | #define LED_OFF_TIME_MS 100 54 | 55 | /*================== Constant and Variable Definitions ====================*/ 56 | 57 | /*================== Function Prototypes ==================================*/ 58 | 59 | /** 60 | * @brief switches the debug LEDs off 61 | * 62 | * @return void 63 | */ 64 | extern void LED_Init(void); 65 | 66 | /** 67 | * @brief controls the debug LED blinking frequency 68 | * 69 | * @return void 70 | */ 71 | extern void LED_Ctrl(void); 72 | 73 | /*================== Function Implementations =============================*/ 74 | 75 | #endif /* LED_H_ */ 76 | -------------------------------------------------------------------------------- /src/module/cansignal/cansignal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file cansignal.h 25 | * @author foxBMS Team 26 | * @date 01.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix CANS 29 | * 30 | * @brief Headers for the messages and signal settings for the CAN driver 31 | * 32 | * generic conversion module header of Can signals from CAN buffered reception to 33 | * DATA Manager and vice versa 34 | * 35 | */ 36 | 37 | #ifndef CANSIGNAL_H_ 38 | #define CANSIGNAL_H_ 39 | 40 | /*================== Includes =============================================*/ 41 | #include "cansignal_cfg.h" 42 | 43 | /*================== Macros and Definitions ===============================*/ 44 | 45 | /*================== Constant and Variable Definitions ====================*/ 46 | 47 | /*================== Function Prototypes ==================================*/ 48 | /** 49 | * initializes local variables and module internals needed to use conversion of 50 | * can signals. Until now no initialization is needed and thus the function does 51 | * nothing. 52 | */ 53 | extern void CANS_Init(void); 54 | 55 | /** 56 | * handles the conversion of can signals from and to datamanager database or 57 | * other modules defined by the getter and setter configuration. 58 | */ 59 | extern void CANS_MainFunction(void); 60 | 61 | /*================== Function Implementations =============================*/ 62 | 63 | #endif /* CANSIGNAL_H_ */ 64 | -------------------------------------------------------------------------------- /src/module/chksum/chksum.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file chksum.h 25 | * @author foxBMS Team 26 | * @date 28.08.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix CHK 29 | * 30 | * @brief Header for the driver for the checksum calculation 31 | * 32 | */ 33 | 34 | #ifndef CHKSUM_H_ 35 | #define CHKSUM_H_ 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | #include "version.h" 40 | 41 | 42 | 43 | 44 | /*================== Macros and Definitions ===============================*/ 45 | 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | 49 | typedef enum { 50 | CHK_CHECKSUM_FAILED = 0xFF, 51 | CHK_CHECKSUM_PASSED = 0x00, 52 | /*...*/ 53 | } CHK_CHECKSUM_STATUS_e; 54 | 55 | 56 | typedef struct 57 | { 58 | uint32_t checksum; /* 16 bit checksum for validating the Application SW */ 59 | uint32_t resetstatus; /* last reset status */ 60 | CHK_CHECKSUM_STATUS_e checksumstatus; 61 | } CHK_STATUS_s; 62 | 63 | extern CHK_STATUS_s chk_status; 64 | /*================== Function Prototypes ==================================*/ 65 | 66 | extern STD_RETURN_TYPE_e CHK_Flashchecksum(const VER_ValidStruct_s *valid_struct); 67 | 68 | /*================== Function Implementations =============================*/ 69 | 70 | 71 | 72 | 73 | 74 | 75 | #endif /* CHKSUM_H_ */ 76 | -------------------------------------------------------------------------------- /src/module/config/uart_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file uart_cfg.c 25 | * @author foxBMS Team 26 | * @date 23.09.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix UART 29 | * 30 | * @brief Configuration for the UART 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "uart_cfg.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | UART_HandleTypeDef uart_cfg[UART_NUMBER_OF_USED_UART_CHANNELS] = { 49 | { 50 | .Instance = USART3, 51 | .Init.BaudRate = 115200, 52 | .Init.WordLength = UART_WORDLENGTH_8B, 53 | .Init.StopBits = UART_STOPBITS_1, 54 | .Init.Parity = UART_PARITY_NONE, 55 | .Init.Mode = UART_MODE_TX_RX, 56 | .Init.HwFlowCtl = UART_HWCONTROL_NONE, 57 | .Init.OverSampling = UART_OVERSAMPLING_16, 58 | } 59 | }; 60 | 61 | uint8_t uart_cfg_length = sizeof(uart_cfg)/sizeof(uart_cfg[0]); 62 | 63 | /*================== Function Prototypes ==================================*/ 64 | 65 | /*================== Function Implementations =============================*/ 66 | -------------------------------------------------------------------------------- /src/module/rtc/bkpsram.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file bkpsram.c 25 | * @author foxBMS Team 26 | * @date 20.11.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix BKP_SRAM 29 | * 30 | * @brief Driver for static backup RAM 31 | * 32 | */ 33 | 34 | 35 | /*================== Includes =============================================*/ 36 | /* recommended include order of header files: 37 | * 38 | * 1. include general.h 39 | * 2. include module's own header 40 | * 3... other headers 41 | * 42 | */ 43 | #include "general.h" 44 | #include "bkpsram.h" 45 | 46 | #include "rtc.h" 47 | 48 | /*================== Macros and Definitions ===============================*/ 49 | 50 | /*================== Constant and Variable Definitions ====================*/ 51 | 52 | /*================== Function Prototypes ==================================*/ 53 | 54 | /*================== Function Implementations =============================*/ 55 | 56 | void BKP_SRAM_Init(void) { 57 | #ifdef BKP_SRAM_ENABLE 58 | // Enable PWR clock 59 | RCC->APB1ENR |= RCC_APB1ENR_PWREN; 60 | 61 | // Allow access to backup domain 62 | HAL_PWR_EnableBkUpAccess(); 63 | 64 | // Enable backup SRAM CLK 65 | RCC->AHB1ENR |= RCC_AHB1ENR_BKPSRAMEN; 66 | 67 | /* Enable low power Regulator */ 68 | HAL_PWREx_EnableBkUpReg(); 69 | 70 | if(RTC_BKPSRAM_DATAVALID_VARIABLE == 0) 71 | { 72 | //@todo: clear BKP_SRAM Values? 73 | RTC_BKPSRAM_DATAVALID_VARIABLE = 1; 74 | 75 | } 76 | 77 | #endif 78 | } 79 | -------------------------------------------------------------------------------- /src/module/rtc/rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rtc.h 25 | * @author foxBMS Team 26 | * @date 20.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix RTC 29 | * 30 | * @brief Headers for the driver for the real time clock. 31 | * 32 | */ 33 | 34 | #ifndef RTC_H_ 35 | #define RTC_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "rtc_cfg.h" 39 | #include "mcu_cfg.h" 40 | 41 | /*================== Macros and Definitions ===============================*/ 42 | 43 | 44 | /*================== Constant and Variable Definitions ====================*/ 45 | typedef RTC_TimeTypeDef RTC_Time_s; 46 | typedef RTC_DateTypeDef RTC_Date_s; 47 | 48 | extern RTC_HandleTypeDef hrtc; 49 | 50 | /*================== Function Prototypes ==================================*/ 51 | 52 | /** 53 | * @brief initializes rtc module 54 | * 55 | * @return void 56 | */ 57 | extern void RTC_Init(void); 58 | 59 | /** 60 | * @brief sets RTC time 61 | * 62 | * @return void 63 | */ 64 | extern void RTC_setTime(RTC_TimeTypeDef* time); 65 | 66 | /** 67 | * @brief gets RTC time 68 | * 69 | * @return void 70 | */ 71 | extern void RTC_getTime(RTC_TimeTypeDef* time); 72 | 73 | /** 74 | * @brief sets RTC date 75 | * 76 | * @return void 77 | */ 78 | extern void RTC_setDate(RTC_DateTypeDef* date); 79 | 80 | /** 81 | * @brief gets RTC date 82 | * 83 | * @return void 84 | */ 85 | extern void RTC_getDate(RTC_DateTypeDef* date); 86 | 87 | 88 | /*================== Function Implementations =============================*/ 89 | 90 | #endif /* RTC_H_ */ 91 | -------------------------------------------------------------------------------- /src/general/nvic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file nvic.h 25 | * @author foxBMS Team 26 | * @date 10.09.2015 (date of creation) 27 | * @ingroup GENERAL 28 | * @prefix NVIC 29 | * 30 | * @brief Functions for setting and enabling interrupts, headers 31 | * 32 | */ 33 | 34 | #ifndef NVIC_H_ 35 | #define NVIC_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "nvic_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | 46 | /** 47 | * @brief Initializes and enables interrupts for usage before operating system has started. 48 | * 49 | * @return void 50 | */ 51 | extern void NVIC_PreOsInit(void); 52 | 53 | /** 54 | * @brief Initializes and enables interrupts for usage after operating system has started. 55 | * 56 | * @return void 57 | */ 58 | extern void NVIC_PostOsInit(void); 59 | 60 | /** 61 | * @brief Enables interrupt, if interrupt is not locked 62 | * 63 | * @param interrupt: Interrupt to enable 64 | * 65 | * @return void 66 | */ 67 | extern void NVIC_EnableInterrupts(IRQn_Type interrupt); 68 | 69 | /** 70 | * @brief Disables interrupt, if interrupt is not locked 71 | * 72 | * @param interrupt: Interrupt to disable 73 | * 74 | * @return void 75 | */ 76 | extern void NVIC_DisableInterrupt(IRQn_Type interrupt); 77 | 78 | /*================== Function Implementations =============================*/ 79 | 80 | 81 | #endif /* NVIC_H_ */ 82 | -------------------------------------------------------------------------------- /src/module/watchdog/wdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file wdg.c 25 | * @author foxBMS Team 26 | * @date 16.03.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix WDG 29 | * 30 | * @brief Driver for the watchdog 31 | * 32 | * Source file implements the watchdog interfaces 33 | */ 34 | 35 | /*================== Includes =============================================*/ 36 | /* recommended include order of header files: 37 | * 38 | * 1. include general.h 39 | * 2. include module's own header 40 | * 3... other headers 41 | * 42 | */ 43 | #include "general.h" 44 | #include "wdg.h" 45 | 46 | #include "mcu_cfg.h" 47 | 48 | /*================== Macros and Definitions ===============================*/ 49 | 50 | /** 51 | * defines the watchdog refresh time 52 | */ 53 | #define IWDG_REFRESH_VALUE (4094/8) /* ~1000 ms */ 54 | 55 | 56 | /*================== Constant and Variable Definitions ====================*/ 57 | IWDG_HandleTypeDef hiwdg; 58 | 59 | /*================== Function Prototypes ==================================*/ 60 | 61 | /*================== Function Implementations =============================*/ 62 | 63 | void WDG_Init(void) 64 | { 65 | hiwdg.Instance = IWDG; 66 | hiwdg.Init.Prescaler = IWDG_PRESCALER_64; /* IWDG prescaler set to 64 -> 32kHz/64 (2ms) */ 67 | hiwdg.Init.Reload = IWDG_REFRESH_VALUE; 68 | __HAL_DBGMCU_FREEZE_IWDG(); 69 | HAL_IWDG_Init(&hiwdg); // initialize and start independent watchdog 70 | } 71 | 72 | 73 | 74 | void WDG_IWDG_Refresh(void) 75 | { 76 | HAL_IWDG_Refresh(&hiwdg); // refresh independent watchdog 77 | } 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/application/task/appltask.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file appltask.h 25 | * @author foxBMS Team 26 | * @date 27.08.2015 (date of creation) 27 | * @ingroup APPLICATION 28 | * @prefix APPL 29 | * 30 | * @brief Header for external functions of the application tasks 31 | */ 32 | 33 | #ifndef APPLTASK_H_ 34 | #define APPLTASK_H_ 35 | 36 | /*================== Includes =============================================*/ 37 | #include "appltask_cfg.h" 38 | 39 | /*================== Macros and Definitions ===============================*/ 40 | 41 | /*================== Constant and Variable Definitions ====================*/ 42 | 43 | /*================== Function Prototypes ==================================*/ 44 | 45 | /** 46 | * @brief creates cyclic tasks, called before scheduler start 47 | * 48 | * @return void 49 | */ 50 | extern void APPL_CreateTask(void); 51 | 52 | /** 53 | * @brief creates mutexes, called before scheduler start 54 | * 55 | * @return void 56 | */ 57 | extern void APPL_CreateMutex(void); 58 | 59 | /** 60 | * @brief creates mutex, called before scheduler start 61 | * 62 | * @return void 63 | */ 64 | extern void APPL_CreateEvent(void); 65 | 66 | /** 67 | * @brief 1ms application task 68 | * 69 | * @return void 70 | */ 71 | extern void APPL_TSK_Cyclic_1ms(void); 72 | /** 73 | * @brief 10ms application task 74 | * 75 | * @return void 76 | */ 77 | extern void APPL_TSK_Cyclic_10ms(void); 78 | 79 | /** 80 | * @brief 10ms application task 81 | * 82 | * @return void 83 | */ 84 | extern void APPL_TSK_Cyclic_100ms(void); 85 | 86 | /*================== Function Implementations =============================*/ 87 | 88 | #endif /* APPLTASK_H_ */ 89 | -------------------------------------------------------------------------------- /src/module/config/timer_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file timer_cfg.c 25 | * @author foxBMS Team 26 | * @date 30.09.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix TIM 29 | * 30 | * @brief Configuration of the peripheral timers. 31 | * 32 | * Configuration source file of timer module 33 | * 34 | */ 35 | 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | /* recommended include order of header files: 40 | * 41 | * 1. include general.h 42 | * 2. include module's own header 43 | * 3... other headers 44 | * 45 | */ 46 | #include "general.h" 47 | #include "timer_cfg.h" 48 | 49 | /*================== Macros and Definitions ===============================*/ 50 | 51 | 52 | /*================== Constant and Variable Definitions ====================*/ 53 | 54 | 55 | /*================== Function Prototypes ==================================*/ 56 | 57 | 58 | /*================== Function Implementations =============================*/ 59 | 60 | // Timer-Handle Configuration 61 | TIM_HandleTypeDef htim3 = { 62 | // Generation of Timer Interrupt 63 | .Instance = TIM3, 64 | .Init.CounterMode = TIM_COUNTERMODE_UP, 65 | .Init.Period = 8400 - 1, 66 | .Init.Prescaler = 10 - 1, 67 | .Init.ClockDivision = TIM_CLOCKDIVISION_DIV1, 68 | }; 69 | 70 | TIM_HandleTypeDef htim4 = { 71 | // PWM Output 72 | .Instance = TIM4, 73 | .Init.CounterMode = TIM_COUNTERMODE_UP, 74 | .Init.ClockDivision = TIM_CLOCKDIVISION_DIV1, 75 | }; 76 | 77 | TIM_HandleTypeDef htim9 = { 78 | // PWM IC timer 79 | .Instance = TIM9, 80 | .Init.CounterMode = TIM_COUNTERMODE_UP, 81 | .Init.Period = 0xFFFF, 82 | .Init.ClockDivision = TIM_CLOCKDIVISION_DIV1, 83 | }; 84 | 85 | -------------------------------------------------------------------------------- /src/application/config/appltask_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file appltask_cfg.h 25 | * @author foxBMS Team 26 | * @date 26.08.2015 (date of creation) 27 | * @ingroup APPLICATION_CONF 28 | * @prefix APPL 29 | * 30 | * @brief Configuration for application tasks 31 | * 32 | */ 33 | 34 | #ifndef APPLTASK_CFG_H_ 35 | #define APPLTASK_CFG_H_ 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | #include "os.h" 40 | 41 | /*================== Macros and Definitions ===============================*/ 42 | 43 | /*================== Constant and Variable Definitions ====================*/ 44 | 45 | /** 46 | * Task configuration of the 1ms application task 47 | @ingroup API_OS 48 | */ 49 | extern BMS_Task_Definition_s appl_tskdef_1ms; 50 | 51 | /** 52 | * Task configuration of the 10ms application task 53 | @ingroup API_OS 54 | */ 55 | extern const BMS_Task_Definition_s appl_tskdef_10ms; 56 | 57 | /** 58 | * Task configuration of the 100ms application task 59 | @ingroup API_OS 60 | */ 61 | extern BMS_Task_Definition_s appl_tskdef_100ms; 62 | 63 | /*================== Function Prototypes ==================================*/ 64 | 65 | /** 66 | * @brief user application task 1 milliseconds 67 | @ingroup API_OS 68 | * 69 | * @return void 70 | */ 71 | extern void APPL_Cyclic_1ms(void); 72 | 73 | /** 74 | * @brief user application task 10 milliseconds 75 | @ingroup API_OS 76 | * 77 | * @return void 78 | */ 79 | extern void APPL_Cyclic_10ms(void); 80 | 81 | /** 82 | * @brief user application task 100 milliseconds 83 | @ingroup API_OS 84 | * 85 | * @return void 86 | */ 87 | extern void APPL_Cyclic_100ms(void); 88 | 89 | /*================== Function Implementations =============================*/ 90 | 91 | #endif /* APPLTASK_CFG_H_ */ 92 | -------------------------------------------------------------------------------- /src/module/config/adc_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file adc_cfg.c 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix ADC 29 | * 30 | * @brief Configuration for the analog to digital converter 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "adc_cfg.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | ADC_HandleTypeDef adc_devices[] = { 49 | { 50 | .Instance = ADC1, 51 | 52 | .Init.Resolution = ADC_RESOLUTION_12B, 53 | .Init.DataAlign = ADC_DATAALIGN_RIGHT, 54 | .Init.ScanConvMode = DISABLE, 55 | .Init.ContinuousConvMode = DISABLE, 56 | .Init.DiscontinuousConvMode = DISABLE, 57 | .Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE, 58 | .Init.ExternalTrigConv = ADC_SOFTWARE_START, 59 | .Init.DMAContinuousRequests = DISABLE, 60 | 61 | .Init.NbrOfDiscConversion = 1, 62 | .Init.NbrOfConversion = 1, 63 | 64 | .Init.EOCSelection = ADC_EOC_SINGLE_CONV, 65 | .Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2, 66 | } 67 | 68 | }; 69 | 70 | 71 | const uint8_t adc_number_of_used_devices = sizeof(adc_devices)/sizeof(ADC_HandleTypeDef); 72 | 73 | /*================== Function Prototypes ==================================*/ 74 | 75 | /*================== Function Implementations =============================*/ 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/module/config/sdram_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file sdram_cfg.c 25 | * @author foxBMS Team 26 | * @date 24.05.2016 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix extsd 29 | * 30 | * @brief Configuration and Data Definitons of external SDRAM 31 | * 32 | */ 33 | 34 | 35 | /*================== Includes =============================================*/ 36 | /* recommended include order of header files: 37 | * 38 | * 1. include general.h 39 | * 2. include module's own header 40 | * 3... other headers 41 | * 42 | */ 43 | #include "general.h" 44 | #include "sdram_cfg.h" 45 | 46 | #include "mcu_cfg.h" 47 | 48 | #ifdef HAL_SDRAM_MODULE_ENABLED 49 | /*================== Macros and Definitions ===============================*/ 50 | 51 | /*================== Constant and Variable Definitions ====================*/ 52 | #if 0 53 | uint32_t extsd_testbuffer[100]={0x10,0xf,0xe,0xd,0xc,0xb,0xa,0x9,0x8,7,6,5,4,3,2,1,0xaa}; 54 | volatile uint32_t extsd_test2; 55 | #endif 56 | /*================== Function Prototypes ==================================*/ 57 | 58 | /*================== Function Implementations =============================*/ 59 | 60 | void SDRAM_c_init(void) 61 | { 62 | uint32_t *extRAMptr = (uint32_t*)(&_s_extdata[0]); // start address of external SDRAM .data-section 63 | uint32_t *flashptr = (uint32_t*)(&_sidata_ext[0]); // start address of Flash related to .data-section 64 | 65 | while( extRAMptr < (uint32_t*)(&_e_extdata[0]) ) // compare to end address of external SDRAM .data-section 66 | { 67 | *extRAMptr++ = *flashptr++; 68 | } 69 | } 70 | #if 0 71 | void SDRAM_testram(void) 72 | { 73 | uint32_t i=0; 74 | for(i=0;i<(sizeof(extsd_testbuffer)/sizeof(uint32_t));i++) 75 | { 76 | extsd_testbuffer[i]=i; 77 | } 78 | extsd_test2++; 79 | } 80 | #endif 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/module/config/rcc_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rcc_cfg.c 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix RCC 29 | * 30 | * @brief Configuration for the clock system. 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "rcc_cfg.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | RCC_OscInitTypeDef RCC_OscInitStruct = { 49 | .OscillatorType = RCC_OSCILLATORTYPE_HSE, 50 | .HSEState = RCC_HSE_ON, 51 | .PLL.PLLState = RCC_PLL_ON, 52 | .PLL.PLLSource = RCC_PLLSOURCE_HSE, 53 | .PLL.PLLM = RCC_PLL_M, // Oscillator Clock: 8MHz -> (8Mhz / 8) * 336 / 2 -> 168Mhz 54 | .PLL.PLLN = RCC_PLL_N, 55 | .PLL.PLLP = RCC_PLL_P, 56 | .PLL.PLLQ = RCC_PLL_Q // Oscillator Clock: 8MHz -> (8Mhz / 8) * 336 / 7 -> 48Mhz 57 | }; 58 | 59 | 60 | RCC_ClkInitTypeDef RCC_ClkInitStruct = { 61 | .ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2, 62 | .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK, // System Clock Source: PLL-Clock (Cortex-Core, AHB-Bus, DMA, memory) 63 | .AHBCLKDivider = RCC_AHBCLKDivider, // Div=1 , AHB CLOCK: 168MHz 64 | .APB1CLKDivider = RCC_APB1CLKDivider, // Div=4 , APB1 CLOCK: 42MHz 65 | .APB2CLKDivider = RCC_APB2CLKDivider // Div=2 , APB2 CLOCK: 84MHz 66 | }; 67 | 68 | 69 | /*================== Function Prototypes ==================================*/ 70 | 71 | 72 | /*================== Function Implementations =============================*/ 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/module/intermcu/intermcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file intermcu.h 25 | * @author foxBMS Team 26 | * @date 04.03.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix IMC 29 | * 30 | * @brief Driver for the inter-MCU communication. 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "intermcu.h" 44 | 45 | #include "spi.h" 46 | 47 | /*================== Macros and Definitions ===============================*/ 48 | 49 | /*================== Constant and Variable Definitions======================*/ 50 | uint8_t readArray[] = {0}; 51 | 52 | /*================== Function Prototypes ==================================*/ 53 | 54 | /*================== Function Implementations =============================*/ 55 | 56 | /** 57 | * @brief Sends one byte via the internal SPI bus connecting both the main MCU and the Safety MCU 58 | * 59 | * @param message: the byte to be sent 60 | * 61 | * @return void 62 | */ 63 | void IMC_sendByte(uint8_t message) { 64 | uint8_t transmitArray[] = {message}; 65 | 66 | SPI_SetCS(2); 67 | HAL_SPI_Transmit(SPI_HANDLE_IMC, transmitArray, 1, 1000); 68 | SPI_UnsetCS(2); 69 | } 70 | 71 | /** 72 | * @brief Enables a listener interrupt on the internal SPI bus connecting both the main MCU and the Safety MCU 73 | * 74 | * @return void 75 | */ 76 | void IMC_enableInterrupt(void) { 77 | HAL_SPI_Receive_IT(SPI_HANDLE_IMC, readArray, 1); 78 | } 79 | 80 | /** 81 | * @brief Reads one byte on the internal SPI bus connecting both the main MCU and the Safety MCU that has been received by interrupt 82 | * 83 | * @return the received byte 84 | */ 85 | uint8_t IMC_readByte(void) { 86 | return readArray[0]; 87 | } 88 | -------------------------------------------------------------------------------- /src/engine/task/enginetask.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file enginetask.h 25 | * @author foxBMS Team 26 | * @date 27.08.2015 (date of creation) 27 | * @ingroup ENGINE 28 | * @prefix ENG 29 | * 30 | * @brief Header for external functions of the engine task 31 | * 32 | */ 33 | 34 | #ifndef ENGINETASK_H_ 35 | #define ENGINETASK_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "enginetask_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*================== Constant and Variable Definitions ====================*/ 43 | 44 | /*================== Function Prototypes ==================================*/ 45 | 46 | /** 47 | * @brief Initializes modules that were not initialized before scheduler start. 48 | * 49 | * This function is called after the scheduler started but before any cyclic task runs. 50 | * Here modules get initialized that are not used during the startup process. 51 | * 52 | * @return void 53 | */ 54 | extern void ENG_Init(void); 55 | 56 | 57 | /** 58 | * @brief Cyclic 1ms task for the LTC measurement 59 | * 60 | * @return void 61 | */ 62 | extern void ENG_TSK_Cyclic_1ms(void); 63 | 64 | /** 65 | * @brief Task for system- and bmscontrol and SOX algorithms 66 | * 67 | * @return void 68 | */ 69 | extern void ENG_TSK_Cyclic_10ms(void); 70 | 71 | /** 72 | * @brief Task for ADC control, balancing control and isolation 73 | * measurement 74 | * 75 | * @return void 76 | */ 77 | extern void ENG_TSK_Cyclic_100ms(void); 78 | 79 | /** 80 | * @brief Engine Task for handling of events 81 | * 82 | * @return void 83 | */ 84 | extern void ENG_TSK_EventHandler(void); 85 | 86 | /** 87 | * @brief Engine Task for diagnosis 88 | * 89 | * @return void 90 | */ 91 | extern void ENG_TSK_Diagnosis(void); 92 | /*================== Function Implementations =============================*/ 93 | 94 | #endif /* ENGINETASK_H_ */ 95 | -------------------------------------------------------------------------------- /src/engine/config/enginetask_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file enginetask_cfg.h 25 | * @author foxBMS Team 26 | * @date 26.08.2015 (date of creation) 27 | * @ingroup ENGINE_CONF 28 | * @prefix ENG 29 | * 30 | * @brief Engine task configuration header 31 | * 32 | */ 33 | 34 | #ifndef ENGINETASK_CFG_H_ 35 | #define ENGINETASK_CFG_H_ 36 | 37 | // FIXME is separation of cfg and normal file reasonable? actually I would think of it exactly in the opposite way: implementation changes in cfg.c and fixed code in .c 38 | 39 | /*================== Includes =============================================*/ 40 | 41 | #include "os.h" 42 | 43 | /*================== Macros and Definitions ===============================*/ 44 | 45 | /*================== Constant and Variable Definitions ====================*/ 46 | // FIXME doxygen comments 47 | // Task Configurations 48 | extern BMS_Task_Definition_s eng_tskdef_cyclic_1ms; 49 | extern BMS_Task_Definition_s eng_tskdef_cyclic_10ms; 50 | extern BMS_Task_Definition_s eng_tskdef_cyclic_100ms; 51 | extern BMS_Task_Definition_s eng_tskdef_eventhandler; 52 | extern BMS_Task_Definition_s eng_tskdef_diagnosis; 53 | 54 | extern QueueHandle_t data_queueID; 55 | /*================== Function Prototypes ==================================*/ 56 | 57 | /** 58 | * @brief creates queues, called before scheduler start 59 | * 60 | * @return void 61 | */ 62 | extern void ENG_CreateQueues(void); 63 | 64 | 65 | /** 66 | * @brief creates mutexes, called before scheduler start 67 | * 68 | * @return void 69 | */ 70 | extern void ENG_CreateMutex(void); 71 | 72 | 73 | /** 74 | * @brief creates events, called before scheduler start 75 | * 76 | * @return void 77 | */ 78 | extern void ENG_CreateEvent(void); 79 | 80 | /** 81 | * @brief creates cyclic tasks, called before scheduler start 82 | * 83 | * @return void 84 | */ 85 | extern void ENG_CreateTask(void); 86 | 87 | /*================== Function Implementations =============================*/ 88 | 89 | #endif /* ENGINETASK_CFG_H_ */ 90 | -------------------------------------------------------------------------------- /src/application/config/sox_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file sox_cfg.c 25 | * @author foxBMS Team 26 | * @date 16.11.2015 (date of creation) 27 | * @ingroup APPLICATION_CONF 28 | * @prefix SOX 29 | * 30 | * @brief Configuration for SOX 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | #include "general.h" 36 | #include "sox_cfg.h" 37 | 38 | /*================== Macros and Definitions ===============================*/ 39 | 40 | 41 | /*================== Constant and Variable Definitions ====================*/ 42 | 43 | SOX_SOF_CONFIG_s sox_sof_config = { 44 | .I_ChargeMax_Cont = SOX_CURRENT_MAX_CONTINUOUS_CHARGE, 45 | .I_DischaMax_Cont = SOX_CURRENT_MAX_CONTINUOUS_DISCHARGE, 46 | .I_Limphome = SOX_CURRENT_LIMP_HOME, 47 | .Cutoff_TLow_Discha = SOX_TEMP_LOW_CUTOFF_DISCHARGE, 48 | .Limit_TLow_Discha = SOX_TEMP_LOW_LIMIT_DISCHARGE, 49 | .Cutoff_TLow_Charge = SOX_TEMP_LOW_CUTOFF_CHARGE, 50 | .Limit_TLow_Charge = SOX_TEMP_LOW_LIMIT_CHARGE, 51 | .Cutoff_THigh_Discha = SOX_TEMP_HIGH_CUTOFF_DISCHARGE, 52 | .Limit_THigh_Discha = SOX_TEMP_HIGH_LIMIT_DISCHARGE, 53 | .Cutoff_THigh_Charge = SOX_TEMP_HIGH_CUTOFF_CHARGE, 54 | .Limit_THigh_Charge = SOX_TEMP_HIGH_LIMIT_CHARGE, 55 | .Limit_Soc_Charge = SOX_SOC_LIMIT_CHARGE, 56 | .Cutoff_Soc_Charge = SOX_SOC_CUTOFF_CHARGE, 57 | .Limit_Soc_Discha = SOX_SOC_LIMIT_DISCHARGE, 58 | .Cutoff_Soc_Discha = SOX_SOC_CUTOFF_DISCHARGE, 59 | .Limit_Voltage_Charge = SOX_VOLT_LIMIT_CHARGE, 60 | .Cutoff_Voltage_Charge = SOX_VOLT_CUTOFF_CHARGE, 61 | .Limit_Voltage_Discha = SOX_VOLT_LIMIT_DISCHARGE, 62 | .Cutoff_Voltage_Discha = SOX_VOLT_CUTOFF_DISCHARGE 63 | }; 64 | 65 | 66 | /*================== Function Prototypes ==================================*/ 67 | 68 | 69 | /*================== Function Implementations =============================*/ 70 | -------------------------------------------------------------------------------- /src/module/config/rtc_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rtc_cfg.h 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix RTC 29 | * 30 | * @brief Headers for the configuration for the real time clock 31 | * 32 | */ 33 | 34 | #ifndef RTC_CONF_H_ 35 | #define RTC_CONF_H_ 36 | 37 | /*================== Includes =============================================*/ 38 | #include "mcu_cfg.h" 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | /* backup size of the registers 80 Byte */ 42 | #define RTC_DATAVALID_VARIABLE (hrtc.Instance->BKP0R) // rtc backup register 43 | #define RTC_BKPSRAM_DATAVALID_VARIABLE (hrtc.Instance->BKP1R) // bkpsram data 44 | #define RTC_BKPDIAG_DATAVALID_VARIABLE (hrtc.Instance->BKP2R) // bpksram diag data 45 | #define RTC_NVMRAM_DATAVALID_VARIABLE (hrtc.Instance->BKP3R) // non-volatile data backups 46 | #define RTC_DOWNLOAD_REQUEST_FLAG (hrtc.Instance->BKP4R) // flag for flashing new software 47 | 48 | 49 | /** 50 | * struct for the initialization and configuration of RTC 51 | */ 52 | typedef struct { 53 | RCC_OscInitTypeDef oscInitStruct; /*!< clock configuration of RTCs clock source */ 54 | RCC_PeriphCLKInitTypeDef clkInitStruct; /*!< clock source of RTC: RTCClk can be derived from HSE (ext. crystal), LSE (ext. crystal), LSI (internal RC oscillator) */ 55 | RTC_InitTypeDef initconfig; /*!< RTC configuration: hour format, prescaler,... */ 56 | uint8_t timeformat; /*!< date and time format configuration (binary or BCD) */ 57 | RTC_TimeTypeDef defaultTime; /*!< default time configuration */ 58 | RTC_DateTypeDef defaultDate; /*!< default date configuration */ 59 | } RTC_CFG_s; 60 | 61 | 62 | /*================== Constant and Variable Definitions ====================*/ 63 | extern RTC_CFG_s rtc_cfg; 64 | 65 | /*================== Function Prototypes ===================================*/ 66 | 67 | /*================== Function Implementations ==============================*/ 68 | 69 | #endif /* RTC_CONF_H_ */ 70 | -------------------------------------------------------------------------------- /src/module/config/io_eval_board_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file io_eval_board_cfg.h 25 | * @author foxBMS Team 26 | * @date 26.08.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix none 29 | * 30 | * @brief Configuration for the I/O ports for the evaluation board 31 | * 32 | */ 33 | 34 | #ifndef IO_CFG_H_EVAL_BOARD_H_ 35 | #define IO_CFG_H_EVAL_BOARD_H_ 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | #define PIN_MCU_0_BMS_INTERFACE_SPI_NSS IO_PE_3 // free io-pin on the discovery board 43 | #define PIN_MCU_0_BMS_INTERFACE_SPI_MOSI IO_PE_6 // free io-pin on the discovery board 44 | #define PIN_MCU_0_BMS_INTERFACE_SPI_MISO IO_PE_5 // free io-pin on the discovery board 45 | #define PIN_MCU_0_BMS_INTERFACE_SPI_SCK IO_PE_2 // free io-pin on the discovery board 46 | 47 | #define PIN_CAN1_TX IO_PB_9 // free io-pin on the discovery board 48 | #define PIN_CAN1_RX IO_PB_8 // free io-pin on the discovery board 49 | #define PIN_CAN0_TX IO_PB_6 // free io-pin on the discovery board 50 | #define PIN_CAN0_RX IO_PB_5 // free io-pin on the discovery board 51 | 52 | #define TEST_LED IO_PC_8 // package pin:117 53 | #define TEST_INPUT IO_PG_9 // package pin:152 54 | #define TEST_LED3 IO_PG_13 // package pin:156 55 | #define TEST_LED4 IO_PG_14 // package pin:157 56 | #define TEST_OUTPUT IO_PB_4 // package pin:162 57 | 58 | /*================== Constant and Variable Definitions ====================*/ 59 | 60 | /*================== Function Prototypes ==================================*/ 61 | 62 | /*================== Function Implementations =============================*/ 63 | 64 | #endif /* IO_CFG_H_EVAL_BOARD_H_ */ 65 | -------------------------------------------------------------------------------- /src/module/mcu/timing.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file timing.h 25 | * @author foxBMS Team 26 | * @date 03.02.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix TMG 29 | * 30 | * @brief Headers for the functions for the MCU to manage time and interrupts 31 | * 32 | */ 33 | 34 | #ifndef UTILS_TIMING_H_ 35 | #define UTILS_TIMING_H_ 36 | 37 | 38 | /*================== Includes =============================================*/ 39 | #include "os.h" 40 | 41 | /*================== Macros and Definitions ===============================*/ 42 | 43 | /*================== Constant and Variable Definitions ====================*/ 44 | 45 | /*================== Function Prototypes ==================================*/ 46 | 47 | /** 48 | * @brief returns the time difference between to time stamps as OS_TIMER_s struct 49 | * 50 | * @param measurementTimeOlder (type: OS_TIMER_s) 51 | * @param measurementTimeNewer (type: OS_TIMER_s) 52 | * 53 | * @return timeDifference (type: OS_TIMER_s) 54 | */ 55 | extern OS_TIMER_s TMG_calculateTimeDifference(OS_TIMER_s measurementTimeOlder, OS_TIMER_s measurementTimeNewer); 56 | 57 | /** 58 | * @brief returns E_OK if there is no timing violation, return E_NOT_OK if there is timing violation 59 | * 60 | * @param measurementTime (type: OS_TIMER_s) 61 | * @param currentTime (type: OS_TIMER_s) 62 | * @param allowedDelay (type: CONT_SWITCH_e) 63 | * 64 | * @return timingViolation (type: STD_RETURN_TYPE_e) 65 | */ 66 | extern STD_RETURN_TYPE_e TMG_TimingViolation(OS_TIMER_s measurementTime, OS_TIMER_s currentTime, OS_TIMER_s allowedDelay); 67 | 68 | /** 69 | * @brief returns E_OK if there is no timing violation, return E_NOT_OK if there is timing violation 70 | * use osKernelSysTick() for the time stamps. 71 | * @param measurementTimeOlder (type: uint32_t) 72 | * @param measurementTimeNewer (type: uint32_t) 73 | * @param allowedDelay (type: uint32_t) 74 | * 75 | * @return timingViolation (type: STD_RETURN_TYPE_e) 76 | */ 77 | extern uint32_t TMG_TimingViolationSimple(uint32_t measurementTimeOlder, uint32_t measurementTimeNewer, uint32_t allowedDelay); 78 | /*================== Function Implementations =============================*/ 79 | 80 | #endif /* UTILS_TIMING_H_ */ 81 | -------------------------------------------------------------------------------- /src/general/config/stm32f4xx_it.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @author STMicroelectronics 3 | * @date 2016 4 | * @ingroup GENERAL_CONF 5 | * @brief HAL IT Module header, headers for definition of IRQ handlers for hardware units, 6 | * based on project examples Templates\Inc\stm32f4xx_it.h 7 | * 8 | */ 9 | 10 | /** 11 | ****************************************************************************** 12 | * @file stm32f4xx_it.h 13 | * @author MCD Application Team 14 | * @version V1.0.3 15 | * @date 06-May-2016 16 | * @brief This file contains the headers of the interrupt handlers. 17 | ****************************************************************************** 18 | * @attention 19 | * 20 | *

© COPYRIGHT(c) 2016 STMicroelectronics

21 | * 22 | * Redistribution and use in source and binary forms, with or without modification, 23 | * are permitted provided that the following conditions are met: 24 | * 1. Redistributions of source code must retain the above copyright notice, 25 | * this list of conditions and the following disclaimer. 26 | * 2. Redistributions in binary form must reproduce the above copyright notice, 27 | * this list of conditions and the following disclaimer in the documentation 28 | * and/or other materials provided with the distribution. 29 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 30 | * may be used to endorse or promote products derived from this software 31 | * without specific prior written permission. 32 | * 33 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 34 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 35 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 36 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 37 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 38 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 39 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 40 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 41 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 42 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | * 44 | ****************************************************************************** 45 | */ 46 | 47 | /* Define to prevent recursive inclusion -------------------------------------*/ 48 | #ifndef __STM32F4xx_IT_H 49 | #define __STM32F4xx_IT_H 50 | 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /* Includes ------------------------------------------------------------------*/ 56 | #include "stm32f4xx.h" 57 | 58 | /* Exported types ------------------------------------------------------------*/ 59 | /* Exported constants --------------------------------------------------------*/ 60 | /* Exported macro ------------------------------------------------------------*/ 61 | /* Exported functions ------------------------------------------------------- */ 62 | 63 | void NMI_Handler(void); 64 | void HardFault_Handler(void); 65 | void MemManage_Handler(void); 66 | void BusFault_Handler(void); 67 | void UsageFault_Handler(void); 68 | void SVC_Handler(void); 69 | void DebugMon_Handler(void); 70 | void PendSV_Handler(void); 71 | void SysTick_Handler(void); 72 | void CAN1_TX_IRQHandler(void); /* CAN1 TX */ 73 | void CAN1_RX0_IRQHandler(void); /* CAN1 RX0 */ 74 | void CAN1_RX1_IRQHandler(void); /* CAN1 RX1 */ 75 | void CAN1_SCE_IRQHandler(void); /* CAN1 SCE */ 76 | void CAN0_TX_IRQHandler(void); /* CAN0 TX */ 77 | void CAN0_RX0_IRQHandler(void); /* CAN0 RX0 */ 78 | void CAN0_RX1_IRQHandler(void); /* CAN0 RX1 */ 79 | void CAN0_SCE_IRQHandler(void); /* CAN0 SCE */ 80 | void TIM3_IRQHandler(void); /* TIM3 Interrupt Handler */ 81 | void EXTI15_10_IRQHandler(void); 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* __STM32F4xx_IT_H */ 88 | 89 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 90 | -------------------------------------------------------------------------------- /src/general/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file main.h 25 | * @author foxBMS Team 26 | * @date 26.08.2015 (date of creation) 27 | * @ingroup GENERAL 28 | * @prefix none 29 | * 30 | * @brief Main function header 31 | * 32 | */ 33 | 34 | #ifndef MAIN_H_ 35 | #define MAIN_H_ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | 42 | /*================== Includes =============================================*/ 43 | #include "rtc.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | /** 47 | * Systemwide low level control, status Information of system 48 | */ 49 | typedef struct { 50 | RTC_Date_s date; /*!< RCC clock control & status register at startup */ 51 | RTC_Time_s time; /*!< state of Eeprom Driver State Machine */ 52 | //uint32_t date; /*!< RCC clock control & status register at startup */ 53 | //uint32_t time; /*!< state of Eeprom Driver State Machine */ 54 | uint32_t dummy[4]; /*!< */ 55 | } MAIN_RESETSOURCE_s; 56 | 57 | 58 | /** 59 | * Systemwide low level control, status Information of system 60 | */ 61 | typedef struct { 62 | uint32_t CSR; /*!< RCC clock control & status register at startup */ 63 | uint32_t resetcounter; /*!< state of Eeprom Driver State Machine */ 64 | RTC_Date_s boot_rtcdate; /*!< boot date */ 65 | RTC_Time_s boot_rtctime; /*!< boot time */ 66 | RTC_Date_s terminate_rtcdate; /*!< TODO */ 67 | RTC_Time_s terminate_rtctime; /*!< TODO */ 68 | uint32_t dummy[4]; /*!< */ 69 | MAIN_RESETSOURCE_s resetsource[20]; /*!< in counts of 1ms */ 70 | } MAIN_STATUS_s; 71 | 72 | 73 | /*================== Constant and Variable Definitions ====================*/ 74 | 75 | /*================== Function Prototypes ==================================*/ 76 | 77 | /*================== Function Implementations =============================*/ 78 | 79 | #endif /* MAIN_H_ */ 80 | -------------------------------------------------------------------------------- /src/module/dma/dma.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file dma.c 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix DMA 29 | * 30 | * @brief Driver for the DMA module (encapsulation of the init function). 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "dma.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | 49 | /*================== Function Prototypes ==================================*/ 50 | 51 | /*================== Function Implementations =============================*/ 52 | 53 | void DMA_Init(DMA_HandleTypeDef *hdma) { 54 | 55 | uint8_t i = 0; 56 | 57 | if(hdma != NULL) { 58 | 59 | for (i = 0; i < dma_number_of_used_streams; i++) { 60 | 61 | if ( (hdma[i].Instance == DMA1_Stream0) 62 | ||(hdma[i].Instance == DMA1_Stream1) 63 | ||(hdma[i].Instance == DMA1_Stream2) 64 | ||(hdma[i].Instance == DMA1_Stream3) 65 | ||(hdma[i].Instance == DMA1_Stream4) 66 | ||(hdma[i].Instance == DMA1_Stream5) 67 | ||(hdma[i].Instance == DMA1_Stream6) 68 | ||(hdma[i].Instance == DMA1_Stream7) 69 | ) { 70 | __HAL_RCC_DMA1_CLK_ENABLE(); 71 | } 72 | 73 | if ( (hdma[i].Instance == DMA2_Stream0) 74 | ||(hdma[i].Instance == DMA2_Stream1) 75 | ||(hdma[i].Instance == DMA2_Stream2) 76 | ||(hdma[i].Instance == DMA2_Stream3) 77 | ||(hdma[i].Instance == DMA2_Stream4) 78 | ||(hdma[i].Instance == DMA2_Stream5) 79 | ||(hdma[i].Instance == DMA2_Stream6) 80 | ||(hdma[i].Instance == DMA2_Stream7) 81 | ) { 82 | __HAL_RCC_DMA2_CLK_ENABLE(); 83 | } 84 | 85 | HAL_DMA_Init(&hdma[i]); 86 | 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/engine/task/enginetask.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file enginetask.c 25 | * @author foxBMS Team 26 | * @date 27.08.2015 (date of creation) 27 | * @ingroup ENGINE 28 | * @prefix ENG 29 | * 30 | * @brief Calls of functions within engine task 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | #include "general.h" 36 | #include "enginetask.h" 37 | 38 | #include "ltc.h" 39 | #include "syscontrol.h" 40 | #include "can.h" 41 | #include "cansignal.h" 42 | #include "isoguard.h" 43 | #include "adc.h" 44 | #include "wdg.h" 45 | #include "bal.h" 46 | #include "intermcu.h" 47 | #include "bkpsram.h" 48 | 49 | /*================== Macros and Definitions ===============================*/ 50 | 51 | 52 | /*================== Constant and Variable Definitions ====================*/ 53 | 54 | 55 | /*================== Function Prototypes ==================================*/ 56 | 57 | 58 | /*================== Function Implementations =============================*/ 59 | 60 | void ENG_Init(void) { 61 | SOF_Init(); 62 | ISO_Init(); 63 | #if BUILD_MODULE_ENABLE_SAFETY_FEATURES == 1 64 | IMC_enableInterrupt(); 65 | #endif 66 | } 67 | 68 | void ENG_TSK_Cyclic_1ms(void) { 69 | 70 | LTC_Ctrl(LTC_HAS_TO_MEASURE); 71 | LTC_Trigger(); 72 | EEPR_Trigger(); 73 | 74 | } 75 | 76 | void ENG_TSK_Cyclic_10ms(void) { 77 | SYSCTRL_Trigger(SYS_MODE_CYCLIC_EVENT); 78 | 79 | #if CAN_USE_CAN_NODE0 80 | CAN_TxMsgBuffer(CAN_NODE0); 81 | #endif 82 | #if CAN_USE_CAN_NODE1 83 | CAN_TxMsgBuffer(CAN_NODE1); 84 | #endif 85 | 86 | #if BUILD_MODULE_ENABLE_WATCHDOG 87 | WDG_IWDG_Refresh(); 88 | #endif 89 | } 90 | 91 | void ENG_TSK_Cyclic_100ms(void) { 92 | static uint8_t counter = 0; 93 | 94 | 95 | ADC_Ctrl(); 96 | 97 | // Read every 200ms because of possible jitter and lowest Bender frequency 10Hz -> 100ms 98 | if(counter % 2 == 0) { 99 | ISO_MeasureInsulation(); 100 | } 101 | 102 | if(counter == 255) 103 | NVM_SetOperatingHours(); 104 | 105 | counter++; 106 | } 107 | 108 | 109 | void ENG_TSK_EventHandler(void) { 110 | ; 111 | } 112 | 113 | void ENG_TSK_Diagnosis(void) { 114 | ; 115 | } 116 | 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # foxBMS [![Build Status](https://travis-ci.org/foxBMS/foxBMS-primary.svg?branch=master)](https://travis-ci.org/foxBMS/foxBMS-primary) 2 | 3 | foxBMS is a free, open and flexible development environment to design battery 4 | management systems. It is the first modular open source BMS development 5 | platform. 6 | 7 | ## foxBMS Project Setup 8 | The foxBMS project consists of several repositories. 9 | 10 | The foxConda-installer repository contains the installer for the foxConda 11 | environment. This environment provides all the tools necessary to generate the 12 | documentation, compile the code for the MCUs and flash the generated binaries on 13 | the MCUs (e.g., Python, git, GCC). 14 | 15 | The starting point to get foxBMS is the foxBMS-setup 16 | repository (https://github.com/foxBMS/foxBMS-setup), which contains 17 | the general setup files for the foxBMS project. It includes a setup script 18 | (bootstrap.py) which clones all the other needed repositories. The needed 19 | documentation will be generated automatically after these repositories have been 20 | cloned. The generated documentation is found in the directory ./build. 21 | After the bootstrap step, the top project directory (foxBMS-setup) structure 22 | looks like this: 23 | 24 | - foxBMS-setup 25 | - .git * 26 | - build 27 | - foxBMS-documentation 28 | - foxBMS-hardware 29 | - foxBMS-primary 30 | - foxBMS-secondary 31 | - foxBMS-tools 32 | - FreeRTOS 33 | - hal 34 | - .gitignore * 35 | - bootstrap.py 36 | - build.py 37 | - CHANGELOG.md 38 | - clean.py 39 | - LICENSE.md 40 | - README.md 41 | - wscript 42 | 43 | * Directories and files with starting full stop are hidden in Windows in default 44 | configuration. 45 | 46 | There is a help available by running "python bootstrap.py -h". 47 | 48 | ## foxBMS Repositories 49 | 50 | The foxConda-installer and foxBMS-setup repositories have already been described. 51 | 52 | foxBMS is made out of two Microcontroller Units (MCU), named primary and 53 | secondary. The C code for the primary MCU is found in the repository 54 | foxBMS-primary (https://github.com/foxBMS/foxBMS-primary). The C code for the 55 | secondary MCU is found in the repository foxBMS-secondary 56 | (https://github.com/foxBMS/foxBMS-secondary). The Doxygen documentation is 57 | generated from these sources into ./build/primary/doxygen/html and 58 | ./build/secondary/doxygen/html respectively. The main file is in both cases 59 | index.html. 60 | 61 | The layout and schematic files for the foxBMS hardware are found in the 62 | foxBMS-hardware repository (https://github.com/foxBMS/foxBMS-hardware). 63 | 64 | The Hardware Abstraction Layer (hal) for foxBMS is found in the hal-repository 65 | (https://github.com/foxBMS/hal.) The real time operating system (FreeRTOS) for 66 | foxBMS is found in the FreeRTOS-repository (https://github.com/foxBMS/FreeRTOS.) 67 | 68 | The tools needed for foxBMS are in the foxBMS-tools-repository 69 | (https://github.com/foxBMS/foxBMS-tools.) 70 | 71 | The general documentation files for the foxBMS project are found in the 72 | foxBMS-documentation repository 73 | (https://github.com/foxBMS/foxBMS-documentation). The sphinx documentation is 74 | found in foxBMS-documentation/doc/sphinx while the Doxygen documentation 75 | configuration is found in foxBMS-documentation/doc/doxygen. The Doxygen 76 | documentation itself is found in the software sources of the primary and 77 | secondary microcontroller. The general documentation, rendered from the sphinx 78 | sources is found in ./build/sphinx/foxBMS-documentation/doc/sphinx/html. The 79 | main file is index.html 80 | 81 | A generated version of the Sphinx documentation can be found at 82 | http://foxbms.readthedocs.io/. It explains the structure of the 83 | foxBMS hardware, how to install the foxConda environment and how to use foxConda 84 | to compile and flash the sources. 85 | 86 | ## Building the Sources 87 | For building the software, open a shell and type "python build.py -h". All 88 | available build options will be displayed. The top build directory is ./build. 89 | 90 | ## Cleaning the ./build-Directory 91 | For cleaning instructions open a shell and type "python clean.py -h". All 92 | available cleaning options will be displayed. -------------------------------------------------------------------------------- /src/module/config/isoguard_cfg.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file isoguard_cfg.h 25 | * @author foxBMS Team 26 | * @date 08.12.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix ISO 29 | * 30 | * @brief Headers for the configuration for the isolation monitoring. 31 | * 32 | * Configuration header file for isguard module 33 | */ 34 | 35 | #ifndef ISOGUARD_CFG_H_ 36 | #define ISOGUARD_CFG_H_ 37 | 38 | /*================== Includes =============================================*/ 39 | 40 | /*================== Macros and Definitions ===============================*/ 41 | 42 | /*fox 43 | * Enable/Disable switch for the isoguard module 44 | * @var ISO_ISOGUARD_ENABLE 45 | * @type toggle 46 | * @default True 47 | * @group ISOGUARD 48 | * @level advanced 49 | */ 50 | 51 | /** 52 | * Enable/Disable switch for the isoguard module 53 | */ 54 | #define ISO_ISOGUARD_ENABLE 55 | 56 | /*fox 57 | * Periodic calling time of isoguard measurement. Specifies the hysteresis 58 | * for valid measurement values after startup or reset 59 | * @var ISO_CYCLE_TIME 60 | * @type int 61 | * @unit ms 62 | * @valid 100 < x 63 | * @default 200 64 | * @group ISO 65 | * @level devel 66 | * @group ISOGUARD 67 | */ 68 | 69 | /** 70 | * Specifies the hysteresis for valid measurement values after 71 | * startup or reset 72 | */ 73 | #define ISO_CYCLE_TIME 200 74 | 75 | /*fox 76 | * Resistance threshold in kOhm to differentiate of ISOIR_RESIST_MEAS_GOOD and 77 | * ISOIR_RESIST_MEAS_BAD in NORMAL_MODE within duty cycle of 10%..90% 78 | * @var ISO_RESISTANCE_THRESHOLD 79 | * @type int 80 | * @unit kOhm 81 | * @valid 100 < x 82 | * @default 400 83 | * @group ISO 84 | * @level advanced 85 | * @group ISOGUARD 86 | */ 87 | 88 | /** 89 | * Resistance threshold in kOhm to differentiate of ISOIR_RESIST_MEAS_GOOD and 90 | * ISOIR_RESIST_MEAS_BAD in NORMAL_MODE within duty cycle of 10%..90% 91 | */ 92 | #define ISO_RESISTANCE_THRESHOLD 400 93 | 94 | /*================== Constant and Variable Definitions ====================*/ 95 | 96 | /*================== Function Prototypes ==================================*/ 97 | 98 | /*================== Function Implementations =============================*/ 99 | 100 | #endif /* ISOGUARD_CFG_H_ */ 101 | -------------------------------------------------------------------------------- /src/module/config/rtc_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rtc_cfg.c 25 | * @author foxBMS Team 26 | * @date 13.07.2016 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix RTC 29 | * 30 | * @brief Configuration for the real time clock 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "rtc_cfg.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | 49 | /* Configuration with RTC clock source: LSE cyrstal */ 50 | RTC_CFG_s rtc_cfg = { 51 | .oscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE, // MCU1: LSE (external 32 kHz oscillator), 52 | .oscInitStruct.LSEState = RCC_LSE_ON, 53 | 54 | .clkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC, 55 | .clkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE, // RTC Clocksourse is LSE 56 | 57 | .initconfig.HourFormat = RTC_HOURFORMAT_24, 58 | .initconfig.AsynchPrediv = (128-1), // LSI = 32.768kHz: 32.768kHz/(128*256) = 1Hz 59 | .initconfig.SynchPrediv = (256-1), // Subsecond runs with 32.768kHzkHz/128 60 | .initconfig.OutPut = RTC_OUTPUT_ALARMA, 61 | .initconfig.OutPutPolarity = RTC_OUTPUT_POLARITY_LOW, 62 | .initconfig.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN, 63 | 64 | .timeformat = FORMAT_BIN, 65 | .defaultTime.Hours = 18, 66 | .defaultTime.Minutes = 20, 67 | .defaultTime.Seconds = 0, 68 | .defaultTime.SubSeconds = 0, 69 | .defaultTime.TimeFormat = RTC_HOURFORMAT12_PM, 70 | .defaultTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE, 71 | .defaultTime.StoreOperation = RTC_STOREOPERATION_RESET, 72 | 73 | .defaultDate.WeekDay = RTC_WEEKDAY_TUESDAY, 74 | .defaultDate.Month = RTC_MONTH_JULY, 75 | .defaultDate.Date = 12, 76 | .defaultDate.Year = 16, 77 | 78 | }; 79 | 80 | 81 | 82 | 83 | 84 | /*================== Function Prototypes ===================================*/ 85 | 86 | /*================== Function Implementations ==============================*/ 87 | 88 | -------------------------------------------------------------------------------- /src/application/wscript: -------------------------------------------------------------------------------- 1 | # @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 2 | # 3 | # BSD 3-Clause License 4 | # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | # 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. 7 | # 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. 8 | # 9 | # 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. 10 | # 11 | # 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: 12 | # 13 | # ″This product uses parts of foxBMS®″ 14 | # 15 | # ″This product includes parts of foxBMS®″ 16 | # 17 | # ″This product is derived from foxBMS®″ 18 | 19 | """WAF script for building "foxbms-application" library. 20 | location of this wscript: 21 | /src/application/wscript 22 | 23 | library output: 24 | /build/src/application/libfoxbms-application.a 25 | 26 | """ 27 | 28 | from waflib import Logs, Utils, Context 29 | import os 30 | 31 | 32 | def build(bld): 33 | srcs = bld.path.ant_glob('**/*.c') 34 | 35 | includes = os.path.join(bld.bldnode.abspath()) + ' ' 36 | includes += ' '.join([ 37 | '.', 38 | 39 | 40 | os.path.join('bal'), 41 | os.path.join('bmsctrl'), 42 | os.path.join('com'), 43 | os.path.join('config'), 44 | os.path.join('sox'), 45 | os.path.join('task'), 46 | 47 | os.path.join('..', 'engine', 'config'), 48 | os.path.join('..', 'engine', 'database'), 49 | os.path.join('..', 'engine', 'diag'), 50 | os.path.join('..', 'engine', 'sysctrl'), 51 | 52 | os.path.join('..', 'general'), 53 | os.path.join('..', 'general', 'config'), 54 | os.path.join('..', 'general', 'includes'), 55 | 56 | os.path.join(bld.top_dir, 'hal', 'CMSIS', 'Device', 'ST', 'STM32F4xx', 'Include'), 57 | os.path.join(bld.top_dir, 'hal', 'CMSIS', 'Include'), 58 | os.path.join(bld.top_dir, 'hal', 'STM32F4xx_HAL_Driver', 'Inc'), 59 | os.path.join(bld.top_dir, 'hal', 'STM32F4xx_HAL_Driver', 'Inc', 'Legacy'), 60 | 61 | os.path.join('..', 'module', 'can'), 62 | os.path.join('..', 'module', 'cansignal'), 63 | os.path.join('..', 'module', 'config'), 64 | os.path.join('..', 'module', 'contactor'), 65 | os.path.join('..', 'module', 'nvram'), 66 | os.path.join('..', 'module', 'io'), 67 | os.path.join('..', 'module', 'mcu'), 68 | os.path.join('..', 'module', 'rtc'), 69 | os.path.join('..', 'module', 'uart'), 70 | os.path.join('..', 'module', 'utils'), 71 | 72 | os.path.join('..', 'os'), 73 | os.path.join(bld.top_dir, 'FreeRTOS', 'Source', 'CMSIS_RTOS'), 74 | os.path.join(bld.top_dir, 'FreeRTOS', 'Source', 'include'), 75 | os.path.join(bld.top_dir, 'FreeRTOS', 'Source', 'portable', 'GCC', 'ARM_CM4F'), 76 | ]) 77 | 78 | 79 | bld.stlib( 80 | target='foxbms-application', 81 | source=srcs, 82 | includes=includes 83 | ) 84 | 85 | # vim: set ft=python : 86 | -------------------------------------------------------------------------------- /src/module/config/dma_cfg.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file dma_cfg.c 25 | * @author foxBMS Team 26 | * @date 02.10.2015 (date of creation) 27 | * @ingroup DRIVERS_CONF 28 | * @prefix DMA 29 | * 30 | * @brief Configuration for the DMA module 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "dma_cfg.h" 44 | #include "spi.h" 45 | 46 | /*================== Macros and Definitions ===============================*/ 47 | 48 | /*================== Constant and Variable Definitions ====================*/ 49 | DMA_HandleTypeDef dma_devices[] = { 50 | // SPI1 RX 51 | { 52 | .Instance = DMA2_Stream2, 53 | .Init.Channel = DMA_CHANNEL_3, 54 | .Init.Direction = DMA_PERIPH_TO_MEMORY, 55 | .Init.PeriphInc = DMA_PINC_DISABLE, 56 | .Init.MemInc = DMA_MINC_ENABLE, 57 | .Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE, 58 | .Init.MemDataAlignment = DMA_MDATAALIGN_BYTE, 59 | .Init.Mode = DMA_NORMAL, 60 | .Init.Priority = DMA_PRIORITY_LOW, 61 | .Init.FIFOMode = DMA_FIFOMODE_DISABLE, 62 | .Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL, 63 | .Init.MemBurst = DMA_MBURST_SINGLE, 64 | .Init.PeriphBurst = DMA_PBURST_SINGLE, 65 | .Parent = &spi_devices[0] 66 | }, 67 | // SPI1 TX 68 | { 69 | .Instance = DMA2_Stream3, 70 | .Init.Channel = DMA_CHANNEL_3, 71 | .Init.Direction = DMA_MEMORY_TO_PERIPH, 72 | .Init.PeriphInc = DMA_PINC_DISABLE, 73 | .Init.MemInc = DMA_MINC_ENABLE, 74 | .Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE, 75 | .Init.MemDataAlignment = DMA_MDATAALIGN_BYTE, 76 | .Init.Mode = DMA_NORMAL, 77 | .Init.Priority = DMA_PRIORITY_LOW, 78 | .Init.FIFOMode = DMA_FIFOMODE_DISABLE, 79 | .Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL, 80 | .Init.MemBurst = DMA_MBURST_SINGLE, 81 | .Init.PeriphBurst = DMA_PBURST_SINGLE, 82 | .Parent = &spi_devices[0] 83 | } 84 | }; 85 | 86 | const uint8_t dma_number_of_used_streams = sizeof(dma_devices)/sizeof(DMA_HandleTypeDef); 87 | 88 | /*================== Function Prototypes ==================================*/ 89 | 90 | /*================== Function Implementations =============================*/ 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/module/adc/adc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file adc.h 25 | * @author foxBMS Team 26 | * @date 26.08.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix ADC 29 | * 30 | * @brief Header for the driver for the analog to digital converter 31 | * 32 | * This adc module provides support for analog/digital conversion. 33 | * It must be initialized during startup. 34 | * 35 | */ 36 | 37 | #ifndef ADC_H_ 38 | #define ADC_H_ 39 | 40 | /*================== Includes =============================================*/ 41 | #include "adc_cfg.h" 42 | 43 | //#include "mcu_cfg.h" 44 | 45 | /*================== Macros and Definitions ===============================*/ 46 | 47 | /*================== Constant and Variable Definitions ====================*/ 48 | extern const uint8_t adc_number_of_used_devices; 49 | extern ADC_HandleTypeDef adc_devices[]; 50 | 51 | /*================== Function Prototypes ==================================*/ 52 | /** 53 | * @brief initializes the different ADC devices by enabling their 54 | * corresponding clocks. It is called during startup. 55 | * 56 | * @param AdcHandle: pointer to ADC hardware handle 57 | * 58 | * @return void 59 | */ 60 | extern void ADC_Init(ADC_HandleTypeDef *AdcHandle); 61 | 62 | /** 63 | * @brief determines which kind of measurements are made by the ADCs and stores result in database. 64 | * 65 | * It alternates between measurement of the voltage of the backup battery 66 | * and the voltage of the internal temperature sensor. 67 | * It starts the conversion with ADC_Convert(). 68 | * If the conversion is completed, the result is stored in the database. 69 | * 70 | * @return void 71 | */ 72 | extern void ADC_Ctrl(void); 73 | 74 | /** 75 | * starts the ADC conversion. 76 | * 77 | * @param AdcHandle: pointer to ADC hardware handle 78 | * 79 | * @return (type: void) 80 | */ 81 | extern void ADC_Convert(ADC_HandleTypeDef *AdcHandle); 82 | 83 | /** 84 | * @brief callback function to the ADC conversion. 85 | * 86 | * It is called automatically when an ADC conversion is complete. 87 | * Before getting the converted value, it stops the ADC with HAL_ADC_Stop_IT(). 88 | * Then it gets the converted raw value with HAL_ADC_GetValue(). 89 | * The raw value is then scaled. 90 | * 91 | * @param AdcHandle: pointer to ADC hardware handle 92 | * 93 | * @return void 94 | */ 95 | extern void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle); 96 | 97 | /*================== Function Implementations =============================*/ 98 | 99 | #endif /* ADC_H_ */ 100 | -------------------------------------------------------------------------------- /src/module/rtc/rtc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file rtc.c 25 | * @author foxBMS Team 26 | * @date 20.10.2015 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix RTC 29 | * 30 | * @brief Driver for the real time clock. 31 | * 32 | */ 33 | 34 | 35 | 36 | /*================== Includes =============================================*/ 37 | /* recommended include order of header files: 38 | * 39 | * 1. include general.h 40 | * 2. include module's own header 41 | * 3... other headers 42 | * 43 | */ 44 | #include "general.h" 45 | #include "rtc.h" 46 | 47 | /*================== Macros and Definitions ===============================*/ 48 | 49 | 50 | /*================== Constant and Variable Definitions ====================*/ 51 | RTC_HandleTypeDef hrtc; 52 | 53 | /*================== Function Prototypes ==================================*/ 54 | 55 | 56 | /*================== Function Implementations =============================*/ 57 | void RTC_Init(void) { 58 | 59 | /* Configure RTC clocks */ 60 | HAL_RCC_OscConfig(&rtc_cfg.oscInitStruct); 61 | 62 | HAL_RCCEx_PeriphCLKConfig(&rtc_cfg.clkInitStruct); 63 | 64 | /* Enable RTC clock */ 65 | __HAL_RCC_RTC_ENABLE(); 66 | 67 | /* Initialize RTC */ 68 | hrtc.Instance = RTC; 69 | hrtc.Init = rtc_cfg.initconfig; 70 | HAL_RTC_Init(&hrtc); 71 | 72 | /* Disable WakeUp-Timer */ 73 | HAL_RTCEx_DeactivateWakeUpTimer(&hrtc); 74 | 75 | // set time and date if not already initialized or V_BAT failed 76 | if (!(hrtc.Instance->ISR & (uint32_t)RTC_ISR_INITS)) { 77 | 78 | RTC_DATAVALID_VARIABLE = 0; // invalidate rtc backup data 79 | HAL_RTC_SetTime(&hrtc, &rtc_cfg.defaultTime, rtc_cfg.timeformat); 80 | 81 | HAL_RTC_SetDate(&hrtc, &rtc_cfg.defaultDate, rtc_cfg.timeformat); 82 | 83 | RTC_DATAVALID_VARIABLE = 1; // validate rtc backup data 84 | RTC_BKPSRAM_DATAVALID_VARIABLE = 0; // invalidate bkpsram data 85 | RTC_BKPDIAG_DATAVALID_VARIABLE = 0; // invalidate bkpsram diag data 86 | RTC_NVMRAM_DATAVALID_VARIABLE = 0; // invalidate non-volatile data backups 87 | } 88 | 89 | } 90 | 91 | void RTC_setTime(RTC_Time_s * time) { 92 | HAL_RTC_SetTime(&hrtc, time, FORMAT_BIN); 93 | } 94 | 95 | void RTC_setDate(RTC_Date_s * date) { 96 | HAL_RTC_SetDate(&hrtc, date, FORMAT_BIN); 97 | } 98 | 99 | void RTC_getTime(RTC_Time_s * time) { 100 | HAL_RTC_GetTime(&hrtc, time, FORMAT_BIN); 101 | } 102 | 103 | void RTC_getDate(RTC_Date_s * date) { 104 | HAL_RTC_GetDate(&hrtc, date, FORMAT_BIN); 105 | } 106 | -------------------------------------------------------------------------------- /src/application/bal/bal.c: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file bal.c 25 | * @author foxBMS Team 26 | * @date 26.02.2016 (date of creation) 27 | * @ingroup DRIVERS 28 | * @prefix BAL 29 | * 30 | * @brief Driver for the Balancing module 31 | * 32 | */ 33 | 34 | /*================== Includes =============================================*/ 35 | /* recommended include order of header files: 36 | * 37 | * 1. include general.h 38 | * 2. include module's own header 39 | * 3... other headers 40 | * 41 | */ 42 | #include "general.h" 43 | #include "bal.h" 44 | #include "mcu.h" 45 | 46 | #include "database.h" 47 | 48 | 49 | /*================== Macros and Definitions ===============================*/ 50 | 51 | /*================== Constant and Variable Definitions ====================*/ 52 | static DATA_BLOCK_BALANCING_CONTROL_s bal_balancing; 53 | static DATA_BLOCK_CELLVOLTAGE_s bal_cellvoltage; 54 | static DATA_BLOCK_MINMAX_s bal_minmax; 55 | 56 | /*================== Function Prototypes ==================================*/ 57 | 58 | /*================== Function Implementations =============================*/ 59 | 60 | /*================== Public functions =====================================*/ 61 | void BAL_Init(void) { 62 | DATA_GetTable(&bal_balancing, DATA_BLOCK_ID_BALANCING_CONTROL_VALUES); 63 | bal_balancing.enable_balancing = 0; 64 | DATA_StoreDataBlock(&bal_balancing, DATA_BLOCK_ID_BALANCING_CONTROL_VALUES); 65 | } 66 | 67 | void BAL_Ctrl(void) { 68 | uint32_t i = 0; 69 | uint16_t min = 0; 70 | 71 | DATA_GetTable(&bal_balancing, DATA_BLOCK_ID_BALANCING_CONTROL_VALUES); 72 | DATA_GetTable(&bal_cellvoltage, DATA_BLOCK_ID_CELLVOLTAGE); 73 | DATA_GetTable(&bal_minmax, DATA_BLOCK_ID_MINMAX); 74 | 75 | min = bal_minmax.voltage_min; 76 | 77 | if (bal_balancing.enable_balancing == 1) { 78 | for (i=0;i (min+(uint16_t)(bal_balancing.threshold)) ) { 80 | bal_balancing.value[i] = 1; 81 | } else { 82 | bal_balancing.value[i] = 0; 83 | } 84 | } 85 | } 86 | else { 87 | for (i=0;i 79 | 80 | /*================== Constant and Variable Definitions ====================*/ 81 | 82 | /*================== Function Prototypes ==================================*/ 83 | 84 | /*================== Function Implementations =============================*/ 85 | 86 | uint16_t LTC_pec15_calc(uint8_t len, //Number of bytes that will be used to calculate a PEC 87 | uint8_t *data //Array of data that will be used to calculate a PEC 88 | ) 89 | { 90 | uint16_t remainder,addr; 91 | 92 | remainder = 16;//initialize the PEC 93 | for(uint8_t i = 0; i>7)^data[i])&0xff;//calculate PEC table address 96 | remainder = (remainder<<8)^crc15Table[addr]; 97 | } 98 | return(remainder*2);//The CRC15 has a 0 in the LSB so the remainder must be multiplied by 2 99 | } 100 | 101 | /*================== Public functions =====================================*/ 102 | 103 | /*================== Static functions =====================================*/ 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/engine/database/database.h: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @copyright © 2010 - 2017, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. All rights reserved. 4 | * 5 | * BSD 3-Clause License 6 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | * 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. 9 | * 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. 10 | * 11 | * 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. 12 | * 13 | * 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: 14 | * 15 | * ″This product uses parts of foxBMS®″ 16 | * 17 | * ″This product includes parts of foxBMS®″ 18 | * 19 | * ″This product is derived from foxBMS®″ 20 | * 21 | */ 22 | 23 | /** 24 | * @file database.h 25 | * @author foxBMS Team 26 | * @date 18.08.2015 (date of creation) 27 | * @ingroup ENGINE 28 | * @prefix DATA 29 | * 30 | * @brief Database module header 31 | * 32 | * Provides interfaces to database module 33 | * 34 | */ 35 | 36 | #ifndef DATABASE_H_ 37 | #define DATABASE_H_ 38 | 39 | /*================== Includes =============================================*/ 40 | // FIXME circular include 41 | #include "database_cfg.h" 42 | 43 | 44 | /*================== Macros and Definitions ===============================*/ 45 | // FIXME doxygen comments 46 | typedef struct { 47 | // FIXME what is the intention of this union? isn't it dangerous if someone expects a pointer to and accesses via .u32ptr, but there is a value stored in value? 48 | union { 49 | uint32_t u32value; /* reference by uint32_t value */ 50 | uint32_t *u32ptr; /* reference by uint32_t pointer */ 51 | void *voidptr; /* reference by general pointer */ 52 | } value; 53 | DATA_BLOCK_ID_TYPE_e blockID; /* definition of used message data type */ 54 | DATA_BLOCK_ACCESS_TYPE_e accesstype; /* read or write access type */ 55 | } DATA_QUEUE_MESSAGE_s; 56 | 57 | 58 | typedef struct { 59 | void *RDptr; 60 | void *WRptr; 61 | DATA_BLOCK_CONSISTENCY_TYPE_e nr_of_buffer; // todo really needed? 62 | } DATA_BLOCK_ACCESS_s; 63 | 64 | /*================== Constant and Variable Definitions ====================*/ 65 | 66 | 67 | 68 | /*================== Function Prototypes ==================================*/ 69 | /** 70 | * @brief Stores a datablock in database 71 | * @param blockID (type: DATA_BLOCK_ID_TYPE_e) 72 | * @param dataptrfromSender (type: void *) 73 | * @return void 74 | */ 75 | extern void DATA_StoreDataBlock(void *dataptrfromSender, DATA_BLOCK_ID_TYPE_e blockID); 76 | 77 | /** 78 | * @brief Reads a datablock in database by value 79 | * @param blockID (type: DATA_BLOCK_ID_TYPE_e) 80 | * @param dataptrtoReceiver (type: void *) 81 | * @return STD_RETURN_TYPE_e 82 | */ 83 | extern STD_RETURN_TYPE_e DATA_GetTable(void *dataptrtoReceiver, DATA_BLOCK_ID_TYPE_e blockID); 84 | 85 | /** 86 | * @brief Gets a pointer to datablock in database () 87 | * @param blockID (type: DATA_BLOCK_ID_TYPE_e) 88 | * @return void* RDptr 89 | */ 90 | extern void * DATA_GetTablePtrBeginCritical(DATA_BLOCK_ID_TYPE_e blockID); 91 | 92 | /** 93 | * @brief trigger of database manager 94 | * 95 | * @return void 96 | */ 97 | extern void DATA_Task(void); 98 | 99 | /*================== Function Implementations =============================*/ 100 | 101 | 102 | #endif /* DATABASE_H_ */ 103 | --------------------------------------------------------------------------------