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_baro.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
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 /*
23  *
24  * test baro using interrupts
25  *
26  */
27 
28 #include BOARD_CONFIG
29 
30 #include "mcu.h"
31 #include "mcu_periph/sys_time.h"
32 #include "mcu_periph/uart.h"
33 #include "mcu_periph/i2c.h"
34 
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 int main(void) {
50  main_init();
51 
52  while(1) {
56  }
57 
58  return 0;
59 }
60 
61 static inline void main_init( void ) {
62  mcu_init();
64  baro_init();
65 
66  // DEBUG_SERVO1_INIT();
67  // DEBUG_SERVO2_INIT();
68 
69 
70 }
71 
72 
73 
74 static inline void main_periodic_task( void ) {
75 
76  RunOnceEvery(2, {baro_periodic();});
77  LED_PERIODIC();
78  RunOnceEvery(256, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
79  RunOnceEvery(256,
80  {
81  uint16_t i2c2_ack_fail_cnt = i2c2.errors->ack_fail_cnt;
82  uint16_t i2c2_miss_start_stop_cnt = i2c2.errors->miss_start_stop_cnt;
83  uint16_t i2c2_arb_lost_cnt = i2c2.errors->arb_lost_cnt;
84  uint16_t i2c2_over_under_cnt = i2c2.errors->over_under_cnt;
85  uint16_t i2c2_pec_recep_cnt = i2c2.errors->pec_recep_cnt;
86  uint16_t i2c2_timeout_tlow_cnt = i2c2.errors->timeout_tlow_cnt;
87  uint16_t i2c2_smbus_alert_cnt = i2c2.errors->smbus_alert_cnt;
88  uint16_t i2c2_unexpected_event_cnt = i2c2.errors->unexpected_event_cnt;
89  uint32_t i2c2_last_unexpected_event = i2c2.errors->last_unexpected_event;
90  const uint8_t _bus2 = 2;
91  DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
92  &i2c2_ack_fail_cnt,
93  &i2c2_miss_start_stop_cnt,
94  &i2c2_arb_lost_cnt,
95  &i2c2_over_under_cnt,
96  &i2c2_pec_recep_cnt,
97  &i2c2_timeout_tlow_cnt,
98  &i2c2_smbus_alert_cnt,
99  &i2c2_unexpected_event_cnt,
100  &i2c2_last_unexpected_event,
101  &_bus2);
102  });
103 }
104 
105 
106 
107 static inline void main_event_task( void ) {
109 }
110 
111 
112 
113 static inline void main_on_baro_diff(void) {
114 
115 }
116 
117 static inline void main_on_baro_abs(void) {
118  RunOnceEvery(5,{DOWNLINK_SEND_BARO_RAW(DefaultChannel, DefaultDevice, &baro.absolute, &baro.differential);});
119 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static void main_init(void)
Definition: test_baro.c:61
void baro_periodic(void)
Definition: baro_board.c:56
#define BaroEvent(_b_abs_handler, _b_diff_handler)
Definition: baro_board.h:22
#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
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
static void main_on_baro_diff(void)
Definition: test_baro.c:113
#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_periodic_task(void)
Definition: test_baro.c:74
arch independent LED (Light Emitting Diodes) API
int main(void)
Definition: test_baro.c:46
static void main_event_task(void)
Definition: test_baro.c:107
static void main_on_baro_abs(void)
Definition: test_baro.c:117
void mcu_init(void)
Definition: mcu.c:57