L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
sys_app.c File Reference

Initializes HW and SW system entities (not related to the radio). More...

#include <stdio.h>
#include "platform.h"
#include "sys_app.h"
#include "adc_if.h"
#include "stm32_seq.h"
#include "stm32_systime.h"
#include "stm32_lpm.h"
#include "timer_if.h"
#include "utilities_def.h"
#include "sys_debug.h"
#include "sys_sensors.h"
Include dependency graph for sys_app.c:

Go to the source code of this file.

Macros

#define MAX_TS_SIZE   (int) 16
#define LORAWAN_MAX_BAT   254

Functions

static void TimestampNow (uint8_t *buff, uint16_t *size)
 Returns sec and msec based on the systime in use.
static void tiny_snprintf_like (char *buf, uint32_t maxsize, const char *strFormat,...)
 it calls UTIL_ADV_TRACE_VSNPRINTF
void SystemApp_Init (void)
 initialize the system (dbg pins, trace, mbmux, sys timer, LPM, ...)
void UTIL_SEQ_Idle (void)
 redefines __weak function in stm32_seq.c such to enter low power
uint8_t GetBatteryLevel (void)
 callback to get the battery level in % of full charge (254 full charge, 0 no charge)
int16_t GetTemperatureLevel (void)
 callback to get the current temperature in the MCU
void GetUniqueId (uint8_t *id)
 callback to get the board 64 bits unique ID
void GetDevAddr (uint32_t *devAddr)
 callback to get the board 32 bits unique ID (LSB)
void UTIL_ADV_TRACE_PreSendHook (void)
void UTIL_ADV_TRACE_PostSendHook (void)
HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
uint32_t HAL_GetTick (void)
void HAL_Delay (__IO uint32_t Delay)

Variables

static uint8_t SYS_TimerInitialisedFlag = 0

Detailed Description

Initializes HW and SW system entities (not related to the radio).

Author
MCD Application Team
Attention

Copyright (c) 2026 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file sys_app.c.

Macro Definition Documentation

◆ LORAWAN_MAX_BAT

#define LORAWAN_MAX_BAT   254

Defines the maximum battery level

Definition at line 54 of file sys_app.c.

Referenced by GetBatteryLevel().

◆ MAX_TS_SIZE

#define MAX_TS_SIZE   (int) 16

Definition at line 49 of file sys_app.c.

Referenced by TimestampNow().

Function Documentation

◆ GetBatteryLevel()

uint8_t GetBatteryLevel ( void )

callback to get the battery level in % of full charge (254 full charge, 0 no charge)

Return values
batterylevel

Definition at line 152 of file sys_app.c.

References LORAWAN_MAX_BAT, SYS_GetBatteryLevel(), VDD_BAT, and VDD_MIN.

Referenced by mems_WriteToSystemParams(), and sensors_CayennelFromBckData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDevAddr()

void GetDevAddr ( uint32_t * devAddr)

callback to get the board 32 bits unique ID (LSB)

Parameters
devAddrDevice Address

Definition at line 239 of file sys_app.c.

Referenced by systemParams_getAppDevEUI().

Here is the caller graph for this function:

◆ GetTemperatureLevel()

int16_t GetTemperatureLevel ( void )

callback to get the current temperature in the MCU

Return values
temperaturelevel

Definition at line 184 of file sys_app.c.

References EnvSensors_Read(), and sensor_t::temperature.

Here is the call graph for this function:

◆ GetUniqueId()

void GetUniqueId ( uint8_t * id)

callback to get the board 64 bits unique ID

Parameters
idunique ID

Definition at line 198 of file sys_app.c.

◆ HAL_Delay()

void HAL_Delay ( __IO uint32_t Delay)
Note
This function overwrites the __weak one from HAL

Definition at line 369 of file sys_app.c.

References TIMER_IF_DelayMs().

Referenced by Error_Handler(), I2C_IsDeviceReadyMT(), I2C_Scan(), main(), nfc_st25dv16kc_Init(), nfc_st25dv16kc_WriteEEPROM(), nfc_st25dv16kc_WriteGPO(), scd41_Init(), scd41_IsDataReady(), scd41_Read(), sps30_Init(), sps30_Off(), sps30_On(), and tmphm_sht45_Read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HAL_GetTick()

uint32_t HAL_GetTick ( void )
Note
This function overwrites the __weak one from HAL

Definition at line 337 of file sys_app.c.

References SYS_TimerInitialisedFlag, and TIMER_IF_GetTimerValue().

Referenced by main(), sensorsBase_StartTimerToOff(), sensorsBase_StopTimerToOff(), sleeper_IsElapsed(), and sleeper_Next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HAL_InitTick()

HAL_StatusTypeDef HAL_InitTick ( uint32_t TickPriority)
Note
This function overwrites the __weak one from HAL

Definition at line 322 of file sys_app.c.

◆ SystemApp_Init()

void SystemApp_Init ( void )

initialize the system (dbg pins, trace, mbmux, sys timer, LPM, ...)

Definition at line 90 of file sys_app.c.

References CFG_LPM_APPLI_Id, DBG_Init(), EnvSensors_Init(), SYS_InitMeasurement(), SYS_TimerInitialisedFlag, TimestampNow(), and VERBOSE_LEVEL.

Referenced by main(), and MX_LoRaWAN_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimestampNow()

void TimestampNow ( uint8_t * buff,
uint16_t * size )
static

Returns sec and msec based on the systime in use.

Parameters
buffto update with timestamp
sizeof updated buffer

Definition at line 262 of file sys_app.c.

References MAX_TS_SIZE, and tiny_snprintf_like().

Referenced by SystemApp_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tiny_snprintf_like()

void tiny_snprintf_like ( char * buf,
uint32_t maxsize,
const char * strFormat,
... )
static

it calls UTIL_ADV_TRACE_VSNPRINTF

Definition at line 299 of file sys_app.c.

References UTIL_ADV_TRACE_VSNPRINTF.

Referenced by TimestampNow().

Here is the caller graph for this function:

◆ UTIL_ADV_TRACE_PostSendHook()

void UTIL_ADV_TRACE_PostSendHook ( void )

Definition at line 287 of file sys_app.c.

References CFG_LPM_UART_TX_Id.

◆ UTIL_ADV_TRACE_PreSendHook()

void UTIL_ADV_TRACE_PreSendHook ( void )

Definition at line 276 of file sys_app.c.

References CFG_LPM_UART_TX_Id.

◆ UTIL_SEQ_Idle()

void UTIL_SEQ_Idle ( void )

redefines __weak function in stm32_seq.c such to enter low power

Definition at line 141 of file sys_app.c.

Variable Documentation

◆ SYS_TimerInitialisedFlag

uint8_t SYS_TimerInitialisedFlag = 0
static

Definition at line 66 of file sys_app.c.

Referenced by HAL_GetTick(), and SystemApp_Init().