summaryrefslogtreecommitdiff
path: root/software/mpu
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2013-11-06 01:21:50 +0000
committerChristian Pointner <equinox@mur.at>2013-11-06 01:21:50 +0000
commit3d27e7fdc5d80473e4d9af0fdd667eb414f20a8f (patch)
tree2be8db75fb945fd88e1f8563bd151a386070b0ee /software/mpu
parentadded leds to usb charger (diff)
main.c cleanup
git-svn-id: https://svn.spreadspace.org/mur.sat@853 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/mpu')
-rw-r--r--software/mpu/main.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/software/mpu/main.c b/software/mpu/main.c
index 9224531..90c5ef9 100644
--- a/software/mpu/main.c
+++ b/software/mpu/main.c
@@ -36,25 +36,35 @@
#include "heartbeat.h"
#include "usb-cdc-shell.h"
-static void reboot(void)
+static void sysInit(void)
{
- NVIC_SystemReset();
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
}
-static void reset2bootloader(void)
+static void subsystemsInit(void)
{
- NVIC_SystemReset();
- /* TODO: not just reset but go to bootloader */
+ /* call init functions of all subsystems which should spawn threads for their task */
+ heartbeatInit();
}
-static void shutdown(void)
+static void subsystemsStop(void)
{
/* Safely stop critical threads, aka call shutdown functions of all subsystems */
- /* nothing here. */
+ /* -> invoke the xxxStop() method on all the active device drivers */
- /* Invoke the xxxStop() method on all the active device drivers */
- /* nothing here. */
+ /* nothing here ... for now anyway */
+}
+static void sysShutdown(void)
+{
chSysDisable();
/* Stop the system timer whose service routine invokes chSysTimerHandlerI(). */
@@ -69,29 +79,31 @@ static void shutdown(void)
chSysEnable();
}
+
+static void reboot(void)
+{
+ NVIC_SystemReset();
+}
+
+static void reset2bootloader(void)
+{
+ NVIC_SystemReset();
+ /* TODO: not just reset but go to bootloader */
+}
+
/*
* Application entry point.
*/
int main(void)
{
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
- /* the base os is ready now */
-
- /* call init functions of all subsystems which should spawn threads for their task */
- heartbeatInit();
+ sysInit(); /* the base os is ready now */
+ subsystemsInit();
int8_t ret = usbCDCShellRun();
/* the debug shell returned - we have to halt, reboot or goto bootloader */
- shutdown();
+ subsystemsStop();
+ sysShutdown();
/* the OS is stopped now */
switch(ret) {