Chameleon-Mini
Battery.h
1 /*
2  * Battery.h
3  *
4  * Created on: 20.08.2014
5  * Author: sk
6  */
7 
8 #ifndef BATTERY_H_
9 #define BATTERY_H_
10 
11 #include "Common.h"
12 
13 #define BATTERY_PORT PORTD
14 #define BATTERY_STAT_PIN PIN0_bm
15 #define BATTERY_STAT_PINCTRL PIN0CTRL
16 #define BATTERY_PORT_MASK (BATTERY_STAT_PIN)
17 
18 INLINE void BatteryInit(void) {
19  BATTERY_PORT.DIRCLR = BATTERY_PORT_MASK;
20  BATTERY_PORT.BATTERY_STAT_PINCTRL = PORT_OPC_PULLUP_gc;
21 }
22 
23 INLINE bool BatteryIsCharging(void) {
24  if (!(BATTERY_PORT.IN & BATTERY_STAT_PIN)) {
25  return true;
26  } else {
27  return false;
28  }
29 }
30 
31 #endif /* BATTERY_H_ */