Add low-voltage warning blink

This commit is contained in:
Stefan `Sec` Zehl 2011-06-13 23:39:21 +02:00
parent 93a5e2696b
commit 2b73b15157
3 changed files with 17 additions and 1 deletions

View File

@ -128,5 +128,6 @@ void delayms(uint32_t ms);
// voltage.c // voltage.c
void VoltageCheck(void); void VoltageCheck(void);
uint32_t GetVoltage(void);
#endif #endif

View File

@ -2,9 +2,9 @@
#include "basic/basic.h" #include "basic/basic.h"
uint32_t results=5000;
void VoltageCheck(void){ void VoltageCheck(void){
uint32_t results;
results = adcRead(1); results = adcRead(1);
results *= 10560; results *= 10560;
@ -18,3 +18,7 @@ void VoltageCheck(void){
__asm volatile ("WFI"); __asm volatile ("WFI");
}; };
}; };
uint32_t GetVoltage(void){
return results;
};

View File

@ -1,4 +1,5 @@
#include <sysinit.h> #include <sysinit.h>
#include "basic/basic.h"
/**************************************************************************/ /**************************************************************************/
@ -15,6 +16,16 @@ void tick_default(void) {
VoltageCheck(); VoltageCheck();
ctr=0; ctr=0;
}; };
if(ctr%5==0){
if(GetVoltage()<3600){
IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output);
if( (ctr/5)%10 == 1 )
gpioSetValue (RB_LED3, 1);
else
gpioSetValue (RB_LED3, 0);
};
};
return; return;
}; };