---- revised for cr2450 ----keep for GPIO analog setting

This commit is contained in:
Yunhorn 2024-07-03 13:01:45 +08:00
parent 5a7d25f39d
commit f49230bf14
7 changed files with 94 additions and 31 deletions

View File

@ -77,7 +77,7 @@ void MX_DMA_Init(void)
HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
#endif
#if 1
#if 0
/* DMA1_Channel7_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);

View File

@ -45,12 +45,12 @@ void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
#if 0
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
#if 0
GPIO_InitStruct.Pin = GPIO_PIN_All;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
@ -58,10 +58,41 @@ void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
#endif
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
//0b0000 0000 0000 0000
//0b0001 1010 0000 0000 INCLUDE PA9 PA11 PA12 --> 0x1A00
//0b1110 0101 1111 1111 exclude PA9 PA11 PA12 --> 0xE5FF
GPIO_InitStruct.Pin = 0xE5FF; // or ~0x1A00;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
//0b0000 0001 0011 1000 INCLUDE PB3 PB4 PB5 PB8 --> 0x0138
//0b1111 1110 1100 0111 exclude PB3 PB4 PB5 PB8 --> 0xFEC7
GPIO_InitStruct.Pin = 0xFEC7; // or ~0x0138;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
//0b0010 0000 0000 0000 INCLUDE PC13 --> 0x2000
//0b1101 1111 1111 1111 exclude PC13 --> 0xDFFF
GPIO_InitStruct.Pin = 0xDFFF;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
//__HAL_RCC_GPIOA_CLK_DISABLE();
//__HAL_RCC_GPIOB_CLK_DISABLE();
//__HAL_RCC_GPIOC_CLK_DISABLE();
#endif
__HAL_RCC_GPIOC_CLK_DISABLE();
/*Configure GPIO pin Output Level */
#if defined(STM32WL55xx)
HAL_GPIO_WritePin(GPIOB, LED1_Pin|LED2_Pin|PROB2_Pin|PROB1_Pin
@ -69,7 +100,8 @@ void MX_GPIO_Init(void)
#endif
/*Configure GPIO pin Output Level */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
//HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_RESET);
#if defined(TOF_1)
@ -99,7 +131,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;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
@ -111,7 +143,7 @@ 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
/*Configure GPIO pins : TOF_C_INT_Pin */
#if (defined(TOF_1) && defined(TOF_2))
@ -177,6 +209,18 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(MEMS_POWER_GPIO_Port, &GPIO_InitStruct);
#if defined(TOF_1)
HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET);
#endif
#if defined(TOF_2)
HAL_GPIO_WritePin(TOF_L_XSHUT_GPIO_Port, TOF_L_XSHUT_Pin, GPIO_PIN_SET);
#endif
HAL_GPIO_WritePin(MEMS_POWER_GPIO_Port, MEMS_POWER_Pin, GPIO_PIN_SET);
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOA_CLK_DISABLE();
#if defined(SOAP_LEVEL_SENSOR)
/* ============== SOAP LEVEL DETECTION ========================= */
@ -198,14 +242,14 @@ HAL_GPIO_Init(SOAP_SWITCH_GPIO_Port, &GPIO_InitStruct);
/* ============== SOAP LEVEL DETECTION ========================= */
#endif
#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) && defined(TOF_2))
HAL_NVIC_SetPriority(TOF_C_INT_EXTI_IRQn, 0, 0);

View File

@ -95,10 +95,27 @@ void PWR_ExitOffMode(void)
void PWR_EnterStopMode(void)
{
/* USER CODE BEGIN EnterStopMode_1 */
#if 0
HAL_UART_DeInit(&huart2);
vcom_DeInit();
HAL_GPIO_DeInit(GPIOA,GPIO_PIN_All);
HAL_GPIO_DeInit(GPIOB,GPIO_PIN_All);
HAL_GPIO_DeInit(GPIOC,GPIO_PIN_All);
#endif
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
HAL_GPIO_WritePin(GPIOA, 0xE5FF, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, 0xFEC7, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, 0xDFFF, GPIO_PIN_RESET);
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
//HAL_GPIO_WritePin(GPIOA, GPIO_PIN_All, GPIO_PIN_RESET);
//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET);
/* USER CODE END EnterStopMode_1 */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_All, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET);
HAL_SuspendTick();
/* Clear Status Flag before entering STOP/STANDBY Mode */
LL_PWR_ClearFlag_C1STOP_C1STB();
@ -127,12 +144,12 @@ void PWR_ExitStopMode(void)
SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */
/* Resume not retained USARTx and DMA */
vcom_Resume(); //DON'T REMOVE THIS, KKEP LOW POWER
//vcom_Resume(); //DON'T REMOVE THIS, KKEP LOW POWER
/* USER CODE BEGIN ExitStopMode_2 */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C2_Init();
//PME_ON;
PME_ON;
/* USER CODE END ExitStopMode_2 */
}

View File

