Compare commits
10 Commits
2d07e5f52e
...
14b4f0595f
| Author | SHA1 | Date | |
|---|---|---|---|
| 14b4f0595f | |||
| 8574ffadc9 | |||
| 0e9b352db7 | |||
| 7893e7aa0c | |||
| f410ea90aa | |||
| 5ea401f34d | |||
|
|
5b424697c7 | ||
|
|
ad4ae7357a | ||
|
|
b86b879ede | ||
|
|
a5b0b7db8d |
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
39
.mxproject
Normal file
39
.mxproject
Normal file
File diff suppressed because one or more lines are too long
32
.project
Normal file
32
.project
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>CCSModuleSW30Web</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>com.st.stm32cube.ide.mcu.MCUCubeProjectNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature</nature>
|
||||||
|
<nature>com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature</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>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"charger_config.h": "c",
|
||||||
|
"charger_gbt.h": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
406
CCSModuleSW30Web.ioc
Executable file
406
CCSModuleSW30Web.ioc
Executable file
@@ -0,0 +1,406 @@
|
|||||||
|
#MicroXplorer Configuration settings - do not modify
|
||||||
|
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_8
|
||||||
|
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master
|
||||||
|
ADC1.NbrOfConversionFlag=1
|
||||||
|
ADC1.Rank-0\#ChannelRegularConversion=1
|
||||||
|
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5
|
||||||
|
ADC1.master=1
|
||||||
|
CAD.formats=
|
||||||
|
CAD.pinconfig=
|
||||||
|
CAD.provider=
|
||||||
|
CAN1.ABOM=ENABLE
|
||||||
|
CAN1.AWUM=ENABLE
|
||||||
|
CAN1.BS1=CAN_BS1_15TQ
|
||||||
|
CAN1.BS2=CAN_BS2_2TQ
|
||||||
|
CAN1.CalculateBaudRate=250000
|
||||||
|
CAN1.CalculateTimeBit=4000
|
||||||
|
CAN1.CalculateTimeQuantum=222.22222222222223
|
||||||
|
CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,BS2,Prescaler,ABOM,AWUM,TXFP,NART
|
||||||
|
CAN1.NART=ENABLE
|
||||||
|
CAN1.Prescaler=8
|
||||||
|
CAN1.TXFP=ENABLE
|
||||||
|
CAN2.ABOM=ENABLE
|
||||||
|
CAN2.AWUM=ENABLE
|
||||||
|
CAN2.BS1=CAN_BS1_15TQ
|
||||||
|
CAN2.BS2=CAN_BS2_2TQ
|
||||||
|
CAN2.CalculateBaudRate=125000
|
||||||
|
CAN2.CalculateTimeBit=8000
|
||||||
|
CAN2.CalculateTimeQuantum=444.44444444444446
|
||||||
|
CAN2.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1,BS2,ABOM,AWUM,TXFP,NART
|
||||||
|
CAN2.NART=ENABLE
|
||||||
|
CAN2.Prescaler=16
|
||||||
|
CAN2.TXFP=ENABLE
|
||||||
|
File.Version=6
|
||||||
|
GPIO.groupedBy=Group By Peripherals
|
||||||
|
KeepUserPlacement=false
|
||||||
|
Mcu.CPN=STM32F107VCT6
|
||||||
|
Mcu.Family=STM32F1
|
||||||
|
Mcu.IP0=ADC1
|
||||||
|
Mcu.IP1=CAN1
|
||||||
|
Mcu.IP10=UART5
|
||||||
|
Mcu.IP11=USART1
|
||||||
|
Mcu.IP12=USART2
|
||||||
|
Mcu.IP13=USART3
|
||||||
|
Mcu.IP2=CAN2
|
||||||
|
Mcu.IP3=CRC
|
||||||
|
Mcu.IP4=NVIC
|
||||||
|
Mcu.IP5=RCC
|
||||||
|
Mcu.IP6=RTC
|
||||||
|
Mcu.IP7=SYS
|
||||||
|
Mcu.IP8=TIM3
|
||||||
|
Mcu.IP9=TIM4
|
||||||
|
Mcu.IPNb=14
|
||||||
|
Mcu.Name=STM32F107V(B-C)Tx
|
||||||
|
Mcu.Package=LQFP100
|
||||||
|
Mcu.Pin0=PC14-OSC32_IN
|
||||||
|
Mcu.Pin1=PC15-OSC32_OUT
|
||||||
|
Mcu.Pin10=PC4
|
||||||
|
Mcu.Pin11=PC5
|
||||||
|
Mcu.Pin12=PB0
|
||||||
|
Mcu.Pin13=PB1
|
||||||
|
Mcu.Pin14=PE7
|
||||||
|
Mcu.Pin15=PE8
|
||||||
|
Mcu.Pin16=PE9
|
||||||
|
Mcu.Pin17=PE10
|
||||||
|
Mcu.Pin18=PE11
|
||||||
|
Mcu.Pin19=PE12
|
||||||
|
Mcu.Pin2=OSC_IN
|
||||||
|
Mcu.Pin20=PE14
|
||||||
|
Mcu.Pin21=PD13
|
||||||
|
Mcu.Pin22=PD14
|
||||||
|
Mcu.Pin23=PD15
|
||||||
|
Mcu.Pin24=PA9
|
||||||
|
Mcu.Pin25=PA10
|
||||||
|
Mcu.Pin26=PA13
|
||||||
|
Mcu.Pin27=PA14
|
||||||
|
Mcu.Pin28=PA15
|
||||||
|
Mcu.Pin29=PC10
|
||||||
|
Mcu.Pin3=OSC_OUT
|
||||||
|
Mcu.Pin30=PC11
|
||||||
|
Mcu.Pin31=PC12
|
||||||
|
Mcu.Pin32=PD0
|
||||||
|
Mcu.Pin33=PD1
|
||||||
|
Mcu.Pin34=PD2
|
||||||
|
Mcu.Pin35=PD3
|
||||||
|
Mcu.Pin36=PD4
|
||||||
|
Mcu.Pin37=PD5
|
||||||
|
Mcu.Pin38=PD6
|
||||||
|
Mcu.Pin39=PD7
|
||||||
|
Mcu.Pin4=PC3
|
||||||
|
Mcu.Pin40=PB3
|
||||||
|
Mcu.Pin41=PB4
|
||||||
|
Mcu.Pin42=PB5
|
||||||
|
Mcu.Pin43=PB6
|
||||||
|
Mcu.Pin44=PB7
|
||||||
|
Mcu.Pin45=PB8
|
||||||
|
Mcu.Pin46=PB9
|
||||||
|
Mcu.Pin47=PE1
|
||||||
|
Mcu.Pin48=VP_ADC1_TempSens_Input
|
||||||
|
Mcu.Pin49=VP_ADC1_Vref_Input
|
||||||
|
Mcu.Pin5=PA1
|
||||||
|
Mcu.Pin50=VP_CRC_VS_CRC
|
||||||
|
Mcu.Pin51=VP_RTC_VS_RTC_Activate
|
||||||
|
Mcu.Pin52=VP_SYS_VS_Systick
|
||||||
|
Mcu.Pin53=VP_TIM3_VS_ClockSourceINT
|
||||||
|
Mcu.Pin54=VP_TIM4_VS_ClockSourceINT
|
||||||
|
Mcu.Pin6=PA2
|
||||||
|
Mcu.Pin7=PA3
|
||||||
|
Mcu.Pin8=PA4
|
||||||
|
Mcu.Pin9=PA7
|
||||||
|
Mcu.PinsNb=55
|
||||||
|
Mcu.ThirdPartyNb=0
|
||||||
|
Mcu.UserConstants=
|
||||||
|
Mcu.UserName=STM32F107VCTx
|
||||||
|
MxCube.Version=6.15.0
|
||||||
|
MxDb.Version=DB.6.0.150
|
||||||
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.CAN2_RX1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.CAN2_TX_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.ForceEnableDMAVector=true
|
||||||
|
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||||
|
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||||
|
NVIC.TIM3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.UART5_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.USART3_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
|
OSC_IN.Mode=HSE-External-Oscillator
|
||||||
|
OSC_IN.Signal=RCC_OSC_IN
|
||||||
|
OSC_OUT.Mode=HSE-External-Oscillator
|
||||||
|
OSC_OUT.Signal=RCC_OSC_OUT
|
||||||
|
PA1.GPIOParameters=GPIO_Label
|
||||||
|
PA1.GPIO_Label=IN_SW0
|
||||||
|
PA1.Locked=true
|
||||||
|
PA1.Signal=GPIO_Input
|
||||||
|
PA10.Locked=true
|
||||||
|
PA10.Mode=Asynchronous
|
||||||
|
PA10.Signal=USART1_RX
|
||||||
|
PA13.Mode=Serial_Wire
|
||||||
|
PA13.Signal=SYS_JTMS-SWDIO
|
||||||
|
PA14.Mode=Serial_Wire
|
||||||
|
PA14.Signal=SYS_JTCK-SWCLK
|
||||||
|
PA15.GPIOParameters=GPIO_Label
|
||||||
|
PA15.GPIO_Label=RELAY_CC
|
||||||
|
PA15.Locked=true
|
||||||
|
PA15.Signal=GPIO_Output
|
||||||
|
PA2.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||||
|
PA2.GPIO_Label=IN_SW1
|
||||||
|
PA2.GPIO_PuPd=GPIO_PULLDOWN
|
||||||
|
PA2.Locked=true
|
||||||
|
PA2.Signal=GPIO_Input
|
||||||
|
PA3.Locked=true
|
||||||
|
PA3.Signal=ADCx_IN3
|
||||||
|
PA4.GPIOParameters=GPIO_Label
|
||||||
|
PA4.GPIO_Label=CP_ADC
|
||||||
|
PA4.Locked=true
|
||||||
|
PA4.Signal=ADCx_IN4
|
||||||
|
PA7.GPIOParameters=GPIO_Label
|
||||||
|
PA7.GPIO_Label=CP_PWM
|
||||||
|
PA7.Locked=true
|
||||||
|
PA7.Signal=S_TIM3_CH2
|
||||||
|
PA9.Locked=true
|
||||||
|
PA9.Mode=Asynchronous
|
||||||
|
PA9.Signal=USART1_TX
|
||||||
|
PB0.GPIOParameters=GPIO_Label
|
||||||
|
PB0.GPIO_Label=ADC_NTC1
|
||||||
|
PB0.Locked=true
|
||||||
|
PB0.Signal=ADCx_IN8
|
||||||
|
PB1.GPIOParameters=GPIO_Label
|
||||||
|
PB1.GPIO_Label=ADC_NTC2
|
||||||
|
PB1.Locked=true
|
||||||
|
PB1.Signal=ADCx_IN9
|
||||||
|
PB3.GPIOParameters=GPIO_Label
|
||||||
|
PB3.GPIO_Label=IN_FB2
|
||||||
|
PB3.Locked=true
|
||||||
|
PB3.Signal=GPIO_Input
|
||||||
|
PB4.GPIOParameters=GPIO_Label
|
||||||
|
PB4.GPIO_Label=IN_FB1
|
||||||
|
PB4.Locked=true
|
||||||
|
PB4.Signal=GPIO_Input
|
||||||
|
PB5.Locked=true
|
||||||
|
PB5.Mode=CAN_Activate
|
||||||
|
PB5.Signal=CAN2_RX
|
||||||
|
PB6.Locked=true
|
||||||
|
PB6.Mode=CAN_Activate
|
||||||
|
PB6.Signal=CAN2_TX
|
||||||
|
PB7.GPIOParameters=GPIO_Label
|
||||||
|
PB7.GPIO_Label=EE_WP
|
||||||
|
PB7.Locked=true
|
||||||
|
PB7.Signal=GPIO_Output
|
||||||
|
PB8.Locked=true
|
||||||
|
PB8.Signal=I2C1_SCL
|
||||||
|
PB9.Locked=true
|
||||||
|
PB9.Signal=I2C1_SDA
|
||||||
|
PC10.Locked=true
|
||||||
|
PC10.Mode=Asynchronous
|
||||||
|
PC10.Signal=USART3_TX
|
||||||
|
PC11.Locked=true
|
||||||
|
PC11.Mode=Asynchronous
|
||||||
|
PC11.Signal=USART3_RX
|
||||||
|
PC12.Mode=Asynchronous
|
||||||
|
PC12.Signal=UART5_TX
|
||||||
|
PC14-OSC32_IN.Mode=LSE-External-Oscillator
|
||||||
|
PC14-OSC32_IN.Signal=RCC_OSC32_IN
|
||||||
|
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
|
||||||
|
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
|
||||||
|
PC3.GPIOParameters=GPIO_Label
|
||||||
|
PC3.GPIO_Label=RELAY_CP
|
||||||
|
PC3.Locked=true
|
||||||
|
PC3.Signal=GPIO_Output
|
||||||
|
PC4.GPIOParameters=GPIO_Label
|
||||||
|
PC4.GPIO_Label=LOCK_A
|
||||||
|
PC4.Locked=true
|
||||||
|
PC4.Signal=GPIO_Output
|
||||||
|
PC5.GPIOParameters=GPIO_Label
|
||||||
|
PC5.GPIO_Label=LOCK_B
|
||||||
|
PC5.Locked=true
|
||||||
|
PC5.Signal=GPIO_Output
|
||||||
|
PD0.Locked=true
|
||||||
|
PD0.Mode=CAN_Activate
|
||||||
|
PD0.Signal=CAN1_RX
|
||||||
|
PD1.Locked=true
|
||||||
|
PD1.Mode=CAN_Activate
|
||||||
|
PD1.Signal=CAN1_TX
|
||||||
|
PD13.Locked=true
|
||||||
|
PD13.Signal=S_TIM4_CH2
|
||||||
|
PD14.Locked=true
|
||||||
|
PD14.Signal=S_TIM4_CH3
|
||||||
|
PD15.Locked=true
|
||||||
|
PD15.Signal=S_TIM4_CH4
|
||||||
|
PD2.Locked=true
|
||||||
|
PD2.Mode=Asynchronous
|
||||||
|
PD2.Signal=UART5_RX
|
||||||
|
PD3.GPIOParameters=GPIO_Label
|
||||||
|
PD3.GPIO_Label=RELAY_DC
|
||||||
|
PD3.Locked=true
|
||||||
|
PD3.Signal=GPIO_Output
|
||||||
|
PD4.GPIOParameters=GPIO_Label
|
||||||
|
PD4.GPIO_Label=USART2_DIR
|
||||||
|
PD4.Locked=true
|
||||||
|
PD4.Signal=GPIO_Output
|
||||||
|
PD5.Locked=true
|
||||||
|
PD5.Mode=Asynchronous
|
||||||
|
PD5.Signal=USART2_TX
|
||||||
|
PD6.Locked=true
|
||||||
|
PD6.Mode=Asynchronous
|
||||||
|
PD6.Signal=USART2_RX
|
||||||
|
PD7.GPIOParameters=GPIO_Label
|
||||||
|
PD7.GPIO_Label=IN_ESTOP
|
||||||
|
PD7.Locked=true
|
||||||
|
PD7.Signal=GPIO_Input
|
||||||
|
PE1.GPIOParameters=GPIO_Label
|
||||||
|
PE1.GPIO_Label=ISO_IN
|
||||||
|
PE1.Locked=true
|
||||||
|
PE1.Signal=GPIO_Input
|
||||||
|
PE10.GPIOParameters=GPIO_Label
|
||||||
|
PE10.GPIO_Label=RELAY3
|
||||||
|
PE10.Locked=true
|
||||||
|
PE10.Signal=GPIO_Output
|
||||||
|
PE11.GPIOParameters=GPIO_Label
|
||||||
|
PE11.GPIO_Label=RELAY4
|
||||||
|
PE11.Locked=true
|
||||||
|
PE11.Signal=GPIO_Output
|
||||||
|
PE12.GPIOParameters=GPIO_Label
|
||||||
|
PE12.GPIO_Label=RELAY5
|
||||||
|
PE12.Locked=true
|
||||||
|
PE12.Signal=GPIO_Output
|
||||||
|
PE14.GPIOParameters=GPIO_Label
|
||||||
|
PE14.GPIO_Label=AC_OK
|
||||||
|
PE14.Locked=true
|
||||||
|
PE14.Signal=GPIO_Input
|
||||||
|
PE7.GPIOParameters=GPIO_Label
|
||||||
|
PE7.GPIO_Label=IN0
|
||||||
|
PE7.Locked=true
|
||||||
|
PE7.Signal=GPIO_Input
|
||||||
|
PE8.GPIOParameters=GPIO_Label
|
||||||
|
PE8.GPIO_Label=RELAY1
|
||||||
|
PE8.Locked=true
|
||||||
|
PE8.Signal=GPIO_Output
|
||||||
|
PE9.GPIOParameters=GPIO_Label
|
||||||
|
PE9.GPIO_Label=RELAY2
|
||||||
|
PE9.Locked=true
|
||||||
|
PE9.Signal=GPIO_Output
|
||||||
|
PinOutPanel.RotationAngle=-90
|
||||||
|
ProjectManager.AskForMigrate=true
|
||||||
|
ProjectManager.BackupPrevious=true
|
||||||
|
ProjectManager.CompilerLinker=GCC
|
||||||
|
ProjectManager.CompilerOptimize=6
|
||||||
|
ProjectManager.ComputerToolchain=false
|
||||||
|
ProjectManager.CoupleFile=true
|
||||||
|
ProjectManager.CustomerFirmwarePackage=
|
||||||
|
ProjectManager.DefaultFWLocation=true
|
||||||
|
ProjectManager.DeletePrevious=true
|
||||||
|
ProjectManager.DeviceId=STM32F107VCTx
|
||||||
|
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.6
|
||||||
|
ProjectManager.FreePins=false
|
||||||
|
ProjectManager.HalAssertFull=false
|
||||||
|
ProjectManager.HeapSize=0x200
|
||||||
|
ProjectManager.KeepUserCode=true
|
||||||
|
ProjectManager.LastFirmware=false
|
||||||
|
ProjectManager.LibraryCopy=1
|
||||||
|
ProjectManager.MainLocation=Core/Src
|
||||||
|
ProjectManager.NoMain=false
|
||||||
|
ProjectManager.PreviousToolchain=
|
||||||
|
ProjectManager.ProjectBuild=false
|
||||||
|
ProjectManager.ProjectFileName=CCSModuleSW30Web.ioc
|
||||||
|
ProjectManager.ProjectName=CCSModuleSW30Web
|
||||||
|
ProjectManager.ProjectStructure=
|
||||||
|
ProjectManager.RegisterCallBack=
|
||||||
|
ProjectManager.StackSize=0x400
|
||||||
|
ProjectManager.TargetToolchain=STM32CubeIDE
|
||||||
|
ProjectManager.ToolChainLocation=
|
||||||
|
ProjectManager.UAScriptAfterPath=
|
||||||
|
ProjectManager.UAScriptBeforePath=
|
||||||
|
ProjectManager.UnderRoot=true
|
||||||
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_CAN2_Init-CAN2-false-HAL-true,6-MX_RTC_Init-RTC-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_USART2_UART_Init-USART2-false-HAL-true,9-MX_CRC_Init-CRC-false-HAL-true,10-MX_UART5_Init-UART5-false-HAL-true,11-MX_USART1_UART_Init-USART1-false-HAL-true,12-MX_USART3_UART_Init-USART3-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true
|
||||||
|
RCC.ADCFreqValue=12000000
|
||||||
|
RCC.ADCPresc=RCC_ADCPCLK2_DIV6
|
||||||
|
RCC.AHBFreq_Value=72000000
|
||||||
|
RCC.APB1CLKDivider=RCC_HCLK_DIV2
|
||||||
|
RCC.APB1Freq_Value=36000000
|
||||||
|
RCC.APB1TimFreq_Value=72000000
|
||||||
|
RCC.APB2Freq_Value=72000000
|
||||||
|
RCC.APB2TimFreq_Value=72000000
|
||||||
|
RCC.FCLKCortexFreq_Value=72000000
|
||||||
|
RCC.FamilyName=M
|
||||||
|
RCC.HCLKFreq_Value=72000000
|
||||||
|
RCC.HSEDivPLL=RCC_HSE_PREDIV_DIV5
|
||||||
|
RCC.HSE_VALUE=25000000
|
||||||
|
RCC.I2S2Freq_Value=72000000
|
||||||
|
RCC.I2S3Freq_Value=72000000
|
||||||
|
RCC.IPParameters=ADCFreqValue,ADCPresc,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSEDivPLL,HSE_VALUE,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,PLLMUL,PLLSourceVirtual,Prediv1Source,Prediv2,Prediv2FreqValue,RTCClockSelection,RTCFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
|
||||||
|
RCC.MCOFreq_Value=72000000
|
||||||
|
RCC.PLL2CLKoutputFreqValue=40000000
|
||||||
|
RCC.PLL2VCOoutputFreqValue=80000000
|
||||||
|
RCC.PLL3CLKoutputFreqValue=40000000
|
||||||
|
RCC.PLL3VCOoutputFreqValue=80000000
|
||||||
|
RCC.PLLCLKFreq_Value=72000000
|
||||||
|
RCC.PLLMUL=RCC_PLL_MUL9
|
||||||
|
RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
|
||||||
|
RCC.Prediv1Source=RCC_PREDIV1_SOURCE_PLL2
|
||||||
|
RCC.Prediv2=RCC_HSE_PREDIV2_DIV5
|
||||||
|
RCC.Prediv2FreqValue=5000000
|
||||||
|
RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE
|
||||||
|
RCC.RTCFreq_Value=32768
|
||||||
|
RCC.SYSCLKFreq_VALUE=72000000
|
||||||
|
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||||
|
RCC.TimSysFreq_Value=72000000
|
||||||
|
RCC.USBFreq_Value=48000000
|
||||||
|
RCC.VCOOutput2Freq_Value=8000000
|
||||||
|
SH.ADCx_IN3.0=ADC1_IN3,IN3
|
||||||
|
SH.ADCx_IN3.ConfNb=1
|
||||||
|
SH.ADCx_IN4.0=ADC1_IN4,IN4
|
||||||
|
SH.ADCx_IN4.ConfNb=1
|
||||||
|
SH.ADCx_IN8.0=ADC1_IN8,IN8
|
||||||
|
SH.ADCx_IN8.ConfNb=1
|
||||||
|
SH.ADCx_IN9.0=ADC1_IN9,IN9
|
||||||
|
SH.ADCx_IN9.ConfNb=1
|
||||||
|
SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
|
||||||
|
SH.S_TIM3_CH2.ConfNb=1
|
||||||
|
SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2
|
||||||
|
SH.S_TIM4_CH2.ConfNb=1
|
||||||
|
SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3
|
||||||
|
SH.S_TIM4_CH3.ConfNb=1
|
||||||
|
SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4
|
||||||
|
SH.S_TIM4_CH4.ConfNb=1
|
||||||
|
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||||
|
TIM3.IPParameters=Channel-PWM Generation2 CH2
|
||||||
|
TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||||
|
TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
|
||||||
|
TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
|
||||||
|
TIM4.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4,Prescaler,Period
|
||||||
|
TIM4.Period=100
|
||||||
|
TIM4.Prescaler=720
|
||||||
|
UART5.BaudRate=9600
|
||||||
|
UART5.IPParameters=VirtualMode,BaudRate
|
||||||
|
UART5.VirtualMode=Asynchronous
|
||||||
|
USART1.IPParameters=VirtualMode
|
||||||
|
USART1.VirtualMode=VM_ASYNC
|
||||||
|
USART2.IPParameters=VirtualMode
|
||||||
|
USART2.VirtualMode=VM_ASYNC
|
||||||
|
USART3.IPParameters=VirtualMode
|
||||||
|
USART3.VirtualMode=VM_ASYNC
|
||||||
|
VP_ADC1_TempSens_Input.Mode=IN-TempSens
|
||||||
|
VP_ADC1_TempSens_Input.Signal=ADC1_TempSens_Input
|
||||||
|
VP_ADC1_Vref_Input.Mode=IN-Vrefint
|
||||||
|
VP_ADC1_Vref_Input.Signal=ADC1_Vref_Input
|
||||||
|
VP_CRC_VS_CRC.Mode=CRC_Activate
|
||||||
|
VP_CRC_VS_CRC.Signal=CRC_VS_CRC
|
||||||
|
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
|
||||||
|
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
|
||||||
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
|
VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
||||||
|
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
|
||||||
|
VP_TIM4_VS_ClockSourceINT.Mode=Internal
|
||||||
|
VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
|
||||||
|
board=custom
|
||||||
|
isbadioc=false
|
||||||
BIN
Core/.DS_Store
vendored
Executable file
BIN
Core/.DS_Store
vendored
Executable file
Binary file not shown.
BIN
Core/Inc/.DS_Store
vendored
Executable file
BIN
Core/Inc/.DS_Store
vendored
Executable file
Binary file not shown.
52
Core/Inc/adc.h
Executable file
52
Core/Inc/adc.h
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file adc.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the adc.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __ADC_H__
|
||||||
|
#define __ADC_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_ADC1_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ADC_H__ */
|
||||||
|
|
||||||
64
Core/Inc/board.h
Executable file
64
Core/Inc/board.h
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* board.h
|
||||||
|
*
|
||||||
|
* Created on: Apr 15, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_BOARD_H_
|
||||||
|
#define SRC_BOARD_H_
|
||||||
|
|
||||||
|
void GBT_Lock(uint8_t state);
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
RELAY_AUX0 = 0,
|
||||||
|
RELAY_AUX1,
|
||||||
|
RELAY3,
|
||||||
|
RELAY_DC,
|
||||||
|
RELAY_AC,
|
||||||
|
RELAY_CP,
|
||||||
|
RELAY_CC,
|
||||||
|
RELAY_DC1,
|
||||||
|
//
|
||||||
|
RELAY_COUNT
|
||||||
|
} relay_t;
|
||||||
|
|
||||||
|
void RELAY_Write(relay_t num, uint8_t state);
|
||||||
|
void Init_Peripheral();
|
||||||
|
uint8_t GBT_LockGetState();
|
||||||
|
void GBT_Lock(uint8_t state);
|
||||||
|
uint8_t SW_GetAddr();
|
||||||
|
void ADC_Select_Channel(uint32_t ch);
|
||||||
|
uint8_t ADC_TryLock(void);
|
||||||
|
void ADC_LockBlocking(void);
|
||||||
|
void ADC_Unlock(void);
|
||||||
|
int16_t GBT_ReadTemp(uint8_t ch);
|
||||||
|
int16_t CONN_ReadTemp(uint8_t ch);
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
IN_SW0 = 0,
|
||||||
|
IN_SW1,
|
||||||
|
IN0,
|
||||||
|
IN_ESTOP,
|
||||||
|
IN_FB1,
|
||||||
|
IN_CONT_FB_DC,
|
||||||
|
ISO_IN,
|
||||||
|
} inputNum_t;
|
||||||
|
|
||||||
|
uint8_t IN_ReadInput(inputNum_t input_n);
|
||||||
|
|
||||||
|
// Версия устройства
|
||||||
|
#define VERSION_OFFSET (0x1E4)
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint32_t serialNumber; // Байты 0-3: серийный номер станции (little-endian)
|
||||||
|
uint8_t stationType; // Байт 4: тип станции
|
||||||
|
uint8_t boardVersion; // Байт 5: версия платы
|
||||||
|
uint8_t addrEdcan; // Байт 6: адрес EDCAN
|
||||||
|
uint8_t reserved[57]; // Байты 7-63: зарезервированы
|
||||||
|
} InfoBlock_t;
|
||||||
|
|
||||||
|
extern InfoBlock_t *InfoBlock;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SRC_BOARD_H_ */
|
||||||
55
Core/Inc/can.h
Executable file
55
Core/Inc/can.h
Executable file
@@ -0,0 +1,55 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file can.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the can.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __CAN_H__
|
||||||
|
#define __CAN_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern CAN_HandleTypeDef hcan1;
|
||||||
|
|
||||||
|
extern CAN_HandleTypeDef hcan2;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_CAN1_Init(void);
|
||||||
|
void MX_CAN2_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CAN_H__ */
|
||||||
|
|
||||||
13
Core/Inc/charger_config.h
Executable file
13
Core/Inc/charger_config.h
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#define PSU_MAX_VOLTAGE 1000 //1V/bit
|
||||||
|
#define PSU_MIN_VOLTAGE 150 //1V/bit
|
||||||
|
#define PSU_MAX_CURRENT 133 //1A/bit
|
||||||
|
#define PSU_MIN_CURRENT 1 //1A/bit
|
||||||
|
#define PSU_MAX_POWER 30000 //1W/bit
|
||||||
|
|
||||||
|
#define PSU_NUM 1
|
||||||
|
|
||||||
|
#define GBT_CH_VER_MAJOR 1
|
||||||
|
#define GBT_CH_VER_MINOR 0
|
||||||
98
Core/Inc/charger_control.h
Executable file
98
Core/Inc/charger_control.h
Executable file
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* charger_control.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 29, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_CHARGER_CONTROL_H_
|
||||||
|
#define INC_CHARGER_CONTROL_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
// Статус
|
||||||
|
// статус подключения к автомобилю
|
||||||
|
|
||||||
|
typedef enum __attribute__((packed)) {
|
||||||
|
Unknown,
|
||||||
|
Unplugged,
|
||||||
|
Disabled,
|
||||||
|
Preparing,
|
||||||
|
AuthRequired,
|
||||||
|
WaitingForEnergy,
|
||||||
|
ChargingPausedEV,
|
||||||
|
ChargingPausedEVSE,
|
||||||
|
Charging,
|
||||||
|
AuthTimeout,
|
||||||
|
Finished,
|
||||||
|
FinishedEVSE,
|
||||||
|
FinishedEV,
|
||||||
|
Replugging
|
||||||
|
} CONN_State_t;
|
||||||
|
|
||||||
|
// Управление
|
||||||
|
// Разрешение на зарядку
|
||||||
|
|
||||||
|
typedef enum __attribute__((packed)){
|
||||||
|
CMD_NONE = 0,
|
||||||
|
CMD_STOP = 1,
|
||||||
|
CMD_START = 2,
|
||||||
|
CMD_FORCE_UNLOCK = 3,
|
||||||
|
CMD_REPLUG = 4,
|
||||||
|
} CONN_Control_t;
|
||||||
|
|
||||||
|
typedef enum __attribute__((packed)){
|
||||||
|
CONN_NO_ERROR = 0,
|
||||||
|
CONN_ERR_INSULATION = 1, // Утечка тока
|
||||||
|
CONN_ERR_EMERGENCY = 2, // Нажата кнопка аварийной остановки
|
||||||
|
CONN_ERR_DOOR_OPEN = 3, // Открыта дверь
|
||||||
|
CONN_ERR_LOCK = 4, // Ошибка замка
|
||||||
|
CONN_ERR_CONN_TEMP = 5, // Перегрев коннектора
|
||||||
|
CONN_ERR_AC_FAULT = 6, // Нет напряжения сети
|
||||||
|
CONN_ERR_CONTACTOR = 7, // Контактор неисправен
|
||||||
|
CONN_ERR_HOTPLUG = 8, // Коннектор неожиданно отключился
|
||||||
|
CONN_ERR_EV_COMM = 9, // Ошибка протокола связи с электромобилем
|
||||||
|
CONN_ERR_PSU_FAULT = 10, // Ошибка PSU
|
||||||
|
|
||||||
|
}CONN_Error_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
CONN_Control_t connControl; //0
|
||||||
|
CONN_State_t connState; //1
|
||||||
|
uint8_t SOC; // State of charge [%] //2
|
||||||
|
uint32_t Power; // Power [W] //3..6
|
||||||
|
uint32_t Energy; // Energy [Wh] //7..10
|
||||||
|
uint32_t RequestedPower; //1W/bit
|
||||||
|
uint16_t RequestedVoltage; //1V/bit
|
||||||
|
uint16_t RequestedCurrent; //0.1A/bit
|
||||||
|
uint16_t MeasuredVoltage; //1V/bit
|
||||||
|
uint16_t MeasuredCurrent; //0.1A/bit
|
||||||
|
uint8_t EnableOutput;
|
||||||
|
uint8_t outputEnabled;
|
||||||
|
int16_t UnmetDemand;
|
||||||
|
uint16_t WantedCurrent; //0.1A/bit
|
||||||
|
CONN_Error_t chargingError; // 0 if okay
|
||||||
|
uint8_t EvConnected;
|
||||||
|
|
||||||
|
} ChargingConnector_t;
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
extern ChargingConnector_t CONN;
|
||||||
|
|
||||||
|
//информация о зарядке
|
||||||
|
|
||||||
|
//база данных с хранением инфы
|
||||||
|
//главный блок хранит в себе инфу о конфиге возможно во флеше
|
||||||
|
//либо в charger_config.h
|
||||||
|
//OCPP - универсальный блок типа
|
||||||
|
|
||||||
|
void CONN_Init();
|
||||||
|
void CONN_Loop();
|
||||||
|
|
||||||
|
void CONN_PrintChargingTotal();
|
||||||
|
|
||||||
|
#endif /* INC_CHARGER_CONTROL_H_ */
|
||||||
21
Core/Inc/connector.h
Executable file
21
Core/Inc/connector.h
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* connector.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 31, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_CONNECTOR_H_
|
||||||
|
#define INC_CONNECTOR_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "charger_control.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern CONN_State_t connectorState;
|
||||||
|
|
||||||
|
void CONN_Init();
|
||||||
|
void CONN_Task();
|
||||||
|
void CONN_SetState(CONN_State_t state);
|
||||||
|
|
||||||
|
#endif /* INC_CONNECTOR_H_ */
|
||||||
27
Core/Inc/cp.h
Normal file
27
Core/Inc/cp.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef __CP_H
|
||||||
|
#define __CP_H
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define DUTY_INVERT 0
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
EV_STATE_A_IDLE = 0,
|
||||||
|
EV_STATE_B_CONN_PREP = 1,
|
||||||
|
EV_STATE_C_CONN_ACTIVE = 2,
|
||||||
|
EV_STATE_D_CONN_ACT_VENT = 3,
|
||||||
|
EV_STATE_E_NO_POWER = 4,
|
||||||
|
EV_STATE_F_ERROR = 5,
|
||||||
|
EV_STATE_ACQUIRING = 6,
|
||||||
|
} CP_State_t;
|
||||||
|
|
||||||
|
void CP_Init(void);
|
||||||
|
void CP_SetDuty(uint8_t percentage);
|
||||||
|
uint8_t CP_GetDuty(void);
|
||||||
|
int32_t CP_GetVoltage(void);
|
||||||
|
CP_State_t CP_GetState(void);
|
||||||
|
void CP_Loop(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
52
Core/Inc/crc.h
Normal file
52
Core/Inc/crc.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file crc.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the crc.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __CRC_H__
|
||||||
|
#define __CRC_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern CRC_HandleTypeDef hcrc;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_CRC_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CRC_H__ */
|
||||||
|
|
||||||
34
Core/Inc/debug.h
Executable file
34
Core/Inc/debug.h
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* debug.h
|
||||||
|
*
|
||||||
|
* Created on: Apr 16, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_DEBUG_H_
|
||||||
|
#define SRC_DEBUG_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LOG_EMERG = 1,
|
||||||
|
LOG_ALERT = 2,
|
||||||
|
LOG_CRIT = 3,
|
||||||
|
LOG_ERR = 4,
|
||||||
|
LOG_WARN = 5,
|
||||||
|
LOG_NOTICE = 6,
|
||||||
|
LOG_INFO = 7,
|
||||||
|
LOG_DEBUG = 8,
|
||||||
|
} LogLevel_t;
|
||||||
|
|
||||||
|
|
||||||
|
// Функции для работы с кольцевым буфером отладочных сообщений
|
||||||
|
void debug_buffer_add(const uint8_t* data, uint16_t len);
|
||||||
|
uint16_t debug_buffer_available(void);
|
||||||
|
void debug_buffer_send(void);
|
||||||
|
|
||||||
|
// Кастомный printf с приоритетом лога
|
||||||
|
int log_printf(LogLevel_t level, const char *format, ...);
|
||||||
|
|
||||||
|
#endif /* SRC_DEBUG_H_ */
|
||||||
49
Core/Inc/gpio.h
Executable file
49
Core/Inc/gpio.h
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file gpio.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the gpio.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __GPIO_H__
|
||||||
|
#define __GPIO_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_GPIO_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /*__ GPIO_H__ */
|
||||||
|
|
||||||
119
Core/Inc/main.h
Normal file
119
Core/Inc/main.h
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file : main.h
|
||||||
|
* @brief : Header for main.c file.
|
||||||
|
* This file contains the common defines of the application.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __MAIN_H
|
||||||
|
#define __MAIN_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f1xx_hal.h"
|
||||||
|
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include <stdio.h>
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN ET */
|
||||||
|
|
||||||
|
/* USER CODE END ET */
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN EC */
|
||||||
|
#define FW_VERSION_MAJOR 0x01
|
||||||
|
#define FW_VERSION_MINOR 0x00
|
||||||
|
#define FW_VERSION_PATCH 0x02
|
||||||
|
/* 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 RELAY_CP_Pin GPIO_PIN_3
|
||||||
|
#define RELAY_CP_GPIO_Port GPIOC
|
||||||
|
#define IN_SW0_Pin GPIO_PIN_1
|
||||||
|
#define IN_SW0_GPIO_Port GPIOA
|
||||||
|
#define IN_SW1_Pin GPIO_PIN_2
|
||||||
|
#define IN_SW1_GPIO_Port GPIOA
|
||||||
|
#define CP_ADC_Pin GPIO_PIN_4
|
||||||
|
#define CP_ADC_GPIO_Port GPIOA
|
||||||
|
#define CP_PWM_Pin GPIO_PIN_7
|
||||||
|
#define CP_PWM_GPIO_Port GPIOA
|
||||||
|
#define LOCK_A_Pin GPIO_PIN_4
|
||||||
|
#define LOCK_A_GPIO_Port GPIOC
|
||||||
|
#define LOCK_B_Pin GPIO_PIN_5
|
||||||
|
#define LOCK_B_GPIO_Port GPIOC
|
||||||
|
#define ADC_NTC1_Pin GPIO_PIN_0
|
||||||
|
#define ADC_NTC1_GPIO_Port GPIOB
|
||||||
|
#define ADC_NTC2_Pin GPIO_PIN_1
|
||||||
|
#define ADC_NTC2_GPIO_Port GPIOB
|
||||||
|
#define IN0_Pin GPIO_PIN_7
|
||||||
|
#define IN0_GPIO_Port GPIOE
|
||||||
|
#define RELAY1_Pin GPIO_PIN_8
|
||||||
|
#define RELAY1_GPIO_Port GPIOE
|
||||||
|
#define RELAY2_Pin GPIO_PIN_9
|
||||||
|
#define RELAY2_GPIO_Port GPIOE
|
||||||
|
#define RELAY3_Pin GPIO_PIN_10
|
||||||
|
#define RELAY3_GPIO_Port GPIOE
|
||||||
|
#define RELAY4_Pin GPIO_PIN_11
|
||||||
|
#define RELAY4_GPIO_Port GPIOE
|
||||||
|
#define RELAY5_Pin GPIO_PIN_12
|
||||||
|
#define RELAY5_GPIO_Port GPIOE
|
||||||
|
#define AC_OK_Pin GPIO_PIN_14
|
||||||
|
#define AC_OK_GPIO_Port GPIOE
|
||||||
|
#define RELAY_CC_Pin GPIO_PIN_15
|
||||||
|
#define RELAY_CC_GPIO_Port GPIOA
|
||||||
|
#define RELAY_DC_Pin GPIO_PIN_3
|
||||||
|
#define RELAY_DC_GPIO_Port GPIOD
|
||||||
|
#define USART2_DIR_Pin GPIO_PIN_4
|
||||||
|
#define USART2_DIR_GPIO_Port GPIOD
|
||||||
|
#define IN_ESTOP_Pin GPIO_PIN_7
|
||||||
|
#define IN_ESTOP_GPIO_Port GPIOD
|
||||||
|
#define IN_FB2_Pin GPIO_PIN_3
|
||||||
|
#define IN_FB2_GPIO_Port GPIOB
|
||||||
|
#define IN_FB1_Pin GPIO_PIN_4
|
||||||
|
#define IN_FB1_GPIO_Port GPIOB
|
||||||
|
#define EE_WP_Pin GPIO_PIN_7
|
||||||
|
#define EE_WP_GPIO_Port GPIOB
|
||||||
|
#define ISO_IN_Pin GPIO_PIN_1
|
||||||
|
#define ISO_IN_GPIO_Port GPIOE
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __MAIN_H */
|
||||||
31
Core/Inc/meter.h
Executable file
31
Core/Inc/meter.h
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* psu_struct.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 24, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_METER_H_
|
||||||
|
#define INC_METER_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "charger_config.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t meterLastTick; // Время последнего пакета Alive
|
||||||
|
uint8_t online;
|
||||||
|
uint32_t lastTick; // Время последнего вызова для каждого коннектора
|
||||||
|
uint64_t EnergyPSU_Ws; // Энергия для каждого коннектора (расчет по силовым модулям)
|
||||||
|
uint32_t AbsoluteEnergy; // Абсолютная энергия каждого счетчика (ватт*час)
|
||||||
|
uint32_t EnergyOffset; // смещение энергии по счетчикам (если 0, значит не успели захватить Offset) (ватт*час)
|
||||||
|
uint32_t EnergyOffset1; // смещение энергии по счетчикам относительно PSU
|
||||||
|
|
||||||
|
uint8_t enable; //если 0, то счетчик обнуляется
|
||||||
|
}METER_t;
|
||||||
|
|
||||||
|
extern METER_t METER;
|
||||||
|
|
||||||
|
void METER_CalculateEnergy();
|
||||||
|
|
||||||
|
#endif /* INC_METER_H_ */
|
||||||
196
Core/Inc/psu_control.h
Executable file
196
Core/Inc/psu_control.h
Executable file
@@ -0,0 +1,196 @@
|
|||||||
|
/*
|
||||||
|
* ccs_control.h
|
||||||
|
*
|
||||||
|
* Created on: 19 авг. 2024 г.
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_PSU_CONTROL_H_
|
||||||
|
#define INC_PSU_CONTROL_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "charger_config.h"
|
||||||
|
|
||||||
|
void PSU_Init();
|
||||||
|
void PSU_Enable(uint8_t addr, uint8_t enable);
|
||||||
|
void PSU_Loop();
|
||||||
|
void CONT_Loop();
|
||||||
|
|
||||||
|
// --- Состояние силового модуля (DC30, один PSU) ---
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
PSU_UNREADY, // отключен, не готов к использованию
|
||||||
|
PSU_INITIALIZING, // инициализация модуля
|
||||||
|
PSU_READY, // отключен, готов к использованию
|
||||||
|
PSU_WAIT_ACK_ON, // ждём подтверждение включения модуля (напряжение выше порога)
|
||||||
|
PSU_CONT_WAIT_ACK_ON, // включаем DC-контактор и ждём подтверждение
|
||||||
|
PSU_CONNECTED, // модуль включён, DC-контактор замкнут
|
||||||
|
PSU_CURRENT_DROP, // снижение тока перед отключением
|
||||||
|
PSU_WAIT_ACK_OFF, // ждём подтверждение выключения модуля (напряжение ниже порога)
|
||||||
|
PSU_CONT_WAIT_ACK_OFF, // выключаем DC-контактор и ждём подтверждение
|
||||||
|
PSU_OFF_PAUSE, // пауза после выключения модуля
|
||||||
|
} PSU_State_t;
|
||||||
|
|
||||||
|
/* Status0 (состояние модуля N, таблица 0 — modularForm0) */
|
||||||
|
typedef struct{
|
||||||
|
/* Bit0 */ uint8_t shortCircuitFault:1; /* 1: короткое замыкание на выходе */
|
||||||
|
/* Bit1 */ uint8_t unevenFlowAlarm:1; /* 1: перекос/неравномерность распределения тока между модулями */
|
||||||
|
/* Bit2 */ uint8_t internalCommunicationFault:1; /* 1: внутренняя ошибка связи модуля */
|
||||||
|
/* Bit3 */ uint8_t inputBusLineFault:1; /* 1: авария по входу или по шине постоянного тока */
|
||||||
|
/* Bit4 */ uint8_t lockProtection:1; /* 1: защита с защёлкой (латч, блокировка до сброса) */
|
||||||
|
/* Bit5 */ uint8_t dischargeFault:1; /* 1: неисправность цепи разряда (bleeder/разрядный резистор) */
|
||||||
|
/* Bit6 */ uint8_t eepromFault:1; /* 1: ошибка/неисправность EEPROM */
|
||||||
|
/* Bit7 */ uint8_t rsvd_s0:1; /* зарезервировано */
|
||||||
|
} PSU_Status0_t;
|
||||||
|
|
||||||
|
/* Status1 (состояние модуля N, таблица 1 — modularForm1) */
|
||||||
|
typedef struct{
|
||||||
|
/* Bit0 */ uint8_t dcSideOffStatus:1; /* 1: отключена сторона постоянного тока (DC-выход) */
|
||||||
|
/* Bit1 */ uint8_t moduleFaultAlarm:1; /* 1: общая авария модуля */
|
||||||
|
/* Bit2 */ uint8_t moduleProtectionAlarm:1; /* 1: сработала защита модуля */
|
||||||
|
/* Bit3 */ uint8_t fanFaultAlarm:1; /* 1: авария вентилятора */
|
||||||
|
/* Bit4 */ uint8_t overTempAlarm:1; /* 1: перегрев модуля */
|
||||||
|
/* Bit5 */ uint8_t outputOverVoltageAlarm:1; /* 1: перенапряжение на выходе */
|
||||||
|
/* Bit6 */ uint8_t outputOverCurrentAlarm:1; /* 1: сверхток на выходе */
|
||||||
|
/* Bit7 */ uint8_t canCommunicationInterruptAlarm:1; /* 1: нарушение связи по CAN */
|
||||||
|
} PSU_Status1_t;
|
||||||
|
|
||||||
|
/* Status2 (состояние модуля N, таблица 2 — modularForm2) */
|
||||||
|
typedef struct{
|
||||||
|
/* Bit0 */ uint8_t powerLimitStatus:1; /* 1: активен режим ограничения мощности */
|
||||||
|
/* Bit1 */ uint8_t moduleAddressDuplicate:1; /* 1: дублирование адреса модуля */
|
||||||
|
/* Bit2 */ uint8_t severeUnevenFlowFault:1; /* 1: сильный перекос токораспределения между модулями */
|
||||||
|
/* Bit3 */ uint8_t threePhaseInputPhaseLossAlarm:1; /* 1: авария по пропаданию фазы трёхфазного входа */
|
||||||
|
/* Bit4 */ uint8_t threePhaseInputUnbalanceAlarm:1; /* 1: авария по разбалансу трёхфазного входа */
|
||||||
|
/* Bit5 */ uint8_t inputUnderVoltageAlarm:1; /* 1: пониженное напряжение на входе */
|
||||||
|
/* Bit6 */ uint8_t inputOverVoltageAlarm:1; /* 1: повышенное напряжение на входе */
|
||||||
|
/* Bit7 */ uint8_t pfcSideOffStatus:1; /* 1: отключена сторона PFC */
|
||||||
|
} PSU_Status2_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t enableAC; // состояние AC-контактора (желание)
|
||||||
|
uint8_t enableOutput; // разрешение выхода модуля (желание)
|
||||||
|
uint16_t outputVoltage; // измеренное выходное напряжение [В]
|
||||||
|
int16_t outputCurrent; // измеренный выходной ток [0.1 А]
|
||||||
|
uint8_t temperature; // температура модуля
|
||||||
|
|
||||||
|
PSU_State_t state; // состояние силового модуля и контакторов
|
||||||
|
|
||||||
|
uint8_t online; // модуль в сети (есть телеметрия)
|
||||||
|
uint8_t ready; // модуль готов к работе (online && нет ошибок)
|
||||||
|
uint8_t PSU_enabled; // на выходе есть напряжение (> порога)
|
||||||
|
uint8_t CONT_enabled; // DC-контактор замкнут (по обратной связи)
|
||||||
|
uint8_t cont_fault; // внутренняя ошибка контакторов
|
||||||
|
uint8_t psu_fault; // внутренняя ошибка силового модуля
|
||||||
|
|
||||||
|
uint32_t statetick; // время входа в состояние
|
||||||
|
|
||||||
|
// Дополнительные параметры для одного модуля DC30
|
||||||
|
uint32_t power_limit; // лимит мощности [кВт]
|
||||||
|
uint8_t hv_mode; // HV-режим (ограничение напряжения)
|
||||||
|
|
||||||
|
uint32_t tempAmbient; // температура окружающего воздуха (из PSU_04)
|
||||||
|
union { uint8_t raw; PSU_Status0_t bits; } status0; // modularForm0
|
||||||
|
union { uint8_t raw; PSU_Status1_t bits; } status1; // modularForm1
|
||||||
|
union { uint8_t raw; PSU_Status2_t bits; } status2; // modularForm2
|
||||||
|
} PSU_t;
|
||||||
|
|
||||||
|
extern PSU_t PSU0;
|
||||||
|
|
||||||
|
void PSU_Task(void);
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t source:8;
|
||||||
|
uint8_t destination:8;
|
||||||
|
uint8_t command:6;
|
||||||
|
uint8_t device:4;
|
||||||
|
uint8_t error:3;
|
||||||
|
|
||||||
|
}CanId_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t rsvd0[2];
|
||||||
|
uint16_t moduleNumber;
|
||||||
|
uint8_t rsvd1[5];
|
||||||
|
}PSU_02_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t rsvd0[2];
|
||||||
|
uint16_t moduleGroupNumber;
|
||||||
|
uint8_t moduleTemperature;
|
||||||
|
uint8_t rsvd1;
|
||||||
|
uint8_t modularForm2;
|
||||||
|
uint8_t modularForm1;
|
||||||
|
uint8_t modularForm0;
|
||||||
|
}PSU_04_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t VABHi;
|
||||||
|
uint8_t VABLo;
|
||||||
|
uint8_t VBCHi;
|
||||||
|
uint8_t VBCLo;
|
||||||
|
uint8_t VCAHi;
|
||||||
|
uint8_t VCALo;
|
||||||
|
uint8_t rsvd1[2];
|
||||||
|
|
||||||
|
uint32_t VAB;
|
||||||
|
uint32_t VBC;
|
||||||
|
uint32_t VCA;
|
||||||
|
}PSU_06_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint32_t totalSystemVoltage;
|
||||||
|
uint32_t totalSystemCurrent;
|
||||||
|
}PSU_08_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t moduleNVoltage_[4];
|
||||||
|
uint8_t moduleNCurrent_[4];
|
||||||
|
uint32_t moduleNVoltage;
|
||||||
|
uint32_t moduleNCurrent;
|
||||||
|
}PSU_09_t;
|
||||||
|
|
||||||
|
// setup
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t enable;
|
||||||
|
uint8_t rsvd1[7];
|
||||||
|
}PSU_1A_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t moduleVoltage[4];
|
||||||
|
uint8_t moduleCurrentTotal[4];
|
||||||
|
}PSU_1B_t;
|
||||||
|
|
||||||
|
//typedef struct{
|
||||||
|
// uint32_t moduleVoltage;
|
||||||
|
// uint32_t moduleCurrentTotal;
|
||||||
|
//}PSU_1B_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t moduleVoltage[4];
|
||||||
|
uint8_t moduleCurrentTotal[4];
|
||||||
|
}PSU_1C_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t enable;
|
||||||
|
uint8_t rsvd1[7];
|
||||||
|
}PSU_1D_t;
|
||||||
|
|
||||||
|
extern PSU_02_t PSU_02;
|
||||||
|
extern PSU_04_t PSU_04;
|
||||||
|
extern PSU_06_t PSU_06;
|
||||||
|
extern PSU_08_t PSU_08;
|
||||||
|
extern PSU_09_t PSU_09;
|
||||||
|
|
||||||
|
extern PSU_1A_t PSU_1A;
|
||||||
|
extern PSU_1B_t PSU_1B;
|
||||||
|
extern PSU_1C_t PSU_1C;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INC_PSU_CONTROL_H_ */
|
||||||
53
Core/Inc/rgb_controller.h
Executable file
53
Core/Inc/rgb_controller.h
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* rgb_handler.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 25, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_RGB_CONTROLLER_H_
|
||||||
|
#define INC_RGB_CONTROLLER_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t R;
|
||||||
|
uint8_t G;
|
||||||
|
uint8_t B;
|
||||||
|
|
||||||
|
}RGB_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
RGB_t Color1;
|
||||||
|
uint8_t Tr; //20ms/step, 5.1s max
|
||||||
|
uint8_t Th; //20ms/step, 5.1s max
|
||||||
|
uint8_t Tf; //20ms/step, 5.1s max
|
||||||
|
uint8_t Tl; //20ms/step, 5.1s max
|
||||||
|
RGB_t Color2;
|
||||||
|
//uint8_t rsvd[6]; // 6 bytes reserved
|
||||||
|
}RGB_Cycle_t;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
LED_RISING,
|
||||||
|
LED_HIGH,
|
||||||
|
LED_FALLING,
|
||||||
|
LED_LOW,
|
||||||
|
}RGB_Phase_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t state; // 0 1 2 3
|
||||||
|
uint16_t tick;
|
||||||
|
RGB_t color;
|
||||||
|
uint8_t phasesync;
|
||||||
|
}RGB_State_t;
|
||||||
|
|
||||||
|
void LED_Task();
|
||||||
|
void LED_Write();
|
||||||
|
void LED_Init();
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* INC_RGB_CONTROLLER_H_ */
|
||||||
52
Core/Inc/rtc.h
Executable file
52
Core/Inc/rtc.h
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file rtc.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the rtc.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __RTC_H__
|
||||||
|
#define __RTC_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern RTC_HandleTypeDef hrtc;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_RTC_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RTC_H__ */
|
||||||
|
|
||||||
127
Core/Inc/serial.h
Normal file
127
Core/Inc/serial.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
#ifndef __SERIAL_H
|
||||||
|
#define __SERIAL_H
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "charger_control.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "cp.h"
|
||||||
|
|
||||||
|
void CCS_SerialLoop(void);
|
||||||
|
void CCS_Init(void);
|
||||||
|
void CCS_SendEmergencyStop(void);
|
||||||
|
void CCS_SendStart(void);
|
||||||
|
void CCS_RxEventCallback(UART_HandleTypeDef *huart, uint16_t size);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CCS_DISABLED = 0,
|
||||||
|
CCS_UNPLUGGED = 1,
|
||||||
|
CCS_AUTH_REQUIRED = 2,
|
||||||
|
CCS_CONNECTED = 3,
|
||||||
|
CCS_REPLUGGING = 4,
|
||||||
|
} CCS_ConnectorState_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PSU_OFF = 0,
|
||||||
|
PSU_ON = 1,
|
||||||
|
PSU_PREPARE = 2,
|
||||||
|
} EnablePSU_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t maxVoltage;
|
||||||
|
uint16_t minVoltage;
|
||||||
|
uint16_t maxCurrent;
|
||||||
|
uint16_t minCurrent;
|
||||||
|
uint32_t maxPower;
|
||||||
|
} CCS_MaxLoad_t;
|
||||||
|
|
||||||
|
/* Commands Everest -> module. */
|
||||||
|
#define CMD_E2M_PWM_DUTY 0x40
|
||||||
|
#define CMD_E2M_ENABLE_OUTPUT 0x41
|
||||||
|
#define CMD_E2M_RESET 0x42
|
||||||
|
#define CMD_E2M_ENABLE 0x43
|
||||||
|
#define CMD_E2M_REPLUG 0x44
|
||||||
|
#define CMD_E2M_SET_OUTPUT_VOLTAGE 0x45
|
||||||
|
#define CMD_E2M_ISOLATION_CONTROL 0x46
|
||||||
|
#define CMD_E2M_EV_INFO 0x47
|
||||||
|
#define CMD_E2M_EVSE_STATE 0x48
|
||||||
|
#define CMD_E2M_KEEP_ALIVE 0x49
|
||||||
|
|
||||||
|
/* Commands module -> Everest. */
|
||||||
|
#define CMD_M2E_STATE 0x50
|
||||||
|
#define CMD_M2E_RESET 0x52
|
||||||
|
#define CMD_M2E_ESTOP 0x53
|
||||||
|
#define CMD_M2E_START 0x54
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t pwm_duty_percent;
|
||||||
|
} e2m_pwm_duty_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t enable_output;
|
||||||
|
} e2m_enable_output_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t reset;
|
||||||
|
} e2m_reset_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t enable;
|
||||||
|
} e2m_enable_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t replug;
|
||||||
|
} e2m_replug_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint16_t voltage_V;
|
||||||
|
uint16_t current_0p1A;
|
||||||
|
} e2m_set_output_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t command;
|
||||||
|
} e2m_isolation_control_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint16_t valid_mask;
|
||||||
|
uint16_t soc;
|
||||||
|
uint16_t present_voltage;
|
||||||
|
uint16_t present_current;
|
||||||
|
uint16_t target_voltage;
|
||||||
|
uint16_t target_current;
|
||||||
|
uint16_t max_current;
|
||||||
|
uint16_t min_current;
|
||||||
|
uint16_t max_voltage;
|
||||||
|
uint32_t max_power;
|
||||||
|
uint32_t remaining_energy;
|
||||||
|
uint16_t battery_capacity;
|
||||||
|
uint16_t battery_full_soc;
|
||||||
|
uint16_t battery_bulk_soc;
|
||||||
|
uint32_t estimated_time_full;
|
||||||
|
uint32_t departure_time;
|
||||||
|
uint32_t estimated_time_bulk;
|
||||||
|
} CCS_EvInfo_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t DutyCycle;
|
||||||
|
uint8_t OutputEnabled;
|
||||||
|
uint16_t MeasuredVoltage;
|
||||||
|
uint16_t MeasuredCurrent;
|
||||||
|
uint32_t Power;
|
||||||
|
uint32_t Energy;
|
||||||
|
uint32_t IsolationResistance;
|
||||||
|
uint8_t IsolationValid;
|
||||||
|
uint8_t CpState;
|
||||||
|
uint16_t MaxVoltage;
|
||||||
|
uint16_t MinVoltage;
|
||||||
|
uint16_t MaxCurrent;
|
||||||
|
uint16_t MinCurrent;
|
||||||
|
uint32_t MaxPower;
|
||||||
|
} CCS_State_t;
|
||||||
|
|
||||||
|
extern CCS_MaxLoad_t CCS_MaxLoad;
|
||||||
|
extern CCS_EvInfo_t CCS_EvInfo;
|
||||||
|
extern CONN_State_t CCS_EvseState;
|
||||||
|
extern uint8_t REPLUG;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
182
Core/Inc/serial_control.h
Normal file
182
Core/Inc/serial_control.h
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
#ifndef SERIALCONTROL_H
|
||||||
|
#define SERIALCONTROL_H
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include "charger_control.h"
|
||||||
|
|
||||||
|
#define USE_WEB_INTERFACE
|
||||||
|
|
||||||
|
// Команды от ПК к устройству
|
||||||
|
// Пакет статуса изоляции от отдельного блока по одностороннему UART
|
||||||
|
#define CMD_ISOLATION_STATUS 0x01
|
||||||
|
|
||||||
|
#define CMD_GET_STATUS 0x40
|
||||||
|
|
||||||
|
#define CMD_GET_LOG 0x50
|
||||||
|
#define CMD_GET_LOG_CONTINUE 0x51
|
||||||
|
#define CMD_GET_INFO 0x60
|
||||||
|
|
||||||
|
// Команды с аргументами
|
||||||
|
#define CMD_SET_POWER_LIMIT 0xC0
|
||||||
|
#define CMD_TEST_PSU 0xC1
|
||||||
|
#define CMD_CHARGE_PERMIT 0xC2
|
||||||
|
|
||||||
|
// Сервисные команды
|
||||||
|
#define CMD_SET_CONFIG 0xB0
|
||||||
|
|
||||||
|
// Перезагрузка для входа в бутлоадер
|
||||||
|
#define CMD_DEVICE_RESET 0xB5
|
||||||
|
|
||||||
|
// Коды ответов
|
||||||
|
#define RESP_SUCCESS 0x12
|
||||||
|
#define RESP_FAILED 0x13
|
||||||
|
#define RESP_INVALID 0x14
|
||||||
|
|
||||||
|
// Максимальный размер буфера полезной нагрузки (включая 4 байта CRC)
|
||||||
|
#define MAX_TX_BUFFER_SIZE 256
|
||||||
|
// Максимальный размер буфера для принятого экранированного пакета без START/END
|
||||||
|
#define MAX_RX_BUFFER_SIZE 256
|
||||||
|
|
||||||
|
// Макросы для CRC
|
||||||
|
#define SERIAL_PROTOCOL_CRC_CLK_ENABLE() do { \
|
||||||
|
__IO uint32_t tmpreg; \
|
||||||
|
SET_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN);\
|
||||||
|
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN);\
|
||||||
|
UNUSED(tmpreg); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define SERIAL_PROTOCOL_CRC_CLK_DISABLE() (RCC->AHBENR &= ~(RCC_AHBENR_CRCEN))
|
||||||
|
|
||||||
|
#define CRC32_POLYNOMIAL ((uint32_t)0xEDB88320)
|
||||||
|
|
||||||
|
void ReadVersion();
|
||||||
|
|
||||||
|
// Структура для хранения принятой команды с аргументом
|
||||||
|
typedef struct {
|
||||||
|
uint8_t command;
|
||||||
|
uint8_t argument_length;
|
||||||
|
void* argument;
|
||||||
|
} ReceivedCommand_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SC_SOURCE_UART2 = 0,
|
||||||
|
SC_SOURCE_UART5 = 1,
|
||||||
|
} SC_Source_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint8_t isolationStatus;
|
||||||
|
uint16_t isolationResistance;
|
||||||
|
int16_t voltageHigh;
|
||||||
|
int16_t voltageLow;
|
||||||
|
int16_t voltageComm;
|
||||||
|
} IsolationStatusPacket_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
|
||||||
|
CONN_State_t connState;
|
||||||
|
CONN_Error_t chargingError; // Причина остановки зарядки
|
||||||
|
uint8_t SOC; // State of charge [%]
|
||||||
|
uint32_t Energy; // Energy [Wh]
|
||||||
|
uint16_t RequestedVoltage; //1V/bit
|
||||||
|
uint16_t RequestedCurrent; //0.1A/bit
|
||||||
|
uint16_t MeasuredVoltage; //1V/bit
|
||||||
|
uint16_t MeasuredCurrent; //0.1A/bit
|
||||||
|
uint8_t outputEnabled;
|
||||||
|
uint16_t chargingElapsedTimeMin;
|
||||||
|
uint8_t chargingElapsedTimeSec;
|
||||||
|
uint16_t estimatedRemainingChargingTime;
|
||||||
|
|
||||||
|
// Flags (32 bit)
|
||||||
|
uint8_t relayAC:1;
|
||||||
|
uint8_t relayDC:1;
|
||||||
|
uint8_t relayAUX:1;
|
||||||
|
uint8_t lockState:1;
|
||||||
|
uint8_t stopButton:1;
|
||||||
|
uint8_t logAvailable:1;
|
||||||
|
uint8_t evInfoAvailable:1;
|
||||||
|
uint8_t psuOnline:1;
|
||||||
|
uint8_t rsvd1[3];
|
||||||
|
|
||||||
|
int8_t tempConnector0;
|
||||||
|
int8_t tempConnector1;
|
||||||
|
int8_t tempAmbient;
|
||||||
|
int8_t tempBatteryMax;
|
||||||
|
int8_t tempBatteryMin;
|
||||||
|
|
||||||
|
uint16_t highestVoltageOfBatteryCell;
|
||||||
|
uint8_t batteryStatus;
|
||||||
|
|
||||||
|
uint16_t phaseVoltageAB;
|
||||||
|
uint16_t phaseVoltageBC;
|
||||||
|
uint16_t phaseVoltageCA;
|
||||||
|
|
||||||
|
char VIN[17];
|
||||||
|
|
||||||
|
uint8_t batteryType; //battery type
|
||||||
|
uint16_t batteryCapacity; // 0.1Ah/bit
|
||||||
|
uint16_t batteryVoltage; // 0.1V/bit
|
||||||
|
uint8_t batteryVendor[4]; // Battery vendor (ASCII string)
|
||||||
|
uint32_t batterySN; // int
|
||||||
|
uint8_t batteryManuY; // year (offset 1985)
|
||||||
|
uint8_t batteryManuM; // month
|
||||||
|
uint8_t batteryManuD; // day
|
||||||
|
uint16_t batteryCycleCount;
|
||||||
|
uint8_t ownAuto; // 0 = lizing, 1 = own auto
|
||||||
|
uint8_t EV_SW_VER[8];
|
||||||
|
|
||||||
|
uint8_t testMode;
|
||||||
|
uint16_t testVoltage;
|
||||||
|
uint16_t testCurrent;
|
||||||
|
|
||||||
|
} StatusPacket_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
uint16_t serialNumber;
|
||||||
|
uint8_t boardVersion;
|
||||||
|
uint8_t stationType;
|
||||||
|
uint16_t fw_version_major;
|
||||||
|
uint16_t fw_version_minor;
|
||||||
|
uint16_t fw_version_patch;
|
||||||
|
} InfoPacket_t;
|
||||||
|
|
||||||
|
typedef struct __attribute__((packed)) {
|
||||||
|
char location[3];
|
||||||
|
uint32_t chargerNumber;
|
||||||
|
uint32_t unixTime;
|
||||||
|
|
||||||
|
} ConfigBlock_t;
|
||||||
|
|
||||||
|
// Предварительное объявление структуры протокола
|
||||||
|
typedef struct SerialControl_t SerialControl_t;
|
||||||
|
|
||||||
|
// Структура протокола
|
||||||
|
struct SerialControl_t {
|
||||||
|
// Буферы для UART
|
||||||
|
uint8_t tx_buffer[MAX_TX_BUFFER_SIZE];
|
||||||
|
uint8_t rx_buffer[MAX_RX_BUFFER_SIZE];
|
||||||
|
|
||||||
|
// Переменные для передачи команды
|
||||||
|
volatile ReceivedCommand_t received_command;
|
||||||
|
volatile uint8_t command_ready;
|
||||||
|
|
||||||
|
// Время отправки последнего пакета
|
||||||
|
volatile uint32_t tx_tick;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Публичные методы
|
||||||
|
void SC_Init();
|
||||||
|
void SC_Task();
|
||||||
|
void SC_SendPacket(const uint8_t* payload, uint16_t payload_len, uint8_t response_code);
|
||||||
|
|
||||||
|
// Внешняя функция обработки команд (определена в serial_handler.c)
|
||||||
|
extern void SC_CommandHandler(ReceivedCommand_t* cmd);
|
||||||
|
|
||||||
|
extern SerialControl_t serial_control;
|
||||||
|
extern StatusPacket_t statusPacket;
|
||||||
|
extern InfoPacket_t infoPacket;
|
||||||
|
extern IsolationStatusPacket_t ISO;
|
||||||
|
extern volatile SC_Source_t g_sc_command_source;
|
||||||
|
|
||||||
|
#endif // SERIALCONTROL_H
|
||||||
23
Core/Inc/sma_filter.h
Normal file
23
Core/Inc/sma_filter.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef SMA_FILTER_H
|
||||||
|
#define SMA_FILTER_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Простая скользящая SMA (simple moving average) для целых значений.
|
||||||
|
// Окно фиксировано и задается макросом.
|
||||||
|
#ifndef SMA_FILTER_WINDOW
|
||||||
|
#define SMA_FILTER_WINDOW 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t sum;
|
||||||
|
uint16_t idx;
|
||||||
|
uint16_t count;
|
||||||
|
int32_t buffer[SMA_FILTER_WINDOW];
|
||||||
|
} SMAFilter_t;
|
||||||
|
|
||||||
|
void SMAFilter_Init(SMAFilter_t* f);
|
||||||
|
int32_t SMAFilter_Update(SMAFilter_t* f, int32_t x);
|
||||||
|
|
||||||
|
#endif // SMA_FILTER_H
|
||||||
|
|
||||||
19
Core/Inc/soft_rtc.h
Executable file
19
Core/Inc/soft_rtc.h
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* soft_rtc.h
|
||||||
|
*
|
||||||
|
* Created on: Jul 22, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_SOFT_RTC_H_
|
||||||
|
#define INC_SOFT_RTC_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
uint32_t get_Current_Time();
|
||||||
|
void set_Time(uint32_t unix_time);
|
||||||
|
void unix_to_bcd(uint32_t unix_time, uint8_t *time);
|
||||||
|
void writeTimeReg(uint8_t reg_number, uint8_t value);
|
||||||
|
uint8_t getTimeReg(uint8_t reg_number);
|
||||||
|
|
||||||
|
#endif /* INC_SOFT_RTC_H_ */
|
||||||
391
Core/Inc/stm32f1xx_hal_conf.h
Normal file
391
Core/Inc/stm32f1xx_hal_conf.h
Normal file
@@ -0,0 +1,391 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f1xx_hal_conf.h
|
||||||
|
* @brief HAL configuration file.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F1xx_HAL_CONF_H
|
||||||
|
#define __STM32F1xx_HAL_CONF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* ########################## Module Selection ############################## */
|
||||||
|
/**
|
||||||
|
* @brief This is the list of modules to be used in the HAL driver
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HAL_MODULE_ENABLED
|
||||||
|
#define HAL_ADC_MODULE_ENABLED
|
||||||
|
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||||
|
#define HAL_CAN_MODULE_ENABLED
|
||||||
|
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||||
|
/*#define HAL_CEC_MODULE_ENABLED */
|
||||||
|
/*#define HAL_CORTEX_MODULE_ENABLED */
|
||||||
|
#define HAL_CRC_MODULE_ENABLED
|
||||||
|
/*#define HAL_DAC_MODULE_ENABLED */
|
||||||
|
/*#define HAL_DMA_MODULE_ENABLED */
|
||||||
|
/*#define HAL_ETH_MODULE_ENABLED */
|
||||||
|
/*#define HAL_FLASH_MODULE_ENABLED */
|
||||||
|
#define HAL_GPIO_MODULE_ENABLED
|
||||||
|
/*#define HAL_I2C_MODULE_ENABLED */
|
||||||
|
/*#define HAL_I2S_MODULE_ENABLED */
|
||||||
|
/*#define HAL_IRDA_MODULE_ENABLED */
|
||||||
|
/*#define HAL_IWDG_MODULE_ENABLED */
|
||||||
|
/*#define HAL_NOR_MODULE_ENABLED */
|
||||||
|
/*#define HAL_NAND_MODULE_ENABLED */
|
||||||
|
/*#define HAL_PCCARD_MODULE_ENABLED */
|
||||||
|
/*#define HAL_PCD_MODULE_ENABLED */
|
||||||
|
/*#define HAL_HCD_MODULE_ENABLED */
|
||||||
|
/*#define HAL_PWR_MODULE_ENABLED */
|
||||||
|
/*#define HAL_RCC_MODULE_ENABLED */
|
||||||
|
#define HAL_RTC_MODULE_ENABLED
|
||||||
|
/*#define HAL_SD_MODULE_ENABLED */
|
||||||
|
/*#define HAL_MMC_MODULE_ENABLED */
|
||||||
|
/*#define HAL_SDRAM_MODULE_ENABLED */
|
||||||
|
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||||
|
/*#define HAL_SPI_MODULE_ENABLED */
|
||||||
|
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||||
|
#define HAL_TIM_MODULE_ENABLED
|
||||||
|
#define HAL_UART_MODULE_ENABLED
|
||||||
|
/*#define HAL_USART_MODULE_ENABLED */
|
||||||
|
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#define HAL_CORTEX_MODULE_ENABLED
|
||||||
|
#define HAL_DMA_MODULE_ENABLED
|
||||||
|
#define HAL_FLASH_MODULE_ENABLED
|
||||||
|
#define HAL_EXTI_MODULE_ENABLED
|
||||||
|
#define HAL_GPIO_MODULE_ENABLED
|
||||||
|
#define HAL_PWR_MODULE_ENABLED
|
||||||
|
#define HAL_RCC_MODULE_ENABLED
|
||||||
|
|
||||||
|
/* ########################## Oscillator Values adaptation ####################*/
|
||||||
|
/**
|
||||||
|
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||||
|
* This value is used by the RCC HAL module to compute the system frequency
|
||||||
|
* (when HSE is used as system clock source, directly or through the PLL).
|
||||||
|
*/
|
||||||
|
#if !defined (HSE_VALUE)
|
||||||
|
#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
|
||||||
|
#endif /* HSE_VALUE */
|
||||||
|
|
||||||
|
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||||
|
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
|
||||||
|
#endif /* HSE_STARTUP_TIMEOUT */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal High Speed oscillator (HSI) value.
|
||||||
|
* This value is used by the RCC HAL module to compute the system frequency
|
||||||
|
* (when HSI is used as system clock source, directly or through the PLL).
|
||||||
|
*/
|
||||||
|
#if !defined (HSI_VALUE)
|
||||||
|
#define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
|
||||||
|
#endif /* HSI_VALUE */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal Low Speed oscillator (LSI) value.
|
||||||
|
*/
|
||||||
|
#if !defined (LSI_VALUE)
|
||||||
|
#define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
|
||||||
|
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||||
|
The real value may vary depending on the variations
|
||||||
|
in voltage and temperature. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief External Low Speed oscillator (LSE) value.
|
||||||
|
* This value is used by the UART, RTC HAL module to compute the system frequency
|
||||||
|
*/
|
||||||
|
#if !defined (LSE_VALUE)
|
||||||
|
#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
|
||||||
|
#endif /* LSE_VALUE */
|
||||||
|
|
||||||
|
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||||
|
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
|
||||||
|
#endif /* LSE_STARTUP_TIMEOUT */
|
||||||
|
|
||||||
|
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||||
|
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||||
|
|
||||||
|
/* ########################### System Configuration ######################### */
|
||||||
|
/**
|
||||||
|
* @brief This is the HAL system configuration section
|
||||||
|
*/
|
||||||
|
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||||
|
#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority (lowest by default) */
|
||||||
|
#define USE_RTOS 0U
|
||||||
|
#define PREFETCH_ENABLE 1U
|
||||||
|
|
||||||
|
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||||
|
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
|
||||||
|
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||||
|
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||||
|
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||||
|
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
|
||||||
|
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
|
||||||
|
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
|
||||||
|
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
|
||||||
|
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
|
||||||
|
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
|
||||||
|
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
|
||||||
|
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
|
||||||
|
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
|
||||||
|
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
|
||||||
|
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
|
||||||
|
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
|
||||||
|
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
|
||||||
|
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||||
|
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
|
||||||
|
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||||
|
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||||
|
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||||
|
|
||||||
|
/* ########################## Assert Selection ############################## */
|
||||||
|
/**
|
||||||
|
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||||
|
* HAL drivers code
|
||||||
|
*/
|
||||||
|
/* #define USE_FULL_ASSERT 1U */
|
||||||
|
|
||||||
|
/* ################## Ethernet peripheral configuration ##################### */
|
||||||
|
|
||||||
|
/* Section 1 : Ethernet peripheral configuration */
|
||||||
|
|
||||||
|
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
|
||||||
|
#define MAC_ADDR0 2U
|
||||||
|
#define MAC_ADDR1 0U
|
||||||
|
#define MAC_ADDR2 0U
|
||||||
|
#define MAC_ADDR3 0U
|
||||||
|
#define MAC_ADDR4 0U
|
||||||
|
#define MAC_ADDR5 0U
|
||||||
|
|
||||||
|
/* Definition of the Ethernet driver buffers size and count */
|
||||||
|
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||||
|
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||||
|
#define ETH_RXBUFNB 8U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||||
|
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||||
|
|
||||||
|
/* Section 2: PHY configuration section */
|
||||||
|
|
||||||
|
/* DP83848_PHY_ADDRESS Address*/
|
||||||
|
#define DP83848_PHY_ADDRESS 0x01U
|
||||||
|
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
|
||||||
|
#define PHY_RESET_DELAY 0x000000FFU
|
||||||
|
/* PHY Configuration delay */
|
||||||
|
#define PHY_CONFIG_DELAY 0x00000FFFU
|
||||||
|
|
||||||
|
#define PHY_READ_TO 0x0000FFFFU
|
||||||
|
#define PHY_WRITE_TO 0x0000FFFFU
|
||||||
|
|
||||||
|
/* Section 3: Common PHY Registers */
|
||||||
|
|
||||||
|
#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
|
||||||
|
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
|
||||||
|
|
||||||
|
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
|
||||||
|
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
|
||||||
|
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
|
||||||
|
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
|
||||||
|
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
|
||||||
|
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
|
||||||
|
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
|
||||||
|
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
|
||||||
|
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
|
||||||
|
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
|
||||||
|
|
||||||
|
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
|
||||||
|
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
|
||||||
|
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
|
||||||
|
|
||||||
|
/* Section 4: Extended PHY Registers */
|
||||||
|
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
|
||||||
|
|
||||||
|
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
|
||||||
|
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
|
||||||
|
|
||||||
|
/* ################## SPI peripheral configuration ########################## */
|
||||||
|
|
||||||
|
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
|
||||||
|
* Activated: CRC code is present inside driver
|
||||||
|
* Deactivated: CRC code cleaned from driver
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USE_SPI_CRC 0U
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief Include module's header file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAL_RCC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_rcc.h"
|
||||||
|
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_gpio.h"
|
||||||
|
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_exti.h"
|
||||||
|
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DMA_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_dma.h"
|
||||||
|
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_ETH_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_eth.h"
|
||||||
|
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CAN_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_can.h"
|
||||||
|
#endif /* HAL_CAN_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
|
||||||
|
#include "Legacy/stm32f1xx_hal_can_legacy.h"
|
||||||
|
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CEC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_cec.h"
|
||||||
|
#endif /* HAL_CEC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_cortex.h"
|
||||||
|
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_ADC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_adc.h"
|
||||||
|
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_CRC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_crc.h"
|
||||||
|
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_DAC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_dac.h"
|
||||||
|
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_flash.h"
|
||||||
|
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SRAM_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_sram.h"
|
||||||
|
#endif /* HAL_SRAM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_NOR_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_nor.h"
|
||||||
|
#endif /* HAL_NOR_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_I2C_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_i2c.h"
|
||||||
|
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_I2S_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_i2s.h"
|
||||||
|
#endif /* HAL_I2S_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_iwdg.h"
|
||||||
|
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_PWR_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_pwr.h"
|
||||||
|
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_RTC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_rtc.h"
|
||||||
|
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_PCCARD_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_pccard.h"
|
||||||
|
#endif /* HAL_PCCARD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SD_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_sd.h"
|
||||||
|
#endif /* HAL_SD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_NAND_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_nand.h"
|
||||||
|
#endif /* HAL_NAND_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SPI_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_spi.h"
|
||||||
|
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_TIM_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_tim.h"
|
||||||
|
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_UART_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_uart.h"
|
||||||
|
#endif /* HAL_UART_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_USART_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_usart.h"
|
||||||
|
#endif /* HAL_USART_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_irda.h"
|
||||||
|
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_smartcard.h"
|
||||||
|
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_wwdg.h"
|
||||||
|
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_PCD_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_pcd.h"
|
||||||
|
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_HCD_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_hcd.h"
|
||||||
|
#endif /* HAL_HCD_MODULE_ENABLED */
|
||||||
|
|
||||||
|
#ifdef HAL_MMC_MODULE_ENABLED
|
||||||
|
#include "stm32f1xx_hal_mmc.h"
|
||||||
|
#endif /* HAL_MMC_MODULE_ENABLED */
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
/**
|
||||||
|
* @brief The assert_param macro is used for function's parameters check.
|
||||||
|
* @param expr If expr is false, it calls assert_failed function
|
||||||
|
* which reports the name of the source file and the source
|
||||||
|
* line number of the call that failed.
|
||||||
|
* If expr is true, it returns no value.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
void assert_failed(uint8_t* file, uint32_t line);
|
||||||
|
#else
|
||||||
|
#define assert_param(expr) ((void)0U)
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STM32F1xx_HAL_CONF_H */
|
||||||
|
|
||||||
74
Core/Inc/stm32f1xx_it.h
Normal file
74
Core/Inc/stm32f1xx_it.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f1xx_it.h
|
||||||
|
* @brief This file contains the headers of the interrupt handlers.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F1xx_IT_H
|
||||||
|
#define __STM32F1xx_IT_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 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 NMI_Handler(void);
|
||||||
|
void HardFault_Handler(void);
|
||||||
|
void MemManage_Handler(void);
|
||||||
|
void BusFault_Handler(void);
|
||||||
|
void UsageFault_Handler(void);
|
||||||
|
void SVC_Handler(void);
|
||||||
|
void DebugMon_Handler(void);
|
||||||
|
void PendSV_Handler(void);
|
||||||
|
void SysTick_Handler(void);
|
||||||
|
void CAN1_RX0_IRQHandler(void);
|
||||||
|
void TIM3_IRQHandler(void);
|
||||||
|
void USART1_IRQHandler(void);
|
||||||
|
void USART2_IRQHandler(void);
|
||||||
|
void USART3_IRQHandler(void);
|
||||||
|
void UART5_IRQHandler(void);
|
||||||
|
void CAN2_TX_IRQHandler(void);
|
||||||
|
void CAN2_RX1_IRQHandler(void);
|
||||||
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STM32F1xx_IT_H */
|
||||||
57
Core/Inc/tim.h
Normal file
57
Core/Inc/tim.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the tim.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __TIM_H__
|
||||||
|
#define __TIM_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim3;
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim4;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_TIM3_Init(void);
|
||||||
|
void MX_TIM4_Init(void);
|
||||||
|
|
||||||
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TIM_H__ */
|
||||||
|
|
||||||
61
Core/Inc/usart.h
Normal file
61
Core/Inc/usart.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usart.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the usart.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __USART_H__
|
||||||
|
#define __USART_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart5;
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart1;
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart2;
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart3;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_UART5_Init(void);
|
||||||
|
void MX_USART1_UART_Init(void);
|
||||||
|
void MX_USART2_UART_Init(void);
|
||||||
|
void MX_USART3_UART_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __USART_H__ */
|
||||||
|
|
||||||
BIN
Core/Src/.DS_Store
vendored
Executable file
BIN
Core/Src/.DS_Store
vendored
Executable file
Binary file not shown.
135
Core/Src/adc.c
Normal file
135
Core/Src/adc.c
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file adc.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the ADC instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "adc.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
/* ADC1 init function */
|
||||||
|
void MX_ADC1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 0 */
|
||||||
|
|
||||||
|
ADC_ChannelConfTypeDef sConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 1 */
|
||||||
|
|
||||||
|
/** Common config
|
||||||
|
*/
|
||||||
|
hadc1.Instance = ADC1;
|
||||||
|
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
|
||||||
|
hadc1.Init.ContinuousConvMode = DISABLE;
|
||||||
|
hadc1.Init.DiscontinuousConvMode = DISABLE;
|
||||||
|
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||||
|
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||||
|
hadc1.Init.NbrOfConversion = 1;
|
||||||
|
if (HAL_ADC_Init(&hadc1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure Regular Channel
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_8;
|
||||||
|
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||||
|
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN ADC1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(adcHandle->Instance==ADC1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN ADC1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspInit 0 */
|
||||||
|
/* ADC1 clock enable */
|
||||||
|
__HAL_RCC_ADC1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**ADC1 GPIO Configuration
|
||||||
|
PA3 ------> ADC1_IN3
|
||||||
|
PA4 ------> ADC1_IN4
|
||||||
|
PB0 ------> ADC1_IN8
|
||||||
|
PB1 ------> ADC1_IN9
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_3|CP_ADC_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = ADC_NTC1_Pin|ADC_NTC2_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(adcHandle->Instance==ADC1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN ADC1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_ADC1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**ADC1 GPIO Configuration
|
||||||
|
PA3 ------> ADC1_IN3
|
||||||
|
PA4 ------> ADC1_IN4
|
||||||
|
PB0 ------> ADC1_IN8
|
||||||
|
PB1 ------> ADC1_IN9
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_3|CP_ADC_Pin);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOB, ADC_NTC1_Pin|ADC_NTC2_Pin);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
213
Core/Src/board.c
Executable file
213
Core/Src/board.c
Executable file
@@ -0,0 +1,213 @@
|
|||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "tim.h"
|
||||||
|
#include "sma_filter.h"
|
||||||
|
|
||||||
|
extern ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
//TEMP READ
|
||||||
|
// Connector temperature sensors
|
||||||
|
|
||||||
|
InfoBlock_t *InfoBlock = (InfoBlock_t *)(VERSION_OFFSET);
|
||||||
|
|
||||||
|
uint8_t RELAY_State[RELAY_COUNT];
|
||||||
|
static volatile uint8_t adc_lock = 0;
|
||||||
|
static SMAFilter_t conn_temp_adc_filter[2];
|
||||||
|
|
||||||
|
void RELAY_Write(relay_t num, uint8_t state){
|
||||||
|
switch (num) {
|
||||||
|
case RELAY_AUX0:
|
||||||
|
HAL_GPIO_WritePin(RELAY1_GPIO_Port, RELAY1_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY_AUX1:
|
||||||
|
HAL_GPIO_WritePin(RELAY2_GPIO_Port, RELAY2_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY3:
|
||||||
|
HAL_GPIO_WritePin(RELAY3_GPIO_Port, RELAY3_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY_DC:
|
||||||
|
HAL_GPIO_WritePin(RELAY4_GPIO_Port, RELAY4_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY_AC:
|
||||||
|
HAL_GPIO_WritePin(RELAY5_GPIO_Port, RELAY5_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY_CP:
|
||||||
|
HAL_GPIO_WritePin(RELAY_CP_GPIO_Port, RELAY_CP_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY_CC:
|
||||||
|
HAL_GPIO_WritePin(RELAY_CC_GPIO_Port, RELAY_CC_Pin, state);
|
||||||
|
break;
|
||||||
|
case RELAY_DC1:
|
||||||
|
HAL_GPIO_WritePin(RELAY_DC_GPIO_Port, RELAY_DC_Pin, state);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RELAY_State[num] = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RELAY_Read(relay_t num){
|
||||||
|
return RELAY_State[num];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t IN_ReadInput(inputNum_t input_n){
|
||||||
|
switch(input_n){
|
||||||
|
case IN_SW0:
|
||||||
|
return HAL_GPIO_ReadPin(IN_SW0_GPIO_Port, IN_SW0_Pin);
|
||||||
|
case IN_SW1:
|
||||||
|
return HAL_GPIO_ReadPin(IN_SW1_GPIO_Port, IN_SW1_Pin);
|
||||||
|
case IN0:
|
||||||
|
return HAL_GPIO_ReadPin(IN0_GPIO_Port, IN0_Pin);
|
||||||
|
case IN_ESTOP:
|
||||||
|
return HAL_GPIO_ReadPin(IN_ESTOP_GPIO_Port, IN_ESTOP_Pin);
|
||||||
|
case IN_FB1:
|
||||||
|
return HAL_GPIO_ReadPin(IN_FB1_GPIO_Port, IN_FB1_Pin);
|
||||||
|
case IN_CONT_FB_DC:
|
||||||
|
return HAL_GPIO_ReadPin(IN_FB2_GPIO_Port, IN_FB2_Pin);
|
||||||
|
case ISO_IN:
|
||||||
|
return HAL_GPIO_ReadPin(ISO_IN_GPIO_Port, ISO_IN_Pin);
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GetBoardTemp(){
|
||||||
|
//TODO
|
||||||
|
// HAL_ADC_Start(&hadc1); // start the adc
|
||||||
|
//
|
||||||
|
// HAL_ADC_PollForConversion(&hadc1, 100); // poll for conversion
|
||||||
|
//
|
||||||
|
// adc_val = HAL_ADC_GetValue(&hadc1); // get the adc value
|
||||||
|
//
|
||||||
|
// HAL_ADC_Stop(&hadc1); // stop adc
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_Peripheral(){
|
||||||
|
HAL_ADCEx_Calibration_Start(&hadc1);
|
||||||
|
|
||||||
|
RELAY_Write(RELAY_AUX0, 0);
|
||||||
|
RELAY_Write(RELAY_AUX1, 0);
|
||||||
|
RELAY_Write(RELAY3, 0);
|
||||||
|
RELAY_Write(RELAY_DC, 0);
|
||||||
|
RELAY_Write(RELAY_AC, 0);
|
||||||
|
RELAY_Write(RELAY_CP, 1);
|
||||||
|
RELAY_Write(RELAY_CC, 1);
|
||||||
|
RELAY_Write(RELAY_DC1, 0);
|
||||||
|
|
||||||
|
SMAFilter_Init(&conn_temp_adc_filter[0]);
|
||||||
|
SMAFilter_Init(&conn_temp_adc_filter[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
float pt1000_to_temperature(float resistance) {
|
||||||
|
// Константы для PT1000
|
||||||
|
const float R0 = 1000.0; // Сопротивление при 0 °C
|
||||||
|
const float C_A = 3.9083E-3f;
|
||||||
|
|
||||||
|
float temperature = (resistance-R0) / ( R0 * C_A);
|
||||||
|
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float calculate_NTC_resistance(int adc_value, float Vref, float Vin, float R) {
|
||||||
|
// Преобразуем значение АЦП в выходное напряжение
|
||||||
|
float Vout = (adc_value / 4095.0) * Vref;
|
||||||
|
|
||||||
|
// Проверяем, чтобы Vout не было равно Vin
|
||||||
|
if (Vout >= Vin) {
|
||||||
|
return -1; // Ошибка: Vout не может быть больше или равно Vin
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вычисляем сопротивление термистора
|
||||||
|
float R_NTC = R * (Vout / (Vin - Vout));
|
||||||
|
|
||||||
|
return R_NTC;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t CONN_ReadTemp(uint8_t ch){
|
||||||
|
ADC_LockBlocking();
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
if(ch)ADC_Select_Channel(ADC_CHANNEL_8);
|
||||||
|
else ADC_Select_Channel(ADC_CHANNEL_9);
|
||||||
|
// Начало конверсии
|
||||||
|
HAL_ADC_Start(&hadc1);
|
||||||
|
|
||||||
|
|
||||||
|
// Ожидание окончания конверсии
|
||||||
|
HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
|
||||||
|
|
||||||
|
// Получение значения
|
||||||
|
uint32_t adcValue = HAL_ADC_GetValue(&hadc1);
|
||||||
|
|
||||||
|
// Остановка АЦП (по желанию)
|
||||||
|
HAL_ADC_Stop(&hadc1);
|
||||||
|
|
||||||
|
int32_t adc_filtered = SMAFilter_Update(&conn_temp_adc_filter[ch ? 1u : 0u], (int32_t)adcValue);
|
||||||
|
if((uint32_t)adc_filtered > 4000u) {
|
||||||
|
ADC_Unlock();
|
||||||
|
return 20; //Термодатчик не подключен
|
||||||
|
}
|
||||||
|
|
||||||
|
// int adc_value = 2048; // Пример значения АЦП
|
||||||
|
float Vref = 3.3; // Напряжение опорное
|
||||||
|
float Vin = 5.0; // Входное напряжение
|
||||||
|
float R = 1000; // Сопротивление резистора в Омах
|
||||||
|
|
||||||
|
float temp = pt1000_to_temperature(calculate_NTC_resistance((int)adc_filtered, Vref, Vin, R));
|
||||||
|
|
||||||
|
ADC_Unlock();
|
||||||
|
return (int16_t)temp;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t GBT_ReadTemp(uint8_t ch){
|
||||||
|
return CONN_ReadTemp(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ADC_Select_Channel(uint32_t ch) {
|
||||||
|
ADC_ChannelConfTypeDef conf = {
|
||||||
|
.Channel = ch,
|
||||||
|
.Rank = 1,
|
||||||
|
.SamplingTime = ADC_SAMPLETIME_28CYCLES_5,
|
||||||
|
};
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &conf) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ADC_TryLock(void) {
|
||||||
|
uint32_t primask = __get_PRIMASK();
|
||||||
|
__disable_irq();
|
||||||
|
if (adc_lock != 0u) {
|
||||||
|
if (primask == 0u) {
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
adc_lock = 1u;
|
||||||
|
if (primask == 0u) {
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
return 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ADC_LockBlocking(void) {
|
||||||
|
while (ADC_TryLock() == 0u) {
|
||||||
|
/* wait in main context until ADC is free */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ADC_Unlock(void) {
|
||||||
|
uint32_t primask = __get_PRIMASK();
|
||||||
|
__disable_irq();
|
||||||
|
adc_lock = 0u;
|
||||||
|
if (primask == 0u) {
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
}
|
||||||
231
Core/Src/can.c
Normal file
231
Core/Src/can.c
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file can.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the CAN instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "can.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
CAN_HandleTypeDef hcan1;
|
||||||
|
CAN_HandleTypeDef hcan2;
|
||||||
|
|
||||||
|
/* CAN1 init function */
|
||||||
|
void MX_CAN1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CAN1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CAN1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_Init 1 */
|
||||||
|
hcan1.Instance = CAN1;
|
||||||
|
hcan1.Init.Prescaler = 8;
|
||||||
|
hcan1.Init.Mode = CAN_MODE_NORMAL;
|
||||||
|
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||||
|
hcan1.Init.TimeSeg1 = CAN_BS1_15TQ;
|
||||||
|
hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
|
||||||
|
hcan1.Init.TimeTriggeredMode = DISABLE;
|
||||||
|
hcan1.Init.AutoBusOff = ENABLE;
|
||||||
|
hcan1.Init.AutoWakeUp = ENABLE;
|
||||||
|
hcan1.Init.AutoRetransmission = ENABLE;
|
||||||
|
hcan1.Init.ReceiveFifoLocked = DISABLE;
|
||||||
|
hcan1.Init.TransmitFifoPriority = ENABLE;
|
||||||
|
if (HAL_CAN_Init(&hcan1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN CAN1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
/* CAN2 init function */
|
||||||
|
void MX_CAN2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CAN2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CAN2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_Init 1 */
|
||||||
|
hcan2.Instance = CAN2;
|
||||||
|
hcan2.Init.Prescaler = 16;
|
||||||
|
hcan2.Init.Mode = CAN_MODE_NORMAL;
|
||||||
|
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||||
|
hcan2.Init.TimeSeg1 = CAN_BS1_15TQ;
|
||||||
|
hcan2.Init.TimeSeg2 = CAN_BS2_2TQ;
|
||||||
|
hcan2.Init.TimeTriggeredMode = DISABLE;
|
||||||
|
hcan2.Init.AutoBusOff = ENABLE;
|
||||||
|
hcan2.Init.AutoWakeUp = ENABLE;
|
||||||
|
hcan2.Init.AutoRetransmission = ENABLE;
|
||||||
|
hcan2.Init.ReceiveFifoLocked = DISABLE;
|
||||||
|
hcan2.Init.TransmitFifoPriority = ENABLE;
|
||||||
|
if (HAL_CAN_Init(&hcan2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN CAN2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0;
|
||||||
|
|
||||||
|
void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(canHandle->Instance==CAN1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspInit 0 */
|
||||||
|
/* CAN1 clock enable */
|
||||||
|
HAL_RCC_CAN1_CLK_ENABLED++;
|
||||||
|
if(HAL_RCC_CAN1_CLK_ENABLED==1){
|
||||||
|
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
/**CAN1 GPIO Configuration
|
||||||
|
PD0 ------> CAN1_RX
|
||||||
|
PD1 ------> CAN1_TX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_1;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
__HAL_AFIO_REMAP_CAN1_3();
|
||||||
|
|
||||||
|
/* CAN1 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||||
|
/* USER CODE BEGIN CAN1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspInit 1 */
|
||||||
|
}
|
||||||
|
else if(canHandle->Instance==CAN2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN2_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_MspInit 0 */
|
||||||
|
/* CAN2 clock enable */
|
||||||
|
__HAL_RCC_CAN2_CLK_ENABLE();
|
||||||
|
HAL_RCC_CAN1_CLK_ENABLED++;
|
||||||
|
if(HAL_RCC_CAN1_CLK_ENABLED==1){
|
||||||
|
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**CAN2 GPIO Configuration
|
||||||
|
PB5 ------> CAN2_RX
|
||||||
|
PB6 ------> CAN2_TX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_5;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
__HAL_AFIO_REMAP_CAN2_ENABLE();
|
||||||
|
|
||||||
|
/* CAN2 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(CAN2_TX_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN2_TX_IRQn);
|
||||||
|
HAL_NVIC_SetPriority(CAN2_RX1_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN2_RX1_IRQn);
|
||||||
|
/* USER CODE BEGIN CAN2_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(canHandle->Instance==CAN1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
HAL_RCC_CAN1_CLK_ENABLED--;
|
||||||
|
if(HAL_RCC_CAN1_CLK_ENABLED==0){
|
||||||
|
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**CAN1 GPIO Configuration
|
||||||
|
PD0 ------> CAN1_RX
|
||||||
|
PD1 ------> CAN1_TX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1);
|
||||||
|
|
||||||
|
/* CAN1 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn);
|
||||||
|
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
else if(canHandle->Instance==CAN2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN2_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_CAN2_CLK_DISABLE();
|
||||||
|
HAL_RCC_CAN1_CLK_ENABLED--;
|
||||||
|
if(HAL_RCC_CAN1_CLK_ENABLED==0){
|
||||||
|
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**CAN2 GPIO Configuration
|
||||||
|
PB5 ------> CAN2_RX
|
||||||
|
PB6 ------> CAN2_TX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6);
|
||||||
|
|
||||||
|
/* CAN2 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(CAN2_TX_IRQn);
|
||||||
|
HAL_NVIC_DisableIRQ(CAN2_RX1_IRQn);
|
||||||
|
/* USER CODE BEGIN CAN2_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
88
Core/Src/charger_control.c
Normal file
88
Core/Src/charger_control.c
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
|
||||||
|
#include "charger_control.h"
|
||||||
|
#include "charger_config.h"
|
||||||
|
#include "psu_control.h"
|
||||||
|
#include "connector.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
ChargingConnector_t CONN;
|
||||||
|
CONN_State_t connectorState;
|
||||||
|
|
||||||
|
void CONN_Init(){
|
||||||
|
|
||||||
|
CONN.connControl = CMD_NONE;
|
||||||
|
CONN.connState = Unknown;
|
||||||
|
CONN.RequestedVoltage = PSU_MIN_VOLTAGE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CONN_Loop(){
|
||||||
|
static CONN_State_t last_connState = Unknown;
|
||||||
|
if(last_connState != CONN.connState){
|
||||||
|
last_connState = CONN.connState;
|
||||||
|
CONN.connControl = CMD_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(PSU0.cont_fault){
|
||||||
|
CONN.chargingError = CONN_ERR_CONTACTOR;
|
||||||
|
} else if(PSU0.psu_fault){
|
||||||
|
CONN.chargingError = CONN_ERR_PSU_FAULT;
|
||||||
|
// } else if(!CTRL.ac_ok) {
|
||||||
|
// CONN.chargingError = CONN_ERR_AC_FAULT;
|
||||||
|
// } else
|
||||||
|
}else if (CONN.EvConnected == 0){
|
||||||
|
CONN.chargingError = CONN_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ED_TraceWarning(CONN.chargingError, 0)) printf("CONN%d Error: %d\n", 0, CONN.chargingError);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CONN_Task(){
|
||||||
|
/* CCS state machine is handled in serial.c.
|
||||||
|
* Keep this task lightweight for scheduler compatibility.
|
||||||
|
*/
|
||||||
|
if (CONN.chargingError != CONN_NO_ERROR) {
|
||||||
|
CONN_SetState(Disabled);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connectorState == Unknown) {
|
||||||
|
CONN_SetState(Unplugged);
|
||||||
|
} else if (connectorState == Disabled && CONN.chargingError == CONN_NO_ERROR) {
|
||||||
|
CONN_SetState(Unplugged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CONN_SetState(CONN_State_t state){
|
||||||
|
if (connectorState == state) {
|
||||||
|
CONN.connState = state;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connectorState = state;
|
||||||
|
|
||||||
|
if(connectorState == Unknown) log_printf(LOG_INFO, "Connector: Unknown\n");
|
||||||
|
if(connectorState == Unplugged) log_printf(LOG_INFO, "Connector: Unplugged\n");
|
||||||
|
if(connectorState == Disabled) log_printf(LOG_INFO, "Connector: Disabled\n");
|
||||||
|
if(connectorState == Preparing) log_printf(LOG_INFO, "Connector: Preparing\n");
|
||||||
|
if(connectorState == AuthRequired) log_printf(LOG_INFO, "Connector: AuthRequired\n");
|
||||||
|
if(connectorState == WaitingForEnergy) log_printf(LOG_INFO, "Connector: WaitingForEnergy\n");
|
||||||
|
if(connectorState == ChargingPausedEV) log_printf(LOG_INFO, "Connector: ChargingPausedEV\n");
|
||||||
|
if(connectorState == ChargingPausedEVSE) log_printf(LOG_INFO, "Connector: ChargingPausedEVSE\n");
|
||||||
|
if(connectorState == Charging) log_printf(LOG_INFO, "Connector: Charging\n");
|
||||||
|
if(connectorState == AuthTimeout) log_printf(LOG_INFO, "Connector: AuthTimeout\n");
|
||||||
|
if(connectorState == Finished) log_printf(LOG_INFO, "Connector: Finished\n");
|
||||||
|
if(connectorState == FinishedEVSE) log_printf(LOG_INFO, "Connector: FinishedEVSE\n");
|
||||||
|
if(connectorState == FinishedEV) log_printf(LOG_INFO, "Connector: FinishedEV\n");
|
||||||
|
if(connectorState == Replugging) log_printf(LOG_INFO, "Connector: Replugging\n");
|
||||||
|
|
||||||
|
CONN.connState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CONN_PrintChargingTotal(){
|
||||||
|
printf("CONN%d Charging Finished:\n", 0);
|
||||||
|
// printf("Charging Time: %d\n", CONN.chargingTime);
|
||||||
|
printf("Charging Energy: %d\n", CONN.Energy);
|
||||||
|
// printf("Charging Power: %d\n", CONN.chargingPower);
|
||||||
|
}
|
||||||
115
Core/Src/cp.c
Normal file
115
Core/Src/cp.c
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
#include "cp.h"
|
||||||
|
#include "adc.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "tim.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define MAX_DUTY 450
|
||||||
|
|
||||||
|
static int32_t cp_voltage_mv = 0;
|
||||||
|
static uint8_t cp_duty = 0;
|
||||||
|
CP_State_t fake_cp_state = EV_STATE_ACQUIRING;
|
||||||
|
|
||||||
|
static uint32_t CP_ReadAdcChannel(uint32_t ch) {
|
||||||
|
uint32_t adc = 0;
|
||||||
|
|
||||||
|
ADC_Select_Channel(ch);
|
||||||
|
HAL_ADC_Start(&hadc1);
|
||||||
|
HAL_ADC_PollForConversion(&hadc1, 10);
|
||||||
|
adc = HAL_ADC_GetValue(&hadc1);
|
||||||
|
HAL_ADC_Stop(&hadc1);
|
||||||
|
|
||||||
|
return adc;
|
||||||
|
}
|
||||||
|
#define VREFINT_CAL_ADDR ((uint16_t*)0x1FFFF7BA) // для STM32F1!
|
||||||
|
|
||||||
|
static int32_t CP_ReadVoltageMv(void)
|
||||||
|
{
|
||||||
|
uint32_t adc = 0;
|
||||||
|
int32_t v_adc_mv = 0;
|
||||||
|
int32_t v_out_mv = 0;
|
||||||
|
|
||||||
|
adc = CP_ReadAdcChannel((uint32_t)4u);
|
||||||
|
v_adc_mv = (int32_t)((adc * 3300u) / 4095u);
|
||||||
|
v_out_mv = ((v_adc_mv - 1723) * 1000) / 130;
|
||||||
|
|
||||||
|
return v_out_mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CP_Init(void) {
|
||||||
|
/* TIM3_CH2 (PA7): set 1kHz PWM like original CCS logic. */
|
||||||
|
htim3.Instance->PSC = 160 - 1;
|
||||||
|
htim3.Instance->ARR = MAX_DUTY - 1;
|
||||||
|
|
||||||
|
#if DUTY_INVERT == 0
|
||||||
|
htim3.Instance->CCR2 = MAX_DUTY;
|
||||||
|
htim3.Instance->CCR1 = MAX_DUTY + 5;
|
||||||
|
#else
|
||||||
|
htim3.Instance->CCR2 = 0;
|
||||||
|
htim3.Instance->CCR1 = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
|
||||||
|
HAL_TIM_OC_Start_IT(&htim3, TIM_CHANNEL_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CP_SetDuty(uint8_t percentage) {
|
||||||
|
uint32_t pwmduty = MAX_DUTY * percentage / 100;
|
||||||
|
cp_duty = percentage;
|
||||||
|
|
||||||
|
#if DUTY_INVERT == 0
|
||||||
|
htim3.Instance->CCR2 = pwmduty;
|
||||||
|
htim3.Instance->CCR1 = 0 + 1;
|
||||||
|
#else
|
||||||
|
htim3.Instance->CCR2 = MAX_DUTY - pwmduty;
|
||||||
|
htim3.Instance->CCR1 = MAX_DUTY - pwmduty + 5;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CP_GetDuty(void) {
|
||||||
|
return cp_duty;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CP_GetVoltage(void) {
|
||||||
|
return cp_voltage_mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
CP_State_t CP_GetState(void) {
|
||||||
|
int32_t voltage_real = cp_voltage_mv;
|
||||||
|
|
||||||
|
if(fake_cp_state != EV_STATE_ACQUIRING) {
|
||||||
|
return fake_cp_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (voltage_real >= (12000-1000)) {
|
||||||
|
return EV_STATE_A_IDLE;
|
||||||
|
} else if (voltage_real >= (9000-1000) && voltage_real <= (9000+1000)) {
|
||||||
|
return EV_STATE_B_CONN_PREP;
|
||||||
|
} else if (voltage_real >= (6000-1000) && voltage_real <= (6000+1000)) {
|
||||||
|
return EV_STATE_C_CONN_ACTIVE;
|
||||||
|
} else if (voltage_real >= (3000-1000) && voltage_real <= (3000 + 1000)) {
|
||||||
|
return EV_STATE_D_CONN_ACT_VENT;
|
||||||
|
} else if (voltage_real >= (0-1000) && voltage_real <= (0+2000)){
|
||||||
|
return EV_STATE_E_NO_POWER;
|
||||||
|
} else if (voltage_real <= (-12000+1000)) {
|
||||||
|
return EV_STATE_F_ERROR;
|
||||||
|
} else {
|
||||||
|
return EV_STATE_ACQUIRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CP_Loop(void) {
|
||||||
|
(void)CP_GetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
|
||||||
|
{
|
||||||
|
if (htim->Instance == TIM3 && htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
|
||||||
|
if (ADC_TryLock() == 0u) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cp_voltage_mv = CP_ReadVoltageMv();
|
||||||
|
ADC_Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
85
Core/Src/crc.c
Normal file
85
Core/Src/crc.c
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file crc.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the CRC instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "crc.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
CRC_HandleTypeDef hcrc;
|
||||||
|
|
||||||
|
/* CRC init function */
|
||||||
|
void MX_CRC_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CRC_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN CRC_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_Init 1 */
|
||||||
|
hcrc.Instance = CRC;
|
||||||
|
if (HAL_CRC_Init(&hcrc) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN CRC_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CRC_MspInit(CRC_HandleTypeDef* crcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(crcHandle->Instance==CRC)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CRC_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspInit 0 */
|
||||||
|
/* CRC clock enable */
|
||||||
|
__HAL_RCC_CRC_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN CRC_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CRC_MspDeInit(CRC_HandleTypeDef* crcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(crcHandle->Instance==CRC)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CRC_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_CRC_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN CRC_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
365
Core/Src/debug.c
Executable file
365
Core/Src/debug.c
Executable file
@@ -0,0 +1,365 @@
|
|||||||
|
/*
|
||||||
|
* debug.c
|
||||||
|
*
|
||||||
|
* Created on: Apr 16, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "debug.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include <time.h>
|
||||||
|
#include <connector.h>
|
||||||
|
#include "serial_control.h"
|
||||||
|
|
||||||
|
// Кольцевой буфер для отладочных сообщений
|
||||||
|
#define DEBUG_BUFFER_SIZE 1024
|
||||||
|
#define DEBUG_BUFFER_MAX_COUNT 128
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t buffer[DEBUG_BUFFER_SIZE];
|
||||||
|
volatile uint16_t write_index;
|
||||||
|
volatile uint16_t read_index;
|
||||||
|
volatile uint16_t count;
|
||||||
|
} DebugBuffer_t;
|
||||||
|
|
||||||
|
static DebugBuffer_t debug_buffer = {
|
||||||
|
.buffer = {0},
|
||||||
|
.write_index = 0,
|
||||||
|
.read_index = 0,
|
||||||
|
.count = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
int _write(int fd, char * ptr, int len)
|
||||||
|
{
|
||||||
|
debug_buffer_add((const uint8_t*)ptr, len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Добавляет данные в кольцевой буфер
|
||||||
|
void debug_buffer_add(const uint8_t* data, uint16_t len)
|
||||||
|
{
|
||||||
|
__disable_irq();
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < len; i++) {
|
||||||
|
// Если буфер полон, перезаписываем старые данные
|
||||||
|
if (debug_buffer.count >= DEBUG_BUFFER_SIZE) {
|
||||||
|
debug_buffer.read_index = (debug_buffer.read_index + 1) % DEBUG_BUFFER_SIZE;
|
||||||
|
debug_buffer.count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_buffer.buffer[debug_buffer.write_index] = data[i];
|
||||||
|
debug_buffer.write_index = (debug_buffer.write_index + 1) % DEBUG_BUFFER_SIZE;
|
||||||
|
debug_buffer.count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Возвращает количество доступных данных в буфере
|
||||||
|
uint16_t debug_buffer_available(void)
|
||||||
|
{
|
||||||
|
__disable_irq();
|
||||||
|
uint16_t count = debug_buffer.count;
|
||||||
|
__enable_irq();
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Отправляет один пакет данных из буфера через SC_SendPacket (не более 250 байт)
|
||||||
|
void debug_buffer_send(void)
|
||||||
|
{
|
||||||
|
__disable_irq();
|
||||||
|
|
||||||
|
// Если буфер пуст, ничего не делаем
|
||||||
|
if (debug_buffer.count == 0) {
|
||||||
|
__enable_irq();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Определяем сколько байт можно отправить (не более 250)
|
||||||
|
uint16_t bytes_to_send = debug_buffer.count;
|
||||||
|
if (bytes_to_send > DEBUG_BUFFER_MAX_COUNT) {
|
||||||
|
bytes_to_send = DEBUG_BUFFER_MAX_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вычисляем сколько байт до конца буфера
|
||||||
|
uint16_t bytes_to_end = DEBUG_BUFFER_SIZE - debug_buffer.read_index;
|
||||||
|
|
||||||
|
// Отправляем только непрерывный блок (до конца буфера или до bytes_to_send)
|
||||||
|
if (bytes_to_send > bytes_to_end) {
|
||||||
|
bytes_to_send = bytes_to_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Отправляем данные напрямую из буфера
|
||||||
|
if(bytes_to_send == debug_buffer.count){
|
||||||
|
SC_SendPacket(&debug_buffer.buffer[debug_buffer.read_index], bytes_to_send, CMD_GET_LOG);
|
||||||
|
}else{
|
||||||
|
SC_SendPacket(&debug_buffer.buffer[debug_buffer.read_index], bytes_to_send, CMD_GET_LOG_CONTINUE);
|
||||||
|
}
|
||||||
|
debug_buffer.read_index = (debug_buffer.read_index + bytes_to_send) % DEBUG_BUFFER_SIZE;
|
||||||
|
debug_buffer.count -= bytes_to_send;
|
||||||
|
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LOG_BUFFER_SIZE 128
|
||||||
|
uint8_t log_buffer[LOG_BUFFER_SIZE];
|
||||||
|
|
||||||
|
// Кастомный printf с приоритетом лога
|
||||||
|
int log_printf(LogLevel_t level, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
// Добавляем приоритет первым байтом
|
||||||
|
log_buffer[0] = (uint8_t)level;
|
||||||
|
|
||||||
|
// Форматируем строку начиная со второго байта
|
||||||
|
va_start(args, format);
|
||||||
|
result = vsnprintf((char*)&log_buffer[1], LOG_BUFFER_SIZE - 2, format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
// Проверяем, не переполнился ли буфер
|
||||||
|
if (result < 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ограничиваем размер, чтобы оставить место для нуль-терминатора
|
||||||
|
if (result >= (LOG_BUFFER_SIZE - 2)) {
|
||||||
|
result = LOG_BUFFER_SIZE - 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Добавляем нуль-терминатор в конец
|
||||||
|
log_buffer[result + 1] = '\0';
|
||||||
|
|
||||||
|
// Отправляем в буфер (приоритет + строка + нуль-терминатор)
|
||||||
|
debug_buffer_add(log_buffer, result + 2);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef USE_WEB_INTERFACE
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart2;
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t debug_rx_buffer[256];
|
||||||
|
uint8_t debug_cmd_received;
|
||||||
|
uint8_t debug_rx_buffer_size = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){
|
||||||
|
|
||||||
|
// if(huart->Instance == USART1){
|
||||||
|
// mm_rx_interrupt(huart, Size);
|
||||||
|
// }
|
||||||
|
if(huart->Instance == USART2){
|
||||||
|
debug_rx_interrupt(huart, Size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void debug_rx_interrupt(UART_HandleTypeDef *huart, uint16_t Size){
|
||||||
|
debug_rx_buffer[Size] = '\0';
|
||||||
|
debug_rx_buffer_size = Size;
|
||||||
|
debug_cmd_received = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void debug_init(){
|
||||||
|
HAL_UARTEx_ReceiveToIdle_IT(&huart2,debug_rx_buffer,255);
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_command(uint8_t* buffer, size_t length) {
|
||||||
|
// ignore \r \n symbols
|
||||||
|
size_t i = 0;
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
if (buffer[i] == '\r' || buffer[i] == '\n') {
|
||||||
|
buffer[i] = '\0';
|
||||||
|
length = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buffer[0] == 0) return;
|
||||||
|
if (strncmp((const char*)buffer, "reset", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Resetting...\n");
|
||||||
|
NVIC_SystemReset();
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "relayaux", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Relaying...\n");
|
||||||
|
RELAY_Write(RELAY_AUX, 1);
|
||||||
|
HAL_Delay(2000);
|
||||||
|
RELAY_Write(RELAY_AUX, 0);
|
||||||
|
} else if (strncmp((const char*)buffer, "relaycc", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Relaying...\n");
|
||||||
|
RELAY_Write(RELAY_CC, 1);
|
||||||
|
HAL_Delay(200);
|
||||||
|
RELAY_Write(RELAY_CC, 0);
|
||||||
|
} else if (strncmp((const char*)buffer, "relaydc", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Relaying...\n");
|
||||||
|
RELAY_Write(RELAY_DC, 1);
|
||||||
|
HAL_Delay(200);
|
||||||
|
RELAY_Write(RELAY_DC, 0);
|
||||||
|
} else if (strncmp((const char*)buffer, "relayac", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Relaying...\n");
|
||||||
|
RELAY_Write(RELAY_AC, 1);
|
||||||
|
HAL_Delay(200);
|
||||||
|
RELAY_Write(RELAY_AC, 0);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "adc", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "CC1=%.2f\n", CONN_CC_GetAdc());
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "lock_state", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Lock state=%d\n", GBT_LockGetState());
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "lock_lock", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Locked\n");
|
||||||
|
GBT_Lock(1);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "lock_unlock", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Unlocked\n");
|
||||||
|
GBT_Lock(0);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "complete", length) == 0) {
|
||||||
|
CONN_SetState(Finished);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "start", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Started\n");
|
||||||
|
GBT_Start();
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "stop", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Stopped\n");
|
||||||
|
GBT_StopEVSE(GBT_CST_SUSPENDS_ARTIFICIALLY);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "stop1", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Stopped\n");
|
||||||
|
GBT_ForceStop();
|
||||||
|
|
||||||
|
// } else if (strncmp((const char*)buffer, "force", length) == 0) {
|
||||||
|
// log_printf(LOG_INFO, "Stopped\n");
|
||||||
|
// GBT_Lock(1);
|
||||||
|
// GBT_SwitchState(GBT_S2_LOCKED);
|
||||||
|
// GBT_Delay(500);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "cc_state", length) == 0) {
|
||||||
|
switch(CONN_CC_GetState()){
|
||||||
|
case GBT_CC_UNKNOWN:
|
||||||
|
log_printf(LOG_INFO, "GBT_CC_UNKNOWN\n");
|
||||||
|
break;
|
||||||
|
case GBT_CC_12V:
|
||||||
|
log_printf(LOG_INFO, "GBT_CC_12V\n");
|
||||||
|
break;
|
||||||
|
case GBT_CC_6V:
|
||||||
|
log_printf(LOG_INFO, "GBT_CC_6V\n");
|
||||||
|
break;
|
||||||
|
case GBT_CC_4V:
|
||||||
|
log_printf(LOG_INFO, "GBT_CC_4V\n");
|
||||||
|
break;
|
||||||
|
case GBT_CC_2V:
|
||||||
|
log_printf(LOG_INFO, "GBT_CC_2V\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (strncmp((const char*)buffer, "temp", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "temp1 %d\n",GBT_ReadTemp(0));
|
||||||
|
log_printf(LOG_INFO, "temp2 %d\n",GBT_ReadTemp(1));
|
||||||
|
} else if (strncmp((const char*)buffer, "info1", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Battery info:\n");
|
||||||
|
log_printf(LOG_INFO, "maxCV %dV\n",GBT_BATStat.maxCellVoltage/100); // 0.01v/bit
|
||||||
|
log_printf(LOG_INFO, "maxCC %dA\n",GBT_BATStat.maxChargingCurrent/10); // 0.1A/bit
|
||||||
|
log_printf(LOG_INFO, "totE %dkWh\n",GBT_BATStat.totalEnergy/10); // 0.1kWh
|
||||||
|
log_printf(LOG_INFO, "maxCV %dV\n",GBT_BATStat.maxChargingVoltage/10); // 0.1V/ bit
|
||||||
|
log_printf(LOG_INFO, "maxT %dC\n",(int16_t)GBT_BATStat.maxTemp-50); // 1C/bit, -50C offset
|
||||||
|
log_printf(LOG_INFO, "SOC %dp\n",GBT_BATStat.SOC/10); // 0.1%/bit , 0..100%
|
||||||
|
log_printf(LOG_INFO, "Volt. %dV\n",GBT_BATStat.measVoltage/10); // 0.1V/bit
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "info2", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "EV info:\n");
|
||||||
|
log_printf(LOG_INFO, "GBT_ver V%d.%d%d\n",GBT_EVInfo.version[0],GBT_EVInfo.version[1],GBT_EVInfo.version[2]);
|
||||||
|
log_printf(LOG_INFO, "Battery type: %d\n",GBT_EVInfo.batteryType);
|
||||||
|
log_printf(LOG_INFO, "Battery capacity: %d\n", GBT_EVInfo.batteryCapacity); // 0.1Ah/bit
|
||||||
|
log_printf(LOG_INFO, "Battery voltage: %d\n", GBT_EVInfo.batteryVoltage); // 0.1V/bit
|
||||||
|
log_printf(LOG_INFO, "Battery vendor: %.4s\n", GBT_EVInfo.batteryVendor); // Battery vendor (ASCII string)
|
||||||
|
log_printf(LOG_INFO, "Battery SN: %lu\n", GBT_EVInfo.batterySN); // int
|
||||||
|
log_printf(LOG_INFO, "Battery manufacture date: %02d.%02d.%04d\n", GBT_EVInfo.batteryManuD, GBT_EVInfo.batteryManuM ,GBT_EVInfo.batteryManuY+1985); // year (offset 1985)
|
||||||
|
log_printf(LOG_INFO, "Battery cycles: %d\n", GBT_EVInfo.batteryCycleCount); //uint24_t
|
||||||
|
log_printf(LOG_INFO, "Own auto: %d\n", GBT_EVInfo.ownAuto); // 0 = lizing, 1 = own auto
|
||||||
|
log_printf(LOG_INFO, "EVIN: %.17s\n", GBT_EVInfo.EVIN); //EVIN
|
||||||
|
log_printf(LOG_INFO, "EV_SW_VER: %.8s\n", GBT_EVInfo.EV_SW_VER);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "info3", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "GBT_MaxLoad info:\n");
|
||||||
|
log_printf(LOG_INFO, "Output max current: %d\n",GBT_MaxLoad.maxOutputCurrent);
|
||||||
|
log_printf(LOG_INFO, "Output min current: %d\n",GBT_MaxLoad.minOutputCurrent);
|
||||||
|
log_printf(LOG_INFO, "Output max voltage: %d\n",GBT_MaxLoad.maxOutputVoltage);
|
||||||
|
log_printf(LOG_INFO, "Output min voltage: %d\n",GBT_MaxLoad.minOutputVoltage);
|
||||||
|
log_printf(LOG_INFO, "\nGBT_ChargerInfo info:\n");
|
||||||
|
log_printf(LOG_INFO, "BMS Recognized: %d\n",GBT_ChargerInfo.bmsIdentified);
|
||||||
|
log_printf(LOG_INFO, "Charger location: %.3s\n",GBT_ChargerInfo.chargerLocation);
|
||||||
|
log_printf(LOG_INFO, "Charger number: %lu\n",GBT_ChargerInfo.chargerNumber);
|
||||||
|
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "help", length) == 0) {
|
||||||
|
log_printf(LOG_INFO, "Command list:\n");
|
||||||
|
log_printf(LOG_INFO, "reset\n");
|
||||||
|
log_printf(LOG_INFO, "help\n");
|
||||||
|
log_printf(LOG_INFO, "cc_state\n");
|
||||||
|
log_printf(LOG_INFO, "lock_lock\n");
|
||||||
|
log_printf(LOG_INFO, "lock_unlock\n");
|
||||||
|
log_printf(LOG_INFO, "lock_state\n");
|
||||||
|
log_printf(LOG_INFO, "adc\n");
|
||||||
|
log_printf(LOG_INFO, "relay(cc,aux,ac,dc)\n");
|
||||||
|
log_printf(LOG_INFO, "start\n");
|
||||||
|
log_printf(LOG_INFO, "stop\n");
|
||||||
|
log_printf(LOG_INFO, "stop1\n");
|
||||||
|
// log_printf(LOG_INFO, "force\n");
|
||||||
|
log_printf(LOG_INFO, "temp\n");
|
||||||
|
log_printf(LOG_INFO, "info1\n");
|
||||||
|
log_printf(LOG_INFO, "info2\n");
|
||||||
|
log_printf(LOG_INFO, "info3\n");
|
||||||
|
log_printf(LOG_INFO, "time\n");
|
||||||
|
log_printf(LOG_INFO, "cantest\n");
|
||||||
|
|
||||||
|
//TODO: info commands
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "time", length) == 0) {
|
||||||
|
|
||||||
|
time_t unix_time = (time_t)get_Current_Time();
|
||||||
|
struct tm *parts = localtime(&unix_time);
|
||||||
|
|
||||||
|
log_printf(LOG_INFO, "Year: %d\n", parts->tm_year + 1900);
|
||||||
|
log_printf(LOG_INFO, "Month: %d\n", parts->tm_mon + 1);
|
||||||
|
log_printf(LOG_INFO, "Day: %d\n", parts->tm_mday);
|
||||||
|
log_printf(LOG_INFO, "Hour: %d\n", parts->tm_hour);
|
||||||
|
log_printf(LOG_INFO, "Minute: %d\n", parts->tm_min);
|
||||||
|
log_printf(LOG_INFO, "Second: %d\n", parts->tm_sec);
|
||||||
|
|
||||||
|
} else if (strncmp((const char*)buffer, "cantest", length) == 0) {
|
||||||
|
//GBT_SendCHM();
|
||||||
|
GBT_Error(0xFDF0C0FC); //BRM Timeout
|
||||||
|
log_printf(LOG_INFO, "can test\n");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log_printf(LOG_INFO, "Unknown command\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void debug_task(){
|
||||||
|
if(debug_cmd_received){
|
||||||
|
parse_command(debug_rx_buffer, debug_rx_buffer_size);
|
||||||
|
HAL_UARTEx_ReceiveToIdle_IT(&huart2,debug_rx_buffer,255);
|
||||||
|
debug_cmd_received = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif // USE_WEB_INTERFACE
|
||||||
152
Core/Src/gpio.c
Normal file
152
Core/Src/gpio.c
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file gpio.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of all used GPIO pins.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Configure GPIO */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/** Configure pins as
|
||||||
|
* Analog
|
||||||
|
* Input
|
||||||
|
* Output
|
||||||
|
* EVENT_OUT
|
||||||
|
* EXTI
|
||||||
|
PB8 ------> I2C1_SCL
|
||||||
|
PB9 ------> I2C1_SDA
|
||||||
|
*/
|
||||||
|
void MX_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
|
||||||
|
/* GPIO Ports Clock Enable */
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOC, RELAY_CP_Pin|LOCK_A_Pin|LOCK_B_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOE, RELAY1_Pin|RELAY2_Pin|RELAY3_Pin|RELAY4_Pin
|
||||||
|
|RELAY5_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(RELAY_CC_GPIO_Port, RELAY_CC_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOD, RELAY_DC_Pin|USART2_DIR_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(EE_WP_GPIO_Port, EE_WP_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : RELAY_CP_Pin LOCK_A_Pin LOCK_B_Pin */
|
||||||
|
GPIO_InitStruct.Pin = RELAY_CP_Pin|LOCK_A_Pin|LOCK_B_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : IN_SW0_Pin */
|
||||||
|
GPIO_InitStruct.Pin = IN_SW0_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(IN_SW0_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : IN_SW1_Pin */
|
||||||
|
GPIO_InitStruct.Pin = IN_SW1_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||||
|
HAL_GPIO_Init(IN_SW1_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : IN0_Pin AC_OK_Pin ISO_IN_Pin */
|
||||||
|
GPIO_InitStruct.Pin = IN0_Pin|AC_OK_Pin|ISO_IN_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : RELAY1_Pin RELAY2_Pin RELAY3_Pin RELAY4_Pin
|
||||||
|
RELAY5_Pin */
|
||||||
|
GPIO_InitStruct.Pin = RELAY1_Pin|RELAY2_Pin|RELAY3_Pin|RELAY4_Pin
|
||||||
|
|RELAY5_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : RELAY_CC_Pin */
|
||||||
|
GPIO_InitStruct.Pin = RELAY_CC_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(RELAY_CC_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : RELAY_DC_Pin USART2_DIR_Pin */
|
||||||
|
GPIO_InitStruct.Pin = RELAY_DC_Pin|USART2_DIR_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : IN_ESTOP_Pin */
|
||||||
|
GPIO_InitStruct.Pin = IN_ESTOP_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(IN_ESTOP_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : IN_FB2_Pin IN_FB1_Pin */
|
||||||
|
GPIO_InitStruct.Pin = IN_FB2_Pin|IN_FB1_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : EE_WP_Pin */
|
||||||
|
GPIO_InitStruct.Pin = EE_WP_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(EE_WP_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : PB8 PB9 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure peripheral I/O remapping */
|
||||||
|
__HAL_AFIO_REMAP_I2C1_ENABLE();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
/* USER CODE END 2 */
|
||||||
301
Core/Src/main.c
Normal file
301
Core/Src/main.c
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
#include "adc.h"
|
||||||
|
#include "can.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "rtc.h"
|
||||||
|
#include "tim.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include "can.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "debug.h"
|
||||||
|
#include "soft_rtc.h"
|
||||||
|
#include "connector.h"
|
||||||
|
#include "serial_control.h"
|
||||||
|
#include "charger_config.h"
|
||||||
|
#include "serial.h"
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PTD */
|
||||||
|
|
||||||
|
/* USER CODE END PTD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
|
/* USER CODE END PD */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PM */
|
||||||
|
|
||||||
|
/* USER CODE END PM */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
void SystemClock_Config(void);
|
||||||
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
/* Private user code ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Vector base address configuration. It should no longer be at the start of
|
||||||
|
* flash memory but moved forward because the first part of flash is
|
||||||
|
* reserved for the bootloader. Note that this is already done by the
|
||||||
|
* bootloader before starting this program. Unfortunately, function
|
||||||
|
* SystemInit() overwrites this change again.
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
static void VectorBase_Config(void)
|
||||||
|
{
|
||||||
|
/* The constant array with vectors of the vector table is declared externally in the
|
||||||
|
* c-startup code.
|
||||||
|
*/
|
||||||
|
extern const unsigned long g_pfnVectors[];
|
||||||
|
|
||||||
|
/* Remap the vector table to where the vector table is located for this program. */
|
||||||
|
SCB->VTOR = (unsigned long)&g_pfnVectors[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ED_TraceWarning(uint8_t flag, uint8_t id){
|
||||||
|
static uint8_t memory[32];
|
||||||
|
if(id > 31) return 0;
|
||||||
|
uint8_t result = 0;
|
||||||
|
if(memory[id] != flag){
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
memory[id] = flag;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ED_Delay(uint32_t Delay)
|
||||||
|
{
|
||||||
|
uint32_t tickstart = HAL_GetTick();
|
||||||
|
uint32_t wait = Delay;
|
||||||
|
|
||||||
|
if (wait < HAL_MAX_DELAY)
|
||||||
|
{
|
||||||
|
wait += (uint32_t)(uwTickFreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((HAL_GetTick() - tickstart) < wait){
|
||||||
|
CCS_SerialLoop();
|
||||||
|
// CP_Loop();
|
||||||
|
CONN_Task();
|
||||||
|
LED_Task();
|
||||||
|
SC_Task();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StopButtonControl(){
|
||||||
|
|
||||||
|
//Charging do nothing
|
||||||
|
if(!IN_ReadInput(IN_ESTOP)){
|
||||||
|
CONN.connControl = CMD_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t temp0, temp1;
|
||||||
|
|
||||||
|
static void CAN1_MinimalReInit(void)
|
||||||
|
{
|
||||||
|
HAL_CAN_Stop(&hcan1);
|
||||||
|
MX_CAN1_Init();
|
||||||
|
if (HAL_CAN_Start(&hcan1) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The application entry point.
|
||||||
|
* @retval int
|
||||||
|
*/
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
VectorBase_Config();
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||||
|
HAL_Init();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Init */
|
||||||
|
HAL_RCC_DeInit();
|
||||||
|
/* USER CODE END Init */
|
||||||
|
|
||||||
|
/* Configure the system clock */
|
||||||
|
SystemClock_Config();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SysInit */
|
||||||
|
|
||||||
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
|
/* Initialize all configured peripherals */
|
||||||
|
MX_GPIO_Init();
|
||||||
|
MX_ADC1_Init();
|
||||||
|
MX_CAN1_Init();
|
||||||
|
MX_CAN2_Init();
|
||||||
|
MX_RTC_Init();
|
||||||
|
MX_TIM4_Init();
|
||||||
|
MX_USART2_UART_Init();
|
||||||
|
MX_CRC_Init();
|
||||||
|
MX_UART5_Init();
|
||||||
|
MX_USART1_UART_Init();
|
||||||
|
MX_USART3_UART_Init();
|
||||||
|
MX_TIM3_Init();
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
Init_Peripheral();
|
||||||
|
LED_Init();
|
||||||
|
|
||||||
|
HAL_Delay(300);
|
||||||
|
CCS_Init();
|
||||||
|
SC_Init();
|
||||||
|
log_printf(LOG_INFO, "CCS module start\n");
|
||||||
|
ReadVersion();
|
||||||
|
log_printf(LOG_INFO, "Serial number: %d\n", infoPacket.serialNumber);
|
||||||
|
log_printf(LOG_INFO, "Board revision: %d\n", infoPacket.boardVersion);
|
||||||
|
log_printf(LOG_INFO, "FW version: %d.%d.%d\n", infoPacket.fw_version_major, infoPacket.fw_version_minor, infoPacket.fw_version_patch);
|
||||||
|
CAN1_MinimalReInit();
|
||||||
|
PSU_Init();
|
||||||
|
CONN_Init();
|
||||||
|
|
||||||
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
|
/* Infinite loop */
|
||||||
|
/* USER CODE BEGIN WHILE */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 3 */
|
||||||
|
|
||||||
|
|
||||||
|
PSU_ReadWrite();
|
||||||
|
PSU_Task();
|
||||||
|
ED_Delay(10);
|
||||||
|
METER_CalculateEnergy();
|
||||||
|
CONN_Loop();
|
||||||
|
LED_Write();
|
||||||
|
ED_Delay(10);
|
||||||
|
StopButtonControl();
|
||||||
|
ED_Delay(50);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* USER CODE END 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief System Clock Configuration
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemClock_Config(void)
|
||||||
|
{
|
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||||
|
|
||||||
|
/** Initializes the RCC Oscillators according to the specified parameters
|
||||||
|
* in the RCC_OscInitTypeDef structure.
|
||||||
|
*/
|
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
|
||||||
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||||
|
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV5;
|
||||||
|
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
||||||
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
|
RCC_OscInitStruct.Prediv1Source = RCC_PREDIV1_SOURCE_PLL2;
|
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||||
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
||||||
|
RCC_OscInitStruct.PLL2.PLL2State = RCC_PLL2_ON;
|
||||||
|
RCC_OscInitStruct.PLL2.PLL2MUL = RCC_PLL2_MUL8;
|
||||||
|
RCC_OscInitStruct.PLL2.HSEPrediv2Value = RCC_HSE_PREDIV2_DIV5;
|
||||||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Initializes the CPU, AHB and APB buses clocks
|
||||||
|
*/
|
||||||
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||||
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||||
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||||
|
|
||||||
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_ADC;
|
||||||
|
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
||||||
|
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
|
||||||
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure the Systick interrupt time
|
||||||
|
*/
|
||||||
|
__HAL_RCC_PLLI2S_ENABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 4 */
|
||||||
|
|
||||||
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is executed in case of error occurrence.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void Error_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
|
__disable_irq();
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* USER CODE END Error_Handler_Debug */
|
||||||
|
}
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
/**
|
||||||
|
* @brief Reports the name of the source file and the source line number
|
||||||
|
* where the assert_param error has occurred.
|
||||||
|
* @param file: pointer to the source file name
|
||||||
|
* @param line: assert_param error line source number
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void assert_failed(uint8_t *file, uint32_t line)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN 6 */
|
||||||
|
/* User can add his own implementation to report the file name and line number,
|
||||||
|
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||||
|
/* USER CODE END 6 */
|
||||||
|
}
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
||||||
54
Core/Src/meter.c
Executable file
54
Core/Src/meter.c
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* meter.c
|
||||||
|
*
|
||||||
|
* Created on: 27 сент. 2024 г.
|
||||||
|
* Author: root
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "meter.h"
|
||||||
|
#include "charger_config.h"
|
||||||
|
#include "charger_control.h"
|
||||||
|
|
||||||
|
|
||||||
|
METER_t METER;
|
||||||
|
|
||||||
|
// Функция для расчета и накопления энергии c дробной частью без счетчиков
|
||||||
|
void METER_CalculateEnergy() {
|
||||||
|
// Проверяем, что индекс находится в пределах массива
|
||||||
|
|
||||||
|
METER.online = 0;
|
||||||
|
|
||||||
|
if(CONN.connState == Charging){
|
||||||
|
METER.enable = 1;
|
||||||
|
}else{
|
||||||
|
METER.enable = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t currentTick = HAL_GetTick(); // Получаем текущее время в миллисекундах
|
||||||
|
uint32_t elapsedTimeMs = currentTick - METER.lastTick; // Вычисляем время, прошедшее с последнего вызова в секундах
|
||||||
|
METER.lastTick = currentTick; // Обновляем время последнего вызова для текущего коннектора
|
||||||
|
uint32_t energyWs = CONN.Power * elapsedTimeMs / 1000; // Рассчитываем энергию в ватт-секундах за прошедший промежуток времени
|
||||||
|
|
||||||
|
//Расчет энергии теперь идет всегда, смещение берем суммарное
|
||||||
|
METER.EnergyPSU_Ws += energyWs;
|
||||||
|
|
||||||
|
// Абсолютное значение энергии разъема складывается из накопленной дробной части и значения со счетчиков
|
||||||
|
METER.AbsoluteEnergy = (uint32_t)METER.EnergyPSU_Ws/3600; //переводим в Вт*час
|
||||||
|
|
||||||
|
if(METER.enable) {
|
||||||
|
//enabled state
|
||||||
|
CONN.Energy = METER.AbsoluteEnergy - METER.EnergyOffset;//переводим в Вт*час
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// Reset statе
|
||||||
|
CONN.Energy = 0;
|
||||||
|
|
||||||
|
METER.EnergyOffset = METER.AbsoluteEnergy;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
447
Core/Src/psu_control.c
Executable file
447
Core/Src/psu_control.c
Executable file
@@ -0,0 +1,447 @@
|
|||||||
|
|
||||||
|
#include <psu_control.h>
|
||||||
|
|
||||||
|
#include "can.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "charger_config.h"
|
||||||
|
#include "charger_control.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
PSU_02_t PSU_02;
|
||||||
|
PSU_04_t PSU_04;
|
||||||
|
PSU_06_t PSU_06;
|
||||||
|
PSU_08_t PSU_08;
|
||||||
|
PSU_09_t PSU_09;
|
||||||
|
|
||||||
|
PSU_1A_t PSU_1A;
|
||||||
|
PSU_1B_t PSU_1B;
|
||||||
|
PSU_1C_t PSU_1C;
|
||||||
|
|
||||||
|
PSU_t PSU0;
|
||||||
|
|
||||||
|
#define CAN_DELAY 20
|
||||||
|
#define PSU_VOLTAGE_THRESHOLD 20 // Порог напряжения для определения состояния (В)
|
||||||
|
#define PSU_ONLINE_TIMEOUT 500 // Таймаут для определения состояния (мс)
|
||||||
|
#define PSU_STARTUP_DELAY 4000 // Задержка 2 секунды перед включением
|
||||||
|
|
||||||
|
uint32_t can_lastpacket;
|
||||||
|
|
||||||
|
extern CAN_HandleTypeDef hcan2;
|
||||||
|
|
||||||
|
static void PSU_SwitchState(PSU_State_t state){
|
||||||
|
PSU0.state = state;
|
||||||
|
PSU0.statetick = HAL_GetTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t PSU_StateTime(void){
|
||||||
|
return HAL_GetTick() - PSU0.statetick;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan){
|
||||||
|
|
||||||
|
static CAN_RxHeaderTypeDef RxHeader;
|
||||||
|
static uint8_t RxData[8] = {0,};
|
||||||
|
CanId_t CanId;
|
||||||
|
|
||||||
|
if(HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO1, &RxHeader, RxData) == HAL_OK)
|
||||||
|
{
|
||||||
|
memcpy(&CanId, &RxHeader.ExtId, sizeof(CanId_t));
|
||||||
|
|
||||||
|
/* Для DC30 поддерживается только один силовой модуль (source == 0) */
|
||||||
|
if(CanId.source != 0) return;
|
||||||
|
can_lastpacket = HAL_GetTick();
|
||||||
|
|
||||||
|
if(CanId.command==0x02){
|
||||||
|
memcpy(&PSU_02, RxData, 8);
|
||||||
|
}
|
||||||
|
if(CanId.command==0x04){
|
||||||
|
memcpy(&PSU_04, RxData, 8);
|
||||||
|
|
||||||
|
PSU0.tempAmbient = PSU_04.moduleTemperature;
|
||||||
|
PSU0.status0.raw = PSU_04.modularForm0;
|
||||||
|
PSU0.status1.raw = PSU_04.modularForm1;
|
||||||
|
PSU0.status2.raw = PSU_04.modularForm2;
|
||||||
|
}
|
||||||
|
if(CanId.command==0x06){
|
||||||
|
memcpy(&PSU_06, RxData, 8);
|
||||||
|
|
||||||
|
PSU_06.VAB = PSU_06.VABLo+(PSU_06.VABHi<<8);
|
||||||
|
PSU_06.VBC = PSU_06.VBCLo+(PSU_06.VBCHi<<8);
|
||||||
|
PSU_06.VCA = PSU_06.VCALo+(PSU_06.VCAHi<<8);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(CanId.command==0x08){
|
||||||
|
memcpy(&PSU_08, RxData, 8);
|
||||||
|
}
|
||||||
|
if(CanId.command==0x09){
|
||||||
|
|
||||||
|
memcpy(&PSU_09, RxData, 8);
|
||||||
|
PSU_09.moduleNCurrent = PSU_09.moduleNCurrent_[3];
|
||||||
|
PSU_09.moduleNCurrent |= PSU_09.moduleNCurrent_[2]<<8;
|
||||||
|
PSU_09.moduleNCurrent |= PSU_09.moduleNCurrent_[1]<<16;
|
||||||
|
PSU_09.moduleNCurrent |= PSU_09.moduleNCurrent_[0]<<24;
|
||||||
|
|
||||||
|
PSU_09.moduleNVoltage = PSU_09.moduleNVoltage_[3];
|
||||||
|
PSU_09.moduleNVoltage |= PSU_09.moduleNVoltage_[2]<<8;
|
||||||
|
PSU_09.moduleNVoltage |= PSU_09.moduleNVoltage_[1]<<16;
|
||||||
|
PSU_09.moduleNVoltage |= PSU_09.moduleNVoltage_[0]<<24;
|
||||||
|
|
||||||
|
// PSU_09 -> PSU -> CONN (один модуль)
|
||||||
|
{
|
||||||
|
uint16_t v = PSU_09.moduleNVoltage / 1000;
|
||||||
|
int16_t i = PSU_09.moduleNCurrent / 100;
|
||||||
|
|
||||||
|
// Обновляем модель PSU0 по телеметрии
|
||||||
|
PSU0.outputVoltage = v;
|
||||||
|
PSU0.outputCurrent = i;
|
||||||
|
PSU0.PSU_enabled = (v >= PSU_VOLTAGE_THRESHOLD);
|
||||||
|
PSU0.online = 1;
|
||||||
|
PSU0.temperature = PSU_04.moduleTemperature;
|
||||||
|
|
||||||
|
// Экспортируем значения из PSU0 в CONN только,
|
||||||
|
// когда модуль хотя бы в состоянии READY и выше
|
||||||
|
if(PSU0.state >= PSU_READY){
|
||||||
|
CONN.MeasuredVoltage = PSU0.outputVoltage;
|
||||||
|
CONN.MeasuredCurrent = PSU0.outputCurrent;
|
||||||
|
CONN.Power = CONN.MeasuredCurrent * CONN.MeasuredVoltage / 10;
|
||||||
|
CONN.outputEnabled = PSU0.PSU_enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_CAN_FilterInit(){
|
||||||
|
CAN_FilterTypeDef sFilterConfig;
|
||||||
|
|
||||||
|
sFilterConfig.FilterBank = 14;
|
||||||
|
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
|
||||||
|
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
|
||||||
|
sFilterConfig.FilterIdHigh = 0x0000;
|
||||||
|
sFilterConfig.FilterIdLow = 0x0000;
|
||||||
|
sFilterConfig.FilterMaskIdHigh = 0x0000;
|
||||||
|
sFilterConfig.FilterMaskIdLow = 0x0000;
|
||||||
|
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
|
||||||
|
sFilterConfig.FilterActivation = ENABLE;
|
||||||
|
|
||||||
|
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
|
||||||
|
sFilterConfig.SlaveStartFilterBank = 14;
|
||||||
|
|
||||||
|
|
||||||
|
if(HAL_CAN_ConfigFilter(&hcan2, &sFilterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_Init(){
|
||||||
|
|
||||||
|
HAL_CAN_Stop(&hcan2);
|
||||||
|
MX_CAN2_Init();
|
||||||
|
PSU_CAN_FilterInit();
|
||||||
|
HAL_CAN_Start(&hcan2);
|
||||||
|
HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO1_MSG_PENDING /* | CAN_IT_ERROR | CAN_IT_BUSOFF | CAN_IT_LAST_ERROR_CODE | CAN_IT_TX_MAILBOX_EMPTY*/);
|
||||||
|
memset(&PSU0, 0, sizeof(PSU0));
|
||||||
|
PSU0.state = PSU_UNREADY;
|
||||||
|
PSU0.statetick = HAL_GetTick();
|
||||||
|
|
||||||
|
PSU0.power_limit = PSU_MAX_POWER; // kW
|
||||||
|
PSU0.hv_mode = 0;
|
||||||
|
|
||||||
|
PSU_Enable(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_Enable(uint8_t addr, uint8_t enable){
|
||||||
|
PSU_1A_t data;
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
/* Для DC30 поддерживается только один модуль с адресом 0 */
|
||||||
|
if(addr != 0) return;
|
||||||
|
if(PSU0.online == 0) return;
|
||||||
|
|
||||||
|
data.enable = !enable;
|
||||||
|
PSU_SendCmd(0xF0, addr, 0x1A, &data);
|
||||||
|
ED_Delay(CAN_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_SetHVMode(uint8_t addr, uint8_t enable){
|
||||||
|
PSU_1D_t data;
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
data.enable = !enable;
|
||||||
|
if(addr != 0) return;
|
||||||
|
PSU_SendCmd(0xF0, addr, 0x1D, &data);
|
||||||
|
}
|
||||||
|
void PSU_SetVoltageCurrent(uint8_t addr, uint16_t voltage, uint16_t current){
|
||||||
|
PSU_1C_t data;
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
|
||||||
|
if(addr != 0) return;
|
||||||
|
|
||||||
|
if(voltage<PSU_MIN_VOLTAGE) voltage = PSU_MIN_VOLTAGE;
|
||||||
|
|
||||||
|
if((PSU0.hv_mode==0) && voltage>499) voltage = 499;
|
||||||
|
|
||||||
|
uint32_t current_ma = current * 100;
|
||||||
|
uint32_t voltage_mv = voltage * 1000;
|
||||||
|
|
||||||
|
data.moduleCurrentTotal[0] = (current_ma >> 24) & 0xFF;
|
||||||
|
data.moduleCurrentTotal[1] = (current_ma >> 16) & 0xFF;
|
||||||
|
data.moduleCurrentTotal[2] = (current_ma >> 8) & 0xFF;
|
||||||
|
data.moduleCurrentTotal[3] = (current_ma >> 0) & 0xFF;
|
||||||
|
|
||||||
|
data.moduleVoltage[0] = (voltage_mv >> 24) & 0xFF;
|
||||||
|
data.moduleVoltage[1] = (voltage_mv >> 16) & 0xFF;
|
||||||
|
data.moduleVoltage[2] = (voltage_mv >> 8) & 0xFF;
|
||||||
|
data.moduleVoltage[3] = (voltage_mv >> 0) & 0xFF;
|
||||||
|
|
||||||
|
PSU_SendCmd(0xF0, addr, 0x1C, &data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data){
|
||||||
|
CanId_t CanId;
|
||||||
|
CanId.source = source;
|
||||||
|
CanId.destination = destination;
|
||||||
|
CanId.command = cmd;
|
||||||
|
CanId.device = 0x0A;
|
||||||
|
|
||||||
|
int8_t retry_counter = 10;
|
||||||
|
CAN_TxHeaderTypeDef tx_header;
|
||||||
|
uint32_t tx_mailbox;
|
||||||
|
HAL_StatusTypeDef CAN_result;
|
||||||
|
|
||||||
|
memcpy(&tx_header.ExtId, &CanId, sizeof(CanId_t));
|
||||||
|
|
||||||
|
tx_header.RTR = CAN_RTR_DATA;
|
||||||
|
tx_header.IDE = CAN_ID_EXT;
|
||||||
|
tx_header.DLC = 8;
|
||||||
|
|
||||||
|
while(retry_counter>0){ //если буфер полон, ждем пока он освободится
|
||||||
|
if (HAL_CAN_GetTxMailboxesFreeLevel(&hcan2) > 0){
|
||||||
|
/* отправка сообщения */
|
||||||
|
CAN_result = HAL_CAN_AddTxMessage(&hcan2, &tx_header, (uint8_t*)data, &tx_mailbox);
|
||||||
|
|
||||||
|
/* если отправка удалась, выход */
|
||||||
|
if(CAN_result == HAL_OK) {
|
||||||
|
return;
|
||||||
|
retry_counter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ED_Delay(1);
|
||||||
|
|
||||||
|
retry_counter--;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t max(uint32_t a, uint32_t b){
|
||||||
|
if(a>b) return a;
|
||||||
|
else return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_ReadWrite(){
|
||||||
|
|
||||||
|
uint8_t zero_data[8] = {0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
|
PSU_SendCmd(0xF0, 0, 0x04, zero_data);ED_Delay(CAN_DELAY);
|
||||||
|
PSU_SendCmd(0xF0, 0, 0x06, zero_data);ED_Delay(CAN_DELAY);
|
||||||
|
// PSU_SendCmd(0xF0, 0, 0x08, zero_data);ED_Delay(CAN_DELAY);
|
||||||
|
PSU_SendCmd(0xF0, 0, 0x09, zero_data);ED_Delay(CAN_DELAY);
|
||||||
|
|
||||||
|
// Power Limit
|
||||||
|
if ((CONN.WantedCurrent/10) * CONN.MeasuredVoltage > PSU0.power_limit){
|
||||||
|
CONN.RequestedCurrent = PSU0.power_limit * 10 / CONN.MeasuredVoltage;
|
||||||
|
}else{
|
||||||
|
CONN.RequestedCurrent = CONN.WantedCurrent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(CONN.RequestedCurrent > (PSU_MAX_CURRENT*10)){
|
||||||
|
CONN.RequestedCurrent = PSU_MAX_CURRENT*10;
|
||||||
|
}
|
||||||
|
CONN.RequestedPower = CONN.RequestedCurrent * CONN.RequestedVoltage / 10;
|
||||||
|
|
||||||
|
|
||||||
|
if(PSU0.ready){
|
||||||
|
PSU_SetVoltageCurrent(0, CONN.RequestedVoltage, CONN.RequestedCurrent); // Normal mode
|
||||||
|
ED_Delay(CAN_DELAY);
|
||||||
|
if(CONN.MeasuredVoltage>490) PSU0.hv_mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSU_SetHVMode(0, PSU0.hv_mode); // auto set, no need
|
||||||
|
// ED_Delay(CAN_DELAY);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PSU_Task(void){
|
||||||
|
static uint32_t psu_on_tick = 0;
|
||||||
|
static uint32_t dc_on_tick = 0;
|
||||||
|
static uint32_t cont_ok_tick = 0;
|
||||||
|
|
||||||
|
// Обновляем ONLINE/READY по таймауту
|
||||||
|
if((HAL_GetTick() - can_lastpacket) > PSU_ONLINE_TIMEOUT){
|
||||||
|
PSU0.online = 0;
|
||||||
|
PSU0.PSU_enabled = 0;
|
||||||
|
PSU_04.moduleTemperature = 0;
|
||||||
|
PSU_04.modularForm0 = 0;
|
||||||
|
PSU_04.modularForm1 = 0;
|
||||||
|
PSU_04.modularForm2 = 0;
|
||||||
|
PSU_06.VAB = 0;
|
||||||
|
PSU_06.VBC = 0;
|
||||||
|
PSU_06.VCA = 0;
|
||||||
|
PSU_09.moduleNCurrent = 0;
|
||||||
|
PSU_09.moduleNVoltage = 0;
|
||||||
|
}
|
||||||
|
if(!PSU0.online || !PSU0.enableAC){
|
||||||
|
CONN.MeasuredVoltage = 0;
|
||||||
|
CONN.MeasuredCurrent = 0;
|
||||||
|
CONN.outputEnabled = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Управление AC-контактором с задержкой отключения 1 минута
|
||||||
|
if(CONN.EvConnected){
|
||||||
|
RELAY_Write(RELAY_AC, 1);
|
||||||
|
psu_on_tick = HAL_GetTick();
|
||||||
|
PSU0.enableAC = 1;
|
||||||
|
}else{
|
||||||
|
if((HAL_GetTick() - psu_on_tick) > 1 * 60000){
|
||||||
|
RELAY_Write(RELAY_AC, 0);
|
||||||
|
PSU0.enableAC = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Текущее состояние DC-контактора по обратной связи
|
||||||
|
PSU0.CONT_enabled = IN_ReadInput(IN_CONT_FB_DC);
|
||||||
|
|
||||||
|
// Обновляем ready с учётом ошибок
|
||||||
|
if(PSU0.online && !PSU0.cont_fault && PSU0.enableAC){
|
||||||
|
// PSU0.ready = 1;
|
||||||
|
}else{
|
||||||
|
PSU0.ready = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(PSU0.state){
|
||||||
|
case PSU_UNREADY:
|
||||||
|
PSU0.enableOutput = 0;
|
||||||
|
RELAY_Write(RELAY_DC, 0);
|
||||||
|
if(PSU0.online && PSU0.enableAC && !PSU0.cont_fault){
|
||||||
|
PSU_SwitchState(PSU_INITIALIZING);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_INITIALIZING:
|
||||||
|
if(PSU_StateTime() > 4000){ // Wait 4s for PSU to initialize
|
||||||
|
PSU0.ready = 1;
|
||||||
|
PSU_SwitchState(PSU_READY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_READY:
|
||||||
|
// модуль готов, но выключен
|
||||||
|
PSU0.hv_mode = 0;
|
||||||
|
|
||||||
|
RELAY_Write(RELAY_DC, 0);
|
||||||
|
if(!PSU0.ready){
|
||||||
|
PSU_SwitchState(PSU_UNREADY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(CONN.EnableOutput){
|
||||||
|
PSU_Enable(0, 1);
|
||||||
|
PSU_SwitchState(PSU_WAIT_ACK_ON);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_WAIT_ACK_ON:
|
||||||
|
|
||||||
|
if(PSU0.PSU_enabled && PSU0.ready){
|
||||||
|
dc_on_tick = HAL_GetTick();
|
||||||
|
PSU_SwitchState(PSU_CONT_WAIT_ACK_ON);
|
||||||
|
}else if(PSU_StateTime() > 10000){
|
||||||
|
PSU0.psu_fault = 1;
|
||||||
|
CONN.chargingError = CONN_ERR_PSU_FAULT;
|
||||||
|
PSU_SwitchState(PSU_UNREADY);
|
||||||
|
log_printf(LOG_ERR, "PSU on timeout\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_CONT_WAIT_ACK_ON:
|
||||||
|
// замыкаем DC-контактор и ждём подтверждение
|
||||||
|
RELAY_Write(RELAY_DC, 1);
|
||||||
|
if(PSU0.CONT_enabled){
|
||||||
|
PSU_SwitchState(PSU_CONNECTED);
|
||||||
|
}else if(PSU_StateTime() > 1000){
|
||||||
|
PSU0.cont_fault = 1;
|
||||||
|
CONN.chargingError = CONN_ERR_CONTACTOR;
|
||||||
|
PSU_SwitchState(PSU_CURRENT_DROP);
|
||||||
|
log_printf(LOG_ERR, "Contactor error, stopping...\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_CONNECTED:
|
||||||
|
// Основное рабочее состояние
|
||||||
|
if(!CONN.EnableOutput || !PSU0.ready){
|
||||||
|
PSU_SwitchState(PSU_CURRENT_DROP);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// контроль контактора: 1 c таймаут
|
||||||
|
if (IN_ReadInput(IN_CONT_FB_DC) != RELAY_Read(RELAY_DC)){
|
||||||
|
if((HAL_GetTick() - cont_ok_tick) > 1000){
|
||||||
|
CONN.chargingError = CONN_ERR_CONTACTOR;
|
||||||
|
PSU0.cont_fault = 1;
|
||||||
|
PSU_SwitchState(PSU_CURRENT_DROP);
|
||||||
|
log_printf(LOG_ERR, "Contactor error, stopping...\n");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
cont_ok_tick = HAL_GetTick();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_CURRENT_DROP:
|
||||||
|
// снижаем ток до нуля перед отключением DC
|
||||||
|
CONN.RequestedCurrent = 0;
|
||||||
|
|
||||||
|
// если ток действительно упал или вышло время, отключаем DC
|
||||||
|
if((CONN.MeasuredCurrent < 30) || (PSU_StateTime() > 5000)){
|
||||||
|
PSU_SwitchState(PSU_CONT_WAIT_ACK_OFF);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_CONT_WAIT_ACK_OFF:
|
||||||
|
RELAY_Write(RELAY_DC, 0);
|
||||||
|
if(!PSU0.CONT_enabled){
|
||||||
|
PSU_Enable(0, 0);
|
||||||
|
PSU_SwitchState(PSU_WAIT_ACK_OFF);
|
||||||
|
}else if(PSU_StateTime() > 1000){
|
||||||
|
PSU0.cont_fault = 1;
|
||||||
|
CONN.chargingError = CONN_ERR_CONTACTOR;
|
||||||
|
PSU_Enable(0, 0);
|
||||||
|
PSU_SwitchState(PSU_WAIT_ACK_OFF);
|
||||||
|
log_printf(LOG_ERR, "Contactor error, stopping...\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PSU_WAIT_ACK_OFF:
|
||||||
|
if(!PSU0.PSU_enabled){
|
||||||
|
PSU_SwitchState(PSU_OFF_PAUSE);
|
||||||
|
}else if(PSU_StateTime() > 10000){
|
||||||
|
PSU0.psu_fault = 1;
|
||||||
|
CONN.chargingError = CONN_ERR_PSU_FAULT;
|
||||||
|
PSU_SwitchState(PSU_UNREADY);
|
||||||
|
log_printf(LOG_ERR, "PSU off timeout\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PSU_OFF_PAUSE:
|
||||||
|
if(PSU_StateTime() > 4000){
|
||||||
|
PSU_SwitchState(PSU_READY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
PSU_SwitchState(PSU_UNREADY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
251
Core/Src/rgb_controller.c
Normal file
251
Core/Src/rgb_controller.c
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
#include "rgb_controller.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "charger_control.h"
|
||||||
|
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
RGB_State_t LED_State;
|
||||||
|
RGB_Cycle_t LED_Cycle;
|
||||||
|
|
||||||
|
RGB_Cycle_t color_estop = {
|
||||||
|
.Color1 = { .R = 250, .G = 0, .B = 0 },
|
||||||
|
.Color2 = { .R = 250, .G = 0, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 50,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 50,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_unknown = {
|
||||||
|
.Color1 = { .R = 64, .G = 0, .B = 0 },
|
||||||
|
.Color2 = { .R = 64, .G = 0, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_light = {
|
||||||
|
.Color1 = { .R = 0, .G = 255, .B = 0 },
|
||||||
|
.Color2 = { .R = 0, .G = 255, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_disabled = {
|
||||||
|
.Color1 = { .R = 250, .G = 0, .B = 0 },
|
||||||
|
.Color2 = { .R = 32, .G = 0, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_unplugged = {
|
||||||
|
.Color1 = { .R = 0, .G = 128, .B = 0 },
|
||||||
|
.Color2 = { .R = 0, .G = 128, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_preparing = {
|
||||||
|
.Color1 = { .R = 0, .G = 0, .B = 250 },
|
||||||
|
.Color2 = { .R = 0, .G = 0, .B = 250 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_charging = {
|
||||||
|
.Color1 = { .R = 0, .G = 255, .B = 0 },
|
||||||
|
.Color2 = { .R = 0, .G = 32, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_finished = {
|
||||||
|
.Color1 = { .R = 255, .G = 255, .B = 255 },
|
||||||
|
.Color2 = { .R = 255, .G = 255, .B = 255 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
RGB_Cycle_t color_error = {
|
||||||
|
.Color1 = { .R = 255, .G = 0, .B = 0 },
|
||||||
|
.Color2 = { .R = 32, .G = 0, .B = 0 },
|
||||||
|
.Tr = 50,
|
||||||
|
.Th = 10,
|
||||||
|
.Tf = 50,
|
||||||
|
.Tl = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
void LED_Write(){
|
||||||
|
if(CONN.chargingError != CONN_NO_ERROR){
|
||||||
|
LED_SetColor(&color_error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch(CONN.connState){
|
||||||
|
case Unknown:
|
||||||
|
LED_SetColor(&color_unknown);
|
||||||
|
break;
|
||||||
|
case Unplugged:
|
||||||
|
LED_SetColor(&color_unplugged);
|
||||||
|
break;
|
||||||
|
case Disabled:
|
||||||
|
LED_SetColor(&color_error);
|
||||||
|
break;
|
||||||
|
case Preparing:
|
||||||
|
LED_SetColor(&color_preparing);
|
||||||
|
break;
|
||||||
|
case AuthRequired:
|
||||||
|
LED_SetColor(&color_preparing);
|
||||||
|
break;
|
||||||
|
case WaitingForEnergy:
|
||||||
|
LED_SetColor(&color_charging);
|
||||||
|
break;
|
||||||
|
case ChargingPausedEV:
|
||||||
|
LED_SetColor(&color_charging);
|
||||||
|
break;
|
||||||
|
case ChargingPausedEVSE:
|
||||||
|
LED_SetColor(&color_charging);
|
||||||
|
break;
|
||||||
|
case Charging:
|
||||||
|
LED_SetColor(&color_charging);
|
||||||
|
break;
|
||||||
|
case AuthTimeout:
|
||||||
|
LED_SetColor(&color_finished);
|
||||||
|
break;
|
||||||
|
case Finished:
|
||||||
|
LED_SetColor(&color_finished);
|
||||||
|
break;
|
||||||
|
case FinishedEVSE:
|
||||||
|
LED_SetColor(&color_finished);
|
||||||
|
break;
|
||||||
|
case FinishedEV:
|
||||||
|
LED_SetColor(&color_finished);
|
||||||
|
break;
|
||||||
|
case Replugging:
|
||||||
|
LED_SetColor(&color_preparing);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LED_SetColor(&color_unknown);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void interpolateColors(RGB_t* color1, RGB_t* color2, uint16_t a, uint16_t b, RGB_t *result) {
|
||||||
|
|
||||||
|
// Проверяем, чтобы a не выходила за пределы диапазона
|
||||||
|
if (a > b) a = b;
|
||||||
|
|
||||||
|
if(b==0) b = 1;
|
||||||
|
|
||||||
|
// Вычисляем коэффициент смешивания в виде целого числа
|
||||||
|
uint16_t t = (a * 255) / b; // t будет от 0 до 255
|
||||||
|
|
||||||
|
// Линейная интерполяция с использованием целых чисел
|
||||||
|
result->R = (color1->R * (255 - t) + color2->R * t) / 255;
|
||||||
|
result->G = (color1->G * (255 - t) + color2->G * t) / 255;
|
||||||
|
result->B = (color1->B * (255 - t) + color2->B * t) / 255;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RGB_SetColor(RGB_t *color){
|
||||||
|
htim4.Instance->CCR2 = color->R * 100 / 255;
|
||||||
|
htim4.Instance->CCR3 = color->G * 100 / 255;
|
||||||
|
htim4.Instance->CCR4 = color->B * 100 / 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LED_SetColor(RGB_Cycle_t *color){
|
||||||
|
memcpy(&LED_Cycle, color, sizeof(RGB_Cycle_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LED_Init(){
|
||||||
|
RGB_t color = {.R=0, .G=0, .B=0};
|
||||||
|
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2);
|
||||||
|
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3);
|
||||||
|
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4);
|
||||||
|
RGB_SetColor(&color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// void LED_PhaseSync(uint8_t led_n){
|
||||||
|
// if(LED_State[led_n].phasesync){
|
||||||
|
// LED_State[led_n].phasesync = 0;
|
||||||
|
// //default settings
|
||||||
|
// LED_State[led_n].state = LED_HIGH;
|
||||||
|
// LED_State[led_n].tick = 0;
|
||||||
|
// //ищем среди всех светодиодов такую же последовательность
|
||||||
|
// for (uint8_t led_n1 = 0; led_n1 < 5; led_n1++){
|
||||||
|
// if ((LED_Cycle[led_n].Tf == LED_Cycle[led_n1].Tf) &&
|
||||||
|
// (LED_Cycle[led_n].Tr == LED_Cycle[led_n1].Tr) &&
|
||||||
|
// (LED_Cycle[led_n].Th == LED_Cycle[led_n1].Th) &&
|
||||||
|
// (LED_Cycle[led_n].Tl == LED_Cycle[led_n1].Tl) &&
|
||||||
|
// (led_n != led_n1)){
|
||||||
|
// //если нашли, то копируем фазу оттуда
|
||||||
|
// LED_State[led_n].state = LED_State[led_n1].state;
|
||||||
|
// LED_State[led_n].tick = LED_State[led_n1].tick;
|
||||||
|
// return;
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
void LED_Task(){
|
||||||
|
static uint32_t led_tick;
|
||||||
|
if((HAL_GetTick() - led_tick) > 20){
|
||||||
|
led_tick = HAL_GetTick();
|
||||||
|
LED_State.tick++;
|
||||||
|
// LED_PhaseSync(led_n);
|
||||||
|
switch(LED_State.state){
|
||||||
|
case LED_RISING:
|
||||||
|
interpolateColors(&LED_Cycle.Color2, &LED_Cycle.Color1, LED_State.tick, LED_Cycle.Tr, &LED_State.color);
|
||||||
|
|
||||||
|
if(LED_State.tick>LED_Cycle.Tr){
|
||||||
|
LED_State.state = LED_HIGH;
|
||||||
|
LED_State.tick = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LED_HIGH:
|
||||||
|
memcpy(&LED_State.color, &LED_Cycle.Color1, sizeof(RGB_t));
|
||||||
|
|
||||||
|
if(LED_State.tick>LED_Cycle.Th){
|
||||||
|
LED_State.state = LED_FALLING;
|
||||||
|
LED_State.tick = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LED_FALLING:
|
||||||
|
interpolateColors(&LED_Cycle.Color1, &LED_Cycle.Color2, LED_State.tick, LED_Cycle.Tf, &LED_State.color);
|
||||||
|
|
||||||
|
if(LED_State.tick>LED_Cycle.Tf){
|
||||||
|
LED_State.state = LED_LOW;
|
||||||
|
LED_State.tick = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LED_LOW:
|
||||||
|
memcpy(&LED_State.color, &LED_Cycle.Color2, sizeof(RGB_t));
|
||||||
|
|
||||||
|
if(LED_State.tick>LED_Cycle.Tl){
|
||||||
|
LED_State.state = LED_RISING;
|
||||||
|
LED_State.tick = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LED_State.state = LED_RISING;
|
||||||
|
}
|
||||||
|
RGB_SetColor(&LED_State.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
77
Core/Src/rtc.c
Executable file
77
Core/Src/rtc.c
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "rtc.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
RTC_HandleTypeDef hrtc;
|
||||||
|
|
||||||
|
/* RTC init function */
|
||||||
|
void MX_RTC_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTC_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN RTC_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_Init 1 */
|
||||||
|
|
||||||
|
/** Initialize RTC Only
|
||||||
|
*/
|
||||||
|
hrtc.Instance = RTC;
|
||||||
|
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
|
||||||
|
hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
|
||||||
|
if (HAL_RTC_Init(&hrtc) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN RTC_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(rtcHandle->Instance==RTC)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN RTC_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_MspInit 0 */
|
||||||
|
HAL_PWR_EnableBkUpAccess();
|
||||||
|
/* Enable BKP CLK enable for backup registers */
|
||||||
|
__HAL_RCC_BKP_CLK_ENABLE();
|
||||||
|
/* RTC clock enable */
|
||||||
|
__HAL_RCC_RTC_ENABLE();
|
||||||
|
/* USER CODE BEGIN RTC_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(rtcHandle->Instance==RTC)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN RTC_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_RTC_DISABLE();
|
||||||
|
/* USER CODE BEGIN RTC_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END RTC_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
427
Core/Src/serial.c
Normal file
427
Core/Src/serial.c
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
#include "serial.h"
|
||||||
|
#include "cp.h"
|
||||||
|
#include "connector.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "charger_config.h"
|
||||||
|
#include "psu_control.h"
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart3;
|
||||||
|
|
||||||
|
static void send_state(void);
|
||||||
|
static void CCS_SendResetReason(void);
|
||||||
|
|
||||||
|
CCS_MaxLoad_t CCS_MaxLoad;
|
||||||
|
|
||||||
|
uint32_t CCS_Power = 0;
|
||||||
|
uint32_t CCS_EnergyWs = 0;
|
||||||
|
uint32_t CCS_Energy = 0;
|
||||||
|
|
||||||
|
uint32_t last_cmd_sent = 0;
|
||||||
|
uint32_t last_stop_sent = 0;
|
||||||
|
CONN_Control_t last_cmd = CMD_NONE;
|
||||||
|
uint8_t ev_enable_output = 0;
|
||||||
|
|
||||||
|
#define CMD_INTERVAL 10
|
||||||
|
#define MAX_TX_BUFFER_SIZE 256
|
||||||
|
#define MAX_RX_BUFFER_SIZE 256
|
||||||
|
|
||||||
|
static uint8_t rx_buffer[MAX_RX_BUFFER_SIZE];
|
||||||
|
static uint8_t tx_buffer[MAX_TX_BUFFER_SIZE];
|
||||||
|
static uint8_t rx_armed = 0;
|
||||||
|
|
||||||
|
uint8_t ESTOP = 0;
|
||||||
|
uint8_t REPLUG = 0;
|
||||||
|
|
||||||
|
static uint8_t enabled = 0;
|
||||||
|
static uint8_t pwm_duty_percent = 100;
|
||||||
|
uint8_t isolation_enable = 0;
|
||||||
|
static uint32_t last_host_seen = 0;
|
||||||
|
static CP_State_t cp_state_buffer = EV_STATE_ACQUIRING;
|
||||||
|
|
||||||
|
CCS_State_t CCS_State;
|
||||||
|
CCS_EvInfo_t CCS_EvInfo;
|
||||||
|
CONN_State_t CCS_EvseState;
|
||||||
|
CCS_ConnectorState_t CCS_ConnectorState = CCS_UNPLUGGED;
|
||||||
|
|
||||||
|
static uint8_t process_received_packet(const uint8_t* packet, uint16_t packet_len);
|
||||||
|
|
||||||
|
void CCS_RxEventCallback(UART_HandleTypeDef *huart, uint16_t size) {
|
||||||
|
if (huart != &huart3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rx_armed = 0;
|
||||||
|
if (size > 0 && size <= sizeof(rx_buffer)) {
|
||||||
|
process_received_packet(rx_buffer, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCS_SerialLoop(void) {
|
||||||
|
static uint32_t replug_tick = 0;
|
||||||
|
static uint32_t replug_watchdog_tick = 0;
|
||||||
|
static uint32_t replug_watchdog1_tick = 0;
|
||||||
|
static uint32_t last_state_sent = 0;
|
||||||
|
|
||||||
|
if (!rx_armed && HAL_UART_GetState(&huart3) == HAL_UART_STATE_READY) {
|
||||||
|
if (HAL_UARTEx_ReceiveToIdle_IT(&huart3, rx_buffer, sizeof(rx_buffer)) == HAL_OK) {
|
||||||
|
rx_armed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read CP once per loop and use buffered value below. */
|
||||||
|
cp_state_buffer = CP_GetState();
|
||||||
|
|
||||||
|
if (CONN.connControl != CMD_NONE) {
|
||||||
|
last_cmd = CONN.connControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((HAL_GetTick() - last_cmd_sent) > CMD_INTERVAL){
|
||||||
|
if ((HAL_GetTick() - last_state_sent) >= 200) {
|
||||||
|
send_state();
|
||||||
|
last_state_sent = HAL_GetTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ESTOP) {
|
||||||
|
log_printf(LOG_ERR, "ESTOP triggered\n");
|
||||||
|
CCS_SendEmergencyStop();
|
||||||
|
ESTOP = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((CONN.connControl == CMD_STOP) ||
|
||||||
|
(CONN.chargingError != CONN_NO_ERROR)) &&
|
||||||
|
((HAL_GetTick() - last_stop_sent) > 1000)) {
|
||||||
|
last_stop_sent = HAL_GetTick();
|
||||||
|
log_printf(LOG_WARN, "Stopping charging...\n");
|
||||||
|
CCS_SendEmergencyStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((CCS_EvseState == FinishedEV) || (CCS_EvseState == FinishedEVSE)) &&
|
||||||
|
((HAL_GetTick() - last_stop_sent) > 1000)) {
|
||||||
|
last_stop_sent = HAL_GetTick();
|
||||||
|
log_printf(LOG_WARN, "FinishedEV, stopping...\n");
|
||||||
|
CCS_SendEmergencyStop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)replug_watchdog_tick;
|
||||||
|
(void)replug_watchdog1_tick;
|
||||||
|
|
||||||
|
switch(CCS_ConnectorState){
|
||||||
|
case CCS_DISABLED:
|
||||||
|
RELAY_Write(RELAY_CP, 0);
|
||||||
|
CONN_SetState(Disabled);
|
||||||
|
if (CONN.chargingError == CONN_NO_ERROR){
|
||||||
|
CCS_ConnectorState = CCS_UNPLUGGED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CCS_UNPLUGGED:
|
||||||
|
RELAY_Write(RELAY_CP, 1);
|
||||||
|
CONN_SetState(Unplugged);
|
||||||
|
if ((cp_state_buffer == EV_STATE_B_CONN_PREP) || (cp_state_buffer == EV_STATE_C_CONN_ACTIVE)){
|
||||||
|
CCS_ConnectorState = CCS_AUTH_REQUIRED;
|
||||||
|
}
|
||||||
|
if (CONN.chargingError != CONN_NO_ERROR){
|
||||||
|
log_printf(LOG_ERR, "Charging error %d, state -> disabled\n", CONN.chargingError);
|
||||||
|
CCS_ConnectorState = CCS_DISABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case CCS_AUTH_REQUIRED:
|
||||||
|
RELAY_Write(RELAY_CP, 1);
|
||||||
|
CONN_SetState(AuthRequired);
|
||||||
|
if(CONN.connControl == CMD_START){
|
||||||
|
log_printf(LOG_INFO, "Charging permitted, start charging\n");
|
||||||
|
CCS_ConnectorState = CCS_CONNECTED;
|
||||||
|
}
|
||||||
|
if (cp_state_buffer == EV_STATE_A_IDLE){
|
||||||
|
log_printf(LOG_INFO, "Car unplugged\n");
|
||||||
|
CCS_ConnectorState = CCS_UNPLUGGED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CCS_CONNECTED:
|
||||||
|
RELAY_Write(RELAY_CP, 1);
|
||||||
|
if(CCS_EvseState < Preparing) {
|
||||||
|
CONN_SetState(Preparing);
|
||||||
|
} else {
|
||||||
|
CONN_SetState(CCS_EvseState);
|
||||||
|
}
|
||||||
|
if (cp_state_buffer == EV_STATE_A_IDLE){
|
||||||
|
log_printf(LOG_INFO, "Car unplugged\n");
|
||||||
|
CCS_ConnectorState = CCS_UNPLUGGED;
|
||||||
|
}
|
||||||
|
if(REPLUG > 0){
|
||||||
|
log_printf(LOG_INFO, "Replugging...\n");
|
||||||
|
CCS_ConnectorState = CCS_REPLUGGING;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CCS_REPLUGGING:
|
||||||
|
RELAY_Write(RELAY_CP, 0);
|
||||||
|
CONN_SetState(Replugging);
|
||||||
|
if((HAL_GetTick() - replug_tick) > 1000){
|
||||||
|
replug_tick = HAL_GetTick();
|
||||||
|
if(REPLUG > 0){
|
||||||
|
if (REPLUG != 0xFF) REPLUG--;
|
||||||
|
} else {
|
||||||
|
log_printf(LOG_INFO, "Replugging finished, but car unplugged\n");
|
||||||
|
CCS_ConnectorState = CCS_UNPLUGGED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(REPLUG == 0){
|
||||||
|
if(cp_state_buffer == EV_STATE_B_CONN_PREP){
|
||||||
|
log_printf(LOG_INFO, "Replugging finished, car plugged, state -> auth required\n");
|
||||||
|
CCS_ConnectorState = CCS_AUTH_REQUIRED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last_host_seen > 0 && (HAL_GetTick() - last_host_seen) > 500) {
|
||||||
|
CONN.EnableOutput = 0;
|
||||||
|
CCS_EvseState = Unknown;
|
||||||
|
CP_SetDuty(100);
|
||||||
|
log_printf(LOG_ERR, "Everest timeout\n");
|
||||||
|
} else {
|
||||||
|
if (last_cmd == CMD_STOP) {
|
||||||
|
CONN.EnableOutput = 0;
|
||||||
|
} else {
|
||||||
|
CONN.EnableOutput = ev_enable_output ? 1 : 0;
|
||||||
|
if((CONN.EnableOutput == 0) && (CONN.connState == Preparing)){
|
||||||
|
CONN.EnableOutput = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((cp_state_buffer == EV_STATE_B_CONN_PREP) ||
|
||||||
|
(cp_state_buffer == EV_STATE_C_CONN_ACTIVE) ||
|
||||||
|
(cp_state_buffer == EV_STATE_D_CONN_ACT_VENT)) {
|
||||||
|
CONN.EvConnected = 1;
|
||||||
|
} else {
|
||||||
|
CONN.EvConnected = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCS_Init(void){
|
||||||
|
CP_Init();
|
||||||
|
CP_SetDuty(100);
|
||||||
|
CCS_MaxLoad.maxVoltage = PSU_MAX_VOLTAGE; // 1000V
|
||||||
|
CCS_MaxLoad.minVoltage = PSU_MIN_VOLTAGE; //150V
|
||||||
|
CCS_MaxLoad.maxCurrent = PSU_MAX_CURRENT*10; //100A
|
||||||
|
CCS_MaxLoad.minCurrent = PSU_MIN_CURRENT*10; //1A
|
||||||
|
CCS_MaxLoad.maxPower = PSU_MAX_POWER; //30000W
|
||||||
|
CCS_SendResetReason();
|
||||||
|
log_printf(LOG_INFO, "CCS init\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t crc16_ibm(const uint8_t* data, uint16_t length) {
|
||||||
|
uint16_t crc = 0xFFFFu;
|
||||||
|
for (uint16_t i = 0; i < length; i++) {
|
||||||
|
crc ^= data[i];
|
||||||
|
for (uint8_t j = 0; j < 8; j++) {
|
||||||
|
if (crc & 1u) {
|
||||||
|
crc = (crc >> 1) ^ 0xA001u;
|
||||||
|
} else {
|
||||||
|
crc >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t CCS_BuildPacket(uint8_t cmd, const void* payload, uint16_t payload_len, uint8_t* out, uint16_t out_max) {
|
||||||
|
uint16_t total_len = (uint16_t)(1u + payload_len + 2u);
|
||||||
|
if (total_len > out_max) return 0;
|
||||||
|
|
||||||
|
out[0] = cmd;
|
||||||
|
if (payload_len && payload != NULL) {
|
||||||
|
memcpy(&out[1], payload, payload_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t crc = crc16_ibm(out, (uint16_t)(1u + payload_len));
|
||||||
|
out[1u + payload_len] = (uint8_t)(crc & 0xFFu);
|
||||||
|
out[1u + payload_len + 1u] = (uint8_t)((crc >> 8) & 0xFFu);
|
||||||
|
|
||||||
|
return total_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CCS_SendPacket(uint8_t cmd, const void* payload, uint16_t payload_len) {
|
||||||
|
uint16_t len = CCS_BuildPacket(cmd, payload, payload_len, tx_buffer, sizeof(tx_buffer));
|
||||||
|
if (len > 0) {
|
||||||
|
HAL_UART_Transmit(&huart3, tx_buffer, len, 1000);
|
||||||
|
}
|
||||||
|
last_cmd_sent = HAL_GetTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CCS_SendResetReason(void) {
|
||||||
|
CCS_SendPacket(CMD_M2E_RESET, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCS_SendEmergencyStop(void) {
|
||||||
|
CCS_SendPacket(CMD_M2E_ESTOP, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCS_SendStart(void) {
|
||||||
|
CCS_SendPacket(CMD_M2E_START, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CCS_CalculateEnergy(void) {
|
||||||
|
static uint32_t lastTick = 0;
|
||||||
|
uint32_t currentTick = HAL_GetTick();
|
||||||
|
uint32_t elapsedTimeMs = currentTick - lastTick;
|
||||||
|
lastTick = currentTick;
|
||||||
|
|
||||||
|
CCS_Power = CONN.MeasuredVoltage * CONN.MeasuredCurrent / 10;
|
||||||
|
CCS_EnergyWs += (CCS_Power * elapsedTimeMs) / 1000;
|
||||||
|
|
||||||
|
if(CCS_EvseState == Unplugged) {
|
||||||
|
CCS_EnergyWs = 0;
|
||||||
|
}
|
||||||
|
CCS_Energy = CCS_EnergyWs / 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void send_state(void) {
|
||||||
|
CCS_CalculateEnergy();
|
||||||
|
|
||||||
|
CCS_State.DutyCycle = CP_GetDuty();
|
||||||
|
CCS_State.OutputEnabled = PSU0.CONT_enabled;
|
||||||
|
CCS_State.MeasuredVoltage = (uint16_t)CONN.MeasuredVoltage;
|
||||||
|
CCS_State.MeasuredCurrent = (uint16_t)CONN.MeasuredCurrent;
|
||||||
|
CCS_State.Power = CCS_Power;
|
||||||
|
CCS_State.Energy = CCS_Energy;
|
||||||
|
|
||||||
|
if(CCS_ConnectorState == CCS_CONNECTED){
|
||||||
|
CCS_State.CpState = cp_state_buffer;
|
||||||
|
} else {
|
||||||
|
CCS_State.CpState = EV_STATE_A_IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
CCS_State.MaxVoltage = CCS_MaxLoad.maxVoltage;
|
||||||
|
CCS_State.MinVoltage = CCS_MaxLoad.minVoltage;
|
||||||
|
CCS_State.MaxCurrent = CCS_MaxLoad.maxCurrent;
|
||||||
|
CCS_State.MinCurrent = CCS_MaxLoad.minCurrent;
|
||||||
|
CCS_State.MaxPower = CCS_MaxLoad.maxPower;
|
||||||
|
CCS_State.IsolationValid = isolation_enable;
|
||||||
|
CCS_State.IsolationResistance = 900000;
|
||||||
|
|
||||||
|
CCS_SendPacket(CMD_M2E_STATE, &CCS_State, sizeof(CCS_State));
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t expected_payload_len(uint8_t cmd) {
|
||||||
|
switch (cmd) {
|
||||||
|
case CMD_E2M_PWM_DUTY: return sizeof(e2m_pwm_duty_t);
|
||||||
|
case CMD_E2M_ENABLE_OUTPUT: return sizeof(e2m_enable_output_t);
|
||||||
|
case CMD_E2M_RESET: return sizeof(e2m_reset_t);
|
||||||
|
case CMD_E2M_ENABLE: return sizeof(e2m_enable_t);
|
||||||
|
case CMD_E2M_REPLUG: return sizeof(e2m_replug_t);
|
||||||
|
case CMD_E2M_SET_OUTPUT_VOLTAGE: return sizeof(e2m_set_output_t);
|
||||||
|
case CMD_E2M_ISOLATION_CONTROL: return sizeof(e2m_isolation_control_t);
|
||||||
|
case CMD_E2M_EV_INFO: return sizeof(CCS_EvInfo_t);
|
||||||
|
case CMD_E2M_EVSE_STATE: return sizeof(CONN_State_t);
|
||||||
|
case CMD_E2M_KEEP_ALIVE: return 0;
|
||||||
|
default: return 0xFFFFu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void apply_command(uint8_t cmd, const uint8_t* payload, uint16_t payload_len) {
|
||||||
|
(void)payload_len;
|
||||||
|
last_host_seen = HAL_GetTick();
|
||||||
|
switch (cmd) {
|
||||||
|
case CMD_E2M_PWM_DUTY: {
|
||||||
|
const e2m_pwm_duty_t* p = (const e2m_pwm_duty_t*)payload;
|
||||||
|
uint8_t duty = p->pwm_duty_percent;
|
||||||
|
if (duty > 100) duty = 100;
|
||||||
|
pwm_duty_percent = duty;
|
||||||
|
CP_SetDuty(duty);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_ENABLE_OUTPUT: {
|
||||||
|
const e2m_enable_output_t* p = (const e2m_enable_output_t*)payload;
|
||||||
|
ev_enable_output = (p->enable_output != 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_RESET: {
|
||||||
|
const e2m_reset_t* p = (const e2m_reset_t*)payload;
|
||||||
|
if (p->reset) {
|
||||||
|
log_printf(LOG_WARN, "Everest reset command\n");
|
||||||
|
CCS_SendResetReason();
|
||||||
|
HAL_Delay(10);
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_ENABLE: {
|
||||||
|
const e2m_enable_t* p = (const e2m_enable_t*)payload;
|
||||||
|
enabled = (p->enable != 0);
|
||||||
|
(void)enabled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_SET_OUTPUT_VOLTAGE: {
|
||||||
|
const e2m_set_output_t* p = (const e2m_set_output_t*)payload;
|
||||||
|
CONN.RequestedVoltage = p->voltage_V;
|
||||||
|
CONN.WantedCurrent = p->current_0p1A;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_ISOLATION_CONTROL: {
|
||||||
|
const e2m_isolation_control_t* p = (const e2m_isolation_control_t*)payload;
|
||||||
|
isolation_enable = p->command;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_EV_INFO: {
|
||||||
|
memcpy(&CCS_EvInfo, payload, sizeof(CCS_EvInfo_t));
|
||||||
|
CONN.SOC = (uint8_t)(CCS_EvInfo.soc / 10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_EVSE_STATE: {
|
||||||
|
CCS_EvseState = (CONN_State_t)payload[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_REPLUG: {
|
||||||
|
(void)payload;
|
||||||
|
CP_SetDuty(pwm_duty_percent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_E2M_KEEP_ALIVE: {
|
||||||
|
last_host_seen = HAL_GetTick();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t process_received_packet(const uint8_t* packet, uint16_t packet_len) {
|
||||||
|
if (packet_len < 3) return 0;
|
||||||
|
|
||||||
|
uint8_t cmd = packet[0];
|
||||||
|
uint16_t payload_len = (uint16_t)(packet_len - 3);
|
||||||
|
|
||||||
|
uint16_t received_crc = (uint16_t)packet[packet_len - 2u] |
|
||||||
|
(uint16_t)packet[packet_len - 1u] << 8;
|
||||||
|
|
||||||
|
uint16_t calculated_crc = crc16_ibm(packet, (uint16_t)(1 + payload_len));
|
||||||
|
if (received_crc != calculated_crc) {
|
||||||
|
log_printf(LOG_ERR, "Packet CRC error\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t expected_len = expected_payload_len(cmd);
|
||||||
|
if (expected_len == 0xFFFF) {
|
||||||
|
log_printf(LOG_WARN, "Unknown cmd 0x%02x\n", cmd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (expected_len != payload_len) {
|
||||||
|
log_printf(LOG_ERR, "Packet len mismatch cmd=0x%02x\n", cmd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload_len > 0) {
|
||||||
|
apply_command(cmd, &packet[1], payload_len);
|
||||||
|
} else {
|
||||||
|
apply_command(cmd, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
238
Core/Src/serial_control.c
Normal file
238
Core/Src/serial_control.c
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
#include "serial_control.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
|
// Приватные функции
|
||||||
|
static uint32_t calculate_crc32(const uint8_t* data, uint16_t length);
|
||||||
|
static uint16_t encode_packet(const uint8_t* payload, uint16_t payload_len, uint8_t* output, uint8_t response_code);
|
||||||
|
static uint8_t parse_packet(const uint8_t* packet_data, uint16_t packet_len, ReceivedCommand_t* out_cmd);
|
||||||
|
static uint8_t process_received_packet(SerialControl_t *ctx, const uint8_t* packet_data, uint16_t packet_len);
|
||||||
|
|
||||||
|
uint8_t test_crc_invalid = 0;
|
||||||
|
|
||||||
|
SerialControl_t serial_control;
|
||||||
|
// Контекст для приема пакетов по UART5 (однонаправленный UART)
|
||||||
|
static SerialControl_t serial_iso;
|
||||||
|
volatile SC_Source_t g_sc_command_source = SC_SOURCE_UART2;
|
||||||
|
|
||||||
|
StatusPacket_t statusPacket = {
|
||||||
|
.SOC = 0,
|
||||||
|
.Energy = 0,
|
||||||
|
.RequestedVoltage = 0,
|
||||||
|
.RequestedCurrent = 0,
|
||||||
|
.MeasuredVoltage = 0,
|
||||||
|
.MeasuredCurrent = 0,
|
||||||
|
.outputEnabled = 0,
|
||||||
|
.chargingError = 0,
|
||||||
|
.connState = 0,
|
||||||
|
.chargingElapsedTimeMin = 0,
|
||||||
|
.chargingElapsedTimeSec = 0,
|
||||||
|
.estimatedRemainingChargingTime = 0,
|
||||||
|
.relayAC = 0,
|
||||||
|
.relayDC = 0,
|
||||||
|
.relayAUX = 0,
|
||||||
|
.lockState = 0,
|
||||||
|
.evInfoAvailable = 0,
|
||||||
|
.psuOnline = 0,
|
||||||
|
.tempConnector0 = 0,
|
||||||
|
.tempConnector1 = 0,
|
||||||
|
.tempAmbient = 0,
|
||||||
|
.tempBatteryMax = 0,
|
||||||
|
.tempBatteryMin = 0,
|
||||||
|
.highestVoltageOfBatteryCell = 0,
|
||||||
|
.batteryStatus = 0,
|
||||||
|
.phaseVoltageAB = 0,
|
||||||
|
.phaseVoltageBC = 0,
|
||||||
|
.phaseVoltageCA = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
InfoPacket_t infoPacket = {
|
||||||
|
.serialNumber = 0,
|
||||||
|
.boardVersion = 0,
|
||||||
|
.stationType = 0,
|
||||||
|
.fw_version_major = 0,
|
||||||
|
.fw_version_minor = 0,
|
||||||
|
.fw_version_patch = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
void ReadVersion(){
|
||||||
|
infoPacket.serialNumber = InfoBlock->serialNumber;
|
||||||
|
infoPacket.boardVersion = InfoBlock->boardVersion;
|
||||||
|
infoPacket.stationType = InfoBlock->stationType;
|
||||||
|
infoPacket.fw_version_major = FW_VERSION_MAJOR;
|
||||||
|
infoPacket.fw_version_minor = FW_VERSION_MINOR;
|
||||||
|
infoPacket.fw_version_patch = FW_VERSION_PATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Внешняя функция обработки команд (определена в serial_handler.c)
|
||||||
|
extern void SC_CommandHandler(ReceivedCommand_t* cmd);
|
||||||
|
|
||||||
|
void SC_Init() {
|
||||||
|
// Обнуляем структуру
|
||||||
|
memset(&serial_control, 0, sizeof(SerialControl_t));
|
||||||
|
memset(&serial_iso, 0, sizeof(serial_iso));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SC_Task() {
|
||||||
|
// Запуск приема в режиме прерывания с ожиданием idle
|
||||||
|
if((huart2.RxState == HAL_UART_STATE_READY) && (serial_control.command_ready == 0)) HAL_UARTEx_ReceiveToIdle_IT(&huart2, serial_control.rx_buffer, MAX_RX_BUFFER_SIZE - 1);
|
||||||
|
if((huart5.RxState == HAL_UART_STATE_READY)) HAL_UARTEx_ReceiveToIdle_IT(&huart5, serial_iso.rx_buffer, MAX_RX_BUFFER_SIZE - 1);
|
||||||
|
|
||||||
|
// Проверка таймаута отправки пакета (больше 100 мс)
|
||||||
|
if (huart2.gState == HAL_UART_STATE_BUSY_TX && serial_control.tx_tick != 0) {
|
||||||
|
if ((HAL_GetTick() - serial_control.tx_tick) > 100) {
|
||||||
|
// Таймаут: принудительно сбрасываем передачу
|
||||||
|
HAL_UART_Abort_IT(&huart2);
|
||||||
|
// Выключаем DIR при сбросе передачи
|
||||||
|
HAL_GPIO_WritePin(USART2_DIR_GPIO_Port, USART2_DIR_Pin, GPIO_PIN_RESET);
|
||||||
|
serial_control.tx_tick = 0; // Сбрасываем tick
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Проверка наличия принятой команды для обработки
|
||||||
|
if (serial_control.command_ready && (huart2.gState != HAL_UART_STATE_BUSY_TX)) {
|
||||||
|
// HAL_Delay(2);
|
||||||
|
SC_CommandHandler(&serial_control.received_command);
|
||||||
|
HAL_UARTEx_ReceiveToIdle_IT(&huart2, serial_control.rx_buffer, MAX_RX_BUFFER_SIZE - 1);
|
||||||
|
serial_control.command_ready = 0; // Сбрасываем флаг
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
|
||||||
|
if (huart->Instance == huart2.Instance) {
|
||||||
|
if(!process_received_packet(&serial_control, serial_control.rx_buffer, Size)){
|
||||||
|
SC_SendPacket(NULL, 0, RESP_INVALID);
|
||||||
|
}
|
||||||
|
g_sc_command_source = SC_SOURCE_UART2;
|
||||||
|
HAL_UARTEx_ReceiveToIdle_IT(&huart2, serial_control.rx_buffer, MAX_RX_BUFFER_SIZE - 1);
|
||||||
|
} else if (huart->Instance == huart5.Instance) {
|
||||||
|
if (process_received_packet(&serial_iso, serial_iso.rx_buffer, Size)) {
|
||||||
|
g_sc_command_source = SC_SOURCE_UART5;
|
||||||
|
SC_CommandHandler((ReceivedCommand_t*)&serial_iso.received_command);
|
||||||
|
}
|
||||||
|
HAL_UARTEx_ReceiveToIdle_IT(&huart5, serial_iso.rx_buffer, MAX_RX_BUFFER_SIZE - 1);
|
||||||
|
} else if (huart->Instance == huart3.Instance) {
|
||||||
|
CCS_RxEventCallback(huart, Size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
||||||
|
if (huart->Instance == huart2.Instance) {
|
||||||
|
HAL_GPIO_WritePin(USART2_DIR_GPIO_Port, USART2_DIR_Pin, GPIO_PIN_RESET);
|
||||||
|
serial_control.tx_tick = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Приватные функции реализации
|
||||||
|
|
||||||
|
// Полностью программная реализация CRC-32 (полином CRC32_POLYNOMIAL, порядок little-endian)
|
||||||
|
static uint32_t calculate_crc32(const uint8_t* data, uint16_t length) {
|
||||||
|
uint32_t crc = 0xFFFFFFFFu;
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < length; i++) {
|
||||||
|
crc ^= data[i];
|
||||||
|
for (uint8_t bit = 0; bit < 8; bit++) {
|
||||||
|
if (crc & 0x1u) {
|
||||||
|
crc = (crc >> 1) ^ CRC32_POLYNOMIAL;
|
||||||
|
} else {
|
||||||
|
crc >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc ^ 0xFFFFFFFFu;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t encode_packet(const uint8_t* payload, uint16_t payload_len, uint8_t* output, uint8_t response_code) {
|
||||||
|
uint16_t out_index = 0;
|
||||||
|
|
||||||
|
output[out_index++] = response_code;
|
||||||
|
|
||||||
|
if (payload != NULL) {
|
||||||
|
// Просто копируем полезную нагрузку без какого‑либо экранирования
|
||||||
|
for (uint16_t i = 0; i < payload_len; i++) {
|
||||||
|
output[out_index++] = payload[i];
|
||||||
|
|
||||||
|
// Проверка переполнения
|
||||||
|
if (out_index >= MAX_TX_BUFFER_SIZE - 5) { // 4 байта CRC + END_BYTE
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вычисляем CRC для всего содержимого (код ответа + полезная нагрузка)
|
||||||
|
uint32_t crc = calculate_crc32(output, out_index);
|
||||||
|
uint8_t* crc_bytes = (uint8_t*)&crc;
|
||||||
|
|
||||||
|
// Добавляем CRC без экранирования
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
output[out_index++] = crc_bytes[i];
|
||||||
|
|
||||||
|
if (out_index >= MAX_TX_BUFFER_SIZE - 1) { // место для END_BYTE
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SC_SendPacket(const uint8_t* payload, uint16_t payload_len, uint8_t response_code) {
|
||||||
|
uint16_t packet_len = encode_packet(payload, payload_len, serial_control.tx_buffer, response_code);
|
||||||
|
|
||||||
|
if (packet_len > 0) {
|
||||||
|
if (huart2.gState == HAL_UART_STATE_BUSY_TX) {
|
||||||
|
HAL_UART_Abort_IT(&huart2);
|
||||||
|
HAL_GPIO_WritePin(USART2_DIR_GPIO_Port, USART2_DIR_Pin, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(USART2_DIR_GPIO_Port, USART2_DIR_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
HAL_UART_Transmit_IT(&huart2, serial_control.tx_buffer, packet_len);
|
||||||
|
|
||||||
|
serial_control.tx_tick = HAL_GetTick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t parse_packet(const uint8_t* packet_data, uint16_t packet_len, ReceivedCommand_t* out_cmd) {
|
||||||
|
// if (test_crc_invalid && (packet_data[1] != CMD_GET_STATUS)) {
|
||||||
|
// test_crc_invalid--;
|
||||||
|
// return 0;
|
||||||
|
// }else{
|
||||||
|
// test_crc_invalid = 5;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Минимальный размер: 1 байт команды + 4 байта CRC
|
||||||
|
if (packet_len < 5) return 0;
|
||||||
|
if (packet_len > MAX_RX_BUFFER_SIZE) return 0;
|
||||||
|
|
||||||
|
uint16_t payload_length = packet_len - 4;
|
||||||
|
|
||||||
|
// Извлекаем принятую CRC (последние 4 байта, little-endian)
|
||||||
|
uint32_t received_checksum =
|
||||||
|
((uint32_t)packet_data[payload_length] << 0) |
|
||||||
|
((uint32_t)packet_data[payload_length + 1] << 8) |
|
||||||
|
((uint32_t)packet_data[payload_length + 2] << 16) |
|
||||||
|
((uint32_t)packet_data[payload_length + 3] << 24);
|
||||||
|
|
||||||
|
// Вычисляем CRC для полезной нагрузки
|
||||||
|
uint32_t calculated_checksum = calculate_crc32(packet_data, payload_length);
|
||||||
|
|
||||||
|
if (received_checksum != calculated_checksum) return 0; // CRC не совпадает
|
||||||
|
|
||||||
|
out_cmd->argument = (void *)&packet_data[1];
|
||||||
|
out_cmd->command = packet_data[0];
|
||||||
|
out_cmd->argument_length = (uint8_t)(payload_length - 1);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t process_received_packet(SerialControl_t *ctx, const uint8_t* packet_data, uint16_t packet_len) {
|
||||||
|
if (!parse_packet(packet_data, packet_len, (ReceivedCommand_t *)&ctx->received_command)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->command_ready = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
205
Core/Src/serial_handler.c
Normal file
205
Core/Src/serial_handler.c
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
#include "serial_control.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "charger_control.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "psu_control.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef USE_WEB_INTERFACE
|
||||||
|
|
||||||
|
extern volatile SC_Source_t g_sc_command_source;
|
||||||
|
|
||||||
|
IsolationStatusPacket_t ISO = {
|
||||||
|
.isolationResistance = 0xFFFF
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t config_initialized = 0;
|
||||||
|
ConfigBlock_t config = {
|
||||||
|
.location = "RUS",
|
||||||
|
.chargerNumber = 00001,
|
||||||
|
.unixTime = 1721651966,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Единая функция-обработчик всех команд со switch-case
|
||||||
|
void SC_CommandHandler(ReceivedCommand_t* cmd) {
|
||||||
|
|
||||||
|
uint8_t response_code = RESP_FAILED;
|
||||||
|
|
||||||
|
switch (cmd->command) {
|
||||||
|
// Команды БЕЗ аргументов
|
||||||
|
case CMD_GET_STATUS:
|
||||||
|
// Логика получения информации
|
||||||
|
monitoring_data_callback();
|
||||||
|
|
||||||
|
// Отправляем с нормальным приоритетом
|
||||||
|
SC_SendPacket((uint8_t*)&statusPacket, sizeof(statusPacket), CMD_GET_STATUS);
|
||||||
|
return; // Специальный ответ уже отправлен
|
||||||
|
|
||||||
|
case CMD_GET_INFO:
|
||||||
|
SC_SendPacket((uint8_t*)&infoPacket, sizeof(infoPacket), CMD_GET_INFO);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case CMD_GET_LOG:
|
||||||
|
debug_buffer_send();
|
||||||
|
return; // Ответ формируется внутри debug_buffer_send
|
||||||
|
|
||||||
|
// Команды С аргументами
|
||||||
|
|
||||||
|
case CMD_SET_CONFIG:
|
||||||
|
if (cmd->argument_length == sizeof(ConfigBlock_t)) {
|
||||||
|
memcpy(&config, cmd->argument, sizeof(ConfigBlock_t));
|
||||||
|
config_initialized = 1;
|
||||||
|
log_printf(LOG_INFO, "Set Config: %s %d\n", config.location, config.chargerNumber);
|
||||||
|
response_code = RESP_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
response_code = RESP_FAILED;
|
||||||
|
break;
|
||||||
|
case CMD_SET_POWER_LIMIT:
|
||||||
|
if (cmd->argument_length == 1) {
|
||||||
|
PSU0.power_limit = ((uint8_t*)cmd->argument)[0] * 1000;
|
||||||
|
log_printf(LOG_INFO, "Power limit: %d\n", PSU0.power_limit);
|
||||||
|
//CONN.connState = (((uint8_t*)cmd->argument)[0])/4;
|
||||||
|
response_code = RESP_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
response_code = RESP_FAILED;
|
||||||
|
break;
|
||||||
|
case CMD_CHARGE_PERMIT:
|
||||||
|
if (cmd->argument_length == 1) {
|
||||||
|
CONN.connControl = ((uint8_t*)cmd->argument)[0];
|
||||||
|
log_printf(LOG_INFO, "Charge permit: %d\n", CONN.connControl);
|
||||||
|
response_code = RESP_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
response_code = RESP_FAILED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_TEST_PSU:
|
||||||
|
// if (cmd->argument_length == sizeof(PSU_TestMode_t)) {
|
||||||
|
// memcpy(&PSU_TestMode, cmd->argument, sizeof(PSU_TestMode_t));
|
||||||
|
// log_printf(LOG_INFO, "Test PSU: %d %d %d\n", PSU_TestMode.enable, PSU_TestMode.voltage, PSU_TestMode.current);
|
||||||
|
// response_code = RESP_SUCCESS;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
response_code = RESP_FAILED;
|
||||||
|
break;
|
||||||
|
case CMD_DEVICE_RESET:
|
||||||
|
// 2. Отправляем SUCCESS (хост может успеть получить его перед ребутом)
|
||||||
|
SC_SendPacket(NULL, 0, RESP_SUCCESS);
|
||||||
|
|
||||||
|
while(huart2.gState == HAL_UART_STATE_BUSY_TX); // Ожидание завершения передачи
|
||||||
|
|
||||||
|
HAL_Delay(10);
|
||||||
|
// 3. Выполняем программный сброс
|
||||||
|
NVIC_SystemReset();
|
||||||
|
return; // Сюда код уже не дойдет, но для компилятора нxужно
|
||||||
|
|
||||||
|
case CMD_ISOLATION_STATUS:
|
||||||
|
if (cmd->argument_length == sizeof(IsolationStatusPacket_t)) {
|
||||||
|
memcpy(&ISO, cmd->argument, sizeof(IsolationStatusPacket_t));
|
||||||
|
// Для однонаправленного UART5 ответ не нужен
|
||||||
|
if (g_sc_command_source == SC_SOURCE_UART5) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
response_code = RESP_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
response_code = RESP_FAILED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Неизвестная команда
|
||||||
|
response_code = RESP_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Отправляем финальный ответ (для команд без собственного ответа)
|
||||||
|
SC_SendPacket(NULL, 0, response_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Колбэк для заполнения данных мониторинга
|
||||||
|
void monitoring_data_callback() {
|
||||||
|
|
||||||
|
// Информация о зарядной сессии
|
||||||
|
statusPacket.SOC = CONN.SOC;
|
||||||
|
statusPacket.Energy = CONN.Energy;
|
||||||
|
statusPacket.RequestedVoltage = CONN.RequestedVoltage;
|
||||||
|
statusPacket.RequestedCurrent = CONN.WantedCurrent;
|
||||||
|
statusPacket.MeasuredVoltage = CONN.MeasuredVoltage;
|
||||||
|
statusPacket.MeasuredCurrent = CONN.MeasuredCurrent;
|
||||||
|
statusPacket.outputEnabled = CONN.outputEnabled;
|
||||||
|
statusPacket.chargingError = CONN.chargingError;
|
||||||
|
statusPacket.connState = CONN.connState;
|
||||||
|
statusPacket.chargingElapsedTimeMin = 0;
|
||||||
|
statusPacket.chargingElapsedTimeSec = 0;
|
||||||
|
statusPacket.estimatedRemainingChargingTime = 0;
|
||||||
|
|
||||||
|
// состояние зарядной станции
|
||||||
|
statusPacket.relayAC = RELAY_Read(RELAY_AC);
|
||||||
|
statusPacket.relayDC = RELAY_Read(RELAY_DC);
|
||||||
|
statusPacket.relayAUX = RELAY_Read(RELAY_AUX0);
|
||||||
|
statusPacket.lockState = 0;
|
||||||
|
statusPacket.stopButton = !IN_ReadInput(IN_ESTOP);
|
||||||
|
statusPacket.logAvailable = (debug_buffer_available()>0)?1:0;
|
||||||
|
statusPacket.evInfoAvailable = 0;
|
||||||
|
statusPacket.psuOnline = PSU0.online;
|
||||||
|
|
||||||
|
statusPacket.tempConnector0 = CONN_ReadTemp(0); // температура коннектора
|
||||||
|
statusPacket.tempConnector1 = CONN_ReadTemp(1);
|
||||||
|
statusPacket.tempAmbient = PSU0.tempAmbient; // температура окружающего воздуха
|
||||||
|
statusPacket.tempBatteryMax = 0;
|
||||||
|
statusPacket.tempBatteryMin = 0;
|
||||||
|
|
||||||
|
statusPacket.highestVoltageOfBatteryCell = 0;
|
||||||
|
statusPacket.batteryStatus = 0;
|
||||||
|
|
||||||
|
statusPacket.phaseVoltageAB = PSU_06.VAB;
|
||||||
|
statusPacket.phaseVoltageBC = PSU_06.VBC;
|
||||||
|
statusPacket.phaseVoltageCA = PSU_06.VCA;
|
||||||
|
|
||||||
|
// GBT TODO
|
||||||
|
memset(statusPacket.VIN, 0, sizeof(statusPacket.VIN));
|
||||||
|
|
||||||
|
// GBT TODO
|
||||||
|
statusPacket.batteryType = 0;
|
||||||
|
statusPacket.batteryCapacity = 0;
|
||||||
|
statusPacket.batteryVoltage = 0;
|
||||||
|
memset(statusPacket.batteryVendor, 0, sizeof(statusPacket.batteryVendor));
|
||||||
|
statusPacket.batterySN = 0;
|
||||||
|
statusPacket.batteryManuD = 0;
|
||||||
|
statusPacket.batteryManuM = 0;
|
||||||
|
statusPacket.batteryManuY = 0;
|
||||||
|
statusPacket.batteryCycleCount = 0;
|
||||||
|
statusPacket.ownAuto = 0;
|
||||||
|
memset(statusPacket.EV_SW_VER, 0, sizeof(statusPacket.EV_SW_VER));
|
||||||
|
|
||||||
|
statusPacket.testMode = 0;
|
||||||
|
statusPacket.testVoltage = 0;
|
||||||
|
statusPacket.testCurrent = 0;
|
||||||
|
|
||||||
|
// Информация о тачке
|
||||||
|
|
||||||
|
// --- Информация об EV (из команды info2) ---
|
||||||
|
// memcpy(statusPacket.version, GBT_EVInfo.version, sizeof(statusPacket.version));
|
||||||
|
|
||||||
|
|
||||||
|
// --- Состояние Hardware и GBT (различные команды) ---
|
||||||
|
//statusPacket.lockState = GBT_LockGetState(); // Из команды lock_state
|
||||||
|
//statusPacket.ccState = CONN_CC_GetState(); // Из команды cc_state
|
||||||
|
//statusPacket.ccAdc = CONN_CC_GetAdc(); // Из команды adc
|
||||||
|
|
||||||
|
// --- Поля, требующие внимания (неявные геттеры) ---
|
||||||
|
|
||||||
|
// 1. Состояние соединения (ConnState)
|
||||||
|
// В debug.c есть CONN_SetState, предполагаем наличие CONN_GetState()
|
||||||
|
// Если такой функции нет, закомментируйте следующую строку:
|
||||||
|
// statusPacket.connState = CONN_GetState();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
40
Core/Src/sma_filter.c
Normal file
40
Core/Src/sma_filter.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include "sma_filter.h"
|
||||||
|
|
||||||
|
void SMAFilter_Init(SMAFilter_t* f)
|
||||||
|
{
|
||||||
|
if (f == 0) return;
|
||||||
|
|
||||||
|
f->sum = 0;
|
||||||
|
f->idx = 0;
|
||||||
|
f->count = 0;
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < SMA_FILTER_WINDOW; i++) {
|
||||||
|
f->buffer[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t SMAFilter_Update(SMAFilter_t* f, int32_t x)
|
||||||
|
{
|
||||||
|
if (f == 0) return x;
|
||||||
|
|
||||||
|
// Пока окно не заполнено полностью, делим по фактическому count.
|
||||||
|
if (f->count < SMA_FILTER_WINDOW) {
|
||||||
|
f->buffer[f->idx] = x;
|
||||||
|
f->sum += x;
|
||||||
|
f->idx++;
|
||||||
|
if (f->idx >= SMA_FILTER_WINDOW) f->idx = 0;
|
||||||
|
f->count++;
|
||||||
|
return (int32_t)(f->sum / (int32_t)f->count);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Окно заполнено: "вычитаем старое + добавляем новое".
|
||||||
|
int32_t old = f->buffer[f->idx];
|
||||||
|
f->buffer[f->idx] = x;
|
||||||
|
f->sum += (x - old);
|
||||||
|
|
||||||
|
f->idx++;
|
||||||
|
if (f->idx >= SMA_FILTER_WINDOW) f->idx = 0;
|
||||||
|
|
||||||
|
return (int32_t)(f->sum / (int32_t)SMA_FILTER_WINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
197
Core/Src/soft_rtc.c
Executable file
197
Core/Src/soft_rtc.c
Executable file
@@ -0,0 +1,197 @@
|
|||||||
|
/*
|
||||||
|
* rtc.c
|
||||||
|
*
|
||||||
|
* Created on: Jul 22, 2024
|
||||||
|
* Author: colorbass
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <soft_rtc.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
uint8_t tmp_time[4];
|
||||||
|
uint32_t tmp_time32;
|
||||||
|
|
||||||
|
extern RTC_HandleTypeDef hrtc;
|
||||||
|
static HAL_StatusTypeDef RTC1_WriteTimeCounter(RTC_HandleTypeDef *hrtc, uint32_t TimeCounter);
|
||||||
|
static uint32_t RTC1_ReadTimeCounter(RTC_HandleTypeDef *hrtc);
|
||||||
|
static HAL_StatusTypeDef RTC1_ExitInitMode(RTC_HandleTypeDef *hrtc);
|
||||||
|
static HAL_StatusTypeDef RTC1_EnterInitMode(RTC_HandleTypeDef *hrtc);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t get_Current_Time(){
|
||||||
|
return RTC1_ReadTimeCounter(&hrtc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_Time(uint32_t unix_time){
|
||||||
|
RTC1_WriteTimeCounter(&hrtc, unix_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t to_bcd(int value) {
|
||||||
|
return ((value / 10) << 4) | (value % 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void unix_to_bcd(uint32_t unix_time, uint8_t *time) {
|
||||||
|
struct tm *tm_info;
|
||||||
|
time_t raw_time = (time_t)unix_time;
|
||||||
|
tm_info = gmtime(&raw_time);
|
||||||
|
|
||||||
|
time[0] = to_bcd(tm_info->tm_sec);
|
||||||
|
time[1] = to_bcd(tm_info->tm_min);
|
||||||
|
time[2] = to_bcd(tm_info->tm_hour);
|
||||||
|
time[3] = to_bcd(tm_info->tm_mday);
|
||||||
|
time[4] = to_bcd(tm_info->tm_mon + 1); // tm_mon is 0-11
|
||||||
|
time[5] = to_bcd((tm_info->tm_year + 1900) % 100); // Year in 2 digits
|
||||||
|
time[6] = to_bcd((tm_info->tm_year + 1900) / 100); // Century in 2 digits
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeTimeReg(uint8_t reg_number, uint8_t value){
|
||||||
|
tmp_time[reg_number] = value;
|
||||||
|
if(reg_number == 3) set_Time((tmp_time[0])+(tmp_time[1]<<8)+(tmp_time[2]<<16)+(tmp_time[3]<<24));
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t getTimeReg(uint8_t reg_number){
|
||||||
|
if(reg_number == 0){
|
||||||
|
tmp_time32 = get_Current_Time();
|
||||||
|
return tmp_time32 & 0xFF;
|
||||||
|
}else if(reg_number == 1){
|
||||||
|
return (tmp_time32>>8) & 0xFF;
|
||||||
|
}else if(reg_number == 2){
|
||||||
|
return (tmp_time32>>16) & 0xFF;
|
||||||
|
}else if(reg_number == 3){
|
||||||
|
return (tmp_time32>>24) & 0xFF;
|
||||||
|
}else{
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//int main() {
|
||||||
|
// uint32_t unix_time = 1672531199; // Example Unix timestamp
|
||||||
|
// uint8_t time[8];
|
||||||
|
//
|
||||||
|
// unix_to_bcd(unix_time, time);
|
||||||
|
//
|
||||||
|
// // Print the BCD values for verification
|
||||||
|
// for (int i = 0; i < 8; i++) {
|
||||||
|
// log_printf(LOG_INFO, "time[%d]: %02X\n", i, time[i]);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read the time counter available in RTC_CNT registers.
|
||||||
|
* @param hrtc pointer to a RTC_HandleTypeDef structure that contains
|
||||||
|
* the configuration information for RTC.
|
||||||
|
* @retval Time counter
|
||||||
|
*/
|
||||||
|
static uint32_t RTC1_ReadTimeCounter(RTC_HandleTypeDef *hrtc)
|
||||||
|
{
|
||||||
|
uint16_t high1 = 0U, high2 = 0U, low = 0U;
|
||||||
|
uint32_t timecounter = 0U;
|
||||||
|
|
||||||
|
high1 = READ_REG(hrtc->Instance->CNTH & RTC_CNTH_RTC_CNT);
|
||||||
|
low = READ_REG(hrtc->Instance->CNTL & RTC_CNTL_RTC_CNT);
|
||||||
|
high2 = READ_REG(hrtc->Instance->CNTH & RTC_CNTH_RTC_CNT);
|
||||||
|
|
||||||
|
if (high1 != high2)
|
||||||
|
{
|
||||||
|
/* In this case the counter roll over during reading of CNTL and CNTH registers,
|
||||||
|
read again CNTL register then return the counter value */
|
||||||
|
timecounter = (((uint32_t) high2 << 16U) | READ_REG(hrtc->Instance->CNTL & RTC_CNTL_RTC_CNT));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* No counter roll over during reading of CNTL and CNTH registers, counter
|
||||||
|
value is equal to first value of CNTL and CNTH */
|
||||||
|
timecounter = (((uint32_t) high1 << 16U) | low);
|
||||||
|
}
|
||||||
|
|
||||||
|
return timecounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write the time counter in RTC_CNT registers.
|
||||||
|
* @param hrtc pointer to a RTC_HandleTypeDef structure that contains
|
||||||
|
* the configuration information for RTC.
|
||||||
|
* @param TimeCounter: Counter to write in RTC_CNT registers
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
static HAL_StatusTypeDef RTC1_WriteTimeCounter(RTC_HandleTypeDef *hrtc, uint32_t TimeCounter)
|
||||||
|
{
|
||||||
|
HAL_StatusTypeDef status = HAL_OK;
|
||||||
|
|
||||||
|
/* Set Initialization mode */
|
||||||
|
if (RTC1_EnterInitMode(hrtc) != HAL_OK)
|
||||||
|
{
|
||||||
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Set RTC COUNTER MSB word */
|
||||||
|
WRITE_REG(hrtc->Instance->CNTH, (TimeCounter >> 16U));
|
||||||
|
/* Set RTC COUNTER LSB word */
|
||||||
|
WRITE_REG(hrtc->Instance->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT));
|
||||||
|
|
||||||
|
/* Wait for synchro */
|
||||||
|
if (RTC1_ExitInitMode(hrtc) != HAL_OK)
|
||||||
|
{
|
||||||
|
status = HAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enters the RTC Initialization mode.
|
||||||
|
* @param hrtc pointer to a RTC_HandleTypeDef structure that contains
|
||||||
|
* the configuration information for RTC.
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
static HAL_StatusTypeDef RTC1_EnterInitMode(RTC_HandleTypeDef *hrtc)
|
||||||
|
{
|
||||||
|
uint32_t tickstart = 0U;
|
||||||
|
|
||||||
|
tickstart = HAL_GetTick();
|
||||||
|
/* Wait till RTC is in INIT state and if Time out is reached exit */
|
||||||
|
while ((hrtc->Instance->CRL & RTC_CRL_RTOFF) == (uint32_t)RESET)
|
||||||
|
{
|
||||||
|
if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
|
||||||
|
{
|
||||||
|
return HAL_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Disable the write protection for RTC registers */
|
||||||
|
__HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
|
||||||
|
|
||||||
|
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Exit the RTC Initialization mode.
|
||||||
|
* @param hrtc pointer to a RTC_HandleTypeDef structure that contains
|
||||||
|
* the configuration information for RTC.
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
static HAL_StatusTypeDef RTC1_ExitInitMode(RTC_HandleTypeDef *hrtc)
|
||||||
|
{
|
||||||
|
uint32_t tickstart = 0U;
|
||||||
|
|
||||||
|
/* Disable the write protection for RTC registers */
|
||||||
|
__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
|
||||||
|
|
||||||
|
tickstart = HAL_GetTick();
|
||||||
|
/* Wait till RTC is in INIT state and if Time out is reached exit */
|
||||||
|
while ((hrtc->Instance->CRL & RTC_CRL_RTOFF) == (uint32_t)RESET)
|
||||||
|
{
|
||||||
|
if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
|
||||||
|
{
|
||||||
|
return HAL_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
86
Core/Src/stm32f1xx_hal_msp.c
Normal file
86
Core/Src/stm32f1xx_hal_msp.c
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f1xx_hal_msp.c
|
||||||
|
* @brief This file provides code for the MSP Initialization
|
||||||
|
* and de-Initialization codes.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN TD */
|
||||||
|
|
||||||
|
/* USER CODE END TD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Define */
|
||||||
|
|
||||||
|
/* USER CODE END Define */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Macro */
|
||||||
|
|
||||||
|
/* USER CODE END Macro */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
/* External functions --------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN ExternalFunctions */
|
||||||
|
|
||||||
|
/* USER CODE END ExternalFunctions */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
/**
|
||||||
|
* Initializes the Global MSP.
|
||||||
|
*/
|
||||||
|
void HAL_MspInit(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END MspInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_AFIO_CLK_ENABLE();
|
||||||
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* System interrupt init*/
|
||||||
|
|
||||||
|
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||||
|
*/
|
||||||
|
__HAL_AFIO_REMAP_SWJ_NOJTAG();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END MspInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
321
Core/Src/stm32f1xx_it.c
Normal file
321
Core/Src/stm32f1xx_it.c
Normal file
@@ -0,0 +1,321 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f1xx_it.c
|
||||||
|
* @brief Interrupt Service Routines.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
#include "stm32f1xx_it.h"
|
||||||
|
/* Private includes ----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN TD */
|
||||||
|
|
||||||
|
/* USER CODE END TD */
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
|
/* USER CODE END PD */
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PM */
|
||||||
|
|
||||||
|
/* USER CODE END PM */
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
/* USER CODE END PV */
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
|
/* Private user code ---------------------------------------------------------*/
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/* External variables --------------------------------------------------------*/
|
||||||
|
extern CAN_HandleTypeDef hcan1;
|
||||||
|
extern CAN_HandleTypeDef hcan2;
|
||||||
|
extern TIM_HandleTypeDef htim3;
|
||||||
|
extern UART_HandleTypeDef huart5;
|
||||||
|
extern UART_HandleTypeDef huart1;
|
||||||
|
extern UART_HandleTypeDef huart2;
|
||||||
|
extern UART_HandleTypeDef huart3;
|
||||||
|
/* USER CODE BEGIN EV */
|
||||||
|
|
||||||
|
/* USER CODE END EV */
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||||
|
/******************************************************************************/
|
||||||
|
/**
|
||||||
|
* @brief This function handles Non maskable interrupt.
|
||||||
|
*/
|
||||||
|
void NMI_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||||
|
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Hard fault interrupt.
|
||||||
|
*/
|
||||||
|
void HardFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END HardFault_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
||||||
|
/* USER CODE END W1_HardFault_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Memory management fault.
|
||||||
|
*/
|
||||||
|
void MemManage_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
||||||
|
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Prefetch fault, memory access fault.
|
||||||
|
*/
|
||||||
|
void BusFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END BusFault_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
||||||
|
/* USER CODE END W1_BusFault_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Undefined instruction or illegal state.
|
||||||
|
*/
|
||||||
|
void UsageFault_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END UsageFault_IRQn 0 */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
||||||
|
/* USER CODE END W1_UsageFault_IRQn 0 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles System service call via SWI instruction.
|
||||||
|
*/
|
||||||
|
void SVC_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SVCall_IRQn 0 */
|
||||||
|
/* USER CODE BEGIN SVCall_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SVCall_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Debug monitor.
|
||||||
|
*/
|
||||||
|
void DebugMon_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||||
|
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DebugMonitor_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles Pendable request for system service.
|
||||||
|
*/
|
||||||
|
void PendSV_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN PendSV_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END PendSV_IRQn 0 */
|
||||||
|
/* USER CODE BEGIN PendSV_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END PendSV_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles System tick timer.
|
||||||
|
*/
|
||||||
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SysTick_IRQn 0 */
|
||||||
|
HAL_IncTick();
|
||||||
|
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SysTick_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* STM32F1xx Peripheral Interrupt Handlers */
|
||||||
|
/* Add here the Interrupt Handlers for the used peripherals. */
|
||||||
|
/* For the available peripheral interrupt handler names, */
|
||||||
|
/* please refer to the startup file (startup_stm32f1xx.s). */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN1 RX0 interrupt.
|
||||||
|
*/
|
||||||
|
void CAN1_RX0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_RX0_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX0_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan1);
|
||||||
|
/* USER CODE BEGIN CAN1_RX0_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX0_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles TIM3 global interrupt.
|
||||||
|
*/
|
||||||
|
void TIM3_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_IRQn 0 */
|
||||||
|
HAL_TIM_IRQHandler(&htim3);
|
||||||
|
/* USER CODE BEGIN TIM3_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles USART1 global interrupt.
|
||||||
|
*/
|
||||||
|
void USART1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_IRQn 0 */
|
||||||
|
HAL_UART_IRQHandler(&huart1);
|
||||||
|
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles USART2 global interrupt.
|
||||||
|
*/
|
||||||
|
void USART2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART2_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_IRQn 0 */
|
||||||
|
HAL_UART_IRQHandler(&huart2);
|
||||||
|
/* USER CODE BEGIN USART2_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles USART3 global interrupt.
|
||||||
|
*/
|
||||||
|
void USART3_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART3_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_IRQn 0 */
|
||||||
|
HAL_UART_IRQHandler(&huart3);
|
||||||
|
/* USER CODE BEGIN USART3_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles UART5 global interrupt.
|
||||||
|
*/
|
||||||
|
void UART5_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN UART5_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_IRQn 0 */
|
||||||
|
HAL_UART_IRQHandler(&huart5);
|
||||||
|
/* USER CODE BEGIN UART5_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN2 TX interrupt.
|
||||||
|
*/
|
||||||
|
void CAN2_TX_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN2_TX_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_TX_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan2);
|
||||||
|
/* USER CODE BEGIN CAN2_TX_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_TX_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN2 RX1 interrupt.
|
||||||
|
*/
|
||||||
|
void CAN2_RX1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN2_RX1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_RX1_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan2);
|
||||||
|
/* USER CODE BEGIN CAN2_RX1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN2_RX1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
176
Core/Src/syscalls.c
Executable file
176
Core/Src/syscalls.c
Executable file
@@ -0,0 +1,176 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file syscalls.c
|
||||||
|
* @author Auto-generated by STM32CubeIDE
|
||||||
|
* @brief STM32CubeIDE Minimal System calls file
|
||||||
|
*
|
||||||
|
* For more information about which c-functions
|
||||||
|
* need which of these lowlevel functions
|
||||||
|
* please consult the Newlib libc-manual
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020-2023 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/times.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Variables */
|
||||||
|
extern int __io_putchar(int ch) __attribute__((weak));
|
||||||
|
extern int __io_getchar(void) __attribute__((weak));
|
||||||
|
|
||||||
|
|
||||||
|
char *__env[1] = { 0 };
|
||||||
|
char **environ = __env;
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions */
|
||||||
|
void initialise_monitor_handles()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _getpid(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _kill(int pid, int sig)
|
||||||
|
{
|
||||||
|
(void)pid;
|
||||||
|
(void)sig;
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _exit (int status)
|
||||||
|
{
|
||||||
|
_kill(status, -1);
|
||||||
|
while (1) {} /* Make sure we hang here */
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) int _read(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
int DataIdx;
|
||||||
|
|
||||||
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||||
|
{
|
||||||
|
*ptr++ = __io_getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) int _write(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
int DataIdx;
|
||||||
|
|
||||||
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||||
|
{
|
||||||
|
__io_putchar(*ptr++);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _close(int file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int _fstat(int file, struct stat *st)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _isatty(int file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _lseek(int file, int ptr, int dir)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
(void)ptr;
|
||||||
|
(void)dir;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _open(char *path, int flags, ...)
|
||||||
|
{
|
||||||
|
(void)path;
|
||||||
|
(void)flags;
|
||||||
|
/* Pretend like we always fail */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _wait(int *status)
|
||||||
|
{
|
||||||
|
(void)status;
|
||||||
|
errno = ECHILD;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _unlink(char *name)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _times(struct tms *buf)
|
||||||
|
{
|
||||||
|
(void)buf;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _stat(char *file, struct stat *st)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _link(char *old, char *new)
|
||||||
|
{
|
||||||
|
(void)old;
|
||||||
|
(void)new;
|
||||||
|
errno = EMLINK;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fork(void)
|
||||||
|
{
|
||||||
|
errno = EAGAIN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _execve(char *name, char **argv, char **env)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
(void)argv;
|
||||||
|
(void)env;
|
||||||
|
errno = ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
79
Core/Src/sysmem.c
Executable file
79
Core/Src/sysmem.c
Executable file
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file sysmem.c
|
||||||
|
* @author Generated by STM32CubeIDE
|
||||||
|
* @brief STM32CubeIDE System Memory calls file
|
||||||
|
*
|
||||||
|
* For more information about which C functions
|
||||||
|
* need which of these lowlevel functions
|
||||||
|
* please consult the newlib libc manual
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes */
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the current high watermark of the heap usage
|
||||||
|
*/
|
||||||
|
static uint8_t *__sbrk_heap_end = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief _sbrk() allocates memory to the newlib heap and is used by malloc
|
||||||
|
* and others from the C library
|
||||||
|
*
|
||||||
|
* @verbatim
|
||||||
|
* ############################################################################
|
||||||
|
* # .data # .bss # newlib heap # MSP stack #
|
||||||
|
* # # # # Reserved by _Min_Stack_Size #
|
||||||
|
* ############################################################################
|
||||||
|
* ^-- RAM start ^-- _end _estack, RAM end --^
|
||||||
|
* @endverbatim
|
||||||
|
*
|
||||||
|
* This implementation starts allocating at the '_end' linker symbol
|
||||||
|
* The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
|
||||||
|
* The implementation considers '_estack' linker symbol to be RAM end
|
||||||
|
* NOTE: If the MSP stack, at any point during execution, grows larger than the
|
||||||
|
* reserved size, please increase the '_Min_Stack_Size'.
|
||||||
|
*
|
||||||
|
* @param incr Memory size
|
||||||
|
* @return Pointer to allocated memory
|
||||||
|
*/
|
||||||
|
void *_sbrk(ptrdiff_t incr)
|
||||||
|
{
|
||||||
|
extern uint8_t _end; /* Symbol defined in the linker script */
|
||||||
|
extern uint8_t _estack; /* Symbol defined in the linker script */
|
||||||
|
extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
|
||||||
|
const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
|
||||||
|
const uint8_t *max_heap = (uint8_t *)stack_limit;
|
||||||
|
uint8_t *prev_heap_end;
|
||||||
|
|
||||||
|
/* Initialize heap end at first call */
|
||||||
|
if (NULL == __sbrk_heap_end)
|
||||||
|
{
|
||||||
|
__sbrk_heap_end = &_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Protect heap from growing into the reserved MSP stack */
|
||||||
|
if (__sbrk_heap_end + incr > max_heap)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return (void *)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_heap_end = __sbrk_heap_end;
|
||||||
|
__sbrk_heap_end += incr;
|
||||||
|
|
||||||
|
return (void *)prev_heap_end;
|
||||||
|
}
|
||||||
406
Core/Src/system_stm32f1xx.c
Executable file
406
Core/Src/system_stm32f1xx.c
Executable file
@@ -0,0 +1,406 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file system_stm32f1xx.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
|
||||||
|
*
|
||||||
|
* 1. This file provides two functions and one global variable to be called from
|
||||||
|
* user application:
|
||||||
|
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
|
||||||
|
* factors, AHB/APBx prescalers and Flash settings).
|
||||||
|
* This function is called at startup just after reset and
|
||||||
|
* before branch to main program. This call is made inside
|
||||||
|
* the "startup_stm32f1xx_xx.s" file.
|
||||||
|
*
|
||||||
|
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||||
|
* by the user application to setup the SysTick
|
||||||
|
* timer or configure other parameters.
|
||||||
|
*
|
||||||
|
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||||
|
* be called whenever the core clock is changed
|
||||||
|
* during program execution.
|
||||||
|
*
|
||||||
|
* 2. After each device reset the HSI (8 MHz) is used as system clock source.
|
||||||
|
* Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to
|
||||||
|
* configure the system clock before to branch to main program.
|
||||||
|
*
|
||||||
|
* 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on
|
||||||
|
* the product used), refer to "HSE_VALUE".
|
||||||
|
* When HSE is used as system clock source, directly or through PLL, and you
|
||||||
|
* are using different crystal you have to adapt the HSE value to your own
|
||||||
|
* configuration.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2021 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup CMSIS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup stm32f1xx_system
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_Includes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stm32f1xx.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_TypesDefinitions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_Defines
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (HSE_VALUE)
|
||||||
|
#define HSE_VALUE 8000000U /*!< Default value of the External oscillator in Hz.
|
||||||
|
This value can be provided and adapted by the user application. */
|
||||||
|
#endif /* HSE_VALUE */
|
||||||
|
|
||||||
|
#if !defined (HSI_VALUE)
|
||||||
|
#define HSI_VALUE 8000000U /*!< Default value of the Internal oscillator in Hz.
|
||||||
|
This value can be provided and adapted by the user application. */
|
||||||
|
#endif /* HSI_VALUE */
|
||||||
|
|
||||||
|
/*!< Uncomment the following line if you need to use external SRAM */
|
||||||
|
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||||
|
/* #define DATA_IN_ExtSRAM */
|
||||||
|
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
|
||||||
|
|
||||||
|
/* Note: Following vector table addresses must be defined in line with linker
|
||||||
|
configuration. */
|
||||||
|
/*!< Uncomment the following line if you need to relocate the vector table
|
||||||
|
anywhere in Flash or Sram, else the vector table is kept at the automatic
|
||||||
|
remap of boot address selected */
|
||||||
|
/* #define USER_VECT_TAB_ADDRESS */
|
||||||
|
|
||||||
|
#if defined(USER_VECT_TAB_ADDRESS)
|
||||||
|
/*!< Uncomment the following line if you need to relocate your vector Table
|
||||||
|
in Sram else user remap will be done in Flash. */
|
||||||
|
/* #define VECT_TAB_SRAM */
|
||||||
|
#if defined(VECT_TAB_SRAM)
|
||||||
|
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#else
|
||||||
|
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||||
|
This value must be a multiple of 0x200. */
|
||||||
|
#endif /* VECT_TAB_SRAM */
|
||||||
|
#endif /* USER_VECT_TAB_ADDRESS */
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_Variables
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This variable is updated in three ways:
|
||||||
|
1) by calling CMSIS function SystemCoreClockUpdate()
|
||||||
|
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
|
||||||
|
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
|
||||||
|
Note: If you use this function to configure the system clock; then there
|
||||||
|
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||||
|
variable is updated automatically.
|
||||||
|
*/
|
||||||
|
uint32_t SystemCoreClock = 16000000;
|
||||||
|
const uint8_t AHBPrescTable[16U] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||||
|
const uint8_t APBPrescTable[8U] = {0, 0, 0, 0, 1, 2, 3, 4};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_FunctionPrototypes
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||||
|
#ifdef DATA_IN_ExtSRAM
|
||||||
|
static void SystemInit_ExtMemCtl(void);
|
||||||
|
#endif /* DATA_IN_ExtSRAM */
|
||||||
|
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup STM32F1xx_System_Private_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup the microcontroller system
|
||||||
|
* Initialize the Embedded Flash Interface, the PLL and update the
|
||||||
|
* SystemCoreClock variable.
|
||||||
|
* @note This function should be used only after reset.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemInit (void)
|
||||||
|
{
|
||||||
|
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||||
|
#ifdef DATA_IN_ExtSRAM
|
||||||
|
SystemInit_ExtMemCtl();
|
||||||
|
#endif /* DATA_IN_ExtSRAM */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configure the Vector Table location -------------------------------------*/
|
||||||
|
#if defined(USER_VECT_TAB_ADDRESS)
|
||||||
|
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
|
||||||
|
#endif /* USER_VECT_TAB_ADDRESS */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update SystemCoreClock variable according to Clock Register Values.
|
||||||
|
* The SystemCoreClock variable contains the core clock (HCLK), it can
|
||||||
|
* be used by the user application to setup the SysTick timer or configure
|
||||||
|
* other parameters.
|
||||||
|
*
|
||||||
|
* @note Each time the core clock (HCLK) changes, this function must be called
|
||||||
|
* to update SystemCoreClock variable value. Otherwise, any configuration
|
||||||
|
* based on this variable will be incorrect.
|
||||||
|
*
|
||||||
|
* @note - The system frequency computed by this function is not the real
|
||||||
|
* frequency in the chip. It is calculated based on the predefined
|
||||||
|
* constant and the selected clock source:
|
||||||
|
*
|
||||||
|
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
|
||||||
|
*
|
||||||
|
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
|
||||||
|
*
|
||||||
|
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
|
||||||
|
* or HSI_VALUE(*) multiplied by the PLL factors.
|
||||||
|
*
|
||||||
|
* (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
|
||||||
|
* 8 MHz) but the real value may vary depending on the variations
|
||||||
|
* in voltage and temperature.
|
||||||
|
*
|
||||||
|
* (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
|
||||||
|
* 8 MHz or 25 MHz, depending on the product used), user has to ensure
|
||||||
|
* that HSE_VALUE is same as the real frequency of the crystal used.
|
||||||
|
* Otherwise, this function may have wrong result.
|
||||||
|
*
|
||||||
|
* - The result of this function could be not correct when using fractional
|
||||||
|
* value for HSE crystal.
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemCoreClockUpdate (void)
|
||||||
|
{
|
||||||
|
uint32_t tmp = 0U, pllmull = 0U, pllsource = 0U;
|
||||||
|
|
||||||
|
#if defined(STM32F105xC) || defined(STM32F107xC)
|
||||||
|
uint32_t prediv1source = 0U, prediv1factor = 0U, prediv2factor = 0U, pll2mull = 0U;
|
||||||
|
#endif /* STM32F105xC */
|
||||||
|
|
||||||
|
#if defined(STM32F100xB) || defined(STM32F100xE)
|
||||||
|
uint32_t prediv1factor = 0U;
|
||||||
|
#endif /* STM32F100xB or STM32F100xE */
|
||||||
|
|
||||||
|
/* Get SYSCLK source -------------------------------------------------------*/
|
||||||
|
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||||
|
|
||||||
|
switch (tmp)
|
||||||
|
{
|
||||||
|
case 0x00U: /* HSI used as system clock */
|
||||||
|
SystemCoreClock = HSI_VALUE;
|
||||||
|
break;
|
||||||
|
case 0x04U: /* HSE used as system clock */
|
||||||
|
SystemCoreClock = HSE_VALUE;
|
||||||
|
break;
|
||||||
|
case 0x08U: /* PLL used as system clock */
|
||||||
|
|
||||||
|
/* Get PLL clock source and multiplication factor ----------------------*/
|
||||||
|
pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
|
||||||
|
pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
|
||||||
|
|
||||||
|
#if !defined(STM32F105xC) && !defined(STM32F107xC)
|
||||||
|
pllmull = ( pllmull >> 18U) + 2U;
|
||||||
|
|
||||||
|
if (pllsource == 0x00U)
|
||||||
|
{
|
||||||
|
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
|
||||||
|
SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if defined(STM32F100xB) || defined(STM32F100xE)
|
||||||
|
prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
|
||||||
|
/* HSE oscillator clock selected as PREDIV1 clock entry */
|
||||||
|
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
|
||||||
|
#else
|
||||||
|
/* HSE selected as PLL clock entry */
|
||||||
|
if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
|
||||||
|
{/* HSE oscillator clock divided by 2 */
|
||||||
|
SystemCoreClock = (HSE_VALUE >> 1U) * pllmull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SystemCoreClock = HSE_VALUE * pllmull;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pllmull = pllmull >> 18U;
|
||||||
|
|
||||||
|
if (pllmull != 0x0DU)
|
||||||
|
{
|
||||||
|
pllmull += 2U;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* PLL multiplication factor = PLL input clock * 6.5 */
|
||||||
|
pllmull = 13U / 2U;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pllsource == 0x00U)
|
||||||
|
{
|
||||||
|
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
|
||||||
|
SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{/* PREDIV1 selected as PLL clock entry */
|
||||||
|
|
||||||
|
/* Get PREDIV1 clock source and division factor */
|
||||||
|
prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
|
||||||
|
prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
|
||||||
|
|
||||||
|
if (prediv1source == 0U)
|
||||||
|
{
|
||||||
|
/* HSE oscillator clock selected as PREDIV1 clock entry */
|
||||||
|
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{/* PLL2 clock selected as PREDIV1 clock entry */
|
||||||
|
|
||||||
|
/* Get PREDIV2 division factor and PLL2 multiplication factor */
|
||||||
|
prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4U) + 1U;
|
||||||
|
pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8U) + 2U;
|
||||||
|
SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* STM32F105xC */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
SystemCoreClock = HSI_VALUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute HCLK clock frequency ----------------*/
|
||||||
|
/* Get HCLK prescaler */
|
||||||
|
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
|
||||||
|
/* HCLK clock frequency */
|
||||||
|
SystemCoreClock >>= tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||||
|
/**
|
||||||
|
* @brief Setup the external memory controller. Called in startup_stm32f1xx.s
|
||||||
|
* before jump to __main
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#ifdef DATA_IN_ExtSRAM
|
||||||
|
/**
|
||||||
|
* @brief Setup the external memory controller.
|
||||||
|
* Called in startup_stm32f1xx_xx.s/.c before jump to main.
|
||||||
|
* This function configures the external SRAM mounted on STM3210E-EVAL
|
||||||
|
* board (STM32 High density devices). This SRAM will be used as program
|
||||||
|
* data memory (including heap and stack).
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void SystemInit_ExtMemCtl(void)
|
||||||
|
{
|
||||||
|
__IO uint32_t tmpreg;
|
||||||
|
/*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is
|
||||||
|
required, then adjust the Register Addresses */
|
||||||
|
|
||||||
|
/* Enable FSMC clock */
|
||||||
|
RCC->AHBENR = 0x00000114U;
|
||||||
|
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);
|
||||||
|
|
||||||
|
/* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
|
||||||
|
RCC->APB2ENR = 0x000001E0U;
|
||||||
|
|
||||||
|
/* Delay after an RCC peripheral clock enabling */
|
||||||
|
tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);
|
||||||
|
|
||||||
|
(void)(tmpreg);
|
||||||
|
|
||||||
|
/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/
|
||||||
|
/*---------------- SRAM Address lines configuration -------------------------*/
|
||||||
|
/*---------------- NOE and NWE configuration --------------------------------*/
|
||||||
|
/*---------------- NE3 configuration ----------------------------------------*/
|
||||||
|
/*---------------- NBL0, NBL1 configuration ---------------------------------*/
|
||||||
|
|
||||||
|
GPIOD->CRL = 0x44BB44BBU;
|
||||||
|
GPIOD->CRH = 0xBBBBBBBBU;
|
||||||
|
|
||||||
|
GPIOE->CRL = 0xB44444BBU;
|
||||||
|
GPIOE->CRH = 0xBBBBBBBBU;
|
||||||
|
|
||||||
|
GPIOF->CRL = 0x44BBBBBBU;
|
||||||
|
GPIOF->CRH = 0xBBBB4444U;
|
||||||
|
|
||||||
|
GPIOG->CRL = 0x44BBBBBBU;
|
||||||
|
GPIOG->CRH = 0x444B4B44U;
|
||||||
|
|
||||||
|
/*---------------- FSMC Configuration ---------------------------------------*/
|
||||||
|
/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
|
||||||
|
|
||||||
|
FSMC_Bank1->BTCR[4U] = 0x00001091U;
|
||||||
|
FSMC_Bank1->BTCR[5U] = 0x00110212U;
|
||||||
|
}
|
||||||
|
#endif /* DATA_IN_ExtSRAM */
|
||||||
|
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
267
Core/Src/tim.c
Normal file
267
Core/Src/tim.c
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the TIM instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
TIM_HandleTypeDef htim3;
|
||||||
|
TIM_HandleTypeDef htim4;
|
||||||
|
|
||||||
|
/* TIM3 init function */
|
||||||
|
void MX_TIM3_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_Init 0 */
|
||||||
|
|
||||||
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_Init 1 */
|
||||||
|
htim3.Instance = TIM3;
|
||||||
|
htim3.Init.Prescaler = 0;
|
||||||
|
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim3.Init.Period = 65535;
|
||||||
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
|
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_OC_Init(&htim3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
|
sConfigOC.Pulse = 0;
|
||||||
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_TIMING;
|
||||||
|
sConfigOC.Pulse = 1;
|
||||||
|
if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM3_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_Init 2 */
|
||||||
|
HAL_TIM_MspPostInit(&htim3);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* TIM4 init function */
|
||||||
|
void MX_TIM4_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM4_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_Init 0 */
|
||||||
|
|
||||||
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM4_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_Init 1 */
|
||||||
|
htim4.Instance = TIM4;
|
||||||
|
htim4.Init.Prescaler = 720;
|
||||||
|
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim4.Init.Period = 100;
|
||||||
|
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
|
if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_PWM_Init(&htim4) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
|
sConfigOC.Pulse = 0;
|
||||||
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM4_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_Init 2 */
|
||||||
|
HAL_TIM_MspPostInit(&htim4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_baseHandle->Instance==TIM3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspInit 0 */
|
||||||
|
/* TIM3 clock enable */
|
||||||
|
__HAL_RCC_TIM3_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* TIM3 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(TIM3_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM3_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspInit 1 */
|
||||||
|
}
|
||||||
|
else if(tim_baseHandle->Instance==TIM4)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM4_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspInit 0 */
|
||||||
|
/* TIM4 clock enable */
|
||||||
|
__HAL_RCC_TIM4_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN TIM4_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(timHandle->Instance==TIM3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_MspPostInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspPostInit 0 */
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**TIM3 GPIO Configuration
|
||||||
|
PA7 ------> TIM3_CH2
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = CP_PWM_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(CP_PWM_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_MspPostInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspPostInit 1 */
|
||||||
|
}
|
||||||
|
else if(timHandle->Instance==TIM4)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM4_MspPostInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspPostInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
/**TIM4 GPIO Configuration
|
||||||
|
PD13 ------> TIM4_CH2
|
||||||
|
PD14 ------> TIM4_CH3
|
||||||
|
PD15 ------> TIM4_CH4
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
__HAL_AFIO_REMAP_TIM4_ENABLE();
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM4_MspPostInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspPostInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_baseHandle->Instance==TIM3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM3_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM3_CLK_DISABLE();
|
||||||
|
|
||||||
|
/* TIM3 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(TIM3_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM3_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM3_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
else if(tim_baseHandle->Instance==TIM4)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM4_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM4_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN TIM4_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
368
Core/Src/usart.c
Normal file
368
Core/Src/usart.c
Normal file
@@ -0,0 +1,368 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file usart.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the USART instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "usart.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
UART_HandleTypeDef huart5;
|
||||||
|
UART_HandleTypeDef huart1;
|
||||||
|
UART_HandleTypeDef huart2;
|
||||||
|
UART_HandleTypeDef huart3;
|
||||||
|
|
||||||
|
/* UART5 init function */
|
||||||
|
void MX_UART5_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN UART5_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN UART5_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_Init 1 */
|
||||||
|
huart5.Instance = UART5;
|
||||||
|
huart5.Init.BaudRate = 9600;
|
||||||
|
huart5.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart5.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart5.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart5.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart5.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
if (HAL_UART_Init(&huart5) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN UART5_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
/* USART1 init function */
|
||||||
|
|
||||||
|
void MX_USART1_UART_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 1 */
|
||||||
|
huart1.Instance = USART1;
|
||||||
|
huart1.Init.BaudRate = 115200;
|
||||||
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart1.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart1.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
if (HAL_UART_Init(&huart1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN USART1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
/* USART2 init function */
|
||||||
|
|
||||||
|
void MX_USART2_UART_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_Init 1 */
|
||||||
|
huart2.Instance = USART2;
|
||||||
|
huart2.Init.BaudRate = 115200;
|
||||||
|
huart2.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart2.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart2.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart2.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
if (HAL_UART_Init(&huart2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN USART2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
/* USART3 init function */
|
||||||
|
|
||||||
|
void MX_USART3_UART_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART3_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN USART3_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_Init 1 */
|
||||||
|
huart3.Instance = USART3;
|
||||||
|
huart3.Init.BaudRate = 115200;
|
||||||
|
huart3.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart3.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart3.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart3.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
if (HAL_UART_Init(&huart3) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN USART3_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(uartHandle->Instance==UART5)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN UART5_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_MspInit 0 */
|
||||||
|
/* UART5 clock enable */
|
||||||
|
__HAL_RCC_UART5_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
/**UART5 GPIO Configuration
|
||||||
|
PC12 ------> UART5_TX
|
||||||
|
PD2 ------> UART5_RX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* UART5 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(UART5_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(UART5_IRQn);
|
||||||
|
/* USER CODE BEGIN UART5_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_MspInit 1 */
|
||||||
|
}
|
||||||
|
else if(uartHandle->Instance==USART1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspInit 0 */
|
||||||
|
/* USART1 clock enable */
|
||||||
|
__HAL_RCC_USART1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**USART1 GPIO Configuration
|
||||||
|
PA9 ------> USART1_TX
|
||||||
|
PA10 ------> USART1_RX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_9;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USART1 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||||
|
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspInit 1 */
|
||||||
|
}
|
||||||
|
else if(uartHandle->Instance==USART2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART2_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_MspInit 0 */
|
||||||
|
/* USART2 clock enable */
|
||||||
|
__HAL_RCC_USART2_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
/**USART2 GPIO Configuration
|
||||||
|
PD5 ------> USART2_TX
|
||||||
|
PD6 ------> USART2_RX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_5;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
__HAL_AFIO_REMAP_USART2_ENABLE();
|
||||||
|
|
||||||
|
/* USART2 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||||
|
/* USER CODE BEGIN USART2_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_MspInit 1 */
|
||||||
|
}
|
||||||
|
else if(uartHandle->Instance==USART3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART3_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_MspInit 0 */
|
||||||
|
/* USART3 clock enable */
|
||||||
|
__HAL_RCC_USART3_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
/**USART3 GPIO Configuration
|
||||||
|
PC10 ------> USART3_TX
|
||||||
|
PC11 ------> USART3_RX
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
__HAL_AFIO_REMAP_USART3_PARTIAL();
|
||||||
|
|
||||||
|
/* USART3 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(USART3_IRQn);
|
||||||
|
/* USER CODE BEGIN USART3_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(uartHandle->Instance==UART5)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN UART5_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_UART5_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**UART5 GPIO Configuration
|
||||||
|
PC12 ------> UART5_TX
|
||||||
|
PD2 ------> UART5_RX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
|
||||||
|
|
||||||
|
/* UART5 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(UART5_IRQn);
|
||||||
|
/* USER CODE BEGIN UART5_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END UART5_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
else if(uartHandle->Instance==USART1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_USART1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**USART1 GPIO Configuration
|
||||||
|
PA9 ------> USART1_TX
|
||||||
|
PA10 ------> USART1_RX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
|
||||||
|
|
||||||
|
/* USART1 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||||
|
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
else if(uartHandle->Instance==USART2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART2_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_USART2_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**USART2 GPIO Configuration
|
||||||
|
PD5 ------> USART2_TX
|
||||||
|
PD6 ------> USART2_RX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_5|GPIO_PIN_6);
|
||||||
|
|
||||||
|
/* USART2 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
||||||
|
/* USER CODE BEGIN USART2_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART2_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
else if(uartHandle->Instance==USART3)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN USART3_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_USART3_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**USART3 GPIO Configuration
|
||||||
|
PC10 ------> USART3_TX
|
||||||
|
PC11 ------> USART3_RX
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
|
||||||
|
|
||||||
|
/* USART3 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(USART3_IRQn);
|
||||||
|
/* USER CODE BEGIN USART3_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END USART3_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
474
Core/Startup/startup_stm32f107vctx.s
Executable file
474
Core/Startup/startup_stm32f107vctx.s
Executable file
@@ -0,0 +1,474 @@
|
|||||||
|
/**
|
||||||
|
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
||||||
|
* @file startup_stm32f107xc.s
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief STM32F107xC Devices vector table for Atollic toolchain.
|
||||||
|
* This module performs:
|
||||||
|
* - Set the initial SP
|
||||||
|
* - Set the initial PC == Reset_Handler,
|
||||||
|
* - Set the vector table entries with the exceptions ISR address
|
||||||
|
* - Configure the clock system
|
||||||
|
* - Branches to main in the C library (which eventually
|
||||||
|
* calls main()).
|
||||||
|
* After Reset the Cortex-M3 processor is in Thread mode,
|
||||||
|
* priority is Privileged, and the Stack is set to Main.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2021 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.cpu cortex-m3
|
||||||
|
.fpu softvfp
|
||||||
|
.thumb
|
||||||
|
|
||||||
|
.global g_pfnVectors
|
||||||
|
.global Default_Handler
|
||||||
|
|
||||||
|
/* start address for the initialization values of the .data section.
|
||||||
|
defined in linker script */
|
||||||
|
.word _sidata
|
||||||
|
/* start address for the .data section. defined in linker script */
|
||||||
|
.word _sdata
|
||||||
|
/* end address for the .data section. defined in linker script */
|
||||||
|
.word _edata
|
||||||
|
/* start address for the .bss section. defined in linker script */
|
||||||
|
.word _sbss
|
||||||
|
/* end address for the .bss section. defined in linker script */
|
||||||
|
.word _ebss
|
||||||
|
|
||||||
|
.equ BootRAM, 0xF1E0F85F
|
||||||
|
/**
|
||||||
|
* @brief This is the code that gets called when the processor first
|
||||||
|
* starts execution following a reset event. Only the absolutely
|
||||||
|
* necessary set is performed, after which the application
|
||||||
|
* supplied main() routine is called.
|
||||||
|
* @param None
|
||||||
|
* @retval : None
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .text.Reset_Handler
|
||||||
|
.weak Reset_Handler
|
||||||
|
.type Reset_Handler, %function
|
||||||
|
Reset_Handler:
|
||||||
|
ldr sp, =_estack /* set stack pointer */
|
||||||
|
|
||||||
|
/* Call the clock system initialization function.*/
|
||||||
|
bl SystemInit
|
||||||
|
|
||||||
|
/* Copy the data segment initializers from flash to SRAM */
|
||||||
|
ldr r0, =_sdata
|
||||||
|
ldr r1, =_edata
|
||||||
|
ldr r2, =_sidata
|
||||||
|
movs r3, #0
|
||||||
|
b LoopCopyDataInit
|
||||||
|
|
||||||
|
CopyDataInit:
|
||||||
|
ldr r4, [r2, r3]
|
||||||
|
str r4, [r0, r3]
|
||||||
|
adds r3, r3, #4
|
||||||
|
|
||||||
|
LoopCopyDataInit:
|
||||||
|
adds r4, r0, r3
|
||||||
|
cmp r4, r1
|
||||||
|
bcc CopyDataInit
|
||||||
|
|
||||||
|
/* Zero fill the bss segment. */
|
||||||
|
ldr r2, =_sbss
|
||||||
|
ldr r4, =_ebss
|
||||||
|
movs r3, #0
|
||||||
|
b LoopFillZerobss
|
||||||
|
|
||||||
|
FillZerobss:
|
||||||
|
str r3, [r2]
|
||||||
|
adds r2, r2, #4
|
||||||
|
|
||||||
|
LoopFillZerobss:
|
||||||
|
cmp r2, r4
|
||||||
|
bcc FillZerobss
|
||||||
|
|
||||||
|
|
||||||
|
/* Call static constructors */
|
||||||
|
bl __libc_init_array
|
||||||
|
/* Call the application's entry point.*/
|
||||||
|
bl main
|
||||||
|
bx lr
|
||||||
|
.size Reset_Handler, .-Reset_Handler
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is the code that gets called when the processor receives an
|
||||||
|
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||||
|
* the system state for examination by a debugger.
|
||||||
|
*
|
||||||
|
* @param None
|
||||||
|
* @retval : None
|
||||||
|
*/
|
||||||
|
.section .text.Default_Handler,"ax",%progbits
|
||||||
|
Default_Handler:
|
||||||
|
Infinite_Loop:
|
||||||
|
b Infinite_Loop
|
||||||
|
.size Default_Handler, .-Default_Handler
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
||||||
|
* must be placed on this to ensure that it ends up at physical address
|
||||||
|
* 0x0000.0000.
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
.section .isr_vector,"a",%progbits
|
||||||
|
.type g_pfnVectors, %object
|
||||||
|
.size g_pfnVectors, .-g_pfnVectors
|
||||||
|
|
||||||
|
|
||||||
|
g_pfnVectors:
|
||||||
|
|
||||||
|
.word _estack
|
||||||
|
.word Reset_Handler
|
||||||
|
.word NMI_Handler
|
||||||
|
.word HardFault_Handler
|
||||||
|
.word MemManage_Handler
|
||||||
|
.word BusFault_Handler
|
||||||
|
.word UsageFault_Handler
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word SVC_Handler
|
||||||
|
.word DebugMon_Handler
|
||||||
|
.word 0
|
||||||
|
.word PendSV_Handler
|
||||||
|
.word SysTick_Handler
|
||||||
|
.word WWDG_IRQHandler
|
||||||
|
.word PVD_IRQHandler
|
||||||
|
.word TAMPER_IRQHandler
|
||||||
|
.word RTC_IRQHandler
|
||||||
|
.word FLASH_IRQHandler
|
||||||
|
.word RCC_IRQHandler
|
||||||
|
.word EXTI0_IRQHandler
|
||||||
|
.word EXTI1_IRQHandler
|
||||||
|
.word EXTI2_IRQHandler
|
||||||
|
.word EXTI3_IRQHandler
|
||||||
|
.word EXTI4_IRQHandler
|
||||||
|
.word DMA1_Channel1_IRQHandler
|
||||||
|
.word DMA1_Channel2_IRQHandler
|
||||||
|
.word DMA1_Channel3_IRQHandler
|
||||||
|
.word DMA1_Channel4_IRQHandler
|
||||||
|
.word DMA1_Channel5_IRQHandler
|
||||||
|
.word DMA1_Channel6_IRQHandler
|
||||||
|
.word DMA1_Channel7_IRQHandler
|
||||||
|
.word ADC1_2_IRQHandler
|
||||||
|
.word CAN1_TX_IRQHandler
|
||||||
|
.word CAN1_RX0_IRQHandler
|
||||||
|
.word CAN1_RX1_IRQHandler
|
||||||
|
.word CAN1_SCE_IRQHandler
|
||||||
|
.word EXTI9_5_IRQHandler
|
||||||
|
.word TIM1_BRK_IRQHandler
|
||||||
|
.word TIM1_UP_IRQHandler
|
||||||
|
.word TIM1_TRG_COM_IRQHandler
|
||||||
|
.word TIM1_CC_IRQHandler
|
||||||
|
.word TIM2_IRQHandler
|
||||||
|
.word TIM3_IRQHandler
|
||||||
|
.word TIM4_IRQHandler
|
||||||
|
.word I2C1_EV_IRQHandler
|
||||||
|
.word I2C1_ER_IRQHandler
|
||||||
|
.word I2C2_EV_IRQHandler
|
||||||
|
.word I2C2_ER_IRQHandler
|
||||||
|
.word SPI1_IRQHandler
|
||||||
|
.word SPI2_IRQHandler
|
||||||
|
.word USART1_IRQHandler
|
||||||
|
.word USART2_IRQHandler
|
||||||
|
.word USART3_IRQHandler
|
||||||
|
.word EXTI15_10_IRQHandler
|
||||||
|
.word RTC_Alarm_IRQHandler
|
||||||
|
.word OTG_FS_WKUP_IRQHandler
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word TIM5_IRQHandler
|
||||||
|
.word SPI3_IRQHandler
|
||||||
|
.word UART4_IRQHandler
|
||||||
|
.word UART5_IRQHandler
|
||||||
|
.word TIM6_IRQHandler
|
||||||
|
.word TIM7_IRQHandler
|
||||||
|
.word DMA2_Channel1_IRQHandler
|
||||||
|
.word DMA2_Channel2_IRQHandler
|
||||||
|
.word DMA2_Channel3_IRQHandler
|
||||||
|
.word DMA2_Channel4_IRQHandler
|
||||||
|
.word DMA2_Channel5_IRQHandler
|
||||||
|
.word ETH_IRQHandler
|
||||||
|
.word ETH_WKUP_IRQHandler
|
||||||
|
.word CAN2_TX_IRQHandler
|
||||||
|
.word CAN2_RX0_IRQHandler
|
||||||
|
.word CAN2_RX1_IRQHandler
|
||||||
|
.word CAN2_SCE_IRQHandler
|
||||||
|
.word OTG_FS_IRQHandler
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word 0
|
||||||
|
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
||||||
|
STM32F10x Connectivity line Devices. */
|
||||||
|
.word 0x66666666 /* Reserved for OpenBLT checksum*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
*
|
||||||
|
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||||
|
* As they are weak aliases, any function with the same name will override
|
||||||
|
* this definition.
|
||||||
|
*
|
||||||
|
*******************************************************************************/
|
||||||
|
.weak NMI_Handler
|
||||||
|
.thumb_set NMI_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak HardFault_Handler
|
||||||
|
.thumb_set HardFault_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak MemManage_Handler
|
||||||
|
.thumb_set MemManage_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak BusFault_Handler
|
||||||
|
.thumb_set BusFault_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak UsageFault_Handler
|
||||||
|
.thumb_set UsageFault_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak SVC_Handler
|
||||||
|
.thumb_set SVC_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak DebugMon_Handler
|
||||||
|
.thumb_set DebugMon_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak PendSV_Handler
|
||||||
|
.thumb_set PendSV_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak SysTick_Handler
|
||||||
|
.thumb_set SysTick_Handler,Default_Handler
|
||||||
|
|
||||||
|
.weak WWDG_IRQHandler
|
||||||
|
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak PVD_IRQHandler
|
||||||
|
.thumb_set PVD_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TAMPER_IRQHandler
|
||||||
|
.thumb_set TAMPER_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak RTC_IRQHandler
|
||||||
|
.thumb_set RTC_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak FLASH_IRQHandler
|
||||||
|
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak RCC_IRQHandler
|
||||||
|
.thumb_set RCC_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI0_IRQHandler
|
||||||
|
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI1_IRQHandler
|
||||||
|
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI2_IRQHandler
|
||||||
|
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI3_IRQHandler
|
||||||
|
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI4_IRQHandler
|
||||||
|
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel1_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel2_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel3_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel4_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel5_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel6_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA1_Channel7_IRQHandler
|
||||||
|
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak ADC1_2_IRQHandler
|
||||||
|
.thumb_set ADC1_2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN1_TX_IRQHandler
|
||||||
|
.thumb_set CAN1_TX_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN1_RX0_IRQHandler
|
||||||
|
.thumb_set CAN1_RX0_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN1_RX1_IRQHandler
|
||||||
|
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN1_SCE_IRQHandler
|
||||||
|
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI9_5_IRQHandler
|
||||||
|
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM1_BRK_IRQHandler
|
||||||
|
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM1_UP_IRQHandler
|
||||||
|
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM1_TRG_COM_IRQHandler
|
||||||
|
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM1_CC_IRQHandler
|
||||||
|
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM2_IRQHandler
|
||||||
|
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM3_IRQHandler
|
||||||
|
.thumb_set TIM3_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM4_IRQHandler
|
||||||
|
.thumb_set TIM4_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak I2C1_EV_IRQHandler
|
||||||
|
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak I2C1_ER_IRQHandler
|
||||||
|
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak I2C2_EV_IRQHandler
|
||||||
|
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak I2C2_ER_IRQHandler
|
||||||
|
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak SPI1_IRQHandler
|
||||||
|
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak SPI2_IRQHandler
|
||||||
|
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak USART1_IRQHandler
|
||||||
|
.thumb_set USART1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak USART2_IRQHandler
|
||||||
|
.thumb_set USART2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak USART3_IRQHandler
|
||||||
|
.thumb_set USART3_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak EXTI15_10_IRQHandler
|
||||||
|
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak RTC_Alarm_IRQHandler
|
||||||
|
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak OTG_FS_WKUP_IRQHandler
|
||||||
|
.thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM5_IRQHandler
|
||||||
|
.thumb_set TIM5_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak SPI3_IRQHandler
|
||||||
|
.thumb_set SPI3_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak UART4_IRQHandler
|
||||||
|
.thumb_set UART4_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak UART5_IRQHandler
|
||||||
|
.thumb_set UART5_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM6_IRQHandler
|
||||||
|
.thumb_set TIM6_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak TIM7_IRQHandler
|
||||||
|
.thumb_set TIM7_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA2_Channel1_IRQHandler
|
||||||
|
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA2_Channel2_IRQHandler
|
||||||
|
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA2_Channel3_IRQHandler
|
||||||
|
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA2_Channel4_IRQHandler
|
||||||
|
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak DMA2_Channel5_IRQHandler
|
||||||
|
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak ETH_IRQHandler
|
||||||
|
.thumb_set ETH_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak ETH_WKUP_IRQHandler
|
||||||
|
.thumb_set ETH_WKUP_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN2_TX_IRQHandler
|
||||||
|
.thumb_set CAN2_TX_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN2_RX0_IRQHandler
|
||||||
|
.thumb_set CAN2_RX0_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN2_RX1_IRQHandler
|
||||||
|
.thumb_set CAN2_RX1_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak CAN2_SCE_IRQHandler
|
||||||
|
.thumb_set CAN2_SCE_IRQHandler,Default_Handler
|
||||||
|
|
||||||
|
.weak OTG_FS_IRQHandler
|
||||||
|
.thumb_set OTG_FS_IRQHandler ,Default_Handler
|
||||||
|
|
||||||
BIN
Debug/.DS_Store
vendored
Normal file
BIN
Debug/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Debug/CCSModuleSW30Web.bin
Executable file
BIN
Debug/CCSModuleSW30Web.bin
Executable file
Binary file not shown.
33115
Debug/CCSModuleSW30Web.list
Normal file
33115
Debug/CCSModuleSW30Web.list
Normal file
File diff suppressed because it is too large
Load Diff
3683
Debug/CCSModuleSW30Web.srec
Executable file
3683
Debug/CCSModuleSW30Web.srec
Executable file
File diff suppressed because it is too large
Load Diff
BIN
Debug/Core/.DS_Store
vendored
Normal file
BIN
Debug/Core/.DS_Store
vendored
Normal file
Binary file not shown.
3
Debug/Core/Src/adc.cyclo
Normal file
3
Debug/Core/Src/adc.cyclo
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
../Core/Src/adc.c:30:6:MX_ADC1_Init 3
|
||||||
|
../Core/Src/adc.c:72:6:HAL_ADC_MspInit 2
|
||||||
|
../Core/Src/adc.c:106:6:HAL_ADC_MspDeInit 2
|
||||||
13
Debug/Core/Src/board.cyclo
Normal file
13
Debug/Core/Src/board.cyclo
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
../Core/Src/board.c:19:6:RELAY_Write 9
|
||||||
|
../Core/Src/board.c:52:9:RELAY_Read 1
|
||||||
|
../Core/Src/board.c:57:9:IN_ReadInput 8
|
||||||
|
../Core/Src/board.c:78:9:GetBoardTemp 1
|
||||||
|
../Core/Src/board.c:90:6:Init_Peripheral 1
|
||||||
|
../Core/Src/board.c:106:7:pt1000_to_temperature 1
|
||||||
|
../Core/Src/board.c:117:7:calculate_NTC_resistance 2
|
||||||
|
../Core/Src/board.c:132:9:CONN_ReadTemp 4
|
||||||
|
../Core/Src/board.c:169:9:GBT_ReadTemp 1
|
||||||
|
../Core/Src/board.c:173:6:ADC_Select_Channel 2
|
||||||
|
../Core/Src/board.c:184:9:ADC_TryLock 4
|
||||||
|
../Core/Src/board.c:200:6:ADC_LockBlocking 2
|
||||||
|
../Core/Src/board.c:206:6:ADC_Unlock 2
|
||||||
4
Debug/Core/Src/can.cyclo
Normal file
4
Debug/Core/Src/can.cyclo
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
../Core/Src/can.c:31:6:MX_CAN1_Init 2
|
||||||
|
../Core/Src/can.c:63:6:MX_CAN2_Init 2
|
||||||
|
../Core/Src/can.c:97:6:HAL_CAN_MspInit 5
|
||||||
|
../Core/Src/can.c:176:6:HAL_CAN_MspDeInit 5
|
||||||
5
Debug/Core/Src/charger_control.cyclo
Normal file
5
Debug/Core/Src/charger_control.cyclo
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
../Core/Src/charger_control.c:11:6:CONN_Init 1
|
||||||
|
../Core/Src/charger_control.c:19:6:CONN_Loop 6
|
||||||
|
../Core/Src/charger_control.c:41:6:CONN_Task 5
|
||||||
|
../Core/Src/charger_control.c:57:6:CONN_SetState 16
|
||||||
|
../Core/Src/charger_control.c:83:6:CONN_PrintChargingTotal 1
|
||||||
2
Debug/Core/Src/connector.cyclo
Normal file
2
Debug/Core/Src/connector.cyclo
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
../Core/Src/connector.c:12:6:CONN_Task 5
|
||||||
|
../Core/Src/connector.c:28:6:CONN_SetState 16
|
||||||
9
Debug/Core/Src/cp.cyclo
Normal file
9
Debug/Core/Src/cp.cyclo
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
../Core/Src/cp.c:13:17:CP_ReadAdcChannel 1
|
||||||
|
../Core/Src/cp.c:26:16:CP_ReadVoltageMv 1
|
||||||
|
../Core/Src/cp.c:39:6:CP_Init 1
|
||||||
|
../Core/Src/cp.c:56:6:CP_SetDuty 1
|
||||||
|
../Core/Src/cp.c:69:9:CP_GetDuty 1
|
||||||
|
../Core/Src/cp.c:73:9:CP_GetVoltage 1
|
||||||
|
../Core/Src/cp.c:77:12:CP_GetState 12
|
||||||
|
../Core/Src/cp.c:101:6:CP_Loop 1
|
||||||
|
../Core/Src/cp.c:105:6:HAL_TIM_OC_DelayElapsedCallback 4
|
||||||
3
Debug/Core/Src/crc.cyclo
Normal file
3
Debug/Core/Src/crc.cyclo
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
../Core/Src/crc.c:30:6:MX_CRC_Init 2
|
||||||
|
../Core/Src/crc.c:51:6:HAL_CRC_MspInit 2
|
||||||
|
../Core/Src/crc.c:67:6:HAL_CRC_MspDeInit 2
|
||||||
5
Debug/Core/Src/debug.cyclo
Normal file
5
Debug/Core/Src/debug.cyclo
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
../Core/Src/debug.c:42:5:_write 1
|
||||||
|
../Core/Src/debug.c:50:6:debug_buffer_add 3
|
||||||
|
../Core/Src/debug.c:70:10:debug_buffer_available 1
|
||||||
|
../Core/Src/debug.c:79:6:debug_buffer_send 5
|
||||||
|
../Core/Src/debug.c:119:5:log_printf 3
|
||||||
0
Debug/Core/Src/edcan_handler_user.cyclo
Normal file
0
Debug/Core/Src/edcan_handler_user.cyclo
Normal file
3
Debug/Core/Src/gbt_control.cyclo
Normal file
3
Debug/Core/Src/gbt_control.cyclo
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
../Core/Src/gbt_control.c:10:6:GBT_SetConfig 1
|
||||||
|
../Core/Src/gbt_control.c:24:6:GBT_ControlRead 1
|
||||||
|
../Core/Src/gbt_control.c:33:6:GBT_ControlWrite 2
|
||||||
1
Debug/Core/Src/gpio.cyclo
Normal file
1
Debug/Core/Src/gpio.cyclo
Normal file
@@ -0,0 +1 @@
|
|||||||
|
../Core/Src/gpio.c:44:6:MX_GPIO_Init 1
|
||||||
8
Debug/Core/Src/main.cyclo
Normal file
8
Debug/Core/Src/main.cyclo
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
../Core/Src/main.c:64:13:VectorBase_Config 1
|
||||||
|
../Core/Src/main.c:75:9:ED_TraceWarning 3
|
||||||
|
../Core/Src/main.c:87:6:ED_Delay 3
|
||||||
|
../Core/Src/main.c:106:6:StopButtonControl 2
|
||||||
|
../Core/Src/main.c:117:13:CAN1_MinimalReInit 3
|
||||||
|
../Core/Src/main.c:135:5:main 1
|
||||||
|
../Core/Src/main.c:216:6:SystemClock_Config 4
|
||||||
|
../Core/Src/main.c:276:6:Error_Handler 1
|
||||||
1
Debug/Core/Src/meter.cyclo
Normal file
1
Debug/Core/Src/meter.cyclo
Normal file
@@ -0,0 +1 @@
|
|||||||
|
../Core/Src/meter.c:17:6:METER_CalculateEnergy 3
|
||||||
12
Debug/Core/Src/psu_control.cyclo
Normal file
12
Debug/Core/Src/psu_control.cyclo
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
../Core/Src/psu_control.c:33:13:PSU_SwitchState 1
|
||||||
|
../Core/Src/psu_control.c:38:17:PSU_StateTime 1
|
||||||
|
../Core/Src/psu_control.c:42:6:HAL_CAN_RxFifo1MsgPendingCallback 9
|
||||||
|
../Core/Src/psu_control.c:116:6:PSU_CAN_FilterInit 2
|
||||||
|
../Core/Src/psu_control.c:139:6:PSU_Init 1
|
||||||
|
../Core/Src/psu_control.c:156:6:PSU_Enable 3
|
||||||
|
../Core/Src/psu_control.c:168:6:PSU_SetHVMode 2
|
||||||
|
../Core/Src/psu_control.c:175:6:PSU_SetVoltageCurrent 5
|
||||||
|
../Core/Src/psu_control.c:202:6:PSU_SendCmd 4
|
||||||
|
../Core/Src/psu_control.c:238:10:max 2
|
||||||
|
../Core/Src/psu_control.c:243:6:PSU_ReadWrite 5
|
||||||
|
../Core/Src/psu_control.c:276:6:PSU_Task 41
|
||||||
6
Debug/Core/Src/rgb_controller.cyclo
Normal file
6
Debug/Core/Src/rgb_controller.cyclo
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
../Core/Src/rgb_controller.c:92:6:LED_Write 16
|
||||||
|
../Core/Src/rgb_controller.c:146:6:interpolateColors 3
|
||||||
|
../Core/Src/rgb_controller.c:164:6:RGB_SetColor 1
|
||||||
|
../Core/Src/rgb_controller.c:170:6:LED_SetColor 1
|
||||||
|
../Core/Src/rgb_controller.c:175:6:LED_Init 1
|
||||||
|
../Core/Src/rgb_controller.c:207:6:LED_Task 10
|
||||||
3
Debug/Core/Src/rtc.cyclo
Normal file
3
Debug/Core/Src/rtc.cyclo
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
../Core/Src/rtc.c:14:6:MX_RTC_Init 2
|
||||||
|
../Core/Src/rtc.c:40:6:HAL_RTC_MspInit 2
|
||||||
|
../Core/Src/rtc.c:59:6:HAL_RTC_MspDeInit 2
|
||||||
15
Debug/Core/Src/serial.cyclo
Normal file
15
Debug/Core/Src/serial.cyclo
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
|
||||||
|
../Core/Src/serial.c:51:6:CCS_RxEventCallback 4
|
||||||
|
../Core/Src/serial.c:61:6:CCS_SerialLoop 41
|
||||||
|
../Core/Src/serial.c:206:6:CCS_Init 1
|
||||||
|
../Core/Src/serial.c:218:17:crc16_ibm 4
|
||||||
|
../Core/Src/serial.c:233:17:CCS_BuildPacket 4
|
||||||
|
../Core/Src/serial.c:249:13:CCS_SendPacket 2
|
||||||
|
../Core/Src/serial.c:257:13:CCS_SendResetReason 1
|
||||||
|
../Core/Src/serial.c:261:6:CCS_SendEmergencyStop 1
|
||||||
|
../Core/Src/serial.c:265:6:CCS_SendStart 1
|
||||||
|
../Core/Src/serial.c:269:13:CCS_CalculateEnergy 2
|
||||||
|
../Core/Src/serial.c:284:13:send_state 2
|
||||||
|
../Core/Src/serial.c:311:17:expected_payload_len 11
|
||||||
|
../Core/Src/serial.c:327:13:apply_command 13
|
||||||
|
../Core/Src/serial.c:394:16:process_received_packet 6
|
||||||
10
Debug/Core/Src/serial_control.cyclo
Normal file
10
Debug/Core/Src/serial_control.cyclo
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
../Core/Src/serial_control.c:59:6:ReadVersion 1
|
||||||
|
../Core/Src/serial_control.c:71:6:SC_Init 1
|
||||||
|
../Core/Src/serial_control.c:77:6:SC_Task 9
|
||||||
|
../Core/Src/serial_control.c:102:6:HAL_UARTEx_RxEventCallback 6
|
||||||
|
../Core/Src/serial_control.c:120:6:HAL_UART_TxCpltCallback 2
|
||||||
|
../Core/Src/serial_control.c:130:17:calculate_crc32 4
|
||||||
|
../Core/Src/serial_control.c:147:17:encode_packet 6
|
||||||
|
../Core/Src/serial_control.c:180:6:SC_SendPacket 3
|
||||||
|
../Core/Src/serial_control.c:197:16:parse_packet 4
|
||||||
|
../Core/Src/serial_control.c:230:16:process_received_packet 2
|
||||||
3
Debug/Core/Src/serial_handler.cyclo
Normal file
3
Debug/Core/Src/serial_handler.cyclo
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
|
||||||
|
../Core/Src/serial_handler.c:26:6:SC_CommandHandler 19
|
||||||
|
../Core/Src/serial_handler.c:125:6:monitoring_data_callback 1
|
||||||
2
Debug/Core/Src/sma_filter.cyclo
Normal file
2
Debug/Core/Src/sma_filter.cyclo
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
../Core/Src/sma_filter.c:3:6:SMAFilter_Init 3
|
||||||
|
../Core/Src/sma_filter.c:16:9:SMAFilter_Update 6
|
||||||
10
Debug/Core/Src/soft_rtc.cyclo
Normal file
10
Debug/Core/Src/soft_rtc.cyclo
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
../Core/Src/soft_rtc.c:22:10:get_Current_Time 1
|
||||||
|
../Core/Src/soft_rtc.c:26:6:set_Time 1
|
||||||
|
../Core/Src/soft_rtc.c:30:9:to_bcd 1
|
||||||
|
../Core/Src/soft_rtc.c:34:6:unix_to_bcd 1
|
||||||
|
../Core/Src/soft_rtc.c:48:6:writeTimeReg 2
|
||||||
|
../Core/Src/soft_rtc.c:53:9:getTimeReg 5
|
||||||
|
../Core/Src/soft_rtc.c:87:17:RTC1_ReadTimeCounter 2
|
||||||
|
../Core/Src/soft_rtc.c:119:26:RTC1_WriteTimeCounter 3
|
||||||
|
../Core/Src/soft_rtc.c:151:26:RTC1_EnterInitMode 3
|
||||||
|
../Core/Src/soft_rtc.c:178:26:RTC1_ExitInitMode 3
|
||||||
1
Debug/Core/Src/stm32f1xx_hal_msp.cyclo
Normal file
1
Debug/Core/Src/stm32f1xx_hal_msp.cyclo
Normal file
@@ -0,0 +1 @@
|
|||||||
|
../Core/Src/stm32f1xx_hal_msp.c:63:6:HAL_MspInit 1
|
||||||
17
Debug/Core/Src/stm32f1xx_it.cyclo
Normal file
17
Debug/Core/Src/stm32f1xx_it.cyclo
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
../Core/Src/stm32f1xx_it.c:75:6:NMI_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:90:6:HardFault_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:105:6:MemManage_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:120:6:BusFault_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:135:6:UsageFault_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:150:6:SVC_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:163:6:DebugMon_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:176:6:PendSV_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:189:6:SysTick_Handler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:210:6:CAN1_RX0_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:224:6:TIM3_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:238:6:USART1_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:252:6:USART2_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:266:6:USART3_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:280:6:UART5_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:294:6:CAN2_TX_IRQHandler 1
|
||||||
|
../Core/Src/stm32f1xx_it.c:308:6:CAN2_RX1_IRQHandler 1
|
||||||
99
Debug/Core/Src/subdir.mk
Executable file
99
Debug/Core/Src/subdir.mk
Executable file
@@ -0,0 +1,99 @@
|
|||||||
|
################################################################################
|
||||||
|
# Automatically-generated file. Do not edit!
|
||||||
|
# Toolchain: GNU Tools for STM32 (13.3.rel1)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Add inputs and outputs from these tool invocations to the build variables
|
||||||
|
C_SRCS += \
|
||||||
|
../Core/Src/adc.c \
|
||||||
|
../Core/Src/board.c \
|
||||||
|
../Core/Src/can.c \
|
||||||
|
../Core/Src/charger_control.c \
|
||||||
|
../Core/Src/cp.c \
|
||||||
|
../Core/Src/crc.c \
|
||||||
|
../Core/Src/debug.c \
|
||||||
|
../Core/Src/gpio.c \
|
||||||
|
../Core/Src/main.c \
|
||||||
|
../Core/Src/meter.c \
|
||||||
|
../Core/Src/psu_control.c \
|
||||||
|
../Core/Src/rgb_controller.c \
|
||||||
|
../Core/Src/rtc.c \
|
||||||
|
../Core/Src/serial.c \
|
||||||
|
../Core/Src/serial_control.c \
|
||||||
|
../Core/Src/serial_handler.c \
|
||||||
|
../Core/Src/sma_filter.c \
|
||||||
|
../Core/Src/soft_rtc.c \
|
||||||
|
../Core/Src/stm32f1xx_hal_msp.c \
|
||||||
|
../Core/Src/stm32f1xx_it.c \
|
||||||
|
../Core/Src/syscalls.c \
|
||||||
|
../Core/Src/sysmem.c \
|
||||||
|
../Core/Src/system_stm32f1xx.c \
|
||||||
|
../Core/Src/tim.c \
|
||||||
|
../Core/Src/usart.c
|
||||||
|
|
||||||
|
C_DEPS += \
|
||||||
|
./Core/Src/adc.d \
|
||||||
|
./Core/Src/board.d \
|
||||||
|
./Core/Src/can.d \
|
||||||
|
./Core/Src/charger_control.d \
|
||||||
|
./Core/Src/cp.d \
|
||||||
|
./Core/Src/crc.d \
|
||||||
|
./Core/Src/debug.d \
|
||||||
|
./Core/Src/gpio.d \
|
||||||
|
./Core/Src/main.d \
|
||||||
|
./Core/Src/meter.d \
|
||||||
|
./Core/Src/psu_control.d \
|
||||||
|
./Core/Src/rgb_controller.d \
|
||||||
|
./Core/Src/rtc.d \
|
||||||
|
./Core/Src/serial.d \
|
||||||
|
./Core/Src/serial_control.d \
|
||||||
|
./Core/Src/serial_handler.d \
|
||||||
|
./Core/Src/sma_filter.d \
|
||||||
|
./Core/Src/soft_rtc.d \
|
||||||
|
./Core/Src/stm32f1xx_hal_msp.d \
|
||||||
|
./Core/Src/stm32f1xx_it.d \
|
||||||
|
./Core/Src/syscalls.d \
|
||||||
|
./Core/Src/sysmem.d \
|
||||||
|
./Core/Src/system_stm32f1xx.d \
|
||||||
|
./Core/Src/tim.d \
|
||||||
|
./Core/Src/usart.d
|
||||||
|
|
||||||
|
OBJS += \
|
||||||
|
./Core/Src/adc.o \
|
||||||
|
./Core/Src/board.o \
|
||||||
|
./Core/Src/can.o \
|
||||||
|
./Core/Src/charger_control.o \
|
||||||
|
./Core/Src/cp.o \
|
||||||
|
./Core/Src/crc.o \
|
||||||
|
./Core/Src/debug.o \
|
||||||
|
./Core/Src/gpio.o \
|
||||||
|
./Core/Src/main.o \
|
||||||
|
./Core/Src/meter.o \
|
||||||
|
./Core/Src/psu_control.o \
|
||||||
|
./Core/Src/rgb_controller.o \
|
||||||
|
./Core/Src/rtc.o \
|
||||||
|
./Core/Src/serial.o \
|
||||||
|
./Core/Src/serial_control.o \
|
||||||
|
./Core/Src/serial_handler.o \
|
||||||
|
./Core/Src/sma_filter.o \
|
||||||
|
./Core/Src/soft_rtc.o \
|
||||||
|
./Core/Src/stm32f1xx_hal_msp.o \
|
||||||
|
./Core/Src/stm32f1xx_it.o \
|
||||||
|
./Core/Src/syscalls.o \
|
||||||
|
./Core/Src/sysmem.o \
|
||||||
|
./Core/Src/system_stm32f1xx.o \
|
||||||
|
./Core/Src/tim.o \
|
||||||
|
./Core/Src/usart.o
|
||||||
|
|
||||||
|
|
||||||
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
|
Core/Src/%.o Core/Src/%.su Core/Src/%.cyclo: ../Core/Src/%.c Core/Src/subdir.mk
|
||||||
|
arm-none-eabi-gcc "$<" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F107xC -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
|
||||||
|
|
||||||
|
clean: clean-Core-2f-Src
|
||||||
|
|
||||||
|
clean-Core-2f-Src:
|
||||||
|
-$(RM) ./Core/Src/adc.cyclo ./Core/Src/adc.d ./Core/Src/adc.o ./Core/Src/adc.su ./Core/Src/board.cyclo ./Core/Src/board.d ./Core/Src/board.o ./Core/Src/board.su ./Core/Src/can.cyclo ./Core/Src/can.d ./Core/Src/can.o ./Core/Src/can.su ./Core/Src/charger_control.cyclo ./Core/Src/charger_control.d ./Core/Src/charger_control.o ./Core/Src/charger_control.su ./Core/Src/cp.cyclo ./Core/Src/cp.d ./Core/Src/cp.o ./Core/Src/cp.su ./Core/Src/crc.cyclo ./Core/Src/crc.d ./Core/Src/crc.o ./Core/Src/crc.su ./Core/Src/debug.cyclo ./Core/Src/debug.d ./Core/Src/debug.o ./Core/Src/debug.su ./Core/Src/gpio.cyclo ./Core/Src/gpio.d ./Core/Src/gpio.o ./Core/Src/gpio.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/meter.cyclo ./Core/Src/meter.d ./Core/Src/meter.o ./Core/Src/meter.su ./Core/Src/psu_control.cyclo ./Core/Src/psu_control.d ./Core/Src/psu_control.o ./Core/Src/psu_control.su ./Core/Src/rgb_controller.cyclo ./Core/Src/rgb_controller.d ./Core/Src/rgb_controller.o ./Core/Src/rgb_controller.su ./Core/Src/rtc.cyclo ./Core/Src/rtc.d ./Core/Src/rtc.o ./Core/Src/rtc.su ./Core/Src/serial.cyclo ./Core/Src/serial.d ./Core/Src/serial.o ./Core/Src/serial.su ./Core/Src/serial_control.cyclo ./Core/Src/serial_control.d ./Core/Src/serial_control.o ./Core/Src/serial_control.su ./Core/Src/serial_handler.cyclo ./Core/Src/serial_handler.d ./Core/Src/serial_handler.o ./Core/Src/serial_handler.su ./Core/Src/sma_filter.cyclo ./Core/Src/sma_filter.d ./Core/Src/sma_filter.o ./Core/Src/sma_filter.su ./Core/Src/soft_rtc.cyclo ./Core/Src/soft_rtc.d ./Core/Src/soft_rtc.o ./Core/Src/soft_rtc.su ./Core/Src/stm32f1xx_hal_msp.cyclo ./Core/Src/stm32f1xx_hal_msp.d ./Core/Src/stm32f1xx_hal_msp.o ./Core/Src/stm32f1xx_hal_msp.su ./Core/Src/stm32f1xx_it.cyclo ./Core/Src/stm32f1xx_it.d ./Core/Src/stm32f1xx_it.o ./Core/Src/stm32f1xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f1xx.cyclo ./Core/Src/system_stm32f1xx.d ./Core/Src/system_stm32f1xx.o ./Core/Src/system_stm32f1xx.su ./Core/Src/tim.cyclo ./Core/Src/tim.d ./Core/Src/tim.o ./Core/Src/tim.su ./Core/Src/usart.cyclo ./Core/Src/usart.d ./Core/Src/usart.o ./Core/Src/usart.su
|
||||||
|
|
||||||
|
.PHONY: clean-Core-2f-Src
|
||||||
|
|
||||||
18
Debug/Core/Src/syscalls.cyclo
Normal file
18
Debug/Core/Src/syscalls.cyclo
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
../Core/Src/syscalls.c:44:6:initialise_monitor_handles 1
|
||||||
|
../Core/Src/syscalls.c:48:5:_getpid 1
|
||||||
|
../Core/Src/syscalls.c:53:5:_kill 1
|
||||||
|
../Core/Src/syscalls.c:61:6:_exit 1
|
||||||
|
../Core/Src/syscalls.c:67:27:_read 2
|
||||||
|
../Core/Src/syscalls.c:80:27:_write 2
|
||||||
|
../Core/Src/syscalls.c:92:5:_close 1
|
||||||
|
../Core/Src/syscalls.c:99:5:_fstat 1
|
||||||
|
../Core/Src/syscalls.c:106:5:_isatty 1
|
||||||
|
../Core/Src/syscalls.c:112:5:_lseek 1
|
||||||
|
../Core/Src/syscalls.c:120:5:_open 1
|
||||||
|
../Core/Src/syscalls.c:128:5:_wait 1
|
||||||
|
../Core/Src/syscalls.c:135:5:_unlink 1
|
||||||
|
../Core/Src/syscalls.c:142:5:_times 1
|
||||||
|
../Core/Src/syscalls.c:148:5:_stat 1
|
||||||
|
../Core/Src/syscalls.c:155:5:_link 1
|
||||||
|
../Core/Src/syscalls.c:163:5:_fork 1
|
||||||
|
../Core/Src/syscalls.c:169:5:_execve 1
|
||||||
1
Debug/Core/Src/sysmem.cyclo
Normal file
1
Debug/Core/Src/sysmem.cyclo
Normal file
@@ -0,0 +1 @@
|
|||||||
|
../Core/Src/sysmem.c:53:7:_sbrk 3
|
||||||
2
Debug/Core/Src/system_stm32f1xx.cyclo
Normal file
2
Debug/Core/Src/system_stm32f1xx.cyclo
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
../Core/Src/system_stm32f1xx.c:175:6:SystemInit 1
|
||||||
|
../Core/Src/system_stm32f1xx.c:224:6:SystemCoreClockUpdate 8
|
||||||
5
Debug/Core/Src/tim.cyclo
Normal file
5
Debug/Core/Src/tim.cyclo
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
../Core/Src/tim.c:31:6:MX_TIM3_Init 8
|
||||||
|
../Core/Src/tim.c:95:6:MX_TIM4_Init 8
|
||||||
|
../Core/Src/tim.c:157:6:HAL_TIM_Base_MspInit 3
|
||||||
|
../Core/Src/tim.c:187:6:HAL_TIM_MspPostInit 3
|
||||||
|
../Core/Src/tim.c:235:6:HAL_TIM_Base_MspDeInit 3
|
||||||
6
Debug/Core/Src/usart.cyclo
Normal file
6
Debug/Core/Src/usart.cyclo
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
../Core/Src/usart.c:33:6:MX_UART5_Init 2
|
||||||
|
../Core/Src/usart.c:62:6:MX_USART1_UART_Init 2
|
||||||
|
../Core/Src/usart.c:91:6:MX_USART2_UART_Init 2
|
||||||
|
../Core/Src/usart.c:120:6:MX_USART3_UART_Init 2
|
||||||
|
../Core/Src/usart.c:148:6:HAL_UART_MspInit 5
|
||||||
|
../Core/Src/usart.c:279:6:HAL_UART_MspDeInit 5
|
||||||
27
Debug/Core/Startup/subdir.mk
Executable file
27
Debug/Core/Startup/subdir.mk
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
################################################################################
|
||||||
|
# Automatically-generated file. Do not edit!
|
||||||
|
# Toolchain: GNU Tools for STM32 (13.3.rel1)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Add inputs and outputs from these tool invocations to the build variables
|
||||||
|
S_SRCS += \
|
||||||
|
../Core/Startup/startup_stm32f107vctx.s
|
||||||
|
|
||||||
|
S_DEPS += \
|
||||||
|
./Core/Startup/startup_stm32f107vctx.d
|
||||||
|
|
||||||
|
OBJS += \
|
||||||
|
./Core/Startup/startup_stm32f107vctx.o
|
||||||
|
|
||||||
|
|
||||||
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
|
Core/Startup/%.o: ../Core/Startup/%.s Core/Startup/subdir.mk
|
||||||
|
arm-none-eabi-gcc -mcpu=cortex-m3 -g3 -DDEBUG -c -I/Users/colorbass/STM32CubeIDE/workspace_1.12.0/lib_EDCAN -x assembler-with-cpp -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@" "$<"
|
||||||
|
|
||||||
|
clean: clean-Core-2f-Startup
|
||||||
|
|
||||||
|
clean-Core-2f-Startup:
|
||||||
|
-$(RM) ./Core/Startup/startup_stm32f107vctx.d ./Core/Startup/startup_stm32f107vctx.o
|
||||||
|
|
||||||
|
.PHONY: clean-Core-2f-Startup
|
||||||
|
|
||||||
BIN
Debug/Drivers/.DS_Store
vendored
Normal file
BIN
Debug/Drivers/.DS_Store
vendored
Normal file
Binary file not shown.
25
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.cyclo
Normal file
25
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.cyclo
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:142:19:HAL_Init 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:175:19:HAL_DeInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:200:13:HAL_MspInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:211:13:HAL_MspDeInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:234:26:HAL_InitTick 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:293:13:HAL_IncTick 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:304:17:HAL_GetTick 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:313:10:HAL_GetTickPrio 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:322:19:HAL_SetTickFreq 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:355:21:HAL_GetTickFreq 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:371:13:HAL_Delay 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:397:13:HAL_SuspendTick 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:413:13:HAL_ResumeTick 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:423:10:HAL_GetHalVersion 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:439:10:HAL_GetREVID 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:455:10:HAL_GetDEVID 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:464:10:HAL_GetUIDw0 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:473:10:HAL_GetUIDw1 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:482:10:HAL_GetUIDw2 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:491:6:HAL_DBGMCU_EnableDBGSleepMode 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:507:6:HAL_DBGMCU_DisableDBGSleepMode 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:537:6:HAL_DBGMCU_EnableDBGStopMode 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:553:6:HAL_DBGMCU_DisableDBGStopMode 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:569:6:HAL_DBGMCU_EnableDBGStandbyMode 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c:585:6:HAL_DBGMCU_DisableDBGStandbyMode 1
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:411:19:HAL_ADC_Init 12
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:629:19:HAL_ADC_DeInit 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:777:13:HAL_ADC_MspInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:791:13:HAL_ADC_MspDeInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1036:19:HAL_ADC_Start 13
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1149:19:HAL_ADC_Stop 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1193:19:HAL_ADC_PollForConversion 25
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1332:19:HAL_ADC_PollForEvent 6
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1385:19:HAL_ADC_Start_IT 13
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1496:19:HAL_ADC_Stop_IT 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1553:19:HAL_ADC_Start_DMA 14
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1694:19:HAL_ADC_Stop_DMA 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1762:10:HAL_ADC_GetValue 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1779:6:HAL_ADC_IRQHandler 17
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1909:13:HAL_ADC_ConvCpltCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1923:13:HAL_ADC_ConvHalfCpltCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1937:13:HAL_ADC_LevelOutOfWindowCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:1952:13:HAL_ADC_ErrorCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2000:19:HAL_ADC_ConfigChannel 11
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2110:19:HAL_ADC_AnalogWDGConfig 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2197:10:HAL_ADC_GetState 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2208:10:HAL_ADC_GetError 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2232:19:ADC_Enable 6
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2291:19:ADC_ConversionStop_Disable 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2333:6:ADC_DMAConvCplt 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2380:6:ADC_DMAHalfConvCplt 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c:2398:6:ADC_DMAError 1
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:119:19:HAL_ADCEx_Calibration_Start 10
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:229:19:HAL_ADCEx_InjectedStart 10
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:328:19:HAL_ADCEx_InjectedStop 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:381:19:HAL_ADCEx_InjectedPollForConversion 25
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:507:19:HAL_ADCEx_InjectedStart_IT 10
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:606:19:HAL_ADCEx_InjectedStop_IT 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:675:19:HAL_ADCEx_MultiModeStart_DMA 7
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:801:19:HAL_ADCEx_MultiModeStop_DMA 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:889:10:HAL_ADCEx_InjectedGetValue 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:926:10:HAL_ADCEx_MultiModeGetValue 2
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:958:13:HAL_ADCEx_InjectedConvCpltCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:1000:19:HAL_ADCEx_InjectedConfigChannel 23
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c:1261:19:HAL_ADCEx_MultiModeConfigChannel 5
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:275:19:HAL_CAN_Init 13
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:460:19:HAL_CAN_DeInit 2
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:507:13:HAL_CAN_MspInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:523:13:HAL_CAN_MspDeInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:840:19:HAL_CAN_ConfigFilter 8
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1006:19:HAL_CAN_Start 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1058:19:HAL_CAN_Stop 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1113:19:HAL_CAN_RequestSleep 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1144:19:HAL_CAN_WakeUp 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1191:10:HAL_CAN_IsSleepActive 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1222:19:HAL_CAN_AddTxMessage 8
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1322:19:HAL_CAN_AbortTxRequest 6
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1371:10:HAL_CAN_GetTxMailboxesFreeLevel 6
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1414:10:HAL_CAN_IsTxMessagePending 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1446:10:HAL_CAN_GetTxTimestamp 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1480:19:HAL_CAN_GetRxMessage 9
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1580:10:HAL_CAN_GetRxFifoFillLevel 4
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1633:19:HAL_CAN_ActivateNotification 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1666:19:HAL_CAN_DeactivateNotification 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:1697:6:HAL_CAN_IRQHandler 51
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2108:13:HAL_CAN_TxMailbox0CompleteCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2125:13:HAL_CAN_TxMailbox1CompleteCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2142:13:HAL_CAN_TxMailbox2CompleteCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2159:13:HAL_CAN_TxMailbox0AbortCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2176:13:HAL_CAN_TxMailbox1AbortCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2193:13:HAL_CAN_TxMailbox2AbortCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2210:13:HAL_CAN_RxFifo0MsgPendingCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2227:13:HAL_CAN_RxFifo0FullCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2244:13:HAL_CAN_RxFifo1MsgPendingCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2261:13:HAL_CAN_RxFifo1FullCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2278:13:HAL_CAN_SleepCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2294:13:HAL_CAN_WakeUpFromRxMsgCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2311:13:HAL_CAN_ErrorCallback 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2348:22:HAL_CAN_GetState 5
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2383:10:HAL_CAN_GetError 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c:2395:19:HAL_CAN_ResetError 3
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1480:22:__NVIC_SetPriorityGrouping 1
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1499:26:__NVIC_GetPriorityGrouping 1
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1511:22:__NVIC_EnableIRQ 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1547:22:__NVIC_DisableIRQ 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1566:26:__NVIC_GetPendingIRQ 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1585:22:__NVIC_SetPendingIRQ 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1600:22:__NVIC_ClearPendingIRQ 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1617:26:__NVIC_GetActive 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1639:22:__NVIC_SetPriority 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1661:26:__NVIC_GetPriority 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1686:26:NVIC_EncodePriority 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1713:22:NVIC_DecodePriority 2
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
|
||||||
|
../Drivers/CMSIS/Include/core_cm3.h:1834:26:SysTick_Config 2
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:142:6:HAL_NVIC_SetPriorityGrouping 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:164:6:HAL_NVIC_SetPriority 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:186:6:HAL_NVIC_EnableIRQ 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:202:6:HAL_NVIC_DisableIRQ 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:215:6:HAL_NVIC_SystemReset 0
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:228:10:HAL_SYSTICK_Config 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:369:10:HAL_NVIC_GetPriorityGrouping 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:396:6:HAL_NVIC_GetPriority 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:411:6:HAL_NVIC_SetPendingIRQ 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:429:10:HAL_NVIC_GetPendingIRQ 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:445:6:HAL_NVIC_ClearPendingIRQ 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:462:10:HAL_NVIC_GetActive 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:479:6:HAL_SYSTICK_CLKSourceConfig 2
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:497:6:HAL_SYSTICK_IRQHandler 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:506:13:HAL_SYSTICK_Callback 1
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:95:19:HAL_CRC_Init 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:126:19:HAL_CRC_DeInit 3
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:170:13:HAL_CRC_MspInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:185:13:HAL_CRC_MspDeInit 1
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:227:10:HAL_CRC_Accumulate 2
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:257:10:HAL_CRC_Calculate 2
|
||||||
|
../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c:306:22:HAL_CRC_GetState 1
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user