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_datalink.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 #define DATALINK_C
25 
26 #include BOARD_CONFIG
27 #include "mcu.h"
28 #include "mcu_periph/sys_time.h"
30 
32 
33 static inline void main_init( void );
34 static inline void main_periodic( void );
35 static inline void main_event( void );
36 
37 int main(void) {
38 
39  main_init();
40 
41  while (1) {
43  main_periodic();
44  main_event();
45  }
46  return 0;
47 }
48 
49 static inline void main_init( void ) {
50  mcu_init();
52 }
53 
54 static inline void main_periodic( void ) {
55  RunOnceEvery(100, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
56 }
57 
58 static inline void main_event( void ) {
59  DatalinkEvent();
60 }
61 
62 void dl_parse_msg(void) {
63  // FIXME : when i remove the datalink=0 line it stops working !!!!
64  datalink_time = 0;
65  uint8_t msg_id = dl_buffer[1];
66  switch (msg_id) {
67 
68  case DL_PING:
69  {
70  DOWNLINK_SEND_PONG(DefaultChannel, DefaultDevice);
71  }
72  break;
73  }
74 }
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
Architecture independent timing functions.
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:35
static bool_t sys_time_check_and_ack_timer(tid_t id)
Definition: sys_time.h:90
uint16_t datalink_time
Definition: sim_ap.c:46
arch independent mcu ( Micro Controller Unit ) utilities
unsigned char uint8_t
Definition: types.h:14
void mcu_init(void)
Definition: mcu.c:57