@ -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.
*/
@ -264,7 +264,7 @@ void EXTI1_IRQHandler(void)
/* USER CODE END EXTI1_IRQn 1 */
}
#endif
/**
* @brief This function handles DMA1 Channel 2 Interrupt.
@ -329,7 +329,7 @@ void DMA1_Channel5_IRQHandler(void)
/**
* @brief This function handles DMA1 Channel 6 Interrupt.
*/
#if 0
void DMA1_Channel6_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
@ -357,7 +357,7 @@ void DMA1_Channel7_IRQHandler(void)
/* USER CODE END DMA1_Channel7_IRQn 1 */
}
#endif
void EXTI3_IRQHandler(void)
{

View File

@ -785,7 +785,7 @@ static void SendTxData(void)
/* USER CODE BEGIN SendTxData_1 */
LmHandlerErrorStatus_t status = LORAMAC_HANDLER_ERROR;
uint8_t batteryLevel = GetBatteryLevel();
//uint16_t batteryLevelmV = SYS_GetBatteryLevel();
uint16_t batteryLevelmV = SYS_GetBatteryLevel();
//sensor_t sensor_data;
#if defined(YUNHORN_STS_R0_ENABLED)||defined(YUNHORN_STS_R5_ENABLED)
STS_R0_SensorDataTypeDef r0_data;
@ -824,7 +824,8 @@ static void SendTxData(void)
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_mtmcode1); //mtmcode1; //#02
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_mtmcode2); //mtmcode2; //#03
AppData.Buffer[i++] = (uint8_t)(0xFF & sts_hardware_ver); //hardware_Ver; //#04
AppData.Buffer[i++] = (uint8_t)(0xFF & (99*batteryLevel/254)); //#05
//AppData.Buffer[i++] = (uint8_t)(0xFF & (99*batteryLevel/254)); //#05
AppData.Buffer[i++] = (uint8_t)(0xFF & (uint8_t)(batteryLevelmV/100)); //#05
#endif
if (heart_beat_timer != 0U)
@ -1000,7 +1001,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
OnTxPeriodicityChanged(TxPeriodicity);
APP_LOG(TS_OFF, VLEVEL_L,"\r\n STS_LoRa_WAN_Joined = %s \r\n", (STS_LoRa_WAN_Joined == 1)?"ABP":"OTAA");
//APP_LOG(TS_OFF, VLEVEL_L,"\r\n STS_LoRa_WAN_Joined = %s \r\n", (STS_LoRa_WAN_Joined == 1)?"ABP":"OTAA");
}
else
{
@ -1009,8 +1010,9 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
APP_LOG(TS_OFF, VLEVEL_M, "###### U/L FRAME:JOIN | DR:%d | PWR:%d\r\n", joinParams->Datarate, joinParams->TxPower);
}
heart_beat_timer = 1;
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
//heart_beat_timer = 1;
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
//STS_SENSOR_Upload_Message(LORAWAN_USER_HTBT_PORT, 12,"Yunhorn88STS");
/* USER CODE END OnJoinRequest_1 */
}
@ -1093,7 +1095,7 @@ static void OnTxPeriodicityChanged(uint32_t periodicity)
UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
UTIL_TIMER_Start(&TxTimer);
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
APP_LOG(TS_OFF, VLEVEL_H,"\r\n TxPeriodicity changed to %u (msec) \r\n", TxPeriodicity);
//APP_LOG(TS_OFF, VLEVEL_H,"\r\n TxPeriodicity changed to %u (msec) \r\n", TxPeriodicity);
/* USER CODE END OnTxPeriodicityChanged_2 */
}
@ -1299,7 +1301,7 @@ static void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
/* USER CODE BEGIN OnTxPeriodicityChanged_2 */
APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity Changed to: %u (ms)\r\n", HeartBeatPeriodicity );
//APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity Changed to: %u (ms)\r\n", HeartBeatPeriodicity );
/* USER CODE END OnTxPeriodicityChanged_2 */
}
@ -2122,7 +2124,7 @@ void STS_SENSOR_Function_Test_Process(void)
}
else
{
tstbuf[i++] = (uint8_t) (count*2+1)&0xff; //length of following data
//tstbuf[i++] = (uint8_t) (count*2+1)&0xff; //length of following data
#ifdef YUNHORN_STS_O6_ENABLED
tstbuf[i++] = (uint8_t)20; //length of following data
uint8_t self_test_result[10]={0,0,0,0,0, 0,0,0,0,0};

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-752586124573436390" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1048471218779752885" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-752586124573436390" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1048471218779752885" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -406,9 +406,9 @@ void STS_TOF_VL53L0X_Range_Process(void)
} else {
// nSensorPresent >0
sts_tof_distance_data[0] = 1000;
sts_tof_distance_data[1] = 1000;
sts_tof_distance_data[2] = 1000;
sts_tof_distance_data[0] = STS_MAX_L0_RANGE;
sts_tof_distance_data[1] = STS_MAX_L0_RANGE;
sts_tof_distance_data[2] = STS_MAX_L0_RANGE;
}
// reset for next ranging