Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
temp_tcouple_adc.c
Go to the documentation of this file.
1 /*
2  * $Id: temp_tcouple_adc.c $
3  *
4  * Copyright (C) 2011 Martin Mueller
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
33 #include "mcu_periph/adc.h"
34 #include "mcu_periph/uart.h"
35 #include "messages.h"
38 
39 #ifndef ADC_CHANNEL_TEMP_REF
40 #define ADC_CHANNEL_TEMP_REF ADC_4
41 #endif
42 #ifndef ADC_CHANNEL_TEMP_VAL
43 #define ADC_CHANNEL_TEMP_VAL ADC_3
44 #endif
45 
46 #ifndef ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
47 #define ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES 16
48 #endif
49 
50 #ifndef DOWNLINK_DEVICE
51 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
52 #endif
53 
57 
60 
61 void temp_tcouple_adc_init( void ) {
68  temp_cnt = 0;
69 }
70 
74 
75  /* no voltage divider, 10 bits adc, 3.3V max */
76  /* T = U * 52.288899706 - 7.977784737996595 */
77  fval[temp_cnt] = ((float)(val[temp_cnt] * 3.3) / 1023.)
78  * 52.288899706 - 7.977784737996595;
79  fref[temp_cnt] = ((float)(ref[temp_cnt] * 3.3) / 1023.)
80  * 100. - 13.;
81 
82  if (++temp_cnt >= TCOUPLE_NB) {
83  DOWNLINK_SEND_TEMP_TCOUPLE(DefaultChannel, DefaultDevice,
84  &fval[0], &fval[1], &fval[2], &fval[3],
85  &fref[0], &fref[1], &fref[2], &fref[3],
86  &val[0], &val[1], &val[2], &val[3],
87  &ref[0], &ref[1], &ref[2], &ref[3]);
88  temp_cnt = 0;
89  }
90 }
91 
unsigned short uint16_t
Definition: types.h:16
#define TCOUPLE_NB
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
float fval[TCOUPLE_NB]
static struct adc_buf buf_temp_tcouple_ref
#define ADC_CHANNEL_TEMP_VAL
uint8_t av_nb_sample
Definition: adc.h:64
arch independent ADC (Analog to Digital Converter) API
uint32_t sum
Definition: adc.h:61
uint16_t ref[TCOUPLE_NB]
#define ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES
uint16_t val[TCOUPLE_NB]
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:60
static struct adc_buf buf_temp_tcouple_val
#define ADC_CHANNEL_TEMP_REF
signed long int32_t
Definition: types.h:19
void temp_tcouple_adc_init(void)
void adc_buf_channel(uint8_t adc_channel __attribute__((unused)), struct adc_buf *s __attribute__((unused)), uint8_t av_nb_sample __attribute__((unused)))
Required by infrared.c:ir_init()
Definition: jsbsim_ir.c:35
void temp_tcouple_adc_periodic(void)
float fref[TCOUPLE_NB]
int32_t temp_cnt