2011-06-13 21:17:09 +00:00
|
|
|
#include <sysinit.h>
|
|
|
|
|
|
|
|
#include "basic/basic.h"
|
2011-08-02 19:01:48 +00:00
|
|
|
#include "funk/nrf24l01p.h"
|
2011-06-13 21:17:09 +00:00
|
|
|
|
2011-08-04 23:22:34 +00:00
|
|
|
static uint32_t results=5000;
|
|
|
|
static uint8_t chrg=1;
|
2011-06-13 21:17:09 +00:00
|
|
|
|
|
|
|
void VoltageCheck(void){
|
|
|
|
|
2011-08-04 23:22:34 +00:00
|
|
|
chrg=gpioGetValue(RB_PWR_CHRG);
|
|
|
|
|
2011-06-13 21:17:09 +00:00
|
|
|
results = adcRead(1);
|
|
|
|
results *= 10560;
|
|
|
|
results /= 1024;
|
2011-08-05 18:15:59 +00:00
|
|
|
results += 50;
|
2011-06-13 21:17:09 +00:00
|
|
|
if( results < 3500 ){
|
2011-08-01 03:31:47 +00:00
|
|
|
nrf_off();
|
2011-06-13 21:17:09 +00:00
|
|
|
gpioSetValue (RB_PWR_GOOD, 0);
|
|
|
|
gpioSetValue (RB_LCD_BL, 0);
|
|
|
|
SCB_SCR |= SCB_SCR_SLEEPDEEP;
|
|
|
|
PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN;
|
|
|
|
__asm volatile ("WFI");
|
|
|
|
};
|
|
|
|
};
|
2011-06-13 21:39:21 +00:00
|
|
|
|
|
|
|
uint32_t GetVoltage(void){
|
|
|
|
return results;
|
|
|
|
};
|
2011-08-04 23:22:34 +00:00
|
|
|
|
|
|
|
uint8_t GetChrgStat(void){
|
|
|
|
return !chrg;
|
|
|
|
};
|