Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mf_ptu.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Gautier Hattenberger
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
24
25#include "mcu_periph/gpio.h"
26#include "mcu_periph/adc.h"
28#include "generated/airframe.h"
29
33#ifndef PTU_PRESSURE_OFFSET
34#define PTU_PRESSURE_OFFSET 0
35#endif
36#ifndef PTU_PRESSURE_SCALE
37#define PTU_PRESSURE_SCALE 1.0
38#endif
39#ifndef PTU_TEMPERATURE_OFFSET
40#define PTU_TEMPERATURE_OFFSET 0
41#endif
42#ifndef PTU_TEMPERATURE_SCALE
43#define PTU_TEMPERATURE_SCALE 1.0
44#endif
45#ifndef PTU_HUMIDTY_OFFSET
46#define PTU_HUMIDTY_OFFSET 0
47#endif
48#ifndef PTU_HUMIDTY_SCALE
49#define PTU_HUMIDTY_SCALE 1.0
50#endif
51
53#ifndef ADC_CHANNEL_PTU_NB_SAMPLES
54#define ADC_CHANNEL_PTU_NB_SAMPLES DEFAULT_AV_NB_SAMPLE
55#endif
58
63
64#if LOG_PTU
67#endif
68
69#if SEND_PTU
70#include "mcu_periph/uart.h"
71#include "pprzlink/messages.h"
73#include "modules/gps/gps.h"
74#endif
75
94
96{
97 // Read ADC
100 // Read PWM
102
103 // Log data
104#if LOG_PTU
105 if (pprzLogFile != -1) {
106 if (!log_ptu_started) {
108 "P(adc) T(adc) H(usec) GPS_fix TOW(ms) Week Lat(1e7rad) Lon(1e7rad) HMSL(mm) gpseed(cm/s) course(1e7rad) climb(cm/s)\n");
109 log_ptu_started = true;
110 } else {
111 sdLogWriteLog(pprzLogFile, "%d %d %d %d %d %d %d %d %d %d %d %d\n",
113 gps.fix, gps.tow, gps.week,
116 }
117 }
118#endif
119
120 // Send data
121#if SEND_PTU
122#define PTU_DATA_SIZE 3
123 float ptu_data[PTU_DATA_SIZE];
128#endif
129}
130
131
arch independent ADC (Analog to Digital Converter) API
uint32_t sum
Definition adc.h:54
uint8_t av_nb_sample
Definition adc.h:57
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition adc.h:53
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:312
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition gpio_arch.c:33
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
Definition gpio_arch.h:104
Some architecture independent helper functions for GPIOs.
struct GpsState gps
global GPS state
Definition gps.c:74
Device independent GPS code (interface)
uint32_t tow
GPS time of week in ms.
Definition gps.h:109
int32_t hmsl
height above mean sea level (MSL) in mm
Definition gps.h:94
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition gps.h:92
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition gps.h:99
struct NedCoor_i ned_vel
speed NED in cm/s
Definition gps.h:96
uint16_t gspeed
norm of 2d ground speed in cm/s
Definition gps.h:97
uint16_t week
GPS week.
Definition gps.h:108
uint8_t fix
status of fix
Definition gps.h:107
int32_t lat
in degrees*1e7
int32_t z
Down.
int32_t lon
in degrees*1e7
uint16_t foo
Definition main_demo5.c:58
#define PTU_PRESSURE_OFFSET
Default scale and offset send raw values if nothing defined in airframe file.
Definition mf_ptu.c:34
uint32_t humid_period
Definition mf_ptu.c:62
void mf_ptu_init(void)
Data acquisition module for Meteo France PTU board.
Definition mf_ptu.c:76
struct adc_buf pressure_buf
Definition mf_ptu.c:56
void mf_ptu_periodic(void)
Definition mf_ptu.c:95
#define ADC_CHANNEL_PTU_NB_SAMPLES
ADC buffers.
Definition mf_ptu.c:54
uint16_t pressure_adc
Raw values.
Definition mf_ptu.c:60
struct adc_buf temp_buf
Definition mf_ptu.c:57
#define PTU_PRESSURE_SCALE
Definition mf_ptu.c:37
uint16_t temp_adc
Definition mf_ptu.c:61
#define PTU_HUMIDTY_SCALE
Definition mf_ptu.c:49
#define PTU_TEMPERATURE_SCALE
Definition mf_ptu.c:43
#define PTU_TEMPERATURE_OFFSET
Definition mf_ptu.c:40
#define PTU_HUMIDTY_OFFSET
Definition mf_ptu.c:46
uint32_t get_pwm_input_period_in_usec(uint32_t channel)
Definition pwm_input.c:44
arch independent PWM input capture API
FileDes pprzLogFile
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.