diff --git a/Core/Inc/main.h b/Core/Inc/main.h index f10aa6a..2e0c2bf 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -211,17 +211,15 @@ void Error_Handler(void); #endif // defined(VL53LX)||defined(VL53L0) /* VL53L8A1 for Power_En, LPn, Int */ +/* for Yunhorn STS_RM1.3 Round PCB */ #ifdef L8 -#define TOF_INT_EXTI_PIN (GPIO_PIN_10) //(GPIO_PIN_4) +#define TOF_INT_EXTI_PIN (GPIO_PIN_15) //(GPIO_PIN_4) #define TOF_INT_EXTI_PORT (GPIOA) //(GPIOA) #define TOF_INT_EXTI_IRQn EXTI15_10_IRQn - -#define VL53L8A1_PWR_EN_C_PIN (GPIO_PIN_7) //(GPIO_PIN_7) -#define VL53L8A1_PWR_EN_C_PORT (GPIOA) //(GPIOA) - -#define VL53L8A1_LPn_C_PIN (GPIO_PIN_4) //(GPIO_PIN_0) -#define VL53L8A1_LPn_C_PORT (GPIOB) //(GPIOB) - +#define VL53L8A1_PWR_EN_C_PIN (GPIO_PIN_4) //(GPIO_PIN_7) +#define VL53L8A1_PWR_EN_C_PORT (GPIOB) //(GPIOA) +#define VL53L8A1_LPn_C_PIN (GPIO_PIN_10) //(GPIO_PIN_0) +#define VL53L8A1_LPn_C_PORT (GPIOA) //(GPIOB) #endif @@ -232,9 +230,14 @@ void Error_Handler(void); // FOR STM32WLE5CCU6 UFQFPN48 PA12 PA11 #ifdef STM32WLE5xx -#define I2C2_STANDARD_100K 0x00000E14 -#define I2C2_FAST_400K 0x00000004 -#define I2C2_FAST_PLUS_1M 0x00000000 +//#define I2C2_STANDARD_100K 0x00000E14 +//#define I2C2_FAST_400K 0x00000004 +//#define I2C2_FAST_PLUS_1M 0x00000000 + +#define I2C2_STANDARD_100K 0x10805D88 +#define I2C2_FAST_400K 0x0090194B +#define I2C2_FAST_PLUS_1M 0x00700814 + #else /* * FOR STM32WLE5CCU6 UFQFPN48 PA12 PA11 diff --git a/Core/Src/dma.c b/Core/Src/dma.c index 0aad753..523a960 100644 --- a/Core/Src/dma.c +++ b/Core/Src/dma.c @@ -80,8 +80,7 @@ void MX_DMA_Init(void) //HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0); //HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn); - HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 2, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn); + } diff --git a/Core/Src/main.c b/Core/Src/main.c index a0ab3d1..867d38c 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -124,9 +124,9 @@ int main(void) while (1) { /* USER CODE END WHILE */ - + //MX_TOF_Process(); MX_LoRaWAN_Process(); - //MX_TOF_Process(); + // MX_TOF_Ranging_Process(); /* USER CODE BEGIN 3 */ diff --git a/Core/Src/stm32wlxx_nucleo_bus.c b/Core/Src/stm32wlxx_nucleo_bus.c index 751b22b..145b527 100644 --- a/Core/Src/stm32wlxx_nucleo_bus.c +++ b/Core/Src/stm32wlxx_nucleo_bus.c @@ -400,7 +400,8 @@ __weak HAL_StatusTypeDef MX_I2C2_Init(I2C_HandleTypeDef* hi2c) HAL_StatusTypeDef ret = HAL_OK; hi2c->Instance = I2C2; - hi2c->Init.Timing = 0x20303E5D; + //hi2c->Init.Timing = 0x20303E5D; + hi2c->Init.Timing = 0x0090194B; // 2024 NOV 13 10:20PM hi2c->Init.OwnAddress1 = 0; hi2c->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; @@ -448,14 +449,14 @@ static void I2C2_MspInit(I2C_HandleTypeDef* i2cHandle) GPIO_InitStruct.Pin = BUS_I2C2_SCL_GPIO_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = BUS_I2C2_SCL_GPIO_AF; HAL_GPIO_Init(BUS_I2C2_SCL_GPIO_PORT, &GPIO_InitStruct); GPIO_InitStruct.Pin = BUS_I2C2_SDA_GPIO_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = BUS_I2C2_SDA_GPIO_AF; HAL_GPIO_Init(BUS_I2C2_SDA_GPIO_PORT, &GPIO_InitStruct); diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 64cf905..b813bfb 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -42,7 +42,7 @@ void MX_USART2_UART_Init(void) /* USER CODE END USART2_Init 1 */ huart2.Instance = USART2; #ifdef L8 - huart2.Init.BaudRate = 460800; + huart2.Init.BaudRate = 921600; #else huart2.Init.BaudRate = 115200; #endif diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 3bc6e31..fc22fbc 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -560,17 +560,21 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0); } break; + #ifndef STS_R4 case BUT2_Pin: UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), CFG_SEQ_Prio_0); break; #endif + case BUT3_Pin: UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaStoreContextEvent), CFG_SEQ_Prio_0); break; #if (defined(VL53L0)||defined(VL53LX)||defined(L8)) case TOF_INT_EXTI_PIN: + printf("\r\n ToF Event Detected=%d \r\n", ToF_EventDetected); ToF_EventDetected = 1; + printf("\r\n ToF Event Detected=%d \r\n", ToF_EventDetected); break; #endif default: diff --git a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf index adb291f..c8e6583 100644 Binary files a/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf and b/STM32CubeIDE/Release/WLE5CC_NODE_STS.elf differ diff --git a/STS/Core/Src/yunhorn_sts_process.c b/STS/Core/Src/yunhorn_sts_process.c index 361672f..f88872d 100644 --- a/STS/Core/Src/yunhorn_sts_process.c +++ b/STS/Core/Src/yunhorn_sts_process.c @@ -121,7 +121,7 @@ volatile uint8_t sensor_data_ready=0; #if defined(STS_R1)||defined(STS_R5)||defined(STS_R4)||defined(STS_R1D) volatile uint32_t STS_TOFScanPeriod_msec=50, STS_TxPeriod_sec=30, STS_HeartBeatTimerPeriod_sec=3600; #elif defined(STS_L8)||defined(STS_P2)||defined(STS_O6T)||defined(STS_T6) -volatile uint32_t STS_TOFScanPeriod_msec=500, STS_TxPeriod_sec=10, STS_HeartBeatTimerPeriod_sec=60; +volatile uint32_t STS_TOFScanPeriod_msec=100, STS_TxPeriod_sec=10, STS_HeartBeatTimerPeriod_sec=60; #endif static uint8_t outbuf[128]={0x0}; diff --git a/STS/TOF/App/app_tof.c b/STS/TOF/App/app_tof.c index 5fbc0b0..ca4a8b9 100644 --- a/STS/TOF/App/app_tof.c +++ b/STS/TOF/App/app_tof.c @@ -69,8 +69,8 @@ extern "C" { #ifdef L8 /* for VL53L8A1 */ #define RANGING_FREQUENCY (10U) /* Ranging frequency Hz (shall be consistent with TimingBudget value) */ -#define LOW_THRESHOLD (2000U) -#define HIGH_THRESHOLD (2600U) +#define LOW_THRESHOLD (200U) +#define HIGH_THRESHOLD (600U) /* Private variables ---------------------------------------------------------*/ static RANGING_SENSOR_Capabilities_t Cap; @@ -241,7 +241,7 @@ static void MX_53L8A1_ThresholdDetection_Init(void) printf("VL53L8A1_RANGING_SENSOR_Init failed\n"); //while (1); } - + printf("\r\nVL53L8A1_RANGING_SENSOR_Init Success\r\n"); } static void MX_53L8A1_ThresholdDetection_Process(void) @@ -270,36 +270,6 @@ static void MX_53L8A1_ThresholdDetection_Process(void) VL53L8A1_RANGING_SENSOR_ConfigIT(VL53L8A1_DEV_CENTER, &ITConfig); - // L8CX Motion - - /*********************************/ - /* Program motion indicator */ - /*********************************/ - Dev.platform.address = 0x52; - /* Create motion indicator with resolution 8x8 */ - int status = vl53l8cx_motion_indicator_init(&Dev, &motion_config, VL53L8CX_RESOLUTION_8X8); - if(status) - { - printf("Motion indicator init failed with status : %u\n", status); - //return status; - } - - /* (Optional) Change the min and max distance used to detect motions. The - * difference between min and max must never be >1500mm, and minimum never be <400mm, - * otherwise the function below returns error 127 */ - status = vl53l8cx_motion_indicator_set_distance_motion(&Dev, &motion_config, 1000, 2000); - if(status) - { - printf("Motion indicator set distance motion failed with status : %u\n", status); - //return status; - } - - /* If user want to change the resolution, he also needs to update the motion indicator resolution */ - status = vl53l8cx_set_resolution(&Dev, VL53L8CX_RESOLUTION_8X8); - status = vl53l8cx_motion_indicator_set_resolution(&Dev, &motion_config, VL53L8CX_RESOLUTION_8X8); - - // L8CX Motion - status = VL53L8A1_RANGING_SENSOR_Start(VL53L8A1_DEV_CENTER, RS_MODE_ASYNC_CONTINUOUS); if (status != BSP_ERROR_NONE) @@ -314,7 +284,7 @@ static void MX_53L8A1_ThresholdDetection_Process(void) printf("please put a target between %d and %d millimeters from the sensor\n\r", LOW_THRESHOLD, HIGH_THRESHOLD); #if 1 - //while (1) + //while (1) { /* interrupt mode */ if (ToF_EventDetected != 0) @@ -322,11 +292,7 @@ static void MX_53L8A1_ThresholdDetection_Process(void) ToF_EventDetected = 0; status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result); -#if 0 - L8CXResult.motion_indicator.motion[montion_config. ] - motion_config. - vl53l8cx_get_ranging_data(&Dev, &Result); -#endif + if (status == BSP_ERROR_NONE) { print_result(&Result); @@ -391,10 +357,11 @@ static void print_result(RANGING_SENSOR_Result_t *Result) printf("Zone : %3d, Motion power : %3lu\n", i, Results. Results.motion_indicator.motion[motion_config.map_id[i]]); #endif - printf("| \033[38;5;10m%5ld\033[0m :%2d%5ld ", +#if 0 + printf("| \033[38;5;10m%5ld\033[0m :%2d%5ld ", (long)Result->ZoneResult[j + k].Distance[l],(j+k), (long)Result->ZoneResult[j + k].Status[l]); - +#endif } printf("\n"); diff --git a/STS/TOF/Target/app_tof_pin_conf.h b/STS/TOF/Target/app_tof_pin_conf.h index 3ad355d..ce8e788 100644 --- a/STS/TOF/Target/app_tof_pin_conf.h +++ b/STS/TOF/Target/app_tof_pin_conf.h @@ -31,15 +31,15 @@ extern "C" { #ifdef STS_L8 //#define TOF_INT_EXTI_PIN (GPIO_PIN_3) // (GPIO_PIN_4) //#define TOF_INT_EXTI_PORT (GPIOB) -#define TOF_INT_EXTI_PIN (GPIO_PIN_10) //(GPIO_PIN_4) +#define TOF_INT_EXTI_PIN (GPIO_PIN_15) //(GPIO_PIN_4) #define TOF_INT_EXTI_PORT (GPIOA) //(GPIOA) #define TOF_INT_EXTI_IRQn EXTI15_10_IRQn -#define VL53L8A1_PWR_EN_C_PIN (GPIO_PIN_7) //(GPIO_PIN_7) -#define VL53L8A1_PWR_EN_C_PORT (GPIOA) //(GPIOA) +#define VL53L8A1_PWR_EN_C_PIN (GPIO_PIN_4) //(GPIO_PIN_7) +#define VL53L8A1_PWR_EN_C_PORT (GPIOB) //(GPIOA) -#define VL53L8A1_LPn_C_PIN (GPIO_PIN_4) //(GPIO_PIN_0) -#define VL53L8A1_LPn_C_PORT (GPIOB) //(GPIOB) +#define VL53L8A1_LPn_C_PIN (GPIO_PIN_10) //(GPIO_PIN_0) +#define VL53L8A1_LPn_C_PORT (GPIOA) //(GPIOB) #endif #ifdef __cplusplus }