Add VoltageCheck to shutdown on low power
This commit is contained in:
parent
94003362a4
commit
2dfe80221a
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ OBJS = main.o
|
|||
|
||||
VPATH +=
|
||||
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
|
||||
LIBS += core/libcore.a lcd/liblcd.a modules/libmodules.a
|
||||
|
||||
|
|
|
@ -126,4 +126,7 @@ void EnterISP(void);
|
|||
// delayms.c
|
||||
void delayms(uint32_t ms);
|
||||
|
||||
// voltage.c
|
||||
void VoltageCheck(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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");
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue