AskSin++
Globals.cpp
1 
2 #include <AskSinPP.h>
3 #include <BatterySensor.h>
4 
5 namespace as {
6 
7 void* __gb_store;
8 void* __gb_radio;
9 
10 const char* __gb_chartable = "0123456789ABCDEF";
11 
12 void(* resetFunc) (void) = 0;
13 
14 #if defined(ARDUINO_ARCH_AVR) && ! defined(__AVR_ATmega644A__)
15 volatile uint16_t intVCC=0;
16 
17 volatile uint16_t IrqBaseBatt::__gb_BatCurrent = 0;
18 volatile uint8_t IrqBaseBatt::__gb_BatCount = 0;
19 uint16_t (*IrqBaseBatt::__gb_BatIrq)() = 0;
20 
21 void IrqBaseBatt::__vectorfunc() {
22  if( __gb_BatIrq != 0 ) {
23  __gb_BatCount++;
24  if( __gb_BatCount > 10 ) { // ignore first 10 values
25  uint16_t v = __gb_BatIrq();
26  if( __gb_BatCurrent == 0 ) {
27  __gb_BatCurrent = v;
28  }
29  else {
30  if( v < __gb_BatCurrent ) {
31  __gb_BatCurrent = v;
32  }
33  }
34  }
35 
36  if( __gb_BatIrq != 0 )
37  ADCSRA |= (1 << ADSC); // start conversion again
38  }
39 }
40 #endif
41 
42 }