2 ******************************************************************************
3 * @addtogroup LibrePilotSystem LibrePilot System
5 * @addtogroup LibrePilotCore LibrePilot Core
6 * @brief This is where the LP firmware starts. Those files also define the compile-time
7 * options of the firmware.
10 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
11 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015
12 * @brief Sets up and runs main tasks.
13 * @see The GNU Public License (GPL) Version 3
15 *****************************************************************************/
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "inc/openpilot.h"
34 #include <systemmod.h>
37 /* Global Variables */
38 extern void Stack_Change(void);
42 * OpenPilot Main function:
45 * Create the "System" task (SystemModInitializein Modules/System/systemmod.c) <BR>
46 * Start FreeRTOS Scheduler (vTaskStartScheduler) (Now handled by caller)
47 * If something goes wrong, blink LED1 and LED2 every 100ms
52 /* NOTE: Do NOT modify the following start-up sequence */
53 /* Any new initialization functions should be added in OpenPilotInit() */
55 vPortInitialiseBlocks();
57 /* Brings up System using CMSIS functions, enables the LEDs. */
63 /* Start the FreeRTOS scheduler, which should never return.
65 * NOTE: OpenPilot runs an operating system (FreeRTOS), which constantly calls
66 * (schedules) function files (modules). These functions never return from their
67 * while loops, which explains why each module has a while(1){} segment. Thus,
68 * the OpenPilot software actually starts at the vTaskStartScheduler() function,
69 * even though this is somewhat obscure.
71 * In addition, there are many main() functions in the OpenPilot firmware source tree
72 * This is because each main() refers to a separate hardware platform. Of course,
73 * C only allows one main(), so only the relevant main() function is compiled when
74 * making a specific firmware.
77 vTaskStartScheduler();
79 /* If all is well we will never reach here as the scheduler will now be running. */
81 /* Do some indication to user that something bad just happened */
83 #if defined(PIOS_LED_HEARTBEAT)
84 PIOS_LED_Toggle(PIOS_LED_HEARTBEAT
);
85 #endif /* PIOS_LED_HEARTBEAT */
86 PIOS_DELAY_WaitmS(100);