Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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 MCU_PERIPH_ADC_H
35 #define MCU_PERIPH_ADC_H
36 
37 #include <inttypes.h>
38 #include "mcu_periph/adc_arch.h"
39 
40 #define MAX_AV_NB_SAMPLE 0x20
41 #define DEFAULT_AV_NB_SAMPLE 0x20
42 
53 struct adc_buf {
54  uint32_t sum; /* Sum of samples in buffer (avg = sum / av_nb_sample) */
55  uint16_t values[MAX_AV_NB_SAMPLE]; /* Buffer for sample values from ADC */
56  uint8_t head; /* Position index of write head in buffer */
57  uint8_t av_nb_sample; /* Number of samples to use in buffer (used for avg) */
58 };
59 
70 void adc_buf_channel(uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample);
71 
73 void adc_init(void);
74 
75 #endif
uint8_t av_nb_sample
Definition: adc.h:57
unsigned short uint16_t
Definition: types.h:16
static uint32_t s
uint32_t sum
Definition: adc.h:54
uint8_t head
Definition: adc.h:56
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:281
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:53
unsigned long uint32_t
Definition: types.h:18
void adc_init(void)
Starts conversions.
Definition: adc_arch.c:304
#define MAX_AV_NB_SAMPLE
Definition: adc.h:40
uint16_t values[MAX_AV_NB_SAMPLE]
Definition: adc.h:55
unsigned char uint8_t
Definition: types.h:14