crashtest-r0ket/firmware/applications/default.c

80 lines
1.6 KiB
C
Raw Normal View History

#include <sysinit.h>
2011-06-13 21:39:21 +00:00
#include "basic/basic.h"
2011-07-31 23:34:11 +00:00
#include "basic/config.h"
#include "lcd/lcd.h"
#include "lcd/fonts/smallfonts.h"
#include "lcd/print.h"
#include "filesystem/ff.h"
2011-07-31 20:13:06 +00:00
#include "usb/usbmsc.h"
#include "basic/random.h"
/**************************************************************************/
void main_default(void) {
2011-07-26 22:25:24 +00:00
systickInit(SYSTICKSPEED);
2011-07-31 20:13:06 +00:00
switch(getInputRaw()){
case BTN_ENTER:
ISPandReset();
break;
case BTN_DOWN:
usbMSCInit();
while(1)
delayms_power(100);
break;
};
readConfig();
2011-07-24 14:03:19 +00:00
randomInit();
return;
};
// every 10 ms
void tick_default(void) {
static int ctr;
ctr++;
incTimer();
2011-07-26 22:25:24 +00:00
if(ctr>1000/SYSTICKSPEED){
2011-07-25 21:26:18 +00:00
if(!adcMutex){
VoltageCheck();
LightCheck();
2011-07-25 21:41:26 +00:00
ctr=0;
}else{
ctr--;
2011-07-25 21:26:18 +00:00
};
};
if(ctr>100/SYSTICKSPEED){
if(isNight()){
backlightSetBrightness(GLOBAL(lcdbacklight));
2011-07-31 20:13:06 +00:00
lcdSetInvert(0);
} else {
backlightSetBrightness(0);
2011-07-31 20:13:06 +00:00
if(GLOBAL(dayinvert))
lcdSetInvert(1);
2011-07-31 20:13:06 +00:00
else
lcdSetInvert(0);
}
}
2011-07-26 22:25:24 +00:00
if(ctr%(50/SYSTICKSPEED)==0){
if(GetVoltage()<3600
#ifdef SAFE
|| GetVoltage() > 10000 // pin not connected
#endif
){
2011-06-13 21:39:21 +00:00
IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output);
2011-07-26 22:25:24 +00:00
if( (ctr/(50/SYSTICKSPEED))%10 == 1 )
2011-06-13 21:39:21 +00:00
gpioSetValue (RB_LED3, 1);
else
gpioSetValue (RB_LED3, 0);
};
};
return;
};