diff --git a/Core/Inc/main.h b/Core/Inc/main.h new file mode 100644 index 0000000..c87b808 --- /dev/null +++ b/Core/Inc/main.h @@ -0,0 +1,215 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file: main.h * + * @author Yunhorn (r) Technology Limited Application Team * + * @brief Yunhorn (r) SmarToilets (r) Product configuration file. * + ****************************************************************************** + * @attention + * + * Copyright (c) 2023 Yunhorn Technology Limited. + * Copyright (c) 2023 Shenzhen Yunhorn Technology Co., Ltd. + * All rights reserved. + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wlxx_hal.h" +#include "yunhorn_sts_prd_conf.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ +void MX_I2C2_Init(void); +void MX_DMA_Init(void); +void MX_TOF_Init(void); +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define RTC_N_PREDIV_S 10 +#define RTC_PREDIV_S ((1<>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 __HAL_RCC_GPIOC_CLK_DISABLE(); /*Configure GPIO pin Output Level */ @@ -92,7 +96,7 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct); #endif - +#if 0 /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = BUT2_Pin; #ifdef TOF_2 @@ -109,8 +113,8 @@ void MX_GPIO_Init(void) GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(BUT1_GPIO_Port, &GPIO_InitStruct); +#endif - __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pins : TOF_C_INT_Pin */ #if defined(TOF_1) GPIO_InitStruct.Pin = TOF_C_INT_Pin; @@ -195,13 +199,17 @@ HAL_GPIO_Init(SOAP_SWITCH_GPIO_Port, &GPIO_InitStruct); /* ============== SOAP LEVEL DETECTION ========================= */ #endif +//__HAL_RCC_GPIOA_CLK_DISABLE(); +//__HAL_RCC_GPIOB_CLK_DISABLE(); +#if 0 /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI0_IRQn); HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(EXTI1_IRQn); +#endif #if defined(TOF_1) HAL_NVIC_SetPriority(TOF_C_INT_EXTI_IRQn, 0, 0); HAL_NVIC_EnableIRQ(TOF_C_INT_EXTI_IRQn); diff --git a/Core/Src/i2c.c b/Core/Src/i2c.c index 89074ee..5237598 100644 --- a/Core/Src/i2c.c +++ b/Core/Src/i2c.c @@ -88,8 +88,8 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle) /** Initializes the peripherals clocks */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C2; - PeriphClkInitStruct.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1; + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C2; + PeriphClkInitStruct.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index bc98a7c..3cb075b 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -80,14 +80,34 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver = void PWR_EnterOffMode(void) { +<<<<<<< HEAD /* USER CODE BEGIN EnterOffMode_1 */ /* USER CODE END EnterOffMode_1 */ +======= + + POWER_OFF; + + HAL_GPIO_DeInit(GPIOA,GPIO_PIN_All); + HAL_GPIO_DeInit(GPIOB,GPIO_PIN_All); + HAL_GPIO_DeInit(GPIOC,GPIO_PIN_All); + HAL_SuspendTick(); + HAL_PWR_EnterSTANDBYMode(); + +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 } void PWR_ExitOffMode(void) { /* USER CODE BEGIN ExitOffMode_1 */ +<<<<<<< HEAD +======= +#if 1 + POWER_ON; + HAL_ResumeTick(); + return; +#endif +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 /* USER CODE END ExitOffMode_1 */ } @@ -95,11 +115,17 @@ void PWR_ExitOffMode(void) void PWR_EnterStopMode(void) { /* USER CODE BEGIN EnterStopMode_1 */ +<<<<<<< HEAD HAL_UART_DeInit(&huart2); vcom_DeInit(); HAL_GPIO_WritePin(GPIOA,GPIO_PIN_All, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB,GPIO_PIN_All, GPIO_PIN_RESET); #if 0 +======= + POWER_OFF; + //HAL_UART_DeInit(&huart2); + //vcom_DeInit(); +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 HAL_GPIO_DeInit(GPIOA,GPIO_PIN_All); HAL_GPIO_DeInit(GPIOB,GPIO_PIN_All); #endif @@ -124,6 +150,7 @@ void PWR_ExitStopMode(void) /* USER CODE END ExitStopMode_1 */ /* Resume sysTick : work around for debugger problem in dual core */ + POWER_ON; HAL_ResumeTick(); /*Not retained periph: ADC interface diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c index 9157797..a8d27e1 100644 --- a/Core/Src/stm32wlxx_it.c +++ b/Core/Src/stm32wlxx_it.c @@ -234,7 +234,7 @@ void TAMP_STAMP_LSECSS_SSRU_IRQHandler(void) /* USER CODE END TAMP_STAMP_LSECSS_SSRU_IRQn 1 */ } - +#if 0 /** * @brief This function handles EXTI Line 0 Interrupt. */ @@ -249,7 +249,8 @@ void EXTI0_IRQHandler(void) /* USER CODE END EXTI0_IRQn 1 */ } - +#endif +#if 0 /** * @brief This function handles EXTI Line 1 Interrupt. */ @@ -263,7 +264,7 @@ void EXTI1_IRQHandler(void) /* USER CODE END EXTI1_IRQn 1 */ } - +#endif /** * @brief This function handles DMA1 Channel 2 Interrupt. @@ -342,6 +343,7 @@ void DMA1_Channel6_IRQHandler(void) /* USER CODE END DMA1_Channel6_IRQn 1 */ } #endif +#if 0 /** * @brief This function handles DMA1 Channel 7 Interrupt. */ @@ -355,6 +357,19 @@ void DMA1_Channel7_IRQHandler(void) /* USER CODE END DMA1_Channel7_IRQn 1 */ } +#endif +void EXTI3_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI3_IRQn 0 */ + + /* USER CODE END EXTI3_IRQn 0 */ +#ifdef STM32WLE5xx + HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN); +#endif + /* USER CODE BEGIN EXTI3_IRQn 1 */ + + /* USER CODE END EXTI3_IRQn 1 */ +} #if 0 /** @@ -371,7 +386,7 @@ void EXTI4_IRQHandler(void) /* USER CODE END EXTI9_5_IRQn 1 */ } #endif - +#if 0 /** * @brief This function handles EXTI Lines [9:5] Interrupt. */ @@ -410,7 +425,8 @@ void EXTI3_IRQHandler(void) /* USER CODE END EXTI9_5_IRQn 1 */ } - +#endif +#if 0 /** * @brief This function handles EXTI Lines [9:5] Interrupt. */ @@ -426,9 +442,9 @@ void EXTI15_10_IRQHandler(void) /* USER CODE END EXTI15_10_IRQn 1 */ } +#endif - - +#if 0 /** * @brief This function handles USART2 Interrupt. */ @@ -442,7 +458,7 @@ void USART2_IRQHandler(void) /* USER CODE END USART2_IRQn 1 */ } - +#endif /** * @brief This function handles RTC Alarms (A and B) Interrupt. */ diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 1c8bcf9..2f44737 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -28,9 +28,7 @@ UART_HandleTypeDef huart2; DMA_HandleTypeDef hdma_usart2_tx; -#if 0 -DMA_HandleTypeDef hdma_usart2_rx; -#endif + /* USART2 init function */ void MX_USART2_UART_Init(void) @@ -62,12 +60,7 @@ void MX_USART2_UART_Init(void) { Error_Handler(); } -#if 0 - if (HAL_UARTEx_SetRxFifoThreshold(&huart2, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) - { - Error_Handler(); - } -#endif + if (HAL_UARTEx_EnableFifoMode(&huart2) != HAL_OK) { Error_Handler(); diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject index 79ad68b..bba8485 100644 --- a/STM32CubeIDE/.cproject +++ b/STM32CubeIDE/.cproject @@ -1,3 +1,4 @@ +<<<<<<< HEAD @@ -237,4 +238,245 @@ +======= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 \ No newline at end of file diff --git a/STM32CubeIDE/.settings/language.settings.xml b/STM32CubeIDE/.settings/language.settings.xml index fca738d..1ff67c8 100644 --- a/STM32CubeIDE/.settings/language.settings.xml +++ b/STM32CubeIDE/.settings/language.settings.xml @@ -5,7 +5,11 @@ +<<<<<<< HEAD +======= + +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 @@ -16,7 +20,11 @@ +<<<<<<< HEAD +======= + +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 diff --git a/STM32CubeIDE/STM32WLE5CCUX_FLASH.ld b/STM32CubeIDE/STM32WLE5CCUX_FLASH.ld index a1bcb94..e02ffc2 100644 --- a/STM32CubeIDE/STM32WLE5CCUX_FLASH.ld +++ b/STM32CubeIDE/STM32WLE5CCUX_FLASH.ld @@ -1,3 +1,4 @@ +<<<<<<< HEAD /* ****************************************************************************** ** @@ -184,3 +185,191 @@ SECTIONS .ARM.attributes 0 : { *(.ARM.attributes) } } +======= +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : STM32CubeIDE +** +** Abstract : Linker script for STM32WLE5xC Device +** 256Kbytes FLASH +** 64Kbytes RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed as is without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +** Copyright (c) 2022 STMicroelectronics. +** All rights reserved. +** +** This software is licensed under terms that can be found in the LICENSE file +** in the root directory of this software component. +** If no LICENSE file comes with this software, it is provided AS-IS. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x800; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K + RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab (READONLY) : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM (READONLY): { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array (READONLY) : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array (READONLY): + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array (READONLY): + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} +>>>>>>> 1458ae8e13a1641094a8aa2707dd4983bd07cd89 diff --git a/TOF/App/X-WL55_WLE5_53L0X.c b/TOF/App/X-WL55_WLE5_53L0X.c index 9d9260c..12b332b 100644 --- a/TOF/App/X-WL55_WLE5_53L0X.c +++ b/TOF/App/X-WL55_WLE5_53L0X.c @@ -101,6 +101,7 @@ static void _I2cFailRecover(){ }while(HAL_GPIO_ReadPin(I2C2_SDA_PORT, I2C2_SDA_PIN) == 0 && nRetry++<7); if( HAL_GPIO_ReadPin(I2C2_SDA_PORT, I2C2_SDA_PIN) == 0 ){ +#if 0 __GPIOA_CLK_ENABLE(); //We are still in bad i2c state warm user by blinking led but stay here GPIO_InitStruct.Pin = LED1_Pin ; @@ -117,6 +118,7 @@ static void _I2cFailRecover(){ HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); HAL_Delay(33*20); }while(1); +#endif } } diff --git a/TOF/App/X-WL55_WLE5_53L0X.h b/TOF/App/X-WL55_WLE5_53L0X.h index 826ae63..0381a61 100644 --- a/TOF/App/X-WL55_WLE5_53L0X.h +++ b/TOF/App/X-WL55_WLE5_53L0X.h @@ -136,6 +136,7 @@ extern void XNUCLEO53L1A1_USART2_UART_Init(void); #endif /* ############ FOR SHARED GPIO1 INTR TO MCU ###### */ +#if 0 #define VL53L0X_GPIO1_C_GPIO_PORT GPIOA #define VL53L0X_GPIO1_C_CLK_ENABLE __GPIOA_CLK_ENABLE #define VL53L0X_GPIO1_C_GPIO_PIN GPIO_PIN_10 @@ -150,6 +151,22 @@ extern void XNUCLEO53L1A1_USART2_UART_Init(void); #define VL53L0X_GPIO1_R_CLK_ENABLE __GPIOA_CLK_ENABLE #define VL53L0X_GPIO1_R_GPIO_PIN GPIO_PIN_10 #define VL53L0X_GPIO1_R_INTx EXTI15_10_IRQn +#endif +#define VL53L0X_GPIO1_C_GPIO_PORT GPIOB +#define VL53L0X_GPIO1_C_CLK_ENABLE __GPIOB_CLK_ENABLE +#define VL53L0X_GPIO1_C_GPIO_PIN GPIO_PIN_3 +#define VL53L0X_GPIO1_C_INTx EXTI3_IRQn + +#define VL53L0X_GPIO1_L_GPIO_PORT GPIOB +#define VL53L0X_GPIO1_L_CLK_ENABLE __GPIOB_CLK_ENABLE +#define VL53L0X_GPIO1_L_GPIO_PIN GPIO_PIN_3 +#define VL53L0X_GPIO1_L_INTx EXTI3_IRQn + +#define VL53L0X_GPIO1_R_GPIO_PORT GPIOB +#define VL53L0X_GPIO1_R_CLK_ENABLE __GPIOB_CLK_ENABLE +#define VL53L0X_GPIO1_R_GPIO_PIN GPIO_PIN_3 +#define VL53L0X_GPIO1_R_INTx EXTI3_IRQn + /* ############ FOR SHARED GPIO1 INTR TO MCU ###### */ /** @} */ /* defgroup L53L1A1_GPIO1_MAP */