diff --git a/firmware/targets/f3/f3-1/Inc/main.h b/firmware/targets/f3/f3-1/Inc/main.h index 88bfea21..b0227887 100644 --- a/firmware/targets/f3/f3-1/Inc/main.h +++ b/firmware/targets/f3/f3-1/Inc/main.h @@ -88,8 +88,8 @@ void Error_Handler(void); #define LED_BLUE_GPIO_Port GPIOA #define PA4_Pin GPIO_PIN_4 #define PA4_GPIO_Port GPIOA -#define PA5_Pin GPIO_PIN_5 -#define PA5_GPIO_Port GPIOA +#define SPI_R_SCK_Pin GPIO_PIN_5 +#define SPI_R_SCK_GPIO_Port GPIOA #define PA6_Pin GPIO_PIN_6 #define PA6_GPIO_Port GPIOA #define PA7_Pin GPIO_PIN_7 @@ -143,8 +143,8 @@ void Error_Handler(void); #define CC1101_CS_GPIO_Port GPIOD #define SPI_D_SCK_Pin GPIO_PIN_1 #define SPI_D_SCK_GPIO_Port GPIOD -#define SPI_R_SCK_Pin GPIO_PIN_3 -#define SPI_R_SCK_GPIO_Port GPIOB +#define PB3_Pin GPIO_PIN_3 +#define PB3_GPIO_Port GPIOB #define SPI_R_MISO_Pin GPIO_PIN_4 #define SPI_R_MISO_GPIO_Port GPIOB #define SPI_R_MOSI_Pin GPIO_PIN_5 diff --git a/firmware/targets/f3/f3-1/Src/gpio.c b/firmware/targets/f3/f3-1/Src/gpio.c index b0040fe6..84634b10 100644 --- a/firmware/targets/f3/f3-1/Src/gpio.c +++ b/firmware/targets/f3/f3-1/Src/gpio.c @@ -97,8 +97,8 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PAPin PAPin PAPin PAPin */ - GPIO_InitStruct.Pin = PA4_Pin|PA5_Pin|PA6_Pin|PA7_Pin; + /*Configure GPIO pins : PAPin PAPin PAPin */ + GPIO_InitStruct.Pin = PA4_Pin|PA6_Pin|PA7_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -115,8 +115,8 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(CC1101_G0_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PBPin PBPin */ - GPIO_InitStruct.Pin = PB2_Pin|iBTN_Pin; + /*Configure GPIO pins : PBPin PBPin PBPin */ + GPIO_InitStruct.Pin = PB2_Pin|iBTN_Pin|PB3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); diff --git a/firmware/targets/f3/f3-1/Src/spi.c b/firmware/targets/f3/f3-1/Src/spi.c index b5929653..e777b347 100644 --- a/firmware/targets/f3/f3-1/Src/spi.c +++ b/firmware/targets/f3/f3-1/Src/spi.c @@ -88,13 +88,21 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) /* SPI1 clock enable */ __HAL_RCC_SPI1_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**SPI1 GPIO Configuration - PB3 ------> SPI1_SCK + PA5 ------> SPI1_SCK PB4 ------> SPI1_MISO PB5 ------> SPI1_MOSI */ - GPIO_InitStruct.Pin = SPI_R_SCK_Pin|SPI_R_MISO_Pin|SPI_R_MOSI_Pin; + GPIO_InitStruct.Pin = SPI_R_SCK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(SPI_R_SCK_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = SPI_R_MISO_Pin|SPI_R_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; @@ -164,11 +172,13 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) __HAL_RCC_SPI1_CLK_DISABLE(); /**SPI1 GPIO Configuration - PB3 ------> SPI1_SCK + PA5 ------> SPI1_SCK PB4 ------> SPI1_MISO PB5 ------> SPI1_MOSI */ - HAL_GPIO_DeInit(GPIOB, SPI_R_SCK_Pin|SPI_R_MISO_Pin|SPI_R_MOSI_Pin); + HAL_GPIO_DeInit(SPI_R_SCK_GPIO_Port, SPI_R_SCK_Pin); + + HAL_GPIO_DeInit(GPIOB, SPI_R_MISO_Pin|SPI_R_MOSI_Pin); /* USER CODE BEGIN SPI1_MspDeInit 1 */ diff --git a/firmware/targets/f3/f3-1/f3-1.ioc b/firmware/targets/f3/f3-1/f3-1.ioc index ea8c87a3..14041721 100644 --- a/firmware/targets/f3/f3-1/f3-1.ioc +++ b/firmware/targets/f3/f3-1/f3-1.ioc @@ -56,7 +56,6 @@ NVIC.EXTI15_10_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PB2.Signal=GPIO_Analog -PB3.Mode=Full_Duplex_Master PH3-BOOT0.Locked=true PA8.Locked=true PD1.GPIOParameters=GPIO_Label @@ -95,6 +94,7 @@ PB9.Signal=TIM1_CH3N Mcu.Package=VFQFPN68 TIM2.Prescaler=64-1 PB1.Signal=GPXTI1 +PA5.Locked=true NVIC.TimeBase=TIM1_TRG_COM_TIM17_IRQn SPI2.Mode=SPI_MODE_MASTER PA2.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD @@ -128,6 +128,7 @@ ProjectManager.CustomerFirmwarePackage= PC4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI NVIC.RCC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:false RCC.HSI48_VALUE=48000000 +PA5.Mode=Full_Duplex_Master PA6.GPIOParameters=GPIO_Label SH.GPXTI10.0=GPIO_EXTI10 PCC.Ble.Mode=NOT_SELECTED @@ -205,7 +206,7 @@ Mcu.Pin46=PD1 Mcu.Pin47=PB3 PB10.Signal=GPXTI10 PB14.Signal=GPIO_Analog -PA5.Signal=GPIO_Analog +PA5.Signal=SPI1_SCK Mcu.Pin40=PA14 Mcu.Pin41=PA15 Mcu.Pin44=PC12 @@ -261,7 +262,7 @@ Mcu.Pin20=PC4 ADC1.master=1 PA3.Locked=true Mcu.Pin21=PC5 -PA5.GPIO_Label=PA5 +PA5.GPIO_Label=SPI_R_SCK PA10.Locked=true NVIC.ForceEnableDMAVector=true OSC_IN.Mode=HSE-External-Oscillator @@ -456,7 +457,7 @@ PB4.Signal=SPI1_MISO RCC.PLLSAI1N=6 PA3.Signal=GPIO_Output PA2.Locked=true -PB3.GPIO_Label=SPI_R_SCK +PB3.GPIO_Label=PB3 VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE PC15-OSC32_OUT.Mode=LSE-External-Oscillator @@ -467,7 +468,7 @@ PB9.GPIO_Label=IR_TX PC10.GPIO_Label=PC10 PA10.Mode=I2C ProjectManager.NoMain=false -SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,CLKPhase +SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,CLKPhase,BaudRatePrescaler USB_DEVICE.VirtualModeFS=Cdc_FS PC4.GPIO_PuPd=GPIO_PULLDOWN NVIC.SavedSvcallIrqHandlerGenerated=false @@ -551,7 +552,7 @@ Mcu.IP9=PKA Mcu.IP6=HSEM Mcu.IP7=I2C1 ProjectManager.CoupleFile=true -PB3.Signal=SPI1_SCK +PB3.Signal=GPIO_Analog RCC.SYSCLKFreq_VALUE=64000000 PA7.GPIO_Label=PA7 PA1.Locked=true