Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
test_datalink.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 #define DATALINK_C
23 
24 #include BOARD_CONFIG
25 #include "mcu.h"
26 #include "mcu_periph/sys_time.h"
28 
30 
31 static inline void main_init( void );
32 static inline void main_periodic( void );
33 static inline void main_event( void );
34 
35 int main(void) {
36 
37  main_init();
38 
39  while (1) {
41  main_periodic();
42  main_event();
43  }
44  return 0;
45 }
46 
47 static inline void main_init( void ) {
48  mcu_init();
50 }
51 
52 static inline void main_periodic( void ) {
53  RunOnceEvery(100, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
54 }
55 
56 static inline void main_event( void ) {
57  DatalinkEvent();
58 }
59 
60 void dl_parse_msg(void) {
61  // FIXME : when i remove the datalink=0 line it stops working !!!!
62  datalink_time = 0;
63  uint8_t msg_id = dl_buffer[1];
64  switch (msg_id) {
65 
66  case DL_PING:
67  {
68  DOWNLINK_SEND_PONG(DefaultChannel, DefaultDevice);
69  }
70  break;
71  }
72 }
void mcu_init(void)
Microcontroller peripherals initialization.
Definition: mcu.c:61
Architecture independent timing functions.
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:37
static bool_t sys_time_check_and_ack_timer(tid_t id)
Check if timer has elapsed.
Definition: sys_time.h:111
uint16_t datalink_time
Definition: sim_ap.c:44
Arch independent mcu ( Micro Controller Unit ) utilities.
unsigned char uint8_t
Definition: types.h:14
uint8_t dl_buffer[MSG_SIZE]
Definition: main_demo5.c:59
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54