Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
main_chibios_libopencm3.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Gautier Hattenberger, Alexandre Bustico
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 
27 #include "mcu_periph/sys_time.h"
28 #include "chibios_stub.h"
29 #include "subsystems/chibios-libopencm3/chibios_sdlog.h"
30 #include "sdLog.h"
31 
32 #ifdef FBW
34 #define Fbw(f) f ## _fbw()
35 #else
36 #define Fbw(f)
37 #endif
38 
39 #ifdef AP
41 #define Ap(f) f ## _ap()
42 #else
43 #define Ap(f)
44 #endif
45 
46 #include "led.h"
47 
48 
49 static int32_t pprz_thd (void *arg);
50 static bool_t sdlogOk ;
51 bool_t pprzReady = FALSE;
52 
53 int main( void )
54 {
55  // Init
56  sys_time_init();
57 
58  // Init ChibiOS
60 
61  // Init PPRZ
62  Fbw(init);
63  Ap(init);
64 
65  chibios_chThdSleepMilliseconds(100);
66 
68  pprzReady = TRUE;
69  // Call PPRZ periodic and event functions
70  while (TRUE) {
71  chibios_chThdSleepMilliseconds(1000);
72  }
73  return 0;
74 }
75 
76 
77 static int32_t pprz_thd (void *arg)
78 {
79  /*
80  To be compatible with rtos architecture, each of this 4 workers should
81  be implemented in differents threads, each of them waiting for job to be done:
82  periodic task should sleep, and event task should wait for event
83  */
84  (void) arg;
85  chibios_chRegSetThreadName ("pprz big loop");
86 
87  while (!chThdShouldTerminate()) {
90  Fbw(event_task);
91  Ap(event_task);
92  chibios_chThdSleepMilliseconds(1);
93  }
94 
95  return 0;
96 }
FBW ( FlyByWire ) process API.
AP ( AutoPilot ) process API.
#define Fbw(f)
#define Ap(f)
bool_t chibios_init(void)
Definition: chibios_init.c:68
STATIC_INLINE void handle_periodic_tasks(void)
Definition: main.c:200
#define FALSE
Definition: imu_chimu.h:141
Architecture independent timing functions.
void sys_time_init(void)
Definition: sys_time.c:70
signed long int32_t
Definition: types.h:19
#define TRUE
Definition: imu_chimu.h:144
bool_t pprzReady
static int32_t pprz_thd(void *arg)
int main(void)
void launch_pprz_thd(int32_t(*thd)(void *arg))
Definition: chibios_init.c:83
static bool_t sdlogOk
arch independent LED (Light Emitting Diodes) API