diff --git a/Inc/main.h b/Inc/main.h index efbacc90..56c8ff7a 100644 --- a/Inc/main.h +++ b/Inc/main.h @@ -59,10 +59,10 @@ void Error_Handler(void); /* Private defines -----------------------------------------------------------*/ #define CH395_INT_Pin GPIO_PIN_5 #define CH395_INT_GPIO_Port GPIOE -#define LED1_Pin GPIO_PIN_4 +#define LED1_Pin GPIO_PIN_5 #define LED1_GPIO_Port GPIOC -#define LED2_Pin GPIO_PIN_5 -#define LED2_GPIO_Port GPIOC +#define LED2_Pin GPIO_PIN_0 +#define LED2_GPIO_Port GPIOB #define LED3_Pin GPIO_PIN_1 #define LED3_GPIO_Port GPIOB #define LED4_Pin GPIO_PIN_2 @@ -89,10 +89,10 @@ void Error_Handler(void); #define CH395_SCS_GPIO_Port GPIOB #define CH395F_SCK_Pin GPIO_PIN_13 #define CH395F_SCK_GPIO_Port GPIOB -#define CH395F_SDO_Pin GPIO_PIN_14 +#define CH395F_SDI_Pin GPIO_PIN_14 +#define CH395F_SDI_GPIO_Port GPIOB +#define CH395F_SDO_Pin GPIO_PIN_15 #define CH395F_SDO_GPIO_Port GPIOB -#define CH395F_SDOB15_Pin GPIO_PIN_15 -#define CH395F_SDOB15_GPIO_Port GPIOB #define DB2_Pin GPIO_PIN_2 #define DB2_GPIO_Port GPIOG #define DB3_Pin GPIO_PIN_3 diff --git a/STM32F407-Demo.ioc b/STM32F407-Demo.ioc index 7606de09..a8472649 100644 --- a/STM32F407-Demo.ioc +++ b/STM32F407-Demo.ioc @@ -120,7 +120,7 @@ Mcu.Pin26=PG8 Mcu.Pin27=PA9 Mcu.Pin28=PA10 Mcu.Pin29=PA13 -Mcu.Pin3=PC4 +Mcu.Pin3=PC5 Mcu.Pin30=PA14 Mcu.Pin31=PC10 Mcu.Pin32=PC11 @@ -131,7 +131,7 @@ Mcu.Pin36=PD2 Mcu.Pin37=PD3 Mcu.Pin38=PD4 Mcu.Pin39=PD5 -Mcu.Pin4=PC5 +Mcu.Pin4=PB0 Mcu.Pin40=PD6 Mcu.Pin41=PD7 Mcu.Pin42=PG9 @@ -160,8 +160,8 @@ Mcu.PinsNb=59 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F407ZGTx -MxCube.Version=6.17.0 -MxDb.Version=DB.6.0.170 +MxCube.Version=6.18.1 +MxDb.Version=DB.6.0.181 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.DMA1_Stream3_IRQn=true\:7\:0\:true\:false\:true\:true\:false\:true\:true NVIC.DMA1_Stream4_IRQn=true\:7\:0\:true\:false\:true\:true\:false\:true\:true @@ -209,10 +209,13 @@ PA9.GPIO_PuPd=GPIO_NOPULL PA9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PA9.Mode=Asynchronous PA9.Signal=USART1_TX -PB1.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label +PB0.GPIOParameters=PinState,GPIO_Label +PB0.GPIO_Label=LED2 +PB0.Locked=true +PB0.PinState=GPIO_PIN_SET +PB0.Signal=GPIO_Output +PB1.GPIOParameters=PinState,GPIO_Label PB1.GPIO_Label=LED3 -PB1.GPIO_PuPd=GPIO_PULLUP -PB1.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PB1.Locked=true PB1.PinState=GPIO_PIN_SET PB1.Signal=GPIO_Output @@ -239,7 +242,7 @@ PB13.Locked=true PB13.Mode=Full_Duplex_Master PB13.Signal=SPI2_SCK PB14.GPIOParameters=GPIO_PuPd,GPIO_Label -PB14.GPIO_Label=CH395F_SDO +PB14.GPIO_Label=CH395F_SDI PB14.GPIO_PuPd=GPIO_PULLUP PB14.Locked=true PB14.Mode=Full_Duplex_Master @@ -306,25 +309,19 @@ PC12.GPIO_Label=ST_TX4 PC12.Locked=true PC12.Mode=Asynchronous PC12.Signal=UART5_TX -PC4.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label -PC4.GPIO_Label=LED1 -PC4.GPIO_PuPd=GPIO_PULLUP -PC4.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PC4.Locked=true -PC4.PinState=GPIO_PIN_SET -PC4.Signal=GPIO_Output -PC5.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label -PC5.GPIO_Label=LED2 -PC5.GPIO_PuPd=GPIO_PULLUP -PC5.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PC5.GPIOParameters=PinState,GPIO_Label +PC5.GPIO_Label=LED1 PC5.Locked=true PC5.PinState=GPIO_PIN_SET PC5.Signal=GPIO_Output +PCC.Bar.Display=Horizontal Bar PCC.Checker=false PCC.Display=Plot\: All Steps PCC.Line=STM32F407/417 PCC.MCU=STM32F407Z(E-G)Tx PCC.PartNumber=STM32F407ZGTx +PCC.SequenceTime=1.0 ms +PCC.SequenceTime.Unit=ms PCC.Series=STM32F4 PCC.Temperature=25 PCC.Vdd=3.3 diff --git a/Src/gpio.c b/Src/gpio.c index d62e88e1..7bd24b0b 100644 --- a/Src/gpio.c +++ b/Src/gpio.c @@ -55,10 +55,11 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, LED1_Pin|LED2_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, LED3_Pin|LED4_Pin|CH395_SCS_Pin|GD_WP_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(GPIOB, LED2_Pin|LED3_Pin|LED4_Pin|CH395_SCS_Pin + |GD_WP_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOF, LED5_Pin|LED6_Pin, GPIO_PIN_SET); @@ -81,19 +82,26 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(CH395_INT_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : LED1_Pin LED2_Pin */ - GPIO_InitStruct.Pin = LED1_Pin|LED2_Pin; + /*Configure GPIO pin : LED1_Pin */ + GPIO_InitStruct.Pin = LED1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : LED3_Pin LED4_Pin */ - GPIO_InitStruct.Pin = LED3_Pin|LED4_Pin; + /*Configure GPIO pins : LED2_Pin LED3_Pin */ + GPIO_InitStruct.Pin = LED2_Pin|LED3_Pin; + 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 pin : LED4_Pin */ + GPIO_InitStruct.Pin = LED4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + HAL_GPIO_Init(LED4_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : LED5_Pin LED6_Pin */ GPIO_InitStruct.Pin = LED5_Pin|LED6_Pin; diff --git a/Src/spi.c b/Src/spi.c index c875b811..b9b79baa 100644 --- a/Src/spi.c +++ b/Src/spi.c @@ -179,19 +179,19 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) PB14 ------> SPI2_MISO PB15 ------> SPI2_MOSI */ - GPIO_InitStruct.Pin = CH395F_SCK_Pin|CH395F_SDOB15_Pin; + GPIO_InitStruct.Pin = CH395F_SCK_Pin|CH395F_SDO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - GPIO_InitStruct.Pin = CH395F_SDO_Pin; + GPIO_InitStruct.Pin = CH395F_SDI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; - HAL_GPIO_Init(CH395F_SDO_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(CH395F_SDI_GPIO_Port, &GPIO_InitStruct); /* SPI2 DMA Init */ /* SPI2_RX Init */ @@ -280,7 +280,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle) PB14 ------> SPI2_MISO PB15 ------> SPI2_MOSI */ - HAL_GPIO_DeInit(GPIOB, CH395F_SCK_Pin|CH395F_SDO_Pin|CH395F_SDOB15_Pin); + HAL_GPIO_DeInit(GPIOB, CH395F_SCK_Pin|CH395F_SDI_Pin|CH395F_SDO_Pin); /* SPI2 DMA DeInit */ HAL_DMA_DeInit(spiHandle->hdmarx);