-
Notifications
You must be signed in to change notification settings - Fork 115
/
Power.cpp
29 lines (24 loc) · 866 Bytes
/
Power.cpp
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
#include <Arduino.h>
#include "settings.h"
#include "Power.h"
#include "Port.h"
void Power_Init(void) {
#if (POWER >= 0 && POWER <= MAX_GPIO)
pinMode(POWER, OUTPUT); // Only necessary for GPIO. For port-expander it's done (previously) via Port_init()
#endif
}
// Switch on peripherals. Please note: meaning of POWER_ON is HIGH per default. But is LOW in case of INVERT_POWER is enabled.
void Power_PeripheralOn(void) {
Port_Write(POWER, POWER_ON, false);
#ifdef BUTTONS_LED
Port_Write(BUTTONS_LED, HIGH, false);
#endif
delay(50); // Give peripherals some time to settle down
}
// Switch off peripherals. Please note: meaning of POWER_OFF is LOW per default. But is HIGH in case of INVERT_POWER is enabled.
void Power_PeripheralOff(void) {
Port_Write(POWER, POWER_OFF, false);
#ifdef BUTTONS_LED
Port_Write(BUTTONS_LED, LOW, false);
#endif
}