Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mcu_arch.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2009-2013 The Paparazzi Team
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
30 #include "mcu_arch.h"
31 
32 #if USE_LINUX_SIGNAL
33 #include "message_pragmas.h"
34 PRINT_CONFIG_MSG("Catching SIGINT. Press CTRL-C twice to stop program.")
35 
36 /*
37  * Handle linux signals by hand if the program is not launch
38  * by a shell already doing it
39  */
40 
41 #include <stdlib.h>
42 #include <stdio.h>
43 #include <signal.h>
44 
48 static void sig_handler(int signo)
49 {
50  static int nb_signal = 0;
51 
52  if (signo == SIGINT) {
53  printf("Received SIGINT\n");
54  if (nb_signal == 0) {
55  printf("Press Ctrl-C again to stop the program\n");
56  nb_signal++;
57  } else {
58  printf("Leaving now\n");
59  exit(0);
60  }
61  }
62 }
63 
64 void mcu_arch_init(void)
65 {
66  struct sigaction sa;
67  sigemptyset(&sa.sa_mask);
68  sa.sa_flags = 0;
69  sa.sa_handler = &sig_handler;
70  if (sigaction(SIGINT, &sa, NULL) == -1) {
71  printf("Can't catch SIGINT\n");
72  }
73 }
74 
75 #else
76 
77 void mcu_arch_init(void) { }
78 
79 #endif
80 
void mcu_arch_init(void)
Definition: mcu_arch.c:109
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
linux arch dependant microcontroller initialisation functions.