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

Read status related to the chip (battery level, VREF, chip temperature). More...

#include "adc_if.h"
#include "sys_app.h"
Include dependency graph for adc_if.c:

Go to the source code of this file.

Macros

#define TEMPSENSOR_TYP_CAL1_V   (( int32_t) 760)
#define TEMPSENSOR_TYP_AVGSLOPE   (( int32_t) 2500)

Functions

static uint32_t ADC_ReadChannels (uint32_t channel)
 This function reads the ADC channel.
void SYS_InitMeasurement (void)
 Initializes the ADC input.
void SYS_DeInitMeasurement (void)
 DeInitializes the ADC.
int16_t SYS_GetTemperatureLevel (void)
 Get the current temperature.
uint16_t SYS_GetBatteryLevel (void)
 Get the current battery level.

Variables

ADC_HandleTypeDef hadc
 ADC handle.

Detailed Description

Read status related to the chip (battery level, VREF, chip temperature).

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 adc_if.c.

Macro Definition Documentation

◆ TEMPSENSOR_TYP_AVGSLOPE

#define TEMPSENSOR_TYP_AVGSLOPE   (( int32_t) 2500)

Internal temperature sensor, parameter Avg_Slope (unit: uV/DegCelsius). Refer to device datasheet for min/typ/max values.

Definition at line 45 of file adc_if.c.

Referenced by SYS_GetTemperatureLevel().

◆ TEMPSENSOR_TYP_CAL1_V

#define TEMPSENSOR_TYP_CAL1_V   (( int32_t) 760)

Internal temperature sensor, parameter V30 (unit: mV). Refer to device datasheet for min/typ/max values.

Definition at line 44 of file adc_if.c.

Referenced by SYS_GetTemperatureLevel().

Function Documentation

◆ ADC_ReadChannels()

uint32_t ADC_ReadChannels ( uint32_t channel)
static

This function reads the ADC channel.

Parameters
channelchannel number to read
Returns
adc measured level value

Wait for end of conversion

Wait for end of conversion

Definition at line 181 of file adc_if.c.

References Error_Handler(), hadc, and MX_ADC_Init().

Referenced by SYS_GetBatteryLevel(), and SYS_GetTemperatureLevel().

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

◆ SYS_DeInitMeasurement()

void SYS_DeInitMeasurement ( void )

DeInitializes the ADC.

Definition at line 90 of file adc_if.c.

◆ SYS_GetBatteryLevel()

uint16_t SYS_GetBatteryLevel ( void )

Get the current battery level.

Returns
value battery level in linear scale

Definition at line 139 of file adc_if.c.

References ADC_ReadChannels().

Referenced by GetBatteryLevel(), mems_WriteToSystemParams(), and SYS_GetTemperatureLevel().

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

◆ SYS_GetTemperatureLevel()

int16_t SYS_GetTemperatureLevel ( void )

Get the current temperature.

Returns
value temperature in degree Celsius( q7.8 )

< Internal temperature sensor, parameter Avg_Slope (unit: uV/DegCelsius). Refer to device datasheet for min/typ/max values.

< Internal temperature sensor, parameter V30 (unit: mV). Refer to device datasheet for min/typ/max values.

Definition at line 97 of file adc_if.c.

References ADC_ReadChannels(), SYS_GetBatteryLevel(), TEMPSENSOR_TYP_AVGSLOPE, and TEMPSENSOR_TYP_CAL1_V.

Referenced by EnvSensors_Read().

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

◆ SYS_InitMeasurement()

void SYS_InitMeasurement ( void )

Initializes the ADC input.

Definition at line 79 of file adc_if.c.

References hadc.

Referenced by SystemApp_Init().

Here is the caller graph for this function:

Variable Documentation

◆ hadc

ADC_HandleTypeDef hadc
extern

ADC handle.

Definition at line 27 of file adc.c.