diff --git a/.gitignore b/.gitignore
index 5848973..50243d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@
*.o
*.ko
*.obj
-*.elf
+
# Linker output
*.ilk
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 38ae308..7e551a7 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -101,20 +101,26 @@ void Error_Handler(void);
#define LED1_OFF HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET)
#define LED1_STATE HAL_GPIO_ReadPin(LED1_GPIO_Port, LED1_Pin)
#define LED1_TOGGLE HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin)
+
+#ifndef L8
#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
+#endif
+
+
+
#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 PME_TOGGLE HAL_GPIO_TogglePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin)
#if (defined(TOF_1)||defined(TOF_2)||defined(STS_R1)||defined(STS_R5)||defined(STS_R1D))
-#define VL53L0
+#define VL53L0 1U
#elif (defined(STS_P2)||defined(STS_T6))
-#define VL53LX 1
+#define VL53LX 1U
#endif
/* DUAL TOF VL53L0 */
@@ -220,7 +226,7 @@ void Error_Handler(void);
#define I2C2_SDA_PORT GPIOA
// FOR STM32WLE5CCU6 UFQFPN48 PA12 PA11
-#ifndef STM32WLE5xx
+#ifdef STM32WLE5xx
#define I2C2_STANDARD_100K 0x00000E14
#define I2C2_FAST_400K 0x00000004
#define I2C2_FAST_PLUS_1M 0x00000000
@@ -238,11 +244,16 @@ void Error_Handler(void);
/*
* FOR STM32WL55JCIX UFBGA73 PA12 PA11
*/
-#ifdef STM32WL55xx
+
+#ifdef STM32WL55xx
+
#define I2C2_STANDARD_100K 0x10805D88
#define I2C2_FAST_400K 0x0090194B
#define I2C2_FAST_PLUS_1M 0x00700814
#endif
+
+
+
#if defined(STS_R4)
/* IF_SOAP_IN, MEMS_IF_3, PA10 */
#define SOAP_STATUS_Pin GPIO_PIN_10
diff --git a/Core/Src/dma.c b/Core/Src/dma.c
index a72ac4c..0aad753 100644
--- a/Core/Src/dma.c
+++ b/Core/Src/dma.c
@@ -50,12 +50,12 @@ void MX_DMA_Init(void)
#if defined(VL53LX)||defined(VL53L0)
/* DMA1_Channel3_IRQn interrupt configuration */
/* I2C2 RX */
- HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
+ HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);
/* DMA1_Channel4_IRQn interrupt configuration */
/* I2C2 TX */
- HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
+ HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
#endif
#endif
diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c
index 85140f6..8f0d4aa 100644
--- a/Core/Src/gpio.c
+++ b/Core/Src/gpio.c
@@ -81,6 +81,7 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(BUT3_GPIO_Port, &GPIO_InitStruct);
+
#ifndef L8
/* STS-PME PB-4 */
/*Configure GPIO pins : PBPin PBPin PBPin */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 16ed38d..a0ab3d1 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -102,10 +102,19 @@ int main(void)
/* Initialize all configured peripherals */
MX_GPIO_Init();
- MX_I2C2_Init();
- MX_DMA_Init();
+#if 0
+ if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
+ {
+ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
+ }
+ else
+#endif
+ {
+ MX_I2C2_Init();
+ MX_DMA_Init();
+ MX_LoRaWAN_Init();
+ }
- MX_LoRaWAN_Init();
/* USER CODE BEGIN 2 */
//MX_USART2_UART_Init();
/* USER CODE END 2 */
diff --git a/Core/Src/sys_app.c b/Core/Src/sys_app.c
index 182c229..cbfffe8 100644
--- a/Core/Src/sys_app.c
+++ b/Core/Src/sys_app.c
@@ -125,6 +125,9 @@ void SystemApp_Init(void)
#if defined(L8)
MX_TOF_Init();
#endif
+#if defined(STS_R1D)
+ MX_TOF_Init();
+#endif
#if defined(STS_P2)
STS_TOF_VL53LX_PeopleCounting_Process_Init();
#endif
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 53ed709..6032670 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -808,6 +808,8 @@ static void SendTxData(void)
#ifdef VL53L0
STS_YunhornSTSEventP4_Process();
STS_RR_Sensor_Read(&sts_rr_sensor_data);
+ APP_LOG(TS_OFF, VLEVEL_M, "\r\n VL53L0 sensor data read \r\n");
+
#ifdef STS_R1
AppData.Port = YUNHORN_STS_R1_LORA_APP_DATA_PORT; /* STS-R1 Data Port */
#elif defined(STS_R1D)
@@ -833,11 +835,11 @@ static void SendTxData(void)
AppData.Buffer[i++] = (uint8_t) sts_hardware_ver;
AppData.Buffer[i++] = (uint8_t) 99*batteryLevel/254;
-#if 0
+#if 1
APP_LOG(TS_ON, VLEVEL_M, "VDDA: %d\r\n", batteryLevel);
APP_LOG(TS_ON, VLEVEL_M, "temp: %d\r\n", (int16_t)(sensor_data.temperature));
- AppData.Port = LORAWAN_USER_APP_PORT;
+ //AppData.Port = LORAWAN_USER_APP_PORT;
#endif
#ifdef STS_P2
@@ -1025,6 +1027,9 @@ static void OnTxTimerEvent(void *context)
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), CFG_SEQ_Prio_0);
#elif defined(STS_M1)
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP1), CFG_SEQ_Prio_0);
+#elif defined(STS_R1D)
+ APP_LOG(TS_OFF, VLEVEL_M, "\nSET TASK P4\r\n");
+ UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), CFG_SEQ_Prio_0);
#endif
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
@@ -1444,7 +1449,7 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
appHeartBeatBufferSize = 2;
appHeartBeatDataBuffer[0]=(uint8_t)(0x80|AppLedStateOn);
appHeartBeatDataBuffer[1]=(uint8_t)(SYS_GetBatteryLevel()/100); //TODO XXX change to battery level in mV
- //APP_LOG(TS_OFF, VLEVEL_M, "\n\n HEART-BEAT TIMER = %d\n\n", rfac_timer);
+ APP_LOG(TS_OFF, VLEVEL_M, "\n\n HEART-BEAT TIMER = %d\n\n", rfac_timer);
STS_SENSOR_Upload_Message(appHeartBeatDataPort, appHeartBeatBufferSize, (uint8_t*)appHeartBeatDataBuffer);
#endif
@@ -1478,7 +1483,6 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
/* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
-
APP_LOG(TS_OFF, VLEVEL_M,"* STS HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
/* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject
index 521ff96..aed9a96 100644
--- a/STM32CubeIDE/.cproject
+++ b/STM32CubeIDE/.cproject
@@ -133,7 +133,9 @@