From 5020dd9f8e143aa9f9614c52ae1e4a8d95e73f2a Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Tue, 19 Mar 2024 12:55:24 +0800 Subject: [PATCH] sort those changes together --- Core/Src/dma.c | 10 +++------- Core/Src/main.c | 27 --------------------------- Core/Src/rtc.c | 4 ++-- Core/Src/stm32_lpm_if.c | 4 ++++ Core/Src/sys_app.c | 2 +- Core/Src/usart.c | 1 - Core/Src/yunhorn_sts_process.c | 5 +---- LoRaWAN/App/lora_app.c | 10 ++++++++++ 8 files changed, 21 insertions(+), 42 deletions(-) diff --git a/Core/Src/dma.c b/Core/Src/dma.c index 366b255..4adac40 100644 --- a/Core/Src/dma.c +++ b/Core/Src/dma.c @@ -44,9 +44,9 @@ void MX_DMA_Init(void) /* DMA controller clock enable */ __HAL_RCC_DMAMUX1_CLK_ENABLE(); __HAL_RCC_DMA1_CLK_ENABLE(); - __HAL_RCC_DMA2_CLK_ENABLE(); + //__HAL_RCC_DMA2_CLK_ENABLE(); /* DMA interrupt init */ - +#if 0 // **** TIM1_CH2 WS2812B @ PA-9 HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); @@ -73,16 +73,12 @@ void MX_DMA_Init(void) /* DMA1_Channel6_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn); +#endif /* DMA1_Channel7_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn); // **** USART2 - /* DMA2_Channel1_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Channel1_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DMA2_Channel1_IRQn); - - } /* USER CODE BEGIN 2 */ diff --git a/Core/Src/main.c b/Core/Src/main.c index f6c5681..bde61f9 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -123,33 +123,6 @@ int main(void) /* Infinite loop */ /* USER CODE BEGIN WHILE */ -#if 0 - while(1) - { - HAL_GPIO_WritePin(SOAP_SWITCH_GPIO_Port, SOAP_SWITCH_Pin, GPIO_PIN_SET); - HAL_Delay(1000); - //uint8_t soapData = SOAP_DATA; - uint8_t soapData = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin); - uint8_t read2nd = 0; - APP_LOG(TS_OFF, VLEVEL_L, "\r\n Soap State = %d \r\n", soapData); - #if 0 - HAL_GPIO_WritePin(SOAP_SWITCH_GPIO_Port, SOAP_SWITCH_Pin, GPIO_PIN_RESET); - HAL_Delay(1000); - read2nd = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin); - - APP_LOG(TS_OFF, VLEVEL_L, "\r\n 2nd read after 1 seconds= %d \r\n", read2nd); - - HAL_Delay(1000); - - read2nd = HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin); - - APP_LOG(TS_OFF, VLEVEL_L, "\r\n 3rd read after another 1 seconds= %d \r\n", read2nd); - #endif - HAL_Delay(20000); - - } -#endif - while (1) { diff --git a/Core/Src/rtc.c b/Core/Src/rtc.c index 436dbf3..7c2121f 100644 --- a/Core/Src/rtc.c +++ b/Core/Src/rtc.c @@ -67,7 +67,7 @@ void MX_RTC_Init(void) { Error_Handler(); } - +#if 0 /** Enable the Alarm A */ sAlarm.BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO; @@ -80,7 +80,7 @@ void MX_RTC_Init(void) Error_Handler(); } /* USER CODE BEGIN RTC_Init 2 */ - +#endif /* USER CODE END RTC_Init 2 */ } diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index 8c33849..1a579e6 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -82,6 +82,8 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver = void PWR_EnterOffMode(void) { /* USER CODE BEGIN EnterOffMode_1 */ + HAL_SuspendTick(); + HAL_PWR_EnterSTANDBYMode(); #if 0 HAL_SuspendTick(); HAL_UART_DeInit(&huart2); @@ -106,6 +108,8 @@ void PWR_EnterOffMode(void) void PWR_ExitOffMode(void) { /* USER CODE BEGIN ExitOffMode_1 */ + HAL_ResumeTick(); + return; #if 0 HAL_ResumeTick(); if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) diff --git a/Core/Src/sys_app.c b/Core/Src/sys_app.c index 994787b..f4b9484 100644 --- a/Core/Src/sys_app.c +++ b/Core/Src/sys_app.c @@ -123,7 +123,7 @@ void SystemApp_Init(void) UTIL_LPM_Init(); /* Disable Stand-by mode */ UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE); - + UTIL_LPM_SetOffMode((1 << CFG_LPM_UART_TX_Id), UTIL_LPM_ENABLE); #if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 1) /* Disable Stop Mode */ UTIL_LPM_SetStopMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE); diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 0739434..9c2da11 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -115,7 +115,6 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) GPIO_InitStruct.Pin = USARTx_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USART2 DMA Init */ diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 02e104d..5436734 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -34,7 +34,7 @@ #include "yunhorn_sts_prd_conf.h" #include "yunhorn_sts_sensors.h" #include "sts_cmox_hmac_sha.h" - +#include "main.h" /* USER CODE BEGIN Includes */ extern volatile sts_cfg_nvm_t sts_cfg_nvm; extern volatile uint8_t sts_ac_code[20]; @@ -580,12 +580,9 @@ void STS_SENSOR_NVM_CFG_SIMPLE(void) void STS_O5_SENSOR_Read(STS_OO_SensorDataTypeDef *oo_data) { - sts_reed_hall_result = (STS_Reed_Hall_State==0)?1:0; - oo_data->state_sensor1_on_off = sts_reed_hall_result; - sensor_data_ready = 1; } #endif diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 8563aea..791b96e 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -721,6 +721,16 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params) break; } } + + DeviceClass_t deviceClass = CLASS_A; + LmHandlerGetCurrentClass( &deviceClass ); + uint8_t i=0; + outbuf[i++] = (uint8_t) 'L'; + outbuf[i++] = (uint8_t) sts_mtmcode1; + outbuf[i++] = (uint8_t) sts_mtmcode2; + outbuf[i++] = (uint8_t) sts_version; + outbuf[i++] = (uint8_t) (0x41+ deviceClass); //translate to 'A','B','C' + STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf); break; case LORAWAN_USER_APP_PORT: if (appData->BufferSize == 1)