Add VoltageCheck to shutdown on low power

This commit is contained in:
Stefan `Sec` Zehl 2011-06-13 23:17:09 +02:00
parent 94003362a4
commit 2dfe80221a
3 changed files with 24 additions and 1 deletions

View File

@ -7,7 +7,7 @@ OBJS = main.o
VPATH += VPATH +=
OBJS += OBJS +=
OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o basic/voltage.o
OBJS += eeprom/eeprom.o OBJS += eeprom/eeprom.o
LIBS += core/libcore.a lcd/liblcd.a modules/libmodules.a LIBS += core/libcore.a lcd/liblcd.a modules/libmodules.a

View File

@ -126,4 +126,7 @@ void EnterISP(void);
// delayms.c // delayms.c
void delayms(uint32_t ms); void delayms(uint32_t ms);
// voltage.c
void VoltageCheck(void);
#endif #endif

20
basic/voltage.c Normal file
View File

@ -0,0 +1,20 @@
#include <sysinit.h>
#include "basic/basic.h"
void VoltageCheck(void){
uint32_t results;
results = adcRead(1);
results *= 10560;
results /= 1024;
if( results < 3500 ){
gpioSetValue (RB_PWR_GOOD, 0);
gpioSetValue (RB_LCD_BL, 0);
SCB_SCR |= SCB_SCR_SLEEPDEEP;
PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN;
__asm volatile ("WFI");
};
};