-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
92 lines (82 loc) · 3.39 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
******************************************************************************
@file main.cpp
@author Lucian Copeland <[email protected]>, December 2016
@author Tom Moxon <[email protected]>, September 2017
@version 1.0.0
MIT License
@brief This file provides the Main program entry point/function.
@mainpage Platform Firmware Documentation
@section main_intro Introduction
@par
\nThe "main" function runs the platform code.
Using mbed-os version 5.5 or later, the "main" routine
runs in it's own os-thread, transparently to the user.
If needed, other threads may be spawned later.
(The NVSR HL FIrmware is currently single-threaded)
The main function performs the following actions:
\n
1. Starts the platform code:
which in turn, starts and initializes each of the
library components that are part of the design.
2. The main loop runs the platform code:
which in turn, calls each of the library components,
if any foreground processing is needed by that component.
Most data movement, and any control flag processing
occurs in the interrupt context, in the background.
An interrupt driven state machine is implemented for those
components requiring additonal data and control functions.
\n
@par
@section main_packages Firmware Packages
@par
The HL Firmware utilizes several external software packages \n
with various licenses. Check each package for redistribution terms. \n
@par
\n
@par
@TODO (audit any other third-party code/tools for licensing terms) \n
@par
******************************************************************************
*/
/*-----------------------------------------------------------------------------*/
/* Include Files */
/*-----------------------------------------------------------------------------*/
#include "HL_Platform.h"
/*-----------------------------------------------------------------------------*/
/** @defgroup main main
* @{
*/
/*-----------------------------------------------------------------------------*/
/**
* @fn int main(void)
* @brief Firmware Main Entry Point
* @brief The main entry point
* @param None.
* @retval int (Main never returns, a return of int is used to indicate failure)
*/
int main() {
/** Set the MKIII Hardware Platform to "Start" mode to initialize the platform */
Platform_Mode = PLATFORM_START;
while(1) {
/** Run the Hardware Platform, a state machine with START/RUN/SLEEP/WAKE/STOP/etc. "states" */
if ((Platform_RetVal = Platform_Run(Platform_Mode)) != PLATFORM_SUCCESS) {
/** if unsuccessful, try a "Platform restart" */
if ((Platform_RetVal = Platform_Restart(Platform_RetVal)) != PLATFORM_SUCCESS) {
/** "Platform restart" failed, stop the platform now */
Platform_RetVal = Platform_Stop();
/** infinite loop on unrecoverable suit restart */
while(1) {
/** deepsleep() the processor */
deepsleep();
}
}
}
}
}
/*-----------------------------------------------------------------------------*/
/**
* Close the Doxygen main group.
* @}
*/
/* [] END OF FILE */