Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test_baro.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
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  *
26  * test baro using interrupts
27  *
28  */
29 
30 #include BOARD_CONFIG
31 
32 #include "mcu.h"
33 #include "mcu_periph/sys_time.h"
34 #include "mcu_periph/uart.h"
35 #include "led.h"
36 
38 
40 //#include "my_debug_servo.h"
41 
42 static inline void main_init( void );
43 static inline void main_periodic_task( void );
44 static inline void main_event_task( void );
45 
46 static inline void main_on_baro_diff(void);
47 static inline void main_on_baro_abs(void);
48 
49 
50 int main(void) {
51  main_init();
52 
53  while(1) {
57  }
58 
59  return 0;
60 }
61 
62 static inline void main_init( void ) {
63  mcu_init();
65  baro_init();
66 
67  // DEBUG_SERVO1_INIT();
68  // DEBUG_SERVO2_INIT();
69 
70 
71 }
72 
73 
74 
75 static inline void main_periodic_task( void ) {
76 
77  RunOnceEvery(2, {baro_periodic();});
78  LED_PERIODIC();
79  RunOnceEvery(256, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
80  RunOnceEvery(256,
81  {
82  uint16_t i2c2_ack_fail_cnt = i2c2.errors->ack_fail_cnt;
83  uint16_t i2c2_miss_start_stop_cnt = i2c2.errors->miss_start_stop_cnt;
84  uint16_t i2c2_arb_lost_cnt = i2c2.errors->arb_lost_cnt;
85  uint16_t i2c2_over_under_cnt = i2c2.errors->over_under_cnt;
86  uint16_t i2c2_pec_recep_cnt = i2c2.errors->pec_recep_cnt;
87  uint16_t i2c2_timeout_tlow_cnt = i2c2.errors->timeout_tlow_cnt;
88  uint16_t i2c2_smbus_alert_cnt = i2c2.errors->smbus_alert_cnt;
89  uint16_t i2c2_unexpected_event_cnt = i2c2.errors->unexpected_event_cnt;
90  uint32_t i2c2_last_unexpected_event = i2c2.errors->last_unexpected_event;
91  const uint8_t _bus2 = 2;
92  DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
93  &i2c2_ack_fail_cnt,
94  &i2c2_miss_start_stop_cnt,
95  &i2c2_arb_lost_cnt,
96  &i2c2_over_under_cnt,
97  &i2c2_pec_recep_cnt,
98  &i2c2_timeout_tlow_cnt,
99  &i2c2_smbus_alert_cnt,
100  &i2c2_unexpected_event_cnt,
101  &i2c2_last_unexpected_event,
102  &_bus2);
103  });
104 }
105 
106 
107 
108 static inline void main_event_task( void ) {
110 }
111 
112 
113 
114 static inline void main_on_baro_diff(void) {
115 
116 }
117 
118 static inline void main_on_baro_abs(void) {
119  RunOnceEvery(5,{DOWNLINK_SEND_BARO_RAW(DefaultChannel, DefaultDevice, &baro.absolute, &baro.differential);});
120 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static void main_event_task(void)
Definition: test_baro.c:108
void baro_periodic(void)
Definition: baro_board.c:56
#define BaroEvent(_b_abs_handler, _b_diff_handler)
Definition: baro_board.h:22
static void main_on_baro_diff(void)
Definition: test_baro.c:114
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
int32_t absolute
Definition: baro.h:42
struct Baro baro
Definition: baro_board.c:34
Architecture independent timing functions.
int32_t differential
Definition: baro.h:43
unsigned long uint32_t
Definition: types.h:18
static void main_periodic_task(void)
Definition: test_baro.c:75
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:35
void baro_init(void)
Definition: baro_board.c:38
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
unsigned char uint8_t
Definition: types.h:14
static void main_init(void)
Definition: test_baro.c:62
arch independent LED (Light Emitting Diodes) API
static void main_on_baro_abs(void)
Definition: test_baro.c:118
int main(void)
Definition: test_baro.c:46
void mcu_init(void)
Definition: mcu.c:57