Merge branch 'master' of http://gitea.yunhorn.com/sundp/WL55JC_AS923
This commit is contained in:
commit
23f3fb3ecf
|
@ -81,7 +81,7 @@ extern "C" {
|
|||
* @brief Disable Low Power mode
|
||||
* @note 0: LowPowerMode enabled. MCU enters stop2 mode, 1: LowPowerMode disabled. MCU enters sleep mode only
|
||||
*/
|
||||
#define LOW_POWER_DISABLE 0
|
||||
#define LOW_POWER_DISABLE 1
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef enum
|
|||
CFG_SEQ_Task_LoRaStoreContextEvent,
|
||||
CFG_SEQ_Task_LoRaStopJoinEvent,
|
||||
/* USER CODE BEGIN CFG_SEQ_Task_Id_t */
|
||||
|
||||
CFG_SEQ_Task_YunhornSTSP1CheckingEvent,
|
||||
/* USER CODE END CFG_SEQ_Task_Id_t */
|
||||
CFG_SEQ_Task_NBR
|
||||
} CFG_SEQ_Task_Id_t;
|
||||
|
|
|
@ -49,6 +49,21 @@ void MX_GPIO_Init(void)
|
|||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_All;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
__HAL_RCC_GPIOB_CLK_DISABLE();
|
||||
__HAL_RCC_GPIOC_CLK_DISABLE();
|
||||
|
||||
GPIO_InitStruct.Pin = BUT1_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
__HAL_RCC_GPIOA_CLK_DISABLE();
|
||||
#if 0
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, LED1_Pin|LED2_Pin|PROB2_Pin|PROB1_Pin
|
||||
|LED3_Pin, GPIO_PIN_RESET);
|
||||
|
@ -78,17 +93,17 @@ 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);
|
||||
|
||||
#endif
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||
|
||||
#if 0
|
||||
HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
|
||||
|
||||
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
|
|
@ -65,7 +65,7 @@ void MX_RTC_Init(void)
|
|||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
#if 0
|
||||
/** Enable the Alarm A
|
||||
*/
|
||||
sAlarm.BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO;
|
||||
|
@ -78,7 +78,7 @@ void MX_RTC_Init(void)
|
|||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN RTC_Init 2 */
|
||||
|
||||
#endif
|
||||
/* USER CODE END RTC_Init 2 */
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "usart_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#include "gpio.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
|
@ -78,14 +78,30 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver =
|
|||
void PWR_EnterOffMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN EnterOffMode_1 */
|
||||
/* Enable Power Clock */
|
||||
HAL_SuspendTick();
|
||||
|
||||
/* Disable all used wakeup sources: Pin1(PA.0) */
|
||||
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1|PWR_WAKEUP_PIN2|PWR_WAKEUP_PIN3);
|
||||
|
||||
/* Clear all related wakeup flags */
|
||||
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
|
||||
|
||||
/* Re-enable all used wakeup sources: Pin1(PA.0) */
|
||||
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
|
||||
|
||||
/*## Enter Standby Mode ####################################################*/
|
||||
/* Request to enter STANDBY mode */
|
||||
HAL_PWR_EnterSTANDBYMode();
|
||||
/* USER CODE END EnterOffMode_1 */
|
||||
}
|
||||
|
||||
void PWR_ExitOffMode(void)
|
||||
{
|
||||
/* USER CODE BEGIN ExitOffMode_1 */
|
||||
|
||||
//HAL_ResumeTick();
|
||||
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
|
||||
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
|
||||
/* USER CODE END ExitOffMode_1 */
|
||||
}
|
||||
|
||||
|
@ -94,6 +110,10 @@ void PWR_EnterStopMode(void)
|
|||
/* USER CODE BEGIN EnterStopMode_1 */
|
||||
|
||||
/* USER CODE END EnterStopMode_1 */
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_All, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, ~GPIO_PIN_0, GPIO_PIN_RESET);
|
||||
vcom_DeInit();
|
||||
|
||||
HAL_SuspendTick();
|
||||
/* Clear Status Flag before entering STOP/STANDBY Mode */
|
||||
LL_PWR_ClearFlag_C1STOP_C1STB();
|
||||
|
@ -120,7 +140,8 @@ void PWR_ExitStopMode(void)
|
|||
SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */
|
||||
|
||||
/* Resume not retained USARTx and DMA */
|
||||
vcom_Resume();
|
||||
//MX_GPIO_Init();
|
||||
//vcom_Resume();
|
||||
/* USER CODE BEGIN ExitStopMode_2 */
|
||||
|
||||
/* USER CODE END ExitStopMode_2 */
|
||||
|
|
|
@ -227,7 +227,7 @@ void EXTI0_IRQHandler(void)
|
|||
|
||||
/* USER CODE END EXTI0_IRQn 1 */
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* @brief This function handles EXTI Line 1 Interrupt.
|
||||
*/
|
||||
|
@ -283,7 +283,7 @@ void USART2_IRQHandler(void)
|
|||
|
||||
/* USER CODE END USART2_IRQn 1 */
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @brief This function handles RTC Alarms (A and B) Interrupt.
|
||||
*/
|
||||
|
|
|
@ -100,7 +100,7 @@ void SystemApp_Init(void)
|
|||
UTIL_TIMER_Init();
|
||||
SYS_TimerInitialisedFlag = 1;
|
||||
/* Initializes the SW probes pins and the monitor RF pins via Alternate Function */
|
||||
DBG_Init();
|
||||
//DBG_Init();
|
||||
|
||||
/*Initialize the terminal */
|
||||
UTIL_ADV_TRACE_Init();
|
||||
|
@ -122,7 +122,7 @@ void SystemApp_Init(void)
|
|||
UTIL_LPM_Init();
|
||||
/* Disable Stand-by mode */
|
||||
UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE);
|
||||
|
||||
UTIL_LPM_SetOffMode((1 << CFG_LPM_UART_TX_Id), UTIL_LPM_ENABLE);
|
||||
#if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 1)
|
||||
/* Disable Stop Mode */
|
||||
UTIL_LPM_SetStopMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE);
|
||||
|
|
|
@ -100,13 +100,18 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||
PA3 ------> USART2_RX
|
||||
PA2 ------> USART2_TX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = USARTx_RX_Pin|USARTx_TX_Pin;
|
||||
GPIO_InitStruct.Pin = USARTx_TX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = USARTx_RX_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USART2 DMA Init */
|
||||
/* USART2_TX Init */
|
||||
hdma_usart2_tx.Instance = DMA1_Channel5;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "flash_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#include "gpio.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
|
@ -215,6 +215,7 @@ static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity);
|
|||
static void OnSystemReset(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
static void OnYunhornSTSP1CheckingEvent(void);
|
||||
|
||||
/**
|
||||
* @brief LED Tx timer callback function
|
||||
|
@ -300,7 +301,7 @@ static UTIL_TIMER_Object_t TxTimer;
|
|||
/**
|
||||
* @brief Tx Timer period
|
||||
*/
|
||||
static UTIL_TIMER_Time_t TxPeriodicity = APP_TX_DUTYCYCLE;
|
||||
static UTIL_TIMER_Time_t TxPeriodicity = 1000;
|
||||
|
||||
/**
|
||||
* @brief Join Timer period
|
||||
|
@ -342,7 +343,8 @@ static UTIL_TIMER_Object_t JoinLedTimer;
|
|||
|
||||
/* Exported functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
volatile uint8_t door_status=0, door_changed_flag=0, door_previous_status=0;
|
||||
volatile uint32_t checking_sn=0;
|
||||
/* USER CODE END EF */
|
||||
|
||||
void LoRaWAN_Init(void)
|
||||
|
@ -404,7 +406,7 @@ void LoRaWAN_Init(void)
|
|||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), UTIL_SEQ_RFU, SendTxData);
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LoRaStoreContextEvent), UTIL_SEQ_RFU, StoreContext);
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_LoRaStopJoinEvent), UTIL_SEQ_RFU, StopJoin);
|
||||
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSP1CheckingEvent),UTIL_SEQ_RFU, OnYunhornSTSP1CheckingEvent);
|
||||
/* Init Info table used by LmHandler*/
|
||||
LoraInfo_Init();
|
||||
|
||||
|
@ -423,7 +425,7 @@ void LoRaWAN_Init(void)
|
|||
if (EventType == TX_ON_TIMER)
|
||||
{
|
||||
/* send every time timer elapses */
|
||||
UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_ONESHOT, OnTxTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_PERIODIC, OnTxTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
else
|
||||
|
@ -446,6 +448,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
{
|
||||
case BUT1_Pin:
|
||||
/* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
|
||||
door_changed_flag = 1;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSP1CheckingEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
if (EventType == TX_ON_EVENT)
|
||||
{
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
@ -466,7 +471,21 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
static void OnYunhornSTSP1CheckingEvent(void)
|
||||
{
|
||||
|
||||
|
||||
door_status = HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0);
|
||||
|
||||
if (door_status != door_previous_status)
|
||||
{
|
||||
door_previous_status = door_status;
|
||||
door_changed_flag = 1;
|
||||
APP_LOG(TS_OFF,VLEVEL_M,"\r\n----- Door Status Changed-------------\r\n");
|
||||
}
|
||||
|
||||
//UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
}
|
||||
/* USER CODE END PrFD */
|
||||
|
||||
static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
|
||||
|
@ -572,10 +591,10 @@ static void SendTxData(void)
|
|||
#endif /* CAYENNE_LPP */
|
||||
|
||||
EnvSensors_Read(&sensor_data);
|
||||
|
||||
#if 0
|
||||
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));
|
||||
|
||||
#endif
|
||||
AppData.Port = LORAWAN_USER_APP_PORT;
|
||||
|
||||
#ifdef CAYENNE_LPP
|
||||
|
@ -610,8 +629,8 @@ static void SendTxData(void)
|
|||
{
|
||||
AppData.Buffer[i++] = 0;
|
||||
AppData.Buffer[i++] = 0;
|
||||
AppData.Buffer[i++] = 0;
|
||||
AppData.Buffer[i++] = 0;
|
||||
AppData.Buffer[i++] = (uint8_t)(99*GetBatteryLevel()/255); /* 1 (very low) to 254 (fully charged) */
|
||||
AppData.Buffer[i++] = door_status;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -666,12 +685,13 @@ static void SendTxData(void)
|
|||
static void OnTxTimerEvent(void *context)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxTimerEvent_1 */
|
||||
|
||||
/* USER CODE END OnTxTimerEvent_1 */
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
/*Wait for next tx slot*/
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSP1CheckingEvent), CFG_SEQ_Prio_0);
|
||||
if (door_changed_flag ==1)
|
||||
{
|
||||
door_changed_flag =0;
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
//UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
/* USER CODE BEGIN OnTxTimerEvent_2 */
|
||||
|
||||
/* USER CODE END OnTxTimerEvent_2 */
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
# This is an NUCLEO-WL55JC1 board with a single STM32WL55JCIx chip
|
||||
#
|
||||
# Generated by STM32CubeIDE
|
||||
# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
|
||||
|
||||
source [find interface/stlink-dap.cfg]
|
||||
|
||||
st-link backend tcp
|
||||
|
||||
set WORKAREASIZE 0x8000
|
||||
|
||||
transport select "dapdirect_swd"
|
||||
|
||||
set CHIPNAME STM32WL55JCIx
|
||||
set BOARDNAME NUCLEO-WL55JC1
|
||||
|
||||
# Enable debug when in low power modes
|
||||
set ENABLE_LOW_POWER 1
|
||||
|
||||
# Stop Watchdog counters when halt
|
||||
set STOP_WATCHDOG 1
|
||||
|
||||
# STlink Debug clock frequency
|
||||
set CLOCK_FREQ 8000
|
||||
|
||||
# Reset configuration
|
||||
# use hardware reset, connect under reset
|
||||
# connect_assert_srst needed if low power mode application running (WFI...)
|
||||
reset_config srst_only srst_nogate connect_assert_srst
|
||||
set CONNECT_UNDER_RESET 1
|
||||
set CORE_RESET 0
|
||||
|
||||
# ACCESS PORT NUMBER
|
||||
set AP_NUM 0
|
||||
# GDB PORT
|
||||
set GDB_PORT 3333
|
||||
|
||||
|
||||
|
||||
|
||||
set DUAL_CORE 1
|
||||
|
||||
# BCTM CPU variables
|
||||
|
||||
source [find target/stm32wlx.cfg]
|
||||
|
|
@ -78,5 +78,6 @@
|
|||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
|
Loading…
Reference in New Issue