update credits
[librepilot.git] / flight / targets / boards / tinyfish / firmware / main.cpp
blobd1ebd36253705e8e4a197cc2f8bc1a6d5b011a0b
1 /**
2 ******************************************************************************
3 * @addtogroup LibrePilotSystem LibrePilot System
4 * @brief These files are the core system files for LibrePilot.
5 * They are the ground layer just above PiOS. In practice, LibrePilot actually starts
6 * in the main() function of main.cpp
7 * @{
8 * @addtogroup LibrePilotCore LibrePilot Core
9 * @brief This is where the LP firmware starts. Those files also define the compile-time
10 * options of the firmware.
11 * @{
12 * @file main.cpp
13 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2017.
14 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015
15 * @brief Sets up and runs main tasks.
16 * @see The GNU Public License (GPL) Version 3
18 *****************************************************************************/
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful, but
26 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 * for more details.
30 * You should have received a copy of the GNU General Public License along
31 * with this program; if not, write to the Free Software Foundation, Inc.,
32 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 extern "C" {
36 #include "inc/openpilot.h"
37 #include <systemmod.h>
38 /* Task Priorities */
40 /* Global Variables */
41 extern void Stack_Change(void);
42 } /* extern "C" */
44 /**
45 * OpenPilot Main function:
47 * Initialize PiOS<BR>
48 * Create the "System" task (SystemModInitializein Modules/System/systemmod.c) <BR>
49 * Start FreeRTOS Scheduler (vTaskStartScheduler) (Now handled by caller)
50 * If something goes wrong, blink LED1 and LED2 every 100ms
53 int main()
55 /* NOTE: Do NOT modify the following start-up sequence */
56 /* Any new initialization functions should be added in OpenPilotInit() */
58 vPortInitialiseBlocks();
60 /* Brings up System using CMSIS functions, enables the LEDs. */
61 PIOS_SYS_Init();
64 SystemModStart();
66 /* Start the FreeRTOS scheduler, which should never return.
68 * NOTE: OpenPilot runs an operating system (FreeRTOS), which constantly calls
69 * (schedules) function files (modules). These functions never return from their
70 * while loops, which explains why each module has a while(1){} segment. Thus,
71 * the OpenPilot software actually starts at the vTaskStartScheduler() function,
72 * even though this is somewhat obscure.
74 * In addition, there are many main() functions in the OpenPilot firmware source tree
75 * This is because each main() refers to a separate hardware platform. Of course,
76 * C only allows one main(), so only the relevant main() function is compiled when
77 * making a specific firmware.
80 vTaskStartScheduler();
82 /* If all is well we will never reach here as the scheduler will now be running. */
84 /* Do some indication to user that something bad just happened */
85 while (1) {
86 #if defined(PIOS_LED_HEARTBEAT)
87 PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
88 #endif /* PIOS_LED_HEARTBEAT */
89 PIOS_DELAY_WaitmS(100);
92 return 0;
95 /**
96 * @}
97 * @}