Skip to content

Commit

Permalink
Merge pull request #1 from PUT-Motorsport/sch_remake
Browse files Browse the repository at this point in the history
finished schematic and layout
  • Loading branch information
Karanami authored Jun 27, 2023
2 parents d41993f + 002a63d commit 287fbeb
Show file tree
Hide file tree
Showing 334 changed files with 681,264 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.bak
*.bck
*.kicad_pcb-bak
*.kicad_sch-bak
*.sch-bak
*~
_autosave-*
Expand All @@ -26,8 +27,8 @@ fp-info-cache
*.csv

# 3d files
*.step
*.wrl
#*.step
#*.wrl

# Compile files
*.bin
Expand Down
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[submodule "firmware/Core/Inc/PUTM_EV_CAN_LIBRARY"]
url = https://github.com/PUT-Motorsport/PUTM_EV_CAN_LIBRARY
246 changes: 246 additions & 0 deletions firmware/.cproject

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions firmware/.mxproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[PreviousLibFiles]
LibFiles=Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ramfunc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_cortex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h;Drivers\STM32F4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_def.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_exti.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_can.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rtc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rtc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_sdmmc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_sd.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_spi.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h;Middlewares\Third_Party\FatFs\src\diskio.h;Middlewares\Third_Party\FatFs\src\ff.h;Middlewares\Third_Party\FatFs\src\ff_gen_drv.h;Middlewares\Third_Party\FatFs\src\integer.h;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_can.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_sdmmc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_sd.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_spi.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c;Middlewares\Third_Party\FatFs\src\diskio.c;Middlewares\Third_Party\FatFs\src\ff.c;Middlewares\Third_Party\FatFs\src\ff_gen_drv.c;Middlewares\Third_Party\FatFs\src\option\syscall.c;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ramfunc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_cortex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h;Drivers\STM32F4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_def.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_exti.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_can.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rtc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rtc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_sdmmc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_sd.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_spi.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h;Middlewares\Third_Party\FatFs\src\diskio.h;Middlewares\Third_Party\FatFs\src\ff.h;Middlewares\Third_Party\FatFs\src\ff_gen_drv.h;Middlewares\Third_Party\FatFs\src\integer.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f446xx.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h;Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;

[PreviousUsedCubeIDEFiles]
SourceFiles=Core\Src\main.c;FATFS\Target\bsp_driver_sd.c;FATFS\Target\sd_diskio.c;FATFS\App\fatfs.c;FATFS\Target\fatfs_platform.c;Core\Src\stm32f4xx_it.c;Core\Src\stm32f4xx_hal_msp.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_can.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_sdmmc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_sd.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_spi.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c;Middlewares\Third_Party\FatFs\src\diskio.c;Middlewares\Third_Party\FatFs\src\ff.c;Middlewares\Third_Party\FatFs\src\ff_gen_drv.c;Middlewares\Third_Party\FatFs\src\option\syscall.c;Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c;Core\Src\system_stm32f4xx.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_can.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rtc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_sdmmc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_sd.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_spi.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c;Middlewares\Third_Party\FatFs\src\diskio.c;Middlewares\Third_Party\FatFs\src\ff.c;Middlewares\Third_Party\FatFs\src\ff_gen_drv.c;Middlewares\Third_Party\FatFs\src\option\syscall.c;Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c;Core\Src\system_stm32f4xx.c;;;Middlewares\Third_Party\FatFs\src\diskio.c;Middlewares\Third_Party\FatFs\src\ff.c;Middlewares\Third_Party\FatFs\src\ff_gen_drv.c;Middlewares\Third_Party\FatFs\src\option\syscall.c;
HeaderPath=Drivers\STM32F4xx_HAL_Driver\Inc;Drivers\STM32F4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FatFs\src;Drivers\CMSIS\Device\ST\STM32F4xx\Include;Drivers\CMSIS\Include;FATFS\Target;FATFS\App;Core\Inc;
CDefines=USE_HAL_DRIVER;STM32F446xx;USE_HAL_DRIVER;USE_HAL_DRIVER;

