rebase standard v13
This commit is contained in:
parent
e4d7d6998d
commit
06af55bf9c
|
@ -85,8 +85,14 @@ void Error_Handler(void);
|
|||
#define USARTx_TX_GPIO_Port GPIOA
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
#ifdef STS_WS
|
||||
#define HX711_SCK_PIN GPIO_PIN_5
|
||||
#define HX711_DOUT_PIN GPIO_PIN_6
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
#define HX711_SCK_PORT GPIOA
|
||||
#define HX711_DOUT_PORT GPIOA
|
||||
#endif
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -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 1
|
||||
#define LOW_POWER_DISABLE 0
|
||||
|
||||
/* 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,21 +49,6 @@ 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);
|
||||
|
@ -93,17 +78,36 @@ 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);
|
||||
#ifdef STS_WS
|
||||
// STS_Weight_Scale
|
||||
|
||||
// HX711_SCK
|
||||
GPIO_InitStruct.Pin = HX711_SCK_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
HAL_GPIO_Init(HX711_SCK_PORT, &GPIO_InitStruct);
|
||||
|
||||
// HX711_DOUT
|
||||
GPIO_InitStruct.Pin = HX711_DOUT_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
HAL_GPIO_Init(HX711_DOUT_PORT, &GPIO_InitStruct);
|
||||
|
||||
HAL_GPIO_WritePin(HX711_SCK_PORT, HX711_SCK_PIN, GPIO_PIN_RESET);
|
||||
|
||||
#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,30 +78,14 @@ 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 */
|
||||
}
|
||||
|
||||
|
@ -110,10 +94,6 @@ 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();
|
||||
|
@ -140,8 +120,7 @@ void PWR_ExitStopMode(void)
|
|||
SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */
|
||||
|
||||
/* Resume not retained USARTx and DMA */
|
||||
//MX_GPIO_Init();
|
||||
//vcom_Resume();
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
#include "sys_sensors.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#ifdef STS_WS
|
||||
#include "sts_weight_scale.h"
|
||||
#endif
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
|
@ -100,7 +102,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();
|
||||
|
@ -117,12 +119,14 @@ void SystemApp_Init(void)
|
|||
|
||||
/*Initialize the Sensors */
|
||||
EnvSensors_Init();
|
||||
|
||||
#ifdef STS_WS
|
||||
sts_weight_scale_init();
|
||||
#endif
|
||||
/*Init low power manager*/
|
||||
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,18 +100,13 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||
PA3 ------> USART2_RX
|
||||
PA2 ------> USART2_TX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = USARTx_TX_Pin;
|
||||
GPIO_InitStruct.Pin = USARTx_RX_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,9 @@
|
|||
#include "flash_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "gpio.h"
|
||||
#ifdef STS_WS
|
||||
#include "sts_weight_scale.h"
|
||||
#endif
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
|
@ -215,7 +217,6 @@ static void OnPingSlotPeriodicityChanged(uint8_t pingSlotPeriodicity);
|
|||
static void OnSystemReset(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
static void OnYunhornSTSP1CheckingEvent(void);
|
||||
|
||||
/**
|
||||
* @brief LED Tx timer callback function
|
||||
|
@ -301,7 +302,7 @@ static UTIL_TIMER_Object_t TxTimer;
|
|||
/**
|
||||
* @brief Tx Timer period
|
||||
*/
|
||||
static UTIL_TIMER_Time_t TxPeriodicity = 1000;
|
||||
static UTIL_TIMER_Time_t TxPeriodicity = APP_TX_DUTYCYCLE;
|
||||
|
||||
/**
|
||||
* @brief Join Timer period
|
||||
|
@ -343,8 +344,7 @@ 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)
|
||||
|
@ -406,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();
|
||||
|
||||
|
@ -425,7 +425,7 @@ void LoRaWAN_Init(void)
|
|||
if (EventType == TX_ON_TIMER)
|
||||
{
|
||||
/* send every time timer elapses */
|
||||
UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_PERIODIC, OnTxTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&TxTimer, TxPeriodicity, UTIL_TIMER_ONESHOT, OnTxTimerEvent, NULL);
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
}
|
||||
else
|
||||
|
@ -448,9 +448,6 @@ 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);
|
||||
|
@ -471,21 +468,7 @@ 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)
|
||||
|
@ -574,6 +557,9 @@ static void SendTxData(void)
|
|||
LmHandlerErrorStatus_t status = LORAMAC_HANDLER_ERROR;
|
||||
uint8_t batteryLevel = GetBatteryLevel();
|
||||
sensor_t sensor_data;
|
||||
#ifdef STS_WS
|
||||
sts_sensor_t sts_sensor_data;
|
||||
#endif
|
||||
UTIL_TIMER_Time_t nextTxIn = 0;
|
||||
|
||||
if (LmHandlerIsBusy() == false)
|
||||
|
@ -591,10 +577,14 @@ static void SendTxData(void)
|
|||
#endif /* CAYENNE_LPP */
|
||||
|
||||
EnvSensors_Read(&sensor_data);
|
||||
#if 0
|
||||
#ifdef STS_WS
|
||||
sts_weight_scale(&sts_sensor_data);
|
||||
APP_LOG(TS_ON, VLEVEL_M, "Weigt Scale : %d\r\n", sts_sensor_data.weight_scale_value);
|
||||
|
||||
#endif
|
||||
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
|
||||
|
@ -629,8 +619,8 @@ static void SendTxData(void)
|
|||
{
|
||||
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;
|
||||
AppData.Buffer[i++] = 0;
|
||||
AppData.Buffer[i++] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -647,7 +637,10 @@ static void SendTxData(void)
|
|||
AppData.Buffer[i++] = (uint8_t)((altitudeGps >> 8) & 0xFF);
|
||||
AppData.Buffer[i++] = (uint8_t)(altitudeGps & 0xFF);
|
||||
}
|
||||
|
||||
#ifdef STS_WS
|
||||
AppData.Buffer[i++] = (uint8_t)(sts_sensor_data.weight_scale_value >> 8& 0xFF);
|
||||
AppData.Buffer[i++] = (uint8_t)(sts_sensor_data.weight_scale_value & 0xFF);
|
||||
#endif
|
||||
AppData.BufferSize = i;
|
||||
#endif /* CAYENNE_LPP */
|
||||
|
||||
|
@ -685,13 +678,12 @@ static void SendTxData(void)
|
|||
static void OnTxTimerEvent(void *context)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxTimerEvent_1 */
|
||||
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 END OnTxTimerEvent_1 */
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||
|
||||
/*Wait for next tx slot*/
|
||||
UTIL_TIMER_Start(&TxTimer);
|
||||
/* USER CODE BEGIN OnTxTimerEvent_2 */
|
||||
|
||||
/* USER CODE END OnTxTimerEvent_2 */
|
||||
|
|
Loading…
Reference in New Issue