From 24a37e9e5fc345c9f71716e9318ca7452e0d6fd8 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 26 Feb 2021 20:02:52 +0100 Subject: [PATCH] modem uart --- cube/Core/Inc/main.h | 2 +- cube/Core/Inc/stm32f1xx_it.h | 1 + cube/Core/Src/stm32f1xx_it.c | 15 +++++++++++++++ cube/Core/Src/stm32f1xx_it.c-bak | 15 +++++++++++++++ cube/Core/Src/usart.c | 5 +++++ cube/Makefile.sav | 7 +++++-- cube/cube.ioc | 5 +++-- 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/cube/Core/Inc/main.h b/cube/Core/Inc/main.h index 686f13b..f29559b 100644 --- a/cube/Core/Inc/main.h +++ b/cube/Core/Inc/main.h @@ -61,8 +61,8 @@ void Error_Handler(void); #define eepromSpi hspi1 #define etherSpi hspi2 #define debugUart huart1 -#define modemUart huart2 #define mainsCnt htim1 +#define modemUart huart2 #define LED_Red_Pin GPIO_PIN_13 #define LED_Red_GPIO_Port GPIOC #define LED_Green_Pin GPIO_PIN_14 diff --git a/cube/Core/Inc/stm32f1xx_it.h b/cube/Core/Inc/stm32f1xx_it.h index cbb37a7..a998416 100644 --- a/cube/Core/Inc/stm32f1xx_it.h +++ b/cube/Core/Inc/stm32f1xx_it.h @@ -59,6 +59,7 @@ void SysTick_Handler(void); void TIM1_CC_IRQHandler(void); void SPI1_IRQHandler(void); void USART1_IRQHandler(void); +void USART2_IRQHandler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/cube/Core/Src/stm32f1xx_it.c b/cube/Core/Src/stm32f1xx_it.c index 23f5010..0ec773a 100644 --- a/cube/Core/Src/stm32f1xx_it.c +++ b/cube/Core/Src/stm32f1xx_it.c @@ -62,6 +62,7 @@ extern SPI_HandleTypeDef hspi1; extern TIM_HandleTypeDef htim1; extern UART_HandleTypeDef huart1; +extern UART_HandleTypeDef huart2; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -246,6 +247,20 @@ void USART1_IRQHandler(void) /* 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 */ +} + /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ diff --git a/cube/Core/Src/stm32f1xx_it.c-bak b/cube/Core/Src/stm32f1xx_it.c-bak index a383998..e4675a1 100644 --- a/cube/Core/Src/stm32f1xx_it.c-bak +++ b/cube/Core/Src/stm32f1xx_it.c-bak @@ -59,6 +59,7 @@ extern SPI_HandleTypeDef hspi1; extern TIM_HandleTypeDef htim1; extern UART_HandleTypeDef huart1; +extern UART_HandleTypeDef huart2; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -241,6 +242,20 @@ void USART1_IRQHandler(void) /* 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 */ +} + /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ diff --git a/cube/Core/Src/usart.c b/cube/Core/Src/usart.c index f8d4680..7d6881f 100644 --- a/cube/Core/Src/usart.c +++ b/cube/Core/Src/usart.c @@ -123,6 +123,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(MODEM_RX_GPIO_Port, &GPIO_InitStruct); + /* 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 */ @@ -166,6 +169,8 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) */ HAL_GPIO_DeInit(GPIOA, MODEM_TX_Pin|MODEM_RX_Pin); + /* USART2 interrupt Deinit */ + HAL_NVIC_DisableIRQ(USART2_IRQn); /* USER CODE BEGIN USART2_MspDeInit 1 */ /* USER CODE END USART2_MspDeInit 1 */ diff --git a/cube/Makefile.sav b/cube/Makefile.sav index d831d26..e3ba010 100644 --- a/cube/Makefile.sav +++ b/cube/Makefile.sav @@ -97,11 +97,14 @@ C_SOURCES += \ User/Src/ports.c \ User/Src/wizHelper.c \ User/Src/networkAbstractionLayer_lan.c +NETWORK_STACK=1 endif ifeq ($(NETWORK), WiFi) C_SOURCES += \ -User/Src/networkAbstractionLayer_wifi.c +User/Src/networkAbstractionLayer_wifi.c \ +User/Src/modemCom.c +NETWORK_STACK=2 endif # ASM sources @@ -181,7 +184,7 @@ endif # compile gcc flags ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -Werror -fdata-sections -ffunction-sections -CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -DNETWORK=$(NETWORK) -DVERSION="\"$(VERSION)\"" -Wall -Werror -fdata-sections -ffunction-sections +CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -DNETWORK_STACK=$(NETWORK_STACK) -DVERSION="\"$(VERSION)\"" -Wall -Werror -fdata-sections -ffunction-sections ifeq ($(DEBUG), 1) CFLAGS += -g -gdwarf-2 diff --git a/cube/cube.ioc b/cube/cube.ioc index 123a239..ffc38e6 100644 --- a/cube/cube.ioc +++ b/cube/cube.ioc @@ -47,7 +47,7 @@ Mcu.Pin8=PA4 Mcu.Pin9=PA5 Mcu.PinsNb=28 Mcu.ThirdPartyNb=0 -Mcu.UserConstants=eepromSpi,hspi1;etherSpi,hspi2;debugUart,huart1;mainsCnt,htim1 +Mcu.UserConstants=eepromSpi,hspi1;etherSpi,hspi2;debugUart,huart1;mainsCnt,htim1;modemUart,huart2 Mcu.UserName=STM32F103C8Tx MxCube.Version=6.0.0 MxDb.Version=DB.6.0.0 @@ -64,6 +64,7 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true NVIC.TIM1_CC_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true +NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false PA1.GPIOParameters=GPIO_Label PA1.GPIO_Label=MODEM_RES @@ -187,7 +188,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Makefile ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_SPI2_Init-SPI2-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_USART1_UART_Init-USART1-false-HAL-true,7-MX_IWDG_Init-IWDG-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_SPI2_Init-SPI2-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_USART1_UART_Init-USART1-false-HAL-true,7-MX_IWDG_Init-IWDG-false-HAL-true,8-MX_USART2_UART_Init-USART2-false-HAL-true RCC.ADCFreqValue=36000000 RCC.AHBFreq_Value=72000000 RCC.APB1CLKDivider=RCC_HCLK_DIV2