diff options
author | Christian Pointner <equinox@mur.at> | 2013-08-28 02:48:21 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2013-08-28 02:48:21 +0000 |
commit | 4ef06df354f5252982988815d4c30b182bd12692 (patch) | |
tree | 7f5783a28c38017f2b5ec2142e5208a013fc140e /software/mpu/main.c | |
parent | added hardware support for SMT32F405 (diff) |
implemented system shutdown and reboot (not yet finished)
git-svn-id: https://svn.spreadspace.org/mur.sat@846 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/mpu/main.c')
-rw-r--r-- | software/mpu/main.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/software/mpu/main.c b/software/mpu/main.c index 461c071..a737d9b 100644 --- a/software/mpu/main.c +++ b/software/mpu/main.c @@ -36,6 +36,17 @@ #include "heartbeat.h" #include "usb-cdc-shell.h" +static void reboot(void) +{ + NVIC_SystemReset(); +} + +static void reset2bootloader(void) +{ + NVIC_SystemReset(); + /* TODO: not just reset but go to bootloader */ +} + /* * Application entry point. */ @@ -52,8 +63,31 @@ int main(void) chSysInit(); heartbeatInit(); - usbCDCShellInit(); - while (TRUE) { - 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(); + /* the OS is stopped now */ + + switch(ret) { + case MPU_BOOTLOADER: reset2bootloader(); break; + case MPU_REBOOT: reboot(); break; } + for(;;); /* halting system, aka loop endlessly */ } |