[PreviousGenFiles]
AdvancedFolderStructure=true
HeaderFileListSize=8
HeaderFiles#0=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/ffconf.h
HeaderFiles#1=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/bsp_driver_sd.h
HeaderFiles#2=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/sd_diskio.h
HeaderFiles#3=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/App/fatfs.h
HeaderFiles#4=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/fatfs_platform.h
HeaderFiles#5=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Inc/stm32f4xx_it.h
HeaderFiles#6=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Inc/stm32f4xx_hal_conf.h
HeaderFiles#7=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Inc/main.h
HeaderFolderListSize=3
HeaderPath#0=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target
HeaderPath#1=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/App
HeaderPath#2=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Inc
HeaderFiles=;
SourceFileListSize=7
SourceFiles#0=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/bsp_driver_sd.c
SourceFiles#1=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/sd_diskio.c
SourceFiles#2=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/App/fatfs.c
SourceFiles#3=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target/fatfs_platform.c
SourceFiles#4=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Src/stm32f4xx_it.c
SourceFiles#5=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Src/stm32f4xx_hal_msp.c
SourceFiles#6=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Src/main.c
SourceFolderListSize=3
SourcePath#0=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/Target
SourcePath#1=D:/GitHub/PUTM_EV_BMS_HV_2021/FATFS/App
SourcePath#2=D:/GitHub/PUTM_EV_BMS_HV_2021/Core/Src
SourceFiles=;

34 changes: 34 additions & 0 deletions firmware/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PUTM_EV_BMS_HV_2021</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.st.stm32cube.ide.mcu.MCUProjectNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUCubeProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCURootProjectNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>
6 changes: 6 additions & 0 deletions firmware/.settings/org.eclipse.cdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doxygen/doxygen_new_line_after_brief=true
doxygen/doxygen_use_brief_tag=false
doxygen/doxygen_use_javadoc_tags=true
doxygen/doxygen_use_pre_tag=false
doxygen/doxygen_use_structural_commands=false
eclipse.preferences.version=1
3 changes: 3 additions & 0 deletions firmware/.settings/stm32cubeide.project.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
8DF89ED150041C4CBC7CB9A9CAA90856=7A9A5572D8A41100AEA88E5E5A272E59
DC22A860405A8BF2F2C095E5B6529F12=632E4A9F6884CCAB418D6590F0C4206E
eclipse.preferences.version=1
111 changes: 111 additions & 0 deletions firmware/Core/Inc/ltc_stack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#ifndef LTC_STACK_H
#define LTC_STACK_H

#include "main.h"




#define LTCS_IN_STACK 15
#define CELLS_IN_LTC 9

#define LTC_ADC_MD 0b11
#define LTC_ADC_DCP 0b0
#define LTC_CFG_REFON 0b1
#define LTC_CFG_ADCOPT 0b1
#define LTC_CFG_GPIO 0b11111

#define LTC_REFRESH_PERIOD 50
#define LTC_ADC_DELAY 8

#define CELL_VOLTAGE_MIN 3000
#define CELL_VOLTAGE_MAX 4180
#define CELL_TEMPERATURE_MIN 40
#define CELL_TEMPERATURE_MAX 550
#define CELL_TEMPERATURE_CHARGING_MAX 410

#define CELL_VOLTAGE_ERR_CNTR_THRESHOLD 9
#define CELL_CURRENT_ERR_CNTR_THRESHOLD 9
#define CELL_TEMPERATURE_ERR_CNTR_THRESHOLD 19

#define CELL_ERROR_VOLTAGE_FLAG 0x01
#define CELL_ERROR_TEMPERATURE_FLAG 0x02
#define CELL_ERROR_CURRENT_FLAG 0x04

#define LTC_BALANCE_ROUND_PERIOD 60000

struct stack_data_type{
// measurements
uint16_t voltages[9 * LTCS_IN_STACK];
int16_t temperatures[3 * LTCS_IN_STACK];
// summary
uint32_t total_voltage_mv;
int16_t temperature_max;
uint16_t cell_minimum_voltage;
// discharge
uint8_t discharge[9 * LTCS_IN_STACK];
// errors
uint8_t voltages_err_cntr[9 * LTCS_IN_STACK];
uint8_t temperatures_err_cntr[9 * LTCS_IN_STACK];
uint8_t current_err_cntr;
uint8_t error;
// measurement time
uint32_t data_refresh_tick;
// minimum cell
int minimum_cell_no;
// balancing
uint8_t balance_activation_flag;
};

