Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
adc.h
Go to the documentation of this file.
1 /*
2  * Paparazzi adc functions
3  *
4  * Copyright (C) 2003-2010 The Paparazzi team
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 
34 #ifndef _ADC_H_
35 #define _ADC_H_
36 
37 #include <inttypes.h>
38 #include "mcu_periph/adc_arch.h"
39 
40 /* Allow driver implementation to define
41  * number of available ADCs implicitly
42  */
43 #ifndef NB_ADC
44 #define NB_ADC 8
45 #endif
46 
47 #define MAX_AV_NB_SAMPLE 0x20
48 #define DEFAULT_AV_NB_SAMPLE 0x20
49 
60 struct adc_buf {
61  uint32_t sum; /* Sum of samples in buffer (avg = sum / av_nb_sample) */
62  uint16_t values[MAX_AV_NB_SAMPLE]; /* Buffer for sample values from ADC */
63  uint8_t head; /* Position index of write head in buffer */
64  uint8_t av_nb_sample; /* Number of samples to use in buffer (used for avg) */
65 };
66 
77 void adc_buf_channel(uint8_t adc_channel, struct adc_buf* s, uint8_t av_nb_sample);
78 
80 void adc_init( void );
81 #endif
unsigned short uint16_t
Definition: types.h:16
uint16_t values[MAX_AV_NB_SAMPLE]
Definition: adc.h:62
uint8_t av_nb_sample
Definition: adc.h:64
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:
Definition: adc_arch.c:205
uint32_t sum
Definition: adc.h:61
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:60
unsigned long uint32_t
Definition: types.h:18
void adc_init(void)
Starts conversions.
Definition: adc_arch.c:189
#define MAX_AV_NB_SAMPLE
Definition: adc.h:47
unsigned char uint8_t
Definition: types.h:14
uint8_t head
Definition: adc.h:63