diff --git a/app/Core/Src/gpio.c b/app/Core/Src/gpio.c index 889a527..31c082d 100644 --- a/app/Core/Src/gpio.c +++ b/app/Core/Src/gpio.c @@ -55,100 +55,58 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8|GPIO_PIN_10, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11|GPIO_PIN_12, GPIO_PIN_SET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6, GPIO_PIN_RESET); - /*Configure GPIO pins : PE2 PE3 PE4 PE5 - PE6 PE7 PE13 PE14 + PE6 PE7 PE8 PE10 + PE11 PE12 PE13 PE14 PE15 PE0 PE1 */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - /*Configure GPIO pins : PC13 PC14 PC15 PC8 - PC10 PC11 PC12 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_8 - |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; + /*Configure GPIO pins : PC13 PC14 PC15 PC0 + PC1 PC2 PC3 PC4 + PC5 PC6 PC7 PC10 + PC11 PC12 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0 + |GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 + |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PC0 PC2 PC3 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3; - 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 pins : PC1 PC4 PC5 PC6 - PC7 */ - GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 - |GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA1 PA2 PA3 - PA8 PA15 */ + PA4 PA8 PA15 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_8|GPIO_PIN_15; + |GPIO_PIN_4|GPIO_PIN_8|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pin : PA4 */ - GPIO_InitStruct.Pin = GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pin : PB1 */ - GPIO_InitStruct.Pin = GPIO_PIN_1; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pins : PB2 PB10 PB11 PB12 - PB13 PB14 PB15 PB4 - PB5 PB8 PB9 */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 - |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4 - |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9; + /*Configure GPIO pins : PB0 PB1 PB2 PB10 + PB11 PB12 PB13 PB14 + PB15 PB4 PB5 PB8 + PB9 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8 + |GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PE8 PE10 PE11 PE12 */ - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; - 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 pins : PD8 PD9 PD10 PD11 - PD12 PD13 PD15 */ + PD12 PD13 PD15 PD0 + PD1 PD2 PD3 PD4 + PD5 PD6 PD7 */ GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_15; + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_15|GPIO_PIN_0 + |GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4 + |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); @@ -161,21 +119,6 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Alternate = GPIO_AF0_MCO; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PD0 PD1 PD2 PD3 - PD7 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /*Configure GPIO pins : PD4 PD5 PD6 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; - 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); - } /* USER CODE BEGIN 2 */ diff --git a/app/Core/Src/tim.c b/app/Core/Src/tim.c index 4ea4d7d..74f8dbe 100644 --- a/app/Core/Src/tim.c +++ b/app/Core/Src/tim.c @@ -436,16 +436,16 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle) /* USER CODE END TIM3_MspPostInit 0 */ - __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); /**TIM3 GPIO Configuration - PB0 ------> TIM3_CH3 + PC8 ------> TIM3_CH3 */ - GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLDOWN; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* USER CODE BEGIN TIM3_MspPostInit 1 */ diff --git a/app/MDK-ARM/app.uvoptx b/app/MDK-ARM/app.uvoptx index 9dbc890..91b90c0 100644 --- a/app/MDK-ARM/app.uvoptx +++ b/app/MDK-ARM/app.uvoptx @@ -1,4 +1,4 @@ - + 1.0 @@ -45,7 +45,7 @@ 79 66 8 - + 1 @@ -104,16 +104,16 @@ 0 0 4 - - - - - - - - - - + + + + + + + + + + Segger\JL2CM3.dll @@ -135,7 +135,7 @@ 0 ARMDBGFLAGS - + 0 @@ -172,7 +172,7 @@ 0 1 ..\..\src\umain.cpp - + \\app\../../src/umain.cpp\70 @@ -188,8 +188,8 @@ 0 0 ..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c - - + + 2 @@ -204,8 +204,8 @@ 0 0 ..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c - - + + 3 @@ -220,8 +220,8 @@ 0 0 ..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c - - + + 4 @@ -236,8 +236,8 @@ 0 0 ..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c - - + + 5 @@ -252,8 +252,8 @@ 0 0 ..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c - - + + 6 @@ -268,8 +268,8 @@ 0 0 ..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c - - + + 7 @@ -284,8 +284,8 @@ 0 0 ..\..\dep\libtrinamic\src\ic\tmc4361A.cpp - - + + 8 @@ -300,8 +300,8 @@ 0 0 ..\..\dep\libtrinamic\src\ic\tmc4361A.cpp - - + + 9 @@ -316,8 +316,8 @@ 0 0 ..\..\dep\libtrinamic\src\ic\tmc4361A.cpp - - + + 10 @@ -332,8 +332,8 @@ 0 0 ..\..\dep\libtrinamic\src\ic\tmc4361A.cpp - - + + 11 @@ -348,8 +348,8 @@ 0 0 ..\..\dep\libtrinamic\src\ic\tmc4361A.cpp - - + + @@ -381,19 +381,19 @@ 0 0 - - + + 0 0 0 - - - - - - - - + + + + + + + + 1 0 diff --git a/app/MDK-ARM/app.uvprojx b/app/MDK-ARM/app.uvprojx index 54d958b..e4a77f7 100644 --- a/app/MDK-ARM/app.uvprojx +++ b/app/MDK-ARM/app.uvprojx @@ -1,10 +1,7 @@ - - - + + 2.1 -
### uVision Project, (C) Keil Software
- app @@ -19,28 +16,28 @@ Keil.STM32F4xx_DFP.2.16.0 http://www.keil.com/pack/ IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x807FFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ - - - + + + 0 - - - - - - - - - - + + + + + + + + + + $$Device:STM32F407VETx$CMSIS\SVD\STM32F40x.svd 0 0 - - - - - + + + + + 0 0 @@ -55,15 +52,15 @@ 1 1 1 - + 1 0 0 0 0 - - + + 0 0 0 @@ -72,8 +69,8 @@ 0 0 - - + + 0 0 0 @@ -82,15 +79,15 @@ 0 0 - - + + 0 0 0 0 1 - + 0 @@ -104,8 +101,8 @@ 0 0 3 - - + + 0 @@ -139,10 +136,10 @@ 1 BIN\UL2V8M.DLL "" () - - - - + + + + 0 @@ -175,7 +172,7 @@ 0 0 "Cortex-M4" - + 0 0 0 @@ -309,7 +306,7 @@ 0x4000 - + 1 @@ -338,7 +335,7 @@ --diag_suppress=381 --diag_suppress=1 --diag_suppress=177 --diag_suppress=111 --diag_suppress=1295 USE_HAL_DRIVER,STM32F407xx - + ../Core/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include;../../dep;../../src;../../dep/libtrinamic/IFLYTOP-TMC-API @@ -354,10 +351,10 @@ 0 1 - - - - + + + + @@ -367,15 +364,15 @@ 0 1 0 - - - - - - - - - + + + + + + + + + @@ -420,8 +417,6 @@ 2 2 11 - - 1 @@ -449,12 +444,6 @@ 2 2 2 - - - - - - @@ -476,8 +465,6 @@ 2 2 11 - - 1 @@ -505,12 +492,6 @@ 2 2 2 - - - - - - @@ -532,8 +513,6 @@ 2 2 11 - - 1 @@ -561,12 +540,6 @@ 2 2 2 - - - - - - @@ -588,8 +561,6 @@ 2 2 11 - - 1 @@ -617,12 +588,6 @@ 2 2 2 - - - - - - @@ -644,8 +609,6 @@ 2 2 11 - - 1 @@ -673,12 +636,6 @@ 2 2 2 - - - - - - @@ -700,8 +657,6 @@ 2 2 11 - - 1 @@ -729,12 +684,6 @@ 2 2 2 - - - - - - @@ -776,8 +725,6 @@ 2 2 11 - - 1 @@ -805,12 +752,6 @@ 2 2 2 - - - - - - @@ -897,8 +838,6 @@ 2 2 11 - - 1 @@ -926,12 +865,6 @@ 2 2 2 - - - - - - @@ -953,8 +886,6 @@ 2 2 11 - - 1 @@ -982,12 +913,6 @@ 2 2 2 - - - - - - @@ -1009,8 +934,6 @@ 2 2 11 - - 1 @@ -1038,12 +961,6 @@ 2 2 2 - - - - - - @@ -1065,8 +982,6 @@ 2 2 11 - - 1 @@ -1094,12 +1009,6 @@ 2 2 2 - - - - - - @@ -1121,8 +1030,6 @@ 2 2 11 - - 1 @@ -1150,12 +1057,6 @@ 2 2 2 - - - - - - @@ -1288,18 +1189,17 @@ - - + - + - + - + -
+ diff --git a/app/app.ioc b/app/app.ioc index 5178e61..098d680 100644 --- a/app/app.ioc +++ b/app/app.ioc @@ -42,52 +42,30 @@ Mcu.Name=STM32F407V(E-G)Tx Mcu.Package=LQFP100 Mcu.Pin0=PH0-OSC_IN Mcu.Pin1=PH1-OSC_OUT -Mcu.Pin10=PC4 -Mcu.Pin11=PC5 -Mcu.Pin12=PB0 -Mcu.Pin13=PB1 -Mcu.Pin14=PE8 -Mcu.Pin15=PE9 -Mcu.Pin16=PE10 -Mcu.Pin17=PE11 -Mcu.Pin18=PE12 -Mcu.Pin19=PD14 -Mcu.Pin2=PC0 -Mcu.Pin20=PC6 -Mcu.Pin21=PC7 -Mcu.Pin22=PC9 -Mcu.Pin23=PA9 -Mcu.Pin24=PA10 -Mcu.Pin25=PA11 -Mcu.Pin26=PA12 -Mcu.Pin27=PA13 -Mcu.Pin28=PA14 -Mcu.Pin29=PD0 -Mcu.Pin3=PC1 -Mcu.Pin30=PD1 -Mcu.Pin31=PD2 -Mcu.Pin32=PD3 -Mcu.Pin33=PD4 -Mcu.Pin34=PD5 -Mcu.Pin35=PD6 -Mcu.Pin36=PD7 -Mcu.Pin37=PB3 -Mcu.Pin38=PB6 -Mcu.Pin39=PB7 -Mcu.Pin4=PC2 -Mcu.Pin40=VP_CRC_VS_CRC -Mcu.Pin41=VP_RNG_VS_RNG -Mcu.Pin42=VP_SYS_VS_Systick -Mcu.Pin43=VP_TIM1_VS_ClockSourceINT -Mcu.Pin44=VP_TIM3_VS_ClockSourceINT -Mcu.Pin45=VP_TIM6_VS_ClockSourceINT -Mcu.Pin46=VP_TIM7_VS_ClockSourceINT -Mcu.Pin5=PC3 -Mcu.Pin6=PA4 -Mcu.Pin7=PA5 -Mcu.Pin8=PA6 -Mcu.Pin9=PA7 -Mcu.PinsNb=47 +Mcu.Pin10=PA10 +Mcu.Pin11=PA11 +Mcu.Pin12=PA12 +Mcu.Pin13=PA13 +Mcu.Pin14=PA14 +Mcu.Pin15=PB3 +Mcu.Pin16=PB6 +Mcu.Pin17=PB7 +Mcu.Pin18=VP_CRC_VS_CRC +Mcu.Pin19=VP_RNG_VS_RNG +Mcu.Pin2=PA5 +Mcu.Pin20=VP_SYS_VS_Systick +Mcu.Pin21=VP_TIM1_VS_ClockSourceINT +Mcu.Pin22=VP_TIM3_VS_ClockSourceINT +Mcu.Pin23=VP_TIM6_VS_ClockSourceINT +Mcu.Pin24=VP_TIM7_VS_ClockSourceINT +Mcu.Pin3=PA6 +Mcu.Pin4=PA7 +Mcu.Pin5=PE9 +Mcu.Pin6=PD14 +Mcu.Pin7=PC8 +Mcu.Pin8=PC9 +Mcu.Pin9=PA9 +Mcu.PinsNb=25 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F407VETx @@ -119,8 +97,6 @@ PA13.Mode=Serial_Wire PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Serial_Wire PA14.Signal=SYS_JTCK-SWCLK -PA4.Locked=true -PA4.Signal=GPIO_Output PA5.Locked=true PA5.Mode=Full_Duplex_Master PA5.Signal=SPI1_SCK @@ -133,13 +109,6 @@ PA7.Signal=SPI1_MOSI PA9.Locked=true PA9.Mode=Asynchronous PA9.Signal=USART1_TX -PB0.GPIOParameters=GPIO_ModeDefaultPP,GPIO_PuPd -PB0.GPIO_ModeDefaultPP=GPIO_MODE_AF_PP -PB0.GPIO_PuPd=GPIO_PULLDOWN -PB0.Locked=true -PB0.Signal=S_TIM3_CH3 -PB1.Locked=true -PB1.Signal=GPIO_Output PB3.Locked=true PB3.Signal=S_TIM2_CH2 PB6.Locked=true @@ -148,55 +117,16 @@ PB6.Signal=I2C1_SCL PB7.Locked=true PB7.Mode=I2C PB7.Signal=I2C1_SDA -PC0.Locked=true -PC0.Signal=GPIO_Output -PC1.Locked=true -PC1.Signal=GPIO_Input -PC2.Locked=true -PC2.Signal=GPIO_Output -PC3.Locked=true -PC3.Signal=GPIO_Output -PC4.Locked=true -PC4.Signal=GPIO_Input -PC5.Locked=true -PC5.Signal=GPIO_Input -PC6.Locked=true -PC6.Signal=GPIO_Input -PC7.Locked=true -PC7.Signal=GPIO_Input +PC8.GPIOParameters=GPIO_ModeDefaultPP,GPIO_PuPd +PC8.GPIO_ModeDefaultPP=GPIO_MODE_AF_PP +PC8.GPIO_PuPd=GPIO_PULLDOWN +PC8.Locked=true +PC8.Signal=S_TIM3_CH3 PC9.Locked=true PC9.Mode=Clock-out-2 PC9.Signal=RCC_MCO_2 -PD0.Locked=true -PD0.Signal=GPIO_Input -PD1.Locked=true -PD1.Signal=GPIO_Input PD14.Locked=true PD14.Signal=S_TIM4_CH3 -PD2.Locked=true -PD2.Signal=GPIO_Input -PD3.Locked=true -PD3.Signal=GPIO_Input -PD4.Locked=true -PD4.Signal=GPIO_Output -PD5.Locked=true -PD5.Signal=GPIO_Output -PD6.Locked=true -PD6.Signal=GPIO_Output -PD7.Locked=true -PD7.Signal=GPIO_Input -PE10.Locked=true -PE10.Signal=GPIO_Output -PE11.GPIOParameters=PinState -PE11.Locked=true -PE11.PinState=GPIO_PIN_SET -PE11.Signal=GPIO_Output -PE12.GPIOParameters=PinState -PE12.Locked=true -PE12.PinState=GPIO_PIN_SET -PE12.Signal=GPIO_Output -PE8.Locked=true -PE8.Signal=GPIO_Output PE9.GPIOParameters=GPIO_ModeDefaultPP,GPIO_PuPd PE9.GPIO_ModeDefaultPP=GPIO_MODE_AF_PP PE9.GPIO_PuPd=GPIO_PULLDOWN @@ -234,7 +164,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=MDK-ARM V5.32 ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_TIM2_Init-TIM2-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_CRC_Init-CRC-false-HAL-true,8-MX_RNG_Init-RNG-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_CAN1_Init-CAN1-false-HAL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_TIM2_Init-TIM2-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_CRC_Init-CRC-false-HAL-true,8-MX_RNG_Init-RNG-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_CAN1_Init-CAN1-false-HAL-true,14-MX_I2C1_Init-I2C1-false-HAL-true RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=144000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 diff --git a/dep/libiflytop_micro b/dep/libiflytop_micro index 8a21b34..b85d8c6 160000 --- a/dep/libiflytop_micro +++ b/dep/libiflytop_micro @@ -1 +1 @@ -Subproject commit 8a21b347ee6436e79cdc404bd3082946deade41f +Subproject commit b85d8c6f872e7d3465d2b6d75d7ef8802eb1feab diff --git a/src/device_io_service.cpp b/src/device_io_service.cpp index 40c5f4c..ce79341 100644 --- a/src/device_io_service.cpp +++ b/src/device_io_service.cpp @@ -1,6 +1,6 @@ #include "device_io_service.hpp" -#include "libiflytop_micro/stm32/basic/stm32_clock_utils.hpp" +#include "libiflytop_micro/stm32/basic/stm32_hal_utils.hpp" extern "C" { int fputc(int ch, FILE *stream) { uint8_t c = ch; @@ -14,13 +14,9 @@ namespace iflytop { DeviceIoService deviceIoService; } -void DeviceIoService::fanInit(int freq) { +void DeviceIoService::fanInit(int freq) {} -} - -void DeviceIoService::fanSetDutyCycle(int fanIndex, uint16_t dutyCycle) { - -} +void DeviceIoService::fanSetDutyCycle(int fanIndex, uint16_t dutyCycle) {} bool *DeviceIoService::fanGetState(int fanIndex) { return &m_fanState[fanIndex]; } /******************************************************************************* @@ -35,6 +31,10 @@ void DeviceIoService::peltier_hot_ctr_pwm(int pwm) { __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, pwm); HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3); } +void DeviceIoService::peltier_init() { // + Stm32HalUtils::gpioInit(GPIOB, GPIO_PIN_1, GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_RESET); + Stm32HalUtils::gpioInit(GPIOE, GPIO_PIN_10, GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_RESET); +} void DeviceIoService::peltier_set_pwm(int pwm) { /** * @brief @@ -76,6 +76,15 @@ void DeviceIoService::peltier_set_pwm(int pwm) { /******************************************************************************* * tmc芯片驱动相关 * *******************************************************************************/ +void DeviceIoService::tmc_init() { + Stm32HalUtils::gpioInit( // + GPIOA, GPIO_PIN_4, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_SET); + Stm32HalUtils::gpioInit( // + GPIOE, GPIO_PIN_12, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_SET); + Stm32HalUtils::gpioInit( // + GPIOE, GPIO_PIN_11, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_SET); +} + void DeviceIoService::tmc_motor_spi_select(int channel, bool state) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, state ? GPIO_PIN_SET : GPIO_PIN_RESET); } void DeviceIoService::tmc_motor_spi_write_and_read(int channel, uint8_t *data, size_t length) { if (channel == MOTOR_1_TMC4361A_CHANNEL) { @@ -93,30 +102,6 @@ void DeviceIoService::tmc_extern_clk_enable() { */ #endif } - -void port_tmc_nFREEZE_pin_set_state(uint8_t channel, bool state) { - if (channel == MOTOR_1_TMC4361A_CHANNEL) { - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, state ? GPIO_PIN_SET : GPIO_PIN_RESET); - } -} -void port_tmc_ENN_pin_set_state(uint8_t channel, bool state) { - if (channel == MOTOR_1_TMC2160_CHANNEL) { - HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, state ? GPIO_PIN_SET : GPIO_PIN_RESET); - } -} -void port_tmc_nRESET_pin_set_state(uint8_t channel, bool state) {} -void port_tmc_extern_clk_enable() { -#if 1 - /** - * @brief TMC使用的外部时钟在stm32cubemx中已经进行配置,输出时钟为16MHZ - * 配置可以参考https://iflytop1.feishu.cn/wiki/wikcnog3hFm6dGFLMRksnhLb7Aw - */ -#else - // HAL_TIM_Base_Start(&TMC4361A_CLK_TIMER); - HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_4); -#endif -} - void DeviceIoService::tmc_nFREEZE_pin_set_state(uint8_t channel, bool state) { if (channel == MOTOR_1_TMC4361A_CHANNEL) { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, state ? GPIO_PIN_SET : GPIO_PIN_RESET); diff --git a/src/device_io_service.hpp b/src/device_io_service.hpp index 50e5ebf..a8f03f5 100644 --- a/src/device_io_service.hpp +++ b/src/device_io_service.hpp @@ -24,21 +24,21 @@ class DeviceIoService : public IflytopMicroOS { public: DeviceIoService(/* args */) {} ~DeviceIoService() {} - /******************************************************************************* * 风扇控制 * *******************************************************************************/ void fanInit(int freq); void fanSetDutyCycle(int fanIndex, uint16_t dutyCycle); bool *fanGetState(int fanIndex); - /******************************************************************************* * 帕尔贴驱动电路 * *******************************************************************************/ + void peltier_init(); void peltier_set_pwm(int pwm); /******************************************************************************* * tmc芯片驱动相关 * *******************************************************************************/ + void tmc_init(); void tmc_motor_spi_write_and_read(int channel, uint8_t *data, size_t length); void tmc_extern_clk_enable(); void tmc_nFREEZE_pin_set_state(uint8_t channel, bool state); @@ -59,7 +59,7 @@ class DeviceIoService : public IflytopMicroOS { void peltier_cold_ctr_pwm(int pwm); // PB0 HOT_CTR_PWM0 void peltier_hot_ctr_pwm(int pwm); - + void tmc_motor_spi_select(int channel, bool state); }; diff --git a/src/fan_state_monitor.cpp b/src/fan_state_monitor.cpp index 54d6c24..efe9761 100644 --- a/src/fan_state_monitor.cpp +++ b/src/fan_state_monitor.cpp @@ -1,13 +1,25 @@ #include "fan_state_monitor.hpp" #include "libiflytop_micro/stm32/basic/basic.h" +#include "libiflytop_micro\stm32\basic\stm32_hal_utils.hpp" using namespace iflytop; #define TAG "FAN_STATE_MONITOR" void FanStateMonitor::initialize(IflytopMicroOS* os, GPIO_TypeDef* FB_GPIOx, uint16_t FB_GPIO_Pin, bool* fanstate) { - // - m_fanstate = fanstate; + m_FB_GPIOx = FB_GPIOx; + m_FB_GPIO_Pin = FB_GPIO_Pin; + m_fanstate = fanstate; + m_os = os; + m_fanFBCount = 0; + m_lastPinState = GPIO_PIN_RESET; + m_lastCallTicket = 0; + m_fanOpenTicket = 0; + m_lastFanState = false; + m_fanError = false; + + Stm32HalUtils::gpioInitAsInput(FB_GPIOx, FB_GPIO_Pin); + m_lastPinState = HAL_GPIO_ReadPin(m_FB_GPIOx, m_FB_GPIO_Pin); } void FanStateMonitor::doFanStateCheckPeriodicJob() { /** diff --git a/src/fan_state_monitor.hpp b/src/fan_state_monitor.hpp index e13fe64..b73c186 100644 --- a/src/fan_state_monitor.hpp +++ b/src/fan_state_monitor.hpp @@ -3,15 +3,15 @@ #include "main.h" namespace iflytop { class FanStateMonitor { - GPIO_TypeDef* m_FB_GPIOx; // 风扇反馈引脚 - uint16_t m_FB_GPIO_Pin; // 风扇反馈引脚 - bool* m_fanstate; // 风扇当前是否正在工作 - IflytopMicroOS* m_os; // 系统基础方法 - uint16_t m_fanFBCount; // 风扇反馈计数 - GPIO_PinState m_lastPinState; // 上次风扇反馈引脚状态,用来实现风扇反馈计数逻辑 - uint32_t m_lastCallTicket = 0; // 上次调用周期性任务的时间戳 - uint32_t m_fanOpenTicket = 0; // 风扇打开的时间戳 - bool m_lastFanState = false; // 上次风扇状态,用来实现捕获风扇打开事件 + GPIO_TypeDef* m_FB_GPIOx; // 风扇反馈引脚 + uint16_t m_FB_GPIO_Pin; // 风扇反馈引脚 + bool* m_fanstate; // 风扇当前是否正在工作 + IflytopMicroOS* m_os; // 系统基础方法 + uint16_t m_fanFBCount; // 风扇反馈计数 + GPIO_PinState m_lastPinState; // 上次风扇反馈引脚状态,用来实现风扇反馈计数逻辑 + uint32_t m_lastCallTicket; // 上次调用周期性任务的时间戳 + uint32_t m_fanOpenTicket; // 风扇打开的时间戳 + bool m_lastFanState; // 上次风扇状态,用来实现捕获风扇打开事件 bool m_fanError; // 风扇故障标志位 @@ -35,7 +35,6 @@ class FanStateMonitor { /******************************************************************************* * 周期性调度任务 * *******************************************************************************/ - /** * @brief 周期性调度任务,需要上层代码尽可能的频繁调度 */