34 #ifndef SYS_TIME_FREQUENCY
35 #error SYS_TIME_FREQUENCY should be defined in Makefile.chibios or airframe.xml and be equal to CH_CFG_ST_FREQUENCY
36 #elif CH_CFG_ST_FREQUENCY < (2 * PERIODIC_FREQUENCY) || SYS_TIME_FREQUENCY < (2 * PERIODIC_FREQUENCY)
37 #error CH_CFG_ST_FREQUENCY and SYS_TIME_FREQUENCY should be >= 2 x PERIODIC_FREQUENCY
40 #if (defined AP) && (defined FBW)
41 #error "AP and FBW can't be defined at the same time"
43 #if (!defined AP) && (!defined FBW)
44 #error "AP or FBW should be defined"
49 #define Call(f) main_fbw_ ## f
54 #define Call(f) main_ap_ ## f
57 #include "generated/modules.h"
59 #ifndef THD_WORKING_AREA_MAIN
60 #define THD_WORKING_AREA_MAIN 8192
66 static void thd_ap(
void *arg);
70 #if USE_HARD_FAULT_RECOVERY
73 #ifndef THD_WORKING_AREA_RECOVERY
74 #define THD_WORKING_AREA_RECOVERY 1024
77 static void thd_recovery(
void *arg);
79 static thread_t *recoveryThdPtr = NULL;
92 #if USE_HARD_FAULT_RECOVERY
94 if (!recovering_from_hard_fault) {
97 chThdSleepMilliseconds(100);
100 apThdPtr = chThdCreateStatic(wa_thd_ap,
sizeof(wa_thd_ap), NORMALPRIO,
thd_ap, NULL);
102 #if USE_HARD_FAULT_RECOVERY
105 chThdSleepMilliseconds(100);
108 recoveryThdPtr = chThdCreateStatic(wa_thd_recovery,
sizeof(wa_thd_recovery), NORMALPRIO, thd_recovery, NULL);
113 chThdSleep(TIME_INFINITE);
125 chRegSetThreadName(
"AP");
127 while (!chThdShouldTerminateX()) {
128 systime_t t = chVTGetSystemTime();
141 #if USE_HARD_FAULT_RECOVERY
147 static void thd_recovery(
void *arg)
150 chRegSetThreadName(
"RECOVERY");
152 while (!chThdShouldTerminateX()) {
153 systime_t t = chVTGetSystemTime();
178 #if USE_HARD_FAULT_RECOVERY
179 if (recoveryThdPtr != NULL) {
180 chThdTerminate(recoveryThdPtr);
181 chThdWait(recoveryThdPtr);
182 recoveryThdPtr = NULL;
#define CH_CFG_ST_FREQUENCY
System tick frequency.
static thread_t * apThdPtr
static void thd_ap(void *arg)
#define THD_WORKING_AREA_MAIN
int main(void)
Main function.
THD_WORKING_AREA(wa_thd_ap, THD_WORKING_AREA_MAIN)
void pprz_terminate_autopilot_threads(void)
Terminate all autopilot threads Wait until proper stop.
void main_recovery_periodic(void)
void main_recovery_event(void)
void main_recovery_init(void)
Recovery mode: run manual mode in case of hardfault Based on legacy FBW.
Arch independent mcu ( Micro Controller Unit ) utilities.
Architecture independent timing functions.