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
test_adc.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 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 
25 #include <stm32/flash.h>
26 #include <stm32/misc.h>
27 
28 #include BOARD_CONFIG
29 #include "mcu.h"
30 #include "mcu_periph/sys_time.h"
31 #include "led.h"
32 #include "mcu_periph/adc.h"
33 #include "mcu_periph/uart.h"
35 
36 int main_periodic(void);
37 static inline void main_init( void );
38 static inline void main_periodic_task( void );
39 static inline void main_event_task( void );
40 
41 static struct adc_buf adc0_buf;
42 static struct adc_buf adc1_buf;
43 static struct adc_buf adc2_buf;
44 static struct adc_buf adc3_buf;
45 
47 
48 static inline void main_init( void ) {
49  mcu_init();
51  adc_init();
52  adc_buf_channel(0, &adc0_buf, 8);
53  adc_buf_channel(1, &adc1_buf, 3);
54  adc_buf_channel(2, &adc2_buf, 3);
55  adc_buf_channel(3, &adc3_buf, 3);
56 }
57 
58 int main( void ) {
59  main_init();
60 
61  while(1) {
64  }
66  }
67  return 0;
68 }
69 
70 static inline void main_periodic_task( void ) {
71  RunOnceEvery(100, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
72  RunOnceEvery(100, {/*LED_TOGGLE(7);*/ DOWNLINK_SEND_TIME(DefaultChannel, DefaultDevice, &sys_time.nb_sec);});
73  LED_PERIODIC();
74 }
75 
76 static inline void main_event_task( void ) {
77 
80  uint16_t v1 = 123;
81  uint16_t v2 = 123;
82  // v1 = (((adc0_buf.values[0])));
84  v2 = (((adc3_buf.values[0])));
85  RunOnceEvery(100, {DOWNLINK_SEND_ADC_GENERIC(DefaultChannel, DefaultDevice, &v1, &v2)});
86  }
87 
88 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint16_t values[MAX_AV_NB_SAMPLE]
Definition: adc.h:62
static void main_event_task(void)
Definition: test_adc.c:76
static void main_init(void)
Definition: test_adc.c:48
uint8_t av_nb_sample
Definition: adc.h:64
arch independent ADC (Analog to Digital Converter) API
uint32_t sum
Definition: adc.h:61
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
static struct adc_buf adc1_buf
Definition: test_adc.c:42
int main(void)
Definition: test_adc.c:58
Architecture independent timing functions.
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:60
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:35
uint8_t adc_new_data_trigger
Definition: adc_arch.c:100
static bool_t sys_time_check_and_ack_timer(tid_t id)
Definition: sys_time.h:90
#define LED_PERIODIC()
Definition: led_hw.h:8
arch independent mcu ( Micro Controller Unit ) utilities
static struct adc_buf adc0_buf
Definition: test_adc.c:41
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
unsigned char uint8_t
Definition: types.h:14
int main_periodic(void)
Definition: main.c:157
volatile uint32_t nb_sec
full seconds since startup
Definition: sys_time.h:55
static void main_periodic_task(void)
Definition: test_adc.c:70
void adc_init(void)
Starts conversions.
Definition: adc_arch.c:189
arch independent LED (Light Emitting Diodes) API
static struct adc_buf adc3_buf
Definition: test_adc.c:44
static struct adc_buf adc2_buf
Definition: test_adc.c:43
void mcu_init(void)
Definition: mcu.c:57