void LtcInitPec15Table();

uint16_t LtcPec15(uint8_t *data , int len);

void LtcInit(SPI_HandleTypeDef *hspi, GPIO_TypeDef *cs_gpio, uint16_t cs_pin);

void LtcCommunicationThread();

void LtcWakeupSleep();

void LtcWakeupIdle();

void LtcTxCallback();

void LtcCsPinSet(uint8_t pin_state);

void LtcSendConfig(uint8_t discharge_activation);

void LtcStartAdcCell();

void LtcStartAdcGpio();

void LtcStartReadCell(uint8_t group);

void LtcStartReadGpio(uint8_t group);

void LtcReadCell(uint8_t group);

void LtcReadGpio(uint8_t group);

void LtcStackDataReorder();

int16_t LtcCalculateTemperature(uint16_t gpio_voltage);

void LtcErrorCheck();

uint8_t LtcGetStackError();

void LtcStackSummary();

void LtcClearCellAdc();

void LtcClearGpioAdc();

void LtcStackBalance();



#endif



99 changes: 99 additions & 0 deletions firmware/Core/Inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define AIR_PLUS_Pin GPIO_PIN_0
#define AIR_PLUS_GPIO_Port GPIOC
#define AIR_MINUS_Pin GPIO_PIN_1
#define AIR_MINUS_GPIO_Port GPIOC
#define AIR_PRE_Pin GPIO_PIN_2
#define AIR_PRE_GPIO_Port GPIOC
#define SAFETY_DETECTION_Pin GPIO_PIN_3
#define SAFETY_DETECTION_GPIO_Port GPIOC
#define AMS_FAULT_MCU_Pin GPIO_PIN_4
#define AMS_FAULT_MCU_GPIO_Port GPIOC
#define LED1_Pin GPIO_PIN_1
#define LED1_GPIO_Port GPIOB
#define LED2_Pin GPIO_PIN_2
#define LED2_GPIO_Port GPIOB
#define LED3_Pin GPIO_PIN_10
#define LED3_GPIO_Port GPIOB
#define SPI2_CS1_Pin GPIO_PIN_6
#define SPI2_CS1_GPIO_Port GPIOC
#define SPI2_CS2_Pin GPIO_PIN_7
#define SPI2_CS2_GPIO_Port GPIOC
#define CARD_DETECT_Pin GPIO_PIN_8
#define CARD_DETECT_GPIO_Port GPIOA
#define DIN_1_Pin GPIO_PIN_3
#define DIN_1_GPIO_Port GPIOB
#define DIN_2_Pin GPIO_PIN_4
#define DIN_2_GPIO_Port GPIOB
#define DIN_3_Pin GPIO_PIN_5
#define DIN_3_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
39 changes: 39 additions & 0 deletions firmware/Core/Inc/serialport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef SERIALPORT_H
#define SERIALPORT_H

#include "stm32f4xx_hal.h"

#ifdef __cplusplus
extern "C" {
#endif


#define SERIAL_RX_BUF_SIZE 50
#define SERIAL_TX_BUF_SIZE 2000

struct serialport_type{
UART_HandleTypeDef *huart;

uint8_t rx_buffer[SERIAL_RX_BUF_SIZE];
uint16_t rx_head;
uint16_t rx_tail;

uint8_t tx_buffer[SERIAL_TX_BUF_SIZE];
uint16_t tx_head;
uint16_t tx_tail;

uint8_t tx_busy;
uint16_t tx_length;
};

void SerialportOpen(UART_HandleTypeDef *huart);
void SerialportRxCallback();
void SerialportTxCallback();
uint8_t SerialportWrite(uint8_t *data, uint16_t length);
char* SerialportReadLine(uint16_t *length);

#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit 287fbeb

Please sign in to comment.