From f31b17a3d548564ad3c14326533833a199afedb5 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 24 Apr 2024 19:42:44 +0800 Subject: [PATCH] revised PME_ON, OFF --- Core/Inc/main.h | 7 ++++--- Core/Src/yunhorn_sts_process.c | 20 +++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Core/Inc/main.h b/Core/Inc/main.h index 5914dbc..da8a051 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -109,12 +109,13 @@ void MX_TOF_Init(void); #define USARTx_TX_Pin GPIO_PIN_2 #define USARTx_TX_GPIO_Port GPIOA -#define MEMS_POWER_Pin GPIO_PIN_4 // PMU_ENABLE -#define MEMS_POWER_GPIO_Port GPIOB // PMU_ENABLE +#define MEMS_POWER_Pin GPIO_PIN_4 // PMU_ENABLE +#define MEMS_POWER_GPIO_Port GPIOB // PMU_ENABLE #define MEMS_RESET_Pin GPIO_PIN_4 #define MEMS_RESET_GPIO_Port GPIOB - +#define PME_ON HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port,MEMS_POWER_Pin,GPIO_PIN_SET) +#define PME_OFF HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port,MEMS_POWER_Pin,GPIO_PIN_RESET) #define TOF250_I2C_ADDR (0x52<<1) #if defined(STM32WLE5xx) || defined(STM32WL55xx) diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index 1d23415..72d8db8 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -524,11 +524,7 @@ void STS_SENSOR_Power_ON(uint8_t cnt) case 0: case 1: case 2: -#if (defined(YUNHORN_STS_M7_ENABLED) || defined(YUNHORN_STS_R0_ENABLED)) - HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_SET); -#endif - - + PME_ON; break; default: break; @@ -541,10 +537,7 @@ void STS_SENSOR_Power_OFF(uint8_t cnt) case 0: case 1: case 2: -#if (defined(YUNHORN_STS_M7_ENABLED) || defined(YUNHORN_STS_R0_ENABLED)) - HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_RESET); -#endif - + PME_OFF; break; default: break; @@ -557,14 +550,7 @@ void STS_SENSOR_MEMS_Reset(uint8_t cnt) case 0: case 1: case 2: -#if (defined(YUNHORN_STS_M7_ENABLED) || defined(YUNHORN_STS_R0_ENABLED)) - HAL_GPIO_WritePin(MEMS_RESET_GPIO_Port, MEMS_RESET_Pin, GPIO_PIN_SET); - HAL_Delay(50); - HAL_GPIO_WritePin(MEMS_RESET_GPIO_Port, MEMS_RESET_Pin, GPIO_PIN_RESET); -#endif - HAL_GPIO_WritePin(MEMS_RESET_GPIO_Port, MEMS_RESET_Pin, GPIO_PIN_SET); - HAL_Delay(50); - HAL_GPIO_WritePin(MEMS_RESET_GPIO_Port, MEMS_RESET_Pin, GPIO_PIN_RESET); + HAL_GPIO_TogglePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin); break; default: break;