-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpower.c
63 lines (37 loc) · 951 Bytes
/
power.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*************************************************
* Firmware for SKVA-03 IVM
* Shendrik Andrey
* 2016 (c)
*
*************************************************/
/* ----------------------- Platform includes ----------------------------------*/
#include "avr/io.h"
/* -------------------------- Own includes ------------------------------------*/
#include "power.h"
static UCHAR ucIsSleep = FALSE; /* if MCU is in sleep mode */
void vPowerControl_Init()
{
/* Enable On battery power supply pin */
ON_BAT_INIT();
}
UCHAR ucOnBattery()
{
return (ON_BAT_PINPORT & _BV(ON_BAT_PIN))>>ON_BAT_PIN;
}
UCHAR ucIsSleeping()
{
return ucIsSleep;
}
void vGoSleep()
{
ucIsSleep=TRUE;
/* going to power save mode */
SMCR=(1<<SM1)|(1<<SM0)|(1<<SE);
#asm("sleep")
}
void vWakingUp()
{
ucIsSleep=FALSE;
SMCR&=~(1<<SE);
}