Paparazzi UAS
v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
main_chibios.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2013-2015 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
26
#include "
mcu_periph/sys_time.h
"
27
#include "
mcu.h
"
28
#include <ch.h>
29
30
#ifndef SYS_TIME_FREQUENCY
31
#error SYS_TIME_FREQUENCY should be defined in Makefile.chibios or airframe.xml and be equal to CH_CFG_ST_FREQUENCY
32
#elif SYS_TIME_FREQUENCY != CH_CFG_ST_FREQUENCY
33
#error SYS_TIME_FREQUENCY should be equal to CH_CFG_ST_FREQUENCY
34
#elif CH_CFG_ST_FREQUENCY < (2 * PERIODIC_FREQUENCY)
35
#error CH_CFG_ST_FREQUENCY and SYS_TIME_FREQUENCY should be >= 2 x PERIODIC_FREQUENCY
36
#endif
37
38
#include "
firmwares/rotorcraft/main_ap.h
"
39
40
#ifndef THD_WORKING_AREA_MAIN
41
#define THD_WORKING_AREA_MAIN 8192
42
#endif
43
44
/*
45
* PPRZ/AP thread
46
* Also include FBW on single MCU
47
*/
48
static
void
thd_ap
(
void
*arg);
49
THD_WORKING_AREA
(wa_thd_ap,
THD_WORKING_AREA_MAIN
);
50
static
thread_t *
apThdPtr
= NULL;
51
55
int
main
(
void
)
56
{
57
// Init
58
main_init
();
59
60
chThdSleepMilliseconds(100);
61
62
// Create threads
63
apThdPtr
= chThdCreateStatic(wa_thd_ap,
sizeof
(wa_thd_ap), NORMALPRIO,
thd_ap
, NULL);
64
65
// Main loop, do nothing
66
chThdSleep(TIME_INFINITE);
67
return
0;
68
}
69
70
/*
71
* PPRZ/AP thread
72
*
73
* Call PPRZ AP periodic and event functions
74
*/
75
static
void
thd_ap
(
void
*arg)
76
{
77
(void) arg;
78
chRegSetThreadName(
"AP"
);
79
80
while
(!chThdShouldTerminateX()) {
81
handle_periodic_tasks
();
82
main_event
();
83
// In tick mode, the minimum step is 1e6 / CH_CFG_ST_FREQUENCY
84
// which means that whatever happens, if we do a sleep of this
85
// time step, the next wakeup will be "aligned" and we won't see
86
// jitter. The polling on event will also be as fast as possible
87
// Be careful that in tick-less mode, it will be required to use
88
// the chThdSleepUntil function with a correct computation of the
89
// wakeup time, in particular roll-over should be check.
90
chThdSleepMicroseconds(1000000 /
CH_CFG_ST_FREQUENCY
);
91
}
92
93
chThdExit(0);
94
}
95
96
/*
97
* Terminate autopilot threads
98
* Wait until proper stop
99
*/
100
void
pprz_terminate_autopilot_threads
(
void
)
101
{
102
if
(
apThdPtr
!= NULL) {
103
chThdTerminate(
apThdPtr
);
104
chThdWait(
apThdPtr
);
105
apThdPtr
= NULL;
106
}
107
}
108
THD_WORKING_AREA_MAIN
#define THD_WORKING_AREA_MAIN
Definition:
main_chibios.c:41
handle_periodic_tasks
STATIC_INLINE void handle_periodic_tasks(void)
Definition:
main_ap.c:202
THD_WORKING_AREA
THD_WORKING_AREA(wa_thd_ap, THD_WORKING_AREA_MAIN)
thd_ap
static void thd_ap(void *arg)
Definition:
main_chibios.c:75
sys_time.h
Architecture independent timing functions.
main_event
static void main_event(void)
Definition:
uart_tunnel.c:85
main_ap.h
Rotorcraft main loop.
pprz_terminate_autopilot_threads
void pprz_terminate_autopilot_threads(void)
Terminate all autopilot threads Wait until proper stop.
Definition:
main_chibios.c:178
mcu.h
Arch independent mcu ( Micro Controller Unit ) utilities.
main_init
static void main_init(void)
Definition:
demo_ahrs_actuators.c:87
apThdPtr
static thread_t * apThdPtr
Definition:
main_chibios.c:50
main
int main(void)
Main function.
Definition:
main_chibios.c:87
CH_CFG_ST_FREQUENCY
#define CH_CFG_ST_FREQUENCY
System tick frequency.
Definition:
chconf.h:52
sw
airborne
firmwares
rotorcraft
main_chibios.c
Generated on Wed Feb 10 2021 04:34:00 for Paparazzi UAS by
1.8.8