diff options
Diffstat (limited to 'nuttx/configs/vsn/src/power.c')
-rw-r--r-- | nuttx/configs/vsn/src/power.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/nuttx/configs/vsn/src/power.c b/nuttx/configs/vsn/src/power.c index 2e23ed033..c7c73448a 100644 --- a/nuttx/configs/vsn/src/power.c +++ b/nuttx/configs/vsn/src/power.c @@ -1,6 +1,6 @@ /**************************************************************************** - * config/vsn/src/ramtron.c - * arch/arm/src/board/ramtron.c + * config/vsn/src/power.c + * arch/arm/src/board/power.c * * Copyright (C) 2011 Uros Platise. All rights reserved. * @@ -37,21 +37,57 @@ #include <nuttx/config.h> +#include <arch/board/board.h> +#include <arch/stm32/irq.h> + #include <stdint.h> #include <stdbool.h> #include <debug.h> -#include <arch/board/board.h> +#include "stm32_gpio.h" #include "vsn.h" +#include "up_arch.h" + void board_power_register(void); void board_power_adjust(void); void board_power_status(void); -void board_power_setbootvoltage(void) + + +void board_power_init(void) { stm32_configgpio(GPIO_PVS); + stm32_configgpio(GPIO_PST); + stm32_configgpio(GPIO_XPWR); + stm32_configgpio(GPIO_SCTC); + stm32_configgpio(GPIO_PCLR); +} + + +void board_power_reboot(void) +{ + // low-level board reset (not just MCU reset) + // if external power is present, stimulate power-off as board + // will wake-up immediatelly, if power is not present, set an alarm + // before power off the board. } -void board_power_reboot(void); -void board_power_off(void); + +void board_power_off(void) +{ + // Check if external supply is not present, otherwise return + // notifying that it is not possible to power-off the board + + // \todo + + // stop backgorund processes + irqsave(); + + // switch to internal HSI and get the PD0 and PD1 as GPIO + stm32_board_select_hsi(); + + // trigger shutdown with pull-up resistor (not push-pull!) and wait. + stm32_gpiowrite(GPIO_PCLR, true); + for(;;); +} |