Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
temp_adc.c File Reference

Temperature sensor module for LM35 or NTC (10k / 100k) sensor via analog input. More...

#include "std.h"
#include "modules/sensors/temp_adc.h"
#include "mcu_periph/adc.h"
#include "mcu_periph/uart.h"
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include <BOARD_CONFIG>
#include "modules/datalink/telemetry.h"
+ Include dependency graph for temp_adc.c:

Go to the source code of this file.

Macros

#define LM35   0
 
#define NTC   1
 
#define TEMP_ADC_NB_SAMPLES   DEFAULT_AV_NB_SAMPLE
 
#define TEMP_ADC_SYNC_SEND   FALSE
 Send a TEMP_ADC message with every new measurement. More...
 

Functions

float get_temp (uint8_t nr)
 
static float calc_ntc (int16_t raw_adc, uint16_t pull_up_r, float a, float b, float c)
 Calculate the NTC tempreature in celcius based on the Steinhart equation. More...
 
static float calc_lm35 (int16_t raw_temp)
 
static void temp_adc_downlink (struct transport_tx *trans, struct link_device *dev)
 
void temp_adc_init (void)
 Temperature ADC initialize channels. More...
 
void temp_adc_periodic (void)
 

Variables

bool temp_adc_sync_send = false
 
static float temp_c1
 
static float temp_c2
 
static float temp_c3
 

Detailed Description

Temperature sensor module for LM35 or NTC (10k / 100k) sensor via analog input.

Definition in file temp_adc.c.

Macro Definition Documentation

◆ LM35

#define LM35   0

Definition at line 55 of file temp_adc.c.

◆ NTC

#define NTC   1

Definition at line 56 of file temp_adc.c.

◆ TEMP_ADC_NB_SAMPLES

#define TEMP_ADC_NB_SAMPLES   DEFAULT_AV_NB_SAMPLE

Definition at line 91 of file temp_adc.c.

◆ TEMP_ADC_SYNC_SEND

#define TEMP_ADC_SYNC_SEND   FALSE

Send a TEMP_ADC message with every new measurement.

Mainly for debug, use with caution, sends message at ~10Hz.

Definition at line 98 of file temp_adc.c.

Function Documentation

◆ calc_lm35()

static float calc_lm35 ( int16_t  raw_temp)
inlinestatic

Definition at line 116 of file temp_adc.c.

Referenced by temp_adc_periodic().

+ Here is the caller graph for this function:

◆ calc_ntc()

static float calc_ntc ( int16_t  raw_adc,
uint16_t  pull_up_r,
float  a,
float  b,
float  c 
)
inlinestatic

Calculate the NTC tempreature in celcius based on the Steinhart equation.

Definition at line 104 of file temp_adc.c.

References ADC_RESOLUTION, and b.

Referenced by temp_adc_periodic().

+ Here is the caller graph for this function:

◆ get_temp()

float get_temp ( uint8_t  nr)

Definition at line 37 of file temp_adc.c.

References logger_uart_parse::nr, temp_c1, temp_c2, and temp_c3.

◆ temp_adc_downlink()

static void temp_adc_downlink ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

Definition at line 121 of file temp_adc.c.

References dev, temp_c1, temp_c2, and temp_c3.

Referenced by temp_adc_init(), and temp_adc_periodic().

+ Here is the caller graph for this function:

◆ temp_adc_init()

void temp_adc_init ( void  )

Temperature ADC initialize channels.

Definition at line 129 of file temp_adc.c.

References adc_buf_channel(), DefaultPeriodic, register_periodic_telemetry(), TEMP_ADC_CHANNEL1, TEMP_ADC_CHANNEL2, temp_adc_downlink(), TEMP_ADC_NB_SAMPLES, temp_adc_sync_send, and TEMP_ADC_SYNC_SEND.

+ Here is the call graph for this function:

◆ temp_adc_periodic()

Variable Documentation

◆ temp_adc_sync_send

bool temp_adc_sync_send = false

Definition at line 34 of file temp_adc.c.

Referenced by temp_adc_init(), and temp_adc_periodic().

◆ temp_c1

float temp_c1
static

Definition at line 35 of file temp_adc.c.

Referenced by get_temp(), temp_adc_downlink(), and temp_adc_periodic().

◆ temp_c2

float temp_c2
static

Definition at line 35 of file temp_adc.c.

Referenced by get_temp(), temp_adc_downlink(), and temp_adc_periodic().

◆ temp_c3

float temp_c3
static

Definition at line 35 of file temp_adc.c.

Referenced by get_temp(), temp_adc_downlink(), and temp_adc_periodic().