Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
light_temt.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Martin Mueller
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
31 #include "mcu_periph/adc.h"
32 #include "mcu_periph/uart.h"
33 #include "pprzlink/messages.h"
35 
36 #ifndef ADC_CHANNEL_LIGHT_TEMT
37 #define ADC_CHANNEL_LIGHT_TEMT ADC_4
38 #endif
39 
40 #ifndef ADC_CHANNEL_LIGHT_NB_SAMPLES
41 #define ADC_CHANNEL_LIGHT_NB_SAMPLES 16
42 #endif
43 
44 
46 
47 static struct adc_buf buf_light_temt;
48 
49 void light_temt_init(void)
50 {
52 }
53 
55 {
56  float f_light_temt;
57 
59 
60  /* 3.6k/6.8k voltage divider, 10 bits adc */
61  f_light_temt = (adc_light_temt / 1024.) * 100.;
62 
63  DOWNLINK_SEND_TEMT_STATUS(DefaultChannel, DefaultDevice, &adc_light_temt, &f_light_temt);
64 }
65 
buf_light_temt
static struct adc_buf buf_light_temt
Definition: light_temt.c:47
uint16_t
unsigned short uint16_t
Definition: types.h:16
ADC_CHANNEL_LIGHT_NB_SAMPLES
#define ADC_CHANNEL_LIGHT_NB_SAMPLES
Definition: light_temt.c:41
adc_light_temt
uint16_t adc_light_temt
Definition: light_temt.c:45
adc_buf_channel
void adc_buf_channel(uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample)
Link between ChibiOS ADC drivers and Paparazzi adc_buffers.
Definition: adc_arch.c:289
light_temt_periodic
void light_temt_periodic(void)
Definition: light_temt.c:54
adc.h
arch independent ADC (Analog to Digital Converter) API
adc_buf::sum
uint32_t sum
Definition: adc.h:54
ADC_CHANNEL_LIGHT_TEMT
#define ADC_CHANNEL_LIGHT_TEMT
Definition: light_temt.c:37
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
light_temt_init
void light_temt_init(void)
Definition: light_temt.c:49
adc_buf::av_nb_sample
uint8_t av_nb_sample
Definition: adc.h:57
light_temt.h
adc_buf
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:53