36 #if PERIODIC_TELEMETRY
43 #ifndef TEMP_ADC_CHANNEL1
44 #ifndef TEMP_ADC_CHANNEL2
45 #ifndef TEMP_ADC_CHANNEL3
46 #error "at least one TEMP_ADC_CHANNEL1/2/3 needs to be defined to use the temp_adc module"
51 #ifndef TEMP_ADC_CHANNEL1_TYPE
52 #define TEMP_ADC_CHANNEL1_TYPE LM35
54 #ifndef TEMP_ADC_CHANNEL2_TYPE
55 #define TEMP_ADC_CHANNEL2_TYPE LM35
57 #ifndef TEMP_ADC_CHANNEL3_TYPE
58 #define TEMP_ADC_CHANNEL3_TYPE LM35
61 #ifdef TEMP_ADC_CHANNEL1
62 static struct adc_buf temp_buf1;
65 #ifdef TEMP_ADC_CHANNEL2
66 static struct adc_buf temp_buf2;
69 #ifdef TEMP_ADC_CHANNEL3
70 static struct adc_buf temp_buf3;
73 #ifndef TEMP_ADC_NB_SAMPLES
74 #define TEMP_ADC_NB_SAMPLES DEFAULT_AV_NB_SAMPLE
80 #ifndef TEMP_ADC_SYNC_SEND
81 #define TEMP_ADC_SYNC_SEND FALSE
88 temp_c = log(((10240000 / raw_temp) - 10000) * 10);
90 temp_c = 1 / (0.000603985662844 + (0.000229995493730 * temp_c) + (0.000000067653027 * temp_c *
92 temp_c = temp_c - 273.15;
98 return ((
float)raw_temp * (3300.0f / 1024.0f) / 10.0f);
110 #ifdef TEMP_ADC_CHANNEL1
114 #ifdef TEMP_ADC_CHANNEL2
118 #ifdef TEMP_ADC_CHANNEL3
122 #if PERIODIC_TELEMETRY
132 #ifdef TEMP_ADC_CHANNEL1
133 adc_raw = temp_buf1.sum / temp_buf1.av_nb_sample;
134 #if TEMP_ADC_CHANNEL1_TYPE == LM35
136 #elif TEMP_ADC_CHANNEL1_TYPE == NTC
141 #ifdef TEMP_ADC_CHANNEL2
142 adc_raw = temp_buf2.sum / temp_buf2.av_nb_sample;
143 #if TEMP_ADC_CHANNEL2_TYPE == LM35
145 #elif TEMP_ADC_CHANNEL2_TYPE == NTC
150 #ifdef TEMP_ADC_CHANNEL3
151 adc_raw = temp_buf3.sum / temp_buf3.av_nb_sample;
152 #if TEMP_ADC_CHANNEL3_TYPE == LM35
154 #elif TEMP_ADC_CHANNEL3_TYPE == NTC
#define TEMP_ADC_NB_SAMPLES
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
Generic transmission transport header.
Periodic telemetry system header (includes downlink utility and generated code).
bool_t temp_adc_sync_send
flag to enable sending every new measurement via telemetry
arch independent ADC (Analog to Digital Converter) API
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
float calc_ntc(int16_t raw_temp)
float calc_lm35(int16_t raw_temp)
static void temp_adc_downlink(struct transport_tx *trans, struct link_device *dev)
void temp_adc_periodic(void)
#define DefaultPeriodic
Set default periodic telemetry.
void adc_buf_channel(uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample)
Registers a buffer to be used to store the specified converted channel Usage:
static const struct usb_device_descriptor dev
#define DefaultChannel
SITL.
Common code for AP and FBW telemetry.
temperature driver for LM35 and 100k NTC analog sensores
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define TEMP_ADC_SYNC_SEND
Send a TEMP_ADC message with every new measurement.