summaryrefslogtreecommitdiff
path: root/software/mpu/main.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2013-10-04 12:56:18 +0000
committerChristian Pointner <equinox@mur.at>2013-10-04 12:56:18 +0000
commit5d999bbb012e0c649125531f2a14db9ce334fe89 (patch)
tree503b64c1d93d3c9a1bc5d84cf1f129240248ebb3 /software/mpu/main.c
parentmoved new usb charger to satelite-bus (diff)
some cleanups
git-svn-id: https://svn.spreadspace.org/mur.sat@850 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/mpu/main.c')
-rw-r--r--software/mpu/main.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/software/mpu/main.c b/software/mpu/main.c
index a737d9b..9224531 100644
--- a/software/mpu/main.c
+++ b/software/mpu/main.c
@@ -47,6 +47,28 @@ static void reset2bootloader(void)
/* TODO: not just reset but go to bootloader */
}
+static void shutdown(void)
+{
+ /* Safely stop critical threads, aka call shutdown functions of all subsystems */
+ /* nothing here. */
+
+ /* Invoke the xxxStop() method on all the active device drivers */
+ /* nothing here. */
+
+ chSysDisable();
+
+ /* Stop the system timer whose service routine invokes chSysTimerHandlerI(). */
+ SysTick->CTRL &= ~(SysTick_CTRL_ENABLE_Msk);
+
+ /* Disable any other interrupt source that may invoke OS APIs */
+ /* nothing here. */
+
+ /* Perform any application related de-initialization. */
+ /* nothing here. */
+
+ chSysEnable();
+}
+
/*
* Application entry point.
*/
@@ -61,28 +83,15 @@ int main(void)
*/
halInit();
chSysInit();
+ /* the base os is ready now */
+ /* call init functions of all subsystems which should spawn threads for their task */
heartbeatInit();
- int8_t ret = usbCDCShellRun();
+ int8_t ret = usbCDCShellRun();
/* the debug shell returned - we have to halt, reboot or goto bootloader */
- /* Safely stop critical threads */
- /* nothing here. */
-
- /* Invoke the xxxStop() method on all the active device drivers */
- chSysDisable();
-
- /* Stop the system timer whose service routine invokes chSysTimerHandlerI(). */
- SysTick->CTRL &= ~(SysTick_CTRL_ENABLE_Msk);
-
- /* Disable any other interrupt source that may invoke OS APIs */
- /* nothing here. */
-
- /* Perform any application related de-initialization. */
- /* nothing here. */
-
- chSysEnable();
+ shutdown();
/* the OS is stopped now */
switch(ret) {